const SimpleWeb3 = require('./simple-web3') const Config = require('../../config/config') class IERC20 {} IERC20.batchInit = async function (context, ierc20TokenAddressList) { IERC20.contractMap = {} // 初始化token for (const tokenHash of ierc20TokenAddressList) { await IERC20.initTokenByHash(context, tokenHash) } } IERC20.initTokenByHash = async function (context, tokenHash) { // 合约初始化 IERC20.contractMap[tokenHash] = new SimpleWeb3.web3.eth.Contract(Config.BASE_ABI, tokenHash) } IERC20.getTokenName = async function (tokenHash) { return await IERC20.contractMap[tokenHash].methods.name().call() } IERC20.getTokenSymbol = async function (tokenHash) { return await IERC20.contractMap[tokenHash].methods.symbol().call() } IERC20.getDecimals = async function (tokenHash) { return await IERC20.contractMap[tokenHash].methods.decimals().call() } module.exports = IERC20