docs: fixed typos and improve migration docs (#3717, #3721, #3723, #3725, #3736, #3795).

This commit is contained in:
Richard Moore 2023-02-18 22:16:58 -05:00
parent 399356b912
commit b39e955eb6
5 changed files with 120 additions and 27 deletions

@ -1,4 +1,4 @@
_section: Contributings and Hacking @<about-contrib> @priority<-90> _section: Contributions and Hacking @<about-contrib> @priority<-90>
Pull requests are welcome, but please keep the following in mind: Pull requests are welcome, but please keep the following in mind:
@ -93,7 +93,7 @@ _subsection: Adding Features @<about-contrib-feature>
Contributing new features usually require a deeper understanding Contributing new features usually require a deeper understanding
of the internal interactions with Ethers and its components, and of the internal interactions with Ethers and its components, and
generally requires a minor version bumpincludes anything w generally requires a minor version bump.
When making any of the following changes, you must first open a When making any of the following changes, you must first open a
[[link-discussion]] as the minor version will need to be bumped. [[link-discussion]] as the minor version will need to be bumped.

@ -48,7 +48,7 @@ objects available and what they are responsible for, at a high level.
_heading: Provider _heading: Provider
A [[Provider]] is a read-only connection to the blockchain, which allows A [[Provider]] is a read-only connection to the blockchain, which allows
querying the blockchain state, such as accout, block or transaction details, querying the blockchain state, such as account, block or transaction details,
querying event logs or evaluating read-only code using call. querying event logs or evaluating read-only code using call.
If you are coming from Web3.js, you are used to a **Provider** offering If you are coming from Web3.js, you are used to a **Provider** offering
@ -118,7 +118,7 @@ extension that injects objects into the ``window``, providing:
- authenticated write access backed by a private key (a [[Signer]]) - authenticated write access backed by a private key (a [[Signer]])
When requesting access to the authenticated methods, such as When requesting access to the authenticated methods, such as
sending a transaction or even requesting the private key addess, sending a transaction or even requesting the private key address,
MetaMask will show a pop-up to the user asking for permission. MetaMask will show a pop-up to the user asking for permission.
_code: @lang<script> _code: @lang<script>
@ -172,7 +172,7 @@ _code: connecting to a JSON-RPC URL @lang<script>
_subsection: User Interaction @<starting-display> _subsection: User Interaction @<starting-display>
All units in Ethereum tend to be integer values, since dealing with All units in Ethereum tend to be integer values, since dealing with
decimals and floating points can lead to inprecise and non-obvious decimals and floating points can lead to imprecise and non-obvious
results when performing mathematic operations. results when performing mathematic operations.
As a result, the internal units used (e.g. wei) which are suited for As a result, the internal units used (e.g. wei) which are suited for
@ -272,7 +272,7 @@ _subsection: Contracts @<starting-contracts>
A **Contract** is a meta-class, which means that its definition A **Contract** is a meta-class, which means that its definition
its derived at run-time, based on the ABI it is passed, which then its derived at run-time, based on the ABI it is passed, which then
determined what mehods and properties are available on it. determined what methods and properties are available on it.
_heading: Application Binary Interface (ABI) _heading: Application Binary Interface (ABI)
@ -291,7 +291,7 @@ Any methods or events that are not needed can be safely excluded.
There are several common formats available to describe an ABI. The There are several common formats available to describe an ABI. The
Solidity compiler usually dumps a JSON representation but when typing Solidity compiler usually dumps a JSON representation but when typing
an ABI by hand it is often easier (and more readable) to use the an ABI by hand it is often easier (and more readable) to use the
human-readable ABI, which is just the Solidity signautre. human-readable ABI, which is just the Solidity signature.
_code: simplified ERC-20 ABI @lang<script> _code: simplified ERC-20 ABI @lang<script>
abi = [ abi = [
@ -478,7 +478,7 @@ it. It can also be used to sign other forms of data, which are then able
to be validated for other purposes. to be validated for other purposes.
For example, signing **a message** can be used to prove ownership of an For example, signing **a message** can be used to prove ownership of an
account which a website could use to authenicate a user and log them in. account which a website could use to authenticate a user and log them in.
_code: @lang<javascript> _code: @lang<javascript>

@ -3,7 +3,7 @@ _section: Documentation @<about-home> @nav<Documentation>
The ethers.js library aims to be a complete and compact library The ethers.js library aims to be a complete and compact library
for interacting with the Ethereum Blockchain and its ecosystem. for interacting with the Ethereum Blockchain and its ecosystem.
It is ofen used to create decentralized applications (dapps), It is often used to create decentralized applications (dapps),
wallets (such as [[link-metamask]] and [[link-tally]]) and wallets (such as [[link-metamask]] and [[link-tally]]) and
other tools and simple scripts that require reading and writing other tools and simple scripts that require reading and writing
to the blockchain. to the blockchain.
@ -14,7 +14,7 @@ _subsection: About this documentation?
These docs are still under construction, and are being expanded These docs are still under construction, and are being expanded
every day. every day.
Developers new to Ethers shoud be sure to read through the Developers new to Ethers should be sure to read through the
[[getting-started]] section. [[getting-started]] section.
And the [[about-api]] is available for drilling down into more details And the [[about-api]] is available for drilling down into more details

@ -34,7 +34,7 @@ link-infura-secret [link-infura-secret](https://infura.io/docs/gettingStarted/au
link-parity-trace [link-parity-trace](https://openethereum.github.io/wiki/JSONRPC-trace-module) link-parity-trace [link-parity-trace](https://openethereum.github.io/wiki/JSONRPC-trace-module)
link-parity-rpc [link-parity-rpc](https://openethereum.github.io/wiki/JSONRPC) link-parity-rpc [link-parity-rpc](https://openethereum.github.io/wiki/JSONRPC)
link-pocket-signup [link-pocket-signup](https://pokt.network/pocket-gateway-ethereum-mainnet/) link-pocket-signup [link-pocket-signup](https://pokt.network/pocket-gateway-ethereum-mainnet/)
link-web3 [link-web3](https://github.com/ethereum/web3.js) link-web3js [link-web3](https://github.com/ethereum/web3.js)
link-web3-http [link-web3-http](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http) link-web3-http [link-web3-http](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http)
link-web3-ipc [link-web3-ipc](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ipc) link-web3-ipc [link-web3-ipc](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ipc)
link-web3-send [link-web3-send](https://github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-http/types/index.d.ts#L57) link-web3-send [link-web3-send](https://github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-http/types/index.d.ts#L57)

@ -10,7 +10,11 @@ so a lot of changes are largely internal.
- [BigNumbers](migrate-bigint) - [BigNumbers](migrate-bigint)
- [Contracts](migrate-contracts) - [Contracts](migrate-contracts)
- [Importing](migrate-importing) - [Importing](migrate-importing)
- [Odds and Ends](migrate-other) - [Providers](migrate-providers)
- [Signatures](migrate-signatures)
- [Transactions](migrate-transactions)
- [Utilities](migrate-utils)
- [Removed Items](migrate-missing)
_subsection: Big Numbers @<migrate-bigint> _subsection: Big Numbers @<migrate-bigint>
@ -32,7 +36,7 @@ _code: creating large numbers @lang<script>
// Using BigNumber in v5 // Using BigNumber in v5
value = BigNumber.from("1000") value = BigNumber.from("1000")
// Using BigInt in v6 (ysing literal notation). // Using BigInt in v6 (using literal notation).
// Notice the suffix n // Notice the suffix n
value = 1000n value = 1000n
@ -193,10 +197,95 @@ _code: importing in v6 @lang<script>
import { InfuraProvider } from "ethers/providers" import { InfuraProvider } from "ethers/providers"
_subsection: Odds and Ends @<migrate-other> _subsection: Providers @<migrate-providers>
In addition to all the ``ethers.providers.*`` being moved to
``ethers.*``, the biggest change developers need to keep in
mind is that ``Web3Provider`` (which historically was used
to wrap [[link-web3js]] providers) is now called
[[BrowserProvider]] which is designed to wrap EIP-1193
providers, which is the standard that both modern Web3.js and
injected providers offer.
_code: wrapping EIP-1193 providers @lang<script>
// v5
provider = new ethers.providers.Web3Provider(window.ethereum)
// v6:
provider = new ethers.BrowserProvider(window.ethereum)
_code: default AbiCoder @lang<script> _subsection: Signatures @<migrate-signatures>
The Signature is now a class which facilitates all the parsing
and serializing.
_code: signature manipulation
// v5
splitSig = splitSignature(sigBytes)
sigBytes = joinSignature(splitSig)
// v6
splitSig = ethers.Signature.from(sigBytes)
sigBytes = ethers.Signature.from(splitSig).serialized
_subsection: Transactions @<migrate-transactions>
The transaction helpers present in v5 were all wrapped into a
[[Transaction]] class, which can handle any supported transaction
format to be further processed
_code: parasing transactions @lang<script>
// v5
tx = parseTransaction(txBytes)
txBytes = serializeTransaction(tx)
txBytes = serializeTransaction(tx, sig)
// v6
tx = Transaction.from(txBytes)
// v6 (the tx can optionally include the signature)
txBytes = Transaction.from(tx).serialized
_subsection: Utilities @<migrate-utils>
_code: Bytes32 string helpers @lang<script>
// In v5:
bytes32 = ethers.utils.formatBytes32String(text)
text = ethers.utils.parseBytes32String(bytes32)
// In v6:
bytes32 = ethers.encodeBytes32String(text)
text = ethers.decodeBytes32String(bytes32)
_code: constants @lang<script>
// v5:
ethers.constants.AddressZero
ethers.constants.HashZero
// v6:
ethers.ZeroAddress
ethers.ZeroHash
_code: data manipulation @lang<script>
// v5
slice = ethers.utils.hexDataSlice(value, start, end)
padded = ethers.utils.hexZeroPad(value, length)
// v5; converting numbers to hexstrings
hex = hexlify(35)
// v6
slice = ethers.dataSlice(value, start, end)
padded = ethers.zeroPadValue(value, length)
// v6; converting numbers to hexstrings
hex = toBeHex(35)
_code: defaultAbiCoder @lang<script>
// In v5, it is a property of AbiCoder // In v5, it is a property of AbiCoder
coder = AbiCoder.defaultAbiCoder coder = AbiCoder.defaultAbiCoder
@ -206,23 +295,27 @@ _code: default AbiCoder @lang<script>
// instance is returned. // instance is returned.
coder = AbiCoder.defaultAbiCoder() coder = AbiCoder.defaultAbiCoder()
_code: getting a JSON-RPC quantity @lang<script> _code: hex conversion @lang<script>
// In v5: // v5
hex = ethers.util.hexValue(value) hex = ethers.utils.hexValue(value)
array = ethers.utils.arrayify(value)
// In v6: // v6
hex = ethers.toQuantity(value) hex = ethers.toQuantity(value)
array = ethers.getBytes(value)
_code: using Bytes32 strings @lang<script> _code: solidity non-standard packed @lang<script>
// In v5: // v5
bytes32 = formatBytes32String(text) ethers.utils.solidityPack(types, values)
text = parseBytes32String(bytes32)
// In v6: // v6
bytes32 = encodeBytes32String(text) ethers.solidityPacked(types, values)
text = decodeBytes32String(bytes32)
_subsection: Removed Classes and functions
_subsection: Removed Classes and functions @<migrate-missing>
The **Logger** class has been replaced by The **Logger** class has been replaced by
[several Error utility functions](about-errors). [several Error utility functions](about-errors).
The ``checkProperties`` and ``shallowCopy`` have been
removed in favor of using ``.map`` and ``Object.assign``.