feat: 充值查询+刷新

This commit is contained in:
chaosBreaking
2019-09-08 17:24:36 +08:00
parent 8edcc85903
commit 383e24fbfa
9 changed files with 173 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
'use strict';
module.exports = {
USDTAddr: '0xdac17f958d2ee523a2206206994597c13d831ec7'
USDTAddr: '0xdac17f958d2ee523a2206206994597c13d831ec7',
startBlock: 6327420
};

34
src/common/deposit.js Normal file
View File

@@ -0,0 +1,34 @@
'use strict';
const { ERC20 } = require('../utils/erc20');
const { USDTAddr, startBlock } = require('./constant');
const getUSDTTxList = async address => {
if (!address) return null;
const res = await ERC20.getActions(address, USDTAddr, startBlock).catch(err => {
if (err) return [];
});
return res;
};
const parseUsdtTx = txList => {
if (!txList || !Array.isArray(txList)) return [];
return txList.map(tx => {
return {
amount: +tx.value,
hash: tx.hash,
blockNumber: tx.blockNumber
};
});
};
const getNewDepositTx = (usdtTx = [], fundList = []) => {
if (fundList.length > usdtTx.length) return null;
// fundList的顺序应该与usdtTx的顺序一致所以只要截取新的
const newUsdtTxList = usdtTx.slice(fundList.length);
return parseUsdtTx(newUsdtTxList);
};
module.exports = {
getUSDTTxList,
getNewDepositTx
};