add ability to pass amount to worm aptos faucet

This commit is contained in:
aki 2022-11-30 03:59:46 +00:00
parent fd1ed1564e
commit fd37e46b7b
1 changed files with 21 additions and 12 deletions

View File

@ -1,13 +1,13 @@
import { assertChain, CHAIN_ID_APTOS, CHAIN_ID_SOLANA, coalesceChainId } from "@certusone/wormhole-sdk/lib/cjs/utils/consts";
import { BCS, FaucetClient } from "aptos"; import { BCS, FaucetClient } from "aptos";
import { ethers } from "ethers";
import yargs from "yargs";
import { callEntryFunc, deriveResourceAccount, deriveWrappedAssetAddress } from "../aptos";
import { spawnSync } from 'child_process'; import { spawnSync } from 'child_process';
import { config } from '../config'; import { ethers } from "ethers";
import fs from 'fs'; import fs from 'fs';
import sha3 from 'js-sha3'; import sha3 from 'js-sha3';
import yargs from "yargs";
import { callEntryFunc, deriveResourceAccount, deriveWrappedAssetAddress } from "../aptos";
import { config } from '../config';
import { NETWORKS } from "../networks"; import { NETWORKS } from "../networks";
import { assertChain, CHAIN_ID_APTOS, CHAIN_ID_SOLANA, coalesceChainId } from "@certusone/wormhole-sdk/lib/cjs/utils/consts";
type Network = "MAINNET" | "TESTNET" | "DEVNET" type Network = "MAINNET" | "TESTNET" | "DEVNET"
@ -32,13 +32,13 @@ const network_options = {
const rpc_description = { const rpc_description = {
alias: "r", alias: "r",
describe: "override default rpc endpoint url", describe: "Override default rpc endpoint url",
type: "string", type: "string",
required: false, required: false,
} as const; } as const;
const named_addresses = { const named_addresses = {
describe: "named addresses in the format addr1=0x0,addr2=0x1,...", describe: "Named addresses in the format addr1=0x0,addr2=0x1,...",
type: "string", type: "string",
require: false require: false
} as const; } as const;
@ -321,13 +321,19 @@ exports.builder = function(y: typeof yargs) {
.option("faucet", { .option("faucet", {
alias: "f", alias: "f",
required: false, required: false,
describe: "faucet url", describe: "Faucet url",
type: "string", type: "string",
}) })
.option("amount", {
alias: "m",
required: false,
describe: "Amount to request",
type: "number",
})
.option("account", { .option("account", {
alias: "a", alias: "a",
required: false, required: false,
describe: "account to fund", describe: "Account to fund",
type: "string", type: "string",
}) })
}, },
@ -335,6 +341,7 @@ exports.builder = function(y: typeof yargs) {
let NODE_URL = "http://0.0.0.0:8080/v1"; let NODE_URL = "http://0.0.0.0:8080/v1";
let FAUCET_URL = "http://0.0.0.0:8081"; let FAUCET_URL = "http://0.0.0.0:8081";
let account = "0x277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b"; let account = "0x277fa055b6a73c42c0662d5236c65c864ccbf2d4abd21f174a30c8b786eab84b";
let amount = 20000000;
if (argv.faucet != undefined) { if (argv.faucet != undefined) {
FAUCET_URL = argv.faucet as string; FAUCET_URL = argv.faucet as string;
@ -342,13 +349,15 @@ exports.builder = function(y: typeof yargs) {
if (argv.rpc != undefined) { if (argv.rpc != undefined) {
NODE_URL = argv.rpc as string; NODE_URL = argv.rpc as string;
} }
if (argv.amount != undefined) {
amount = argv.amount as number;
}
if (argv.account != undefined) { if (argv.account != undefined) {
account = argv.account as string; account = argv.account as string;
} }
const faucetClient = new FaucetClient(NODE_URL, FAUCET_URL); const faucetClient = new FaucetClient(NODE_URL, FAUCET_URL);
const coins = 20000000; await faucetClient.fundAccount(account, amount);
await faucetClient.fundAccount(account, coins); console.log(`Funded ${account} with ${amount} coins`);
console.log(`Funded ${account} with ${coins} coins`);
}) })
.strict().demandCommand(); .strict().demandCommand();
} }