Fixed address filtering and added more features to the event metadata.
This commit is contained in:
parent
132e56e65e
commit
178980c34a
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user