From 0010c1bc77911f545dd204d9ecf382a23ee72323 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 17 Feb 2020 13:00:38 +0100 Subject: [PATCH] Remove fees argument from makeReadOnly --- packages/sdk/src/cosmwasmclient.ts | 22 +++++++++++----------- packages/sdk/types/cosmwasmclient.d.ts | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/sdk/src/cosmwasmclient.ts b/packages/sdk/src/cosmwasmclient.ts index 1a31b4bf..0ce088dc 100644 --- a/packages/sdk/src/cosmwasmclient.ts +++ b/packages/sdk/src/cosmwasmclient.ts @@ -27,7 +27,7 @@ function singleAmount(amount: number, denom: string): readonly Coin[] { return [{ amount: amount.toString(), denom: denom }]; } -const defaultFeeTable: FeeTable = { +const defaultFees: FeeTable = { upload: { amount: singleAmount(25000, "ucosm"), gas: "1000000", // one million @@ -98,8 +98,8 @@ export interface ExecuteResult { } export class CosmWasmClient { - public static makeReadOnly(url: string, feeTable?: Partial): CosmWasmClient { - return new CosmWasmClient(url, undefined, feeTable); + public static makeReadOnly(url: string): CosmWasmClient { + return new CosmWasmClient(url, undefined, {}); } public static makeWritable( @@ -114,13 +114,13 @@ export class CosmWasmClient { senderAddress: senderAddress, signCallback: signCallback, }, - feeTable, + feeTable || {}, ); } private readonly restClient: RestClient; private readonly signingData: SigningData | undefined; - private readonly feeTable: FeeTable; + private readonly fees: FeeTable; private get senderAddress(): string { if (!this.signingData) throw new Error("Signing data not set in this client"); @@ -132,10 +132,10 @@ export class CosmWasmClient { return this.signingData.signCallback; } - private constructor(url: string, signingData?: SigningData, feeTable?: Partial) { + private constructor(url: string, signingData: SigningData | undefined, customFees: Partial) { this.restClient = new RestClient(url); this.signingData = signingData; - this.feeTable = { ...defaultFeeTable, ...(feeTable || {}) }; + this.fees = { ...defaultFees, ...customFees }; } public async chainId(): Promise { @@ -242,7 +242,7 @@ export class CosmWasmClient { builder: "", }, }; - const fee = this.feeTable.upload; + const fee = this.fees.upload; const { accountNumber, sequence } = await this.getNonce(); const chainId = await this.chainId(); const signBytes = makeSignBytes([storeCodeMsg], fee, chainId, memo, accountNumber, sequence); @@ -278,7 +278,7 @@ export class CosmWasmClient { init_funds: transferAmount || [], }, }; - const fee = this.feeTable.init; + const fee = this.fees.init; const { accountNumber, sequence } = await this.getNonce(); const chainId = await this.chainId(); const signBytes = makeSignBytes([instantiateMsg], fee, chainId, memo, accountNumber, sequence); @@ -312,7 +312,7 @@ export class CosmWasmClient { sent_funds: transferAmount || [], }, }; - const fee = this.feeTable.exec; + const fee = this.fees.exec; const { accountNumber, sequence } = await this.getNonce(); const chainId = await this.chainId(); const signBytes = makeSignBytes([executeMsg], fee, chainId, memo, accountNumber, sequence); @@ -345,7 +345,7 @@ export class CosmWasmClient { amount: transferAmount, }, }; - const fee = this.feeTable.send; + const fee = this.fees.send; const { accountNumber, sequence } = await this.getNonce(); const chainId = await this.chainId(); const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence); diff --git a/packages/sdk/types/cosmwasmclient.d.ts b/packages/sdk/types/cosmwasmclient.d.ts index 43a72f4b..49e49d7a 100644 --- a/packages/sdk/types/cosmwasmclient.d.ts +++ b/packages/sdk/types/cosmwasmclient.d.ts @@ -34,7 +34,7 @@ export interface ExecuteResult { readonly logs: readonly Log[]; } export declare class CosmWasmClient { - static makeReadOnly(url: string, feeTable?: Partial): CosmWasmClient; + static makeReadOnly(url: string): CosmWasmClient; static makeWritable( url: string, senderAddress: string, @@ -43,7 +43,7 @@ export declare class CosmWasmClient { ): CosmWasmClient; private readonly restClient; private readonly signingData; - private readonly feeTable; + private readonly fees; private get senderAddress(); private get signCallback(); private constructor();