Make messages in makeSignBytes a list
this fixes a bug introduced in 2d14efa4cd
This commit is contained in:
parent
555534ba1b
commit
63e3ab037c
@ -38,7 +38,7 @@ export class CosmWasmCodec implements TxCodec {
|
||||
sequence: nonceToSequence(nonce),
|
||||
};
|
||||
const signBytes = makeSignBytes(
|
||||
built.value.msg[0],
|
||||
built.value.msg,
|
||||
built.value.fee,
|
||||
Caip5.decode(unsigned.chainId),
|
||||
built.value.memo || "",
|
||||
|
||||
@ -28,23 +28,33 @@ export function marshalTx(tx: StdTx): Uint8Array {
|
||||
return Encoding.toUtf8(json);
|
||||
}
|
||||
|
||||
interface SignJson {
|
||||
readonly account_number: string;
|
||||
readonly chain_id: string;
|
||||
readonly fee: StdFee;
|
||||
readonly memo: string;
|
||||
readonly msgs: readonly Msg[];
|
||||
readonly sequence: string;
|
||||
}
|
||||
|
||||
export function makeSignBytes(
|
||||
msg: Msg,
|
||||
msgs: readonly Msg[],
|
||||
fee: StdFee,
|
||||
chainId: string,
|
||||
memo: string,
|
||||
account: NonceInfo,
|
||||
): Uint8Array {
|
||||
const signMsg = sortJson({
|
||||
const signJson: SignJson = {
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
account_number: account.account_number.toString(),
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
chain_id: chainId,
|
||||
fee: fee,
|
||||
memo: memo,
|
||||
msgs: msg,
|
||||
msgs: msgs,
|
||||
sequence: account.sequence.toString(),
|
||||
});
|
||||
};
|
||||
const signMsg = sortJson(signJson);
|
||||
return toUtf8(JSON.stringify(signMsg));
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ describe("RestClient", () => {
|
||||
|
||||
const client = new RestClient(httpUrl);
|
||||
const account = (await client.authAccounts(faucetAddress)).result.value;
|
||||
const signBytes = makeSignBytes(theMsg, fee, defaultNetworkId, memo, account) as SignableBytes;
|
||||
const signBytes = makeSignBytes([theMsg], fee, defaultNetworkId, memo, account) as SignableBytes;
|
||||
const rawSignature = await wallet.createTransactionSignature(signer, signBytes, PrehashType.Sha256);
|
||||
const signature = encodeSecp256k1Signature(signer.pubkey.data, rawSignature);
|
||||
|
||||
|
||||
2
packages/sdk/types/encoding.d.ts
vendored
2
packages/sdk/types/encoding.d.ts
vendored
@ -2,7 +2,7 @@ import { Msg, NonceInfo, StdFee, StdSignature, StdTx } from "./types";
|
||||
export declare function sortJson(json: any): any;
|
||||
export declare function marshalTx(tx: StdTx): Uint8Array;
|
||||
export declare function makeSignBytes(
|
||||
msg: Msg,
|
||||
msgs: readonly Msg[],
|
||||
fee: StdFee,
|
||||
chainId: string,
|
||||
memo: string,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user