11import * as scureBip39 from '@scure/bip39' ;
22import { wordlist } from '@scure/bip39/wordlists/english' ;
33import { buildPreorderNameTx , buildRegisterNameTx } from '@stacks/bns' ;
4- import { bytesToHex , HIRO_TESTNET_URL } from '@stacks/common' ;
4+ import { bytesToHex } from '@stacks/common' ;
55import {
66 ACCOUNT_PATH ,
77 broadcastTransaction ,
@@ -1870,8 +1870,8 @@ async function preorder(_network: CLINetworkAdapter, args: string[]): Promise<st
18701870function faucetCall ( _network : CLINetworkAdapter , args : string [ ] ) : Promise < string > {
18711871 const address = args [ 0 ] ;
18721872
1873- // Faucet only exists on testnet
1874- const config = new Configuration ( { basePath : HIRO_TESTNET_URL } ) ;
1873+ const network = getStacksNetwork ( _network ) ;
1874+ const config = new Configuration ( { basePath : network . client . baseUrl } ) ;
18751875 const faucets = new FaucetsApi ( config ) ;
18761876
18771877 return faucets
@@ -2016,7 +2016,7 @@ export function CLIMain() {
20162016 const debug = CLIOptAsBool ( opts , 'd' ) || Boolean ( process . env . DEBUG ) ;
20172017 const consensusHash = CLIOptAsString ( opts , 'C' ) ;
20182018 const integration_test = CLIOptAsBool ( opts , 'i' ) ;
2019- const testnet = CLIOptAsBool ( opts , 't' ) ;
2019+ let testnet = CLIOptAsBool ( opts , 't' ) ;
20202020 const localnet = CLIOptAsBool ( opts , 'l' ) ;
20212021
20222022 const magicBytes = CLIOptAsString ( opts , 'm' ) ;
@@ -2031,6 +2031,22 @@ export function CLIMain() {
20312031 BLOCKSTACK_TEST = integration_test ;
20322032 }
20332033
2034+ // Command specific checks and overrides
2035+ if ( cmdArgs . command === 'help' ) {
2036+ console . log ( makeCommandUsageString ( cmdArgs . args [ 0 ] ) ) ;
2037+ process . exit ( 0 ) ;
2038+ }
2039+
2040+ if ( cmdArgs . command === 'faucet' ) {
2041+ if ( ! testnet && ! localnet && ! nodeAPIUrl && ! apiUrl ) {
2042+ // If not otherwise configured the `faucet` command will default to testnet for backwards compatibility
2043+ testnet = true ;
2044+ }
2045+ if ( localnet || nodeAPIUrl || apiUrl ) {
2046+ console . info ( 'The "faucet" feature may be unavailable for custom API setups.' ) ;
2047+ }
2048+ }
2049+
20342050 const configPath = CLIOptAsString ( opts , 'c' )
20352051 ? CLIOptAsString ( opts , 'c' )
20362052 : testnet
@@ -2095,11 +2111,6 @@ export function CLIMain() {
20952111 // blockstack.config.network = blockstackNetwork;
20962112 blockstack . config . logLevel = 'error' ;
20972113
2098- if ( cmdArgs . command === 'help' ) {
2099- console . log ( makeCommandUsageString ( cmdArgs . args [ 0 ] ) ) ;
2100- process . exit ( 0 ) ;
2101- }
2102-
21032114 const method = COMMANDS [ cmdArgs . command ] ;
21042115 let exitcode = 0 ;
21052116
0 commit comments