Compare commits

...

199 Commits

Author SHA1 Message Date
053ca44133 Change to @tornado/ethers and use @tornado/noble-curves 2024-04-18 20:05:00 -07:00
Richard Moore
b553b1bc43 admin: updated dist files 2024-04-17 01:09:22 -04:00
Richard Moore
631aa1d91f tests: migrated all goerli tests to sepolia; contracts and config 2024-04-17 01:08:25 -04:00
Richard Moore
8220090c20 admin: fixed typo in CI (#4634) 2024-04-16 21:49:57 -04:00
Richard Moore
d437d0fd17 admin: updated dist files 2024-04-16 21:49:08 -04:00
Richard Moore
16a22560ff docs: fixed typo in EtherscanProvider (#4666) 2024-04-16 21:47:30 -04:00
Richard Moore
b4aaab8d39 Added Linea Sepolia network and Infura endpoint (#4655). 2024-04-16 21:45:49 -04:00
Richard Moore
287f743107 admin: updated dist files 2024-04-16 21:35:12 -04:00
Richard Moore
c45935e29c Do not send unsubscribe messages to destroyed Providers (#4678). 2024-04-16 21:32:34 -04:00
Richard Moore
38e32d8214 Get definitive network from InfuraProvider when using InfuraWebSocketProvider. 2024-04-16 21:30:15 -04:00
Richard Moore
29beb93ea7 admin: updated dist files 2024-04-12 00:11:30 -04:00
Richard Moore
9230aa0b9a Better error messages for transaction field mismatch (#4659). 2024-04-12 00:09:48 -04:00
Richard Moore
ec6a754f0c Added prevRandao to block (#3372). 2024-04-12 00:08:01 -04:00
Richard Moore
501de23450 admin: updated dist files 2024-04-09 21:13:01 -04:00
Richard Moore
531ab95b3e Merge branch 'wip-4844-write' 2024-04-09 21:04:49 -04:00
Richard Moore
1717abbf29 Added Polygon Amoy testnet (#4645). 2024-04-09 20:58:48 -04:00
Richard Moore
014004d940 Added Chainstack provider (#2741). 2024-04-09 20:36:16 -04:00
Richard Moore
03bfe2a4f7 Added deep convertion to Result for toObject and toArray (#4681). 2024-04-09 20:02:29 -04:00
Richard Moore
a05f40f1be Added note on BLS modulo size per BLOb field. 2024-04-09 19:31:18 -04:00
Richard Moore
92bad88261 Added EIP-4844 broadcast support. 2024-03-27 14:43:57 -04:00
Richard Moore
12772e9498 Fix ignored throttle parameters (#4663). 2024-03-26 16:09:37 -04:00
Richard Moore
ad5f1c5fc7 admin: updated dist files 2024-02-14 13:14:24 -05:00
Richard Moore
556fdd91d9 Throw an error when attempting to derive from a master path from a non-master node (#4551). 2024-02-14 13:11:54 -05:00
Richard Moore
7f14bdebf1 Allow ENS wildcards with labels up to 255 bytes wide; discussed with ENS and deemed safe (#4543). 2024-02-14 12:36:29 -05:00
Richard Moore
f45bb87aef Enforce string is passed to toUtf8Bytes (#4583). 2024-02-14 12:32:43 -05:00
Richard Moore
7f0e140d5e Fix transaction.index not being populated on some backends (#4591). 2024-02-14 12:23:48 -05:00
Richard Moore
3a1d175c20 admin: updated dist files 2024-02-08 20:27:03 -05:00
Richard Moore
f02211d055 Allow transaction encoding for inferred type transactions. 2024-02-08 20:24:50 -05:00
Richard Moore
d8a7cbe83a admin: updated dist files 2024-02-05 19:59:21 -05:00
Richard Moore
c5f126faf7 Added EIP-4788, receipts root and state root fields to Block (#4570). 2024-02-05 19:56:26 -05:00
Richard Moore
cac1da1f91 admin: update dist files 2024-02-03 00:19:51 -05:00
Richard Moore
7b4f2c1a74 Added EIP-4844 fields to Provider classes and formatter (#4570). 2024-02-03 00:17:45 -05:00
Richard Moore
f1666f167f admin: updated dist files 2024-02-02 04:18:15 -05:00
Richard Moore
6bf19c1937 tests: added test for gasless ENS-DNS resolution 2024-02-02 04:17:10 -05:00
Richard Moore
416de27589 admin: update dist files; updated package-lock 2024-02-02 03:30:31 -05:00
Richard Moore
eeb1a4b650 admin: updated dist files 2024-02-02 03:25:03 -05:00
Richard Moore
47f1addb41 admin: update ens-normalize dependency 2024-02-02 03:11:24 -05:00
Richard Moore
b69f43bc6f Assert BrowserProvider receives an EIP-1193 provider to fail early when passing undefined ethereum object. 2024-02-02 03:10:40 -05:00
Richard Moore
095de51e60 Add timeout to ContractTransactionResponse wait (#4497). 2024-02-02 03:03:18 -05:00
Richard Moore
be5ec2d327 Allow override keyword in human-readable ABI and improve error messages (#4514, #4548). 2024-02-01 03:19:20 -05:00
Richard Moore
98496bc48e Expand Contract sub-class to accept BaseContract super-class constructor arguments (#4538). 2024-02-01 01:59:31 -05:00
Richard Moore
b6bf7aba62 Allow network for default provider to be null to select mainnet (#4501). 2024-02-01 01:50:59 -05:00
Richard Moore
59cfa864be docs: fixed jsdocs typo (#4515) 2024-01-31 00:40:17 -05:00
Richard Moore
7a73b686cc docs: fixed jsdocs typo (#4522) 2024-01-31 00:39:08 -05:00
Richard Moore
2c817e5e09 docs: fixed jsdocs typo (#4532) 2024-01-31 00:36:39 -05:00
Richard Moore
62d181ea0f docs: fixed jsdoc typos (#4556) 2024-01-31 00:35:34 -05:00
Richard Moore
a1363483a5 Allow long dnsEncode names with optional length parameter (#4543). 2024-01-31 00:22:23 -05:00
Richard Moore
20cd8a23ea Fix parseLog signature when receiving read-only array for topics (#4029, #4459). 2024-01-31 00:00:19 -05:00
Richard Moore
1f6e188251 Use Secure endpoints for BNB on Etherscan (#4525). 2024-01-30 23:55:06 -05:00
Richard Moore
561f7a0f38 Merge branch 'wip-4844' into wip-v6.11 2024-01-30 23:42:38 -05:00
Richard Moore
c6e6c43257 Added holesky network and related end-points for supporting providers. 2024-01-24 22:39:05 -05:00
Richard Moore
9c1e82e123 Added EIP-4844 BLOb transactions (#4554). 2024-01-24 20:35:59 -05:00
Richard Moore
a26ff77c21 admin: updated dist files 2024-01-17 20:36:41 -05:00
Richard Moore
a513e406ad tests: add tests for EIP-712 payload aliases 2024-01-17 20:36:06 -05:00
Richard Moore
56c1361ee8 Normalize EIP-712 types before computing the payload (#4541). 2024-01-17 20:33:38 -05:00
Richard Moore
319d475648 admin: updated dist files 2024-01-17 14:33:43 -05:00
Richard Moore
ce93cb1eed tests: rename test suite to follow naming convention 2024-01-17 13:23:35 -05:00
Richard Moore
2b4891d86e Updated thrid-part provider URLs for QuickNode. 2024-01-17 13:22:49 -05:00
Richard Moore
fed28e4a8c tests: added testing for correct thrid-party URLs 2024-01-17 00:01:29 -05:00
Richard Moore
e66ce74835 admin: updated dist files 2024-01-16 17:43:38 -05:00
Richard Moore
8f99601df1 Fixed normalization and abstracted EIP-712 Array parsing (#4541). 2024-01-16 17:41:57 -05:00
Richard Moore
92cb3e4c06 admin: updated dist files 2024-01-15 23:07:48 -05:00
Richard Moore
84ca14f1ff Updated third-party provider network URLs (#4542). 2024-01-15 23:06:21 -05:00
Richard Moore
4efef76e8c Added additional sepolia testnets. 2024-01-15 23:04:20 -05:00
Richard Moore
43fb9c2336 Fix EIP-712 type aliases for uint and int (#4541). 2024-01-15 23:03:38 -05:00
Richard Moore
7882905085 Fixed typo in Error string (#4539). 2024-01-15 14:23:49 -05:00
Richard Moore
cd89de4eaf docs: added StaticJsonRpcProvider to migration docs 2024-01-15 14:10:00 -05:00
Richard Moore
bee07a0750 Better debugging output on fetch errors. 2024-01-15 13:43:56 -05:00
Richard Moore
2f36f59d76 admin: updated dist files 2024-01-12 19:47:16 -05:00
Richard Moore
1b4debd4a9 Limit decoded result imflation ratio from ABI-encoded data (#4537). 2024-01-12 19:45:26 -05:00
Richard Moore
6017d3d39a admin: updated dist files 2024-01-02 19:12:56 -05:00
Richard Moore
ccac24a5b0 Fix Base58 padding for string representation of binary data (#4527). 2024-01-02 19:11:11 -05:00
Richard Moore
f6d155c820 admin: update dist files 2023-12-19 04:53:50 -05:00
Richard Moore
180221574c Fix uncatchable issue when sending transactions over JSON-RPC and provide some retry-recovery for missing v (#4513). 2023-12-19 04:52:38 -05:00
Richard Moore
6ee1a5f8bb docs: Fixed some grammar in getting-started (#4486, #4487, #4488) 2023-12-05 16:51:45 -05:00
Richard Moore
98910ba01e admin: update changelog after build-clean 2023-11-27 06:14:57 -05:00
Richard Moore
d60dfc14a3 admin: updated dist files 2023-11-27 06:11:49 -05:00
Richard Moore
f8f11c754a Use provider-specified suggested priority fee when available, otherwise fallback onto existing logic of 1 gwei (#4463). 2023-11-27 06:04:52 -05:00
Richard Moore
4681b83d51 Add auto-detected static network support to providers and allow customizing socket provider options (#4199, #4418, #4441). 2023-11-27 05:23:10 -05:00
Richard Moore
9e74d14432 Added Base network to AlchemyProvider (#4384). 2023-11-25 17:52:15 -05:00
Richard Moore
2b67488151 Fixed ParamType formatting causing bad tuple full and minimal ABI output (#4329, #4479). 2023-11-25 17:46:30 -05:00
Richard Moore
da34e3569e Account for provider config weight when kicking off a request in FallbackProvider (#4298). 2023-11-23 21:26:26 -05:00
Richard Moore
e2485b8ef9 More robust FallbackProvider broadcast (#4186, #4297, #4442). 2023-11-16 20:39:21 -05:00
Richard Moore
93fb138809 admin: style fix (#4356) 2023-11-11 18:48:30 -05:00
Richard Moore
944cbbc0a5 tests: bumped Node versions for testing (#4451) 2023-11-11 18:47:10 -05:00
Richard Moore
a92766e56a Added safe and finalized provider events (#3921). 2023-11-11 18:41:40 -05:00
Richard Moore
cf00331309 admin: updated dist files 2023-11-11 18:00:39 -05:00
Richard Moore
ee79d7d005 admin: added diff scripts for build page 2023-11-11 17:58:48 -05:00
Richard Moore
aff7addfd9 docs: fixed typo in jsdocs for Wallet.createRandom (#4461) 2023-11-10 23:00:50 -05:00
Richard Moore
39315288be docs: updated the readme with more recent URLs and info 2023-11-02 14:56:36 -04:00
Richard Moore
1c71ec6df6 docs: fixed jsdocs for signMessage (#4314) 2023-11-02 14:48:45 -04:00
Richard Moore
1d9c0197a2 docs: removed Pocket from list of community resources (#4345) 2023-11-02 14:47:56 -04:00
Richard Moore
168518f1cb docs: fixed typos in Fetch jsdocs (#4355) 2023-11-02 14:44:53 -04:00
Richard Moore
e9fac926c9 docs: fixed typo in ENS cookbook (#4379) 2023-11-02 14:39:03 -04:00
Richard Moore
238f4f64ca docs: fixed typo from copy-paste ENS cookbook example (#4382) 2023-11-02 14:38:04 -04:00
Richard Moore
d11a2b5a5e docs: fixed typos in signing cookbook (#4400) 2023-11-02 14:37:05 -04:00
Richard Moore
61a66e413a docs: fixed typo in ens cookbook (#4401) 2023-11-02 14:35:19 -04:00
Richard Moore
22b7a2c111 docs: fixed typo in jsdocs (#4417) 2023-11-02 14:33:28 -04:00
Richard Moore
5d62591796 docs: fixed typos in jsdocs (#4421). 2023-11-02 14:32:39 -04:00
Richard Moore
85a039f180 docs: fixed typo in migrations docs (#4435) 2023-11-02 14:29:08 -04:00
Richard Moore
5431723ec3 admin: updated dist files 2023-11-01 16:17:49 -04:00
Richard Moore
8fed2f8476 Fixed typo in error description when converting values to arrays (#4427, #4446). 2023-11-01 16:04:27 -04:00
Richard Moore
73adb393e8 docs: fixed typo in jsdocs (#4391). 2023-11-01 15:58:07 -04:00
Richard Moore
2e0bd90744 Fix invalid token nonpayable being included in formatted constructor (#4412). 2023-11-01 15:56:47 -04:00
Richard Moore
1da50ae286 Add ENS support for Sepolia (#4422). 2023-11-01 15:55:05 -04:00
Richard Moore
e0c1d976b2 tests: only trigger browser testing when relevant code changed 2023-10-11 02:14:04 -04:00
Richard Moore
e454afb2fa tests: fix typo in env prepare scripts 2023-10-11 02:12:06 -04:00
Richard Moore
4772915f0c tests: updated env tests for TypeScript 5.2 2023-10-11 02:10:52 -04:00
Richard Moore
3a73c56ee3 admin: updated dist files 2023-10-10 22:41:46 -04:00
Richard Moore
c847f16d5c Fixed internal ens-normalize testcase for empty string. 2023-10-10 22:40:41 -04:00
Richard Moore
125ff1189b Replicated former ENS normalize behaviour for empty strings and update namehash testcases. 2023-10-10 22:22:55 -04:00
Richard Moore
bc115a2733 docs: update docs building info 2023-10-09 20:28:22 -04:00
Richard Moore
3644140861 admin: updated dist files 2023-10-09 20:27:56 -04:00
Richard Moore
aca848f772 admin: bump ens-normalize package 2023-10-09 20:22:04 -04:00
Richard Moore
d6a8c14d90 Initial shortMessage support for errors (#4241). 2023-10-09 20:20:32 -04:00
Richard Moore
2616f4c30c Fixed resolving ENS addresses used as from parameters (#3961). 2023-10-09 19:34:58 -04:00
Richard Moore
cd5f0fe03f Merge branch 'v5.8-progress' 2023-10-09 18:36:46 -04:00
Richard Moore
9a4b753445 Allow more loose input format for RLP encoder (#4402). 2023-10-09 18:35:44 -04:00
Richard Moore
06db040822 admin: added drips authentication 2023-10-02 04:51:55 -04:00
Richard Moore
0c9c23b02d docs: added docs to getDefaultProvider; fixes search in Flatworm (#4254). 2023-09-27 18:27:24 -04:00
Richard Moore
b27faa02ac Update to latest noble crypto libraries (#3975). 2023-09-13 03:27:40 -04:00
Richard Moore
9541f2f70c More robust configuration options for FetchRequest getUrl functions (#4353). 2023-09-13 02:54:03 -04:00
Richard Moore
c7f8abefa4 docs: fix typo in jsdocs 2023-09-12 21:28:45 -04:00
Richard Moore
dcea9b3536 Ignore blockTag when calling Etherscan if it is the default block tag. 2023-09-12 21:28:14 -04:00
Richard Moore
bc6cfbf2cc docs: added info on transaction order within a block and commify migration info (#4343, #4352) 2023-09-12 21:25:59 -04:00
Richard Moore
77fcc7fdab docs: added some cookbook recipes 2023-09-12 03:27:29 -04:00
Richard Moore
32915634be admin: udpated dist files 2023-08-15 03:08:10 -04:00
Richard Moore
7d4173049e Prevent destroyed providers from emitting network detection errors. 2023-08-15 03:07:03 -04:00
Richard Moore
30d3d6ee32 admin: updated dist files 2023-08-15 00:58:04 -04:00
Richard Moore
71606b5799 docs: remove beta target in getting started docs (#4147) 2023-08-15 00:56:12 -04:00
Richard Moore
4d2e1ff810 docs: added solidity packed functions to migration docs (#4289) 2023-08-15 00:54:56 -04:00
Richard Moore
203dfc33b9 Fixed VSCode lint vs tsc discrepency (#4153, #4156, #4158, #4159). 2023-08-14 20:05:38 -04:00
Richard Moore
4eb84da865 Fix VSCode reported lint issues (#4153, #4156, #4158, #4159). 2023-08-14 20:00:45 -04:00
Richard Moore
609e2f53eb admin: updated devDependency semver 2023-08-14 19:40:50 -04:00
Richard Moore
2710077bea docs: add title for socket providers section 2023-08-14 19:34:41 -04:00
Richard Moore
0df3ab9313 Add gasPrice to Polygon feeData for type 0 and type 1 legacy transactions (#4315). 2023-08-14 19:34:01 -04:00
Richard Moore
b4fb1a166d docs: fixed typo in error message (#4306) 2023-08-10 14:20:41 -04:00
Richard Moore
dfe1eefd03 docs: better align jsdocs with parameter names (#4292) 2023-08-10 14:19:23 -04:00
Richard Moore
6fda150426 docs: fixed typo (discord) 2023-08-08 23:36:21 -04:00
Richard Moore
c5cb7cd71d admin: updated dist files 2023-08-02 23:52:01 -04:00
Richard Moore
e45bc77cd9 tests: add faucet address to output for refilling 2023-08-02 23:51:09 -04:00
Richard Moore
c3971ab428 docs: updated jsdocs for flatworm generation 2023-08-02 23:48:42 -04:00
Richard Moore
d6be75f266 admin: update dist files 2023-08-02 23:42:17 -04:00
Richard Moore
25fef4f8d7 Fixed receipt wait not throwing on reverted transactions. 2023-08-02 19:07:50 -04:00
Richard Moore
ff80b04f31 Added custom priority fee to Optimism chain (via telegram). 2023-08-02 18:37:54 -04:00
Richard Moore
f3c46f2299 Add context to Logs that fail decoding due to ABI issues to help debugging. 2023-08-02 18:29:50 -04:00
Richard Moore
d32f81b3c3 Merge branch 'main' into v6.7.0-progress 2023-07-29 02:37:03 -04:00
Richard Moore
17969fe416 admin: updated dist files 2023-07-28 14:50:56 -04:00
Richard Moore
0dca645632 Prevent malformed logs from preventing other logs being decoded (#4275). 2023-07-28 14:48:55 -04:00
Richard Moore
3a52201fe2 Allow visibility on human-readable constructors (via telegram). 2023-07-28 14:14:23 -04:00
Richard Moore
b5724e4713 admin: updated dist files 2023-07-28 01:14:37 -04:00
Richard Moore
aa2ea3d529 Better error message when passing invalid overrides object into a contract deployment (#4182). 2023-07-28 01:13:21 -04:00
Richard Moore
b1dbbb0de3 Added new exports for FallbackProviderOptions and FetchUrlFeeDataNetworkPlugin (#2828, #4160). 2023-07-28 00:34:29 -04:00
Richard Moore
f42f258beb Allow overriding pollingInterval in JsonRpcProvider constructor (via discord). 2023-07-27 20:53:55 -04:00
Richard Moore
78538eb100 Fixed FallbackProvider priority sorting (#4150). 2023-07-27 20:51:07 -04:00
Richard Moore
d3e5e2c45b Added linea network to InfuraProvider and Network (#4184, #4190). 2023-07-27 20:49:02 -04:00
Richard Moore
82bb936542 Added whitelist support to getDefaultProvider. 2023-07-27 20:21:55 -04:00
Richard Moore
23704a9c44 Add Polygon RPC endpoints to the default provider (#3689). 2023-07-27 20:11:08 -04:00
Richard Moore
8f0a50921a Added customizable quorum to FallbackProvider (#4160). 2023-07-27 19:51:50 -04:00
Richard Moore
229145ddf5 Added basic Gas Station support via a NetworkPlugin (#2828). 2023-07-27 18:04:46 -04:00
Richard Moore
ec39abe067 Add BNB URLs to EtherscanProvider networks. 2023-07-26 17:07:38 -04:00
Richard Moore
ff9d124c60 admin: updated dist files 2023-07-24 17:48:37 -04:00
Richard Moore
ba36079a28 Added tests for JSON format (#4248). 2023-07-24 17:45:27 -04:00
Richard Moore
8c2652c8cb Use empty string for unnamed parameters in JSON output instead of undefined (#4248). 2023-07-24 17:44:42 -04:00
Richard Moore
5bf7b3494e Return undefined for Contract properties that do not exist instead of throwing an error (#4266). 2023-07-24 17:38:32 -04:00
Richard Moore
bcc4d8c870 admin: updated dist files 2023-07-24 00:06:04 -04:00
Richard Moore
ac2f5e563b Reflect symbols in the Contract Proxy to target (#4048). 2023-07-24 00:03:12 -04:00
Richard Moore
93af87c447 Allow arrays of address for indexed filter topics (#4259). 2023-07-23 23:58:16 -04:00
Richard Moore
fa3a883ff7 Fixed filter encoding for bytesX (#4244). 2023-07-23 23:48:47 -04:00
Richard Moore
a8bc49bdcf Fix JSON formatting for tuple arrays (#4237). 2023-07-23 22:50:49 -04:00
Richard Moore
e36b6c35b7 Better error messages when parsing fragment strings (#4246). 2023-07-23 12:59:10 -04:00
Richard Moore
450a176ee2 Include the missing fragment key and args when no matching Contract method or event is present (#3809). 2023-07-23 12:36:52 -04:00
Richard Moore
b1375f4e44 Prevent a single malformed event from preventing other Contract logs; reported on Discord. 2023-07-23 12:30:21 -04:00
Richard Moore
5a56fc36d7 admin: updatd dist files 2023-07-16 00:36:12 -04:00
Richard Moore
a7e4048fe3 More robust support for Signatures with less standard parameter values (#3835, #4228). 2023-07-16 00:33:50 -04:00
Richard Moore
330c318773 admin: updated dist files 2023-07-15 17:55:24 -04:00
Richard Moore
57f1e1c471 Fixed CCIP-read in the EnsResolver (#4221). 2023-07-15 17:51:38 -04:00
Richard Moore
19cbcaf3b0 docs: fixed typo in jsdocs 2023-07-15 17:46:53 -04:00
Richard Moore
492919d14f Skip checking confirmation count if confirms is 0 (#4229, #4242). 2023-07-15 17:45:37 -04:00
Richard Moore
43c253a402 Fixed waiting for confirmations in deployment transactions (#4212, #4230). 2023-07-15 17:25:46 -04:00
Richard Moore
fe631c6f1f docs: fixed typo in migration docs (#4125). 2023-07-15 17:20:57 -04:00
Richard Moore
1dd542721d admin: updated dist files 2023-07-11 20:55:58 -03:00
Richard Moore
80f62efc41 Throw more desscriptive error for unconfigured ENS name contract targets (#4213). 2023-07-11 20:54:37 -03:00
Richard Moore
7d061b786f Fixed contract once not running stop callback. 2023-07-11 20:42:43 -03:00
Richard Moore
3c17cf56b5 admin: updated dist files 2023-06-27 23:31:10 -02:30
Richard Moore
9197f9f938 Wider error detection for call exceptions on certain backends (#4154, #4155). 2023-06-27 23:28:57 -02:30
Richard Moore
1dc8986a33 Added wider error deetection for JSON-RPC unsupported operation (#4162). 2023-06-27 11:18:21 -03:00
Richard Moore
3d141b44b5 Fixed formatUnits and parseUnits for values over 128 bits (#4037, #4133). 2023-06-27 10:58:22 -03:00
Richard Moore
d2b5f1da02 admin: updated dist files 2023-06-23 00:35:07 -04:00
Richard Moore
857aa8ccc3 Prevent CCIP-read flags being passed to EtherscanProvider (#4043) 2023-06-23 00:33:43 -04:00
Richard Moore
3df09fcbe6 admin: updated dist files 2023-06-23 00:07:06 -04:00
Richard Moore
d51e3fbff4 Fixed CCIP read in contract calls (#4043). 2023-06-23 00:04:16 -04:00
Richard Moore
5210b68a78 docs: fix typos 2023-06-13 21:47:55 -04:00
Richard Moore
31cc4edf2c admin: updated dist files 2023-06-13 21:47:44 -04:00
Richard Moore
203a759efc Add exports for AbstractProviderOptions and for MulticoinProviderPlugin. 2023-06-13 21:41:33 -04:00
Richard Moore
de0f5189f6 Add option to adjust perform cache timeout in AbstractProvider. 2023-06-13 21:40:26 -04:00
Richard Moore
84375be92d Add full support for MultiCoin plugins and automatic detection for EVM-compatible coin types (#3888, #4081). 2023-06-13 16:26:40 -04:00
Richard Moore
2318005dfd Allow Interface instances where InterfaceAbi are allowed (#4142). 2023-06-13 16:22:40 -04:00
Richard Moore
9055ef6c69 Allow Numeric type for decimals in FixedNumber (#4141). 2023-06-12 22:11:08 -04:00
591 changed files with 22265 additions and 8456 deletions

View File

@ -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

View File

@ -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

View File

@ -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
@ -98,7 +98,7 @@ jobs:
name: coverage-complete
path: ./output/coverage.tar
- name: Upload coverage to to build.ethers.org
- name: Upload coverage to build.ethers.org
uses: ethers-io/sync-s3-action@main
with:
aws_access_key_id: ${{ secrets.BUILD_AWS_ACCESS_KEY_ID }}

View File

@ -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

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
node_modules/**
output/**
**/*.save
**/*.swp
**/*.tgz
dist/*.gz

1
.npmrc Normal file
View File

@ -0,0 +1 @@
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/

View File

@ -3,6 +3,181 @@ Change Log
This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.
ethers/v6.12.0 (2024-04-17 01:09)
---------------------------------
- Added Linea Sepolia network and Infura endpoint ([#4655](https://github.com/ethers-io/ethers.js/issues/4655); [b4aaab8](https://github.com/ethers-io/ethers.js/commit/b4aaab8d39fe47f8a1a296fa442f0856f84faf03)).
- Do not send unsubscribe messages to destroyed Providers ([#4678](https://github.com/ethers-io/ethers.js/issues/4678); [c45935e](https://github.com/ethers-io/ethers.js/commit/c45935e29ca0dd1ecdf1277fa1107246041be580)).
- Get definitive network from InfuraProvider when using InfuraWebSocketProvider ([38e32d8](https://github.com/ethers-io/ethers.js/commit/38e32d82145eb289e5179f9b6b11f4a9225a7022)).
- Better error messages for transaction field mismatch ([#4659](https://github.com/ethers-io/ethers.js/issues/4659); [9230aa0](https://github.com/ethers-io/ethers.js/commit/9230aa0b9a88b5241915a8d6afa8a522d35abd5d)).
- Added prevRandao to block ([#3372](https://github.com/ethers-io/ethers.js/issues/3372); [ec6a754](https://github.com/ethers-io/ethers.js/commit/ec6a754f0c8647dae59c73b2589225cb200d83dd)).
- Added Polygon Amoy testnet ([#4645](https://github.com/ethers-io/ethers.js/issues/4645); [1717abb](https://github.com/ethers-io/ethers.js/commit/1717abbf29a14a6f6b106e479fe9a5b1f8768dc4)).
- Added Chainstack provider ([#2741](https://github.com/ethers-io/ethers.js/issues/2741); [014004d](https://github.com/ethers-io/ethers.js/commit/014004d9402d7fd8c15553792cfb7a8a84ed327a)).
- Added deep convertion to Result for toObject and toArray ([#4681](https://github.com/ethers-io/ethers.js/issues/4681); [03bfe2a](https://github.com/ethers-io/ethers.js/commit/03bfe2a4f7b29b15cd90127974b7fc1d8b03edf9)).
- Added EIP-4844 broadcast support ([92bad88](https://github.com/ethers-io/ethers.js/commit/92bad88261a5d8a538535a7d5528162fe5010527)).
- Fix ignored throttle parameters ([#4663](https://github.com/ethers-io/ethers.js/issues/4663); [12772e9](https://github.com/ethers-io/ethers.js/commit/12772e9498b70f8538838f30e16f3792ea90e173)).
ethers/v6.11.1 (2024-02-14 13:13)
---------------------------------
- Throw an error when attempting to derive from a master path from a non-master node ([#4551](https://github.com/ethers-io/ethers.js/issues/4551); [556fdd9](https://github.com/ethers-io/ethers.js/commit/556fdd91d9b6bf7db4041bb099e66b2080e1a985)).
- Allow ENS wildcards with labels up to 255 bytes wide; discussed with ENS and deemed safe ([#4543](https://github.com/ethers-io/ethers.js/issues/4543); [7f14bde](https://github.com/ethers-io/ethers.js/commit/7f14bdebf1aef6760462a1c2437c31f002b984fe)).
- Enforce string is passed to toUtf8Bytes ([#4583](https://github.com/ethers-io/ethers.js/issues/4583); [f45bb87](https://github.com/ethers-io/ethers.js/commit/f45bb87aefaf2c6c3a4991f6e30a81c227ae83c0)).
- Fix transaction.index not being populated on some backends ([#4591](https://github.com/ethers-io/ethers.js/issues/4591); [7f0e140](https://github.com/ethers-io/ethers.js/commit/7f0e140d5e3925a42e8bb2ac9eb1ba3fbd939864)).
ethers/v6.11.0 (2024-02-08 20:26)
---------------------------------
- Allow transaction encoding for inferred type transactions ([f02211d](https://github.com/ethers-io/ethers.js/commit/f02211d055567b51373b5faa2c3dc6efe0523618)).
- Added EIP-4788, receipts root and state root fields to Block ([#4570](https://github.com/ethers-io/ethers.js/issues/4570); [c5f126f](https://github.com/ethers-io/ethers.js/commit/c5f126faf7d826b6a99df0ee578ff3d0ef409381)).
- Added EIP-4844 fields to Provider classes and formatter ([#4570](https://github.com/ethers-io/ethers.js/issues/4570); [7b4f2c1](https://github.com/ethers-io/ethers.js/commit/7b4f2c1a74db411829b5e8ef758bfa2ee21e5890)).
- Assert BrowserProvider receives an EIP-1193 provider to fail early when passing undefined ethereum object ([b69f43b](https://github.com/ethers-io/ethers.js/commit/b69f43bc6f35da881ca7a0c8ccc5fda92edd076d)).
- Add timeout to ContractTransactionResponse wait ([#4497](https://github.com/ethers-io/ethers.js/issues/4497); [095de51](https://github.com/ethers-io/ethers.js/commit/095de51e605a9b88576e5e34fd55a6e32befa4eb)).
- Allow override keyword in human-readable ABI and improve error messages ([#4514](https://github.com/ethers-io/ethers.js/issues/4514), [#4548](https://github.com/ethers-io/ethers.js/issues/4548); [be5ec2d](https://github.com/ethers-io/ethers.js/commit/be5ec2d327a503b2e5fc0f37c47eee9e828f8e23)).
- Expand Contract sub-class to accept BaseContract super-class constructor arguments ([#4538](https://github.com/ethers-io/ethers.js/issues/4538); [98496bc](https://github.com/ethers-io/ethers.js/commit/98496bc48ec23ce0d9c21d3c6c87e5b1b796a610)).
- Allow network for default provider to be null to select mainnet ([#4501](https://github.com/ethers-io/ethers.js/issues/4501); [b6bf7ab](https://github.com/ethers-io/ethers.js/commit/b6bf7aba62fb38839cd01858432b801cc5c28a11)).
- Allow long dnsEncode names with optional length parameter ([#4543](https://github.com/ethers-io/ethers.js/issues/4543); [a136348](https://github.com/ethers-io/ethers.js/commit/a1363483a56b0dee342595c8f44ed8fcce7ecca9)).
- Fix parseLog signature when receiving read-only array for topics ([#4029](https://github.com/ethers-io/ethers.js/issues/4029), [#4459](https://github.com/ethers-io/ethers.js/issues/4459); [20cd8a2](https://github.com/ethers-io/ethers.js/commit/20cd8a23eaf8e8a14e2b51f7f64da4cb3e32fccb)).
- Use Secure endpoints for BNB on Etherscan ([#4525](https://github.com/ethers-io/ethers.js/issues/4525); [1f6e188](https://github.com/ethers-io/ethers.js/commit/1f6e1882515195bd67f0bce9fe347ec05107324b)).
- Added holesky network and related end-points for supporting providers ([c6e6c43](https://github.com/ethers-io/ethers.js/commit/c6e6c432574a0b7e55c300ab3e470aafdace28b3)).
- Added EIP-4844 BLOb transactions ([#4554](https://github.com/ethers-io/ethers.js/issues/4554); [9c1e82e](https://github.com/ethers-io/ethers.js/commit/9c1e82e1230526ebcd62902890c4f24b1f7f7d79)).
- Normalize EIP-712 types before computing the payload ([#4541](https://github.com/ethers-io/ethers.js/issues/4541); [56c1361](https://github.com/ethers-io/ethers.js/commit/56c1361ee83db8b68859caf0850c95ff70e7e306)).
- Updated thrid-part provider URLs for QuickNode ([2b4891d](https://github.com/ethers-io/ethers.js/commit/2b4891d86e72e849079cb1dc98b18e158b0c0620)).
- Fixed normalization and abstracted EIP-712 Array parsing ([#4541](https://github.com/ethers-io/ethers.js/issues/4541); [8f99601](https://github.com/ethers-io/ethers.js/commit/8f99601df1f26a8ba4d6d9dea5e033e7f688107e)).
- Updated third-party provider network URLs ([#4542](https://github.com/ethers-io/ethers.js/issues/4542); [84ca14f](https://github.com/ethers-io/ethers.js/commit/84ca14f1ffc5afbdd7f4c26a9b734ec5951eee3c)).
- Added additional sepolia testnets ([4efef76](https://github.com/ethers-io/ethers.js/commit/4efef76e8cab0acaf1b2ba231a0148f9381bb1ee)).
- Fix EIP-712 type aliases for uint and int ([#4541](https://github.com/ethers-io/ethers.js/issues/4541); [43fb9c2](https://github.com/ethers-io/ethers.js/commit/43fb9c233696aeaa80b1c2b0e5fafce90e0ad508)).
- Fixed typo in Error string ([#4539](https://github.com/ethers-io/ethers.js/issues/4539); [7882905](https://github.com/ethers-io/ethers.js/commit/78829050853093bc5291ae78fc5a904044759aa0)).
- Better debugging output on fetch errors ([bee07a0](https://github.com/ethers-io/ethers.js/commit/bee07a0750b448a9d13c2d57014bcf27f43e2ed7)).
ethers/v6.10.0 (2024-01-12 19:46)
---------------------------------
- Limit decoded result imflation ratio from ABI-encoded data ([#4537](https://github.com/ethers-io/ethers.js/issues/4537); [1b4debd](https://github.com/ethers-io/ethers.js/commit/1b4debd4a9e61d171bfc60590116facb8bdbd2da)).
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)
--------------------------------

7
FUNDING.json Normal file
View File

@ -0,0 +1,7 @@
{
"drips": {
"ethereum": {
"ownedBy": "0x89EdE5cBE53473A64d6C8DF14176a0d658dAAeDC"
}
}
}

View File

@ -47,6 +47,7 @@ For the latest changes, see the
**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)
@ -116,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
@ -126,8 +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 (coming soon)
- Account Abstraction (coming soon)
- [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

6242
dist/ethers.js vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

6248
dist/ethers.umd.js vendored

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

View File

@ -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.5.1";
const version = "6.12.0";
/**
* Property helper functions.
@ -243,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) {
@ -259,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));
@ -290,6 +243,9 @@ function makeError(message, code, info) {
if (info) {
Object.assign(error, info);
}
if (error.shortMessage == null) {
defineProperties(error, { shortMessage });
}
return error;
}
/**
@ -547,6 +503,7 @@ function getUtf8CodePoints(_bytes, onError) {
* If %%form%% is specified, the string is normalized.
*/
function toUtf8Bytes(str, form) {
assertArgument(typeof (str) === "string", "invalid string value", "str", str);
if (form != null) {
assertNormalize(form);
str = str.normalize(form);
@ -601,14 +558,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];
@ -620,14 +579,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);
@ -688,7 +647,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');
@ -701,7 +660,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;
@ -727,8 +686,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;
@ -749,11 +708,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);
@ -784,25 +743,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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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
View 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"));
})();

View 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)

View 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();
});

View 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...//

View File

@ -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

View File

@ -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)

View File

@ -1,5 +1,6 @@
link-alchemy [Alchemy](https://alchemy.com/?a=ethers)
link-ankr [Ankr](https://www.ankr.com)
link-chainstack [Chainstack](https://chainstack.com)
link-cloudflare [Cloudflare](https://developers.cloudflare.com/distributed-web/ethereum-gateway/)
link-ens [ENS](https://ens.domains/)
link-ethereum [Ethereum](https://ethereumorg)
@ -45,3 +46,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)

View File

@ -31,6 +31,8 @@ link-eip-2098 [EIP-2098](https://eips.ethereum.org/EIPS/eip-2098)
link-eip-2304 [EIP-2304](https://eips.ethereum.org/EIPS/eip-2304)
link-eip-2718 [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)
link-eip-2930 [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)
link-eip-4788 [EIP-4844](https://eips.ethereum.org/EIPS/eip-4788)
link-eip-4844 [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
# Open Standards
link-base58 [Base58](https://en.bitcoinwiki.org/wiki/Base58)

View File

@ -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>
@ -225,6 +225,27 @@ _code: broadcasting transactions @lang<script>
provider.broadcastTransaction(signedTx)
The ``StaticJsonRpcProvider`` in v5 is now integrated into the v6
``JsonRpcProvider`` directly. When connecting to a network which
cannot change its network, it is much more efficient to disable
the automatic safety check ethers performs.
_code: Create a Provider on a static network @lang<script>
// v5
provider = new StaticJsonRpcProvider(url, network);
// v6: If you know the network ahead of time and wish
// to avoid even a single eth_chainId call
provider = new JsonRpcProvider(url, network, {
staticNetwork: network
});
// v6: If you want the network automatically detected,
// this will query eth_chainId only once
provider = new JsonRpcProvider(url, undefined, {
staticNetwork: true
});
_subsection: Signatures @<migrate-signatures>
The Signature is now a class which facilitates all the parsing
@ -314,7 +335,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 +369,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 +384,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>

View File

@ -1,4 +1,4 @@
export type TestBlockchainNetwork = "mainnet" | "goerli";
export type TestBlockchainNetwork = "mainnet" | "goerli" | "sepolia";
export interface TestBlockchainAddress {
test: string;
address: string;
@ -22,12 +22,18 @@ export interface TestBlockchainBlock {
extraData: string;
transactions: Array<string>;
baseFeePerGas?: bigint;
blobGasUsed?: bigint;
excessBlobGas?: bigint;
parentBeaconBlockRoot?: string;
stateRoot?: string;
receiptsRoot?: string;
}
export interface TestBlockchainTransaction {
test: string;
hash: string;
blockHash: string;
blockNumber: number;
index: number;
type: number;
from: string;
gasPrice: bigint;
@ -40,7 +46,7 @@ export interface TestBlockchainTransaction {
r: string;
s: string;
yParity: 0 | 1;
v: number;
v?: number;
networkV: null | bigint;
};
creates: null | string;
@ -48,6 +54,8 @@ export interface TestBlockchainTransaction {
accessList?: Array<Record<string, Array<string>>>;
maxPriorityFeePerGas?: bigint;
maxFeePerGas?: bigint;
maxFeePerBlobGas?: bigint;
blobVersionedHashes?: Array<string>;
}
export interface TestBlockchainReceipt {
test: string;
@ -75,6 +83,8 @@ export interface TestBlockchainReceipt {
to: string;
hash: string;
index: number;
blobGasUsed?: bigint;
blobGasPrice?: bigint;
}
export declare const testAddress: Record<TestBlockchainNetwork, Array<TestBlockchainAddress>>;
export declare const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>>;

View File

@ -1 +1 @@
{"version":3,"file":"blockchain-data.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/blockchain-data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,SAAS,GAAG,QAAQ,CAAC;AAEzB,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE5B,aAAa,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IAEpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC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qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAyBnF,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAmK/E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CA2F3F,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CA6GnF,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,qBAAqB,CAErD,CAAC;AACF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQ7E"}

View File

@ -23,7 +23,8 @@ exports.testAddress = {
name: "ricmoo.firefly.eth"
},
],
goerli: []
goerli: [],
sepolia: []
};
exports.testBlock = {
mainnet: [
@ -39,6 +40,8 @@ exports.testBlock = {
gasUsed: BigInt("0"),
miner: "0x5088D623ba0fcf0131E0897a91734A4D83596AA0",
extraData: "0x476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34",
stateRoot: '0x76ab0b899e8387436ff2658e2988f83cbf1af1590b9fe9feca3714f8d1824940',
receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
transactions: []
},
{
@ -54,6 +57,8 @@ exports.testBlock = {
miner: "0x2A20380DcA5bC24D052acfbf79ba23e988ad0050",
extraData: "0x706f6f6c696e2e636f6d21f7092f019bb92a76",
baseFeePerGas: BigInt("40911884304"),
stateRoot: '0xd08663f630cfcf2d7d8fe4d52f7685ad09798b7e6150cabea5eeceb1d89e11c2',
receiptsRoot: '0x473e83ec3df279f44c4fc6da50fe1d0c5a18f1929b90de8917bdcdb88a132750',
transactions: [
"0x1c3a398933db10634631f54b435c40c8805c13f12bbac7c3dab858ca44213fa2",
"0xd98947cbdd892cc7f679c903903e6d18a5c5afb19e94437beba79372ad71c347",
@ -86,6 +91,104 @@ exports.testBlock = {
}
],
goerli: [],
sepolia: [
{
test: "eip-4844-BLob-block",
hash: "0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d",
parentHash: "0x2b579cb7224abdbe7a66c76380d60329bba41d95d225feb80ca1a78cf83a5124",
parentBeaconBlockRoot: '0xa05d27aa9c2f3d57943ca86134a08f6f7852ad5e9dbe360f86b466e2f0ed7bb5',
number: 5198187,
timestamp: 1706801700,
nonce: "0x0000000000000000",
difficulty: BigInt(0),
gasLimit: BigInt("30000000"),
gasUsed: BigInt("5622957"),
baseFeePerGas: BigInt("48793932840"),
miner: "0x008b3b2F992C0E14eDaa6E2c662Bec549CAA8df1",
extraData: "0x",
blobGasUsed: BigInt("524288"),
excessBlobGas: BigInt("79691776"),
stateRoot: '0xa78ad0e0f5d2b3383fdb13f4ad0523723816863556be3a5414536862f4d217df',
receiptsRoot: '0xa254ed337328248b77011c70c2b85d6575f965f2fe65ed233c27e3750c0b7170',
transactions: [
"0xe8a096a98cd7b8d783cbb30687c3adc8e59f1e9563c0454623cc8af59f8bcab1",
"0x5aac2d50b15e177e8edaae4819e989650a6cdb335dd8924b5a7a7ed1675d15e7",
"0x21c94c24419f746efd2c1f470c0842df21ab8da14f7db8e30a12c53a4e7d5145",
"0x85b40ce37262a7962487bd37bf36867b344525b425a90a25516ac3c2cb1f6535",
"0x1a674ff3bd6bbe7bc7ada2ae3da893a7b74b4cfaadebc8c3f0fe0c9ad3c1c35b",
"0x48cafe99a7d2284a1664e05c404dd88e4113ffb65bf49846716bd855ffc6835d",
"0x658065003e8952782d121d9b5729845862c2a45ed24e46c634041a77c4577bed",
"0xc5416e0a2383b1a9b3ba030803f88e45faebfb35ad5db022e44a09b15aeae385",
"0x9030f7962f3f638f96bb703f45cdaa8778cf393ead767592aa50bce32230eae3",
"0xce008888308a4c1d51f87a1c2a75b1d0bd15eb096c675ad091dcc9705e4d016d",
"0xcf17c1f09a22c992a469da0023ad3c9bd2c29a8532146bcdf9ce3216609ea50c",
"0x3933e49a215c80b35ec7d48e2741fda50c8cc7b92652e79663e4423c00e8e1e2",
"0x82b2af4ed108880c151ee38cb3ab28e81ba86a2b0e707dd9cee9bf341f895a8a",
"0x51ef5af42d572d6135bec154d5c754928465bad00d1ff7b769a5b65e0054a90e",
"0x87cab3ae3a36d439a539ded7eb57e0ef07c5a1fbe1697c2e5ba8d7c03875fd22",
"0x70371a20dfbff0ee753b52cd9445f431454b929c7375624a96f5dbc25e88afed",
"0x57ee8a4a09875b7720f7d9e75fb93a1cc86d166ad9a1b4c2d7cf2c7c8324fbc0",
"0xf004bd2b0119aca5f364b16421a5b2e7db811568761f5542fdcd74903cd9115d",
"0x5b6635688362651e1cd33c668bd748d964ba93006661e53dc117d1c1e44886a5",
"0xe5893e07bfec18dd206da279a47ee5cc9471930bbb3b85d64ee4945b98137348",
"0x4f0f48032a77a80550f71cbcbe86f7d1b34009910f12dbe153a93cb66965393e",
"0x5420c3f7b5118e0829df31794aa55a1a91e0009600bbff283b553d5ac7a248ff",
"0xece2175e4b06bf6105f5be10a9ed48808a5f96f12f80b3941ee7cb1eeca99e03",
"0x383ea6445cd183e32fbc7b846c00b34c419078fe4055cd078f8692fc02b300c8",
"0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
"0xe7e24b8c8182832e7b1113cd07ae68e4ca8618decdc527650f57d25d0b681fde",
"0xef5f520662c133be33209249fbc93afb7c614c06a0b45086d15c33bd7c0ca47a",
"0x4af20dc2e952e381789065f2cd0c88730fea820bcc3db82eaddf63b36e65b3ac",
"0xf99eef2240abc5002c9d71a90ffd463935642aaf81213f37337327c1afcb502c",
"0xf7d1ad53e2435e6d978563e39db89660d1b4de6084a3a3cefe7025d28507017f",
"0xfc21e64a158ac26ea9afc754460e16fefc4316a3fb92ec9a6042b792d7855788",
"0xee60e551bcf518853ef4f5c33551ad07fa95267814940c4203934c79355b1ac0",
"0x2a3c649caf77b942b206b9eb1be4635d950cf9a15fea2b43d3d7cbeddf700739",
"0xbbd7b9c1434eb98d177f2ff8911b0186309534dea942c40a86517d69247cd0ac",
"0xd86daa6d16e2aee4fc6ae831336ada63623685fb998dc5c605284a034604d751",
"0xcfc848dfbbbe76fe0095f04ef35c931799c294eb3623e5cb8c0d81362e8bf125",
"0x71e3ea97c91bd14388d99d69d122314a1cf0d595cbad1e45040277b470c4e67b",
"0xa9b2e44e46d38bb67cbd7a2d47d57e60892dff018f7754b54a221ae3f1b996c4",
"0xd1b8f9d669bd7f5072a095476e94e90510f2a18b434551fb7852b5c38c41471a",
"0xa3858e80680997080fddde083398e857b14cd4e2cfe74629f6a1245df0447efb",
"0x97593f663b07f8a4555202abb691cf7997210284195c24980abee02040c60618",
"0x03387f22b01919486338fbd874dd7059f8df62d5b16052cb0ab855b6a364777e",
"0xf2561f5f487c3d20c42b42e697a49fb5d05e0fb844ca97b2f127b210475f457e",
"0xa67951a1309f1c7ec07ee518ecad831d12c5c78619250681068e7973243f7d9b",
"0x7b007997da62b3ac9e5a7005066941e74f5c14d0bdaf4ac44faa8c3479b3cf45",
"0x74379408aa3518cbbb394886c91f77ba95ccd37f6b10517834f69a8ff5120ca7",
"0xd4843ef02a0d9802d31a89e13e60b6e71870de9124d0b472047012f7a4320f83",
"0xaa50331afeafd8f9e913a9f78e898e299314d0825936724cc31211ebf177a9bf",
"0xf20c83f2e5d199ad84a7b5dc6fda9611772516e07e7fc71b9f7889af4f2a16aa",
"0x89a7c645987dc079ce1af236ed3dd445ad805cc030e5a57766324d4a0a1def9a",
"0xe8e7d1116c2c60afd063b9c1e87624426cf6c9fd8d3fa6befe25666e68459570",
"0x50be079e71cabf80ca27c39a27f9c0759ac272151f4608b9b75ebfac8284a601",
"0xca24f69d47438ebd0b8f304f2f6d7a513d056905f10b164ed6a2cff6da1d4fea",
"0x08d2521e04dfd0decc2f556b11274212e84076ff84a0135e9b4e3434de09d42a",
"0xcc1e01932a627e9aa20d2b72480d13b4826e128efbbe03526504f7cb9facfc1f",
"0x0a3ac907b6d1584cb3d7f9f588ddb4bdd7878db34bc47bd8baf881dd71a98f7d",
"0x487539ee9cc6933e13e75e94935c30faffa826c28460fed6d9c3a07d15e2617f",
"0xad251856762796acc75dc2846def1f6995fe1b5c747bcab51c10f561d22ffd57",
"0x27ca72aa253e009e5e4497dd838986c561e7bea129fec930bc276968525456a8",
"0xe26391de668d3eb6f5a3c2f3e14f911dc683873b7ea60d883116c205610b36ff",
"0x691c3c5583c5f6444dc6c2f26315a127fc72ebd4f3848055cc8abb8a941d065b",
"0x449578293a1dce8d3c147fed564a765515d090e8cd8866209648eb86cd5c1090",
"0xb79c6f59d533663ca4fa3a70e9c8be18a3761edc43923c2ecd0904447f654f90",
"0xc03863ffa85dd15e0d774ea20006dffd01a868dbf3ff2abe04ccdbf4f027d7ec",
"0x28bc1a65696947beb387adbbeabb5328e5f812c435db288688041d9a8c6ab372",
"0x6dca99c2103d3894ba83c75e0fa0d42f722e5e93fe6f7a6a55a80cf2907a1a5e",
"0x75a7c5f00d79f1b30f82855a8b25077182f1abfd5dbccdf18fe1276e6c9e6a1e",
"0x3fc5a320d8c16bcfe2eda847582d34731abc12a3bffbf334a238b47c0bacb90d",
"0x47a61770f0771ba34d8e8ab883a3d588769a8d387eb5531b4befccb7ea23a6d3",
"0xdc8d0b20e8d8b0fbce50d24eaa36bc56467f35459139dda5e42ffebb1060535c",
"0x65bebb9628b5bf5d5e1dbedf00a7e6610fb5615c7ff9d92adaa135bc88f90648",
"0x9d2f5b7858631ee196bc24d14d2ef1ce07af081d8fe27b2be70ab90bd8edf930",
"0xd7724915af54b4d2c896d05c039f5ba508c878d524eb132c09c3abc22f6111ca",
"0xfda6f72dde86c0b8f84ea7c1e157f1d207dd2e974589cc351404bd5a01fe1d9d",
"0x3fae3676e266af80b0cc810b6b491750b64b013da78935a288b93e33215bee32"
]
},
],
};
exports.testTransaction = {
mainnet: [
@ -94,7 +197,7 @@ exports.testTransaction = {
hash: "0xccc90ab97a74c952fb3376c4a3efb566a58a10df62eb4d44a61e106fcf10ec61",
blockHash: "0x9653f180a5720f3634816eb945a6d722adee52cc47526f6357ac10adaf368135",
blockNumber: 4097745,
// index: 18,
index: 18,
type: 0,
from: "0x32DEF047DeFd076DB21A2D759aff2A591c972248",
gasPrice: BigInt("0x4a817c800"),
@ -118,7 +221,7 @@ exports.testTransaction = {
hash: "0x8ff41d0ba5d239acc8c123ff12451a2c15721c838f657e583d355999af4a4349",
blockHash: '0x9d4c3bef68e119841281105da96beb1c7252f357340d7a3355236b3332b197b0',
blockNumber: 12966000,
// index: 185,
index: 185,
type: 2,
from: '0x5afFBa12E9332bbc0E221c8E7BEf7CB7cfB3F281',
to: '0x2258CcD34ae29E6B199b6CD64eb2aEF157df7CdE',
@ -141,7 +244,42 @@ exports.testTransaction = {
accessList: []
}
],
goerli: []
goerli: [],
sepolia: [
{
test: "EIP-4844-BLOb-tx",
hash: "0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
blockHash: '0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d',
blockNumber: 5198187,
index: 24,
type: 3,
from: '0x1803c760451DC8da8935c7B7E47e1c60910E6986',
to: '0x4f56fFC63c28b72F79b02E91F11a4707bac4043C',
gasLimit: BigInt("21000"),
nonce: 1635,
data: '0x',
value: BigInt("0"),
gasPrice: BigInt("54793932840"),
maxPriorityFeePerGas: BigInt("6000000000"),
maxFeePerGas: BigInt("600000000000"),
maxFeePerBlobGas: BigInt("60000000000"),
chainId: BigInt(11155111),
signature: {
r: "0x56fc10a770e9fa39a30f71a56d13affbdc390a1bfb419ff806e59b54bfc8bab1",
s: "0x35be8b0c774c179520dd43df46925361c4817472441d7dd5162d43efc90679f1",
yParity: 1,
networkV: null
},
creates: null,
accessList: [],
blobVersionedHashes: [
"0x010264a7b018f0edbe5caa5cb309ca50d3d7c6c7c990d21bf30a7f18ffd06cd6",
"0x017fe9ef61e3c501acec804ec15849d977433f4cf87050c098272dd1257f9c68",
"0x019975416c9d7c70ba9cc041464a6e1c3e4f176bdab463573504b55c681364c8",
"0x0123ae55ad7d8e8afec2202bdc6dfb931efc8990acf29afbd0c3c0ef61eae92d"
]
}
]
};
exports.testReceipt = {
mainnet: [
@ -227,10 +365,33 @@ exports.testReceipt = {
index: 0x1e
}
],
goerli: []
goerli: [],
sepolia: [
{
test: "eip-4844-BLOb-receipt",
//byzantium: true,
blockHash: "0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d",
blockNumber: 5198187,
type: 3,
contractAddress: null,
cumulativeGasUsed: BigInt("930313"),
from: "0x1803c760451DC8da8935c7B7E47e1c60910E6986",
gasUsed: BigInt("21000"),
gasPrice: BigInt("54793932840"),
logs: [],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
root: null,
status: 1,
to: "0x4f56fFC63c28b72F79b02E91F11a4707bac4043C",
hash: "0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
index: 24,
blobGasUsed: BigInt("524288"),
blobGasPrice: BigInt("23276216517"),
}
]
};
exports.networkNames = [
"mainnet", "goerli"
"mainnet", "goerli", "sepolia"
];
function networkFeatureAtBlock(feature, block) {
switch (feature) {

File diff suppressed because one or more lines are too long

View File

@ -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;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"}
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkGpD,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"}

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.connect = exports.checkProvider = exports.getProvider = exports.getProviderNetworks = exports.providerNames = exports.setupProviders = void 0;
const index_js_1 = require("../index.js");
;
const ethNetworks = ["default", "mainnet", "goerli"];
const ethNetworks = ["default", "mainnet", "sepolia"];
//const maticNetworks = [ "matic", "maticmum" ];
const ProviderCreators = [
{
@ -31,6 +31,13 @@ const ProviderCreators = [
}
},
*/
{
name: "ChainstackProvider",
networks: ["default", "mainnet", "arbitrum", "bnb", "matic"],
create: function (network) {
return new index_js_1.ChainstackProvider(network);
}
},
{
name: "EtherscanProvider",
networks: ethNetworks,
@ -137,7 +144,7 @@ function getProvider(provider, network) {
exports.getProvider = getProvider;
function checkProvider(provider, network) {
const creator = getCreator(provider);
return (creator != null);
return (creator != null && creator.networks.indexOf(network) >= 0);
}
exports.checkProvider = checkProvider;
function connect(network) {

View File

@ -1 +1 @@
{"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":";;;AAAA,0CAWqB;AAQpB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAE,CAAC;AACvD,gDAAgD;AAEhD,MAAM,gBAAgB,GAA2B;IAC7C;QACI,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,0BAAe,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC5E,CAAC;KACJ;IACD;;;;;;;;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,CAAC;QAC5F,CAAC;KACJ;IACL;;;;;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E;KAC5D;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAhBD,kCAgBC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,OAAe;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,CAAC,OAAO,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACvE,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"}

View File

@ -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

View File

@ -6,7 +6,8 @@ const create_provider_js_1 = require("./create-provider.js");
const index_js_1 = require("../index.js");
(0, create_provider_js_1.setupProviders)();
describe("Test Contract", function () {
const addr = "0x99417252Aad7B065940eBdF50d665Fb8879c5958";
const addr = "0x24264C81146c23bbF83Db1d3F87d2111C2935Ffa";
const networkName = "sepolia";
const abi = [
"error CustomError1(uint256 code, string message)",
"event EventUint256(uint256 indexed value)",
@ -21,20 +22,20 @@ describe("Test Contract", function () {
];
it("tests contract calls", async function () {
this.timeout(10000);
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
const contract = new index_js_1.Contract(addr, abi, provider);
assert_1.default.equal(await contract.testCallAdd(4, 5), BigInt(9), "testCallAdd(4, 5)");
assert_1.default.equal(await contract.testCallAdd(6, 0), BigInt(6), "testCallAdd(6, 0)");
});
it("tests events", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
assert_1.default.ok(provider);
const contract = new index_js_1.Contract(addr, abi, provider);
const signer = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY), provider);
const contractSigner = contract.connect(signer);
const vUint256 = 42;
const vAddrName = "ethers.eth";
const vAddrName = "tests.eth";
const vAddr = "0x228568EA92aC5Bc281c1E30b1893735c60a139F1";
const vString = "Hello";
const vBytes = "0x12345678";
@ -215,8 +216,9 @@ describe("Test Typed Contract Interaction", function () {
abi.push(`function testTyped(bool) public pure returns (string memory)`);
abi.push(`function testTyped(bytes memory) public pure returns (string memory)`);
abi.push(`function testTyped(string memory) public pure returns (string memory)`);
const addr = "0x838f41545DA5e18AA0e1ab391085d22E172B7B02";
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
const addr = "0xf20ba47c47a32fc2d9ad846ff06f2fa6e89eec74";
const networkName = "sepolia";
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
const contract = new index_js_1.Contract(addr, abi, provider);
for (const { types, valueFunc } of tests) {
for (const type of types) {
@ -305,7 +307,8 @@ describe("Test Contract Fallback", function () {
sendDataAndValue: { error: "overrides" },
},
];
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
const networkName = "sepolia";
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
const testGroups = [
{
group: "sendNone",

File diff suppressed because one or more lines are too long

View File

@ -16,4 +16,139 @@ describe("Tests Typed Data (EIP-712)", function () {
});
}
});
describe("Tests Typed Data (EIP-712) aliases", function () {
const tests = [
{
name: "uint",
types: {
foo: [
{ name: "a", type: "uint256" },
{ name: "b", type: "string" },
],
},
typesAlias: {
foo: [
{ name: "a", type: "uint" },
{ name: "b", type: "string" },
],
},
data: {
a: 35,
b: "hello"
},
encoded: "0x859b6b4a5d436f85a809f6383b4b35a153aa6fe9c95946c366d9dfd634b89f4700000000000000000000000000000000000000000000000000000000000000231c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
},
{
name: "int",
types: {
foo: [
{ name: "a", type: "int256" },
{ name: "b", type: "string" },
],
},
typesAlias: {
foo: [
{ name: "a", type: "int" },
{ name: "b", type: "string" },
],
},
data: {
a: 35,
b: "hello"
},
encoded: "0xa272ada5f88085e4cb18acdb87bd057a8cbfec249fee53de0149409080947cf500000000000000000000000000000000000000000000000000000000000000231c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
},
{
name: "array-uint",
types: {
foo: [
{ name: "a", type: "uint256[]" },
{ name: "b", type: "string" },
],
},
typesAlias: {
foo: [
{ name: "a", type: "uint[]" },
{ name: "b", type: "string" },
],
},
data: {
a: [35, 36, 37],
b: "hello"
},
encoded: "0x1a961843d0002bdd66ec21afd6e4a5b0aac34a4b6112890378c6e3a38b752e0b0c22b846886e98aeffc1f1166d4b35868da4d4da853dcb3b2856cfc233fd10c81c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
},
{
name: "array-int",
types: {
foo: [
{ name: "a", type: "int256[]" },
{ name: "b", type: "string" },
],
},
typesAlias: {
foo: [
{ name: "a", type: "int[]" },
{ name: "b", type: "string" },
],
},
data: {
a: [35, 36, 37],
b: "hello"
},
encoded: "0x0b89085a01a3b67d2231c6a136f9c8eea75d7d479a83a127356f8540ee15af010c22b846886e98aeffc1f1166d4b35868da4d4da853dcb3b2856cfc233fd10c81c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
},
{
name: "nested-array-uint",
types: {
foo: [
{ name: "a", type: "uint256[][]" },
{ name: "b", type: "string" },
],
},
typesAlias: {
foo: [
{ name: "a", type: "uint[][]" },
{ name: "b", type: "string" },
],
},
data: {
a: [[35, 36], [37]],
b: "hello"
},
encoded: "0x5efa7c4b66979cf78fcc7c3e71cbfa04ec2c7529002642082bf20a91552c1147fa5ffe3a0504d850bc7c9eeda1cf960b596b73f4dc0272a6fa89dace08e320291c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
},
];
for (const test of tests) {
it(`tests encoding typed-data: ${test.name}`, function () {
const encoder = index_js_1.TypedDataEncoder.from(test.types);
assert_1.default.equal(encoder.primaryType, "foo", "primaryType");
assert_1.default.equal(encoder.encodeData("foo", test.data), test.encoded, "encoded");
const encoderAlias = index_js_1.TypedDataEncoder.from(test.typesAlias);
assert_1.default.equal(encoderAlias.primaryType, "foo", "primaryType");
assert_1.default.equal(encoderAlias.encodeData("foo", test.data), test.encoded, "encoded");
const payload = index_js_1.TypedDataEncoder.getPayload({}, test.types, test.data);
const payloadAlias = index_js_1.TypedDataEncoder.getPayload({}, test.typesAlias, test.data);
assert_1.default.equal(JSON.stringify(payloadAlias), JSON.stringify(payload), "payload");
});
}
it(`tests overriding an alias as a type`, function () {
const encoder = index_js_1.TypedDataEncoder.from({
uint: [
{ name: "value", type: "uint256" }
],
foo: [
{ name: "a", type: "uint" },
{ name: "b", type: "string" },
]
});
assert_1.default.equal(encoder.primaryType, "foo", "primaryType");
const data = encoder.encodeData("foo", {
a: { value: 42 },
b: "hello"
});
const encoded = "0x87a4bfff36f1a2ecde6468d6acd51ecc5ef8f3a15d8115a412c686d82d3fdbe4628fc3080b86a044fb60153bb7dc3f904e9ed1cebadf35c17099a060ba4df90b1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8";
assert_1.default.equal(data, encoded, "encoded");
});
});
//# sourceMappingURL=test-hash-typeddata.js.map

View File

@ -1 +1 @@
{"version":3,"file":"test-hash-typeddata.js","sourceRoot":"","sources":["../../src.ts/_tests/test-hash-typeddata.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,yCAAuC;AAGvC,0CAA+C;AAG/C,QAAQ,CAAC,4BAA4B,EAAE;IACnC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAoB,YAAY,CAAC,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,EAAE,CAAC,8BAA+B,IAAI,CAAC,IAAK,EAAE,EAAE;YAC5C,MAAM,OAAO,GAAG,2BAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClD,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YACnE,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAEjE,gBAAM,CAAC,KAAK,CAAC,2BAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YAC3F,gBAAM,CAAC,KAAK,CAAC,2BAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACnG,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAC"}
{"version":3,"file":"test-hash-typeddata.js","sourceRoot":"","sources":["../../src.ts/_tests/test-hash-typeddata.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,yCAAuC;AAEvC,0CAA+C;AAG/C,QAAQ,CAAC,4BAA4B,EAAE;IACnC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAoB,YAA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UAAU,CAAC,KAAK,EAAE;YACnC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAChB,CAAC,EAAE,OAAO;SACb,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,oMAAoM,CAAC;QACrN,gBAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const index_js_1 = require("../index.js");
const utils_js_1 = require("./utils.js");
//import { dnsEncode, isValidName, namehash } from "../index.js";
const index_js_2 = require("../index.js");
describe("Tests Namehash", function () {
const tests = (0, utils_js_1.loadTests)("namehash");
for (const test of tests) {
@ -37,94 +37,48 @@ describe("Tests Namehash", function () {
}
}
});
/*
describe("Tests Bad ENS Names", function() {
const badTests: Array<{ ensName: any, prefix: string }> = [
{ ensName: ".", prefix: "missing component" },
{ ensName:"..", prefix: "missing component" },
{ ensName:"ricmoo..eth", prefix: "missing component" },
{ ensName:"ricmoo...eth", prefix: "missing component" },
{ ensName:".foo", prefix: "missing component" },
{ ensName:"foo.", prefix: "missing component" },
{ ensName: 1234, prefix: "not a string" },
{ ensName: true, prefix: "not a string" },
describe("Test dnsEncode", function () {
const tests = [
{ name: "ricmoo.com", result: "0x067269636d6f6f03636f6d00" },
{ name: "ricmoo.com", length: 5, error: "exceeds 5 bytes" },
{
name: "a-very-long-label-without-a-length-override-foo-12345678901234567890",
error: "exceeds 63 bytes"
},
{
name: "a-very-long-label-with-a-length-override-to-255-foo-12345678901234567890",
length: 255, result: "0x48612d766572792d6c6f6e672d6c6162656c2d776974682d612d6c656e6774682d6f766572726964652d746f2d3235352d666f6f2d313233343536373839303132333435363738393000"
},
];
// The empty string is not a valid name, but has a valid namehash
// (the zero hash) as it is the base case for recursion
it("empty ENS name", function() {
assert.ok(!isValidName(""), "!isValidName");
});
for (const { ensName, prefix } of badTests) {
it(`fails on bad ENS name: ${ JSON.stringify(ensName) }`, function() {
assert.ok(!isValidName(ensName), "!isValidName");
assert.throws(() => {
const result = namehash(ensName);
console.log(result);
}, (error) => {
const errorPrefix = `invalid ENS name; ${ prefix }`;
return (error.code === "INVALID_ARGUMENT" &&
error.argument === "name" && error.value === ensName &&
error.message.substring(0, errorPrefix.length) === errorPrefix);
});
for (const test of tests) {
it(`tests dnsEncode: ${test.name}`, function () {
if (test.error) {
assert_1.default.throws(() => {
let result;
if (test.length != null) {
result = (0, index_js_2.dnsEncode)(test.name, test.length);
}
else {
result = (0, index_js_2.dnsEncode)(test.name);
}
console.log("result", result);
}, (error) => {
return ((0, index_js_1.isError)(error, "INVALID_ARGUMENT") &&
error.argument === "name" && error.value === test.name &&
error.message.indexOf(test.error || "") >= 0);
});
}
else {
if (test.length != null) {
assert_1.default.equal((0, index_js_2.dnsEncode)(test.name, test.length), test.result, "dnsEncode(name, length)");
}
else {
assert_1.default.equal((0, index_js_2.dnsEncode)(test.name), test.result, "dnsEncode(name)");
}
}
});
}
});
describe("Tests DNS Encoding", function() {
const tests: Array<{ ensName: string, dnsEncoded: string}> = [
{ ensName: "", dnsEncoded: "0x00" },
{ ensName: "ricmoo.eth", dnsEncoded: "0x067269636d6f6f0365746800" },
];
for (const { ensName, dnsEncoded } of tests) {
it(`computes the DNS Encoding: ${ JSON.stringify(ensName) }`, function() {
assert.equal(dnsEncode(ensName), dnsEncoded, "dnsEncoded");
});
}
});
describe("Tests DNS Names", function() {
const badTests: Array<{ ensName: any, prefix: string}> = [
{ ensName: ".", prefix: "invalid DNS name; missing component" },
{ ensName: "foo..bar", prefix: "invalid DNS name; missing component" },
{ ensName: ".foo", prefix: "invalid DNS name; missing component" },
{ ensName: "foo.", prefix: "invalid DNS name; missing component" },
{ ensName: 1234, prefix: "invalid DNS name; not a string" },
{ ensName: true, prefix: "invalid DNS name; not a string" },
];
for (const { ensName, prefix } of badTests) {
it(`fails on bad DNS name: ${ JSON.stringify(ensName) }`, function() {
assert.throws(() => {
const result = dnsEncode(ensName);
console.log(result);
}, (error) => {
return (error.code === "INVALID_ARGUMENT" &&
error.argument === "name" && error.value === ensName &&
error.message.substring(0, prefix.length) === prefix);
});
});
}
{
const ensName = "foobar012345678901234567890123456789012345678901234567890123456789";
const prefix = "too long";
it(`fails on bad DNS name: ${ JSON.stringify(ensName) }`, function() {
assert.throws(() => {
const result = dnsEncode(ensName);
console.log(result);
}, (error) => {
return (error.code === "INVALID_ARGUMENT" &&
error.argument === "value" && error.value === ensName &&
error.message.substring(0, prefix.length) === prefix);
});
});
}
});
*/
describe("Test EIP-191 Personal Message Hash", function () {
const tests = [
{

View File

@ -1 +1 @@
{"version":3,"file":"test-hash.js","sourceRoot":"","sources":["../../src.ts/_tests/test-hash.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,0CAKqB;AAErB,yCAAsC;AAKtC,iEAAiE;AAEjE,QAAQ,CAAC,gBAAgB,EAAE;IACvB,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAmB,UAAU,CAAC,CAAC;IAEtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,EAAE,CAAC,oBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAE,EAAE,EAAE;gBAClD,MAAM,MAAM,GAAG,IAAA,mBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEtC,gBAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;gBAEhD,2CAA2C;gBAC3C,IAAI,IAAI,CAAC,OAAO,EAAE;oBACd,gBAAM,CAAC,EAAE,CAAC,IAAA,sBAAW,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;iBACvD;YACL,CAAC,CAAC,CAAC;SACN;KACJ;IAED,KAAK,MAAM,IAAI,I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AC,CAAC;KACN;IAED,MAAM,QAAQ,GAAG;QACb,EAAE,KAAK,EAAE,CAAE,OAAO,CAAE,EAAE,MAAM,EAAE,CAAE,CAAC,CAAE,EAAE;QACrC,EAAE,KAAK,EAAE,CAAE,QAAQ,CAAE,EAAE,MAAM,EAAE,CAAE,IAAI,CAAE,EAAE;QACzC,EAAE,KAAK,EAAE,CAAE,OAAO,CAAE,EAAE,MAAM,EAAE,CAAE,KAAK,CAAE,EAAE;KAC5C,CAAC;IAEF,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,QAAQ,EAAE;QACtC,EAAE,CAAC,iCAAiC,EAAE;YAClC,gBAAM,CAAC,MAAM,CAAC;gBACV,MAAM,MAAM,GAAG,IAAA,yBAAc,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC7C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC,EAAE,UAAU,KAAK;gBACd,OAAO,CAAC,IAAA,kBAAO,EAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;YAC7E,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAC"}

View File

@ -6,13 +6,13 @@ const create_provider_js_1 = require("./create-provider.js");
(0, create_provider_js_1.setupProviders)();
describe("Resolve ENS avatar", function () {
[
{ title: "data", name: "data-avatar.tests.ethers.eth", value: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAMAAACeL25MAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFk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mQsQgpda6JAYkFoeVcj5iPbwV3xRcvaiXv3bhp1VuYUqw" },
{ title: "url", name: "url-avatar.tests.ethers.eth", value: "https:/\/ethers.org/static/logo.png" },
{ title: "data", name: "data-avatar.tests.eth", value: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAMAAACeL25MAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDAyIDc5LjE2NDQ4OCwgMjAyMC8wNy8xMC0yMjowNjo1MyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIyLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUQ4NTEyNUIyOEIwMTFFQzg0NTBDNTU2RDk1NTA5NzgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NUQ4NTEyNUMyOEIwMTFFQzg0NTBDNTU2RDk1NTA5NzgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg1MTI1OTI4QjAxMUVDODQ1MEM1NTZEOTU1MDk3OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg1MTI1QTI4QjAxMUVDODQ1MEM1NTZEOTU1MDk3OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkbM0uMAAAAGUExURQAA/wAAAHtivz4AAAAOSURBVHjaYmDABAABBgAAFAABaEkyYwAAAABJRU5ErkJggg==" },
{ title: "ipfs", name: "ipfs-avatar.tests.eth", value: "https:/\/gateway.ipfs.io/ipfs/QmQsQgpda6JAYkFoeVcj5iPbwV3xRcvaiXv3bhp1VuYUqw" },
{ title: "url", name: "url-avatar.tests.eth", value: "https:/\/ethers.org/static/logo.png" },
].forEach((test) => {
it(`Resolves avatar for ${test.title}`, async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)("sepolia");
const avatar = await provider.getAvatar(test.name);
assert_1.default.equal(test.value, avatar, "avatar url");
});

View File

@ -1 +1 @@
{"version":3,"file":"test-providers-avatar.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-avatar.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,6DAA+D;AAE/D,IAAA,mCAAc,GAAE,CAAC;AAEjB,QAAQ,CAAC,oBAAoB,EAAE;IAC3B;QACI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE,KAAK,EAAE,owCAAowC,EAAE;QACp0C,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE,KAAK,EAAE,8EAA8E,EAAE;QAC9I,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,6BAA6B,EAAE,KAAK,EAAE,qCAAqC,EAAE;KACtG,CAAC,OA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AAC,CAAC;YACnD,gBAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACP;;;;;;;;;;;;;MAaE;AACF,CAAC,CAAC,CAAC"}

View File

@ -15,11 +15,12 @@ describe("Test CCIP execution", function () {
]);
assert_1.default.equal(result, (0, index_js_1.keccak256)(check), "response is equal");
};
const address = "0x6C5ed35574a9b4d163f75bBf0595F7540D8FCc2d";
const address = "0xaeaa06a37e6421ac63120d6daddee0ffa04b43e8";
const networkName = "sepolia";
const calldata = "0x1234";
it("testGet passes under normal operation", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testGet(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
@ -30,7 +31,7 @@ describe("Test CCIP execution", function () {
});
it("testGet should fail with CCIP not explicitly enabled by overrides", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testGet(bytes callData = "0x1234")
const tx = {
to: address,
@ -40,13 +41,17 @@ describe("Test CCIP execution", function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const offchainErrorData = "0x556f18300000000000000000000000006c5ed35574a9b4d163f75bbf0595f7540d8fcc2d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
const offchainErrorData = (0, index_js_1.concat)([
"0x556f1830000000000000000000000000",
address,
"0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000"
]);
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData);
});
});
it("testGet should fail with CCIP explicitly disabled on provider", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
provider.disableCcipRead = true;
// testGetFail(bytes callData = "0x1234")
const tx = {
@ -57,13 +62,17 @@ describe("Test CCIP execution", function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const offchainErrorData = "0x556f18300000000000000000000000006c5ed35574a9b4d163f75bbf0595f7540d8fcc2d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
const offchainErrorData = (0, index_js_1.concat)([
"0x556f1830000000000000000000000000",
address,
"0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000"
]);
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData);
});
});
it("testGetFail should fail if all URLs 5xx", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testGetFail(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
@ -80,7 +89,7 @@ describe("Test CCIP execution", function () {
});
it("testGetSenderFail should fail if sender does not match", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testGetSenderFail(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
@ -100,7 +109,7 @@ describe("Test CCIP execution", function () {
});
it("testGetMissing should fail if early URL 4xx", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testGetMissing(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
@ -117,7 +126,7 @@ describe("Test CCIP execution", function () {
});
it("testGetFallback passes if any URL returns correctly", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testGetFallback(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
@ -128,7 +137,7 @@ describe("Test CCIP execution", function () {
});
it("testPost passes under normal operation", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)(networkName);
// testPost(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const create_provider_js_1 = require("./create-provider.js");
const utils_js_1 = require("./utils.js");
const index_js_1 = require("../index.js");
const blockchain_data_js_1 = require("./blockchain-data.js");
(0, create_provider_js_1.setupProviders)();
function forEach(prefix, tests, func) {
@ -101,11 +102,24 @@ describe("Test Provider Address operations", function () {
});
function assertObj(prefix, actual, expected) {
assert_1.default.ok(actual != null, `${prefix} is null`);
if (typeof (expected) !== "object") {
assert_1.default.equal(actual, expected, prefix);
return;
}
for (const key in expected) {
if (expected[key] === undefined) {
continue;
}
assert_1.default.equal(actual[key], expected[key], `${prefix}.${key}`);
if (Array.isArray(expected[key])) {
assert_1.default.ok(Array.isArray(actual[key]), `Array.isArray(${prefix}.${key})`);
assert_1.default.equal(actual[key].length, expected[key].length, `${prefix}.${key}.length`);
for (let i = 0; i < expected[key].length; i++) {
assertObj(`${prefix}[${i}]`, actual[key][i], expected[key][i]);
}
}
else {
assert_1.default.equal(actual[key], expected[key], `${prefix}.${key}`);
}
}
}
function assertBlock(actual, expected) {
@ -202,4 +216,34 @@ describe("Test Provider Transaction operations", function () {
};
});
});
describe("Test Networks", function () {
const networks = [
"mainnet", "sepolia", "holesky",
"arbitrum", "arbitrum-sepolia",
"base", "base-sepolia",
"bnb", "bnbt",
"linea", "linea-sepolia",
"matic", "matic-mumbai", "matic-amoy",
"optimism", "optimism-sepolia",
"xdai",
];
const providerNames = [
"AlchemyProvider", "InfuraProvider", "AnkrProvider",
"QuickNodeProvider",
];
for (const providerName of providerNames) {
for (const networkName of networks) {
const network = index_js_1.Network.from(networkName);
const provider = (0, create_provider_js_1.getProvider)(providerName, networkName);
if (provider == null || !(provider instanceof index_js_1.JsonRpcProvider)) {
continue;
}
it(`checks network chainId: ${providerName}/${networkName}`, async function () {
this.timeout(10000);
const chainId = await provider.send("eth_chainId", []);
assert_1.default.equal(parseInt(chainId), network.chainId, "chainId");
});
}
}
});
//# sourceMappingURL=test-providers-data.js.map

File diff suppressed because one or more lines are too long

View File

@ -19,8 +19,8 @@ describe("Tests Provider Call Exception", function () {
//{ code: 0x41, reason: "OUT_OF_MEMORY" },
//{ code: 0x51, reason: "UNINITIALIZED_FUNCTION_CALL" },
];
const testAddr = "0xF20Ba47c47a32fc2d9ad846fF06f2fa6e89eeC74";
const networkName = "goerli";
const testAddr = "0x86d19fF4b2EB0D451511B5B930b01DC71fD9a2Ee";
const networkName = "sepolia";
for (const { code, reason } of panics) {
for (const method of ["call", "estimateGas"]) {
for (const providerName of create_provider_js_1.providerNames) {
@ -132,7 +132,7 @@ describe("Tests Provider Call Exception", function () {
});
describe("Test Provider Blockchain Errors", function () {
const wallet = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY));
const networkName = "goerli";
const networkName = "sepolia";
for (const providerName of create_provider_js_1.providerNames) {
const provider = (0, create_provider_js_1.getProvider)(providerName, networkName);
if (provider == null) {

File diff suppressed because one or more lines are too long

View 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

View 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"}

View 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

View 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,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAKD,MAAa,YAAa,SAAQ,2BAAgB;IACrC,QAAQ,CAAY;IAE7B,YAAY,OAAkB;QAC1B,KAAK,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,cAAc,KAAuB,OAAO,OAAO,CAAC,CAAC,CAAC;IAE5D,KAAK,CAAC,OAAO,CAAC,GAAyB;QACnC,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ;AAbD,oCAaC;AAED,QAAQ,CAAC,yBAAyB,EAAE;IAEhC,MAAM,MAAM,GAAG,oEAAoE,CAAC;IAEpF,KAAK,UAAU,IAAI,CAAC,OAAkD;QAClE,qGAAqG;QACrG,MAAM,EAAE,GAAG,sPAAs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AAC,CAAC,MAAO,EAAE,CAAC,CAAC;YACvD,CAAC,CAAC;YACF,YAAY,EAAE,QAAQ,EAAE,MAAM;SACjC,CAAC,CAAC,CAAC;QAEJ,MAAM,QAAQ,GAAG,IAAI,2BAAgB,CAAC,OAAO,EAAE,OAAO,EAAE;YACpD,YAAY,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,GAAG;YACtC,MAAM;SACT,CAAC,CAAC;QACH,MAAM,QAAQ,CAAC,UAAU,CAAC,sBAAW,CAAC,CAAC;QAEvC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,aAAa;IACb,EAAE,CAAC,2CAA2C,EAAE,KAAK;QACjD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;YACzB,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,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"}

View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-providers-jsonrpc.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"test-providers-jsonrpc.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-jsonrpc.ts"],"names":[],"mappings":""}

View 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-providers-jsonrpc.js.map

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,8 @@ function stall(duration) {
(0, create_provider_js_1.setupProviders)();
describe("Sends Transactions", function () {
const wallet = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY));
const networkName = "goerli";
console.log("Faucet Address:", wallet.address);
const networkName = "sepolia";
for (const providerName of create_provider_js_1.providerNames) {
const provider = (0, create_provider_js_1.getProvider)(providerName, networkName);
if (provider == null) {

View File

@ -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,CAAC;IAC7B,KAAK,MAAM,YAAY,IAAI,kCAAa,EAAE;QACtC,MAAM,QAAQ,GAAG,IAAA,gCAAW,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QACxD,IAAI,QAAQ,IAAI,IAAI,EAAE;YAAE,SAAS;SAAE;QAEnC,EAAE,CAAC,kBAAmB,YAAa,EAAE,EAAE,KAAK;YACxC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAErB,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,iBAAM,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC;YAE/C,8CAA8C;YAC9C,IAAI,EAAE,GAA+B,IAAI,CAAC;YAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;gBACzB,IAAI;oBACA,EAAE,GAAG,MAAM,CAAC,CAAC,eAAe,CAAC;wBAC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AAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY;YACrE,uBAAuB;YAEvB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACpD,gBAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;KACN;AAGL,CAAC,CAAC,CAAC"}

View File

@ -5,15 +5,24 @@ const assert_1 = tslib_1.__importDefault(require("assert"));
const create_provider_js_1 = require("./create-provider.js");
(0, create_provider_js_1.setupProviders)();
describe("Test EIP-2544 ENS wildcards", function () {
const provider = (0, create_provider_js_1.connect)("goerli");
const provider = (0, create_provider_js_1.connect)("sepolia");
it("Resolves recursively", async function () {
this.timeout(10000);
const resolver = await provider.getResolver("ricmoose.hatch.eth");
assert_1.default.ok(resolver, "failed to get resolver");
assert_1.default.equal(resolver.address, "0x15abA1fa74Bfdecd63A71218DC632d4328Db8168", "address");
assert_1.default.equal(resolver.address, "0x657D81B1E647A56457ff035Af22898411673f7FD", "address");
assert_1.default.equal(await resolver.supportsWildcard(), true, "supportsWildcard()");
// Test pass-through avatar
assert_1.default.equal(await resolver.getAvatar(), "https:/\/static.ricmoo.com/uploads/profile-06cb9c3031c9.jpg", "getAvatar()");
assert_1.default.equal(await resolver.getAddress(), "0x4B711A377B1b3534749FBe5e59Bcf7F94d92EA98", "getAddress()");
assert_1.default.equal(await resolver.getAddress(), "0xF0d6e3fC0f5A23aAAA4933700438b6313Dd331bD", "getAddress()");
});
});
describe("Test ENS-DNS gasless resolver", function () {
it("Resolved almonit.org", async function () {
this.timeout(10000);
const provider = (0, create_provider_js_1.connect)("mainnet");
const addr = await provider.resolveName("almonit.org");
assert_1.default.equal(addr, "0x0D59d0f7DcC0fBF0A3305cE0261863aAf7Ab685c", "addr");
});
});
//# sourceMappingURL=test-providers-wildcard.js.map

View File

@ -1 +1 @@
{"version":3,"file":"test-providers-wildcard.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-wildcard.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,6DAA+D;AAE/D,IAAA,mCAAc,GAAE,CAAC;AAEjB,QAAQ,CAAC,6BAA6B,EAAE;IACpC,MAAM,QAAQ,GAAG,IAAA,4BAAO,EAAC,QAAQ,CAAC,CAAC;IAEnC,EAAE,CAAC,sBAAsB,EAAE,KAAK;QAC5B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;QAClE,gBAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;QAE9C,gBAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,4CAA4C,EAAE,SAAS,CAAC,CAAC;QACxF,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAE5E,2BAA2B;QAC3B,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,SAAS,EAAE,EAAE,6DAA6D,EAAE,aAAa,CAAC,CAAC;QAEvH,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE,EAAE,4CAA4C,EAAE,cAAc,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
{"version":3,"file":"test-providers-wildcard.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-wildcard.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,6DAA+D;AAE/D,IAAA,mCAAc,GAAE,CAAC;AAEjB,QAAQ,CAAC,6BAA6B,EAAE;IACpC,MAAM,QAAQ,GAAG,IAAA,4BAAO,EAAC,SAAS,CAAC,CAAC;IAEpC,EAAE,CAAC,sBAAsB,EAAE,KAAK;QAC5B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpB,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;QAClE,gBAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;QAE9C,gBAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,4CAA4C,EAAE,SAAS,CAAC,CAAC;QACxF,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAE5E,2BAA2B;QAC3B,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,SAAS,EAAE,EAAE,6DAA6D,EAAE,aAAa,CAAC,CAAC;QAEvH,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE,EAAE,4CAA4C,EAAE,cAAc,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,+BAA+B,EAAE;IACtC,EAAE,CAAC,sBAAsB,EAAE,KAAK;QAC5B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpB,MAAM,QAAQ,GAAG,IAAA,4BAAO,EAAC,SAAS,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QACvD,gBAAM,CAAC,KAAK,CAAC,IAAI,EAAE,4CAA4C,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -57,6 +57,16 @@ describe("Tests Unsigned Transaction Serializing", function () {
assert_1.default.equal(tx.unsignedSerialized, test.unsignedLondon, "unsignedLondon");
});
}
for (const test of tests) {
if (!test.unsignedCancun) {
continue;
}
it(`serialized unsigned cancun transaction: ${test.name}`, function () {
const txData = Object.assign({}, test.transaction, { type: 3 });
const tx = index_js_1.Transaction.from(txData);
assert_1.default.equal(tx.unsignedSerialized, test.unsignedCancun, "unsignedCancun");
});
}
});
describe("Tests Signed Transaction Serializing", function () {
const tests = (0, utils_js_1.loadTests)("transactions");
@ -114,6 +124,19 @@ describe("Tests Signed Transaction Serializing", function () {
assert_1.default.equal(tx.serialized, test.signedLondon, "signedLondon");
});
}
for (const test of tests) {
if (!test.signedCancun) {
continue;
}
it(`serialized signed Cancun transaction: ${test.name}`, function () {
const txData = Object.assign({}, test.transaction, {
type: 3,
signature: test.signatureCancun
});
const tx = index_js_1.Transaction.from(txData);
assert_1.default.equal(tx.serialized, test.signedCancun, "signedCancun");
});
}
});
function assertTxUint(actual, _expected, name) {
const expected = (_expected != null ? BigInt(_expected) : null);
@ -197,6 +220,17 @@ describe("Tests Unsigned Transaction Parsing", function () {
assertTxEqual(tx, expected);
});
}
for (const test of tests) {
if (!test.unsignedCancun) {
continue;
}
it(`parses unsigned Cancun transaction: ${test.name}`, function () {
const tx = index_js_1.Transaction.from(test.unsignedCancun);
const expected = addDefaults(test.transaction);
expected.gasPrice = null;
assertTxEqual(tx, expected);
});
}
});
describe("Tests Signed Transaction Parsing", function () {
const tests = (0, utils_js_1.loadTests)("transactions");
@ -238,6 +272,7 @@ describe("Tests Signed Transaction Parsing", function () {
assert_1.default.equal(tx.isLegacy(), true, "isLegacy");
assert_1.default.equal(tx.isBerlin(), false, "isBerlin");
assert_1.default.equal(tx.isLondon(), false, "isLondon");
assert_1.default.equal(tx.isCancun(), false, "isCancun");
assert_1.default.ok(!!tx.signature, "signature:!null");
assert_1.default.equal(tx.signature.r, test.signatureEip155.r, "signature.r");
assert_1.default.equal(tx.signature.s, test.signatureEip155.s, "signature.s");
@ -258,6 +293,7 @@ describe("Tests Signed Transaction Parsing", function () {
assert_1.default.equal(tx.isLegacy(), false, "isLegacy");
assert_1.default.equal(tx.isBerlin(), true, "isBerlin");
assert_1.default.equal(tx.isLondon(), false, "isLondon");
assert_1.default.equal(tx.isCancun(), false, "isCancun");
assert_1.default.ok(!!tx.signature, "signature:!null");
assert_1.default.equal(tx.signature.r, test.signatureBerlin.r, "signature.r");
assert_1.default.equal(tx.signature.s, test.signatureBerlin.s, "signature.s");
@ -277,6 +313,7 @@ describe("Tests Signed Transaction Parsing", function () {
assert_1.default.equal(tx.isLegacy(), false, "isLegacy");
assert_1.default.equal(tx.isBerlin(), false, "isBerlin");
assert_1.default.equal(tx.isLondon(), true, "isLondon");
assert_1.default.equal(tx.isCancun(), false, "isCancun");
assert_1.default.ok(!!tx.signature, "signature:!null");
assert_1.default.equal(tx.signature.r, test.signatureLondon.r, "signature.r");
assert_1.default.equal(tx.signature.s, test.signatureLondon.s, "signature.s");
@ -286,6 +323,30 @@ describe("Tests Signed Transaction Parsing", function () {
}
});
}
for (const test of tests) {
if (!test.signedCancun) {
continue;
}
it(`parses signed Cancun transaction: ${test.name}`, function () {
let tx = index_js_1.Transaction.from(test.signedCancun);
const expected = addDefaults(test.transaction);
expected.gasPrice = null;
for (let i = 0; i < 2; i++) {
assertTxEqual(tx, expected);
assert_1.default.equal(tx.typeName, "eip-4844", "typeName");
assert_1.default.equal(tx.isLegacy(), false, "isLegacy");
assert_1.default.equal(tx.isBerlin(), false, "isBerlin");
assert_1.default.equal(tx.isLondon(), false, "isLondon");
assert_1.default.equal(tx.isCancun(), true, "isCancun");
assert_1.default.ok(!!tx.signature, "signature:!null");
assert_1.default.equal(tx.signature.r, test.signatureCancun.r, "signature.r");
assert_1.default.equal(tx.signature.s, test.signatureCancun.s, "signature.s");
assert_1.default.equal(tx.signature.yParity, parseInt(test.signatureCancun.v), "signature.v");
// Test cloning
tx = tx.clone();
}
});
}
});
describe("Tests Transaction Parameters", function () {
const badData = [

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"file":"test-wallet-mnemonic.js","sourceRoot":"","sources":["../../src.ts/_tests/test-wallet-mnemonic.ts"],"names":[],"mappings":";;;AACA,4DAA4B;AAE5B,0CAGqB;AAErB,yCAAuC;AAKvC,MAAM,OAAO,GAA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G,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzC,EAAE,CAAC,8CAA+C,QAAQ,CAAC,MAAO,EAAE,EAAE;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"}

View File

@ -173,10 +173,13 @@ export interface TestCaseTransaction {
signedBerlin: string;
unsignedLondon: string;
signedLondon: string;
unsignedCancun: string;
signedCancun: string;
signatureLegacy: TestCaseTransactionSig;
signatureEip155: TestCaseTransactionSig;
signatureBerlin: TestCaseTransactionSig;
signatureLondon: TestCaseTransactionSig;
signatureCancun: TestCaseTransactionSig;
}
export interface TestCaseMnemonicNode {
path: string;

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src.ts/_tests/types.ts"],"names":[],"mappings":";;AA4PC,CAAC"}
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src.ts/_tests/types.ts"],"names":[],"mappings":";;AA+PC,CAAC"}

View File

@ -1 +1 @@
{"version":3,"file":"_version.d.ts","sourceRoot":"","sources":["../src.ts/_version.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAgB,CAAC"}
{"version":3,"file":"_version.d.ts","sourceRoot":"","sources":["../src.ts/_version.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAiB,CAAC"}

View File

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

View File

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

View File

@ -40,6 +40,7 @@ export declare class AbiCoder {
* padded event data emitted from ``external`` functions.
*/
decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
static _setDefaultMaxInflation(value: number): void;
/**
* Returns the shared singleton instance of a default [[AbiCoder]].
*

View File

@ -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;;;GAGG;AACH,qBAAa,QAAQ;;IA4CjB;;;;;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM;IAMjE;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,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,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ACH,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"}

View File

@ -43,6 +43,7 @@ PanicReasons.set(0x51, "UNINITIALIZED_FUNCTION_CALL");
const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
let defaultCoder = null;
let defaultMaxInflation = 1024;
function getBuiltinCallException(action, tx, data, abiCoder) {
let message = "missing revert data";
let reason = null;
@ -179,7 +180,11 @@ class AbiCoder {
decode(types, data, loose) {
const coders = types.map((type) => this.#getCoder(fragments_js_1.ParamType.from(type)));
const coder = new tuple_js_1.TupleCoder(coders, "_");
return coder.decode(new abstract_coder_js_1.Reader(data, loose));
return coder.decode(new abstract_coder_js_1.Reader(data, loose, defaultMaxInflation));
}
static _setDefaultMaxInflation(value) {
(0, index_js_1.assertArgument)(typeof (value) === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
defaultMaxInflation = value;
}
/**
* Returns the shared singleton instance of a default [[AbiCoder]].

File diff suppressed because one or more lines are too long

View File

@ -18,19 +18,22 @@ export declare class Result extends Array<any> {
*/
constructor(...args: Array<any>);
/**
* Returns the Result as a normal Array.
* Returns the Result as a normal Array. If %%deep%%, any children
* which are Result objects are also converted to a normal Array.
*
* This will throw if there are any outstanding deferred
* errors.
*/
toArray(): Array<any>;
toArray(deep?: boolean): Array<any>;
/**
* Returns the Result as an Object with each name-value pair.
* Returns the Result as an Object with each name-value pair. If
* %%deep%%, any children which are Result objects are also
* converted to an Object.
*
* This will throw if any value is unnamed, or if there are
* any outstanding deferred errors.
*/
toObject(): Record<string, any>;
toObject(deep?: boolean): Record<string, any>;
/**
* @_ignore
*/
@ -108,7 +111,7 @@ export declare class Writer {
export declare class Reader {
#private;
readonly allowLoose: boolean;
constructor(data: BytesLike, allowLoose?: boolean);
constructor(data: BytesLike, allowLoose?: boolean, maxInflation?: number);
get data(): string;
get dataLength(): number;
get consumed(): number;

View File

@ -1 +1 @@
{"version":3,"file":"abstract-coder.d.ts","sourceRoot":"","sources":["../../../src.ts/abi/coders/abstract-coder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAW,CAAC;AAenC;;;;;;GAMG;AACH,qBAAa,MAAO,SAAQ,KAAK,CAAC,GAAG,CAAC;;IAGlC,CAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAI,GAAG,CAAA;IAE3B;;OAEG;gBACS,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;IAyF/B;;;;;OAKG;IACH,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC;IASrB;;;;;OAKG;IACH,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAe/B;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IAuBnE;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,MAAM;IAiB3F;;OAEG;IACH,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG,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OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK;IAI/C,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM;IACnD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG;IAEpC,QAAQ,CAAC,YAAY,IAAI,GAAG;CAC/B;AAED;;GAEG;AACH,qBAAa,MAAM;;;IAUf,IAAI,IAAI,IAAI,MAAM,CAEjB;IACD,IAAI,MAAM,IAAI,MAAM,CAA6B;IAQjD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAKpC,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAUpC,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM;IAMvC,mBAAmB,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI;CAQvD;AAED;;GAEG;AACH,qBAAa,MAAM;;IAKf,QAAQ,CAAC,UAAU,EAAG,OAAO,CAAC;gBASlB,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,MAAM;IAWxE,IAAI,IAAI,IAAI,MAAM,CAAgC;IAClD,IAAI,UAAU,IAAI,MAAM,CAA8B;IACtD,IAAI,QAAQ,IAAI,MAAM,CAAyB;IAC/C,IAAI,KAAK,IAAI,UAAU,CAAuC;IAkC9D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAOjC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU;IAStD,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;CAGtB"}

View File

@ -106,35 +106,45 @@ class Result extends Array {
});
}
/**
* Returns the Result as a normal Array.
* Returns the Result as a normal Array. If %%deep%%, any children
* which are Result objects are also converted to a normal Array.
*
* This will throw if there are any outstanding deferred
* errors.
*/
toArray() {
toArray(deep) {
const result = [];
this.forEach((item, index) => {
if (item instanceof Error) {
throwError(`index ${index}`, item);
}
if (deep && item instanceof Result) {
item = item.toArray(deep);
}
result.push(item);
});
return result;
}
/**
* Returns the Result as an Object with each name-value pair.
* Returns the Result as an Object with each name-value pair. If
* %%deep%%, any children which are Result objects are also
* converted to an Object.
*
* This will throw if any value is unnamed, or if there are
* any outstanding deferred errors.
*/
toObject() {
toObject(deep) {
return this.#names.reduce((accum, name, index) => {
(0, index_js_1.assert)(name != null, "value at index ${ index } unnamed", "UNSUPPORTED_OPERATION", {
operation: "toObject()"
});
// Add values for names that don't conflict
if (!(name in accum)) {
accum[name] = this.getValue(name);
let child = this.getValue(name);
if (deep && child instanceof Result) {
child = child.toObject(deep);
}
accum[name] = child;
}
return accum;
}, {});
@ -359,15 +369,35 @@ class Reader {
allowLoose;
#data;
#offset;
constructor(data, allowLoose) {
#bytesRead;
#parent;
#maxInflation;
constructor(data, allowLoose, maxInflation) {
(0, index_js_1.defineProperties)(this, { allowLoose: !!allowLoose });
this.#data = (0, index_js_1.getBytesCopy)(data);
this.#bytesRead = 0;
this.#parent = null;
this.#maxInflation = (maxInflation != null) ? maxInflation : 1024;
this.#offset = 0;
}
get data() { return (0, index_js_1.hexlify)(this.#data); }
get dataLength() { return this.#data.length; }
get consumed() { return this.#offset; }
get bytes() { return new Uint8Array(this.#data); }
#incrementBytesRead(count) {
if (this.#parent) {
return this.#parent.#incrementBytesRead(count);
}
this.#bytesRead += count;
// Check for excessive inflation (see: #4537)
(0, index_js_1.assert)(this.#maxInflation < 1 || this.#bytesRead <= this.#maxInflation * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#maxInflation} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
buffer: (0, index_js_1.getBytesCopy)(this.#data), offset: this.#offset,
length: count, info: {
bytesRead: this.#bytesRead,
dataLength: this.dataLength
}
});
}
#peekBytes(offset, length, loose) {
let alignedLength = Math.ceil(length / exports.WordSize) * exports.WordSize;
if (this.#offset + alignedLength > this.#data.length) {
@ -386,11 +416,14 @@ class Reader {
}
// Create a sub-reader with the same underlying data, but offset
subReader(offset) {
return new Reader(this.#data.slice(this.#offset + offset), this.allowLoose);
const reader = new Reader(this.#data.slice(this.#offset + offset), this.allowLoose, this.#maxInflation);
reader.#parent = this;
return reader;
}
// Read bytes
readBytes(length, loose) {
let bytes = this.#peekBytes(0, length, !!loose);
this.#incrementBytesRead(length);
this.#offset += bytes.length;
// @TODO: Make sure the length..end bytes are all 0?
return bytes.slice(0, length);

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

View File

@ -21,8 +21,10 @@ function setify(items) {
items.forEach((k) => result.add(k));
return Object.freeze(result);
}
const _kwVisibDeploy = "external public payable override";
const KwVisibDeploy = setify(_kwVisibDeploy.split(" "));
// Visibility Keywords
const _kwVisib = "constant external internal payable private public pure view";
const _kwVisib = "constant external internal payable private public pure view override";
const KwVisib = setify(_kwVisib.split(" "));
const _kwTypes = "constructor error event fallback function receive struct";
const KwTypes = setify(_kwTypes.split(" "));
@ -76,7 +78,8 @@ class TokenString {
// Pops and returns the value of the next token if it is `type`; throws if out of tokens
popType(type) {
if (this.peek().type !== type) {
throw new Error(`expected ${type}; got ${JSON.stringify(this.peek())}`);
const top = this.peek();
throw new Error(`expected ${type}; got ${top.type} ${JSON.stringify(top.text)}`);
}
return this.pop().text;
}
@ -308,7 +311,7 @@ function consumeGas(tokens) {
}
function consumeEoi(tokens) {
if (tokens.length) {
throw new Error(`unexpected tokens: ${tokens.toString()}`);
throw new Error(`unexpected tokens at offset ${tokens.offset}: ${tokens.toString()}`);
}
}
const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
@ -429,9 +432,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;
@ -449,9 +459,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 {
@ -609,7 +616,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 = "";
@ -933,7 +945,12 @@ class EventFragment extends NamedFragment {
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);
@ -988,7 +1005,9 @@ 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()}`);
}
@ -1002,12 +1021,17 @@ class ConstructorFragment extends Fragment {
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);
@ -1055,7 +1079,12 @@ class FallbackFragment extends Fragment {
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();
@ -1203,7 +1232,12 @@ class FunctionFragment extends NamedFragment {
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);
@ -1269,7 +1303,12 @@ class StructFragment extends NamedFragment {
*/
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);

File diff suppressed because one or more lines are too long

View File

@ -361,14 +361,14 @@ export declare class Interface {
* If the matching event cannot be found, returns null.
*/
parseLog(log: {
topics: Array<string>;
topics: ReadonlyArray<string>;
data: string;
}): null | LogDescription;
/**
* Parses a revert data, finding the matching error and extracts
* the parameter values along with other useful error details.
*
* If the matching event cannot be found, returns null.
* 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

View File

@ -253,7 +253,7 @@ class Interface {
frags.push(fragments_js_1.Fragment.from(a));
}
catch (error) {
console.log("EE", error);
console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, error.message);
}
}
(0, index_js_3.defineProperties)(this, {
@ -884,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];
@ -1066,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

View File

@ -59,12 +59,17 @@ export declare class BaseContract implements Addressable, EventEmitterable<Contr
* 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 dedployed bytecode or null if no bytecode is found.
* Return the deployed bytecode or null if no bytecode is found.
*/
getDeployedCode(): Promise<null | string>;
/**
@ -147,13 +152,13 @@ export declare class BaseContract implements Addressable, EventEmitterable<Contr
/**
* Create a new Class for the %%abi%%.
*/
static buildClass<T = ContractInterface>(abi: InterfaceAbi): new (target: string, runner?: null | ContractRunner) => BaseContract & Omit<T, keyof BaseContract>;
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: InterfaceAbi, runner?: null | ContractRunner): BaseContract & Omit<T, keyof BaseContract>;
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 | Addressable, abi: Interface | InterfaceAbi, runner?: ContractRunner | null | undefined) => BaseContract & Omit<ContractInterface, keyof BaseContract>;
/**
* A [[BaseContract]] with no type guards on its methods or events.
*/

View File

@ -1 +1 @@
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src.ts/contract/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,iBAAiB,CAAC;AAInD,OAAO,EAAe,GAAG,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAMjF,OAAO,EAEH,2BAA2B,EAC3B,QAAQ,EACX,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAU,MAAM,iBAAiB,CAAC;AACxG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EACR,QAAQ,EAAE,cAAc,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAER,iBAAiB,EACjB,iBAAiB,EAEjB,cAAc,EAEd,aAAa,EACb,mBAAmB,EAEnB,eAAe,EAClB,MAAM,YAAY,CAAC;AA6FpB;;GAEG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,CAgB9I;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,IAAI,GAAG,cAAc,EAAE,MAAM,EAAE,aAAa,CAAC,SAA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AiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB/D;;;OAGG;IACG,SAAS,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAgBpE;;;OAGG;IACG,GAAG,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBvE;;;OAGG;IACG,kBAAkB,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlE;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9E;;OAEG;IACG,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,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"}

View File

@ -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,6 +131,9 @@ 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 = ((0, index_js_3.getBigInt)((tx.value || BN_0), "overrides.value") === BN_0);
const noData = ((tx.data || "0x") === "0x");
@ -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) {
@ -544,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;
@ -564,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
@ -590,22 +626,26 @@ 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);
}
});
}
@ -616,12 +656,19 @@ class BaseContract {
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 dedployed bytecode or null if no bytecode is found.
* Return the deployed bytecode or null if no bytecode is found.
*/
async getDeployedCode() {
const provider = getProvider(this.runner);
@ -703,9 +750,23 @@ class BaseContract {
* @_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"``)
@ -733,11 +794,14 @@ 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);
});
}
/**

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
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";
@ -31,6 +32,7 @@ export declare class ContractFactory<A extends Array<any> = Array<any>, I = Base
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.
@ -40,7 +42,7 @@ export declare class ContractFactory<A extends Array<any> = Array<any>, I = Base
* Resolves to the Contract deployed by passing %%args%% into the
* constructor.
*
* This will resovle to the Contract before it has been deployed to the
* This will resolve to the Contract before it has been deployed to the
* network, so the [[BaseContract-waitForDeployment]] should be used before
* sending any transactions to it.
*/

View File

@ -1 +1 @@
{"version":3,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AAc,CAAC;IAExC;;;;;;OAMG;gBACS,GAAG,EAAE,SAAS,GAAG,YAAY,EAAE,QAAQ,EAAE,SAAS,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,cAAc;IAiBnH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC;IAIhF;;;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"}

View File

@ -49,6 +49,9 @@ 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.
@ -70,7 +73,7 @@ class ContractFactory {
* Resolves to the Contract deployed by passing %%args%% into the
* constructor.
*
* This will resovle to the Contract before it has been deployed to the
* This will resolve to the Contract before it has been deployed to the
* network, so the [[BaseContract-waitForDeployment]] should be used before
* sending any transactions to it.
*/

View File

@ -1 +1 @@
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src.ts/contract/factory.ts"],"names":[],"mappings":";;;AACA,8CAA4C;AAC5C,kDAAuD;AACvD,gDAG2B;AAE3B,+CAAyE;AAYzE,mCAAmC;AACnC,sCAAsC;AAEtC;;GAEG;AACH,MAAa,eAAe;IAExB;;OAEG;IACM,SAAS,CAAa;IAE/B;;OAEG;IACM,QAAQ,CAAU;IAE3B;;OAEG;IACM,MAAM,CAAyB;IAExC;;;;;;OAMG;IACH,YAAY,GAA6B,EAAE,QAAwC,EAAE,MAA8B;QAC/G,MAAM,KAAK,GAAG,oBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAElC,wEAAwE;QACxE,IAAI,QAAQ,YAAY,UAAU,EAAE;YAChC,QAAQ,GAAG,IAAA,kBAAO,EAAC,IAAA,mBAAQ,EAAC,QAAQ,CAAC,CAAC,CAAC;SAC1C;aAAM;YACH,IAAI,OAAM,CAAC,QAAQ,CAAC,KAAK,QAAQ,EAAE;gBAAE,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;aAAE;YAClE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAAE,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC;aAAE;YAC/D,QAAQ,GAAG,IAAA,kBAAO,EAAC,IAAA,mBAAQ,EAAC,QAAQ,CAAC,CAAC,CAAC;SAC1C;QAED,IAAA,2BAAgB,EAAkB,IAAI,EAAE;YACpC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,MAAM,IAAI,IAAI,CAAC;SACvD,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,oBAAoB,CAAC,GAAG,IAA2B;QACrD,IAAI,SAAS,GAA4C,EAAG,CAAC;QAE7D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC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AAA,yBAAc,EAAC,MAAM,IAAI,IAAI,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAExE,IAAI,OAAM,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE;YAAE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,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"}

View File

@ -8,6 +8,6 @@
*/
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

View File

@ -1 +1 @@
{"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,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"}

View File

@ -1,6 +1,6 @@
"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;
/**
* A **Contract** object is a meta-class (a class whose definition is
* defined at runtime), which communicates with a deployed smart contract
@ -20,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

View File

@ -1 +1 @@
{"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"}
{"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"}

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