Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8142c1c

Browse files
committed
fix: Respect network changing flags for faucet command
1 parent 04bb69c commit 8142c1c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/cli/src/cli.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,22 +1866,27 @@ async function preorder(_network: CLINetworkAdapter, args: string[]): Promise<st
18661866
});
18671867
}
18681868

1869-
function faucetCall(_: CLINetworkAdapter, args: string[]): Promise<string> {
1869+
function faucetCall(network: CLINetworkAdapter, args: string[]): Promise<string> {
18701870
const address = args[0];
18711871
// console.log(address);
18721872

1873+
// Use network configuration if available, otherwise default to testnet
1874+
// Since faucets only exist on testnets, we default to testnet if no custom URL is provided
1875+
const basePath = network.nodeAPIUrl || HIRO_TESTNET_URL;
1876+
18731877
const apiConfig = new Configuration({
1874-
basePath: 'https://api.testnet.hiro.so',
1878+
basePath,
18751879
});
18761880

18771881
const faucets = new FaucetsApi(apiConfig);
1882+
const stacksNetwork = getStacksNetwork(network);
18781883

18791884
return faucets
18801885
.runFaucetStx({ address })
18811886
.then((faucetTx: any) => {
18821887
return JSONStringify({
18831888
txid: faucetTx.txId!,
1884-
transaction: generateExplorerTxPageUrl(faucetTx.txId!.replace(/^0x/, ''), STACKS_TESTNET),
1889+
transaction: generateExplorerTxPageUrl(faucetTx.txId!.replace(/^0x/, ''), stacksNetwork),
18851890
});
18861891
})
18871892
.catch((error: any) => error.toString());

0 commit comments

Comments
 (0)