Skip to content

Commit

Permalink
chore: allow passing recipient to faucet
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Aug 28, 2024
1 parent 4efc586 commit 565b43e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sui/faucet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui/faucet');
const { saveConfig, loadConfig, printInfo } = require('../common/utils');
const { getWallet, printWalletInfo, addBaseOptions } = require('./utils');
const { Command } = require('commander');
const { Command, Option } = require('commander');

async function processCommand(config, chain, options) {
const [keypair, client] = getWallet(chain, options);
const recipient = options.recipient || keypair.toSuiAddress();

await printWalletInfo(keypair, client, chain, options);

await requestSuiFromFaucetV0({
host: getFaucetHost(chain.networkType),
recipient: keypair.toSuiAddress(),
recipient,
});

printInfo('Funds requested');
Expand All @@ -27,13 +28,15 @@ async function mainProcessor(options, processor) {
if (require.main === module) {
const program = new Command();

program.name('faucet').description('Query the faucet for funds.');
program
.name('faucet')
.addOption(new Option('--recipient <recipient>', 'recipient to request funds for'))
.description('Query the faucet for funds.')
.action((options) => {
mainProcessor(options, processCommand);
});

addBaseOptions(program);

program.action((options) => {
mainProcessor(options, processCommand);
});

program.parse();
}

0 comments on commit 565b43e

Please sign in to comment.