feat: 充值查询+刷新
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
USDTAddr: '0xdac17f958d2ee523a2206206994597c13d831ec7'
|
||||
USDTAddr: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
||||
startBlock: 6327420
|
||||
};
|
||||
34
src/common/deposit.js
Normal file
34
src/common/deposit.js
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user