Add config variables FAUCET_FEE and FAUCET_GAS

This commit is contained in:
Simon Warta 2020-08-11 12:29:04 +02:00
parent 4f54b26ac3
commit 55d6ab9ff5
5 changed files with 26 additions and 2 deletions

View File

@ -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)

View File

@ -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".

View File

@ -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".

View File

@ -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;

View File

@ -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<FeeTable> = {
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;