diff --git a/environments/local.toml b/environments/local.toml index 87ea2d2..2eca458 100644 --- a/environments/local.toml +++ b/environments/local.toml @@ -1,4 +1,4 @@ -[upstream] +[registry] rpcEndpoint = "http://localhost:26657" chainId = "laconic_9000-1" denom = "photon" diff --git a/src/index.ts b/src/index.ts index 47c2daa..bdcdf78 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ const FAUCET_DATA_FILE = 'faucet_data.sqlite'; const FAUCET_DATA_TTL = 86400000; // 24 hrs interface Config { - upstream: { + registry: { rpcEndpoint: string chainId: string denom: string @@ -50,7 +50,7 @@ async function main (): Promise { return res.status(400).json({ error: 'address is required' }); } - if (!isValidAddress(accountAddress, config.upstream.prefix)) { + if (!isValidAddress(accountAddress, config.registry.prefix)) { return res.status(400).json({ error: 'invalid address' }); } @@ -108,27 +108,27 @@ async function initKVStore (dbDir: string): Promise { } async function sendTokens (config: Config, recipientAddress: string, amount: string): Promise { - let faucetKey = config.upstream.faucetKey; + let faucetKey = config.registry.faucetKey; if (faucetKey.startsWith('0x')) { faucetKey = faucetKey.slice(2); } const wallet = await DirectSecp256k1Wallet.fromKey( Buffer.from(faucetKey, 'hex'), - config.upstream.prefix + config.registry.prefix ); const [faucetAccount] = await wallet.getAccounts(); const client = await SigningStargateClient.connectWithSigner( - config.upstream.rpcEndpoint, + config.registry.rpcEndpoint, wallet, - { gasPrice: GasPrice.fromString(`${config.upstream.gasPrice}${config.upstream.denom}`) } + { gasPrice: GasPrice.fromString(`${config.registry.gasPrice}${config.registry.denom}`) } ); const result = await client.sendTokens( faucetAccount.address, recipientAddress, - [{ denom: config.upstream.denom, amount: amount }], + [{ denom: config.registry.denom, amount: amount }], 'auto', 'Faucet transfer' );