diff --git a/CHANGELOG.md b/CHANGELOG.md index 60eca0e346..0924b41b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - @cosmjs/faucet: Log errors for failed send transactions. - @cosmjs/faucet: Add config variable `FAUCET_MEMO`. +- @cosmjs/faucet: Add config variables `FAUCET_FEE` and `FAUCET_GAS`. - @cosmjs/launchpad: Add `parseCoins` helper. ## 0.22.1 (2020-08-11) diff --git a/packages/faucet/README.md b/packages/faucet/README.md index 2c65e27acb..c0549afc8f 100644 --- a/packages/faucet/README.md +++ b/packages/faucet/README.md @@ -47,6 +47,9 @@ Environment variables FAUCET_CONCURRENCY Number of distributor accounts. Defaults to 5. FAUCET_PORT Port of the webserver. Defaults to 8000. FAUCET_MEMO Memo for send transactions. Defaults to unset. +FAUCET_FEE Fee for send transactions as a comma separated list, + e.g. "200ushell,30ureef". Defaults to "2000ucosm". +FAUCET_GAS Gas for send transactions. Defaults to 80000. FAUCET_MNEMONIC Secret mnemonic that serves as the base secret for the faucet HD accounts FAUCET_ADDRESS_PREFIX The bech32 address prefix. Defaults to "cosmos". diff --git a/packages/faucet/src/actions/help.ts b/packages/faucet/src/actions/help.ts index 1dd0d047c3..466c96c6a8 100644 --- a/packages/faucet/src/actions/help.ts +++ b/packages/faucet/src/actions/help.ts @@ -20,6 +20,9 @@ Environment variables FAUCET_CONCURRENCY Number of distributor accounts. Defaults to 5. FAUCET_PORT Port of the webserver. Defaults to 8000. FAUCET_MEMO Memo for send transactions. Defaults to unset. +FAUCET_FEE Fee for send transactions as a comma separated list, + e.g. "200ushell,30ureef". Defaults to "2000ucosm". +FAUCET_GAS Gas for send transactions. Defaults to 80000. FAUCET_MNEMONIC Secret mnemonic that serves as the base secret for the faucet HD accounts FAUCET_ADDRESS_PREFIX The bech32 address prefix. Defaults to "cosmos". diff --git a/packages/faucet/src/constants.ts b/packages/faucet/src/constants.ts index ed385085ff..e4e8be1dea 100644 --- a/packages/faucet/src/constants.ts +++ b/packages/faucet/src/constants.ts @@ -1,8 +1,12 @@ +import { Coin, parseCoins } from "@cosmjs/launchpad"; + import { TokenConfiguration } from "./tokenmanager"; import { parseBankTokens } from "./tokens"; export const binaryName = "cosmwasm-faucet"; export const memo: string | undefined = process.env.FAUCET_MEMO; +export const fee: readonly Coin[] = parseCoins(process.env.FAUCET_FEE || "2000ucosm"); +export const gas: string = process.env.FAUCET_GAS || "80000"; export const concurrency: number = Number.parseInt(process.env.FAUCET_CONCURRENCY || "", 10) || 5; export const port: number = Number.parseInt(process.env.FAUCET_PORT || "", 10) || 8000; export const mnemonic: string | undefined = process.env.FAUCET_MNEMONIC; diff --git a/packages/faucet/src/faucet.ts b/packages/faucet/src/faucet.ts index 78aeeac36a..b34fa8abba 100644 --- a/packages/faucet/src/faucet.ts +++ b/packages/faucet/src/faucet.ts @@ -1,4 +1,10 @@ -import { assertIsPostTxSuccess, CosmosClient, OfflineSigner, SigningCosmosClient } from "@cosmjs/launchpad"; +import { + assertIsPostTxSuccess, + CosmosClient, + FeeTable, + OfflineSigner, + SigningCosmosClient, +} from "@cosmjs/launchpad"; import { sleep } from "@cosmjs/utils"; import * as constants from "./constants"; @@ -51,10 +57,17 @@ export class Faucet { this.holderAddress = wallets[0][0]; this.distributorAddresses = wallets.slice(1).map((pair) => pair[0]); + const fees: Partial = { + send: { + amount: constants.fee, + gas: constants.gas, + }, + }; + // we need one client per sender const clients: { [senderAddress: string]: SigningCosmosClient } = {}; for (const [senderAddress, wallet] of wallets) { - clients[senderAddress] = new SigningCosmosClient(apiUrl, senderAddress, wallet); + clients[senderAddress] = new SigningCosmosClient(apiUrl, senderAddress, wallet, fees); } this.clients = clients; this.logging = logging;