Compare commits

..

30 Commits

Author SHA1 Message Date
Richard Moore
fb3dffcc12 docs: fixed formatting of ignore character 2023-02-22 21:32:01 -05:00
Richard Moore
77a7323119 Added chain parameters for Arbitrum and Optimism (#3811). 2023-02-22 21:29:44 -05:00
Richard Moore
5a3c10a29c Fix NoneManager race condition (#3812, #3813). 2023-02-22 21:10:43 -05:00
Richard Moore
f9eed4cdb1 Add UMD output to dist builds (#3814). 2023-02-22 21:03:47 -05:00
Richard Moore
981a962543 docs: updated RLP link 2023-02-22 05:04:46 -05:00
Richard Moore
f61a78fceb admin: organize github workflows 2023-02-22 04:49:50 -05:00
Richard Moore
405fbbdea8 admin: fix duplicate name for issue templates 2023-02-22 04:04:57 -05:00
Richard Moore
d5f360d12a docs: add defineProperties to migration docs 2023-02-22 04:02:15 -05:00
Richard Moore
09805afad5 admin: add more changelog details 2023-02-22 04:01:49 -05:00
Richard Moore
5853530bdb admin: fix issue template descriptions 2023-02-22 04:01:30 -05:00
Richard Moore
5715d611e7 admin: updated dist files 2023-02-18 22:18:42 -05:00
Richard Moore
b39e955eb6 docs: fixed typos and improve migration docs (#3717, #3721, #3723, #3725, #3736, #3795). 2023-02-18 22:16:58 -05:00
Richard Moore
399356b912 Fixed Result to behave correctly like an array using slice and toArray (#3787). 2023-02-18 21:42:01 -05:00
Richard Moore
4512e97f9b Replaced substring from 0 index with startsWith (#3691). 2023-02-18 14:00:42 -05:00
Richard Moore
762c2f34ea Fixed inverted assert in duplicate name detection for ABI encoding (#3792). 2023-02-18 13:45:45 -05:00
Richard Moore
48bbef7ade Fixed missing property during transaction copy (#3793). 2023-02-18 13:37:48 -05:00
Richard Moore
4665fb4c68 Add support for Wallet private keys without 0x prefix (#3768). 2023-02-18 13:36:23 -05:00
Richard Moore
b1bb69356a admin: updated GitHub issue templates for adding version tags 2023-02-16 09:51:51 -05:00
Richard Moore
a8afb72fbb Fixed quicknode property for defaultProvider (#3741). 2023-02-16 09:45:28 -05:00
Richard Moore
085a9054f3 Fixed exports field order (#3703, #3755). 2023-02-16 09:44:13 -05:00
Richard Moore
ddaa87a2e6 admin: remove docs and github config from npm package 2023-02-16 08:22:53 -05:00
Richard Moore
5afe840552 admin: update dist files 2023-02-16 08:19:59 -05:00
Richard Moore
4d9b29de75 Fixed custom error decoding (#3785). 2023-02-16 08:17:39 -05:00
Richard Moore
e1e0929348 Removed stray debug logging. 2023-02-16 07:49:33 -05:00
Richard Moore
92def9c148 Fixed lookupAddress when bad resolver is present (#3782). 2023-02-15 15:50:13 -05:00
Richard Moore
557c7d4224 docs: added jsdocs to update-version generated output 2023-02-14 12:24:53 -05:00
Richard Moore
83957dc283 Fixed FallbackProvider median calculation (#3746). 2023-02-14 11:54:08 -05:00
Richard Moore
179e6ca520 Move the xnf normalize variant to pkg.browser instead of import (#3724). 2023-02-13 10:53:47 -05:00
Richard Moore
2a30facb2b docs: added LICENSE.md 2023-02-13 10:48:48 -05:00
Richard Moore
9b508a4656 admin: updated dist files 2023-02-12 22:14:26 -05:00
404 changed files with 1180 additions and 8441 deletions

View File

@@ -0,0 +1,81 @@
name: "Bug Report v5 (legacy)"
description: "Open an issue for a bug in Ethers v5 (legacy)"
title: "Add Bug Title Here"
labels: [ "investigate", "v5" ]
assignees:
- ricmoo
body:
- type: markdown
attributes:
value: |
**READ THIS FIRST** and follow all instructions, please. `:)`
Thank you for taking the time to report an issue. This form is for reporting **bugs within ethers**, specifically for the legacy v5 branch.
If you are **new to ethers** or *uncertain* whether this is a bug in ethers, a bug in another framework or a bug in your own code, please [start a discussion](https://github.com/ethers-io/ethers.js/discussions) first.
- type: input
id: version
attributes:
label: Ethers Version
description: What version of ethers are you using? Before opening an issue, please make sure you are up to date.
placeholder: 5.y.z
validations:
required: true
- type: input
id: search-terms
attributes:
label: Search Terms
description: Have you searched for answers [in the documentation](https://docs.ethers.org), through [the issues](https://github.com/ethers-io/ethers.js/issues) and [on the discusions](https://github.com/ethers-io/ethers.js/discussions)? Please include the search terms you have tried. This helps us add more keywords where needed.
placeholder: e.g. abi, network, utf8
- type: textarea
id: about-the-bug
attributes:
label: Describe the Problem
description: Please describe what you expected to happen vs what did happen?
placeholder: What happened?
validations:
required: true
- type: textarea
id: code-snippet
attributes:
label: Code Snippet
description: If possible, please include a **short and concise** code snippets that can reproduce this issue. Ideally code that can be pasted into the [Ethers Playground](https://playground.ethers.org).
placeholder: e.g. provider.getBlockNumber()
render: shell
- type: textarea
id: contract-abi
attributes:
label: Contract ABI
description: If this involves a contract, please include any **concise and relevant** ABI fragments.
placeholder: e.g. [ 'function balanceOf(address owner) view returns (uint)' ]
render: shell
- type: textarea
id: errors
attributes:
label: Errors
description: If there is an error, please include the **entire error** (redacting any sensitive information).
placeholder: "e.g. Error: invalid name (code='INVALID_ARGUMENT, ...)"
render: shell
- type: dropdown
id: environment
attributes:
label: Environment
description: What environment, platforms or frameworks are you using? Select all that apply.
multiple: true
options:
- Ethereum (mainnet/ropsten/rinkeby/goerli)
- Altcoin - Please specify (e.g. Polygon)
- node.js (v12 or newer)
- node.js (older than v12)
- Browser (Chrome, Safari, etc)
- React Native/Expo/JavaScriptCore
- Hardhat
- Geth
- Parity
- Ganache
- Other (please specify)
- type: input
id: other-envrionment
attributes:
label: Environment (Other)
placeholder: anything else?

View File

@@ -1,7 +1,7 @@
name: Bug Report
description: Open an issue for a bug in Ethers
title: "Bug Report Title"
labels: ["investigate"]
name: "Bug Report v6 (latest)"
description: "Open an issue for a bug in Ethers v6 (latest)"
title: "Add Bug Title Here"
labels: [ "investigate", "v6" ]
assignees:
- ricmoo
body:
@@ -18,7 +18,7 @@ body:
attributes:
label: Ethers Version
description: What version of ethers are you using? Before opening an issue, please make sure you are up to date.
placeholder: x.y.z
placeholder: 6.y.z
validations:
required: true
- type: input

45
.github/workflows/generate-docs.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Generate Documentation
on:
push:
branches:
- main
jobs:
docs:
name: Generate Documentation
runs-on: ubuntu-latest
environment: ethers-tests
env:
FAUCET_PRIVATEKEY: ${{ secrets.FAUCET_PRIVATEKEY }}
steps:
- uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Install dependencies
run: npm ci
- name: Install Flatworm
run: npm install --no-save 'https://github.com/ricmoo/flatworm.git#tsdocs'
- name: Build Documentation
run: node node_modules/flatworm/lib/test-api-index ./docs.wrm/config.js
- name: Upload documentation to to docs.ethers.org
uses: ethers-io/sync-s3-action@main
with:
aws_access_key_id: ${{ secrets.DOCS_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY}}
aws_s3_bucket: ethers.org
source_folder: 'output/docs/'
destination_prefix: 'docs/'
aws_cloudfront_id: ${{ secrets.DOCS_AWS_CLOUDFRONT_ID }}

View File

@@ -4,6 +4,8 @@ on:
push:
branches:
- main
paths:
- "src.ts/**"
jobs:
@@ -97,44 +99,3 @@ jobs:
source_folder: 'output/'
destination_prefix: 'build/output/'
aws_cloudfront_id: ${{ secrets.BUILD_AWS_CLOUDFRONT_ID }}
docs:
name: Generate Documentation
runs-on: ubuntu-latest
environment: ethers-tests
env:
FAUCET_PRIVATEKEY: ${{ secrets.FAUCET_PRIVATEKEY }}
continue-on-error: true
steps:
- uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Install dependencies
run: npm ci
- name: Install Flatworm
run: npm install --no-save 'https://github.com/ricmoo/flatworm.git#tsdocs'
- name: Build Documentation
run: node node_modules/flatworm/lib/test-api-index ./docs.wrm/config.js
- name: Upload documentation to to docs.ethers.org
uses: ethers-io/sync-s3-action@main
with:
aws_access_key_id: ${{ secrets.DOCS_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY}}
aws_s3_bucket: ethers.org
source_folder: 'output/docs/'
destination_prefix: 'docs/'
aws_cloudfront_id: ${{ secrets.DOCS_AWS_CLOUDFRONT_ID }}

View File

@@ -4,6 +4,8 @@ tsconfig.*.json
tsconfig.tsbuildinfo
rollup.config.js
output/**
docs.wrm/**
.github/**
# Ignore admin scripts and files
src.ts/_admin/**

View File

@@ -1,7 +1,49 @@
Changelog
=========
Change Log
==========
ethers/v6.0.0 (2023-02-02 21:19)
This change log is maintained by `src.ts/_admin/update-changelog.ts but may also be manually updated.`
ethers/v6.0.5 (2023-02-18 22:36)
--------------------------------
- Initial v6 release.
- Fixed Result to behave correctly like an array using slice and toArray ([#3787](https://github.com/ethers-io/ethers.js/issues/3787); [399356b](https://github.com/ethers-io/ethers.js/commit/399356b91227db04e496628af60c4b8e38207760)).
- Replaced substring from 0 index with startsWith ([#3691](https://github.com/ethers-io/ethers.js/issues/3691); [4512e97](https://github.com/ethers-io/ethers.js/commit/4512e97f9b55607ce388aa6eb63a37fc196a5d9d)).
- Fixed inverted assert in duplicate name detection for ABI encoding ([#3792](https://github.com/ethers-io/ethers.js/issues/3792); [762c2f3](https://github.com/ethers-io/ethers.js/commit/762c2f34eac848c5464389f11d1697dcd8ebcbb5)).
- Fixed missing property during transaction copy ([#3793](https://github.com/ethers-io/ethers.js/issues/3793); [48bbef7](https://github.com/ethers-io/ethers.js/commit/48bbef7ade69bcfe86542f752f15049cc62f4141)).
- Add support for Wallet private keys without 0x prefix ([#3768](https://github.com/ethers-io/ethers.js/issues/3768); [4665fb4](https://github.com/ethers-io/ethers.js/commit/4665fb4c6886c8b344dee316ba9f4fde57ce7557)).
- Fixed quicknode property for defaultProvider ([#3741](https://github.com/ethers-io/ethers.js/issues/3741); [a8afb72](https://github.com/ethers-io/ethers.js/commit/a8afb72fbbceb6a5024c1edb85badb72099787ea)).
- Fixed exports field order ([#3703](https://github.com/ethers-io/ethers.js/issues/3703), [#3755](https://github.com/ethers-io/ethers.js/issues/3755); [085a905](https://github.com/ethers-io/ethers.js/commit/085a9054f349afb816ca1a123737293ec9bd2532)).
ethers/v6.0.4 (2023-02-16 08:55)
--------------------------------
- Fixed custom error decoding ([#3785](https://github.com/ethers-io/ethers.js/issues/3785); [4d9b29d](https://github.com/ethers-io/ethers.js/commit/4d9b29de751e2387c143e474bb96d271da892ea6)).
- Removed stray debug logging ([e1e0929](https://github.com/ethers-io/ethers.js/commit/e1e09293483a9d07fd8e8f96552aa958b5ec45ed)).
- Fixed lookupAddress when bad resolver is present ([#3782](https://github.com/ethers-io/ethers.js/issues/3782); [92def9c](https://github.com/ethers-io/ethers.js/commit/92def9c1489bb35ad13fe58a1cd107ee3a05a112)).
- Fixed FallbackProvider median calculation ([#3746](https://github.com/ethers-io/ethers.js/issues/3746); [83957dc](https://github.com/ethers-io/ethers.js/commit/83957dc283043b9af8f6e89920faac3e09ca69fc)).
- Move the xnf normalize variant to pkg.browser instead of import ([#3724](https://github.com/ethers-io/ethers.js/issues/3724); [179e6ca](https://github.com/ethers-io/ethers.js/commit/179e6ca520392177c7dea5e477b29930952ed637)).
ethers/v6.0.3 (2023-02-12 22:45)
--------------------------------
- Allow null type in transaction receipt for legacy type 0 networks ([#3459](https://github.com/ethers-io/ethers.js/issues/3459); [6372a46](https://github.com/ethers-io/ethers.js/commit/6372a46b1b273db3e4c1189daebb4b888bd588bc)).
- Fixed events when slicing immutable Result ([#3765](https://github.com/ethers-io/ethers.js/issues/3765); [2ba4a17](https://github.com/ethers-io/ethers.js/commit/2ba4a172555b7e17ac01fedfc944549defab61bc)).
- More robust support on networks which throw when filters are not supported ([#3767](https://github.com/ethers-io/ethers.js/issues/3767); [37bf4fb](https://github.com/ethers-io/ethers.js/commit/37bf4fb55563d7ff66edee15c7515c8a0d6a2266)).
- Fixed ignored polling override for JsonRpcApiProvider ([400d576](https://github.com/ethers-io/ethers.js/commit/400d57621b3e9a33679a528b5072449699f0a068)).
ethers/v6.0.2 (2023-02-04 08:50)
--------------------------------
- Fixed crossed assert in Fetch ([#3733](https://github.com/ethers-io/ethers.js/issues/3733); [6c338c1](https://github.com/ethers-io/ethers.js/commit/6c338c1c5b4013db9754c9d1a33dcbf54330e5c7)).
ethers/v6.0.1 (2023-02-04 04:06)
--------------------------------
- Fix Subscriber model when removed within emit callback ([d0ed918](https://github.com/ethers-io/ethers.js/commit/d0ed91840c9f51c7ce9061ebb1d36727dbdd51a4)).
- Fixed human-readable parser when identifier begins with valid type prefix ([#3728](https://github.com/ethers-io/ethers.js/issues/3728); [522fd16](https://github.com/ethers-io/ethers.js/commit/522fd16f68aabc53e4dc8745d4128e0d61260ed5)).
- Update to latest secp256k1 library ([#3719](https://github.com/ethers-io/ethers.js/issues/3719); [803e8f9](https://github.com/ethers-io/ethers.js/commit/803e8f9821950b83efa876d64b1cfb35f6bccc38)).
ethers/v6.0.0 (2023-02-02 22:48)
--------------------------------
- Initial release ([90afd9b](https://github.com/ethers-io/ethers.js/commit/90afd9bd81ed1408421a0247fa0845a74c9eb319)).

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2023 Richard Moore
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

265
dist/ethers.js vendored
View File

@@ -1,4 +1,8 @@
const version = "6.0.2";
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
/**
* The current version of Ethers.
*/
const version = "6.0.5";
/**
* Property helper functions.
@@ -171,7 +175,7 @@ function makeError(message, code, info) {
}
defineProperties(error, { code });
if (info) {
defineProperties(error, info);
Object.assign(error, info);
}
return error;
}
@@ -385,7 +389,7 @@ function dataSlice(data, start, end) {
*/
function stripZerosLeft(data) {
let bytes = hexlify(data).substring(2);
while (bytes.substring(0, 2) == "00") {
while (bytes.startsWith("00")) {
bytes = bytes.substring(2);
}
return "0x" + bytes;
@@ -411,7 +415,7 @@ function zeroPad(data, length, left) {
* Return the [[DataHexString]] of %%data%% padded on the **left**
* to %%length%% bytes.
*
* If %%data%% already exceeds %%length%%, a [[BufferOverrun]] is
* If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is
* thrown.
*
* This pads data the same as **values** are in Solidity
@@ -424,7 +428,7 @@ function zeroPadValue(data, length) {
* Return the [[DataHexString]] of %%data%% padded on the **right**
* to %%length%% bytes.
*
* If %%data%% already exceeds %%length%%, a [[BufferOverrun]] is
* If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is
* thrown.
*
* This pads data the same as **bytes** are in Solidity
@@ -497,7 +501,7 @@ function mask(_value, _bits) {
return value & ((BN_1$5 << bits) - BN_1$5);
}
/**
* Gets a [[BigInt]] from %%value%%. If it is an invalid value for
* Gets a BigInt from %%value%%. If it is an invalid value for
* a BigInt, then an ArgumentError will be thrown for %%name%%.
*/
function getBigInt(value, name) {
@@ -634,7 +638,7 @@ function toBeArray(_value) {
*/
function toQuantity(value) {
let result = hexlify(isBytesLike(value) ? value : toBeArray(value)).substring(2);
while (result.substring(0, 1) === "0") {
while (result.startsWith("0")) {
result = result.substring(1);
}
if (result === "") {
@@ -795,7 +799,21 @@ function replaceFunc(reason, offset, bytes, output, badCodepoint) {
// Otherwise, process as if ignoring errors
return ignoreFunc(reason, offset, bytes, output, badCodepoint);
}
// Common error handing strategies
/**
* A handful of popular, built-in UTF-8 error handling strategies.
*
* **``"error"``** - throws on ANY illegal UTF-8 sequence or
* non-canonical (overlong) codepoints (this is the default)
*
* **``"ignore"``** - silently drops any illegal UTF-8 sequence
* and accepts non-canonical (overlong) codepoints
*
* **``"replace"``** - replace any illegal UTF-8 sequence with the
* UTF-8 replacement character (i.e. `\ufffd`) and accepts
* non-canonical (overlong) codepoints
*
* @returns: Record<"error" | "ignore" | "replace", Utf8ErrorFunc>
*/
const Utf8ErrorFuncs = Object.freeze({
error: errorFunc,
ignore: ignoreFunc,
@@ -942,7 +960,7 @@ function _toUtf8String(codePoints) {
*
* When %%onError%% function is specified, it is called on UTF-8
* errors allowing recovery using the [[Utf8ErrorFunc]] API.
* (default: [error](Utf8ErrorFuncs-error))
* (default: [error](Utf8ErrorFuncs))
*/
function toUtf8String(bytes, onError) {
return _toUtf8String(getUtf8CodePoints(bytes, onError));
@@ -2462,7 +2480,7 @@ function formatUnits(value, unit) {
return FixedNumber.fromValue(value, decimals, { decimals }).toString();
}
/**
* Converts the //decimal string// %%value%% to a [[BigInt]], assuming
* Converts the //decimal string// %%value%% to a BigInt, assuming
* %%unit%% decimal places. The %%unit%% may the number of decimal places
* or the name of a unit (e.g. ``"gwei"`` for 9 decimal places).
*/
@@ -2486,7 +2504,7 @@ function formatEther(wei) {
return formatUnits(wei, 18);
}
/**
* Converts the //decimal string// %%ether%% to a [[BigInt]], using 18
* Converts the //decimal string// %%ether%% to a BigInt, using 18
* decimal places.
*/
function parseEther(ether) {
@@ -2527,7 +2545,7 @@ function uuidV4(randomBytes) {
* Ethereum and to simplify the library, without increasing
* the library dependencies for simple functions.
*
* @_section api/utils:Utilities [utils]
* @_section api/utils:Utilities [about-utils]
*/
/**
@@ -2640,12 +2658,14 @@ class Result extends Array {
* errors.
*/
toArray() {
const result = [];
this.forEach((item, index) => {
if (item instanceof Error) {
throwError(`index ${index}`, item);
}
result.push(item);
});
return Array.of(this);
return result;
}
/**
* Returns the Result as an Object with each name-value pair.
@@ -2672,9 +2692,24 @@ class Result extends Array {
if (start == null) {
start = 0;
}
if (start < 0) {
start += this.length;
if (start < 0) {
start = 0;
}
}
if (end == null) {
end = this.length;
}
if (end < 0) {
end += this.length;
if (end < 0) {
end = 0;
}
}
if (end > this.length) {
end = this.length;
}
const result = [], names = [];
for (let i = start; i < end; i++) {
result.push(this[i]);
@@ -5932,7 +5967,7 @@ const MessagePrefix = "\x19Ethereum Signed Message:\n";
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [constants]
* @_section: api/constants: Constants [about-constants]
*/
// Constants
@@ -5948,6 +5983,9 @@ function toUint256(value) {
}
/**
* A Signature @TODO
*
*
* @_docloc: api/crypto:Signing
*/
class Signature {
#r;
@@ -6231,6 +6269,11 @@ class Signature {
}
}
/**
* Add details about signing here.
*
* @_subsection: api/crypto:Signing [about-signing]
*/
//const N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
// Make noble-secp256k1 sync
utils.hmacSha256Sync = function (key, ...messages) {
@@ -6402,7 +6445,7 @@ class SigningKey {
* A fundamental building block of Ethereum is the underlying
* cryptographic primitives.
*
* @_section: api/crypto:Cryptographic Functions [crypto]
* @_section: api/crypto:Cryptographic Functions [about-crypto]
*/
null;
function lock() {
@@ -6525,7 +6568,7 @@ function getAddress(address) {
assertArgument(typeof (address) === "string", "invalid address", "address", address);
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
// Missing the 0x prefix
if (address.substring(0, 2) !== "0x") {
if (!address.startsWith("0x")) {
address = "0x" + address;
}
const result = getChecksumAddress(address);
@@ -6762,7 +6805,7 @@ function resolveAddress(target, resolver) {
* These functions help convert between various formats, validate
* addresses and safely resolve ENS names.
*
* @_section: api/address:Addresses [addresses]
* @_section: api/address:Addresses [about-addresses]
*/
null;
@@ -6826,7 +6869,7 @@ class Typed {
return !!(this.type.match(/^u?int[0-9]+$/));
}
isData() {
return (this.type.substring(0, 5) === "bytes");
return this.type.startsWith("bytes");
}
isString() {
return (this.type === "string");
@@ -7053,7 +7096,7 @@ function pack(writer, coders, values) {
arrayValues = coders.map((coder) => {
const name = coder.localName;
assert$1(name, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
assert$1(unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
assert$1(!unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
unique[name] = true;
return values[name];
});
@@ -9218,7 +9261,7 @@ class Transaction {
/**
* Transactions..
*
* @_section api/transaction:Transactions [transactions]
* @_section api/transaction:Transactions [about-transactions]
*/
null;
@@ -9751,13 +9794,13 @@ class TypedDataEncoder {
/**
* About hashing here...
*
* @_section: api/hashing:Hashing Utilities [hashing]
* @_section: api/hashing:Hashing Utilities [about-hashing]
*/
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments
* @_subsection api/abi/abi-coder:Fragments [about-fragments]
*/
;
// [ "a", "b" ] => { "a": 1, "b": 1 }
@@ -10109,26 +10152,25 @@ class ParamType {
/**
* True if the parameters is indexed.
*
* For non-indexable types (see [[ParamType_isIndexable]]) this
* is ``null``.
* For non-indexable types this is ``null``.
*/
indexed;
/**
* The components for the tuple.
*
* For non-tuple types (see [[ParamType_isTuple]]) this is ``null``.
* For non-tuple types this is ``null``.
*/
components;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
* For non-array types this is ``null``.
*/
arrayLength;
/**
* The type of each child in the array.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
* For non-array types this is ``null``.
*/
arrayChildren;
/**
@@ -10423,7 +10465,7 @@ class ParamType {
});
return new ParamType(_guard$2, name || "", type, "array", indexed, null, arrayLength, arrayChildren);
}
if (type === "tuple" || type.substring(0, 5) === "tuple(" || type[0] === "(") {
if (type === "tuple" || type.startsWith("tuple(" /* fix: ) */) || type.startsWith("(" /* fix: ) */)) {
const comps = (obj.components != null) ? obj.components.map((c) => ParamType.from(c)) : null;
const tuple = new ParamType(_guard$2, name || "", type, "tuple", indexed, comps, null, null);
// @TODO: use lexer to validate and normalize type
@@ -10979,7 +11021,11 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
message = "execution reverted";
const bytes = getBytes(data);
data = hexlify(data);
if (bytes.length % 32 !== 4) {
if (bytes.length === 0) {
message += " (no data present; likely require(false) occurred";
reason = "require(false)";
}
else if (bytes.length % 32 !== 4) {
message += " (could not decode reason; invalid data length)";
}
else if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
@@ -10994,8 +11040,7 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
message += `: ${JSON.stringify(reason)}`;
}
catch (error) {
console.log(error);
message += " (could not decode reason; invalid data)";
message += " (could not decode reason; invalid string data)";
}
}
else if (hexlify(bytes.slice(0, 4)) === "0x4e487b71") {
@@ -11011,8 +11056,7 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
message += `: ${reason}`;
}
catch (error) {
console.log(error);
message += " (could not decode panic reason)";
message += " (could not decode panic code)";
}
}
else {
@@ -11117,7 +11161,7 @@ class AbiCoder {
return defaultCoder;
}
/**
* Returns an ethers-compatible [[CALL_EXCEPTION]] Error for the given
* Returns an ethers-compatible [[CallExceptionError]] Error for the given
* result %%data%% for the [[CallExceptionAction]] %%action%% against
* the Transaction %%tx%%.
*/
@@ -11721,7 +11765,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* Most developers should prefer the [[parseCallResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
@@ -11791,7 +11835,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* Most developers should prefer the [[parseCallResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
@@ -11821,16 +11865,15 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
const data = getBytes(_data, "data");
const error = AbiCoder.getBuiltinCallException("call", tx, data);
// Not a built-in error; try finding a custom error
if (!error.message.match(/could not decode/)) {
const customPrefix = "execution reverted (unknown custom error)";
if (error.message.startsWith(customPrefix)) {
const selector = hexlify(data.slice(0, 4));
error.message = "execution reverted (unknown custom error)";
const ef = this.getError(selector);
if (ef) {
try {
const args = this.#abiCoder.decode(ef.inputs, data.slice(4));
error.revert = {
name: ef.name,
signature: ef.format(),
args: this.#abiCoder.decode(ef.inputs, data.slice(4))
name: ef.name, signature: ef.format(), args
};
error.reason = error.revert.signature;
error.message = `execution reverted: ${error.reason}`;
@@ -12140,7 +12183,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [abi]
* @_section api/abi:Application Binary Interface [about-abi]
* @_navTitle: ABI
*/
@@ -12229,7 +12272,7 @@ function copyRequest(req) {
if (req.data) {
result.data = hexlify(req.data);
}
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerGas, maxPriorityFeePerGas,value".split(/,/);
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
for (const key of bigIntKeys) {
if (!(key in req) || req[key] == null) {
continue;
@@ -13489,7 +13532,7 @@ async function _emit(contract, event, args, payloadFunc) {
}
const count = sub.listeners.length;
sub.listeners = sub.listeners.filter(({ listener, once }) => {
const passArgs = args.slice();
const passArgs = Array.from(args);
if (payloadFunc) {
passArgs.push(payloadFunc(once ? null : listener));
}
@@ -13821,7 +13864,7 @@ class ContractFactory {
if (typeof (bytecode) === "object") {
bytecode = bytecode.object;
}
if (bytecode.substring(0, 2) !== "0x") {
if (!bytecode.startsWith("0x")) {
bytecode = "0x" + bytecode;
}
bytecode = hexlify(getBytes(bytecode));
@@ -13875,7 +13918,7 @@ class ContractFactory {
/**
* About contracts...
*
* @_section: api/contract:Contracts [contracts]
* @_section: api/contract:Contracts [about-contracts]
*/
/**
@@ -14486,7 +14529,7 @@ const _formatTransactionReceipt = object({
cumulativeGasUsed: getBigInt,
effectiveGasPrice: allowNull(getBigInt),
status: allowNull(getNumber),
type: getNumber
type: allowNull(getNumber, 0)
}, {
effectiveGasPrice: ["gasPrice"],
hash: ["transactionHash"],
@@ -15895,14 +15938,23 @@ class AbstractProvider {
"function name(bytes32) view returns (string)"
], this);
const name = await resolverContract.name(node);
// Failed forward resolution
const check = await this.resolveName(name);
if (check !== address) {
console.log("FAIL", address, check);
return null;
}
return name;
}
catch (error) {
console.log("TEMP", error);
// No data was returned from the resolver
if (isError(error, "BAD_DATA") && error.value === "0x") {
return null;
}
// Something reerted
if (isError(error, "CALL_EXCEPTION")) {
return null;
}
throw error;
}
return null;
}
@@ -16619,11 +16671,24 @@ class FilterIdSubscriber {
}
async #poll(blockNumber) {
try {
// Subscribe if necessary
if (this.#filterIdPromise == null) {
this.#filterIdPromise = this._subscribe(this.#provider);
}
const filterId = await this.#filterIdPromise;
// Get the Filter ID
let filterId = null;
try {
filterId = await this.#filterIdPromise;
}
catch (error) {
if (!isError(error, "UNSUPPORTED_OPERATION") || error.operation !== "eth_newFilter") {
throw error;
}
}
// The backend does not support Filter ID; downgrade to
// polling
if (filterId == null) {
this.#filterIdPromise = null;
this.#provider._recoverSubscriber(this, this._recover(this.#provider));
return;
}
@@ -17127,6 +17192,9 @@ class JsonRpcApiProvider extends AbstractProvider {
return new FilterIdPendingSubscriber(this);
}
if (sub.type === "event") {
if (this._getOption("polling")) {
return new PollingEventSubscriber(this, sub.filter);
}
return new FilterIdEventSubscriber(this, sub.filter);
}
// Orphaned Logs are handled automatically, by the filter, since
@@ -17282,74 +17350,6 @@ class JsonRpcApiProvider extends AbstractProvider {
const e = AbiCoder.getBuiltinCallException((method === "eth_call") ? "call" : "estimateGas", (payload.params[0]), (result ? result.data : null));
e.info = { error, payload };
return e;
/*
let message = "missing revert data during JSON-RPC call";
const action = <"call" | "estimateGas" | "unknown">(({ eth_call: "call", eth_estimateGas: "estimateGas" })[method] || "unknown");
let data: null | string = null;
let reason: null | string = null;
const transaction = <{ from: string, to: string, data: string }>((<any>payload).params[0]);
const invocation = null;
let revert: null | { signature: string, name: string, args: Array<any> } = null;
if (result) {
// @TODO: Extract errorSignature, errorName, errorArgs, reason if
// it is Error(string) or Panic(uint25)
message = "execution reverted during JSON-RPC call";
data = result.data;
let bytes = getBytes(data);
if (bytes.length % 32 !== 4) {
message += " (could not parse reason; invalid data length)";
} else if (data.substring(0, 10) === "0x08c379a0") {
// Error(string)
try {
if (bytes.length < 68) { throw new Error("bad length"); }
bytes = bytes.slice(4);
const pointer = getNumber(hexlify(bytes.slice(0, 32)));
bytes = bytes.slice(pointer);
if (bytes.length < 32) { throw new Error("overrun"); }
const length = getNumber(hexlify(bytes.slice(0, 32)));
bytes = bytes.slice(32);
if (bytes.length < length) { throw new Error("overrun"); }
reason = toUtf8String(bytes.slice(0, length));
revert = {
signature: "Error(string)",
name: "Error",
args: [ reason ]
};
message += `: ${ JSON.stringify(reason) }`;
} catch (error) {
console.log(error);
message += " (could not parse reason; invalid data length)";
}
} else if (data.substring(0, 10) === "0x4e487b71") {
// Panic(uint256)
try {
if (bytes.length !== 36) { throw new Error("bad length"); }
const arg = getNumber(hexlify(bytes.slice(4)));
revert = {
signature: "Panic(uint256)",
name: "Panic",
args: [ arg ]
};
reason = `Panic due to ${ PanicReasons.get(Number(arg)) || "UNKNOWN" }(${ arg })`;
message += `: ${ reason }`;
} catch (error) {
console.log(error);
message += " (could not parse panic reason)";
}
}
}
return makeError(message, "CALL_EXCEPTION", {
action, data, reason, transaction, invocation, revert,
info: { payload, error }
});
*/
}
// Only estimateGas and call can return arbitrary contract-defined text, so now we
// we can process text safely.
@@ -17374,7 +17374,7 @@ class JsonRpcApiProvider extends AbstractProvider {
const transaction = (payload.params[0]);
if (message.match(/insufficient funds|base fee exceeds gas limit/i)) {
return makeError("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", {
transaction
transaction, info: { error }
});
}
if (message.match(/nonce/i) && message.match(/too low/i)) {
@@ -17392,7 +17392,7 @@ class JsonRpcApiProvider extends AbstractProvider {
}
if (message.match(/the method .* does not exist/i)) {
return makeError("unsupported operation", "UNSUPPORTED_OPERATION", {
operation: payload.method
operation: payload.method, info: { error }
});
}
return makeError("could not coalesce error", "UNKNOWN_ERROR", { error });
@@ -19023,7 +19023,7 @@ function getMedian(quorum, results) {
}
// Get the sorted values
values.sort((a, b) => ((a < b) ? -1 : (b > a) ? 1 : 0));
const mid = values.length / 2;
const mid = Math.floor(values.length / 2);
// Odd-length; take the middle value
if (values.length % 2) {
return values[mid];
@@ -19482,7 +19482,7 @@ function getDefaultProvider(network, options) {
*/
if (options.quicknode !== "-") {
try {
let token = options.qquicknode;
let token = options.quicknode;
providers.push(new QuickNodeProvider(network, token));
}
catch (error) {
@@ -19740,7 +19740,7 @@ const IpcSocketProvider = undefined;
/**
* About providers.
*
* @_section: api/providers:Providers [providers]
* @_section: api/providers:Providers [about-providers]
*/
/**
@@ -19895,7 +19895,7 @@ function decodeOwl(data) {
/**
* A Wordlist represents a collection of language-specific
* words used to encode and devoce [[BIP-39]] encoded data
* words used to encode and devoce [[link-bip-39]] encoded data
* by mapping words to 11-bit values and vice versa.
*/
class Wordlist {
@@ -20086,7 +20086,7 @@ function entropyToMnemonic(entropy, wordlist) {
}
const _guard$1 = {};
/**
* A **Mnemonic** wraps all properties required to compute [[link-bip39]]
* A **Mnemonic** wraps all properties required to compute [[link-bip-39]]
* seeds and convert between phrases and entropy.
*/
class Mnemonic {
@@ -20166,7 +20166,7 @@ class Mnemonic {
return mnemonicToEntropy(phrase, wordlist);
}
/**
* Returns true if %%phrase%% is a valid [[link-bip39]] phrase.
* Returns true if %%phrase%% is a valid [[link-bip-39]] phrase.
*
* This checks all the provided words belong to the %%wordlist%%,
* that the length is valid and the checksum is correct.
@@ -20722,8 +20722,8 @@ function pkcs7Strip(data) {
* @_ignore
*/
function looseArrayify(hexString) {
if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') {
hexString = '0x' + hexString;
if (typeof (hexString) === "string" && !hexString.startsWith("0x")) {
hexString = "0x" + hexString;
}
return getBytesCopy(hexString);
}
@@ -20904,7 +20904,7 @@ function getAccount(data, _key) {
const address = computeAddress(privateKey);
if (data.address) {
let check = data.address.toLowerCase();
if (check.substring(0, 2) !== "0x") {
if (!check.startsWith("0x")) {
check = "0x" + check;
}
assertArgument(getAddress(check) === address, "keystore address/privateKey mismatch", "address", data.address);
@@ -21697,6 +21697,9 @@ class Wallet extends BaseWallet {
* to %%provider%%.
*/
constructor(key, provider) {
if (typeof (key) === "string" && !key.startsWith("0x")) {
key = "0x" + key;
}
let signingKey = (typeof (key) === "string") ? new SigningKey(key) : key;
super(signingKey, provider);
}
@@ -21828,7 +21831,7 @@ class Wallet extends BaseWallet {
* low-level details of how an HD wallets are derived, exported
* or imported.
*
* @_section: api/wallet:Wallets [wallets]
* @_section: api/wallet:Wallets [about-wallets]
*/
const Base64 = ")!@#$%^&*(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
@@ -21933,7 +21936,7 @@ const wordlists = {
* languages, but for maximal compatibility, the
* [English Wordlist](LangEn) is recommended.
*
* @_section: api/wordlists:Wordlists [wordlists]
* @_section: api/wordlists:Wordlists [about-wordlists]
*/
/////////////////////////////

2
dist/ethers.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -145,7 +145,11 @@ const u64 = {
add, add3L, add3H, add4L, add4H, add5H, add5L,
};
const version = "6.0.2";
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
/**
* The current version of Ethers.
*/
const version = "6.0.5";
/**
* Property helper functions.
@@ -278,7 +282,7 @@ function makeError(message, code, info) {
}
defineProperties(error, { code });
if (info) {
defineProperties(error, info);
Object.assign(error, info);
}
return error;
}
@@ -426,7 +430,21 @@ function replaceFunc(reason, offset, bytes, output, badCodepoint) {
// Otherwise, process as if ignoring errors
return ignoreFunc(reason, offset, bytes);
}
// Common error handing strategies
/**
* A handful of popular, built-in UTF-8 error handling strategies.
*
* **``"error"``** - throws on ANY illegal UTF-8 sequence or
* non-canonical (overlong) codepoints (this is the default)
*
* **``"ignore"``** - silently drops any illegal UTF-8 sequence
* and accepts non-canonical (overlong) codepoints
*
* **``"replace"``** - replace any illegal UTF-8 sequence with the
* UTF-8 replacement character (i.e. `\ufffd`) and accepts
* non-canonical (overlong) codepoints
*
* @returns: Record<"error" | "ignore" | "replace", Utf8ErrorFunc>
*/
const Utf8ErrorFuncs = Object.freeze({
error: errorFunc,
ignore: ignoreFunc,
@@ -571,7 +589,7 @@ function _toUtf8String(codePoints) {
*
* When %%onError%% function is specified, it is called on UTF-8
* errors allowing recovery using the [[Utf8ErrorFunc]] API.
* (default: [error](Utf8ErrorFuncs-error))
* (default: [error](Utf8ErrorFuncs))
*/
function toUtf8String(bytes, onError) {
return _toUtf8String(getUtf8CodePoints(bytes, onError));
@@ -897,7 +915,7 @@ function decodeOwl(data) {
/**
* A Wordlist represents a collection of language-specific
* words used to encode and devoce [[BIP-39]] encoded data
* words used to encode and devoce [[link-bip-39]] encoded data
* by mapping words to 11-bit values and vice versa.
*/
class Wordlist {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
_section: Contributings and Hacking @<about-contrib> @priority<-90>
_section: Contributions and Hacking @<about-contrib> @priority<-90>
Pull requests are welcome, but please keep the following in mind:
@@ -93,7 +93,7 @@ _subsection: Adding Features @<about-contrib-feature>
Contributing new features usually require a deeper understanding
of the internal interactions with Ethers and its components, and
generally requires a minor version bumpincludes anything w
generally requires a minor version bump.
When making any of the following changes, you must first open a
[[link-discussion]] as the minor version will need to be bumped.

View File

@@ -48,7 +48,7 @@ objects available and what they are responsible for, at a high level.
_heading: Provider
A [[Provider]] is a read-only connection to the blockchain, which allows
querying the blockchain state, such as accout, block or transaction details,
querying the blockchain state, such as account, block or transaction details,
querying event logs or evaluating read-only code using call.
If you are coming from Web3.js, you are used to a **Provider** offering
@@ -118,7 +118,7 @@ extension that injects objects into the ``window``, providing:
- authenticated write access backed by a private key (a [[Signer]])
When requesting access to the authenticated methods, such as
sending a transaction or even requesting the private key addess,
sending a transaction or even requesting the private key address,
MetaMask will show a pop-up to the user asking for permission.
_code: @lang<script>
@@ -172,7 +172,7 @@ _code: connecting to a JSON-RPC URL @lang<script>
_subsection: User Interaction @<starting-display>
All units in Ethereum tend to be integer values, since dealing with
decimals and floating points can lead to inprecise and non-obvious
decimals and floating points can lead to imprecise and non-obvious
results when performing mathematic operations.
As a result, the internal units used (e.g. wei) which are suited for
@@ -272,7 +272,7 @@ _subsection: Contracts @<starting-contracts>
A **Contract** is a meta-class, which means that its definition
its derived at run-time, based on the ABI it is passed, which then
determined what mehods and properties are available on it.
determined what methods and properties are available on it.
_heading: Application Binary Interface (ABI)
@@ -291,7 +291,7 @@ Any methods or events that are not needed can be safely excluded.
There are several common formats available to describe an ABI. The
Solidity compiler usually dumps a JSON representation but when typing
an ABI by hand it is often easier (and more readable) to use the
human-readable ABI, which is just the Solidity signautre.
human-readable ABI, which is just the Solidity signature.
_code: simplified ERC-20 ABI @lang<script>
abi = [
@@ -478,7 +478,7 @@ it. It can also be used to sign other forms of data, which are then able
to be validated for other purposes.
For example, signing **a message** can be used to prove ownership of an
account which a website could use to authenicate a user and log them in.
account which a website could use to authenticate a user and log them in.
_code: @lang<javascript>

View File

@@ -3,7 +3,7 @@ _section: Documentation @<about-home> @nav<Documentation>
The ethers.js library aims to be a complete and compact library
for interacting with the Ethereum Blockchain and its ecosystem.
It is ofen used to create decentralized applications (dapps),
It is often used to create decentralized applications (dapps),
wallets (such as [[link-metamask]] and [[link-tally]]) and
other tools and simple scripts that require reading and writing
to the blockchain.
@@ -14,7 +14,7 @@ _subsection: About this documentation?
These docs are still under construction, and are being expanded
every day.
Developers new to Ethers shoud be sure to read through the
Developers new to Ethers should be sure to read through the
[[getting-started]] section.
And the [[about-api]] is available for drilling down into more details

View File

@@ -34,7 +34,7 @@ link-infura-secret [link-infura-secret](https://infura.io/docs/gettingStarted/au
link-parity-trace [link-parity-trace](https://openethereum.github.io/wiki/JSONRPC-trace-module)
link-parity-rpc [link-parity-rpc](https://openethereum.github.io/wiki/JSONRPC)
link-pocket-signup [link-pocket-signup](https://pokt.network/pocket-gateway-ethereum-mainnet/)
link-web3 [link-web3](https://github.com/ethereum/web3.js)
link-web3js [link-web3](https://github.com/ethereum/web3.js)
link-web3-http [link-web3-http](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http)
link-web3-ipc [link-web3-ipc](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ipc)
link-web3-send [link-web3-send](https://github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-http/types/index.d.ts#L57)

View File

@@ -39,7 +39,7 @@ link-icap [ICAP Address](https://github.com/ethereum/wiki/wiki/Inter-exchange-Cl
link-jsonrpc [link-jsonrpc](https://github.com/ethereum/wiki/wiki/JSON-RPC)
link-mit [MIT License](https://en.m.wikipedia.org/wiki/MIT_License)
link-namehash [namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names)
link-rlp [Recursive-Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)
link-rlp [Recursive-Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/)
link-pbkdf2 [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2)
link-solc-errors [Solidity Custom Errors](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#errors)
link-solc-events [Solidity Events](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#events)

View File

@@ -10,7 +10,11 @@ so a lot of changes are largely internal.
- [BigNumbers](migrate-bigint)
- [Contracts](migrate-contracts)
- [Importing](migrate-importing)
- [Odds and Ends](migrate-other)
- [Providers](migrate-providers)
- [Signatures](migrate-signatures)
- [Transactions](migrate-transactions)
- [Utilities](migrate-utils)
- [Removed Items](migrate-missing)
_subsection: Big Numbers @<migrate-bigint>
@@ -32,7 +36,7 @@ _code: creating large numbers @lang<script>
// Using BigNumber in v5
value = BigNumber.from("1000")
// Using BigInt in v6 (ysing literal notation).
// Using BigInt in v6 (using literal notation).
// Notice the suffix n
value = 1000n
@@ -193,10 +197,95 @@ _code: importing in v6 @lang<script>
import { InfuraProvider } from "ethers/providers"
_subsection: Odds and Ends @<migrate-other>
_subsection: Providers @<migrate-providers>
In addition to all the ``ethers.providers.*`` being moved to
``ethers.*``, the biggest change developers need to keep in
mind is that ``Web3Provider`` (which historically was used
to wrap [[link-web3js]] providers) is now called
[[BrowserProvider]] which is designed to wrap EIP-1193
providers, which is the standard that both modern Web3.js and
injected providers offer.
_code: wrapping EIP-1193 providers @lang<script>
// v5
provider = new ethers.providers.Web3Provider(window.ethereum)
// v6:
provider = new ethers.BrowserProvider(window.ethereum)
_code: default AbiCoder @lang<script>
_subsection: Signatures @<migrate-signatures>
The Signature is now a class which facilitates all the parsing
and serializing.
_code: signature manipulation
// v5
splitSig = splitSignature(sigBytes)
sigBytes = joinSignature(splitSig)
// v6
splitSig = ethers.Signature.from(sigBytes)
sigBytes = ethers.Signature.from(splitSig).serialized
_subsection: Transactions @<migrate-transactions>
The transaction helpers present in v5 were all wrapped into a
[[Transaction]] class, which can handle any supported transaction
format to be further processed
_code: parasing transactions @lang<script>
// v5
tx = parseTransaction(txBytes)
txBytes = serializeTransaction(tx)
txBytes = serializeTransaction(tx, sig)
// v6
tx = Transaction.from(txBytes)
// v6 (the tx can optionally include the signature)
txBytes = Transaction.from(tx).serialized
_subsection: Utilities @<migrate-utils>
_code: Bytes32 string helpers @lang<script>
// In v5:
bytes32 = ethers.utils.formatBytes32String(text)
text = ethers.utils.parseBytes32String(bytes32)
// In v6:
bytes32 = ethers.encodeBytes32String(text)
text = ethers.decodeBytes32String(bytes32)
_code: constants @lang<script>
// v5:
ethers.constants.AddressZero
ethers.constants.HashZero
// v6:
ethers.ZeroAddress
ethers.ZeroHash
_code: data manipulation @lang<script>
// v5
slice = ethers.utils.hexDataSlice(value, start, end)
padded = ethers.utils.hexZeroPad(value, length)
// v5; converting numbers to hexstrings
hex = hexlify(35)
// v6
slice = ethers.dataSlice(value, start, end)
padded = ethers.zeroPadValue(value, length)
// v6; converting numbers to hexstrings
hex = toBeHex(35)
_code: defaultAbiCoder @lang<script>
// In v5, it is a property of AbiCoder
coder = AbiCoder.defaultAbiCoder
@@ -206,23 +295,34 @@ _code: default AbiCoder @lang<script>
// instance is returned.
coder = AbiCoder.defaultAbiCoder()
_code: getting a JSON-RPC quantity @lang<script>
// In v5:
hex = ethers.util.hexValue(value)
_code: hex conversion @lang<script>
// v5
hex = ethers.utils.hexValue(value)
array = ethers.utils.arrayify(value)
// In v6:
// v6
hex = ethers.toQuantity(value)
array = ethers.getBytes(value)
_code: using Bytes32 strings @lang<script>
// In v5:
bytes32 = formatBytes32String(text)
text = parseBytes32String(bytes32)
_code: solidity non-standard packed @lang<script>
// v5
ethers.utils.solidityPack(types, values)
// In v6:
bytes32 = encodeBytes32String(text)
text = decodeBytes32String(bytes32)
// v6
ethers.solidityPacked(types, values)
_subsection: Removed Classes and functions
_code: property manipulation @lang<script>
// v5
ethers.utils.defineReadOnly(obj, "name", value)
// v6
ethers.defineProperties(obj, { name: value });
_subsection: Removed Classes and functions @<migrate-missing>
The **Logger** class has been replaced by
[several Error utility functions](about-errors).
The ``checkProperties`` and ``shallowCopy`` have been
removed in favor of using ``.map`` and ``Object.assign``.

View File

@@ -1,84 +0,0 @@
export type TestBlockchainNetwork = "mainnet" | "goerli";
export interface TestBlockchainAddress {
test: string;
address: string;
code?: string;
nonce?: number;
name?: string;
balance?: bigint;
storage?: Record<string, string>;
}
export interface TestBlockchainBlock {
test: string;
hash: string;
parentHash: string;
number: number;
timestamp: number;
nonce: string;
difficulty: bigint;
gasLimit: bigint;
gasUsed: bigint;
miner: string;
extraData: string;
transactions: Array<string>;
baseFeePerGas?: bigint;
}
export interface TestBlockchainTransaction {
test: string;
hash: string;
blockHash: string;
blockNumber: number;
type: number;
from: string;
gasPrice: bigint;
gasLimit: bigint;
to: string;
value: bigint;
nonce: number;
data: string;
signature: {
r: string;
s: string;
yParity: 0 | 1;
v: number;
networkV: null | bigint;
};
creates: null | string;
chainId: bigint;
accessList?: Array<Record<string, Array<string>>>;
maxPriorityFeePerGas?: bigint;
maxFeePerGas?: bigint;
}
export interface TestBlockchainReceipt {
test: string;
blockHash: string;
blockNumber: number;
type: number;
contractAddress: null | string;
cumulativeGasUsed: bigint;
from: string;
gasUsed: bigint;
gasPrice: bigint;
logs: Array<{
address: string;
blockHash: string;
blockNumber: number;
data: string;
index: number;
topics: Array<string>;
transactionHash: string;
transactionIndex: number;
}>;
logsBloom: string;
root: null | string;
status: null | number;
to: string;
hash: string;
index: number;
}
export declare const testAddress: Record<TestBlockchainNetwork, Array<TestBlockchainAddress>>;
export declare const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>>;
export declare const testTransaction: Record<TestBlockchainNetwork, Array<TestBlockchainTransaction>>;
export declare const testReceipt: Record<TestBlockchainNetwork, Array<TestBlockchainReceipt>>;
export declare const networkNames: Array<TestBlockchainNetwork>;
export declare function networkFeatureAtBlock(feature: string, block: number): boolean;

View File

@@ -1,7 +0,0 @@
import type { AbstractProvider } from "../index.js";
export declare function setupProviders(): void;
export declare const providerNames: readonly string[];
export declare function getProviderNetworks(provider: string): Array<string>;
export declare function getProvider(provider: string, network: string): null | AbstractProvider;
export declare function checkProvider(provider: string, network: string): boolean;
export declare function connect(network: string): AbstractProvider;

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -189,11 +189,19 @@ describe("Test Provider Transaction operations", function () {
assert_1.default.ok(receipt != null, "receipt != null");
// Cloudflare doesn't return the root in legacy receipts; but it isn't
// *actually* that important, so we'll give it a pass...
if (providerName === "CloudflareProvider") {
if (providerName === "CloudflareProvider" || providerName === "AnkrProvider" || providerName === "PocketProvider") {
test = Object.assign({}, test, { root: undefined });
}
//if (providerName === "PocketProvider") {
//}
assertReceipt(receipt, test);
};
});
forEach("test lookupAddress(addr) == null", blockchain_data_js_1.testReceipt, (providerName, test) => {
return async (provider) => {
const name = await provider.lookupAddress("0x0123456789012345678901234567890123456789");
assert_1.default.ok(name == null, "name == null");
};
});
});
//# sourceMappingURL=test-providers-data.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1,12 +0,0 @@
export type TestCaseBadString = {
name: string;
bytes: Uint8Array;
ignore: string;
replace: string;
error: string;
};
export type TestCaseCodePoints = {
name: string;
text: string;
codepoints: Array<number>;
};

View File

@@ -1,6 +0,0 @@
declare global {
class TextDecoder {
decode(data: Uint8Array): string;
}
}
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1 +0,0 @@
export {};

View File

@@ -1,216 +0,0 @@
export type TestCaseAbiVerbose = {
type: "address" | "hexstring" | "number" | "string";
value: string;
} | {
type: "boolean";
value: boolean;
} | {
type: "array";
value: Array<TestCaseAbiVerbose>;
} | {
type: "object";
value: Array<TestCaseAbiVerbose>;
};
export interface TestCaseAbi {
name: string;
type: string;
value: any;
verbose: TestCaseAbiVerbose;
bytecode: string;
encoded: string;
}
export interface TestCaseAccount {
name: string;
privateKey: string;
address: string;
icap: string;
}
export type TestCaseCreate = {
sender: string;
creates: Array<{
name: string;
nonce: number;
address: string;
}>;
};
export type TestCaseCreate2 = {
sender: string;
creates: Array<{
name: string;
salt: string;
initCode: string;
initCodeHash: string;
address: string;
}>;
};
export interface TestCaseHash {
name: string;
data: string;
sha256: string;
sha512: string;
ripemd160: string;
keccak256: string;
}
export interface TestCasePbkdf {
name: string;
password: string;
salt: string;
dkLen: number;
pbkdf2: {
iterations: number;
algorithm: "sha256" | "sha512";
key: string;
};
scrypt: {
N: number;
r: number;
p: number;
key: string;
};
}
export interface TestCaseHmac {
name: string;
data: string;
key: string;
algorithm: "sha256" | "sha512";
hmac: string;
}
export interface TestCaseHash {
name: string;
data: string;
sha256: string;
sha512: string;
ripemd160: string;
keccak256: string;
}
export interface TestCaseNamehash {
name: string;
ensName: string;
error?: string;
namehash?: string;
}
export interface TestCaseTypedDataDomain {
name?: string;
version?: string;
chainId?: number;
verifyingContract?: string;
salt?: string;
}
export interface TestCaseTypedDataType {
name: string;
type: string;
}
export interface TestCaseTypedData {
name: string;
domain: TestCaseTypedDataDomain;
primaryType: string;
types: Record<string, Array<TestCaseTypedDataType>>;
data: any;
encoded: string;
digest: string;
privateKey?: string;
signature?: string;
}
export interface TestCaseSolidityHash {
name: string;
types: Array<string>;
keccak256: string;
ripemd160: string;
sha256: string;
values: Array<any>;
}
export interface TestCaseUnit {
name: string;
wei: string;
ethers: string;
ether_format: string;
kwei?: string;
mwei?: string;
gwei?: string;
szabo?: string;
finney?: string;
finney_format?: string;
szabo_format?: string;
gwei_format?: string;
mwei_format?: string;
kwei_format?: string;
}
export type NestedHexString = string | Array<string | NestedHexString>;
export interface TestCaseRlp {
name: string;
encoded: string;
decoded: NestedHexString;
}
export interface TestCaseTransactionTx {
to?: string;
nonce?: number;
gasLimit?: string;
gasPrice?: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
data?: string;
value?: string;
accessList?: Array<{
address: string;
storageKeys: Array<string>;
}>;
chainId?: string;
}
export interface TestCaseTransactionSig {
r: string;
s: string;
v: string;
}
export interface TestCaseTransaction {
name: string;
transaction: TestCaseTransactionTx;
privateKey: string;
unsignedLegacy: string;
signedLegacy: string;
unsignedEip155: string;
signedEip155: string;
unsignedBerlin: string;
signedBerlin: string;
unsignedLondon: string;
signedLondon: string;
signatureLegacy: TestCaseTransactionSig;
signatureEip155: TestCaseTransactionSig;
signatureBerlin: TestCaseTransactionSig;
signatureLondon: TestCaseTransactionSig;
}
export interface TestCaseMnemonicNode {
path: string;
chainCode: string;
depth: number;
index: number;
parentFingerprint: string;
fingerprint: string;
publicKey: string;
privateKey: string;
xpriv: string;
xpub: string;
}
export interface TestCaseMnemonic {
name: string;
phrase: string;
phraseHash: string;
password: string;
locale: string;
entropy: string;
seed: string;
nodes: Array<TestCaseMnemonicNode>;
}
export interface TestCaseWallet {
name: string;
filename: string;
type: string;
address: string;
password: string;
content: string;
}
export interface TestCaseWordlist {
name: string;
filename: string;
locale: string;
content: string;
}

View File

@@ -1,8 +0,0 @@
export declare function loadTests<T>(tag: string): Array<T>;
export declare function log(context: any, text: string): void;
export declare function stall(duration: number): Promise<void>;
export interface MochaRunnable {
timeout: (value: number) => void;
skip: () => void;
}
export declare function retryIt(name: string, func: (this: MochaRunnable) => Promise<void>): Promise<void>;

View File

@@ -1 +0,0 @@
export declare const version: string;

View File

@@ -1,5 +1,9 @@
"use strict";
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "6.0.2";
/**
* The current version of Ethers.
*/
exports.version = "6.0.5";
//# sourceMappingURL=_version.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"_version.js","sourceRoot":"","sources":["../src.ts/_version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAW,OAAO,CAAC"}
{"version":3,"file":"_version.js","sourceRoot":"","sources":["../src.ts/_version.ts"],"names":[],"mappings":";AAAA,mEAAmE;;;AAEnE;;GAEG;AACU,QAAA,OAAO,GAAW,OAAO,CAAC"}

View File

@@ -1,58 +0,0 @@
/**
* When sending values to or receiving values from a [[Contract]], the
* data is generally encoded using the [ABI standard](solc-abi-standard).
*
* The AbiCoder provides a utility to encode values to ABI data and
* decode values from ABI data.
*
* Most of the time, developers should favour the [[Contract]] class,
* which further abstracts a lot of the finer details of ABI data.
*
* @_section api/abi/abi-coder:ABI Encoding
*/
import { Result } from "./coders/abstract-coder.js";
import { ParamType } from "./fragments.js";
import type { BytesLike, CallExceptionAction, CallExceptionError } from "../utils/index.js";
/**
* About AbiCoder
*/
export declare class AbiCoder {
#private;
/**
* Get the default values for the given %%types%%.
*
* For example, a ``uint`` is by default ``0`` and ``bool``
* is by default ``false``.
*/
getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
/**
* Encode the %%values%% as the %%types%% into ABI data.
*
* @returns DataHexstring
*/
encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
/**
* Decode the ABI %%data%% as the %%types%% into values.
*
* If %%loose%% decoding is enabled, then strict padding is
* not enforced. Some older versions of Solidity incorrectly
* padded event data emitted from ``external`` functions.
*/
decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
/**
* Returns the shared singleton instance of a default [[AbiCoder]].
*
* On the first call, the instance is created internally.
*/
static defaultAbiCoder(): AbiCoder;
/**
* Returns an ethers-compatible [[CALL_EXCEPTION]] Error for the given
* result %%data%% for the [[CallExceptionAction]] %%action%% against
* the Transaction %%tx%%.
*/
static getBuiltinCallException(action: CallExceptionAction, tx: {
to?: null | string;
from?: null | string;
data?: string;
}, data: null | BytesLike): CallExceptionError;
}

View File

@@ -52,7 +52,11 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
message = "execution reverted";
const bytes = (0, index_js_3.getBytes)(data);
data = (0, index_js_3.hexlify)(data);
if (bytes.length % 32 !== 4) {
if (bytes.length === 0) {
message += " (no data present; likely require(false) occurred";
reason = "require(false)";
}
else if (bytes.length % 32 !== 4) {
message += " (could not decode reason; invalid data length)";
}
else if ((0, index_js_3.hexlify)(bytes.slice(0, 4)) === "0x08c379a0") {
@@ -67,8 +71,7 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
message += `: ${JSON.stringify(reason)}`;
}
catch (error) {
console.log(error);
message += " (could not decode reason; invalid data)";
message += " (could not decode reason; invalid string data)";
}
}
else if ((0, index_js_3.hexlify)(bytes.slice(0, 4)) === "0x4e487b71") {
@@ -84,8 +87,7 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
message += `: ${reason}`;
}
catch (error) {
console.log(error);
message += " (could not decode panic reason)";
message += " (could not decode panic code)";
}
}
else {
@@ -190,7 +192,7 @@ class AbiCoder {
return defaultCoder;
}
/**
* Returns an ethers-compatible [[CALL_EXCEPTION]] Error for the given
* Returns an ethers-compatible [[CallExceptionError]] Error for the given
* result %%data%% for the [[CallExceptionAction]] %%action%% against
* the Transaction %%tx%%.
*/

File diff suppressed because one or more lines are too long

View File

@@ -1,14 +0,0 @@
/**
* About bytes32 strings...
*
* @_docloc: api/utils:Bytes32 Strings
*/
import type { BytesLike } from "../utils/index.js";
/**
* Encodes %%text%% as a Bytes32 string.
*/
export declare function encodeBytes32String(text: string): string;
/**
* Encodes the Bytes32-encoded %%bytes%% into a string.
*/
export declare function decodeBytes32String(_bytes: BytesLike): string;

View File

@@ -1,116 +0,0 @@
import type { BigNumberish, BytesLike } from "../../utils/index.js";
/**
* @_ignore:
*/
export declare const WordSize: number;
/**
* A [[Result]] is a sub-class of Array, which allows accessing any
* of its values either positionally by its index or, if keys are
* provided by its name.
*
* @_docloc: api/abi
*/
export declare class Result extends Array<any> {
#private;
[K: string | number]: any;
/**
* @private
*/
constructor(...args: Array<any>);
/**
* Returns the Result as a normal Array.
*
* This will throw if there are any outstanding deferred
* errors.
*/
toArray(): Array<any>;
/**
* Returns the Result as an Object with each name-value pair.
*
* This will throw if any value is unnamed, or if there are
* any outstanding deferred errors.
*/
toObject(): Record<string, any>;
/**
* @_ignore
*/
slice(start?: number | undefined, end?: number | undefined): Result;
/**
* @_ignore
*/
filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result;
/**
* Returns the value for %%name%%.
*
* Since it is possible to have a key whose name conflicts with
* a method on a [[Result]] or its superclass Array, or any
* JavaScript keyword, this ensures all named values are still
* accessible by name.
*/
getValue(name: string): any;
/**
* Creates a new [[Result]] for %%items%% with each entry
* also accessible by its corresponding name in %%keys%%.
*/
static fromItems(items: Array<any>, keys?: Array<null | string>): Result;
}
/**
* Returns all errors found in a [[Result]].
*
* Since certain errors encountered when creating a [[Result]] do
* not impact the ability to continue parsing data, they are
* deferred until they are actually accessed. Hence a faulty string
* in an Event that is never used does not impact the program flow.
*
* However, sometimes it may be useful to access, identify or
* validate correctness of a [[Result]].
*
* @_docloc api/abi
*/
export declare function checkResultErrors(result: Result): Array<{
path: Array<string | number>;
error: Error;
}>;
/**
* @_ignore
*/
export declare abstract class Coder {
readonly name: string;
readonly type: string;
readonly localName: string;
readonly dynamic: boolean;
constructor(name: string, type: string, localName: string, dynamic: boolean);
_throwError(message: string, value: any): never;
abstract encode(writer: Writer, value: any): number;
abstract decode(reader: Reader): any;
abstract defaultValue(): any;
}
/**
* @_ignore
*/
export declare class Writer {
#private;
constructor();
get data(): string;
get length(): number;
appendWriter(writer: Writer): number;
writeBytes(value: BytesLike): number;
writeValue(value: BigNumberish): number;
writeUpdatableValue(): (value: BigNumberish) => void;
}
/**
* @_ignore
*/
export declare class Reader {
#private;
readonly allowLoose: boolean;
constructor(data: BytesLike, allowLoose?: boolean);
get data(): string;
get dataLength(): number;
get consumed(): number;
get bytes(): Uint8Array;
subReader(offset: number): Reader;
readBytes(length: number, loose?: boolean): Uint8Array;
readValue(): bigint;
readIndex(): number;
}

View File

@@ -112,12 +112,14 @@ class Result extends Array {
* errors.
*/
toArray() {
const result = [];
this.forEach((item, index) => {
if (item instanceof Error) {
throwError(`index ${index}`, item);
}
result.push(item);
});
return Array.of(this);
return result;
}
/**
* Returns the Result as an Object with each name-value pair.
@@ -144,9 +146,24 @@ class Result extends Array {
if (start == null) {
start = 0;
}
if (start < 0) {
start += this.length;
if (start < 0) {
start = 0;
}
}
if (end == null) {
end = this.length;
}
if (end < 0) {
end += this.length;
if (end < 0) {
end = 0;
}
}
if (end > this.length) {
end = this.length;
}
const result = [], names = [];
for (let i = start; i < end; i++) {
result.push(this[i]);

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +0,0 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class AddressCoder extends Coder {
constructor(localName: string);
defaultValue(): string;
encode(writer: Writer, _value: string | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -1,14 +0,0 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* Clones the functionality of an existing Coder, but without a localName
*
* @_ignore
*/
export declare class AnonymousCoder extends Coder {
private coder;
constructor(coder: Coder);
defaultValue(): any;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

View File

@@ -1,24 +0,0 @@
import { Typed } from "../typed.js";
import { Coder, Result, Writer } from "./abstract-coder.js";
import type { Reader } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare function pack(writer: Writer, coders: ReadonlyArray<Coder>, values: Array<any> | {
[name: string]: any;
}): number;
/**
* @_ignore
*/
export declare function unpack(reader: Reader, coders: ReadonlyArray<Coder>): Result;
/**
* @_ignore
*/
export declare class ArrayCoder extends Coder {
readonly coder: Coder;
readonly length: number;
constructor(coder: Coder, length: number, localName: string);
defaultValue(): Array<any>;
encode(writer: Writer, _value: Array<any> | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -18,7 +18,7 @@ function pack(writer, coders, values) {
arrayValues = coders.map((coder) => {
const name = coder.localName;
(0, index_js_1.assert)(name, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
(0, index_js_1.assert)(unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
(0, index_js_1.assert)(!unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
unique[name] = true;
return values[name];
});

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +0,0 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class BooleanCoder extends Coder {
constructor(localName: string);
defaultValue(): boolean;
encode(writer: Writer, _value: boolean | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -1,18 +0,0 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class DynamicBytesCoder extends Coder {
constructor(type: string, localName: string);
defaultValue(): string;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}
/**
* @_ignore
*/
export declare class BytesCoder extends DynamicBytesCoder {
constructor(localName: string);
decode(reader: Reader): any;
}

View File

@@ -1,14 +0,0 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { BytesLike } from "../../utils/index.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class FixedBytesCoder extends Coder {
readonly size: number;
constructor(size: number, localName: string);
defaultValue(): string;
encode(writer: Writer, _value: BytesLike | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -1,11 +0,0 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class NullCoder extends Coder {
constructor(localName: string);
defaultValue(): null;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

View File

@@ -1,15 +0,0 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { BigNumberish } from "../../utils/index.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class NumberCoder extends Coder {
readonly size: number;
readonly signed: boolean;
constructor(size: number, signed: boolean, localName: string);
defaultValue(): number;
encode(writer: Writer, _value: BigNumberish | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -1,12 +0,0 @@
import { Typed } from "../typed.js";
import { DynamicBytesCoder } from "./bytes.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class StringCoder extends DynamicBytesCoder {
constructor(localName: string);
defaultValue(): string;
encode(writer: Writer, _value: string | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -1,15 +0,0 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class TupleCoder extends Coder {
readonly coders: ReadonlyArray<Coder>;
constructor(coders: Array<Coder>, localName: string);
defaultValue(): any;
encode(writer: Writer, _value: Array<any> | {
[name: string]: any;
} | Typed): number;
decode(reader: Reader): any;
}

View File

@@ -1,372 +0,0 @@
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments
*/
/**
* A type description in a JSON API.
*/
export interface JsonFragmentType {
/**
* The parameter name.
*/
readonly name?: string;
/**
* If the parameter is indexed.
*/
readonly indexed?: boolean;
/**
* The type of the parameter.
*/
readonly type?: string;
/**
* The internal Solidity type.
*/
readonly internalType?: string;
/**
* The components for a tuple.
*/
readonly components?: ReadonlyArray<JsonFragmentType>;
}
/**
* A fragment for a method, event or error in a JSON API.
*/
export interface JsonFragment {
/**
* The name of the error, event, function, etc.
*/
readonly name?: string;
/**
* The type of the fragment (e.g. ``event``, ``"function"``, etc.)
*/
readonly type?: string;
/**
* If the event is anonymous.
*/
readonly anonymous?: boolean;
/**
* If the function is payable.
*/
readonly payable?: boolean;
/**
* If the function is constant.
*/
readonly constant?: boolean;
/**
* The mutability state of the function.
*/
readonly stateMutability?: string;
/**
* The input parameters.
*/
readonly inputs?: ReadonlyArray<JsonFragmentType>;
/**
* The output parameters.
*/
readonly outputs?: ReadonlyArray<JsonFragmentType>;
/**
* The gas limit to use when sending a transaction for this function.
*/
readonly gas?: string;
}
/**
* The format to serialize the output as.
*/
export type FormatType = "sighash" | "minimal" | "full" | "json";
/**
* When [walking](ParamType-walk) a [[ParamType]], this is called
* on each component.
*/
export type ParamTypeWalkFunc = (type: string, value: any) => any;
/**
* When [walking asynchronously](ParamType-walkAsync) a [[ParamType]],
* this is called on each component.
*/
export type ParamTypeWalkAsyncFunc = (type: string, value: any) => any | Promise<any>;
/**
* Each input and output of a [[Fragment]] is an Array of **PAramType**.
*/
export declare class ParamType {
#private;
/**
* The local name of the parameter (or ``""`` if unbound)
*/
readonly name: string;
/**
* The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``,
* ``"uint256[3][]"``)
*/
readonly type: string;
/**
* The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``)
*/
readonly baseType: string;
/**
* True if the parameters is indexed.
*
* For non-indexable types (see [[ParamType_isIndexable]]) this
* is ``null``.
*/
readonly indexed: null | boolean;
/**
* The components for the tuple.
*
* For non-tuple types (see [[ParamType_isTuple]]) this is ``null``.
*/
readonly components: null | ReadonlyArray<ParamType>;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
*/
readonly arrayLength: null | number;
/**
* The type of each child in the array.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
*/
readonly arrayChildren: null | ParamType;
/**
* @private
*/
constructor(guard: any, name: string, type: string, baseType: string, indexed: null | boolean, components: null | ReadonlyArray<ParamType>, arrayLength: null | number, arrayChildren: null | ParamType);
/**
* Return a string representation of this type.
*
* For example,
*
* ``sighash" => "(uint256,address)"``
*
* ``"minimal" => "tuple(uint256,address) indexed"``
*
* ``"full" => "tuple(uint256 foo, address bar) indexed baz"``
*/
format(format?: FormatType): string;
/**
* Returns true if %%this%% is an Array type.
*
* This provides a type gaurd ensuring that [[arrayChildren]]
* and [[arrayLength]] are non-null.
*/
isArray(): this is (ParamType & {
arrayChildren: ParamType;
arrayLength: number;
});
/**
* Returns true if %%this%% is a Tuple type.
*
* This provides a type gaurd ensuring that [[components]]
* is non-null.
*/
isTuple(): this is (ParamType & {
components: ReadonlyArray<ParamType>;
});
/**
* Returns true if %%this%% is an Indexable type.
*
* This provides a type gaurd ensuring that [[indexed]]
* is non-null.
*/
isIndexable(): this is (ParamType & {
indexed: boolean;
});
/**
* Walks the **ParamType** with %%value%%, calling %%process%%
* on each type, destructing the %%value%% recursively.
*/
walk(value: any, process: ParamTypeWalkFunc): any;
/**
* Walks the **ParamType** with %%value%%, asynchronously calling
* %%process%% on each type, destructing the %%value%% recursively.
*
* This can be used to resolve ENS naes by walking and resolving each
* ``"address"`` type.
*/
walkAsync(value: any, process: ParamTypeWalkAsyncFunc): Promise<any>;
/**
* Creates a new **ParamType** for %%obj%%.
*
* If %%allowIndexed%% then the ``indexed`` keyword is permitted,
* otherwise the ``indexed`` keyword will throw an error.
*/
static from(obj: any, allowIndexed?: boolean): ParamType;
/**
* Returns true if %%value%% is a **ParamType**.
*/
static isParamType(value: any): value is ParamType;
}
/**
* The type of a [[Fragment]].
*/
export type FragmentType = "constructor" | "error" | "event" | "fallback" | "function" | "struct";
/**
* An abstract class to represent An individual fragment from a parse ABI.
*/
export declare abstract class Fragment {
/**
* The type of the fragment.
*/
readonly type: FragmentType;
/**
* The inputs for the fragment.
*/
readonly inputs: ReadonlyArray<ParamType>;
/**
* @private
*/
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>);
/**
* Returns a string representation of this fragment.
*/
abstract format(format?: FormatType): string;
/**
* Creates a new **Fragment** for %%obj%%, wich can be any supported
* ABI frgament type.
*/
static from(obj: any): Fragment;
/**
* Returns true if %%value%% is a [[ConstructorFragment]].
*/
static isConstructor(value: any): value is ConstructorFragment;
/**
* Returns true if %%value%% is an [[ErrorFragment]].
*/
static isError(value: any): value is ErrorFragment;
/**
* Returns true if %%value%% is an [[EventFragment]].
*/
static isEvent(value: any): value is EventFragment;
/**
* Returns true if %%value%% is a [[FunctionFragment]].
*/
static isFunction(value: any): value is FunctionFragment;
/**
* Returns true if %%value%% is a [[StructFragment]].
*/
static isStruct(value: any): value is StructFragment;
}
/**
* An abstract class to represent An individual fragment
* which has a name from a parse ABI.
*/
export declare abstract class NamedFragment extends Fragment {
/**
* The name of the fragment.
*/
readonly name: string;
/**
* @private
*/
constructor(guard: any, type: FragmentType, name: string, inputs: ReadonlyArray<ParamType>);
}
/**
* A Fragment which represents a //Custom Error//.
*/
export declare class ErrorFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
/**
* The Custom Error selector.
*/
get selector(): string;
format(format?: FormatType): string;
static from(obj: any): ErrorFragment;
static isFragment(value: any): value is ErrorFragment;
}
/**
* A Fragment which represents an Event.
*/
export declare class EventFragment extends NamedFragment {
readonly anonymous: boolean;
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>, anonymous: boolean);
/**
* The Event topic hash.
*/
get topicHash(): string;
format(format?: FormatType): string;
static getTopicHash(name: string, params?: Array<any>): string;
static from(obj: any): EventFragment;
static isFragment(value: any): value is EventFragment;
}
/**
* A Fragment which represents a constructor.
*/
export declare class ConstructorFragment extends Fragment {
readonly payable: boolean;
readonly gas: null | bigint;
/**
* @private
*/
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>, payable: boolean, gas: null | bigint);
format(format?: FormatType): string;
static from(obj: any): ConstructorFragment;
static isFragment(value: any): value is ConstructorFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
constructor(guard: any, inputs: ReadonlyArray<ParamType>, payable: boolean);
format(format?: FormatType): string;
static from(obj: any): FallbackFragment;
static isFragment(value: any): value is FallbackFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FunctionFragment extends NamedFragment {
/**
* If the function is constant (e.g. ``pure`` or ``view`` functions).
*/
readonly constant: boolean;
/**
* The returned types for the result of calling this function.
*/
readonly outputs: ReadonlyArray<ParamType>;
/**
* The state mutability (e.g. ``payable``, ``nonpayable``, ``view``
* or ``pure``)
*/
readonly stateMutability: "payable" | "nonpayable" | "view" | "pure";
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
/**
* The amount of gas to send when calling this function
*/
readonly gas: null | bigint;
/**
* @private
*/
constructor(guard: any, name: string, stateMutability: "payable" | "nonpayable" | "view" | "pure", inputs: ReadonlyArray<ParamType>, outputs: ReadonlyArray<ParamType>, gas: null | bigint);
/**
* The Function selector.
*/
get selector(): string;
format(format?: FormatType): string;
static getSelector(name: string, params?: Array<any>): string;
static from(obj: any): FunctionFragment;
static isFragment(value: any): value is FunctionFragment;
}
/**
* A Fragment which represents a structure.
*/
export declare class StructFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
format(): string;
static from(obj: any): StructFragment;
static isFragment(value: any): value is FunctionFragment;
}

View File

@@ -2,7 +2,7 @@
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments
* @_subsection api/abi/abi-coder:Fragments [about-fragments]
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.StructFragment = exports.FunctionFragment = exports.FallbackFragment = exports.ConstructorFragment = exports.EventFragment = exports.ErrorFragment = exports.NamedFragment = exports.Fragment = exports.ParamType = void 0;
@@ -358,26 +358,25 @@ class ParamType {
/**
* True if the parameters is indexed.
*
* For non-indexable types (see [[ParamType_isIndexable]]) this
* is ``null``.
* For non-indexable types this is ``null``.
*/
indexed;
/**
* The components for the tuple.
*
* For non-tuple types (see [[ParamType_isTuple]]) this is ``null``.
* For non-tuple types this is ``null``.
*/
components;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
* For non-array types this is ``null``.
*/
arrayLength;
/**
* The type of each child in the array.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
* For non-array types this is ``null``.
*/
arrayChildren;
/**
@@ -672,7 +671,7 @@ class ParamType {
});
return new ParamType(_guard, name || "", type, "array", indexed, null, arrayLength, arrayChildren);
}
if (type === "tuple" || type.substring(0, 5) === "tuple(" || type[0] === "(") {
if (type === "tuple" || type.startsWith("tuple(" /* fix: ) */) || type.startsWith("(" /* fix: ) */)) {
const comps = (obj.components != null) ? obj.components.map((c) => ParamType.from(c)) : null;
const tuple = new ParamType(_guard, name || "", type, "tuple", indexed, comps, null, null);
// @TODO: use lexer to validate and normalize type

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +0,0 @@
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [abi]
* @_navTitle: ABI
*/
export { AbiCoder } from "./abi-coder.js";
export { decodeBytes32String, encodeBytes32String } from "./bytes32.js";
export { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { checkResultErrors, Indexed, Interface, ErrorDescription, LogDescription, TransactionDescription, Result } from "./interface.js";
export { Typed } from "./typed.js";
export type { JsonFragment, JsonFragmentType, FormatType, FragmentType, ParamTypeWalkAsyncFunc, ParamTypeWalkFunc } from "./fragments.js";
export type { InterfaceAbi, } from "./interface.js";

View File

@@ -2,7 +2,7 @@
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [abi]
* @_section api/abi:Application Binary Interface [about-abi]
* @_navTitle: ABI
*/
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -1,253 +0,0 @@
/**
* About Interface
*
* @_subsection api/abi:Interfaces [interfaces]
*/
import { AbiCoder } from "./abi-coder.js";
import { checkResultErrors, Result } from "./coders/abstract-coder.js";
import { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, ParamType } from "./fragments.js";
import { Typed } from "./typed.js";
import type { BigNumberish, BytesLike, CallExceptionError, CallExceptionTransaction } from "../utils/index.js";
import type { JsonFragment } from "./fragments.js";
export { checkResultErrors, Result };
export declare class LogDescription {
readonly fragment: EventFragment;
readonly name: string;
readonly signature: string;
readonly topic: string;
readonly args: Result;
constructor(fragment: EventFragment, topic: string, args: Result);
}
export declare class TransactionDescription {
readonly fragment: FunctionFragment;
readonly name: string;
readonly args: Result;
readonly signature: string;
readonly selector: string;
readonly value: bigint;
constructor(fragment: FunctionFragment, selector: string, args: Result, value: bigint);
}
export declare class ErrorDescription {
readonly fragment: ErrorFragment;
readonly name: string;
readonly args: Result;
readonly signature: string;
readonly selector: string;
constructor(fragment: ErrorFragment, selector: string, args: Result);
}
export declare class Indexed {
readonly hash: null | string;
readonly _isIndexed: boolean;
static isIndexed(value: any): value is Indexed;
constructor(hash: null | string);
}
/**
* @TODO
*/
export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>;
/**
* An Interface abstracts many of the low-level details for
* encoding and decoding the data on the blockchain.
*
* An ABI provides information on how to encode data to send to
* a Contract, how to decode the results and events and how to
* interpret revert errors.
*
* The ABI can be specified by [any supported format](InterfaceAbi).
*/
export declare class Interface {
#private;
/**
* All the Contract ABI members (i.e. methods, events, errors, etc).
*/
readonly fragments: ReadonlyArray<Fragment>;
/**
* The Contract constructor.
*/
readonly deploy: ConstructorFragment;
/**
* The Fallback method, if any.
*/
readonly fallback: null | FallbackFragment;
/**
* If receiving ether is supported.
*/
readonly receive: boolean;
/**
* Create a new Interface for the %%fragments%%.
*/
constructor(fragments: InterfaceAbi);
/**
* Returns the entire Human-Readable ABI, as an array of
* signatures, optionally as %%minimal%% strings, which
* removes parameter names and unneceesary spaces.
*/
format(minimal?: boolean): Array<string>;
/**
* Return the JSON-encoded ABI. This is the format Solidiy
* returns.
*/
formatJson(): string;
/**
* The ABI coder that will be used to encode and decode binary
* data.
*/
getAbiCoder(): AbiCoder;
/**
* Get the function name for %%key%%, which may be a function selector,
* function name or function signature that belongs to the ABI.
*/
getFunctionName(key: string): string;
/**
* Get the [[FunctionFragment]] for %%key%%, which may be a function
* selector, function name or function signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple functions match by name.
*
* If the %%key%% and %%values%% do not refine to a single function in
* the ABI, this will throw.
*/
getFunction(key: string, values?: Array<any | Typed>): null | FunctionFragment;
/**
* Iterate over all functions, calling %%callback%%, sorted by their name.
*/
forEachFunction(callback: (func: FunctionFragment, index: number) => void): void;
/**
* Get the event name for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*/
getEventName(key: string): string;
/**
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple events match by name.
*
* If the %%key%% and %%values%% do not refine to a single event in
* the ABI, this will throw.
*/
getEvent(key: string, values?: Array<any | Typed>): null | EventFragment;
/**
* Iterate over all events, calling %%callback%%, sorted by their name.
*/
forEachEvent(callback: (func: EventFragment, index: number) => void): void;
/**
* Get the [[ErrorFragment]] for %%key%%, which may be an error
* selector, error name or error signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple errors match by name.
*
* If the %%key%% and %%values%% do not refine to a single error in
* the ABI, this will throw.
*/
getError(key: string, values?: Array<any | Typed>): null | ErrorFragment;
/**
* Iterate over all errors, calling %%callback%%, sorted by their name.
*/
forEachError(callback: (func: ErrorFragment, index: number) => void): void;
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
_encodeParams(params: ReadonlyArray<ParamType>, values: ReadonlyArray<any>): string;
/**
* Encodes a ``tx.data`` object for deploying the Contract with
* the %%values%% as the constructor arguments.
*/
encodeDeploy(values?: ReadonlyArray<any>): string;
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result;
/**
* Encodes the transaction revert data for a call result that
* reverted from the the Contract with the sepcified %%error%%
* (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string;
/**
* Decodes the %%data%% from a transaction ``tx.data`` for
* the function specified (see [[getFunction]] for valid values
* for %%fragment%%).
*
* Most developers should prefer the [[parseTransaction]] method
* instead, which will automatically detect the fragment.
*/
decodeFunctionData(fragment: FunctionFragment | string, data: BytesLike): Result;
/**
* Encodes the ``tx.data`` for a transaction that calls the function
* specified (see [[getFunction]] for valid values for %%fragment%%) with
* the %%values%%.
*/
encodeFunctionData(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeFunctionResult(fragment: FunctionFragment | string, data: BytesLike): Result;
makeError(_data: BytesLike, tx: CallExceptionTransaction): CallExceptionError;
/**
* Encodes the result data (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values
* for %%fragment%%) with %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeFunctionResult(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
encodeFilterTopics(fragment: EventFragment | string, values: ReadonlyArray<any>): Array<null | string | Array<string>>;
encodeEventLog(fragment: EventFragment | string, values: ReadonlyArray<any>): {
data: string;
topics: Array<string>;
};
decodeEventLog(fragment: EventFragment | string, data: BytesLike, topics?: ReadonlyArray<string>): Result;
/**
* Parses a transaction, finding the matching function and extracts
* the parameter values along with other useful function details.
*
* If the matching function cannot be found, return null.
*/
parseTransaction(tx: {
data: string;
value?: BigNumberish;
}): null | TransactionDescription;
parseCallResult(data: BytesLike): Result;
/**
* Parses a receipt log, finding the matching event and extracts
* the parameter values along with other useful event details.
*
* If the matching event cannot be found, returns null.
*/
parseLog(log: {
topics: Array<string>;
data: string;
}): null | LogDescription;
/**
* Parses a revert data, finding the matching error and extracts
* the parameter values along with other useful error details.
*
* If the matching event cannot be found, returns null.
*/
parseError(data: BytesLike): null | ErrorDescription;
/**
* Creates a new [[Interface]] from the ABI %%value%%.
*
* The %%value%% may be provided as an existing [[Interface]] object,
* a JSON-encoded ABI or any Human-Readable ABI format.
*/
static from(value: InterfaceAbi | Interface): Interface;
}

View File

@@ -570,7 +570,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* Most developers should prefer the [[parseCallResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
@@ -640,7 +640,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* Most developers should prefer the [[parseCallResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
@@ -670,16 +670,15 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
const data = (0, index_js_3.getBytes)(_data, "data");
const error = abi_coder_js_1.AbiCoder.getBuiltinCallException("call", tx, data);
// Not a built-in error; try finding a custom error
if (!error.message.match(/could not decode/)) {
const customPrefix = "execution reverted (unknown custom error)";
if (error.message.startsWith(customPrefix)) {
const selector = (0, index_js_3.hexlify)(data.slice(0, 4));
error.message = "execution reverted (unknown custom error)";
const ef = this.getError(selector);
if (ef) {
try {
const args = this.#abiCoder.decode(ef.inputs, data.slice(4));
error.revert = {
name: ef.name,
signature: ef.format(),
args: this.#abiCoder.decode(ef.inputs, data.slice(4))
name: ef.name, signature: ef.format(), args
};
error.reason = error.revert.signature;
error.message = `execution reverted: ${error.reason}`;

File diff suppressed because one or more lines are too long

View File

@@ -1,162 +0,0 @@
/**
* About typed...
*
* @_subsection: api/abi:Typed Values
*/
import type { Addressable } from "../address/index.js";
import type { BigNumberish, BytesLike } from "../utils/index.js";
import type { Result } from "./coders/abstract-coder.js";
export interface TypedNumber extends Typed {
value: number;
defaultValue(): number;
minValue(): number;
maxValue(): number;
}
export interface TypedBigInt extends Typed {
value: bigint;
defaultValue(): bigint;
minValue(): bigint;
maxValue(): bigint;
}
export interface TypedData extends Typed {
value: string;
defaultValue(): string;
}
export interface TypedString extends Typed {
value: string;
defaultValue(): string;
}
export declare class Typed {
#private;
readonly type: string;
readonly value: any;
readonly _typedSymbol: Symbol;
constructor(gaurd: any, type: string, value: any, options?: any);
format(): string;
defaultValue(): string | number | bigint | Result;
minValue(): string | number | bigint;
maxValue(): string | number | bigint;
isBigInt(): this is TypedBigInt;
isData(): this is TypedData;
isString(): this is TypedString;
get tupleName(): null | string;
get arrayLength(): null | number;
static from(type: string, value: any): Typed;
static uint8(v: BigNumberish): Typed;
static uint16(v: BigNumberish): Typed;
static uint24(v: BigNumberish): Typed;
static uint32(v: BigNumberish): Typed;
static uint40(v: BigNumberish): Typed;
static uint48(v: BigNumberish): Typed;
static uint56(v: BigNumberish): Typed;
static uint64(v: BigNumberish): Typed;
static uint72(v: BigNumberish): Typed;
static uint80(v: BigNumberish): Typed;
static uint88(v: BigNumberish): Typed;
static uint96(v: BigNumberish): Typed;
static uint104(v: BigNumberish): Typed;
static uint112(v: BigNumberish): Typed;
static uint120(v: BigNumberish): Typed;
static uint128(v: BigNumberish): Typed;
static uint136(v: BigNumberish): Typed;
static uint144(v: BigNumberish): Typed;
static uint152(v: BigNumberish): Typed;
static uint160(v: BigNumberish): Typed;
static uint168(v: BigNumberish): Typed;
static uint176(v: BigNumberish): Typed;
static uint184(v: BigNumberish): Typed;
static uint192(v: BigNumberish): Typed;
static uint200(v: BigNumberish): Typed;
static uint208(v: BigNumberish): Typed;
static uint216(v: BigNumberish): Typed;
static uint224(v: BigNumberish): Typed;
static uint232(v: BigNumberish): Typed;
static uint240(v: BigNumberish): Typed;
static uint248(v: BigNumberish): Typed;
static uint256(v: BigNumberish): Typed;
static uint(v: BigNumberish): Typed;
static int8(v: BigNumberish): Typed;
static int16(v: BigNumberish): Typed;
static int24(v: BigNumberish): Typed;
static int32(v: BigNumberish): Typed;
static int40(v: BigNumberish): Typed;
static int48(v: BigNumberish): Typed;
static int56(v: BigNumberish): Typed;
static int64(v: BigNumberish): Typed;
static int72(v: BigNumberish): Typed;
static int80(v: BigNumberish): Typed;
static int88(v: BigNumberish): Typed;
static int96(v: BigNumberish): Typed;
static int104(v: BigNumberish): Typed;
static int112(v: BigNumberish): Typed;
static int120(v: BigNumberish): Typed;
static int128(v: BigNumberish): Typed;
static int136(v: BigNumberish): Typed;
static int144(v: BigNumberish): Typed;
static int152(v: BigNumberish): Typed;
static int160(v: BigNumberish): Typed;
static int168(v: BigNumberish): Typed;
static int176(v: BigNumberish): Typed;
static int184(v: BigNumberish): Typed;
static int192(v: BigNumberish): Typed;
static int200(v: BigNumberish): Typed;
static int208(v: BigNumberish): Typed;
static int216(v: BigNumberish): Typed;
static int224(v: BigNumberish): Typed;
static int232(v: BigNumberish): Typed;
static int240(v: BigNumberish): Typed;
static int248(v: BigNumberish): Typed;
static int256(v: BigNumberish): Typed;
static int(v: BigNumberish): Typed;
static bytes1(v: BytesLike): Typed;
static bytes2(v: BytesLike): Typed;
static bytes3(v: BytesLike): Typed;
static bytes4(v: BytesLike): Typed;
static bytes5(v: BytesLike): Typed;
static bytes6(v: BytesLike): Typed;
static bytes7(v: BytesLike): Typed;
static bytes8(v: BytesLike): Typed;
static bytes9(v: BytesLike): Typed;
static bytes10(v: BytesLike): Typed;
static bytes11(v: BytesLike): Typed;
static bytes12(v: BytesLike): Typed;
static bytes13(v: BytesLike): Typed;
static bytes14(v: BytesLike): Typed;
static bytes15(v: BytesLike): Typed;
static bytes16(v: BytesLike): Typed;
static bytes17(v: BytesLike): Typed;
static bytes18(v: BytesLike): Typed;
static bytes19(v: BytesLike): Typed;
static bytes20(v: BytesLike): Typed;
static bytes21(v: BytesLike): Typed;
static bytes22(v: BytesLike): Typed;
static bytes23(v: BytesLike): Typed;
static bytes24(v: BytesLike): Typed;
static bytes25(v: BytesLike): Typed;
static bytes26(v: BytesLike): Typed;
static bytes27(v: BytesLike): Typed;
static bytes28(v: BytesLike): Typed;
static bytes29(v: BytesLike): Typed;
static bytes30(v: BytesLike): Typed;
static bytes31(v: BytesLike): Typed;
static bytes32(v: BytesLike): Typed;
static address(v: string | Addressable): Typed;
static bool(v: any): Typed;
static bytes(v: BytesLike): Typed;
static string(v: string): Typed;
static array(v: Array<any | Typed>, dynamic?: null | boolean): Typed;
static tuple(v: Array<any | Typed> | Record<string, any | Typed>, name?: string): Typed;
static overrides(v: Record<string, any>): Typed;
/**
* Returns true only if %%value%% is a [[Typed]] instance.
*/
static isTyped(value: any): value is Typed;
/**
* If the value is a [[Typed]] instance, validates the underlying value
* and returns it, otherwise returns value directly.
*
* This is useful for functions that with to accept either a [[Typed]]
* object or values.
*/
static dereference<T>(value: Typed | T, type: string): T;
}

View File

@@ -62,7 +62,7 @@ class Typed {
return !!(this.type.match(/^u?int[0-9]+$/));
}
isData() {
return (this.type.substring(0, 5) === "bytes");
return this.type.startsWith("bytes");
}
isString() {
return (this.type === "string");

File diff suppressed because one or more lines are too long

View File

@@ -1,55 +0,0 @@
/**
* Returns a normalized and checksumed address for %%address%%.
* This accepts non-checksum addresses, checksum addresses and
* [[getIcapAddress]] formats.
*
* The checksum in Ethereum uses the capitalization (upper-case
* vs lower-case) of the characters within an address to encode
* its checksum, which offers, on average, a checksum of 15-bits.
*
* If %%address%% contains both upper-case and lower-case, it is
* assumed to already be a checksum address and its checksum is
* validated, and if the address fails its expected checksum an
* error is thrown.
*
* If you wish the checksum of %%address%% to be ignore, it should
* be converted to lower-case (i.e. ``.toLowercase()``) before
* being passed in. This should be a very rare situation though,
* that you wish to bypass the safegaurds in place to protect
* against an address that has been incorrectly copied from another
* source.
*
* @example:
* // Adds the checksum (via upper-casing specific letters)
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
* //_result:
*
* // Converts ICAP address and adds checksum
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
* //_result:
*
* // Throws an error if an address contains mixed case,
* // but the checksum fails
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
* //_error:
*/
export declare function getAddress(address: string): string;
/**
* The [ICAP Address format](link-icap) format is an early checksum
* format which attempts to be compatible with the banking
* industry [IBAN format](link-wiki-iban] for bank accounts.
*
* It is no longer common or a recommended format.
*
* @example:
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
* //_result:
*
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
* //_result:
*
* // Throws an error if the ICAP checksum is wrong
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
* //_error:
*/
export declare function getIcapAddress(address: string): string;

View File

@@ -110,7 +110,7 @@ function getAddress(address) {
(0, index_js_2.assertArgument)(typeof (address) === "string", "invalid address", "address", address);
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
// Missing the 0x prefix
if (address.substring(0, 2) !== "0x") {
if (!address.startsWith("0x")) {
address = "0x" + address;
}
const result = getChecksumAddress(address);

View File

@@ -1 +1 @@
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src.ts/address/address.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAC/C,gDAA6D;AAG7D,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzB,SAAS,kBAAkB,CAAC,OAAe;IAC3C,sCAAsC;IACtC,2EAA2E;IAC3E,OAAO;IAEH,OAAO,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M,CAAC,MAAM,GAAG,EAAE,EAAE;QAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;KAAE;IACrD,OAAO,IAAI,GAAG,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AACzD,CAAC;AALD,wCAKC"}

View File

@@ -1,80 +0,0 @@
import type { Addressable, AddressLike, NameResolver } from "./index.js";
/**
* Returns true if %%value%% is an object which implements the
* [[Addressable]] interface.
*
* @example:
* // Wallets and AbstractSigner sub-classes
* isAddressable(Wallet.createRandom())
* //_result:
*
* // Contracts
* contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
* isAddressable(contract)
* //_result:
*/
export declare function isAddressable(value: any): value is Addressable;
/**
* Returns true if %%value%% is a valid address.
*
* @example:
* // Valid address
* isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
* //_result:
*
* // Valid ICAP address
* isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
* //_result:
*
* // Invalid checksum
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
* //_result:
*
* // Invalid ICAP checksum
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
* //_result:
*
* // Not an address (an ENS name requires a provided and an
* // asynchronous API to access)
* isAddress("ricmoo.eth")
* //_result:
*/
export declare function isAddress(value: any): value is string;
/**
* Resolves to an address for the %%target%%, which may be any
* supported address type, an [[Addressable]] or a Promise which
* resolves to an address.
*
* If an ENS name is provided, but that name has not been correctly
* configured a [[UnconfiguredNameError]] is thrown.
*
* @example:
* addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
*
* // Addresses are return synchronously
* resolveAddress(addr, provider)
* //_result:
*
* // Address promises are resolved asynchronously
* resolveAddress(Promise.resolve(addr))
* //_result:
*
* // ENS names are resolved asynchronously
* resolveAddress("dai.tokens.ethers.eth", provider)
* //_result:
*
* // Addressable objects are resolved asynchronously
* contract = new Contract(addr, [ ])
* resolveAddress(contract, provider)
* //_result:
*
* // Unconfigured ENS names reject
* resolveAddress("nothing-here.ricmoo.eth", provider)
* //_error:
*
* // ENS names require a NameResolver object passed in
* // (notice the provider was omitted)
* resolveAddress("nothing-here.ricmoo.eth")
* //_error:
*/
export declare function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string>;

View File

@@ -1,47 +0,0 @@
import type { BigNumberish, BytesLike } from "../utils/index.js";
/**
* Returns the address that would result from a ``CREATE`` for %%tx%%.
*
* This can be used to compute the address a contract will be
* deployed to by an EOA when sending a deployment transaction (i.e.
* when the ``to`` address is ``null``).
*
* This can also be used to compute the address a contract will be
* deployed to by a contract, by using the contract's address as the
* ``to`` and the contract's nonce.
*
* @example
* from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
* nonce = 5;
*
* getCreateAddress({ from, nonce });
* //_result:
*/
export declare function getCreateAddress(tx: {
from: string;
nonce: BigNumberish;
}): string;
/**
* Returns the address that would result from a ``CREATE2`` operation
* with the given %%from%%, %%salt%% and %%initCodeHash%%.
*
* To compute the %%initCodeHash%% from a contract's init code, use
* the [[keccak256]] function.
*
* For a quick overview and example of ``CREATE2``, see [[link-ricmoo-wisps]].
*
* @example
* // The address of the contract
* from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72"
*
* // The salt
* salt = id("HelloWorld")
*
* // The hash of the initCode
* initCode = "0x6394198df16000526103ff60206004601c335afa6040516060f3";
* initCodeHash = keccak256(initCode)
*
* getCreate2Address(from, salt, initCodeHash)
* //_result:
*/
export declare function getCreate2Address(_from: string, _salt: BytesLike, _initCodeHash: BytesLike): string;

View File

@@ -1,48 +0,0 @@
/**
* Addresses are a fundamental part of interacting with Ethereum. They
* represent the gloabal identity of Externally Owned Accounts (accounts
* backed by a private key) and contracts.
*
* The Ethereum Naming Service (ENS) provides an interconnected ecosystem
* of contracts, standards and libraries which enable looking up an
* address for an ENS name.
*
* These functions help convert between various formats, validate
* addresses and safely resolve ENS names.
*
* @_section: api/address:Addresses [addresses]
*/
/**
* An interface for objects which have an address, and can
* resolve it asyncronously.
*
* This allows objects such as [[Signer]] or [[Contract]] to
* be used most places an address can be, for example getting
* the [balance](Provider-getBalance).
*/
export interface Addressable {
/**
* Get the object address.
*/
getAddress(): Promise<string>;
}
/**
* Anything that can be used to return or resolve an address.
*/
export type AddressLike = string | Promise<string> | Addressable;
/**
* An interface for any object which can resolve an ENS name.
*/
export interface NameResolver {
/**
* Resolve to the address for the ENS %%name%%.
*
* Resolves to ``null`` if the name is unconfigued. Use
* [[resolveAddress]] (passing this object as %%resolver%%) to
* throw for names that are unconfigured.
*/
resolveName(name: string): Promise<null | string>;
}
export { getAddress, getIcapAddress } from "./address.js";
export { getCreateAddress, getCreate2Address } from "./contract-address.js";
export { isAddressable, isAddress, resolveAddress } from "./checks.js";

View File

@@ -11,7 +11,7 @@
* These functions help convert between various formats, validate
* addresses and safely resolve ENS names.
*
* @_section: api/address:Addresses [addresses]
* @_section: api/address:Addresses [about-addresses]
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveAddress = exports.isAddress = exports.isAddressable = exports.getCreate2Address = exports.getCreateAddress = exports.getIcapAddress = exports.getAddress = void 0;

View File

@@ -1,6 +0,0 @@
/**
* A constant for the zero address.
*
* (**i.e.** ``"0x0000000000000000000000000000000000000000"``)
*/
export declare const ZeroAddress: string;

View File

@@ -1,6 +0,0 @@
/**
* A constant for the zero hash.
*
* (**i.e.** ``"0x0000000000000000000000000000000000000000000000000000000000000000"``)
*/
export declare const ZeroHash: string;

View File

@@ -1,9 +0,0 @@
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [constants]
*/
export { ZeroAddress } from "./addresses.js";
export { ZeroHash } from "./hashes.js";
export { N, WeiPerEther, MaxUint256, MinInt256, MaxInt256 } from "./numbers.js";
export { EtherSymbol, MessagePrefix } from "./strings.js";

View File

@@ -2,7 +2,7 @@
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [constants]
* @_section: api/constants: Constants [about-constants]
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessagePrefix = exports.EtherSymbol = exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.N = exports.ZeroHash = exports.ZeroAddress = void 0;

View File

@@ -1,30 +0,0 @@
/**
* A constant for the order N for the secp256k1 curve.
*
* (**i.e.** ``0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n``)
*/
export declare const N: bigint;
/**
* A constant for the number of wei in a single ether.
*
* (**i.e.** ``1000000000000000000n``)
*/
export declare const WeiPerEther: bigint;
/**
* A constant for the maximum value for a ``uint256``.
*
* (**i.e.** ``0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``)
*/
export declare const MaxUint256: bigint;
/**
* A constant for the minimum value for an ``int256``.
*
* (**i.e.** ``-8000000000000000000000000000000000000000000000000000000000000000n``)
*/
export declare const MinInt256: bigint;
/**
* A constant for the maximum value for an ``int256``.
*
* (**i.e.** ``0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``)
*/
export declare const MaxInt256: bigint;

View File

@@ -1,12 +0,0 @@
/**
* A constant for the ether symbol (normalized using NFKC).
*
* (**i.e.** ``"\\u039e"``)
*/
export declare const EtherSymbol: string;
/**
* A constant for the [[link-eip-191]] personal message prefix.
*
* (**i.e.** ``"\\x19Ethereum Signed Message:\\n"``)
*/
export declare const MessagePrefix: string;

View File

@@ -1,58 +0,0 @@
import { Interface } from "../abi/index.js";
import { Log, TransactionResponse } from "../providers/provider.js";
import { ContractTransactionResponse, EventLog } from "./wrappers.js";
import type { EventFragment, FunctionFragment, InterfaceAbi, ParamType } from "../abi/index.js";
import type { Addressable } from "../address/index.js";
import type { EventEmitterable, Listener } from "../utils/index.js";
import type { BlockTag, ContractRunner, TransactionRequest } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction } from "./types.js";
/**
* @_ignore:
*/
export declare function copyOverrides<O extends string = "data" | "to">(arg: any, allowed?: Array<string>): Promise<Omit<ContractTransaction, O>>;
/**
* @_ignore:
*/
export declare function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray<ParamType>, args: Array<any>): Promise<Array<any>>;
declare class WrappedFallback {
readonly _contract: BaseContract;
constructor(contract: BaseContract);
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}
declare const internal: unique symbol;
export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {
readonly target: string | Addressable;
readonly interface: Interface;
readonly runner: null | ContractRunner;
readonly filters: Record<string, ContractEvent>;
readonly [internal]: any;
readonly fallback: null | WrappedFallback;
constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse);
connect(runner: null | ContractRunner): BaseContract;
getAddress(): Promise<string>;
getDeployedCode(): Promise<null | string>;
waitForDeployment(): Promise<this>;
deploymentTransaction(): null | ContractTransactionResponse;
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
getEvent(key: string | EventFragment): ContractEvent;
queryTransaction(hash: string): Promise<Array<EventLog>>;
queryFilter(event: ContractEventName, fromBlock?: BlockTag, toBlock?: BlockTag): Promise<Array<EventLog | Log>>;
on(event: ContractEventName, listener: Listener): Promise<this>;
once(event: ContractEventName, listener: Listener): Promise<this>;
emit(event: ContractEventName, ...args: Array<any>): Promise<boolean>;
listenerCount(event?: ContractEventName): Promise<number>;
listeners(event?: ContractEventName): Promise<Array<Listener>>;
off(event: ContractEventName, listener?: Listener): Promise<this>;
removeAllListeners(event?: ContractEventName): Promise<this>;
addListener(event: ContractEventName, listener: Listener): Promise<this>;
removeListener(event: ContractEventName, listener: Listener): Promise<this>;
static buildClass<T = ContractInterface>(abi: InterfaceAbi): new (target: string, runner?: null | ContractRunner) => BaseContract & Omit<T, keyof BaseContract>;
static from<T = ContractInterface>(target: string, abi: InterfaceAbi, runner?: null | ContractRunner): BaseContract & Omit<T, keyof BaseContract>;
}
declare const Contract_base: new (target: string, abi: InterfaceAbi, runner?: ContractRunner | null | undefined) => BaseContract & Omit<ContractInterface, keyof BaseContract>;
export declare class Contract extends Contract_base {
}
export {};

View File

@@ -457,7 +457,7 @@ async function _emit(contract, event, args, payloadFunc) {
}
const count = sub.listeners.length;
sub.listeners = sub.listeners.filter(({ listener, once }) => {
const passArgs = args.slice();
const passArgs = Array.from(args);
if (payloadFunc) {
passArgs.push(payloadFunc(once ? null : listener));
}

File diff suppressed because one or more lines are too long

View File

@@ -1,21 +0,0 @@
import { Interface } from "../abi/index.js";
import { BaseContract } from "./contract.js";
import type { InterfaceAbi } from "../abi/index.js";
import type { ContractRunner } from "../providers/index.js";
import type { BytesLike } from "../utils/index.js";
import type { ContractInterface, ContractMethodArgs, ContractDeployTransaction } from "./types.js";
import type { ContractTransactionResponse } from "./wrappers.js";
export declare class ContractFactory<A extends Array<any> = Array<any>, I = BaseContract> {
readonly interface: Interface;
readonly bytecode: string;
readonly runner: null | ContractRunner;
constructor(abi: Interface | InterfaceAbi, bytecode: BytesLike | {
object: string;
}, runner?: null | ContractRunner);
getDeployTransaction(...args: ContractMethodArgs<A>): Promise<ContractDeployTransaction>;
deploy(...args: ContractMethodArgs<A>): Promise<BaseContract & {
deploymentTransaction(): ContractTransactionResponse;
} & Omit<I, keyof BaseContract>>;
connect(runner: null | ContractRunner): ContractFactory<A, I>;
static fromSolidity<A extends Array<any> = Array<any>, I = ContractInterface>(output: any, runner?: ContractRunner): ContractFactory<A, I>;
}

Some files were not shown because too many files have changed in this diff Show More