Pull out explicit fee constants

This commit is contained in:
Simon Warta 2020-02-11 11:09:22 +01:00
parent 83bb1021aa
commit 6783b273f8

View File

@ -12,6 +12,36 @@ import {
StdSignature, StdSignature,
} from "./types"; } from "./types";
const defaultUploadFee: StdFee = {
amount: [
{
amount: "5000",
denom: "ucosm",
},
],
gas: "1000000", // one million
};
const defaultInitFee: StdFee = {
amount: [
{
amount: "5000",
denom: "ucosm",
},
],
gas: "500000", // 500k
};
const defaultExecFee: StdFee = {
amount: [
{
amount: "5000",
denom: "ucosm",
},
],
gas: "200000", // 200k
};
export interface SigningCallback { export interface SigningCallback {
(signBytes: Uint8Array): Promise<StdSignature>; (signBytes: Uint8Array): Promise<StdSignature>;
} }
@ -108,16 +138,7 @@ export class CosmWasmClient {
builder: "", builder: "",
}, },
}; };
const fee: StdFee = { const fee = defaultUploadFee;
amount: [
{
amount: "5000000",
denom: "ucosm",
},
],
gas: "89000000",
};
const { accountNumber, sequence } = await this.getNonce(); const { accountNumber, sequence } = await this.getNonce();
const chainId = await this.chainId(); const chainId = await this.chainId();
const signBytes = makeSignBytes([storeCodeMsg], fee, chainId, memo, accountNumber, sequence); const signBytes = makeSignBytes([storeCodeMsg], fee, chainId, memo, accountNumber, sequence);
@ -153,16 +174,7 @@ export class CosmWasmClient {
init_funds: transferAmount || [], init_funds: transferAmount || [],
}, },
}; };
const fee: StdFee = { const fee = defaultInitFee;
amount: [
{
amount: "5000000",
denom: "ucosm",
},
],
gas: "89000000",
};
const { accountNumber, sequence } = await this.getNonce(); const { accountNumber, sequence } = await this.getNonce();
const chainId = await this.chainId(); const chainId = await this.chainId();
const signBytes = makeSignBytes([instantiateMsg], fee, chainId, memo, accountNumber, sequence); const signBytes = makeSignBytes([instantiateMsg], fee, chainId, memo, accountNumber, sequence);
@ -196,16 +208,7 @@ export class CosmWasmClient {
sent_funds: transferAmount || [], sent_funds: transferAmount || [],
}, },
}; };
const fee: StdFee = { const fee = defaultExecFee;
amount: [
{
amount: "5000000",
denom: "ucosm",
},
],
gas: "89000000",
};
const { accountNumber, sequence } = await this.getNonce(); const { accountNumber, sequence } = await this.getNonce();
const chainId = await this.chainId(); const chainId = await this.chainId();
const signBytes = makeSignBytes([executeMsg], fee, chainId, memo, accountNumber, sequence); const signBytes = makeSignBytes([executeMsg], fee, chainId, memo, accountNumber, sequence);