File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -130,11 +130,12 @@ export function createFaucetRouter(db: DataStore): RouterWithAsync {
130
130
let sendError : Error | undefined = undefined ;
131
131
let sendSuccess = false ;
132
132
for ( let i = 0 ; i < MAX_NONCE_INCREMENT_RETRIES ; i ++ ) {
133
+ const network = getStxFaucetNetwork ( ) ;
133
134
const txOpts : SignedTokenTransferOptions = {
134
135
recipient : address ,
135
136
amount : new BN ( stxAmount . toString ( ) ) ,
136
137
senderKey : privateKey ,
137
- network : getStxFaucetNetwork ( ) ,
138
+ network : network ,
138
139
memo : 'Faucet' ,
139
140
} ;
140
141
if ( nextNonce !== undefined ) {
@@ -143,7 +144,9 @@ export function createFaucetRouter(db: DataStore): RouterWithAsync {
143
144
const tx = await makeSTXTokenTransfer ( txOpts ) ;
144
145
const serializedTx = tx . serialize ( ) ;
145
146
try {
146
- const txSendResult = await new StacksCoreRpcClient ( ) . sendTransaction ( serializedTx ) ;
147
+ const coreUrl = new URL ( network . coreApiUrl ) ;
148
+ const rpcClient = new StacksCoreRpcClient ( { host : coreUrl . hostname , port : coreUrl . port } ) ;
149
+ const txSendResult = await rpcClient . sendTransaction ( serializedTx ) ;
147
150
res . json ( {
148
151
success : true ,
149
152
txId : txSendResult . txId ,
@@ -152,7 +155,9 @@ export function createFaucetRouter(db: DataStore): RouterWithAsync {
152
155
sendSuccess = true ;
153
156
break ;
154
157
} catch ( error ) {
155
- sendError = error ;
158
+ if ( sendError === undefined ) {
159
+ sendError = error ;
160
+ }
156
161
if ( error . message ?. includes ( 'ConflictingNonceInMempool' ) ) {
157
162
nextNonce = unwrap ( tx . auth . spendingCondition ) . nonce . add ( new BN ( 1 ) ) ;
158
163
} else if ( error . message ?. includes ( 'BadNonce' ) ) {
You can’t perform that action at this time.
0 commit comments