Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dad3829c2e | ||
|
|
de4d683f6d | ||
|
|
ebe4cc90f5 | ||
|
|
35e3bf9d11 | ||
|
|
2d717dcef8 | ||
|
|
3316468e3e | ||
|
|
5144acf456 | ||
|
|
aadc5cd3d6 | ||
|
|
6e088099ad | ||
|
|
b6370f1360 | ||
|
|
26464c5425 | ||
|
|
37a9c77ab2 | ||
|
|
483d67f55c | ||
|
|
987bec87af | ||
|
|
a9cdbe1238 | ||
|
|
4e9abfdee4 | ||
|
|
3bb5fbf533 | ||
|
|
cadccc3060 | ||
|
|
65196097f6 | ||
|
|
8e22e0260e | ||
|
|
de7da421b3 | ||
|
|
a9f7957550 | ||
|
|
bd2d44eecf | ||
|
|
bd05aed070 | ||
|
|
ce8f1e4015 | ||
|
|
58488e78f9 | ||
|
|
29116593ba | ||
|
|
51f0e1a52f | ||
|
|
c086962302 | ||
|
|
c0daf437f7 | ||
|
|
8eaeba35f5 | ||
|
|
4a44865a8c | ||
|
|
725fe0aa32 | ||
|
|
08adc18a68 | ||
|
|
1fcf4b6ce6 | ||
|
|
7c8ae9cfcb | ||
|
|
0cd5fccfad | ||
|
|
53ee187443 | ||
|
|
4577444c44 | ||
|
|
1cb3199e5c | ||
|
|
25c3024a89 | ||
|
|
ae0d5eb7c2 | ||
|
|
b8df000c8f | ||
|
|
eb1ec2f231 | ||
|
|
b65508995c | ||
|
|
2a7dbf0571 | ||
|
|
0dc6f4a45b | ||
|
|
2534b1b3b2 | ||
|
|
a11602d066 | ||
|
|
bec066bcb5 | ||
|
|
ef5a2b4baa | ||
|
|
9e273220b6 | ||
|
|
d55ab6d4e6 | ||
|
|
1a7c4e89ef | ||
|
|
c84a5e62f5 | ||
|
|
6978cca17d | ||
|
|
0e3016bfae | ||
|
|
d50b2d7e65 | ||
|
|
941e4210c6 |
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: investigate
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Note: Not all sections may be relevant, but please be as thorough while remaining concise as possible. Remove this Notice and any sections that don't feel pertinent.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Reproduction steps**
|
||||
Please include code snippets, with console.log output, any contract ABI, contract address, network and the full error.
|
||||
|
||||
**Environment:**
|
||||
Please include anything that may be useful in diagnosing the issue. Node vs Browser? Geth vs Parity vs Ganache? Third Party tools, like Hardhat? Mobile vs. Desktop?
|
||||
|
||||
**Search Terms**
|
||||
Often similar issues have come up before. Include any search terms you have tried in this repository's Issues (including closed issues) and Discussions, so if there are matching issues, we can be sure to add those keywords to make it easier for people to find in the future.
|
||||
22
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest a new feature for ethers
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Note: The best place to start a Feature Request is usually in the Discussions, to mull through the desired feature, current options and think through the impact on the library overall.
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
51
CHANGELOG.md
51
CHANGELOG.md
@@ -3,6 +3,57 @@ Changelog
|
||||
|
||||
This change log is managed by `admin/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.2.0 (2021-05-17 16:18)
|
||||
--------------------------------
|
||||
|
||||
- More aggresively check for mempool transactions sent from JsonRpcSigner. ([3316468](https://github.com/ethers-io/ethers.js/commit/3316468e3e0a5925cbecad85d894cc7d622394e7))
|
||||
- Added initial support for detecting replacement transactions. ([#1477](https://github.com/ethers-io/ethers.js/issues/1477); [987bec8](https://github.com/ethers-io/ethers.js/commit/987bec87afaa365f291290a0136cedbc2b1992f2), [5144acf](https://github.com/ethers-io/ethers.js/commit/5144acf456b51c95bbe3950bd37609abecc7ebc7))
|
||||
- Added convenience method for HD path derivation. ([aadc5cd](https://github.com/ethers-io/ethers.js/commit/aadc5cd3d65421e13ebd4e4d7c293ac3ece5e178))
|
||||
- Added mnemonicPath option to cli. ([6e08809](https://github.com/ethers-io/ethers.js/commit/6e088099adabd7c5d2e6710062ebc62b316ba0f1))
|
||||
- Added some popular Ethereum-compatible chains to networks. ([b6370f1](https://github.com/ethers-io/ethers.js/commit/b6370f13600a0c444342cbf16a83f010a929976b))
|
||||
- Added debug event to Web3Provider. ([26464c5](https://github.com/ethers-io/ethers.js/commit/26464c54258f98c321638475d6cf11595186e76d))
|
||||
- Abstracted EtherscanProivder to more easily fascilitate other Etherscan-supported chains. ([#1204](https://github.com/ethers-io/ethers.js/issues/1204), [#1473](https://github.com/ethers-io/ethers.js/issues/1473); [37a9c77](https://github.com/ethers-io/ethers.js/commit/37a9c77ab2acb7f75e1fc4cc918810d2fe59dd76))
|
||||
- Added Custom Contract Errors. ([#1498](https://github.com/ethers-io/ethers.js/issues/1498); [6519609](https://github.com/ethers-io/ethers.js/commit/65196097f6626401638d85cf19e3d628a6223d5d), [483d67f](https://github.com/ethers-io/ethers.js/commit/483d67f55c15a76bcd853e889a0e35815d9850f7))
|
||||
- More flexible FixedNumber input and output for strings with no decimals. ([#1019](https://github.com/ethers-io/ethers.js/issues/1019), [#1291](https://github.com/ethers-io/ethers.js/issues/1291), [#1463](https://github.com/ethers-io/ethers.js/issues/1463); [a9cdbe1](https://github.com/ethers-io/ethers.js/commit/a9cdbe1238c149a7167c6bb1a78f314805b52755))
|
||||
- Added hex support for bigint. ([#1472](https://github.com/ethers-io/ethers.js/issues/1472); [4e9abfd](https://github.com/ethers-io/ethers.js/commit/4e9abfdee478a8423da4d55feea8c1aae78a8eb4))
|
||||
- Added support for null entries in EventFilter. ([#1499](https://github.com/ethers-io/ethers.js/issues/1499); [3bb5fbf](https://github.com/ethers-io/ethers.js/commit/3bb5fbf533107e880377ecc14f30f314a5028e56))
|
||||
- Add bigint to allowed BigNumberish types. ([#1472](https://github.com/ethers-io/ethers.js/issues/1472); [cadccc3](https://github.com/ethers-io/ethers.js/commit/cadccc3060b88ab2ca64aeb302717d2d1c95a897))
|
||||
- Minor version bump. ([8e22e02](https://github.com/ethers-io/ethers.js/commit/8e22e0260eb70713c943c9e99ee8d66d71ebe56d))
|
||||
|
||||
ethers/v5.1.4 (2021-04-22 06:33)
|
||||
--------------------------------
|
||||
|
||||
- Do not throw on ABI "error" type. ([#1493](https://github.com/ethers-io/ethers.js/issues/1493), [#1497](https://github.com/ethers-io/ethers.js/issues/1497); [bd05aed](https://github.com/ethers-io/ethers.js/commit/bd05aed070ac9e1421a3e2bff2ceea150bedf9b7))
|
||||
|
||||
ethers/v5.1.3 (2021-04-19 21:01)
|
||||
--------------------------------
|
||||
|
||||
- Fixed JsonRpcProvider event-loop caching when using any network. ([#1484](https://github.com/ethers-io/ethers.js/issues/1484); [58488e7](https://github.com/ethers-io/ethers.js/commit/58488e78f9ef79715693e19b42663335aad88c03))
|
||||
- Updated experimental Eip1193Bridge to support final EIP-1193 API. ([2911659](https://github.com/ethers-io/ethers.js/commit/29116593ba6c9c0fa491b13787cca8b233d4218c))
|
||||
- Fail early for ABI decoding that will obviously run out of data. ([#1486](https://github.com/ethers-io/ethers.js/issues/1486); [51f0e1a](https://github.com/ethers-io/ethers.js/commit/51f0e1a52fb885e6f146f7b3b70ed487fd1c8f5a))
|
||||
- Fixed BigNumber toBigInt return type. ([#1485](https://github.com/ethers-io/ethers.js/issues/1485); [c086962](https://github.com/ethers-io/ethers.js/commit/c0869623024bbf3671938dad03b131ff2ac54345))
|
||||
|
||||
ethers/v5.1.2 (2021-04-18 19:31)
|
||||
--------------------------------
|
||||
|
||||
- Increase provider tests gas price for sending a transaction. ([8eaeba3](https://github.com/ethers-io/ethers.js/commit/8eaeba35f550c3d9aa1ae62eb8d8e0c912818f7f))
|
||||
- Fixed run-checking non-filter Contract events. ([#1458](https://github.com/ethers-io/ethers.js/issues/1458); [4a44865](https://github.com/ethers-io/ethers.js/commit/4a44865a8c22adb9c55d5c37a81ee46ebc68228c))
|
||||
|
||||
ethers/v5.1.1 (2021-04-18 02:47)
|
||||
--------------------------------
|
||||
|
||||
- Increased sendTransaction timeout to 15 minutes and pull Pocket from tx tests. ([08adc18](https://github.com/ethers-io/ethers.js/commit/08adc18a68bdc730633bdaaf2329014a84c12b2b))
|
||||
- Export Eip1193Bridge in experimental package. ([1fcf4b6](https://github.com/ethers-io/ethers.js/commit/1fcf4b6ce6922d2bcb245375c967da3072f113ed))
|
||||
- Prevent non-typed transactions from unsafely ignoring specified access lists. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [4577444](https://github.com/ethers-io/ethers.js/commit/4577444c448f41114263077c5b54fbe6af749fd4))
|
||||
- Update tests for current EIP-2930 support across backends. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [1cb3199](https://github.com/ethers-io/ethers.js/commit/1cb3199e5cb01f5a55eb00ab6c7904606d7ea1dd))
|
||||
- Removed underscore from the JsonRpcBatchProvider name. ([#62](https://github.com/ethers-io/ethers.js/issues/62), [#656](https://github.com/ethers-io/ethers.js/issues/656), [#892](https://github.com/ethers-io/ethers.js/issues/892); [ae0d5eb](https://github.com/ethers-io/ethers.js/commit/ae0d5eb7c2e37a003d893671db59c2d5719aea0f))
|
||||
- Added better error detection when pre-EIP-155 transactions are disabled. ([b8df000](https://github.com/ethers-io/ethers.js/commit/b8df000c8f0ccd252b6049ac5a32a986d5a8e08d))
|
||||
- Fix Android React Native environment shims which crash on normalizing Korean test. ([#1298](https://github.com/ethers-io/ethers.js/issues/1298); [eb1ec2f](https://github.com/ethers-io/ethers.js/commit/eb1ec2f2318e2851073ea1634e5003cdb53f1c1b))
|
||||
- Fixed EIP-2930 transactions for EtherscanProvider. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [b655089](https://github.com/ethers-io/ethers.js/commit/b65508995ce7d02f109a970ebeb625819beb915a))
|
||||
- Re-enable AlchemyProvider Berlin tests. ([bec066b](https://github.com/ethers-io/ethers.js/commit/bec066bcb5ab8b95a7e7ce4848d7b76d7f248ccc))
|
||||
- Added experimental _JsonRpcBatchProvider. ([#62](https://github.com/ethers-io/ethers.js/issues/62), [#656](https://github.com/ethers-io/ethers.js/issues/656), [#892](https://github.com/ethers-io/ethers.js/issues/892); [d55ab6d](https://github.com/ethers-io/ethers.js/commit/d55ab6d4e6025c484cc7e64486d927bd54a0772b))
|
||||
- Cache JsonRpcProvider requests for certain methods per event loop. ([#1371](https://github.com/ethers-io/ethers.js/issues/1371); [1a7c4e8](https://github.com/ethers-io/ethers.js/commit/1a7c4e89efecc2b8afc8bea4c1f8f75fdaac08c5))
|
||||
|
||||
ethers/v5.1.0 (2021-03-30 14:44)
|
||||
--------------------------------
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Installing
|
||||
**browser (UMD)**
|
||||
|
||||
```
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js" type="text/javascript">
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.1.umd.min.js" type="text/javascript">
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -52,7 +52,7 @@ Installing
|
||||
|
||||
```
|
||||
<script type="module">
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.esm.min.js";
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.1.esm.min.js";
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@ to be run with the input of the transaction data.
|
||||
|
||||
_subsection: Creating Instances @<Contract--creating>
|
||||
|
||||
_property: new ethers.Contract(address, abi, signerOrProvider) @src<contracts:constructor.Contract>
|
||||
_property: new ethers.Contract(address, abi, signerOrProvider) @src<contracts:class.Contract>
|
||||
|
||||
_property: contract.attach(addressOrName) => [[Contract]] @<Contract-attach> @SRC<contracts:Contract.attach>
|
||||
_property: contract.attach(addressOrName) => [[Contract]] @<Contract-attach> @SRC<contracts:BaseContract.attach>
|
||||
Returns a new instance of the **Contract** attached to a new
|
||||
address. This is useful if there are multiple similar or identical
|
||||
copies of a Contract on the network and you wish to interact with
|
||||
each of them.
|
||||
|
||||
_property: contract.connect(providerOrSigner) => [[Contract]] @<Contract-connect> @SRC<contracts:Contract.connect>
|
||||
_property: contract.connect(providerOrSigner) => [[Contract]] @<Contract-connect> @SRC<contracts:BaseContract.connect>
|
||||
Returns a new instance of the Contract, but connected to
|
||||
//providerOrSigner//.
|
||||
|
||||
@@ -65,11 +65,11 @@ _subsection: Events @<Contract--events>
|
||||
_property: contract.queryFilter(event [ , fromBlockOrBlockHash [ , toBlock ]) => Promise<Array<Event>> @<Contract-queryFilter> @SRC<contracts>
|
||||
Return Events that match the //event//.
|
||||
|
||||
_property: contract.listenerCount([ event ]) => number @<Contract-listenerCount> @SRC<contracts:Contract.listenerCount>
|
||||
_property: contract.listenerCount([ event ]) => number @<Contract-listenerCount> @SRC<contracts:BaseContract.listenerCount>
|
||||
Return the number of listeners that are subscribed to //event//. If
|
||||
no event is provided, returns the total count of all events.
|
||||
|
||||
_property: contract.listeners(event) => Array<Listener> @<Contract-listeners> @SRC<contracts:Contract.listeners>
|
||||
_property: contract.listeners(event) => Array<Listener> @<Contract-listeners> @SRC<contracts:BaseContract.listeners>
|
||||
Return a list of listeners that are subscribed to //event//.
|
||||
|
||||
_property: contract.off(event, listener) => this @<Contract-off> @SRC<contracts>
|
||||
@@ -82,7 +82,7 @@ _property: contract.once(event, listener) => this @<Contract-once> @SRC<contrac
|
||||
Subscribe once to //event// calling //listener// when the event
|
||||
occurs.
|
||||
|
||||
_property: contract.removeAllListeners([ event ]) => this @<Contract-removeAllListeners> @SRC<contracts:Contract.removeAllListeners>
|
||||
_property: contract.removeAllListeners([ event ]) => this @<Contract-removeAllListeners> @SRC<contracts:BaseContract.removeAllListeners>
|
||||
Unsubscribe all listeners for //event//. If no event is provided,
|
||||
all events are unsubscribed.
|
||||
|
||||
@@ -120,6 +120,13 @@ number is used. Otherwise a [[BigNumber]] is returned.
|
||||
|
||||
For bytes (both fixed length and dynamic), a [[DataHexString]] is returned.
|
||||
|
||||
If the call reverts (or runs out of gas), a [CALL_EXCEPTION](errors--call-exception)
|
||||
will be thrown which will include:
|
||||
|
||||
- ``error.address`` - the contract address
|
||||
- ``error.args`` - the arguments passed into the method
|
||||
- ``error.transaction`` - the transaction
|
||||
|
||||
The //overrides// object for a read-only method may include any of:
|
||||
|
||||
- ``overrides.from`` - the ``msg.sender`` (or ``CALLER``) to use during the
|
||||
|
||||
@@ -136,7 +136,7 @@ Returns the number of decimal places used by this ERC-20 token. This can be
|
||||
used with [parseUnits](utils-parseUnits) when taking input from the user or
|
||||
[formatUnits](utils-formatunits] when displaying the token amounts in the UI.
|
||||
|
||||
_property: erc20.getBalance(owner [, overrides ]) => Promise<[[BigNumber]]>
|
||||
_property: erc20.balanceOf(owner [, overrides ]) => Promise<[[BigNumber]]>
|
||||
Returns the balance of //owner// for this ERC-20 token.
|
||||
|
||||
_property: erc20.symbol([ overrides ]) => Promise<string>
|
||||
|
||||
@@ -202,7 +202,18 @@ The chain ID this transaction is authorized on, as specified by
|
||||
If the chain ID is 0 will disable EIP-155 and the transaction will be valid
|
||||
on any network. This can be **dangerous** and care should be taken, since it
|
||||
allows transactions to be replayed on networks that were possibly not
|
||||
intended.
|
||||
intended. Intentionally-replayable transactions are also disabled by default
|
||||
on recent versions of Geth and require configuration to enable.
|
||||
|
||||
_property: transactionRequest.type => null | number
|
||||
|
||||
The [[link-eip-2718]] type of this transaction envelope, or ``null``
|
||||
for legacy transactions that do not have an envelope.
|
||||
|
||||
_property: transactionRequest.accessList => [[providers-AccessListish]]
|
||||
|
||||
The [[providers-AccessList]] to include in an [[link-eip-2930]] transaction, which will
|
||||
include a ``type`` of ``1``.
|
||||
|
||||
_heading: TransactionResponse @<providers-TransactionResponse> @INHERIT<[[Transaction]]>
|
||||
|
||||
@@ -241,6 +252,16 @@ the following properties:
|
||||
- ``error.transactionHash`` - the hash of the transaction
|
||||
- ``error.receipt`` - the actual receipt, with the status of ``0``
|
||||
|
||||
_property: transactionRequest.type => null | number
|
||||
|
||||
The [[link-eip-2718]] type of this transaction envelope, or ``null``
|
||||
for legacy transactions that do not have an envelope.
|
||||
|
||||
_property: transactionRequest.accessList => [[providers-AccessList]]
|
||||
|
||||
The [[providers-AccessList]] included in an [[link-eip-2930]] transaction, which will
|
||||
also have its ``type`` equal to ``1``.
|
||||
|
||||
_heading: TransactionReceipt @<providers-TransactionReceipt>
|
||||
|
||||
_property: receipt.to => string<[[address]]>
|
||||
@@ -314,3 +335,110 @@ _property: receipt.status => boolean
|
||||
The status of a transaction is 1 is successful or 0 if it was
|
||||
reverted. Only transactions included in blocks [post-Byzantium Hard Fork](link-eip-609)
|
||||
have this property.
|
||||
|
||||
_subsection: Access Lists
|
||||
|
||||
An Access List is optional an includes a list of addresses and storage
|
||||
slots for that address which should be //warmed// or pre-fetched for
|
||||
use within the execution of this transaction. A //warmed// value has an
|
||||
additional upfront cost to access, but is discounted throughout the code
|
||||
execution for reading and writing.
|
||||
|
||||
_heading: AccessListish @<providers-AccessListish>
|
||||
|
||||
A looser description of an [[providers-AccessList]], which will be
|
||||
converted internally using [accessListify](utils-accessListify).
|
||||
|
||||
|
||||
It may be any of:
|
||||
|
||||
- any [[providers-AccessList]]
|
||||
- an Array of 2-element Arrays, where the first element is the address
|
||||
and second array is an array of storage keys
|
||||
- an object, whose keys represent the addresses and each value is an
|
||||
array of storage keys
|
||||
|
||||
When using the object form (the last option), the addresses and storage
|
||||
slots will be sorted. If an explicit order for the access list is
|
||||
required, one of the other forms must be used. Most developers
|
||||
**do not** require explicit order.
|
||||
|
||||
_code: equivalent to the AccessList example below @lang<javascript>
|
||||
|
||||
// Option 1:
|
||||
// AccessList
|
||||
// see below
|
||||
|
||||
// Option 2:
|
||||
// Array< [ Address, Array<Bytes32> ] >
|
||||
[
|
||||
[
|
||||
"0x0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
|
||||
[
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d"
|
||||
]
|
||||
],
|
||||
[
|
||||
"0x5FfC014343cd971B7eb70732021E26C35B744cc4",
|
||||
[
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
||||
]
|
||||
]
|
||||
]
|
||||
// <hide>
|
||||
;
|
||||
// </hide>
|
||||
|
||||
// Option 3:
|
||||
// Record<Address, Array<Bytes32>>
|
||||
// <hide>
|
||||
(
|
||||
// </hide>
|
||||
{
|
||||
"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d"
|
||||
],
|
||||
"0x5FfC014343cd971B7eb70732021E26C35B744cc4": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
||||
]
|
||||
}
|
||||
// <hide>
|
||||
)
|
||||
// </hide>
|
||||
|
||||
|
||||
_heading: AccessList @<providers-AccessList>
|
||||
|
||||
An [[link-eip-2930]] transaction allows an optional **AccessList**
|
||||
which causes a transaction to //warm// (i.e. pre-cache) another
|
||||
addresses state and the specified storage keys.
|
||||
|
||||
This incurs an increased intrinsic cost for the transaction, but provides
|
||||
discounts for storage and state access throughout the execution of the
|
||||
transaction.
|
||||
|
||||
_code: example access list
|
||||
|
||||
// Array of objects with the form:
|
||||
// {
|
||||
// address: Address,
|
||||
// storageKey: Array< DataHexString< 32 > >
|
||||
// }
|
||||
|
||||
[
|
||||
{
|
||||
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
|
||||
storageKeys: [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d"
|
||||
]
|
||||
},
|
||||
{
|
||||
address: "0x5FfC014343cd971B7eb70732021E26C35B744cc4",
|
||||
storageKeys: [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -97,6 +97,15 @@ used to encode the chain ID into the serialized transaction.
|
||||
|
||||
_subsection: Functions @<transactions--functions>
|
||||
|
||||
_property: ethers.utils.accessListify(anAcceslistish) => [[providers-AccessList]] @<utils-accessListify> @SRC<transactions:accessListify>
|
||||
Normalizes the [[providers-AccessListish]] //anAccessListish// into
|
||||
an [[providers-AccessList]].
|
||||
|
||||
This is useful for other utility functions which wish to remain
|
||||
flexible as to the input parameter for access lists, such as
|
||||
when creating a [[Signer]] which needs to manipulate a possibly
|
||||
typed transaction envelope.
|
||||
|
||||
_property: ethers.utils.parseTransaction(aBytesLike) => [[Transaction]] @<utils-parseTransaction> @SRC<transactions:parse>
|
||||
Parses the transaction properties from a serialized transaction.
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ _subsection: Solidity Topics @<events-solidity>
|
||||
This is a quick (and non-comprehensive) overview of how events are computed
|
||||
in Solidity.
|
||||
|
||||
This is likely out of the scope for most developers, but may be intersting
|
||||
This is likely out of the scope for most developers, but may be interesting
|
||||
to those who want to learn a bit more about the underlying technology.
|
||||
|
||||
Solidity provides two types of events, anonymous and non-anonymous. The
|
||||
|
||||
@@ -161,7 +161,7 @@ function codeContextify(context) {
|
||||
|
||||
module.exports = {
|
||||
title: "ethers",
|
||||
subtitle: "v5.0",
|
||||
subtitle: "v5.2",
|
||||
description: "Documentation for ethers, a complete, tiny and simple Ethereum library.",
|
||||
logo: "logo.svg",
|
||||
|
||||
@@ -204,7 +204,8 @@ module.exports = {
|
||||
"link-rtd": "https:/\/github.com/readthedocs/sphinx_rtd_theme",
|
||||
"link-semver": { name: "semver", url: "https:/\/semver.org" },
|
||||
"link-solidity": { name: "Solidity" , url: "https:/\/solidity.readthedocs.io/" },
|
||||
"link-solidity-events": "https:/\/docs.soliditylang.org/en/v0.8.1/abi-spec.html#events",
|
||||
"link-solidity-errors": "https:/\/docs.soliditylang.org/en/v0.8.4/abi-spec.html#errors",
|
||||
"link-solidity-events": "https:/\/docs.soliditylang.org/en/v0.8.4/abi-spec.html#events",
|
||||
"link-sphinx": { name: "Sphinx", url: "https:/\/www.sphinx-doc.org/" },
|
||||
|
||||
"link-alchemy-signup": "https:/\/dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d",
|
||||
@@ -246,7 +247,7 @@ module.exports = {
|
||||
|
||||
"link-ethersio": "https:/\/ethers.io/",
|
||||
"link-ethers-docs": "https:/\/docs.ethers.io/",
|
||||
"link-ethers-js": "https:/\/cdn.ethers.io/lib/ethers-5.0.esm.min.js",
|
||||
"link-ethers-js": "https:/\/cdn.ethers.io/lib/ethers-5.1.esm.min.js",
|
||||
"link-ethers-npm": "https:/\/www.npmjs.com/search?q=%40ethersproject%2F",
|
||||
"link-ethers-asm-grammar": "https:/\/github.com/ethers-io/ethers.js/blob/master/packages/asm/grammar.jison",
|
||||
|
||||
@@ -260,6 +261,8 @@ module.exports = {
|
||||
"link-eip-1577": { name: "EIP-1577", url: "https:/\/eips.ethereum.org/EIPS/eip-1577" },
|
||||
"link-eip-2098": { name: "EIP-2098", url: "https:/\/eips.ethereum.org/EIPS/eip-2098" },
|
||||
"link-eip-2304": { name: "EIP-2304", url: "https:/\/eips.ethereum.org/EIPS/eip-2304" },
|
||||
"link-eip-2718": { name: "EIP-2718", url: "https:/\/eips.ethereum.org/EIPS/eip-2718" },
|
||||
"link-eip-2930": { name: "EIP-2930", url: "https:/\/eips.ethereum.org/EIPS/eip-2930" },
|
||||
"link-bip-39": { name: "BIP-39", url: "https:/\/en.bitcoin.it/wiki/BIP_0039" },
|
||||
"link-bip-32": { name: "BIP-32", url: "https:/\/github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" },
|
||||
"link-bip-44": { name: "BIP-44", url: "https:/\/en.bitcoin.it/wiki/BIP_0044" },
|
||||
|
||||
@@ -101,7 +101,7 @@ with Ethereum and is available in all major Ethereum node implementations
|
||||
third-party web services (e.g. [[link-infura]]). It typically provides:
|
||||
|
||||
- A connection to the Ethereum network (a [[Provider]])
|
||||
- Holds your private key and can sign thing (a [[Signer]])
|
||||
- Holds your private key and can sign things (a [[Signer]])
|
||||
|
||||
_code: Connecting to an RPC client @lang<script>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ of uses.
|
||||
|
||||
_heading: MIT License
|
||||
|
||||
//Copyright © 2019 [Richard Moore](mailto:me@ricmoo.com).//
|
||||
//Copyright © 2019-2021 [Richard Moore](mailto:me@ricmoo.com).//
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupBuild = void 0;
|
||||
const path_1 = require("./path");
|
||||
const utils_1 = require("./utils");
|
||||
function setupConfig(outDir, moduleType, targetType) {
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -11,14 +30,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getLatestChange = exports.generate = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const local = __importStar(require("./local"));
|
||||
const log_1 = require("./log");
|
||||
|
||||
1
misc/admin/lib/cmds/bump-minor-version.d.ts
vendored
Normal file
1
misc/admin/lib/cmds/bump-minor-version.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
75
misc/admin/lib/cmds/bump-minor-version.js
Normal file
75
misc/admin/lib/cmds/bump-minor-version.js
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
//import fs from "fs";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const local = __importStar(require("../local"));
|
||||
const npm = __importStar(require("../npm"));
|
||||
const path_1 = require("../path");
|
||||
(function () {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const pNpm = yield npm.getPackage("ethers");
|
||||
const newVersion = semver_1.default.inc(pNpm.version, "minor");
|
||||
for (let i = 0; i < path_1.dirnames.length; i++) {
|
||||
const dirname = path_1.dirnames[i];
|
||||
const pLocal = local.getPackage(dirname);
|
||||
const deps = Object.keys(pLocal.dependencies).reduce((accum, name) => {
|
||||
let version = pLocal.dependencies[name];
|
||||
const prefix = name.split("/")[0];
|
||||
if (dirname === "ethers") {
|
||||
if (prefix === "@ethersproject") {
|
||||
if (!version.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
|
||||
throw new Error(`bad version for bumping: ${dirname}:${name}:${version}`);
|
||||
}
|
||||
version = newVersion;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (prefix === "ethers" || prefix === "@ethersproject") {
|
||||
if (version.substring(0, 1) !== "^") {
|
||||
throw new Error(`bad version for bumping: ${dirname}:${name}:${version}`);
|
||||
}
|
||||
version = "^" + newVersion;
|
||||
}
|
||||
}
|
||||
accum[name] = version;
|
||||
return accum;
|
||||
}, {});
|
||||
const packageJsonPath = path_1.getPackageJsonPath(dirname);
|
||||
local.updateJson(packageJsonPath, {
|
||||
dependencies: deps,
|
||||
version: newVersion
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -1,4 +1,23 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -11,13 +30,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
@@ -45,7 +57,14 @@ const utils_1 = require("../utils");
|
||||
const tarballHash = local.computeTarballHash(dirname);
|
||||
let version = pNpm.version;
|
||||
if (tarballHash !== pNpm.tarballHash) {
|
||||
version = semver_1.default.inc(version, "patch");
|
||||
if (semver_1.default.gt(pLocal.version, version)) {
|
||||
// Already have a more recent version locally
|
||||
version = pLocal.version;
|
||||
}
|
||||
else {
|
||||
// Bump the patch version from NPM
|
||||
version = semver_1.default.inc(version, "patch");
|
||||
}
|
||||
output.push([
|
||||
" ",
|
||||
log_1.colorify.blue(pLocal.name),
|
||||
|
||||
@@ -35,7 +35,7 @@ function link(existing, path) {
|
||||
// Link
|
||||
const dir = path_1.dirname(path);
|
||||
utils_1.mkdir(dir);
|
||||
fs_1.default.symlinkSync(existing, path);
|
||||
fs_1.default.symlinkSync(existing, path, "junction");
|
||||
}
|
||||
(function () {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -11,14 +30,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.invalidate = exports.putObject = void 0;
|
||||
const { createHash } = require("crypto");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
||||
@@ -147,6 +160,8 @@ exports.invalidate = invalidate;
|
||||
}
|
||||
if (publishNames.indexOf("ethers") >= 0 || forcePublish) {
|
||||
const change = changelog_1.getLatestChange();
|
||||
const patchVersion = change.version.substring(1);
|
||||
const minorVersion = patchVersion.split(".").slice(0, 2).join(".");
|
||||
const awsAccessId = yield config_1.config.get("aws-upload-scripts-accesskey");
|
||||
const awsSecretKey = yield config_1.config.get("aws-upload-scripts-secretkey");
|
||||
// Publish tagged release on GitHub
|
||||
@@ -163,7 +178,7 @@ exports.invalidate = invalidate;
|
||||
content += '<script type="text/javascript"\n';
|
||||
content += ` integrity="sha384-${hash}"\n`;
|
||||
content += ' crossorigin="anonymous"\n';
|
||||
content += ` src="https:/\/cdn-cors.ethers.io/lib/ethers-${change.version.substring(1)}.umd.min.js">\n`;
|
||||
content += ` src="https:/\/cdn-cors.ethers.io/lib/ethers-${patchVersion}.umd.min.js">\n`;
|
||||
content += '</script>\n';
|
||||
content += '```';
|
||||
// Publish the release
|
||||
@@ -171,7 +186,7 @@ exports.invalidate = invalidate;
|
||||
const link = yield github_1.createRelease(username, password, change.version, change.title, content, beta, gitCommit);
|
||||
console.log(`${log_1.colorify.bold("Published release:")} ${link}`);
|
||||
}
|
||||
// Upload libs to the CDN (as ethers-v5.0 and ethers-5.0.x)
|
||||
// Upload libs to the CDN (as ethers-v5.1 and ethers-5.1.x)
|
||||
{
|
||||
const bucketNameLib = yield config_1.config.get("aws-upload-scripts-bucket");
|
||||
const originRootLib = yield config_1.config.get("aws-upload-scripts-root");
|
||||
@@ -182,7 +197,7 @@ exports.invalidate = invalidate;
|
||||
accessKeyId: awsAccessId,
|
||||
secretAccessKey: awsSecretKey
|
||||
});
|
||||
// Upload the libs to ethers-v5.0 and ethers-5.0.x
|
||||
// Upload the libs to ethers-v5.1 and ethers-5.1.x
|
||||
const fileInfos = [
|
||||
// The CORS-enabled versions on cdn-cors.ethers.io
|
||||
{
|
||||
@@ -190,39 +205,39 @@ exports.invalidate = invalidate;
|
||||
originRoot: originRootCors,
|
||||
suffix: "-cors",
|
||||
filename: "packages/ethers/dist/ethers.esm.min.js",
|
||||
key: `ethers-${change.version.substring(1)}.esm.min.js`
|
||||
key: `ethers-${patchVersion}.esm.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameCors,
|
||||
originRoot: originRootCors,
|
||||
suffix: "-cors",
|
||||
filename: "packages/ethers/dist/ethers.umd.min.js",
|
||||
key: `ethers-${change.version.substring(1)}.umd.min.js`
|
||||
key: `ethers-${patchVersion}.umd.min.js`
|
||||
},
|
||||
// The non-CORS-enabled versions on cdn.ethers.io
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.esm.min.js",
|
||||
key: `ethers-${change.version.substring(1)}.esm.min.js`
|
||||
key: `ethers-${patchVersion}.esm.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.umd.min.js",
|
||||
key: `ethers-${change.version.substring(1)}.umd.min.js`
|
||||
key: `ethers-${patchVersion}.umd.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.esm.min.js",
|
||||
key: "ethers-5.0.esm.min.js"
|
||||
key: `ethers-${minorVersion}.esm.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.umd.min.js",
|
||||
key: "ethers-5.0.umd.min.js"
|
||||
key: `ethers-${minorVersion}.umd.min.js`
|
||||
},
|
||||
];
|
||||
for (let i = 0; i < fileInfos.length; i++) {
|
||||
|
||||
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.start = exports.getMime = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const http_1 = require("http");
|
||||
const path_1 = require("path");
|
||||
|
||||
@@ -31,10 +31,11 @@ expired failed fetches formatted formatting funding generated
|
||||
hardened has highly ignoring implemented implementer imported including instantiate
|
||||
joined keyword labelled larger lookup matches mined modified modifies multi
|
||||
named needed nested neutered numeric offline optimizer overriding owned packed
|
||||
padded parsed parsing passed placeholder processing properties prototyping reached
|
||||
padded parsed parsing passed payload placeholder processing properties prototyping reached
|
||||
recommended recovered redacted remaining replaced required reverted
|
||||
serializes shared signed signing skipped stored supported tagging targetted
|
||||
throttled transactions typed uninstall unstake unsubscribe using verifies verifying website
|
||||
throttled transactions typed uninstall unstake unsubscribe untyped
|
||||
using verifies verifying website
|
||||
|
||||
// Overly Specific Words
|
||||
bech BIP BIP39 BIP44 btc bzz crypto eip etc hashes hmac icap
|
||||
@@ -54,15 +55,15 @@ jumpdest mstore shr shl xor
|
||||
ABIEncoder testcase numberish Wordlist
|
||||
|
||||
// Common Code Strings
|
||||
abi addr api app arg arrayify asm basex bigint bignumber bn byte
|
||||
abi addr api app arg arrayify asm backend basex bigint bignumber bn byte
|
||||
bytecode callback calldata charset checksum ciphertext cli codepoint
|
||||
commify config
|
||||
contenthash ctr ctrl debug dd dklen eexist encseed eof ethaddr
|
||||
contenthash ctr ctrl debug dd dklen eexist encseed eof eq ethaddr
|
||||
ethseed ethers eval exec filename func gz gzip hid http https hw iv
|
||||
info init ipc json kdf kdfparams labelhash lang lib mm multihash nfc
|
||||
nfkc nfd nfkd nodehash notok nowait nullish oob opcode pbkdf pc plugin
|
||||
pragma pre prf repl rpc sighash topichash solc stdin stdout subclasses
|
||||
subnode timeout todo txt ufixed utc utf util url urlencoded uuid vm
|
||||
pragma pre prf recid repl rpc sighash topichash solc stdin stdout subclasses
|
||||
subnode timeout todo txt typeof ufixed utc utf util url urlencoded uuid vm
|
||||
vs websocket wikipedia www wx xe xpriv xpub xx yyyy zlib
|
||||
|
||||
// AbiV2
|
||||
|
||||
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.putObject = exports.getKeys = void 0;
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = require("path");
|
||||
|
||||
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.config = void 0;
|
||||
const crypto_1 = require("crypto");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const os_1 = __importDefault(require("os"));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sort = exports.getOrdered = void 0;
|
||||
const path_1 = require("./path");
|
||||
const local_1 = require("./local");
|
||||
class OrderedSet {
|
||||
|
||||
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getUrl = void 0;
|
||||
const http_1 = __importDefault(require("http"));
|
||||
const https_1 = __importDefault(require("https"));
|
||||
const url_1 = require("url");
|
||||
|
||||
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getGitTag = void 0;
|
||||
const run_1 = require("./run");
|
||||
// Returns the most recent git commit hash for a given filename
|
||||
function getGitTag(filename) {
|
||||
|
||||
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createRelease = exports.syncIssues = exports.getIssues = exports.fetchGitHub = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const zlib_1 = __importDefault(require("zlib"));
|
||||
const js_sha3_1 = require("js-sha3");
|
||||
|
||||
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.computeTarballHash = exports.getPackList = exports.getDependencies = exports.updateJson = exports.getPackage = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = require("./path");
|
||||
const run_1 = require("./run");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPassword = exports.getPrompt = exports.colorify = exports.getProgressBar = void 0;
|
||||
const utils_1 = require("./utils");
|
||||
// See: https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
|
||||
let disableColor = !(process.stdout.isTTY);
|
||||
|
||||
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.publish = exports.getPackage = void 0;
|
||||
const libnpmpublish_1 = require("libnpmpublish");
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const geturl_1 = require("./geturl");
|
||||
|
||||
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isEthers = exports.getPackageJsonPath = exports.getDirname = exports.getPackagePath = exports.packages = exports.dirnames = exports.dirs = exports.resolve = exports.root = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = require("path");
|
||||
exports.root = path_1.resolve(__dirname, "../../../");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.run = void 0;
|
||||
const child_process_1 = require("child_process");
|
||||
function run(progname, args, currentWorkingDirectory) {
|
||||
if (args == null) {
|
||||
|
||||
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getDateTime = exports.mkdir = exports.resolveProperties = exports.saveJson = exports.loadJson = exports.atomicWrite = exports.sortRecords = exports.sha256 = exports.repeat = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = require("path");
|
||||
const crypto_1 = require("crypto");
|
||||
|
||||
47
misc/admin/src.ts/cmds/bump-minor-version.ts
Normal file
47
misc/admin/src.ts/cmds/bump-minor-version.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
//import fs from "fs";
|
||||
|
||||
import semver from "semver";
|
||||
|
||||
import * as local from "../local";
|
||||
import * as npm from "../npm";
|
||||
import { dirnames, getPackageJsonPath } from "../path";
|
||||
|
||||
(async function() {
|
||||
const pNpm = await npm.getPackage("ethers");
|
||||
const newVersion = semver.inc(pNpm.version, "minor");
|
||||
|
||||
for (let i = 0; i < dirnames.length; i++) {
|
||||
const dirname = dirnames[i];
|
||||
const pLocal = local.getPackage(dirname);
|
||||
|
||||
const deps = Object.keys(pLocal.dependencies).reduce((accum, name) => {
|
||||
let version = pLocal.dependencies[name];
|
||||
|
||||
const prefix = name.split("/")[0];
|
||||
if (dirname === "ethers") {
|
||||
if (prefix === "@ethersproject") {
|
||||
if (!version.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
|
||||
throw new Error(`bad version for bumping: ${ dirname }:${ name }:${ version }`);
|
||||
}
|
||||
version = newVersion;
|
||||
}
|
||||
} else {
|
||||
if (prefix === "ethers" || prefix === "@ethersproject") {
|
||||
if (version.substring(0, 1) !== "^") {
|
||||
throw new Error(`bad version for bumping: ${ dirname }:${ name }:${ version }`);
|
||||
}
|
||||
version = "^" + newVersion;
|
||||
}
|
||||
}
|
||||
accum[name] = version;
|
||||
|
||||
return accum;
|
||||
}, <Record<string, string>>{});
|
||||
|
||||
const packageJsonPath = getPackageJsonPath(dirname);
|
||||
local.updateJson(packageJsonPath, {
|
||||
dependencies: deps,
|
||||
version: newVersion
|
||||
}, true);
|
||||
}
|
||||
})();
|
||||
@@ -36,7 +36,13 @@ import { loadJson, repeat, saveJson } from "../utils";
|
||||
let version = pNpm.version;
|
||||
|
||||
if (tarballHash !== pNpm.tarballHash) {
|
||||
version = semver.inc(version, "patch");
|
||||
if (semver.gt(pLocal.version, version)) {
|
||||
// Already have a more recent version locally
|
||||
version = pLocal.version;
|
||||
} else {
|
||||
// Bump the patch version from NPM
|
||||
version = semver.inc(version, "patch");
|
||||
}
|
||||
|
||||
output.push([
|
||||
" ",
|
||||
|
||||
@@ -21,7 +21,7 @@ function link(existing: string, path: string): void {
|
||||
// Link
|
||||
const dir = dirname(path);
|
||||
mkdir(dir);
|
||||
fs.symlinkSync(existing, path);
|
||||
fs.symlinkSync(existing, path, "junction");
|
||||
}
|
||||
|
||||
(async function() {
|
||||
|
||||
@@ -150,6 +150,9 @@ export function invalidate(cloudfront: AWS.CloudFront, distributionId: string):
|
||||
if (publishNames.indexOf("ethers") >= 0 || forcePublish) {
|
||||
const change = getLatestChange();
|
||||
|
||||
const patchVersion = change.version.substring(1);
|
||||
const minorVersion = patchVersion.split(".").slice(0, 2).join(".")
|
||||
|
||||
const awsAccessId = await config.get("aws-upload-scripts-accesskey");
|
||||
const awsSecretKey = await config.get("aws-upload-scripts-secretkey");
|
||||
|
||||
@@ -170,7 +173,7 @@ export function invalidate(cloudfront: AWS.CloudFront, distributionId: string):
|
||||
content += '<script type="text/javascript"\n';
|
||||
content += ` integrity="sha384-${ hash }"\n`;
|
||||
content += ' crossorigin="anonymous"\n';
|
||||
content += ` src="https:/\/cdn-cors.ethers.io/lib/ethers-${ change.version.substring(1) }.umd.min.js">\n`;
|
||||
content += ` src="https:/\/cdn-cors.ethers.io/lib/ethers-${ patchVersion }.umd.min.js">\n`;
|
||||
content += '</script>\n';
|
||||
content += '```';
|
||||
|
||||
@@ -180,7 +183,7 @@ export function invalidate(cloudfront: AWS.CloudFront, distributionId: string):
|
||||
console.log(`${ colorify.bold("Published release:") } ${ link }`);
|
||||
}
|
||||
|
||||
// Upload libs to the CDN (as ethers-v5.0 and ethers-5.0.x)
|
||||
// Upload libs to the CDN (as ethers-v5.1 and ethers-5.1.x)
|
||||
{
|
||||
const bucketNameLib = await config.get("aws-upload-scripts-bucket");
|
||||
const originRootLib = await config.get("aws-upload-scripts-root");
|
||||
@@ -194,7 +197,7 @@ export function invalidate(cloudfront: AWS.CloudFront, distributionId: string):
|
||||
secretAccessKey: awsSecretKey
|
||||
});
|
||||
|
||||
// Upload the libs to ethers-v5.0 and ethers-5.0.x
|
||||
// Upload the libs to ethers-v5.1 and ethers-5.1.x
|
||||
const fileInfos: Array<{ bucketName: string, originRoot: string, filename: string, key: string, suffix?: string }> = [
|
||||
// The CORS-enabled versions on cdn-cors.ethers.io
|
||||
{
|
||||
@@ -202,14 +205,14 @@ export function invalidate(cloudfront: AWS.CloudFront, distributionId: string):
|
||||
originRoot: originRootCors,
|
||||
suffix: "-cors",
|
||||
filename: "packages/ethers/dist/ethers.esm.min.js",
|
||||
key: `ethers-${ change.version.substring(1) }.esm.min.js`
|
||||
key: `ethers-${ patchVersion }.esm.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameCors,
|
||||
originRoot: originRootCors,
|
||||
suffix: "-cors",
|
||||
filename: "packages/ethers/dist/ethers.umd.min.js",
|
||||
key: `ethers-${ change.version.substring(1) }.umd.min.js`
|
||||
key: `ethers-${ patchVersion }.umd.min.js`
|
||||
},
|
||||
|
||||
// The non-CORS-enabled versions on cdn.ethers.io
|
||||
@@ -217,25 +220,25 @@ export function invalidate(cloudfront: AWS.CloudFront, distributionId: string):
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.esm.min.js",
|
||||
key: `ethers-${ change.version.substring(1) }.esm.min.js`
|
||||
key: `ethers-${ patchVersion }.esm.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.umd.min.js",
|
||||
key: `ethers-${ change.version.substring(1) }.umd.min.js`
|
||||
key: `ethers-${ patchVersion }.umd.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.esm.min.js",
|
||||
key: "ethers-5.0.esm.min.js"
|
||||
key: `ethers-${ minorVersion }.esm.min.js`
|
||||
},
|
||||
{
|
||||
bucketName: bucketNameLib,
|
||||
originRoot: originRootLib,
|
||||
filename: "packages/ethers/dist/ethers.umd.min.js",
|
||||
key: "ethers-5.0.umd.min.js"
|
||||
key: `ethers-${ minorVersion }.umd.min.js`
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -22,10 +22,11 @@ expired failed fetches formatted formatting funding generated
|
||||
hardened has highly ignoring implemented implementer imported including instantiate
|
||||
joined keyword labelled larger lookup matches mined modified modifies multi
|
||||
named needed nested neutered numeric offline optimizer overriding owned packed
|
||||
padded parsed parsing passed placeholder processing properties prototyping reached
|
||||
padded parsed parsing passed payload placeholder processing properties prototyping reached
|
||||
recommended recovered redacted remaining replaced required reverted
|
||||
serializes shared signed signing skipped stored supported tagging targetted
|
||||
throttled transactions typed uninstall unstake unsubscribe using verifies verifying website
|
||||
throttled transactions typed uninstall unstake unsubscribe untyped
|
||||
using verifies verifying website
|
||||
|
||||
// Overly Specific Words
|
||||
bech BIP BIP39 BIP44 btc bzz crypto eip etc hashes hmac icap
|
||||
@@ -45,15 +46,15 @@ jumpdest mstore shr shl xor
|
||||
ABIEncoder testcase numberish Wordlist
|
||||
|
||||
// Common Code Strings
|
||||
abi addr api app arg arrayify asm basex bigint bignumber bn byte
|
||||
abi addr api app arg arrayify asm backend basex bigint bignumber bn byte
|
||||
bytecode callback calldata charset checksum ciphertext cli codepoint
|
||||
commify config
|
||||
contenthash ctr ctrl debug dd dklen eexist encseed eof ethaddr
|
||||
contenthash ctr ctrl debug dd dklen eexist encseed eof eq ethaddr
|
||||
ethseed ethers eval exec filename func gz gzip hid http https hw iv
|
||||
info init ipc json kdf kdfparams labelhash lang lib mm multihash nfc
|
||||
nfkc nfd nfkd nodehash notok nowait nullish oob opcode pbkdf pc plugin
|
||||
pragma pre prf repl rpc sighash topichash solc stdin stdout subclasses
|
||||
subnode timeout todo txt ufixed utc utf util url urlencoded uuid vm
|
||||
pragma pre prf recid repl rpc sighash topichash solc stdin stdout subclasses
|
||||
subnode timeout todo txt typeof ufixed utc utf util url urlencoded uuid vm
|
||||
vs websocket wikipedia www wx xe xpriv xpub xx yyyy zlib
|
||||
|
||||
// AbiV2
|
||||
|
||||
1179
package-lock.json
generated
1179
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@
|
||||
"diff": "4.0.1",
|
||||
"flatworm": "0.0.2-beta.5",
|
||||
"jison": "0.4.18",
|
||||
"karma": "5.2.3",
|
||||
"karma": "6.3.2",
|
||||
"karma-chrome-launcher": "3.1.0",
|
||||
"karma-mocha": "2.0.1",
|
||||
"libnpmpublish": "3.0.1",
|
||||
|
||||
2
packages/abi/lib.esm/_version.d.ts
vendored
2
packages/abi/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abi/5.1.0";
|
||||
export declare const version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abi/5.1.0";
|
||||
export const version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src.ts/coders/array.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGjE,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,GAAG,CAAA;CAAE,GAAG,MAAM,CAuEzH;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAiFnE;AAGD,qBAAa,UAAW,SAAQ,KAAK;IACjC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAS3D,YAAY,IAAI,KAAK,CAAC,GAAG,CAAC;IAW1B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM;IAoBjD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG;CAW9B"}
|
||||
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src.ts/coders/array.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGjE,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,GAAG,CAAA;CAAE,GAAG,MAAM,CAuEzH;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAiFnE;AAGD,qBAAa,UAAW,SAAQ,KAAK;IACjC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAS3D,YAAY,IAAI,KAAK,CAAC,GAAG,CAAC;IAW1B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM;IAoBjD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG;CAsB9B"}
|
||||
@@ -185,6 +185,17 @@ export class ArrayCoder extends Coder {
|
||||
let count = this.length;
|
||||
if (count === -1) {
|
||||
count = reader.readValue().toNumber();
|
||||
// Check that there is *roughly* enough data to ensure
|
||||
// stray random data is not being read as a length. Each
|
||||
// slot requires at least 32 bytes for their value (or 32
|
||||
// bytes as a link to the data). This could use a much
|
||||
// tighter bound, but we are erroring on the side of safety.
|
||||
if (count * 32 > reader._data.length) {
|
||||
logger.throwError("insufficient data length", Logger.errors.BUFFER_OVERRUN, {
|
||||
length: reader._data.length,
|
||||
count: count
|
||||
});
|
||||
}
|
||||
}
|
||||
let coders = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
7
packages/abi/lib.esm/fragments.d.ts
vendored
7
packages/abi/lib.esm/fragments.d.ts
vendored
@@ -74,4 +74,11 @@ export declare class FunctionFragment extends ConstructorFragment {
|
||||
static fromString(value: string): FunctionFragment;
|
||||
static isFunctionFragment(value: any): value is FunctionFragment;
|
||||
}
|
||||
export declare class ErrorFragment extends Fragment {
|
||||
format(format?: string): string;
|
||||
static from(value: ErrorFragment | JsonFragment | string): ErrorFragment;
|
||||
static fromObject(value: ErrorFragment | JsonFragment): ErrorFragment;
|
||||
static fromString(value: string): ErrorFragment;
|
||||
static isErrorFragment(value: any): value is ErrorFragment;
|
||||
}
|
||||
//# sourceMappingURL=fragments.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../src.ts/fragments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAOrD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAEnD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACzB;AA4MD,eAAO,MAAM,WAAW,EAAE;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CAAA;CAYlD,CAAC;AAIH,qBAAa,SAAS;IAGlB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAGtB,QAAQ,CAAC,IAAI,EAAE,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mB;IAwBjF,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB;IAiBrD,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,mBAAmB;CAGzE;AAOD,qBAAa,gBAAiB,SAAQ,mBAAmB;IACrD,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAE3B,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAoD/B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,MAAM,GAAG,gBAAgB;IAO9E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,gBAAgB;IAuB3E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;IAmClD,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,gBAAgB;CAGnE;AAaD,qBAAa,aAAc,SAAQ,QAAQ;IAEvC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IA2B/B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,aAAa;IAOxE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,aAAa;IAgBrE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IAgB/C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa;CAG7D"}
|
||||
@@ -354,6 +354,8 @@ export class Fragment {
|
||||
return EventFragment.fromObject(value);
|
||||
case "constructor":
|
||||
return ConstructorFragment.fromObject(value);
|
||||
case "error":
|
||||
return ErrorFragment.fromObject(value);
|
||||
case "fallback":
|
||||
case "receive":
|
||||
// @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
|
||||
@@ -375,6 +377,9 @@ export class Fragment {
|
||||
else if (value.split("(")[0].trim() === "constructor") {
|
||||
return ConstructorFragment.fromString(value.trim());
|
||||
}
|
||||
else if (value.split(" ")[0] === "error") {
|
||||
return ErrorFragment.fromString(value.substring(5).trim());
|
||||
}
|
||||
return logger.throwArgumentError("unsupported fragment", "value", value);
|
||||
}
|
||||
static isFragment(value) {
|
||||
@@ -730,10 +735,74 @@ export class FunctionFragment extends ConstructorFragment {
|
||||
return (value && value._isFragment && value.type === "function");
|
||||
}
|
||||
}
|
||||
//export class ErrorFragment extends Fragment {
|
||||
//}
|
||||
//export class StructFragment extends Fragment {
|
||||
//}
|
||||
function checkForbidden(fragment) {
|
||||
const sig = fragment.format();
|
||||
if (sig === "Error(string)" || sig === "Panic(uint256)") {
|
||||
logger.throwArgumentError(`cannot specify user defined ${sig} error`, "fragment", fragment);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
export class ErrorFragment extends Fragment {
|
||||
format(format) {
|
||||
if (!format) {
|
||||
format = FormatTypes.sighash;
|
||||
}
|
||||
if (!FormatTypes[format]) {
|
||||
logger.throwArgumentError("invalid format type", "format", format);
|
||||
}
|
||||
if (format === FormatTypes.json) {
|
||||
return JSON.stringify({
|
||||
type: "error",
|
||||
name: this.name,
|
||||
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
||||
});
|
||||
}
|
||||
let result = "";
|
||||
if (format !== FormatTypes.sighash) {
|
||||
result += "error ";
|
||||
}
|
||||
result += this.name + "(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") ";
|
||||
return result.trim();
|
||||
}
|
||||
static from(value) {
|
||||
if (typeof (value) === "string") {
|
||||
return ErrorFragment.fromString(value);
|
||||
}
|
||||
return ErrorFragment.fromObject(value);
|
||||
}
|
||||
static fromObject(value) {
|
||||
if (ErrorFragment.isErrorFragment(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.type !== "error") {
|
||||
logger.throwArgumentError("invalid error object", "value", value);
|
||||
}
|
||||
const params = {
|
||||
type: value.type,
|
||||
name: verifyIdentifier(value.name),
|
||||
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : [])
|
||||
};
|
||||
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
||||
}
|
||||
static fromString(value) {
|
||||
let params = { type: "error" };
|
||||
let parens = value.match(regexParen);
|
||||
if (!parens) {
|
||||
logger.throwArgumentError("invalid error signature", "value", value);
|
||||
}
|
||||
params.name = parens[1].trim();
|
||||
if (params.name) {
|
||||
verifyIdentifier(params.name);
|
||||
}
|
||||
params.inputs = parseParams(parens[2], false);
|
||||
return checkForbidden(ErrorFragment.fromObject(params));
|
||||
}
|
||||
static isErrorFragment(value) {
|
||||
return (value && value._isFragment && value.type === "error");
|
||||
}
|
||||
}
|
||||
function verifyType(type) {
|
||||
// These need to be transformed to their full description
|
||||
if (type.match(/^uint($|[^1-9])/)) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
packages/abi/lib.esm/index.d.ts
vendored
4
packages/abi/lib.esm/index.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription } from "./interface";
|
||||
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrJ,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpK,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, ParamType } from "./fragments";
|
||||
import { AbiCoder, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, TransactionDescription } from "./interface";
|
||||
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, checkResultErrors, LogDescription, TransactionDescription };
|
||||
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, checkResultErrors, LogDescription, TransactionDescription };
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAkC,SAAS,EAAE,MAAM,aAAa,CAAC;AACrJ,OAAO,EAAE,QAAQ,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAU,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAUP,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAkC,SAAS,EAAE,MAAM,aAAa,CAAC;AACpK,OAAO,EAAE,QAAQ,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAU,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAUP,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
7
packages/abi/lib.esm/interface.d.ts
vendored
7
packages/abi/lib.esm/interface.d.ts
vendored
@@ -3,7 +3,7 @@ import { BytesLike } from "@ethersproject/bytes";
|
||||
import { Description } from "@ethersproject/properties";
|
||||
import { AbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Result } from "./coders/abstract-coder";
|
||||
import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
export { checkResultErrors, Result };
|
||||
export declare class LogDescription extends Description<LogDescription> {
|
||||
readonly eventFragment: EventFragment;
|
||||
@@ -28,7 +28,7 @@ export declare class Indexed extends Description<Indexed> {
|
||||
export declare class Interface {
|
||||
readonly fragments: ReadonlyArray<Fragment>;
|
||||
readonly errors: {
|
||||
[name: string]: any;
|
||||
[name: string]: ErrorFragment;
|
||||
};
|
||||
readonly events: {
|
||||
[name: string]: EventFragment;
|
||||
@@ -46,10 +46,11 @@ export declare class Interface {
|
||||
format(format?: string): string | Array<string>;
|
||||
static getAbiCoder(): AbiCoder;
|
||||
static getAddress(address: string): string;
|
||||
static getSighash(functionFragment: FunctionFragment): string;
|
||||
static getSighash(fragment: ErrorFragment | FunctionFragment): string;
|
||||
static getEventTopic(eventFragment: EventFragment): string;
|
||||
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
|
||||
getEvent(nameOrSignatureOrTopic: string): EventFragment;
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment;
|
||||
getSighash(functionFragment: FunctionFragment | string): string;
|
||||
getEventTopic(eventFragment: EventFragment | string): string;
|
||||
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src.ts/interface.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAY,SAAS,EAA0D,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAkB,WAAW,EAAa,MAAM,2BAA2B,CAAC;AAEnF,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAe,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMnI,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW,CAAC,cAAc,CAAC;IAC3D,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,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AAc;IAgCrE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS;CAGrD"}
|
||||
@@ -21,6 +21,10 @@ export class Indexed extends Description {
|
||||
return !!(value && value._isIndexed);
|
||||
}
|
||||
}
|
||||
const BuiltinErrors = {
|
||||
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
|
||||
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
|
||||
};
|
||||
function wrapAccessError(property, error) {
|
||||
const wrap = new Error(`deferred error during ABI decoding triggered accessing ${property}`);
|
||||
wrap.error = error;
|
||||
@@ -78,6 +82,9 @@ export class Interface {
|
||||
//checkNames(fragment, "input", fragment.inputs);
|
||||
bucket = this.events;
|
||||
break;
|
||||
case "error":
|
||||
bucket = this.errors;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -118,8 +125,8 @@ export class Interface {
|
||||
static getAddress(address) {
|
||||
return getAddress(address);
|
||||
}
|
||||
static getSighash(functionFragment) {
|
||||
return hexDataSlice(id(functionFragment.format()), 0, 4);
|
||||
static getSighash(fragment) {
|
||||
return hexDataSlice(id(fragment.format()), 0, 4);
|
||||
}
|
||||
static getEventTopic(eventFragment) {
|
||||
return id(eventFragment.format());
|
||||
@@ -183,6 +190,37 @@ export class Interface {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Find a function definition by any means necessary (unless it is ambiguous)
|
||||
getError(nameOrSignatureOrSighash) {
|
||||
if (isHexString(nameOrSignatureOrSighash)) {
|
||||
const getSighash = getStatic(this.constructor, "getSighash");
|
||||
for (const name in this.errors) {
|
||||
const error = this.errors[name];
|
||||
if (nameOrSignatureOrSighash === getSighash(error)) {
|
||||
return this.errors[name];
|
||||
}
|
||||
}
|
||||
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
||||
}
|
||||
// It is a bare name, look up the function (will return null if ambiguous)
|
||||
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
||||
const name = nameOrSignatureOrSighash.trim();
|
||||
const matching = Object.keys(this.errors).filter((f) => (f.split("(" /* fix:) */)[0] === name));
|
||||
if (matching.length === 0) {
|
||||
logger.throwArgumentError("no matching error", "name", name);
|
||||
}
|
||||
else if (matching.length > 1) {
|
||||
logger.throwArgumentError("multiple matching errors", "name", name);
|
||||
}
|
||||
return this.errors[matching[0]];
|
||||
}
|
||||
// Normlize the signature and lookup the function
|
||||
const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
||||
if (!result) {
|
||||
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
getSighash(functionFragment) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
@@ -234,6 +272,8 @@ export class Interface {
|
||||
}
|
||||
let bytes = arrayify(data);
|
||||
let reason = null;
|
||||
let errorArgs = null;
|
||||
let errorName = null;
|
||||
let errorSignature = null;
|
||||
switch (bytes.length % this._abiCoder._getWordSize()) {
|
||||
case 0:
|
||||
@@ -242,18 +282,34 @@ export class Interface {
|
||||
}
|
||||
catch (error) { }
|
||||
break;
|
||||
case 4:
|
||||
if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
||||
errorSignature = "Error(string)";
|
||||
reason = this._abiCoder.decode(["string"], bytes.slice(4))[0];
|
||||
case 4: {
|
||||
const selector = hexlify(bytes.slice(0, 4));
|
||||
const builtin = BuiltinErrors[selector];
|
||||
if (builtin) {
|
||||
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
||||
errorName = builtin.name;
|
||||
errorSignature = builtin.signature;
|
||||
if (builtin.reason) {
|
||||
reason = errorArgs[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
const error = this.getError(selector);
|
||||
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
||||
errorName = error.name;
|
||||
errorSignature = error.format();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return logger.throwError("call revert exception", Logger.errors.CALL_EXCEPTION, {
|
||||
method: functionFragment.format(),
|
||||
errorSignature: errorSignature,
|
||||
errorArgs: [reason],
|
||||
reason: reason
|
||||
errorArgs, errorName, errorSignature, reason
|
||||
});
|
||||
}
|
||||
// Encode the result for a function call (e.g. for eth_call)
|
||||
@@ -459,6 +515,8 @@ export class Interface {
|
||||
value: BigNumber.from(tx.value || "0"),
|
||||
});
|
||||
}
|
||||
// @TODO
|
||||
//parseCallResult(data: BytesLike): ??
|
||||
// Given an event log, find the matching event fragment (if any) and
|
||||
// determine all its properties and values
|
||||
parseLog(log) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
packages/abi/lib/_version.d.ts
vendored
2
packages/abi/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abi/5.1.0";
|
||||
export declare const version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "abi/5.1.0";
|
||||
exports.version = "abi/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src.ts/coders/array.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGjE,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG;IAAE,CAAE,IAAI,EAAE,MAAM,GAAI,GAAG,CAAA;CAAE,GAAG,MAAM,CA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C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM;IAoBjD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG;CAsB9B"}
|
||||
@@ -210,6 +210,17 @@ var ArrayCoder = /** @class */ (function (_super) {
|
||||
var count = this.length;
|
||||
if (count === -1) {
|
||||
count = reader.readValue().toNumber();
|
||||
// Check that there is *roughly* enough data to ensure
|
||||
// stray random data is not being read as a length. Each
|
||||
// slot requires at least 32 bytes for their value (or 32
|
||||
// bytes as a link to the data). This could use a much
|
||||
// tighter bound, but we are erroring on the side of safety.
|
||||
if (count * 32 > reader._data.length) {
|
||||
logger.throwError("insufficient data length", logger_1.Logger.errors.BUFFER_OVERRUN, {
|
||||
length: reader._data.length,
|
||||
count: count
|
||||
});
|
||||
}
|
||||
}
|
||||
var coders = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
7
packages/abi/lib/fragments.d.ts
vendored
7
packages/abi/lib/fragments.d.ts
vendored
@@ -74,4 +74,11 @@ export declare class FunctionFragment extends ConstructorFragment {
|
||||
static fromString(value: string): FunctionFragment;
|
||||
static isFunctionFragment(value: any): value is FunctionFragment;
|
||||
}
|
||||
export declare class ErrorFragment extends Fragment {
|
||||
format(format?: string): string;
|
||||
static from(value: ErrorFragment | JsonFragment | string): ErrorFragment;
|
||||
static fromObject(value: ErrorFragment | JsonFragment): ErrorFragment;
|
||||
static fromString(value: string): ErrorFragment;
|
||||
static isErrorFragment(value: any): value is ErrorFragment;
|
||||
}
|
||||
//# sourceMappingURL=fragments.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../src.ts/fragments.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAOrD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,C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MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,MAAM,GAAG,gBAAgB;IAO9E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,gBAAgB;IAuB3E,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;IAmClD,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,gBAAgB;CAGnE;AAaD,qBAAa,aAAc,SAAQ,QAAQ;IAEvC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IA2B/B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,aAAa;IAOxE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,aAAa;IAgBrE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa;IAgB/C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa;CAG7D"}
|
||||
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
|
||||
exports.ErrorFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.Fragment = exports.ParamType = exports.FormatTypes = void 0;
|
||||
var bignumber_1 = require("@ethersproject/bignumber");
|
||||
var properties_1 = require("@ethersproject/properties");
|
||||
var logger_1 = require("@ethersproject/logger");
|
||||
@@ -373,6 +373,8 @@ var Fragment = /** @class */ (function () {
|
||||
return EventFragment.fromObject(value);
|
||||
case "constructor":
|
||||
return ConstructorFragment.fromObject(value);
|
||||
case "error":
|
||||
return ErrorFragment.fromObject(value);
|
||||
case "fallback":
|
||||
case "receive":
|
||||
// @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
|
||||
@@ -394,6 +396,9 @@ var Fragment = /** @class */ (function () {
|
||||
else if (value.split("(")[0].trim() === "constructor") {
|
||||
return ConstructorFragment.fromString(value.trim());
|
||||
}
|
||||
else if (value.split(" ")[0] === "error") {
|
||||
return ErrorFragment.fromString(value.substring(5).trim());
|
||||
}
|
||||
return logger.throwArgumentError("unsupported fragment", "value", value);
|
||||
};
|
||||
Fragment.isFragment = function (value) {
|
||||
@@ -769,10 +774,80 @@ var FunctionFragment = /** @class */ (function (_super) {
|
||||
return FunctionFragment;
|
||||
}(ConstructorFragment));
|
||||
exports.FunctionFragment = FunctionFragment;
|
||||
//export class ErrorFragment extends Fragment {
|
||||
//}
|
||||
//export class StructFragment extends Fragment {
|
||||
//}
|
||||
function checkForbidden(fragment) {
|
||||
var sig = fragment.format();
|
||||
if (sig === "Error(string)" || sig === "Panic(uint256)") {
|
||||
logger.throwArgumentError("cannot specify user defined " + sig + " error", "fragment", fragment);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
var ErrorFragment = /** @class */ (function (_super) {
|
||||
__extends(ErrorFragment, _super);
|
||||
function ErrorFragment() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ErrorFragment.prototype.format = function (format) {
|
||||
if (!format) {
|
||||
format = exports.FormatTypes.sighash;
|
||||
}
|
||||
if (!exports.FormatTypes[format]) {
|
||||
logger.throwArgumentError("invalid format type", "format", format);
|
||||
}
|
||||
if (format === exports.FormatTypes.json) {
|
||||
return JSON.stringify({
|
||||
type: "error",
|
||||
name: this.name,
|
||||
inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }),
|
||||
});
|
||||
}
|
||||
var result = "";
|
||||
if (format !== exports.FormatTypes.sighash) {
|
||||
result += "error ";
|
||||
}
|
||||
result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") ";
|
||||
return result.trim();
|
||||
};
|
||||
ErrorFragment.from = function (value) {
|
||||
if (typeof (value) === "string") {
|
||||
return ErrorFragment.fromString(value);
|
||||
}
|
||||
return ErrorFragment.fromObject(value);
|
||||
};
|
||||
ErrorFragment.fromObject = function (value) {
|
||||
if (ErrorFragment.isErrorFragment(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.type !== "error") {
|
||||
logger.throwArgumentError("invalid error object", "value", value);
|
||||
}
|
||||
var params = {
|
||||
type: value.type,
|
||||
name: verifyIdentifier(value.name),
|
||||
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : [])
|
||||
};
|
||||
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
||||
};
|
||||
ErrorFragment.fromString = function (value) {
|
||||
var params = { type: "error" };
|
||||
var parens = value.match(regexParen);
|
||||
if (!parens) {
|
||||
logger.throwArgumentError("invalid error signature", "value", value);
|
||||
}
|
||||
params.name = parens[1].trim();
|
||||
if (params.name) {
|
||||
verifyIdentifier(params.name);
|
||||
}
|
||||
params.inputs = parseParams(parens[2], false);
|
||||
return checkForbidden(ErrorFragment.fromObject(params));
|
||||
};
|
||||
ErrorFragment.isErrorFragment = function (value) {
|
||||
return (value && value._isFragment && value.type === "error");
|
||||
};
|
||||
return ErrorFragment;
|
||||
}(Fragment));
|
||||
exports.ErrorFragment = ErrorFragment;
|
||||
function verifyType(type) {
|
||||
// These need to be transformed to their full description
|
||||
if (type.match(/^uint($|[^1-9])/)) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
packages/abi/lib/index.d.ts
vendored
4
packages/abi/lib/index.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription } from "./interface";
|
||||
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
export { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result, checkResultErrors, LogDescription, TransactionDescription };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrJ,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpK,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEpH,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,WAAW,EAEX,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,OAAO,EAKP,UAAU,EACV,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,iBAAiB,EAEjB,cAAc,EACd,sBAAsB,EACzB,CAAC"}
|
||||
@@ -1,8 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = exports.Indexed = exports.Interface = exports.defaultAbiCoder = exports.AbiCoder = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ConstructorFragment = void 0;
|
||||
exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = exports.Indexed = exports.Interface = exports.defaultAbiCoder = exports.AbiCoder = exports.FormatTypes = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = void 0;
|
||||
var fragments_1 = require("./fragments");
|
||||
Object.defineProperty(exports, "ConstructorFragment", { enumerable: true, get: function () { return fragments_1.ConstructorFragment; } });
|
||||
Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: function () { return fragments_1.ErrorFragment; } });
|
||||
Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return fragments_1.EventFragment; } });
|
||||
Object.defineProperty(exports, "FormatTypes", { enumerable: true, get: function () { return fragments_1.FormatTypes; } });
|
||||
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragments_1.Fragment; } });
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAAqJ;AAKjJ,oGALK,+BAAmB,OAKL;AACnB,8FAN0B,yBAAa,OAM1B;AAIb,4FAVyC,uBAAW,OAUzC;AAHX,yFAPsD,oBAAQ,OAOtD;AACR,iGARgE,4BAAgB,OAQhE;AAChB,0FATkH,qBAAS,OASlH;AARb,yCAAoE;AAWhE,yFAXK,oBAAQ,OAWL;AACR,gGAZ2B,2BAAe,OAY3B;AAXnB,yCAAoH;AAwBhH,kGAxBK,6BAAiB,OAwBL;AAVjB,wFAdwB,mBAAO,OAcxB;AADP,0FAbiC,qBAAS,OAajC;AAaT,+FA1B4C,0BAAc,OA0B5C;AACd,uGA3BoE,kCAAsB,OA2BpE"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAAoK;AAKhK,oGALK,+BAAmB,OAKL;AACnB,8FAN0B,yBAAa,OAM1B;AACb,8FAPyC,yBAAa,OAOzC;AAIb,4FAXwD,uBAAW,OAWxD;AAHX,yFARqE,oBAAQ,OAQrE;AACR,iGAT+E,4BAAgB,OAS/E;AAChB,0FAViI,qBAAS,OAUjI;AATb,yCAAoE;AAYhE,yFAZK,oBAAQ,OAYL;AACR,gGAb2B,2BAAe,OAa3B;AAZnB,yCAAoH;AAyBhH,kGAzBK,6BAAiB,OAyBL;AAVjB,wFAfwB,mBAAO,OAexB;AADP,0FAdiC,qBAAS,OAcjC;AAaT,+FA3B4C,0BAAc,OA2B5C;AACd,uGA5BoE,kCAAsB,OA4BpE"}
|
||||
7
packages/abi/lib/interface.d.ts
vendored
7
packages/abi/lib/interface.d.ts
vendored
@@ -3,7 +3,7 @@ import { BytesLike } from "@ethersproject/bytes";
|
||||
import { Description } from "@ethersproject/properties";
|
||||
import { AbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Result } from "./coders/abstract-coder";
|
||||
import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
export { checkResultErrors, Result };
|
||||
export declare class LogDescription extends Description<LogDescription> {
|
||||
readonly eventFragment: EventFragment;
|
||||
@@ -28,7 +28,7 @@ export declare class Indexed extends Description<Indexed> {
|
||||
export declare class Interface {
|
||||
readonly fragments: ReadonlyArray<Fragment>;
|
||||
readonly errors: {
|
||||
[name: string]: any;
|
||||
[name: string]: ErrorFragment;
|
||||
};
|
||||
readonly events: {
|
||||
[name: string]: EventFragment;
|
||||
@@ -46,10 +46,11 @@ export declare class Interface {
|
||||
format(format?: string): string | Array<string>;
|
||||
static getAbiCoder(): AbiCoder;
|
||||
static getAddress(address: string): string;
|
||||
static getSighash(functionFragment: FunctionFragment): string;
|
||||
static getSighash(fragment: ErrorFragment | FunctionFragment): string;
|
||||
static getEventTopic(eventFragment: EventFragment): string;
|
||||
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
|
||||
getEvent(nameOrSignatureOrTopic: string): EventFragment;
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment;
|
||||
getSighash(functionFragment: FunctionFragment | string): string;
|
||||
getEventTopic(eventFragment: EventFragment | string): string;
|
||||
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src.ts/interface.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAY,SAAS,EAA0D,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAkB,WAAW,E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GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;KAAE;IA4CjH,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM;IA0F9G,gBAAgB,CAAC,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,YAAY,CAAA;KAAE,GAAG,sBAAsB;IAoBpF,QAAQ,CAAC,GAAG,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,cAAc;IAgCrE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS;CAGrD"}
|
||||
@@ -56,6 +56,10 @@ var Indexed = /** @class */ (function (_super) {
|
||||
return Indexed;
|
||||
}(properties_1.Description));
|
||||
exports.Indexed = Indexed;
|
||||
var BuiltinErrors = {
|
||||
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true },
|
||||
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: ["uint256"] }
|
||||
};
|
||||
function wrapAccessError(property, error) {
|
||||
var wrap = new Error("deferred error during ABI decoding triggered accessing " + property);
|
||||
wrap.error = error;
|
||||
@@ -115,6 +119,9 @@ var Interface = /** @class */ (function () {
|
||||
//checkNames(fragment, "input", fragment.inputs);
|
||||
bucket = _this.events;
|
||||
break;
|
||||
case "error":
|
||||
bucket = _this.errors;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -155,8 +162,8 @@ var Interface = /** @class */ (function () {
|
||||
Interface.getAddress = function (address) {
|
||||
return address_1.getAddress(address);
|
||||
};
|
||||
Interface.getSighash = function (functionFragment) {
|
||||
return bytes_1.hexDataSlice(hash_1.id(functionFragment.format()), 0, 4);
|
||||
Interface.getSighash = function (fragment) {
|
||||
return bytes_1.hexDataSlice(hash_1.id(fragment.format()), 0, 4);
|
||||
};
|
||||
Interface.getEventTopic = function (eventFragment) {
|
||||
return hash_1.id(eventFragment.format());
|
||||
@@ -220,6 +227,37 @@ var Interface = /** @class */ (function () {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
// Find a function definition by any means necessary (unless it is ambiguous)
|
||||
Interface.prototype.getError = function (nameOrSignatureOrSighash) {
|
||||
if (bytes_1.isHexString(nameOrSignatureOrSighash)) {
|
||||
var getSighash = properties_1.getStatic(this.constructor, "getSighash");
|
||||
for (var name_5 in this.errors) {
|
||||
var error = this.errors[name_5];
|
||||
if (nameOrSignatureOrSighash === getSighash(error)) {
|
||||
return this.errors[name_5];
|
||||
}
|
||||
}
|
||||
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
||||
}
|
||||
// It is a bare name, look up the function (will return null if ambiguous)
|
||||
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
||||
var name_6 = nameOrSignatureOrSighash.trim();
|
||||
var matching = Object.keys(this.errors).filter(function (f) { return (f.split("(" /* fix:) */)[0] === name_6); });
|
||||
if (matching.length === 0) {
|
||||
logger.throwArgumentError("no matching error", "name", name_6);
|
||||
}
|
||||
else if (matching.length > 1) {
|
||||
logger.throwArgumentError("multiple matching errors", "name", name_6);
|
||||
}
|
||||
return this.errors[matching[0]];
|
||||
}
|
||||
// Normlize the signature and lookup the function
|
||||
var result = this.errors[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
||||
if (!result) {
|
||||
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
Interface.prototype.getSighash = function (functionFragment) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
@@ -271,6 +309,8 @@ var Interface = /** @class */ (function () {
|
||||
}
|
||||
var bytes = bytes_1.arrayify(data);
|
||||
var reason = null;
|
||||
var errorArgs = null;
|
||||
var errorName = null;
|
||||
var errorSignature = null;
|
||||
switch (bytes.length % this._abiCoder._getWordSize()) {
|
||||
case 0:
|
||||
@@ -279,18 +319,34 @@ var Interface = /** @class */ (function () {
|
||||
}
|
||||
catch (error) { }
|
||||
break;
|
||||
case 4:
|
||||
if (bytes_1.hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
||||
errorSignature = "Error(string)";
|
||||
reason = this._abiCoder.decode(["string"], bytes.slice(4))[0];
|
||||
case 4: {
|
||||
var selector = bytes_1.hexlify(bytes.slice(0, 4));
|
||||
var builtin = BuiltinErrors[selector];
|
||||
if (builtin) {
|
||||
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
||||
errorName = builtin.name;
|
||||
errorSignature = builtin.signature;
|
||||
if (builtin.reason) {
|
||||
reason = errorArgs[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
var error = this.getError(selector);
|
||||
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
||||
errorName = error.name;
|
||||
errorSignature = error.format();
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return logger.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, {
|
||||
method: functionFragment.format(),
|
||||
errorSignature: errorSignature,
|
||||
errorArgs: [reason],
|
||||
reason: reason
|
||||
errorArgs: errorArgs, errorName: errorName, errorSignature: errorSignature, reason: reason
|
||||
});
|
||||
};
|
||||
// Encode the result for a function call (e.g. for eth_call)
|
||||
@@ -501,6 +557,8 @@ var Interface = /** @class */ (function () {
|
||||
value: bignumber_1.BigNumber.from(tx.value || "0"),
|
||||
});
|
||||
};
|
||||
// @TODO
|
||||
//parseCallResult(data: BytesLike): ??
|
||||
// Given an event log, find the matching event fragment (if any) and
|
||||
// determine all its properties and values
|
||||
Interface.prototype.parseLog = function (log) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/address": "^5.1.0",
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/constants": "^5.1.0",
|
||||
"@ethersproject/hash": "^5.1.0",
|
||||
"@ethersproject/keccak256": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0",
|
||||
"@ethersproject/strings": "^5.1.0"
|
||||
"@ethersproject/address": "^5.2.0",
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/constants": "^5.2.0",
|
||||
"@ethersproject/hash": "^5.2.0",
|
||||
"@ethersproject/keccak256": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0",
|
||||
"@ethersproject/strings": "^5.2.0"
|
||||
},
|
||||
"description": "Utilities and Classes for parsing, formatting and managing Ethereum ABIs.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -43,7 +43,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x1268f244b9c48541e6ac01c961ac81782d8dc8212aa3a00f570f8e4a5ebb541b",
|
||||
"tarballHash": "0xe6a078fafe9b871044b84c2f528321d6f35a175220d2d0cd29b5f7b75b7c3752",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abi/5.1.0";
|
||||
export const version = "abi/5.2.0";
|
||||
|
||||
@@ -212,8 +212,19 @@ export class ArrayCoder extends Coder {
|
||||
let count = this.length;
|
||||
if (count === -1) {
|
||||
count = reader.readValue().toNumber();
|
||||
}
|
||||
|
||||
// Check that there is *roughly* enough data to ensure
|
||||
// stray random data is not being read as a length. Each
|
||||
// slot requires at least 32 bytes for their value (or 32
|
||||
// bytes as a link to the data). This could use a much
|
||||
// tighter bound, but we are erroring on the side of safety.
|
||||
if (count * 32 > reader._data.length) {
|
||||
logger.throwError("insufficient data length", Logger.errors.BUFFER_OVERRUN, {
|
||||
length: reader._data.length,
|
||||
count: count
|
||||
});
|
||||
}
|
||||
}
|
||||
let coders = [];
|
||||
for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); }
|
||||
|
||||
|
||||
@@ -445,6 +445,8 @@ export abstract class Fragment {
|
||||
return EventFragment.fromObject(value);
|
||||
case "constructor":
|
||||
return ConstructorFragment.fromObject(value);
|
||||
case "error":
|
||||
return ErrorFragment.fromObject(value);
|
||||
case "fallback":
|
||||
case "receive":
|
||||
// @TODO: Something? Maybe return a FunctionFragment? A custom DefaultFunctionFragment?
|
||||
@@ -466,6 +468,8 @@ export abstract class Fragment {
|
||||
return FunctionFragment.fromString(value.substring(8).trim());
|
||||
} else if (value.split("(")[0].trim() === "constructor") {
|
||||
return ConstructorFragment.fromString(value.trim());
|
||||
} else if (value.split(" ")[0] === "error") {
|
||||
return ErrorFragment.fromString(value.substring(5).trim());
|
||||
}
|
||||
|
||||
return logger.throwArgumentError("unsupported fragment", "value", value);
|
||||
@@ -927,12 +931,90 @@ export class FunctionFragment extends ConstructorFragment {
|
||||
}
|
||||
}
|
||||
|
||||
//export class ErrorFragment extends Fragment {
|
||||
//}
|
||||
|
||||
//export class StructFragment extends Fragment {
|
||||
//}
|
||||
|
||||
function checkForbidden(fragment: ErrorFragment): ErrorFragment {
|
||||
const sig = fragment.format();
|
||||
if (sig === "Error(string)" || sig === "Panic(uint256)") {
|
||||
logger.throwArgumentError(`cannot specify user defined ${ sig } error`, "fragment", fragment);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
|
||||
export class ErrorFragment extends Fragment {
|
||||
|
||||
format(format?: string): string {
|
||||
if (!format) { format = FormatTypes.sighash; }
|
||||
if (!FormatTypes[format]) {
|
||||
logger.throwArgumentError("invalid format type", "format", format);
|
||||
}
|
||||
|
||||
if (format === FormatTypes.json) {
|
||||
return JSON.stringify({
|
||||
type: "error",
|
||||
name: this.name,
|
||||
inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
|
||||
});
|
||||
}
|
||||
|
||||
let result = "";
|
||||
|
||||
if (format !== FormatTypes.sighash) {
|
||||
result += "error ";
|
||||
}
|
||||
|
||||
result += this.name + "(" + this.inputs.map(
|
||||
(input) => input.format(format)
|
||||
).join((format === FormatTypes.full) ? ", ": ",") + ") ";
|
||||
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
static from(value: ErrorFragment | JsonFragment | string): ErrorFragment {
|
||||
if (typeof(value) === "string") {
|
||||
return ErrorFragment.fromString(value);
|
||||
}
|
||||
return ErrorFragment.fromObject(value);
|
||||
}
|
||||
|
||||
static fromObject(value: ErrorFragment | JsonFragment): ErrorFragment {
|
||||
if (ErrorFragment.isErrorFragment(value)) { return value; }
|
||||
|
||||
if (value.type !== "error") {
|
||||
logger.throwArgumentError("invalid error object", "value", value);
|
||||
}
|
||||
|
||||
const params: TypeCheck<_Fragment> = {
|
||||
type: value.type,
|
||||
name: verifyIdentifier(value.name),
|
||||
inputs: (value.inputs ? value.inputs.map(ParamType.fromObject): [])
|
||||
};
|
||||
|
||||
return checkForbidden(new ErrorFragment(_constructorGuard, params));
|
||||
}
|
||||
|
||||
static fromString(value: string): ErrorFragment {
|
||||
let params: any = { type: "error" };
|
||||
|
||||
let parens = value.match(regexParen);
|
||||
if (!parens) {
|
||||
logger.throwArgumentError("invalid error signature", "value", value);
|
||||
}
|
||||
|
||||
params.name = parens[1].trim();
|
||||
if (params.name) { verifyIdentifier(params.name); }
|
||||
|
||||
params.inputs = parseParams(parens[2], false);
|
||||
|
||||
return checkForbidden(ErrorFragment.fromObject(params));
|
||||
}
|
||||
|
||||
static isErrorFragment(value: any): value is ErrorFragment {
|
||||
return (value && value._isFragment && value.type === "error");
|
||||
}
|
||||
}
|
||||
|
||||
function verifyType(type: string): string {
|
||||
|
||||
// These need to be transformed to their full description
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
|
||||
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription } from "./interface";
|
||||
|
||||
export {
|
||||
ConstructorFragment,
|
||||
ErrorFragment,
|
||||
EventFragment,
|
||||
Fragment,
|
||||
FunctionFragment,
|
||||
|
||||
@@ -9,7 +9,7 @@ import { defineReadOnly, Description, getStatic } from "@ethersproject/propertie
|
||||
|
||||
import { AbiCoder, defaultAbiCoder } from "./abi-coder";
|
||||
import { checkResultErrors, Result } from "./coders/abstract-coder";
|
||||
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
import { ConstructorFragment, ErrorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
|
||||
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
@@ -43,6 +43,11 @@ export class Indexed extends Description<Indexed> {
|
||||
}
|
||||
}
|
||||
|
||||
const BuiltinErrors: Record<string, { signature: string, inputs: Array<string>, name: string, reason?: boolean }> = {
|
||||
"0x08c379a0": { signature: "Error(string)", name: "Error", inputs: [ "string" ], reason: true },
|
||||
"0x4e487b71": { signature: "Panic(uint256)", name: "Panic", inputs: [ "uint256" ] }
|
||||
}
|
||||
|
||||
function wrapAccessError(property: string, error: Error): Error {
|
||||
const wrap = new Error(`deferred error during ABI decoding triggered accessing ${ property }`);
|
||||
(<any>wrap).error = error;
|
||||
@@ -65,7 +70,7 @@ function checkNames(fragment: Fragment, type: "input" | "output", params: Array<
|
||||
export class Interface {
|
||||
readonly fragments: ReadonlyArray<Fragment>;
|
||||
|
||||
readonly errors: { [ name: string ]: any };
|
||||
readonly errors: { [ name: string ]: ErrorFragment };
|
||||
readonly events: { [ name: string ]: EventFragment };
|
||||
readonly functions: { [ name: string ]: FunctionFragment };
|
||||
readonly structs: { [ name: string ]: any };
|
||||
@@ -118,6 +123,9 @@ export class Interface {
|
||||
//checkNames(fragment, "input", fragment.inputs);
|
||||
bucket = this.events;
|
||||
break;
|
||||
case "error":
|
||||
bucket = this.errors;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -167,8 +175,8 @@ export class Interface {
|
||||
return getAddress(address);
|
||||
}
|
||||
|
||||
static getSighash(functionFragment: FunctionFragment): string {
|
||||
return hexDataSlice(id(functionFragment.format()), 0, 4);
|
||||
static getSighash(fragment: ErrorFragment | FunctionFragment): string {
|
||||
return hexDataSlice(id(fragment.format()), 0, 4);
|
||||
}
|
||||
|
||||
static getEventTopic(eventFragment: EventFragment): string {
|
||||
@@ -240,6 +248,40 @@ export class Interface {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find a function definition by any means necessary (unless it is ambiguous)
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment {
|
||||
if (isHexString(nameOrSignatureOrSighash)) {
|
||||
const getSighash = getStatic<(f: ErrorFragment | FunctionFragment) => string>(this.constructor, "getSighash");
|
||||
for (const name in this.errors) {
|
||||
const error = this.errors[name];
|
||||
if (nameOrSignatureOrSighash === getSighash(error)) {
|
||||
return this.errors[name];
|
||||
}
|
||||
}
|
||||
logger.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash);
|
||||
}
|
||||
|
||||
// It is a bare name, look up the function (will return null if ambiguous)
|
||||
if (nameOrSignatureOrSighash.indexOf("(") === -1) {
|
||||
const name = nameOrSignatureOrSighash.trim();
|
||||
const matching = Object.keys(this.errors).filter((f) => (f.split("("/* fix:) */)[0] === name));
|
||||
if (matching.length === 0) {
|
||||
logger.throwArgumentError("no matching error", "name", name);
|
||||
} else if (matching.length > 1) {
|
||||
logger.throwArgumentError("multiple matching errors", "name", name);
|
||||
}
|
||||
|
||||
return this.errors[matching[0]];
|
||||
}
|
||||
|
||||
// Normlize the signature and lookup the function
|
||||
const result = this.errors[FunctionFragment.fromString(nameOrSignatureOrSighash).format()];
|
||||
if (!result) {
|
||||
logger.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
getSighash(functionFragment: FunctionFragment | string): string {
|
||||
if (typeof(functionFragment) === "string") {
|
||||
@@ -304,9 +346,11 @@ export class Interface {
|
||||
functionFragment = this.getFunction(functionFragment);
|
||||
}
|
||||
|
||||
let bytes = arrayify(data);
|
||||
let bytes = arrayify(data);
|
||||
|
||||
let reason: string = null;
|
||||
let errorArgs: Result = null;
|
||||
let errorName: string = null;
|
||||
let errorSignature: string = null;
|
||||
switch (bytes.length % this._abiCoder._getWordSize()) {
|
||||
case 0:
|
||||
@@ -315,19 +359,31 @@ export class Interface {
|
||||
} catch (error) { }
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
|
||||
errorSignature = "Error(string)";
|
||||
reason = this._abiCoder.decode([ "string" ], bytes.slice(4))[0];
|
||||
case 4: {
|
||||
const selector = hexlify(bytes.slice(0, 4));
|
||||
const builtin = BuiltinErrors[selector];
|
||||
if (builtin) {
|
||||
errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4));
|
||||
errorName = builtin.name;
|
||||
errorSignature = builtin.signature;
|
||||
if (builtin.reason) { reason = errorArgs[0]; }
|
||||
} else {
|
||||
try {
|
||||
const error = this.getError(selector);
|
||||
errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4));
|
||||
errorName = error.name;
|
||||
errorSignature = error.format();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return logger.throwError("call revert exception", Logger.errors.CALL_EXCEPTION, {
|
||||
method: functionFragment.format(),
|
||||
errorSignature: errorSignature,
|
||||
errorArgs: [ reason ],
|
||||
reason: reason
|
||||
errorArgs, errorName, errorSignature, reason
|
||||
});
|
||||
}
|
||||
|
||||
@@ -547,6 +603,9 @@ export class Interface {
|
||||
});
|
||||
}
|
||||
|
||||
// @TODO
|
||||
//parseCallResult(data: BytesLike): ??
|
||||
|
||||
// Given an event log, find the matching event fragment (if any) and
|
||||
// determine all its properties and values
|
||||
parseLog(log: { topics: Array<string>, data: string}): LogDescription {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-provider/5.1.0";
|
||||
export declare const version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abstract-provider/5.1.0";
|
||||
export const version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -75,7 +75,7 @@ export interface TransactionReceipt {
|
||||
}
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string>>;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
}
|
||||
export interface Filter extends EventFilter {
|
||||
fromBlock?: BlockTag;
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
packages/abstract-provider/lib/_version.d.ts
vendored
2
packages/abstract-provider/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-provider/5.1.0";
|
||||
export declare const version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "abstract-provider/5.1.0";
|
||||
exports.version = "abstract-provider/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/abstract-provider/lib/index.d.ts
vendored
2
packages/abstract-provider/lib/index.d.ts
vendored
@@ -75,7 +75,7 @@ export interface TransactionReceipt {
|
||||
}
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string>>;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
}
|
||||
export interface Filter extends EventFilter {
|
||||
fromBlock?: BlockTag;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/networks": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0",
|
||||
"@ethersproject/transactions": "^5.1.0",
|
||||
"@ethersproject/web": "^5.1.0"
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/networks": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0",
|
||||
"@ethersproject/transactions": "^5.2.0",
|
||||
"@ethersproject/web": "^5.2.0"
|
||||
},
|
||||
"description": "An Abstract Class for describing an Ethereum Provider for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -41,7 +41,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x9a2ee9005c813b52689b7d87a01f6ce29010ef3f899c5fc500e6ae3ea0f03ea2",
|
||||
"tarballHash": "0x7b9f83b84726a18491bd1665ff4d856364aba22521e78572353d1d9995ac1c4e",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abstract-provider/5.1.0";
|
||||
export const version = "abstract-provider/5.2.0";
|
||||
|
||||
@@ -114,7 +114,7 @@ export interface TransactionReceipt {
|
||||
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string>>;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
}
|
||||
|
||||
export interface Filter extends EventFilter {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-signer/5.1.0";
|
||||
export declare const version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abstract-signer/5.1.0";
|
||||
export const version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/abstract-signer/lib/_version.d.ts
vendored
2
packages/abstract-signer/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-signer/5.1.0";
|
||||
export declare const version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "abstract-signer/5.1.0";
|
||||
exports.version = "abstract-signer/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/abstract-provider": "^5.1.0",
|
||||
"@ethersproject/bignumber": "^5.1.0",
|
||||
"@ethersproject/bytes": "^5.1.0",
|
||||
"@ethersproject/logger": "^5.1.0",
|
||||
"@ethersproject/properties": "^5.1.0"
|
||||
"@ethersproject/abstract-provider": "^5.2.0",
|
||||
"@ethersproject/bignumber": "^5.2.0",
|
||||
"@ethersproject/bytes": "^5.2.0",
|
||||
"@ethersproject/logger": "^5.2.0",
|
||||
"@ethersproject/properties": "^5.2.0"
|
||||
},
|
||||
"description": "An Abstract Class for desribing an Ethereum Signer for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -39,7 +39,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0x56d53f21cca4bb8b1b1f7c25edf66e7633dbe56c90164546110f4702c6d0650e",
|
||||
"tarballHash": "0x6a009bacd601b395a4cf53b290b3f3eb6e624fdaabf4b24940ecb1cf0836d096",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.1.0"
|
||||
"version": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abstract-signer/5.1.0";
|
||||
export const version = "abstract-signer/5.2.0";
|
||||
|
||||
2
packages/address/lib.esm/_version.d.ts
vendored
2
packages/address/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "address/5.1.0";
|
||||
export declare const version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "address/5.1.0";
|
||||
export const version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/address/lib/_version.d.ts
vendored
2
packages/address/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "address/5.1.0";
|
||||
export declare const version = "address/5.2.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user