forked from tornado-packages/ethers.js
Compare commits
153 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b4debd4a9 | ||
|
|
6017d3d39a | ||
|
|
ccac24a5b0 | ||
|
|
f6d155c820 | ||
|
|
180221574c | ||
|
|
6ee1a5f8bb | ||
|
|
98910ba01e | ||
|
|
d60dfc14a3 | ||
|
|
f8f11c754a | ||
|
|
4681b83d51 | ||
|
|
9e74d14432 | ||
|
|
2b67488151 | ||
|
|
da34e3569e | ||
|
|
e2485b8ef9 | ||
|
|
93fb138809 | ||
|
|
944cbbc0a5 | ||
|
|
a92766e56a | ||
|
|
cf00331309 | ||
|
|
ee79d7d005 | ||
|
|
aff7addfd9 | ||
|
|
39315288be | ||
|
|
1c71ec6df6 | ||
|
|
1d9c0197a2 | ||
|
|
168518f1cb | ||
|
|
e9fac926c9 | ||
|
|
238f4f64ca | ||
|
|
d11a2b5a5e | ||
|
|
61a66e413a | ||
|
|
22b7a2c111 | ||
|
|
5d62591796 | ||
|
|
85a039f180 | ||
|
|
5431723ec3 | ||
|
|
8fed2f8476 | ||
|
|
73adb393e8 | ||
|
|
2e0bd90744 | ||
|
|
1da50ae286 | ||
|
|
e0c1d976b2 | ||
|
|
e454afb2fa | ||
|
|
4772915f0c | ||
|
|
3a73c56ee3 | ||
|
|
c847f16d5c | ||
|
|
125ff1189b | ||
|
|
bc115a2733 | ||
|
|
3644140861 | ||
|
|
aca848f772 | ||
|
|
d6a8c14d90 | ||
|
|
2616f4c30c | ||
|
|
cd5f0fe03f | ||
|
|
9a4b753445 | ||
|
|
06db040822 | ||
|
|
0c9c23b02d | ||
|
|
b27faa02ac | ||
|
|
9541f2f70c | ||
|
|
c7f8abefa4 | ||
|
|
dcea9b3536 | ||
|
|
bc6cfbf2cc | ||
|
|
77fcc7fdab | ||
|
|
32915634be | ||
|
|
7d4173049e | ||
|
|
30d3d6ee32 | ||
|
|
71606b5799 | ||
|
|
4d2e1ff810 | ||
|
|
203dfc33b9 | ||
|
|
4eb84da865 | ||
|
|
609e2f53eb | ||
|
|
2710077bea | ||
|
|
0df3ab9313 | ||
|
|
b4fb1a166d | ||
|
|
dfe1eefd03 | ||
|
|
6fda150426 | ||
|
|
c5cb7cd71d | ||
|
|
e45bc77cd9 | ||
|
|
c3971ab428 | ||
|
|
d6be75f266 | ||
|
|
25fef4f8d7 | ||
|
|
ff80b04f31 | ||
|
|
f3c46f2299 | ||
|
|
d32f81b3c3 | ||
|
|
17969fe416 | ||
|
|
0dca645632 | ||
|
|
3a52201fe2 | ||
|
|
b5724e4713 | ||
|
|
aa2ea3d529 | ||
|
|
b1dbbb0de3 | ||
|
|
f42f258beb | ||
|
|
78538eb100 | ||
|
|
d3e5e2c45b | ||
|
|
82bb936542 | ||
|
|
23704a9c44 | ||
|
|
8f0a50921a | ||
|
|
229145ddf5 | ||
|
|
ec39abe067 | ||
|
|
ff9d124c60 | ||
|
|
ba36079a28 | ||
|
|
8c2652c8cb | ||
|
|
5bf7b3494e | ||
|
|
bcc4d8c870 | ||
|
|
ac2f5e563b | ||
|
|
93af87c447 | ||
|
|
fa3a883ff7 | ||
|
|
a8bc49bdcf | ||
|
|
e36b6c35b7 | ||
|
|
450a176ee2 | ||
|
|
b1375f4e44 | ||
|
|
5a56fc36d7 | ||
|
|
a7e4048fe3 | ||
|
|
330c318773 | ||
|
|
57f1e1c471 | ||
|
|
19cbcaf3b0 | ||
|
|
492919d14f | ||
|
|
43c253a402 | ||
|
|
fe631c6f1f | ||
|
|
1dd542721d | ||
|
|
80f62efc41 | ||
|
|
7d061b786f | ||
|
|
3c17cf56b5 | ||
|
|
9197f9f938 | ||
|
|
1dc8986a33 | ||
|
|
3d141b44b5 | ||
|
|
d2b5f1da02 | ||
|
|
857aa8ccc3 | ||
|
|
3df09fcbe6 | ||
|
|
d51e3fbff4 | ||
|
|
5210b68a78 | ||
|
|
31cc4edf2c | ||
|
|
203a759efc | ||
|
|
de0f5189f6 | ||
|
|
84375be92d | ||
|
|
2318005dfd | ||
|
|
9055ef6c69 | ||
|
|
026c5bb137 | ||
|
|
c448458633 | ||
|
|
8dd21f0333 | ||
|
|
11956aee34 | ||
|
|
374fbaebcd | ||
|
|
9a14709def | ||
|
|
38ee3195b0 | ||
|
|
51a9610fe0 | ||
|
|
20c3d1b109 | ||
|
|
bb8685b112 | ||
|
|
3c1bad2fb7 | ||
|
|
f37a52da28 | ||
|
|
7dcecfa47d | ||
|
|
3235910f3b | ||
|
|
8eb8cae8cd | ||
|
|
c1357847dc | ||
|
|
9b0e9920c0 | ||
|
|
56ed4e7380 | ||
|
|
15ed2f5b32 | ||
|
|
d8e9586044 | ||
|
|
bbcfb5f6b8 | ||
|
|
c785c1e515 | ||
|
|
a6000e3c6d |
4
.github/workflows/generate-docs.yml
vendored
4
.github/workflows/generate-docs.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 20.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
@@ -35,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/cli-test ./docs.wrm/config.js
|
||||
run: node node_modules/flatworm/lib/cli-test ./docs.wrm/config.mjs
|
||||
|
||||
- name: Upload documentation to to docs.ethers.org
|
||||
uses: ethers-io/sync-s3-action@main
|
||||
|
||||
7
.github/workflows/test-browser.yml
vendored
7
.github/workflows/test-browser.yml
vendored
@@ -4,6 +4,11 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src.ts/**"
|
||||
- "lib.esm/**"
|
||||
- "lib.commonjs/**"
|
||||
- "misc/test-browser/**"
|
||||
|
||||
jobs:
|
||||
test-browser:
|
||||
@@ -20,7 +25,7 @@ jobs:
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 20.x
|
||||
|
||||
- name: Install and run Geth
|
||||
uses: ethers-io/run-geth-action@main
|
||||
|
||||
4
.github/workflows/test-ci.yml
vendored
4
.github/workflows/test-ci.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [ 16.x, 18.x ]
|
||||
node-version: [ 18.x, 20.x ]
|
||||
test-type: [ esm, commonjs ]
|
||||
|
||||
steps:
|
||||
@@ -66,7 +66,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 20.x
|
||||
|
||||
- name: Install and run Geth
|
||||
uses: ethers-io/run-geth-action@main
|
||||
|
||||
4
.github/workflows/test-env.yml
vendored
4
.github/workflows/test-env.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 20.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 18.x
|
||||
node-version: 20.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
@@ -28,3 +28,4 @@ testcases/**
|
||||
node_modules/**
|
||||
misc/**
|
||||
**/*.tgz
|
||||
dist/*.gz
|
||||
|
||||
152
CHANGELOG.md
152
CHANGELOG.md
@@ -3,9 +3,159 @@ Change Log
|
||||
|
||||
This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.
|
||||
|
||||
ethers/v6.4.0 (2023-05-18 17:12)
|
||||
ethers/v6.9.2 (2024-01-02 19:12)
|
||||
--------------------------------
|
||||
|
||||
- Fix Base58 padding for string representation of binary data ([#4527](https://github.com/ethers-io/ethers.js/issues/4527); [ccac24a](https://github.com/ethers-io/ethers.js/commit/ccac24a5b0a4d07a4b639c1c4d0a44703e32d418)).
|
||||
|
||||
ethers/v6.9.1 (2023-12-19 04:53)
|
||||
--------------------------------
|
||||
|
||||
- Fix uncatchable issue when sending transactions over JSON-RPC and provide some retry-recovery for missing v ([#4513](https://github.com/ethers-io/ethers.js/issues/4513); [1802215](https://github.com/ethers-io/ethers.js/commit/180221574c5d2af9ad85404af4fab8752d3d5029)).
|
||||
|
||||
ethers/v6.9.0 (2023-11-27 06:15)
|
||||
--------------------------------
|
||||
|
||||
- Use provider-specified suggested priority fee when available, otherwise fallback onto existing logic of 1 gwei ([#4463](https://github.com/ethers-io/ethers.js/issues/4463); [f8f11c7](https://github.com/ethers-io/ethers.js/commit/f8f11c754aa2c9b541db73d3bde66a8ffa5146f0)).
|
||||
- Add auto-detected static network support to providers and allow customizing socket provider options ([#4199](https://github.com/ethers-io/ethers.js/issues/4199), [#4418](https://github.com/ethers-io/ethers.js/issues/4418), [#4441](https://github.com/ethers-io/ethers.js/issues/4441); [4681b83](https://github.com/ethers-io/ethers.js/commit/4681b83d516ab2eb41ddb68b5021c97e14c6f2cf)).
|
||||
- Added Base network to AlchemyProvider ([#4384](https://github.com/ethers-io/ethers.js/issues/4384); [9e74d14](https://github.com/ethers-io/ethers.js/commit/9e74d14432e6efebdff21b9a7d2e6143af55e143)).
|
||||
- Fixed ParamType formatting causing bad tuple full and minimal ABI output ([#4329](https://github.com/ethers-io/ethers.js/issues/4329), [#4479](https://github.com/ethers-io/ethers.js/issues/4479); [2b67488](https://github.com/ethers-io/ethers.js/commit/2b6748815169abf2c99a647131875c13b8b6a787)).
|
||||
- Adjust for provider config weight when kicking off a request in FallbackProvider ([#4298](https://github.com/ethers-io/ethers.js/issues/4298); [da34e35](https://github.com/ethers-io/ethers.js/commit/da34e3569e95357d9469209d926cb645f0750bfa)).
|
||||
- More robust FallbackProvider broadcast ([#4186](https://github.com/ethers-io/ethers.js/issues/4186), [#4297](https://github.com/ethers-io/ethers.js/issues/4297), [#4442](https://github.com/ethers-io/ethers.js/issues/4442); [e2485b8](https://github.com/ethers-io/ethers.js/commit/e2485b8ef927d18c7a15d2d29b3b0feffec9991a)).
|
||||
- Added safe and finalized provider events ([#3921](https://github.com/ethers-io/ethers.js/issues/3921); [a92766e](https://github.com/ethers-io/ethers.js/commit/a92766e56ad04185625037d84fc28adaac7fae8c)).
|
||||
|
||||
ethers/v6.8.1 (2023-11-01 16:08)
|
||||
--------------------------------
|
||||
|
||||
- Fixed typo in error description when converting values to arrays ([#4427](https://github.com/ethers-io/ethers.js/issues/4427), [#4446](https://github.com/ethers-io/ethers.js/issues/4446); [8fed2f8](https://github.com/ethers-io/ethers.js/commit/8fed2f84768ace4bf3e5742c931a74841da7c637)).
|
||||
- Fix invalid token nonpayable being included in formatted constructor ([#4412](https://github.com/ethers-io/ethers.js/issues/4412); [2e0bd90](https://github.com/ethers-io/ethers.js/commit/2e0bd90744b8e76fcf03f75a66cb0061d50f7bd9)).
|
||||
- Add ENS support for Sepolia ([#4422](https://github.com/ethers-io/ethers.js/issues/4422); [1da50ae](https://github.com/ethers-io/ethers.js/commit/1da50ae286da01e58a70bb8df8aa5cc5d260e33e)).
|
||||
|
||||
ethers/v6.8.0 (2023-10-10 22:42)
|
||||
--------------------------------
|
||||
|
||||
- Replicated former ENS normalize behaviour for empty strings and update namehash testcases ([125ff11](https://github.com/ethers-io/ethers.js/commit/125ff1189b9cefb8abfd7da9c104c75e382a50cc)).
|
||||
- Initial shortMessage support for errors ([#4241](https://github.com/ethers-io/ethers.js/issues/4241); [d6a8c14](https://github.com/ethers-io/ethers.js/commit/d6a8c14d907cf8b90347444c0186b83a5db2e293)).
|
||||
- Fixed resolving ENS addresses used as from parameters ([#3961](https://github.com/ethers-io/ethers.js/issues/3961); [2616f4c](https://github.com/ethers-io/ethers.js/commit/2616f4c30c82bd45449b73fa37ef269d60a07d80)).
|
||||
- Merge: 9a4b7534 0c9c23b0 Merge branch 'v5.8-progress' ([cd5f0fe](https://github.com/ethers-io/ethers.js/commit/cd5f0fe03f2137fbc47e295f8db38a5151111e72)).
|
||||
- Allow more loose input format for RLP encoder ([#4402](https://github.com/ethers-io/ethers.js/issues/4402); [9a4b753](https://github.com/ethers-io/ethers.js/commit/9a4b7534458fc79a0654b0eb57fc956bffa02a2f)).
|
||||
- Update to latest noble crypto libraries ([#3975](https://github.com/ethers-io/ethers.js/issues/3975); [b27faa0](https://github.com/ethers-io/ethers.js/commit/b27faa02ac8f90e2e54b188e8139c59d98c469e3)).
|
||||
- More robust configuration options for FetchRequest getUrl functions ([#4353](https://github.com/ethers-io/ethers.js/issues/4353); [9541f2f](https://github.com/ethers-io/ethers.js/commit/9541f2f70cd7f5c6f3caf93f5a3d5e34eae5281a)).
|
||||
- Ignore blockTag when calling Etherscan if it is the default block tag ([dcea9b3](https://github.com/ethers-io/ethers.js/commit/dcea9b353619d85878ad2ba340ae17e5c285d558)).
|
||||
|
||||
ethers/v6.7.1 (2023-08-15 03:08)
|
||||
--------------------------------
|
||||
|
||||
- Prevent destroyed providers from emitting network detection errors ([7d41730](https://github.com/ethers-io/ethers.js/commit/7d4173049edc3b4ff2de1971c3ecca3b08588651)).
|
||||
- Fix VSCode reported lint issues ([#4153](https://github.com/ethers-io/ethers.js/issues/4153), [#4156](https://github.com/ethers-io/ethers.js/issues/4156), [#4158](https://github.com/ethers-io/ethers.js/issues/4158), [#4159](https://github.com/ethers-io/ethers.js/issues/4159); [4eb84da](https://github.com/ethers-io/ethers.js/commit/4eb84da865a82a27c5113c38102b6b710096958e), [203dfc3](https://github.com/ethers-io/ethers.js/commit/203dfc33b9c8e72c9cdfe0a349ac763ef17a4484)).
|
||||
- Add gasPrice to Polygon feeData for type 0 and type 1 legacy transactions ([#4315](https://github.com/ethers-io/ethers.js/issues/4315); [0df3ab9](https://github.com/ethers-io/ethers.js/commit/0df3ab93137039de1e1986bbfe9a5b32ceffa8a4)).
|
||||
|
||||
ethers/v6.7.0 (2023-08-02 23:52)
|
||||
--------------------------------
|
||||
|
||||
- Fixed receipt wait not throwing on reverted transactions ([25fef4f](https://github.com/ethers-io/ethers.js/commit/25fef4f8d756f5bbf5a2a05e38233248a8eb43ac)).
|
||||
- Added custom priority fee to Optimism chain (via telegram) ([ff80b04](https://github.com/ethers-io/ethers.js/commit/ff80b04f31da21496e72d3687cecd1c01efaecc5)).
|
||||
- Add context to Logs that fail decoding due to ABI issues to help debugging ([f3c46f2](https://github.com/ethers-io/ethers.js/commit/f3c46f22994d194ff78b3b176407b2ecb7af1c77)).
|
||||
- Added new exports for FallbackProviderOptions and FetchUrlFeeDataNetworkPlugin ([#2828](https://github.com/ethers-io/ethers.js/issues/2828), [#4160](https://github.com/ethers-io/ethers.js/issues/4160); [b1dbbb0](https://github.com/ethers-io/ethers.js/commit/b1dbbb0de3f10a3d9e12d6a84ad5c52bea25c7f6)).
|
||||
- Allow overriding pollingInterval in JsonRpcProvider constructor (via discord) ([f42f258](https://github.com/ethers-io/ethers.js/commit/f42f258beb305a06e563ad16522f095a72da32eb)).
|
||||
- Fixed FallbackProvider priority sorting ([#4150](https://github.com/ethers-io/ethers.js/issues/4150); [78538eb](https://github.com/ethers-io/ethers.js/commit/78538eb100addd135d29e60c9fa4fed3946278fa)).
|
||||
- Added linea network to InfuraProvider and Network ([#4184](https://github.com/ethers-io/ethers.js/issues/4184), [#4190](https://github.com/ethers-io/ethers.js/issues/4190); [d3e5e2c](https://github.com/ethers-io/ethers.js/commit/d3e5e2c45b28c377f306091acfc024e30c49ef20)).
|
||||
- Added whitelist support to getDefaultProvider ([82bb936](https://github.com/ethers-io/ethers.js/commit/82bb936542e29c6441ac8dc2d3ebbdd4edb708ee)).
|
||||
- Add Polygon RPC endpoints to the default provider ([#3689](https://github.com/ethers-io/ethers.js/issues/3689); [23704a9](https://github.com/ethers-io/ethers.js/commit/23704a9c44d5857817e138fb19d44ce2103ca005)).
|
||||
- Added customizable quorum to FallbackProvider ([#4160](https://github.com/ethers-io/ethers.js/issues/4160); [8f0a509](https://github.com/ethers-io/ethers.js/commit/8f0a50921a12a866addcf5b0fabc576bfc287689)).
|
||||
- Added basic Gas Station support via a NetworkPlugin ([#2828](https://github.com/ethers-io/ethers.js/issues/2828); [229145d](https://github.com/ethers-io/ethers.js/commit/229145ddf566a962517588eaeed155734c7d4598)).
|
||||
- Add BNB URLs to EtherscanProvider networks ([ec39abe](https://github.com/ethers-io/ethers.js/commit/ec39abe067259fad4ea8607a6c5aece61890eb41)).
|
||||
- Added tests for JSON format ([#4248](https://github.com/ethers-io/ethers.js/issues/4248); [ba36079](https://github.com/ethers-io/ethers.js/commit/ba36079a285706694532ce726568c4c447acad47)).
|
||||
- Use empty string for unnamed parameters in JSON output instead of undefined ([#4248](https://github.com/ethers-io/ethers.js/issues/4248); [8c2652c](https://github.com/ethers-io/ethers.js/commit/8c2652c8cb4d054207d89688d30930869d9d3f8b)).
|
||||
- Return undefined for Contract properties that do not exist instead of throwing an error ([#4266](https://github.com/ethers-io/ethers.js/issues/4266); [5bf7b34](https://github.com/ethers-io/ethers.js/commit/5bf7b3494ed62952fc387b4368a0bdc86dfe163e)).
|
||||
|
||||
ethers/v6.6.7 (2023-07-28 14:50)
|
||||
--------------------------------
|
||||
|
||||
- Prevent malformed logs from preventing other logs being decoded ([#4275](https://github.com/ethers-io/ethers.js/issues/4275); [0dca645](https://github.com/ethers-io/ethers.js/commit/0dca645632d73488bf6ad460e0d779361a537bbe)).
|
||||
- Allow visibility on human-readable constructors ([#4278](https://github.com/ethers-io/ethers.js/issues/4278); [3a52201](https://github.com/ethers-io/ethers.js/commit/3a52201fe2ba68a00105cca2c0901da5ffa18d6b)).
|
||||
|
||||
ethers/v6.6.6 (2023-07-28 01:14)
|
||||
--------------------------------
|
||||
|
||||
- Better error message when passing invalid overrides object into a contract deployment ([#4182](https://github.com/ethers-io/ethers.js/issues/4182); [aa2ea3d](https://github.com/ethers-io/ethers.js/commit/aa2ea3d5296956fd0d40b83888e1ca053bb250ee)).
|
||||
|
||||
ethers/v6.6.5 (2023-07-24 00:04)
|
||||
--------------------------------
|
||||
|
||||
- Reflect symbols in the Contract Proxy to target ([#4084](https://github.com/ethers-io/ethers.js/issues/4048); [ac2f5e5](https://github.com/ethers-io/ethers.js/commit/ac2f5e563b8ec0e91a931470eb6ea58b0c01fb3d)).
|
||||
- Allow arrays of address for indexed filter topics ([#4259](https://github.com/ethers-io/ethers.js/issues/4259); [93af87c](https://github.com/ethers-io/ethers.js/commit/93af87c447eeb77090e29bd940612603b3f74026)).
|
||||
- Fixed filter encoding for bytesX ([#4244](https://github.com/ethers-io/ethers.js/issues/4244); [fa3a883](https://github.com/ethers-io/ethers.js/commit/fa3a883ff7c88611ce766f58bdd4b8ac90814470)).
|
||||
- Fix JSON formatting for tuple arrays ([#4237](https://github.com/ethers-io/ethers.js/issues/4237); [a8bc49b](https://github.com/ethers-io/ethers.js/commit/a8bc49bdcf07a51b35f38cf209db27e116cc1a59)).
|
||||
- Better error messages when parsing fragment strings ([#4246](https://github.com/ethers-io/ethers.js/issues/4246); [e36b6c3](https://github.com/ethers-io/ethers.js/commit/e36b6c35b7bc777c9adbe0055b32b31a13185240)).
|
||||
- Include the missing fragment key and args when no matching Contract method or event is present ([#3809](https://github.com/ethers-io/ethers.js/issues/3809); [450a176](https://github.com/ethers-io/ethers.js/commit/450a176ee25f88a2ddb9ff23b153ef70bf1dc546)).
|
||||
- Prevent a single malformed event from preventing other Contract logs; reported on Discord ([b1375f4](https://github.com/ethers-io/ethers.js/commit/b1375f4e4463b856855ebc684b45945455ac082e)).
|
||||
|
||||
ethers/v6.6.4 (2023-07-16 00:35)
|
||||
--------------------------------
|
||||
|
||||
- More robust support for Signatures with less standard parameter values ([#3835](https://github.com/ethers-io/ethers.js/issues/3835), [#4228](https://github.com/ethers-io/ethers.js/issues/4228); [a7e4048](https://github.com/ethers-io/ethers.js/commit/a7e4048fe3b75a743cec8c8ef2a5fad4bdc8b14c)).
|
||||
- Fixed CCIP-read in the EnsResolver ([#4221](https://github.com/ethers-io/ethers.js/issues/4221); [57f1e1c](https://github.com/ethers-io/ethers.js/commit/57f1e1c47148921148e35c10c83539531942923e)).
|
||||
- Skip checking confirmation count if confirms is 0 ([#4229](https://github.com/ethers-io/ethers.js/issues/4229), [#4242](https://github.com/ethers-io/ethers.js/issues/4242); [492919d](https://github.com/ethers-io/ethers.js/commit/492919d14f646c630f29e1596e5564df1e51f309)).
|
||||
- Fixed waiting for confirmations in deployment transactions ([#4212](https://github.com/ethers-io/ethers.js/issues/4212), [#4230](https://github.com/ethers-io/ethers.js/issues/4230); [43c253a](https://github.com/ethers-io/ethers.js/commit/43c253a402f52a08353c424f6c4e236836cfaf36)).
|
||||
|
||||
ethers/v6.6.3 (2023-07-11 20:55)
|
||||
--------------------------------
|
||||
|
||||
- Throw more desscriptive error for unconfigured ENS name contract targets ([#4213](https://github.com/ethers-io/ethers.js/issues/4213); [80f62ef](https://github.com/ethers-io/ethers.js/commit/80f62efc41c3a29e690af40a1976928b7f886a0e)).
|
||||
- Fixed contract once not running stop callback ([7d061b7](https://github.com/ethers-io/ethers.js/commit/7d061b786f72cbfc461bf80d139d10aeff533a6e)).
|
||||
|
||||
ethers/v6.6.2 (2023-06-27 23:30)
|
||||
--------------------------------
|
||||
|
||||
- Wider error detection for call exceptions on certain backends ([#4154](https://github.com/ethers-io/ethers.js/issues/4154), [#4155](https://github.com/ethers-io/ethers.js/issues/4155); [9197f9f](https://github.com/ethers-io/ethers.js/commit/9197f9f938b5f3b5f97c043f2dab06854656c932)).
|
||||
- Added wider error deetection for JSON-RPC unsupported operation ([#4162](https://github.com/ethers-io/ethers.js/issues/4162); [1dc8986](https://github.com/ethers-io/ethers.js/commit/1dc8986a33be9dce536b24189326cbfaabf1342e)).
|
||||
- Fixed formatUnits and parseUnits for values over 128 bits ([#4037](https://github.com/ethers-io/ethers.js/issues/4037), [#4133](https://github.com/ethers-io/ethers.js/issues/4133); [3d141b4](https://github.com/ethers-io/ethers.js/commit/3d141b44b528f52b3c9205125b64ce342f91643c)).
|
||||
|
||||
ethers/v6.6.1 (2023-06-23 00:35)
|
||||
--------------------------------
|
||||
|
||||
- Fixed CCIP read in contract calls ([#4043](https://github.com/ethers-io/ethers.js/issues/4043); [d51e3fb](https://github.com/ethers-io/ethers.js/commit/d51e3fbff43c31d88353ac71151626312d22c0b9), [857aa8c](https://github.com/ethers-io/ethers.js/commit/857aa8ccc30f25eda8e83dcac3e0ad2c1a5ce2b3)).
|
||||
|
||||
ethers/v6.6.0 (2023-06-13 21:42)
|
||||
--------------------------------
|
||||
|
||||
- Add exports for AbstractProviderOptions and for MulticoinProviderPlugin ([203a759](https://github.com/ethers-io/ethers.js/commit/203a759efc65bf6901d3e574a601525ea3936238)).
|
||||
- Add option to adjust perform cache timeout in AbstractProvider ([de0f518](https://github.com/ethers-io/ethers.js/commit/de0f5189f695c181a5fa09100af96a691a338e2b)).
|
||||
- Add full support for MultiCoin plugins and automatic detection for EVM-compatible coin types ([#3888](https://github.com/ethers-io/ethers.js/issues/3888), [#4081](https://github.com/ethers-io/ethers.js/issues/4081); [84375be](https://github.com/ethers-io/ethers.js/commit/84375be92d32a2939cf4a2f713e4c554b5b54a32)).
|
||||
- Allow Interface instances where InterfaceAbi are allowed ([#4142](https://github.com/ethers-io/ethers.js/issues/4142); [2318005](https://github.com/ethers-io/ethers.js/commit/2318005dfd996c8a7c51603d0264ceabe9bb6141)).
|
||||
- Allow Numeric type for decimals in FixedNumber ([#4141](https://github.com/ethers-io/ethers.js/issues/4141); [9055ef6](https://github.com/ethers-io/ethers.js/commit/9055ef6c69291f1a44ea23a2e7b5aaf3140a5577)).
|
||||
|
||||
ethers/v6.5.1 (2023-06-07 20:19)
|
||||
--------------------------------
|
||||
|
||||
- Fix lost promise fulfillment when a batch has an error response ([#4126](https://github.com/ethers-io/ethers.js/issues/4126); [8dd21f0](https://github.com/ethers-io/ethers.js/commit/8dd21f03334ffd3cdb7ac532376d51fd4130c7ab)).
|
||||
|
||||
ethers/v6.5.0 (2023-06-06 22:41)
|
||||
--------------------------------
|
||||
|
||||
- Fix CJS browser bundling ([#4033](https://github.com/ethers-io/ethers.js/issues/4033); [38ee319](https://github.com/ethers-io/ethers.js/commit/38ee3195b0192d8180899fd61308e03fa3a0eb32)).
|
||||
- Fixed type guard for non-Typed instances ([#4087](https://github.com/ethers-io/ethers.js/issues/4087); [20c3d1b](https://github.com/ethers-io/ethers.js/commit/20c3d1b109743e33ab60a75d69bf7ede73b15ce2)).
|
||||
- Add confirmations to TransactionResponse ([#4094](https://github.com/ethers-io/ethers.js/issues/4094); [bb8685b](https://github.com/ethers-io/ethers.js/commit/bb8685b112ce1c689c740d4dbcb358c16fb9b22d)).
|
||||
- Fix stray promises when a node returns invalid results ([#4118](https://github.com/ethers-io/ethers.js/issues/4118); [3c1bad2](https://github.com/ethers-io/ethers.js/commit/3c1bad2fb7ad4a6ff90ff11f3e382fd18e41c800)).
|
||||
- Added support to detect and stop providers spinning on intitial network detection ([#4015](https://github.com/ethers-io/ethers.js/issues/4015); [f37a52d](https://github.com/ethers-io/ethers.js/commit/f37a52da28ac130b7f4de52901618320994ea87a)).
|
||||
|
||||
ethers/v6.4.2 (2023-06-05 22:41)
|
||||
--------------------------------
|
||||
|
||||
- Bump ens-normalize version ([#4071](https://github.com/ethers-io/ethers.js/issues/4071), [#4077](https://github.com/ethers-io/ethers.js/issues/4077), [#4080](https://github.com/ethers-io/ethers.js/issues/4080), [#4102](https://github.com/ethers-io/ethers.js/issues/4102); [c135784](https://github.com/ethers-io/ethers.js/commit/c1357847dcdec93d72f28d890f9271d0289ccefd)).
|
||||
- Fix for networks with polling with non-consistent block and filter events ([#4119](https://github.com/ethers-io/ethers.js/issues/4119); [9b0e992](https://github.com/ethers-io/ethers.js/commit/9b0e9920c09577296ec0e2abb3acc3f3299d96c7)).
|
||||
|
||||
ethers/v6.4.1 (2023-06-01 17:52)
|
||||
--------------------------------
|
||||
|
||||
- Fixed AbstractProvider lookupAddress bug ([#4086](https://github.com/ethers-io/ethers.js/issues/4086); [15ed2f5](https://github.com/ethers-io/ethers.js/commit/15ed2f5b32084527961332481c9442a313036a01)).
|
||||
- Fix FixedNumber comparison bug ([#4112](https://github.com/ethers-io/ethers.js/issues/4112); [d8e9586](https://github.com/ethers-io/ethers.js/commit/d8e9586044e888e424b5ead0f6e01f88140dba8a)).
|
||||
|
||||
ethers/v6.4.0 (2023-05-18 17:28)
|
||||
--------------------------------
|
||||
|
||||
- Coerce value into BigInt when checking for value ([83d7f43](https://github.com/ethers-io/ethers.js/commit/83d7f43b9ca4b9868a3952510e56b41ea8610baa)).
|
||||
- Better errors when junk passed as Contract target ([#3947](https://github.com/ethers-io/ethers.js/issues/3947), [#4053](https://github.com/ethers-io/ethers.js/issues/4053); [219b16d](https://github.com/ethers-io/ethers.js/commit/219b16dc284b0c6a532c8c49e824d8234f94222b)).
|
||||
- More robust message checking in socket providers ([#4051](https://github.com/ethers-io/ethers.js/issues/4051); [f58990b](https://github.com/ethers-io/ethers.js/commit/f58990b80cfd83579014339315e58663c0aa6ae3)).
|
||||
- More robust defaultProvider start-up when a backend fails on bootstrap ([#3979](https://github.com/ethers-io/ethers.js/issues/3979); [984f6fa](https://github.com/ethers-io/ethers.js/commit/984f6fa155fca08ebec2353c75ee0a0b974e8568)).
|
||||
|
||||
7
FUNDING.json
Normal file
7
FUNDING.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"drips": {
|
||||
"ethereum": {
|
||||
"ownedBy": "0x89EdE5cBE53473A64d6C8DF14176a0d658dAAeDC"
|
||||
}
|
||||
}
|
||||
}
|
||||
23
README.md
23
README.md
@@ -21,27 +21,33 @@ in [TypeScript](https://www.typescriptlang.org).
|
||||
- Meta-classes create JavaScript objects from any contract ABI, including **ABIv2** and **Human-Readable ABI**
|
||||
- Connect to Ethereum nodes over [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC), [INFURA](https://infura.io), [Etherscan](https://etherscan.io), [Alchemy](https://alchemyapi.io), [Ankr](https://ankr.com) or [MetaMask](https://metamask.io)
|
||||
- **ENS names** are first-class citizens; they can be used anywhere an Ethereum addresses can be used
|
||||
- **Tiny** (~120kb compressed; 400kb uncompressed)
|
||||
- **Small** (~144kb compressed; 460kb uncompressed)
|
||||
- **Tree-shaking** focused; include only what you need during bundling
|
||||
- **Complete** functionality for all your Ethereum desires
|
||||
- Extensive [documentation](https://docs.ethers.org/v6/)
|
||||
- Large collection of **test cases** which are maintained and added to
|
||||
- Fully written in **TypeScript**, with strict types for security
|
||||
- Fully written in **TypeScript**, with strict types for security and safety
|
||||
- **MIT License** (including ALL dependencies); completely open source to do with as you please
|
||||
|
||||
|
||||
Keep Updated
|
||||
------------
|
||||
|
||||
For the latest news and advisories, please follow the
|
||||
[@ethersproject](https://twitter.com/ethersproject) on Twitter (low-traffic,
|
||||
non-marketing, important information only) as well as watch this GitHub project.
|
||||
For advisories and important notices, follow [@ethersproject](https://twitter.com/ethersproject)
|
||||
on Twitter (low-traffic, non-marketing, important information only) as well as watch this GitHub project.
|
||||
|
||||
For more general news, discussions, and feedback, follow or DM me,
|
||||
[@ricmoo](https://twitter.com/ricmoo) on Twitter or on the
|
||||
[Ethers Discord](https://discord.gg/qYtSscGYYc).
|
||||
|
||||
|
||||
For the latest changes, see the
|
||||
[CHANGELOG](https://github.com/ethers-io/ethers.js/blob/main/CHANGELOG.md).
|
||||
|
||||
|
||||
**Summaries**
|
||||
|
||||
- [August 2023](https://blog.ricmoo.com/highlights-ethers-js-august-2023-fb68354c576c)
|
||||
- [September 2022](https://blog.ricmoo.com/highlights-ethers-js-september-2022-d7bda0fc37ed)
|
||||
- [June 2022](https://blog.ricmoo.com/highlights-ethers-js-june-2022-f5328932e35d)
|
||||
- [March 2022](https://blog.ricmoo.com/highlights-ethers-js-march-2022-f511fe1e88a1)
|
||||
@@ -111,7 +117,6 @@ A special thanks to these services for providing community resources:
|
||||
- [Etherscan](https://etherscan.io/)
|
||||
- [INFURA](https://infura.io/)
|
||||
- [Alchemy](https://dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d)
|
||||
- [Pocket](https://pokt.network/pocket-gateway-ethereum-mainnet/)
|
||||
|
||||
|
||||
Extension Packages
|
||||
@@ -121,7 +126,11 @@ The `ethers` package only includes the most common and most core
|
||||
functionality to interact with Ethereum. There are many other
|
||||
packages designed to further enhance the functionality and experience.
|
||||
|
||||
- Hardware Wallets (@TODO)
|
||||
- [MulticallProvider](https://github.com/ethers-io/ext-provider-multicall) - A Provider which bundles multiple call requests into a single `call` to reduce latency and backend request capacity
|
||||
- [MulticoinPlugin](https://github.com/ethers-io/ext-provider-plugin-multicoin) - A Provider plugin to expand the support of ENS coin types
|
||||
- [GanaceProvider](https://github.com/ethers-io/ext-provider-ganache) - A Provider for in-memory node instances, for fast debugging, testing and simulating blockchain operations
|
||||
- [Optimism Utilities](https://github.com/ethers-io/ext-utils-optimism) - A collection of Optimism utilities
|
||||
- [LedgerSigner](https://github.com/ethers-io/ext-signer-ledger) - A Signer to interact directly with Ledger Hardware Wallets
|
||||
|
||||
|
||||
License
|
||||
|
||||
7008
dist/ethers.js
vendored
7008
dist/ethers.js
vendored
File diff suppressed because one or more lines are too long
2
dist/ethers.js.map
vendored
2
dist/ethers.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethers.min.js
vendored
2
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
7013
dist/ethers.umd.js
vendored
7013
dist/ethers.umd.js
vendored
File diff suppressed because one or more lines are too long
2
dist/ethers.umd.js.map
vendored
2
dist/ethers.umd.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethers.umd.min.js
vendored
2
dist/ethers.umd.min.js
vendored
File diff suppressed because one or more lines are too long
204
dist/wordlists-extra.js
vendored
204
dist/wordlists-extra.js
vendored
@@ -2,21 +2,11 @@ function number(n) {
|
||||
if (!Number.isSafeInteger(n) || n < 0)
|
||||
throw new Error(`Wrong positive integer: ${n}`);
|
||||
}
|
||||
function bool(b) {
|
||||
if (typeof b !== 'boolean')
|
||||
throw new Error(`Expected boolean, not ${b}`);
|
||||
}
|
||||
function bytes(b, ...lengths) {
|
||||
if (!(b instanceof Uint8Array))
|
||||
throw new TypeError('Expected Uint8Array');
|
||||
throw new Error('Expected Uint8Array');
|
||||
if (lengths.length > 0 && !lengths.includes(b.length))
|
||||
throw new TypeError(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
||||
}
|
||||
function hash(hash) {
|
||||
if (typeof hash !== 'function' || typeof hash.create !== 'function')
|
||||
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
||||
number(hash.outputLen);
|
||||
number(hash.blockLen);
|
||||
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
||||
}
|
||||
function exists(instance, checkFinished = true) {
|
||||
if (instance.destroyed)
|
||||
@@ -31,36 +21,39 @@ function output(out, instance) {
|
||||
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
||||
}
|
||||
}
|
||||
const assert$1 = {
|
||||
number,
|
||||
bool,
|
||||
bytes,
|
||||
hash,
|
||||
exists,
|
||||
output,
|
||||
};
|
||||
|
||||
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
// The import here is via the package name. This is to ensure
|
||||
// that exports mapping/resolution does fall into place.
|
||||
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
||||
// node.js versions earlier than v19 don't declare it in global scope.
|
||||
// For node.js, package.json#exports field mapping rewrites import
|
||||
// from `crypto` to `cryptoNode`, which imports native module.
|
||||
// Makes the utils un-importable in browsers without a bundler.
|
||||
// Once node.js 18 is deprecated, we can just drop the import.
|
||||
const u8a = (a) => a instanceof Uint8Array;
|
||||
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'));
|
||||
/**
|
||||
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
|
||||
*/
|
||||
function utf8ToBytes(str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
|
||||
}
|
||||
return new TextEncoder().encode(str);
|
||||
if (typeof str !== 'string')
|
||||
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
||||
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
||||
}
|
||||
/**
|
||||
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
||||
* Warning: when Uint8Array is passed, it would NOT get copied.
|
||||
* Keep in mind for future mutable operations.
|
||||
*/
|
||||
function toBytes(data) {
|
||||
if (typeof data === 'string')
|
||||
data = utf8ToBytes(data);
|
||||
if (!(data instanceof Uint8Array))
|
||||
throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
|
||||
if (!u8a(data))
|
||||
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
||||
return data;
|
||||
}
|
||||
// For runtime check if class implements interface
|
||||
@@ -70,25 +63,17 @@ class Hash {
|
||||
return this._cloneInto();
|
||||
}
|
||||
}
|
||||
function wrapConstructor(hashConstructor) {
|
||||
const hashC = (message) => hashConstructor().update(toBytes(message)).digest();
|
||||
const tmp = hashConstructor();
|
||||
function wrapConstructor(hashCons) {
|
||||
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
||||
const tmp = hashCons();
|
||||
hashC.outputLen = tmp.outputLen;
|
||||
hashC.blockLen = tmp.blockLen;
|
||||
hashC.create = () => hashConstructor();
|
||||
return hashC;
|
||||
}
|
||||
function wrapConstructorWithOpts(hashCons) {
|
||||
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
||||
const tmp = hashCons({});
|
||||
hashC.outputLen = tmp.outputLen;
|
||||
hashC.blockLen = tmp.blockLen;
|
||||
hashC.create = (opts) => hashCons(opts);
|
||||
hashC.create = () => hashCons();
|
||||
return hashC;
|
||||
}
|
||||
|
||||
const U32_MASK64 = BigInt(2 ** 32 - 1);
|
||||
const _32n = BigInt(32);
|
||||
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
||||
const _32n = /* @__PURE__ */ BigInt(32);
|
||||
// We are not using BigUint64Array, because they are extremely slow as per 2022
|
||||
function fromBig(n, le = false) {
|
||||
if (le)
|
||||
@@ -104,54 +89,18 @@ function split(lst, le = false) {
|
||||
}
|
||||
return [Ah, Al];
|
||||
}
|
||||
const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
|
||||
// for Shift in [0, 32)
|
||||
const shrSH = (h, l, s) => h >>> s;
|
||||
const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
||||
// Right rotate for Shift in [1, 32)
|
||||
const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
|
||||
const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
|
||||
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
|
||||
const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
|
||||
const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
|
||||
// Right rotate for shift===32 (just swaps l&h)
|
||||
const rotr32H = (h, l) => l;
|
||||
const rotr32L = (h, l) => h;
|
||||
// Left rotate for Shift in [1, 32)
|
||||
const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
|
||||
const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
|
||||
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
|
||||
const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
|
||||
const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
|
||||
// JS uses 32-bit signed integers for bitwise operations which means we cannot
|
||||
// simple take carry out of low bit sum by shift, we need to use division.
|
||||
// Removing "export" has 5% perf penalty -_-
|
||||
function add(Ah, Al, Bh, Bl) {
|
||||
const l = (Al >>> 0) + (Bl >>> 0);
|
||||
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
|
||||
}
|
||||
// Addition with more than 2 elements
|
||||
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
||||
const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
|
||||
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
||||
const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
|
||||
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
||||
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
|
||||
// prettier-ignore
|
||||
const u64 = {
|
||||
fromBig, split, toBig,
|
||||
shrSH, shrSL,
|
||||
rotrSH, rotrSL, rotrBH, rotrBL,
|
||||
rotr32H, rotr32L,
|
||||
rotlSH, rotlSL, rotlBH, rotlBL,
|
||||
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
||||
};
|
||||
|
||||
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
|
||||
/**
|
||||
* The current version of Ethers.
|
||||
*/
|
||||
const version = "6.4.0";
|
||||
const version = "6.9.2";
|
||||
|
||||
/**
|
||||
* Property helper functions.
|
||||
@@ -196,7 +145,11 @@ function defineProperties(target, values, types) {
|
||||
}
|
||||
|
||||
/**
|
||||
* About Errors.
|
||||
* All errors in ethers include properties to ensure they are both
|
||||
* human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``).
|
||||
*
|
||||
* The [[isError]] function can be used to check the error ``code`` and
|
||||
* provide a type guard for the properties present on that error interface.
|
||||
*
|
||||
* @_section: api/utils/errors:Errors [about-errors]
|
||||
*/
|
||||
@@ -239,15 +192,16 @@ function stringify(value) {
|
||||
}
|
||||
/**
|
||||
* Returns a new Error configured to the format ethers emits errors, with
|
||||
* the %%message%%, [[api:ErrorCode]] %%code%% and additioanl properties
|
||||
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
|
||||
* for the corresponding EthersError.
|
||||
*
|
||||
* Each error in ethers includes the version of ethers, a
|
||||
* machine-readable [[ErrorCode]], and depneding on %%code%%, additional
|
||||
* required properties. The error message will also include the %%meeage%%,
|
||||
* ethers version, %%code%% and all aditional properties, serialized.
|
||||
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
|
||||
* required properties. The error message will also include the %%message%%,
|
||||
* ethers version, %%code%% and all additional properties, serialized.
|
||||
*/
|
||||
function makeError(message, code, info) {
|
||||
let shortMessage = message;
|
||||
{
|
||||
const details = [];
|
||||
if (info) {
|
||||
@@ -255,6 +209,9 @@ function makeError(message, code, info) {
|
||||
throw new Error(`value will overwrite populated values: ${stringify(info)}`);
|
||||
}
|
||||
for (const key in info) {
|
||||
if (key === "shortMessage") {
|
||||
continue;
|
||||
}
|
||||
const value = (info[key]);
|
||||
// try {
|
||||
details.push(key + "=" + stringify(value));
|
||||
@@ -286,6 +243,9 @@ function makeError(message, code, info) {
|
||||
if (info) {
|
||||
Object.assign(error, info);
|
||||
}
|
||||
if (error.shortMessage == null) {
|
||||
defineProperties(error, { shortMessage });
|
||||
}
|
||||
return error;
|
||||
}
|
||||
/**
|
||||
@@ -597,14 +557,16 @@ function toUtf8String(bytes, onError) {
|
||||
return _toUtf8String(getUtf8CodePoints(bytes, onError));
|
||||
}
|
||||
|
||||
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
|
||||
// It's called a sponge function.
|
||||
// Various per round constants calculations
|
||||
const [SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []];
|
||||
const _0n = BigInt(0);
|
||||
const _1n = BigInt(1);
|
||||
const _2n = BigInt(2);
|
||||
const _7n = BigInt(7);
|
||||
const _256n = BigInt(256);
|
||||
const _0x71n = BigInt(0x71);
|
||||
const _0n = /* @__PURE__ */ BigInt(0);
|
||||
const _1n = /* @__PURE__ */ BigInt(1);
|
||||
const _2n = /* @__PURE__ */ BigInt(2);
|
||||
const _7n = /* @__PURE__ */ BigInt(7);
|
||||
const _256n = /* @__PURE__ */ BigInt(256);
|
||||
const _0x71n = /* @__PURE__ */ BigInt(0x71);
|
||||
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
||||
// Pi
|
||||
[x, y] = [y, (2 * x + 3 * y) % 5];
|
||||
@@ -616,14 +578,14 @@ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
||||
for (let j = 0; j < 7; j++) {
|
||||
R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
|
||||
if (R & _2n)
|
||||
t ^= _1n << ((_1n << BigInt(j)) - _1n);
|
||||
t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
|
||||
}
|
||||
_SHA3_IOTA.push(t);
|
||||
}
|
||||
const [SHA3_IOTA_H, SHA3_IOTA_L] = u64.split(_SHA3_IOTA, true);
|
||||
const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);
|
||||
// Left rotation (without 0, 32, 64)
|
||||
const rotlH = (h, l, s) => s > 32 ? u64.rotlBH(h, l, s) : u64.rotlSH(h, l, s);
|
||||
const rotlL = (h, l, s) => s > 32 ? u64.rotlBL(h, l, s) : u64.rotlSL(h, l, s);
|
||||
const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
|
||||
const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
|
||||
// Same as keccakf1600, but allows to skip some rounds
|
||||
function keccakP(s, rounds = 24) {
|
||||
const B = new Uint32Array(5 * 2);
|
||||
@@ -684,7 +646,7 @@ class Keccak extends Hash {
|
||||
this.finished = false;
|
||||
this.destroyed = false;
|
||||
// Can be passed from user as dkLen
|
||||
assert$1.number(outputLen);
|
||||
number(outputLen);
|
||||
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
||||
if (0 >= this.blockLen || this.blockLen >= 200)
|
||||
throw new Error('Sha3 supports only keccak-f1600 function');
|
||||
@@ -697,7 +659,7 @@ class Keccak extends Hash {
|
||||
this.pos = 0;
|
||||
}
|
||||
update(data) {
|
||||
assert$1.exists(this);
|
||||
exists(this);
|
||||
const { blockLen, state } = this;
|
||||
data = toBytes(data);
|
||||
const len = data.length;
|
||||
@@ -723,8 +685,8 @@ class Keccak extends Hash {
|
||||
this.keccak();
|
||||
}
|
||||
writeInto(out) {
|
||||
assert$1.exists(this, false);
|
||||
assert$1.bytes(out);
|
||||
exists(this, false);
|
||||
bytes(out);
|
||||
this.finish();
|
||||
const bufferOut = this.state;
|
||||
const { blockLen } = this;
|
||||
@@ -745,11 +707,11 @@ class Keccak extends Hash {
|
||||
return this.writeInto(out);
|
||||
}
|
||||
xof(bytes) {
|
||||
assert$1.number(bytes);
|
||||
number(bytes);
|
||||
return this.xofInto(new Uint8Array(bytes));
|
||||
}
|
||||
digestInto(out) {
|
||||
assert$1.output(out, this);
|
||||
output(out, this);
|
||||
if (this.finished)
|
||||
throw new Error('digest() was already called');
|
||||
this.writeInto(out);
|
||||
@@ -780,25 +742,11 @@ class Keccak extends Hash {
|
||||
}
|
||||
}
|
||||
const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));
|
||||
gen(0x06, 144, 224 / 8);
|
||||
/**
|
||||
* SHA3-256 hash function
|
||||
* @param message - that would be hashed
|
||||
*/
|
||||
gen(0x06, 136, 256 / 8);
|
||||
gen(0x06, 104, 384 / 8);
|
||||
gen(0x06, 72, 512 / 8);
|
||||
gen(0x01, 144, 224 / 8);
|
||||
/**
|
||||
* keccak-256 hash function. Different from SHA3-256.
|
||||
* @param message - that would be hashed
|
||||
*/
|
||||
const keccak_256 = gen(0x01, 136, 256 / 8);
|
||||
gen(0x01, 104, 384 / 8);
|
||||
gen(0x01, 72, 512 / 8);
|
||||
const genShake = (suffix, blockLen, outputLen) => wrapConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
||||
genShake(0x1f, 168, 128 / 8);
|
||||
genShake(0x1f, 136, 256 / 8);
|
||||
const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
|
||||
|
||||
/**
|
||||
* Cryptographic hashing functions
|
||||
@@ -968,7 +916,7 @@ class Wordlist {
|
||||
* based on ASCII-7 small.
|
||||
*
|
||||
* If necessary, there are tools within the ``generation/`` folder
|
||||
* to create these necessary data.
|
||||
* to create the necessary data.
|
||||
*/
|
||||
class WordlistOwl extends Wordlist {
|
||||
#data;
|
||||
@@ -983,7 +931,13 @@ class WordlistOwl extends Wordlist {
|
||||
this.#checksum = checksum;
|
||||
this.#words = null;
|
||||
}
|
||||
/**
|
||||
* The OWL-encoded data.
|
||||
*/
|
||||
get _data() { return this.#data; }
|
||||
/**
|
||||
* Decode all the words for the wordlist.
|
||||
*/
|
||||
_decodeWords() {
|
||||
return decodeOwl(this.#data);
|
||||
}
|
||||
@@ -1109,15 +1063,25 @@ function decodeOwlA(data, accents) {
|
||||
* based on latin-1 small.
|
||||
*
|
||||
* If necessary, there are tools within the ``generation/`` folder
|
||||
* to create these necessary data.
|
||||
* to create the necessary data.
|
||||
*/
|
||||
class WordlistOwlA extends WordlistOwl {
|
||||
#accent;
|
||||
/**
|
||||
* Creates a new Wordlist for %%locale%% using the OWLA %%data%%
|
||||
* and %%accent%% data and validated against the %%checksum%%.
|
||||
*/
|
||||
constructor(locale, data, accent, checksum) {
|
||||
super(locale, data, checksum);
|
||||
this.#accent = accent;
|
||||
}
|
||||
/**
|
||||
* The OWLA-encoded accent data.
|
||||
*/
|
||||
get _accent() { return this.#accent; }
|
||||
/**
|
||||
* Decode all the words for the wordlist.
|
||||
*/
|
||||
_decodeWords() {
|
||||
return decodeOwlA(this._data, this._accent);
|
||||
}
|
||||
|
||||
2
dist/wordlists-extra.js.map
vendored
2
dist/wordlists-extra.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/wordlists-extra.min.js
vendored
2
dist/wordlists-extra.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,26 +1,97 @@
|
||||
_section: ABI
|
||||
_section: Application Binary Interfaces @<docs-abi>
|
||||
|
||||
Explain about ABI here, what it does and does not do
|
||||
When interacting with any application, whether it is on Ethereum,
|
||||
over the internet or within a compiled application on a computer
|
||||
all information is stored and sent as binary data which is just a
|
||||
sequence of bytes.
|
||||
|
||||
- encodes arbitrary (but defined) data structures to raw bytes
|
||||
So every application must agree on how to encode and decode their
|
||||
information as a sequence of bytes.
|
||||
|
||||
_subsection: Call
|
||||
An **Application Binary Interface** (ABI) provides a way to describe
|
||||
the encoding and decoding process, in a generic way so that a variety
|
||||
of types and structures of types can be defined.
|
||||
|
||||
About encoding
|
||||
For example, a string is often encoded as a UTF-8 sequence of bytes,
|
||||
which uses specific bits within sub-sequences to indicate emoji and
|
||||
other special characters. Every implementation of UTF-8 must understand
|
||||
and operate under the same rules so that strings work universally. In
|
||||
this way, UTF-8 standard is itself an ABI.
|
||||
|
||||
_heading: selector or signature hash (sighash)
|
||||
When interacting with Ethereum, a contract received a sequence of bytes
|
||||
as input (provided by sending a transaction or through a call) and
|
||||
returns a result as a sequence of bytes. So, each Contract has its own
|
||||
ABI that helps specify how to encode the input and how to decode the output.
|
||||
|
||||
_heading: Results
|
||||
It is up to the contract developer to make this ABI available. Many
|
||||
Contracts implement a standard (such as ERC-20), in which case the
|
||||
ABI for that standard can be used. Many developers choose to verify their
|
||||
source code on Etherscan, in which case Etherscan computes the ABI and
|
||||
provides it through their website (which can be fetched using the ``getContract``
|
||||
method). Otherwise, beyond reverse engineering the Contract there is
|
||||
not a meaningful way to extract the contract ABI.
|
||||
|
||||
_subsection: Events
|
||||
_subsection: Call Data Representation
|
||||
|
||||
When calling a Contract on Ethereum, the input data must be encoded
|
||||
according to the ABI.
|
||||
|
||||
The first 4 bytes of the data are the **method selector**, which is
|
||||
the keccak256 hash of the normalized method signature.
|
||||
|
||||
Then the method parameters are encoded and concatenated to the selector.
|
||||
|
||||
All encoded data is made up of components padded to 32 bytes, so the length
|
||||
of input data will always be congruent to ``4 mod 32``.
|
||||
|
||||
The result of a successful call will be encoded values, whose components
|
||||
are padded to 32 bytes each as well, so the length of a result will always
|
||||
be congruent to ``0 mod 32``, on success.
|
||||
|
||||
The result of a reverted call will contain the **error selector** as the
|
||||
first 4 bytes, which is the keccak256 of the normalized error signature,
|
||||
followed by the encoded values, whose components are padded to 32 bytes
|
||||
each, so the length of a revert will be congruent to ``4 mod 32``.
|
||||
|
||||
The one exception to all this is that ``revert(false)`` will return a
|
||||
result or ``0x``.
|
||||
|
||||
|
||||
_subsection: Event Data Representation
|
||||
|
||||
When an Event is emitted from a contract, there are two places data is
|
||||
logged in a Log: the **topics** and the **data**.
|
||||
|
||||
An additonal fee is paid for each **topic**, but this affords a topic
|
||||
to be indexed in a bloom filter within the block, which allows efficient
|
||||
filtering.
|
||||
|
||||
The **topic hash** is always the first topic in a Log, which is the
|
||||
keccak256 of the normalized event signature. This allows a specific
|
||||
event to be efficiently filtered, finding the matching events in a block.
|
||||
|
||||
Each additional **indexed** parameter (i.e. parameters marked with
|
||||
``indexed`` in the signautre) are placed in the topics as well, but may be
|
||||
filtered to find matching values.
|
||||
|
||||
All non-indexed parameters are encoded and placed in the **data**. This
|
||||
is cheaper and more compact, but does not allow filtering on these values.
|
||||
|
||||
For example, the event ``Transfer(address indexed from, address indexed to, uint value)``
|
||||
would require 3 topics, which are the topic hash, the ``from`` address
|
||||
and the ``to`` address and the data would contain 32 bytes, which is
|
||||
the padded big-endian representation of ``value``. This allows for
|
||||
efficient filtering by the event (i.e. ``Transfer``) as well as the ``from``
|
||||
address and ``to`` address.
|
||||
|
||||
|
||||
_subsection: Deployment
|
||||
|
||||
About initcode
|
||||
When deploying a transaction, the data provided is treated as **initcode**,
|
||||
which executes the data as normal EVM bytecode, which returns a sequence
|
||||
of bytes, but instead of that sequence of bytes being treated as data that
|
||||
result is instead the bytecode to install as the bytecode of the contract.
|
||||
|
||||
Another paragraph [[link-bip-39]].
|
||||
|
||||
_heading: Foo?
|
||||
|
||||
Bar?
|
||||
The bytecode produced by Solidity is designed to have all constructor
|
||||
parameters encoded normally and concatenated to the bytecode and provided
|
||||
as the ``data`` to a transaction with no ``to`` address.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
_section: Ethereum Basics @priority<99>
|
||||
_section: Ethereum Basics @<docs-basics> @priority<99>
|
||||
|
||||
Prelude here...
|
||||
This section aims to cover some of the basics for those interested
|
||||
in a deeper understanding of the inner-workings of Ethereum.
|
||||
|
||||
_subsection: About stuff?
|
||||
_subsection: Topics
|
||||
|
||||
Some info
|
||||
- [Application Binary Interface](docs-abi)
|
||||
|
||||
@@ -65,7 +65,7 @@ _code: Building with the v2 Flatworm @lang<shell>
|
||||
/home/ricmoo/flatworm> npm install
|
||||
|
||||
# Ready to build the docs; output to a folder ./output/
|
||||
/home/ricmoo/flatworm> node lib/test-api-index PATH_TO_WRM_ROOT
|
||||
/home/ricmoo/flatworm> node lib/cli-test PATH_TO_WRM_ROOT
|
||||
|
||||
Eventually the code for the v2 branch will be cleaned up, and it
|
||||
will be much easier to include as a ``devDependency`` for Ethers.
|
||||
|
||||
66
docs.wrm/cookbook/ens.wrm
Normal file
66
docs.wrm/cookbook/ens.wrm
Normal file
@@ -0,0 +1,66 @@
|
||||
_section: Cookbook: ENS Recipes @<cookbook-ens>
|
||||
|
||||
Here is a collection of short, but useful examples of working with
|
||||
ENS entries.
|
||||
|
||||
|
||||
_subsection: Get all Text records @<cookbook-ens-allText>
|
||||
|
||||
Here is a short recipe to get all the text records set for an ENS
|
||||
name.
|
||||
|
||||
It first queries all ``TextChanged`` events on the resovler, and
|
||||
uses a MulticallProvider to batch all the ``eth_call`` queries
|
||||
for each key into a single ``eth_call``. As such, you will need
|
||||
to install:
|
||||
|
||||
``/home/ricmoo> npm install @ethers-ext/provider-multicall``
|
||||
|
||||
|
||||
_code: Fetching all ENS text records. @lang<script>
|
||||
|
||||
import { ethers } from "ethers";
|
||||
import { MulticallProvider } from "@ethers-ext/provider-multicall";
|
||||
|
||||
async function getTextRecords(_provider, name) {
|
||||
// Prepare a multicall-based provider to batch all the call operations
|
||||
const provider = new MulticallProvider(_provider);
|
||||
|
||||
// Get the resolver for the given name
|
||||
const resolver = await provider.getResolver(name);
|
||||
|
||||
// A contract instance; used filter and parse logs
|
||||
const contract = new ethers.Contract(resolver.address, [
|
||||
"event TextChanged(bytes32 indexed node, string indexed _key, string key)"
|
||||
], provider);
|
||||
|
||||
// A filter for the given name
|
||||
const filter = contract.filters.TextChanged(ethers.namehash(name));
|
||||
|
||||
// Get the matching logs
|
||||
const logs = await contract.queryFilter(filter);
|
||||
|
||||
// Filter the *unique* keys
|
||||
const keys = [ ...(new Set(logs.map((log) => log.args.key))) ];
|
||||
|
||||
// Get the values for the keys; failures are discarded
|
||||
const values = await Promise.all(keys.map((key) => {
|
||||
try {
|
||||
return resolver.getText(key);
|
||||
} catch (error) { }
|
||||
return null;
|
||||
}));
|
||||
|
||||
// Return a Map of the key/value pairs
|
||||
return keys.reduce((accum, key, index) => {
|
||||
const value = values[index];
|
||||
if (value != null) { accum.set(key, value); }
|
||||
return accum;
|
||||
}, new Map());
|
||||
}
|
||||
|
||||
// Example usage
|
||||
(async function() {
|
||||
const provider = new ethers.InfuraProvider();
|
||||
console.log(await getTextRecords(provider, "ricmoo.eth"));
|
||||
})();
|
||||
7
docs.wrm/cookbook/index.wrm
Normal file
7
docs.wrm/cookbook/index.wrm
Normal file
@@ -0,0 +1,7 @@
|
||||
_section: Cookbook @<cookbook>
|
||||
|
||||
A growing collection of code snippets for common problems and use cases
|
||||
when developing dapps and other blockchain tools.
|
||||
|
||||
- [Signing Messages and Data](cookbook-signing)
|
||||
- [React Native Performance](cookbook-react-native)
|
||||
36
docs.wrm/cookbook/react-native.wrm
Normal file
36
docs.wrm/cookbook/react-native.wrm
Normal file
@@ -0,0 +1,36 @@
|
||||
_section: React Native @<cookbook-react-native>
|
||||
|
||||
When using React Native, many of the built-in cryptographic primitives
|
||||
can be replaced by native, substantially faster implementations.
|
||||
|
||||
This should be available in its own package in the future, but for now
|
||||
this is highly recommended, and requires installing the
|
||||
[[link-npm-react-native-quick-crypto]] package.
|
||||
|
||||
|
||||
_code:
|
||||
|
||||
import { ethers } from "ethers";
|
||||
|
||||
import crypto from "react-native-quick-crypto";
|
||||
|
||||
ethers.randomBytes.register((length) => {
|
||||
return new Uint8Array(crypto.randomBytes(length));
|
||||
});
|
||||
|
||||
ethers.computeHmac.register((algo, key, data) => {
|
||||
return crypto.createHmac(algo, key).update(data).digest();
|
||||
});
|
||||
|
||||
ethers.pbkdf2.register((passwd, salt, iter, keylen, algo) => {
|
||||
return crypto.pbkdf2Sync(passwd, salt, iter, keylen, algo);
|
||||
});
|
||||
|
||||
ethers.sha256.register((data) => {
|
||||
return crypto.createHash('sha256').update(data).digest();
|
||||
});
|
||||
|
||||
ethers.sha512.register((data) => {
|
||||
return crypto.createHash('sha512').update(data).digest();
|
||||
});
|
||||
|
||||
273
docs.wrm/cookbook/signing.wrm
Normal file
273
docs.wrm/cookbook/signing.wrm
Normal file
@@ -0,0 +1,273 @@
|
||||
_section: Signing @<cookbook-signing>
|
||||
|
||||
Signing content and providing the content and signature to a
|
||||
Contract allows on-chain validation that a signer has access
|
||||
to the private key of a specific address.
|
||||
|
||||
The ecrecover algorithm allows the public key to be determined
|
||||
given some message digest and the signature generated by the
|
||||
private key for that digest. From the public key, the address
|
||||
can then be computed.
|
||||
|
||||
How a digest is derived depends on the type of data being
|
||||
signed and a variety of encoding formats are employed. Each
|
||||
format is designed to ensure that they do not collide, so for
|
||||
example, a user **cannot** be tricked into signing a message
|
||||
which is actually a valid transaction.
|
||||
|
||||
For this reason, most APIs in Ethereum do not permit signing a
|
||||
raw digest, and instead require a separate API for each format
|
||||
type and require the related data be specified, protecting the
|
||||
user from accidentally authorizing an action they didn't intend.
|
||||
|
||||
_subsection: Messages @<cookbook-signing-messages>
|
||||
|
||||
A signed message can be any data, but it is generally recommended
|
||||
to use human-readable text, as this is easier for a user to
|
||||
verify visually.
|
||||
|
||||
This technique could be used, for example, to sign into a service
|
||||
by using the text ``"I am signing into ethers.org on 2023-06-04 12:57pm"``.
|
||||
The user can then see the message in MetaMask or on a Ledger
|
||||
Hardware Wallet and accept that they wish to sign the message which
|
||||
the site can then authenticate them with. By providing a timestamp
|
||||
the site can ensure that an older signed message cannot be used again
|
||||
in the future.
|
||||
|
||||
The format that is signed uses [[link-eip-191]] with the
|
||||
**personal sign** version code (``0x45``, or ``"E"``).
|
||||
|
||||
For those interested in the choice of this prefix, signed messages
|
||||
began as a Bitcoin feature, which used ``"\\x18Bitcoin Signed Message:\\n"``,
|
||||
which was a Bitcoin var-int length-prefixed string (as ``0x18`` is 24,
|
||||
the length of ``"Bitcoin Signed Message:\\n"``.). When Ethereum adopted
|
||||
the similar feature, the relevant string was ``"\\x19Ethereum Signed Message:\\n"``.
|
||||
|
||||
In one of the most brilliant instances of technical retcon-ing,
|
||||
since 0x19 is invalid as the first byte of a transaction (in [[link-rlp]] it
|
||||
indicates a single byte of value 25), the initial byte ``\\x19`` has
|
||||
now been adopted as a prefix for //some sort of signed data//,
|
||||
where the second byte determines how to interpret that data. If the
|
||||
second byte is 69 (the letter ``"E"``, as in
|
||||
``"Ethereum Signed Message:\\n"``), then the format is a
|
||||
the above prefixed message format.
|
||||
|
||||
So, all existing messages, tools and instances using the signed
|
||||
message format were already EIP-191 compliant, long before the
|
||||
standard existed or was even conceived and allowed for an extensible
|
||||
format for future formats (of which there now a few).
|
||||
|
||||
Anyways, the necessary JavaScript and Solidity are provided below.
|
||||
|
||||
_code: JavaScript @lang<javascript>
|
||||
|
||||
// The contract below is deployed to Sepolia at this address
|
||||
contractAddress = "0xf554DA5e35b2e40C09DDB481545A395da1736513";
|
||||
contract = new Contract(contractAddress, [
|
||||
"function recoverStringFromCompact(string message, (bytes32 r, bytes32 yParityAndS) sig) pure returns (address)",
|
||||
"function recoverStringFromExpanded(string message, (uint8 v, bytes32 r, bytes32 s) sig) pure returns (address)",
|
||||
"function recoverStringFromVRS(string message, uint8 v, bytes32 r, bytes32 s) pure returns (address)",
|
||||
"function recoverStringFromRaw(string message, bytes sig) pure returns (address)",
|
||||
"function recoverHashFromCompact(bytes32 hash, (bytes32 r, bytes32 yParityAndS) sig) pure returns (address)"
|
||||
], new ethers.InfuraProvider("sepolia"));
|
||||
|
||||
// The Signer; it does not need to be connected to a Provider to sign
|
||||
signer = new Wallet(id("foobar"));
|
||||
signer.address
|
||||
//_result:
|
||||
|
||||
// Our message
|
||||
message = "Hello World";
|
||||
|
||||
// The raw signature; 65 bytes
|
||||
rawSig = await signer.signMessage(message);
|
||||
//_result:
|
||||
|
||||
// Converting it to a Signature object provides more
|
||||
// flexibility, such as using it as a struct
|
||||
sig = Signature.from(rawSig);
|
||||
//_result:
|
||||
|
||||
|
||||
// If the signature matches the EIP-2098 format, a Signature
|
||||
// can be passed as the struct value directly, since the
|
||||
// parser will pull out the matching struct keys from sig.
|
||||
await contract.recoverStringFromCompact(message, sig);
|
||||
//_result:
|
||||
|
||||
// Likewise, if the struct keys match an expanded signature
|
||||
// struct, it can also be passed as the struct value directly.
|
||||
await contract.recoverStringFromExpanded(message, sig);
|
||||
//_result:
|
||||
|
||||
// If using an older API which requires the v, r and s be passed
|
||||
// separately, those members are present on the Signature.
|
||||
await contract.recoverStringFromVRS(message, sig.v, sig.r, sig.s);
|
||||
//_result:
|
||||
|
||||
// Or if using an API that expects a raw signature.
|
||||
await contract.recoverStringFromRaw(message, rawSig);
|
||||
//_result:
|
||||
|
||||
// Note: The above recovered addresses matches the signer address
|
||||
|
||||
_null:
|
||||
|
||||
The Solidity Contract has been deployed and verified on
|
||||
the Sepolia testnet at the address
|
||||
[0xf554DA5e35b2e40C09DDB481545A395da1736513](link-sol-recovermessage).
|
||||
|
||||
It provides a variety of examples using various Signature
|
||||
encodings and formats, to recover the address for an [[link-eip-191]]
|
||||
signed message.
|
||||
|
||||
_code: Solidity @lang<solidity>
|
||||
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// For more info, see: https://docs.ethers.org
|
||||
|
||||
|
||||
pragma solidity ^0.8.21;
|
||||
|
||||
// Returns the decimal string representation of value
|
||||
function itoa(uint value) pure returns (string memory) {
|
||||
|
||||
// Count the length of the decimal string representation
|
||||
uint length = 1;
|
||||
uint v = value;
|
||||
while ((v /= 10) != 0) { length++; }
|
||||
|
||||
// Allocated enough bytes
|
||||
bytes memory result = new bytes(length);
|
||||
|
||||
// Place each ASCII string character in the string,
|
||||
// right to left
|
||||
while (true) {
|
||||
length--;
|
||||
|
||||
// The ASCII value of the modulo 10 value
|
||||
result[length] = bytes1(uint8(0x30 + (value % 10)));
|
||||
|
||||
value /= 10;
|
||||
|
||||
if (length == 0) { break; }
|
||||
}
|
||||
|
||||
return string(result);
|
||||
}
|
||||
|
||||
contract RecoverMessage {
|
||||
|
||||
// This is the EIP-2098 compact representation, which reduces gas costs
|
||||
struct SignatureCompact {
|
||||
bytes32 r;
|
||||
bytes32 yParityAndS;
|
||||
}
|
||||
|
||||
// This is an expaned Signature representation
|
||||
struct SignatureExpanded {
|
||||
uint8 v;
|
||||
bytes32 r;
|
||||
bytes32 s;
|
||||
}
|
||||
|
||||
// Helper function
|
||||
function _ecrecover(string memory message, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
|
||||
// Compute the EIP-191 prefixed message
|
||||
bytes memory prefixedMessage = abi.encodePacked(
|
||||
"\x19Ethereum Signed Message:\n",
|
||||
itoa(bytes(message).length),
|
||||
message
|
||||
);
|
||||
|
||||
// Compute the message digest
|
||||
bytes32 digest = keccak256(prefixedMessage);
|
||||
|
||||
// Use the native ecrecover provided by the EVM
|
||||
return ecrecover(digest, v, r, s);
|
||||
}
|
||||
|
||||
// Recover the address from an EIP-2098 compact Signature, which packs the bit for
|
||||
// v into an unused bit within s, which saves gas overall, costing a little extra
|
||||
// in computation, but saves far more in calldata length.
|
||||
//
|
||||
// This Signature format is 64 bytes in length.
|
||||
function recoverStringFromCompact(string calldata message, SignatureCompact calldata sig) public pure returns (address) {
|
||||
|
||||
// Decompose the EIP-2098 signature (the struct is 64 bytes in length)
|
||||
uint8 v = 27 + uint8(uint256(sig.yParityAndS) >> 255);
|
||||
bytes32 s = bytes32((uint256(sig.yParityAndS) << 1) >> 1);
|
||||
|
||||
return _ecrecover(message, v, sig.r, s);
|
||||
}
|
||||
|
||||
// Recover the address from the expanded Signature struct.
|
||||
//
|
||||
// This Signature format is 96 bytes in length.
|
||||
function recoverStringFromExpanded(string calldata message, SignatureExpanded calldata sig) public pure returns (address) {
|
||||
|
||||
// The v, r and s are included directly within the struct, which is 96 bytes in length
|
||||
return _ecrecover(message, sig.v, sig.r, sig.s);
|
||||
}
|
||||
|
||||
// Recover the address from a v, r and s passed directly into the method.
|
||||
//
|
||||
// This Signature format is 96 bytes in length.
|
||||
function recoverStringFromVRS(string calldata message, uint8 v, bytes32 r, bytes32 s) public pure returns (address) {
|
||||
|
||||
// The v, r and s are included directly within the struct, which is 96 bytes in length
|
||||
return _ecrecover(message, v, r, s);
|
||||
}
|
||||
|
||||
// Recover the address from a raw signature. The signature is 65 bytes, which when
|
||||
// ABI encoded is 160 bytes long (a pointer, a length and the padded 3 words of data).
|
||||
//
|
||||
// When using raw signatures, some tools return the v as 0 or 1. In this case you must
|
||||
// add 27 to that value as v must be either 27 or 28.
|
||||
//
|
||||
// This Signature format is 65 bytes of data, but when ABI encoded is 160 bytes in length;
|
||||
// a pointer (32 bytes), a length (32 bytes) and the padded 3 words of data (96 bytes).
|
||||
function recoverStringFromRaw(string calldata message, bytes calldata sig) public pure returns (address) {
|
||||
|
||||
// Sanity check before using assembly
|
||||
require(sig.length == 65, "invalid signature");
|
||||
|
||||
// Decompose the raw signature into r, s and v (note the order)
|
||||
uint8 v;
|
||||
bytes32 r;
|
||||
bytes32 s;
|
||||
assembly {
|
||||
r := calldataload(sig.offset)
|
||||
s := calldataload(add(sig.offset, 0x20))
|
||||
v := calldataload(add(sig.offset, 0x21))
|
||||
}
|
||||
|
||||
return _ecrecover(message, v, r, s);
|
||||
}
|
||||
|
||||
// This is provided as a quick example for those that only need to recover a signature
|
||||
// for a signed hash (highly discouraged; but common), which means we can hardcode the
|
||||
// length in the prefix. This means we can drop the itoa and _ecrecover functions above.
|
||||
function recoverHashFromCompact(bytes32 hash, SignatureCompact calldata sig) public pure returns (address) {
|
||||
bytes memory prefixedMessage = abi.encodePacked(
|
||||
// Notice the length of the message is hard-coded to 32
|
||||
// here -----------------------v
|
||||
"\x19Ethereum Signed Message:\n32",
|
||||
hash
|
||||
);
|
||||
|
||||
bytes32 digest = keccak256(prefixedMessage);
|
||||
|
||||
// Decompose the EIP-2098 signature
|
||||
uint8 v = 27 + uint8(uint256(sig.yParityAndS) >> 255);
|
||||
bytes32 s = bytes32((uint256(sig.yParityAndS) << 1) >> 1);
|
||||
|
||||
return ecrecover(digest, v, sig.r, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_subsection: EIP-712 Typed Data @<cookbook-signing-eip712>
|
||||
|
||||
//Coming soon...//
|
||||
@@ -11,7 +11,7 @@ If using NPM, you must first install Ethers.
|
||||
|
||||
_code: installing via NPM @lang<shell>
|
||||
# Install ethers
|
||||
/home/ricmoo/test-ethers> npm install ethers@beta-exports
|
||||
/home/ricmoo/test-ethers> npm install ethers
|
||||
|
||||
_null:
|
||||
|
||||
@@ -35,7 +35,7 @@ _code: importing in Node.js @lang<script>
|
||||
|
||||
_code: importing ESM in a browser @lang<script>
|
||||
<script type="module">
|
||||
import { ethers } from "https://cdnjs.cloudflare.com/ajax/libs/ethers/5.7.2/ethers.min.js";
|
||||
import { ethers } from "https://cdnjs.cloudflare.com/ajax/libs/ethers/6.7.0/ethers.min.js";
|
||||
// Your code here...
|
||||
</script>
|
||||
|
||||
@@ -129,8 +129,8 @@ _code: @lang<script>
|
||||
|
||||
// If MetaMask is not installed, we use the default provider,
|
||||
// which is backed by a variety of third-party services (such
|
||||
// as INFURA). They do not have private keys installed so are
|
||||
// only have read-only access
|
||||
// as INFURA). They do not have private keys installed,
|
||||
// so they only have read-only access
|
||||
console.log("MetaMask not installed; using read-only defaults")
|
||||
provider = ethers.getDefaultProvider()
|
||||
|
||||
@@ -156,7 +156,7 @@ you can use the [[JsonRpcProvider]] directly, which communicates
|
||||
using the [[link-jsonrpc]] protocol.
|
||||
|
||||
When using your own Ethereum node or a developer-base blockchain,
|
||||
such as Hardhat or Ganache, you can get access the accounts with
|
||||
such as Hardhat or Ganache, you can get access to the accounts with
|
||||
[[JsonRpcProvider-getSigner]].
|
||||
|
||||
_code: connecting to a JSON-RPC URL @lang<script>
|
||||
@@ -177,7 +177,7 @@ results when performing mathematic operations.
|
||||
|
||||
As a result, the internal units used (e.g. wei) which are suited for
|
||||
machine-readable purposes and maths are often very large and not
|
||||
terribly human-readable.
|
||||
easily 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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
link-js-array [link-js-array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
link-js-bigint [link-js-bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
|
||||
link-js-date [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
|
||||
link-js-fetch [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
link-js-normalize [String.normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
||||
link-js-maxsafe [link-js-maxsafe](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER#Description)
|
||||
link-js-proxy [link-js-proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
|
||||
|
||||
@@ -2,3 +2,4 @@ link-npm-ethers [link-ethers-npm](https://www.npmjs.com/search?q=%40ethersprojec
|
||||
link-npm-events [EventEmitter](https://nodejs.org/dist/latest-v13.x/docs/api/events.html#events_class_eventemitter)
|
||||
link-npm-query-bignumber [link-npm-query-bignumber](https://www.npmjs.com/search?q=bignumber)
|
||||
link-npm-react-native-get-random-values [React Native get-random-values](https://www.npmjs.com/package/react-native-get-random-values)
|
||||
link-npm-react-native-quick-crypto [Quick Crypto](https://www.npmjs.com/package/react-native-quick-crypto)
|
||||
|
||||
@@ -12,6 +12,7 @@ link-infura [INFURA](https://infura.io)
|
||||
link-javascriptcore [JavaScriptCore](https://developer.apple.com/documentation/javascriptcore?language=objc)
|
||||
link-ledger [Ledger](https://www.ledger.com)
|
||||
link-metamask [MetaMask](https://metamask.io/)
|
||||
link-node [Node.js](https://nodejs.org/)
|
||||
link-otto [Otto](https://github.com/robertkrimen/otto)
|
||||
link-parity [Parity](https://www.parity.io)
|
||||
link-pocket [Pocket Network](https://pokt.network)
|
||||
@@ -44,3 +45,5 @@ link-solidity-errors [link-solidity-errors](https://docs.soliditylang.org/en/v0.
|
||||
link-solidity-events [link-solidity-events](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#events)
|
||||
|
||||
link-other-ethereum-dev-docs [link-other-ethereum-dev-docs](https://ethereum.org/en/developers/docs/)
|
||||
|
||||
link-sol-recovermessage [RecoverMessage.sol](https://sepolia.etherscan.io/address/0xf554da5e35b2e40c09ddb481545a395da1736513#code)
|
||||
|
||||
@@ -43,6 +43,7 @@ link-namehash [namehash](https://docs.ens.domains/contract-api-reference/name-pr
|
||||
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-jsonabi [ABI JSON Specification](https://docs.soliditylang.org/en/v0.8.19/abi-spec.html#json)
|
||||
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)
|
||||
|
||||
@@ -4,7 +4,7 @@ This guide aims to capture some of the high-level differences
|
||||
between v5 and v6 to help those migrating an existing app and
|
||||
those already familiar with v5 that just need a quick primer.
|
||||
|
||||
The biggest differnce in v6 is the use of modern ES6 features,
|
||||
The biggest difference in v6 is the use of modern ES6 features,
|
||||
so a lot of changes are largely internal.
|
||||
|
||||
- [BigNumbers](migrate-bigint)
|
||||
@@ -60,7 +60,7 @@ _code: simple comparison on large numbers @lang<script>
|
||||
isEqual = value1.eq(value2)
|
||||
|
||||
// Using BigInt in v6
|
||||
isEqaul = (value1 == value2)
|
||||
isEqual = (value1 == value2)
|
||||
|
||||
|
||||
_subsection: Contracts @<migrate-contracts>
|
||||
@@ -172,7 +172,7 @@ managed as a monorepo.
|
||||
|
||||
In v6 all imports are available in the root package, and for those
|
||||
who wish to have finer-grained control, the ``pkg.exports`` makes
|
||||
certain folders avilable directly.
|
||||
certain folders available directly.
|
||||
|
||||
_code: importing in v5 @lang<script>
|
||||
|
||||
@@ -314,7 +314,7 @@ _code: fetching content @lang<script>
|
||||
url, user: "username", password: "password"
|
||||
// etc. properties have FetchRequest equivalents
|
||||
};
|
||||
data = await ethers.utils.detchJson(req, json, processFunc)
|
||||
data = await ethers.utils.fetchJson(req, json, processFunc)
|
||||
|
||||
// v6
|
||||
req = new ethers.FetchRequest(url)
|
||||
@@ -348,9 +348,13 @@ _code: hex conversion @lang<script>
|
||||
_code: solidity non-standard packed @lang<script>
|
||||
// v5
|
||||
ethers.utils.solidityPack(types, values)
|
||||
ethers.utils.solidityKeccak256(types, values)
|
||||
ethers.utils.soliditySha256(types, values)
|
||||
|
||||
// v6
|
||||
ethers.solidityPacked(types, values)
|
||||
ethers.solidityPackedKeccak256(types, values)
|
||||
ethers.solidityPackedSha256(types, values)
|
||||
|
||||
_code: property manipulation @lang<script>
|
||||
// v5
|
||||
@@ -359,6 +363,30 @@ _code: property manipulation @lang<script>
|
||||
// v6
|
||||
ethers.defineProperties(obj, { name: value });
|
||||
|
||||
_code: commify @lang<script>
|
||||
// v5
|
||||
ethers.utils.commify("1234.5")
|
||||
|
||||
// v6; we removed some of these local-specific utilities,
|
||||
// however the functionality can be easily replicated
|
||||
// and adjusted depending on your desired output format,
|
||||
// for which everyone wanted their own tweaks anyways.
|
||||
//
|
||||
// However, to mimic v5 functionality, this can be used:
|
||||
function commify(value) {
|
||||
const match = value.match(/^(-?)([0-9]*)(\.?)([0-9]*)$/);
|
||||
if (!match || (!match[2] && !match[4])) {
|
||||
throw new Error(`bad formatted number: ${ JSON.stringify(value) }`);
|
||||
}
|
||||
|
||||
const neg = match[1];
|
||||
const whole = BigInt(match[2] || 0).toLocaleString("en-us");
|
||||
const frac = match[4] ? match[4].match(/^(.*?)0*$/)[1]: "0";
|
||||
|
||||
return `${ neg }${ whole }.${ frac }`;
|
||||
}
|
||||
|
||||
commify("1234.5");
|
||||
|
||||
_subsection: Removed Classes and functions @<migrate-missing>
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAyFpD,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED,eAAO,MAAM,aAAa,mBAAuD,CAAC;AAQlF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAInE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,CAgBtF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGxE;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAIzD"}
|
||||
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA2FpD,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED,eAAO,MAAM,aAAa,mBAAuD,CAAC;AAQlF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAInE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,CAgBtF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGxE;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAIzD"}
|
||||
@@ -52,13 +52,15 @@ const ProviderCreators = [
|
||||
return index_js_1.InfuraProvider.getWebSocketProvider(network, "49a0efa3aaee4fd99797bfa94d8ce2f1");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "PocketProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
return new index_js_1.PocketProvider(network);
|
||||
}
|
||||
},
|
||||
/*
|
||||
{
|
||||
name: "PocketProvider",
|
||||
networks: ethNetworks,
|
||||
create: function(network: string) {
|
||||
return new PocketProvider(network);
|
||||
}
|
||||
},
|
||||
*/
|
||||
{
|
||||
name: "QuickNodeProvider",
|
||||
networks: ethNetworks,
|
||||
|
||||
@@ -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;;;;;;;;MAQE;IACF;;;;;;;;MAQE;IACF;QACI,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,4BAAiB,CAAC,OAAO,EAAE,oCAAoC,CAAC,CAAC;QAChF,CAAC;KACJ;IACD;QACI,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,yBAAc,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC3E,CAAC;KACJ;IACD;QACI,IAAI,EAAE,yBAAyB;QAC/B,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,yBAAc,CAAC,oBAAoB,CAAC,OAAO,EAAE,kCAAkC,CAAC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AC;AAhBD,kCAgBC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,OAAe;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;AAC7B,CAAC;AAHD,sCAGC;AAED,SAAgB,OAAO,CAAC,OAAe;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,QAAQ,IAAI,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAyB,OAAQ,EAAE,CAAC,CAAC;KAAE;IAC/E,OAAO,QAAQ,CAAC;AACpB,CAAC;AAJD,0BAIC"}
|
||||
@@ -66,7 +66,9 @@ describe("Test Bytes32 strings", function () {
|
||||
describe("Test Interface", function () {
|
||||
const iface = new index_js_1.Interface([
|
||||
"function balanceOf(address owner) returns (uint)",
|
||||
"event Transfer(address indexed from, address indexed to, uint amount)"
|
||||
"event Transfer(address indexed from, address indexed to, uint amount)",
|
||||
// #4244
|
||||
"event RedemptionRequested(bytes20 indexed walletPubKeyHash, bytes redeemerOutputScript, address indexed redeemer, uint64 requestedAmount, uint64 treasuryFee, uint64 txMaxFee)"
|
||||
]);
|
||||
it("does interface stuff; @TODO expand this", function () {
|
||||
const addr = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
|
||||
@@ -95,6 +97,18 @@ describe("Test Interface", function () {
|
||||
assert_1.default.equal(filter[0], "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");
|
||||
assert_1.default.equal(filter[1], "0x0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba72");
|
||||
assert_1.default.equal(filter[2], "0x000000000000000000000000ac1639cf97a3a46d431e6d1216f576622894cbb5");
|
||||
// See: #4244
|
||||
// https://goerli.etherscan.io/tx/0xe61cef4cd706db8e23114717a207d76cc6b0df0b74ec52805551c4d1bf347a27#eventlog
|
||||
// See `RedemptionRequested` event.
|
||||
{
|
||||
const walletPubKeyHash = "0x03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e";
|
||||
const redeemer = "0x086813525A7dC7dafFf015Cdf03896Fd276eab60";
|
||||
const filterWithBytes20 = iface.encodeFilterTopics("RedemptionRequested", [walletPubKeyHash, undefined, redeemer]);
|
||||
assert_1.default.equal(filterWithBytes20.length, 3);
|
||||
assert_1.default.equal(filterWithBytes20[0], "0x97a0199072f487232635d50ab75860891afe0b91c976ed2fc76502c4d82d0d95");
|
||||
assert_1.default.equal(filterWithBytes20[1], "0x03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e000000000000000000000000");
|
||||
assert_1.default.equal(filterWithBytes20[2], "0x000000000000000000000000086813525a7dc7dafff015cdf03896fd276eab60");
|
||||
}
|
||||
const eventLog = iface.encodeEventLog("Transfer", [addr, addr2, 234]);
|
||||
assert_1.default.equal(eventLog.data, "0x00000000000000000000000000000000000000000000000000000000000000ea");
|
||||
assert_1.default.deepEqual(eventLog.topics, [
|
||||
@@ -117,6 +131,21 @@ describe("Test Interface", function () {
|
||||
assert_1.default.equal(log.args[1], "0xAC1639CF97a3A46D431e6d1216f576622894cBB5");
|
||||
assert_1.default.equal(log.args[2], BigInt(234));
|
||||
});
|
||||
// See #4248
|
||||
it("formats JSON ABI parameters with default empty string for `name` key", function () {
|
||||
assert_1.default.deepEqual(JSON.parse(iface.getFunction("balanceOf").format('json')), {
|
||||
constant: false,
|
||||
inputs: [
|
||||
{ name: "owner", type: "address" }
|
||||
],
|
||||
name: "balanceOf",
|
||||
outputs: [
|
||||
{ name: "", type: "uint256" }
|
||||
],
|
||||
payable: false,
|
||||
type: "function",
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("Tests Legacy ABI formats", function () {
|
||||
// See: #3932
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
lib.commonjs/_tests/test-provider-jsonrpc.d.ts
vendored
Normal file
2
lib.commonjs/_tests/test-provider-jsonrpc.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-provider-jsonrpc.d.ts.map
|
||||
1
lib.commonjs/_tests/test-provider-jsonrpc.d.ts.map
Normal file
1
lib.commonjs/_tests/test-provider-jsonrpc.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"test-provider-jsonrpc.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-provider-jsonrpc.ts"],"names":[],"mappings":""}
|
||||
160
lib.commonjs/_tests/test-provider-jsonrpc.js
Normal file
160
lib.commonjs/_tests/test-provider-jsonrpc.js
Normal file
@@ -0,0 +1,160 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const index_js_1 = require("../index.js");
|
||||
const StatusMessages = {
|
||||
200: "OK",
|
||||
400: "BAD REQUEST",
|
||||
500: "SERVER ERROR",
|
||||
};
|
||||
const wallet = new index_js_1.Wallet((0, index_js_1.id)("test"));
|
||||
function createProvider(testFunc) {
|
||||
let blockNumber = 1;
|
||||
const ticker = setInterval(() => { blockNumber++; }, 100);
|
||||
if (ticker.unref) {
|
||||
ticker.unref();
|
||||
}
|
||||
const processReq = (req) => {
|
||||
let result = testFunc(req.method, req.params, blockNumber);
|
||||
if (result === undefined) {
|
||||
switch (req.method) {
|
||||
case "eth_blockNumber":
|
||||
result = blockNumber;
|
||||
break;
|
||||
case "eth_chainId":
|
||||
result = "0x1337";
|
||||
break;
|
||||
case "eth_accounts":
|
||||
result = [wallet.address];
|
||||
break;
|
||||
default:
|
||||
console.log("****", req);
|
||||
return { id: index_js_1.id, error: "unsupported", jsonrpc: "2.0" };
|
||||
}
|
||||
}
|
||||
return { id: req.id, result, jsonrpc: "2.0" };
|
||||
};
|
||||
const req = new index_js_1.FetchRequest("http:/\/localhost:8082/");
|
||||
req.getUrlFunc = async (_req, signal) => {
|
||||
const req = JSON.parse(_req.hasBody() ? (0, index_js_1.toUtf8String)(_req.body) : "");
|
||||
let statusCode = 200;
|
||||
const headers = {};
|
||||
let resp;
|
||||
try {
|
||||
if (Array.isArray(req)) {
|
||||
resp = req.map((r) => processReq(r));
|
||||
}
|
||||
else {
|
||||
resp = processReq(req);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
statusCode = 500;
|
||||
resp = error.message;
|
||||
}
|
||||
const body = (0, index_js_1.toUtf8Bytes)(JSON.stringify(resp));
|
||||
return {
|
||||
statusCode,
|
||||
statusMessage: StatusMessages[statusCode],
|
||||
headers, body
|
||||
};
|
||||
};
|
||||
return new index_js_1.JsonRpcProvider(req, undefined, { cacheTimeout: -1 });
|
||||
}
|
||||
describe("Ensure Catchable Errors", function () {
|
||||
it("Can catch bad broadcast replies", async function () {
|
||||
this.timeout(15000);
|
||||
const txInfo = {
|
||||
chainId: 1337,
|
||||
gasLimit: 100000,
|
||||
maxFeePerGas: 2000000000,
|
||||
maxPriorityFeePerGas: 1000000000,
|
||||
to: wallet.address,
|
||||
value: 1,
|
||||
};
|
||||
const txSign = await wallet.signTransaction(txInfo);
|
||||
const txObj = index_js_1.Transaction.from(txSign);
|
||||
let count = 0;
|
||||
const provider = createProvider((method, params, blockNumber) => {
|
||||
switch (method) {
|
||||
case "eth_sendTransaction":
|
||||
return txObj.hash;
|
||||
case "eth_getTransactionByHash": {
|
||||
count++;
|
||||
// First time; fail!
|
||||
if (count === 1) {
|
||||
throw (0, index_js_1.makeError)("Faux Error", "SERVER_ERROR", {
|
||||
request: ({})
|
||||
});
|
||||
}
|
||||
// Second time; return null
|
||||
if (count === 2) {
|
||||
return null;
|
||||
}
|
||||
// Return a valid tx...
|
||||
const result = Object.assign({}, txObj.toJSON(), txObj.signature.toJSON(), { hash: txObj.hash, from: wallet.address });
|
||||
// ...eventually mined
|
||||
if (count > 4) {
|
||||
result.blockNumber = blockNumber;
|
||||
result.blockHash = (0, index_js_1.id)("test");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
const signer = await provider.getSigner();
|
||||
const tx = await signer.sendTransaction(txInfo);
|
||||
(0, assert_1.default)(tx);
|
||||
});
|
||||
it("Missing v is recovered", async function () {
|
||||
this.timeout(15000);
|
||||
const txInfo = {
|
||||
chainId: 1337,
|
||||
gasLimit: 100000,
|
||||
maxFeePerGas: 2000000000,
|
||||
maxPriorityFeePerGas: 1000000000,
|
||||
to: wallet.address,
|
||||
value: 1,
|
||||
};
|
||||
const txSign = await wallet.signTransaction(txInfo);
|
||||
const txObj = index_js_1.Transaction.from(txSign);
|
||||
let count = 0;
|
||||
// A provider which is mocked to return a "missing v"
|
||||
// in getTransaction
|
||||
const provider = createProvider((method, params, blockNumber) => {
|
||||
switch (method) {
|
||||
case "eth_sendTransaction":
|
||||
return txObj.hash;
|
||||
case "eth_getTransactionByHash": {
|
||||
count++;
|
||||
// The fully valid tx response
|
||||
const result = Object.assign({}, txObj.toJSON(), txObj.signature.toJSON(), { hash: txObj.hash, from: wallet.address, sig: null });
|
||||
// First time; fail with a missing v!
|
||||
if (count < 2) {
|
||||
delete result.v;
|
||||
}
|
||||
// Debug
|
||||
result._count = count;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
// Track any "missing v" error
|
||||
let missingV = null;
|
||||
provider.on("error", (e) => {
|
||||
if ((0, index_js_1.isError)(e, "UNKNOWN_ERROR") && (0, index_js_1.isError)(e.error, "INVALID_ARGUMENT")) {
|
||||
if (e.error.argument === "signature" && e.error.shortMessage === "missing v") {
|
||||
missingV = e.error;
|
||||
}
|
||||
}
|
||||
});
|
||||
const signer = await provider.getSigner();
|
||||
const tx = await signer.sendTransaction(txInfo);
|
||||
assert_1.default.ok(!!tx, "we got a transaction");
|
||||
assert_1.default.ok(!!missingV, "missing v error present");
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test-provider-jsonrpc.js.map
|
||||
1
lib.commonjs/_tests/test-provider-jsonrpc.js.map
Normal file
1
lib.commonjs/_tests/test-provider-jsonrpc.js.map
Normal file
File diff suppressed because one or more lines are too long
10
lib.commonjs/_tests/test-providers-fallback.d.ts
vendored
Normal file
10
lib.commonjs/_tests/test-providers-fallback.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { AbstractProvider, Network } from "../index.js";
|
||||
import type { PerformActionRequest } from "../index.js";
|
||||
export type Performer = (req: PerformActionRequest) => Promise<any>;
|
||||
export declare class MockProvider extends AbstractProvider {
|
||||
readonly _perform: Performer;
|
||||
constructor(perform: Performer);
|
||||
_detectNetwork(): Promise<Network>;
|
||||
perform(req: PerformActionRequest): Promise<any>;
|
||||
}
|
||||
//# sourceMappingURL=test-providers-fallback.d.ts.map
|
||||
1
lib.commonjs/_tests/test-providers-fallback.d.ts.map
Normal file
1
lib.commonjs/_tests/test-providers-fallback.d.ts.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"test-providers-fallback.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-fallback.ts"],"names":[],"mappings":"AAEA,OAAO,EAGH,gBAAgB,EAAoB,OAAO,EAE9C,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACR,oBAAoB,EACvB,MAAM,aAAa,CAAC;AAWrB,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpE,qBAAa,YAAa,SAAQ,gBAAgB;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;gBAEjB,OAAO,EAAE,SAAS;IAKxB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAElC,OAAO,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC;CAGzD"}
|
||||
138
lib.commonjs/_tests/test-providers-fallback.js
Normal file
138
lib.commonjs/_tests/test-providers-fallback.js
Normal file
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MockProvider = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const index_js_1 = require("../index.js");
|
||||
const network = index_js_1.Network.from("mainnet");
|
||||
function stall(duration) {
|
||||
return new Promise((resolve) => { setTimeout(resolve, duration); });
|
||||
}
|
||||
class MockProvider extends index_js_1.AbstractProvider {
|
||||
_perform;
|
||||
constructor(perform) {
|
||||
super(network, { cacheTimeout: -1 });
|
||||
this._perform = perform;
|
||||
}
|
||||
async _detectNetwork() { return network; }
|
||||
async perform(req) {
|
||||
return await this._perform(req);
|
||||
}
|
||||
}
|
||||
exports.MockProvider = MockProvider;
|
||||
describe("Test Fallback broadcast", function () {
|
||||
const txHash = "0x33017397ef7c7943dee3b422aec52b0a210de58d73d49c1b3ce455970f01c83a";
|
||||
async function test(actions) {
|
||||
// https://sepolia.etherscan.io/tx/0x33017397ef7c7943dee3b422aec52b0a210de58d73d49c1b3ce455970f01c83a
|
||||
const tx = "0x02f87683aa36a7048459682f00845d899ef982520894b5bdaa442bb34f27e793861c456cd5bdc527ac8c89056bc75e2d6310000080c001a07503893743e94445b2361a444343757e6f59d52e19e9b3f65eb138d802eaa972a06e4e9bc10ff55474f9aac0a4c284733b4195cb7b273de5e7465ce75a168e0c38";
|
||||
const providers = actions.map(({ timeout, error }) => {
|
||||
return new MockProvider(async (r) => {
|
||||
if (r.method === "getBlockNumber") {
|
||||
return 1;
|
||||
}
|
||||
if (r.method === "broadcastTransaction") {
|
||||
await stall(timeout);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
return txHash;
|
||||
}
|
||||
throw new Error(`unhandled method: ${r.method}`);
|
||||
});
|
||||
});
|
||||
;
|
||||
const provider = new index_js_1.FallbackProvider(providers);
|
||||
return await provider.broadcastTransaction(tx);
|
||||
}
|
||||
it("picks late non-failed broadcasts", async function () {
|
||||
const result = await test([
|
||||
{ timeout: 200, error: (0, index_js_1.makeError)("already seen", "UNKNOWN_ERROR") },
|
||||
{ timeout: 4000, error: (0, index_js_1.makeError)("already seen", "UNKNOWN_ERROR") },
|
||||
{ timeout: 400 },
|
||||
]);
|
||||
(0, assert_1.default)(result.hash === txHash, "result.hash === txHash");
|
||||
});
|
||||
it("picks late non-failed broadcasts with quorum-met red-herrings", async function () {
|
||||
const result = await test([
|
||||
{ timeout: 200, error: (0, index_js_1.makeError)("bad nonce", "NONCE_EXPIRED") },
|
||||
{ timeout: 400, error: (0, index_js_1.makeError)("bad nonce", "NONCE_EXPIRED") },
|
||||
{ timeout: 1000 },
|
||||
]);
|
||||
(0, assert_1.default)(result.hash === txHash, "result.hash === txHash");
|
||||
});
|
||||
it("insufficient funds short-circuit broadcast", async function () {
|
||||
await assert_1.default.rejects(async function () {
|
||||
const result = await test([
|
||||
{ timeout: 200, error: (0, index_js_1.makeError)("is broke", "INSUFFICIENT_FUNDS") },
|
||||
{ timeout: 400, error: (0, index_js_1.makeError)("is broke", "INSUFFICIENT_FUNDS") },
|
||||
{ timeout: 800 },
|
||||
{ timeout: 1000 },
|
||||
]);
|
||||
console.log(result);
|
||||
}, function (error) {
|
||||
(0, assert_1.default)((0, index_js_1.isError)(error, "INSUFFICIENT_FUNDS"));
|
||||
return true;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("Test Inflight Quorum", function () {
|
||||
// Fires the %%actions%% as providers which will delay before returning,
|
||||
// and returns an array of arrays, where each sub-array indicates which
|
||||
// providers were inflight at once.
|
||||
async function test(actions, quorum) {
|
||||
const inflights = [[]];
|
||||
const configs = actions.map(({ delay, stallTimeout, priority, weight }, index) => ({
|
||||
provider: new MockProvider(async (r) => {
|
||||
if (r.method === "getBlockNumber") {
|
||||
return 1;
|
||||
}
|
||||
if (r.method === "getBalance") {
|
||||
// Add this as inflight
|
||||
let last = inflights.pop();
|
||||
if (last == null) {
|
||||
throw new Error("no elements");
|
||||
}
|
||||
inflights.push(last);
|
||||
last = last.slice();
|
||||
last.push(index);
|
||||
inflights.push(last);
|
||||
// Do the thing
|
||||
await stall(delay);
|
||||
// Remove as inflight
|
||||
last = inflights.pop();
|
||||
if (last == null) {
|
||||
throw new Error("no elements");
|
||||
}
|
||||
inflights.push(last);
|
||||
last = last.filter((v) => (v !== index));
|
||||
inflights.push(last);
|
||||
return 0;
|
||||
}
|
||||
console.log(r);
|
||||
throw new Error(`unhandled method: ${r.method}`);
|
||||
}),
|
||||
stallTimeout, priority, weight
|
||||
}));
|
||||
const provider = new index_js_1.FallbackProvider(configs, network, {
|
||||
cacheTimeout: -1, pollingInterval: 100,
|
||||
quorum
|
||||
});
|
||||
await provider.getBalance(index_js_1.ZeroAddress);
|
||||
return inflights;
|
||||
}
|
||||
// See: #4298
|
||||
it("applies weights against inflight requests", async function () {
|
||||
this.timeout(2000);
|
||||
const inflights = await test([
|
||||
{ delay: 50, stallTimeout: 1000, priority: 1, weight: 2 },
|
||||
{ delay: 50, stallTimeout: 1000, priority: 1, weight: 2 },
|
||||
], 2);
|
||||
// Make sure there is never more than 1 inflight provider at once
|
||||
for (const running of inflights) {
|
||||
assert_1.default.ok(running.length <= 1, `too many inflight requests: ${JSON.stringify(inflights)}`);
|
||||
}
|
||||
});
|
||||
// @TODO: add lots more tests, checking on priority, weight and stall
|
||||
// configurations
|
||||
});
|
||||
//# sourceMappingURL=test-providers-fallback.js.map
|
||||
1
lib.commonjs/_tests/test-providers-fallback.js.map
Normal file
1
lib.commonjs/_tests/test-providers-fallback.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"test-providers-fallback.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-fallback.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAE5B,0CAKqB;AAQrB,MAAM,OAAO,GAAG,kBAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAExC,SAAS,KAAK,CAAC,QAAgB;IAC3B,OAAQ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,E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AAM,EAAE,CAAC,EAAE;YACzD,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;SAC5D,EAAE,CAAC,CAAC,CAAC;QAEN,iEAAiE;QACjE,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;YAC7B,gBAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,+BAAgC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAE,EAAE,CAAC,CAAC;SAChG;IACL,CAAC,CAAC,CAAC;IAEH,qEAAqE;IACrE,wBAAwB;AAC5B,CAAC,CAAC,CAAC"}
|
||||
@@ -10,6 +10,7 @@ function stall(duration) {
|
||||
(0, create_provider_js_1.setupProviders)();
|
||||
describe("Sends Transactions", function () {
|
||||
const wallet = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY));
|
||||
console.log("Faucet Address:", wallet.address);
|
||||
const networkName = "goerli";
|
||||
for (const providerName of create_provider_js_1.providerNames) {
|
||||
const provider = (0, create_provider_js_1.getProvider)(providerName, networkName);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"test-providers-send.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-send.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,0CAA8C;AAE9C,6DAAkF;AAIlF,SAAS,KAAK,CAAC,QAAgB;IAC3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,IAAA,mCAAc,GAAE,CAAC;AAEjB,QAAQ,CAAC,oBAAoB,EAAE;IAE3B,MAAM,MAAM,GAAG,IAAI,iBAAM,CAAS,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,QAAQ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AAE;YAClE,gBAAM,CAAC,MAAM,CAAC;gBACV,mBAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC,EAAE,UAAS,KAAU;gBAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB;oBACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC;oBAC5C,KAAK,CAAC,QAAQ,KAAK,SAAS;oBAC5B,KAAK,CAAC,KAAK,KAAK,cAAc,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAA"}
|
||||
@@ -5,5 +5,5 @@ exports.version = void 0;
|
||||
/**
|
||||
* The current version of Ethers.
|
||||
*/
|
||||
exports.version = "6.4.0";
|
||||
exports.version = "6.9.2";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
5
lib.commonjs/abi/abi-coder.d.ts
vendored
5
lib.commonjs/abi/abi-coder.d.ts
vendored
@@ -14,8 +14,9 @@ import { Result } from "./coders/abstract-coder.js";
|
||||
import { ParamType } from "./fragments.js";
|
||||
import type { BytesLike, CallExceptionAction, CallExceptionError } from "../utils/index.js";
|
||||
/**
|
||||
* About AbiCoder
|
||||
*/
|
||||
* The **AbiCoder** is a low-level class responsible for encoding JavaScript
|
||||
* values into binary data and decoding binary data into JavaScript values.
|
||||
*/
|
||||
export declare class AbiCoder {
|
||||
#private;
|
||||
/**
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"abi-coder.d.ts","sourceRoot":"","sources":["../../src.ts/abi/abi-coder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAiB,MAAM,EAAU,MAAM,4BAA4B,CAAC;AAU3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,OAAO,KAAK,EACR,SAAS,EACT,mBAAmB,EAAE,kBAAkB,EAC1C,MAAM,mBAAmB,CAAC;AAuF3B;;IAE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,MAAM,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,MAAM;IAWpF;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM;IAM1F;;;;OAIG;IACH,MAAM,CAAC,eAAe,IAAI,QAAQ;IAOlC;;;;OAIG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,EAAE,EAAE,EAAE;QAAE,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,kBAAkB;CAG3K"}
|
||||
@@ -106,8 +106,9 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
|
||||
});
|
||||
}
|
||||
/**
|
||||
* About AbiCoder
|
||||
*/
|
||||
* The **AbiCoder** is a low-level class responsible for encoding JavaScript
|
||||
* values into binary data and decoding binary data into JavaScript values.
|
||||
*/
|
||||
class AbiCoder {
|
||||
#getCoder(param) {
|
||||
if (param.isArray()) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
106
lib.commonjs/abi/fragments.d.ts
vendored
106
lib.commonjs/abi/fragments.d.ts
vendored
@@ -1,10 +1,16 @@
|
||||
/**
|
||||
* About frgaments...
|
||||
* A fragment is a single item from an ABI, which may represent any of:
|
||||
*
|
||||
* - [Functions](FunctionFragment)
|
||||
* - [Events](EventFragment)
|
||||
* - [Constructors](ConstructorFragment)
|
||||
* - Custom [Errors](ErrorFragment)
|
||||
* - [Fallback or Receive](FallbackFragment) functions
|
||||
*
|
||||
* @_subsection api/abi/abi-coder:Fragments [about-fragments]
|
||||
*/
|
||||
/**
|
||||
* A type description in a JSON API.
|
||||
* A Type description in a [JSON ABI format](link-solc-jsonabi).
|
||||
*/
|
||||
export interface JsonFragmentType {
|
||||
/**
|
||||
@@ -29,7 +35,7 @@ export interface JsonFragmentType {
|
||||
readonly components?: ReadonlyArray<JsonFragmentType>;
|
||||
}
|
||||
/**
|
||||
* A fragment for a method, event or error in a JSON API.
|
||||
* A fragment for a method, event or error in a [JSON ABI format](link-solc-jsonabi).
|
||||
*/
|
||||
export interface JsonFragment {
|
||||
/**
|
||||
@@ -71,6 +77,19 @@ export interface JsonFragment {
|
||||
}
|
||||
/**
|
||||
* The format to serialize the output as.
|
||||
*
|
||||
* **``"sighash"``** - the bare formatting, used to compute the selector
|
||||
* or topic hash; this format cannot be reversed (as it discards ``indexed``)
|
||||
* so cannot by used to export an [[Interface]].
|
||||
*
|
||||
* **``"minimal"``** - Human-Readable ABI with minimal spacing and without
|
||||
* names, so it is compact, but will result in Result objects that cannot
|
||||
* be accessed by name.
|
||||
*
|
||||
* **``"full"``** - Full Human-Readable ABI, with readable spacing and names
|
||||
* intact; this is generally the recommended format.
|
||||
*
|
||||
* **``"json"``** - The [JSON ABI format](link-solc-jsonabi).
|
||||
*/
|
||||
export type FormatType = "sighash" | "minimal" | "full" | "json";
|
||||
/**
|
||||
@@ -84,7 +103,7 @@ export type ParamTypeWalkFunc = (type: string, value: any) => any;
|
||||
*/
|
||||
export type ParamTypeWalkAsyncFunc = (type: string, value: any) => any | Promise<any>;
|
||||
/**
|
||||
* Each input and output of a [[Fragment]] is an Array of **PAramType**.
|
||||
* Each input and output of a [[Fragment]] is an Array of **ParamType**.
|
||||
*/
|
||||
export declare class ParamType {
|
||||
#private;
|
||||
@@ -215,7 +234,7 @@ export declare abstract class Fragment {
|
||||
*/
|
||||
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>);
|
||||
/**
|
||||
* Returns a string representation of this fragment.
|
||||
* Returns a string representation of this fragment as %%format%%.
|
||||
*/
|
||||
abstract format(format?: FormatType): string;
|
||||
/**
|
||||
@@ -270,14 +289,27 @@ export declare class ErrorFragment extends NamedFragment {
|
||||
* The Custom Error selector.
|
||||
*/
|
||||
get selector(): string;
|
||||
/**
|
||||
* Returns a string representation of this fragment as %%format%%.
|
||||
*/
|
||||
format(format?: FormatType): string;
|
||||
/**
|
||||
* Returns a new **ErrorFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj: any): ErrorFragment;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is an
|
||||
* **ErrorFragment**.
|
||||
*/
|
||||
static isFragment(value: any): value is ErrorFragment;
|
||||
}
|
||||
/**
|
||||
* A Fragment which represents an Event.
|
||||
*/
|
||||
export declare class EventFragment extends NamedFragment {
|
||||
/**
|
||||
* Whether this event is anonymous.
|
||||
*/
|
||||
readonly anonymous: boolean;
|
||||
/**
|
||||
* @private
|
||||
@@ -287,23 +319,52 @@ export declare class EventFragment extends NamedFragment {
|
||||
* The Event topic hash.
|
||||
*/
|
||||
get topicHash(): string;
|
||||
/**
|
||||
* Returns a string representation of this event as %%format%%.
|
||||
*/
|
||||
format(format?: FormatType): string;
|
||||
/**
|
||||
* Return the topic hash for an event with %%name%% and %%params%%.
|
||||
*/
|
||||
static getTopicHash(name: string, params?: Array<any>): string;
|
||||
/**
|
||||
* Returns a new **EventFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj: any): EventFragment;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is an
|
||||
* **EventFragment**.
|
||||
*/
|
||||
static isFragment(value: any): value is EventFragment;
|
||||
}
|
||||
/**
|
||||
* A Fragment which represents a constructor.
|
||||
*/
|
||||
export declare class ConstructorFragment extends Fragment {
|
||||
/**
|
||||
* Whether the constructor can receive an endowment.
|
||||
*/
|
||||
readonly payable: boolean;
|
||||
/**
|
||||
* The recommended gas limit for deployment or ``null``.
|
||||
*/
|
||||
readonly gas: null | bigint;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>, payable: boolean, gas: null | bigint);
|
||||
/**
|
||||
* Returns a string representation of this constructor as %%format%%.
|
||||
*/
|
||||
format(format?: FormatType): string;
|
||||
/**
|
||||
* Returns a new **ConstructorFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj: any): ConstructorFragment;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **ConstructorFragment**.
|
||||
*/
|
||||
static isFragment(value: any): value is ConstructorFragment;
|
||||
}
|
||||
/**
|
||||
@@ -315,8 +376,18 @@ export declare class FallbackFragment extends Fragment {
|
||||
*/
|
||||
readonly payable: boolean;
|
||||
constructor(guard: any, inputs: ReadonlyArray<ParamType>, payable: boolean);
|
||||
/**
|
||||
* Returns a string representation of this fallback as %%format%%.
|
||||
*/
|
||||
format(format?: FormatType): string;
|
||||
/**
|
||||
* Returns a new **FallbackFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj: any): FallbackFragment;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **FallbackFragment**.
|
||||
*/
|
||||
static isFragment(value: any): value is FallbackFragment;
|
||||
}
|
||||
/**
|
||||
@@ -341,7 +412,7 @@ export declare class FunctionFragment extends NamedFragment {
|
||||
*/
|
||||
readonly payable: boolean;
|
||||
/**
|
||||
* The amount of gas to send when calling this function
|
||||
* The recommended gas limit to send when calling this function.
|
||||
*/
|
||||
readonly gas: null | bigint;
|
||||
/**
|
||||
@@ -352,9 +423,22 @@ export declare class FunctionFragment extends NamedFragment {
|
||||
* The Function selector.
|
||||
*/
|
||||
get selector(): string;
|
||||
/**
|
||||
* Returns a string representation of this function as %%format%%.
|
||||
*/
|
||||
format(format?: FormatType): string;
|
||||
/**
|
||||
* Return the selector for a function with %%name%% and %%params%%.
|
||||
*/
|
||||
static getSelector(name: string, params?: Array<any>): string;
|
||||
/**
|
||||
* Returns a new **FunctionFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj: any): FunctionFragment;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **FunctionFragment**.
|
||||
*/
|
||||
static isFragment(value: any): value is FunctionFragment;
|
||||
}
|
||||
/**
|
||||
@@ -365,8 +449,18 @@ export declare class StructFragment extends NamedFragment {
|
||||
* @private
|
||||
*/
|
||||
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
|
||||
/**
|
||||
* Returns a string representation of this struct as %%format%%.
|
||||
*/
|
||||
format(): string;
|
||||
/**
|
||||
* Returns a new **StructFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj: any): StructFragment;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **StructFragment**.
|
||||
*/
|
||||
static isFragment(value: any): value is FunctionFragment;
|
||||
}
|
||||
//# sourceMappingURL=fragments.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
/**
|
||||
* About frgaments...
|
||||
* A fragment is a single item from an ABI, which may represent any of:
|
||||
*
|
||||
* - [Functions](FunctionFragment)
|
||||
* - [Events](EventFragment)
|
||||
* - [Constructors](ConstructorFragment)
|
||||
* - Custom [Errors](ErrorFragment)
|
||||
* - [Fallback or Receive](FallbackFragment) functions
|
||||
*
|
||||
* @_subsection api/abi/abi-coder:Fragments [about-fragments]
|
||||
*/
|
||||
@@ -15,6 +21,8 @@ function setify(items) {
|
||||
items.forEach((k) => result.add(k));
|
||||
return Object.freeze(result);
|
||||
}
|
||||
const _kwVisibDeploy = "external public payable";
|
||||
const KwVisibDeploy = setify(_kwVisibDeploy.split(" "));
|
||||
// Visibility Keywords
|
||||
const _kwVisib = "constant external internal payable private public pure view";
|
||||
const KwVisib = setify(_kwVisib.split(" "));
|
||||
@@ -338,7 +346,7 @@ const FallbackFragmentInternal = "_FallbackInternal";
|
||||
const FunctionFragmentInternal = "_FunctionInternal";
|
||||
const StructFragmentInternal = "_StructInternal";
|
||||
/**
|
||||
* Each input and output of a [[Fragment]] is an Array of **PAramType**.
|
||||
* Each input and output of a [[Fragment]] is an Array of **ParamType**.
|
||||
*/
|
||||
class ParamType {
|
||||
/**
|
||||
@@ -423,9 +431,16 @@ class ParamType {
|
||||
format = "sighash";
|
||||
}
|
||||
if (format === "json") {
|
||||
let result = {
|
||||
const name = this.name || "";
|
||||
if (this.isArray()) {
|
||||
const result = JSON.parse(this.arrayChildren.format("json"));
|
||||
result.name = name;
|
||||
result.type += `[${(this.arrayLength < 0 ? "" : String(this.arrayLength))}]`;
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
const result = {
|
||||
type: ((this.baseType === "tuple") ? "tuple" : this.type),
|
||||
name: (this.name || undefined)
|
||||
name
|
||||
};
|
||||
if (typeof (this.indexed) === "boolean") {
|
||||
result.indexed = this.indexed;
|
||||
@@ -443,9 +458,6 @@ class ParamType {
|
||||
}
|
||||
else {
|
||||
if (this.isTuple()) {
|
||||
if (format !== "sighash") {
|
||||
result += this.type;
|
||||
}
|
||||
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
|
||||
}
|
||||
else {
|
||||
@@ -462,15 +474,6 @@ class ParamType {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
* Returns true if %%value%% is an Array type.
|
||||
*
|
||||
* This provides a type gaurd ensuring that the
|
||||
* [[arrayChildren]] and [[arrayLength]] are non-null.
|
||||
*/
|
||||
//static isArray(value: any): value is { arrayChildren: ParamType, arrayLength: number } {
|
||||
// return value && (value.baseType === "array")
|
||||
//}
|
||||
/**
|
||||
* Returns true if %%this%% is an Array type.
|
||||
*
|
||||
@@ -612,7 +615,12 @@ class ParamType {
|
||||
return obj;
|
||||
}
|
||||
if (typeof (obj) === "string") {
|
||||
return ParamType.from(lex(obj), allowIndexed);
|
||||
try {
|
||||
return ParamType.from(lex(obj), allowIndexed);
|
||||
}
|
||||
catch (error) {
|
||||
(0, index_js_1.assertArgument)(false, "invalid param type", "obj", obj);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof TokenString) {
|
||||
let type = "", baseType = "";
|
||||
@@ -825,6 +833,9 @@ class ErrorFragment extends NamedFragment {
|
||||
get selector() {
|
||||
return (0, index_js_2.id)(this.format("sighash")).substring(0, 10);
|
||||
}
|
||||
/**
|
||||
* Returns a string representation of this fragment as %%format%%.
|
||||
*/
|
||||
format(format) {
|
||||
if (format == null) {
|
||||
format = "sighash";
|
||||
@@ -843,6 +854,9 @@ class ErrorFragment extends NamedFragment {
|
||||
result.push(this.name + joinParams(format, this.inputs));
|
||||
return result.join(" ");
|
||||
}
|
||||
/**
|
||||
* Returns a new **ErrorFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj) {
|
||||
if (ErrorFragment.isFragment(obj)) {
|
||||
return obj;
|
||||
@@ -858,6 +872,10 @@ class ErrorFragment extends NamedFragment {
|
||||
}
|
||||
return new ErrorFragment(_guard, obj.name, obj.inputs ? obj.inputs.map(ParamType.from) : []);
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is an
|
||||
* **ErrorFragment**.
|
||||
*/
|
||||
static isFragment(value) {
|
||||
return (value && value[internal] === ErrorFragmentInternal);
|
||||
}
|
||||
@@ -867,6 +885,9 @@ exports.ErrorFragment = ErrorFragment;
|
||||
* A Fragment which represents an Event.
|
||||
*/
|
||||
class EventFragment extends NamedFragment {
|
||||
/**
|
||||
* Whether this event is anonymous.
|
||||
*/
|
||||
anonymous;
|
||||
/**
|
||||
* @private
|
||||
@@ -882,6 +903,9 @@ class EventFragment extends NamedFragment {
|
||||
get topicHash() {
|
||||
return (0, index_js_2.id)(this.format("sighash"));
|
||||
}
|
||||
/**
|
||||
* Returns a string representation of this event as %%format%%.
|
||||
*/
|
||||
format(format) {
|
||||
if (format == null) {
|
||||
format = "sighash";
|
||||
@@ -904,17 +928,28 @@ class EventFragment extends NamedFragment {
|
||||
}
|
||||
return result.join(" ");
|
||||
}
|
||||
/**
|
||||
* Return the topic hash for an event with %%name%% and %%params%%.
|
||||
*/
|
||||
static getTopicHash(name, params) {
|
||||
params = (params || []).map((p) => ParamType.from(p));
|
||||
const fragment = new EventFragment(_guard, name, params, false);
|
||||
return fragment.topicHash;
|
||||
}
|
||||
/**
|
||||
* Returns a new **EventFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj) {
|
||||
if (EventFragment.isFragment(obj)) {
|
||||
return obj;
|
||||
}
|
||||
if (typeof (obj) === "string") {
|
||||
return EventFragment.from(lex(obj));
|
||||
try {
|
||||
return EventFragment.from(lex(obj));
|
||||
}
|
||||
catch (error) {
|
||||
(0, index_js_1.assertArgument)(false, "invalid event fragment", "obj", obj);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof TokenString) {
|
||||
const name = consumeName("event", obj);
|
||||
@@ -925,6 +960,10 @@ class EventFragment extends NamedFragment {
|
||||
}
|
||||
return new EventFragment(_guard, obj.name, obj.inputs ? obj.inputs.map((p) => ParamType.from(p, true)) : [], !!obj.anonymous);
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is an
|
||||
* **EventFragment**.
|
||||
*/
|
||||
static isFragment(value) {
|
||||
return (value && value[internal] === EventFragmentInternal);
|
||||
}
|
||||
@@ -934,7 +973,13 @@ exports.EventFragment = EventFragment;
|
||||
* A Fragment which represents a constructor.
|
||||
*/
|
||||
class ConstructorFragment extends Fragment {
|
||||
/**
|
||||
* Whether the constructor can receive an endowment.
|
||||
*/
|
||||
payable;
|
||||
/**
|
||||
* The recommended gas limit for deployment or ``null``.
|
||||
*/
|
||||
gas;
|
||||
/**
|
||||
* @private
|
||||
@@ -944,6 +989,9 @@ class ConstructorFragment extends Fragment {
|
||||
Object.defineProperty(this, internal, { value: ConstructorFragmentInternal });
|
||||
(0, index_js_1.defineProperties)(this, { payable, gas });
|
||||
}
|
||||
/**
|
||||
* Returns a string representation of this constructor as %%format%%.
|
||||
*/
|
||||
format(format) {
|
||||
(0, index_js_1.assert)(format != null && format !== "sighash", "cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", { operation: "format(sighash)" });
|
||||
if (format === "json") {
|
||||
@@ -956,29 +1004,43 @@ class ConstructorFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
const result = [`constructor${joinParams(format, this.inputs)}`];
|
||||
result.push((this.payable) ? "payable" : "nonpayable");
|
||||
if (this.payable) {
|
||||
result.push("payable");
|
||||
}
|
||||
if (this.gas != null) {
|
||||
result.push(`@${this.gas.toString()}`);
|
||||
}
|
||||
return result.join(" ");
|
||||
}
|
||||
/**
|
||||
* Returns a new **ConstructorFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj) {
|
||||
if (ConstructorFragment.isFragment(obj)) {
|
||||
return obj;
|
||||
}
|
||||
if (typeof (obj) === "string") {
|
||||
return ConstructorFragment.from(lex(obj));
|
||||
try {
|
||||
return ConstructorFragment.from(lex(obj));
|
||||
}
|
||||
catch (error) {
|
||||
(0, index_js_1.assertArgument)(false, "invalid constuctor fragment", "obj", obj);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof TokenString) {
|
||||
consumeKeywords(obj, setify(["constructor"]));
|
||||
const inputs = consumeParams(obj);
|
||||
const payable = !!consumeKeywords(obj, setify(["payable"])).has("payable");
|
||||
const payable = !!consumeKeywords(obj, KwVisibDeploy).has("payable");
|
||||
const gas = consumeGas(obj);
|
||||
consumeEoi(obj);
|
||||
return new ConstructorFragment(_guard, "constructor", inputs, payable, gas);
|
||||
}
|
||||
return new ConstructorFragment(_guard, "constructor", obj.inputs ? obj.inputs.map(ParamType.from) : [], !!obj.payable, (obj.gas != null) ? obj.gas : null);
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **ConstructorFragment**.
|
||||
*/
|
||||
static isFragment(value) {
|
||||
return (value && value[internal] === ConstructorFragmentInternal);
|
||||
}
|
||||
@@ -997,6 +1059,9 @@ class FallbackFragment extends Fragment {
|
||||
Object.defineProperty(this, internal, { value: FallbackFragmentInternal });
|
||||
(0, index_js_1.defineProperties)(this, { payable });
|
||||
}
|
||||
/**
|
||||
* Returns a string representation of this fallback as %%format%%.
|
||||
*/
|
||||
format(format) {
|
||||
const type = ((this.inputs.length === 0) ? "receive" : "fallback");
|
||||
if (format === "json") {
|
||||
@@ -1005,12 +1070,20 @@ class FallbackFragment extends Fragment {
|
||||
}
|
||||
return `${type}()${this.payable ? " payable" : ""}`;
|
||||
}
|
||||
/**
|
||||
* Returns a new **FallbackFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj) {
|
||||
if (FallbackFragment.isFragment(obj)) {
|
||||
return obj;
|
||||
}
|
||||
if (typeof (obj) === "string") {
|
||||
return FallbackFragment.from(lex(obj));
|
||||
try {
|
||||
return FallbackFragment.from(lex(obj));
|
||||
}
|
||||
catch (error) {
|
||||
(0, index_js_1.assertArgument)(false, "invalid fallback fragment", "obj", obj);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof TokenString) {
|
||||
const errorObj = obj.toString();
|
||||
@@ -1053,6 +1126,10 @@ class FallbackFragment extends Fragment {
|
||||
}
|
||||
(0, index_js_1.assertArgument)(false, "invalid fallback description", "obj", obj);
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **FallbackFragment**.
|
||||
*/
|
||||
static isFragment(value) {
|
||||
return (value && value[internal] === FallbackFragmentInternal);
|
||||
}
|
||||
@@ -1080,7 +1157,7 @@ class FunctionFragment extends NamedFragment {
|
||||
*/
|
||||
payable;
|
||||
/**
|
||||
* The amount of gas to send when calling this function
|
||||
* The recommended gas limit to send when calling this function.
|
||||
*/
|
||||
gas;
|
||||
/**
|
||||
@@ -1100,6 +1177,9 @@ class FunctionFragment extends NamedFragment {
|
||||
get selector() {
|
||||
return (0, index_js_2.id)(this.format("sighash")).substring(0, 10);
|
||||
}
|
||||
/**
|
||||
* Returns a string representation of this function as %%format%%.
|
||||
*/
|
||||
format(format) {
|
||||
if (format == null) {
|
||||
format = "sighash";
|
||||
@@ -1135,17 +1215,28 @@ class FunctionFragment extends NamedFragment {
|
||||
}
|
||||
return result.join(" ");
|
||||
}
|
||||
/**
|
||||
* Return the selector for a function with %%name%% and %%params%%.
|
||||
*/
|
||||
static getSelector(name, params) {
|
||||
params = (params || []).map((p) => ParamType.from(p));
|
||||
const fragment = new FunctionFragment(_guard, name, "view", params, [], null);
|
||||
return fragment.selector;
|
||||
}
|
||||
/**
|
||||
* Returns a new **FunctionFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj) {
|
||||
if (FunctionFragment.isFragment(obj)) {
|
||||
return obj;
|
||||
}
|
||||
if (typeof (obj) === "string") {
|
||||
return FunctionFragment.from(lex(obj));
|
||||
try {
|
||||
return FunctionFragment.from(lex(obj));
|
||||
}
|
||||
catch (error) {
|
||||
(0, index_js_1.assertArgument)(false, "invalid function fragment", "obj", obj);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof TokenString) {
|
||||
const name = consumeName("function", obj);
|
||||
@@ -1180,6 +1271,10 @@ class FunctionFragment extends NamedFragment {
|
||||
// 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);
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **FunctionFragment**.
|
||||
*/
|
||||
static isFragment(value) {
|
||||
return (value && value[internal] === FunctionFragmentInternal);
|
||||
}
|
||||
@@ -1196,12 +1291,23 @@ class StructFragment extends NamedFragment {
|
||||
super(guard, "struct", name, inputs);
|
||||
Object.defineProperty(this, internal, { value: StructFragmentInternal });
|
||||
}
|
||||
/**
|
||||
* Returns a string representation of this struct as %%format%%.
|
||||
*/
|
||||
format() {
|
||||
throw new Error("@TODO");
|
||||
}
|
||||
/**
|
||||
* Returns a new **StructFragment** for %%obj%%.
|
||||
*/
|
||||
static from(obj) {
|
||||
if (typeof (obj) === "string") {
|
||||
return StructFragment.from(lex(obj));
|
||||
try {
|
||||
return StructFragment.from(lex(obj));
|
||||
}
|
||||
catch (error) {
|
||||
(0, index_js_1.assertArgument)(false, "invalid struct fragment", "obj", obj);
|
||||
}
|
||||
}
|
||||
else if (obj instanceof TokenString) {
|
||||
const name = consumeName("struct", obj);
|
||||
@@ -1211,6 +1317,11 @@ class StructFragment extends NamedFragment {
|
||||
}
|
||||
return new StructFragment(_guard, obj.name, obj.inputs ? obj.inputs.map(ParamType.from) : []);
|
||||
}
|
||||
// @TODO: fix this return type
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard if %%value%% is a
|
||||
* **StructFragment**.
|
||||
*/
|
||||
static isFragment(value) {
|
||||
return (value && value[internal] === StructFragmentInternal);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
lib.commonjs/abi/index.d.ts
vendored
6
lib.commonjs/abi/index.d.ts
vendored
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* Explain about ABI here...
|
||||
* The Application Binary Interface (ABI) describes how method input
|
||||
* parameters should be encoded, their results decoded, and how to
|
||||
* decode events and errors.
|
||||
*
|
||||
* See [About ABIs](docs-abi) for more details how they are used.
|
||||
*
|
||||
* @_section api/abi:Application Binary Interface [about-abi]
|
||||
* @_navTitle: ABI
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACH,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EACnE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,GACvE,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EACxD,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,YAAY,EACR,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EACtE,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,YAAY,GACf,MAAM,gBAAgB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACH,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EACnE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,GACvE,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EACxD,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,YAAY,EACR,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EACtE,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACR,YAAY,GACf,MAAM,gBAAgB,CAAC"}
|
||||
@@ -1,6 +1,10 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Explain about ABI here...
|
||||
* The Application Binary Interface (ABI) describes how method input
|
||||
* parameters should be encoded, their results decoded, and how to
|
||||
* decode events and errors.
|
||||
*
|
||||
* See [About ABIs](docs-abi) for more details how they are used.
|
||||
*
|
||||
* @_section api/abi:Application Binary Interface [about-abi]
|
||||
* @_navTitle: ABI
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,MAAM;AACN,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAEjB,2CAAwE;AAA/D,iHAAA,mBAAmB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAEjD,+CAGwB;AAFpB,mHAAA,mBAAmB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AACnE,wGAAA,QAAQ,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,8GAAA,cAAc,OAAA;AAGxE,+CAMwB;AALpB,iHAAA,iBAAiB,OAAA;AACjB,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AACxD,sGAAA,MAAM,OAAA;AAGV,uCAAmC;AAA1B,iGAAA,KAAK,OAAA"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,MAAM;AACN,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAEjB,2CAAwE;AAA/D,iHAAA,mBAAmB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAEjD,+CAGwB;AAFpB,mHAAA,mBAAmB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AACnE,wGAAA,QAAQ,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,8GAAA,cAAc,OAAA;AAGxE,+CAMwB;AALpB,iHAAA,iBAAiB,OAAA;AACjB,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AACxD,sGAAA,MAAM,OAAA;AAGV,uCAAmC;AAA1B,iGAAA,KAAK,OAAA"}
|
||||
118
lib.commonjs/abi/interface.d.ts
vendored
118
lib.commonjs/abi/interface.d.ts
vendored
@@ -1,5 +1,11 @@
|
||||
/**
|
||||
* About Interface
|
||||
* The Interface class is a low-level class that accepts an
|
||||
* ABI and provides all the necessary functionality to encode
|
||||
* and decode paramaters to and results from methods, events
|
||||
* and errors.
|
||||
*
|
||||
* It also provides several convenience methods to automatically
|
||||
* search and find matching transactions and events to parse them.
|
||||
*
|
||||
* @_subsection api/abi:Interfaces [interfaces]
|
||||
*/
|
||||
@@ -10,39 +16,145 @@ import { Typed } from "./typed.js";
|
||||
import type { BigNumberish, BytesLike, CallExceptionError, CallExceptionTransaction } from "../utils/index.js";
|
||||
import type { JsonFragment } from "./fragments.js";
|
||||
export { checkResultErrors, Result };
|
||||
/**
|
||||
* When using the [[Interface-parseLog]] to automatically match a Log to its event
|
||||
* for parsing, a **LogDescription** is returned.
|
||||
*/
|
||||
export declare class LogDescription {
|
||||
/**
|
||||
* The matching fragment for the ``topic0``.
|
||||
*/
|
||||
readonly fragment: EventFragment;
|
||||
/**
|
||||
* The name of the Event.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* The full Event signature.
|
||||
*/
|
||||
readonly signature: string;
|
||||
/**
|
||||
* The topic hash for the Event.
|
||||
*/
|
||||
readonly topic: string;
|
||||
/**
|
||||
* The arguments passed into the Event with ``emit``.
|
||||
*/
|
||||
readonly args: Result;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(fragment: EventFragment, topic: string, args: Result);
|
||||
}
|
||||
/**
|
||||
* When using the [[Interface-parseTransaction]] to automatically match
|
||||
* a transaction data to its function for parsing,
|
||||
* a **TransactionDescription** is returned.
|
||||
*/
|
||||
export declare class TransactionDescription {
|
||||
/**
|
||||
* The matching fragment from the transaction ``data``.
|
||||
*/
|
||||
readonly fragment: FunctionFragment;
|
||||
/**
|
||||
* The name of the Function from the transaction ``data``.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* The arguments passed to the Function from the transaction ``data``.
|
||||
*/
|
||||
readonly args: Result;
|
||||
/**
|
||||
* The full Function signature from the transaction ``data``.
|
||||
*/
|
||||
readonly signature: string;
|
||||
/**
|
||||
* The selector for the Function from the transaction ``data``.
|
||||
*/
|
||||
readonly selector: string;
|
||||
/**
|
||||
* The ``value`` (in wei) from the transaction.
|
||||
*/
|
||||
readonly value: bigint;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(fragment: FunctionFragment, selector: string, args: Result, value: bigint);
|
||||
}
|
||||
/**
|
||||
* When using the [[Interface-parseError]] to automatically match an
|
||||
* error for a call result for parsing, an **ErrorDescription** is returned.
|
||||
*/
|
||||
export declare class ErrorDescription {
|
||||
/**
|
||||
* The matching fragment.
|
||||
*/
|
||||
readonly fragment: ErrorFragment;
|
||||
/**
|
||||
* The name of the Error.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* The arguments passed to the Error with ``revert``.
|
||||
*/
|
||||
readonly args: Result;
|
||||
/**
|
||||
* The full Error signature.
|
||||
*/
|
||||
readonly signature: string;
|
||||
/**
|
||||
* The selector for the Error.
|
||||
*/
|
||||
readonly selector: string;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(fragment: ErrorFragment, selector: string, args: Result);
|
||||
}
|
||||
/**
|
||||
* An **Indexed** is used as a value when a value that does not
|
||||
* fit within a topic (i.e. not a fixed-length, 32-byte type). It
|
||||
* is the ``keccak256`` of the value, and used for types such as
|
||||
* arrays, tuples, bytes and strings.
|
||||
*/
|
||||
export declare class Indexed {
|
||||
/**
|
||||
* The ``keccak256`` of the value logged.
|
||||
*/
|
||||
readonly hash: null | string;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
readonly _isIndexed: boolean;
|
||||
/**
|
||||
* Returns ``true`` if %%value%% is an **Indexed**.
|
||||
*
|
||||
* This provides a Type Guard for property access.
|
||||
*/
|
||||
static isIndexed(value: any): value is Indexed;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(hash: null | string);
|
||||
}
|
||||
/**
|
||||
* @TODO
|
||||
* An **InterfaceAbi** may be any supported ABI format.
|
||||
*
|
||||
* A string is expected to be a JSON string, which will be parsed
|
||||
* using ``JSON.parse``. This means that the value **must** be a valid
|
||||
* JSON string, with no stray commas, etc.
|
||||
*
|
||||
* An array may contain any combination of:
|
||||
* - Human-Readable fragments
|
||||
* - Parsed JSON fragment
|
||||
* - [[Fragment]] instances
|
||||
*
|
||||
* A **Human-Readable Fragment** is a string which resembles a Solidity
|
||||
* signature and is introduced in [this blog entry](link-ricmoo-humanreadableabi).
|
||||
* For example, ``function balanceOf(address) view returns (uint)``.
|
||||
*
|
||||
* A **Parsed JSON Fragment** is a JavaScript Object desribed in the
|
||||
* [Solidity documentation](link-solc-jsonabi).
|
||||
*/
|
||||
export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>;
|
||||
/**
|
||||
@@ -256,7 +368,7 @@ export declare class Interface {
|
||||
* 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.
|
||||
* If the matching error cannot be found, returns null.
|
||||
*/
|
||||
parseError(data: BytesLike): null | ErrorDescription;
|
||||
/**
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,12 @@
|
||||
"use strict";
|
||||
/**
|
||||
* About Interface
|
||||
* The Interface class is a low-level class that accepts an
|
||||
* ABI and provides all the necessary functionality to encode
|
||||
* and decode paramaters to and results from methods, events
|
||||
* and errors.
|
||||
*
|
||||
* It also provides several convenience methods to automatically
|
||||
* search and find matching transactions and events to parse them.
|
||||
*
|
||||
* @_subsection api/abi:Interfaces [interfaces]
|
||||
*/
|
||||
@@ -15,12 +21,34 @@ Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: fun
|
||||
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return abstract_coder_js_1.Result; } });
|
||||
const fragments_js_1 = require("./fragments.js");
|
||||
const typed_js_1 = require("./typed.js");
|
||||
/**
|
||||
* When using the [[Interface-parseLog]] to automatically match a Log to its event
|
||||
* for parsing, a **LogDescription** is returned.
|
||||
*/
|
||||
class LogDescription {
|
||||
/**
|
||||
* The matching fragment for the ``topic0``.
|
||||
*/
|
||||
fragment;
|
||||
/**
|
||||
* The name of the Event.
|
||||
*/
|
||||
name;
|
||||
/**
|
||||
* The full Event signature.
|
||||
*/
|
||||
signature;
|
||||
/**
|
||||
* The topic hash for the Event.
|
||||
*/
|
||||
topic;
|
||||
/**
|
||||
* The arguments passed into the Event with ``emit``.
|
||||
*/
|
||||
args;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(fragment, topic, args) {
|
||||
const name = fragment.name, signature = fragment.format();
|
||||
(0, index_js_3.defineProperties)(this, {
|
||||
@@ -29,13 +57,39 @@ class LogDescription {
|
||||
}
|
||||
}
|
||||
exports.LogDescription = LogDescription;
|
||||
/**
|
||||
* When using the [[Interface-parseTransaction]] to automatically match
|
||||
* a transaction data to its function for parsing,
|
||||
* a **TransactionDescription** is returned.
|
||||
*/
|
||||
class TransactionDescription {
|
||||
/**
|
||||
* The matching fragment from the transaction ``data``.
|
||||
*/
|
||||
fragment;
|
||||
/**
|
||||
* The name of the Function from the transaction ``data``.
|
||||
*/
|
||||
name;
|
||||
/**
|
||||
* The arguments passed to the Function from the transaction ``data``.
|
||||
*/
|
||||
args;
|
||||
/**
|
||||
* The full Function signature from the transaction ``data``.
|
||||
*/
|
||||
signature;
|
||||
/**
|
||||
* The selector for the Function from the transaction ``data``.
|
||||
*/
|
||||
selector;
|
||||
/**
|
||||
* The ``value`` (in wei) from the transaction.
|
||||
*/
|
||||
value;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(fragment, selector, args, value) {
|
||||
const name = fragment.name, signature = fragment.format();
|
||||
(0, index_js_3.defineProperties)(this, {
|
||||
@@ -44,12 +98,34 @@ class TransactionDescription {
|
||||
}
|
||||
}
|
||||
exports.TransactionDescription = TransactionDescription;
|
||||
/**
|
||||
* When using the [[Interface-parseError]] to automatically match an
|
||||
* error for a call result for parsing, an **ErrorDescription** is returned.
|
||||
*/
|
||||
class ErrorDescription {
|
||||
/**
|
||||
* The matching fragment.
|
||||
*/
|
||||
fragment;
|
||||
/**
|
||||
* The name of the Error.
|
||||
*/
|
||||
name;
|
||||
/**
|
||||
* The arguments passed to the Error with ``revert``.
|
||||
*/
|
||||
args;
|
||||
/**
|
||||
* The full Error signature.
|
||||
*/
|
||||
signature;
|
||||
/**
|
||||
* The selector for the Error.
|
||||
*/
|
||||
selector;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(fragment, selector, args) {
|
||||
const name = fragment.name, signature = fragment.format();
|
||||
(0, index_js_3.defineProperties)(this, {
|
||||
@@ -58,12 +134,32 @@ class ErrorDescription {
|
||||
}
|
||||
}
|
||||
exports.ErrorDescription = ErrorDescription;
|
||||
/**
|
||||
* An **Indexed** is used as a value when a value that does not
|
||||
* fit within a topic (i.e. not a fixed-length, 32-byte type). It
|
||||
* is the ``keccak256`` of the value, and used for types such as
|
||||
* arrays, tuples, bytes and strings.
|
||||
*/
|
||||
class Indexed {
|
||||
/**
|
||||
* The ``keccak256`` of the value logged.
|
||||
*/
|
||||
hash;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
_isIndexed;
|
||||
/**
|
||||
* Returns ``true`` if %%value%% is an **Indexed**.
|
||||
*
|
||||
* This provides a Type Guard for property access.
|
||||
*/
|
||||
static isIndexed(value) {
|
||||
return !!(value && value._isIndexed);
|
||||
}
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(hash) {
|
||||
(0, index_js_3.defineProperties)(this, { hash, _isIndexed: true });
|
||||
}
|
||||
@@ -788,15 +884,17 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
||||
if (param.type === "bool" && typeof (value) === "boolean") {
|
||||
value = (value ? "0x01" : "0x00");
|
||||
}
|
||||
if (param.type.match(/^u?int/)) {
|
||||
value = (0, index_js_3.toBeHex)(value);
|
||||
else if (param.type.match(/^u?int/)) {
|
||||
value = (0, index_js_3.toBeHex)(value); // @TODO: Should this toTwos??
|
||||
}
|
||||
// Check addresses are valid
|
||||
if (param.type === "address") {
|
||||
else if (param.type.match(/^bytes/)) {
|
||||
value = (0, index_js_3.zeroPadBytes)(value, 32);
|
||||
}
|
||||
else if (param.type === "address") {
|
||||
// Check addresses are valid
|
||||
this.#abiCoder.encode(["address"], [value]);
|
||||
}
|
||||
return (0, index_js_3.zeroPadValue)((0, index_js_3.hexlify)(value), 32);
|
||||
//@TOOD should probably be return toHex(value, 32)
|
||||
};
|
||||
values.forEach((value, index) => {
|
||||
const param = fragment.inputs[index];
|
||||
@@ -970,7 +1068,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
||||
* 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.
|
||||
* If the matching error cannot be found, returns null.
|
||||
*/
|
||||
parseError(data) {
|
||||
const hexData = (0, index_js_3.hexlify)(data);
|
||||
|
||||
File diff suppressed because one or more lines are too long
398
lib.commonjs/abi/typed.d.ts
vendored
398
lib.commonjs/abi/typed.d.ts
vendored
@@ -15,146 +15,544 @@
|
||||
import type { Addressable } from "../address/index.js";
|
||||
import type { BigNumberish, BytesLike } from "../utils/index.js";
|
||||
import type { Result } from "./coders/abstract-coder.js";
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
export interface TypedNumber extends Typed {
|
||||
value: number;
|
||||
defaultValue(): number;
|
||||
minValue(): number;
|
||||
maxValue(): number;
|
||||
}
|
||||
/**
|
||||
* A **Typed** that represents a numeric value.
|
||||
*/
|
||||
export interface TypedBigInt extends Typed {
|
||||
/**
|
||||
* The value.
|
||||
*/
|
||||
value: bigint;
|
||||
/**
|
||||
* The default value for all numeric types is ``0``.
|
||||
*/
|
||||
defaultValue(): bigint;
|
||||
/**
|
||||
* The minimum value for this type, accounting for bit-width and signed-ness.
|
||||
*/
|
||||
minValue(): bigint;
|
||||
/**
|
||||
* The minimum value for this type, accounting for bit-width.
|
||||
*/
|
||||
maxValue(): bigint;
|
||||
}
|
||||
/**
|
||||
* A **Typed** that represents a binary sequence of data as bytes.
|
||||
*/
|
||||
export interface TypedData extends Typed {
|
||||
/**
|
||||
* The value.
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The default value for this type.
|
||||
*/
|
||||
defaultValue(): string;
|
||||
}
|
||||
/**
|
||||
* A **Typed** that represents a UTF-8 sequence of bytes.
|
||||
*/
|
||||
export interface TypedString extends Typed {
|
||||
/**
|
||||
* The value.
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The default value for the string type is the empty string (i.e. ``""``).
|
||||
*/
|
||||
defaultValue(): string;
|
||||
}
|
||||
/**
|
||||
* The **Typed** class to wrap values providing explicit type information.
|
||||
*/
|
||||
export declare class Typed {
|
||||
#private;
|
||||
/**
|
||||
* The type, as a Solidity-compatible type.
|
||||
*/
|
||||
readonly type: string;
|
||||
/**
|
||||
* The actual value.
|
||||
*/
|
||||
readonly value: any;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
readonly _typedSymbol: Symbol;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(gaurd: any, type: string, value: any, options?: any);
|
||||
/**
|
||||
* Format the type as a Human-Readable type.
|
||||
*/
|
||||
format(): string;
|
||||
/**
|
||||
* The default value returned by this type.
|
||||
*/
|
||||
defaultValue(): string | number | bigint | Result;
|
||||
/**
|
||||
* The minimum value for numeric types.
|
||||
*/
|
||||
minValue(): string | number | bigint;
|
||||
/**
|
||||
* The maximum value for numeric types.
|
||||
*/
|
||||
maxValue(): string | number | bigint;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard is this is a [[TypedBigInt]].
|
||||
*/
|
||||
isBigInt(): this is TypedBigInt;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard is this is a [[TypedData]].
|
||||
*/
|
||||
isData(): this is TypedData;
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard is this is a [[TypedString]].
|
||||
*/
|
||||
isString(): this is TypedString;
|
||||
/**
|
||||
* Returns the tuple name, if this is a tuple. Throws otherwise.
|
||||
*/
|
||||
get tupleName(): null | string;
|
||||
/**
|
||||
* Returns the length of the array type or ``-1`` if it is dynamic.
|
||||
*
|
||||
* Throws if the type is not an array.
|
||||
*/
|
||||
get arrayLength(): null | number;
|
||||
/**
|
||||
* Returns a new **Typed** of %%type%% with the %%value%%.
|
||||
*/
|
||||
static from(type: string, value: any): Typed;
|
||||
/**
|
||||
* Return a new ``uint8`` type for %%v%%.
|
||||
*/
|
||||
static uint8(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint16`` type for %%v%%.
|
||||
*/
|
||||
static uint16(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint24`` type for %%v%%.
|
||||
*/
|
||||
static uint24(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint32`` type for %%v%%.
|
||||
*/
|
||||
static uint32(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint40`` type for %%v%%.
|
||||
*/
|
||||
static uint40(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint48`` type for %%v%%.
|
||||
*/
|
||||
static uint48(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint56`` type for %%v%%.
|
||||
*/
|
||||
static uint56(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint64`` type for %%v%%.
|
||||
*/
|
||||
static uint64(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint72`` type for %%v%%.
|
||||
*/
|
||||
static uint72(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint80`` type for %%v%%.
|
||||
*/
|
||||
static uint80(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint88`` type for %%v%%.
|
||||
*/
|
||||
static uint88(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint96`` type for %%v%%.
|
||||
*/
|
||||
static uint96(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint104`` type for %%v%%.
|
||||
*/
|
||||
static uint104(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint112`` type for %%v%%.
|
||||
*/
|
||||
static uint112(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint120`` type for %%v%%.
|
||||
*/
|
||||
static uint120(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint128`` type for %%v%%.
|
||||
*/
|
||||
static uint128(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint136`` type for %%v%%.
|
||||
*/
|
||||
static uint136(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint144`` type for %%v%%.
|
||||
*/
|
||||
static uint144(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint152`` type for %%v%%.
|
||||
*/
|
||||
static uint152(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint160`` type for %%v%%.
|
||||
*/
|
||||
static uint160(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint168`` type for %%v%%.
|
||||
*/
|
||||
static uint168(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint176`` type for %%v%%.
|
||||
*/
|
||||
static uint176(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint184`` type for %%v%%.
|
||||
*/
|
||||
static uint184(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint192`` type for %%v%%.
|
||||
*/
|
||||
static uint192(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint200`` type for %%v%%.
|
||||
*/
|
||||
static uint200(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint208`` type for %%v%%.
|
||||
*/
|
||||
static uint208(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint216`` type for %%v%%.
|
||||
*/
|
||||
static uint216(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint224`` type for %%v%%.
|
||||
*/
|
||||
static uint224(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint232`` type for %%v%%.
|
||||
*/
|
||||
static uint232(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint240`` type for %%v%%.
|
||||
*/
|
||||
static uint240(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint248`` type for %%v%%.
|
||||
*/
|
||||
static uint248(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint256`` type for %%v%%.
|
||||
*/
|
||||
static uint256(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``uint256`` type for %%v%%.
|
||||
*/
|
||||
static uint(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int8`` type for %%v%%.
|
||||
*/
|
||||
static int8(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int16`` type for %%v%%.
|
||||
*/
|
||||
static int16(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int24`` type for %%v%%.
|
||||
*/
|
||||
static int24(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int32`` type for %%v%%.
|
||||
*/
|
||||
static int32(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int40`` type for %%v%%.
|
||||
*/
|
||||
static int40(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int48`` type for %%v%%.
|
||||
*/
|
||||
static int48(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int56`` type for %%v%%.
|
||||
*/
|
||||
static int56(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int64`` type for %%v%%.
|
||||
*/
|
||||
static int64(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int72`` type for %%v%%.
|
||||
*/
|
||||
static int72(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int80`` type for %%v%%.
|
||||
*/
|
||||
static int80(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int88`` type for %%v%%.
|
||||
*/
|
||||
static int88(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int96`` type for %%v%%.
|
||||
*/
|
||||
static int96(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int104`` type for %%v%%.
|
||||
*/
|
||||
static int104(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int112`` type for %%v%%.
|
||||
*/
|
||||
static int112(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int120`` type for %%v%%.
|
||||
*/
|
||||
static int120(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int128`` type for %%v%%.
|
||||
*/
|
||||
static int128(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int136`` type for %%v%%.
|
||||
*/
|
||||
static int136(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int144`` type for %%v%%.
|
||||
*/
|
||||
static int144(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int52`` type for %%v%%.
|
||||
*/
|
||||
static int152(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int160`` type for %%v%%.
|
||||
*/
|
||||
static int160(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int168`` type for %%v%%.
|
||||
*/
|
||||
static int168(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int176`` type for %%v%%.
|
||||
*/
|
||||
static int176(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int184`` type for %%v%%.
|
||||
*/
|
||||
static int184(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int92`` type for %%v%%.
|
||||
*/
|
||||
static int192(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int200`` type for %%v%%.
|
||||
*/
|
||||
static int200(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int208`` type for %%v%%.
|
||||
*/
|
||||
static int208(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int216`` type for %%v%%.
|
||||
*/
|
||||
static int216(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int224`` type for %%v%%.
|
||||
*/
|
||||
static int224(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int232`` type for %%v%%.
|
||||
*/
|
||||
static int232(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int240`` type for %%v%%.
|
||||
*/
|
||||
static int240(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int248`` type for %%v%%.
|
||||
*/
|
||||
static int248(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int256`` type for %%v%%.
|
||||
*/
|
||||
static int256(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``int256`` type for %%v%%.
|
||||
*/
|
||||
static int(v: BigNumberish): Typed;
|
||||
/**
|
||||
* Return a new ``bytes1`` type for %%v%%.
|
||||
*/
|
||||
static bytes1(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes2`` type for %%v%%.
|
||||
*/
|
||||
static bytes2(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes3`` type for %%v%%.
|
||||
*/
|
||||
static bytes3(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes4`` type for %%v%%.
|
||||
*/
|
||||
static bytes4(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes5`` type for %%v%%.
|
||||
*/
|
||||
static bytes5(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes6`` type for %%v%%.
|
||||
*/
|
||||
static bytes6(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes7`` type for %%v%%.
|
||||
*/
|
||||
static bytes7(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes8`` type for %%v%%.
|
||||
*/
|
||||
static bytes8(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes9`` type for %%v%%.
|
||||
*/
|
||||
static bytes9(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes10`` type for %%v%%.
|
||||
*/
|
||||
static bytes10(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes11`` type for %%v%%.
|
||||
*/
|
||||
static bytes11(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes12`` type for %%v%%.
|
||||
*/
|
||||
static bytes12(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes13`` type for %%v%%.
|
||||
*/
|
||||
static bytes13(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes14`` type for %%v%%.
|
||||
*/
|
||||
static bytes14(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes15`` type for %%v%%.
|
||||
*/
|
||||
static bytes15(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes16`` type for %%v%%.
|
||||
*/
|
||||
static bytes16(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes17`` type for %%v%%.
|
||||
*/
|
||||
static bytes17(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes18`` type for %%v%%.
|
||||
*/
|
||||
static bytes18(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes19`` type for %%v%%.
|
||||
*/
|
||||
static bytes19(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes20`` type for %%v%%.
|
||||
*/
|
||||
static bytes20(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes21`` type for %%v%%.
|
||||
*/
|
||||
static bytes21(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes22`` type for %%v%%.
|
||||
*/
|
||||
static bytes22(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes23`` type for %%v%%.
|
||||
*/
|
||||
static bytes23(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes24`` type for %%v%%.
|
||||
*/
|
||||
static bytes24(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes25`` type for %%v%%.
|
||||
*/
|
||||
static bytes25(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes26`` type for %%v%%.
|
||||
*/
|
||||
static bytes26(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes27`` type for %%v%%.
|
||||
*/
|
||||
static bytes27(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes28`` type for %%v%%.
|
||||
*/
|
||||
static bytes28(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes29`` type for %%v%%.
|
||||
*/
|
||||
static bytes29(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes30`` type for %%v%%.
|
||||
*/
|
||||
static bytes30(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes31`` type for %%v%%.
|
||||
*/
|
||||
static bytes31(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``bytes32`` type for %%v%%.
|
||||
*/
|
||||
static bytes32(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``address`` type for %%v%%.
|
||||
*/
|
||||
static address(v: string | Addressable): Typed;
|
||||
/**
|
||||
* Return a new ``bool`` type for %%v%%.
|
||||
*/
|
||||
static bool(v: any): Typed;
|
||||
/**
|
||||
* Return a new ``bytes`` type for %%v%%.
|
||||
*/
|
||||
static bytes(v: BytesLike): Typed;
|
||||
/**
|
||||
* Return a new ``string`` type for %%v%%.
|
||||
*/
|
||||
static string(v: string): Typed;
|
||||
/**
|
||||
* Return a new ``array`` type for %%v%%, allowing %%dynamic%% length.
|
||||
*/
|
||||
static array(v: Array<any | Typed>, dynamic?: null | boolean): Typed;
|
||||
/**
|
||||
* Return a new ``tuple`` type for %%v%%, with the optional %%name%%.
|
||||
*/
|
||||
static tuple(v: Array<any | Typed> | Record<string, any | Typed>, name?: string): Typed;
|
||||
/**
|
||||
* Return a new ``uint8`` type for %%v%%.
|
||||
*/
|
||||
static overrides(v: Record<string, any>): Typed;
|
||||
/**
|
||||
* Returns true only if %%value%% is a [[Typed]] instance.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -31,11 +31,26 @@ function b(value, size) {
|
||||
return new Typed(_gaurd, `bytes${(size) ? size : ""}`, value, { size });
|
||||
}
|
||||
const _typedSymbol = Symbol.for("_ethers_typed");
|
||||
/**
|
||||
* The **Typed** class to wrap values providing explicit type information.
|
||||
*/
|
||||
class Typed {
|
||||
/**
|
||||
* The type, as a Solidity-compatible type.
|
||||
*/
|
||||
type;
|
||||
/**
|
||||
* The actual value.
|
||||
*/
|
||||
value;
|
||||
#options;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
_typedSymbol;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(gaurd, type, value, options) {
|
||||
if (options == null) {
|
||||
options = null;
|
||||
@@ -46,6 +61,9 @@ class Typed {
|
||||
// Check the value is valid
|
||||
this.format();
|
||||
}
|
||||
/**
|
||||
* Format the type as a Human-Readable type.
|
||||
*/
|
||||
format() {
|
||||
if (this.type === "array") {
|
||||
throw new Error("");
|
||||
@@ -58,24 +76,45 @@ class Typed {
|
||||
}
|
||||
return this.type;
|
||||
}
|
||||
/**
|
||||
* The default value returned by this type.
|
||||
*/
|
||||
defaultValue() {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* The minimum value for numeric types.
|
||||
*/
|
||||
minValue() {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* The maximum value for numeric types.
|
||||
*/
|
||||
maxValue() {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard is this is a [[TypedBigInt]].
|
||||
*/
|
||||
isBigInt() {
|
||||
return !!(this.type.match(/^u?int[0-9]+$/));
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard is this is a [[TypedData]].
|
||||
*/
|
||||
isData() {
|
||||
return this.type.startsWith("bytes");
|
||||
}
|
||||
/**
|
||||
* Returns ``true`` and provides a type guard is this is a [[TypedString]].
|
||||
*/
|
||||
isString() {
|
||||
return (this.type === "string");
|
||||
}
|
||||
/**
|
||||
* Returns the tuple name, if this is a tuple. Throws otherwise.
|
||||
*/
|
||||
get tupleName() {
|
||||
if (this.type !== "tuple") {
|
||||
throw TypeError("not a tuple");
|
||||
@@ -86,6 +125,11 @@ class Typed {
|
||||
// - `null` indicates the length is unforced, it could be dynamic
|
||||
// - `-1` indicates the length is dynamic
|
||||
// - any other value indicates it is a static array and is its length
|
||||
/**
|
||||
* Returns the length of the array type or ``-1`` if it is dynamic.
|
||||
*
|
||||
* Throws if the type is not an array.
|
||||
*/
|
||||
get arrayLength() {
|
||||
if (this.type !== "array") {
|
||||
throw TypeError("not an array");
|
||||
@@ -98,119 +142,437 @@ class Typed {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns a new **Typed** of %%type%% with the %%value%%.
|
||||
*/
|
||||
static from(type, value) {
|
||||
return new Typed(_gaurd, type, value);
|
||||
}
|
||||
/**
|
||||
* Return a new ``uint8`` type for %%v%%.
|
||||
*/
|
||||
static uint8(v) { return n(v, 8); }
|
||||
/**
|
||||
* Return a new ``uint16`` type for %%v%%.
|
||||
*/
|
||||
static uint16(v) { return n(v, 16); }
|
||||
/**
|
||||
* Return a new ``uint24`` type for %%v%%.
|
||||
*/
|
||||
static uint24(v) { return n(v, 24); }
|
||||
/**
|
||||
* Return a new ``uint32`` type for %%v%%.
|
||||
*/
|
||||
static uint32(v) { return n(v, 32); }
|
||||
/**
|
||||
* Return a new ``uint40`` type for %%v%%.
|
||||
*/
|
||||
static uint40(v) { return n(v, 40); }
|
||||
/**
|
||||
* Return a new ``uint48`` type for %%v%%.
|
||||
*/
|
||||
static uint48(v) { return n(v, 48); }
|
||||
/**
|
||||
* Return a new ``uint56`` type for %%v%%.
|
||||
*/
|
||||
static uint56(v) { return n(v, 56); }
|
||||
/**
|
||||
* Return a new ``uint64`` type for %%v%%.
|
||||
*/
|
||||
static uint64(v) { return n(v, 64); }
|
||||
/**
|
||||
* Return a new ``uint72`` type for %%v%%.
|
||||
*/
|
||||
static uint72(v) { return n(v, 72); }
|
||||
/**
|
||||
* Return a new ``uint80`` type for %%v%%.
|
||||
*/
|
||||
static uint80(v) { return n(v, 80); }
|
||||
/**
|
||||
* Return a new ``uint88`` type for %%v%%.
|
||||
*/
|
||||
static uint88(v) { return n(v, 88); }
|
||||
/**
|
||||
* Return a new ``uint96`` type for %%v%%.
|
||||
*/
|
||||
static uint96(v) { return n(v, 96); }
|
||||
/**
|
||||
* Return a new ``uint104`` type for %%v%%.
|
||||
*/
|
||||
static uint104(v) { return n(v, 104); }
|
||||
/**
|
||||
* Return a new ``uint112`` type for %%v%%.
|
||||
*/
|
||||
static uint112(v) { return n(v, 112); }
|
||||
/**
|
||||
* Return a new ``uint120`` type for %%v%%.
|
||||
*/
|
||||
static uint120(v) { return n(v, 120); }
|
||||
/**
|
||||
* Return a new ``uint128`` type for %%v%%.
|
||||
*/
|
||||
static uint128(v) { return n(v, 128); }
|
||||
/**
|
||||
* Return a new ``uint136`` type for %%v%%.
|
||||
*/
|
||||
static uint136(v) { return n(v, 136); }
|
||||
/**
|
||||
* Return a new ``uint144`` type for %%v%%.
|
||||
*/
|
||||
static uint144(v) { return n(v, 144); }
|
||||
/**
|
||||
* Return a new ``uint152`` type for %%v%%.
|
||||
*/
|
||||
static uint152(v) { return n(v, 152); }
|
||||
/**
|
||||
* Return a new ``uint160`` type for %%v%%.
|
||||
*/
|
||||
static uint160(v) { return n(v, 160); }
|
||||
/**
|
||||
* Return a new ``uint168`` type for %%v%%.
|
||||
*/
|
||||
static uint168(v) { return n(v, 168); }
|
||||
/**
|
||||
* Return a new ``uint176`` type for %%v%%.
|
||||
*/
|
||||
static uint176(v) { return n(v, 176); }
|
||||
/**
|
||||
* Return a new ``uint184`` type for %%v%%.
|
||||
*/
|
||||
static uint184(v) { return n(v, 184); }
|
||||
/**
|
||||
* Return a new ``uint192`` type for %%v%%.
|
||||
*/
|
||||
static uint192(v) { return n(v, 192); }
|
||||
/**
|
||||
* Return a new ``uint200`` type for %%v%%.
|
||||
*/
|
||||
static uint200(v) { return n(v, 200); }
|
||||
/**
|
||||
* Return a new ``uint208`` type for %%v%%.
|
||||
*/
|
||||
static uint208(v) { return n(v, 208); }
|
||||
/**
|
||||
* Return a new ``uint216`` type for %%v%%.
|
||||
*/
|
||||
static uint216(v) { return n(v, 216); }
|
||||
/**
|
||||
* Return a new ``uint224`` type for %%v%%.
|
||||
*/
|
||||
static uint224(v) { return n(v, 224); }
|
||||
/**
|
||||
* Return a new ``uint232`` type for %%v%%.
|
||||
*/
|
||||
static uint232(v) { return n(v, 232); }
|
||||
/**
|
||||
* Return a new ``uint240`` type for %%v%%.
|
||||
*/
|
||||
static uint240(v) { return n(v, 240); }
|
||||
/**
|
||||
* Return a new ``uint248`` type for %%v%%.
|
||||
*/
|
||||
static uint248(v) { return n(v, 248); }
|
||||
/**
|
||||
* Return a new ``uint256`` type for %%v%%.
|
||||
*/
|
||||
static uint256(v) { return n(v, 256); }
|
||||
/**
|
||||
* Return a new ``uint256`` type for %%v%%.
|
||||
*/
|
||||
static uint(v) { return n(v, 256); }
|
||||
/**
|
||||
* Return a new ``int8`` type for %%v%%.
|
||||
*/
|
||||
static int8(v) { return n(v, -8); }
|
||||
/**
|
||||
* Return a new ``int16`` type for %%v%%.
|
||||
*/
|
||||
static int16(v) { return n(v, -16); }
|
||||
/**
|
||||
* Return a new ``int24`` type for %%v%%.
|
||||
*/
|
||||
static int24(v) { return n(v, -24); }
|
||||
/**
|
||||
* Return a new ``int32`` type for %%v%%.
|
||||
*/
|
||||
static int32(v) { return n(v, -32); }
|
||||
/**
|
||||
* Return a new ``int40`` type for %%v%%.
|
||||
*/
|
||||
static int40(v) { return n(v, -40); }
|
||||
/**
|
||||
* Return a new ``int48`` type for %%v%%.
|
||||
*/
|
||||
static int48(v) { return n(v, -48); }
|
||||
/**
|
||||
* Return a new ``int56`` type for %%v%%.
|
||||
*/
|
||||
static int56(v) { return n(v, -56); }
|
||||
/**
|
||||
* Return a new ``int64`` type for %%v%%.
|
||||
*/
|
||||
static int64(v) { return n(v, -64); }
|
||||
/**
|
||||
* Return a new ``int72`` type for %%v%%.
|
||||
*/
|
||||
static int72(v) { return n(v, -72); }
|
||||
/**
|
||||
* Return a new ``int80`` type for %%v%%.
|
||||
*/
|
||||
static int80(v) { return n(v, -80); }
|
||||
/**
|
||||
* Return a new ``int88`` type for %%v%%.
|
||||
*/
|
||||
static int88(v) { return n(v, -88); }
|
||||
/**
|
||||
* Return a new ``int96`` type for %%v%%.
|
||||
*/
|
||||
static int96(v) { return n(v, -96); }
|
||||
/**
|
||||
* Return a new ``int104`` type for %%v%%.
|
||||
*/
|
||||
static int104(v) { return n(v, -104); }
|
||||
/**
|
||||
* Return a new ``int112`` type for %%v%%.
|
||||
*/
|
||||
static int112(v) { return n(v, -112); }
|
||||
/**
|
||||
* Return a new ``int120`` type for %%v%%.
|
||||
*/
|
||||
static int120(v) { return n(v, -120); }
|
||||
/**
|
||||
* Return a new ``int128`` type for %%v%%.
|
||||
*/
|
||||
static int128(v) { return n(v, -128); }
|
||||
/**
|
||||
* Return a new ``int136`` type for %%v%%.
|
||||
*/
|
||||
static int136(v) { return n(v, -136); }
|
||||
/**
|
||||
* Return a new ``int144`` type for %%v%%.
|
||||
*/
|
||||
static int144(v) { return n(v, -144); }
|
||||
/**
|
||||
* Return a new ``int52`` type for %%v%%.
|
||||
*/
|
||||
static int152(v) { return n(v, -152); }
|
||||
/**
|
||||
* Return a new ``int160`` type for %%v%%.
|
||||
*/
|
||||
static int160(v) { return n(v, -160); }
|
||||
/**
|
||||
* Return a new ``int168`` type for %%v%%.
|
||||
*/
|
||||
static int168(v) { return n(v, -168); }
|
||||
/**
|
||||
* Return a new ``int176`` type for %%v%%.
|
||||
*/
|
||||
static int176(v) { return n(v, -176); }
|
||||
/**
|
||||
* Return a new ``int184`` type for %%v%%.
|
||||
*/
|
||||
static int184(v) { return n(v, -184); }
|
||||
/**
|
||||
* Return a new ``int92`` type for %%v%%.
|
||||
*/
|
||||
static int192(v) { return n(v, -192); }
|
||||
/**
|
||||
* Return a new ``int200`` type for %%v%%.
|
||||
*/
|
||||
static int200(v) { return n(v, -200); }
|
||||
/**
|
||||
* Return a new ``int208`` type for %%v%%.
|
||||
*/
|
||||
static int208(v) { return n(v, -208); }
|
||||
/**
|
||||
* Return a new ``int216`` type for %%v%%.
|
||||
*/
|
||||
static int216(v) { return n(v, -216); }
|
||||
/**
|
||||
* Return a new ``int224`` type for %%v%%.
|
||||
*/
|
||||
static int224(v) { return n(v, -224); }
|
||||
/**
|
||||
* Return a new ``int232`` type for %%v%%.
|
||||
*/
|
||||
static int232(v) { return n(v, -232); }
|
||||
/**
|
||||
* Return a new ``int240`` type for %%v%%.
|
||||
*/
|
||||
static int240(v) { return n(v, -240); }
|
||||
/**
|
||||
* Return a new ``int248`` type for %%v%%.
|
||||
*/
|
||||
static int248(v) { return n(v, -248); }
|
||||
/**
|
||||
* Return a new ``int256`` type for %%v%%.
|
||||
*/
|
||||
static int256(v) { return n(v, -256); }
|
||||
/**
|
||||
* Return a new ``int256`` type for %%v%%.
|
||||
*/
|
||||
static int(v) { return n(v, -256); }
|
||||
/**
|
||||
* Return a new ``bytes1`` type for %%v%%.
|
||||
*/
|
||||
static bytes1(v) { return b(v, 1); }
|
||||
/**
|
||||
* Return a new ``bytes2`` type for %%v%%.
|
||||
*/
|
||||
static bytes2(v) { return b(v, 2); }
|
||||
/**
|
||||
* Return a new ``bytes3`` type for %%v%%.
|
||||
*/
|
||||
static bytes3(v) { return b(v, 3); }
|
||||
/**
|
||||
* Return a new ``bytes4`` type for %%v%%.
|
||||
*/
|
||||
static bytes4(v) { return b(v, 4); }
|
||||
/**
|
||||
* Return a new ``bytes5`` type for %%v%%.
|
||||
*/
|
||||
static bytes5(v) { return b(v, 5); }
|
||||
/**
|
||||
* Return a new ``bytes6`` type for %%v%%.
|
||||
*/
|
||||
static bytes6(v) { return b(v, 6); }
|
||||
/**
|
||||
* Return a new ``bytes7`` type for %%v%%.
|
||||
*/
|
||||
static bytes7(v) { return b(v, 7); }
|
||||
/**
|
||||
* Return a new ``bytes8`` type for %%v%%.
|
||||
*/
|
||||
static bytes8(v) { return b(v, 8); }
|
||||
/**
|
||||
* Return a new ``bytes9`` type for %%v%%.
|
||||
*/
|
||||
static bytes9(v) { return b(v, 9); }
|
||||
/**
|
||||
* Return a new ``bytes10`` type for %%v%%.
|
||||
*/
|
||||
static bytes10(v) { return b(v, 10); }
|
||||
/**
|
||||
* Return a new ``bytes11`` type for %%v%%.
|
||||
*/
|
||||
static bytes11(v) { return b(v, 11); }
|
||||
/**
|
||||
* Return a new ``bytes12`` type for %%v%%.
|
||||
*/
|
||||
static bytes12(v) { return b(v, 12); }
|
||||
/**
|
||||
* Return a new ``bytes13`` type for %%v%%.
|
||||
*/
|
||||
static bytes13(v) { return b(v, 13); }
|
||||
/**
|
||||
* Return a new ``bytes14`` type for %%v%%.
|
||||
*/
|
||||
static bytes14(v) { return b(v, 14); }
|
||||
/**
|
||||
* Return a new ``bytes15`` type for %%v%%.
|
||||
*/
|
||||
static bytes15(v) { return b(v, 15); }
|
||||
/**
|
||||
* Return a new ``bytes16`` type for %%v%%.
|
||||
*/
|
||||
static bytes16(v) { return b(v, 16); }
|
||||
/**
|
||||
* Return a new ``bytes17`` type for %%v%%.
|
||||
*/
|
||||
static bytes17(v) { return b(v, 17); }
|
||||
/**
|
||||
* Return a new ``bytes18`` type for %%v%%.
|
||||
*/
|
||||
static bytes18(v) { return b(v, 18); }
|
||||
/**
|
||||
* Return a new ``bytes19`` type for %%v%%.
|
||||
*/
|
||||
static bytes19(v) { return b(v, 19); }
|
||||
/**
|
||||
* Return a new ``bytes20`` type for %%v%%.
|
||||
*/
|
||||
static bytes20(v) { return b(v, 20); }
|
||||
/**
|
||||
* Return a new ``bytes21`` type for %%v%%.
|
||||
*/
|
||||
static bytes21(v) { return b(v, 21); }
|
||||
/**
|
||||
* Return a new ``bytes22`` type for %%v%%.
|
||||
*/
|
||||
static bytes22(v) { return b(v, 22); }
|
||||
/**
|
||||
* Return a new ``bytes23`` type for %%v%%.
|
||||
*/
|
||||
static bytes23(v) { return b(v, 23); }
|
||||
/**
|
||||
* Return a new ``bytes24`` type for %%v%%.
|
||||
*/
|
||||
static bytes24(v) { return b(v, 24); }
|
||||
/**
|
||||
* Return a new ``bytes25`` type for %%v%%.
|
||||
*/
|
||||
static bytes25(v) { return b(v, 25); }
|
||||
/**
|
||||
* Return a new ``bytes26`` type for %%v%%.
|
||||
*/
|
||||
static bytes26(v) { return b(v, 26); }
|
||||
/**
|
||||
* Return a new ``bytes27`` type for %%v%%.
|
||||
*/
|
||||
static bytes27(v) { return b(v, 27); }
|
||||
/**
|
||||
* Return a new ``bytes28`` type for %%v%%.
|
||||
*/
|
||||
static bytes28(v) { return b(v, 28); }
|
||||
/**
|
||||
* Return a new ``bytes29`` type for %%v%%.
|
||||
*/
|
||||
static bytes29(v) { return b(v, 29); }
|
||||
/**
|
||||
* Return a new ``bytes30`` type for %%v%%.
|
||||
*/
|
||||
static bytes30(v) { return b(v, 30); }
|
||||
/**
|
||||
* Return a new ``bytes31`` type for %%v%%.
|
||||
*/
|
||||
static bytes31(v) { return b(v, 31); }
|
||||
/**
|
||||
* Return a new ``bytes32`` type for %%v%%.
|
||||
*/
|
||||
static bytes32(v) { return b(v, 32); }
|
||||
/**
|
||||
* Return a new ``address`` type for %%v%%.
|
||||
*/
|
||||
static address(v) { return new Typed(_gaurd, "address", v); }
|
||||
/**
|
||||
* Return a new ``bool`` type for %%v%%.
|
||||
*/
|
||||
static bool(v) { return new Typed(_gaurd, "bool", !!v); }
|
||||
/**
|
||||
* Return a new ``bytes`` type for %%v%%.
|
||||
*/
|
||||
static bytes(v) { return new Typed(_gaurd, "bytes", v); }
|
||||
/**
|
||||
* Return a new ``string`` type for %%v%%.
|
||||
*/
|
||||
static string(v) { return new Typed(_gaurd, "string", v); }
|
||||
/**
|
||||
* Return a new ``array`` type for %%v%%, allowing %%dynamic%% length.
|
||||
*/
|
||||
static array(v, dynamic) {
|
||||
throw new Error("not implemented yet");
|
||||
return new Typed(_gaurd, "array", v, dynamic);
|
||||
}
|
||||
/**
|
||||
* Return a new ``tuple`` type for %%v%%, with the optional %%name%%.
|
||||
*/
|
||||
static tuple(v, name) {
|
||||
throw new Error("not implemented yet");
|
||||
return new Typed(_gaurd, "tuple", v, name);
|
||||
}
|
||||
/**
|
||||
* Return a new ``uint8`` type for %%v%%.
|
||||
*/
|
||||
static overrides(v) {
|
||||
return new Typed(_gaurd, "overrides", Object.assign({}, v));
|
||||
}
|
||||
@@ -218,7 +580,10 @@ class Typed {
|
||||
* Returns true only if %%value%% is a [[Typed]] instance.
|
||||
*/
|
||||
static isTyped(value) {
|
||||
return (value && value._typedSymbol === _typedSymbol);
|
||||
return (value
|
||||
&& typeof (value) === "object"
|
||||
&& "_typedSymbol" in value
|
||||
&& value._typedSymbol === _typedSymbol);
|
||||
}
|
||||
/**
|
||||
* If the value is a [[Typed]] instance, validates the underlying value
|
||||
|
||||
File diff suppressed because one or more lines are too long
123
lib.commonjs/contract/contract.d.ts
vendored
123
lib.commonjs/contract/contract.d.ts
vendored
@@ -16,35 +16,152 @@ export declare function copyOverrides<O extends string = "data" | "to">(arg: any
|
||||
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> {
|
||||
/**
|
||||
* The target to connect to.
|
||||
*
|
||||
* This can be an address, ENS name or any [[Addressable]], such as
|
||||
* another contract. To get the resovled address, use the ``getAddress``
|
||||
* method.
|
||||
*/
|
||||
readonly target: string | Addressable;
|
||||
/**
|
||||
* The contract Interface.
|
||||
*/
|
||||
readonly interface: Interface;
|
||||
/**
|
||||
* The connected runner. This is generally a [[Provider]] or a
|
||||
* [[Signer]], which dictates what operations are supported.
|
||||
*
|
||||
* For example, a **Contract** connected to a [[Provider]] may
|
||||
* only execute read-only operations.
|
||||
*/
|
||||
readonly runner: null | ContractRunner;
|
||||
/**
|
||||
* All the Events available on this contract.
|
||||
*/
|
||||
readonly filters: Record<string, ContractEvent>;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
readonly [internal]: any;
|
||||
/**
|
||||
* The fallback or receive function if any.
|
||||
*/
|
||||
readonly fallback: null | WrappedFallback;
|
||||
/**
|
||||
* Creates a new contract connected to %%target%% with the %%abi%% and
|
||||
* optionally connected to a %%runner%% to perform operations on behalf
|
||||
* of.
|
||||
*/
|
||||
constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse);
|
||||
/**
|
||||
* Return a new Contract instance with the same target and ABI, but
|
||||
* a different %%runner%%.
|
||||
*/
|
||||
connect(runner: null | ContractRunner): BaseContract;
|
||||
/**
|
||||
* Return a new Contract instance with the same ABI and runner, but
|
||||
* a different %%target%%.
|
||||
*/
|
||||
attach(target: string | Addressable): BaseContract;
|
||||
/**
|
||||
* Return the resolved address of this Contract.
|
||||
*/
|
||||
getAddress(): Promise<string>;
|
||||
/**
|
||||
* Return the deployed bytecode or null if no bytecode is found.
|
||||
*/
|
||||
getDeployedCode(): Promise<null | string>;
|
||||
/**
|
||||
* Resolve to this Contract once the bytecode has been deployed, or
|
||||
* resolve immediately if already deployed.
|
||||
*/
|
||||
waitForDeployment(): Promise<this>;
|
||||
/**
|
||||
* Return the transaction used to deploy this contract.
|
||||
*
|
||||
* This is only available if this instance was returned from a
|
||||
* [[ContractFactory]].
|
||||
*/
|
||||
deploymentTransaction(): null | ContractTransactionResponse;
|
||||
/**
|
||||
* Return the function for a given name. This is useful when a contract
|
||||
* method name conflicts with a JavaScript name such as ``prototype`` or
|
||||
* when using a Contract programatically.
|
||||
*/
|
||||
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
|
||||
/**
|
||||
* Return the event for a given name. This is useful when a contract
|
||||
* event name conflicts with a JavaScript name such as ``prototype`` or
|
||||
* when using a Contract programatically.
|
||||
*/
|
||||
getEvent(key: string | EventFragment): ContractEvent;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
queryTransaction(hash: string): Promise<Array<EventLog>>;
|
||||
/**
|
||||
* Provide historic access to event data for %%event%% in the range
|
||||
* %%fromBlock%% (default: ``0``) to %%toBlock%% (default: ``"latest"``)
|
||||
* inclusive.
|
||||
*/
|
||||
queryFilter(event: ContractEventName, fromBlock?: BlockTag, toBlock?: BlockTag): Promise<Array<EventLog | Log>>;
|
||||
/**
|
||||
* Add an event %%listener%% for the %%event%%.
|
||||
*/
|
||||
on(event: ContractEventName, listener: Listener): Promise<this>;
|
||||
/**
|
||||
* Add an event %%listener%% for the %%event%%, but remove the listener
|
||||
* after it is fired once.
|
||||
*/
|
||||
once(event: ContractEventName, listener: Listener): Promise<this>;
|
||||
/**
|
||||
* Emit an %%event%% calling all listeners with %%args%%.
|
||||
*
|
||||
* Resolves to ``true`` if any listeners were called.
|
||||
*/
|
||||
emit(event: ContractEventName, ...args: Array<any>): Promise<boolean>;
|
||||
/**
|
||||
* Resolves to the number of listeners of %%event%% or the total number
|
||||
* of listeners if unspecified.
|
||||
*/
|
||||
listenerCount(event?: ContractEventName): Promise<number>;
|
||||
/**
|
||||
* Resolves to the listeners subscribed to %%event%% or all listeners
|
||||
* if unspecified.
|
||||
*/
|
||||
listeners(event?: ContractEventName): Promise<Array<Listener>>;
|
||||
/**
|
||||
* Remove the %%listener%% from the listeners for %%event%% or remove
|
||||
* all listeners if unspecified.
|
||||
*/
|
||||
off(event: ContractEventName, listener?: Listener): Promise<this>;
|
||||
/**
|
||||
* Remove all the listeners for %%event%% or remove all listeners if
|
||||
* unspecified.
|
||||
*/
|
||||
removeAllListeners(event?: ContractEventName): Promise<this>;
|
||||
/**
|
||||
* Alias for [on].
|
||||
*/
|
||||
addListener(event: ContractEventName, listener: Listener): Promise<this>;
|
||||
/**
|
||||
* Alias for [off].
|
||||
*/
|
||||
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>;
|
||||
/**
|
||||
* Create a new Class for the %%abi%%.
|
||||
*/
|
||||
static buildClass<T = ContractInterface>(abi: Interface | InterfaceAbi): new (target: string, runner?: null | ContractRunner) => BaseContract & Omit<T, keyof BaseContract>;
|
||||
/**
|
||||
* Create a new BaseContract with a specified Interface.
|
||||
*/
|
||||
static from<T = ContractInterface>(target: string, abi: Interface | 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>;
|
||||
declare const Contract_base: new (target: string, abi: Interface | InterfaceAbi, runner?: ContractRunner | null | undefined) => BaseContract & Omit<ContractInterface, keyof BaseContract>;
|
||||
/**
|
||||
* A [[BaseContract]] with no type guards on its methods or events.
|
||||
*/
|
||||
export declare class Contract extends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GAAG,OAAO,CAAC,IAAI,CAAC;IAIjF;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,EAAE,SAAS,GAAG,YAAY,GAAG,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,cAAc,KAAK,YAAY,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC;IAS3K;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,YAAY,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,cAAc,GAAG,YAAY,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC;CAKhK;;AAMD;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAAe;CAAI"}
|
||||
@@ -21,6 +21,17 @@ function canResolve(value) {
|
||||
function canSend(value) {
|
||||
return (value && typeof (value.sendTransaction) === "function");
|
||||
}
|
||||
function getResolver(value) {
|
||||
if (value != null) {
|
||||
if (canResolve(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.provider) {
|
||||
return value.provider;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
class PreparedTopicFilter {
|
||||
#filter;
|
||||
fragment;
|
||||
@@ -40,6 +51,9 @@ class PreparedTopicFilter {
|
||||
}
|
||||
return param.walkAsync(args[index], (type, value) => {
|
||||
if (type === "address") {
|
||||
if (Array.isArray(value)) {
|
||||
return Promise.all(value.map((v) => (0, index_js_2.resolveAddress)(v, resolver)));
|
||||
}
|
||||
return (0, index_js_2.resolveAddress)(value, resolver);
|
||||
}
|
||||
return value;
|
||||
@@ -80,13 +94,16 @@ function getProvider(value) {
|
||||
* @_ignore:
|
||||
*/
|
||||
async function copyOverrides(arg, allowed) {
|
||||
// Make sure the overrides passed in are a valid overrides object
|
||||
const _overrides = index_js_1.Typed.dereference(arg, "overrides");
|
||||
(0, index_js_3.assertArgument)(typeof (_overrides) === "object", "invalid overrides parameter", "overrides", arg);
|
||||
// Create a shallow copy (we'll deep-ify anything needed during normalizing)
|
||||
const overrides = (0, provider_js_1.copyRequest)(index_js_1.Typed.dereference(arg, "overrides"));
|
||||
const overrides = (0, provider_js_1.copyRequest)(_overrides);
|
||||
(0, index_js_3.assertArgument)(overrides.to == null || (allowed || []).indexOf("to") >= 0, "cannot override to", "overrides.to", overrides.to);
|
||||
(0, index_js_3.assertArgument)(overrides.data == null || (allowed || []).indexOf("data") >= 0, "cannot override data", "overrides.data", overrides.data);
|
||||
// Resolve any from
|
||||
if (overrides.from) {
|
||||
overrides.from = await (0, index_js_2.resolveAddress)(overrides.from);
|
||||
overrides.from = overrides.from;
|
||||
}
|
||||
return overrides;
|
||||
}
|
||||
@@ -114,8 +131,11 @@ function buildWrappedFallback(contract) {
|
||||
// If an overrides was passed in, copy it and normalize the values
|
||||
const tx = (await copyOverrides(overrides, ["data"]));
|
||||
tx.to = await contract.getAddress();
|
||||
if (tx.from) {
|
||||
tx.from = await (0, index_js_2.resolveAddress)(tx.from, getResolver(contract.runner));
|
||||
}
|
||||
const iface = contract.interface;
|
||||
const noValue = ((tx.value || BN_0) === BN_0);
|
||||
const noValue = ((0, index_js_3.getBigInt)((tx.value || BN_0), "overrides.value") === BN_0);
|
||||
const noData = ((tx.data || "0x") === "0x");
|
||||
if (iface.fallback && !iface.fallback.payable && iface.receive && !noData && !noValue) {
|
||||
(0, index_js_3.assertArgument)(false, "cannot send data to receive or send value to non-payable fallback", "overrides", overrides);
|
||||
@@ -171,7 +191,8 @@ 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"
|
||||
operation: "fragment",
|
||||
info: { key, args }
|
||||
});
|
||||
return fragment;
|
||||
};
|
||||
@@ -181,6 +202,9 @@ function buildWrappedMethod(contract, key) {
|
||||
let overrides = {};
|
||||
if (fragment.inputs.length + 1 === args.length) {
|
||||
overrides = await copyOverrides(args.pop());
|
||||
if (overrides.from) {
|
||||
overrides.from = await (0, index_js_2.resolveAddress)(overrides.from, getResolver(contract.runner));
|
||||
}
|
||||
}
|
||||
if (fragment.inputs.length !== args.length) {
|
||||
throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
|
||||
@@ -251,7 +275,8 @@ function buildWrappedMethod(contract, key) {
|
||||
get: () => {
|
||||
const fragment = contract.interface.getFunction(key);
|
||||
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
||||
operation: "fragment"
|
||||
operation: "fragment",
|
||||
info: { key }
|
||||
});
|
||||
return fragment;
|
||||
}
|
||||
@@ -262,7 +287,8 @@ 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"
|
||||
operation: "fragment",
|
||||
info: { key, args }
|
||||
});
|
||||
return fragment;
|
||||
};
|
||||
@@ -281,7 +307,8 @@ function buildWrappedEvent(contract, key) {
|
||||
get: () => {
|
||||
const fragment = contract.interface.getEvent(key);
|
||||
(0, index_js_3.assert)(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
||||
operation: "fragment"
|
||||
operation: "fragment",
|
||||
info: { key }
|
||||
});
|
||||
return fragment;
|
||||
}
|
||||
@@ -461,6 +488,10 @@ async function _emit(contract, event, args, payloadFunc) {
|
||||
catch (error) { }
|
||||
return !once;
|
||||
});
|
||||
if (sub.listeners.length === 0) {
|
||||
sub.stop();
|
||||
getInternal(contract).subs.delete(sub.tag);
|
||||
}
|
||||
return (count > 0);
|
||||
}
|
||||
async function emit(contract, event, args, payloadFunc) {
|
||||
@@ -474,12 +505,43 @@ async function emit(contract, event, args, payloadFunc) {
|
||||
}
|
||||
const passProperties = ["then"];
|
||||
class BaseContract {
|
||||
/**
|
||||
* The target to connect to.
|
||||
*
|
||||
* This can be an address, ENS name or any [[Addressable]], such as
|
||||
* another contract. To get the resovled address, use the ``getAddress``
|
||||
* method.
|
||||
*/
|
||||
target;
|
||||
/**
|
||||
* The contract Interface.
|
||||
*/
|
||||
interface;
|
||||
/**
|
||||
* The connected runner. This is generally a [[Provider]] or a
|
||||
* [[Signer]], which dictates what operations are supported.
|
||||
*
|
||||
* For example, a **Contract** connected to a [[Provider]] may
|
||||
* only execute read-only operations.
|
||||
*/
|
||||
runner;
|
||||
/**
|
||||
* All the Events available on this contract.
|
||||
*/
|
||||
filters;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
[internal];
|
||||
/**
|
||||
* The fallback or receive function if any.
|
||||
*/
|
||||
fallback;
|
||||
/**
|
||||
* Creates a new contract connected to %%target%% with the %%abi%% and
|
||||
* optionally connected to a %%runner%% to perform operations on behalf
|
||||
* of.
|
||||
*/
|
||||
constructor(target, abi, runner, _deployTx) {
|
||||
(0, index_js_3.assertArgument)(typeof (target) === "string" || (0, index_js_2.isAddressable)(target), "invalid value for Contract target", "target", target);
|
||||
if (runner == null) {
|
||||
@@ -513,7 +575,9 @@ class BaseContract {
|
||||
}
|
||||
addrPromise = resolver.resolveName(target).then((addr) => {
|
||||
if (addr == null) {
|
||||
throw new Error("TODO");
|
||||
throw (0, index_js_3.makeError)("an ENS name used for a contract target must be correctly configured", "UNCONFIGURED_NAME", {
|
||||
value: target
|
||||
});
|
||||
}
|
||||
getInternal(this).addr = addr;
|
||||
return addr;
|
||||
@@ -533,17 +597,20 @@ class BaseContract {
|
||||
setInternal(this, { addrPromise, addr, deployTx, subs });
|
||||
// Add the event filters
|
||||
const filters = new Proxy({}, {
|
||||
get: (target, _prop, receiver) => {
|
||||
get: (target, prop, receiver) => {
|
||||
// Pass important checks (like `then` for Promise) through
|
||||
if (passProperties.indexOf(_prop) >= 0) {
|
||||
return Reflect.get(target, _prop, receiver);
|
||||
if (typeof (prop) === "symbol" || passProperties.indexOf(prop) >= 0) {
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
const prop = String(_prop);
|
||||
const result = this.getEvent(prop);
|
||||
if (result) {
|
||||
return result;
|
||||
try {
|
||||
return this.getEvent(prop);
|
||||
}
|
||||
throw new Error(`unknown contract event: ${prop}`);
|
||||
catch (error) {
|
||||
if (!(0, index_js_3.isError)(error, "INVALID_ARGUMENT") || error.argument !== "key") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
has: (target, prop) => {
|
||||
// Pass important checks (like `then` for Promise) through
|
||||
@@ -559,29 +626,50 @@ class BaseContract {
|
||||
});
|
||||
// Return a Proxy that will respond to functions
|
||||
return new Proxy(this, {
|
||||
get: (target, _prop, receiver) => {
|
||||
if (_prop in target || passProperties.indexOf(_prop) >= 0) {
|
||||
return Reflect.get(target, _prop, receiver);
|
||||
get: (target, prop, receiver) => {
|
||||
if (typeof (prop) === "symbol" || prop in target || passProperties.indexOf(prop) >= 0) {
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
const prop = String(_prop);
|
||||
const result = target.getFunction(prop);
|
||||
if (result) {
|
||||
return result;
|
||||
// Undefined properties should return undefined
|
||||
try {
|
||||
return target.getFunction(prop);
|
||||
}
|
||||
throw new Error(`unknown contract method: ${prop}`);
|
||||
catch (error) {
|
||||
if (!(0, index_js_3.isError)(error, "INVALID_ARGUMENT") || error.argument !== "key") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
has: (target, prop) => {
|
||||
if (prop in target || passProperties.indexOf(prop) >= 0) {
|
||||
if (typeof (prop) === "symbol" || prop in target || passProperties.indexOf(prop) >= 0) {
|
||||
return Reflect.has(target, prop);
|
||||
}
|
||||
return target.interface.hasFunction(String(prop));
|
||||
return target.interface.hasFunction(prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Return a new Contract instance with the same target and ABI, but
|
||||
* a different %%runner%%.
|
||||
*/
|
||||
connect(runner) {
|
||||
return new BaseContract(this.target, this.interface, runner);
|
||||
}
|
||||
/**
|
||||
* Return a new Contract instance with the same ABI and runner, but
|
||||
* a different %%target%%.
|
||||
*/
|
||||
attach(target) {
|
||||
return new BaseContract(target, this.interface, this.runner);
|
||||
}
|
||||
/**
|
||||
* Return the resolved address of this Contract.
|
||||
*/
|
||||
async getAddress() { return await getInternal(this).addrPromise; }
|
||||
/**
|
||||
* Return the deployed bytecode or null if no bytecode is found.
|
||||
*/
|
||||
async getDeployedCode() {
|
||||
const provider = getProvider(this.runner);
|
||||
(0, index_js_3.assert)(provider, "runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "getDeployedCode" });
|
||||
@@ -591,6 +679,10 @@ class BaseContract {
|
||||
}
|
||||
return code;
|
||||
}
|
||||
/**
|
||||
* Resolve to this Contract once the bytecode has been deployed, or
|
||||
* resolve immediately if already deployed.
|
||||
*/
|
||||
async waitForDeployment() {
|
||||
// We have the deployement transaction; just use that (throws if deployement fails)
|
||||
const deployTx = this.deploymentTransaction();
|
||||
@@ -622,9 +714,20 @@ class BaseContract {
|
||||
checkCode();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Return the transaction used to deploy this contract.
|
||||
*
|
||||
* This is only available if this instance was returned from a
|
||||
* [[ContractFactory]].
|
||||
*/
|
||||
deploymentTransaction() {
|
||||
return getInternal(this).deployTx;
|
||||
}
|
||||
/**
|
||||
* Return the function for a given name. This is useful when a contract
|
||||
* method name conflicts with a JavaScript name such as ``prototype`` or
|
||||
* when using a Contract programatically.
|
||||
*/
|
||||
getFunction(key) {
|
||||
if (typeof (key) !== "string") {
|
||||
key = key.format();
|
||||
@@ -632,16 +735,43 @@ class BaseContract {
|
||||
const func = buildWrappedMethod(this, key);
|
||||
return func;
|
||||
}
|
||||
/**
|
||||
* Return the event for a given name. This is useful when a contract
|
||||
* event name conflicts with a JavaScript name such as ``prototype`` or
|
||||
* when using a Contract programatically.
|
||||
*/
|
||||
getEvent(key) {
|
||||
if (typeof (key) !== "string") {
|
||||
key = key.format();
|
||||
}
|
||||
return buildWrappedEvent(this, key);
|
||||
}
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
async queryTransaction(hash) {
|
||||
// Is this useful?
|
||||
throw new Error("@TODO");
|
||||
}
|
||||
/*
|
||||
// @TODO: this is a non-backwards compatible change, but will be added
|
||||
// in v7 and in a potential SmartContract class in an upcoming
|
||||
// v6 release
|
||||
async getTransactionReceipt(hash: string): Promise<null | ContractTransactionReceipt> {
|
||||
const provider = getProvider(this.runner);
|
||||
assert(provider, "contract runner does not have a provider",
|
||||
"UNSUPPORTED_OPERATION", { operation: "queryTransaction" });
|
||||
|
||||
const receipt = await provider.getTransactionReceipt(hash);
|
||||
if (receipt == null) { return null; }
|
||||
|
||||
return new ContractTransactionReceipt(this.interface, provider, receipt);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Provide historic access to event data for %%event%% in the range
|
||||
* %%fromBlock%% (default: ``0``) to %%toBlock%% (default: ``"latest"``)
|
||||
* inclusive.
|
||||
*/
|
||||
async queryFilter(event, fromBlock, toBlock) {
|
||||
if (fromBlock == null) {
|
||||
fromBlock = 0;
|
||||
@@ -664,28 +794,47 @@ class BaseContract {
|
||||
catch (error) { }
|
||||
}
|
||||
if (foundFragment) {
|
||||
return new wrappers_js_1.EventLog(log, this.interface, foundFragment);
|
||||
}
|
||||
else {
|
||||
return new provider_js_1.Log(log, provider);
|
||||
try {
|
||||
return new wrappers_js_1.EventLog(log, this.interface, foundFragment);
|
||||
}
|
||||
catch (error) {
|
||||
return new wrappers_js_1.UndecodedEventLog(log, error);
|
||||
}
|
||||
}
|
||||
return new provider_js_1.Log(log, provider);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Add an event %%listener%% for the %%event%%.
|
||||
*/
|
||||
async on(event, listener) {
|
||||
const sub = await getSub(this, "on", event);
|
||||
sub.listeners.push({ listener, once: false });
|
||||
sub.start();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Add an event %%listener%% for the %%event%%, but remove the listener
|
||||
* after it is fired once.
|
||||
*/
|
||||
async once(event, listener) {
|
||||
const sub = await getSub(this, "once", event);
|
||||
sub.listeners.push({ listener, once: true });
|
||||
sub.start();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Emit an %%event%% calling all listeners with %%args%%.
|
||||
*
|
||||
* Resolves to ``true`` if any listeners were called.
|
||||
*/
|
||||
async emit(event, ...args) {
|
||||
return await emit(this, event, args, null);
|
||||
}
|
||||
/**
|
||||
* Resolves to the number of listeners of %%event%% or the total number
|
||||
* of listeners if unspecified.
|
||||
*/
|
||||
async listenerCount(event) {
|
||||
if (event) {
|
||||
const sub = await hasSub(this, event);
|
||||
@@ -701,6 +850,10 @@ class BaseContract {
|
||||
}
|
||||
return total;
|
||||
}
|
||||
/**
|
||||
* Resolves to the listeners subscribed to %%event%% or all listeners
|
||||
* if unspecified.
|
||||
*/
|
||||
async listeners(event) {
|
||||
if (event) {
|
||||
const sub = await hasSub(this, event);
|
||||
@@ -716,6 +869,10 @@ class BaseContract {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Remove the %%listener%% from the listeners for %%event%% or remove
|
||||
* all listeners if unspecified.
|
||||
*/
|
||||
async off(event, listener) {
|
||||
const sub = await hasSub(this, event);
|
||||
if (!sub) {
|
||||
@@ -733,6 +890,10 @@ class BaseContract {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Remove all the listeners for %%event%% or remove all listeners if
|
||||
* unspecified.
|
||||
*/
|
||||
async removeAllListeners(event) {
|
||||
if (event) {
|
||||
const sub = await hasSub(this, event);
|
||||
@@ -751,14 +912,21 @@ class BaseContract {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
// Alias for "on"
|
||||
/**
|
||||
* Alias for [on].
|
||||
*/
|
||||
async addListener(event, listener) {
|
||||
return await this.on(event, listener);
|
||||
}
|
||||
// Alias for "off"
|
||||
/**
|
||||
* Alias for [off].
|
||||
*/
|
||||
async removeListener(event, listener) {
|
||||
return await this.off(event, listener);
|
||||
}
|
||||
/**
|
||||
* Create a new Class for the %%abi%%.
|
||||
*/
|
||||
static buildClass(abi) {
|
||||
class CustomContract extends BaseContract {
|
||||
constructor(address, runner = null) {
|
||||
@@ -768,6 +936,9 @@ class BaseContract {
|
||||
return CustomContract;
|
||||
}
|
||||
;
|
||||
/**
|
||||
* Create a new BaseContract with a specified Interface.
|
||||
*/
|
||||
static from(target, abi, runner) {
|
||||
if (runner == null) {
|
||||
runner = null;
|
||||
@@ -780,6 +951,9 @@ exports.BaseContract = BaseContract;
|
||||
function _ContractBase() {
|
||||
return BaseContract;
|
||||
}
|
||||
/**
|
||||
* A [[BaseContract]] with no type guards on its methods or events.
|
||||
*/
|
||||
class Contract extends _ContractBase() {
|
||||
}
|
||||
exports.Contract = Contract;
|
||||
|
||||
File diff suppressed because one or more lines are too long
40
lib.commonjs/contract/factory.d.ts
vendored
40
lib.commonjs/contract/factory.d.ts
vendored
@@ -1,22 +1,62 @@
|
||||
import { Interface } from "../abi/index.js";
|
||||
import { BaseContract } from "./contract.js";
|
||||
import type { InterfaceAbi } from "../abi/index.js";
|
||||
import type { Addressable } from "../address/index.js";
|
||||
import type { ContractRunner } from "../providers/index.js";
|
||||
import type { BytesLike } from "../utils/index.js";
|
||||
import type { ContractInterface, ContractMethodArgs, ContractDeployTransaction } from "./types.js";
|
||||
import type { ContractTransactionResponse } from "./wrappers.js";
|
||||
/**
|
||||
* A **ContractFactory** is used to deploy a Contract to the blockchain.
|
||||
*/
|
||||
export declare class ContractFactory<A extends Array<any> = Array<any>, I = BaseContract> {
|
||||
/**
|
||||
* The Contract Interface.
|
||||
*/
|
||||
readonly interface: Interface;
|
||||
/**
|
||||
* The Contract deployment bytecode. Often called the initcode.
|
||||
*/
|
||||
readonly bytecode: string;
|
||||
/**
|
||||
* The ContractRunner to deploy the Contract as.
|
||||
*/
|
||||
readonly runner: null | ContractRunner;
|
||||
/**
|
||||
* Create a new **ContractFactory** with %%abi%% and %%bytecode%%,
|
||||
* optionally connected to %%runner%%.
|
||||
*
|
||||
* The %%bytecode%% may be the ``bytecode`` property within the
|
||||
* standard Solidity JSON output.
|
||||
*/
|
||||
constructor(abi: Interface | InterfaceAbi, bytecode: BytesLike | {
|
||||
object: string;
|
||||
}, runner?: null | ContractRunner);
|
||||
attach(target: string | Addressable): BaseContract & Omit<I, keyof BaseContract>;
|
||||
/**
|
||||
* Resolves to the transaction to deploy the contract, passing %%args%%
|
||||
* into the constructor.
|
||||
*/
|
||||
getDeployTransaction(...args: ContractMethodArgs<A>): Promise<ContractDeployTransaction>;
|
||||
/**
|
||||
* Resolves to the Contract deployed by passing %%args%% into the
|
||||
* constructor.
|
||||
*
|
||||
* This will resovle to the Contract before it has been deployed to the
|
||||
* network, so the [[BaseContract-waitForDeployment]] should be used before
|
||||
* sending any transactions to it.
|
||||
*/
|
||||
deploy(...args: ContractMethodArgs<A>): Promise<BaseContract & {
|
||||
deploymentTransaction(): ContractTransactionResponse;
|
||||
} & Omit<I, keyof BaseContract>>;
|
||||
/**
|
||||
* Return a new **ContractFactory** with the same ABI and bytecode,
|
||||
* but connected to %%runner%%.
|
||||
*/
|
||||
connect(runner: null | ContractRunner): ContractFactory<A, I>;
|
||||
/**
|
||||
* Create a new **ContractFactory** from the standard Solidity JSON output.
|
||||
*/
|
||||
static fromSolidity<A extends Array<any> = Array<any>, I = ContractInterface>(output: any, runner?: ContractRunner): ContractFactory<A, I>;
|
||||
}
|
||||
//# sourceMappingURL=factory.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src.ts/contract/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAO5C,OAAO,EAAE,YAAY,EAA8B,MAAM,eAAe,CAAC;AAEzE,OAA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hF;;;OAGG;IACG,oBAAoB,CAAC,GAAG,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAmB9F;;;;;;;OAOG;IACG,MAAM,CAAC,GAAG,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,GAAG;QAAE,qBAAqB,IAAI,2BAA2B,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC;IAY5J;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,IAAI,GAAG,cAAc,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAI7D;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,iBAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;CAgB7I"}
|
||||
@@ -7,10 +7,29 @@ const index_js_3 = require("../utils/index.js");
|
||||
const contract_js_1 = require("./contract.js");
|
||||
// A = Arguments to the constructor
|
||||
// I = Interface of deployed contracts
|
||||
/**
|
||||
* A **ContractFactory** is used to deploy a Contract to the blockchain.
|
||||
*/
|
||||
class ContractFactory {
|
||||
/**
|
||||
* The Contract Interface.
|
||||
*/
|
||||
interface;
|
||||
/**
|
||||
* The Contract deployment bytecode. Often called the initcode.
|
||||
*/
|
||||
bytecode;
|
||||
/**
|
||||
* The ContractRunner to deploy the Contract as.
|
||||
*/
|
||||
runner;
|
||||
/**
|
||||
* Create a new **ContractFactory** with %%abi%% and %%bytecode%%,
|
||||
* optionally connected to %%runner%%.
|
||||
*
|
||||
* The %%bytecode%% may be the ``bytecode`` property within the
|
||||
* standard Solidity JSON output.
|
||||
*/
|
||||
constructor(abi, bytecode, runner) {
|
||||
const iface = index_js_1.Interface.from(abi);
|
||||
// Dereference Solidity bytecode objects and allow a missing `0x`-prefix
|
||||
@@ -30,6 +49,13 @@ class ContractFactory {
|
||||
bytecode, interface: iface, runner: (runner || null)
|
||||
});
|
||||
}
|
||||
attach(target) {
|
||||
return new contract_js_1.BaseContract(target, this.interface, this.runner);
|
||||
}
|
||||
/**
|
||||
* Resolves to the transaction to deploy the contract, passing %%args%%
|
||||
* into the constructor.
|
||||
*/
|
||||
async getDeployTransaction(...args) {
|
||||
let overrides = {};
|
||||
const fragment = this.interface.deploy;
|
||||
@@ -43,6 +69,14 @@ class ContractFactory {
|
||||
const data = (0, index_js_3.concat)([this.bytecode, this.interface.encodeDeploy(resolvedArgs)]);
|
||||
return Object.assign({}, overrides, { data });
|
||||
}
|
||||
/**
|
||||
* Resolves to the Contract deployed by passing %%args%% into the
|
||||
* constructor.
|
||||
*
|
||||
* This will resovle to the Contract before it has been deployed to the
|
||||
* network, so the [[BaseContract-waitForDeployment]] should be used before
|
||||
* sending any transactions to it.
|
||||
*/
|
||||
async deploy(...args) {
|
||||
const tx = await this.getDeployTransaction(...args);
|
||||
(0, index_js_3.assert)(this.runner && typeof (this.runner.sendTransaction) === "function", "factory runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
|
||||
@@ -52,9 +86,16 @@ class ContractFactory {
|
||||
const address = (0, index_js_2.getCreateAddress)(sentTx);
|
||||
return new contract_js_1.BaseContract(address, this.interface, this.runner, sentTx);
|
||||
}
|
||||
/**
|
||||
* Return a new **ContractFactory** with the same ABI and bytecode,
|
||||
* but connected to %%runner%%.
|
||||
*/
|
||||
connect(runner) {
|
||||
return new ContractFactory(this.interface, this.bytecode, runner);
|
||||
}
|
||||
/**
|
||||
* Create a new **ContractFactory** from the standard Solidity JSON output.
|
||||
*/
|
||||
static fromSolidity(output, runner) {
|
||||
(0, index_js_3.assertArgument)(output != null, "bad compiler output", "output", output);
|
||||
if (typeof (output) === "string") {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"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AAM,CAAC,CAAC;SAAE;QAEjE,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QAEvB,IAAI,QAAQ,GAAG,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SAC9B;aAAM,IAAI,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC1C,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;SAClC;QAED,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;CACJ;AAnHD,0CAmHC"}
|
||||
7
lib.commonjs/contract/index.d.ts
vendored
7
lib.commonjs/contract/index.d.ts
vendored
@@ -1,10 +1,13 @@
|
||||
/**
|
||||
* About contracts...
|
||||
* A **Contract** object is a meta-class (a class whose definition is
|
||||
* defined at runtime), which communicates with a deployed smart contract
|
||||
* on the blockchain and provides a simple JavaScript interface to call
|
||||
* methods, send transaction, query historic logs and listen for its events.
|
||||
*
|
||||
* @_section: api/contract:Contracts [about-contracts]
|
||||
*/
|
||||
export { BaseContract, Contract } from "./contract.js";
|
||||
export { ContractFactory } from "./factory.js";
|
||||
export { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./wrappers.js";
|
||||
export { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, UndecodedEventLog } from "./wrappers.js";
|
||||
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, WrappedFallback } from "./types.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/contract/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACH,YAAY,EAAE,QAAQ,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,eAAe,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,oBAAoB,EAAE,2BAA2B,EACjD,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,GACX,MAAM,eAAe,CAAC;AAEvB,YAAY,EACR,kBAAkB,EAAE,sBAAsB,EAC1C,gBAAgB,EAChB,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EACnD,yBAAyB,EACzB,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAC1E,mBAAmB,EAAE,SAAS,EAC9B,eAAe,EAClB,MAAM,YAAY,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/contract/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACH,YAAY,EAAE,QAAQ,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,eAAe,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACH,oBAAoB,EAAE,2BAA2B,EACjD,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,EAAE,iBAAiB,EAC9B,MAAM,eAAe,CAAC;AAEvB,YAAY,EACR,kBAAkB,EAAE,sBAAsB,EAC1C,gBAAgB,EAChB,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EACnD,yBAAyB,EACzB,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAC1E,mBAAmB,EAAE,SAAS,EAC9B,eAAe,EAClB,MAAM,YAAY,CAAC"}
|
||||
@@ -1,8 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EventLog = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.ContractUnknownEventPayload = exports.ContractEventPayload = exports.ContractFactory = exports.Contract = exports.BaseContract = void 0;
|
||||
exports.UndecodedEventLog = exports.EventLog = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.ContractUnknownEventPayload = exports.ContractEventPayload = exports.ContractFactory = exports.Contract = exports.BaseContract = void 0;
|
||||
/**
|
||||
* About contracts...
|
||||
* A **Contract** object is a meta-class (a class whose definition is
|
||||
* defined at runtime), which communicates with a deployed smart contract
|
||||
* on the blockchain and provides a simple JavaScript interface to call
|
||||
* methods, send transaction, query historic logs and listen for its events.
|
||||
*
|
||||
* @_section: api/contract:Contracts [about-contracts]
|
||||
*/
|
||||
@@ -17,4 +20,5 @@ Object.defineProperty(exports, "ContractUnknownEventPayload", { enumerable: true
|
||||
Object.defineProperty(exports, "ContractTransactionReceipt", { enumerable: true, get: function () { return wrappers_js_1.ContractTransactionReceipt; } });
|
||||
Object.defineProperty(exports, "ContractTransactionResponse", { enumerable: true, get: function () { return wrappers_js_1.ContractTransactionResponse; } });
|
||||
Object.defineProperty(exports, "EventLog", { enumerable: true, get: function () { return wrappers_js_1.EventLog; } });
|
||||
Object.defineProperty(exports, "UndecodedEventLog", { enumerable: true, get: function () { return wrappers_js_1.UndecodedEventLog; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/contract/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,6CAEuB;AADnB,2GAAA,YAAY,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAG1B,2CAEsB;AADlB,6GAAA,eAAe,OAAA;AAGnB,6CAIuB;AAHnB,mHAAA,oBAAoB,OAAA;AAAE,0HAAA,2BAA2B,OAAA;AACjD,yHAAA,0BAA0B,OAAA;AAAE,0HAAA,2BAA2B,OAAA;AACvD,uGAAA,QAAQ,OAAA"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/contract/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,6CAEuB;AADnB,2GAAA,YAAY,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAG1B,2CAEsB;AADlB,6GAAA,eAAe,OAAA;AAGnB,6CAIuB;AAHnB,mHAAA,oBAAoB,OAAA;AAAE,0HAAA,2BAA2B,OAAA;AACjD,yHAAA,0BAA0B,OAAA;AAAE,0HAAA,2BAA2B,OAAA;AACvD,uGAAA,QAAQ,OAAA;AAAE,gHAAA,iBAAiB,OAAA"}
|
||||
137
lib.commonjs/contract/types.d.ts
vendored
137
lib.commonjs/contract/types.d.ts
vendored
@@ -1,56 +1,193 @@
|
||||
import type { EventFragment, FunctionFragment, Result, Typed } from "../abi/index.js";
|
||||
import type { TransactionRequest, PreparedTransactionRequest, TopicFilter } from "../providers/index.js";
|
||||
import type { ContractTransactionResponse } from "./wrappers.js";
|
||||
/**
|
||||
* The name for an event used for subscribing to Contract events.
|
||||
*
|
||||
* **``string``** - An event by name. The event must be non-ambiguous.
|
||||
* The parameters will be dereferenced when passed into the listener.
|
||||
*
|
||||
* [[ContractEvent]] - A filter from the ``contract.filters``, which will
|
||||
* pass only the EventPayload as a single parameter, which includes a
|
||||
* ``.signature`` property that can be used to further filter the event.
|
||||
*
|
||||
* [[TopicFilter]] - A filter defined using the standard Ethereum API
|
||||
* which provides the specific topic hash or topic hashes to watch for along
|
||||
* with any additional values to filter by. This will only pass a single
|
||||
* parameter to the listener, the EventPayload which will include additional
|
||||
* details to refine by, such as the event name and signature.
|
||||
*
|
||||
* [[DeferredTopicFilter]] - A filter created by calling a [[ContractEvent]]
|
||||
* with parameters, which will create a filter for a specific event
|
||||
* signautre and dereference each parameter when calling the listener.
|
||||
*/
|
||||
export type ContractEventName = string | ContractEvent | TopicFilter | DeferredTopicFilter;
|
||||
/**
|
||||
* A Contract with no method constraints.
|
||||
*/
|
||||
export interface ContractInterface {
|
||||
[name: string]: BaseContractMethod;
|
||||
}
|
||||
/**
|
||||
* When creating a filter using the ``contract.filters``, this is returned.
|
||||
*/
|
||||
export interface DeferredTopicFilter {
|
||||
getTopicFilter(): Promise<TopicFilter>;
|
||||
fragment: EventFragment;
|
||||
}
|
||||
/**
|
||||
* When populating a transaction this type is returned.
|
||||
*/
|
||||
export interface ContractTransaction extends PreparedTransactionRequest {
|
||||
/**
|
||||
* The target address.
|
||||
*/
|
||||
to: string;
|
||||
/**
|
||||
* The transaction data.
|
||||
*/
|
||||
data: string;
|
||||
/**
|
||||
* The from address, if any.
|
||||
*/
|
||||
from?: string;
|
||||
}
|
||||
/**
|
||||
* A deployment transaction for a contract.
|
||||
*/
|
||||
export interface ContractDeployTransaction extends Omit<ContractTransaction, "to"> {
|
||||
}
|
||||
/**
|
||||
* The overrides for a contract transaction.
|
||||
*/
|
||||
export interface Overrides extends Omit<TransactionRequest, "to" | "data"> {
|
||||
}
|
||||
/**
|
||||
* Arguments to a Contract method can always include an additional and
|
||||
* optional overrides parameter.
|
||||
*
|
||||
* @_ignore:
|
||||
*/
|
||||
export type PostfixOverrides<A extends Array<any>> = A | [...A, Overrides];
|
||||
/**
|
||||
* Arguments to a Contract method can always include an additional and
|
||||
* optional overrides parameter, and each parameter can optionally be
|
||||
* [[Typed]].
|
||||
*
|
||||
* @_ignore:
|
||||
*/
|
||||
export type ContractMethodArgs<A extends Array<any>> = PostfixOverrides<{
|
||||
[I in keyof A]-?: A[I] | Typed;
|
||||
}>;
|
||||
/**
|
||||
* A Contract method can be called directly, or used in various ways.
|
||||
*/
|
||||
export interface BaseContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> {
|
||||
(...args: ContractMethodArgs<A>): Promise<D>;
|
||||
/**
|
||||
* The name of the Contract method.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The fragment of the Contract method. This will throw on ambiguous
|
||||
* method names.
|
||||
*/
|
||||
fragment: FunctionFragment;
|
||||
/**
|
||||
* Returns the fragment constrained by %%args%%. This can be used to
|
||||
* resolve ambiguous method names.
|
||||
*/
|
||||
getFragment(...args: ContractMethodArgs<A>): FunctionFragment;
|
||||
/**
|
||||
* Returns a populated transaction that can be used to perform the
|
||||
* contract method with %%args%%.
|
||||
*/
|
||||
populateTransaction(...args: ContractMethodArgs<A>): Promise<ContractTransaction>;
|
||||
/**
|
||||
* Call the contract method with %%args%% and return the value.
|
||||
*
|
||||
* If the return value is a single type, it will be dereferenced and
|
||||
* returned directly, otherwise the full Result will be returned.
|
||||
*/
|
||||
staticCall(...args: ContractMethodArgs<A>): Promise<R>;
|
||||
/**
|
||||
* Send a transaction for the contract method with %%args%%.
|
||||
*/
|
||||
send(...args: ContractMethodArgs<A>): Promise<ContractTransactionResponse>;
|
||||
/**
|
||||
* Estimate the gas to send the contract method with %%args%%.
|
||||
*/
|
||||
estimateGas(...args: ContractMethodArgs<A>): Promise<bigint>;
|
||||
/**
|
||||
* Call the contract method with %%args%% and return the Result
|
||||
* without any dereferencing.
|
||||
*/
|
||||
staticCallResult(...args: ContractMethodArgs<A>): Promise<Result>;
|
||||
}
|
||||
/**
|
||||
* A contract method on a Contract.
|
||||
*/
|
||||
export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> extends BaseContractMethod<A, R, D> {
|
||||
}
|
||||
/**
|
||||
* A pure of view method on a Contract.
|
||||
*/
|
||||
export interface ConstantContractMethod<A extends Array<any>, R = any> extends ContractMethod<A, R, R> {
|
||||
}
|
||||
/**
|
||||
* Each argument of an event is nullable (to indicate matching //any//.
|
||||
*
|
||||
* @_ignore:
|
||||
*/
|
||||
export type ContractEventArgs<A extends Array<any>> = {
|
||||
[I in keyof A]?: A[I] | Typed | null;
|
||||
};
|
||||
export interface ContractEvent<A extends Array<any> = Array<any>> {
|
||||
(...args: ContractEventArgs<A>): DeferredTopicFilter;
|
||||
/**
|
||||
* The name of the Contract event.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The fragment of the Contract event. This will throw on ambiguous
|
||||
* method names.
|
||||
*/
|
||||
fragment: EventFragment;
|
||||
/**
|
||||
* Returns the fragment constrained by %%args%%. This can be used to
|
||||
* resolve ambiguous event names.
|
||||
*/
|
||||
getFragment(...args: ContractEventArgs<A>): EventFragment;
|
||||
}
|
||||
/**
|
||||
* A Fallback or Receive function on a Contract.
|
||||
*/
|
||||
export interface WrappedFallback {
|
||||
(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
|
||||
/**
|
||||
* Returns a populated transaction that can be used to perform the
|
||||
* fallback method.
|
||||
*
|
||||
* For non-receive fallback, ``data`` may be overridden.
|
||||
*/
|
||||
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
|
||||
/**
|
||||
* Call the contract fallback and return the result.
|
||||
*
|
||||
* For non-receive fallback, ``data`` may be overridden.
|
||||
*/
|
||||
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
|
||||
/**
|
||||
* Send a transaction to the contract fallback.
|
||||
*
|
||||
* For non-receive fallback, ``data`` may be overridden.
|
||||
*/
|
||||
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
|
||||
/**
|
||||
* Estimate the gas to send a transaction to the contract fallback.
|
||||
*
|
||||
* For non-receive fallback, ``data`` may be overridden.
|
||||
*/
|
||||
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
|
||||
}
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src.ts/contract/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EACjD,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACR,kBAAkB,EAAE,0BAA0B,EAAE,WAAW,EAC9D,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAIjE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,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AI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5E"}
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src.ts/contract/types.ts"],"names":[],"mappings":";;AAeC,CAAC;AAoB4E,CAAC;AAkD9E,CAAC"}
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src.ts/contract/types.ts"],"names":[],"mappings":";;AAqCC,CAAC;AAsC4E,CAAC;AA4H9E,CAAC"}
|
||||
102
lib.commonjs/contract/wrappers.d.ts
vendored
102
lib.commonjs/contract/wrappers.d.ts
vendored
@@ -5,37 +5,139 @@ import type { Listener } from "../utils/index.js";
|
||||
import type { Provider } from "../providers/index.js";
|
||||
import type { BaseContract } from "./contract.js";
|
||||
import type { ContractEventName } from "./types.js";
|
||||
/**
|
||||
* An **EventLog** contains additional properties parsed from the [[Log]].
|
||||
*/
|
||||
export declare class EventLog extends Log {
|
||||
/**
|
||||
* The Contract Interface.
|
||||
*/
|
||||
readonly interface: Interface;
|
||||
/**
|
||||
* The matching event.
|
||||
*/
|
||||
readonly fragment: EventFragment;
|
||||
/**
|
||||
* The parsed arguments passed to the event by ``emit``.
|
||||
*/
|
||||
readonly args: Result;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(log: Log, iface: Interface, fragment: EventFragment);
|
||||
/**
|
||||
* The name of the event.
|
||||
*/
|
||||
get eventName(): string;
|
||||
/**
|
||||
* The signature of the event.
|
||||
*/
|
||||
get eventSignature(): string;
|
||||
}
|
||||
/**
|
||||
* An **EventLog** contains additional properties parsed from the [[Log]].
|
||||
*/
|
||||
export declare class UndecodedEventLog extends Log {
|
||||
/**
|
||||
* The error encounted when trying to decode the log.
|
||||
*/
|
||||
readonly error: Error;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(log: Log, error: Error);
|
||||
}
|
||||
/**
|
||||
* A **ContractTransactionReceipt** includes the parsed logs from a
|
||||
* [[TransactionReceipt]].
|
||||
*/
|
||||
export declare class ContractTransactionReceipt extends TransactionReceipt {
|
||||
#private;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(iface: Interface, provider: Provider, tx: TransactionReceipt);
|
||||
/**
|
||||
* The parsed logs for any [[Log]] which has a matching event in the
|
||||
* Contract ABI.
|
||||
*/
|
||||
get logs(): Array<EventLog | Log>;
|
||||
}
|
||||
/**
|
||||
* A **ContractTransactionResponse** will return a
|
||||
* [[ContractTransactionReceipt]] when waited on.
|
||||
*/
|
||||
export declare class ContractTransactionResponse extends TransactionResponse {
|
||||
#private;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(iface: Interface, provider: Provider, tx: TransactionResponse);
|
||||
/**
|
||||
* Resolves once this transaction has been mined and has
|
||||
* %%confirms%% blocks including it (default: ``1``) with an
|
||||
* optional %%timeout%%.
|
||||
*
|
||||
* This can resolve to ``null`` only if %%confirms%% is ``0``
|
||||
* and the transaction has not been mined, otherwise this will
|
||||
* wait until enough confirmations have completed.
|
||||
*/
|
||||
wait(confirms?: number): Promise<null | ContractTransactionReceipt>;
|
||||
}
|
||||
/**
|
||||
* A **ContractUnknownEventPayload** is included as the last parameter to
|
||||
* Contract Events when the event does not match any events in the ABI.
|
||||
*/
|
||||
export declare class ContractUnknownEventPayload extends EventPayload<ContractEventName> {
|
||||
/**
|
||||
* The log with no matching events.
|
||||
*/
|
||||
readonly log: Log;
|
||||
/**
|
||||
* @_event:
|
||||
*/
|
||||
constructor(contract: BaseContract, listener: null | Listener, filter: ContractEventName, log: Log);
|
||||
/**
|
||||
* Resolves to the block the event occured in.
|
||||
*/
|
||||
getBlock(): Promise<Block>;
|
||||
/**
|
||||
* Resolves to the transaction the event occured in.
|
||||
*/
|
||||
getTransaction(): Promise<TransactionResponse>;
|
||||
/**
|
||||
* Resolves to the transaction receipt the event occured in.
|
||||
*/
|
||||
getTransactionReceipt(): Promise<TransactionReceipt>;
|
||||
}
|
||||
/**
|
||||
* A **ContractEventPayload** is included as the last parameter to
|
||||
* Contract Events when the event is known.
|
||||
*/
|
||||
export declare class ContractEventPayload extends ContractUnknownEventPayload {
|
||||
/**
|
||||
* The matching event.
|
||||
*/
|
||||
readonly fragment: EventFragment;
|
||||
/**
|
||||
* The log, with parsed properties.
|
||||
*/
|
||||
readonly log: EventLog;
|
||||
/**
|
||||
* The parsed arguments passed to the event by ``emit``.
|
||||
*/
|
||||
readonly args: Result;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(contract: BaseContract, listener: null | Listener, filter: ContractEventName, fragment: EventFragment, _log: Log);
|
||||
/**
|
||||
* The event name.
|
||||
*/
|
||||
get eventName(): string;
|
||||
/**
|
||||
* The event signature.
|
||||
*/
|
||||
get eventSignature(): string;
|
||||
}
|
||||
//# sourceMappingURL=wrappers.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../src.ts/contract/wrappers.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,EAAE,GAAG,EAAE,kBAAkB,EAAE,mBAAmB,EACtD,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAoB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EACR,QAAQ,EACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpD,qBAAa,QAAS,SAAQ,GAAG;IAC7B,QAAQ,CAAC,SAAS,EAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAG,aAAa,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAG,MAA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AG;IAM5H;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;CACJ"}
|
||||
@@ -1,50 +1,118 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ContractEventPayload = exports.ContractUnknownEventPayload = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.EventLog = void 0;
|
||||
exports.ContractEventPayload = exports.ContractUnknownEventPayload = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.UndecodedEventLog = exports.EventLog = void 0;
|
||||
// import from provider.ts instead of index.ts to prevent circular dep
|
||||
// from EtherscanProvider
|
||||
const provider_js_1 = require("../providers/provider.js");
|
||||
const index_js_1 = require("../utils/index.js");
|
||||
/**
|
||||
* An **EventLog** contains additional properties parsed from the [[Log]].
|
||||
*/
|
||||
class EventLog extends provider_js_1.Log {
|
||||
/**
|
||||
* The Contract Interface.
|
||||
*/
|
||||
interface;
|
||||
/**
|
||||
* The matching event.
|
||||
*/
|
||||
fragment;
|
||||
/**
|
||||
* The parsed arguments passed to the event by ``emit``.
|
||||
*/
|
||||
args;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(log, iface, fragment) {
|
||||
super(log, log.provider);
|
||||
const args = iface.decodeEventLog(fragment, log.data, log.topics);
|
||||
(0, index_js_1.defineProperties)(this, { args, fragment, interface: iface });
|
||||
}
|
||||
/**
|
||||
* The name of the event.
|
||||
*/
|
||||
get eventName() { return this.fragment.name; }
|
||||
/**
|
||||
* The signature of the event.
|
||||
*/
|
||||
get eventSignature() { return this.fragment.format(); }
|
||||
}
|
||||
exports.EventLog = EventLog;
|
||||
/**
|
||||
* An **EventLog** contains additional properties parsed from the [[Log]].
|
||||
*/
|
||||
class UndecodedEventLog extends provider_js_1.Log {
|
||||
/**
|
||||
* The error encounted when trying to decode the log.
|
||||
*/
|
||||
error;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(log, error) {
|
||||
super(log, log.provider);
|
||||
(0, index_js_1.defineProperties)(this, { error });
|
||||
}
|
||||
}
|
||||
exports.UndecodedEventLog = UndecodedEventLog;
|
||||
/**
|
||||
* A **ContractTransactionReceipt** includes the parsed logs from a
|
||||
* [[TransactionReceipt]].
|
||||
*/
|
||||
class ContractTransactionReceipt extends provider_js_1.TransactionReceipt {
|
||||
#iface;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(iface, provider, tx) {
|
||||
super(tx, provider);
|
||||
this.#iface = iface;
|
||||
}
|
||||
/**
|
||||
* The parsed logs for any [[Log]] which has a matching event in the
|
||||
* Contract ABI.
|
||||
*/
|
||||
get logs() {
|
||||
return super.logs.map((log) => {
|
||||
const fragment = log.topics.length ? this.#iface.getEvent(log.topics[0]) : null;
|
||||
if (fragment) {
|
||||
return new EventLog(log, this.#iface, fragment);
|
||||
}
|
||||
else {
|
||||
return log;
|
||||
try {
|
||||
return new EventLog(log, this.#iface, fragment);
|
||||
}
|
||||
catch (error) {
|
||||
return new UndecodedEventLog(log, error);
|
||||
}
|
||||
}
|
||||
return log;
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ContractTransactionReceipt = ContractTransactionReceipt;
|
||||
/**
|
||||
* A **ContractTransactionResponse** will return a
|
||||
* [[ContractTransactionReceipt]] when waited on.
|
||||
*/
|
||||
class ContractTransactionResponse extends provider_js_1.TransactionResponse {
|
||||
#iface;
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(iface, provider, tx) {
|
||||
super(tx, provider);
|
||||
this.#iface = iface;
|
||||
}
|
||||
/**
|
||||
* Resolves once this transaction has been mined and has
|
||||
* %%confirms%% blocks including it (default: ``1``) with an
|
||||
* optional %%timeout%%.
|
||||
*
|
||||
* This can resolve to ``null`` only if %%confirms%% is ``0``
|
||||
* and the transaction has not been mined, otherwise this will
|
||||
* wait until enough confirmations have completed.
|
||||
*/
|
||||
async wait(confirms) {
|
||||
const receipt = await super.wait();
|
||||
const receipt = await super.wait(confirms);
|
||||
if (receipt == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -52,32 +120,64 @@ class ContractTransactionResponse extends provider_js_1.TransactionResponse {
|
||||
}
|
||||
}
|
||||
exports.ContractTransactionResponse = ContractTransactionResponse;
|
||||
/**
|
||||
* A **ContractUnknownEventPayload** is included as the last parameter to
|
||||
* Contract Events when the event does not match any events in the ABI.
|
||||
*/
|
||||
class ContractUnknownEventPayload extends index_js_1.EventPayload {
|
||||
/**
|
||||
* The log with no matching events.
|
||||
*/
|
||||
log;
|
||||
/**
|
||||
* @_event:
|
||||
*/
|
||||
constructor(contract, listener, filter, log) {
|
||||
super(contract, listener, filter);
|
||||
(0, index_js_1.defineProperties)(this, { log });
|
||||
}
|
||||
/**
|
||||
* Resolves to the block the event occured in.
|
||||
*/
|
||||
async getBlock() {
|
||||
return await this.log.getBlock();
|
||||
}
|
||||
/**
|
||||
* Resolves to the transaction the event occured in.
|
||||
*/
|
||||
async getTransaction() {
|
||||
return await this.log.getTransaction();
|
||||
}
|
||||
/**
|
||||
* Resolves to the transaction receipt the event occured in.
|
||||
*/
|
||||
async getTransactionReceipt() {
|
||||
return await this.log.getTransactionReceipt();
|
||||
}
|
||||
}
|
||||
exports.ContractUnknownEventPayload = ContractUnknownEventPayload;
|
||||
/**
|
||||
* A **ContractEventPayload** is included as the last parameter to
|
||||
* Contract Events when the event is known.
|
||||
*/
|
||||
class ContractEventPayload extends ContractUnknownEventPayload {
|
||||
/**
|
||||
* @_ignore:
|
||||
*/
|
||||
constructor(contract, listener, filter, fragment, _log) {
|
||||
super(contract, listener, filter, new EventLog(_log, contract.interface, fragment));
|
||||
const args = contract.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
|
||||
(0, index_js_1.defineProperties)(this, { args, fragment });
|
||||
}
|
||||
/**
|
||||
* The event name.
|
||||
*/
|
||||
get eventName() {
|
||||
return this.fragment.name;
|
||||
}
|
||||
/**
|
||||
* The event signature.
|
||||
*/
|
||||
get eventSignature() {
|
||||
return this.fragment.format();
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"wrappers.js","sourceRoot":"","sources":["../../src.ts/contract/wrappers.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,yBAAyB;AACzB,0DAEkC;AAClC,gDAAmE;AAYnE,MAAa,QAAS,SAAQ,iBAAG;IACpB,SAAS,CAAa;IACtB,QAAQ,CAAiB;IACzB,IAAI,CAAU;IAEvB,YAAY,GAAQ,EAAE,KAAgB,EAAE,QAAuB;QAC3D,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAClE,IAAA,2BAAgB,EAAW,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,IAAI,cAAc,KAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAClE;AAbD,4BAaC;AAED,MAAa,0BAA2B,SAAQ,gCAAkB;IACrD,MAAM,CAAY;IAE3B,YAAY,KAAgB,EAAE,QAAkB,EAAE,EAAsB;QACpE,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAC1B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC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C,GAAG,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAChB,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB;QACvB,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAClD,CAAC;CACJ;AAlCD,kEAkCC;AAED;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,2BAA2B;IAiBjE;;OAEG;IACH,YAAY,QAAsB,EAAE,QAAyB,EAAE,MAAyB,EAAE,QAAuB,EAAE,IAAS;QACxH,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzF,IAAA,2BAAgB,EAAuB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;CACJ;AAvCD,oDAuCC"}
|
||||
4
lib.commonjs/crypto/index.d.ts
vendored
4
lib.commonjs/crypto/index.d.ts
vendored
@@ -14,6 +14,10 @@ import { sha256, sha512 } from "./sha2.js";
|
||||
export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync };
|
||||
export { SigningKey } from "./signing-key.js";
|
||||
export { Signature } from "./signature.js";
|
||||
/**
|
||||
* Once called, prevents any future change to the underlying cryptographic
|
||||
* primitives using the ``.register`` feature for hooks.
|
||||
*/
|
||||
declare function lock(): void;
|
||||
export { lock };
|
||||
export type { ProgressCallback } from "./scrypt.js";
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/crypto/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACH,WAAW,EAEX,WAAW,EAEX,SAAS,EACT,SAAS,EACT,MAAM,EAAE,MAAM,EAEd,MAAM,EACN,MAAM,EAAE,UAAU,EACrB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,iBAAS,IAAI,IAAI,IAAI,CAWpB;AAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAKhB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/crypto/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACH,WAAW,EAEX,WAAW,EAEX,SAAS,EACT,SAAS,EACT,MAAM,EAAE,MAAM,EAEd,MAAM,EACN,MAAM,EAAE,UAAU,EACrB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;GAGG;AACH,iBAAS,IAAI,IAAI,IAAI,CAWpB;AAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAKhB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
||||
@@ -29,6 +29,10 @@ var signing_key_js_1 = require("./signing-key.js");
|
||||
Object.defineProperty(exports, "SigningKey", { enumerable: true, get: function () { return signing_key_js_1.SigningKey; } });
|
||||
var signature_js_1 = require("./signature.js");
|
||||
Object.defineProperty(exports, "Signature", { enumerable: true, get: function () { return signature_js_1.Signature; } });
|
||||
/**
|
||||
* Once called, prevents any future change to the underlying cryptographic
|
||||
* primitives using the ``.register`` feature for hooks.
|
||||
*/
|
||||
function lock() {
|
||||
hmac_js_1.computeHmac.lock();
|
||||
keccak_js_1.keccak256.lock();
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/crypto/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,IAAI,CAAA;AAEJ,8CAA8C;AAC9C,uCAAwC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C;AASvC,uFATK,gBAAM,OASL;AAAE,uFATK,gBAAM,OASL;AAMlB,mDAA8C;AAArC,4GAAA,UAAU,OAAA;AACnB,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAElB;;;GAGG;AACH,SAAS,IAAI;IACT,qBAAW,CAAC,IAAI,EAAE,CAAC;IACnB,qBAAS,CAAC,IAAI,EAAE,CAAC;IACjB,kBAAM,CAAC,IAAI,EAAE,CAAC;IACd,uBAAW,CAAC,IAAI,EAAE,CAAC;IACnB,wBAAS,CAAC,IAAI,EAAE,CAAC;IACjB,kBAAM,CAAC,IAAI,EAAE,CAAC;IACd,sBAAU,CAAC,IAAI,EAAE,CAAC;IAClB,gBAAM,CAAC,IAAI,EAAE,CAAC;IACd,gBAAM,CAAC,IAAI,EAAE,CAAC;IACd,uBAAW,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAEQ,oBAAI"}
|
||||
@@ -283,7 +283,7 @@ class Signature {
|
||||
return { v: (((0, index_js_2.getBytes)(yParityAndS)[0] & 0x80) ? 28 : 27) };
|
||||
}
|
||||
if (yParity != null) {
|
||||
switch (yParity) {
|
||||
switch ((0, index_js_2.getNumber)(yParity, "sig.yParity")) {
|
||||
case 0: return { v: 27 };
|
||||
case 1: return { v: 28 };
|
||||
}
|
||||
@@ -296,8 +296,8 @@ class Signature {
|
||||
result.#networkV = networkV;
|
||||
}
|
||||
// If multiple of v, yParity, yParityAndS we given, check they match
|
||||
assertError(!("yParity" in sig && sig.yParity !== result.yParity), "yParity mismatch");
|
||||
assertError(!("yParityAndS" in sig && sig.yParityAndS !== result.yParityAndS), "yParityAndS mismatch");
|
||||
assertError(sig.yParity == null || (0, index_js_2.getNumber)(sig.yParity, "sig.yParity") === result.yParity, "yParity mismatch");
|
||||
assertError(sig.yParityAndS == null || sig.yParityAndS === result.yParityAndS, "yParityAndS mismatch");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"version":3,"file":"signing-key.d.ts","sourceRoot":"","sources":["../../src.ts/crypto/signing-key.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAUhD;;;GAGG;AACH,qBAAa,UAAU;;IAGnB;;OAEG;gBACS,UAAU,EAAE,SAAS;IAKjC;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAA6B;IAErD;;;;;OAKG;IACH,IAAI,SAAS,IAAI,MAAM,CAA0D;IAEjF;;;;;;OAMG;IACH,IAAI,mBAAmB,IAAI,MAAM,CAAgE;IAEjG;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS;IAgBlC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAK7C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM;IAqBrE;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,GAAG,MAAM;IAY5E;;;;;;;;;OASG;IACH,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM;CAK/E"}
|
||||
{"version":3,"file":"signing-key.d.ts","sourceRoot":"","sources":["../../src.ts/crypto/signing-key.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD;;;GAGG;AACH,qBAAa,UAAU;;IAGnB;;OAEG;gBACS,UAAU,EAAE,SAAS;IAKjC;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAA6B;IAErD;;;;;OAKG;IACH,IAAI,SAAS,IAAI,MAAM,CAA0D;IAEjF;;;;;;OAMG;IACH,IAAI,mBAAmB,IAAI,MAAM,CAAgE;IAEjG;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS;IAclC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAK7C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM;IAqBrE;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,GAAG,MAAM;IAc5E;;;;;;;;;OASG;IACH,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM;CAK/E"}
|
||||
@@ -6,16 +6,9 @@
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SigningKey = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const secp256k1 = tslib_1.__importStar(require("@noble/secp256k1"));
|
||||
const secp256k1_1 = require("@noble/curves/secp256k1");
|
||||
const index_js_1 = require("../utils/index.js");
|
||||
const hmac_js_1 = require("./hmac.js");
|
||||
const signature_js_1 = require("./signature.js");
|
||||
//const N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
||||
// Make noble-secp256k1 sync
|
||||
secp256k1.utils.hmacSha256Sync = function (key, ...messages) {
|
||||
return (0, index_js_1.getBytes)((0, hmac_js_1.computeHmac)("sha256", key, (0, index_js_1.concat)(messages)));
|
||||
};
|
||||
/**
|
||||
* A **SigningKey** provides high-level access to the elliptic curve
|
||||
* cryptography (ECC) operations and key management.
|
||||
@@ -53,15 +46,13 @@ class SigningKey {
|
||||
*/
|
||||
sign(digest) {
|
||||
(0, index_js_1.assertArgument)((0, index_js_1.dataLength)(digest) === 32, "invalid digest length", "digest", digest);
|
||||
const [sigDer, recid] = secp256k1.signSync((0, index_js_1.getBytesCopy)(digest), (0, index_js_1.getBytesCopy)(this.#privateKey), {
|
||||
recovered: true,
|
||||
canonical: true
|
||||
const sig = secp256k1_1.secp256k1.sign((0, index_js_1.getBytesCopy)(digest), (0, index_js_1.getBytesCopy)(this.#privateKey), {
|
||||
lowS: true
|
||||
});
|
||||
const sig = secp256k1.Signature.fromHex(sigDer);
|
||||
return signature_js_1.Signature.from({
|
||||
r: (0, index_js_1.toBeHex)("0x" + sig.r.toString(16), 32),
|
||||
s: (0, index_js_1.toBeHex)("0x" + sig.s.toString(16), 32),
|
||||
v: (recid ? 0x1c : 0x1b)
|
||||
r: (0, index_js_1.toBeHex)(sig.r, 32),
|
||||
s: (0, index_js_1.toBeHex)(sig.s, 32),
|
||||
v: (sig.recovery ? 0x1c : 0x1b)
|
||||
});
|
||||
}
|
||||
/**
|
||||
@@ -88,7 +79,7 @@ class SigningKey {
|
||||
*/
|
||||
computeSharedSecret(other) {
|
||||
const pubKey = SigningKey.computePublicKey(other);
|
||||
return (0, index_js_1.hexlify)(secp256k1.getSharedSecret((0, index_js_1.getBytesCopy)(this.#privateKey), (0, index_js_1.getBytes)(pubKey)));
|
||||
return (0, index_js_1.hexlify)(secp256k1_1.secp256k1.getSharedSecret((0, index_js_1.getBytesCopy)(this.#privateKey), (0, index_js_1.getBytes)(pubKey), false));
|
||||
}
|
||||
/**
|
||||
* Compute the public key for %%key%%, optionally %%compressed%%.
|
||||
@@ -119,7 +110,7 @@ class SigningKey {
|
||||
let bytes = (0, index_js_1.getBytes)(key, "key");
|
||||
// private key
|
||||
if (bytes.length === 32) {
|
||||
const pubKey = secp256k1.getPublicKey(bytes, !!compressed);
|
||||
const pubKey = secp256k1_1.secp256k1.getPublicKey(bytes, !!compressed);
|
||||
return (0, index_js_1.hexlify)(pubKey);
|
||||
}
|
||||
// raw public key; use uncompressed key with 0x04 prefix
|
||||
@@ -129,7 +120,7 @@ class SigningKey {
|
||||
pub.set(bytes, 1);
|
||||
bytes = pub;
|
||||
}
|
||||
const point = secp256k1.Point.fromHex(bytes);
|
||||
const point = secp256k1_1.secp256k1.ProjectivePoint.fromHex(bytes);
|
||||
return (0, index_js_1.hexlify)(point.toRawBytes(compressed));
|
||||
}
|
||||
/**
|
||||
@@ -153,10 +144,11 @@ class SigningKey {
|
||||
static recoverPublicKey(digest, signature) {
|
||||
(0, index_js_1.assertArgument)((0, index_js_1.dataLength)(digest) === 32, "invalid digest length", "digest", digest);
|
||||
const sig = signature_js_1.Signature.from(signature);
|
||||
const der = secp256k1.Signature.fromCompact((0, index_js_1.getBytesCopy)((0, index_js_1.concat)([sig.r, sig.s]))).toDERRawBytes();
|
||||
const pubKey = secp256k1.recoverPublicKey((0, index_js_1.getBytesCopy)(digest), der, sig.yParity);
|
||||
let secpSig = secp256k1_1.secp256k1.Signature.fromCompact((0, index_js_1.getBytesCopy)((0, index_js_1.concat)([sig.r, sig.s])));
|
||||
secpSig = secpSig.addRecoveryBit(sig.yParity);
|
||||
const pubKey = secpSig.recoverPublicKey((0, index_js_1.getBytesCopy)(digest));
|
||||
(0, index_js_1.assertArgument)(pubKey != null, "invalid signautre for digest", "signature", signature);
|
||||
return (0, index_js_1.hexlify)(pubKey);
|
||||
return "0x" + pubKey.toHex(false);
|
||||
}
|
||||
/**
|
||||
* Returns the point resulting from adding the ellipic curve points
|
||||
@@ -169,8 +161,8 @@ class SigningKey {
|
||||
* addresses from parent public keys and chain codes.
|
||||
*/
|
||||
static addPoints(p0, p1, compressed) {
|
||||
const pub0 = secp256k1.Point.fromHex(SigningKey.computePublicKey(p0).substring(2));
|
||||
const pub1 = secp256k1.Point.fromHex(SigningKey.computePublicKey(p1).substring(2));
|
||||
const pub0 = secp256k1_1.secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p0).substring(2));
|
||||
const pub1 = secp256k1_1.secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p1).substring(2));
|
||||
return "0x" + pub0.add(pub1).toHex(!!compressed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"signing-key.js","sourceRoot":"","sources":["../../src.ts/crypto/signing-key.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,oEAA8C;AAE9C,gDAG2B;AAE3B,uCAAwC;AACxC,iDAA2C;AAO3C,yFAAyF;AAEzF,4BAA4B;AAC5B,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,UAAS,GAAe,EAAE,GAAG,QAA2B;IACrF,OAAO,IAAA,mBAAQ,EAAC,IAAA,qBAAW,EAAC,QAAQ,EAAE,GAAG,EAAE,IAAA,iBAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC,CAAA;AAED;;;GAGG;AACH,MAAa,UAAU;IACnB,WAAW,CAAS;IAEpB;;OAEG;IACH,YAAY,UAAqB;QAC7B,IAAA,yBAAc,EAAC,IAAA,qBAAU,EAAC,UAAU,CAAC,KAAK,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QACjG,IAAI,CAAC,WAAW,GAAG,IAAA,kBAAO,EAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAI,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAErD;;;;;OAKG;IACH,IAAI,SAAS,KAAa,OAAO,UAAU,CAAC,gBAAgB,CAAC,IAAI,C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AAC,CAAC;QAEtC,IAAI,OAAO,GAAG,qBAAS,CAAC,SAAS,CAAC,WAAW,CAAC,IAAA,uBAAY,EAAC,IAAA,iBAAM,EAAC,CAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;QACtF,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9C,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAA,uBAAY,EAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,IAAA,yBAAc,EAAC,MAAM,IAAI,IAAI,EAAE,8BAA8B,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAEvF,OAAO,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,SAAS,CAAC,EAAa,EAAE,EAAa,EAAE,UAAoB;QAC/D,MAAM,IAAI,GAAG,qBAAS,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7F,MAAM,IAAI,GAAG,qBAAS,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7F,OAAO,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IACpD,CAAC;CACJ;AA1KD,gCA0KC"}
|
||||
8
lib.commonjs/ethers.d.ts
vendored
8
lib.commonjs/ethers.d.ts
vendored
@@ -2,10 +2,10 @@ export { version } from "./_version.js";
|
||||
export { decodeBytes32String, encodeBytes32String, AbiCoder, ConstructorFragment, ErrorFragment, EventFragment, Fragment, FallbackFragment, FunctionFragment, NamedFragment, ParamType, StructFragment, checkResultErrors, ErrorDescription, Indexed, Interface, LogDescription, Result, TransactionDescription, Typed, } from "./abi/index.js";
|
||||
export { getAddress, getIcapAddress, getCreateAddress, getCreate2Address, isAddressable, isAddress, resolveAddress } from "./address/index.js";
|
||||
export { ZeroAddress, WeiPerEther, MaxUint256, MinInt256, MaxInt256, N, ZeroHash, EtherSymbol, MessagePrefix } from "./constants/index.js";
|
||||
export { BaseContract, Contract, ContractFactory, ContractEventPayload, ContractTransactionReceipt, ContractTransactionResponse, ContractUnknownEventPayload, EventLog, } from "./contract/index.js";
|
||||
export { BaseContract, Contract, ContractFactory, ContractEventPayload, ContractTransactionReceipt, ContractTransactionResponse, ContractUnknownEventPayload, EventLog, UndecodedEventLog } from "./contract/index.js";
|
||||
export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync, lock, Signature, SigningKey } from "./crypto/index.js";
|
||||
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder, verifyTypedData } from "./hash/index.js";
|
||||
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, InfuraWebSocketProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network, EnsPlugin, EtherscanPlugin, FeeDataNetworkPlugin, GasCostPlugin, NetworkPlugin, SocketBlockSubscriber, SocketEventSubscriber, SocketPendingSubscriber, SocketSubscriber, UnmanagedSubscriber, copyRequest, showThrottleMessage } from "./providers/index.js";
|
||||
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, InfuraWebSocketProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network, EnsPlugin, EtherscanPlugin, FeeDataNetworkPlugin, FetchUrlFeeDataNetworkPlugin, GasCostPlugin, NetworkPlugin, MulticoinProviderPlugin, SocketBlockSubscriber, SocketEventSubscriber, SocketPendingSubscriber, SocketSubscriber, UnmanagedSubscriber, copyRequest, showThrottleMessage } from "./providers/index.js";
|
||||
export { accessListify, computeAddress, recoverAddress, Transaction } from "./transaction/index.js";
|
||||
export { decodeBase58, encodeBase58, decodeBase64, encodeBase64, concat, dataLength, dataSlice, getBytes, getBytesCopy, hexlify, isHexString, isBytesLike, stripZerosLeft, zeroPadBytes, zeroPadValue, defineProperties, resolveProperties, assert, assertArgument, assertArgumentCount, assertNormalize, assertPrivate, makeError, isCallException, isError, EventPayload, FetchRequest, FetchResponse, FetchCancelSignal, FixedNumber, getBigInt, getNumber, getUint, toBeArray, toBigInt, toBeHex, toNumber, toQuantity, fromTwos, toTwos, mask, formatEther, parseEther, formatUnits, parseUnits, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, decodeRlp, encodeRlp, uuidV4, } from "./utils/index.js";
|
||||
export { Mnemonic, BaseWallet, HDNodeWallet, HDNodeVoidWallet, Wallet, defaultPath, getAccountPath, getIndexedAccountPath, isCrowdsaleJson, isKeystoreJson, decryptCrowdsaleJson, decryptKeystoreJsonSync, decryptKeystoreJson, encryptKeystoreJson, encryptKeystoreJsonSync, } from "./wallet/index.js";
|
||||
@@ -15,8 +15,8 @@ export type { Addressable, AddressLike, NameResolver } from "./address/index.js"
|
||||
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides, BaseContractMethod, ContractDeployTransaction, PostfixOverrides, WrappedFallback } from "./contract/index.js";
|
||||
export type { ProgressCallback, SignatureLike } from "./crypto/index.js";
|
||||
export type { TypedDataDomain, TypedDataField } from "./hash/index.js";
|
||||
export type { Provider, Signer, AbstractProviderPlugin, BlockParams, BlockTag, ContractRunner, DebugEventBrowserProvider, Eip1193Provider, EventFilter, Filter, FilterByBlockHash, GasCostParameters, JsonRpcApiProviderOptions, JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcTransactionRequest, LogParams, MinedBlock, MinedTransactionResponse, Networkish, OrphanFilter, PerformActionFilter, PerformActionRequest, PerformActionTransaction, PreparedTransactionRequest, ProviderEvent, Subscriber, Subscription, TopicFilter, TransactionReceiptParams, TransactionRequest, TransactionResponseParams, WebSocketCreator, WebSocketLike } from "./providers/index.js";
|
||||
export type { Provider, Signer, AbstractProviderOptions, FallbackProviderOptions, AbstractProviderPlugin, BlockParams, BlockTag, ContractRunner, DebugEventBrowserProvider, Eip1193Provider, EventFilter, Filter, FilterByBlockHash, GasCostParameters, JsonRpcApiProviderOptions, JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcTransactionRequest, LogParams, MinedBlock, MinedTransactionResponse, Networkish, OrphanFilter, PerformActionFilter, PerformActionRequest, PerformActionTransaction, PreparedTransactionRequest, ProviderEvent, Subscriber, Subscription, TopicFilter, TransactionReceiptParams, TransactionRequest, TransactionResponseParams, WebSocketCreator, WebSocketLike } from "./providers/index.js";
|
||||
export type { AccessList, AccessListish, AccessListEntry, TransactionLike } from "./transaction/index.js";
|
||||
export type { BytesLike, BigNumberish, Numeric, ErrorCode, FixedFormat, Utf8ErrorFunc, UnicodeNormalizationForm, Utf8ErrorReason, RlpStructuredData, GetUrlResponse, FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc, FetchGatewayFunc, FetchGetUrlFunc, EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError, ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError, NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError, CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError, ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError, ActionRejectedError, CodedEthersError, CallExceptionAction, CallExceptionTransaction, EventEmitterable, Listener } from "./utils/index.js";
|
||||
export type { BytesLike, BigNumberish, Numeric, ErrorCode, FixedFormat, Utf8ErrorFunc, UnicodeNormalizationForm, Utf8ErrorReason, RlpStructuredData, RlpStructuredDataish, GetUrlResponse, FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc, FetchGatewayFunc, FetchGetUrlFunc, EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError, ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError, NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError, CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError, ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError, ActionRejectedError, CodedEthersError, CallExceptionAction, CallExceptionTransaction, EventEmitterable, Listener } from "./utils/index.js";
|
||||
export type { CrowdsaleAccount, KeystoreAccount, EncryptOptions } from "./wallet/index.js";
|
||||
//# sourceMappingURL=ethers.d.ts.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user