Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethersproject/contracts

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/contracts - npm Package Compare versions

Comparing version 5.0.0-beta.147 to 5.0.0-beta.148

2

lib.esm/_version.d.ts

@@ -1,1 +0,1 @@

export declare const version = "contracts/5.0.0-beta.147";
export declare const version = "contracts/5.0.0-beta.148";

@@ -1,1 +0,1 @@

export const version = "contracts/5.0.0-beta.147";
export const version = "contracts/5.0.0-beta.148";

@@ -28,2 +28,3 @@ import { Fragment, Indexed, Interface, JsonFragment, Result } from "@ethersproject/abi";

args?: Result;
decodeError?: Error;
decode?: (data: string, topics?: Array<string>) => any;

@@ -56,2 +57,3 @@ removeListener: () => void;

prepareEvent(event: Event): void;
getEmit(event: Event): Array<any>;
}

@@ -90,3 +92,3 @@ export declare type ContractInterface = string | Array<Fragment | JsonFragment | string> | Interface;

_checkRunningEvents(runningEvent: RunningEvent): void;
private _wrapEvent;
_wrapEvent(runningEvent: RunningEvent, log: Log, listener: Listener): Event;
private _addEventListener;

@@ -93,0 +95,0 @@ queryFilter(event: EventFilter, fromBlockOrBlockhash?: BlockTag | string, toBlock?: BlockTag): Promise<Array<Event>>;

@@ -226,2 +226,6 @@ "use strict";

}
// Returns the array that will be applied to an emit
getEmit(event) {
return [event];
}
}

@@ -233,2 +237,7 @@ class ErrorRunningEvent extends RunningEvent {

}
// @TODO Fragment should inherit Wildcard? and just override getEmit?
// or have a common abstract super class, with enough constructor
// options to configure both.
// A Fragment Event will populate all the properties that Wildcard
// will, and additioanlly dereference the arguments when emitting
class FragmentRunningEvent extends RunningEvent {

@@ -261,5 +270,22 @@ constructor(address, contractInterface, fragment, topics) {

};
event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics);
try {
event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics);
}
catch (error) {
event.args = null;
event.decodeError = error;
throw error;
}
}
getEmit(event) {
const args = (event.args || []).slice();
args.push(event);
return args;
}
}
// A Wildard Event will attempt to populate:
// - event The name of the event name
// - eventSignature The full signature of the event
// - decode A function to decode data and topics
// - args The decoded data and topics
class WildcardRunningEvent extends RunningEvent {

@@ -273,4 +299,4 @@ constructor(address, contractInterface) {

super.prepareEvent(event);
const parsed = this.interface.parseLog(event);
if (parsed) {
try {
const parsed = this.interface.parseLog(event);
event.event = parsed.name;

@@ -283,2 +309,5 @@ event.eventSignature = parsed.signature;

}
catch (error) {
// No matching event
}
}

@@ -490,23 +519,22 @@ }

}
// Get the event Fragment (throws if ambiguous/unknown event)
const fragment = this.interface.getEvent(eventName);
if (!fragment) {
logger.throwArgumentError("unknown event - " + eventName, "eventName", eventName);
}
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment));
}
const filter = {
address: this.address
};
// Find the matching event in the ABI; if none, we still allow filtering
// since it may be a filter for an otherwise unknown event
if (eventName.topics) {
if (eventName.topics[0]) {
// We have topics to filter by...
if (eventName.topics && eventName.topics.length > 0) {
// Is it a known topichash? (throws if no matching topichash)
try {
const fragment = this.interface.getEvent(eventName.topics[0]);
if (fragment) {
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
}
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
}
filter.topics = eventName.topics;
catch (error) { }
// Filter by the unknown topichash
const filter = {
address: this.address,
topics: eventName.topics
};
return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter));
}
return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter));
return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface));
}

@@ -524,11 +552,6 @@ _checkRunningEvents(runningEvent) {

}
// Subclasses can override this to gracefully recover
// from parse errors if they wish
_wrapEvent(runningEvent, log, listener) {
const event = deepCopy(log);
try {
runningEvent.prepareEvent(event);
}
catch (error) {
this.emit("error", error);
throw error;
}
event.removeListener = () => {

@@ -544,2 +567,4 @@ if (!listener) {

event.getTransactionReceipt = () => { return this.provider.getTransactionReceipt(log.transactionHash); };
// This may throw if the topics and data mismatch the signature
runningEvent.prepareEvent(event);
return event;

@@ -554,8 +579,15 @@ }

this._runningEvents[runningEvent.tag] = runningEvent;
// If we are not polling the provider, start
// If we are not polling the provider, start polling
if (!this._wrappedEmits[runningEvent.tag]) {
const wrappedEmit = (log) => {
const event = this._wrapEvent(runningEvent, log, listener);
const args = (event.args || []).slice();
args.push(event);
let event = null;
try {
event = this._wrapEvent(runningEvent, log, listener);
}
catch (error) {
// There was an error decoding the data and topics
this.emit("error", error, event);
return;
}
const args = runningEvent.getEmit(event);
this.emit(runningEvent.filter, ...args);

@@ -562,0 +594,0 @@ };

@@ -1,1 +0,1 @@

export declare const version = "contracts/5.0.0-beta.147";
export declare const version = "contracts/5.0.0-beta.148";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "contracts/5.0.0-beta.147";
exports.version = "contracts/5.0.0-beta.148";

@@ -28,2 +28,3 @@ import { Fragment, Indexed, Interface, JsonFragment, Result } from "@ethersproject/abi";

args?: Result;
decodeError?: Error;
decode?: (data: string, topics?: Array<string>) => any;

@@ -56,2 +57,3 @@ removeListener: () => void;

prepareEvent(event: Event): void;
getEmit(event: Event): Array<any>;
}

@@ -90,3 +92,3 @@ export declare type ContractInterface = string | Array<Fragment | JsonFragment | string> | Interface;

_checkRunningEvents(runningEvent: RunningEvent): void;
private _wrapEvent;
_wrapEvent(runningEvent: RunningEvent, log: Log, listener: Listener): Event;
private _addEventListener;

@@ -93,0 +95,0 @@ queryFilter(event: EventFilter, fromBlockOrBlockhash?: BlockTag | string, toBlock?: BlockTag): Promise<Array<Event>>;

@@ -253,2 +253,6 @@ "use strict";

};
// Returns the array that will be applied to an emit
RunningEvent.prototype.getEmit = function (event) {
return [event];
};
return RunningEvent;

@@ -263,2 +267,7 @@ }());

}(RunningEvent));
// @TODO Fragment should inherit Wildcard? and just override getEmit?
// or have a common abstract super class, with enough constructor
// options to configure both.
// A Fragment Event will populate all the properties that Wildcard
// will, and additioanlly dereference the arguments when emitting
var FragmentRunningEvent = /** @class */ (function (_super) {

@@ -295,6 +304,23 @@ __extends(FragmentRunningEvent, _super);

};
event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics);
try {
event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics);
}
catch (error) {
event.args = null;
event.decodeError = error;
throw error;
}
};
FragmentRunningEvent.prototype.getEmit = function (event) {
var args = (event.args || []).slice();
args.push(event);
return args;
};
return FragmentRunningEvent;
}(RunningEvent));
// A Wildard Event will attempt to populate:
// - event The name of the event name
// - eventSignature The full signature of the event
// - decode A function to decode data and topics
// - args The decoded data and topics
var WildcardRunningEvent = /** @class */ (function (_super) {

@@ -311,11 +337,14 @@ __extends(WildcardRunningEvent, _super);

_super.prototype.prepareEvent.call(this, event);
var parsed = this.interface.parseLog(event);
if (parsed) {
event.event = parsed.name;
event.eventSignature = parsed.signature;
try {
var parsed_1 = this.interface.parseLog(event);
event.event = parsed_1.name;
event.eventSignature = parsed_1.signature;
event.decode = function (data, topics) {
return _this.interface.decodeEventLog(parsed.eventFragment, data, topics);
return _this.interface.decodeEventLog(parsed_1.eventFragment, data, topics);
};
event.args = parsed.args;
event.args = parsed_1.args;
}
catch (error) {
// No matching event
}
};

@@ -536,23 +565,22 @@ return WildcardRunningEvent;

}
// Get the event Fragment (throws if ambiguous/unknown event)
var fragment = this.interface.getEvent(eventName);
if (!fragment) {
logger.throwArgumentError("unknown event - " + eventName, "eventName", eventName);
}
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment));
}
var filter = {
address: this.address
};
// Find the matching event in the ABI; if none, we still allow filtering
// since it may be a filter for an otherwise unknown event
if (eventName.topics) {
if (eventName.topics[0]) {
// We have topics to filter by...
if (eventName.topics && eventName.topics.length > 0) {
// Is it a known topichash? (throws if no matching topichash)
try {
var fragment = this.interface.getEvent(eventName.topics[0]);
if (fragment) {
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
}
return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics));
}
filter.topics = eventName.topics;
catch (error) { }
// Filter by the unknown topichash
var filter = {
address: this.address,
topics: eventName.topics
};
return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter));
}
return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter));
return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface));
};

@@ -570,12 +598,7 @@ Contract.prototype._checkRunningEvents = function (runningEvent) {

};
// Subclasses can override this to gracefully recover
// from parse errors if they wish
Contract.prototype._wrapEvent = function (runningEvent, log, listener) {
var _this = this;
var event = properties_1.deepCopy(log);
try {
runningEvent.prepareEvent(event);
}
catch (error) {
this.emit("error", error);
throw error;
}
event.removeListener = function () {

@@ -591,2 +614,4 @@ if (!listener) {

event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); };
// This may throw if the topics and data mismatch the signature
runningEvent.prepareEvent(event);
return event;

@@ -602,8 +627,15 @@ };

this._runningEvents[runningEvent.tag] = runningEvent;
// If we are not polling the provider, start
// If we are not polling the provider, start polling
if (!this._wrappedEmits[runningEvent.tag]) {
var wrappedEmit = function (log) {
var event = _this._wrapEvent(runningEvent, log, listener);
var args = (event.args || []).slice();
args.push(event);
var event = null;
try {
event = _this._wrapEvent(runningEvent, log, listener);
}
catch (error) {
// There was an error decoding the data and topics
_this.emit("error", error, event);
return;
}
var args = runningEvent.getEmit(event);
_this.emit.apply(_this, __spreadArrays([runningEvent.filter], args));

@@ -610,0 +642,0 @@ };

@@ -35,5 +35,5 @@ {

},
"tarballHash": "0xf9eed94c2691cdfba2ad5388d60b3c10740a130b29ff74ac141e5b5043d79f87",
"tarballHash": "0x4ff43d361fce2dcebd688d0f068197f8c95444c5a790620dd453119436c5db15",
"types": "./lib/index.d.ts",
"version": "5.0.0-beta.147"
"version": "5.0.0-beta.148"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc