Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cb418cf7d | ||
|
|
8e4ee887b9 | ||
|
|
ef09361539 | ||
|
|
6e36447aa0 | ||
|
|
1c4259881a | ||
|
|
ba00df1ab7 | ||
|
|
45a2902874 | ||
|
|
211defa27f | ||
|
|
bdc6df4b8b | ||
|
|
799896ac13 | ||
|
|
8b54f7ff23 | ||
|
|
2cf462c571 | ||
|
|
1f6646e131 | ||
|
|
e6a52b309b | ||
|
|
fb808d1362 | ||
|
|
fd2882d088 | ||
|
|
a8e3380ed5 | ||
|
|
7f775f7ad6 | ||
|
|
d122d18cfa | ||
|
|
34488cd7d8 | ||
|
|
95e2871966 | ||
|
|
4a8d579dca | ||
|
|
fbbe4ad638 | ||
|
|
20defec9f1 | ||
|
|
c8bb77d8af | ||
|
|
29f6c34343 | ||
|
|
a185e89181 | ||
|
|
c9e548071e | ||
|
|
62c7195ed6 | ||
|
|
cc63e61f73 | ||
|
|
2816850716 | ||
|
|
4b7028a661 | ||
|
|
0382faebb1 | ||
|
|
97efeba8dc | ||
|
|
cddc258c96 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
custom: [ 'https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2', 'https://www.buymeacoffee.com/ricmoo' ]
|
||||
21
.github/workflows/nodejs.yml
vendored
21
.github/workflows/nodejs.yml
vendored
@@ -9,7 +9,8 @@ jobs:
|
||||
|
||||
test-node:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
# runs-on: ubuntu-latest
|
||||
runs-on: macos-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -25,8 +26,8 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node-hid requirements
|
||||
run: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
|
||||
# - name: Install node-hid requirements
|
||||
# run: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
|
||||
|
||||
- name: Install dependencies (and link per package)
|
||||
run: npm ci
|
||||
@@ -40,7 +41,8 @@ jobs:
|
||||
|
||||
test-browser:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
# runs-on: ubuntu-latest
|
||||
runs-on: macos-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -55,8 +57,8 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node-hid requirements
|
||||
run: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
|
||||
# - name: Install node-hid requirements
|
||||
# run: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
|
||||
|
||||
- name: Install dependencies (and link per package)
|
||||
run: npm ci
|
||||
@@ -100,7 +102,8 @@ jobs:
|
||||
|
||||
name: Coverage
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
# runs-on: ubuntu-latest
|
||||
runs-on: macos-latest
|
||||
|
||||
continue-on-error: true
|
||||
|
||||
@@ -112,8 +115,8 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node-hid requirements
|
||||
run: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
|
||||
# - name: Install node-hid requirements
|
||||
# run: sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev libudev-dev
|
||||
|
||||
- name: Install dependencies (and link per package)
|
||||
run: npm ci
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -25,3 +25,5 @@ packages/testcases/input/nameprep/**
|
||||
.nyc_output/**
|
||||
|
||||
output/**
|
||||
|
||||
misc/testing/**
|
||||
|
||||
23
CHANGELOG.md
23
CHANGELOG.md
@@ -3,6 +3,29 @@ Changelog
|
||||
|
||||
This change log is managed by `admin/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.0.23 (2020-11-25 15:25)
|
||||
---------------------------------
|
||||
|
||||
- Fix BigNumber when passed something with a length property. ([#1172](https://github.com/ethers-io/ethers.js/issues/1172); [45a2902](https://github.com/ethers-io/ethers.js/commit/45a2902874e828a16396a253548bcb00bceccf95))
|
||||
|
||||
ethers/v5.0.22 (2020-11-23 19:16)
|
||||
---------------------------------
|
||||
|
||||
- Added directory to repo field for each package. ([799896a](https://github.com/ethers-io/ethers.js/commit/799896ac13cce857ce0124d2fb480f5d1eed114c))
|
||||
- Add ABI coder function to compute default values. ([#1101](https://github.com/ethers-io/ethers.js/issues/1101); [a8e3380](https://github.com/ethers-io/ethers.js/commit/a8e3380ed547b6368be5fe40b48be6e31b5cdd93))
|
||||
- Fix for new versions of Geth which return formatted data on revert rather than standard data. ([#949](https://github.com/ethers-io/ethers.js/issues/949); [4a8d579](https://github.com/ethers-io/ethers.js/commit/4a8d579dcaf026d0c232e20176605d34cba4767d))
|
||||
- Addd missing sideEffects flag to some packages. ([20defec](https://github.com/ethers-io/ethers.js/commit/20defec9f1683487b6ea9c8730d2ab7b3745bfa5))
|
||||
- Allow base-10 to be passed into BigNumbner.toString and improve errors for other radices. ([#1164](https://github.com/ethers-io/ethers.js/issues/1164); [c8bb77d](https://github.com/ethers-io/ethers.js/commit/c8bb77d8af85d2f9f9df82f1afbe7516ab296e98), [fbbe4ad](https://github.com/ethers-io/ethers.js/commit/fbbe4ad638e06089cdd976a7f4ffd51b85a31558))
|
||||
- Allow private keys to Wallet to omit the 0x prefix. ([#1166](https://github.com/ethers-io/ethers.js/issues/1166); [29f6c34](https://github.com/ethers-io/ethers.js/commit/29f6c34343d75fa42023bdcd07632f49a450570c))
|
||||
|
||||
ethers/v5.0.21 (2020-11-19 18:52)
|
||||
---------------------------------
|
||||
|
||||
- Force address to use bignumber package with base36 private functions. ([#1163](https://github.com/ethers-io/ethers.js/issues/1163); [c9e5480](https://github.com/ethers-io/ethers.js/commit/c9e548071e9ed03e3b12f40f0be779c16422a73f))
|
||||
- Remove stray console.log in hardware wallets. ([#1136](https://github.com/ethers-io/ethers.js/issues/1136); [cc63e61](https://github.com/ethers-io/ethers.js/commit/cc63e61f73d530c28655f9421506a25fc0a49df0))
|
||||
- Added some funding links for the sponsor button. ([2816850](https://github.com/ethers-io/ethers.js/commit/2816850716d4bf2b458f1db4e0c7a5dc09fb14f7))
|
||||
- Remove invalid pkg.module reference. ([#1133](https://github.com/ethers-io/ethers.js/issues/1133); [cddc258](https://github.com/ethers-io/ethers.js/commit/cddc258c963ab63de426b89ef190b83aefe6f6cd))
|
||||
|
||||
ethers/v5.0.20 (2020-11-17 20:32)
|
||||
---------------------------------
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ permissions.
|
||||
The ethers library offers default API keys for each service, so that each
|
||||
[[Provider]] works out-of-the-box.
|
||||
|
||||
These API keys are a provided as a community resource by the backend services
|
||||
These API keys are provided as a community resource by the backend services
|
||||
for low-traffic projects and for early prototyping.
|
||||
|
||||
Since these API keys are shared by all users (that have not acquired their
|
||||
@@ -43,7 +43,7 @@ operations required to interact with the Ethereum Blockchain.
|
||||
_subsection: INFURA @<api-keys--infura>
|
||||
|
||||
The INFURA service has been around for quite some time and is very robust
|
||||
and reliable and highly recommend.
|
||||
and reliable and highly recommended.
|
||||
|
||||
They offer a standard JSON-RPC interface and a WebSocket interface, which makes
|
||||
interaction with standard tools versatile, simple and straight forward.
|
||||
@@ -74,6 +74,18 @@ with debugging.
|
||||
- access to advanced token balance and metadata APIs
|
||||
- access to advanced debugging trace and revert reason APIs
|
||||
|
||||
_subsection: Pocket Gateway@<api-keys--pocket-gateway>
|
||||
|
||||
|
||||
[Sign up for a free API key on Pocket](link-pocket-signup)
|
||||
|
||||
**Benefits:**
|
||||
|
||||
- customer usage metrics
|
||||
- decentralized Access to Blockchain Infrastructure
|
||||
- Stake as opposed to paying a monthly fee
|
||||
- Highly redundant global set of nodes incentivized by cryptoeconomic incentives
|
||||
|
||||
|
||||
_subsection: Creating a Default Provider @<api-keys--getDefaultProvider>
|
||||
|
||||
@@ -99,5 +111,16 @@ const network = "homestead";
|
||||
const provider = ethers.getDefaultProvider(network, {
|
||||
etherscan: YOUR_ETHERSCAN_API_KEY,
|
||||
infura: YOUR_INFURA_PROJECT_ID,
|
||||
alchemy: YOUR_ALCHEMY_API_KEY
|
||||
// Or if using a project secret:
|
||||
// infura: {
|
||||
// projectId: YOUR_INFURA_PROJECT_ID,
|
||||
// projectSecret: YOUR_INFURA_PROJECT_SECRET,
|
||||
// },
|
||||
alchemy: YOUR_ALCHEMY_API_KEY,
|
||||
pocket: YOUR_POCKET_APPLICATION_KEY
|
||||
// Or if using an application secret key:
|
||||
// pocket: {
|
||||
// applicationId: ,
|
||||
// applicationSecretKey:
|
||||
// }
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ _property: contractFactory.attach(address) => [[Contract]] @<ContractFactory-att
|
||||
|
||||
Return an instance of a [[Contract]] attached to //address//. This is the
|
||||
same as using the [Contract constructor](Contract--creating) with
|
||||
//address// and this the the //interface// and //signerOrProvider// passed
|
||||
//address// and this the //interface// and //signerOrProvider// passed
|
||||
in when creating the ContractFactory.
|
||||
|
||||
_property: contractFactory.getDeployTransaction(...args) => [[UnsignedTransaction]]
|
||||
|
||||
@@ -55,11 +55,11 @@ The provider associated with the signer.
|
||||
_property: nonceManager.setTransactionCount(count) => void
|
||||
Set the current transaction count (nonce) for the signer.
|
||||
|
||||
This may be useful it interacting with the signer outside of using
|
||||
This may be useful in interacting with the signer outside of using
|
||||
this class.
|
||||
|
||||
_property: nonceManager.increaseTransactionCount( [ count = 1 ]) => void
|
||||
Bump the current transaction count (nonce) by //count//.
|
||||
|
||||
This may be useful it interacting with the signer outside of using
|
||||
This may be useful in interacting with the signer outside of using
|
||||
this class.
|
||||
|
||||
@@ -57,7 +57,7 @@ _heading: PopNode @<asm-popnode> @INHERIT<[[asm-valuenode]]> @SRC<asm:class.PopN
|
||||
|
||||
A **PopNode** is used to store a place-holder for an implicit pop from the
|
||||
stack. It represents the code for an implicit place-holder (i.e. ``$$``) or an
|
||||
explicit place-holder (e.g. ``$1``), which indicates the expect stack position
|
||||
explicit place-holder (e.g. ``$1``), which indicates the expected stack position
|
||||
to consume.
|
||||
|
||||
_property: literalNode.index => number
|
||||
@@ -72,7 +72,7 @@ A **LinkNode** represents a link to another [[asm-node]]'s data,
|
||||
for example ``$foo`` or ``#bar``.
|
||||
|
||||
_property: linkNode.label => string
|
||||
Te name of the target node.
|
||||
The name of the target node.
|
||||
|
||||
_property: linkNode.type => "offset" | "length"
|
||||
Whether this node is for an offset or a length value of the
|
||||
@@ -115,7 +115,7 @@ The code to execute. Any result is ignored.
|
||||
_heading: LabelledNode @<asm-labellednode> @INHERIT<[[asm-node]]> @SRC<asm:class.LabelledNode>
|
||||
|
||||
A **LabelledNode** is used for any Node that has a name, and can therefore
|
||||
be targetted by a [[asm-linknode]].
|
||||
be targeted by a [[asm-linknode]].
|
||||
|
||||
_property: labelledNode.name => string
|
||||
The name of this node.
|
||||
|
||||
@@ -76,7 +76,7 @@ A scope may access the offset of any child [[asm-dialect-datasegment]] or
|
||||
child [[asm-dialect-scope]] (with respect to itself) and may access the length
|
||||
of any [[asm-dialect-datasegment]] or [[asm-dialect-scope]] anywhere in the program.
|
||||
|
||||
Every program in the **Ethers ASM Dialect** has a top-leve scope named ``_``.
|
||||
Every program in the **Ethers ASM Dialect** has a top-level scope named ``_``.
|
||||
|
||||
|
||||
_subsection: Data Segment @<asm-dialect-datasegment>
|
||||
|
||||
@@ -6,7 +6,7 @@ to them, which simplifies development, since you do not need
|
||||
to run your own instance or cluster of Ethereum nodes.
|
||||
|
||||
However, this reliance on third-party services can reduce
|
||||
resiliance, security and increase the amount of required trust.
|
||||
resilience, security and increase the amount of required trust.
|
||||
To mitigate these issues, it is recommended you use a
|
||||
[Default Provider](providers-getDefaultProvider).
|
||||
|
||||
@@ -20,7 +20,7 @@ _property: new ethers.providers.EtherscanProvider([ network = "homestead", [ api
|
||||
Create a new **EtherscanProvider** connected to //network// with the
|
||||
optional //apiKey//.
|
||||
|
||||
The //network// may be specified as **string** for a common
|
||||
The //network// may be specified as a **string** for a common
|
||||
network name, a **number** for a common chain ID or a
|
||||
[Network Object]provider-(network).
|
||||
|
||||
@@ -86,7 +86,7 @@ _property: new ethers.providers.InfuraProvider([ network = "homestead", [ apiKey
|
||||
Create a new **InfuraProvider** connected to //network// with
|
||||
the optional //apiKey//.
|
||||
|
||||
The //network// may be specified as **string** for a common
|
||||
The //network// may be specified as a **string** for a common
|
||||
network name, a **number** for a common chain ID or a
|
||||
[Network Object]provider-(network).
|
||||
|
||||
@@ -157,7 +157,7 @@ _property: new ethers.providers.AlchemyProvider([ network = "homestead", [ apiKe
|
||||
Create a new **AlchemyProvider** connected to //network// with
|
||||
the optional //apiKey//.
|
||||
|
||||
The //network// may be specified as **string** for a common
|
||||
The //network// may be specified as a **string** for a common
|
||||
network name, a **number** for a common chain ID or a
|
||||
[Network Object](providers-Network).
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ for use in production.
|
||||
|
||||
It creates a [[FallbackProvider]] connected to as many backend
|
||||
services as possible. When a request is made, it is sent to
|
||||
multiple backends simulatenously. As responses from each backend
|
||||
multiple backends simultaneously. As responses from each backend
|
||||
are returned, they are checked that they agree. Once a quorum
|
||||
has been reached (i.e. enough of the backends agree), the response
|
||||
is provided to your application.
|
||||
@@ -31,7 +31,7 @@ responses that match the majority.
|
||||
|
||||
_property: ethers.getDefaultProvider([ network, [ options ] ]) => [[Provider]]
|
||||
Returns a new Provider, backed by multiple services, connected
|
||||
to //network//. Is no //network// is provided, **homestead**
|
||||
to //network//. If no //network// is provided, **homestead**
|
||||
(i.e. mainnet) is used.
|
||||
|
||||
The //network// may also be a URL to connect to, such as ``http:/\/localhost:8545``
|
||||
@@ -43,20 +43,22 @@ _table: Option Properties
|
||||
|
||||
$Alchemy: [[link-alchemy]] API Token
|
||||
$Etherscan: [[link-etherscan]] API Token
|
||||
$Infura: [[link-infura]] Project ID or ProjectID and Project Secret
|
||||
$Infura: [[link-infura]] Project ID or ``{ projectId, projectSecret }``
|
||||
$Pocket: [[link-pocket]] Application ID or ``{ applicationId, applicationSecretKey }``
|
||||
$Quorum: The number of backends that must agree
|
||||
//(default: 2 for mainnet, 1 for testnets)//
|
||||
|
||||
|
||||
| **Property** | **Description** |
|
||||
| //alchemy// | $Alchemy |
|
||||
| //etherscan// | $Etherscan |
|
||||
| //infura// | $Infura |
|
||||
| //pocket// | $Pocket |
|
||||
| //quorum// | $Quorum |
|
||||
|
||||
_note: Note: API Keys
|
||||
|
||||
It is highly recommended for production services that to acquire
|
||||
and specify an API Key for each sercice.
|
||||
It is highly recommended for production services to acquire
|
||||
and specify an API Key for each service.
|
||||
|
||||
The default API Keys used by ethers are shared across all users,
|
||||
so services may throttle all services that are using the default
|
||||
|
||||
@@ -41,7 +41,7 @@ The provider for this configuration.
|
||||
|
||||
_property: fallbackProviderConfig.priority => number
|
||||
The priority used for the provider. Higher priorities are favoured over lower
|
||||
priorities. If multiple providers share the same prioirty, they are chosen
|
||||
priorities. If multiple providers share the same priority, they are chosen
|
||||
at random.
|
||||
|
||||
_property: fallbackProviderConfig.stallTimeout => number
|
||||
@@ -152,7 +152,7 @@ which allows for a persistent connection, multiplexing requests and pub-sub
|
||||
events for a more immediate event dispatching.
|
||||
|
||||
The WebSocket API is newer, and if running your own infrastructure, note that
|
||||
WebSockets are much more intensive on your server resourses, as they must manage
|
||||
WebSockets are much more intensive on your server resources, as they must manage
|
||||
and maintain the state for each client. For this reason, many services may also
|
||||
charge additional fees for using their WebSocket endpoints.
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ _subsection: Transactions Methods @<Provider--transaction-methods>
|
||||
_property: provider.call(transaction [ , blockTag = latest ]) => Promise<string<[[DataHexString]]>> @<Provider-call> @SRC<providers/base-provider>
|
||||
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 gettings on Contracts.
|
||||
for calling getters on Contracts.
|
||||
|
||||
_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//
|
||||
@@ -174,7 +174,7 @@ Add a //listener// to be triggered for each //eventName//.
|
||||
|
||||
_property: provider.once(eventName, listener) => this @<Provider-once> @SRC<providers/base-provider>
|
||||
Add a //listener// to be triggered for only the next //eventName//,
|
||||
at which time it be removed.
|
||||
at which time it will be removed.
|
||||
|
||||
_property: provider.emit(eventName, ...args) => boolean @<Provider-emit> @SRC<providers/base-provider>
|
||||
Notify all listeners of //eventName//, passing //args// to each listener. This
|
||||
|
||||
@@ -59,19 +59,19 @@ The timestamp of this block.
|
||||
_property: block.nonce => string<[[DataHexString]]>
|
||||
The nonce used as part of the proof-of-work to mine this block.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
_property: block.difficulty => number
|
||||
The difficulty target required to be met by the miner of the block.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
_property: block.gasLimit => [[BigNumber]]
|
||||
The maximum amount of gas that this block was permitted to use. This
|
||||
is a value that can be voted up or voted down by miners and is used
|
||||
to automatically adjust the bandwidth requirements of the network.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
_property: block.gasUsed => [[BigNumber]]
|
||||
The total amount of gas used by all transactions in this block.
|
||||
@@ -83,7 +83,7 @@ miner that mined this block would like the subsidy reward to go to.
|
||||
_property: block.extraData => string
|
||||
This is extra data a miner may choose to include when mining a block.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
_heading: Block (with transaction hashes)
|
||||
|
||||
@@ -238,7 +238,7 @@ Wait for //confirmations//. If 0, and the transaction has not been mined,
|
||||
_heading: TransactionReceipt @<providers-TransactionReceipt>
|
||||
|
||||
_property: receipt.to => string<[[address]]>
|
||||
The address this transaction is to. This is ``null`` if the the
|
||||
The address this transaction is to. This is ``null`` if the
|
||||
transaction was an **init transaction**, used to deploy a contract.
|
||||
|
||||
_property: receipt.from => string<[[address]]>
|
||||
@@ -295,7 +295,7 @@ including the actual block it was mined in.
|
||||
|
||||
_property: receipt.cumulativeGasUsed => [[BigNumber]]
|
||||
For the block this transaction was included in, this is the sum of the
|
||||
gas used used by each transaction in the ordered list of transactions
|
||||
gas used by each transaction in the ordered list of transactions
|
||||
up to (and including) this transaction.
|
||||
|
||||
This is generally of little interest to developers.
|
||||
|
||||
@@ -6,7 +6,7 @@ which can be used to sign messages and transactions and send
|
||||
signed transactions to the Ethereum Network to execute state
|
||||
changing operations.
|
||||
|
||||
The available operations depends largely on the sub-class used.
|
||||
The available operations depend largely on the sub-class used.
|
||||
|
||||
For example, a Signer from MetaMask can send transactions and sign
|
||||
messages but cannot sign a transaction (without broadcasting it).
|
||||
@@ -20,9 +20,9 @@ The most common Signers you will encounter are:
|
||||
|
||||
_subsection: Signer @<Signer> @SRC<abstract-signer:class.Signer>
|
||||
|
||||
The **Signer** class is abstract and cannot be directly instaniated.
|
||||
The **Signer** class is abstract and cannot be directly instantiated.
|
||||
|
||||
Instead use one of the concreate sub-classes, such as the [[Wallet]],
|
||||
Instead use one of the concrete sub-classes, such as the [[Wallet]],
|
||||
[[VoidSigner]] or [[JsonRpcSigner]].
|
||||
|
||||
_property: signer.connect(provider) => [[Signer]] @<Signer-connect>
|
||||
@@ -112,6 +112,63 @@ Sub-classes **must** implement this, however they may throw if sending a
|
||||
transaction is not supported, such as the [[VoidSigner]] or if the
|
||||
Wallet is offline and not connected to a [[Provider]].
|
||||
|
||||
_property: signer._signTypedData(domain, types, value) => Promise<string<[RawSignature](signature-raw)>> @<Signer-signTypedData>
|
||||
|
||||
Signs the typed data //value// with //types// data structure for //domain// using
|
||||
the [[link-eip-712]] specification.
|
||||
|
||||
_warning: Experimental feature (this method name will change)
|
||||
|
||||
This is still an experimental feature. If using it, please specify the **exact**
|
||||
version of ethers you are using (e.g. spcify ``"5.0.18"``, **not** ``"^5.0.18"``) as
|
||||
the method name will be renamed from ``_signTypedData`` to ``signTypedData`` once
|
||||
it has been used in the field a bit.
|
||||
|
||||
_code: Typed Data Example @lang<javascript>
|
||||
|
||||
// <hide>
|
||||
signer = new Wallet("0x1234567890123456789012345678901234567890123456789012345678901234");
|
||||
// </hide>
|
||||
|
||||
// All properties on a domain are optional
|
||||
const domain = {
|
||||
name: 'Ether Mail',
|
||||
version: '1',
|
||||
chainId: 1,
|
||||
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
|
||||
};
|
||||
|
||||
// The named list of all type definitions
|
||||
const types = {
|
||||
Person: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'wallet', type: 'address' }
|
||||
],
|
||||
Mail: [
|
||||
{ name: 'from', type: 'Person' },
|
||||
{ name: 'to', type: 'Person' },
|
||||
{ name: 'contents', type: 'string' }
|
||||
]
|
||||
};
|
||||
|
||||
// The data to sign
|
||||
const value = {
|
||||
from: {
|
||||
name: 'Cow',
|
||||
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
|
||||
},
|
||||
to: {
|
||||
name: 'Bob',
|
||||
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
|
||||
},
|
||||
contents: 'Hello, Bob!'
|
||||
};
|
||||
|
||||
|
||||
const signature = await signer._signTypedData(domain, types, value);
|
||||
//! async signature
|
||||
|
||||
|
||||
_heading: Sub-Classes @<Signer--subclassing>
|
||||
|
||||
It is very important that all important properties of a **Signer** are
|
||||
@@ -124,20 +181,20 @@ and libraries make this assumption.
|
||||
A sub-class **must** extend Signer and **must** call ``super()``.
|
||||
|
||||
_property: signer.checkTransaction(transactionRequest) => [[providers-TransactionRequest]] @<Signer-checkTransaction> @SRC<abstract-signer>
|
||||
This is generally not required to be overridden, but may needed to provide
|
||||
This is generally not required to be overridden, but may be needed to provide
|
||||
custom behaviour in sub-classes.
|
||||
|
||||
This should return a **copy** of the //transactionRequest//, with any properties
|
||||
needed by ``call``, ``estimateGas`` and ``populateTransaction`` (which is used
|
||||
by sendTransaction). It should also throw an error if any unknown key is specified.
|
||||
|
||||
The default implementation checks only valid [[providers-TransactionRequest]] properties
|
||||
The default implementation checks only if valid [[providers-TransactionRequest]] properties
|
||||
exist and adds ``from`` to the transaction if it does not exist.
|
||||
|
||||
If there is a ``from`` field it **must** be verified to be equal to the Signer's address.
|
||||
|
||||
_property: signer.populateTransaction(transactionRequest) => Promise<[[providers-TransactionRequest]]> @<Signer-populateTransaction> @SRC<abstract-signer>
|
||||
This is generally not required to be overridden, but may needed to provide
|
||||
This is generally not required to be overridden, but may be needed to provide
|
||||
custom behaviour in sub-classes.
|
||||
|
||||
This should return a **copy** of //transactionRequest//, follow the same procedure
|
||||
@@ -193,7 +250,7 @@ _property: wallet.address => string<[[address]]>
|
||||
The address for the account this Wallet represents.
|
||||
|
||||
_property: wallet.provider => [[Provider]]
|
||||
The provider this wallet is connected to, which will ge used for any [[Signer--blockchain-methods]]
|
||||
The provider this wallet is connected to, which will be used for any [[Signer--blockchain-methods]]
|
||||
methods. This can be null.
|
||||
|
||||
_note: Note
|
||||
@@ -352,5 +409,5 @@ The privateKey of this EOA
|
||||
_property: eoa.mnemonic => [[Mnemonic]]
|
||||
|
||||
//Optional//. The account HD mnemonic, if it has one and can be
|
||||
determined. Some sources do not encode the mnemonic, such as an
|
||||
determined. Some sources do not encode the mnemonic, such as
|
||||
HD extended keys.
|
||||
|
||||
@@ -39,7 +39,7 @@ _subsection: Coding Methods @<AbiCoder--methods>
|
||||
|
||||
_property: abiCoder.encode(types, values) => string<[[DataHexString]]> @<AbiCoder-encode> @SRC<abi/abi-coder>
|
||||
|
||||
Encode the array //values// according the array of //types//, each of which may be a
|
||||
Encode the array //values// according to the array of //types//, each of which may be a
|
||||
string or a [[ParamType]].
|
||||
|
||||
_property: abiCoder.decode(types, data) => [[Result]] @<AbiCoder-decode> @SRC<abi/abi-coder>
|
||||
|
||||
@@ -31,7 +31,7 @@ _property: ethers.utils.FragmentTypes.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 readabiliy.
|
||||
to aid in human readability.
|
||||
|
||||
_property: ethers.utils.FragmentTypes.minimal => string
|
||||
|
||||
@@ -81,7 +81,7 @@ will be one of:
|
||||
|
||||
_property: fragment.inputs => Array<[[ParamType]]>
|
||||
|
||||
This is an array of of each [[ParamType]] for the input parameters to
|
||||
This is an array of each [[ParamType]] for the input parameters to
|
||||
the Constructor, Event of Function.
|
||||
|
||||
_heading: Methods
|
||||
@@ -211,13 +211,13 @@ to parameters which are part of an [[EventFragment]].
|
||||
|
||||
_property: paramType.arrayChildren => [[ParamType]] @<ParamType-arrayChildren>
|
||||
|
||||
The type of children of the array. This is null for for any parameter
|
||||
The type of children of the array. This is null for any parameter
|
||||
which is not an array.
|
||||
|
||||
_property: paramType.arrayLength => number @<ParamType-arrayLength>
|
||||
|
||||
The length of the array, or ``-1`` for dynamic-length arrays. This is
|
||||
null for parameters which is not arrays.
|
||||
null for parameters which are not arrays.
|
||||
|
||||
_property: paramType.components => Array<[[ParamType]]> @<ParamType-components>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Many operations in Ethereum operation on numbers which are
|
||||
[outside the range of safe values](BigNumber--notes-safenumbers) to use
|
||||
in JavaScript.
|
||||
|
||||
A **BigNumber** is an object which safely allows mathematic operations
|
||||
A **BigNumber** is an object which safely allows mathematical operations
|
||||
on numbers of any magnitude.
|
||||
|
||||
Most operations which need to return a value will return a **BigNumber**
|
||||
@@ -126,7 +126,7 @@ _heading: Two's Complement
|
||||
|
||||
[Two's Complement](link-wiki-twoscomplement)
|
||||
is an elegant method used to encode and decode fixed-width signed values
|
||||
while efficiently preserving mathematic operations.
|
||||
while efficiently preserving mathematical operations.
|
||||
Most users will not need to interact with these.
|
||||
|
||||
_property: BigNumber.fromTwos(bitwidth) => [[BigNumber]] @SRC<bignumber>
|
||||
@@ -175,7 +175,7 @@ Returns the value of //BigNumber// as a base-16, ``0x``-prefixed [[DataHexString
|
||||
|
||||
_heading: Inspection
|
||||
|
||||
_property: ethers.BigNumnber.isBigNumber(object) => boolean @SRC<bignumber>
|
||||
_property: ethers.BigNumber.isBigNumber(object) => boolean @SRC<bignumber>
|
||||
Returns true if and only if the //object// is a BigNumber object.
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ various purposes.
|
||||
|
||||
_heading: Allow us to set a global Big Number library?
|
||||
|
||||
Another comment that comes up frequently is tha desire to specify a
|
||||
Another comment that comes up frequently is the desire to specify a
|
||||
global user-defined Big Number library, which all functions would
|
||||
return.
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ Any missing properties will be computed.
|
||||
|
||||
_subsection: Random Bytes
|
||||
|
||||
_property: ethers.utils.randomBytes(length) => Uint8Array @<utils-randomBytes> @SRC<random/index>
|
||||
_property: ethers.utils.randomBytes(length) => Uint8Array @<utils-randomBytes> @SRC<random/random>
|
||||
Return a new Uint8Array of //length// random bytes.
|
||||
|
||||
_property: ethers.utils.shuffled(array) => Array<any> @<utils-shuffled> @SRC<random>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
_section: Display Logic and Input
|
||||
_section: Display Logic and Input @<display-logic>
|
||||
|
||||
When creating an Application, it is useful to convert between
|
||||
user-friendly strings (usually displaying **ether**) and the
|
||||
@@ -17,11 +17,11 @@ The [formatUnits](unit-conversion) will format a [BigNumberish](BigNumberish)
|
||||
into a string, which is useful when displaying a balance.
|
||||
|
||||
|
||||
_subsection: Units
|
||||
_subsection: Units @<display-logic--units>
|
||||
|
||||
_heading: Decimal Count
|
||||
|
||||
A **Unit** can be specified as an number, which indicates the
|
||||
A **Unit** can be specified as a number, which indicates the
|
||||
number of decimal places that should be used.
|
||||
|
||||
**Examples:**
|
||||
@@ -29,7 +29,7 @@ number of decimal places that should be used.
|
||||
- 1 ether in wei, has **18** decimal places (i.e. 1 ether represents 10^^18^^ wei)
|
||||
- 1 bitcoin in Satoshi, has **8** decimal places (i.e. 1 bitcoin represents 10^^8^^ satoshi)
|
||||
|
||||
_heading: Named Units
|
||||
_heading: Named Units @<display-logic--named-units>
|
||||
|
||||
There are also several common **Named Units**, in which case their name (as
|
||||
a string) may be used.
|
||||
@@ -46,9 +46,9 @@ _table: @STYLE<compact>
|
||||
| //ether// | 18 |
|
||||
|
||||
|
||||
_subsection: Functions
|
||||
_subsection: Functions @<display-logic--functions>
|
||||
|
||||
_heading: Formatting
|
||||
_heading: Formatting @<display-logic--formatting>
|
||||
|
||||
_property: ethers.utils.commify(value) => string @<utils-commify> @SRC<units>
|
||||
Returns a string with value grouped by 3 digits, separated by ``,``.
|
||||
|
||||
@@ -28,7 +28,7 @@ structures of Arrays and data.
|
||||
_property: ethers.utils.RLP.encode(dataObject) => string<[[DataHexString]]> @<utils-rlpEncode> @SRC<rlp>
|
||||
Encode a structured Data Object into its RLP-encoded representation.
|
||||
|
||||
Each Data component may be an valid [[BytesLike]].
|
||||
Each Data component may be a valid [[BytesLike]].
|
||||
|
||||
_property: ethers.utils.RLP.decode(aBytesLike) => [DataObject](rlp--dataobject) @<utils.rlpDecode> @SRC<rlp>
|
||||
Decode an RLP-encoded //aBytesLike// into its structured Data Object.
|
||||
|
||||
@@ -81,7 +81,7 @@ _subsection: FixedFormat @<FixedFormat>
|
||||
|
||||
A **FixedFormat** is a simple object which represents a decimal
|
||||
(base-10) Fixed-Point data representation. Usually using this
|
||||
class directly is uneccessary, as passing in a [[FixedFormat--strings]]
|
||||
class directly is unnecessary, as passing in a [[FixedFormat--strings]]
|
||||
directly into the [[FixedNumber]] will automatically create this.
|
||||
|
||||
_heading: Format Strings @<FixedFormat--strings>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
_section: Hashing Algorithms @<hashing-algorithms>
|
||||
|
||||
Explain what hash functions are?
|
||||
There are many hashing algorithms used throughout the blockchain
|
||||
space as well as some more complex usages which require utilities
|
||||
to facilitate these common operations.
|
||||
|
||||
|
||||
_subsection: Cryptographic Hash Functions @<cryptographic-hash-functions>
|
||||
@@ -66,7 +68,7 @@ utils.keccak256("0x1234")
|
||||
utils.keccak256([ 0x12, 0x34 ])
|
||||
//!
|
||||
|
||||
const bytes = utils.toUtf8Bytes("0x1234");
|
||||
const bytes = utils.toUtf8Bytes("0x1234")
|
||||
// <hide>
|
||||
bytes
|
||||
// </hide>
|
||||
@@ -119,8 +121,8 @@ Use the [SHA2-512](link-wiki-sha2) hash algorithm.
|
||||
|
||||
_code: HMAC @lang<javascript>
|
||||
|
||||
const key = "0x0102";
|
||||
const data = "0x1234";
|
||||
const key = "0x0102"
|
||||
const data = "0x1234"
|
||||
utils.computeHmac("sha256", key, data)
|
||||
//!
|
||||
|
||||
@@ -132,13 +134,39 @@ Computes the [[link-eip-191]] personal message digest of //message//. Personal m
|
||||
converted to UTF-8 bytes and prefixed with ``\\x19Ethereum Signed Message:``
|
||||
and the length of //message//.
|
||||
|
||||
_property: ethers.utils.namehash(name) => string<[[DataHexString]]<32>> @<utils-namehash> @SRC<hash>
|
||||
Returns the [ENS Namehash](link-namehash) of //name//.
|
||||
|
||||
_code: Hashing Messages @lang<javascript>
|
||||
|
||||
// @TODO: include examples of hashMessage; it can be complex. :)
|
||||
// Hashing a string message
|
||||
utils.hashMessage("Hello World")
|
||||
//!
|
||||
|
||||
// Hashing binary data (also "Hello World", but as bytes)
|
||||
utils.hashMessage( [ 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 ])
|
||||
//!
|
||||
|
||||
// NOTE: It is important to understand how strings and binary
|
||||
// data is handled differently. A string is ALWAYS processed
|
||||
// as the bytes of the string, so a hexstring MUST be
|
||||
// converted to an ArrayLike object first.
|
||||
|
||||
// Hashing a hex string is the same as hashing a STRING
|
||||
// Note: this is the hash of the 4 characters [ '0', 'x', '4', '2' ]
|
||||
utils.hashMessage("0x42")
|
||||
//!
|
||||
|
||||
// Hashing the binary data
|
||||
// Note: this is the hash of the 1 byte [ 0x42 ]
|
||||
utils.hashMessage([ 0x42 ])
|
||||
//!
|
||||
|
||||
// Hashing the binary data
|
||||
// Note: similarly, this is the hash of the 1 byte [ 0x42 ]
|
||||
utils.hashMessage(utils.arrayify("0x42"))
|
||||
//!
|
||||
|
||||
|
||||
_property: ethers.utils.namehash(name) => string<[[DataHexString]]<32>> @<utils-namehash> @SRC<hash>
|
||||
Returns the [ENS Namehash](link-namehash) of //name//.
|
||||
|
||||
_code: Namehash @lang<javascript>
|
||||
|
||||
@@ -154,6 +182,121 @@ utils.namehash("ricmoo.firefly.eth")
|
||||
utils.namehash("ricmoo.xyz")
|
||||
//!
|
||||
|
||||
_heading: Typed Data Encoder @<TypedDataEncoder> @SRC<hash:class.TypedDataEncoder>
|
||||
|
||||
The **TypedDataEncoder** is used to compute the various encoded data required
|
||||
for [[link-eip-712]] signed data.
|
||||
|
||||
Signed data requires a domain, list of structures and their members and the data
|
||||
itself.
|
||||
|
||||
The **domain** is an object with values for any of the standard domain
|
||||
properties.
|
||||
|
||||
The **types** is an object with each property being the name of a structure, mapping
|
||||
to an array of field descriptions. It should **not** include the ``EIP712Domain``
|
||||
property unless it is required as a child structure of another.
|
||||
|
||||
_note: Experimental Feature (this exported class name will change)
|
||||
This is still an experimental feature. If using it, please specify the **exact**
|
||||
version of ethers you are using (e.g. spcify ``"5.0.18"``, **not** ``"^5.0.18"``) as
|
||||
the exported class name will be renamed from ``_TypedDataEncoder`` to ``TypedDataEncoder`` once
|
||||
it has been used in the field a bit.
|
||||
|
||||
_property: ethers.utils._TypedDataEncoder.from(types) => [TypedDataEncoder] @<TypedDataEncoder-from> @SRC<hash:TypedDataEncoder.from>
|
||||
|
||||
Creates a new **TypedDataEncoder** for //types//. This object is a fairly
|
||||
low-level object that most developers should not require using instances
|
||||
directly.
|
||||
|
||||
Most developers will find the static class methods below the most useful.
|
||||
|
||||
_property: TypedDataEncoder.encode(domain, types, values) => string @<TypedDataEncoder-encode> @SRC<hash:staticmethod.TypedDataEncoder.encode>
|
||||
|
||||
Encodes the Returns the hashed [[link-eip-712]] domain.
|
||||
|
||||
_property: TypedDataEncoder.getPayload(domain, types, value) => any @<TypedDataEncoder-getPayload> @SRC<hash:TypedDataEncoder.getPayload>
|
||||
|
||||
Returns the standard payload used by various JSON-RPC ``eth_signTypedData*``
|
||||
calls.
|
||||
|
||||
All domain values and entries in value are normalized and the types are
|
||||
verified.
|
||||
|
||||
_property: TypedDataEncoder.getPrimaryType(types) => string @<TypedDataEncoder-getPrimaryType> @SRC<hash:TypedDataEncoder.getPrimaryType>
|
||||
|
||||
Constructs a directed acyclic graph of the types and returns the
|
||||
root type, which can be used as the **primaryType** for [[link-eip-712]]
|
||||
payloads.
|
||||
|
||||
_property: TypedDataEncoder.hash(domain, types, values) => string<[[DataHexString]]<32>> @<TypedDataEncoder-hash> @SRC<hash:staticmethod.TypedDataEncoder.hash>
|
||||
|
||||
Returns the computed [[link-eip-712]] hash.
|
||||
|
||||
_property: TypedDataEncoder.hashDomain(domain) => string<[[DataHexString]]<32>> @<TypedDataEncoder-hashDomain> @SRC<hash:TypedDataEncoder.hashDomain>
|
||||
|
||||
Returns the hashed [[link-eip-712]] domain.
|
||||
|
||||
_property: TypedDataEncoder.resolveNames(domain, types, value, resolveName) => Promise<any> @<TypedDataEncoder-resolveNames> @SRC<hash:TypedDataEncoder.resolveNames>
|
||||
|
||||
Returns a copy of value, where any leaf value with a type of ``address`` will have
|
||||
been recursively replacedwith the value of calling //resolveName// with that value.
|
||||
|
||||
_code: Typed Data Example @lang<javascript>
|
||||
|
||||
// <hide>
|
||||
TypedDataEncoder = ethers.utils._TypedDataEncoder
|
||||
// </hide>
|
||||
|
||||
const domain = {
|
||||
name: 'Ether Mail',
|
||||
version: '1',
|
||||
chainId: 1,
|
||||
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
|
||||
}
|
||||
|
||||
// The named list of all type definitions
|
||||
const types = {
|
||||
Person: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'wallet', type: 'address' }
|
||||
],
|
||||
Mail: [
|
||||
{ name: 'from', type: 'Person' },
|
||||
{ name: 'to', type: 'Person' },
|
||||
{ name: 'contents', type: 'string' }
|
||||
]
|
||||
}
|
||||
|
||||
// The data to sign
|
||||
const value = {
|
||||
from: {
|
||||
name: 'Cow',
|
||||
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
|
||||
},
|
||||
to: {
|
||||
name: 'Bob',
|
||||
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
|
||||
},
|
||||
contents: 'Hello, Bob!'
|
||||
}
|
||||
|
||||
|
||||
TypedDataEncoder.encode(domain, types, value)
|
||||
//!
|
||||
|
||||
TypedDataEncoder.getPayload(domain, types, value)
|
||||
//!
|
||||
|
||||
TypedDataEncoder.getPrimaryType(types)
|
||||
//!
|
||||
|
||||
TypedDataEncoder.hash(domain, types, value)
|
||||
//!
|
||||
|
||||
TypedDataEncoder.hashDomain(domain)
|
||||
//!
|
||||
|
||||
|
||||
_subsection: Solidity Hashing Algorithms @<utils--solidity-hashing>
|
||||
|
||||
@@ -187,3 +330,20 @@ utils.solidityKeccak256([ "int16", "uint48" ], [ -1, 12 ])
|
||||
utils.soliditySha256([ "int16", "uint48" ], [ -1, 12 ])
|
||||
//!
|
||||
|
||||
// As a short example of the non-distinguished nature of
|
||||
// Solidity tight-packing (which is why it is inappropriate
|
||||
// for many things from a security point of view), consider
|
||||
// the following examples are all equal, despite representing
|
||||
// very different values and layouts.
|
||||
|
||||
utils.solidityPack([ "string", "string" ], [ "hello", "world01" ])
|
||||
//!
|
||||
|
||||
utils.solidityPack([ "string", "string" ], [ "helloworld", "01" ])
|
||||
//!
|
||||
|
||||
utils.solidityPack([ "string", "string", "uint16" ], [ "hell", "oworld", 0x3031 ])
|
||||
//!
|
||||
|
||||
utils.solidityPack([ "uint96" ], [ "32309054545061485574011236401" ])
|
||||
//!
|
||||
|
||||
@@ -196,7 +196,7 @@ _property: Logger.levels.DEBUG
|
||||
Log all output, including debugging information.
|
||||
|
||||
_property: Logger.levels.INFO
|
||||
Only log output for infomational, warnings and errors.
|
||||
Only log output for informational, warnings and errors.
|
||||
|
||||
_property: Logger.levels.WARNING
|
||||
Only log output for warnings and errors.
|
||||
|
||||
@@ -39,7 +39,13 @@ will then be used to compute the address; this allows systems which use
|
||||
the v to encode additional data (such as [EIP-155](link-eip-155))
|
||||
to be used since the v parameter is still completely non-ambiguous.
|
||||
|
||||
_property: ethers.utils.verifyTypedData(domain, types, value, signature) => string<[[address]]> @<utils-verifyTypedData> @SRC<wallet>
|
||||
Returns the address that signed the [[link-eip-712]] //value// for the //domain//
|
||||
and //types// to produce the signature.
|
||||
|
||||
_property: ethers.utils.recoverPublicKey(digest, signature) => string<[[DataHexString]]<65>> @<utils-recoverPublicKey>
|
||||
Returns the uncompressed public key (i.e. the first byte will be ``0x04``)
|
||||
of the private key that was used to sign //digest// which gave the //signature//.
|
||||
|
||||
_property: ethers.utils.computePublicKey(key [, compressed = false ]) => string<[[DataHexString]]> @<utils-computePublicKey>
|
||||
Computes the public key of //key//, optionally compressing it. The //key//
|
||||
|
||||
@@ -7,7 +7,7 @@ An unsigned transaction represents a transaction that has not been
|
||||
signed and its values are flexible as long as they are not ambiguous.
|
||||
|
||||
_property: unsignedTransaction.to => string<[Address](address)>
|
||||
The addres this transaction is to.
|
||||
The address this transaction is to.
|
||||
|
||||
_property: unsignedTransaction.nonce => number
|
||||
The nonce of this transaction.
|
||||
@@ -98,7 +98,7 @@ used to encode the chain ID into the serialized transaction.
|
||||
_subsection: Functions @<transactions--functions>
|
||||
|
||||
_property: ethers.utils.parseTransaction(aBytesLike) => [[Transaction]] @<utils-parseTransaction> @SRC<transactions:parse>
|
||||
Parses the transaction properties from a serialized transactions.
|
||||
Parses the transaction properties from a serialized transaction.
|
||||
|
||||
_property: ethers.utils.serializeTransaction(tx [ , signature ]) => string<[[DataHexString]]> @<utils-serializeTransaction> @SRC<transactions:serialize>
|
||||
Computes the serialized //transaction//, optionally serialized with
|
||||
|
||||
@@ -3,7 +3,7 @@ _section: Web Utilities @<web>
|
||||
|
||||
_property: ethers.utils.fetchJson(urlOrConnectionInfo [, json [ , processFunc ] ]) => Promise<any> @<utils-fetchJson>
|
||||
Fetch and parse the JSON content from //urlOrConnectionInfo//, with the
|
||||
optiona body //json// and optionally processing the result with //processFun//
|
||||
optional body //json// and optionally processing the result with //processFun//
|
||||
before returning it.
|
||||
|
||||
_property: ethers.utils.poll(pollFunc [, options ]) => Promise<any> @<utils-poll>
|
||||
|
||||
@@ -30,7 +30,7 @@ the registered //name//.
|
||||
|
||||
_subsection: Languages @<wordlists--languages>
|
||||
|
||||
The [official wordlists](link-bip39-wordlists) available in at
|
||||
The [official wordlists](link-bip39-wordlists) available at
|
||||
`ethers.wordlists`. In the browser, only the english language is
|
||||
available by default; to include the others (which increases the
|
||||
size of the library), see the dist files in the `ethers` package.
|
||||
|
||||
@@ -104,8 +104,8 @@ bytecode by running multiple passes of an assemble stage, each pass
|
||||
more closely approximating the final result.
|
||||
|
||||
This allows small portions of the bytecode to be massaged and tweaked
|
||||
until the bytecode stablizes. This allows for more compact jump
|
||||
destinations and for code to be include more advanced meta-programming
|
||||
until the bytecode stabilizes. This allows for more compact jump
|
||||
destinations and for code to include more advanced meta-programming
|
||||
techniques.
|
||||
|
||||
_code: @lang<shell>
|
||||
|
||||
@@ -47,8 +47,8 @@ for a given option is invalid or some combination of options and flags is not
|
||||
allowed.
|
||||
|
||||
Once the prepareOptions is complete (the returned promise is resolved), the ``prepareArguments``
|
||||
is called. This should validate the number of arguments is expected and throw
|
||||
and error if there are too many or too few arguments or if any arguments do not
|
||||
is called. This should validate the number of arguments expected and throw
|
||||
an error if there are too many or too few arguments or if any arguments do not
|
||||
make sense.
|
||||
|
||||
Once the prepareArguments is complete (the returned promise is resolved), the ``run``
|
||||
|
||||
@@ -11,3 +11,4 @@ _toc:
|
||||
events
|
||||
gas
|
||||
security
|
||||
best-practices
|
||||
|
||||
@@ -127,7 +127,7 @@ function codeContextify(context) {
|
||||
context.hexlify = ethers.utils.hexlify;
|
||||
context.hexValue = ethers.utils.hexValue;
|
||||
context.Wallet = ethers.Wallet;
|
||||
context.provider = new ethers.providers.InfuraProvider();
|
||||
context.provider = new ethers.providers.InfuraProvider("mainnet", "49a0efa3aaee4fd99797bfa94d8ce2f1");
|
||||
|
||||
context.BigNumber.prototype[inspect.custom] = function(depth, options) {
|
||||
return `{ BigNumber: ${JSON.stringify(this.toString()) } }`;
|
||||
@@ -142,6 +142,7 @@ function codeContextify(context) {
|
||||
//return JSON.stringify(value);
|
||||
return inspect(value, {
|
||||
compact: false,
|
||||
depth: null,
|
||||
breakLength: Infinity,
|
||||
sorted: true,
|
||||
});
|
||||
@@ -185,6 +186,7 @@ module.exports = {
|
||||
"link-metamask": { name: "Metamask", url: "https:/\/metamask.io/" },
|
||||
"link-otto": "https:/\/github.com/robertkrimen/otto",
|
||||
"link-parity": { name: "Parity", url: "https:/\/www.parity.io" },
|
||||
"link-pocket": { name: "Pocket Network", url: "https:/\/pokt.network" },
|
||||
"link-react-native": { name: "React Native", url: "https:/\/reactnative.dev" },
|
||||
"link-rtd": "https:/\/github.com/readthedocs/sphinx_rtd_theme",
|
||||
"link-semver": { name: "semver", url: "https:/\/semver.org" },
|
||||
@@ -195,6 +197,7 @@ module.exports = {
|
||||
"link-etherscan-signup": "https:/\/etherscan.io/apis",
|
||||
"link-etherscan-ratelimit": "https:/\/info.etherscan.com/api-return-errors/",
|
||||
"link-infura-signup": "https:/\/infura.io/register",
|
||||
"link-pocket-signup": "https:/\/pokt.network/pocket-gateway-ethereum-mainnet/",
|
||||
|
||||
"link-json-rpc": "https:/\/github.com/ethereum/wiki/wiki/JSON-RPC",
|
||||
"link-web3-send": "https:/\/github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-http/types/index.d.ts#L57",
|
||||
@@ -236,6 +239,7 @@ module.exports = {
|
||||
"link-eip-155": { name: "EIP-155", url: "https:/\/eips.ethereum.org/EIPS/eip-155" },
|
||||
"link-eip-191": { name: "EIP-191", url: "https:/\/eips.ethereum.org/EIPS/eip-191" },
|
||||
"link-eip-609": { name: "EIP-609", url: "https:/\/eips.ethereum.org/EIPS/eip-609" },
|
||||
"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-2098": { name: "EIP-2098", url: "https:/\/eips.ethereum.org/EIPS/eip-2098" },
|
||||
@@ -247,7 +251,7 @@ module.exports = {
|
||||
"link-npm-events": { name: "EventEmitter", url: "https:/\/nodejs.org/dist/latest-v13.x/docs/api/events.html#events_class_eventemitter" },
|
||||
"link-npm-bnjs": { name: "BN.js", url: "https:/\/www.npmjs.com/package/bn.js" },
|
||||
"link-npm-query-bignumber": "https:/\/www.npmjs.com/search?q=bignumber",
|
||||
"link-npm-react-native-crypto": { name: "React Native Crypto", url: "https:/\/www.npmjs.com/package/react-native-crypto" },
|
||||
"link-npm-react-native-get-random-values": { name: "React Native get-random-values", url: "https:/\/www.npmjs.com/package/react-native-get-random-values" },
|
||||
|
||||
"link-js-array": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array",
|
||||
"link-js-bigint": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt",
|
||||
|
||||
@@ -21,7 +21,7 @@ So, pull requests are always welcome, but please keep a few points in mind:
|
||||
may not be accepted
|
||||
|
||||
In general, **please start an issue //before// beginning a pull request**, so we can
|
||||
have a public discussion and figure out the best way to address to problem/feature.
|
||||
have a public discussion and figure out the best way to address the problem/feature.
|
||||
**:)**
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,21 @@ _subsection: Security @<cookbook-reactnative-security>
|
||||
|
||||
The React Native environment does not contain a secure random source, which
|
||||
is used when computing random private keys. This could result in private
|
||||
keys that others could guess, allowing the funds to be stolen.
|
||||
keys that others could possibly guess, allowing funds to be stolen and assets
|
||||
manipulated.
|
||||
|
||||
For this reason, it is **HIGHLY RECOMMENDED** to get either the
|
||||
[[link-npm-react-native-crypto]] module working or some equivalent.
|
||||
For this reason, it is **HIGHLY RECOMMENDED** to also install the
|
||||
[[link-npm-react-native-get-random-values]], which **must** be included
|
||||
before the shims. If it worked correctly you should not receive any
|
||||
warning in the console regarding missing secure random sources.
|
||||
|
||||
_code: Importing with Secure Random Sources @lang<script>
|
||||
|
||||
// Import the crypto getRandomValues shim (**BEFORE** the shims)
|
||||
import "react-native-get-random-values"
|
||||
|
||||
// Import the the ethers shims (**BEFORE** ethers)
|
||||
import "@ethersproject/shims"
|
||||
|
||||
// Import the ethers library
|
||||
import { ethers } from "ethers";
|
||||
|
||||
@@ -380,7 +380,7 @@ _heading: Variables @<flatworm--table-variable>
|
||||
Often the layout of a table is easier to express and maintain without
|
||||
uneven or changing content within it. So the content can be defined
|
||||
separately within a table directive using **variables**. A variable
|
||||
name must being with a letter and must only contain letters and numbers.
|
||||
name must begin with a letter and must only contain letters and numbers.
|
||||
|
||||
Variables are also useful when content is repeated throughout a table.
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ All errors now belong to the [[Logger]] class and the related functions
|
||||
have been moved to [[Logger]] instances, which can include a per-package
|
||||
version string.
|
||||
|
||||
Global error functions have been moved [[Logger]] class methods.
|
||||
Global error functions have been moved to [[Logger]] class methods.
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ _subsection: Test Suites @<testing-suites>
|
||||
|
||||
The test suites are available as gzipped JSON files in the
|
||||
``@ethersproject/testcases``, which makes it easy to install and import
|
||||
(both GZIP and JSON are quite easy to consume from most langauges). Each
|
||||
(both GZIP and JSON are quite easy to consume from most languages). Each
|
||||
test suite also has its schema available in this package.
|
||||
|
||||
_table: Test Suites @style<full>
|
||||
@@ -126,7 +126,7 @@ _heading: Deterministic Random Numbers (DRNG)
|
||||
|
||||
When creating test cases, often we want want random data from the perspective
|
||||
we do not case what values are used, however we want the values to be consistent
|
||||
accross runs. Otherwise it becomes difficult to reproduce an issue.
|
||||
across runs. Otherwise it becomes difficult to reproduce an issue.
|
||||
|
||||
In each of the following the seed is used to control the random value returned. Be
|
||||
sure to tweak the seed properly, for example on each iteration change the value and
|
||||
|
||||
@@ -33,10 +33,13 @@ Developer Documentation
|
||||
* [Gas Limit](concepts/gas)
|
||||
* [Security](concepts/security)
|
||||
* [Key Derivation Functions](concepts/security)
|
||||
* [Best Practices](concepts/best-practices)
|
||||
* [Network Changes](concepts/best-practices)
|
||||
* [Provider API Keys](api-keys)
|
||||
* [Etherscan](api-keys)
|
||||
* [INFURA](api-keys)
|
||||
* [Alchemy](api-keys)
|
||||
* [Pocket Gateway](api-keys)
|
||||
* [Creating a Default Provider](api-keys)
|
||||
* [Application Programming Interface](api)
|
||||
* [Providers](api/providers)
|
||||
@@ -193,7 +196,7 @@ Developer Documentation
|
||||
* [Data Segment](api/other/assembly/dialect)
|
||||
* [Links](api/other/assembly/dialect)
|
||||
* [Stack Placeholders](api/other/assembly/dialect)
|
||||
* [Evaluation and Excution](api/other/assembly/dialect)
|
||||
* [Evaluation and Execution](api/other/assembly/dialect)
|
||||
* [Utilities](api/other/assembly/api)
|
||||
* [Assembler](api/other/assembly/api)
|
||||
* [Disassembler](api/other/assembly/api)
|
||||
|
||||
@@ -16,6 +16,9 @@ INFURA
|
||||
Alchemy
|
||||
-------
|
||||
|
||||
Pocket Gateway
|
||||
--------------
|
||||
|
||||
Creating a Default Provider
|
||||
---------------------------
|
||||
|
||||
@@ -29,7 +32,18 @@ const network = "homestead";
|
||||
const provider = ethers.getDefaultProvider(network, {
|
||||
etherscan: YOUR_ETHERSCAN_API_KEY,
|
||||
infura: YOUR_INFURA_PROJECT_ID,
|
||||
alchemy: YOUR_ALCHEMY_API_KEY
|
||||
// Or if using a project secret:
|
||||
// infura: {
|
||||
// projectId: YOUR_INFURA_PROJECT_ID,
|
||||
// projectSecret: YOUR_INFURA_PROJECT_SECRET,
|
||||
// },
|
||||
alchemy: YOUR_ALCHEMY_API_KEY,
|
||||
pocket: YOUR_POCKET_APPLICATION_KEY
|
||||
// Or if using an application secret key:
|
||||
// pocket: {
|
||||
// applicationId: ,
|
||||
// applicationSecretKey:
|
||||
// }
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -161,7 +161,7 @@ Application Programming Interface
|
||||
* [Data Segment](other/assembly/dialect)
|
||||
* [Links](other/assembly/dialect)
|
||||
* [Stack Placeholders](other/assembly/dialect)
|
||||
* [Evaluation and Excution](other/assembly/dialect)
|
||||
* [Evaluation and Execution](other/assembly/dialect)
|
||||
* [Utilities](other/assembly/api)
|
||||
* [Assembler](other/assembly/api)
|
||||
* [Disassembler](other/assembly/api)
|
||||
|
||||
@@ -42,7 +42,7 @@ Methods
|
||||
|
||||
#### *contractFactory* . **attach**( address ) => *[Contract](/v5/api/contract/contract/)*
|
||||
|
||||
Return an instance of a [Contract](/v5/api/contract/contract/) attched to *address*. This is the same as using the [Contract constructor](/v5/api/contract/contract/#Contract--creating) with *address* and this the the *interface* and *signerOrProvider* passed in when creating the ContractFactory.
|
||||
Return an instance of a [Contract](/v5/api/contract/contract/) attached to *address*. This is the same as using the [Contract constructor](/v5/api/contract/contract/#Contract--creating) with *address* and this the *interface* and *signerOrProvider* passed in when creating the ContractFactory.
|
||||
|
||||
|
||||
#### *contractFactory* . **getDeployTransaction**( ...args ) => *[UnsignedTransaction](/v5/api/utils/transactions/#UnsignedTransaction)*
|
||||
@@ -52,7 +52,7 @@ Returns the unsigned transaction which would deploy this Contract with *args* pa
|
||||
|
||||
#### *contractFactory* . **deploy**( ...args ) => *Promise< [Contract](/v5/api/contract/contract/) >*
|
||||
|
||||
Uses the signer to deploy the Contract with *args* passed into the constructor and retruns a Contract which is attached to the address where this contract **will** be deployed once the transaction is mined.
|
||||
Uses the signer to deploy the Contract with *args* passed into the constructor and returns a Contract which is attached to the address where this contract **will** be deployed once the transaction is mined.
|
||||
|
||||
The transaction can be found at `contract.deployTransaction`, and no interactions should be made until the transaction is mined.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -17,7 +17,7 @@ Generates a brain wallet, with a slightly improved experience, in which the gene
|
||||
|
||||
#### *BrainWallet* . **generateLegacy**( username , password [ , progressCallback ] ) => *[BrainWallet](/v5/api/experimental/#experimental-brainwallet)*
|
||||
|
||||
Generate a brain wallet which is compatibile with the ethers v3 and earlier.
|
||||
Generate a brain wallet which is compatible with the ethers v3 and earlier.
|
||||
|
||||
|
||||
EIP1193Bridge
|
||||
@@ -45,13 +45,13 @@ The provider associated with the signer.
|
||||
|
||||
Set the current transaction count (nonce) for the signer.
|
||||
|
||||
This may be useful it interacting with the signer outside of using this class.
|
||||
This may be useful in interacting with the signer outside of using this class.
|
||||
|
||||
|
||||
#### *nonceManager* . **increaseTransactionCount**( [ count = 1 ] ) => *void*
|
||||
|
||||
Bump the current transaction count (nonce) by *count*.
|
||||
|
||||
This may be useful it interacting with the signer outside of using this class.
|
||||
This may be useful in interacting with the signer outside of using this class.
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -17,7 +17,7 @@ Other Libraries
|
||||
* [Data Segment](assembly/dialect)
|
||||
* [Links](assembly/dialect)
|
||||
* [Stack Placeholders](assembly/dialect)
|
||||
* [Evaluation and Excution](assembly/dialect)
|
||||
* [Evaluation and Execution](assembly/dialect)
|
||||
* [Utilities](assembly/api)
|
||||
* [Assembler](assembly/api)
|
||||
* [Disassembler](assembly/api)
|
||||
|
||||
@@ -16,7 +16,7 @@ Assembly
|
||||
* [Data Segment](dialect)
|
||||
* [Links](dialect)
|
||||
* [Stack Placeholders](dialect)
|
||||
* [Evaluation and Excution](dialect)
|
||||
* [Evaluation and Execution](dialect)
|
||||
* [Utilities](api)
|
||||
* [Assembler](api)
|
||||
* [Disassembler](api)
|
||||
|
||||
@@ -62,7 +62,7 @@ Opcode
|
||||
|
||||
#### *asm* . *Opcode* . **from**( valueOrMnemonic ) => *[Opcode](/v5/api/other/assembly/api/#asm-opcode)*
|
||||
|
||||
Create a new instnace of an Opcode for a given numeric value (e.g. 0x60 is PUSH1) or mnemonic string (e.g. "PUSH1").
|
||||
Create a new instance of an Opcode for a given numeric value (e.g. 0x60 is PUSH1) or mnemonic string (e.g. "PUSH1").
|
||||
|
||||
|
||||
### Properties
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -53,7 +53,7 @@ The literal value of this node, which may be a [DataHexString](/v5/api/utils/byt
|
||||
|
||||
#### *literalNode* . **verbatim** => *boolean*
|
||||
|
||||
This is true in a [DataNode](/v5/api/other/assembly/ast/#asm-datanode) context, since in that case the value should be taken verbatim and no `PUSH` operation shoud be added, otherwise false.
|
||||
This is true in a [DataNode](/v5/api/other/assembly/ast/#asm-datanode) context, since in that case the value should be taken verbatim and no `PUSH` operation should be added, otherwise false.
|
||||
|
||||
|
||||
### PopNode
|
||||
@@ -67,7 +67,7 @@ The index this **PopNode** is representing. For an implicit place-holder this is
|
||||
|
||||
#### *linkNode* . **label** => *string*
|
||||
|
||||
Te name of the target node.
|
||||
The name of the target node.
|
||||
|
||||
|
||||
#### *linkNode* . **type** => *"offset" | "length"*
|
||||
@@ -91,7 +91,7 @@ A list of all operands passed into this Node.
|
||||
|
||||
#### *literalNode* . **verbatim** => *boolean*
|
||||
|
||||
This is true in a [DataNode](/v5/api/other/assembly/ast/#asm-datanode) context, since in that case the value should be taken verbatim and no `PUSH` operation shoud be added, otherwise false.
|
||||
This is true in a [DataNode](/v5/api/other/assembly/ast/#asm-datanode) context, since in that case the value should be taken verbatim and no `PUSH` operation should be added, otherwise false.
|
||||
|
||||
|
||||
#### *evaluationNode* . **script** => *string*
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -31,6 +31,6 @@ Links
|
||||
Stack Placeholders
|
||||
------------------
|
||||
|
||||
Evaluation and Excution
|
||||
-----------------------
|
||||
Evaluation and Execution
|
||||
------------------------
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -12,7 +12,7 @@ Default Provider
|
||||
|
||||
#### *ethers* . **getDefaultProvider**( [ network , [ options ] ] ) => *[Provider](/v5/api/providers/provider/)*
|
||||
|
||||
Returns a new Provider, backed by multiple services, connected to *network*. Is no *network* is provided, **homestead** (i.e. mainnet) is used.
|
||||
Returns a new Provider, backed by multiple services, connected to *network*. If no *network* is provided, **homestead** (i.e. mainnet) is used.
|
||||
|
||||
The *network* may also be a URL to connect to, such as `http://localhost:8545` or `wss://example.com`.
|
||||
|
||||
@@ -25,7 +25,7 @@ Option Properties
|
||||
|
||||
#### Note: API Keys
|
||||
|
||||
It is highly recommended for production services that to acquire and specify an API Key for each sercice.
|
||||
It is highly recommended for production services to acquire and specify an API Key for each service.
|
||||
|
||||
The default API Keys used by ethers are shared across all users, so services may throttle all services that are using the default API Keys during periods of load without realizing it.
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ EtherscanProvider
|
||||
|
||||
Create a new **EtherscanProvider** connected to *network* with the optional *apiKey*.
|
||||
|
||||
The *network* may be specified as **string** for a common network name, a **number** for a common chain ID or a [Network Object]provider-(network).
|
||||
The *network* may be specified as a **string** for a common network name, a **number** for a common chain ID or a [Network Object]provider-(network).
|
||||
|
||||
If no *apiKey* is provided, a shared API key will be used, which may result in reduced performance and throttled requests. It is highly recommended for production, you register with [Etherscan](https://etherscan.io) for your own API key.
|
||||
|
||||
@@ -71,7 +71,7 @@ InfuraProvider
|
||||
|
||||
Create a new **InfuraProvider** connected to *network* with the optional *apiKey*.
|
||||
|
||||
The *network* may be specified as **string** for a common network name, a **number** for a common chain ID or a [Network Object]provider-(network).
|
||||
The *network* may be specified as a **string** for a common network name, a **number** for a common chain ID or a [Network Object]provider-(network).
|
||||
|
||||
The *apiKey* can be a **string** Project ID or an **object** with the properties `projectId` and `projectSecret` to specify a [Project Secret](https://infura.io/docs/gettingStarted/authentication) which can be used on non-public sources (like on a server) to further secure your API access and quotas.
|
||||
|
||||
@@ -130,7 +130,7 @@ AlchemyProvider
|
||||
|
||||
Create a new **AlchemyProvider** connected to *network* with the optional *apiKey*.
|
||||
|
||||
The *network* may be specified as **string** for a common network name, a **number** for a common chain ID or a [Network Object](/v5/api/providers/types/#providers-Network).
|
||||
The *network* may be specified as a **string** for a common network name, a **number** for a common chain ID or a [Network Object](/v5/api/providers/types/#providers-Network).
|
||||
|
||||
|
||||
#### Note: Default API keys
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -36,7 +36,7 @@ The provider for this configuration.
|
||||
|
||||
#### *fallbackProviderConfig* . **priority** => *number*
|
||||
|
||||
The priority used for the provider. Higher priorities are favoured over lower priorities. If multiple providers share the same prioirty, they are choosen at random.
|
||||
The priority used for the provider. Higher priorities are favoured over lower priorities. If multiple providers share the same priority, they are chosen at random.
|
||||
|
||||
|
||||
#### *fallbackProviderConfig* . **stallTimeout** => *number*
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -33,7 +33,7 @@ Returns the number of transactions *address* has ever **sent**, as of *blockTag*
|
||||
```javascript
|
||||
// Get the balance for an account...
|
||||
provider.getBalance("ricmoo.firefly.eth");
|
||||
// { Promise: { BigNumber: "1492974808274631213" } }
|
||||
// { Promise: { BigNumber: "284831012276355695" } }
|
||||
|
||||
// Get the code for a contract...
|
||||
provider.getCode("registrar.firefly.eth");
|
||||
@@ -45,7 +45,7 @@ provider.getStorageAt("registrar.firefly.eth", 0)
|
||||
|
||||
// Get transaction count of an account...
|
||||
provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
// { Promise: 679 }
|
||||
// { Promise: 689 }
|
||||
```
|
||||
|
||||
Blocks Methods
|
||||
@@ -96,7 +96,7 @@ provider.getBlockWithTransactions(100004)
|
||||
// blockHash: '0xf93283571ae16dcecbe1816adc126954a739350cd1523a1559eabeae155fbb63',
|
||||
// blockNumber: 100004,
|
||||
// chainId: 0,
|
||||
// confirmations: 10719007,
|
||||
// confirmations: 11212224,
|
||||
// creates: null,
|
||||
// data: '0x',
|
||||
// from: '0xcf00A85f3826941e7A25BFcF9Aac575d40410852',
|
||||
@@ -177,16 +177,16 @@ provider.getNetwork()
|
||||
|
||||
// The current block number
|
||||
provider.getBlockNumber()
|
||||
// { Promise: 10819010 }
|
||||
// { Promise: 11312227 }
|
||||
|
||||
// Get the current suggested gas price (in wei)...
|
||||
gasPrice = await provider.getGasPrice()
|
||||
// { BigNumber: "69000000000" }
|
||||
// { BigNumber: "46200000000" }
|
||||
|
||||
// ...often this gas price is easier to understand or
|
||||
// display to the user in gwei (giga-wei, or 1e9 wei)
|
||||
utils.formatUnits(gasPrice, "gwei")
|
||||
// '69.0'
|
||||
// '46.2'
|
||||
```
|
||||
|
||||
Transactions Methods
|
||||
@@ -194,7 +194,7 @@ Transactions Methods
|
||||
|
||||
#### *provider* . **call**( transaction [ , blockTag = latest ] ) => *Promise< string< [DataHexString](/v5/api/utils/bytes/#DataHexString) > >*
|
||||
|
||||
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 gettings on Contracts.
|
||||
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.
|
||||
|
||||
|
||||
#### *provider* . **estimateGas**( transaction ) => *Promise< [BigNumber](/v5/api/utils/bignumber/) >*
|
||||
@@ -224,7 +224,7 @@ Add a *listener* to be triggered for each *eventName*.
|
||||
|
||||
#### *provider* . **once**( eventName , listener ) => *this*
|
||||
|
||||
Add a *listener* to be triggered for only the next *eventName*, at which time it be removed.
|
||||
Add a *listener* to be triggered for only the next *eventName*, at which time it will be removed.
|
||||
|
||||
|
||||
#### *provider* . **emit**( eventName , ...args ) => *boolean*
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -60,21 +60,21 @@ The timestamp of this block.
|
||||
|
||||
The nonce used as part of the proof-of-work to mine this block.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
|
||||
#### *block* . **difficulty** => *number*
|
||||
|
||||
The difficulty target required to be met by the miner of the block.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
|
||||
#### *block* . **gasLimit** => *[BigNumber](/v5/api/utils/bignumber/)*
|
||||
|
||||
The maximum amount of gas that this block was permitted to use. This is a value that can be voted up or voted down by miners and is used to automatically adjust the bandwidth requirements of the network.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
|
||||
#### *block* . **gasUsed** => *[BigNumber](/v5/api/utils/bignumber/)*
|
||||
@@ -91,7 +91,7 @@ The coinbase address of this block, which indicates the address the miner that m
|
||||
|
||||
This is extra data a miner may choose to include when mining a block.
|
||||
|
||||
This property is generally of little interest developers.
|
||||
This property is generally of little interest to developers.
|
||||
|
||||
|
||||
### Block (with transaction hashes)
|
||||
@@ -277,7 +277,7 @@ Wait for *confirmations*. If 0, and the transaction has not been mined, `null` i
|
||||
|
||||
#### *receipt* . **to** => *string< [Address](/v5/api/utils/address/#address) >*
|
||||
|
||||
The address this transaction is to. This is `null` if the the transaction was an **init transaction**, used to deploy a contract.
|
||||
The address this transaction is to. This is `null` if the transaction was an **init transaction**, used to deploy a contract.
|
||||
|
||||
|
||||
#### *receipt* . **from** => *string< [Address](/v5/api/utils/address/#address) >*
|
||||
@@ -313,7 +313,7 @@ The amount of gas actually used by this transaction.
|
||||
|
||||
#### *receipt* . **logsBloom** => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString) >*
|
||||
|
||||
A [bloom-filter](https://en.wikipedia.org/wiki/Bloom_filter), which incldues all the addresses and topics included in any log in this transaction.
|
||||
A [bloom-filter](https://en.wikipedia.org/wiki/Bloom_filter), which includes all the addresses and topics included in any log in this transaction.
|
||||
|
||||
|
||||
#### *receipt* . **blockHash** => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
@@ -343,7 +343,7 @@ The number of blocks that have been mined since this transaction, including the
|
||||
|
||||
#### *receipt* . **cumulativeGasUsed** => *[BigNumber](/v5/api/utils/bignumber/)*
|
||||
|
||||
For the block this transaction was included in, this is the sum of the gas used used by each transaction in the ordered list of transactions up to (and including) this transaction.
|
||||
For the block this transaction was included in, this is the sum of the gas used by each transaction in the ordered list of transactions up to (and including) this transaction.
|
||||
|
||||
This is generally of little interest to developers.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -103,22 +103,72 @@ This method populates the transactionRequest with missing fields, using [populat
|
||||
Sub-classes **must** implement this, however they may throw if sending a transaction is not supported, such as the [VoidSigner](/v5/api/signer/#VoidSigner) or if the Wallet is offline and not connected to a [Provider](/v5/api/providers/provider/).
|
||||
|
||||
|
||||
#### *signer* . **_signTypedData**( domain , types , value ) => *Promise< string< [RawSignature](/v5/api/utils/bytes/#signature-raw) > >*
|
||||
|
||||
Signs the typed data *value* with *types* data structure for *domain* using the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) specification.
|
||||
|
||||
|
||||
#### Experimental feature (this method name will change)
|
||||
|
||||
This is still an experimental feature. If using it, please specify the **exact** version of ethers you are using (e.g. spcify `"5.0.18"`, **not** `"^5.0.18"`) as the method name will be renamed from `_signTypedData` to `signTypedData` once it has been used in the field a bit.
|
||||
|
||||
|
||||
```javascript
|
||||
// All properties on a domain are optional
|
||||
const domain = {
|
||||
name: 'Ether Mail',
|
||||
version: '1',
|
||||
chainId: 1,
|
||||
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
|
||||
};
|
||||
|
||||
// The named list of all type definitions
|
||||
const types = {
|
||||
Person: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'wallet', type: 'address' }
|
||||
],
|
||||
Mail: [
|
||||
{ name: 'from', type: 'Person' },
|
||||
{ name: 'to', type: 'Person' },
|
||||
{ name: 'contents', type: 'string' }
|
||||
]
|
||||
};
|
||||
|
||||
// The data to sign
|
||||
const value = {
|
||||
from: {
|
||||
name: 'Cow',
|
||||
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
|
||||
},
|
||||
to: {
|
||||
name: 'Bob',
|
||||
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
|
||||
},
|
||||
contents: 'Hello, Bob!'
|
||||
};
|
||||
|
||||
|
||||
const signature = await signer._signTypedData(domain, types, value);
|
||||
// '0x463b9c9971d1a144507d2e905f4e98becd159139421a4bb8d3c9c2ed04eb401057dd0698d504fd6ca48829a3c8a7a98c1c961eae617096cb54264bbdd082e13d1c'
|
||||
```
|
||||
|
||||
### Sub-Classes
|
||||
|
||||
#### *signer* . **checkTransaction**( transactionRequest ) => *[TransactionRequest](/v5/api/providers/types/#providers-TransactionRequest)*
|
||||
|
||||
This is generally not required to be overridden, but may needed to provide custom behaviour in sub-classes.
|
||||
This is generally not required to be overridden, but may be needed to provide custom behaviour in sub-classes.
|
||||
|
||||
This should return a **copy** of the *transactionRequest*, with any properties needed by `call`, `estimateGas` and `populateTransaction` (which is used by sendTransaction). It should also throw an error if any unknown key is specified.
|
||||
|
||||
The default implementation checks only valid [TransactionRequest](/v5/api/providers/types/#providers-TransactionRequest) properties exist and adds `from` to the transaction if it does not exist.
|
||||
The default implementation checks only if valid [TransactionRequest](/v5/api/providers/types/#providers-TransactionRequest) properties exist and adds `from` to the transaction if it does not exist.
|
||||
|
||||
If there is a `from` field it **must** be verified to be equal to the Signer's address.
|
||||
|
||||
|
||||
#### *signer* . **populateTransaction**( transactionRequest ) => *Promise< [TransactionRequest](/v5/api/providers/types/#providers-TransactionRequest) >*
|
||||
|
||||
This is generally not required to be overridden, but may needed to provide custom behaviour in sub-classes.
|
||||
This is generally not required to be overridden, but may be needed to provide custom behaviour in sub-classes.
|
||||
|
||||
This should return a **copy** of *transactionRequest*, follow the same procedure as `checkTransaction` and fill in any properties required for sending a transaction. The result should have all promises resolved; if needed the [resolveProperties](/v5/api/utils/properties/#utils-resolveproperties) utility function can be used for this.
|
||||
|
||||
@@ -172,7 +222,7 @@ The address for the account this Wallet represents.
|
||||
|
||||
#### *wallet* . **provider** => *[Provider](/v5/api/providers/provider/)*
|
||||
|
||||
The provider this wallet is connected to, which will ge used for any [Blockchain Methods](/v5/api/signer/#Signer--blockchain-methods) methods. This can be null.
|
||||
The provider this wallet is connected to, which will be used for any [Blockchain Methods](/v5/api/signer/#Signer--blockchain-methods) methods. This can be null.
|
||||
|
||||
|
||||
#### Note
|
||||
@@ -285,7 +335,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
// Get the number of tokens for this account
|
||||
tokens = await contract.balanceOf(signer.getAddress())
|
||||
// { BigNumber: "11386855832278858351495" }
|
||||
// { BigNumber: "15923148775162018481031" }
|
||||
|
||||
//
|
||||
// Pre-flight (check for revert) on DAI from the signer
|
||||
@@ -302,7 +352,7 @@ contract.callStatic.transfer("donations.ethers.eth", tokens)
|
||||
|
||||
// This will fail since it is greater than the token balance
|
||||
contract.callStatic.transfer("donations.ethers.eth", tokens.add(1))
|
||||
// Error: call revert exception (method="transfer(address,uint256)", errorSignature="Error(string)", errorArgs=["Dai/insufficient-balance"], reason="Dai/insufficient-balance", code=CALL_EXCEPTION, version=abi/5.0.4)
|
||||
// Error: call revert exception (method="transfer(address,uint256)", errorSignature="Error(string)", errorArgs=["Dai/insufficient-balance"], reason="Dai/insufficient-balance", code=CALL_EXCEPTION, version=abi/5.0.9)
|
||||
```
|
||||
|
||||
ExternallyOwnedAccount
|
||||
@@ -320,6 +370,6 @@ The privateKey of this EOA
|
||||
|
||||
#### *eoa* . **mnemonic** => *[Mnemonic](/v5/api/utils/hdnode/#Mnemonic)*
|
||||
|
||||
*Optional*. The account HD mnemonic, if it has one and can be determined. Some sources do not encode the mnemonic, such as an HD extended keys.
|
||||
*Optional*. The account HD mnemonic, if it has one and can be determined. Some sources do not encode the mnemonic, such as HD extended keys.
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -29,7 +29,7 @@ Coding Methods
|
||||
|
||||
#### *abiCoder* . **encode**( types , values ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString) >*
|
||||
|
||||
Encode the array *values* according the array of *types*, each of which may be a string or a [ParamType](/v5/api/utils/abi/fragments/#ParamType).
|
||||
Encode the array *values* according to the array of *types*, each of which may be a string or a [ParamType](/v5/api/utils/abi/fragments/#ParamType).
|
||||
|
||||
|
||||
#### *abiCoder* . **decode**( types , data ) => *[Result](/v5/api/utils/abi/interface/#Result)*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ Formats
|
||||
|
||||
#### *ethers* . *utils* . *FragmentTypes* . **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 readabiliy.
|
||||
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.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . *FragmentTypes* . **minimal** => *string*
|
||||
@@ -64,7 +64,7 @@ This is a string which indicates the type of the [Fragment](/v5/api/utils/abi/fr
|
||||
|
||||
#### *fragment* . **inputs** => *Array< [ParamType](/v5/api/utils/abi/fragments/#ParamType) >*
|
||||
|
||||
This is an array of of each [ParamType](/v5/api/utils/abi/fragments/#ParamType) for the input parameters to the Constructor, Event of Function.
|
||||
This is an array of each [ParamType](/v5/api/utils/abi/fragments/#ParamType) for the input parameters to the Constructor, Event of Function.
|
||||
|
||||
|
||||
### Methods
|
||||
@@ -204,12 +204,12 @@ Whether the parameter has been marked as indexed. This **only** applies to param
|
||||
|
||||
#### *paramType* . **arrayChildren** => *[ParamType](/v5/api/utils/abi/fragments/#ParamType)*
|
||||
|
||||
The type of children of the array. This is null for for any parameter wjhich is not an array.
|
||||
The type of children of the array. This is null for any parameter which is not an array.
|
||||
|
||||
|
||||
#### *paramType* . **arrayLength** => *number*
|
||||
|
||||
The length of the array, or `-1` for dynamic-length arrays. This is null for parameters which is not arrays.
|
||||
The length of the array, or `-1` for dynamic-length arrays. This is null for parameters which are not arrays.
|
||||
|
||||
|
||||
#### *paramType* . **components** => *Array< [ParamType](/v5/api/utils/abi/fragments/#ParamType) >*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -85,7 +85,7 @@ BigNumber.from(42n)
|
||||
|
||||
// Numbers outside the safe range fail:
|
||||
BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.6)
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.11)
|
||||
```
|
||||
|
||||
Methods
|
||||
@@ -133,16 +133,16 @@ Returns a BigNumber with the absolute value of *BigNumber*.
|
||||
Returns a BigNumber with the value of *BigNumber* with bits beyond the *bitcount* least significant bits set to zero.
|
||||
|
||||
|
||||
### Two's Compliment
|
||||
### Two's Complement
|
||||
|
||||
#### *BigNumber* . **fromTwos**( bitwidth ) => *[BigNumber](/v5/api/utils/bignumber/)*
|
||||
|
||||
Returns a BigNumber with the value of *BigNumber* converted from twos-compliment with *bitwidth*.
|
||||
Returns a BigNumber with the value of *BigNumber* converted from twos-complement with *bitwidth*.
|
||||
|
||||
|
||||
#### *BigNumber* . **toTwos**( bitwidth ) => *[BigNumber](/v5/api/utils/bignumber/)*
|
||||
|
||||
Returns a BigNumber with the value of *BigNumber* converted to twos-compliment with *bitwidth*.
|
||||
Returns a BigNumber with the value of *BigNumber* converted to twos-complement with *bitwidth*.
|
||||
|
||||
|
||||
### Comparison and Equivalence
|
||||
@@ -198,7 +198,7 @@ Returns the value of *BigNumber* as a base-16, `0x`-prefixed [DataHexString](/v5
|
||||
|
||||
### Inspection
|
||||
|
||||
#### *ethers* . *BigNumnber* . **isBigNumber**( object ) => *boolean*
|
||||
#### *ethers* . *BigNumber* . **isBigNumber**( object ) => *boolean*
|
||||
|
||||
Returns true if and only if the *object* is a BigNumber object.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -101,7 +101,7 @@ Returns a Uint8Array with all leading `0` bytes of *aBtyesLike* removed.
|
||||
|
||||
#### *ethers* . *utils* . **zeroPad**( aBytesLike , length ) => *Uint8Array*
|
||||
|
||||
Retutns a Uint8Array of the data in *aBytesLike* with `0` bytes prepended to *length* bytes long.
|
||||
Returns a Uint8Array of the data in *aBytesLike* with `0` bytes prepended to *length* bytes long.
|
||||
|
||||
If *aBytesLike* is already longer than *length* bytes long, an InvalidArgument error will be thrown.
|
||||
|
||||
@@ -164,20 +164,20 @@ Return a copy of *array* shuffled using [Fisher-Yates Shuffle](https://en.wikipe
|
||||
|
||||
```javascript
|
||||
utils.randomBytes(8)
|
||||
// Uint8Array [ 98, 93, 74, 126, 111, 146, 146, 3 ]
|
||||
// Uint8Array [ 82, 221, 254, 37, 192, 138, 147, 109 ]
|
||||
|
||||
const data = [ 1, 2, 3, 4, 5, 6, 7 ];
|
||||
|
||||
// Returns a new Array
|
||||
utils.shuffled(data);
|
||||
// [
|
||||
// 5,
|
||||
// 2,
|
||||
// 6,
|
||||
// 1,
|
||||
// 4,
|
||||
// 5,
|
||||
// 3,
|
||||
// 2,
|
||||
// 7,
|
||||
// 3
|
||||
// 4,
|
||||
// 1
|
||||
// ]
|
||||
|
||||
// The Original is unscathed...
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -40,7 +40,7 @@ Recursive-Length Prefix
|
||||
|
||||
Encode a structured Data Object into its RLP-encoded representation.
|
||||
|
||||
Each Data component may be an valid [BytesLike](/v5/api/utils/bytes/#BytesLike).
|
||||
Each Data component may be a valid [BytesLike](/v5/api/utils/bytes/#BytesLike).
|
||||
|
||||
|
||||
#### *ethers* . *utils* . *RLP* . **decode**( aBytesLike ) => *[DataObject](/v5/api/utils/encoding/#rlp--dataobject)*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -12,7 +12,7 @@ Cryptographic Hash Functions
|
||||
|
||||
#### *ethers* . *utils* . **id**( text ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
|
||||
The Ethereum Identity function computs the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) hash of the *text* bytes.
|
||||
The Ethereum Identity function computes the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) hash of the *text* bytes.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **keccak256**( aBytesLike ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
@@ -52,7 +52,7 @@ utils.keccak256("0x1234")
|
||||
|
||||
// Do NOT use UTF-8 strings that are not a DataHexstring
|
||||
utils.keccak256("hello world")
|
||||
// Error: invalid arrayify value (argument="value", value="hello world", code=INVALID_ARGUMENT, version=bytes/5.0.4)
|
||||
// Error: invalid arrayify value (argument="value", value="hello world", code=INVALID_ARGUMENT, version=bytes/5.0.6)
|
||||
|
||||
// If needed, convert strings to bytes first:
|
||||
utils.keccak256(utils.toUtf8Bytes("hello world"))
|
||||
@@ -77,7 +77,7 @@ utils.keccak256("0x1234")
|
||||
utils.keccak256([ 0x12, 0x34 ])
|
||||
// '0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432'
|
||||
|
||||
const bytes = utils.toUtf8Bytes("0x1234");
|
||||
const bytes = utils.toUtf8Bytes("0x1234")
|
||||
// Uint8Array [ 48, 120, 49, 50, 51, 52 ]
|
||||
|
||||
// Hash of SIX (6) characters (different than above)
|
||||
@@ -132,8 +132,8 @@ Use the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
||||
|
||||
|
||||
```javascript
|
||||
const key = "0x0102";
|
||||
const data = "0x1234";
|
||||
const key = "0x0102"
|
||||
const data = "0x1234"
|
||||
utils.computeHmac("sha256", key, data)
|
||||
// '0x7553df81c628815cf569696cad13a37c606c5058df13d9dff4fee2cf5e9b5779'
|
||||
```
|
||||
@@ -146,15 +146,41 @@ Hashing Helpers
|
||||
Computes the [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal message digest of *message*. Personal messages are converted to UTF-8 bytes and prefixed with `\x19Ethereum Signed Message:` and the length of *message*.
|
||||
|
||||
|
||||
```javascript
|
||||
// Hashing a string message
|
||||
utils.hashMessage("Hello World")
|
||||
// '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
|
||||
|
||||
// Hashing binary data (also "Hello World", but as bytes)
|
||||
utils.hashMessage( [ 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 ])
|
||||
// '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
|
||||
|
||||
// NOTE: It is important to understand how strings and binary
|
||||
// data is handled differently. A string is ALWAYS processed
|
||||
// as the bytes of the string, so a hexstring MUST be
|
||||
// converted to an ArrayLike object first.
|
||||
|
||||
// Hashing a hex string is the same as hashing a STRING
|
||||
// Note: this is the hash of the 4 characters [ '0', 'x', '4', '2' ]
|
||||
utils.hashMessage("0x42")
|
||||
// '0xf0d544d6e4a96e1c08adc3efabe2fcb9ec5e28db1ad6c33ace880ba354ab0fce'
|
||||
|
||||
// Hashing the binary data
|
||||
// Note: this is the hash of the 1 byte [ 0x42 ]
|
||||
utils.hashMessage([ 0x42 ])
|
||||
// '0xd18c12b87124f9ceb7e1d3a5d06a5ac92ecab15931417e8d1558d9a263f99d63'
|
||||
|
||||
// Hashing the binary data
|
||||
// Note: similarly, this is the hash of the 1 byte [ 0x42 ]
|
||||
utils.hashMessage(utils.arrayify("0x42"))
|
||||
// '0xd18c12b87124f9ceb7e1d3a5d06a5ac92ecab15931417e8d1558d9a263f99d63'
|
||||
```
|
||||
|
||||
#### *ethers* . *utils* . **namehash**( name ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
|
||||
Returns the [ENS Namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) of *name*.
|
||||
|
||||
|
||||
```javascript
|
||||
// @TODO: include examples of hashMessage; it can be complex. :)
|
||||
```
|
||||
|
||||
```javascript
|
||||
utils.namehash("")
|
||||
// '0x0000000000000000000000000000000000000000000000000000000000000000'
|
||||
@@ -169,12 +195,154 @@ utils.namehash("ricmoo.xyz")
|
||||
// '0x7d56aa46358ba2f8b77d8e05bcabdd2358370dcf34e87810f8cea77ecb3fc57d'
|
||||
```
|
||||
|
||||
### Typed Data Encoder
|
||||
|
||||
#### Experimental Feature (this exported class name will change)
|
||||
|
||||
This is still an experimental feature. If using it, please specify the **exact** version of ethers you are using (e.g. spcify `"5.0.18"`, **not** `"^5.0.18"`) as the exported class name will be renamed from `_TypedDataEncoder` to `TypedDataEncoder` once it has been used in the field a bit.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . *_TypedDataEncoder* . **from**( types ) => *[TypedDataEncoder]*
|
||||
|
||||
Creates a new **TypedDataEncoder** for *types*. This object is a fairly low-level object that most developers should not require using instances directly.
|
||||
|
||||
Most developers will find the static class methods below the most useful.
|
||||
|
||||
|
||||
#### *TypedDataEncoder* . **encode**( domain , types , values ) => *string*
|
||||
|
||||
Encodes the Returns the hashed [EIP-712](https://eips.ethereum.org/EIPS/eip-712) domain.
|
||||
|
||||
|
||||
#### *TypedDataEncoder* . **getPayload**( domain , types , value ) => *any*
|
||||
|
||||
Returns the standard payload used by various JSON-RPC `eth_signTypedData*` calls.
|
||||
|
||||
All domain values and entries in value are normalized and the types are verified.
|
||||
|
||||
|
||||
#### *TypedDataEncoder* . **getPrimaryType**( types ) => *string*
|
||||
|
||||
Constructs a directed acyclic graph of the types and returns the root type, which can be used as the **primaryType** for [EIP-712](https://eips.ethereum.org/EIPS/eip-712) payloads.
|
||||
|
||||
|
||||
#### *TypedDataEncoder* . **hash**( domain , types , values ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
|
||||
Returns the computed [EIP-712](https://eips.ethereum.org/EIPS/eip-712) hash.
|
||||
|
||||
|
||||
#### *TypedDataEncoder* . **hashDomain**( domain ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
|
||||
Returns the hashed [EIP-712](https://eips.ethereum.org/EIPS/eip-712) domain.
|
||||
|
||||
|
||||
#### *TypedDataEncoder* . **resolveNames**( domain , types , value , resolveName ) => *Promise< any >*
|
||||
|
||||
Returns a copy of value, where any leaf value with a type of `address` will have been recursively replacedwith the value of calling *resolveName* with that value.
|
||||
|
||||
|
||||
```javascript
|
||||
const domain = {
|
||||
name: 'Ether Mail',
|
||||
version: '1',
|
||||
chainId: 1,
|
||||
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
|
||||
}
|
||||
|
||||
// The named list of all type definitions
|
||||
const types = {
|
||||
Person: [
|
||||
{ name: 'name', type: 'string' },
|
||||
{ name: 'wallet', type: 'address' }
|
||||
],
|
||||
Mail: [
|
||||
{ name: 'from', type: 'Person' },
|
||||
{ name: 'to', type: 'Person' },
|
||||
{ name: 'contents', type: 'string' }
|
||||
]
|
||||
}
|
||||
|
||||
// The data to sign
|
||||
const value = {
|
||||
from: {
|
||||
name: 'Cow',
|
||||
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
|
||||
},
|
||||
to: {
|
||||
name: 'Bob',
|
||||
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
|
||||
},
|
||||
contents: 'Hello, Bob!'
|
||||
}
|
||||
|
||||
|
||||
TypedDataEncoder.encode(domain, types, value)
|
||||
// '0x1901f2cee375fa42b42143804025fc449deafd50cc031ca257e0b194a650a912090fc52c0ee5d84264471806290a3f2c4cecfc5490626bf912d01f240d7a274b371e'
|
||||
|
||||
TypedDataEncoder.getPayload(domain, types, value)
|
||||
// {
|
||||
// domain: {
|
||||
// chainId: '1',
|
||||
// name: 'Ether Mail',
|
||||
// verifyingContract: '0xcccccccccccccccccccccccccccccccccccccccc',
|
||||
// version: '1'
|
||||
// },
|
||||
// message: {
|
||||
// contents: 'Hello, Bob!',
|
||||
// from: {
|
||||
// name: 'Cow',
|
||||
// wallet: '0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826'
|
||||
// },
|
||||
// to: {
|
||||
// name: 'Bob',
|
||||
// wallet: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
||||
// }
|
||||
// },
|
||||
// primaryType: 'Mail',
|
||||
// types: {
|
||||
// Mail: [
|
||||
// {
|
||||
// name: 'from',
|
||||
// type: 'Person'
|
||||
// },
|
||||
// {
|
||||
// name: 'to',
|
||||
// type: 'Person'
|
||||
// },
|
||||
// {
|
||||
// name: 'contents',
|
||||
// type: 'string'
|
||||
// }
|
||||
// ],
|
||||
// Person: [
|
||||
// {
|
||||
// name: 'name',
|
||||
// type: 'string'
|
||||
// },
|
||||
// {
|
||||
// name: 'wallet',
|
||||
// type: 'address'
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
|
||||
TypedDataEncoder.getPrimaryType(types)
|
||||
// 'Mail'
|
||||
|
||||
TypedDataEncoder.hash(domain, types, value)
|
||||
// '0xbe609aee343fb3c4b28e1df9e632fca64fcfaede20f02e86244efddf30957bd2'
|
||||
|
||||
TypedDataEncoder.hashDomain(domain)
|
||||
// '0xf2cee375fa42b42143804025fc449deafd50cc031ca257e0b194a650a912090f'
|
||||
```
|
||||
|
||||
Solidity Hashing Algorithms
|
||||
---------------------------
|
||||
|
||||
#### *ethers* . *utils* . **solidityPack**( types , values ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString) >*
|
||||
|
||||
Returns the non-standard encoded *values* packed according to their respecive type in *types*.
|
||||
Returns the non-standard encoded *values* packed according to their respective type in *types*.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **solidityKeccak256**( types , values ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > >*
|
||||
@@ -199,5 +367,23 @@ utils.solidityKeccak256([ "int16", "uint48" ], [ -1, 12 ])
|
||||
|
||||
utils.soliditySha256([ "int16", "uint48" ], [ -1, 12 ])
|
||||
// '0xa5580fb602f6e2ba9c588011dc4e6c2335e0f5d970dc45869db8f217efc6911a'
|
||||
|
||||
// As a short example of the non-distinguished nature of
|
||||
// Solidity tight-packing (which is why it is inappropriate
|
||||
// for many things from a security point of view), consider
|
||||
// the following examples are all equal, despite representing
|
||||
// very different values and layouts.
|
||||
|
||||
utils.solidityPack([ "string", "string" ], [ "hello", "world01" ])
|
||||
// '0x68656c6c6f776f726c643031'
|
||||
|
||||
utils.solidityPack([ "string", "string" ], [ "helloworld", "01" ])
|
||||
// '0x68656c6c6f776f726c643031'
|
||||
|
||||
utils.solidityPack([ "string", "string", "uint16" ], [ "hell", "oworld", 0x3031 ])
|
||||
// '0x68656c6c6f776f726c643031'
|
||||
|
||||
utils.solidityPack([ "uint96" ], [ "32309054545061485574011236401" ])
|
||||
// '0x68656c6c6f776f726c643031'
|
||||
```
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -125,7 +125,7 @@ A serialized string representation of this HDNode. Not all properties are includ
|
||||
|
||||
#### *hdNode* . **neuter**( ) => *[HDNode](/v5/api/utils/hdnode/#HDNode)*
|
||||
|
||||
Return a new instance of *hdNode* with its private key removed but all otehr properties preserved. This ensures that the key can not leak the private key of itself or any derived children, but may still be used to compute the addresses of itself and any non-hardened children.
|
||||
Return a new instance of *hdNode* with its private key removed but all other properties preserved. This ensures that the key can not leak the private key of itself or any derived children, but may still be used to compute the addresses of itself and any non-hardened children.
|
||||
|
||||
|
||||
#### *hdNode* . **derivePath**( path ) => *[HDNode](/v5/api/utils/hdnode/#HDNode)*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -58,10 +58,10 @@ Throw an [INVALID_ARGUMENT](/v5/api/utils/logger/#errors-InvalidArgument) Error
|
||||
|
||||
#### *logger* . **checkAbstract**( target , kind ) => *void*
|
||||
|
||||
Checks that *target* is not *kind* and performs the same operatons as `checkNew`. This is useful for ensuring abstract classes are not being instantiated.
|
||||
Checks that *target* is not *kind* and performs the same operations as `checkNew`. This is useful for ensuring abstract classes are not being instantiated.
|
||||
|
||||
|
||||
#### *logger* . **checkArgumentCount**( count , expectedCound [ , message ) => *void*
|
||||
#### *logger* . **checkArgumentCount**( count , expectedCount [ , message ) => *void*
|
||||
|
||||
If *count* is not equal to *expectedCount*, throws a [MISSING_ARGUMENT](/v5/api/utils/logger/#errors-MissingArgument) or [UNEXPECTED_ARGUMENT](/v5/api/utils/logger/#errors-UnexpectedArgument) error.
|
||||
|
||||
@@ -215,7 +215,7 @@ Log all output, including debugging information.
|
||||
|
||||
#### *Logger* . *levels* . **INFO**
|
||||
|
||||
Only log output for infomational, warnings and errors.
|
||||
Only log output for informational, warnings and errors.
|
||||
|
||||
|
||||
#### *Logger* . *levels* . **WARNING**
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -19,12 +19,12 @@ The private key for this Signing Key.
|
||||
|
||||
#### *signingKey* . **publicKey** => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 65 > >*
|
||||
|
||||
The uncompressed public key for this Signing Key. It will always be 65 bytes (130 nibbles) and begine with `0x04`.
|
||||
The uncompressed public key for this Signing Key. It will always be 65 bytes (130 nibbles) and begins with `0x04`.
|
||||
|
||||
|
||||
#### *signingKey* . **compressedPublicKey** => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 33 > >*
|
||||
|
||||
The compressed public key for this Signing Key. It will always be 33 bytes (66 nibbles) and begine with either `0x02` or `0x03`.
|
||||
The compressed public key for this Signing Key. It will always be 33 bytes (66 nibbles) and begins with either `0x02` or `0x03`.
|
||||
|
||||
|
||||
#### *signingKey* . **signDigest**( digest ) => *[Signature](/v5/api/utils/bytes/#Signature)*
|
||||
@@ -52,8 +52,14 @@ Other Functions
|
||||
Returns the address that signed *message* producing *signature*. The signature may have a non-canonical v (i.e. does not need to be 27 or 28), in which case it will be normalized to compute the `recoveryParam` which will then be used to compute the address; this allows systems which use the v to encode additional data (such as [EIP-155](https://eips.ethereum.org/EIPS/eip-155)) to be used since the v parameter is still completely non-ambiguous.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **verifyTypedData**( domain , types , value , signature ) => *string< [Address](/v5/api/utils/address/#address) >*
|
||||
|
||||
Returns the address that signed the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) *value* for the *domain* and *types* to produce the signature.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **recoverPublicKey**( digest , signature ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 65 > >*
|
||||
|
||||
Returns the uncompressed public key (i.e. the first byte will be `0x04`) of the private key that was used to sign *digest* which gave the *signature*.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **computePublicKey**( key [ , compressed = false ] ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString) >*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user