http_withdraw.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const axios = require('axios');
  2. var { account_config } = require('../config/config.js');
  3. const logger = require('./logger.js');
  4. var url = account_config.CZZ_BASEURL
  5. const withdraw = async (params) => {
  6. params.privateKey = ''
  7. params.toAddress = params.receiver
  8. logger.info('http-withdraw', process.env.NODE_ENV, url, ' params ', params)
  9. var data = { ...params }
  10. return new Promise(resolve => {
  11. axios.post(url + '/withdraw', data, { timeout: 5 * 60 * 1000 })
  12. .then(res => {
  13. logger.info('withdraw res=>', res.status, res.data);
  14. resolve(res.data)
  15. }).catch(err => {
  16. logger.error('http_request_post withdraw_czz error ', JSON.stringify(err));
  17. resolve(JSON.stringify(err))
  18. });
  19. })
  20. }
  21. const check_withdraw_status = async (params) => {
  22. logger.info('txn_status_czz', process.env.NODE_ENV, url, ' params ', params)
  23. var pars = {
  24. txn_hash: params.hash,
  25. chain: params.chain
  26. }
  27. var data = pars
  28. return new Promise(resolve => {
  29. axios.post(url + '/txn_status', data, { timeout: 1 * 60 * 1000 })
  30. .then(res => {
  31. console.log('check_withdraw_status res=>', res.status, res.data);
  32. resolve(res.data)
  33. }).catch(err => {
  34. logger.error('http_request_post check_withdraw_status error ', JSON.stringify(err));
  35. resolve(JSON.stringify(err))
  36. });
  37. })
  38. }
  39. // check_withdraw_status({
  40. // hash: "0x4561096623a1101b28e6b321f5bd4633dbed992aa9fc7b6d1776ef09581f045f",
  41. // })
  42. module.exports = {
  43. withdraw,
  44. check_withdraw_status
  45. }