Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4166b2753d | ||
|
|
32a6b2a362 | ||
|
|
f2a32d0d5b | ||
|
|
5762a1f83d | ||
|
|
8320d534d7 | ||
|
|
c41b89a0c1 | ||
|
|
b6a061e7bf | ||
|
|
a662490e82 | ||
|
|
bdb54ac52b | ||
|
|
32a90b66f0 | ||
|
|
95b87f61a6 | ||
|
|
017b1feba2 | ||
|
|
accb85268c | ||
|
|
f0b3bc32d5 | ||
|
|
78e4273a32 | ||
|
|
dd09bf0735 | ||
|
|
4b163e9e73 | ||
|
|
aacb95cd6b | ||
|
|
e6315a6b3c | ||
|
|
3ac91a414c | ||
|
|
2dd5c1a6d2 | ||
|
|
2653449f3c | ||
|
|
cddb03880a | ||
|
|
e80f8dd4e6 | ||
|
|
1b4bc7a6a6 | ||
|
|
4e9394554b | ||
|
|
1d27d95670 | ||
|
|
2e431a5002 | ||
|
|
da4e107268 | ||
|
|
7175e2e99c | ||
|
|
68229ac0af | ||
|
|
7274cd06cf | ||
|
|
be3854e648 | ||
|
|
63f8b28223 | ||
|
|
593b4886ff | ||
|
|
6d1904c379 | ||
|
|
0aafca71db | ||
|
|
0d40156fcb | ||
|
|
576e9b54ab | ||
|
|
bc5cc2e7e3 | ||
|
|
660e69db71 | ||
|
|
551cfa0062 | ||
|
|
0f0d0c00d3 | ||
|
|
a1f8d188a7 | ||
|
|
bde861436e | ||
|
|
6e8a39ec35 | ||
|
|
ecae793edf | ||
|
|
bac684c5a0 | ||
|
|
53671d0b17 | ||
|
|
25c8b8b3e6 | ||
|
|
a0fa92c075 | ||
|
|
72feee8f58 | ||
|
|
71b7547f10 | ||
|
|
4970385e7b | ||
|
|
0364dd9368 | ||
|
|
e95708eedc | ||
|
|
ba6854bdd5 | ||
|
|
1e31b34a5a | ||
|
|
7deb4c174a | ||
|
|
f053a7ad58 | ||
|
|
b1affdbc10 | ||
|
|
c2c0ce7503 | ||
|
|
7efc36df29 | ||
|
|
720bde7719 | ||
|
|
319987ec3e | ||
|
|
2a7ce0e72a | ||
|
|
8ba64af29f | ||
|
|
17af9f812f | ||
|
|
d001901c8c | ||
|
|
91951dc825 | ||
|
|
8277f5a62a | ||
|
|
e615e51fbf | ||
|
|
99422c1c7c | ||
|
|
e8a0144b7a | ||
|
|
f9d09645e7 | ||
|
|
91fff1449d | ||
|
|
c5bca7767e | ||
|
|
79c5bf6bcb | ||
|
|
5456c35924 | ||
|
|
7a12216cfb |
66
CHANGELOG.md
66
CHANGELOG.md
@@ -3,6 +3,72 @@ Changelog
|
||||
|
||||
This change log is managed by `admin/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.4.7 (2021-09-16 13:17)
|
||||
--------------------------------
|
||||
|
||||
- Fix parseUints with excess zeros and fix ReDoS issue. ([#2016](https://github.com/ethers-io/ethers.js/issues/2016), [#1975](https://github.com/ethers-io/ethers.js/issues/1975), [#1976](https://github.com/ethers-io/ethers.js/issues/1976); [32a6b2a](https://github.com/ethers-io/ethers.js/commit/32a6b2a362815eb85ce3f3abad5adf92f2b80e10))
|
||||
|
||||
ethers/v5.4.6 (2021-08-27 15:34)
|
||||
--------------------------------
|
||||
|
||||
- Temporarily remove the block miner for clique-based networks from CI testing. ([#1967](https://github.com/ethers-io/ethers.js/issues/1967); [8320d53](https://github.com/ethers-io/ethers.js/commit/8320d534d78173dfa8ecb4def634a00483a6aa9c))
|
||||
- More readable errors involving Uint8Arrays. ([b6a061e](https://github.com/ethers-io/ethers.js/commit/b6a061e7bfd14c1f2df1418df37f704275908e8b))
|
||||
- Added Deferred Error support to Description objects to extent Interface parse methods. ([#1894](https://github.com/ethers-io/ethers.js/issues/1894); [a662490](https://github.com/ethers-io/ethers.js/commit/a662490e82a9b71b5f6dee0a8242e6fa78409d79))
|
||||
- Fix address coder to prepare non-hexdatastring addresses as hexdatastring. ([#1906](https://github.com/ethers-io/ethers.js/issues/1906); [017b1fe](https://github.com/ethers-io/ethers.js/commit/017b1feba2c9dea88f078b299d211cbd58d43b49))
|
||||
- Removed temporary code for better errors needed until Alchemy added EIP-1559 support. ([#1893](https://github.com/ethers-io/ethers.js/issues/1893); [accb852](https://github.com/ethers-io/ethers.js/commit/accb85268c92fa894e769ec1dca322e117d33e5f))
|
||||
|
||||
ethers/v5.4.5 (2021-08-18 03:05)
|
||||
--------------------------------
|
||||
|
||||
- Fxied getBlockWithTransactions results (1858). ([78e4273](https://github.com/ethers-io/ethers.js/commit/78e4273a327d12da9a1ec008d3f2146d97385921))
|
||||
|
||||
ethers/v5.4.4 (2021-08-04 01:37)
|
||||
--------------------------------
|
||||
|
||||
- Fixed Etherscan API key in default provider. ([#1807](https://github.com/ethers-io/ethers.js/issues/1807); [1d27d95](https://github.com/ethers-io/ethers.js/commit/1d27d95670ee3a51879393fed44297128c4a42a3))
|
||||
- Adjust default masPriorityFeePerGas to account for MEV-heavy blocks. ([#1817](https://github.com/ethers-io/ethers.js/issues/1817); [7175e2e](https://github.com/ethers-io/ethers.js/commit/7175e2e99c2747e8d2314feb407bf0a0f9371ece))
|
||||
|
||||
ethers/v5.4.3 (2021-07-29 23:26)
|
||||
--------------------------------
|
||||
|
||||
- Fixed JsonRpcProvider for pre-EIP-2930 chains. ([#1766](https://github.com/ethers-io/ethers.js/issues/1766); [7274cd0](https://github.com/ethers-io/ethers.js/commit/7274cd06cf3f6f31c6df3fd6636706d8536b7ee2))
|
||||
- Forward some missing EIP-1559 fields to call and estimateGas. ([#1766](https://github.com/ethers-io/ethers.js/issues/1766); [be3854e](https://github.com/ethers-io/ethers.js/commit/be3854e648fdef0478db8a64c26be6d9e90cf453))
|
||||
- Fixed possible UnhandledPromiseException for bad ENS names. ([63f8b28](https://github.com/ethers-io/ethers.js/commit/63f8b2822318d1e0fcc41f4662feb6e5ae338f3d))
|
||||
- Prevent overriding value for non-payble constructors. ([#1785](https://github.com/ethers-io/ethers.js/issues/1785); [593b488](https://github.com/ethers-io/ethers.js/commit/593b4886ff607d00d656b8131b843933eb48838e))
|
||||
|
||||
ethers/v5.4.2 (2021-07-23 17:22)
|
||||
--------------------------------
|
||||
|
||||
- Fix test case for new transactions responses. ([0aafca7](https://github.com/ethers-io/ethers.js/commit/0aafca71dbc019beb398e1b5a0f24936a4fd215a))
|
||||
- Added matic support to INFURA and Alchemy. ([#1546](https://github.com/ethers-io/ethers.js/issues/1546); [576e9b5](https://github.com/ethers-io/ethers.js/commit/576e9b54abc3ff048113f93f765aa3177bf3b819))
|
||||
- Added string change to coalesce errors on some clients. ([bc5cc2e](https://github.com/ethers-io/ethers.js/commit/bc5cc2e7e34f6cc69c43c1665be9c18854fb26b8))
|
||||
- Added wait to transactions returned by getBlockWithTransactions. ([#971](https://github.com/ethers-io/ethers.js/issues/971); [660e69d](https://github.com/ethers-io/ethers.js/commit/660e69db71d42084b1fe791d864d13f0111f84fb))
|
||||
- Fixed floor, ceiling and round for FixedNumber for non-default Formats. ([#1749](https://github.com/ethers-io/ethers.js/issues/1749); [551cfa0](https://github.com/ethers-io/ethers.js/commit/551cfa0062ec1645c9310335e0e6cbd250bb3788))
|
||||
- Fixed null confirmations in Wallet transaction. ([#1706](https://github.com/ethers-io/ethers.js/issues/1706); [0f0d0c0](https://github.com/ethers-io/ethers.js/commit/0f0d0c00d3fc14e5454169d42a9286b1d8b0abef))
|
||||
- Fixed Etherscan string change and enabled all tests. ([a1f8d18](https://github.com/ethers-io/ethers.js/commit/a1f8d188a7bc0b0d11426b7ef0d018cc1b7b399d))
|
||||
|
||||
ethers/v5.4.1 (2021-07-02 01:47)
|
||||
--------------------------------
|
||||
|
||||
- Added Pocket back into Homestead defaultProvider and skip certain EtherscanProvider tests affected by outage. ([6e8a39e](https://github.com/ethers-io/ethers.js/commit/6e8a39ec35123e681e47807f54ef9b9122635ea0))
|
||||
- Fixed EtherscanProvider NONCE_EXPIRED matching string update. ([ecae793](https://github.com/ethers-io/ethers.js/commit/ecae793edff172a885e5ee014a8ad0b28b68c1e5))
|
||||
- Fixed explicit EIP-1559 keys for JsonRpcSigner. ([72feee8](https://github.com/ethers-io/ethers.js/commit/72feee8f5841febdab0d15f09baa69539d95e199))
|
||||
|
||||
ethers/v5.4.0 (2021-06-26 01:50)
|
||||
--------------------------------
|
||||
|
||||
- Added EIP-1559 support. ([#1610](https://github.com/ethers-io/ethers.js/issues/1610); [319987e](https://github.com/ethers-io/ethers.js/commit/319987ec3e1d0e8787f98f525e5fc07875bf5570), [91fff14](https://github.com/ethers-io/ethers.js/commit/91fff1449df5e337fd3b4681b5a04b151d92f5a1), [c5bca77](https://github.com/ethers-io/ethers.js/commit/c5bca7767e3f3d43e3d0bd3c9e9420321ee9907a), [5456c35](https://github.com/ethers-io/ethers.js/commit/5456c359245d9eef5d2abdc05ccedb5269576c94), [7a12216](https://github.com/ethers-io/ethers.js/commit/7a12216cfbd3f86b917451924957471b8be21a8b), [e95708e](https://github.com/ethers-io/ethers.js/commit/e95708eedc130aeb92820a2234398970a987c507))
|
||||
- Added effectiveGasPrice to receipt. ([ba6854b](https://github.com/ethers-io/ethers.js/commit/ba6854bdd5a912fe873d5da494cb5c62c190adde))
|
||||
- Fixed ENS names for JsonRpcSigner. ([1e31b34](https://github.com/ethers-io/ethers.js/commit/1e31b34a5a3a269867a45b519662db85f0c86654))
|
||||
- Added EIP-2930 and EIP-1559 transaction tests. ([7deb4c1](https://github.com/ethers-io/ethers.js/commit/7deb4c174a30b75f8419b8661829add4e5cb69d6))
|
||||
- Added ConstructorFragment to exports. ([7efc36d](https://github.com/ethers-io/ethers.js/commit/7efc36df294ddd333e37793cad712cbd587bc686))
|
||||
- Added error utilities to Interface. ([720bde7](https://github.com/ethers-io/ethers.js/commit/720bde7719d9a2fbc7e859f8952b7918e7164b87), [f053a7a](https://github.com/ethers-io/ethers.js/commit/f053a7ad58866c8192a64e1e335a2613358385be))
|
||||
- merged master including transaction type 0 legacy constant. ([#1610](https://github.com/ethers-io/ethers.js/issues/1610); [2a7ce0e](https://github.com/ethers-io/ethers.js/commit/2a7ce0e72a1e0c9469e10392b0329e75e341cf18))
|
||||
- Added type to TransactionResponse and TrnsactionReceipt. ([#1687](https://github.com/ethers-io/ethers.js/issues/1687); [d001901](https://github.com/ethers-io/ethers.js/commit/d001901c8c0541c823eb9638b9b309a316b00757))
|
||||
- Trap CALL_EXCEPTION errors when resolving ENS entries. ([#1690](https://github.com/ethers-io/ethers.js/issues/1690); [91951dc](https://github.com/ethers-io/ethers.js/commit/91951dc825af42d4440d2d3b43cfa7a601b20342))
|
||||
- Fixed transaction serialization with explicit null type. ([#1628](https://github.com/ethers-io/ethers.js/issues/1628); [8277f5a](https://github.com/ethers-io/ethers.js/commit/8277f5a62a6739a05ae6682da6956fb490b81e4a))
|
||||
- Fix issue with loading JSON ABI with internalType property. ([#728](https://github.com/ethers-io/ethers.js/issues/728); [e8a0144](https://github.com/ethers-io/ethers.js/commit/e8a0144b7aa95add967578d9629d70bf01fc55cf))
|
||||
|
||||
ethers/v5.3.1 (2021-06-10 18:28)
|
||||
--------------------------------
|
||||
|
||||
|
||||
34
docs.wrm/api/contract/MyToken.sol
Normal file
34
docs.wrm/api/contract/MyToken.sol
Normal file
@@ -0,0 +1,34 @@
|
||||
// Do not use this; it is only for an example in the docs
|
||||
|
||||
contract MyToken {
|
||||
event Transfer(address indexed from, address indexed to, uint amount);
|
||||
|
||||
mapping (address => uint256) _balances;
|
||||
|
||||
constructor(uint256 totalSupply) {
|
||||
emit Transfer(address(0), msg.sender, totalSupply);
|
||||
_balances[msg.sender] = totalSupply;
|
||||
}
|
||||
|
||||
// Read-Only Functions
|
||||
function balanceOf(address owner) public view returns (uint256) {
|
||||
return _balances[owner];
|
||||
}
|
||||
|
||||
function decimals() public pure returns (uint8) {
|
||||
return 18;
|
||||
}
|
||||
|
||||
function symbol() public pure returns (string memory) {
|
||||
return "MyToken";
|
||||
}
|
||||
|
||||
// Authenticated Functions
|
||||
function transfer(address to, uint amount) public returns (bool) {
|
||||
require(_balances[msg.sender] >= amount, "insufficient token balance");
|
||||
_balances[msg.sender] -= amount;
|
||||
_balances[to] += amount;
|
||||
emit Transfer(msg.sender, to, amount);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ The //overrides// object for a read-only method may include any of:
|
||||
- ``overrides.from`` - the ``msg.sender`` (or ``CALLER``) to use during the
|
||||
execution of the code
|
||||
- ``overrides.value`` - the ``msg.value`` (or ``CALLVALUE``) to use during the
|
||||
exectuiont of the code
|
||||
execution of the code
|
||||
- ``overrides.gasPrice`` - the price to pay per gas (theoretically); since there
|
||||
is no transaction, there is not going to be any fee charged, but the EVM still
|
||||
requires a value to report to ``tx.gasprice`` (or ``GASPRICE``);
|
||||
|
||||
@@ -1,10 +1,75 @@
|
||||
_section: Example: ERC-20 Contract
|
||||
|
||||
The concept of Meta-Classes is somewhat confusing, so we will go
|
||||
over a short example.
|
||||
|
||||
A meta-class is a class which is defined at run-time. A Contract
|
||||
is specified by an //Application Binary Interface// (ABI), which describes
|
||||
the methods and events it has. This description is passed the the
|
||||
[[Contract]] object at run-time, and it creates a new Class, adding
|
||||
all the methods defined in the ABI at run-time.
|
||||
|
||||
_subsection: Deploying a Contract
|
||||
|
||||
Most often, any contract you will need to interact with will already
|
||||
be deployed to the blockchain, but for this example will will first
|
||||
deploy the contract.
|
||||
|
||||
_property: new ethers.ContractFactory(abi, bytecode, signer)
|
||||
Create a new [[ContractFactory]] which can deploy a contract to the
|
||||
blockchain.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const signer = localSigner;
|
||||
//_hide: const parseUnits = utils.parseUnits;
|
||||
|
||||
const bytecode = "0x608060405234801561001057600080fd5b506040516103bc3803806103bc83398101604081905261002f9161007c565b60405181815233906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a333600090815260208190526040902055610094565b60006020828403121561008d578081fd5b5051919050565b610319806100a36000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063313ce5671461005157806370a082311461006557806395d89b411461009c578063a9059cbb146100c5575b600080fd5b604051601281526020015b60405180910390f35b61008e610073366004610201565b6001600160a01b031660009081526020819052604090205490565b60405190815260200161005c565b604080518082018252600781526626bcaa37b5b2b760c91b6020820152905161005c919061024b565b6100d86100d3366004610222565b6100e8565b604051901515815260200161005c565b3360009081526020819052604081205482111561014b5760405162461bcd60e51b815260206004820152601a60248201527f696e73756666696369656e7420746f6b656e2062616c616e6365000000000000604482015260640160405180910390fd5b336000908152602081905260408120805484929061016a9084906102b6565b90915550506001600160a01b0383166000908152602081905260408120805484929061019790849061029e565b90915550506040518281526001600160a01b0384169033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a350600192915050565b80356001600160a01b03811681146101fc57600080fd5b919050565b600060208284031215610212578081fd5b61021b826101e5565b9392505050565b60008060408385031215610234578081fd5b61023d836101e5565b946020939093013593505050565b6000602080835283518082850152825b818110156102775785810183015185820160400152820161025b565b818111156102885783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156102b1576102b16102cd565b500190565b6000828210156102c8576102c86102cd565b500390565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220d80384ce584e101c5b92e4ee9b7871262285070dbcd2d71f99601f0f4fcecd2364736f6c63430008040033";
|
||||
|
||||
// A Human-Readable ABI; we only need to specify relevant fragments,
|
||||
// in the case of deployment this means the constructor
|
||||
const abi = [
|
||||
"constructor(uint totalSupply)"
|
||||
];
|
||||
|
||||
const factory = new ethers.ContractFactory(abi, bytecode, signer)
|
||||
|
||||
// Deploy, setting total supply to 100 tokens (assigned to the deployer)
|
||||
const contract = await factory.deploy(parseUnits("100"));
|
||||
|
||||
// The contract is not currentl live on the network yet, however
|
||||
// its address is ready for us
|
||||
//_result:
|
||||
contract.address
|
||||
//_log:
|
||||
//_hide: _page.address = contract.address;
|
||||
|
||||
// Wait until the contract has been deployed before interacting
|
||||
// with it; returns the receipt for the deployemnt transaction
|
||||
//_result:
|
||||
await contract.deployTransaction.wait();
|
||||
//_log:
|
||||
|
||||
|
||||
_subsection: Connecting to a Contract
|
||||
|
||||
_code: A simple ERC-20 contract @lang<javascript>
|
||||
_heading: ERC20Contract @INHERIT<[[Contract]]>
|
||||
|
||||
// A Human-Readable ABI; any supported ABI format could be used
|
||||
_property: new ethers.Contract(address, abi, providerOrSigner)
|
||||
Creating a new instance of a Contract connects to an existing
|
||||
contract by specifying its //address// on the blockchain,
|
||||
its //abi// (used to populate the class' methods) a //providerOrSigner//.
|
||||
|
||||
If a [[Provider]] is given, the contract has only read-only access, while
|
||||
a [[Signer]] offers access to state manipulating methods.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const provider = localProvider;
|
||||
//_hide: const signer = localSigner;
|
||||
|
||||
// A Human-Readable ABI; for interacting with the contract, we
|
||||
// must include any fragment we wish to use
|
||||
const abi = [
|
||||
// Read-Only Functions
|
||||
"function balanceOf(address owner) view returns (uint256)",
|
||||
@@ -12,20 +77,15 @@ const abi = [
|
||||
"function symbol() view returns (string)",
|
||||
|
||||
// Authenticated Functions
|
||||
"function transfer(address to, uint amount) returns (boolean)",
|
||||
"function transfer(address to, uint amount) returns (bool)",
|
||||
|
||||
// Events
|
||||
"event Transfer(address indexed from, address indexed to, uint amount)"
|
||||
];
|
||||
|
||||
// This can be an address or an ENS name
|
||||
const address = "dai.tokens.ethers.eth";
|
||||
|
||||
// An example Provider
|
||||
const provider = ethers.getDefaultProvider();
|
||||
|
||||
// An example Signer
|
||||
const signer = ethers.Wallet.createRandom().connect(provider);
|
||||
//_hide: const address = _page.address;
|
||||
//_verbatim: `const address = ${ JSON.stringify(address) };`
|
||||
|
||||
// Read-Only; By connecting to a Provider, allows:
|
||||
// - Any constant function
|
||||
@@ -34,20 +94,13 @@ const signer = ethers.Wallet.createRandom().connect(provider);
|
||||
// - Estimating Gas for non-constant (as an anonymous sender)
|
||||
// - Static Calling non-constant methods (as anonymous sender)
|
||||
const erc20 = new ethers.Contract(address, abi, provider);
|
||||
//_hide: _page.erc20 = erc20;
|
||||
|
||||
// Read-Write; By connecting to a Signer, allows:
|
||||
// - Everything from Read-Only (except as Signer, not anonymous)
|
||||
// - Sending transactions for non-constant functions
|
||||
const erc20_rw = new ethers.Contract(address, abi, signer)
|
||||
|
||||
|
||||
_heading: ERC20Contract @INHERIT<[[Contract]]>
|
||||
|
||||
_property: new ethers.Contract(address, abi, providerOrSigner)
|
||||
See the above code example for creating an Instance which will
|
||||
(in addition to the Contact methods and properties) automatically
|
||||
add the additional properties defined in //abi// to a **Contract**
|
||||
connected to //address// using the //providerOrSigner//.
|
||||
const erc20_rw = new ethers.Contract(address, abi, signer);
|
||||
//_hide: _page.erc20_rw = erc20_rw;
|
||||
|
||||
|
||||
_subsection: Properties @NOTE<(inheritted from [[Contract]])>
|
||||
@@ -101,6 +154,8 @@ _property: Contract.isIndexed(value) => boolean
|
||||
|
||||
_subsection: Events @NOTE<(inheritted from [[Contract]])> @<erc20-events>
|
||||
|
||||
See [Meta-Class Filters](erc20-meta-events) for examples using events.
|
||||
|
||||
_property: erc20.queryFilter(event [ , fromBlockOrBlockHash [ , toBlock ]) => Promise<Array<Event>> @<erc20-queryfilter>
|
||||
Return Events that match the //event//.
|
||||
|
||||
@@ -126,7 +181,7 @@ Unsubscribe all listeners for //event//. If no event is provided,
|
||||
all events are unsubscribed.
|
||||
|
||||
|
||||
_subsection: Meta-Class Methods @NOTE<(added at Runtime)>
|
||||
_subsection: Meta-Class Methods @NOTE<(added at Runtime)> @<erc20-meta-methods>
|
||||
|
||||
Since the Contract is a Meta-Class, the methods available here depend
|
||||
on the ABI which was passed into the **Contract**.
|
||||
@@ -136,12 +191,35 @@ 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.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const erc20 = _page.erc20;
|
||||
//_result:
|
||||
await erc20.decimals();
|
||||
//_log:
|
||||
|
||||
_property: erc20.balanceOf(owner [, overrides ]) => Promise<[[BigNumber]]>
|
||||
Returns the balance of //owner// for this ERC-20 token.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const signer = localSigner;
|
||||
//_hide: const erc20 = _page.erc20;
|
||||
|
||||
//_result:
|
||||
await erc20.balanceOf(signer.getAddress())
|
||||
//_log:
|
||||
|
||||
_property: erc20.symbol([ overrides ]) => Promise<string>
|
||||
Returns the symbol of the token.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const erc20 = _page.erc20;
|
||||
//_result:
|
||||
await erc20.symbol();
|
||||
//_log:
|
||||
|
||||
_property: erc20_rw.transfer(target, amount [, overrides ]) => Promise<[[providers-TransactionResponse]]>
|
||||
Transfers //amount// tokens to //target// from the current signer.
|
||||
The return value (a boolean) is inaccessible during a write operation
|
||||
@@ -149,20 +227,86 @@ using a transaction. Other techniques (such as events) are required
|
||||
if this value is required. On-chain contracts calling the ``transfer``
|
||||
function have access to this result, which is why it is possible.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const signer = localSigner;
|
||||
//_hide: const erc20_rw = _page.erc20_rw;
|
||||
//_hide: const parseUnits = utils.parseUnits;
|
||||
//_hide: const formatUnits = utils.formatUnits;
|
||||
|
||||
// Before...
|
||||
//_result:
|
||||
formatUnits(await erc20_rw.balanceOf(signer.getAddress()));
|
||||
//_log:
|
||||
|
||||
// Transfer 1.23 tokens to the ENS name "ricmoo.eth"
|
||||
//_result:
|
||||
tx = await erc20_rw.transfer("ricmoo.eth", parseUnits("1.23"));
|
||||
//_log:
|
||||
|
||||
// Wait for the transaction to be mined...
|
||||
//_result:
|
||||
await tx.wait();
|
||||
//_log:
|
||||
|
||||
// After!
|
||||
//_result:
|
||||
formatUnits(await erc20_rw.balanceOf(signer.getAddress()));
|
||||
//_log:
|
||||
|
||||
//_result:
|
||||
formatUnits(await erc20_rw.balanceOf("ricmoo.eth"));
|
||||
//_log:
|
||||
|
||||
_property: erc20.callStatic.transfer(target, amount [, overrides ]) => Promise<boolean>
|
||||
Performs a dry-run of transferring //amount// tokens to //target// from
|
||||
the current signer, without actually signing or sending a transaction.
|
||||
|
||||
This can be used to preflight check that a transaction will be successful.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const erc20_rw = _page.erc20_rw;
|
||||
//_hide: const randomWallet = ethers.Wallet.createRandom().connect(erc20_rw.provider);
|
||||
//_hide: const parseUnits = utils.parseUnits;
|
||||
|
||||
// The signer has enough tokens to send, so true is returned
|
||||
//_result:
|
||||
await erc20_rw.callStatic.transfer("ricmoo.eth", parseUnits("1.23"));
|
||||
//_log:
|
||||
|
||||
// A random address does not have enough tokens to
|
||||
// send, in which case the contract throws an error
|
||||
erc20_random = erc20_rw.connect(randomWallet);
|
||||
//_throws:
|
||||
await erc20_random.callStatic.transfer("ricmoo.eth", parseUnits("1.23"));
|
||||
//_log:
|
||||
|
||||
_property: erc20.estimateGas.transfer(target, amount [, overrides ]) => Promise<[[BigNumber]]>
|
||||
Returns an estimate for how many units of gas would be required
|
||||
to transfer //amount// tokens to //target//.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const erc20_rw = _page.erc20_rw;
|
||||
//_hide: const parseUnits = utils.parseUnits;
|
||||
|
||||
//_result:
|
||||
await erc20_rw.estimateGas.transfer("ricmoo.eth", parseUnits("1.23"));
|
||||
//_log:
|
||||
|
||||
_property: erc20.populateTransaction.transfer(target, amount [, overrides ]) => Promise<[UnsignedTx](UnsignedTransaction)>
|
||||
Returns an [[UnsignedTransaction]] which could be signed and submitted
|
||||
to the network to transaction //amount// tokens to //target//.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const erc20_rw = _page.erc20_rw;
|
||||
//_hide: const parseUnits = utils.parseUnits;
|
||||
|
||||
//_result:
|
||||
await erc20_rw.populateTransaction.transfer("ricmoo.eth", parseUnits("1.23"));
|
||||
//_log:
|
||||
|
||||
_note: Note on Estimating and Static Calling
|
||||
|
||||
@@ -173,7 +317,7 @@ blockchain also means there are certain consistency modes that cannot be
|
||||
known until an actual transaction is attempted.
|
||||
|
||||
|
||||
_subsection: Meta-Class Filters @NOTE<(added at Runtime)>
|
||||
_subsection: Meta-Class Filters @NOTE<(added at Runtime)> @<erc20-meta-events>
|
||||
|
||||
Since the Contract is a Meta-Class, the methods available here depend
|
||||
on the ABI which was passed into the **Contract**.
|
||||
@@ -184,3 +328,75 @@ to [subscribe/unsubscribe to events](erc20-events).
|
||||
|
||||
If //fromAddress// is null or not provided, then any from address matches.
|
||||
If //toAddress// is null or not provided, then any to address matches.
|
||||
|
||||
_code: query filter *from* events @lang<javascript>
|
||||
|
||||
//_hide: const signer = localSigner;
|
||||
//_hide: const erc20 = _page.erc20;
|
||||
|
||||
//_result:
|
||||
filterFrom = erc20.filters.Transfer(signer.address);
|
||||
//_log:
|
||||
|
||||
// Search for transfers *from* me in the last 10 blocks
|
||||
//_result:
|
||||
logsFrom = await erc20.queryFilter(filterFrom, -10, "latest");
|
||||
//_log:
|
||||
|
||||
// Note that the args providees the details of the event, each
|
||||
// parameters is available positionally, and since our ABI
|
||||
// included parameter names also by name
|
||||
//_result:
|
||||
logsFrom[0].args
|
||||
//_log:
|
||||
|
||||
//_hide: _page.filterFrom = filterFrom;
|
||||
|
||||
|
||||
_code: query filter with *to* events @lang<javascript>
|
||||
|
||||
//_hide: const signer = localSigner;
|
||||
//_hide: const erc20 = _page.erc20;
|
||||
|
||||
//_result:
|
||||
filterTo = erc20.filters.Transfer(null, signer.address);
|
||||
//_log:
|
||||
|
||||
// Search for transfers *to* me in the last 10 blocks
|
||||
// Note: the contract transferred totalSupply tokens to us
|
||||
// when it was deployed in its constructor
|
||||
//_result:
|
||||
logsTo = await erc20.queryFilter(filterTo, -10, "latest");
|
||||
//_log:
|
||||
|
||||
// Note that the args providees the details of the event, each
|
||||
// parameters is available positionally, and since our ABI
|
||||
// included parameter names also by name
|
||||
//_result:
|
||||
logsTo[0].args
|
||||
//_log:
|
||||
|
||||
//_hide: _page.filterTo = filterTo;
|
||||
|
||||
_code: listen for events @lang<javascript>
|
||||
|
||||
//_hide: const erc20 = _page.erc20;
|
||||
//_hide: const filterFrom = _page.filterFrom;
|
||||
//_hide: const filterTo = _page.filterTo;
|
||||
|
||||
// Listen to incoming events from signer:
|
||||
erc20.on(filterFrom, (from, to, amount, event) => {
|
||||
// The `from` will always be the signer address
|
||||
});
|
||||
|
||||
// Listen to incoming events to signer:
|
||||
erc20.on(filterTo, (from, to, amount, event) => {
|
||||
// The `to` will always be the signer address
|
||||
});
|
||||
|
||||
// Listen to all Transfer events:
|
||||
erc20.on("Transfer", (from, to, amount, event) => {
|
||||
// ...
|
||||
});
|
||||
|
||||
//_hide: erc20.removeAllListeners();
|
||||
|
||||
@@ -26,7 +26,7 @@ account (account #0) is used.
|
||||
|
||||
_property: jsonRpcProvider.getUncheckedSigner([ addressOrIndex ]) => [[UncheckedJsonRpcSigner]] @<JsonRpcProvider-getUncheckedSigner> @SRC<providers/json-rpc-provider>
|
||||
|
||||
_property: jsonRpcProvider.listAccounts() => Array<string> @<JsonRpcProvider-listAccounts> @SRC<providers/json-rpc-provider>
|
||||
_property: jsonRpcProvider.listAccounts() => Promise<Array<string>> @<JsonRpcProvider-listAccounts> @SRC<providers/json-rpc-provider>
|
||||
Returns a list of all account addresses managed by this provider.
|
||||
|
||||
_property: jsonRpcProvider.send(method, params) => Promise<any> @<JsonRpcProvider-send> @SRC<providers/json-rpc-provider>
|
||||
@@ -75,6 +75,25 @@ object, with most of the properties set to null, but allows access to the
|
||||
transaction hash quickly, if that is all that is required.
|
||||
|
||||
|
||||
_subsection: StaticJsonRpcProvider @<StaticJsonRpcProvider> @INHERIT<[[JsonRpcProvider]]> @SRC<providers:class.StaticJsonRpcProvider>
|
||||
|
||||
An ethers Provider will execute frequent ``getNetwork`` calls to ensure
|
||||
the network calls and network being communicated with are consistent.
|
||||
|
||||
In the case of a client like MetaMask, this is desired as the network
|
||||
may be changed by the user at any time, in such cases the cost of
|
||||
checking the chainId is local and therefore cheap.
|
||||
|
||||
However, there are also many times where it is known the network cannot
|
||||
change, such as when connecting to an INFURA endpoint, in which case,
|
||||
the **StaticJsonRpcProvider** can be used which will indefinitely cache
|
||||
the chain ID, which can reduce network traffic and reduce round-trip
|
||||
queries for the chain ID.
|
||||
|
||||
This [[Provider]] should **only** be used when it is known the network
|
||||
cannot change.
|
||||
|
||||
|
||||
_subsection: Node-Specific Methods @<JsonRpcProvider--other>
|
||||
|
||||
Many methods are less common or specific to certain Ethereum Node implementations
|
||||
|
||||
@@ -99,7 +99,7 @@ application to ethers by wrapping an existing Web3-compatible (such as a
|
||||
[Web3WsProvider](link-web3-ws)) and exposing it as an ethers.js [[Provider]]
|
||||
which can then be used with the rest of the library.
|
||||
|
||||
This may also be used to wrap a standard [EIP-1193 Provider](link-eip-1193].
|
||||
This may also be used to wrap a standard [EIP-1193 Provider](link-eip-1193).
|
||||
|
||||
_property: new ethers.providers.Web3Provider(externalProvider [, network ])
|
||||
Create a new **Web3Provider**, which wraps an [EIP-1193 Provider](link-eip-1193) or
|
||||
|
||||
@@ -21,38 +21,40 @@ _subsection: Accounts Methods @<Provider--account-methods>
|
||||
_property: provider.getBalance(address [ , blockTag = latest ]) => Promise<[[BigNumber]]> @<Provider-getBalance> @SRC<providers/base-provider>
|
||||
Returns the balance of //address// as of the //blockTag// block height.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getBalance("ricmoo.eth");
|
||||
//_log:
|
||||
|
||||
_property: provider.getCode(address [ , blockTag = latest ]) => Promise<string<[[DataHexString]]>> @<Provider-getCode> @SRC<providers/base-provider>
|
||||
Returns the contract code of //address// as of the //blockTag// block height. If there is
|
||||
no contract currently deployed, the result is ``0x``.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getCode("registrar.firefly.eth");
|
||||
//_log:
|
||||
|
||||
_property: provider.getStorageAt(addr, pos [ , blockTag = latest ]) => Promise<string<[[DataHexString]]>> @<Provider-getStorageAt> @SRC<providers/base-provider>
|
||||
Returns the ``Bytes32`` value of the position //pos// at address //addr//, as of the //blockTag//.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getStorageAt("registrar.firefly.eth", 0)
|
||||
//_log:
|
||||
|
||||
_property: provider.getTransactionCount(address [ , blockTag = latest ]) => Promise<number> @<Provider-getTransactionCount> @SRC<providers/base-provider>
|
||||
Returns the number of transactions //address// has ever **sent**, as of //blockTag//.
|
||||
This value is required to be the nonce for the next transaction from //address//
|
||||
sent to the network.
|
||||
|
||||
_code: Account Examples @lang<javascript>
|
||||
_code: @lang<javascript>
|
||||
|
||||
// Get the balance for an account...
|
||||
//_result:
|
||||
await provider.getBalance("ricmoo.firefly.eth");
|
||||
//_log:
|
||||
|
||||
// Get the code for a contract...
|
||||
//_result:
|
||||
await provider.getCode("registrar.firefly.eth");
|
||||
//_log:
|
||||
|
||||
// Get the storage value at position 0...
|
||||
//_result:
|
||||
await provider.getStorageAt("registrar.firefly.eth", 0)
|
||||
//_log:
|
||||
|
||||
// Get transaction count of an account...
|
||||
//_result:
|
||||
await provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
await provider.getTransactionCount("ricmoo.eth");
|
||||
//_log:
|
||||
|
||||
|
||||
@@ -62,16 +64,18 @@ _property: provider.getBlock(block) => Promise<[[providers-Block]]> @<Provider-
|
||||
Get the //block// from the network, where the ``result.transactions`` is a list
|
||||
of transaction hashes.
|
||||
|
||||
_property: provider.getBlockWithTransactions(block) => Promise<[[providers-BlockWithTransactions]]> @<Provider-getBlockWithTransactions> @SRC<providers/base-provider>
|
||||
Get the //block// from the network, where the ``result.transactions`` is
|
||||
an Array of [[providers-TransactionResponse]] objects.
|
||||
|
||||
_code: Block Examples @lang<javascript>
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getBlock(100004)
|
||||
//_log:
|
||||
|
||||
_property: provider.getBlockWithTransactions(block) => Promise<[[providers-BlockWithTransactions]]> @<Provider-getBlockWithTransactions> @SRC<providers/base-provider>
|
||||
Get the //block// from the network, where the ``result.transactions`` is
|
||||
an Array of [[providers-TransactionResponse]] objects.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getBlockWithTransactions(100004)
|
||||
//_log:
|
||||
@@ -96,26 +100,38 @@ _property: provider.getResolver(name) => Promise<[[EnsResolver]]>
|
||||
Returns an EnsResolver instance which can be used to further inquire
|
||||
about specific entries for an ENS name.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: provider = ethers.getDefaultProvider();
|
||||
|
||||
// See below (Resolver) for examples of using this object
|
||||
const resolver = await provider.getResolver("ricmoo.eth");
|
||||
|
||||
//_hide: _page.resolver = resolver;
|
||||
|
||||
_property: provider.lookupAddress(address) => Promise<string> @<Provider-lookupAddress> @SRC<providers/base-provider>
|
||||
Performs a reverse lookup of the //address// in ENS using the
|
||||
//Reverse Registrar//. If the name does not exist, or the
|
||||
forward lookup does not match, ``null`` is returned.
|
||||
|
||||
An ENS name requries additional configuration to setup a reverse
|
||||
record, they are not automatically set up.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.lookupAddress("0x5555763613a12D8F3e73be831DFf8598089d3dCa");
|
||||
//_log:
|
||||
|
||||
_property: provider.resolveName(name) => Promise<string<[Address](address)>> @<Provider-ResolveName> @SRC<providers/base-provider>
|
||||
Looks up the address of //name//. If the name is not owned, or
|
||||
does not have a //Resolver// configured, or the //Resolver// does
|
||||
not have an address configured, ``null`` is returned.
|
||||
|
||||
_code: ENS Examples @lang<javascript>
|
||||
_code: @lang<javascript>
|
||||
|
||||
// Reverse lookup of an ENS by address...
|
||||
//_result:
|
||||
await provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c");
|
||||
//_log:
|
||||
|
||||
// Lookup an address of an ENS name...
|
||||
//_result:
|
||||
await provider.resolveName("ricmoo.firefly.eth");
|
||||
await provider.resolveName("ricmoo.eth");
|
||||
//_log:
|
||||
|
||||
|
||||
@@ -132,12 +148,51 @@ Returns a Promise which resolves to the [[link-eip-2304]] multicoin address
|
||||
stored for the //coinType//. By default an Ethereum [[address]]
|
||||
(``coinType = 60``) will be returned.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const resolver = _page.resolver;
|
||||
|
||||
// By default, looks up the Ethereum address
|
||||
// (this will match provider.resolveName)
|
||||
//_result:
|
||||
await resolver.getAddress();
|
||||
//_log:
|
||||
|
||||
// Specify the coinType for other coin addresses (0 = Bitcoin)
|
||||
//_result:
|
||||
await resolver.getAddress(0);
|
||||
//_log:
|
||||
|
||||
_property: resolver.getContentHash() => Promise<string>
|
||||
Returns a Promise which resolves to any stored [[link-eip-1577]] content hash.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const resolver = _page.resolver;
|
||||
|
||||
//_result:
|
||||
await resolver.getContentHash();
|
||||
//_log:
|
||||
|
||||
_property: resolver.getText(key) => Promise<string>
|
||||
Returns a Promise which resolves to any stored [[link-eip-634]] text entry for //key//.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const resolver = _page.resolver;
|
||||
|
||||
//_result:
|
||||
await resolver.getText("email");
|
||||
//_log:
|
||||
|
||||
//_result:
|
||||
await resolver.getText("url");
|
||||
//_log:
|
||||
|
||||
//_result:
|
||||
await resolver.getText("com.twitter");
|
||||
//_log:
|
||||
|
||||
_subsection: Logs Methods @<Provider--log-methods>
|
||||
|
||||
_property: provider.getLogs(filter) => Promise<Array<[[providers-Log]]>> @<Provider-getLogs> @SRC<providers/base-provider>
|
||||
@@ -153,12 +208,59 @@ _subsection: Network Status Methods @<Provider--network-methods>
|
||||
_property: provider.getNetwork() => Promise<[[providers-Network]]> @<Provider-getNetwork> @SRC<providers/base-provider:method.BaseProvider.getNetwork>
|
||||
Returns the [[providers-Network]] this Provider is connected to.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getNetwork()
|
||||
//_hide: _ = utils.shallowCopy(_);
|
||||
//_hide: delete _._defaultProvider;
|
||||
//_log:
|
||||
|
||||
_property: provider.getBlockNumber() => Promise<number> @<Provider-getBlockNumber> @SRC<providers/base-provider>
|
||||
Returns the block number (or height) of the most recently mined block.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getBlockNumber()
|
||||
//_log:
|
||||
|
||||
_property: provider.getGasPrice() => Promise<[[BigNumber]]> @<Provider-getGasPrice> @SRC<providers/base-provider>
|
||||
Returns a //best guess// of the [[gas-price]] to use in a transaction.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
// The gas price (in wei)...
|
||||
gasPrice = await provider.getGasPrice()
|
||||
//_log: gasPrice
|
||||
|
||||
// ...often this gas price is easier to understand or
|
||||
// display to the user in gwei
|
||||
//_result:
|
||||
utils.formatUnits(gasPrice, "gwei")
|
||||
//_log:
|
||||
|
||||
_property: provider.getFeeData() => Promise<[[providers-FeeData]]> @<Provider-getFeeData> @SRC<abstract-provider>
|
||||
Returns the current recommended [[providers-FeeData]] to use in a transaction.
|
||||
|
||||
For an EIP-1559 transaction, the ``maxFeePerGas`` and ``maxPriorityFeePerGas``
|
||||
should be used.
|
||||
|
||||
For legacy transactions and networks which do not support EIP-1559, the ``gasPrice``
|
||||
should be used.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
// The gas price (in wei)...
|
||||
feeData = await provider.getFeeData()
|
||||
//_log: feeData
|
||||
|
||||
// ...often these values are easier to understand or
|
||||
// display to the user in gwei
|
||||
//_result:
|
||||
utils.formatUnits(feeData.maxFeePerGas, "gwei")
|
||||
//_log:
|
||||
|
||||
_property: provider.ready => Promise<[[providers-Network]]> @<Provider-ready> @src<providers/base-provider>
|
||||
Returns a Promise which will stall until the network has heen established,
|
||||
ignoring errors due to the target node not being active yet.
|
||||
@@ -166,29 +268,6 @@ ignoring errors due to the target node not being active yet.
|
||||
This can be used for testing or attaching scripts to wait until the node is
|
||||
up and running smoothly.
|
||||
|
||||
_code: Network Status Examples @lang<javascript>
|
||||
|
||||
// The network information
|
||||
network = await provider.getNetwork()
|
||||
//_hide: network = utils.shallowCopy(network);
|
||||
//_hide: delete network._defaultProvider;
|
||||
//_log: network
|
||||
|
||||
// The current block number
|
||||
//_result:
|
||||
await provider.getBlockNumber()
|
||||
//_log:
|
||||
|
||||
// Get the current suggested gas price (in wei)...
|
||||
gasPrice = await provider.getGasPrice()
|
||||
//_log: gasPrice
|
||||
|
||||
// ...often this gas price is easier to understand or
|
||||
// display to the user in gwei (giga-wei, or 1e9 wei)
|
||||
//_result:
|
||||
utils.formatUnits(gasPrice, "gwei")
|
||||
//_log:
|
||||
|
||||
|
||||
_subsection: Transactions Methods @<Provider--transaction-methods>
|
||||
|
||||
@@ -197,6 +276,18 @@ Returns the result of executing the //transaction//, using //call//. A call
|
||||
does not require any ether, but cannot change any state. This is useful
|
||||
for calling getters on Contracts.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.call({
|
||||
// ENS public resovler address
|
||||
to: "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
|
||||
|
||||
// `function addr(namehash("ricmoo.eth")) view returns (address)`
|
||||
data: "0x3b3b57debf074faa138b72c65adbdcfb329847e4f2c04bde7f7dd7fcad5a52d2f395a558"
|
||||
});
|
||||
//_log:
|
||||
|
||||
_property: provider.estimateGas(transaction) => Promise<[[BigNumber]]> @<Provider-estimateGas> @SRC<providers/base-provider>
|
||||
Returns an estimate of the amount of gas that would be required to submit //transaction//
|
||||
to the network.
|
||||
@@ -205,6 +296,23 @@ An estimate may not be accurate since there could be another transaction
|
||||
on the network that was not accounted for, but after being mined affected
|
||||
relevant state.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const parseEther = ethers.utils.parseEther;
|
||||
|
||||
//_result:
|
||||
await provider.estimateGas({
|
||||
// Wrapped ETH address
|
||||
to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
||||
|
||||
// `function deposit() payable`
|
||||
data: "0xd0e30db0",
|
||||
|
||||
// 1 ether
|
||||
value: parseEther("1.0")
|
||||
});
|
||||
//_log:
|
||||
|
||||
_property: provider.getTransaction(hash) => Promise<[[providers-TransactionResponse]]> @<Provider-getTransaction> @src<providers/base-provider>
|
||||
Returns the transaction with //hash// or null if the transaction is unknown.
|
||||
|
||||
@@ -213,6 +321,12 @@ pool. Various backends may have more restrictive transaction pool access (e.g.
|
||||
if the gas price is too low or the transaction was only recently sent and not
|
||||
yet indexed) in which case this method may also return null.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getTransaction("0x5b73e239c55d790e3c9c3bbb84092652db01bb8dbf49ccc9e4a318470419d9a0");
|
||||
//_log:
|
||||
|
||||
_property: provider.getTransactionReceipt(hash) => Promise<[[providers-TransactionReceipt]]> @<Provider-getTransactionReceipt> @src<providers/base-provider>
|
||||
Returns the transaction receipt for //hash// or null if the transaction
|
||||
has not been mined.
|
||||
@@ -220,11 +334,34 @@ has not been mined.
|
||||
To stall until the transaction has been mined, consider the ``waitForTransaction``
|
||||
method below.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_result:
|
||||
await provider.getTransactionReceipt("0x5b73e239c55d790e3c9c3bbb84092652db01bb8dbf49ccc9e4a318470419d9a0");
|
||||
//_log:
|
||||
|
||||
_property: provider.sendTransaction(transaction) => Promise<[[providers-TransactionResponse]]> @<Provider-sendTransaction> @SRC<providers/base-provider>
|
||||
Submits //transaction// to the network to be mined. The //transaction// **must** be signed,
|
||||
and be valid (i.e. the nonce is correct and the account has sufficient balance to pay
|
||||
for the transaction).
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const provider = localProvider;
|
||||
//_hide: const wallet = new ethers.Wallet(ethers.utils.id("HelloWorld"), provider);
|
||||
//_hide: const fundTx = await localSigner.sendTransaction({
|
||||
//_hide: to: wallet.address,
|
||||
//_hide: value: ethers.utils.parseEther("2.0")
|
||||
//_hide: });
|
||||
//_hide: await fundTx.wait();
|
||||
//_hide: const tx = await localSigner.populateTransaction({ to: "ricmoo.eth", value: ethers.utils.parseEther("3.14159") });
|
||||
//_hide: const signedTx = await localSigner.signTransaction(tx);
|
||||
|
||||
//_verbatim: `const signedTx = ${ JSON.stringify(signedTx) };`
|
||||
//_result:
|
||||
await provider.sendTransaction(signedTx);
|
||||
//_log:
|
||||
|
||||
_property: provider.waitForTransaction(hash [ , confirms = 1 [ , timeout ] ]) => Promise<[TxReceipt](providers-TransactionReceipt)> @<Provider-waitForTransaction> @SRC<providers/base-provider>
|
||||
Returns a Promise which will not resolve until //transactionHash// is mined.
|
||||
|
||||
@@ -340,6 +477,7 @@ _code: Events Example @lang<javascript>
|
||||
//_hide: const txHash = utils.id("dummy-data");
|
||||
//_hide: const myAddress = ethers.constants.HashZero;
|
||||
//_hide: const myOtherAddress = ethers.constants.HashZero;
|
||||
//_hide: const hexZeroPad = ethers.utils.hexZeroPad;
|
||||
|
||||
provider.on("block", (blockNumber) => {
|
||||
// Emitted on every block change
|
||||
@@ -371,8 +509,8 @@ topicSets = [
|
||||
utils.id("Transfer(address,address,uint256)"),
|
||||
null,
|
||||
[
|
||||
myAddress,
|
||||
myOtherAddress
|
||||
hexZeroPad(myAddress, 32),
|
||||
hexZeroPad(myOtherAddress, 32)
|
||||
]
|
||||
]
|
||||
provider.on(topicSets, (log, event) => {
|
||||
|
||||
@@ -34,6 +34,23 @@ _property: network.ensAddress => string<[[address]]>
|
||||
The address at which the ENS registry is deployed on this network.
|
||||
|
||||
|
||||
_subsection: FeeData @<providers-FeeData>
|
||||
|
||||
A **FeeData** object encapsulates the necessary fee data required
|
||||
to send a transaction, based on the best available recommendations.
|
||||
|
||||
_property: feeData.gasPrice => [[BigNumber]]
|
||||
The gasPrice to use for legacy transactions or networks which do not
|
||||
support EIP-1559.
|
||||
|
||||
_property: feeData.maxFeePerGas => [[BigNumber]]
|
||||
The ``maxFeePerGas`` to use for a transaction. This is based on the
|
||||
most recent block's ``baseFee``.
|
||||
|
||||
_property: feeData.maxPriorityFeePerGas => [[BigNumber]]
|
||||
The ``maxPriorityFeePerGas`` to use for a transaction. This accounts
|
||||
for the uncle risk and for the majority of current MEV risk.
|
||||
|
||||
_subsection: Block @<providers-Block>
|
||||
|
||||
_property: block.hash => string<[[DataHexString]]<32>>
|
||||
@@ -183,18 +200,46 @@ _property: transactionRequest.nonce => number | Promise<number>
|
||||
The nonce for this transaction. This should be set to the number of
|
||||
transactions ever sent **from** this address.
|
||||
|
||||
_property: transactionRequest.gasLimit => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The maximum amount of gas this transaction is permitted to use.
|
||||
|
||||
_property: transactionRequest.gasPrice => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The price (in wei) per unit of gas this transaction will pay.
|
||||
|
||||
_property: transactionRequest.data => [[DataHexString]] | Promise<[[DataHexString]]>
|
||||
The transaction data.
|
||||
|
||||
_property: transactionRequest.value => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The amount (in wei) this transaction is sending.
|
||||
|
||||
_property: transactionRequest.gasLimit => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The maximum amount of gas this transaction is permitted to use.
|
||||
|
||||
If left unspecified, ethers will use ``estimateGas`` to determine the value
|
||||
to use. For transactions with unpredicatable gas estiamtes, this may be required
|
||||
to specify explicitly.
|
||||
|
||||
_property: transactionRequest.gasPrice => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The price (in wei) per unit of gas this transaction will pay.
|
||||
|
||||
This may not be specified for transactions with ``type`` set to ``1`` or ``2``, or
|
||||
if ``maxFeePerGas`` or ``maxPriorityFeePerGas`` is given.
|
||||
|
||||
_property: transactionRequest.maxFeePerGas => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The maximum price (in wei) per unit of gas this transaction will pay for the
|
||||
[[link-eip-1559]] base fee.
|
||||
|
||||
Most developers should leave this unspecified and use the default value that
|
||||
ethers determines from the network.
|
||||
|
||||
This may not be specified for transactions with ``type`` set to ``0`` or if ``gasPrice``
|
||||
is specified..
|
||||
|
||||
_property: transactionRequest.maxPriorityFeePerGas => [[BigNumber]] | Promise<[[BigNumber]]>
|
||||
The price (in wei) per unit of gas this transaction will pay for the
|
||||
[[link-eip-1559]] priority fee. This is **included in** the ``maxFeePerGass``,
|
||||
so this will **not affect** the total maximum cost set with ``maxFeePerGas``.
|
||||
|
||||
Most developers should leave this unspecified and use the default value that
|
||||
ethers determines from the network.
|
||||
|
||||
This may not be specified for transactions with ``type`` set to ``0`` or if ``gasPrice``
|
||||
is specified.
|
||||
|
||||
_property: transactionRequest.chainId => number | Promise<number>
|
||||
The chain ID this transaction is authorized on, as specified by
|
||||
[EIP-155](link-eip-155).
|
||||
@@ -208,12 +253,13 @@ 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.
|
||||
for to use the network default. To force using a lagacy transaction
|
||||
without an envelope, use type ``0``.
|
||||
|
||||
_property: transactionRequest.accessList => [[providers-AccessListish]]
|
||||
|
||||
The [[providers-AccessList]] to include in an [[link-eip-2930]] transaction, which will
|
||||
include a ``type`` of ``1``.
|
||||
The [[providers-AccessList]] to include; only available for [[link-eip-2930]]
|
||||
and [[link-eip-1559]] transactions.
|
||||
|
||||
_heading: TransactionResponse @<providers-TransactionResponse> @INHERIT<[[Transaction]]>
|
||||
|
||||
@@ -237,7 +283,9 @@ The number of blocks that have been mined (including the initial block) since th
|
||||
transaction was mined.
|
||||
|
||||
_property: transaction.raw => string<[[DataHexString]]>
|
||||
The serialized transaction.
|
||||
The serialized transaction. This may be null as some backends do not
|
||||
rpopulate it. If this is required, it can be computed from a **TransactionResponse**
|
||||
object using [this cookbook recipe](cookbook--compute-raw-transaction).
|
||||
|
||||
_property: transaction.wait([ confirms = 1 ]) => Promise<[[providers-TransactionReceipt]]>
|
||||
Resolves to the [[providers-TransactionReceipt]] once the transaction
|
||||
@@ -267,15 +315,13 @@ send a new transaction from the same account with the original ``nonce``.
|
||||
This is usually to speed up a transaction or to cancel one, by bribing
|
||||
miners with additional fees to prefer the new transaction over the original one.
|
||||
|
||||
_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.type => number
|
||||
The [[link-eip-2718]] type of this transaction. If the transaction
|
||||
is a legacy transaction without an envelope, it will have the type ``0``.
|
||||
|
||||
_property: transactionRequest.accessList => [[providers-AccessList]]
|
||||
|
||||
The [[providers-AccessList]] included in an [[link-eip-2930]] transaction, which will
|
||||
also have its ``type`` equal to ``1``.
|
||||
The [[providers-AccessList]] included, or null for transaction types which
|
||||
do not support access lists.
|
||||
|
||||
_heading: TransactionReceipt @<providers-TransactionReceipt>
|
||||
|
||||
@@ -299,6 +345,10 @@ _property: receipt.transactionIndex => number
|
||||
The index of this transaction in the list of transactions included in
|
||||
the block this transaction was mined in.
|
||||
|
||||
_property: receipt.type => number
|
||||
The [[link-eip-2718]] type of this transaction. If the transaction
|
||||
is a legacy transaction without an envelope, it will have the type ``0``.
|
||||
|
||||
_property: receipt.root => string
|
||||
The intermediate state root of a receipt.
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ asynchronous source, such as hardware wallets.
|
||||
Sub-classes **must** implement this.
|
||||
|
||||
_property: Signer.isSigner(object) => boolean @<Signer-isSigner> @SRC<abstract-signer>
|
||||
Returns true if an only if //object// is a **Signer**.
|
||||
Returns true if and only if //object// is a **Signer**.
|
||||
|
||||
_heading: Blockchain Methods @<Signer--blockchain-methods>
|
||||
|
||||
@@ -74,6 +74,12 @@ _property: signer.signMessage(message) => Promise<string<[RawSignature](signatur
|
||||
This returns a Promise which resolves to the [[signature-raw]]
|
||||
of //message//.
|
||||
|
||||
A signed message is prefixd with ``"\\x19Ethereum signed message:\\n"`` and
|
||||
the length of the message, using the [hashMessage](utils-hashMessage)
|
||||
method, so that it is [EIP-191](link-eip-191) compliant. If recovering
|
||||
the address in Solidity, this prefix will be required to create a matching
|
||||
hash.
|
||||
|
||||
Sub-classes **must** implement this, however they may throw if signing a
|
||||
message is not supported, such as in a Contract-based Wallet or
|
||||
Meta-Transaction-based Wallet.
|
||||
|
||||
@@ -42,7 +42,78 @@ _property: abiCoder.encode(types, values) => string<[[DataHexString]]> @<AbiCode
|
||||
Encode the array //values// according to the array of //types//, each of which may be a
|
||||
string or a [[ParamType]].
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const abiCoder = utils.defaultAbiCoder;
|
||||
|
||||
// Encoding simple types
|
||||
//_result:
|
||||
abiCoder.encode([ "uint", "string" ], [ 1234, "Hello World" ]);
|
||||
//_log:
|
||||
//_hide: _page.example1 = _;
|
||||
|
||||
// Encoding with arrays types
|
||||
//_result:
|
||||
abiCoder.encode([ "uint[]", "string" ], [ [ 1234, 5678 ] , "Hello World" ]);
|
||||
//_log:
|
||||
//_hide: _page.example2 = _;
|
||||
|
||||
// Encoding complex structs (using positional properties)
|
||||
//_result:
|
||||
abiCoder.encode(
|
||||
[ "uint", "tuple(uint256, string)" ],
|
||||
[
|
||||
1234,
|
||||
[ 5678, "Hello World" ]
|
||||
]
|
||||
);
|
||||
//_log:
|
||||
//_hide: _page.example3 = _;
|
||||
|
||||
// Encoding complex structs (using keyword properties)
|
||||
//_result:
|
||||
abiCoder.encode(
|
||||
[ "uint a", "tuple(uint256 b, string c) d" ],
|
||||
[
|
||||
1234,
|
||||
{ b: 5678, c: "Hello World" }
|
||||
]
|
||||
);
|
||||
//_log:
|
||||
|
||||
_property: abiCoder.decode(types, data) => [[Result]] @<AbiCoder-decode> @SRC<abi/abi-coder>
|
||||
|
||||
Decode the //data// according to the array of //types//, each of which may be a
|
||||
string or [[ParamType]].
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const abiCoder = utils.defaultAbiCoder;
|
||||
|
||||
// Decoding simple types
|
||||
//_hide: data = _page.example1;
|
||||
//_verbatim: `data = ${ JSON.stringify(data) };`
|
||||
//_result:
|
||||
abiCoder.decode([ "uint", "string" ], data);
|
||||
//_log:
|
||||
|
||||
// Decoding with arrays types
|
||||
//_hide: data = _page.example2;
|
||||
//_verbatim: `data = ${ JSON.stringify(data) };`
|
||||
//_result:
|
||||
abiCoder.decode([ "uint[]", "string" ], data);
|
||||
//_log:
|
||||
|
||||
// Decoding complex structs; unnamed parameters allows ONLY
|
||||
// positional access to values
|
||||
//_hide: data = _page.example3;
|
||||
//_verbatim: `data = ${ JSON.stringify(data) };`
|
||||
//_result:
|
||||
abiCoder.decode([ "uint", "tuple(uint256, string)" ], data);
|
||||
//_log:
|
||||
|
||||
// Decoding complex structs; named parameters allows positional
|
||||
// or keyword access to values
|
||||
//_result:
|
||||
abiCoder.decode([ "uint a", "tuple(uint256 b, string c) d" ], data);
|
||||
//_log:
|
||||
|
||||
@@ -47,14 +47,29 @@ are not required for the ABI and used old by Solidity's semantic checking
|
||||
system, such as input parameter data location like ``"calldata"``
|
||||
and ``"memory"``. As such, they can be safely dropped in the ABI as well.
|
||||
|
||||
_code: A simple Human-Readable ABI @lang<javascript>
|
||||
_code: Human-Readable ABI Example @lang<javascript>
|
||||
|
||||
const humanReadableAbi = [
|
||||
|
||||
// Simple types
|
||||
"constructor(string symbol, string name)",
|
||||
"function transferFrom(address from, address to, uint value)",
|
||||
"function balanceOf(address owner) view returns (uint balance)",
|
||||
"event Transfer(address indexed from, address indexed to, address value)",
|
||||
"error InsufficientBalance(account owner, uint balance)"
|
||||
"error InsufficientBalance(account owner, uint balance)",
|
||||
|
||||
// Some examples with the struct type, we use the tuple keyword:
|
||||
// (note: the tuple keyword is optional, simply using additional
|
||||
// parentheses accomplishes the same thing)
|
||||
// struct Person {
|
||||
// string name;
|
||||
// uint16 age;
|
||||
// }
|
||||
"function addPerson(tuple(string name, uint16 age) person)",
|
||||
"function addPeople(tuple(string name, uint16 age)[] person)",
|
||||
"function getPerson(uint id) view returns (tuple(string name, uint16 age))",
|
||||
|
||||
"event PersonAdded(uint indexed id, tuple(string name, uint16 age) person)"
|
||||
];
|
||||
|
||||
//_hide: _page.humanReadableAbi = humanReadableAbi;
|
||||
@@ -128,6 +143,75 @@ const jsonAbi = `[
|
||||
{ "type": "account", "name": "owner"},
|
||||
{ "type": "uint256", "name": "balance"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "addPerson",
|
||||
"constant": false,
|
||||
"payable": false,
|
||||
"inputs": [
|
||||
{
|
||||
"type": "tuple",
|
||||
"name": "person",
|
||||
"components": [
|
||||
{ "type": "string", "name": "name" },
|
||||
{ "type": "uint16", "name": "age" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "addPeople",
|
||||
"constant": false,
|
||||
"payable": false,
|
||||
"inputs": [
|
||||
{
|
||||
"type": "tuple[]",
|
||||
"name": "person",
|
||||
"components": [
|
||||
{ "type": "string", "name": "name" },
|
||||
{ "type": "uint16", "name": "age" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getPerson",
|
||||
"constant": true,
|
||||
"stateMutability": "view",
|
||||
"payable": false,
|
||||
"inputs": [
|
||||
{ "type": "uint256", "name": "id" }
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"type": "tuple",
|
||||
"components": [
|
||||
{ "type": "string", "name": "name" },
|
||||
{ "type": "uint16", "name": "age" }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"anonymous": false,
|
||||
"name": "PersonAdded",
|
||||
"inputs": [
|
||||
{ "type": "uint256", "name": "id", "indexed": true },
|
||||
{
|
||||
"type": "tuple",
|
||||
"name": "person",
|
||||
"components": [
|
||||
{ "type": "string", "name": "name", "indexed": false },
|
||||
{ "type": "uint16", "name": "age", "indexed": false }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]`;
|
||||
|
||||
@@ -156,7 +240,7 @@ and errors are available. It is also highly recommend to strip out
|
||||
unused parts of the ABI (such as admin methods) to further reduce
|
||||
code size.
|
||||
|
||||
_code: Converting to Human-Readable ABI @lang<javascript>
|
||||
_code: Converting to Full Human-Readable ABI @lang<javascript>
|
||||
|
||||
//_hide: const Interface = ethers.utils.Interface;
|
||||
//_hide: const FormatTypes = ethers.utils.FormatTypes;
|
||||
@@ -169,9 +253,16 @@ const iface = new Interface(jsonAbi);
|
||||
iface.format(FormatTypes.full);
|
||||
//_log:
|
||||
|
||||
_code: Converting to Minimal Human-Readable ABI @lang<javascript>
|
||||
|
||||
//_hide: const Interface = ethers.utils.Interface;
|
||||
//_hide: const FormatTypes = ethers.utils.FormatTypes;
|
||||
//_hide: jsonAbi = _page.jsonAbi;
|
||||
|
||||
// Using the "minimal" format will save a small amount of
|
||||
// space, but is generally not worth it as named properties
|
||||
// on Results will not be available
|
||||
const iface = new Interface(jsonAbi);
|
||||
//_result:
|
||||
iface.format(FormatTypes.minimal);
|
||||
//_log:
|
||||
|
||||
@@ -52,21 +52,21 @@ _heading: Output Formats @<fragments--output-formats> @SRC<abi/fragments:FormatT
|
||||
Each [[Fragment]] and [[ParamType]] may be output using its ``format``
|
||||
method.
|
||||
|
||||
_property: ethers.utils.FragmentTypes.full => string
|
||||
_property: ethers.utils.FormatTypes.full => string
|
||||
This is a full human-readable string, including all parameter names, any
|
||||
optional modifiers (e.g. ``indexed``, ``public``, etc) and white-space
|
||||
to aid in human readability.
|
||||
|
||||
_property: ethers.utils.FragmentTypes.minimal => string
|
||||
_property: ethers.utils.FormatTypes.minimal => string
|
||||
This is similar to ``full``, except with no unnecessary whitespace or parameter
|
||||
names. This is useful for storing a minimal string which can still fully
|
||||
reconstruct the original Fragment using [Fragment . from](Fragment-from).
|
||||
|
||||
_property: ethers.utils.FragmentTypes.json => string
|
||||
_property: ethers.utils.FormatTypes.json => string
|
||||
This returns a JavaScript Object which is safe to call ``JSON.stringify``
|
||||
on to create a JSON string.
|
||||
|
||||
_property: ethers.utils.FragmentTypes.sighash => string
|
||||
_property: ethers.utils.FormatTypes.sighash => string
|
||||
This is a minimal output format, which is used by Solidity when computing a
|
||||
signature hash or an event topic hash.
|
||||
|
||||
@@ -74,10 +74,14 @@ _warning: Note
|
||||
The ``sighash`` format is **insufficient** to re-create the original [[Fragment]],
|
||||
since it discards modifiers such as indexed, anonymous, stateMutability, etc.
|
||||
|
||||
It is only useful for computing the selector for a Fragment, and cannot
|
||||
be used to format an Interface.
|
||||
|
||||
|
||||
_subsection: Fragment @<Fragment> @SRC<abi/fragments:class.Fragment>
|
||||
An ABI is a collection of **Fragments**, where each fragment specifies:
|
||||
|
||||
- An [Error](ErrorFragment)
|
||||
- An [Event](EventFragment)
|
||||
- A [Function](FunctionFragment)
|
||||
- A [Constructor](ConstructorFragment)
|
||||
|
||||
@@ -33,12 +33,28 @@ _code: Creating an Interface instance @lang<javascript>
|
||||
// This interface is used for the below examples
|
||||
|
||||
const iface = new Interface([
|
||||
// Constructor
|
||||
"constructor(string symbol, string name)",
|
||||
|
||||
// State mutating method
|
||||
"function transferFrom(address from, address to, uint amount)",
|
||||
"function balanceOf(address owner) view returns (uint)",
|
||||
|
||||
// State mutating method, which is payable
|
||||
"function mint(uint amount) payable",
|
||||
|
||||
// Constant method (i.e. "view" or "pure")
|
||||
"function balanceOf(address owner) view returns (uint)",
|
||||
|
||||
// An Event
|
||||
"event Transfer(address indexed from, address indexed to, uint256 amount)",
|
||||
"error AccountLocked(address owner, uint256 balance)"
|
||||
|
||||
// A Custom Solidity Error
|
||||
"error AccountLocked(address owner, uint256 balance)",
|
||||
|
||||
// Examples with structured types
|
||||
"function addUser(tuple(string name, address addr) user) returns (uint id)",
|
||||
"function addUsers(tuple(string name, address addr)[] user) returns (uint[] id)",
|
||||
"function getUser(uint id) view returns (tuple(string name, address addr) user)"
|
||||
]);
|
||||
|
||||
//_hide: _page.iface = iface;
|
||||
@@ -214,6 +230,27 @@ _code: @lang<javascript>
|
||||
iface.encodeDeploy([ "SYM", "Some Name" ])
|
||||
//_log:
|
||||
|
||||
_property: interface.encodeErrorResult(fragment [ , values ]) => string<[[DataHexString]]> @SRC<abi/interface>
|
||||
Returns the encoded error result, which would normally be the response from
|
||||
a reverted call for //fragment// (see [[Interface--specifying-fragments]]) for
|
||||
the given //values//.
|
||||
|
||||
Most developers will not need this method, but may be useful for authors of
|
||||
a mock blockchain.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const iface = _page.iface;
|
||||
//_hide: const parseEther = ethers.utils.parseEther;
|
||||
|
||||
// Encoding result data (like is returned by eth_call during a revert)
|
||||
//_result:
|
||||
iface.encodeErrorResult("AccountLocked", [
|
||||
"0x8ba1f109551bD432803012645Ac136ddd64DBA72",
|
||||
parseEther("1.0")
|
||||
]);
|
||||
//_log:
|
||||
|
||||
_property: interface.encodeFilterTopics(fragment, values) => Array<topic | Array<topic>> @SRC<abi/interface>
|
||||
Returns the encoded topic filter, which can be passed to getLogs for //fragment//
|
||||
(see [[Interface--specifying-fragments]]) for the given //values//.
|
||||
@@ -263,6 +300,25 @@ iface.encodeFunctionData("transferFrom", [
|
||||
])
|
||||
//_log:
|
||||
|
||||
// Encoding structured data (using positional Array)
|
||||
user = [
|
||||
"Richard Moore",
|
||||
"0x8ba1f109551bD432803012645Ac136ddd64DBA72"
|
||||
];
|
||||
//_result:
|
||||
iface.encodeFunctionData("addUser", [ user ]);
|
||||
//_log:
|
||||
|
||||
// Encoding structured data, using objects. Only available
|
||||
// if paramters are named.
|
||||
user = {
|
||||
name: "Richard Moore",
|
||||
addr: "0x8ba1f109551bD432803012645Ac136ddd64DBA72"
|
||||
};
|
||||
//_result:
|
||||
iface.encodeFunctionData("addUser", [ user ]);
|
||||
//_log:
|
||||
|
||||
_property: interface.encodeFunctionResult(fragment [ , values ]) => string<[[DataHexString]]> @SRC<abi/interface>
|
||||
Returns the encoded result, which would normally be the response from a call for
|
||||
//fragment// (see [[Interface--specifying-fragments]]) for the given //values//.
|
||||
@@ -284,6 +340,24 @@ iface.encodeFunctionResult("balanceOf", [
|
||||
|
||||
_subsection: Decoding Data @<Interface--decoding>
|
||||
|
||||
_property: interface.decodeErrorResult(fragment, data) => [[Result]] @SRC<abi/interface>
|
||||
Returns the decoded values from the result of a call during a revert for
|
||||
//fragment// (see [[Interface--specifying-fragments]]) for the given //data//.
|
||||
|
||||
Most developers won't need this, as the ``decodeFunctionResult`` will automatically
|
||||
decode errors if the //data// represents a revert.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const iface = _page.iface;
|
||||
|
||||
// Decoding result data (e.g. from an eth_call)
|
||||
errorData = "0xf7c3865a0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
|
||||
//_result:
|
||||
iface.decodeErrorResult("AccountLocked", errorData)
|
||||
//_log:
|
||||
|
||||
_property: interface.decodeEventLog(fragment, data [ , topics ]) => [[Result]] @SRC<abi/interface>
|
||||
Returns the decoded event values from an event log for
|
||||
//fragment// (see [[Interface--specifying-fragments]]) for the given //data//
|
||||
@@ -342,18 +416,37 @@ _code: @lang<javascript>
|
||||
//_hide: const iface = _page.iface;
|
||||
|
||||
// Decoding result data (e.g. from an eth_call)
|
||||
const resultData = "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
resultData = "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
//_result:
|
||||
iface.decodeFunctionResult("balanceOf", resultData)
|
||||
//_log:
|
||||
|
||||
// Decoding result data which was caused by a revert
|
||||
// Throws a CALL_EXCEPTION, with extra details
|
||||
const errorData = "0xf7c3865a0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
errorData = "0xf7c3865a0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
//_throws:
|
||||
iface.decodeFunctionResult("balanceOf", errorData)
|
||||
//_log:
|
||||
|
||||
// Decoding structured data returns a Result object, which
|
||||
// will include all values positionally and if the ABI
|
||||
// included names, values will additionally be available
|
||||
// by their name.
|
||||
resultData = "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000008ba1f109551bd432803012645ac136ddd64dba72000000000000000000000000000000000000000000000000000000000000000d52696368617264204d6f6f726500000000000000000000000000000000000000";
|
||||
//_result:
|
||||
result = iface.decodeFunctionResult("getUser", resultData);
|
||||
//_log:
|
||||
|
||||
// Access positionally:
|
||||
// The 0th output parameter, the 0th proerty of the structure
|
||||
//_result:
|
||||
result[0][0];
|
||||
//_log:
|
||||
|
||||
// Access by name: (only avilable because parameters were named)
|
||||
//_result:
|
||||
result.user.name
|
||||
//_log:
|
||||
|
||||
_subsection: Parsing @<Interface--parsing>
|
||||
|
||||
@@ -361,6 +454,21 @@ The functions are generally the most useful for most developers. They will
|
||||
automatically search the ABI for a matching Event or Function and decode
|
||||
the components as a fully specified description.
|
||||
|
||||
_property: interface.parseError(data) => [[ErrorDescription]] @SRC<abi/interface>
|
||||
Search for the error that matches the error selector in //data// and parse out
|
||||
the details.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
//_hide: const iface = _page.iface;
|
||||
|
||||
const data = "0xf7c3865a0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000";
|
||||
|
||||
//_result:
|
||||
iface.parseError(data);
|
||||
//_hide: _.errorFragment = createClass("ErrorFragment");
|
||||
//_log:
|
||||
|
||||
_property: interface.parseLog(log) => [[LogDescription]] @SRC<abi/interface>
|
||||
Search the event that matches the //log// topic hash and parse the values
|
||||
the log represents.
|
||||
@@ -413,6 +521,24 @@ any named value for this key is renamed to ``_length``. If there is a
|
||||
name collision, only the first is available by its key.
|
||||
|
||||
|
||||
_heading: ErrorDescription @<ErrorDescription>
|
||||
|
||||
_property: errorDescription.args => [[Result]]
|
||||
The values of the input parameters of the error.
|
||||
|
||||
_property: errorDescription.errorFragment => [[ErrorFragment]]
|
||||
The [[ErrorFragment]] which matches the selector in the data.
|
||||
|
||||
_property: errorDescription.name => string
|
||||
The error name. (e.g. ``AccountLocked``)
|
||||
|
||||
_property: errorDescription.signature => string
|
||||
The error signature. (e.g. ``AccountLocked(address,uint256)``)
|
||||
|
||||
_property: errorDescription.sighash => string
|
||||
The selector of the error.
|
||||
|
||||
|
||||
_heading: LogDescription @<LogDescription>
|
||||
|
||||
_property: logDescription.args => [[Result]]
|
||||
|
||||
@@ -168,6 +168,10 @@ Returns true if and only if the value of //BigNumber// is zero.
|
||||
|
||||
_heading: Conversion
|
||||
|
||||
_property: BigNumber.toBigInt() => bigint @SRC<bignumber>
|
||||
Returns the value of //BigNumber// as a [JavScript BigInt](link-js-bigint) value,
|
||||
on platforms which support them.
|
||||
|
||||
_property: BigNumber.toNumber() => number @SRC<bignumber>
|
||||
Returns the value of //BigNumber// as a JavaScript value.
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ The gas limit for this transaction.
|
||||
_property: unsignedTransaction.gasPrice => [[BigNumberish]]
|
||||
The gas price for this transaction.
|
||||
|
||||
_property: unsignedTransaction.maxFeePerGas => [[BigNumberish]]
|
||||
The maximum fee per unit of gas for this transaction.
|
||||
|
||||
_property: unsignedTransaction.maxPriorityFeePerGas => [[BigNumberish]]
|
||||
The maximum priority fee per unit of gas for this transaction.
|
||||
|
||||
_property: unsignedTransaction.data => [[BytesLike]]
|
||||
The data for this transaction.
|
||||
|
||||
@@ -38,7 +44,7 @@ The transaction hash, which can be used as an identifier for
|
||||
//transaction//. This is the keccak256 of the serialized RLP encoded
|
||||
representation of //transaction//.
|
||||
|
||||
_property: unsignedTransaction.to => string<[Address](address)>
|
||||
_property: transaction.to => string<[Address](address)>
|
||||
The address //transaction// is to.
|
||||
|
||||
_property: transaction.from => string<[Address](address)>
|
||||
@@ -57,9 +63,21 @@ refunded at the end of the transaction, and if there is insufficient gas
|
||||
to complete execution, the effects of the transaction are reverted, but
|
||||
the gas is **fully consumed** and an out-of-gas error occurs.
|
||||
|
||||
_property: transaction.gasPrice => [[BigNumber]]
|
||||
_property: transaction.gasPrice => null | [[BigNumber]]
|
||||
The price (in wei) per unit of gas for //transaction//.
|
||||
|
||||
For [[link-eip-1559]] transactions, this will be null.
|
||||
|
||||
_property: transaction.maxFeePerGas => [[BigNumber]]
|
||||
The maximum price (in wei) per unit of gas for //transaction//.
|
||||
|
||||
For transactions that are not [[link-eip-1559]] transactions, this will be null.
|
||||
|
||||
_property: transaction.maxPriorityFeePerGas => [[BigNumber]]
|
||||
The priority fee price (in wei) per unit of gas for //transaction//.
|
||||
|
||||
For transactions that are not [[link-eip-1559]] transactions, this will be null.
|
||||
|
||||
_property: transaction.data => [[BytesLike]]
|
||||
The data for //transaction//. In a contract this is the call data.
|
||||
|
||||
|
||||
@@ -117,10 +117,14 @@ const getSourceUrl = (function(path, include, exclude) {
|
||||
}
|
||||
})("../packages/", new RegExp("packages/.*/src.ts/.*\.ts$"), new RegExp("/node_modules/|src.ts/.*browser.*"));
|
||||
|
||||
let localSigner = null;
|
||||
|
||||
function codeContextify(context) {
|
||||
const { inspect } = require("util");
|
||||
const ethers = context.require("./packages/ethers");
|
||||
|
||||
if (localSigner == null) { localSigner = ethers.Wallet.createRandom(); }
|
||||
|
||||
context.ethers = ethers;
|
||||
context.BigNumber = ethers.BigNumber;
|
||||
context.constants = ethers.constants;
|
||||
@@ -133,9 +137,9 @@ function codeContextify(context) {
|
||||
|
||||
// We use a local dev node for some signing examples, but want to
|
||||
// resolve ENS names against mainnet; super hacky but makes the
|
||||
// docs nicer
|
||||
// docs nicer (funded in _startup)
|
||||
context.localProvider = new ethers.providers.JsonRpcProvider();
|
||||
context.localSigner = context.localProvider.getSigner();
|
||||
context.localSigner = localSigner.connect(context.localProvider);
|
||||
context.localProvider.resolveName = context.provider.resolveName.bind(context.provider);
|
||||
|
||||
context.BigNumber.prototype[inspect.custom] = function(depth, options) {
|
||||
@@ -179,12 +183,26 @@ function codeContextify(context) {
|
||||
sorted: true,
|
||||
});
|
||||
}
|
||||
|
||||
context._startup = async function() {
|
||||
console.log("Startup");
|
||||
const signer = context.localProvider.getSigner();
|
||||
const tx = await signer.sendTransaction({
|
||||
to: localSigner.address,
|
||||
value: ethers.utils.parseEther("10.0")
|
||||
});
|
||||
await tx.wait();
|
||||
}
|
||||
|
||||
context._shutdown = function() {
|
||||
console.log("Shutdown");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
title: "ethers",
|
||||
subtitle: "v5.2",
|
||||
subtitle: "v5.4",
|
||||
description: "Documentation for ethers, a complete, tiny and simple Ethereum library.",
|
||||
logo: "logo.svg",
|
||||
|
||||
@@ -281,6 +299,7 @@ module.exports = {
|
||||
"link-eip-712": { name: "EIP-712", url: "https:/\/eips.ethereum.org/EIPS/eip-712" },
|
||||
"link-eip-1014": { name: "EIP-1014", url: "https:/\/eips.ethereum.org/EIPS/eip-1014" },
|
||||
"link-eip-1193": { name: "EIP-1193", url: "https:/\/eips.ethereum.org/EIPS/eip-1193" },
|
||||
"link-eip-1559": { name: "EIP-1559", url: "https:/\/eips.ethereum.org/EIPS/eip-1559" },
|
||||
"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" },
|
||||
|
||||
@@ -6,4 +6,5 @@ snippets of code that are in general useful.
|
||||
_toc:
|
||||
|
||||
react-native
|
||||
transactions
|
||||
|
||||
|
||||
24
docs.wrm/cookbook/transactions.wrm
Normal file
24
docs.wrm/cookbook/transactions.wrm
Normal file
@@ -0,0 +1,24 @@
|
||||
_section: Transactions @<cookbook--transactions>
|
||||
|
||||
_subsection: Compute the raw transaction @<cookbook--compute-raw-transaction>
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
function getRawTransaction(tx) {
|
||||
function addKey(accum, key) {
|
||||
if (tx[key]) { accum[key] = tx[key]; }
|
||||
return accum;
|
||||
}
|
||||
|
||||
// Extract the relevant parts of the transaction and signature
|
||||
const txFields = "accessList chainId data gasPrice gasLimit maxFeePerGer maxPriorityFeePerGas nonce to type value".split(" ");
|
||||
const sigFields = "v r s".split(" ");
|
||||
|
||||
// Seriailze the signed transaction
|
||||
const raw = utils.serializeTransaction(txFields.reduce(addKey, { }), sigFields.reduce(addKey, { }));
|
||||
|
||||
// Double check things went well
|
||||
if (utils.keccak256(raw) !== tx.hash) { throw new Error("serializing failed!"); }
|
||||
|
||||
return raw;
|
||||
}
|
||||
@@ -14,4 +14,4 @@ _subsection: Tutorials
|
||||
I do not manage or maintain these tutorials, but have happened across them.
|
||||
If a link is dead or outdated, please [let me know](link-mail) and I'll update it.
|
||||
|
||||
- No links yet; send me some
|
||||
- [Alchemy - How to Mint an NFT](https://docs.alchemy.com/alchemy/tutorials/how-to-create-an-nft/how-to-mint-an-nft-with-ethers)
|
||||
|
||||
@@ -75,7 +75,7 @@ apikey asc endblock startblock
|
||||
alchemyapi Cloudflare Etherscan INFURA IPFS MetaMask Nodesmith
|
||||
Trezor ledgerhq axic bitcoinjs browserify easyseed ethereumjs
|
||||
goerli homestead kotti kovan mainnet morden mordor rinkeby
|
||||
ropsten testnet lb
|
||||
ropsten testnet lb maticmum
|
||||
|
||||
// Demo words
|
||||
args foo eth foo foobar ll localhost passwd ricmoo tx xxx yna
|
||||
|
||||
@@ -73,7 +73,7 @@ function _getUrl(href, options) {
|
||||
options = {};
|
||||
}
|
||||
// @TODO: Once we drop support for node 8, we can pass the href
|
||||
// firectly into request and skip adding the components
|
||||
// directly into request and skip adding the components
|
||||
// to this request object
|
||||
const url = url_1.parse(href);
|
||||
const request = {
|
||||
|
||||
@@ -66,7 +66,7 @@ apikey asc endblock startblock
|
||||
alchemyapi Cloudflare Etherscan INFURA IPFS MetaMask Nodesmith
|
||||
Trezor ledgerhq axic bitcoinjs browserify easyseed ethereumjs
|
||||
goerli homestead kotti kovan mainnet morden mordor rinkeby
|
||||
ropsten testnet lb
|
||||
ropsten testnet lb maticmum
|
||||
|
||||
// Demo words
|
||||
args foo eth foo foobar ll localhost passwd ricmoo tx xxx yna
|
||||
|
||||
@@ -79,7 +79,7 @@ async function _getUrl(href: string, options?: Options): Promise<GetUrlResponse>
|
||||
if (options == null) { options = { }; }
|
||||
|
||||
// @TODO: Once we drop support for node 8, we can pass the href
|
||||
// firectly into request and skip adding the components
|
||||
// directly into request and skip adding the components
|
||||
// to this request object
|
||||
const url = parse(href);
|
||||
|
||||
|
||||
871
package-lock.json
generated
871
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -67,7 +67,7 @@
|
||||
"aes-js": "3.0.0",
|
||||
"aws-sdk": "2.137.0",
|
||||
"diff": "4.0.1",
|
||||
"flatworm": "0.0.2-beta.5",
|
||||
"flatworm": "0.0.2-beta.7",
|
||||
"jison": "0.4.18",
|
||||
"karma": "6.3.2",
|
||||
"karma-chrome-launcher": "3.1.0",
|
||||
|
||||
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.3.1";
|
||||
export declare const version = "abi/5.4.1";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abi/5.3.1";
|
||||
export const version = "abi/5.4.1";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -11,7 +11,7 @@ export class AddressCoder extends Coder {
|
||||
}
|
||||
encode(writer, value) {
|
||||
try {
|
||||
getAddress(value);
|
||||
value = getAddress(value);
|
||||
}
|
||||
catch (error) {
|
||||
this._throwError(error.message, value);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src.ts/coders/address.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAkB,MAAM,kBAAkB,CAAC;AAEzD,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEnC,YAAY,SAAiB;QACzB,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,YAAY;QACR,OAAO,4CAA4C,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,KAAa;QAChC,IAAI;YACA,UAAU,CAAC,KAAK,CAAC,CAAC;SACrB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SAC1C;QACD,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,OAAO,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;CACJ"}
|
||||
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src.ts/coders/address.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAkB,MAAM,kBAAkB,CAAC;AAEzD,MAAM,OAAO,YAAa,SAAQ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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"}
|
||||
{"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,CAmFnE;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"}
|
||||
@@ -131,6 +131,7 @@ export function unpack(reader, coders) {
|
||||
const value = values[index];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(values, name, {
|
||||
enumerable: true,
|
||||
get: () => { throw value; }
|
||||
});
|
||||
}
|
||||
@@ -142,6 +143,7 @@ export function unpack(reader, coders) {
|
||||
const value = values[i];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(values, i, {
|
||||
enumerable: true,
|
||||
get: () => { throw value; }
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
packages/abi/lib.esm/fragments.d.ts
vendored
1
packages/abi/lib.esm/fragments.d.ts
vendored
@@ -3,6 +3,7 @@ export interface JsonFragmentType {
|
||||
readonly name?: string;
|
||||
readonly indexed?: boolean;
|
||||
readonly type?: string;
|
||||
readonly internalType?: any;
|
||||
readonly components?: ReadonlyArray<JsonFragmentType>;
|
||||
}
|
||||
export interface JsonFragment {
|
||||
|
||||
@@ -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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AAC,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"}
|
||||
File diff suppressed because one or more lines are too long
12
packages/abi/lib.esm/interface.d.ts
vendored
12
packages/abi/lib.esm/interface.d.ts
vendored
@@ -20,6 +20,13 @@ export declare class TransactionDescription extends Description<TransactionDescr
|
||||
readonly sighash: string;
|
||||
readonly value: BigNumber;
|
||||
}
|
||||
export declare class ErrorDescription extends Description<ErrorDescription> {
|
||||
readonly errorFragment: ErrorFragment;
|
||||
readonly name: string;
|
||||
readonly args: Result;
|
||||
readonly signature: string;
|
||||
readonly sighash: string;
|
||||
}
|
||||
export declare class Indexed extends Description<Indexed> {
|
||||
readonly hash: string;
|
||||
readonly _isIndexed: boolean;
|
||||
@@ -51,11 +58,13 @@ export declare class Interface {
|
||||
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
|
||||
getEvent(nameOrSignatureOrTopic: string): EventFragment;
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment;
|
||||
getSighash(functionFragment: FunctionFragment | string): string;
|
||||
getSighash(fragment: ErrorFragment | FunctionFragment | string): string;
|
||||
getEventTopic(eventFragment: EventFragment | string): string;
|
||||
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
||||
_encodeParams(params: ReadonlyArray<ParamType>, values: ReadonlyArray<any>): string;
|
||||
encodeDeploy(values?: ReadonlyArray<any>): string;
|
||||
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result;
|
||||
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string;
|
||||
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result;
|
||||
encodeFunctionData(functionFragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
|
||||
decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): Result;
|
||||
@@ -74,6 +83,7 @@ export declare class Interface {
|
||||
topics: Array<string>;
|
||||
data: string;
|
||||
}): LogDescription;
|
||||
parseError(data: BytesLike): ErrorDescription;
|
||||
static isInterface(value: any): value is Interface;
|
||||
}
|
||||
//# sourceMappingURL=interface.d.ts.map
|
||||
@@ -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,aAAa,EAAe,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMlJ,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW,CAAC,cAAc,CAAC;IAC3D,Q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E,aAAa,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAyD3G,cAAc,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,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;IA4F9G,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;IAmBrE,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,gBAAgB;IA4B7C,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS;CAGrD"}
|
||||
@@ -16,6 +16,8 @@ export class LogDescription extends Description {
|
||||
}
|
||||
export class TransactionDescription extends Description {
|
||||
}
|
||||
export class ErrorDescription extends Description {
|
||||
}
|
||||
export class Indexed extends Description {
|
||||
static isIndexed(value) {
|
||||
return !!(value && value._isIndexed);
|
||||
@@ -222,11 +224,21 @@ export class Interface {
|
||||
return result;
|
||||
}
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
getSighash(functionFragment) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
functionFragment = this.getFunction(functionFragment);
|
||||
getSighash(fragment) {
|
||||
if (typeof (fragment) === "string") {
|
||||
try {
|
||||
fragment = this.getFunction(fragment);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
catch (_) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getStatic(this.constructor, "getSighash")(functionFragment);
|
||||
return getStatic(this.constructor, "getSighash")(fragment);
|
||||
}
|
||||
// Get the topic (the bytes32 hash) used by Solidity to identify an event
|
||||
getEventTopic(eventFragment) {
|
||||
@@ -244,6 +256,25 @@ export class Interface {
|
||||
encodeDeploy(values) {
|
||||
return this._encodeParams(this.deploy.inputs, values || []);
|
||||
}
|
||||
decodeErrorResult(fragment, data) {
|
||||
if (typeof (fragment) === "string") {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
const bytes = arrayify(data);
|
||||
if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
|
||||
logger.throwArgumentError(`data signature does not match error ${fragment.name}.`, "data", hexlify(bytes));
|
||||
}
|
||||
return this._decodeParams(fragment.inputs, bytes.slice(4));
|
||||
}
|
||||
encodeErrorResult(fragment, values) {
|
||||
if (typeof (fragment) === "string") {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
return hexlify(concat([
|
||||
this.getSighash(fragment),
|
||||
this._encodeParams(fragment.inputs, values || [])
|
||||
]));
|
||||
}
|
||||
// Decode the data for a function call (e.g. tx.data)
|
||||
decodeFunctionData(functionFragment, data) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
@@ -480,6 +511,7 @@ export class Interface {
|
||||
// Make error named values throw on access
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(result, param.name, {
|
||||
enumerable: true,
|
||||
get: () => { throw wrapAccessError(`property ${JSON.stringify(param.name)}`, value); }
|
||||
});
|
||||
}
|
||||
@@ -493,6 +525,7 @@ export class Interface {
|
||||
const value = result[i];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(result, i, {
|
||||
enumerable: true,
|
||||
get: () => { throw wrapAccessError(`index ${i}`, value); }
|
||||
});
|
||||
}
|
||||
@@ -535,6 +568,20 @@ export class Interface {
|
||||
args: this.decodeEventLog(fragment, log.data, log.topics)
|
||||
});
|
||||
}
|
||||
parseError(data) {
|
||||
const hexData = hexlify(data);
|
||||
let fragment = this.getError(hexData.substring(0, 10).toLowerCase());
|
||||
if (!fragment) {
|
||||
return null;
|
||||
}
|
||||
return new ErrorDescription({
|
||||
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
|
||||
errorFragment: fragment,
|
||||
name: fragment.name,
|
||||
signature: fragment.format(),
|
||||
sighash: this.getSighash(fragment),
|
||||
});
|
||||
}
|
||||
/*
|
||||
static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
|
||||
if (Interface.isInterface(value)) {
|
||||
|
||||
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.3.1";
|
||||
export declare const version = "abi/5.4.1";
|
||||
//# 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.3.1";
|
||||
exports.version = "abi/5.4.1";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -29,7 +29,7 @@ var AddressCoder = /** @class */ (function (_super) {
|
||||
};
|
||||
AddressCoder.prototype.encode = function (writer, value) {
|
||||
try {
|
||||
address_1.getAddress(value);
|
||||
value = address_1.getAddress(value);
|
||||
}
|
||||
catch (error) {
|
||||
this._throwError(error.message, value);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src.ts/coders/address.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;AAEb,kDAAoD;AACpD,8CAAkD;AAElD,mDAAyD;AAEzD;IAAkC,gCAAK;IAEnC,sBAAY,SAAiB;eACzB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AN,UAAO,MAAc;QACjB,OAAO,oBAAU,CAAC,kBAAU,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IACL,mBAAC;AAAD,CAAC,AAtBD,CAAkC,sBAAK,GAsBtC;AAtBY,oCAAY"}
|
||||
@@ -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;CAsB9B"}
|
||||
{"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,CAmFnE;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"}
|
||||
@@ -149,6 +149,7 @@ function unpack(reader, coders) {
|
||||
var value = values[index];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(values, name, {
|
||||
enumerable: true,
|
||||
get: function () { throw value; }
|
||||
});
|
||||
}
|
||||
@@ -160,6 +161,7 @@ function unpack(reader, coders) {
|
||||
var value = values[i];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(values, i, {
|
||||
enumerable: true,
|
||||
get: function () { throw value; }
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
packages/abi/lib/fragments.d.ts
vendored
1
packages/abi/lib/fragments.d.ts
vendored
@@ -3,6 +3,7 @@ export interface JsonFragmentType {
|
||||
readonly name?: string;
|
||||
readonly indexed?: boolean;
|
||||
readonly type?: string;
|
||||
readonly internalType?: any;
|
||||
readonly components?: ReadonlyArray<JsonFragmentType>;
|
||||
}
|
||||
export interface JsonFragment {
|
||||
|
||||
@@ -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,MAAM,CAAC;IAGtB,QAAQ,CAAC,QAAQ,EAAE,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E,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"}
|
||||
File diff suppressed because one or more lines are too long
12
packages/abi/lib/interface.d.ts
vendored
12
packages/abi/lib/interface.d.ts
vendored
@@ -20,6 +20,13 @@ export declare class TransactionDescription extends Description<TransactionDescr
|
||||
readonly sighash: string;
|
||||
readonly value: BigNumber;
|
||||
}
|
||||
export declare class ErrorDescription extends Description<ErrorDescription> {
|
||||
readonly errorFragment: ErrorFragment;
|
||||
readonly name: string;
|
||||
readonly args: Result;
|
||||
readonly signature: string;
|
||||
readonly sighash: string;
|
||||
}
|
||||
export declare class Indexed extends Description<Indexed> {
|
||||
readonly hash: string;
|
||||
readonly _isIndexed: boolean;
|
||||
@@ -51,11 +58,13 @@ export declare class Interface {
|
||||
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
|
||||
getEvent(nameOrSignatureOrTopic: string): EventFragment;
|
||||
getError(nameOrSignatureOrSighash: string): ErrorFragment;
|
||||
getSighash(functionFragment: FunctionFragment | string): string;
|
||||
getSighash(fragment: ErrorFragment | FunctionFragment | string): string;
|
||||
getEventTopic(eventFragment: EventFragment | string): string;
|
||||
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
|
||||
_encodeParams(params: ReadonlyArray<ParamType>, values: ReadonlyArray<any>): string;
|
||||
encodeDeploy(values?: ReadonlyArray<any>): string;
|
||||
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result;
|
||||
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string;
|
||||
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result;
|
||||
encodeFunctionData(functionFragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
|
||||
decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): Result;
|
||||
@@ -74,6 +83,7 @@ export declare class Interface {
|
||||
topics: Array<string>;
|
||||
data: string;
|
||||
}): LogDescription;
|
||||
parseError(data: BytesLike): ErrorDescription;
|
||||
static isInterface(value: any): value is Interface;
|
||||
}
|
||||
//# sourceMappingURL=interface.d.ts.map
|
||||
@@ -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,aAAa,EAAe,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMlJ,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,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,sBAAuB,SAAQ,WAAW,CAAC,sBAAsB,CAAC;IAC3E,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,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C,MAAM,CAAC,GAAG,MAAM;IA4F9G,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;IAmBrE,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,gBAAgB;IA4B7C,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS;CAGrD"}
|
||||
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Interface = exports.Indexed = exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = void 0;
|
||||
exports.Interface = exports.Indexed = exports.ErrorDescription = exports.TransactionDescription = exports.LogDescription = exports.checkResultErrors = void 0;
|
||||
var address_1 = require("@ethersproject/address");
|
||||
var bignumber_1 = require("@ethersproject/bignumber");
|
||||
var bytes_1 = require("@ethersproject/bytes");
|
||||
@@ -45,6 +45,14 @@ var TransactionDescription = /** @class */ (function (_super) {
|
||||
return TransactionDescription;
|
||||
}(properties_1.Description));
|
||||
exports.TransactionDescription = TransactionDescription;
|
||||
var ErrorDescription = /** @class */ (function (_super) {
|
||||
__extends(ErrorDescription, _super);
|
||||
function ErrorDescription() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return ErrorDescription;
|
||||
}(properties_1.Description));
|
||||
exports.ErrorDescription = ErrorDescription;
|
||||
var Indexed = /** @class */ (function (_super) {
|
||||
__extends(Indexed, _super);
|
||||
function Indexed() {
|
||||
@@ -259,11 +267,21 @@ var Interface = /** @class */ (function () {
|
||||
return result;
|
||||
};
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
Interface.prototype.getSighash = function (functionFragment) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
functionFragment = this.getFunction(functionFragment);
|
||||
Interface.prototype.getSighash = function (fragment) {
|
||||
if (typeof (fragment) === "string") {
|
||||
try {
|
||||
fragment = this.getFunction(fragment);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
catch (_) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return properties_1.getStatic(this.constructor, "getSighash")(functionFragment);
|
||||
return properties_1.getStatic(this.constructor, "getSighash")(fragment);
|
||||
};
|
||||
// Get the topic (the bytes32 hash) used by Solidity to identify an event
|
||||
Interface.prototype.getEventTopic = function (eventFragment) {
|
||||
@@ -281,6 +299,25 @@ var Interface = /** @class */ (function () {
|
||||
Interface.prototype.encodeDeploy = function (values) {
|
||||
return this._encodeParams(this.deploy.inputs, values || []);
|
||||
};
|
||||
Interface.prototype.decodeErrorResult = function (fragment, data) {
|
||||
if (typeof (fragment) === "string") {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
var bytes = bytes_1.arrayify(data);
|
||||
if (bytes_1.hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
|
||||
logger.throwArgumentError("data signature does not match error " + fragment.name + ".", "data", bytes_1.hexlify(bytes));
|
||||
}
|
||||
return this._decodeParams(fragment.inputs, bytes.slice(4));
|
||||
};
|
||||
Interface.prototype.encodeErrorResult = function (fragment, values) {
|
||||
if (typeof (fragment) === "string") {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
return bytes_1.hexlify(bytes_1.concat([
|
||||
this.getSighash(fragment),
|
||||
this._encodeParams(fragment.inputs, values || [])
|
||||
]));
|
||||
};
|
||||
// Decode the data for a function call (e.g. tx.data)
|
||||
Interface.prototype.decodeFunctionData = function (functionFragment, data) {
|
||||
if (typeof (functionFragment) === "string") {
|
||||
@@ -519,6 +556,7 @@ var Interface = /** @class */ (function () {
|
||||
// Make error named values throw on access
|
||||
if (value_1 instanceof Error) {
|
||||
Object.defineProperty(result, param.name, {
|
||||
enumerable: true,
|
||||
get: function () { throw wrapAccessError("property " + JSON.stringify(param.name), value_1); }
|
||||
});
|
||||
}
|
||||
@@ -531,6 +569,7 @@ var Interface = /** @class */ (function () {
|
||||
var value = result[i];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(result, i, {
|
||||
enumerable: true,
|
||||
get: function () { throw wrapAccessError("index " + i, value); }
|
||||
});
|
||||
}
|
||||
@@ -577,6 +616,20 @@ var Interface = /** @class */ (function () {
|
||||
args: this.decodeEventLog(fragment, log.data, log.topics)
|
||||
});
|
||||
};
|
||||
Interface.prototype.parseError = function (data) {
|
||||
var hexData = bytes_1.hexlify(data);
|
||||
var fragment = this.getError(hexData.substring(0, 10).toLowerCase());
|
||||
if (!fragment) {
|
||||
return null;
|
||||
}
|
||||
return new ErrorDescription({
|
||||
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
|
||||
errorFragment: fragment,
|
||||
name: fragment.name,
|
||||
signature: fragment.format(),
|
||||
sighash: this.getSighash(fragment),
|
||||
});
|
||||
};
|
||||
/*
|
||||
static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
|
||||
if (Interface.isInterface(value)) {
|
||||
|
||||
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.3.0",
|
||||
"@ethersproject/bignumber": "^5.3.0",
|
||||
"@ethersproject/bytes": "^5.3.0",
|
||||
"@ethersproject/constants": "^5.3.0",
|
||||
"@ethersproject/hash": "^5.3.0",
|
||||
"@ethersproject/keccak256": "^5.3.0",
|
||||
"@ethersproject/logger": "^5.3.0",
|
||||
"@ethersproject/properties": "^5.3.0",
|
||||
"@ethersproject/strings": "^5.3.0"
|
||||
"@ethersproject/address": "^5.4.0",
|
||||
"@ethersproject/bignumber": "^5.4.0",
|
||||
"@ethersproject/bytes": "^5.4.0",
|
||||
"@ethersproject/constants": "^5.4.0",
|
||||
"@ethersproject/hash": "^5.4.0",
|
||||
"@ethersproject/keccak256": "^5.4.0",
|
||||
"@ethersproject/logger": "^5.4.0",
|
||||
"@ethersproject/properties": "^5.4.0",
|
||||
"@ethersproject/strings": "^5.4.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": "0x2e024e140e942ced3e6c1540c7126c30520037c7fff8fb874791eb405ca401b1",
|
||||
"tarballHash": "0x89b79e31d806f85d8e82b0f0cdb92302bdc1a4fd9df3f2c838df55a3a190bad9",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.3.1"
|
||||
"version": "5.4.1"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abi/5.3.1";
|
||||
export const version = "abi/5.4.1";
|
||||
|
||||
@@ -17,7 +17,7 @@ export class AddressCoder extends Coder {
|
||||
|
||||
encode(writer: Writer, value: string): number {
|
||||
try {
|
||||
getAddress(value);
|
||||
value = getAddress(value)
|
||||
} catch (error) {
|
||||
this._throwError(error.message, value);
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ export function unpack(reader: Reader, coders: Array<Coder>): Result {
|
||||
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(values, name, {
|
||||
enumerable: true,
|
||||
get: () => { throw value; }
|
||||
});
|
||||
} else {
|
||||
@@ -155,6 +156,7 @@ export function unpack(reader: Reader, coders: Array<Coder>): Result {
|
||||
const value = values[i];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(values, i, {
|
||||
enumerable: true,
|
||||
get: () => { throw value; }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export interface JsonFragmentType {
|
||||
readonly name?: string;
|
||||
readonly indexed?: boolean;
|
||||
readonly type?: string;
|
||||
readonly internalType?: any; // @TODO: in v6 reduce type
|
||||
readonly components?: ReadonlyArray<JsonFragmentType>;
|
||||
}
|
||||
|
||||
@@ -30,7 +31,6 @@ export interface JsonFragment {
|
||||
readonly gas?: string;
|
||||
};
|
||||
|
||||
|
||||
const _constructorGuard = { };
|
||||
|
||||
// AST Node parser state
|
||||
|
||||
@@ -34,6 +34,14 @@ export class TransactionDescription extends Description<TransactionDescription>
|
||||
readonly value: BigNumber;
|
||||
}
|
||||
|
||||
export class ErrorDescription extends Description<ErrorDescription> {
|
||||
readonly errorFragment: ErrorFragment;
|
||||
readonly name: string;
|
||||
readonly args: Result;
|
||||
readonly signature: string;
|
||||
readonly sighash: string;
|
||||
}
|
||||
|
||||
export class Indexed extends Description<Indexed> {
|
||||
readonly hash: string;
|
||||
readonly _isIndexed: boolean;
|
||||
@@ -283,12 +291,20 @@ export class Interface {
|
||||
}
|
||||
|
||||
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
|
||||
getSighash(functionFragment: FunctionFragment | string): string {
|
||||
if (typeof(functionFragment) === "string") {
|
||||
functionFragment = this.getFunction(functionFragment);
|
||||
getSighash(fragment: ErrorFragment | FunctionFragment | string): string {
|
||||
if (typeof(fragment) === "string") {
|
||||
try {
|
||||
fragment = this.getFunction(fragment);
|
||||
} catch (error) {
|
||||
try {
|
||||
fragment = this.getError(<string>fragment);
|
||||
} catch (_) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getStatic<(f: FunctionFragment) => string>(this.constructor, "getSighash")(functionFragment);
|
||||
return getStatic<(f: ErrorFragment | FunctionFragment) => string>(this.constructor, "getSighash")(fragment);
|
||||
}
|
||||
|
||||
// Get the topic (the bytes32 hash) used by Solidity to identify an event
|
||||
@@ -313,6 +329,31 @@ export class Interface {
|
||||
return this._encodeParams(this.deploy.inputs, values || [ ]);
|
||||
}
|
||||
|
||||
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result {
|
||||
if (typeof(fragment) === "string") {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
|
||||
const bytes = arrayify(data);
|
||||
|
||||
if (hexlify(bytes.slice(0, 4)) !== this.getSighash(fragment)) {
|
||||
logger.throwArgumentError(`data signature does not match error ${ fragment.name }.`, "data", hexlify(bytes));
|
||||
}
|
||||
|
||||
return this._decodeParams(fragment.inputs, bytes.slice(4));
|
||||
}
|
||||
|
||||
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string {
|
||||
if (typeof(fragment) === "string") {
|
||||
fragment = this.getError(fragment);
|
||||
}
|
||||
|
||||
return hexlify(concat([
|
||||
this.getSighash(fragment),
|
||||
this._encodeParams(fragment.inputs, values || [ ])
|
||||
]));
|
||||
}
|
||||
|
||||
// Decode the data for a function call (e.g. tx.data)
|
||||
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result {
|
||||
if (typeof(functionFragment) === "string") {
|
||||
@@ -565,6 +606,7 @@ export class Interface {
|
||||
// Make error named values throw on access
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(result, param.name, {
|
||||
enumerable: true,
|
||||
get: () => { throw wrapAccessError(`property ${ JSON.stringify(param.name) }`, value); }
|
||||
});
|
||||
} else {
|
||||
@@ -578,6 +620,7 @@ export class Interface {
|
||||
const value = result[i];
|
||||
if (value instanceof Error) {
|
||||
Object.defineProperty(result, i, {
|
||||
enumerable: true,
|
||||
get: () => { throw wrapAccessError(`index ${ i }`, value); }
|
||||
});
|
||||
}
|
||||
@@ -627,6 +670,21 @@ export class Interface {
|
||||
});
|
||||
}
|
||||
|
||||
parseError(data: BytesLike): ErrorDescription {
|
||||
const hexData = hexlify(data);
|
||||
let fragment = this.getError(hexData.substring(0, 10).toLowerCase())
|
||||
|
||||
if (!fragment) { return null; }
|
||||
|
||||
return new ErrorDescription({
|
||||
args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)),
|
||||
errorFragment: fragment,
|
||||
name: fragment.name,
|
||||
signature: fragment.format(),
|
||||
sighash: this.getSighash(fragment),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
static from(value: Array<Fragment | string | JsonAbi> | string | Interface) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-provider/5.3.0";
|
||||
export declare const version = "abstract-provider/5.4.1";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abstract-provider/5.3.0";
|
||||
export const version = "abstract-provider/5.4.1";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
11
packages/abstract-provider/lib.esm/index.d.ts
vendored
11
packages/abstract-provider/lib.esm/index.d.ts
vendored
@@ -15,6 +15,8 @@ export declare type TransactionRequest = {
|
||||
chainId?: number;
|
||||
type?: number;
|
||||
accessList?: AccessListish;
|
||||
maxPriorityFeePerGas?: BigNumberish;
|
||||
maxFeePerGas?: BigNumberish;
|
||||
};
|
||||
export interface TransactionResponse extends Transaction {
|
||||
hash: string;
|
||||
@@ -38,6 +40,7 @@ interface _Block {
|
||||
gasUsed: BigNumber;
|
||||
miner: string;
|
||||
extraData: string;
|
||||
baseFeePerGas?: null | BigNumber;
|
||||
}
|
||||
export interface Block extends _Block {
|
||||
transactions: Array<string>;
|
||||
@@ -70,9 +73,16 @@ export interface TransactionReceipt {
|
||||
blockNumber: number;
|
||||
confirmations: number;
|
||||
cumulativeGasUsed: BigNumber;
|
||||
effectiveGasPrice: BigNumber;
|
||||
byzantium: boolean;
|
||||
type: number;
|
||||
status?: number;
|
||||
}
|
||||
export interface FeeData {
|
||||
maxFeePerGas: null | BigNumber;
|
||||
maxPriorityFeePerGas: null | BigNumber;
|
||||
gasPrice: null | BigNumber;
|
||||
}
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
@@ -110,6 +120,7 @@ export declare abstract class Provider implements OnceBlockable {
|
||||
abstract getNetwork(): Promise<Network>;
|
||||
abstract getBlockNumber(): Promise<number>;
|
||||
abstract getGasPrice(): Promise<BigNumber>;
|
||||
getFeeData(): Promise<FeeData>;
|
||||
abstract getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
|
||||
abstract getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
|
||||
abstract getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,16 @@
|
||||
"use strict";
|
||||
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());
|
||||
});
|
||||
};
|
||||
import { BigNumber } from "@ethersproject/bignumber";
|
||||
import { isHexString } from "@ethersproject/bytes";
|
||||
import { Description, defineReadOnly } from "@ethersproject/properties";
|
||||
import { Description, defineReadOnly, resolveProperties } from "@ethersproject/properties";
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
const logger = new Logger(version);
|
||||
@@ -64,6 +74,27 @@ export class Provider {
|
||||
logger.checkAbstract(new.target, Provider);
|
||||
defineReadOnly(this, "_isProvider", true);
|
||||
}
|
||||
getFeeData() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { block, gasPrice } = yield resolveProperties({
|
||||
block: this.getBlock("latest"),
|
||||
gasPrice: this.getGasPrice().catch((error) => {
|
||||
// @TODO: Why is this now failing on Calaveras?
|
||||
//console.log(error);
|
||||
return null;
|
||||
})
|
||||
});
|
||||
let maxFeePerGas = null, maxPriorityFeePerGas = null;
|
||||
if (block && block.baseFeePerGas) {
|
||||
// We may want to compute this more accurately in the future,
|
||||
// using the formula "check if the base fee is correct".
|
||||
// See: https://eips.ethereum.org/EIPS/eip-1559
|
||||
maxPriorityFeePerGas = BigNumber.from("2500000000");
|
||||
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
||||
}
|
||||
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice };
|
||||
});
|
||||
}
|
||||
// Alias for "on"
|
||||
addListener(eventName, listener) {
|
||||
return this.on(eventName, listener);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAa,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAc,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIpF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAwClC,CAAC;AA6DD,CAAC;AAgBF,qCAAqC;AACrC,0EAA0E;AAC1E,IAAI;AAEJ,MAAM,OAAgB,SAAU,SAAQ,WAAW;IAK/C,MAAM,CAAC,WAAW,CAAC,KAAU;QACzB,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;CACJ;AAED,MAAM,OAAO,cAAe,SAAQ,SAAS;IAKzC,YAAY,SAAiB,EAAE,MAAe;QAC1C,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE;YAC7B,MAAM,CAAC,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ClB,cAAc,CAAC,SAAoB,EAAE,QAAkB;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IAYD,MAAM,CAAC,UAAU,CAAC,KAAU;QACxB,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;CAyCJ"}
|
||||
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.3.0";
|
||||
export declare const version = "abstract-provider/5.4.1";
|
||||
//# 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.3.0";
|
||||
exports.version = "abstract-provider/5.4.1";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
11
packages/abstract-provider/lib/index.d.ts
vendored
11
packages/abstract-provider/lib/index.d.ts
vendored
@@ -15,6 +15,8 @@ export declare type TransactionRequest = {
|
||||
chainId?: number;
|
||||
type?: number;
|
||||
accessList?: AccessListish;
|
||||
maxPriorityFeePerGas?: BigNumberish;
|
||||
maxFeePerGas?: BigNumberish;
|
||||
};
|
||||
export interface TransactionResponse extends Transaction {
|
||||
hash: string;
|
||||
@@ -38,6 +40,7 @@ interface _Block {
|
||||
gasUsed: BigNumber;
|
||||
miner: string;
|
||||
extraData: string;
|
||||
baseFeePerGas?: null | BigNumber;
|
||||
}
|
||||
export interface Block extends _Block {
|
||||
transactions: Array<string>;
|
||||
@@ -70,9 +73,16 @@ export interface TransactionReceipt {
|
||||
blockNumber: number;
|
||||
confirmations: number;
|
||||
cumulativeGasUsed: BigNumber;
|
||||
effectiveGasPrice: BigNumber;
|
||||
byzantium: boolean;
|
||||
type: number;
|
||||
status?: number;
|
||||
}
|
||||
export interface FeeData {
|
||||
maxFeePerGas: null | BigNumber;
|
||||
maxPriorityFeePerGas: null | BigNumber;
|
||||
gasPrice: null | BigNumber;
|
||||
}
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
@@ -110,6 +120,7 @@ export declare abstract class Provider implements OnceBlockable {
|
||||
abstract getNetwork(): Promise<Network>;
|
||||
abstract getBlockNumber(): Promise<number>;
|
||||
abstract getGasPrice(): Promise<BigNumber>;
|
||||
getFeeData(): Promise<FeeData>;
|
||||
abstract getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
|
||||
abstract getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
|
||||
abstract getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -14,8 +14,45 @@ var __extends = (this && this.__extends) || (function () {
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Provider = exports.TransactionOrderForkEvent = exports.TransactionForkEvent = exports.BlockForkEvent = exports.ForkEvent = void 0;
|
||||
var bignumber_1 = require("@ethersproject/bignumber");
|
||||
var bytes_1 = require("@ethersproject/bytes");
|
||||
var properties_1 = require("@ethersproject/properties");
|
||||
var logger_1 = require("@ethersproject/logger");
|
||||
@@ -103,6 +140,34 @@ var Provider = /** @class */ (function () {
|
||||
logger.checkAbstract(_newTarget, Provider);
|
||||
properties_1.defineReadOnly(this, "_isProvider", true);
|
||||
}
|
||||
Provider.prototype.getFeeData = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, block, gasPrice, maxFeePerGas, maxPriorityFeePerGas;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0: return [4 /*yield*/, properties_1.resolveProperties({
|
||||
block: this.getBlock("latest"),
|
||||
gasPrice: this.getGasPrice().catch(function (error) {
|
||||
// @TODO: Why is this now failing on Calaveras?
|
||||
//console.log(error);
|
||||
return null;
|
||||
})
|
||||
})];
|
||||
case 1:
|
||||
_a = _b.sent(), block = _a.block, gasPrice = _a.gasPrice;
|
||||
maxFeePerGas = null, maxPriorityFeePerGas = null;
|
||||
if (block && block.baseFeePerGas) {
|
||||
// We may want to compute this more accurately in the future,
|
||||
// using the formula "check if the base fee is correct".
|
||||
// See: https://eips.ethereum.org/EIPS/eip-1559
|
||||
maxPriorityFeePerGas = bignumber_1.BigNumber.from("2500000000");
|
||||
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
||||
}
|
||||
return [2 /*return*/, { maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas, gasPrice: gasPrice }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
// Alias for "on"
|
||||
Provider.prototype.addListener = function (eventName, listener) {
|
||||
return this.on(eventName, listener);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;AAGb,8CAA8D;AAE9D,wDAAoF;AAIpF,gDAA+C;AAC/C,uCAAqC;AACrC,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAO,CAAC,CAAC;AAwClC,CAAC;AA6DD,CAAC;AAgBF,qCAAqC;AACrC,0EAA0E;AAC1E,IAAI;AAEJ;IAAwC,6BAAW;IAAnD;;IAQA,CAAC;IAHU,qBAAW,GAAlB,UAAmB,KAA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,WAAA,EAAE,QAAQ,cAAA;wBASnB,YAAY,GAAG,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;wBAErD,IAAI,KAAK,IAAI,KAAK,CAAC,aAAa,EAAE;4BAC9B,6DAA6D;4BAC7D,wDAAwD;4BACxD,+CAA+C;4BAC/C,oBAAoB,GAAG,qBAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;4BACpD,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;yBACvE;wBAED,sBAAO,EAAE,YAAY,cAAA,EAAE,oBAAoB,sBAAA,EAAE,QAAQ,UAAA,EAAE,EAAC;;;;KAC3D;IAmCD,iBAAiB;IACjB,8BAAW,GAAX,UAAY,SAAoB,EAAE,QAAkB;QAChD,OAAO,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,kBAAkB;IAClB,iCAAc,GAAd,UAAe,SAAoB,EAAE,QAAkB;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IAYM,mBAAU,GAAjB,UAAkB,KAAU;QACxB,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IAyCL,eAAC;AAAD,CAAC,AA/HD,IA+HC;AA/HqB,4BAAQ"}
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bignumber": "^5.3.0",
|
||||
"@ethersproject/bytes": "^5.3.0",
|
||||
"@ethersproject/logger": "^5.3.0",
|
||||
"@ethersproject/networks": "^5.3.0",
|
||||
"@ethersproject/properties": "^5.3.0",
|
||||
"@ethersproject/transactions": "^5.3.0",
|
||||
"@ethersproject/web": "^5.3.0"
|
||||
"@ethersproject/bignumber": "^5.4.0",
|
||||
"@ethersproject/bytes": "^5.4.0",
|
||||
"@ethersproject/logger": "^5.4.0",
|
||||
"@ethersproject/networks": "^5.4.0",
|
||||
"@ethersproject/properties": "^5.4.0",
|
||||
"@ethersproject/transactions": "^5.4.0",
|
||||
"@ethersproject/web": "^5.4.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": "0xbe087cfc8ee43f3154f8006b382424ca7394b04d34fc089372ade08ba9cb65b6",
|
||||
"tarballHash": "0x98d00d08cd419d97002adac0ea555bb5e5c98a1221c71480d168ac666b1c01fb",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.3.0"
|
||||
"version": "5.4.1"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abstract-provider/5.3.0";
|
||||
export const version = "abstract-provider/5.4.1";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
|
||||
import { BytesLike, isHexString } from "@ethersproject/bytes";
|
||||
import { Network } from "@ethersproject/networks";
|
||||
import { Deferrable, Description, defineReadOnly } from "@ethersproject/properties";
|
||||
import { Deferrable, Description, defineReadOnly, resolveProperties } from "@ethersproject/properties";
|
||||
import { AccessListish, Transaction } from "@ethersproject/transactions";
|
||||
import { OnceBlockable } from "@ethersproject/web";
|
||||
|
||||
@@ -29,6 +29,9 @@ export type TransactionRequest = {
|
||||
|
||||
type?: number;
|
||||
accessList?: AccessListish;
|
||||
|
||||
maxPriorityFeePerGas?: BigNumberish;
|
||||
maxFeePerGas?: BigNumberish;
|
||||
}
|
||||
|
||||
export interface TransactionResponse extends Transaction {
|
||||
@@ -67,6 +70,8 @@ interface _Block {
|
||||
|
||||
miner: string;
|
||||
extraData: string;
|
||||
|
||||
baseFeePerGas?: null | BigNumber;
|
||||
}
|
||||
|
||||
export interface Block extends _Block {
|
||||
@@ -108,10 +113,18 @@ export interface TransactionReceipt {
|
||||
blockNumber: number,
|
||||
confirmations: number,
|
||||
cumulativeGasUsed: BigNumber,
|
||||
effectiveGasPrice: BigNumber,
|
||||
byzantium: boolean,
|
||||
type: number;
|
||||
status?: number
|
||||
};
|
||||
|
||||
export interface FeeData {
|
||||
maxFeePerGas: null | BigNumber;
|
||||
maxPriorityFeePerGas: null | BigNumber;
|
||||
gasPrice: null | BigNumber;
|
||||
}
|
||||
|
||||
export interface EventFilter {
|
||||
address?: string;
|
||||
topics?: Array<string | Array<string> | null>;
|
||||
@@ -206,7 +219,6 @@ export type Listener = (...args: Array<any>) => void;
|
||||
|
||||
///////////////////////////////
|
||||
// Exported Abstracts
|
||||
|
||||
export abstract class Provider implements OnceBlockable {
|
||||
|
||||
// Network
|
||||
@@ -215,6 +227,28 @@ export abstract class Provider implements OnceBlockable {
|
||||
// Latest State
|
||||
abstract getBlockNumber(): Promise<number>;
|
||||
abstract getGasPrice(): Promise<BigNumber>;
|
||||
async getFeeData(): Promise<FeeData> {
|
||||
const { block, gasPrice } = await resolveProperties({
|
||||
block: this.getBlock("latest"),
|
||||
gasPrice: this.getGasPrice().catch((error) => {
|
||||
// @TODO: Why is this now failing on Calaveras?
|
||||
//console.log(error);
|
||||
return null;
|
||||
})
|
||||
});
|
||||
|
||||
let maxFeePerGas = null, maxPriorityFeePerGas = null;
|
||||
|
||||
if (block && block.baseFeePerGas) {
|
||||
// We may want to compute this more accurately in the future,
|
||||
// using the formula "check if the base fee is correct".
|
||||
// See: https://eips.ethereum.org/EIPS/eip-1559
|
||||
maxPriorityFeePerGas = BigNumber.from("2500000000");
|
||||
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
||||
}
|
||||
|
||||
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice };
|
||||
}
|
||||
|
||||
// Account
|
||||
abstract getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export declare const version = "abstract-signer/5.3.0";
|
||||
export declare const version = "abstract-signer/5.4.1";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "abstract-signer/5.3.0";
|
||||
export const version = "abstract-signer/5.4.1";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
3
packages/abstract-signer/lib.esm/index.d.ts
vendored
3
packages/abstract-signer/lib.esm/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { BlockTag, FeeData, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
|
||||
import { Bytes, BytesLike } from "@ethersproject/bytes";
|
||||
import { Deferrable } from "@ethersproject/properties";
|
||||
@@ -35,6 +35,7 @@ export declare abstract class Signer {
|
||||
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
||||
getChainId(): Promise<number>;
|
||||
getGasPrice(): Promise<BigNumber>;
|
||||
getFeeData(): Promise<FeeData>;
|
||||
resolveName(name: string): Promise<string>;
|
||||
checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
|
||||
populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE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CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAmCvF,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoInG,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAMxC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM;CAG/C;AAED,qBAAa,UAAW,SAAQ,MAAO,YAAW,eAAe;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAOhD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAMvD,WAAW,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7E,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlI,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU;CAG1C"}
|
||||
@@ -13,7 +13,7 @@ import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
const logger = new Logger(version);
|
||||
const allowedTransactionKeys = [
|
||||
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "type", "value"
|
||||
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
|
||||
];
|
||||
const forwardErrors = [
|
||||
Logger.errors.INSUFFICIENT_FUNDS,
|
||||
@@ -61,11 +61,11 @@ export class Signer {
|
||||
}
|
||||
// Populates all fields in a transaction, signs it and sends it to the network
|
||||
sendTransaction(transaction) {
|
||||
this._checkProvider("sendTransaction");
|
||||
return this.populateTransaction(transaction).then((tx) => {
|
||||
return this.signTransaction(tx).then((signedTx) => {
|
||||
return this.provider.sendTransaction(signedTx);
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this._checkProvider("sendTransaction");
|
||||
const tx = yield this.populateTransaction(transaction);
|
||||
const signedTx = yield this.signTransaction(tx);
|
||||
return yield this.provider.sendTransaction(signedTx);
|
||||
});
|
||||
}
|
||||
getChainId() {
|
||||
@@ -81,6 +81,12 @@ export class Signer {
|
||||
return yield this.provider.getGasPrice();
|
||||
});
|
||||
}
|
||||
getFeeData() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this._checkProvider("getFeeData");
|
||||
return yield this.provider.getFeeData();
|
||||
});
|
||||
}
|
||||
resolveName(name) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this._checkProvider("resolveName");
|
||||
@@ -124,6 +130,9 @@ export class Signer {
|
||||
// this Signer. Should be used by sendTransaction but NOT by signTransaction.
|
||||
// By default called from: (overriding these prevents it)
|
||||
// - sendTransaction
|
||||
//
|
||||
// Notes:
|
||||
// - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
|
||||
populateTransaction(transaction) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const tx = yield resolveProperties(this.checkTransaction(transaction));
|
||||
@@ -138,9 +147,87 @@ export class Signer {
|
||||
}
|
||||
return address;
|
||||
}));
|
||||
// Prevent this error from causing an UnhandledPromiseException
|
||||
tx.to.catch((error) => { });
|
||||
}
|
||||
if (tx.gasPrice == null) {
|
||||
tx.gasPrice = this.getGasPrice();
|
||||
// Do not allow mixing pre-eip-1559 and eip-1559 proerties
|
||||
const hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
|
||||
if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
|
||||
logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
|
||||
}
|
||||
else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
|
||||
logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
|
||||
}
|
||||
if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) {
|
||||
// Fully-formed EIP-1559 transaction (skip getFeeData)
|
||||
tx.type = 2;
|
||||
}
|
||||
else if (tx.type === 0 || tx.type === 1) {
|
||||
// Explicit Legacy or EIP-2930 transaction
|
||||
// Populate missing gasPrice
|
||||
if (tx.gasPrice == null) {
|
||||
tx.gasPrice = this.getGasPrice();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We need to get fee data to determine things
|
||||
const feeData = yield this.getFeeData();
|
||||
if (tx.type == null) {
|
||||
// We need to auto-detect the intended type of this transaction...
|
||||
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
|
||||
// The network supports EIP-1559!
|
||||
// Upgrade transaction from null to eip-1559
|
||||
tx.type = 2;
|
||||
if (tx.gasPrice != null) {
|
||||
// Using legacy gasPrice property on an eip-1559 network,
|
||||
// so use gasPrice as both fee properties
|
||||
const gasPrice = tx.gasPrice;
|
||||
delete tx.gasPrice;
|
||||
tx.maxFeePerGas = gasPrice;
|
||||
tx.maxPriorityFeePerGas = gasPrice;
|
||||
}
|
||||
else {
|
||||
// Populate missing fee data
|
||||
if (tx.maxFeePerGas == null) {
|
||||
tx.maxFeePerGas = feeData.maxFeePerGas;
|
||||
}
|
||||
if (tx.maxPriorityFeePerGas == null) {
|
||||
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feeData.gasPrice != null) {
|
||||
// Network doesn't support EIP-1559...
|
||||
// ...but they are trying to use EIP-1559 properties
|
||||
if (hasEip1559) {
|
||||
logger.throwError("network does not support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "populateTransaction"
|
||||
});
|
||||
}
|
||||
// Populate missing fee data
|
||||
if (tx.gasPrice == null) {
|
||||
tx.gasPrice = feeData.gasPrice;
|
||||
}
|
||||
// Explicitly set untyped transaction to legacy
|
||||
tx.type = 0;
|
||||
}
|
||||
else {
|
||||
// getFeeData has failed us.
|
||||
logger.throwError("failed to get consistent fee data", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "signer.getFeeData"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (tx.type === 2) {
|
||||
// Explicitly using EIP-1559
|
||||
// Populate missing fee data
|
||||
if (tx.maxFeePerGas == null) {
|
||||
tx.maxFeePerGas = feeData.maxFeePerGas;
|
||||
}
|
||||
if (tx.maxPriorityFeePerGas == null) {
|
||||
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tx.nonce == null) {
|
||||
tx.nonce = this.getTransactionCount("pending");
|
||||
|
||||
File diff suppressed because one or more lines are too long
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.3.0";
|
||||
export declare const version = "abstract-signer/5.4.1";
|
||||
//# 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.3.0";
|
||||
exports.version = "abstract-signer/5.4.1";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
3
packages/abstract-signer/lib/index.d.ts
vendored
3
packages/abstract-signer/lib/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { BlockTag, FeeData, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
|
||||
import { Bytes, BytesLike } from "@ethersproject/bytes";
|
||||
import { Deferrable } from "@ethersproject/properties";
|
||||
@@ -35,6 +35,7 @@ export declare abstract class Signer {
|
||||
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
||||
getChainId(): Promise<number>;
|
||||
getGasPrice(): Promise<BigNumber>;
|
||||
getFeeData(): Promise<FeeData>;
|
||||
resolveName(name: string): Promise<string>;
|
||||
checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
|
||||
populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src.ts/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAkD,MAAM,2BAA2B,CAAC;AAmBvG,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAID,MAAM,WA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AAQ,CAAC,EAAE,QAAQ;IAOhD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAMvD,WAAW,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7E,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlI,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU;CAG1C"}
|
||||
@@ -57,7 +57,7 @@ var logger_1 = require("@ethersproject/logger");
|
||||
var _version_1 = require("./_version");
|
||||
var logger = new logger_1.Logger(_version_1.version);
|
||||
var allowedTransactionKeys = [
|
||||
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "type", "value"
|
||||
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
|
||||
];
|
||||
var forwardErrors = [
|
||||
logger_1.Logger.errors.INSUFFICIENT_FUNDS,
|
||||
@@ -136,11 +136,21 @@ var Signer = /** @class */ (function () {
|
||||
};
|
||||
// Populates all fields in a transaction, signs it and sends it to the network
|
||||
Signer.prototype.sendTransaction = function (transaction) {
|
||||
var _this = this;
|
||||
this._checkProvider("sendTransaction");
|
||||
return this.populateTransaction(transaction).then(function (tx) {
|
||||
return _this.signTransaction(tx).then(function (signedTx) {
|
||||
return _this.provider.sendTransaction(signedTx);
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var tx, signedTx;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
this._checkProvider("sendTransaction");
|
||||
return [4 /*yield*/, this.populateTransaction(transaction)];
|
||||
case 1:
|
||||
tx = _a.sent();
|
||||
return [4 /*yield*/, this.signTransaction(tx)];
|
||||
case 2:
|
||||
signedTx = _a.sent();
|
||||
return [4 /*yield*/, this.provider.sendTransaction(signedTx)];
|
||||
case 3: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -171,6 +181,18 @@ var Signer = /** @class */ (function () {
|
||||
});
|
||||
});
|
||||
};
|
||||
Signer.prototype.getFeeData = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
this._checkProvider("getFeeData");
|
||||
return [4 /*yield*/, this.provider.getFeeData()];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Signer.prototype.resolveName = function (name) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
@@ -220,9 +242,12 @@ var Signer = /** @class */ (function () {
|
||||
// this Signer. Should be used by sendTransaction but NOT by signTransaction.
|
||||
// By default called from: (overriding these prevents it)
|
||||
// - sendTransaction
|
||||
//
|
||||
// Notes:
|
||||
// - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
|
||||
Signer.prototype.populateTransaction = function (transaction) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var tx;
|
||||
var tx, hasEip1559, feeData, gasPrice;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
@@ -248,10 +273,87 @@ var Signer = /** @class */ (function () {
|
||||
}
|
||||
});
|
||||
}); });
|
||||
// Prevent this error from causing an UnhandledPromiseException
|
||||
tx.to.catch(function (error) { });
|
||||
}
|
||||
hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
|
||||
if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
|
||||
logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
|
||||
}
|
||||
else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
|
||||
logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
|
||||
}
|
||||
if (!((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null))) return [3 /*break*/, 2];
|
||||
// Fully-formed EIP-1559 transaction (skip getFeeData)
|
||||
tx.type = 2;
|
||||
return [3 /*break*/, 5];
|
||||
case 2:
|
||||
if (!(tx.type === 0 || tx.type === 1)) return [3 /*break*/, 3];
|
||||
// Explicit Legacy or EIP-2930 transaction
|
||||
// Populate missing gasPrice
|
||||
if (tx.gasPrice == null) {
|
||||
tx.gasPrice = this.getGasPrice();
|
||||
}
|
||||
return [3 /*break*/, 5];
|
||||
case 3: return [4 /*yield*/, this.getFeeData()];
|
||||
case 4:
|
||||
feeData = _a.sent();
|
||||
if (tx.type == null) {
|
||||
// We need to auto-detect the intended type of this transaction...
|
||||
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
|
||||
// The network supports EIP-1559!
|
||||
// Upgrade transaction from null to eip-1559
|
||||
tx.type = 2;
|
||||
if (tx.gasPrice != null) {
|
||||
gasPrice = tx.gasPrice;
|
||||
delete tx.gasPrice;
|
||||
tx.maxFeePerGas = gasPrice;
|
||||
tx.maxPriorityFeePerGas = gasPrice;
|
||||
}
|
||||
else {
|
||||
// Populate missing fee data
|
||||
if (tx.maxFeePerGas == null) {
|
||||
tx.maxFeePerGas = feeData.maxFeePerGas;
|
||||
}
|
||||
if (tx.maxPriorityFeePerGas == null) {
|
||||
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (feeData.gasPrice != null) {
|
||||
// Network doesn't support EIP-1559...
|
||||
// ...but they are trying to use EIP-1559 properties
|
||||
if (hasEip1559) {
|
||||
logger.throwError("network does not support EIP-1559", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "populateTransaction"
|
||||
});
|
||||
}
|
||||
// Populate missing fee data
|
||||
if (tx.gasPrice == null) {
|
||||
tx.gasPrice = feeData.gasPrice;
|
||||
}
|
||||
// Explicitly set untyped transaction to legacy
|
||||
tx.type = 0;
|
||||
}
|
||||
else {
|
||||
// getFeeData has failed us.
|
||||
logger.throwError("failed to get consistent fee data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "signer.getFeeData"
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (tx.type === 2) {
|
||||
// Explicitly using EIP-1559
|
||||
// Populate missing fee data
|
||||
if (tx.maxFeePerGas == null) {
|
||||
tx.maxFeePerGas = feeData.maxFeePerGas;
|
||||
}
|
||||
if (tx.maxPriorityFeePerGas == null) {
|
||||
tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
||||
}
|
||||
}
|
||||
_a.label = 5;
|
||||
case 5:
|
||||
if (tx.nonce == null) {
|
||||
tx.nonce = this.getTransactionCount("pending");
|
||||
}
|
||||
@@ -281,7 +383,7 @@ var Signer = /** @class */ (function () {
|
||||
});
|
||||
}
|
||||
return [4 /*yield*/, properties_1.resolveProperties(tx)];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
case 6: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/abstract-provider": "^5.3.0",
|
||||
"@ethersproject/bignumber": "^5.3.0",
|
||||
"@ethersproject/bytes": "^5.3.0",
|
||||
"@ethersproject/logger": "^5.3.0",
|
||||
"@ethersproject/properties": "^5.3.0"
|
||||
"@ethersproject/abstract-provider": "^5.4.0",
|
||||
"@ethersproject/bignumber": "^5.4.0",
|
||||
"@ethersproject/bytes": "^5.4.0",
|
||||
"@ethersproject/logger": "^5.4.0",
|
||||
"@ethersproject/properties": "^5.4.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": "0x2123b325684a93493b8ba0e346cd2e9c4bc8aa2137c217ab428e6069b86d8885",
|
||||
"tarballHash": "0xd92a067be6d0ada9205b48af7af6806d0d3d5e2f876276e48ef3c552837116d8",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.3.0"
|
||||
"version": "5.4.1"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "abstract-signer/5.3.0";
|
||||
export const version = "abstract-signer/5.4.1";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { BlockTag, FeeData, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
|
||||
import { Bytes, BytesLike } from "@ethersproject/bytes";
|
||||
import { Deferrable, defineReadOnly, resolveProperties, shallowCopy } from "@ethersproject/properties";
|
||||
@@ -10,7 +10,7 @@ import { version } from "./_version";
|
||||
const logger = new Logger(version);
|
||||
|
||||
const allowedTransactionKeys: Array<string> = [
|
||||
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "type", "value"
|
||||
"accessList", "chainId", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
|
||||
];
|
||||
|
||||
const forwardErrors = [
|
||||
@@ -119,13 +119,11 @@ export abstract class Signer {
|
||||
}
|
||||
|
||||
// Populates all fields in a transaction, signs it and sends it to the network
|
||||
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
|
||||
async sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse> {
|
||||
this._checkProvider("sendTransaction");
|
||||
return this.populateTransaction(transaction).then((tx) => {
|
||||
return this.signTransaction(tx).then((signedTx) => {
|
||||
return this.provider.sendTransaction(signedTx);
|
||||
});
|
||||
});
|
||||
const tx = await this.populateTransaction(transaction);
|
||||
const signedTx = await this.signTransaction(tx);
|
||||
return await this.provider.sendTransaction(signedTx);
|
||||
}
|
||||
|
||||
async getChainId(): Promise<number> {
|
||||
@@ -139,6 +137,12 @@ export abstract class Signer {
|
||||
return await this.provider.getGasPrice();
|
||||
}
|
||||
|
||||
async getFeeData(): Promise<FeeData> {
|
||||
this._checkProvider("getFeeData");
|
||||
return await this.provider.getFeeData();
|
||||
}
|
||||
|
||||
|
||||
async resolveName(name: string): Promise<string> {
|
||||
this._checkProvider("resolveName");
|
||||
return await this.provider.resolveName(name);
|
||||
@@ -146,7 +150,6 @@ export abstract class Signer {
|
||||
|
||||
|
||||
|
||||
|
||||
// Checks a transaction does not contain invalid keys and if
|
||||
// no "from" is provided, populates it.
|
||||
// - does NOT require a provider
|
||||
@@ -167,6 +170,7 @@ export abstract class Signer {
|
||||
|
||||
if (tx.from == null) {
|
||||
tx.from = this.getAddress();
|
||||
|
||||
} else {
|
||||
// Make sure any provided address matches this signer
|
||||
tx.from = Promise.all([
|
||||
@@ -187,6 +191,9 @@ export abstract class Signer {
|
||||
// this Signer. Should be used by sendTransaction but NOT by signTransaction.
|
||||
// By default called from: (overriding these prevents it)
|
||||
// - sendTransaction
|
||||
//
|
||||
// Notes:
|
||||
// - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
|
||||
async populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest> {
|
||||
|
||||
const tx: Deferrable<TransactionRequest> = await resolveProperties(this.checkTransaction(transaction))
|
||||
@@ -200,8 +207,89 @@ export abstract class Signer {
|
||||
}
|
||||
return address;
|
||||
});
|
||||
|
||||
// Prevent this error from causing an UnhandledPromiseException
|
||||
tx.to.catch((error) => { });
|
||||
}
|
||||
if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); }
|
||||
|
||||
// Do not allow mixing pre-eip-1559 and eip-1559 proerties
|
||||
const hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
|
||||
if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
|
||||
logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
|
||||
} else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
|
||||
logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
|
||||
}
|
||||
|
||||
if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) {
|
||||
// Fully-formed EIP-1559 transaction (skip getFeeData)
|
||||
tx.type = 2;
|
||||
|
||||
} else if (tx.type === 0 || tx.type === 1) {
|
||||
// Explicit Legacy or EIP-2930 transaction
|
||||
|
||||
// Populate missing gasPrice
|
||||
if (tx.gasPrice == null) { tx.gasPrice = this.getGasPrice(); }
|
||||
|
||||
} else {
|
||||
|
||||
// We need to get fee data to determine things
|
||||
const feeData = await this.getFeeData();
|
||||
|
||||
if (tx.type == null) {
|
||||
// We need to auto-detect the intended type of this transaction...
|
||||
|
||||
if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
|
||||
// The network supports EIP-1559!
|
||||
|
||||
// Upgrade transaction from null to eip-1559
|
||||
tx.type = 2;
|
||||
|
||||
if (tx.gasPrice != null) {
|
||||
// Using legacy gasPrice property on an eip-1559 network,
|
||||
// so use gasPrice as both fee properties
|
||||
const gasPrice = tx.gasPrice;
|
||||
delete tx.gasPrice;
|
||||
tx.maxFeePerGas = gasPrice;
|
||||
tx.maxPriorityFeePerGas = gasPrice;
|
||||
|
||||
} else {
|
||||
// Populate missing fee data
|
||||
if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; }
|
||||
if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; }
|
||||
}
|
||||
|
||||
} else if (feeData.gasPrice != null) {
|
||||
// Network doesn't support EIP-1559...
|
||||
|
||||
// ...but they are trying to use EIP-1559 properties
|
||||
if (hasEip1559) {
|
||||
logger.throwError("network does not support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "populateTransaction"
|
||||
});
|
||||
}
|
||||
|
||||
// Populate missing fee data
|
||||
if (tx.gasPrice == null) { tx.gasPrice = feeData.gasPrice; }
|
||||
|
||||
// Explicitly set untyped transaction to legacy
|
||||
tx.type = 0;
|
||||
|
||||
} else {
|
||||
// getFeeData has failed us.
|
||||
logger.throwError("failed to get consistent fee data", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "signer.getFeeData"
|
||||
});
|
||||
}
|
||||
|
||||
} else if (tx.type === 2) {
|
||||
// Explicitly using EIP-1559
|
||||
|
||||
// Populate missing fee data
|
||||
if (tx.maxFeePerGas == null) { tx.maxFeePerGas = feeData.maxFeePerGas; }
|
||||
if (tx.maxPriorityFeePerGas == null) { tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; }
|
||||
}
|
||||
}
|
||||
|
||||
if (tx.nonce == null) { tx.nonce = this.getTransactionCount("pending"); }
|
||||
|
||||
if (tx.gasLimit == null) {
|
||||
|
||||
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.3.0";
|
||||
export declare const version = "address/5.4.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "address/5.3.0";
|
||||
export const version = "address/5.4.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.3.0";
|
||||
export declare const version = "address/5.4.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "address/5.3.0";
|
||||
exports.version = "address/5.4.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"@ethersproject/bignumber": "^5.3.0",
|
||||
"@ethersproject/bytes": "^5.3.0",
|
||||
"@ethersproject/keccak256": "^5.3.0",
|
||||
"@ethersproject/logger": "^5.3.0",
|
||||
"@ethersproject/rlp": "^5.3.0"
|
||||
"@ethersproject/bignumber": "^5.4.0",
|
||||
"@ethersproject/bytes": "^5.4.0",
|
||||
"@ethersproject/keccak256": "^5.4.0",
|
||||
"@ethersproject/logger": "^5.4.0",
|
||||
"@ethersproject/rlp": "^5.4.0"
|
||||
},
|
||||
"description": "Utilities for handling Ethereum Addresses for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -39,7 +39,7 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"tarballHash": "0xa82e0a824c8508389be5bde68ac614fa98c1c867708e80c406b050ea75d12ad3",
|
||||
"tarballHash": "0x34f21682ba69ffb63020bff0089880feb53b731ba1e6616f551621c6bb194261",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.3.0"
|
||||
"version": "5.4.0"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "address/5.3.0";
|
||||
export const version = "address/5.4.0";
|
||||
|
||||
2
packages/asm/lib.esm/_version.d.ts
vendored
2
packages/asm/lib.esm/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "asm/5.3.0";
|
||||
export declare const version = "asm/5.4.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,2 +1,2 @@
|
||||
export const version = "asm/5.3.0";
|
||||
export const version = "asm/5.4.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
2
packages/asm/lib/_version.d.ts
vendored
2
packages/asm/lib/_version.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
export declare const version = "asm/5.3.0";
|
||||
export declare const version = "asm/5.4.0";
|
||||
//# sourceMappingURL=_version.d.ts.map
|
||||
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = "asm/5.3.0";
|
||||
exports.version = "asm/5.4.0";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"author": "Richard Moore <me@ricmoo.com>",
|
||||
"dependencies": {
|
||||
"ethers": "^5.3.0"
|
||||
"ethers": "^5.4.0"
|
||||
},
|
||||
"description": "ASM libraries and tools for the Ethereum EVM.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
@@ -36,7 +36,7 @@
|
||||
"generate": "node ./generate.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0xc19d11fdfbed4b581cab4b18a2f9c6e1b14e961fc6b80862b6b2eb48565ea394",
|
||||
"tarballHash": "0xc74c9dbccf069a9dc15198a6422d792f252651cf607a29c5affc9e0e8e9fb408",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.3.0"
|
||||
"version": "5.4.0"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user