Merge pull request #404 from CosmWasm/test-new-gas-price

Test new GasPrice/GasLimits interface in CLI
This commit is contained in:
Simon Warta 2020-08-19 17:04:49 +02:00 committed by GitHub
commit 7a3d5a9e92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 19 deletions

View File

@ -145,6 +145,7 @@ jobs:
environment:
SKIP_BUILD: 1
command: |
./bin/cosmwasm-cli --init examples/coralnet.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/delegate.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/faucet_addresses.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/generate_address.ts --code "process.exit(0)"

View File

@ -0,0 +1,28 @@
interface Options {
readonly httpUrl: string;
readonly bech32prefix: string;
readonly hdPath: readonly Slip10RawIndex[];
readonly gasPrice: GasPrice;
readonly gasLimits: Partial<GasLimits<CosmWasmFeeTable>>; // only set the ones you want to override
}
const coralnetOptions: Options = {
httpUrl: 'https://lcd.coralnet.cosmwasm.com',
gasPrice: GasPrice.fromString("0.025ushell"),
bech32prefix: 'coral',
hdPath: makeCosmoshubPath(0),
gasLimits: {
upload: 1500000,
}
}
const wallet = await Secp256k1Wallet.generate(12, coralnetOptions.hdPath, coralnetOptions.bech32prefix);
const [{ address }] = await wallet.getAccounts();
const client = new SigningCosmWasmClient(
coralnetOptions.httpUrl,
address,
wallet,
coralnetOptions.gasPrice,
coralnetOptions.gasLimits,
);

View File

@ -16,25 +16,6 @@ const defaultOptions: Options = {
const defaultFaucetUrl = "https://faucet.demo-10.cosmwasm.com/credit";
const buildFeeTable = (feeToken: string, gasPrice: number): CosmWasmFeeTable => {
const calculateFee = (gas: number, denom: string, price: number) => {
const amount = Math.floor(gas * price);
return {
amount: [{ amount: amount.toString(), denom: denom }],
gas: gas.toString(),
};
};
return {
upload: calculateFee(1000000, feeToken, gasPrice),
init: calculateFee(500000, feeToken, gasPrice),
migrate: calculateFee(500000, feeToken, gasPrice),
exec: calculateFee(200000, feeToken, gasPrice),
send: calculateFee(80000, feeToken, gasPrice),
changeAdmin: calculateFee(80000, feeToken, gasPrice),
};
};
// TODO: hit faucet
// if (config.faucetUrl) {
// const acct = await client.getAccount();

View File

@ -102,6 +102,7 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
"BroadcastTxResult",
"Coin",
"CosmosClient",
"GasLimits",
"GasPrice",
"Msg",
"MsgDelegate",