import { getApiKey , validateKey } from "./db" ; import { AxiosResponse } from "axios" ; import { CONFIG , avm , bintools } from './ava' ; const axios = require ( 'axios' ) . default ; const { sendAvaC , CONFIG_C } = require ( "./eth" ) ; const Web3 = require ( "web3" ) ; import { BN } from 'avalanche' ; import { getAddressChain , sendDrop , sendDropX } from "./helpers/helper" ; import ApiHelper from "./helpers/apiHelper" ; var router = require ( 'express' ) . Router ( ) ; router . get ( '/howmuch' , ( req , res ) => { res . json ( { dropSizeX : CONFIG . DROP_SIZE , dropSizeC : CONFIG_C . DROP_SIZE } ) ; } ) ; router . post ( '/token_custom' , async ( req , res ) => { let apiKey = req . body . key ; let amount = req . body . amount ; let to = req . body . to ; ApiHelper . tokenCustom ( apiKey , amount , to ) . then ( txID => { onsuccess ( res , txID ) ; } ) . catch ( ( e ) => { onError ( res , e ) ; } ) ; } ) ; router . post ( '/token' , ( req , res ) => { let address = req . body . address ; let captchaResponse = req . body [ "g-recaptcha-response" ] ; ApiHelper . token ( address , captchaResponse ) . then ( txID => { onsuccess ( res , txID ) ; } ) . catch ( ( e ) => { onError ( res , e ) ; } ) ; } ) ; function onError ( res , err ) { res . json ( { status : 'error' , message : err . message } ) ; } function onsuccess ( res , txHash ) { res . json ( { status : 'success' , message : txHash } ) ; } module . exports = router ;