Compare commits

...

83 Commits

Author SHA1 Message Date
Richard Moore
5e5e5322c4 Demo for migrating to noble-curves 2023-04-22 21:03:20 +09:00
Richard Moore
8fcbd9cac4 tests: update cjs tests to use require 2023-04-22 18:59:18 +09:00
Richard Moore
f701f390cc admin: update dist files 2023-04-22 18:54:45 +09:00
Richard Moore
df685b1bd9 Support transitive dependants that use non-node16 moduleResolution (#3920). 2023-04-22 18:53:35 +09:00
Richard Moore
47f9d16eb7 admin: adjust the target path for faux_modules 2023-04-22 18:42:26 +09:00
Richard Moore
cdb34b0184 admin: move clone path up a folder 2023-04-21 19:10:13 +09:00
Richard Moore
44ba4a0073 admin: dump faux-npm logs 2023-04-21 19:06:41 +09:00
Richard Moore
c3bc38b567 admin: show installed packages during test-env 2023-04-21 18:56:11 +09:00
Richard Moore
d8efa7b77c admin: add clean target to environment tests 2023-04-21 18:44:50 +09:00
Richard Moore
a1d52c3579 admin: add node types as dependency to fix type resolution 2023-04-21 18:44:23 +09:00
Richard Moore
b70c66ee24 admin: update to newer faux_modules path 2023-04-21 17:58:21 +09:00
Richard Moore
e315e1a74c admin: fix typo in workflow 2023-04-21 17:56:16 +09:00
Richard Moore
0f9f385a19 admin: add missing tag to env-tests 2023-04-21 17:51:00 +09:00
Richard Moore
35c0c01a27 admin: restrict paths for docs generation 2023-04-21 17:50:11 +09:00
Richard Moore
db550971c0 admin: adding initial environment tests 2023-04-21 17:48:26 +09:00
Richard Moore
10e03e095b admin: update dist files 2023-04-19 17:30:37 +09:00
Richard Moore
6b9305886f docs: grammar fixes (#3980) 2023-04-19 16:29:41 +09:00
Richard Moore
91a84102d6 docs: fixed v5 typo in contracts (#3969) 2023-04-19 16:26:03 +09:00
Richard Moore
bacd48cd5c docs: fixed typo (#3964) 2023-04-19 16:24:12 +09:00
Richard Moore
a9b3edd2be docs: fixed typo (#3960) 2023-04-19 16:23:28 +09:00
Richard Moore
4e478e625d Populate any missing log.removed with false (#3959). 2023-04-19 15:45:54 +09:00
Richard Moore
0802b70a72 admin: updated dist files 2023-04-06 04:37:10 -04:00
Richard Moore
c764e9a10b admin: prevent duplicate definition error; research why this happened 2023-04-06 04:33:55 -04:00
Richard Moore
8c5973e3a9 Added support for legacy ABI JSON fragments (#3932). 2023-04-06 04:25:54 -04:00
Richard Moore
e4e951124f admin: added default fallback to exports for legacy tooling 2023-04-06 03:42:22 -04:00
Richard Moore
c58ab3a976 Add _in_ operator support for contract and contract.filters (#3901). 2023-04-06 02:46:47 -04:00
Richard Moore
9060dede49 tests: added testcases for twos compliments 2023-04-05 04:22:59 -04:00
Richard Moore
9cb2a9d89b docs: added Typed info 2023-04-05 04:20:48 -04:00
Richard Moore
a851b24d0a Fixed TypedData unsigned value range (#3873). 2023-04-05 04:20:21 -04:00
Richard Moore
356ff2becb Added missing export for getIndexedAccountPath (#3875). 2023-04-04 23:38:38 -04:00
Richard Moore
50b74b8806 Fixed TypedData payloads for JSON-restricted chainId field (#3868). 2023-04-04 23:18:48 -04:00
Richard Moore
130204dd3b admin: updated dist files 2023-03-27 21:22:35 -04:00
Richard Moore
ffaafc0ce1 Fixed events when emitted in WebSocketProvider (#3767, #3922). 2023-03-27 21:21:03 -04:00
Richard Moore
9373864742 admin: update dist files 2023-03-24 00:49:22 -04:00
Richard Moore
88e8124c37 Fixed FetchRequest when using credentials (#3897). 2023-03-23 23:31:31 -04:00
Richard Moore
c05a84aa65 admin: updated dist files 2023-03-23 17:33:55 -04:00
Richard Moore
603d47496e Stall block polling bootstrap when the network is down (#3924). 2023-03-23 17:08:46 -04:00
Richard Moore
d661f70f3f admin: updated dist files 2023-03-20 15:53:36 -04:00
Richard Moore
62c798ce33 tests: fixed keccak256 implementation in testcase generation 2023-03-20 15:52:19 -04:00
Richard Moore
0cfeed2633 tests: small tweaks to improve failing third-party testcases 2023-03-20 14:43:20 -04:00
Richard Moore
30ffa78d14 Added extra details in the error info field for RPC errors. 2023-03-20 14:42:19 -04:00
Richard Moore
6e01e5448f Remove Ankr as a deafult for now as the provided API key is failing. 2023-03-20 14:40:43 -04:00
Richard Moore
d2e683e8eb admin: updated dist files 2023-03-20 13:33:56 -04:00
Richard Moore
2e3802a83b Fixed deferred filters after unsafe-eval changes (#3749, #3763). 2023-03-20 13:32:50 -04:00
Richard Moore
0816d54dd5 admin: fixed typo in CI workflow 2023-03-20 12:59:57 -04:00
Richard Moore
d4af1046c8 docs: added info on replacing fetchJson with FetchRequest 2023-03-20 12:58:10 -04:00
Richard Moore
0a9e4cd67d tests: updated ENS normalization tests to latest standard 2023-03-20 12:54:08 -04:00
Richard Moore
e03390130c admin: updated dist files 2023-03-20 12:53:37 -04:00
Richard Moore
7d3af512c7 Remove use of Function sub-class to address unsafe-eval issues (#3749, #3763). 2023-03-20 12:49:58 -04:00
Richard Moore
5318b939fd tests: added contract integration tests and llocal Geth 2023-03-20 12:46:21 -04:00
Richard Moore
f06a445247 Added verifyTypedData utility (reported on Farcaster). 2023-03-20 11:31:35 -04:00
Richard Moore
e11d4c1c20 Removed stray logging in IpcProvider (#3908, #3909). 2023-03-18 13:27:47 -04:00
Richard Moore
fcf6c8fcee Fixed legacy serialization for implicit chainId transactions (#3898, #3899). 2023-03-16 12:11:46 -04:00
Richard Moore
3ad4273b8b Fix Webpack issue (reported on discord). 2023-03-16 10:19:33 -04:00
Richard Moore
6315e78ea3 Fix some bundlers which cannot handle recursive pkg.exports (#3848). 2023-03-13 06:41:18 -04:00
Richard Moore
7eaf3c4e8b docs: added provider updates to migration (#3844) 2023-03-13 01:16:41 -04:00
Richard Moore
8a02029c00 docs: fixed typo (#3864) 2023-03-13 01:10:42 -04:00
Richard Moore
4a581b9944 admin: added script to create github releases (#3784) 2023-03-12 05:41:15 -04:00
Richard Moore
47ef3ebde3 Fixed typo in signature.s error (#3891). 2023-03-12 04:50:42 -04:00
Richard Moore
f61ad27a8e docs: fixed typo (#3877) 2023-03-12 04:47:08 -04:00
Richard Moore
c220fe2ea7 Fixed stray unreachable code (#3890). 2023-03-12 04:45:12 -04:00
Richard Moore
8136a6476b docs: added more jsdocs to TransactionResponse 2023-03-11 01:02:24 -05:00
Richard Moore
02a0aad612 Move all wrapping to proper _wrap functions (#3818). 2023-03-10 07:02:51 -05:00
Richard Moore
278f841744 admin: updated dist files 2023-03-07 02:11:03 -05:00
Richard Moore
5f2678fb05 Fixed ethers imported in web workers (#3856). 2023-03-07 02:07:03 -05:00
Richard Moore
abeaa74da0 Added Sepolia support (#3863). 2023-03-07 01:36:57 -05:00
Richard Moore
26a830eef5 docs: updated project links 2023-03-03 18:25:27 -07:00
Richard Moore
dced2b7dac admin: updated dist files 2023-03-03 18:25:07 -07:00
Richard Moore
06aa30363f Added missing exports (#3734). 2023-03-03 18:05:55 -07:00
Richard Moore
a32af3adc1 Allow null values for TypedData domain (#3623). 2023-03-03 17:59:58 -07:00
Richard Moore
287d94fc45 Added listAccounts to JsonRpcProvider (#3778). 2023-03-03 17:59:05 -07:00
Richard Moore
fe1f04c6e5 Allow BigInt for blockTag (#3780). 2023-03-03 17:44:08 -07:00
Richard Moore
f1a810dcb5 Fixed typo in error messages (#3822, #3824). 2023-02-28 21:18:27 -05:00
Richard Moore
76fab923da Re-adding definition files to require exports (#3703). 2023-02-28 21:15:18 -05:00
Richard Moore
4f2d1e1c7b docs: fixed typos in docs 2023-02-26 18:25:02 -05:00
Richard Moore
ba967875f7 docs: update flatworm cli 2023-02-24 00:49:05 -05:00
Richard Moore
0d417ff2a9 admin: updated dist files 2023-02-23 06:31:09 -05:00
Richard Moore
20bbd12819 Fix matic-mumbai network and include aliases to legacy names (#3811). 2023-02-23 06:29:09 -05:00
Richard Moore
388edf6abc Fixed getSigner bug (#3821). 2023-02-23 06:20:39 -05:00
Richard Moore
3a0d8685ca admin: updated dist files 2023-02-23 01:41:13 -05:00
Richard Moore
b993f7c3b6 Fixed getContentHash (#3819). 2023-02-23 01:39:57 -05:00
Richard Moore
51e72b98a2 admin: update dist files 2023-02-22 21:53:56 -05:00
Richard Moore
8298e8599f admin: added changelog generation scripts 2023-02-22 21:52:33 -05:00
479 changed files with 38954 additions and 3670 deletions

View File

@@ -4,6 +4,9 @@ on:
push:
branches:
- main
paths:
- "src.ts/**"
- "docs.wrm/**"
jobs:
docs:
@@ -32,7 +35,7 @@ jobs:
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
run: node node_modules/flatworm/lib/cli-test ./docs.wrm/config.js
- name: Upload documentation to to docs.ethers.org
uses: ethers-io/sync-s3-action@main

View File

@@ -32,6 +32,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install and run Geth
uses: ethers-io/run-geth-action@main
- name: Checkout repository
uses: actions/checkout@v2
@@ -63,6 +66,9 @@ jobs:
with:
node-version: 18.x
- name: Install and run Geth
uses: ethers-io/run-geth-action@main
- name: Checkout repository
uses: actions/checkout@v2

48
.github/workflows/test-env.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: Environment Tests
on:
push:
branches:
- main
jobs:
test-env:
name: Test Environments
runs-on: ubuntu-latest
env:
npm_config_registry: http://localhost:8043
strategy:
fail-fast: false
matrix:
test: [ "ts-import-cjs-node16", "ts-import-esm-node16", "ts-import-cjs", "ts-import-esm" ]
steps:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Checkout repository
uses: actions/checkout@v3
with:
path: "faux_modules/ethers"
- name: Install and run Faux Registry
uses: ethers-io/hijack-npm-action@main
- name: Copy tests to working directory
run: cp faux_modules/ethers/testcases/test-env/${{ matrix.test }}/* .
- name: Install packages
run: npm install
- name: Dump Faux Logs
run: cat .fauxNpm.log
- name: Run tests
run: npm test

View File

@@ -1,7 +1,83 @@
Change Log
==========
This change log is maintained by `src.ts/_admin/update-changelog.ts but may also be manually updated.`
This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.
ethers/v6.3.1 (2023-04-22 18:55)
--------------------------------
- Support transitive dependants that use non-node16 moduleResolution ([#3920](https://github.com/ethers-io/ethers.js/issues/3920); [df685b1](https://github.com/ethers-io/ethers.js/commit/df685b1bd9ad346ee7863beb6c3ca3f4e94932a2)).
- Populate any missing log.removed with false ([#3959](https://github.com/ethers-io/ethers.js/issues/3959); [4e478e6](https://github.com/ethers-io/ethers.js/commit/4e478e625d5648f2172631eef5fda5776ee776b0)).
ethers/v6.3.0 (2023-04-06 04:35)
--------------------------------
- Added support for legacy ABI JSON fragments ([#3932](https://github.com/ethers-io/ethers.js/issues/3932); [8c5973e](https://github.com/ethers-io/ethers.js/commit/8c5973e3a9b8d4d4ed80bdf209d8a0b6cc6b8d6d)).
- Add _in_ operator support for contract and contract.filters ([#3901](https://github.com/ethers-io/ethers.js/issues/3901); [c58ab3a](https://github.com/ethers-io/ethers.js/commit/c58ab3a97687e15a3ffe30b038089c5f4b570bb9)).
- Fixed TypedData unsigned value range ([#3873](https://github.com/ethers-io/ethers.js/issues/3873); [a851b24](https://github.com/ethers-io/ethers.js/commit/a851b24d0af009ecf277766d2a5f81f9b3e7f9f8)).
- Added missing export for getIndexedAccountPath ([#3875](https://github.com/ethers-io/ethers.js/issues/3875); [356ff2b](https://github.com/ethers-io/ethers.js/commit/356ff2becb4f4d3622b281d3825770af5caf71ca)).
- Fixed TypedData payloads for JSON-restricted chainId field ([#3836](https://github.com/ethers-io/ethers.js/issues/3836); [50b74b8](https://github.com/ethers-io/ethers.js/commit/50b74b8806ef2064f2764b09f89c7ac75fda3a3c)).
ethers/v6.2.3 (2023-03-27 21:22)
--------------------------------
- Fixed events when emitted in WebSocketProvider ([#3767](https://github.com/ethers-io/ethers.js/issues/3767), [#3922](https://github.com/ethers-io/ethers.js/issues/3922); [ffaafc0](https://github.com/ethers-io/ethers.js/commit/ffaafc0ce1cf40d1d76d8d814c9c445057bf6989)).
ethers/v6.2.2 (2023-03-24 00:49)
--------------------------------
- Fixed FetchRequest when using credentials ([#3897](https://github.com/ethers-io/ethers.js/issues/3897); [88e8124](https://github.com/ethers-io/ethers.js/commit/88e8124c37d377628f9b8abdf140fc07ad06259f)).
ethers/v6.2.1 (2023-03-23 17:33)
--------------------------------
- Stall block polling bootstrap when the network is down ([#3924](https://github.com/ethers-io/ethers.js/issues/3924); [603d474](https://github.com/ethers-io/ethers.js/commit/603d47496e2b667c15b72f315261d6e299381848)).
ethers/v6.2.0 (2023-03-20 15:53)
--------------------------------
- Added extra details in the error info field for RPC errors ([30ffa78](https://github.com/ethers-io/ethers.js/commit/30ffa78d1441fa033677fa09237fc135a314f373)).
- Remove Ankr as a deafult for now as the provided API key is failing ([6e01e54](https://github.com/ethers-io/ethers.js/commit/6e01e5448f4a3e2d30288d4c8447db295c3a2e7a)).
- Fixed deferred filters after unsafe-eval changes ([#3749](https://github.com/ethers-io/ethers.js/issues/3749), [#3763](https://github.com/ethers-io/ethers.js/issues/3763); [2e3802a](https://github.com/ethers-io/ethers.js/commit/2e3802a83b8ad2f5a6269d79fbd1c83c9f2d1047)).
- Remove use of Function sub-class to address unsafe-eval issues ([#3749](https://github.com/ethers-io/ethers.js/issues/3749), [#3763](https://github.com/ethers-io/ethers.js/issues/3763); [7d3af51](https://github.com/ethers-io/ethers.js/commit/7d3af512c75b4c24027ec2daef1e9f4c1064194a)).
- Added verifyTypedData utility (reported on Farcaster) ([f06a445](https://github.com/ethers-io/ethers.js/commit/f06a445247f3b294f9fc805cc8fe0752accb8edc)).
- Removed stray logging in IpcProvider ([#3908](https://github.com/ethers-io/ethers.js/issues/3908), [#3909](https://github.com/ethers-io/ethers.js/issues/3909); [e11d4c1](https://github.com/ethers-io/ethers.js/commit/e11d4c1c20cc5b6fd5803cf9636c4f5bc082dab7)).
- Fixed legacy serialization for implicit chainId transactions ([#3898](https://github.com/ethers-io/ethers.js/issues/3898), [#3899](https://github.com/ethers-io/ethers.js/issues/3899); [fcf6c8f](https://github.com/ethers-io/ethers.js/commit/fcf6c8fcee95ec412aaafba8ec84d5049b077a4e)).
- Fix Webpack issue (reported on discord) ([3ad4273](https://github.com/ethers-io/ethers.js/commit/3ad4273b8b714bff344ccbfb1eb71ed8a8b7cfa4)).
- Fix some bundlers which cannot handle recursive pkg.exports ([#3848](https://github.com/ethers-io/ethers.js/issues/3848); [6315e78](https://github.com/ethers-io/ethers.js/commit/6315e78ea32147653b72ca06f6800f3e2df6ffbf)).
- Fixed typo in signature.s error ([#3891](https://github.com/ethers-io/ethers.js/issues/3891); [47ef3eb](https://github.com/ethers-io/ethers.js/commit/47ef3ebde37bfa0c015c258c3d8a6800d751e147)).
- Fixed stray unreachable code ([#3890](https://github.com/ethers-io/ethers.js/issues/3890); [c220fe2](https://github.com/ethers-io/ethers.js/commit/c220fe2ea747ccc80cd3c4020e0278e3daf3c4fc)).
- Move all wrapping to proper _wrap functions ([#3818](https://github.com/ethers-io/ethers.js/issues/3818); [02a0aad](https://github.com/ethers-io/ethers.js/commit/02a0aad61212c35e8d2723a8ae589989b97dae3e)).
ethers/v6.1.0 (2023-03-07 02:10)
--------------------------------
- Fixed ethers imported in web workers ([#3856](https://github.com/ethers-io/ethers.js/issues/3856); [5f2678f](https://github.com/ethers-io/ethers.js/commit/5f2678fb059d643638b9cc1dc59cbfc61ce7a7b8)).
- Added Sepolia support ([#3863](https://github.com/ethers-io/ethers.js/issues/3863); [abeaa74](https://github.com/ethers-io/ethers.js/commit/abeaa74da04fbe25e837a2ffa7d1e9c1257a5da5)).
- Added missing exports ([#3734](https://github.com/ethers-io/ethers.js/issues/3734); [06aa303](https://github.com/ethers-io/ethers.js/commit/06aa30363f88144db672376d39012d7fe3f86c33)).
- Allow null values for TypedData domain ([#3623](https://github.com/ethers-io/ethers.js/issues/3623); [a32af3a](https://github.com/ethers-io/ethers.js/commit/a32af3adc104c4b07a45097a4a3725a4ce9e0be6)).
- Added listAccounts to JsonRpcProvider ([#3778](https://github.com/ethers-io/ethers.js/issues/3778); [287d94f](https://github.com/ethers-io/ethers.js/commit/287d94fc454d03f1b3086ea98745131cdf40129a)).
- Allow BigInt for blockTag ([#3780](https://github.com/ethers-io/ethers.js/issues/3780); [fe1f04c](https://github.com/ethers-io/ethers.js/commit/fe1f04c6e5fb4254a100f492d7dcbdc3cf19a446)).
- Fixed typo in error messages ([#3822](https://github.com/ethers-io/ethers.js/issues/3822), [#3824](https://github.com/ethers-io/ethers.js/issues/3824); [f1a810d](https://github.com/ethers-io/ethers.js/commit/f1a810dcb56df54b1e1567f2a59c73500619472f)).
- Re-adding definition files to require exports ([#3703](https://github.com/ethers-io/ethers.js/issues/3703); [76fab92](https://github.com/ethers-io/ethers.js/commit/76fab923da33e71e6bb751bb0b5e3ba3faa27ab2)).
ethers/v6.0.8 (2023-02-23 06:30)
--------------------------------
- Fix matic-mumbai network and include aliases to legacy names ([#3811](https://github.com/ethers-io/ethers.js/issues/3811); [20bbd12](https://github.com/ethers-io/ethers.js/commit/20bbd1281911d31b360f6f5032251c9257943541)).
- Fixed getSigner bug ([#3821](https://github.com/ethers-io/ethers.js/issues/3821); [388edf6](https://github.com/ethers-io/ethers.js/commit/388edf6abc168f89f1ca609e9e5b025dc9205add)).
ethers/v6.0.7 (2023-02-23 01:41)
--------------------------------
- Fixed getContentHash ([#3819](https://github.com/ethers-io/ethers.js/issues/3819); [b993f7c](https://github.com/ethers-io/ethers.js/commit/b993f7c3b6c0e135c460c8b8dc5943215628231a)).
ethers/v6.0.6 (2023-02-22 21:53)
--------------------------------
- Added chain parameters for Arbitrum and Optimism ([#3811](https://github.com/ethers-io/ethers.js/issues/3811); [77a7323](https://github.com/ethers-io/ethers.js/commit/77a7323119923e596f4def4f1bc90beae5447320)).
- Fix NonceManager race condition ([#3812](https://github.com/ethers-io/ethers.js/issues/3812), [#3813](https://github.com/ethers-io/ethers.js/issues/3813); [5a3c10a](https://github.com/ethers-io/ethers.js/commit/5a3c10a29c047609a50828adb620d88aa8cf0014)).
- Add UMD output to dist builds ([#3814](https://github.com/ethers-io/ethers.js/issues/3814); [f9eed4c](https://github.com/ethers-io/ethers.js/commit/f9eed4cdb190b06dd4ddaa2382c1de42e8e98de6)).
ethers/v6.0.5 (2023-02-18 22:36)
--------------------------------

4473
dist/ethers.js vendored

File diff suppressed because one or more lines are too long

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

23848
dist/ethers.umd.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/ethers.umd.js.map vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/ethers.umd.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -42,9 +42,9 @@ const assert$1 = {
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
// big-endian hardware is rare. Just in case someone still decides to run hashes:
// early-throw an error because we don't support BE yet.
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
// There is almost no big endian hardware, but js typed arrays uses platform specific endianness.
// So, just to be sure not to corrupt anything.
if (!isLE)
throw new Error('Non little-endian hardware is not supported');
Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
@@ -149,7 +149,7 @@ const u64 = {
/**
* The current version of Ethers.
*/
const version = "6.0.5";
const version = "6.3.1";
/**
* Property helper functions.
@@ -440,7 +440,7 @@ function replaceFunc(reason, offset, bytes, output, badCodepoint) {
* and accepts non-canonical (overlong) codepoints
*
* **``"replace"``** - replace any illegal UTF-8 sequence with the
* UTF-8 replacement character (i.e. `\ufffd`) and accepts
* UTF-8 replacement character (i.e. ``"\\ufffd"``) and accepts
* non-canonical (overlong) codepoints
*
* @returns: Record<"error" | "ignore" | "replace", Utf8ErrorFunc>
@@ -846,7 +846,7 @@ Object.freeze(keccak256);
/**
* A simple hashing function which operates on UTF-8 strings to
* compute an 32-byte irentifier.
* compute an 32-byte identifier.
*
* This simply computes the [UTF-8 bytes](toUtf8Bytes) and computes
* the [[keccak256]].

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -21,7 +21,7 @@ more fine-grained importing.
Generally this documentation will presume all exports from ethers
have been imported in the code examples, but you may import the
necessary objects any way you wish.
necessary objects in any way you wish.
_code: importing in Node.js @lang<script>
// Import everything
@@ -70,7 +70,7 @@ permission from the user and receiving authorization.
_heading: Transaction
To make any state changes to the blockchain, a transaction is required,
which requires a fee be paid, where the fee covers the associated costs
which requires a fee to be paid, where the fee covers the associated costs
with executing the transaction (such as reading the disk and performing
maths) and storing the updated information.
@@ -180,7 +180,7 @@ machine-readable purposes and maths are often very large and not
terribly human-readable.
For example, imagine dealing with dollars and cents; you would show
values like ``"$2.56"``. In the blockchain world we would keep all
values like ``"$2.56"``. In the blockchain world, we would keep all
values as cents, so that would be ``256`` cents, internally.
So, when accepting data that a user types, it must be converted from
@@ -410,7 +410,7 @@ _code: listen for ERC-20 events @lang<script>
// The `event.log` has the entire EventLog
// Optionally, convenience method to stop listening
// Optionally, stop listening
event.removeListener();
});

View File

@@ -24,7 +24,7 @@ link-tally [Tally](https://tallyho.org)
# Project-specific
link-alchemy-signup [Alchemy Signup](https://dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d)
link-ankr-public [link-ankr-public](https://www.ankr.com/protocol/public/)
link-ankr-premium [link-ankr-premium](https://www.ankr.com/protocol/plan/)
link-ankr-signup [link-ankr-premium](https://www.ankr.com/protocol/plan/)
link-etherscan-signup [Etherscan Signup](https://etherscan.io/apis)
link-etherscan-ratelimit [link-etherscan-ratelimit](https://info.etherscan.com/api-return-errors/)
link-infura-signup [INFURA Signup](https://infura.io/register)

View File

@@ -26,6 +26,7 @@ link-eip-1014 [EIP-1014](https://eips.ethereum.org/EIPS/eip-1014)
link-eip-1193 [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)
link-eip-1559 [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
link-eip-1577 [EIP-1577](https://eips.ethereum.org/EIPS/eip-1577)
link-eip-2070 [EIP-2930](https://eips.ethereum.org/EIPS/eip-2070)
link-eip-2098 [EIP-2098](https://eips.ethereum.org/EIPS/eip-2098)
link-eip-2304 [EIP-2304](https://eips.ethereum.org/EIPS/eip-2304)
link-eip-2718 [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)
@@ -41,6 +42,7 @@ 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://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/)
link-pbkdf2 [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2)
link-solc-abi [ABI Specification](https://docs.soliditylang.org/en/v0.8.19/abi-spec.html#formal-specification-of-the-encoding)
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)
link-solc-output [solc standard output](https://solidity.readthedocs.io/en/v0.6.0/using-the-compiler.html#output-description)

View File

@@ -136,7 +136,7 @@ _code: other operations in v5 @lang<script>
contract.functions.foo(addr)
// Forces using call
contract.staticCall.foo(addr)
contract.callStatic.foo(addr)
// Estimate the gas
contract.estimateGas.foo(addr)
@@ -214,6 +214,16 @@ _code: wrapping EIP-1193 providers @lang<script>
// v6:
provider = new ethers.BrowserProvider(window.ethereum)
Also, the method for broadcasting transactions to the network has
changed:
_code: broadcasting transactions @lang<script>
// v5
provider.sendTransaction(signedTx)
// v6
provider.broadcastTransaction(signedTx)
_subsection: Signatures @<migrate-signatures>
@@ -236,7 +246,7 @@ 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>
_code: parsing transactions @lang<script>
// v5
tx = parseTransaction(txBytes)
@@ -295,6 +305,37 @@ _code: defaultAbiCoder @lang<script>
// instance is returned.
coder = AbiCoder.defaultAbiCoder()
_code: fetching content @lang<script>
// v5, with a body and no weird things
data = await ethers.utils.fetchJson(url, json, processFunc)
// v5 with Connection overrides
req = {
url, user: "username", password: "password"
// etc. properties have FetchRequest equivalents
};
data = await ethers.utils.detchJson(req, json, processFunc)
// v6
req = new ethers.FetchRequest(url)
// set a body; optional
req.body = json
// set credentials; optional
req.setCredentials("username", "password")
// set a processFunc; optional
req.processFunc = processFunc
// send the request!
resp = await req.send()
// Get the response body; depending on desired format
data = resp.body // Uint8Array
data = resp.bodyText // Utf8String; throws if invalid
data = resp.bodyJson // Object; throws if invalid
_code: hex conversion @lang<script>
// v5
hex = ethers.utils.hexValue(value)

View File

@@ -0,0 +1,84 @@
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

@@ -0,0 +1,7 @@
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

@@ -13,13 +13,15 @@ const ProviderCreators = [
return new index_js_1.AlchemyProvider(network, "YrPw6SWb20vJDRFkhWq8aKnTQ8JRNRHM");
}
},
/*
{
name: "AnkrProvider",
networks: ethNetworks.concat(["matic", "arbitrum"]),
create: function (network) {
return new index_js_1.AnkrProvider(network);
networks: ethNetworks.concat([ "matic", "arbitrum" ]),
create: function(network: string) {
return new AnkrProvider(network);
}
},
*/
/*
{
name: "CloudflareProvider",

View File

@@ -1 +1 @@
{"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":";;;AAAA,0CAWqB;AAQpB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAE,CAAC;AACvD,gDAAgD;AAEhD,MAAM,gBAAgB,GAA2B;IAC7C;QACI,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,0BAAe,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC5E,CAAC;KACJ;IACD;QACI,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAE,OAAO,EAAE,UAAU,CAAE,CAAC;QACrD,MAAM,EAAE,UAAS,OAAe;YAC5B,OAA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138 @@ describe("Test Interface", function () {
assert_1.default.equal(log.args[2], BigInt(234));
});
});
describe("Tests Legacy ABI formats", function () {
// See: #3932
const iface = new index_js_1.Interface([
{
name: "implicitView",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"constant": true,
"payable": false,
"type": "function"
},
{
name: "implicitSendNonpay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"constant": false,
"payable": false,
"type": "function"
},
{
name: "implicitSendPay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"constant": false,
"payable": true,
"type": "function"
},
{
name: "implicitSendImplicitPay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"constant": false,
"type": "function"
},
{
name: "implicitSendExplicitPay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
payable: true,
type: "function"
},
{
name: "implicitSendExplicitNonpay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
payable: false,
type: "function"
},
{
name: "implicitAll",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"type": "function"
},
{
name: "explicitView",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"stateMutability": "view",
"constant": true,
"payable": false,
"type": "function"
},
{
name: "explicitPure",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"stateMutability": "pure",
"constant": true,
"payable": false,
"type": "function"
},
{
name: "explicitPay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"stateMutability": "payable",
"constant": true,
"payable": true,
"type": "function"
},
{
name: "explicitNonpay",
outputs: [],
inputs: [
{ type: "int128", name: "arg0" }
],
"stateMutability": "nonpayable",
"constant": true,
"payable": false,
"type": "function"
},
]);
function test(name, isConst, payable, stateMutability) {
it(`tests ABI configuration: ${name}`, function () {
const f = iface.getFunction(name);
assert_1.default.ok(!!f, `missing ${name}`);
assert_1.default.equal(f.constant, isConst, `${name}.constant`);
assert_1.default.equal(f.stateMutability, stateMutability, `${name}.stateMutability`);
assert_1.default.equal(f.payable, payable, `${name}.payable`);
});
}
test("explicitView", true, false, "view");
test("explicitPure", true, false, "pure");
test("explicitPay", false, true, "payable");
test("explicitNonpay", false, false, "nonpayable");
test("implicitView", true, false, "view");
test("implicitSendNonpay", false, false, "nonpayable");
test("implicitSendPay", false, true, "payable");
test("implicitSendImplicitPay", false, true, "payable");
test("implicitSendExplicitPay", false, true, "payable");
test("implicitSendExplicitNonpay", false, false, "nonpayable");
test("implicitAll", false, true, "payable");
});
//# sourceMappingURL=test-abi.js.map

File diff suppressed because one or more lines are too long

1
lib.commonjs/_tests/test-address.d.ts vendored Normal file
View File

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

View File

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

View File

@@ -0,0 +1,80 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const index_js_1 = require("../index.js");
describe("Tests contract integration", function () {
const provider = new index_js_1.ethers.JsonRpcProvider("http:/\/127.0.0.1:8545");
const abi = [
"constructor(address owner, uint maxSupply)",
"function mint(address target) returns (bool minted)",
"function totalSupply() view returns (uint supply)",
"function balanceOf(address target) view returns (uint balance)",
"event Minted(address target)"
];
let address = null;
it("deploys a contract", async function () {
this.timeout(10000);
const bytecode = "0x60c060405234801561001057600080fd5b506040516105863803806105868339818101604052810190610032919061010e565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508060a08181525050505061014e565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a58261007a565b9050919050565b6100b58161009a565b81146100c057600080fd5b50565b6000815190506100d2816100ac565b92915050565b6000819050919050565b6100eb816100d8565b81146100f657600080fd5b50565b600081519050610108816100e2565b92915050565b6000806040838503121561012557610124610075565b5b6000610133858286016100c3565b9250506020610144858286016100f9565b9150509250929050565b60805160a051610414610172600039600060fa0152600061021f01526104146000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806318160ddd146100515780636a6278421461006f57806370a082311461009f5780638da5cb5b146100cf575b600080fd5b6100596100ed565b604051610066919061025c565b60405180910390f35b610089600480360381019061008491906102da565b6100f6565b6040516100969190610322565b60405180910390f35b6100b960048036038101906100b491906102da565b6101d2565b6040516100c6919061025c565b60405180910390f35b6100d761021b565b6040516100e4919061034c565b60405180910390f35b60008054905090565b60007f00000000000000000000000000000000000000000000000000000000000000006000541061012657600080fd5b600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061017690610396565b919050555060008081548092919061018d90610396565b91905055507f90ddedd5a25821bba11fbb98de02ec1f75c1be90ae147d6450ce873e7b78b5d8826040516101c1919061034c565b60405180910390a160019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60007f0000000000000000000000000000000000000000000000000000000000000000905090565b6000819050919050565b61025681610243565b82525050565b6000602082019050610271600083018461024d565b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102a78261027c565b9050919050565b6102b78161029c565b81146102c257600080fd5b50565b6000813590506102d4816102ae565b92915050565b6000602082840312156102f0576102ef610277565b5b60006102fe848285016102c5565b91505092915050565b60008115159050919050565b61031c81610307565b82525050565b60006020820190506103376000830184610313565b92915050565b6103468161029c565b82525050565b6000602082019050610361600083018461033d565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103a182610243565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036103d3576103d2610367565b5b60018201905091905056fea26469706673582212200a979ea2bfdf429b5546fa25906c9d20a3d67ef5fbe531f31d2cc83533e3239564736f6c63430008120033";
const signer = await provider.getSigner(0);
const factory = new index_js_1.ethers.ContractFactory(abi, bytecode, signer);
const contract = await factory.deploy(signer, 100);
address = await contract.getAddress();
await contract.waitForDeployment();
const deployed = await provider.getCode(address);
assert_1.default.ok(deployed != "0x", "has bytescode");
});
it("runs contract operations", async function () {
this.timeout(10000);
assert_1.default.ok(address != null);
const signer = await provider.getSigner(0);
const CustomContract = index_js_1.ethers.BaseContract.buildClass(abi);
const contract = new CustomContract(address, signer); //ethers.Contract.from<ContractAbi>(address, abi, signer);
// Test implicit staticCall (i.e. view/pure)
{
const supply0 = await contract.totalSupply();
assert_1.default.equal(supply0, BigInt(0), "initial supply 0; default");
}
// Test explicit staticCall
{
const supply0 = await contract.totalSupply.staticCall();
assert_1.default.equal(supply0, BigInt(0), "initial supply 0; staticCall");
}
// Test staticCallResult (positional and named)
{
const supply0 = await contract.totalSupply.staticCallResult();
assert_1.default.equal(supply0[0], BigInt(0), "initial supply 0; staticCallResult");
assert_1.default.equal(supply0.supply, BigInt(0), "initial supply 0; staticCallResult");
}
// Test populateTransaction
const txInfo = await contract.mint.populateTransaction(signer);
assert_1.default.equal(txInfo.to, address, "populateTransaction.to");
const txInfoData = index_js_1.ethers.hexlify(index_js_1.ethers.concat([
"0x6a627842",
index_js_1.ethers.zeroPadValue(await signer.getAddress(), 32)
]));
assert_1.default.equal(txInfo.data, txInfoData, "populateTransaction.data");
// Test minting (default)
const tx = await contract.mint(signer);
const receipt = await tx.wait();
assert_1.default.ok(receipt, "receipt");
// Check the receipt has parsed the events
assert_1.default.equal(receipt.logs.length, 1, "logs.length");
assert_1.default.ok(receipt instanceof index_js_1.ethers.ContractTransactionReceipt, "receipt typeof");
assert_1.default.ok(receipt.logs[0] instanceof index_js_1.ethers.EventLog, "receipt.log typeof");
assert_1.default.equal(receipt.logs[0].fragment && receipt.logs[0].fragment.name, "Minted", "logs[0].fragment.name");
assert_1.default.equal(receipt.logs[0].args[0], await signer.getAddress(), "logs[0].args[0]");
assert_1.default.equal(receipt.logs[0].args.target, await signer.getAddress(), "logs[0].args.target");
// Check the state has been adjusted
assert_1.default.equal(await contract.totalSupply(), BigInt(1), "initial supply 1; default");
assert_1.default.equal(await contract.balanceOf(signer), BigInt(1), "balanceOf(signer)");
// Test minting (explicit)
const tx2 = await contract.mint.send(signer);
await tx2.wait();
// Check the state has been adjusted
assert_1.default.equal(await contract.totalSupply(), BigInt(2), "initial supply 2; default");
});
});
//# sourceMappingURL=test-contract-integ.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test-contract-integ.js","sourceRoot":"","sources":["../../src.ts/_tests/test-contract-integ.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAG5B,0CAAqC;AAQrC,QAAQ,CAAC,4BAA4B,EAAE;IACnC,MAAM,QAAQ,GAAG,IAAI,iBAAM,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IAEtE,MAAM,GAAG,GAAG;QACR,4CAA4C;QAC5C,qDAAqD;QACrD,mDAAmD;QACnD,gEAAgE;QAChE,8BAA8B;KACjC,CAAC;IAEF,IAAI,OAAO,GAAkB,IAAI,CAAC;IAElC,EAAE,CAAC,oBAAoB,EAAE,KAAK;QAC1B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpB,MAAM,QAAQ,GAAG,gxFAAgxF,CAAC;QAClyF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAE3C,MAAM,OAAO,GAAG,IAAI,iBAAM,CAAC,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAElE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnD,OAAO,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;QAEtC,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAEnC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjD,gBAAM,CAAC,EAAE,CAAC,QAAQ,IAAI,IAAI,EAAE,eAAe,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,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AK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,qBAAqB,CAAC,CAAC;QAE5F,oCAAoC;QACpC,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACnF,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAE/E,0BAA0B;QAC1B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,oCAAoC;QACpC,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

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

View File

@@ -147,6 +147,34 @@ describe("Test Contract", function () {
await specificEvent;
await allEvents;
});
it("tests the _in_ operator for functions", function () {
const contract = new index_js_1.Contract(addr, abi);
assert_1.default.equal("testCallAdd" in contract, true, "has(testCallAdd)");
assert_1.default.equal("nonExist" in contract, false, "has(nonExist)");
{
const sig = "function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)";
assert_1.default.equal(sig in contract, true, `has(${sig})`);
assert_1.default.equal("function nonExist()" in contract, false, "has(function nonExist())");
}
assert_1.default.equal("0xf24684e5" in contract, true, "has(0xf24684e5)");
assert_1.default.equal("0xbad01234" in contract, false, "has(0xbad01234)");
});
it("tests the _in_ operator for events", function () {
const contract = new index_js_1.Contract(addr, abi);
assert_1.default.equal("EventUint256" in contract.filters, true, "has(EventUint256)");
assert_1.default.equal("NonExist" in contract.filters, false, "has(NonExist)");
{
const sig = "event EventUint256(uint256 indexed value)";
assert_1.default.equal(sig in contract.filters, true, `has(${sig})`);
assert_1.default.equal("event NonExist()" in contract.filters, false, "has(event NonExist())");
}
{
const hash = "0x85c55bbb820e6d71c71f4894e57751de334b38c421f9c170b0e66d32eafea337";
const badHash = "0xbad01234567890ffbad01234567890ffbad01234567890ffbad01234567890ff";
assert_1.default.equal(hash in contract.filters, true, `has(${hash})`);
assert_1.default.equal(badHash in contract.filters, false, `has(${badHash})`);
}
});
});
describe("Test Typed Contract Interaction", function () {
const tests = [

File diff suppressed because one or more lines are too long

View File

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

1
lib.commonjs/_tests/test-crypto.d.ts vendored Normal file
View File

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

View File

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

1
lib.commonjs/_tests/test-hash.d.ts vendored Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -36,6 +36,7 @@ describe("Tests Provider Call Exception", function () {
(0, index_js_1.dataSlice)((0, index_js_1.id)("testPanic(uint256)"), 0, 4),
(0, index_js_1.zeroPadValue)((0, index_js_1.toBeArray)(code), 32)
]);
await (0, utils_js_1.stall)(1000);
const tx = { to: testAddr, data };
try {
const result = await (method === "call" ? provider.call(tx) : provider.estimateGas(tx));

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

1
lib.commonjs/_tests/test-rlp.d.ts vendored Normal file
View File

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

View File

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

View File

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

View File

@@ -170,4 +170,25 @@ describe("Tests Bad Math Values", function () {
});
});
});
describe("Tests Twos Compliemnts Functions", function () {
const tests = [
{ width: 8, value: 0, twos: 0 },
{ width: 8, value: 1, twos: 1 },
{ width: 8, value: -1, twos: 0xff },
{ width: 8, value: 127, twos: 127 },
{ width: 8, value: -128, twos: 0x80 },
];
for (const { twos, width, value } of tests) {
it(`computes twos compliment values: ${value}[${width} bits]`, function () {
const result = (0, index_js_1.toTwos)(value, width);
assert_1.default.equal(result, twos);
});
}
for (const { twos, width, value } of tests) {
it(`computes values from twos compliment: ${value}[${width} bits]`, function () {
const result = (0, index_js_1.fromTwos)(twos, width);
assert_1.default.equal(result, value);
});
}
});
//# sourceMappingURL=test-utils-maths.js.map

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

@@ -0,0 +1,12 @@
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

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

View File

@@ -7,6 +7,13 @@ const assert_1 = __importDefault(require("assert"));
const wordlists_js_1 = require("../wordlists/wordlists.js");
const utils_js_1 = require("./utils.js");
const index_js_1 = require("../index.js");
/*
declare global {
class TextDecoder {
decode(data: Uint8Array): string;
}
}
*/
const decoder = new TextDecoder();
function fromHex(hex) {
const data = Buffer.from(hex.substring(2), "hex");

File diff suppressed because one or more lines are too long

View File

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

View File

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

1
lib.commonjs/_tests/test-wallet.d.ts vendored Normal file
View File

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

View File

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

216
lib.commonjs/_tests/types.d.ts vendored Normal file
View File

@@ -0,0 +1,216 @@
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;
}

8
lib.commonjs/_tests/utils.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
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>;

4
lib.commonjs/_version.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
/**
* The current version of Ethers.
*/
export declare const version: string;

View File

@@ -5,5 +5,5 @@ exports.version = void 0;
/**
* The current version of Ethers.
*/
exports.version = "6.0.5";
exports.version = "6.3.1";
//# sourceMappingURL=_version.js.map

58
lib.commonjs/abi/abi-coder.d.ts vendored Normal file
View File

@@ -0,0 +1,58 @@
/**
* When sending values to or receiving values from a [[Contract]], the
* data is generally encoded using the [ABI standard](link-solc-abi).
*
* 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 [[CallExceptionError]] 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

@@ -1,7 +1,7 @@
"use strict";
/**
* When sending values to or receiving values from a [[Contract]], the
* data is generally encoded using the [ABI standard](solc-abi-standard).
* data is generally encoded using the [ABI standard](link-solc-abi).
*
* The AbiCoder provides a utility to encode values to ABI data and
* decode values from ABI data.

14
lib.commonjs/abi/bytes32.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
/**
* 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

@@ -0,0 +1,116 @@
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;
}

12
lib.commonjs/abi/coders/address.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
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;
}

14
lib.commonjs/abi/coders/anonymous.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
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;
}

24
lib.commonjs/abi/coders/array.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
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;
}

12
lib.commonjs/abi/coders/boolean.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
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;
}

18
lib.commonjs/abi/coders/bytes.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
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

@@ -0,0 +1,14 @@
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;
}

11
lib.commonjs/abi/coders/null.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
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;
}

15
lib.commonjs/abi/coders/number.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
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;
}

12
lib.commonjs/abi/coders/string.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
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;
}

15
lib.commonjs/abi/coders/tuple.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
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;
}

371
lib.commonjs/abi/fragments.d.ts vendored Normal file
View File

@@ -0,0 +1,371 @@
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments [about-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 this is ``null``.
*/
readonly indexed: null | boolean;
/**
* The components for the tuple.
*
* For non-tuple types this is ``null``.
*/
readonly components: null | ReadonlyArray<ParamType>;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types this is ``null``.
*/
readonly arrayLength: null | number;
/**
* The type of each child in the array.
*
* For non-array types 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

@@ -57,7 +57,6 @@ class TokenString {
linkBack: (t.linkBack - from),
linkNext: (t.linkNext - from),
}));
return t;
}));
}
// Pops and returns the value of the next token, if it is a keyword in allowed; throws if out of tokens
@@ -506,7 +505,7 @@ class ParamType {
walk(value, process) {
if (this.isArray()) {
if (!Array.isArray(value)) {
throw new Error("invlaid array value");
throw new Error("invalid array value");
}
if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
throw new Error("array is wrong length");
@@ -516,7 +515,7 @@ class ParamType {
}
if (this.isTuple()) {
if (!Array.isArray(value)) {
throw new Error("invlaid tuple value");
throw new Error("invalid tuple value");
}
if (value.length !== this.components.length) {
throw new Error("array is wrong length");
@@ -529,7 +528,7 @@ class ParamType {
#walkAsync(promises, value, process, setValue) {
if (this.isArray()) {
if (!Array.isArray(value)) {
throw new Error("invlaid array value");
throw new Error("invalid array value");
}
if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
throw new Error("array is wrong length");
@@ -553,7 +552,7 @@ class ParamType {
}
else {
if (value == null || typeof (value) !== "object") {
throw new Error("invlaid tuple value");
throw new Error("invalid tuple value");
}
result = components.map((param) => {
if (!param.name) {
@@ -1160,8 +1159,26 @@ class FunctionFragment extends NamedFragment {
consumeEoi(obj);
return new FunctionFragment(_guard, name, mutability, inputs, outputs, gas);
}
// @TODO: verifyState for stateMutability
return new FunctionFragment(_guard, obj.name, obj.stateMutability, obj.inputs ? obj.inputs.map(ParamType.from) : [], obj.outputs ? obj.outputs.map(ParamType.from) : [], (obj.gas != null) ? obj.gas : null);
let stateMutability = obj.stateMutability;
// Use legacy Solidity ABI logic if stateMutability is missing
if (stateMutability == null) {
stateMutability = "payable";
if (typeof (obj.constant) === "boolean") {
stateMutability = "view";
if (!obj.constant) {
stateMutability = "payable";
if (typeof (obj.payable) === "boolean" && !obj.payable) {
stateMutability = "nonpayable";
}
}
}
else if (typeof (obj.payable) === "boolean" && !obj.payable) {
stateMutability = "nonpayable";
}
}
// @TODO: verifyState for stateMutability (e.g. throw if
// payable: false but stateMutability is "nonpayable")
return new FunctionFragment(_guard, obj.name, stateMutability, obj.inputs ? obj.inputs.map(ParamType.from) : [], obj.outputs ? obj.outputs.map(ParamType.from) : [], (obj.gas != null) ? obj.gas : null);
}
static isFragment(value) {
return (value && value[internal] === FunctionFragmentInternal);

File diff suppressed because one or more lines are too long

13
lib.commonjs/abi/index.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [about-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";

269
lib.commonjs/abi/interface.d.ts vendored Normal file
View File

@@ -0,0 +1,269 @@
/**
* 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;
/**
* Returns true if %%key%% (a function selector, function name or
* function signature) is present in the ABI.
*
* In the case of a function name, the name may be ambiguous, so
* accessing the [[FunctionFragment]] may require refinement.
*/
hasFunction(key: string): boolean;
/**
* 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;
/**
* Returns true if %%key%% (an event topic hash, event name or
* event signature) is present in the ABI.
*
* In the case of an event name, the name may be ambiguous, so
* accessing the [[EventFragment]] may require refinement.
*/
hasEvent(key: string): boolean;
/**
* 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 [[parseCallResult]] 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 [[parseCallResult]] 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

@@ -337,6 +337,16 @@ class Interface {
(0, index_js_3.assertArgument)(fragment, "no matching function", "key", key);
return fragment.name;
}
/**
* Returns true if %%key%% (a function selector, function name or
* function signature) is present in the ABI.
*
* In the case of a function name, the name may be ambiguous, so
* accessing the [[FunctionFragment]] may require refinement.
*/
hasFunction(key) {
return !!this.#getFunction(key, null, false);
}
/**
* Get the [[FunctionFragment]] for %%key%%, which may be a function
* selector, function name or function signature that belongs to the ABI.
@@ -429,6 +439,16 @@ class Interface {
(0, index_js_3.assertArgument)(fragment, "no matching event", "key", key);
return fragment.name;
}
/**
* Returns true if %%key%% (an event topic hash, event name or
* event signature) is present in the ABI.
*
* In the case of an event name, the name may be ambiguous, so
* accessing the [[EventFragment]] may require refinement.
*/
hasEvent(key) {
return !!this.#getEvent(key, null, false);
}
/**
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.

File diff suppressed because one or more lines are too long

171
lib.commonjs/abi/typed.d.ts vendored Normal file
View File

@@ -0,0 +1,171 @@
/**
* A Typed object allows a value to have its type explicitly
* specified.
*
* For example, in Solidity, the value ``45`` could represent a
* ``uint8`` or a ``uint256``. The value ``0x1234`` could represent
* a ``bytes2`` or ``bytes``.
*
* Since JavaScript has no meaningful way to explicitly inform any
* APIs which what the type is, this allows transparent interoperation
* with Soldity.
*
* @_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

@@ -1,6 +1,15 @@
"use strict";
/**
* About typed...
* A Typed object allows a value to have its type explicitly
* specified.
*
* For example, in Solidity, the value ``45`` could represent a
* ``uint8`` or a ``uint256``. The value ``0x1234`` could represent
* a ``bytes2`` or ``bytes``.
*
* Since JavaScript has no meaningful way to explicitly inform any
* APIs which what the type is, this allows transparent interoperation
* with Soldity.
*
* @_subsection: api/abi:Typed Values
*/

File diff suppressed because one or more lines are too long

55
lib.commonjs/address/address.d.ts vendored Normal file
View File

@@ -0,0 +1,55 @@
/**
* 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

@@ -134,7 +134,7 @@ exports.getAddress = getAddress;
/**
* 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.
* industry [IBAN format](link-wiki-iban) for bank accounts.
*
* It is no longer common or a recommended format.
*

80
lib.commonjs/address/checks.d.ts vendored Normal file
View File

@@ -0,0 +1,80 @@
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

@@ -0,0 +1,47 @@
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;

48
lib.commonjs/address/index.d.ts vendored Normal file
View File

@@ -0,0 +1,48 @@
/**
* 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 [about-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";

6
lib.commonjs/constants/addresses.d.ts vendored Normal file
View File

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

6
lib.commonjs/constants/hashes.d.ts vendored Normal file
View File

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

9
lib.commonjs/constants/index.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [about-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";

30
lib.commonjs/constants/numbers.d.ts vendored Normal file
View File

@@ -0,0 +1,30 @@
/**
* 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;

12
lib.commonjs/constants/strings.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* 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;

50
lib.commonjs/contract/contract.d.ts vendored Normal file
View File

@@ -0,0 +1,50 @@
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 } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction, WrappedFallback } 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 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

@@ -58,9 +58,6 @@ class PreparedTopicFilter {
// D = The type the default call will return (i.e. R for view/pure,
// TransactionResponse otherwise)
//export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = ContractTransactionResponse> {
function _WrappedMethodBase() {
return Function;
}
function getRunner(value, feature) {
if (value == null) {
return null;
@@ -112,98 +109,68 @@ async function resolveArgs(_runner, inputs, args) {
}));
}
exports.resolveArgs = resolveArgs;
class WrappedFallback {
_contract;
constructor(contract) {
(0, index_js_3.defineProperties)(this, { _contract: contract });
const proxy = new Proxy(this, {
// Perform send when called
apply: async (target, thisArg, args) => {
return await target.send(...args);
},
});
return proxy;
}
async populateTransaction(overrides) {
function buildWrappedFallback(contract) {
const populateTransaction = async function (overrides) {
// If an overrides was passed in, copy it and normalize the values
const tx = (await copyOverrides(overrides, ["data"]));
tx.to = await this._contract.getAddress();
const iface = this._contract.interface;
tx.to = await contract.getAddress();
const iface = contract.interface;
// Only allow payable contracts to set non-zero value
const payable = iface.receive || (iface.fallback && iface.fallback.payable);
(0, index_js_3.assertArgument)(payable || (tx.value || BN_0) === BN_0, "cannot send value to non-payable contract", "overrides.value", tx.value);
// Only allow fallback contracts to set non-empty data
(0, index_js_3.assertArgument)(iface.fallback || (tx.data || "0x") === "0x", "cannot send data to receive-only contract", "overrides.data", tx.data);
return tx;
}
async staticCall(overrides) {
const runner = getRunner(this._contract.runner, "call");
};
const staticCall = async function (overrides) {
const runner = getRunner(contract.runner, "call");
(0, index_js_3.assert)(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(overrides);
const tx = await populateTransaction(overrides);
try {
return await runner.call(tx);
}
catch (error) {
if ((0, index_js_3.isCallException)(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
}
async send(overrides) {
const runner = this._contract.runner;
};
const send = async function (overrides) {
const runner = contract.runner;
(0, index_js_3.assert)(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(overrides));
const provider = getProvider(this._contract.runner);
const tx = await runner.sendTransaction(await populateTransaction(overrides));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new wrappers_js_1.ContractTransactionResponse(this._contract.interface, provider, tx);
}
async estimateGas(overrides) {
const runner = getRunner(this._contract.runner, "estimateGas");
return new wrappers_js_1.ContractTransactionResponse(contract.interface, provider, tx);
};
const estimateGas = async function (overrides) {
const runner = getRunner(contract.runner, "estimateGas");
(0, index_js_3.assert)(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(overrides));
}
return await runner.estimateGas(await populateTransaction(overrides));
};
const method = async (overrides) => {
return await send(overrides);
};
(0, index_js_3.defineProperties)(method, {
_contract: contract,
estimateGas,
populateTransaction,
send, staticCall
});
return method;
}
class WrappedMethod extends _WrappedMethodBase() {
name = ""; // Investigate!
_contract;
_key;
constructor(contract, key) {
super();
(0, index_js_3.defineProperties)(this, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key
});
const proxy = new Proxy(this, {
// Perform the default operation for this fragment type
apply: async (target, thisArg, args) => {
const fragment = target.getFragment(...args);
if (fragment.constant) {
return await target.staticCall(...args);
}
return await target.send(...args);
},
});
return proxy;
}
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
get fragment() {
const fragment = this._contract.interface.getFunction(this._key);
function buildWrappedMethod(contract, key) {
const getFragment = function (...args) {
const fragment = contract.interface.getFunction(key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
getFragment(...args) {
const fragment = this._contract.interface.getFunction(this._key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
async populateTransaction(...args) {
const fragment = this.getFragment(...args);
};
const populateTransaction = async function (...args) {
const fragment = getFragment(...args);
// If an overrides was passed in, copy it and normalize the values
let overrides = {};
if (fragment.inputs.length + 1 === args.length) {
@@ -212,88 +179,109 @@ class WrappedMethod extends _WrappedMethodBase() {
if (fragment.inputs.length !== args.length) {
throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
}
const resolvedArgs = await resolveArgs(this._contract.runner, fragment.inputs, args);
const resolvedArgs = await resolveArgs(contract.runner, fragment.inputs, args);
return Object.assign({}, overrides, await (0, index_js_3.resolveProperties)({
to: this._contract.getAddress(),
data: this._contract.interface.encodeFunctionData(fragment, resolvedArgs)
to: contract.getAddress(),
data: contract.interface.encodeFunctionData(fragment, resolvedArgs)
}));
}
async staticCall(...args) {
const result = await this.staticCallResult(...args);
};
const staticCall = async function (...args) {
const result = await staticCallResult(...args);
if (result.length === 1) {
return result[0];
}
return result;
}
async send(...args) {
const runner = this._contract.runner;
};
const send = async function (...args) {
const runner = contract.runner;
(0, index_js_3.assert)(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
const tx = await runner.sendTransaction(await this.populateTransaction(...args));
const provider = getProvider(this._contract.runner);
const tx = await runner.sendTransaction(await populateTransaction(...args));
const provider = getProvider(contract.runner);
// @TODO: the provider can be null; make a custom dummy provider that will throw a
// meaningful error
return new wrappers_js_1.ContractTransactionResponse(this._contract.interface, provider, tx);
}
async estimateGas(...args) {
const runner = getRunner(this._contract.runner, "estimateGas");
return new wrappers_js_1.ContractTransactionResponse(contract.interface, provider, tx);
};
const estimateGas = async function (...args) {
const runner = getRunner(contract.runner, "estimateGas");
(0, index_js_3.assert)(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
return await runner.estimateGas(await this.populateTransaction(...args));
}
async staticCallResult(...args) {
const runner = getRunner(this._contract.runner, "call");
return await runner.estimateGas(await populateTransaction(...args));
};
const staticCallResult = async function (...args) {
const runner = getRunner(contract.runner, "call");
(0, index_js_3.assert)(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
const tx = await this.populateTransaction(...args);
const tx = await populateTransaction(...args);
let result = "0x";
try {
result = await runner.call(tx);
}
catch (error) {
if ((0, index_js_3.isCallException)(error) && error.data) {
throw this._contract.interface.makeError(error.data, tx);
throw contract.interface.makeError(error.data, tx);
}
throw error;
}
const fragment = this.getFragment(...args);
return this._contract.interface.decodeFunctionResult(fragment, result);
}
const fragment = getFragment(...args);
return contract.interface.decodeFunctionResult(fragment, result);
};
const method = async (...args) => {
const fragment = getFragment(...args);
if (fragment.constant) {
return await staticCall(...args);
}
return await send(...args);
};
(0, index_js_3.defineProperties)(method, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key,
getFragment,
estimateGas,
populateTransaction,
send, staticCall, staticCallResult,
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getFunction(key);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return method;
}
function _WrappedEventBase() {
return Function;
}
class WrappedEvent extends _WrappedEventBase() {
name = ""; // @TODO: investigate
_contract;
_key;
constructor(contract, key) {
super();
(0, index_js_3.defineProperties)(this, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key
});
return new Proxy(this, {
// Perform the default operation for this fragment type
apply: (target, thisArg, args) => {
return new PreparedTopicFilter(contract, target.getFragment(...args), args);
},
});
}
// Only works on non-ambiguous keys
get fragment() {
const fragment = this._contract.interface.getEvent(this._key);
function buildWrappedEvent(contract, key) {
const getFragment = function (...args) {
const fragment = contract.interface.getEvent(key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
getFragment(...args) {
const fragment = this._contract.interface.getEvent(this._key, args);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
};
const method = function (...args) {
return new PreparedTopicFilter(contract, getFragment(...args), args);
};
(0, index_js_3.defineProperties)(method, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key,
getFragment
});
// Only works on non-ambiguous keys (refined fragment is always non-ambiguous)
Object.defineProperty(method, "fragment", {
configurable: false,
enumerable: true,
get: () => {
const fragment = contract.interface.getEvent(key);
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
operation: "fragment"
});
return fragment;
}
});
return method;
}
;
// The combination of TypeScrype, Private Fields and Proxies makes
// the world go boom; so we hide variables with some trickery keeping
// a symbol attached to each BaseContract which its sub-class (even
@@ -549,11 +537,18 @@ class BaseContract {
return result;
}
throw new Error(`unknown contract event: ${prop}`);
},
has: (target, prop) => {
// Pass important checks (like `then` for Promise) through
if (passProperties.indexOf(prop) >= 0) {
return Reflect.has(target, prop);
}
return Reflect.has(target, prop) || this.interface.hasEvent(String(prop));
}
});
(0, index_js_3.defineProperties)(this, { filters });
(0, index_js_3.defineProperties)(this, {
fallback: ((iface.receive || iface.fallback) ? (new WrappedFallback(this)) : null)
fallback: ((iface.receive || iface.fallback) ? (buildWrappedFallback(this)) : null)
});
// Return a Proxy that will respond to functions
return new Proxy(this, {
@@ -567,6 +562,12 @@ class BaseContract {
return result;
}
throw new Error(`unknown contract method: ${prop}`);
},
has: (target, prop) => {
if (prop in target || passProperties.indexOf(prop) >= 0) {
return Reflect.has(target, prop);
}
return target.interface.hasFunction(String(prop));
}
});
}
@@ -621,13 +622,14 @@ class BaseContract {
if (typeof (key) !== "string") {
key = key.format();
}
return (new WrappedMethod(this, key));
const func = buildWrappedMethod(this, key);
return func;
}
getEvent(key) {
if (typeof (key) !== "string") {
key = key.format();
}
return (new WrappedEvent(this, key));
return buildWrappedEvent(this, key);
}
async queryTransaction(hash) {
// Is this useful?

File diff suppressed because one or more lines are too long

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