move to ethers v4

pull/7/head
yann300 6 years ago
parent 09acd177d5
commit c91adc2c65
  1. 2
      remix-lib/package.json
  2. 19
      remix-lib/src/execution/eventsDecoder.js
  3. 2
      remix-lib/src/execution/txHelper.js

@ -19,7 +19,7 @@
"ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.2",
"ethereumjs-vm": "3.0.0",
"ethers": "^3.0.15",
"ethers": "^4.0.27",
"fast-async": "^6.1.2",
"solc": "^0.5.0",
"web3": "0.20.6"

@ -1,5 +1,4 @@
'use strict'
var ethJSUtil = require('ethereumjs-util')
var ethers = require('ethers')
var txHelper = require('./txHelper')
@ -39,10 +38,10 @@ class EventsDecoder {
_eventABI (contract) {
var eventABI = {}
var abi = new ethers.Interface(contract.abi)
var abi = new ethers.utils.Interface(contract.abi)
for (var e in abi.events) {
var event = abi.events[e]
eventABI[ethJSUtil.sha3(Buffer.from(event.signature)).toString('hex')] = { event: event.name, inputs: event.inputs, object: event }
eventABI[event.topic.replace('0x', '')] = { event: event.name, inputs: event.inputs, object: event, abi: abi }
}
return eventABI
}
@ -71,9 +70,17 @@ class EventsDecoder {
// [address, topics, mem]
var log = logs[i]
var topicId = log.topics[0]
var abi = this._event(topicId.replace('0x', ''), eventsABI)
if (abi) {
events.push({ from: log.address, topic: topicId, event: abi.event, args: abi.object.parse(log.topics, log.data) })
var eventAbi = this._event(topicId.replace('0x', ''), eventsABI)
if (eventAbi) {
var decodedlog = eventAbi.abi.parseLog(log)
let decoded = {}
for (const v in decodedlog.values) {
const value = decodedlog.values[v]
if (value._ethersType) value.type = value._ethersType
let decodedValue = value._ethersType === 'BigNumber' ? value.toString() : value
decoded[v] = decodedValue
}
events.push({ from: log.address, topic: topicId, event: eventAbi.event, args: decoded })
} else {
events.push({ from: log.address, data: log.data, topics: log.topics })
}

@ -30,7 +30,7 @@ module.exports = {
encodeFunctionId: function (funABI) {
if (funABI.type === 'fallback') return '0x'
var abi = new ethers.Interface([funABI])
var abi = new ethers.utils.Interface([funABI])
abi = abi.functions[funABI.name]
return abi.sighash
},

Loading…
Cancel
Save