@@ -12,7 +12,7 @@ import fs from 'fs';
1212
1313import { config } from 'dotenv' ;
1414config ( ) ;
15- const { API_PORT } = process . env ;
15+ const { API_PORT , FAUCET_MNEMONIC } = process . env ;
1616
1717
1818const app = express ( ) ;
@@ -26,7 +26,6 @@ let cooldown_map = new Map();
2626interface ChainInfo {
2727 rpc_url : string ;
2828 prefix : string ;
29- faucet_mnemonic : string ;
3029 denom : string ;
3130 amount_to_send : number ;
3231 gas_price : number ;
@@ -71,7 +70,7 @@ app.get('/', (req, res) => {
7170} )
7271
7372
74- app . get ( '/:chain_id' , async ( req , res ) => {
73+ app . get ( '/:chain_id' , async ( req , res ) => {
7574 const { chain_id } = req . params ;
7675
7776 let chain = get_chain ( chain_id ) ;
@@ -83,8 +82,8 @@ app.get('/:chain_id', async (req, res) => {
8382 chain = chain as ChainInfo ;
8483
8584 try {
86- const payment_account = await getAccountFromMnemonic ( chain . faucet_mnemonic , chain . prefix ) ;
87-
85+ const payment_account = await getAccountFromMnemonic ( FAUCET_MNEMONIC , chain . prefix ) ;
86+
8887 const client = await CosmWasmClient . connect ( chain . rpc_url ) ;
8988 const balance = await client . getBalance ( payment_account . account . address , chain . denom ) ;
9089
@@ -129,20 +128,20 @@ app.get('/:chain_id/:address', async (req, res) => {
129128 error : 'Address is not valid'
130129 } )
131130 }
132-
131+
133132 const map_key = `${ chain_id } -${ address } ` ;
134133 if ( cooldown_map . has ( map_key ) ) {
135134 let cooldown = cooldown_map . get ( map_key ) ;
136135 let seconds_until_then = ( cooldown - Date . now ( ) ) / 1000 ;
137136 if ( cooldown > Date . now ( ) ) {
138- res . status ( 400 ) . json ( {
137+ res . status ( 400 ) . json ( {
139138 error : `Address is in cooldown for ${ seconds_until_then } seconds`
140139 } )
141140 return ;
142141 }
143142 }
144143
145- const payment_account = await getAccountFromMnemonic ( chain . faucet_mnemonic , chain . prefix ) ;
144+ const payment_account = await getAccountFromMnemonic ( FAUCET_MNEMONIC , chain . prefix ) ;
146145 if ( address === payment_account . account . address ) {
147146 res . status ( 400 ) . json ( {
148147 error : 'Address is the same as the faucet address'
@@ -168,7 +167,7 @@ app.get('/:chain_id/:address', async (req, res) => {
168167
169168 res . json ( {
170169 message : `Payment of amount: ${ amt . amount } ${ amt . denom } ` ,
171- faucet_account : payment_account . account . address ,
170+ faucet_account : payment_account . account . address ,
172171 result : result
173172 } )
174173
0 commit comments