Finalize feegrant code

This commit is contained in:
Simon Warta 2022-09-07 17:50:57 +02:00
parent c959343cac
commit cc2e36995a
6 changed files with 18 additions and 6 deletions

View File

@ -71,6 +71,8 @@ and this project adheres to
- @cosmjs/stargate: `BankExtension.totalSupply` now takes a pagination key
argument and returns the full `QueryTotalSupplyResponse` including the next
pagination key ([#1095]).
- @cosmjs/proto-signing: `makeAuthInfoBytes` now expects a fee granter and fee
payer argument in position 4 and 5.
[#1131]: https://github.com/cosmos/cosmjs/pull/1131
[#1168]: https://github.com/cosmos/cosmjs/pull/1168

View File

@ -12,7 +12,9 @@ export interface AminoMsg {
export interface StdFee {
readonly amount: readonly Coin[];
readonly gas: string;
/** The granter address that is used for paying with feegrants */
readonly granter?: string;
/** The fee payer address. The payer must have signed the transaction. */
readonly payer?: string;
}

View File

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

View File

@ -44,8 +44,8 @@ describe("DirectSecp256k1Wallet", () => {
const fee = coins(2000, "ucosm");
const gasLimit = 200000;
const chainId = "simd-testing";
const feePayer = "";
const feeGranter = "";
const feePayer = undefined;
const feeGranter = undefined;
const signDoc = makeSignDoc(
fromHex(bodyBytes),
makeAuthInfoBytes([{ pubkey, sequence }], fee, gasLimit, feeGranter, feePayer),

View File

@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { assert } from "@cosmjs/utils";
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
import { AuthInfo, SignDoc, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx";
@ -38,6 +39,13 @@ export function makeAuthInfoBytes(
feePayer: string | undefined,
signMode = SignMode.SIGN_MODE_DIRECT,
): Uint8Array {
// Required arguments 4 and 5 were added in CosmJS 0.29. Use runtime checks to help our non-TS users.
assert(
feeGranter === undefined || typeof feeGranter === "string",
"feeGranter must be undefined or string",
);
assert(feePayer === undefined || typeof feePayer === "string", "feePayer must be undefined or string");
const authInfo = {
signerInfos: makeSignerInfos(signers, signMode),
fee: {

View File

@ -499,8 +499,8 @@ describe("StargateClient", () => {
const chainId = await client.getChainId();
const feeAmount = coins(2000, "ucosm");
const gasLimit = 200000;
const feeGranter = "";
const feePayer = "";
const feeGranter = undefined;
const feePayer = undefined;
const { accountNumber: accountNumber1, sequence: sequence1 } = (await client.getSequence(address))!;
const authInfoBytes1 = makeAuthInfoBytes(