| 123456789101112131415161718192021222324252627282930313233 |
- const SimpleWeb3 = require('./simple-web3')
- 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) {
- const config = context.config
- // 合约初始化
- 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
|