This commit is contained in:
arnabghose997 2022-06-02 15:33:09 +05:30 committed by Simon Warta
parent 45ee5fe15a
commit 4e7490ee5f
6 changed files with 27 additions and 11 deletions

View File

@ -203,7 +203,7 @@ describe("CosmWasmClient", () => {
}; };
const txBodyBytes = registry.encode(txBody); const txBodyBytes = registry.encode(txBody);
const gasLimit = Int53.fromString(fee.gas).toNumber(); const gasLimit = Int53.fromString(fee.gas).toNumber();
const feePayer = "" const feePayer = "";
const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, feePayer); const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, feePayer);
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
const { signed, signature } = await wallet.signDirect(alice.address0, signDoc); const { signed, signature } = await wallet.signDirect(alice.address0, signDoc);

View File

@ -582,7 +582,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
const signedTxBodyBytes = this.registry.encode(signedTxBody); const signedTxBodyBytes = this.registry.encode(signedTxBody);
const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber(); const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber();
const signedSequence = Int53.fromString(signed.sequence).toNumber(); const signedSequence = Int53.fromString(signed.sequence).toNumber();
const signedFeePayer = "" const signedFeePayer = "";
const signedAuthInfoBytes = makeAuthInfoBytes( const signedAuthInfoBytes = makeAuthInfoBytes(
[{ pubkey, sequence: signedSequence }], [{ pubkey, sequence: signedSequence }],
signed.fee.amount, signed.fee.amount,
@ -621,7 +621,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
}; };
const txBodyBytes = this.registry.encode(txBody); const txBodyBytes = this.registry.encode(txBody);
const gasLimit = Int53.fromString(fee.gas).toNumber(); const gasLimit = Int53.fromString(fee.gas).toNumber();
const feePayer = fee.granter == undefined ? "" : fee.granter const feePayer = fee.granter == undefined ? "" : fee.granter;
const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, feePayer); const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, feePayer);
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc); const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc);

View File

@ -261,7 +261,7 @@ describe("DirectSecp256k1HdWallet", () => {
}; };
const fee = coins(2000, "ucosm"); const fee = coins(2000, "ucosm");
const gasLimit = 200000; const gasLimit = 200000;
const feePayer = "" const feePayer = "";
const chainId = "simd-testing"; const chainId = "simd-testing";
const signDoc = makeSignDoc( const signDoc = makeSignDoc(
fromHex(bodyBytes), fromHex(bodyBytes),

View File

@ -42,8 +42,8 @@ export function makeAuthInfoBytes(
fee: { fee: {
amount: [...feeAmount], amount: [...feeAmount],
gasLimit: Long.fromNumber(gasLimit), gasLimit: Long.fromNumber(gasLimit),
granter: feePayer granter: feePayer,
} },
}; };
return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish(); return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish();
} }

View File

@ -362,7 +362,7 @@ export class SigningStargateClient extends StargateClient {
const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject); const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber(); const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber();
const signedSequence = Int53.fromString(signed.sequence).toNumber(); const signedSequence = Int53.fromString(signed.sequence).toNumber();
const signedFeePayer = signed.fee.granter == undefined ? "" : signed.fee.granter const signedFeePayer = signed.fee.granter == undefined ? "" : signed.fee.granter;
const signedAuthInfoBytes = makeAuthInfoBytes( const signedAuthInfoBytes = makeAuthInfoBytes(
[{ pubkey, sequence: signedSequence }], [{ pubkey, sequence: signedSequence }],
signed.fee.amount, signed.fee.amount,
@ -401,7 +401,7 @@ export class SigningStargateClient extends StargateClient {
}; };
const txBodyBytes = this.registry.encode(txBodyEncodeObject); const txBodyBytes = this.registry.encode(txBodyEncodeObject);
const gasLimit = Int53.fromString(fee.gas).toNumber(); const gasLimit = Int53.fromString(fee.gas).toNumber();
const feePayer = fee.granter == undefined ? "" : fee.granter const feePayer = fee.granter == undefined ? "" : fee.granter;
const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, feePayer); const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, feePayer);
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc); const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc);

View File

@ -423,7 +423,13 @@ describe("StargateClient", () => {
const feeAmount = coins(2000, "ucosm"); const feeAmount = coins(2000, "ucosm");
const gasLimit = 200000; const gasLimit = 200000;
const feePayer = ""; const feePayer = "";
const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence }], feeAmount, gasLimit, feePayer, sequence); const authInfoBytes = makeAuthInfoBytes(
[{ pubkey, sequence }],
feeAmount,
gasLimit,
feePayer,
sequence,
);
const chainId = await client.getChainId(); const chainId = await client.getChainId();
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
@ -487,7 +493,12 @@ describe("StargateClient", () => {
const feePayer = ""; const feePayer = "";
const { accountNumber: accountNumber1, sequence: sequence1 } = (await client.getSequence(address))!; const { accountNumber: accountNumber1, sequence: sequence1 } = (await client.getSequence(address))!;
const authInfoBytes1 = makeAuthInfoBytes([{ pubkey, sequence: sequence1 }], feeAmount, gasLimit, feePayer); const authInfoBytes1 = makeAuthInfoBytes(
[{ pubkey, sequence: sequence1 }],
feeAmount,
gasLimit,
feePayer,
);
const signDoc1 = makeSignDoc(txBodyBytes, authInfoBytes1, chainId, accountNumber1); const signDoc1 = makeSignDoc(txBodyBytes, authInfoBytes1, chainId, accountNumber1);
const { signature: signature1 } = await wallet.signDirect(address, signDoc1); const { signature: signature1 } = await wallet.signDirect(address, signDoc1);
const txRaw1 = TxRaw.fromPartial({ const txRaw1 = TxRaw.fromPartial({
@ -501,7 +512,12 @@ describe("StargateClient", () => {
assertIsDeliverTxSuccess(txResult); assertIsDeliverTxSuccess(txResult);
const { accountNumber: accountNumber2, sequence: sequence2 } = (await client.getSequence(address))!; const { accountNumber: accountNumber2, sequence: sequence2 } = (await client.getSequence(address))!;
const authInfoBytes2 = makeAuthInfoBytes([{ pubkey, sequence: sequence2 }], feeAmount, gasLimit, feePayer); const authInfoBytes2 = makeAuthInfoBytes(
[{ pubkey, sequence: sequence2 }],
feeAmount,
gasLimit,
feePayer,
);
const signDoc2 = makeSignDoc(txBodyBytes, authInfoBytes2, chainId, accountNumber2); const signDoc2 = makeSignDoc(txBodyBytes, authInfoBytes2, chainId, accountNumber2);
const { signature: signature2 } = await wallet.signDirect(address, signDoc2); const { signature: signature2 } = await wallet.signDirect(address, signDoc2);
const txRaw2 = TxRaw.fromPartial({ const txRaw2 = TxRaw.fromPartial({