const axios = require('axios'); var { account_config } = require('../config/config.js'); const logger = require('./logger.js'); var url = account_config.CZZ_BASEURL const withdraw = async(params) => { params.privateKey = '' params.toAddress = params.receiver logger.info('http-withdraw', process.env.NODE_ENV, url, ' params ', params) var data = {...params } return new Promise(resolve => { axios.post(url + '/withdraw', data, { timeout: 5 * 60 * 1000 }) .then(res => { logger.info('withdraw res=>', res.status, res.data); resolve(res.data) }).catch(err => { logger.error('http_request_post withdraw_czz error ', JSON.stringify(err)); resolve(JSON.stringify(err)) }); }) } const check_withdraw_status = async(params) => { logger.info('txn_status_czz', process.env.NODE_ENV, url, ' params ', params) var pars = { txn_hash: params.hash, chain: params.chain } var data = pars return new Promise(resolve => { axios.post(url + '/txn_status', data, { timeout: 1 * 60 * 1000 }) .then(res => { console.log('check_withdraw_status res=>', res.status, res.data); resolve(res.data) }).catch(err => { logger.error('http_request_post check_withdraw_status error ', JSON.stringify(err)); resolve(JSON.stringify(err)) }); }) } // check_withdraw_status({ // hash: "0x4561096623a1101b28e6b321f5bd4633dbed992aa9fc7b6d1776ef09581f045f", // }) module.exports = { withdraw, check_withdraw_status }