import http from 'axios' import NumKit from '@/plugins/kit/NumKit' export default class EthMev { static async getEthMevData(block, hash, dataVague, page=1, size=200) { const url = '/ethmev/findByHashOrBlockOrDataVague' const rst = await http.post(url, { block: block, hash: hash, dataVague: dataVague, limit1: (page - 1) * size, limit2: size }) return rst.data } static async getEthMevPendingData(block, hash, dataVague, page=1, size=200) { if (!isNaN(parseInt(block)) && block.charAt(0) !== '-') block = '-' + block const url = '/ethmev/findByHashOrBlockOrDataVaguePending' const rst = await http.post(url, { block: block, hash: hash, dataVague: dataVague, limit1: (page - 1) * size, limit2: size }) return rst.data } static async deleteByHash(hash) { const url = '/ethmev/deleteByHash' const rst = await http.post(url, { hash: hash }) return rst.data } static async appendOrUpdate(block, hash, dataVague) { const url = '/ethmev/appendOrUpdate' const rst = await http.post(url, { block: block, hash: hash, dataVague: dataVague }) return rst.data } static generateTableDataByDbData(historyList) { historyList.map(function (history) { try { let dataObj = history.dataObj dataObj.memo = '0x7ff36ab500000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000000000008000000000000000000000000053125ab9cb23d52468bd051ee1a395991eef6d23000000000000000000000000000000000000000000000000000000006363869e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000007bf88d2c0e32de92cdaf2d43ccdc23e8edfd5990000000000000000000000000ba76ac663c8b30a4508d274f6683a02af705f76b0x7ff36ab500000000000000000000000000000000000000000000000000000002540b' history.from = dataObj.fromAdd history.to = dataObj.toAdd history.gasPrice = NumKit.getSubFloat(parseInt(dataObj.gasPrice) / (1E9), 2) history.index = dataObj.index history.type = dataObj.type history.state = dataObj.status history.pending = dataObj.pending history.tradeInfoList = dataObj.tradeInfo history.memo = dataObj.memo // hash异常处理 if (history.hash.indexOf('0x') === -1 && history.hash.length === 64) history.hash = '0x' + history.hash // token处理 history.tokenMap = {} history.tradeInfoList.map(function (tradeInfo) { if (!history.tokenMap[tradeInfo.token]) history.tokenMap[tradeInfo.token] = tradeInfo.tokenSymbol }) history.tokenAddressList = Object.keys(history.tokenMap) } catch (e) { history.tradeInfo = [] } }) } }