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

@ethersproject/abi

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/abi - npm Package Compare versions

Comparing version 5.0.0-beta.122 to 5.0.0-beta.123

_version.d.ts

12

abi-coder.js

@@ -29,3 +29,4 @@ "use strict";

function AbiCoder(coerceFunc) {
errors.checkNew(this, AbiCoder);
var _newTarget = this.constructor;
errors.checkNew(_newTarget, AbiCoder);
properties_1.defineReadOnly(this, "coerceFunc", coerceFunc || null);

@@ -89,11 +90,2 @@ }

};
/*
_sighashify(functionFragment: FunctionFragment): string {
return id(functionFragment.format());
}
_topicify(eventFragment: EventFragment): string {
return id(eventFragment.format());
}
*/
AbiCoder.prototype.encode = function (types, values) {

@@ -100,0 +92,0 @@ var _this = this;

@@ -29,3 +29,2 @@ import { BigNumber } from "@ethersproject/bignumber";

format(expanded?: boolean): string;
static isParamType(value: any): value is ParamType;
static from(value: string | JsonFragmentType | ParamType, allowIndexed?: boolean): ParamType;

@@ -40,3 +39,2 @@ static fromObject(value: JsonFragmentType | ParamType): ParamType;

constructor(constructorGuard: any, params: any);
static isFragment(value: any): value is Fragment;
format(expanded?: boolean): string;

@@ -49,3 +47,2 @@ static from(value: Fragment | JsonFragment | string): Fragment;

readonly anonymous: boolean;
static isEventFragment(value: any): value is EventFragment;
static from(value: EventFragment | JsonFragment | string): EventFragment;

@@ -59,3 +56,2 @@ static fromObject(value: JsonFragment | EventFragment): EventFragment;

gas?: BigNumber;
static isConstructorFragment(value: any): value is ConstructorFragment;
static from(value: ConstructorFragment | JsonFragment | string): ConstructorFragment;

@@ -68,3 +64,2 @@ static fromObject(value: ConstructorFragment | JsonFragment): ConstructorFragment;

outputs?: Array<ParamType>;
static isFunctionFragment(value: any): value is FunctionFragment;
static from(value: FunctionFragment | JsonFragment | string): FunctionFragment;

@@ -71,0 +66,0 @@ static fromObject(value: FunctionFragment | JsonFragment): FunctionFragment;

@@ -201,6 +201,5 @@ "use strict";

}
properties_1.setType(this, "ParamType");
}
// Format the parameter fragment
// - non-expanded: "tuple(uint256,address)"
// - non-expanded: "(uint256,address)"
// - expanded: "tuple(uint256 foo, addres bar) indexed baz"

@@ -215,6 +214,11 @@ ParamType.prototype.format = function (expanded) {

else {
result += this.type;
if (this.baseType === "tuple") {
if (expanded) {
result += this.type;
}
result += "(" + this.components.map(function (c) { return c.format(expanded); }).join(expanded ? ", " : ",") + ")";
}
else {
result += this.type;
}
}

@@ -231,5 +235,2 @@ if (expanded) {

};
ParamType.isParamType = function (value) {
return properties_1.isType(value, "ParamType");
};
ParamType.from = function (value, allowIndexed) {

@@ -242,3 +243,3 @@ if (typeof (value) === "string") {

ParamType.fromObject = function (value) {
if (ParamType.isParamType(value)) {
if (properties_1.isNamedInstance(ParamType, value)) {
return value;

@@ -277,7 +278,3 @@ }

populate(this, params);
properties_1.setType(this, "Fragment");
}
Fragment.isFragment = function (value) {
return properties_1.isType(value, "Fragment");
};
// @TOOD: move logic to sub-classes; make this abstract

@@ -310,3 +307,3 @@ Fragment.prototype.format = function (expanded) {

Fragment.fromObject = function (value) {
if (Fragment.isFragment(value)) {
if (properties_1.isNamedInstance(Fragment, value)) {
return value;

@@ -352,5 +349,2 @@ }

}
EventFragment.isEventFragment = function (value) {
return properties_1.isType(value, "Fragment") && value.type === "event";
};
EventFragment.from = function (value) {

@@ -363,3 +357,3 @@ if (typeof (value) === "string") {

EventFragment.fromObject = function (value) {
if (EventFragment.isEventFragment(value)) {
if (properties_1.isNamedInstance(EventFragment, value)) {
return value;

@@ -384,3 +378,3 @@ }

match[3].split(" ").forEach(function (modifier) {
switch (modifier) {
switch (modifier.trim()) {
case "anonymous":

@@ -426,3 +420,3 @@ anonymous = true;

value.split(" ").forEach(function (modifier) {
switch (modifier) {
switch (modifier.trim()) {
case "constant":

@@ -445,3 +439,3 @@ params.constant = true;

case "public":
//case "":
case "":
break;

@@ -458,5 +452,2 @@ default:

}
ConstructorFragment.isConstructorFragment = function (value) {
return Fragment.isFragment(value) && value.type === "constructor";
};
ConstructorFragment.from = function (value) {

@@ -469,3 +460,3 @@ if (typeof (value) === "string") {

ConstructorFragment.fromObject = function (value) {
if (ConstructorFragment.isConstructorFragment(value)) {
if (properties_1.isNamedInstance(ConstructorFragment, value)) {
return value;

@@ -505,5 +496,2 @@ }

}
FunctionFragment.isFunctionFragment = function (value) {
return Fragment.isFragment(value) && value.type === "function";
};
FunctionFragment.from = function (value) {

@@ -516,3 +504,3 @@ if (typeof (value) === "string") {

FunctionFragment.fromObject = function (value) {
if (FunctionFragment.isFunctionFragment(value)) {
if (properties_1.isNamedInstance(FunctionFragment, value)) {
return value;

@@ -519,0 +507,0 @@ }

@@ -43,4 +43,6 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber";

readonly deploy: ConstructorFragment;
readonly _abiCoder: AbiCoder;
constructor(fragments: string | Array<Fragment | JsonFragment | string>);
_getAbiCoder(): AbiCoder;
static getAbiCoder(): AbiCoder;
static getAddress(address: string): string;
_sighashify(functionFragment: FunctionFragment): string;

@@ -66,4 +68,2 @@ _topicify(eventFragment: EventFragment): string;

}): LogDescription;
static isInterface(value: any): value is Interface;
static isIndexed(value: any): value is Indexed;
}

@@ -23,2 +23,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var address_1 = require("@ethersproject/address");
var bignumber_1 = require("@ethersproject/bignumber");

@@ -62,7 +63,7 @@ var bytes_1 = require("@ethersproject/bytes");

exports.Result = Result;
var Type = "Interface";
var Interface = /** @class */ (function () {
function Interface(fragments) {
var _newTarget = this.constructor;
var _this = this;
errors.checkNew(this, Interface);
errors.checkNew(_newTarget, Interface);
var abi = [];

@@ -76,3 +77,3 @@ if (typeof (fragments) === "string") {

properties_1.defineReadOnly(this, "fragments", abi.map(function (fragment) {
if (fragments_1.Fragment.isFragment(fragment)) {
if (properties_1.isNamedInstance(fragments_1.Fragment, fragment)) {
return fragment;

@@ -82,2 +83,3 @@ }

}));
properties_1.defineReadOnly(this, "_abiCoder", _newTarget.getAbiCoder());
properties_1.defineReadOnly(this, "functions", {});

@@ -130,7 +132,9 @@ properties_1.defineReadOnly(this, "errors", {});

}
properties_1.setType(this, Type);
}
Interface.prototype._getAbiCoder = function () {
Interface.getAbiCoder = function () {
return abi_coder_1.defaultAbiCoder;
};
Interface.getAddress = function (address) {
return address_1.getAddress(address);
};
Interface.prototype._sighashify = function (functionFragment) {

@@ -176,4 +180,3 @@ return bytes_1.hexDataSlice(hash_1.id(functionFragment.format()), 0, 4);

Interface.prototype._encodeParams = function (params, values) {
var abiCoder = this._getAbiCoder();
return abiCoder.encode(params, values);
return this._abiCoder.encode(params, values);
};

@@ -193,3 +196,2 @@ Interface.prototype.encodeDeploy = function (values) {

Interface.prototype.decodeFunctionResult = function (functionFragment, data) {
var abiCoder = this._getAbiCoder();
if (typeof (functionFragment) === "string") {

@@ -201,6 +203,6 @@ functionFragment = this.getFunction(functionFragment);

var errorSignature = null;
switch (bytes.length % abiCoder._getWordSize()) {
switch (bytes.length % this._abiCoder._getWordSize()) {
case 0:
try {
return abiCoder.decode(functionFragment.outputs, bytes);
return this._abiCoder.decode(functionFragment.outputs, bytes);
}

@@ -212,3 +214,3 @@ catch (error) { }

errorSignature = "Error(string)";
reason = abiCoder.decode(["string"], bytes.slice(4));
reason = this._abiCoder.decode(["string"], bytes.slice(4));
}

@@ -245,2 +247,3 @@ break;

}
return;
}

@@ -262,3 +265,3 @@ if (value == null) {

if (param.type === "address") {
_this._getAbiCoder().encode(["address"], value);
_this._abiCoder.encode(["address"], [value]);
}

@@ -275,7 +278,6 @@ topics.push(bytes_1.hexZeroPad(bytes_1.hexlify(value), 32));

Interface.prototype.decodeEventLog = function (eventFragment, data, topics) {
var abiCoder = this._getAbiCoder();
if (typeof (eventFragment) === "string") {
eventFragment = this.getEvent(eventFragment);
}
if (topics != null && eventFragment.anonymous) {
if (topics != null && !eventFragment.anonymous) {
topics = topics.slice(1);

@@ -288,3 +290,3 @@ }

if (param.indexed) {
if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "tuple") {
if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") {
indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name }));

@@ -303,4 +305,4 @@ dynamic.push(true);

});
var resultIndexed = (topics != null) ? abiCoder.decode(indexed, bytes_1.concat(topics)) : null;
var resultNonIndexed = abiCoder.decode(nonIndexed, data);
var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, bytes_1.concat(topics)) : null;
var resultNonIndexed = this._abiCoder.decode(nonIndexed, data);
var result = [];

@@ -311,6 +313,6 @@ var nonIndexedIndex = 0, indexedIndex = 0;

if (resultIndexed == null) {
result[index] = new Indexed(null);
result[index] = new Indexed({ hash: null });
}
else if (dynamic[index]) {
result[index] = new Indexed(resultIndexed[indexedIndex++]);
result[index] = new Indexed({ hash: resultIndexed[indexedIndex++] });
}

@@ -329,3 +331,2 @@ else {

Interface.prototype.parseTransaction = function (tx) {
var abiCoder = this._getAbiCoder();
var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());

@@ -336,3 +337,3 @@ if (!fragment) {

return new TransactionDescription({
args: abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)),
functionFragment: fragment,

@@ -359,19 +360,2 @@ name: fragment.name,

};
/*
static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
if (Interface.isInterface(value)) {
return value;
}
if (typeof(value) === "string") {
return new Interface(JSON.parse(value));
}
return new Interface(value);
}
*/
Interface.isInterface = function (value) {
return properties_1.isType(value, "Interface");
};
Interface.isIndexed = function (value) {
return null; // @TODO
};
return Interface;

@@ -378,0 +362,0 @@ }());

{
"name": "@ethersproject/abi",
"version": "5.0.0-beta.122",
"version": "5.0.0-beta.123",
"description": "Error utility functions for ethers.",

@@ -29,3 +29,3 @@ "main": "index.js",

},
"tarballHash": "0x8a66428f7a2fcd52c5ff9838f57c1092260ba4e046e8512955cd07ed5debb36d"
"tarballHash": "0xc7508aa17d14bb03df9d5fdb308e3e3905c4625921326cd313a9aca0939f7637"
}
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