Fixed address filtering and added more features to the event metadata.

This commit is contained in:
Richard Moore 2017-12-05 01:58:20 -05:00
parent 132e56e65e
commit 178980c34a
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
2 changed files with 25 additions and 7 deletions

@ -54,6 +54,8 @@ function Contract(addressOrName, contractInterface, signerOrProvider) {
utils.defineProperty(this, 'signer', signer);
utils.defineProperty(this, 'provider', provider);
var addressPromise = provider.resolveName(addressOrName);
function runMethod(method, estimateOnly) {
return function() {
var transaction = {}
@ -229,12 +231,28 @@ function Contract(addressOrName, contractInterface, signerOrProvider) {
var eventCallback = null;
function handleEvent(log) {
try {
var result = eventInfo.parse(log.topics, log.data);
eventCallback.apply(log, Array.prototype.slice.call(result));
} catch (error) {
console.log(error);
}
addressPromise.then(function(address) {
// Not meant for us (the topics just has the same name)
if (address != log.address) { return; }
try {
var result = eventInfo.parse(log.topics, log.data);
// Some useful things to have with the log
log.args = result;
log.event = eventName;
log.parse = eventInfo.parse;
log.removeListener = function() {
provider.removeListener(eventInfo.topics, handleEvent);
}
log.eventSignature = eventInfo.signature;
eventCallback.apply(log, Array.prototype.slice.call(result));
} catch (error) {
console.log(error);
}
});
}
var property = {

@ -1,6 +1,6 @@
{
"name": "ethers-contracts",
"version": "2.1.7",
"version": "2.1.8",
"description": "Contract and Interface (ABI) library for Ethereum.",
"bugs": {
"url": "http://github.com/ethers-io/ethers.js/issues",