@ethersproject/abi
Advanced tools
Comparing version 5.3.1 to 5.4.0
@@ -1,2 +0,2 @@ | ||
export declare const version = "abi/5.3.1"; | ||
export declare const version = "abi/5.4.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "abi/5.3.1"; | ||
export const version = "abi/5.4.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -6,2 +6,3 @@ import { BigNumber } from "@ethersproject/bignumber"; | ||
readonly type?: string; | ||
readonly internalType?: any; | ||
readonly components?: ReadonlyArray<JsonFragmentType>; | ||
@@ -8,0 +9,0 @@ } |
@@ -23,2 +23,9 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; | ||
} | ||
export declare class ErrorDescription extends Description<ErrorDescription> { | ||
readonly errorFragment: ErrorFragment; | ||
readonly name: string; | ||
readonly args: Result; | ||
readonly signature: string; | ||
readonly sighash: string; | ||
} | ||
export declare class Indexed extends Description<Indexed> { | ||
@@ -55,3 +62,3 @@ readonly hash: string; | ||
getError(nameOrSignatureOrSighash: string): ErrorFragment; | ||
getSighash(functionFragment: FunctionFragment | string): string; | ||
getSighash(fragment: ErrorFragment | FunctionFragment | string): string; | ||
getEventTopic(eventFragment: EventFragment | string): string; | ||
@@ -61,2 +68,4 @@ _decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result; | ||
encodeDeploy(values?: ReadonlyArray<any>): string; | ||
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result; | ||
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string; | ||
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result; | ||
@@ -80,4 +89,5 @@ encodeFunctionData(functionFragment: FunctionFragment | string, values?: ReadonlyArray<any>): string; | ||
}): LogDescription; | ||
parseError(data: BytesLike): ErrorDescription; | ||
static isInterface(value: any): value is Interface; | ||
} | ||
//# sourceMappingURL=interface.d.ts.map |
@@ -19,2 +19,4 @@ "use strict"; | ||
} | ||
export class ErrorDescription extends Description { | ||
} | ||
export class Indexed extends Description { | ||
@@ -226,7 +228,17 @@ static isIndexed(value) { | ||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function | ||
getSighash(functionFragment) { | ||
if (typeof (functionFragment) === "string") { | ||
functionFragment = this.getFunction(functionFragment); | ||
getSighash(fragment) { | ||
if (typeof (fragment) === "string") { | ||
try { | ||
fragment = this.getFunction(fragment); | ||
} | ||
catch (error) { | ||
try { | ||
fragment = this.getError(fragment); | ||
} | ||
catch (_) { | ||
throw error; | ||
} | ||
} | ||
} | ||
return getStatic(this.constructor, "getSighash")(functionFragment); | ||
return getStatic(this.constructor, "getSighash")(fragment); | ||
} | ||
@@ -249,2 +261,21 @@ // Get the topic (the bytes32 hash) used by Solidity to identify an event | ||
} | ||
decodeErrorResult(fragment, data) { | ||
if (typeof (fragment) === "string") { | ||
fragment = this.getError(fragment); | ||
} | ||
const bytes = arrayify(data); | ||
if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) { | ||
logger.throwArgumentError(`data signature does not match error ${fragment.name}.`, "data", hexlify(bytes)); | ||
} | ||
return this._decodeParams(fragment.inputs, bytes.slice(4)); | ||
} | ||
encodeErrorResult(fragment, values) { | ||
if (typeof (fragment) === "string") { | ||
fragment = this.getError(fragment); | ||
} | ||
return hexlify(concat([ | ||
this.getSighash(fragment), | ||
this._encodeParams(fragment.inputs, values || []) | ||
])); | ||
} | ||
// Decode the data for a function call (e.g. tx.data) | ||
@@ -541,2 +572,16 @@ decodeFunctionData(functionFragment, data) { | ||
} | ||
parseError(data) { | ||
const hexData = hexlify(data); | ||
let fragment = this.getError(hexData.substring(0, 10).toLowerCase()); | ||
if (!fragment) { | ||
return null; | ||
} | ||
return new ErrorDescription({ | ||
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)), | ||
errorFragment: fragment, | ||
name: fragment.name, | ||
signature: fragment.format(), | ||
sighash: this.getSighash(fragment), | ||
}); | ||
} | ||
/* | ||
@@ -543,0 +588,0 @@ static from(value: Array<Fragment | string | JsonAbi> | string | Interface) { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "abi/5.3.1"; | ||
export declare const version = "abi/5.4.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "abi/5.3.1"; | ||
exports.version = "abi/5.4.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -6,2 +6,3 @@ import { BigNumber } from "@ethersproject/bignumber"; | ||
readonly type?: string; | ||
readonly internalType?: any; | ||
readonly components?: ReadonlyArray<JsonFragmentType>; | ||
@@ -8,0 +9,0 @@ } |
@@ -23,2 +23,9 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; | ||
} | ||
export declare class ErrorDescription extends Description<ErrorDescription> { | ||
readonly errorFragment: ErrorFragment; | ||
readonly name: string; | ||
readonly args: Result; | ||
readonly signature: string; | ||
readonly sighash: string; | ||
} | ||
export declare class Indexed extends Description<Indexed> { | ||
@@ -55,3 +62,3 @@ readonly hash: string; | ||
getError(nameOrSignatureOrSighash: string): ErrorFragment; | ||
getSighash(functionFragment: FunctionFragment | string): string; | ||
getSighash(fragment: ErrorFragment | FunctionFragment | string): string; | ||
getEventTopic(eventFragment: EventFragment | string): string; | ||
@@ -61,2 +68,4 @@ _decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result; | ||
encodeDeploy(values?: ReadonlyArray<any>): string; | ||
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result; | ||
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string; | ||
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result; | ||
@@ -80,4 +89,5 @@ encodeFunctionData(functionFragment: FunctionFragment | string, values?: ReadonlyArray<any>): string; | ||
}): LogDescription; | ||
parseError(data: BytesLike): ErrorDescription; | ||
static isInterface(value: any): value is Interface; | ||
} | ||
//# sourceMappingURL=interface.d.ts.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Interface = exports.Indexed = exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = void 0; | ||
exports.Interface = exports.Indexed = exports.ErrorDescription = exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = void 0; | ||
var address_1 = require("@ethersproject/address"); | ||
@@ -49,2 +49,10 @@ var bignumber_1 = require("@ethersproject/bignumber"); | ||
exports.TransactionDescription = TransactionDescription; | ||
var ErrorDescription = /** @class */ (function (_super) { | ||
__extends(ErrorDescription, _super); | ||
function ErrorDescription() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return ErrorDescription; | ||
}(properties_1.Description)); | ||
exports.ErrorDescription = ErrorDescription; | ||
var Indexed = /** @class */ (function (_super) { | ||
@@ -264,7 +272,17 @@ __extends(Indexed, _super); | ||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function | ||
Interface.prototype.getSighash = function (functionFragment) { | ||
if (typeof (functionFragment) === "string") { | ||
functionFragment = this.getFunction(functionFragment); | ||
Interface.prototype.getSighash = function (fragment) { | ||
if (typeof (fragment) === "string") { | ||
try { | ||
fragment = this.getFunction(fragment); | ||
} | ||
catch (error) { | ||
try { | ||
fragment = this.getError(fragment); | ||
} | ||
catch (_) { | ||
throw error; | ||
} | ||
} | ||
} | ||
return properties_1.getStatic(this.constructor, "getSighash")(functionFragment); | ||
return properties_1.getStatic(this.constructor, "getSighash")(fragment); | ||
}; | ||
@@ -287,2 +305,21 @@ // Get the topic (the bytes32 hash) used by Solidity to identify an event | ||
}; | ||
Interface.prototype.decodeErrorResult = function (fragment, data) { | ||
if (typeof (fragment) === "string") { | ||
fragment = this.getError(fragment); | ||
} | ||
var bytes = bytes_1.arrayify(data); | ||
if (bytes_1.hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) { | ||
logger.throwArgumentError("data signature does not match error " + fragment.name + ".", "data", bytes_1.hexlify(bytes)); | ||
} | ||
return this._decodeParams(fragment.inputs, bytes.slice(4)); | ||
}; | ||
Interface.prototype.encodeErrorResult = function (fragment, values) { | ||
if (typeof (fragment) === "string") { | ||
fragment = this.getError(fragment); | ||
} | ||
return bytes_1.hexlify(bytes_1.concat([ | ||
this.getSighash(fragment), | ||
this._encodeParams(fragment.inputs, values || []) | ||
])); | ||
}; | ||
// Decode the data for a function call (e.g. tx.data) | ||
@@ -584,2 +621,16 @@ Interface.prototype.decodeFunctionData = function (functionFragment, data) { | ||
}; | ||
Interface.prototype.parseError = function (data) { | ||
var hexData = bytes_1.hexlify(data); | ||
var fragment = this.getError(hexData.substring(0, 10).toLowerCase()); | ||
if (!fragment) { | ||
return null; | ||
} | ||
return new ErrorDescription({ | ||
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)), | ||
errorFragment: fragment, | ||
name: fragment.name, | ||
signature: fragment.format(), | ||
sighash: this.getSighash(fragment), | ||
}); | ||
}; | ||
/* | ||
@@ -586,0 +637,0 @@ static from(value: Array<Fragment | string | JsonAbi> | string | Interface) { |
{ | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"dependencies": { | ||
"@ethersproject/address": "^5.3.0", | ||
"@ethersproject/bignumber": "^5.3.0", | ||
"@ethersproject/bytes": "^5.3.0", | ||
"@ethersproject/constants": "^5.3.0", | ||
"@ethersproject/hash": "^5.3.0", | ||
"@ethersproject/keccak256": "^5.3.0", | ||
"@ethersproject/logger": "^5.3.0", | ||
"@ethersproject/properties": "^5.3.0", | ||
"@ethersproject/strings": "^5.3.0" | ||
"@ethersproject/address": "^5.4.0", | ||
"@ethersproject/bignumber": "^5.4.0", | ||
"@ethersproject/bytes": "^5.4.0", | ||
"@ethersproject/constants": "^5.4.0", | ||
"@ethersproject/hash": "^5.4.0", | ||
"@ethersproject/keccak256": "^5.4.0", | ||
"@ethersproject/logger": "^5.4.0", | ||
"@ethersproject/properties": "^5.4.0", | ||
"@ethersproject/strings": "^5.4.0" | ||
}, | ||
@@ -26,3 +26,3 @@ "description": "Utilities and Classes for parsing, formatting and managing Ethereum ABIs.", | ||
], | ||
"gitHead": "412bbe29394661192d7279094783401d300a1f81", | ||
"gitHead": "71b7547f10229f50d8b701611c5e6041b8ed966b", | ||
"keywords": [ | ||
@@ -48,5 +48,5 @@ "Ethereum", | ||
"sideEffects": false, | ||
"tarballHash": "0x2e024e140e942ced3e6c1540c7126c30520037c7fff8fb874791eb405ca401b1", | ||
"tarballHash": "0xc245561411575102d5bd84bff62e1db56c49c8dcd4e99be2a6dba67007a29d7e", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.3.1" | ||
"version": "5.4.0" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "abi/5.3.1"; | ||
export const version = "abi/5.4.0"; |
@@ -14,2 +14,3 @@ "use strict"; | ||
readonly type?: string; | ||
readonly internalType?: any; // @TODO: in v6 reduce type | ||
readonly components?: ReadonlyArray<JsonFragmentType>; | ||
@@ -34,3 +35,2 @@ } | ||
const _constructorGuard = { }; | ||
@@ -37,0 +37,0 @@ |
@@ -37,2 +37,10 @@ "use strict"; | ||
export class ErrorDescription extends Description<ErrorDescription> { | ||
readonly errorFragment: ErrorFragment; | ||
readonly name: string; | ||
readonly args: Result; | ||
readonly signature: string; | ||
readonly sighash: string; | ||
} | ||
export class Indexed extends Description<Indexed> { | ||
@@ -287,8 +295,16 @@ readonly hash: string; | ||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function | ||
getSighash(functionFragment: FunctionFragment | string): string { | ||
if (typeof(functionFragment) === "string") { | ||
functionFragment = this.getFunction(functionFragment); | ||
getSighash(fragment: ErrorFragment | FunctionFragment | string): string { | ||
if (typeof(fragment) === "string") { | ||
try { | ||
fragment = this.getFunction(fragment); | ||
} catch (error) { | ||
try { | ||
fragment = this.getError(<string>fragment); | ||
} catch (_) { | ||
throw error; | ||
} | ||
} | ||
} | ||
return getStatic<(f: FunctionFragment) => string>(this.constructor, "getSighash")(functionFragment); | ||
return getStatic<(f: ErrorFragment | FunctionFragment) => string>(this.constructor, "getSighash")(fragment); | ||
} | ||
@@ -318,2 +334,27 @@ | ||
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result { | ||
if (typeof(fragment) === "string") { | ||
fragment = this.getError(fragment); | ||
} | ||
const bytes = arrayify(data); | ||
if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) { | ||
logger.throwArgumentError(`data signature does not match error ${ fragment.name }.`, "data", hexlify(bytes)); | ||
} | ||
return this._decodeParams(fragment.inputs, bytes.slice(4)); | ||
} | ||
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string { | ||
if (typeof(fragment) === "string") { | ||
fragment = this.getError(fragment); | ||
} | ||
return hexlify(concat([ | ||
this.getSighash(fragment), | ||
this._encodeParams(fragment.inputs, values || [ ]) | ||
])); | ||
} | ||
// Decode the data for a function call (e.g. tx.data) | ||
@@ -633,3 +674,18 @@ decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result { | ||
parseError(data: BytesLike): ErrorDescription { | ||
const hexData = hexlify(data); | ||
let fragment = this.getError(hexData.substring(0, 10).toLowerCase()) | ||
if (!fragment) { return null; } | ||
return new ErrorDescription({ | ||
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)), | ||
errorFragment: fragment, | ||
name: fragment.name, | ||
signature: fragment.format(), | ||
sighash: this.getSighash(fragment), | ||
}); | ||
} | ||
/* | ||
@@ -636,0 +692,0 @@ static from(value: Array<Fragment | string | JsonAbi> | string | Interface) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
493854
7491
Updated@ethersproject/bytes@^5.4.0
Updated@ethersproject/hash@^5.4.0
Updated@ethersproject/logger@^5.4.0