EthMev.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import http from 'axios'
  2. import NumKit from '@/plugins/kit/NumKit'
  3. export default class EthMev {
  4. static async getEthMevData(block, hash, dataVague, page=1, size=200) {
  5. const url = '/ethmev/findByHashOrBlockOrDataVague'
  6. const rst = await http.post(url, {
  7. block: block,
  8. hash: hash,
  9. dataVague: dataVague,
  10. limit1: (page - 1) * size,
  11. limit2: size
  12. })
  13. return rst.data
  14. }
  15. static async getEthMevPendingData(block, hash, dataVague, page=1, size=200) {
  16. if (!isNaN(parseInt(block)) && block.charAt(0) !== '-') block = '-' + block
  17. const url = '/ethmev/findByHashOrBlockOrDataVaguePending'
  18. const rst = await http.post(url, {
  19. block: block,
  20. hash: hash,
  21. dataVague: dataVague,
  22. limit1: (page - 1) * size,
  23. limit2: size
  24. })
  25. return rst.data
  26. }
  27. static async deleteByHash(hash) {
  28. const url = '/ethmev/deleteByHash'
  29. const rst = await http.post(url, {
  30. hash: hash
  31. })
  32. return rst.data
  33. }
  34. static async appendOrUpdate(block, hash, dataVague) {
  35. const url = '/ethmev/appendOrUpdate'
  36. const rst = await http.post(url, {
  37. block: block,
  38. hash: hash,
  39. dataVague: dataVague
  40. })
  41. return rst.data
  42. }
  43. static generateTableDataByDbData(historyList) {
  44. historyList.map(function (history) {
  45. try {
  46. let dataObj = history.dataObj
  47. dataObj.memo = '0x7ff36ab500000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000000000008000000000000000000000000053125ab9cb23d52468bd051ee1a395991eef6d23000000000000000000000000000000000000000000000000000000006363869e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000007bf88d2c0e32de92cdaf2d43ccdc23e8edfd5990000000000000000000000000ba76ac663c8b30a4508d274f6683a02af705f76b0x7ff36ab500000000000000000000000000000000000000000000000000000002540b'
  48. history.from = dataObj.fromAdd
  49. history.to = dataObj.toAdd
  50. history.gasPrice = NumKit.getSubFloat(parseInt(dataObj.gasPrice) / (1E9), 2)
  51. history.index = dataObj.index
  52. history.type = dataObj.type
  53. history.state = dataObj.status
  54. history.pending = dataObj.pending
  55. history.tradeInfoList = dataObj.tradeInfo
  56. history.memo = dataObj.memo
  57. // hash异常处理
  58. if (history.hash.indexOf('0x') === -1 && history.hash.length === 64) history.hash = '0x' + history.hash
  59. // token处理
  60. history.tokenMap = {}
  61. history.tradeInfoList.map(function (tradeInfo) {
  62. if (!history.tokenMap[tradeInfo.token]) history.tokenMap[tradeInfo.token] = tradeInfo.tokenSymbol
  63. })
  64. history.tokenAddressList = Object.keys(history.tokenMap)
  65. } catch (e) {
  66. history.tradeInfo = []
  67. }
  68. })
  69. }
  70. }