From 2f2ae9b55f524e0d9222c18525cf7933e407bbac Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 3 Aug 2022 18:47:47 +0200 Subject: [PATCH] Use txBytes in simulation --- packages/stargate/src/modules/tx/queries.ts | 38 ++++++++++----------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/stargate/src/modules/tx/queries.ts b/packages/stargate/src/modules/tx/queries.ts index 4e6177a6..186cc3ab 100644 --- a/packages/stargate/src/modules/tx/queries.ts +++ b/packages/stargate/src/modules/tx/queries.ts @@ -50,27 +50,25 @@ export function setupTxExtension(base: QueryClient): TxExtension { signer: Pubkey, sequence: number, ) => { - const request = SimulateRequest.fromPartial({ - tx: Tx.fromPartial({ - authInfo: AuthInfo.fromPartial({ - fee: Fee.fromPartial({}), - signerInfos: [ - { - publicKey: encodePubkey(signer), - sequence: Long.fromNumber(sequence, true), - modeInfo: { single: { mode: SignMode.SIGN_MODE_UNSPECIFIED } }, - }, - ], - }), - body: TxBody.fromPartial({ - messages: Array.from(messages), - memo: memo, - }), - signatures: [new Uint8Array()], + const tx = Tx.fromPartial({ + authInfo: AuthInfo.fromPartial({ + fee: Fee.fromPartial({}), + signerInfos: [ + { + publicKey: encodePubkey(signer), + sequence: Long.fromNumber(sequence, true), + modeInfo: { single: { mode: SignMode.SIGN_MODE_UNSPECIFIED } }, + }, + ], }), - // Sending serialized `txBytes` is the future. But - // this is not available in Comsos SDK 0.42. - txBytes: undefined, + body: TxBody.fromPartial({ + messages: Array.from(messages), + memo: memo, + }), + signatures: [new Uint8Array()], + }); + const request = SimulateRequest.fromPartial({ + txBytes: Tx.encode(tx).finish(), }); const response = await queryService.Simulate(request); return response;