-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add ethers v6 codemods #4825
Open
Yugal41735
wants to merge
2
commits into
ethers-io:main
Choose a base branch
from
Yugal41735:feat-codemod-6
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,6 +16,26 @@ so a lot of changes are largely internal. | |||||
- [Utilities](migrate-utils) | ||||||
- [Removed Items](migrate-missing) | ||||||
|
||||||
_subsection: Codemods | ||||||
_heading Ethers v6 Codemods | ||||||
|
||||||
Run the following codemods to automatically update your code for Ethers v6 migration: | ||||||
|
||||||
_code: codemod migration recipe @lang<script> | ||||||
|
||||||
npx codemod@latest Ethers/6/Migration-Recipe | ||||||
|
||||||
This wil run the following codemods from the Ethers Codemod repository: | ||||||
|
||||||
- [[Ethers/6/Big-Numbers]] | ||||||
- [[Ethers/6/Signatures]] | ||||||
- [[Ethers/6/Providers]] | ||||||
- [[Ethers/6/Importing]] | ||||||
- [[Ethers/6/Transactions]] | ||||||
- [[Ethers/6/Contracts/Ambiguous-Methods]] | ||||||
- [[Ethers/6/Contracts/Other-Method-Operations]] | ||||||
- [[Ethers/6/Contracts/Other-Method-Operations]] | ||||||
|
||||||
|
||||||
_subsection: Big Numbers @<migrate-bigint> | ||||||
|
||||||
|
@@ -62,6 +82,11 @@ _code: simple comparison on large numbers @lang<script> | |||||
// Using BigInt in v6 | ||||||
isEqual = (value1 == value2) | ||||||
|
||||||
_note: Codemod transforms BigNumber to BigInt and also refactors addition and equality with: | ||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Big-Numbers | ||||||
|
||||||
|
||||||
_subsection: Contracts @<migrate-contracts> | ||||||
|
||||||
|
@@ -116,6 +141,11 @@ _code: contracts in v6 @lang<script> | |||||
// allows providing typing information to the Contract: | ||||||
contract.foo(Typed.address(addr)) | ||||||
|
||||||
_note: Codemod transforms the ambiguous function to TypedAPI function: | ||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Contracts/Ambiguous-Methods | ||||||
|
||||||
_heading: Other Method Operations | ||||||
|
||||||
In v5, contracts contained a series of method buckets, which | ||||||
|
@@ -164,6 +194,11 @@ _code: other operations in v6 @lang<script> | |||||
// Populate a transaction | ||||||
contract.foo.populateTransaction(addr) | ||||||
|
||||||
_note: Codemod refactors all the functions mentioned above: | ||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Contracts/Other-Method-Operations | ||||||
|
||||||
|
||||||
_subsection: Importing @<migrate-importing> | ||||||
|
||||||
|
@@ -196,6 +231,11 @@ _code: importing in v6 @lang<script> | |||||
// The pkg.exports provides granular access | ||||||
import { InfuraProvider } from "ethers/providers" | ||||||
|
||||||
_note: Codemod updates import statements to new structure: | ||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Importing | ||||||
|
||||||
|
||||||
_subsection: Providers @<migrate-providers> | ||||||
|
||||||
|
@@ -264,6 +304,11 @@ _code: Getting legacy gas price @lang<script> | |||||
(await provider.getFeeData()).gasPrice | ||||||
|
||||||
|
||||||
_note: Codemod updates provider class, transaction broadcasting method, static network providers, and fee data-retrieval to align with new structure: | ||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Providers | ||||||
|
||||||
_subsection: Signatures @<migrate-signatures> | ||||||
|
||||||
The Signature is now a class which facilitates all the parsing | ||||||
|
@@ -278,6 +323,11 @@ _code: signature manipulation | |||||
splitSig = ethers.Signature.from(sigBytes) | ||||||
sigBytes = ethers.Signature.from(splitSig).serialized | ||||||
|
||||||
_note: Codemod replaces [[splitSignature]] and [[joinSignature]] with [[ethers.Signature]] class for parsing and serializing singatures: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Signatures | ||||||
|
||||||
|
||||||
_subsection: Transactions @<migrate-transactions> | ||||||
|
||||||
|
@@ -298,6 +348,11 @@ _code: parsing transactions @lang<script> | |||||
// v6 (the tx can optionally include the signature) | ||||||
txBytes = Transaction.from(tx).serialized | ||||||
|
||||||
_note: Codemod replaces [[parseTransaction]] and [[serializeTransaction]] with new [[Transaction]] class for parsing and serializing singatures: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Transactions | ||||||
|
||||||
|
||||||
_subsection: Utilities @<migrate-utils> | ||||||
|
||||||
|
@@ -427,6 +482,11 @@ _code: commify @lang<script> | |||||
|
||||||
commify("1234.5"); | ||||||
|
||||||
_note: Codemod refactors various utility methods mentioned above, constants, data manipualtion functions, and transaction handling: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
_code: | ||||||
npx codemod@latest Ethers/6/Utilities | ||||||
|
||||||
_subsection: Removed Classes and functions @<migrate-missing> | ||||||
|
||||||
The **Logger** class has been replaced by | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.