Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dad3829c2e | ||
|
|
de4d683f6d | ||
|
|
ebe4cc90f5 | ||
|
|
35e3bf9d11 | ||
|
|
2d717dcef8 | ||
|
|
3316468e3e | ||
|
|
5144acf456 | ||
|
|
aadc5cd3d6 | ||
|
|
6e088099ad | ||
|
|
b6370f1360 | ||
|
|
26464c5425 | ||
|
|
37a9c77ab2 | ||
|
|
483d67f55c | ||
|
|
987bec87af | ||
|
|
a9cdbe1238 | ||
|
|
4e9abfdee4 | ||
|
|
3bb5fbf533 | ||
|
|
cadccc3060 | ||
|
|
65196097f6 | ||
|
|
8e22e0260e | ||
|
|
de7da421b3 | ||
|
|
a9f7957550 | ||
|
|
bd2d44eecf | ||
|
|
bd05aed070 |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -3,6 +3,28 @@ Changelog
|
||||
|
||||
This change log is managed by `admin/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.2.0 (2021-05-17 16:18)
|
||||
--------------------------------
|
||||
|
||||
- More aggresively check for mempool transactions sent from JsonRpcSigner. ([3316468](https://github.com/ethers-io/ethers.js/commit/3316468e3e0a5925cbecad85d894cc7d622394e7))
|
||||
- Added initial support for detecting replacement transactions. ([#1477](https://github.com/ethers-io/ethers.js/issues/1477); [987bec8](https://github.com/ethers-io/ethers.js/commit/987bec87afaa365f291290a0136cedbc2b1992f2), [5144acf](https://github.com/ethers-io/ethers.js/commit/5144acf456b51c95bbe3950bd37609abecc7ebc7))
|
||||
- Added convenience method for HD path derivation. ([aadc5cd](https://github.com/ethers-io/ethers.js/commit/aadc5cd3d65421e13ebd4e4d7c293ac3ece5e178))
|
||||
- Added mnemonicPath option to cli. ([6e08809](https://github.com/ethers-io/ethers.js/commit/6e088099adabd7c5d2e6710062ebc62b316ba0f1))
|
||||
- Added some popular Ethereum-compatible chains to networks. ([b6370f1](https://github.com/ethers-io/ethers.js/commit/b6370f13600a0c444342cbf16a83f010a929976b))
|
||||
- Added debug event to Web3Provider. ([26464c5](https://github.com/ethers-io/ethers.js/commit/26464c54258f98c321638475d6cf11595186e76d))
|
||||
- Abstracted EtherscanProivder to more easily fascilitate other Etherscan-supported chains. ([#1204](https://github.com/ethers-io/ethers.js/issues/1204), [#1473](https://github.com/ethers-io/ethers.js/issues/1473); [37a9c77](https://github.com/ethers-io/ethers.js/commit/37a9c77ab2acb7f75e1fc4cc918810d2fe59dd76))
|
||||
- Added Custom Contract Errors. ([#1498](https://github.com/ethers-io/ethers.js/issues/1498); [6519609](https://github.com/ethers-io/ethers.js/commit/65196097f6626401638d85cf19e3d628a6223d5d), [483d67f](https://github.com/ethers-io/ethers.js/commit/483d67f55c15a76bcd853e889a0e35815d9850f7))
|
||||
- More flexible FixedNumber input and output for strings with no decimals. ([#1019](https://github.com/ethers-io/ethers.js/issues/1019), [#1291](https://github.com/ethers-io/ethers.js/issues/1291), [#1463](https://github.com/ethers-io/ethers.js/issues/1463); [a9cdbe1](https://github.com/ethers-io/ethers.js/commit/a9cdbe1238c149a7167c6bb1a78f314805b52755))
|
||||
- Added hex support for bigint. ([#1472](https://github.com/ethers-io/ethers.js/issues/1472); [4e9abfd](https://github.com/ethers-io/ethers.js/commit/4e9abfdee478a8423da4d55feea8c1aae78a8eb4))
|
||||
- Added support for null entries in EventFilter. ([#1499](https://github.com/ethers-io/ethers.js/issues/1499); [3bb5fbf](https://github.com/ethers-io/ethers.js/commit/3bb5fbf533107e880377ecc14f30f314a5028e56))
|
||||
- Add bigint to allowed BigNumberish types. ([#1472](https://github.com/ethers-io/ethers.js/issues/1472); [cadccc3](https://github.com/ethers-io/ethers.js/commit/cadccc3060b88ab2ca64aeb302717d2d1c95a897))
|
||||
- Minor version bump. ([8e22e02](https://github.com/ethers-io/ethers.js/commit/8e22e0260eb70713c943c9e99ee8d66d71ebe56d))
|
||||
|
||||
ethers/v5.1.4 (2021-04-22 06:33)
|
||||
--------------------------------
|
||||
|
||||
- Do not throw on ABI "error" type. ([#1493](https://github.com/ethers-io/ethers.js/issues/1493), [#1497](https://github.com/ethers-io/ethers.js/issues/1497); [bd05aed](https://github.com/ethers-io/ethers.js/commit/bd05aed070ac9e1421a3e2bff2ceea150bedf9b7))
|
||||
|
||||
ethers/v5.1.3 (2021-04-19 21:01)
|
||||
--------------------------------
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Installing
|
||||
**browser (UMD)**
|
||||
|
||||
```
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js" type="text/javascript">
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.1.umd.min.js" type="text/javascript">
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -52,7 +52,7 @@ Installing
|
||||
|
||||
```
|
||||
<script type="module">
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.esm.min.js";
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.1.esm.min.js";
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ function codeContextify(context) {
|
||||
|
||||
module.exports = {
|
||||
title: "ethers",
|
||||
subtitle: "v5.0",
|
||||
subtitle: "v5.2",
|
||||
description: "Documentation for ethers, a complete, tiny and simple Ethereum library.",
|
||||
logo: "logo.svg",
|
||||
|
||||
@@ -204,7 +204,8 @@ module.exports = {
|
||||
"link-rtd": "https:/\/github.com/readthedocs/sphinx_rtd_theme",
|
||||
"link-semver": { name: "semver", url: "https:/\/semver.org" },
|
||||
"link-solidity": { name: "Solidity" , url: "https:/\/solidity.readthedocs.io/" },
|
||||
"link-solidity-events": "https:/\/docs.soliditylang.org/en/v0.8.1/abi-spec.html#events",
|
||||
"link-solidity-errors": "https:/\/docs.soliditylang.org/en/v0.8.4/abi-spec.html#errors",
|
||||
"link-solidity-events": "https:/\/docs.soliditylang.org/en/v0.8.4/abi-spec.html#events",
|
||||
"link-sphinx": { name: "Sphinx", url: "https:/\/www.sphinx-doc.org/" },
|
||||
|
||||
"link-alchemy-signup": "https:/\/dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d",
|
||||
@@ -246,7 +247,7 @@ module.exports = {
|
||||
|
||||
"link-ethersio": "https:/\/ethers.io/",
|
||||
"link-ethers-docs": "https:/\/docs.ethers.io/",
|
||||
"link-ethers-js": "https:/\/cdn.ethers.io/lib/ethers-5.0.esm.min.js",
|
||||
"link-ethers-js": "https:/\/cdn.ethers.io/lib/ethers-5.1.esm.min.js",
|
||||
"link-ethers-npm": "https:/\/www.npmjs.com/search?q=%40ethersproject%2F",
|
||||
"link-ethers-asm-grammar": "https:/\/github.com/ethers-io/ethers.js/blob/master/packages/asm/grammar.jison",
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ of uses.
|
||||
|
||||
_heading: MIT License
|
||||
|
||||
//Copyright © 2019 [Richard Moore](mailto:me@ricmoo.com).//
|
||||
//Copyright © 2019-2021 [Richard Moore](mailto:me@ricmoo.com).//
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
1116
package-lock.json
generated
1116
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@
|
||||
"diff": "4.0.1",
|
||||
"flatworm": "0.0.2-beta.5",
|
||||
"jison": "0.4.18",
|
||||
"karma": "5.2.3",
|
||||
"karma": "6.3.2",
|
||||
"karma-chrome-launcher": "3.1.0",
|
||||
"karma-mocha": "2.0.1",
|
||||
"libnpmpublish": "3.0.1",
|
||||
|
||||
2
packages/abi/lib.esm/_version.d.ts
vendored
2
packages/abi/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abi/5.1.1";
|
||||
export declare const version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abi/5.1.1";
|
||||
export const version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
7
packages/abi/lib.esm/fragments.d.ts
vendored
7
packages/abi/lib.esm/fragments.d.ts
vendored
@@ -74,4 +74,11 @@ export declare class FunctionFragment extends ConstructorFragment {
|
||||
static fromString(value: string): FunctionFragment;
|
||||
static isFunctionFragment(value: any): value is FunctionFragment;
|
||||
}
|
||||
export declare class ErrorFragment extends Fragment {
|
||||
format(format?: string): string;
|
||||
static from(value: ErrorFragment | JsonFragment | string): ErrorFragment;
|
||||
static fromObject(value: ErrorFragment | JsonFragment): ErrorFragment;
|
||||
static fromString(value: string): ErrorFragment;
|
||||
static isErrorFragment(value: any): value is ErrorFragment;
|
||||
}
|
||||
//# sourceMappingURL=fragments.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../src.ts/fragments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAOrD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAClD,QAAQ,CAAC,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AAK,EAAE,MAAM,GAAG,aAAa;IAgB/C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa;CAG7D"}
|
||||
@@ -354,6 +354,8 @@ export class Fragment {
|
||||
return EventFragment.fromObject(value);
|
||||
case "constructor":
|
||||
return ConstructorFragment.fromObject(value);
|
||||
case "error":
|
||||
return ErrorFragment.fromObject(value);
|
||||
case "fallback":
|
||||
case "receive":
|
||||
// @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
|
||||
@@ -375,6 +377,9 @@ export class Fragment {
|
||||
else if (value.split("(")[0].trim() === "constructor") {
|
||||
return ConstructorFragment.fromString(value.trim());
|
||||
}
|
||||
else if (value.split(" ")[0] === "error") {
|
||||
return ErrorFragment.fromString(value.substring(5).trim());
|
||||
}
|
||||
return logger.throwArgumentError("unsupported fragment", "value", value);
|
||||
}
|
||||
static isFragment(value) {
|
||||
@@ -730,10 +735,74 @@ export class FunctionFragment extends ConstructorFragment {
|
||||
return (value && value._isFragment && value.type === "function");
|
||||
}
|
||||
}
|
||||
//export class ErrorFragment extends Fragment {
|
||||
//}
|
||||
//export class StructFragment extends Fragment {
|
||||
//}
|
||||
function checkForbidden(fragment) {
|
||||
const sig = fragment.format();
|
||||
if (sig === "Error(string)" || sig === "Panic(uint256)") {
|
||||
logger.throwArgumentError(`cannot specify user defined ${sig} error`, "fragment", fragment);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
export class ErrorFragment extends Fragment {
|
||||
format(format) {
|
||||
if (!format) {
|
||||
format = FormatTypes.sighash;
|
||||
}
|
||||
if (!FormatTypes[format]) {
|
||||
logger.throwArgumentError("invalid format type", "format", format);
|
||||
}
|
||||
if (format === FormatTypes.json) {
|
||||
return JSON.stringify({
|
||||
type: "error",
|
||||
name: this.name,
|
||||
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
||||
});
|
||||
}
|
||||
let result = "";
|
||||
if (format !== FormatTypes.sighash) {
|
||||
result += "error ";
|
||||
}
|
||||
result += this.name + "(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") ";
|
||||
return result.trim();
|
||||
}
|
||||
static from(value) {
|
||||
if (typeof (value) === "string") {
|
||||
return ErrorFragment.fromString(value);
|
||||
}
|
||||
return ErrorFragment.fromObject(value);
|
||||
}
|
||||
static fromObject(value) {
|
||||
if (ErrorFragment.isErrorFragment(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.type !== "error") {
|
||||
logger.throwArgumentError("invalid error object", "value", value);
|
||||
}
|
||||
const params = {
|
||||
type: value.type,
|
||||
name: verifyIdentifier(value.name),
|
||||
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : [])
|
||||
};
|
||||
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
||||
}
|
||||
static fromString(value) {
|
||||
let params = { type: "error" };
|
||||
let parens = value.match(regexParen);
|
||||
if (!parens) {
|
||||
logger.throwArgumentError("invalid error signature", "value", value);
|
||||
}
|
||||
params.name = parens[1].trim();
|
||||
if (params.name) {
|
||||
verifyIdentifier(params.name);
|
||||
}
|
||||
params.inputs = parseParams(parens[2], false);
|
||||
return checkForbidden(ErrorFragment.fromObject(params));
|
||||
}
|
||||
static isErrorFragment(value) {
|
||||
return (value && value._isFragment && value.type === "error");
|
||||
}
|
||||
}
|
||||
function verifyType(type) {
|
||||
// These need to be transformed to their full description
|
||||
if (type.match(/^uint($|[^1-9])/)) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
packages/abi/lib.esm/index.d.ts
vendored
4
packages/abi/lib.esm/index.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription } from "./interface";
|
||||
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrJ,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpK,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, ParamType } from "./fragments";
|
||||
import { AbiCoder, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, TransactionDescription } from "./interface";
|
||||
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, checkResultErrors, LogDescription, TransactionDescription };
|
||||
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, checkResultErrors, LogDescription, TransactionDescription };
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAkC,SAAS,EAAE,MAAM,aAAa,CAAC;AACrJ,OAAO,EAAE,QAAQ,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAU,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAUP,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAkC,SAAS,EAAE,MAAM,aAAa,CAAC;AACpK,OAAO,EAAE,QAAQ,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAU,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAUP,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
7
packages/abi/lib.esm/interface.d.ts
vendored
7
packages/abi/lib.esm/interface.d.ts
vendored
@@ -3,7 +3,7 @@ import { BytesLike } from "@ethersproject/bytes";
|
||||
import { Description } from "@ethersproject/properties";
|
||||
import { AbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Result } from "./coders/abstract-coder";
|
||||
import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
export { checkResultErrors, Result };
|
||||
export declare class LogDescription extends Description<LogDescription> {
|
||||
readonly eventFragment: EventFragment;
|
||||
@@ -28,7 +28,7 @@ export declare class Indexed extends Description<Indexed> {
|
||||
export declare class Interface {
|
||||
readonly fragments: ReadonlyArray<Fragment>;
|
||||
readonly errors: {
|
||||
[name: string]: any;
|
||||
[name: string]: ErrorFragment;
|
||||
};
|
||||
readonly events: {
|
||||
[name: string]: EventFragment;
|
||||
@@ -46,10 +46,11 @@ export declare class Interface {
|
||||
format(format?: string): string | Array<string>;
|
||||
static getAbiCoder(): AbiCoder;
|
||||
static getAddress(address: string): string;
|
||||
static getSighash(functionFragment: FunctionFragment): string;
|
||||
static getSighash(fragment: ErrorFragment | FunctionFragment): string;
|
||||
static getEventTopic(eventFragment: EventFragment): string;
|
||||
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
|
||||
getEvent(nameOrSignatureOrTopic: string): EventFragment;
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment;
|
||||
getSighash(functionFragment: FunctionFragment | string): string;
|
||||
getEventTopic(eventFragment: EventFragment | string): string;
|
||||
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src.ts/interface.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAY,SAAS,EAA0D,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAkB,WAAW,EAAa,MAAM,2BAA2B,CAAC;AAEnF,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,a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,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IA0F9G,gBAAgB,CAAC,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,GAAG,sBAAsB;IAoBpF,QAAQ,CAAC,GAAG,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,cAAc;IAgCrE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS;CAGrD"}
|
||||
@@ -21,6 +21,10 @@ export class Indexed extends Description {
|
||||
return !!(value && value._isIndexed);
|
||||
}
|
||||
}
|
||||
const BuiltinErrors = {
|
||||
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
|
||||
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
|
||||
};
|
||||
function wrapAccessError(property, error) {
|
||||
const wrap = new Error(`deferred error during ABI decoding triggered accessing ${property}`);
|
||||
wrap.error = error;
|
||||
@@ -78,6 +82,9 @@ export class Interface {
|
||||
//checkNames(fragment, "input", fragment.inputs);
|
||||
bucket = this.events;
|
||||
break;
|
||||
case "error":
|
||||
bucket = this.errors;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -118,8 +125,8 @@ export class Interface {
|
||||
static getAddress(address) {
|
||||
return getAddress(address);
|
||||
}
|
||||
static getSighash(functionFragment) {
|
||||
return hexDataSlice(id(functionFragment.format()), 0, 4);
|
||||
static getSighash(fragment) {
|
||||
return hexDataSlice(id(fragment.format()), 0, 4);
|
||||
}
|
||||
static getEventTopic(eventFragment) {
|
||||
return id(eventFragment.format());
|
||||
@@ -183,6 +190,37 @@ export class Interface {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Find a function definition by any means necessary (unless it is ambiguous)
|
||||
getError(nameOrSignatureOrSighash) {
|
||||
if (isHexString(nameOrSignatureOrSighash)) {
|
||||
const getSighash = getStatic(this.constructor, "getSighash");
|
||||
for (const name in this.errors) {
|
||||
const error = this.errors[name];
|
||||
if (nameOrSignatureOrSighash === getSighash(error)) {
|
||||
return this.errors[name];
|
||||
}
|
||||
}
|
||||
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
||||
}
|
||||
// It is a bare name, look up the function (will return null if ambiguous)
|
||||
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
||||
const name = nameOrSignatureOrSighash.trim();
|
||||
const matching = Object.keys(this.errors).filter((f) => (f.split("(" /* fix:) */)[0] === name));
|
||||
if (matching.length === 0) {
|
||||
logger.throwArgumentError("no matching error", "name", name);
|
||||
}
|
||||
else if (matching.length > 1) {
|
||||
logger.throwArgumentError("multiple matching errors", "name", name);
|
||||
}
|
||||
return this.errors[matching[0]];
|
||||
}
|
||||
// Normlize the signature and lookup the function
|
||||
const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
||||
if (!result) {
|
||||
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
getSighash(functionFragment) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
@@ -234,6 +272,8 @@ export class Interface {
|
||||
}
|
||||
let bytes = arrayify(data);
|
||||
let reason = null;
|
||||
let errorArgs = null;
|
||||
let errorName = null;
|
||||
let errorSignature = null;
|
||||
switch (bytes.length % this._abiCoder._getWordSize()) {
|
||||
case 0:
|
||||
@@ -242,18 +282,34 @@ export class Interface {
|
||||
}
|
||||
catch (error) { }
|
||||
break;
|
||||
case 4:
|
||||
if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
||||
errorSignature = "Error(string)";
|
||||
reason = this._abiCoder.decode(["string"], bytes.slice(4))[0];
|
||||
case 4: {
|
||||
const selector = hexlify(bytes.slice(0, 4));
|
||||
const builtin = BuiltinErrors[selector];
|
||||
if (builtin) {
|
||||
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
||||
errorName = builtin.name;
|
||||
errorSignature = builtin.signature;
|
||||
if (builtin.reason) {
|
||||
reason = errorArgs[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
const error = this.getError(selector);
|
||||
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
||||
errorName = error.name;
|
||||
errorSignature = error.format();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return logger.throwError("call revert exception", Logger.errors.CALL_EXCEPTION, {
|
||||
method: functionFragment.format(),
|
||||
errorSignature: errorSignature,
|
||||
errorArgs: [reason],
|
||||
reason: reason
|
||||
errorArgs, errorName, errorSignature, reason
|
||||
});
|
||||
}
|
||||
// Encode the result for a function call (e.g. for eth_call)
|
||||
@@ -459,6 +515,8 @@ export class Interface {
|
||||
value: BigNumber.from(tx.value || "0"),
|
||||
});
|
||||
}
|
||||
// @TODO
|
||||
//parseCallResult(data: BytesLike): ??
|
||||
// Given an event log, find the matching event fragment (if any) and
|
||||
// determine all its properties and values
|
||||
parseLog(log) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
packages/abi/lib/_version.d.ts
vendored
2
packages/abi/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abi/5.1.1";
|
||||
export declare const version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "abi/5.1.1";
|
||||
exports.version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
7
packages/abi/lib/fragments.d.ts
vendored
7
packages/abi/lib/fragments.d.ts
vendored
@@ -74,4 +74,11 @@ export declare class FunctionFragment extends ConstructorFragment {
|
||||
static fromString(value: string): FunctionFragment;
|
||||
static isFunctionFragment(value: any): value is FunctionFragment;
|
||||
}
|
||||
export declare class ErrorFragment extends Fragment {
|
||||
format(format?: string): string;
|
||||
static from(value: ErrorFragment | JsonFragment | string): ErrorFragment;
|
||||
static fromObject(value: ErrorFragment | JsonFragment): ErrorFragment;
|
||||
static fromString(value: string): ErrorFragment;
|
||||
static isErrorFragment(value: any): value is ErrorFragment;
|
||||
}
|
||||
//# sourceMappingURL=fragments.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../src.ts/fragments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAOrD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAEnD,QAAQ,CAAC,GAAG,CAAC,EAAE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AK,IAAI,aAAa;CAG7D"}
|
||||
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
|
||||
exports.ErrorFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
|
||||
var bignumber_1 = require("@ethersproject/bignumber");
|
||||
var properties_1 = require("@ethersproject/properties");
|
||||
var logger_1 = require("@ethersproject/logger");
|
||||
@@ -373,6 +373,8 @@ var Fragment = /** @class */ (function () {
|
||||
return EventFragment.fromObject(value);
|
||||
case "constructor":
|
||||
return ConstructorFragment.fromObject(value);
|
||||
case "error":
|
||||
return ErrorFragment.fromObject(value);
|
||||
case "fallback":
|
||||
case "receive":
|
||||
// @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
|
||||
@@ -394,6 +396,9 @@ var Fragment = /** @class */ (function () {
|
||||
else if (value.split("(")[0].trim() === "constructor") {
|
||||
return ConstructorFragment.fromString(value.trim());
|
||||
}
|
||||
else if (value.split(" ")[0] === "error") {
|
||||
return ErrorFragment.fromString(value.substring(5).trim());
|
||||
}
|
||||
return logger.throwArgumentError("unsupported fragment", "value", value);
|
||||
};
|
||||
Fragment.isFragment = function (value) {
|
||||
@@ -769,10 +774,80 @@ var FunctionFragment = /** @class */ (function (_super) {
|
||||
return FunctionFragment;
|
||||
}(ConstructorFragment));
|
||||
exports.FunctionFragment = FunctionFragment;
|
||||
//export class ErrorFragment extends Fragment {
|
||||
//}
|
||||
//export class StructFragment extends Fragment {
|
||||
//}
|
||||
function checkForbidden(fragment) {
|
||||
var sig = fragment.format();
|
||||
if (sig === "Error(string)" || sig === "Panic(uint256)") {
|
||||
logger.throwArgumentError("cannot specify user defined " + sig + " error", "fragment", fragment);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
var ErrorFragment = /** @class */ (function (_super) {
|
||||
__extends(ErrorFragment, _super);
|
||||
function ErrorFragment() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ErrorFragment.prototype.format = function (format) {
|
||||
if (!format) {
|
||||
format = exports.FormatTypes.sighash;
|
||||
}
|
||||
if (!exports.FormatTypes[format]) {
|
||||
logger.throwArgumentError("invalid format type", "format", format);
|
||||
}
|
||||
if (format === exports.FormatTypes.json) {
|
||||
return JSON.stringify({
|
||||
type: "error",
|
||||
name: this.name,
|
||||
inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
|
||||
});
|
||||
}
|
||||
var result = "";
|
||||
if (format !== exports.FormatTypes.sighash) {
|
||||
result += "error ";
|
||||
}
|
||||
result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
|
||||
return result.trim();
|
||||
};
|
||||
ErrorFragment.from = function (value) {
|
||||
if (typeof (value) === "string") {
|
||||
return ErrorFragment.fromString(value);
|
||||
}
|
||||
return ErrorFragment.fromObject(value);
|
||||
};
|
||||
ErrorFragment.fromObject = function (value) {
|
||||
if (ErrorFragment.isErrorFragment(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.type !== "error") {
|
||||
logger.throwArgumentError("invalid error object", "value", value);
|
||||
}
|
||||
var params = {
|
||||
type: value.type,
|
||||
name: verifyIdentifier(value.name),
|
||||
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : [])
|
||||
};
|
||||
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
||||
};
|
||||
ErrorFragment.fromString = function (value) {
|
||||
var params = { type: "error" };
|
||||
var parens = value.match(regexParen);
|
||||
if (!parens) {
|
||||
logger.throwArgumentError("invalid error signature", "value", value);
|
||||
}
|
||||
params.name = parens[1].trim();
|
||||
if (params.name) {
|
||||
verifyIdentifier(params.name);
|
||||
}
|
||||
params.inputs = parseParams(parens[2], false);
|
||||
return checkForbidden(ErrorFragment.fromObject(params));
|
||||
};
|
||||
ErrorFragment.isErrorFragment = function (value) {
|
||||
return (value && value._isFragment && value.type === "error");
|
||||
};
|
||||
return ErrorFragment;
|
||||
}(Fragment));
|
||||
exports.ErrorFragment = ErrorFragment;
|
||||
function verifyType(type) {
|
||||
// These need to be transformed to their full description
|
||||
if (type.match(/^uint($|[^1-9])/)) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
packages/abi/lib/index.d.ts
vendored
4
packages/abi/lib/index.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription } from "./interface";
|
||||
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrJ,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpK,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
@@ -1,8 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = exports.Indexed = exports.Interface = exports.defaultAbiCoder = exports.AbiCoder = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ConstructorFragment = void 0;
|
||||
exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = exports.Indexed = exports.Interface = exports.defaultAbiCoder = exports.AbiCoder = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = void 0;
|
||||
var fragments_1 = require("./fragments");
|
||||
Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return fragments_1.ConstructorFragment; } });
|
||||
Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return fragments_1.ErrorFragment; } });
|
||||
Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return fragments_1.EventFragment; } });
|
||||
Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function () { return fragments_1.FormatTypes; } });
|
||||
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragments_1.Fragment; } });
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAAqJ;AAKjJ,oGALK,+BAAmB,OAKL;AACnB,8FAN0B,yBAAa,OAM1B;AAIb,4FAVyC,uBAAW,OAUzC;AAHX,yFAPsD,oBAAQ,OAOtD;AACR,iGARgE,4BAAgB,OAQhE;AAChB,0FATkH,qBAAS,OASlH;AARb,yCAAoE;AAWhE,yFAXK,oBAAQ,OAWL;AACR,gGAZ2B,2BAAe,OAY3B;AAXnB,yCAAoH;AAwBhH,kGAxBK,6BAAiB,OAwBL;AAVjB,wFAdwB,mBAAO,OAcxB;AADP,0FAbiC,qBAAS,OAajC;AAaT,+FA1B4C,0BAAc,OA0B5C;AACd,uGA3BoE,kCAAsB,OA2BpE"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAAoK;AAKhK,oGALK,+BAAmB,OAKL;AACnB,8FAN0B,yBAAa,OAM1B;AACb,8FAPyC,yBAAa,OAOzC;AAIb,4FAXwD,uBAAW,OAWxD;AAHX,yFARqE,oBAAQ,OAQrE;AACR,iGAT+E,4BAAgB,OAS/E;AAChB,0FAViI,qBAAS,OAUjI;AATb,yCAAoE;AAYhE,yFAZK,oBAAQ,OAYL;AACR,gGAb2B,2BAAe,OAa3B;AAZnB,yCAAoH;AAyBhH,kGAzBK,6BAAiB,OAyBL;AAVjB,wFAfwB,mBAAO,OAexB;AADP,0FAdiC,qBAAS,OAcjC;AAaT,+FA3B4C,0BAAc,OA2B5C;AACd,uGA5BoE,kCAAsB,OA4BpE"}
|
||||
7
packages/abi/lib/interface.d.ts
vendored
7
packages/abi/lib/interface.d.ts
vendored
@@ -3,7 +3,7 @@ import { BytesLike } from "@ethersproject/bytes";
|
||||
import { Description } from "@ethersproject/properties";
|
||||
import { AbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Result } from "./coders/abstract-coder";
|
||||
import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
export { checkResultErrors, Result };
|
||||
export declare class LogDescription extends Description<LogDescription> {
|
||||
readonly eventFragment: EventFragment;
|
||||
@@ -28,7 +28,7 @@ export declare class Indexed extends Description<Indexed> {
|
||||
export declare class Interface {
|
||||
readonly fragments: ReadonlyArray<Fragment>;
|
||||
readonly errors: {
|
||||
[name: string]: any;
|
||||
[name: string]: ErrorFragment;
|
||||
};
|
||||
readonly events: {
|
||||
[name: string]: EventFragment;
|
||||
@@ -46,10 +46,11 @@ export declare class Interface {
|
||||
format(format?: string): string | Array<string>;
|
||||
static getAbiCoder(): AbiCoder;
|
||||
static getAddress(address: string): string;
|
||||
static getSighash(functionFragment: FunctionFragment): string;
|
||||
static getSighash(fragment: ErrorFragment | FunctionFragment): string;
|
||||
static getEventTopic(eventFragment: EventFragment): string;
|
||||
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
|
||||
getEvent(nameOrSignatureOrTopic: string): EventFragment;
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment;
|
||||
getSighash(functionFragment: FunctionFragment | string): string;
|
||||
getEventTopic(eventFragment: EventFragment | string): string;
|
||||
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src.ts/interface.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAY,SAAS,EAA0D,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAkB,WAAW,EAAa,MAAM,2BAA2B,CAAC;AAEnF,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAe,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMnI,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW,CAAC,cAAc,CAAC;IAC3D,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,sBAAuB,SAAQ,WAAW,CAAC,sBAAsB,CAAC;IAC3E,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,C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ors = {
|
||||
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
|
||||
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
|
||||
};
|
||||
function wrapAccessError(property, error) {
|
||||
var wrap = new Error("deferred error during ABI decoding triggered accessing " + property);
|
||||
wrap.error = error;
|
||||
@@ -115,6 +119,9 @@ var Interface = /** @class */ (function () {
|
||||
//checkNames(fragment, "input", fragment.inputs);
|
||||
bucket = _this.events;
|
||||
break;
|
||||
case "error":
|
||||
bucket = _this.errors;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -155,8 +162,8 @@ var Interface = /** @class */ (function () {
|
||||
Interface.getAddress = function (address) {
|
||||
return address_1.getAddress(address);
|
||||
};
|
||||
Interface.getSighash = function (functionFragment) {
|
||||
return bytes_1.hexDataSlice(hash_1.id(functionFragment.format()), 0, 4);
|
||||
Interface.getSighash = function (fragment) {
|
||||
return bytes_1.hexDataSlice(hash_1.id(fragment.format()), 0, 4);
|
||||
};
|
||||
Interface.getEventTopic = function (eventFragment) {
|
||||
return hash_1.id(eventFragment.format());
|
||||
@@ -220,6 +227,37 @@ var Interface = /** @class */ (function () {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
// Find a function definition by any means necessary (unless it is ambiguous)
|
||||
Interface.prototype.getError = function (nameOrSignatureOrSighash) {
|
||||
if (bytes_1.isHexString(nameOrSignatureOrSighash)) {
|
||||
var getSighash = properties_1.getStatic(this.constructor, "getSighash");
|
||||
for (var name_5 in this.errors) {
|
||||
var error = this.errors[name_5];
|
||||
if (nameOrSignatureOrSighash === getSighash(error)) {
|
||||
return this.errors[name_5];
|
||||
}
|
||||
}
|
||||
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
||||
}
|
||||
// It is a bare name, look up the function (will return null if ambiguous)
|
||||
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
||||
var name_6 = nameOrSignatureOrSighash.trim();
|
||||
var matching = Object.keys(this.errors).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_6); });
|
||||
if (matching.length === 0) {
|
||||
logger.throwArgumentError("no matching error", "name", name_6);
|
||||
}
|
||||
else if (matching.length > 1) {
|
||||
logger.throwArgumentError("multiple matching errors", "name", name_6);
|
||||
}
|
||||
return this.errors[matching[0]];
|
||||
}
|
||||
// Normlize the signature and lookup the function
|
||||
var result = this.errors[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
||||
if (!result) {
|
||||
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
Interface.prototype.getSighash = function (functionFragment) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
@@ -271,6 +309,8 @@ var Interface = /** @class */ (function () {
|
||||
}
|
||||
var bytes = bytes_1.arrayify(data);
|
||||
var reason = null;
|
||||
var errorArgs = null;
|
||||
var errorName = null;
|
||||
var errorSignature = null;
|
||||
switch (bytes.length % this._abiCoder._getWordSize()) {
|
||||
case 0:
|
||||
@@ -279,18 +319,34 @@ var Interface = /** @class */ (function () {
|
||||
}
|
||||
catch (error) { }
|
||||
break;
|
||||
case 4:
|
||||
if (bytes_1.hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
||||
errorSignature = "Error(string)";
|
||||
reason = this._abiCoder.decode(["string"], bytes.slice(4))[0];
|
||||
case 4: {
|
||||
var selector = bytes_1.hexlify(bytes.slice(0, 4));
|
||||
var builtin = BuiltinErrors[selector];
|
||||
if (builtin) {
|
||||
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
||||
errorName = builtin.name;
|
||||
errorSignature = builtin.signature;
|
||||
if (builtin.reason) {
|
||||
reason = errorArgs[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
var error = this.getError(selector);
|
||||
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
||||
errorName = error.name;
|
||||
errorSignature = error.format();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return logger.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, {
|
||||
method: functionFragment.format(),
|
||||
errorSignature: errorSignature,
|
||||
errorArgs: [reason],
|
||||
reason: reason
|
||||
errorArgs: errorArgs, errorName: errorName, errorSignature: errorSignature, reason: reason
|
||||
});
|
||||
};
|
||||
// Encode the result for a function call (e.g. for eth_call)
|
||||
@@ -501,6 +557,8 @@ var Interface = /** @class */ (function () {
|
||||
value: bignumber_1.BigNumber.from(tx.value || "0"),
|
||||
});
|
||||
};
|
||||
// @TODO
|
||||
//parseCallResult(data: BytesLike): ??
|
||||
// Given an event log, find the matching event fragment (if any) and
|
||||
// determine all its properties and values
|
||||
Interface.prototype.parseLog = function (log) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/address": "^5.1.0",
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/constants": "^5.1.0",
|
||||
"@ethersproject/hash": "^5.1.0",
|
||||
"@ethersproject/keccak256": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0",
|
||||
"@ethersproject/strings": "^5.1.0"
|
||||
"@ethersproject/address": "^5.2.0",
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/constants": "^5.2.0",
|
||||
"@ethersproject/hash": "^5.2.0",
|
||||
"@ethersproject/keccak256": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0",
|
||||
"@ethersproject/strings": "^5.2.0"
|
||||
},
|
||||
"description": "Utilities and Classes for parsing, formatting and managing Ethereum ABIs.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -43,7 +43,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x070ed6a837106528848f7ee9e3b1289bf4619f37d865653cbf2e6c839288b49b",
|
||||
"tarballHash": "0xe6a078fafe9b871044b84c2f528321d6f35a175220d2d0cd29b5f7b75b7c3752",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.1"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abi/5.1.1";
|
||||
export const version = "abi/5.2.0";
|
||||
|
||||
@@ -445,6 +445,8 @@ export abstract class Fragment {
|
||||
return EventFragment.fromObject(value);
|
||||
case "constructor":
|
||||
return ConstructorFragment.fromObject(value);
|
||||
case "error":
|
||||
return ErrorFragment.fromObject(value);
|
||||
case "fallback":
|
||||
case "receive":
|
||||
// @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
|
||||
@@ -466,6 +468,8 @@ export abstract class Fragment {
|
||||
return FunctionFragment.fromString(value.substring(8).trim());
|
||||
} else if (value.split("(")[0].trim() === "constructor") {
|
||||
return ConstructorFragment.fromString(value.trim());
|
||||
} else if (value.split(" ")[0] === "error") {
|
||||
return ErrorFragment.fromString(value.substring(5).trim());
|
||||
}
|
||||
|
||||
return logger.throwArgumentError("unsupported fragment", "value", value);
|
||||
@@ -927,12 +931,90 @@ export class FunctionFragment extends ConstructorFragment {
|
||||
}
|
||||
}
|
||||
|
||||
//export class ErrorFragment extends Fragment {
|
||||
//}
|
||||
|
||||
//export class StructFragment extends Fragment {
|
||||
//}
|
||||
|
||||
function checkForbidden(fragment: ErrorFragment): ErrorFragment {
|
||||
const sig = fragment.format();
|
||||
if (sig === "Error(string)" || sig === "Panic(uint256)") {
|
||||
logger.throwArgumentError(`cannot specify user defined ${ sig } error`, "fragment", fragment);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
|
||||
export class ErrorFragment extends Fragment {
|
||||
|
||||
format(format?: string): string {
|
||||
if (!format) { format = FormatTypes.sighash; }
|
||||
if (!FormatTypes[format]) {
|
||||
logger.throwArgumentError("invalid format type", "format", format);
|
||||
}
|
||||
|
||||
if (format === FormatTypes.json) {
|
||||
return JSON.stringify({
|
||||
type: "error",
|
||||
name: this.name,
|
||||
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
||||
});
|
||||
}
|
||||
|
||||
let result = "";
|
||||
|
||||
if (format !== FormatTypes.sighash) {
|
||||
result += "error ";
|
||||
}
|
||||
|
||||
result += this.name + "(" + this.inputs.map(
|
||||
(input) => input.format(format)
|
||||
).join((format === FormatTypes.full) ? ", ": ",") + ") ";
|
||||
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
static from(value: ErrorFragment | JsonFragment | string): ErrorFragment {
|
||||
if (typeof(value) === "string") {
|
||||
return ErrorFragment.fromString(value);
|
||||
}
|
||||
return ErrorFragment.fromObject(value);
|
||||
}
|
||||
|
||||
static fromObject(value: ErrorFragment | JsonFragment): ErrorFragment {
|
||||
if (ErrorFragment.isErrorFragment(value)) { return value; }
|
||||
|
||||
if (value.type !== "error") {
|
||||
logger.throwArgumentError("invalid error object", "value", value);
|
||||
}
|
||||
|
||||
const params: TypeCheck<_Fragment> = {
|
||||
type: value.type,
|
||||
name: verifyIdentifier(value.name),
|
||||
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject): [])
|
||||
};
|
||||
|
||||
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
||||
}
|
||||
|
||||
static fromString(value: string): ErrorFragment {
|
||||
let params: any = { type: "error" };
|
||||
|
||||
let parens = value.match(regexParen);
|
||||
if (!parens) {
|
||||
logger.throwArgumentError("invalid error signature", "value", value);
|
||||
}
|
||||
|
||||
params.name = parens[1].trim();
|
||||
if (params.name) { verifyIdentifier(params.name); }
|
||||
|
||||
params.inputs = parseParams(parens[2], false);
|
||||
|
||||
return checkForbidden(ErrorFragment.fromObject(params));
|
||||
}
|
||||
|
||||
static isErrorFragment(value: any): value is ErrorFragment {
|
||||
return (value && value._isFragment && value.type === "error");
|
||||
}
|
||||
}
|
||||
|
||||
function verifyType(type: string): string {
|
||||
|
||||
// These need to be transformed to their full description
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription } from "./interface";
|
||||
|
||||
export {
|
||||
ConstructorFragment,
|
||||
ErrorFragment,
|
||||
EventFragment,
|
||||
Fragment,
|
||||
FunctionFragment,
|
||||
|
||||
@@ -9,7 +9,7 @@ import { defineReadOnly, Description, getStatic } from "@ethersproject/propertie
|
||||
|
||||
import { AbiCoder, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Result } from "./coders/abstract-coder";
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
@@ -43,6 +43,11 @@ export class Indexed extends Description<Indexed> {
|
||||
}
|
||||
}
|
||||
|
||||
const BuiltinErrors: Record<string, { signature: string, inputs: Array<string>, name: string, reason?: boolean }> = {
|
||||
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: [ "string" ], reason: true },
|
||||
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: [ "uint256" ] }
|
||||
}
|
||||
|
||||
function wrapAccessError(property: string, error: Error): Error {
|
||||
const wrap = new Error(`deferred error during ABI decoding triggered accessing ${ property }`);
|
||||
(<any>wrap).error = error;
|
||||
@@ -65,7 +70,7 @@ function checkNames(fragment: Fragment, type: "input" | "output", params: Array<
|
||||
export class Interface {
|
||||
readonly fragments: ReadonlyArray<Fragment>;
|
||||
|
||||
readonly errors: { [ name: string ]: any };
|
||||
readonly errors: { [ name: string ]: ErrorFragment };
|
||||
readonly events: { [ name: string ]: EventFragment };
|
||||
readonly functions: { [ name: string ]: FunctionFragment };
|
||||
readonly structs: { [ name: string ]: any };
|
||||
@@ -118,6 +123,9 @@ export class Interface {
|
||||
//checkNames(fragment, "input", fragment.inputs);
|
||||
bucket = this.events;
|
||||
break;
|
||||
case "error":
|
||||
bucket = this.errors;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -167,8 +175,8 @@ export class Interface {
|
||||
return getAddress(address);
|
||||
}
|
||||
|
||||
static getSighash(functionFragment: FunctionFragment): string {
|
||||
return hexDataSlice(id(functionFragment.format()), 0, 4);
|
||||
static getSighash(fragment: ErrorFragment | FunctionFragment): string {
|
||||
return hexDataSlice(id(fragment.format()), 0, 4);
|
||||
}
|
||||
|
||||
static getEventTopic(eventFragment: EventFragment): string {
|
||||
@@ -240,6 +248,40 @@ export class Interface {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find a function definition by any means necessary (unless it is ambiguous)
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment {
|
||||
if (isHexString(nameOrSignatureOrSighash)) {
|
||||
const getSighash = getStatic<(f: ErrorFragment | FunctionFragment) => string>(this.constructor, "getSighash");
|
||||
for (const name in this.errors) {
|
||||
const error = this.errors[name];
|
||||
if (nameOrSignatureOrSighash === getSighash(error)) {
|
||||
return this.errors[name];
|
||||
}
|
||||
}
|
||||
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
||||
}
|
||||
|
||||
// It is a bare name, look up the function (will return null if ambiguous)
|
||||
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
||||
const name = nameOrSignatureOrSighash.trim();
|
||||
const matching = Object.keys(this.errors).filter((f) => (f.split("("/* fix:) */)[0] === name));
|
||||
if (matching.length === 0) {
|
||||
logger.throwArgumentError("no matching error", "name", name);
|
||||
} else if (matching.length > 1) {
|
||||
logger.throwArgumentError("multiple matching errors", "name", name);
|
||||
}
|
||||
|
||||
return this.errors[matching[0]];
|
||||
}
|
||||
|
||||
// Normlize the signature and lookup the function
|
||||
const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
||||
if (!result) {
|
||||
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
getSighash(functionFragment: FunctionFragment | string): string {
|
||||
if (typeof(functionFragment) === "string") {
|
||||
@@ -304,9 +346,11 @@ export class Interface {
|
||||
functionFragment = this.getFunction(functionFragment);
|
||||
}
|
||||
|
||||
let bytes = arrayify(data);
|
||||
let bytes = arrayify(data);
|
||||
|
||||
let reason: string = null;
|
||||
let errorArgs: Result = null;
|
||||
let errorName: string = null;
|
||||
let errorSignature: string = null;
|
||||
switch (bytes.length % this._abiCoder._getWordSize()) {
|
||||
case 0:
|
||||
@@ -315,19 +359,31 @@ export class Interface {
|
||||
} catch (error) { }
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
||||
errorSignature = "Error(string)";
|
||||
reason = this._abiCoder.decode([ "string" ], bytes.slice(4))[0];
|
||||
case 4: {
|
||||
const selector = hexlify(bytes.slice(0, 4));
|
||||
const builtin = BuiltinErrors[selector];
|
||||
if (builtin) {
|
||||
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
||||
errorName = builtin.name;
|
||||
errorSignature = builtin.signature;
|
||||
if (builtin.reason) { reason = errorArgs[0]; }
|
||||
} else {
|
||||
try {
|
||||
const error = this.getError(selector);
|
||||
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
||||
errorName = error.name;
|
||||
errorSignature = error.format();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return logger.throwError("call revert exception", Logger.errors.CALL_EXCEPTION, {
|
||||
method: functionFragment.format(),
|
||||
errorSignature: errorSignature,
|
||||
errorArgs: [ reason ],
|
||||
reason: reason
|
||||
errorArgs, errorName, errorSignature, reason
|
||||
});
|
||||
}
|
||||
|
||||
@@ -547,6 +603,9 @@ export class Interface {
|
||||
});
|
||||
}
|
||||
|
||||
// @TODO
|
||||
//parseCallResult(data: BytesLike): ??
|
||||
|
||||
// Given an event log, find the matching event fragment (if any) and
|
||||
// determine all its properties and values
|
||||
parseLog(log: { topics: Array<string>, data: string}): LogDescription {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-provider/5.1.0";
|
||||
export declare const version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abstract-provider/5.1.0";
|
||||
export const version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -75,7 +75,7 @@ export interface TransactionReceipt {
|
||||
}
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string>>;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
}
|
||||
export interface Filter extends EventFilter {
|
||||
fromBlock?: BlockTag;
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
packages/abstract-provider/lib/_version.d.ts
vendored
2
packages/abstract-provider/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-provider/5.1.0";
|
||||
export declare const version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "abstract-provider/5.1.0";
|
||||
exports.version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/abstract-provider/lib/index.d.ts
vendored
2
packages/abstract-provider/lib/index.d.ts
vendored
@@ -75,7 +75,7 @@ export interface TransactionReceipt {
|
||||
}
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string>>;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
}
|
||||
export interface Filter extends EventFilter {
|
||||
fromBlock?: BlockTag;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/networks": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0",
|
||||
"@ethersproject/transactions": "^5.1.0",
|
||||
"@ethersproject/web": "^5.1.0"
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/networks": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0",
|
||||
"@ethersproject/transactions": "^5.2.0",
|
||||
"@ethersproject/web": "^5.2.0"
|
||||
},
|
||||
"description": "An Abstract Class for describing an Ethereum Provider for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -41,7 +41,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x9a2ee9005c813b52689b7d87a01f6ce29010ef3f899c5fc500e6ae3ea0f03ea2",
|
||||
"tarballHash": "0x7b9f83b84726a18491bd1665ff4d856364aba22521e78572353d1d9995ac1c4e",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abstract-provider/5.1.0";
|
||||
export const version = "abstract-provider/5.2.0";
|
||||
|
||||
@@ -114,7 +114,7 @@ export interface TransactionReceipt {
|
||||
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string>>;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
}
|
||||
|
||||
export interface Filter extends EventFilter {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-signer/5.1.0";
|
||||
export declare const version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abstract-signer/5.1.0";
|
||||
export const version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/abstract-signer/lib/_version.d.ts
vendored
2
packages/abstract-signer/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-signer/5.1.0";
|
||||
export declare const version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "abstract-signer/5.1.0";
|
||||
exports.version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/abstract-provider": "^5.1.0",
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0"
|
||||
"@ethersproject/abstract-provider": "^5.2.0",
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0"
|
||||
},
|
||||
"description": "An Abstract Class for desribing an Ethereum Signer for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -39,7 +39,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x56d53f21cca4bb8b1b1f7c25edf66e7633dbe56c90164546110f4702c6d0650e",
|
||||
"tarballHash": "0x6a009bacd601b395a4cf53b290b3f3eb6e624fdaabf4b24940ecb1cf0836d096",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abstract-signer/5.1.0";
|
||||
export const version = "abstract-signer/5.2.0";
|
||||
|
||||
2
packages/address/lib.esm/_version.d.ts
vendored
2
packages/address/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "address/5.1.0";
|
||||
export declare const version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "address/5.1.0";
|
||||
export const version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/address/lib/_version.d.ts
vendored
2
packages/address/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "address/5.1.0";
|
||||
export declare const version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "address/5.1.0";
|
||||
exports.version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/keccak256": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/rlp": "^5.1.0"
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/keccak256": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/rlp": "^5.2.0"
|
||||
},
|
||||
"description": "Utilities for handling Ethereum Addresses for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -39,7 +39,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0xaa6a2ab1b7c3cad7bd17a3b20fc759b79d7ea911f01963a082af5385c46a14c6",
|
||||
"tarballHash": "0x6396accbb490919f6a66877226d5e82ed911aa84c4041464b0d1e0237da69a2e",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "address/5.1.0";
|
||||
export const version = "address/5.2.0";
|
||||
|
||||
2
packages/asm/lib.esm/_version.d.ts
vendored
2
packages/asm/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "asm/5.1.0";
|
||||
export declare const version = "asm/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "asm/5.1.0";
|
||||
export const version = "asm/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/asm/lib/_version.d.ts
vendored
2
packages/asm/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "asm/5.1.0";
|
||||
export declare const version = "asm/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "asm/5.1.0";
|
||||
exports.version = "asm/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"ethers": "^5.1.0"
|
||||
"ethers": "^5.2.0"
|
||||
},
|
||||
"description": "ASM libraries and tools for the Ethereum EVM.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -36,7 +36,7 @@
|
||||
"generate": "node ./generate.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0x08e35b51e252b8780fdd4fb88d2df605fc0ba2731a106f73738660fb263a2827",
|
||||
"tarballHash": "0xf903345c132095391c2259543c97dcac983d1ba94f75c60adb9e0026ce031086",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "asm/5.1.0";
|
||||
export const version = "asm/5.2.0";
|
||||
|
||||
2
packages/base64/lib.esm/_version.d.ts
vendored
2
packages/base64/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "base64/5.1.0";
|
||||
export declare const version = "base64/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "base64/5.1.0";
|
||||
export const version = "base64/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/base64/lib/_version.d.ts
vendored
2
packages/base64/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "base64/5.1.0";
|
||||
export declare const version = "base64/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "base64/5.1.0";
|
||||
exports.version = "base64/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -7,7 +7,7 @@
|
||||
"./lib/base64": "./lib/browser-base64.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ethersproject/bytes": "^5.1.0"
|
||||
"@ethersproject/bytes": "^5.2.0"
|
||||
},
|
||||
"description": "Base64 coder.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -41,7 +41,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x2f08f73bfb5244fcf334f2e461e7645a74e2b2fa08b034bb9258025827a3ec31",
|
||||
"tarballHash": "0x74c5fce00eedf475f74d4890e6e1a83c281898964b9055d5645d1f3074dc87bf",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "base64/5.1.0";
|
||||
export const version = "base64/5.2.0";
|
||||
|
||||
2
packages/basex/lib.esm/_version.d.ts
vendored
2
packages/basex/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "basex/5.1.0";
|
||||
export declare const version = "basex/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "basex/5.1.0";
|
||||
export const version = "basex/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/basex/lib/_version.d.ts
vendored
2
packages/basex/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "basex/5.1.0";
|
||||
export declare const version = "basex/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "basex/5.1.0";
|
||||
exports.version = "basex/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0"
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0"
|
||||
},
|
||||
"description": "Base-X without Buffer.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -36,7 +36,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x4d21807d9f84a69f71bf50315cbce419936d0fe374c60f7cdda02aa5a254f1c5",
|
||||
"tarballHash": "0x13fff325a30baa5b8ba04f9fb8e9d1964843c445831d13a3d6e4eba849353900",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "basex/5.1.0";
|
||||
export const version = "basex/5.2.0";
|
||||
|
||||
2
packages/bignumber/lib.esm/_version.d.ts
vendored
2
packages/bignumber/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "bignumber/5.1.1";
|
||||
export declare const version = "bignumber/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "bignumber/5.1.1";
|
||||
export const version = "bignumber/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/bignumber/lib.esm/bignumber.d.ts
vendored
2
packages/bignumber/lib.esm/bignumber.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { Bytes, Hexable } from "@ethersproject/bytes";
|
||||
export declare type BigNumberish = BigNumber | Bytes | string | number;
|
||||
export declare type BigNumberish = BigNumber | Bytes | bigint | string | number;
|
||||
export declare function isBigNumberish(value: any): value is BigNumberish;
|
||||
export declare class BigNumber implements Hexable {
|
||||
readonly _hex: string;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"bignumber.d.ts","sourceRoot":"","sources":["../src.ts/bignumber.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAiC,MAAM,sBAAsB,CAAC;AAWrF,oBAAY,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,YAAY,CAShE;AAKD,qBAAa,SAAU,YAAW,OAAO;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;gBAEnB,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM;IAe9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;IAIlC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;IAIhC,GAAG,IAAI,SAAS;IAOhB,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAInC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAInC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAQnC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAInC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAQnC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAQnC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAQnC,EAAE,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAQlC,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAQnC,IAAI,CAAC,KA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AAG,CAAC,EAAE,MAAM,GAAG,GAAG;IAIzB,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS;IAkElC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS;CAGrD;AAiED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
||||
8
packages/bignumber/lib.esm/fixednumber.d.ts
vendored
8
packages/bignumber/lib.esm/fixednumber.d.ts
vendored
@@ -31,10 +31,10 @@ export declare class FixedNumber {
|
||||
toHexString(width?: number): string;
|
||||
toUnsafeFloat(): number;
|
||||
toFormat(format: FixedFormat | string): FixedNumber;
|
||||
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber;
|
||||
static fromString(value: string, format?: FixedFormat | string): FixedNumber;
|
||||
static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber;
|
||||
static from(value: any, format?: FixedFormat | string): FixedNumber;
|
||||
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string | number): FixedNumber;
|
||||
static fromString(value: string, format?: FixedFormat | string | number): FixedNumber;
|
||||
static fromBytes(value: BytesLike, format?: FixedFormat | string | number): FixedNumber;
|
||||
static from(value: any, format?: FixedFormat | string | number): FixedNumber;
|
||||
static isFixedNumber(value: any): value is FixedNumber;
|
||||
}
|
||||
//# sourceMappingURL=fixednumber.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"fixednumber.d.ts","sourceRoot":"","sources":["../src.ts/fixednumber.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,SAAS,EAAuB,MAAM,sBAAsB,CAAC;AAMhF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAiCtE,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,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,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW;IAchH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW;IAwBrF,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW;IAkBvF,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM;IAqB9D,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW;CAGzD"}
|
||||
@@ -50,7 +50,12 @@ export function formatFixed(value, decimals) {
|
||||
// Strip training 0
|
||||
fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
|
||||
const whole = value.div(multiplier).toString();
|
||||
value = whole + "." + fraction;
|
||||
if (multiplier.length === 1) {
|
||||
value = whole;
|
||||
}
|
||||
else {
|
||||
value = whole + "." + fraction;
|
||||
}
|
||||
if (negative) {
|
||||
value = "-" + value;
|
||||
}
|
||||
@@ -64,9 +69,6 @@ export function parseFixed(value, decimals) {
|
||||
if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) {
|
||||
logger.throwArgumentError("invalid decimal value", "value", value);
|
||||
}
|
||||
if (multiplier.length - 1 === 0) {
|
||||
return BigNumber.from(value);
|
||||
}
|
||||
// Is it negative?
|
||||
const negative = (value.substring(0, 1) === "-");
|
||||
if (negative) {
|
||||
@@ -87,9 +89,12 @@ export function parseFixed(value, decimals) {
|
||||
if (!fraction) {
|
||||
fraction = "0";
|
||||
}
|
||||
// Prevent underflow
|
||||
if (fraction.length > multiplier.length - 1) {
|
||||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
|
||||
// Get significant digits to check truncation for underflow
|
||||
{
|
||||
const sigFraction = fraction.replace(/^([0-9]*?)(0*)$/, (all, sig, zeros) => (sig));
|
||||
if (sigFraction.length > multiplier.length - 1) {
|
||||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
|
||||
}
|
||||
}
|
||||
// Fully pad the string with zeros to get to wei
|
||||
while (fraction.length < multiplier.length - 1) {
|
||||
@@ -121,6 +126,9 @@ export class FixedFormat {
|
||||
if (value instanceof FixedFormat) {
|
||||
return value;
|
||||
}
|
||||
if (typeof (value) === "number") {
|
||||
value = `fixed128x${value}`;
|
||||
}
|
||||
let signed = true;
|
||||
let width = 128;
|
||||
let decimals = 18;
|
||||
@@ -131,7 +139,7 @@ export class FixedFormat {
|
||||
else if (value === "ufixed") {
|
||||
signed = false;
|
||||
}
|
||||
else if (value != null) {
|
||||
else {
|
||||
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
||||
if (!match) {
|
||||
logger.throwArgumentError("invalid fixed format", "format", value);
|
||||
@@ -208,7 +216,10 @@ export class FixedNumber {
|
||||
return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format);
|
||||
}
|
||||
floor() {
|
||||
let comps = this.toString().split(".");
|
||||
const comps = this.toString().split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("0");
|
||||
}
|
||||
let result = FixedNumber.from(comps[0], this.format);
|
||||
const hasFraction = !comps[1].match(/^(0*)$/);
|
||||
if (this.isNegative() && hasFraction) {
|
||||
@@ -217,7 +228,10 @@ export class FixedNumber {
|
||||
return result;
|
||||
}
|
||||
ceiling() {
|
||||
let comps = this.toString().split(".");
|
||||
const comps = this.toString().split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("0");
|
||||
}
|
||||
let result = FixedNumber.from(comps[0], this.format);
|
||||
const hasFraction = !comps[1].match(/^(0*)$/);
|
||||
if (!this.isNegative() && hasFraction) {
|
||||
@@ -231,7 +245,10 @@ export class FixedNumber {
|
||||
decimals = 0;
|
||||
}
|
||||
// If we are already in range, we're done
|
||||
let comps = this.toString().split(".");
|
||||
const comps = this.toString().split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("0");
|
||||
}
|
||||
if (decimals < 0 || decimals > 80 || (decimals % 1)) {
|
||||
logger.throwArgumentError("invalid decimal count", "decimals", decimals);
|
||||
}
|
||||
@@ -242,7 +259,7 @@ export class FixedNumber {
|
||||
return this.mulUnsafe(factor).addUnsafe(BUMP).floor().divUnsafe(factor);
|
||||
}
|
||||
isZero() {
|
||||
return (this._value === "0.0");
|
||||
return (this._value === "0.0" || this._value === "0");
|
||||
}
|
||||
isNegative() {
|
||||
return (this._value[0] === "-");
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
packages/bignumber/lib/_version.d.ts
vendored
2
packages/bignumber/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "bignumber/5.1.1";
|
||||
export declare const version = "bignumber/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "bignumber/5.1.1";
|
||||
exports.version = "bignumber/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/bignumber/lib/bignumber.d.ts
vendored
2
packages/bignumber/lib/bignumber.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { Bytes, Hexable } from "@ethersproject/bytes";
|
||||
export declare type BigNumberish = BigNumber | Bytes | string | number;
|
||||
export declare type BigNumberish = BigNumber | Bytes | bigint | string | number;
|
||||
export declare function isBigNumberish(value: any): value is BigNumberish;
|
||||
export declare class BigNumber implements Hexable {
|
||||
readonly _hex: string;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"bignumber.d.ts","sourceRoot":"","sources":["../src.ts/bignumber.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAiC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D"}
|
||||
8
packages/bignumber/lib/fixednumber.d.ts
vendored
8
packages/bignumber/lib/fixednumber.d.ts
vendored
@@ -31,10 +31,10 @@ export declare class FixedNumber {
|
||||
toHexString(width?: number): string;
|
||||
toUnsafeFloat(): number;
|
||||
toFormat(format: FixedFormat | string): FixedNumber;
|
||||
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber;
|
||||
static fromString(value: string, format?: FixedFormat | string): FixedNumber;
|
||||
static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber;
|
||||
static from(value: any, format?: FixedFormat | string): FixedNumber;
|
||||
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string | number): FixedNumber;
|
||||
static fromString(value: string, format?: FixedFormat | string | number): FixedNumber;
|
||||
static fromBytes(value: BytesLike, format?: FixedFormat | string | number): FixedNumber;
|
||||
static from(value: any, format?: FixedFormat | string | number): FixedNumber;
|
||||
static isFixedNumber(value: any): value is FixedNumber;
|
||||
}
|
||||
//# sourceMappingURL=fixednumber.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"fixednumber.d.ts","sourceRoot":"","sources":["../src.ts/fixednumber.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,SAAS,EAAuB,MAAM,sBAAsB,CAAC;AAMhF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAiCtE,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAuBzF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CA8C5E;AAED,qBAAa,WAAW;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,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,WAAW;IAkBvF,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM;IAqB9D,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,WAAW;CAGzD"}
|
||||
@@ -52,7 +52,12 @@ function formatFixed(value, decimals) {
|
||||
// Strip training 0
|
||||
fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
|
||||
var whole = value.div(multiplier).toString();
|
||||
value = whole + "." + fraction;
|
||||
if (multiplier.length === 1) {
|
||||
value = whole;
|
||||
}
|
||||
else {
|
||||
value = whole + "." + fraction;
|
||||
}
|
||||
if (negative) {
|
||||
value = "-" + value;
|
||||
}
|
||||
@@ -67,9 +72,6 @@ function parseFixed(value, decimals) {
|
||||
if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) {
|
||||
logger.throwArgumentError("invalid decimal value", "value", value);
|
||||
}
|
||||
if (multiplier.length - 1 === 0) {
|
||||
return bignumber_1.BigNumber.from(value);
|
||||
}
|
||||
// Is it negative?
|
||||
var negative = (value.substring(0, 1) === "-");
|
||||
if (negative) {
|
||||
@@ -90,9 +92,12 @@ function parseFixed(value, decimals) {
|
||||
if (!fraction) {
|
||||
fraction = "0";
|
||||
}
|
||||
// Prevent underflow
|
||||
if (fraction.length > multiplier.length - 1) {
|
||||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
|
||||
// Get significant digits to check truncation for underflow
|
||||
{
|
||||
var sigFraction = fraction.replace(/^([0-9]*?)(0*)$/, function (all, sig, zeros) { return (sig); });
|
||||
if (sigFraction.length > multiplier.length - 1) {
|
||||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
|
||||
}
|
||||
}
|
||||
// Fully pad the string with zeros to get to wei
|
||||
while (fraction.length < multiplier.length - 1) {
|
||||
@@ -125,6 +130,9 @@ var FixedFormat = /** @class */ (function () {
|
||||
if (value instanceof FixedFormat) {
|
||||
return value;
|
||||
}
|
||||
if (typeof (value) === "number") {
|
||||
value = "fixed128x" + value;
|
||||
}
|
||||
var signed = true;
|
||||
var width = 128;
|
||||
var decimals = 18;
|
||||
@@ -135,7 +143,7 @@ var FixedFormat = /** @class */ (function () {
|
||||
else if (value === "ufixed") {
|
||||
signed = false;
|
||||
}
|
||||
else if (value != null) {
|
||||
else {
|
||||
var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
||||
if (!match) {
|
||||
logger.throwArgumentError("invalid fixed format", "format", value);
|
||||
@@ -216,6 +224,9 @@ var FixedNumber = /** @class */ (function () {
|
||||
};
|
||||
FixedNumber.prototype.floor = function () {
|
||||
var comps = this.toString().split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("0");
|
||||
}
|
||||
var result = FixedNumber.from(comps[0], this.format);
|
||||
var hasFraction = !comps[1].match(/^(0*)$/);
|
||||
if (this.isNegative() && hasFraction) {
|
||||
@@ -225,6 +236,9 @@ var FixedNumber = /** @class */ (function () {
|
||||
};
|
||||
FixedNumber.prototype.ceiling = function () {
|
||||
var comps = this.toString().split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("0");
|
||||
}
|
||||
var result = FixedNumber.from(comps[0], this.format);
|
||||
var hasFraction = !comps[1].match(/^(0*)$/);
|
||||
if (!this.isNegative() && hasFraction) {
|
||||
@@ -239,6 +253,9 @@ var FixedNumber = /** @class */ (function () {
|
||||
}
|
||||
// If we are already in range, we're done
|
||||
var comps = this.toString().split(".");
|
||||
if (comps.length === 1) {
|
||||
comps.push("0");
|
||||
}
|
||||
if (decimals < 0 || decimals > 80 || (decimals % 1)) {
|
||||
logger.throwArgumentError("invalid decimal count", "decimals", decimals);
|
||||
}
|
||||
@@ -249,7 +266,7 @@ var FixedNumber = /** @class */ (function () {
|
||||
return this.mulUnsafe(factor).addUnsafe(BUMP).floor().divUnsafe(factor);
|
||||
};
|
||||
FixedNumber.prototype.isZero = function () {
|
||||
return (this._value === "0.0");
|
||||
return (this._value === "0.0" || this._value === "0");
|
||||
};
|
||||
FixedNumber.prototype.isNegative = function () {
|
||||
return (this._value[0] === "-");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"bn.js": "^4.4.0"
|
||||
},
|
||||
"description": "BigNumber library used in ethers.js.",
|
||||
@@ -38,7 +38,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x3e0d0e0c51ff62d1611ec52119f7549d3e6f35973a4b489185a70b63ed3178e9",
|
||||
"tarballHash": "0xf541fda3d586d4a9bef45fda1cffa2ef3be324945925e16d0dc04470b59dce11",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.1"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "bignumber/5.1.1";
|
||||
export const version = "bignumber/5.2.0";
|
||||
|
||||
@@ -22,7 +22,7 @@ const _constructorGuard = { };
|
||||
const MAX_SAFE = 0x1fffffffffffff;
|
||||
|
||||
|
||||
export type BigNumberish = BigNumber | Bytes | string | number;
|
||||
export type BigNumberish = BigNumber | Bytes | bigint | string | number;
|
||||
|
||||
export function isBigNumberish(value: any): value is BigNumberish {
|
||||
return (value != null) && (
|
||||
|
||||
@@ -56,8 +56,11 @@ export function formatFixed(value: BigNumberish, decimals?: string | BigNumberis
|
||||
fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
|
||||
|
||||
const whole = value.div(multiplier).toString();
|
||||
|
||||
value = whole + "." + fraction;
|
||||
if (multiplier.length === 1) {
|
||||
value = whole;
|
||||
} else {
|
||||
value = whole + "." + fraction;
|
||||
}
|
||||
|
||||
if (negative) { value = "-" + value; }
|
||||
|
||||
@@ -72,10 +75,6 @@ export function parseFixed(value: string, decimals?: BigNumberish): BigNumber {
|
||||
logger.throwArgumentError("invalid decimal value", "value", value);
|
||||
}
|
||||
|
||||
if (multiplier.length - 1 === 0) {
|
||||
return BigNumber.from(value);
|
||||
}
|
||||
|
||||
// Is it negative?
|
||||
const negative = (value.substring(0, 1) === "-");
|
||||
if (negative) { value = value.substring(1); }
|
||||
@@ -94,9 +93,12 @@ export function parseFixed(value: string, decimals?: BigNumberish): BigNumber {
|
||||
if (!whole) { whole = "0"; }
|
||||
if (!fraction) { fraction = "0"; }
|
||||
|
||||
// Prevent underflow
|
||||
if (fraction.length > multiplier.length - 1) {
|
||||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
|
||||
// Get significant digits to check truncation for underflow
|
||||
{
|
||||
const sigFraction = fraction.replace(/^([0-9]*?)(0*)$/, (all, sig, zeros) => (sig));
|
||||
if (sigFraction.length > multiplier.length - 1) {
|
||||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
|
||||
}
|
||||
}
|
||||
|
||||
// Fully pad the string with zeros to get to wei
|
||||
@@ -140,6 +142,10 @@ export class FixedFormat {
|
||||
static from(value: any): FixedFormat {
|
||||
if (value instanceof FixedFormat) { return value; }
|
||||
|
||||
if (typeof(value) === "number") {
|
||||
value = `fixed128x${value}`
|
||||
}
|
||||
|
||||
let signed = true;
|
||||
let width = 128;
|
||||
let decimals = 18;
|
||||
@@ -149,7 +155,7 @@ export class FixedFormat {
|
||||
// defaults...
|
||||
} else if (value === "ufixed") {
|
||||
signed = false;
|
||||
} else if (value != null) {
|
||||
} else {
|
||||
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
||||
if (!match) { logger.throwArgumentError("invalid fixed format", "format", value); }
|
||||
signed = (match[1] !== "u");
|
||||
@@ -241,7 +247,8 @@ export class FixedNumber {
|
||||
}
|
||||
|
||||
floor(): FixedNumber {
|
||||
let comps = this.toString().split(".");
|
||||
const comps = this.toString().split(".");
|
||||
if (comps.length === 1) { comps.push("0"); }
|
||||
|
||||
let result = FixedNumber.from(comps[0], this.format);
|
||||
|
||||
@@ -254,7 +261,8 @@ export class FixedNumber {
|
||||
}
|
||||
|
||||
ceiling(): FixedNumber {
|
||||
let comps = this.toString().split(".");
|
||||
const comps = this.toString().split(".");
|
||||
if (comps.length === 1) { comps.push("0"); }
|
||||
|
||||
let result = FixedNumber.from(comps[0], this.format);
|
||||
|
||||
@@ -271,7 +279,8 @@ export class FixedNumber {
|
||||
if (decimals == null) { decimals = 0; }
|
||||
|
||||
// If we are already in range, we're done
|
||||
let comps = this.toString().split(".");
|
||||
const comps = this.toString().split(".");
|
||||
if (comps.length === 1) { comps.push("0"); }
|
||||
|
||||
if (decimals < 0 || decimals > 80 || (decimals % 1)) {
|
||||
logger.throwArgumentError("invalid decimal count", "decimals", decimals);
|
||||
@@ -284,7 +293,7 @@ export class FixedNumber {
|
||||
}
|
||||
|
||||
isZero(): boolean {
|
||||
return (this._value === "0.0");
|
||||
return (this._value === "0.0" || this._value === "0");
|
||||
}
|
||||
|
||||
isNegative(): boolean {
|
||||
@@ -307,7 +316,7 @@ export class FixedNumber {
|
||||
}
|
||||
|
||||
|
||||
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber {
|
||||
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string | number): FixedNumber {
|
||||
// If decimals looks more like a format, and there is no format, shift the parameters
|
||||
if (format == null && decimals != null && !isBigNumberish(decimals)) {
|
||||
format = decimals;
|
||||
@@ -321,7 +330,7 @@ export class FixedNumber {
|
||||
}
|
||||
|
||||
|
||||
static fromString(value: string, format?: FixedFormat | string): FixedNumber {
|
||||
static fromString(value: string, format?: FixedFormat | string | number): FixedNumber {
|
||||
if (format == null) { format = "fixed"; }
|
||||
|
||||
const fixedFormat = FixedFormat.from(format);
|
||||
@@ -345,7 +354,7 @@ export class FixedNumber {
|
||||
return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
|
||||
}
|
||||
|
||||
static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber {
|
||||
static fromBytes(value: BytesLike, format?: FixedFormat | string | number): FixedNumber {
|
||||
if (format == null) { format = "fixed"; }
|
||||
|
||||
const fixedFormat = FixedFormat.from(format);
|
||||
@@ -363,7 +372,7 @@ export class FixedNumber {
|
||||
return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
|
||||
}
|
||||
|
||||
static from(value: any, format?: FixedFormat | string) {
|
||||
static from(value: any, format?: FixedFormat | string | number) {
|
||||
if (typeof(value) === "string") {
|
||||
return FixedNumber.fromString(value, format);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user