Skip to content

Commit

Permalink
fix(wallet): revert to returning complete tx data instead of just has…
Browse files Browse the repository at this point in the history
…h in rpc wallet signing

aepps using sdk v11.0.1 and below expects whole tx object.
  • Loading branch information
subhod-i authored and davidyuk committed Jun 17, 2022
1 parent a7ef9f1 commit c3ada74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/AeSdkWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
WalletInfo
} from './utils/aepp-wallet-communication/rpc/types'
import { EncodedData } from './utils/encoder'
import jsonBig from './utils/json-big'

type RpcClientWallet = RpcClient<AeppApi, WalletApi>

Expand Down Expand Up @@ -264,7 +265,9 @@ export default class AeSdkWallet extends AeSdk {
return { signedTransaction: await this.signTransaction(tx, { onAccount }) }
}
try {
return { transactionHash: (await this.send(tx, { onAccount, verify: false })).hash }
return jsonBig.parse(jsonBig.stringify({
transactionHash: await this.send(tx, { onAccount, verify: false })
}))
} catch (error) {
const validation = await verifyTransaction(tx, this.api)
if (validation.length > 0) throw new RpcInvalidTransactionError(validation)
Expand Down
10 changes: 9 additions & 1 deletion src/utils/aepp-wallet-communication/rpc/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { send } from '../../../ae/spend'
import { EncodedData } from '../../encoder'
import { METHODS, SUBSCRIPTION_TYPES, WALLET_TYPE } from '../schema'

Expand Down Expand Up @@ -43,7 +44,14 @@ export interface WalletApi {

[METHODS.sign]: ((
p: { tx: EncodedData<'tx'>, onAccount: EncodedData<'ak'>, returnSigned: boolean }
) => Promise<{ transactionHash?: EncodedData<'th'>, signedTransaction?: EncodedData<'tx'> }>)
) => Promise<{
/**
* @deprecated this is not a hash at all, will be removed later at the same time
* as dropping ability to broadcast transaction by wallet
*/
transactionHash?: Awaited<ReturnType<typeof send>>
signedTransaction?: EncodedData<'tx'>
}>)

[METHODS.signMessage]: (
p: { message: string, onAccount: EncodedData<'ak'> }
Expand Down

0 comments on commit c3ada74

Please sign in to comment.