launchpad: Refactor FeeTable type
This commit is contained in:
parent
f30004db73
commit
914f8d94bb
@ -3,6 +3,8 @@ import { Decimal } from "@cosmjs/math";
|
||||
import { coins } from "./coins";
|
||||
import { StdFee } from "./types";
|
||||
|
||||
export type FeeTable = Record<string, StdFee>;
|
||||
|
||||
export class GasPrice {
|
||||
public readonly amount: Decimal;
|
||||
public readonly denom: string;
|
||||
|
||||
@ -29,7 +29,7 @@ export {
|
||||
isSearchByTagsQuery,
|
||||
} from "./cosmosclient";
|
||||
export { makeSignBytes } from "./encoding";
|
||||
export { buildFeeTable, GasPrice } from "./gas";
|
||||
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||
export {
|
||||
AuthAccountsResponse,
|
||||
AuthExtension,
|
||||
@ -98,7 +98,7 @@ export {
|
||||
} from "./pubkey";
|
||||
export { findSequenceForSignedTx } from "./sequence";
|
||||
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
|
||||
export { FeeTable, SigningCosmosClient } from "./signingcosmosclient";
|
||||
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
|
||||
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
|
||||
export {
|
||||
AccountData,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { Coin } from "./coins";
|
||||
import { Account, BroadcastTxResult, CosmosClient, GetSequenceResult } from "./cosmosclient";
|
||||
import { makeSignBytes } from "./encoding";
|
||||
import { buildFeeTable, GasLimits, GasPrice } from "./gas";
|
||||
import { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||
import { BroadcastMode } from "./lcdapi";
|
||||
import { Msg, MsgSend } from "./msgs";
|
||||
import { StdFee, StdTx } from "./types";
|
||||
@ -11,23 +11,23 @@ import { OfflineSigner } from "./wallet";
|
||||
/**
|
||||
* These fees are used by the higher level methods of SigningCosmosClient
|
||||
*/
|
||||
export interface FeeTable extends Record<string, StdFee> {
|
||||
export interface CosmosFeeTable extends FeeTable {
|
||||
readonly send: StdFee;
|
||||
}
|
||||
|
||||
const defaultGasPrice = GasPrice.fromString("0.025ucosm");
|
||||
const defaultGasLimits: GasLimits<FeeTable> = { send: 80000 };
|
||||
const defaultGasLimits: GasLimits<CosmosFeeTable> = { send: 80000 };
|
||||
|
||||
/** Use for testing only */
|
||||
export interface PrivateSigningCosmosClient {
|
||||
readonly fees: FeeTable;
|
||||
readonly fees: CosmosFeeTable;
|
||||
}
|
||||
|
||||
export class SigningCosmosClient extends CosmosClient {
|
||||
public readonly senderAddress: string;
|
||||
|
||||
private readonly signer: OfflineSigner;
|
||||
private readonly fees: FeeTable;
|
||||
private readonly fees: CosmosFeeTable;
|
||||
|
||||
/**
|
||||
* Creates a new client with signing capability to interact with a Cosmos SDK blockchain. This is the bigger brother of CosmosClient.
|
||||
@ -47,14 +47,14 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
senderAddress: string,
|
||||
signer: OfflineSigner,
|
||||
gasPrice: GasPrice = defaultGasPrice,
|
||||
gasLimits: Partial<GasLimits<FeeTable>> = {},
|
||||
gasLimits: Partial<GasLimits<CosmosFeeTable>> = {},
|
||||
broadcastMode = BroadcastMode.Block,
|
||||
) {
|
||||
super(apiUrl, broadcastMode);
|
||||
this.anyValidAddress = senderAddress;
|
||||
this.senderAddress = senderAddress;
|
||||
this.signer = signer;
|
||||
this.fees = buildFeeTable<FeeTable>(gasPrice, defaultGasLimits, gasLimits);
|
||||
this.fees = buildFeeTable<CosmosFeeTable>(gasPrice, defaultGasLimits, gasLimits);
|
||||
}
|
||||
|
||||
public async getSequence(address?: string): Promise<GetSequenceResult> {
|
||||
|
||||
1
packages/launchpad/types/gas.d.ts
vendored
1
packages/launchpad/types/gas.d.ts
vendored
@ -1,5 +1,6 @@
|
||||
import { Decimal } from "@cosmjs/math";
|
||||
import { StdFee } from "./types";
|
||||
export declare type FeeTable = Record<string, StdFee>;
|
||||
export declare class GasPrice {
|
||||
readonly amount: Decimal;
|
||||
readonly denom: string;
|
||||
|
||||
4
packages/launchpad/types/index.d.ts
vendored
4
packages/launchpad/types/index.d.ts
vendored
@ -27,7 +27,7 @@ export {
|
||||
isSearchByTagsQuery,
|
||||
} from "./cosmosclient";
|
||||
export { makeSignBytes } from "./encoding";
|
||||
export { buildFeeTable, GasPrice } from "./gas";
|
||||
export { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
|
||||
export {
|
||||
AuthAccountsResponse,
|
||||
AuthExtension,
|
||||
@ -96,7 +96,7 @@ export {
|
||||
} from "./pubkey";
|
||||
export { findSequenceForSignedTx } from "./sequence";
|
||||
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
|
||||
export { FeeTable, SigningCosmosClient } from "./signingcosmosclient";
|
||||
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
|
||||
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
|
||||
export {
|
||||
AccountData,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Coin } from "./coins";
|
||||
import { Account, BroadcastTxResult, CosmosClient, GetSequenceResult } from "./cosmosclient";
|
||||
import { GasLimits, GasPrice } from "./gas";
|
||||
import { FeeTable, GasLimits, GasPrice } from "./gas";
|
||||
import { BroadcastMode } from "./lcdapi";
|
||||
import { Msg } from "./msgs";
|
||||
import { StdFee } from "./types";
|
||||
@ -8,12 +8,12 @@ import { OfflineSigner } from "./wallet";
|
||||
/**
|
||||
* These fees are used by the higher level methods of SigningCosmosClient
|
||||
*/
|
||||
export interface FeeTable extends Record<string, StdFee> {
|
||||
export interface CosmosFeeTable extends FeeTable {
|
||||
readonly send: StdFee;
|
||||
}
|
||||
/** Use for testing only */
|
||||
export interface PrivateSigningCosmosClient {
|
||||
readonly fees: FeeTable;
|
||||
readonly fees: CosmosFeeTable;
|
||||
}
|
||||
export declare class SigningCosmosClient extends CosmosClient {
|
||||
readonly senderAddress: string;
|
||||
@ -37,7 +37,7 @@ export declare class SigningCosmosClient extends CosmosClient {
|
||||
senderAddress: string,
|
||||
signer: OfflineSigner,
|
||||
gasPrice?: GasPrice,
|
||||
gasLimits?: Partial<GasLimits<FeeTable>>,
|
||||
gasLimits?: Partial<GasLimits<CosmosFeeTable>>,
|
||||
broadcastMode?: BroadcastMode,
|
||||
);
|
||||
getSequence(address?: string): Promise<GetSequenceResult>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user