Skip to main content
PRONeed enterprise-grade codemods tailored to your codebase?

Assess, plan, evolve.

Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.

17 packages

Sort by
Ethers/6/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-web3 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. ## Example ### Before ```ts provider = new ethers.providers.Web3Provider(window.ethereum); ``` ### After ```ts provider = new ethers.BrowserProvider(window.ethereum); ``` Method for broadcasting transactions to the network has changed ### Before ```ts provider.sendTransaction(signedTx); ``` ### After ```ts provider.broadcastTransaction(signedTx); ``` The **StaticJsonRpcProvider** in v5 is now integrated into the v6 **JsonRpcProvider** directly. When connecting to a network which cannot change its network, it is much more efficient to disable the automatic safety check ethers performs. ### Before ```ts provider = new StaticJsonRpcProvider(url, network); ``` ### After ```ts // This method is involved in tranformation // v6: If you know the network ahead of time and wish to avoid even a single eth_chainId call provider = new JsonRpcProvider(url, network, { staticNetwork: network, }); // If you want to transform your StaticJsonRpcProvider into below method you have to do it manually // v6: If you want the network automatically detected, this will query eth_chainId only once provider = new JsonRpcProvider(url, undefined, { staticNetwork: true, }); ``` Since the fees for Ethereum chains has become more complicated, all Fee parameters in v6 were coalesced into a single `.getFeeData` method. While `gasPrice` is no longer widely used in modern networks, when using a legacy network, it is available using that method. ### Before ```ts await provider.getGasPrice(); ``` ### After ```ts (await provider.getFeeData()).gasPrice; ```

  • ethers.js
  • migration
Yyugal41735
v1.0.3
1
a year ago
ethers/Big-Numbers

This codemod migrates **BigNumber** in v5 to **BigInt** in v6 in **ethers.js** library. It also changes the syntax for addition, and checking equality according to v6. ## Example ### Before ```ts // Using BigNumber in v5 value = BigNumber.from("1000"); // Adding two values in v5 sum = value1.add(value2); // Checking equality in v5 isEqual = value1.eq(value2); ``` ### After ```ts // Using BigInt in v6 value = BigInt("1000"); // Addition, keep in mind, both values must be a BigInt sum = value1 + value2; // Checking equality isEqual = value1 == value2; ```

  • ethers.js
Yyugal41735
v1.0.1
1
a year ago
Ethers/6/Utilities

This codemod does tranformation based on changes in the utils in ethers.js ## Example Byte32 string helpers ### Before ```ts bytes32 = ethers.utils.formatBytes32String(text); text = ethers.utils.parseBytes32String(bytes32); ``` ### After ```ts bytes32 = ethers.encodeBytes32String(text); text = ethers.decodeBytes32String(bytes32); ``` Constants ### Before ```ts ethers.constants.AddressZero; ethers.constants.HashZero; ``` ### After ```ts ethers.ZeroAddress; ethers.ZeroHash; ``` Data Manipulation ### Before ```ts slice = ethers.utils.hexDataSlice(value, start, end); padded = ethers.utils.hexZeroPad(value, length); hex = hexlify(35); ``` ### After ```ts slice = ethers.dataSlice(value, start, end); padded = ethers.zeroPadValue(value, length); // v6; converting numbers to hexstrings hex = toBeHex(35); ``` Deafult AbiCoder ### Before ```ts // In v5, it is a property of AbiCoder coder = AbiCoder.defaultAbiCoder; ``` ### After ```ts // In v6, it is a static function on AbiCoder coder = AbiCoder.defaultAbiCoder(); ``` Hex Conversion ### Before ```ts hex = ethers.utils.hexValue(value); array = ethers.utils.arrayify(value); ``` ### After ```ts hex = ethers.toQuantity(value); array = ethers.getBytes(value); ``` Solidity non-standard packed ### Before ```ts ethers.utils.solidityPack(types, values); ethers.utils.solidityKeccak256(types, values); ethers.utils.soliditySha256(types, values); ``` ### After ```ts ethers.solidityPacked(types, values); ethers.solidityPackedKeccak256(types, values); ethers.solidityPackedSha256(types, values); ``` Property Manipulation ### Before ```ts ethers.utils.defineReadOnly(obj, "name", value); ``` ### After ```ts ethers.defineProperties(obj, { name: value }); ``` Above were some transformation, that were done in utilities section of ethers, now below are some cleanups and breaking changes. PS: These changes are not done using codemod. **Fetching content** Basic Fetch with Json ### Before ```ts data = await ethers.utils.fetchJson(url, json, processFunc); ``` ### After ```ts const req = new ethers.FetchRequest(url); req.body = json; req.processFunc = processFunc; const resp = await req.send(); data = resp.bodyJson; // or resp.bodyText / resp.body depending on the desired format ``` Fetch with Connection Overrides: ### Before ```ts req = { url: url, user: "username", password: "password", // etc. properties have FetchRequest equivalents }; data = await ethers.utils.fetchJson(req, json, processFunc); ``` ### After ```ts const req = new ethers.FetchRequest(url); req.setCredentials("username", "password"); req.body = json; req.processFunc = processFunc; const resp = await req.send(); data = resp.bodyJson; // or resp.bodyText / resp.body depending on the desired format ```

  • ethers.js
  • migration
Yyugal41735
v1.0.2
2
a year ago
Ethers/6/Importing

This codemod helps in tranformation, related to some import packages. In v5, the project was maintained as a large set of sub-packages managed as a monorepo. In v6 all imports are available in the root package, and for those who wish to have finer-grained control, the pkg.exports makes certain folders available directly. ## Example ### Before ```ts import { InfuraProvider } from "@ethersproject/providers"; ``` ### After ```ts import { InfuraProvider } from "ethers/providers"; ``` , ### Before ```ts // in v5, some packages were grouped behind an additional property import { providers } from "ethers"; // And then we could retrieve the below package const { InfuraProvider } = providers; // PS: this codemod transforms the above line only, // import line in this before claus had to be removed manually ``` ### After ```ts // Everything is available on the root package import { InfuraProvider } from "ethers"; ```

  • ethers.js
  • migration
Yyugal41735
v1.0.1
1
a year ago
Ethers/6/Signatures

The Signature is now a class which facilitates all the parsing and serializing. ## Example ### Before ```ts splitSig = splitSignature(sigBytes); ``` ### After ```ts splitSig = ethers.Signature.from(sigBytes); ``` , ### Before ```ts sigBytes = joinSignature(splitSig); ``` ### After ```ts sigBytes = ethers.Signature.from(splitSig).serialized; ```

  • ethers.js
  • migration
Yyugal41735
v1.0.1
0
a year ago
Ethers/6/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. ## Example ### Before ```ts tx = parseTransaction(txBytes); ``` ### After ```ts tx = Transaction.from(txBytes); ``` There is new way to serialize the transaction object('tx') back into raw transaction bytes. The advantage here is that _Transaction_ object itself manages whether the transaction is signed or not, and the serialized property will automatically include the signature if it is present in the Transaction object. Whereas in v5 we have to we have to explicitly mentioned whether the transaction is signed or not. This is for both the transformation below. ### Before ```ts txBytes = serializeTransaction(tx); ``` ### After ```ts txBytes = Transaction.from(tx).serialized; ``` ### Before ```ts txBytes = serializeTransaction(tx, sig); ``` ### After ```ts txBytes = Transaction.from(tx).serialized; ```

  • ethers.js
  • migration
Yyugal41735
v1.0.1
0
a year ago
Ethers/6/migration-recipe

This recipe is a set of codemods that will help migrate to Ethers 6. The recipe includes the following codemods: - Ethers/Big-Numbers - Ethers/6/Signatures - Ethers/6/Providers - Ethers/6/Importing - Ethers/6/Utilities - Ethers/6/Transactions - Ethers/6/Contracts/Ambigous-Methods - Ethers/6/Contracts/Other-Method-Operations

  • migration
  • ethers
Yyugal41735
v1.0.2
0
a year ago
Ethers/6/Contracts/Ambiguous-Methods

In v5, in the case of an ambiguous method, it was necessary to look up a method by its canonical normalized signature. In v6 the signature does not need to be normalized and the Typed API provides a cleaner way to access the desired method. In v5, duplicate definitions also injected warnings into the console, since there was no way to detect them at run-time. ## Example ### Before ```ts abi = ["function foo(address bar)", "function foo(uint160 bar)"]; contract = new Contract(address, abi, provider); // In v5 it was necessary to specify the fully-qualified normalized // signature to access the desired method. For example: contract["foo(address)"](addr); // These would fail, since there signature is not normalized: contract["foo(address )"](addr); contract["foo(address addr)"](addr); // This would fail, since the method is ambiguous: contract.foo(addr); ``` ### After ```ts abi = ["function foo(address bar)", "function foo(uint160 bar)"]; contract = new Contract(address, abi, provider); // Any of these work fine: contract["foo(address)"](addr); contract["foo(address )"](addr); contract["foo(address addr)"](addr); // This still fails, since there is no way to know which // method was intended contract.foo(addr); // However, the Typed API makes things a bit easier, since it // allows providing typing information to the Contract: contract.foo(Typed.address(addr)); ``` Transformation done using this codemod ### Before ```ts abi = ["function foo(address bar)", "function foo(uint160 bar)"]; contract = new Contract(address, abi, provider); contract.foo(addr); ``` ### After ```ts abi = ["function foo(address bar)", "function foo(uint160 bar)"]; contract = new Contract(address, abi, provider); contract.foo(Typed.address(addr)); ```

  • ethers.js
  • Migration
Yyugal41735
v1.0.1
0
a year ago
Ethers/6/Contracts/Other-Method-Operations

This codemod transforms some of the other method operations that are present in Contracts class of ethers. ## Example ### Before ```ts contract.functions.foo(addr); ``` ### After ```ts contract.foo.staticCallResult(addr); ``` ### Before ```ts contract.callStatic.foo(addr); ``` ### After ```ts contract.foo.staticCall(addr); ``` ### Before ```ts contract.estimateGas.foo(addr); ``` ### After ```ts contract.foo.estimateGas(addr); ``` ### Before ```ts contract.populateTransaction.foo(addr); ``` ### After ```ts contract.foo.populateTransaction(addr); ``` Below transformation is not done using codemod, since it is a new feature in v6 Explicitly sends a transaction, regardless of function type ```ts contract.foo.send(addr); ```

  • ethers.js
  • Migration
Yyugal41735
v1.0.1
0
a year ago
ethers-v5-to-v6

EtherMod — automatically migrate ethers.js v5 to v6. Handles utils/providers namespace flattening, BigNumber → bigint, Web3Provider → BrowserProvider, and import cleanup.

  • ethers
  • web3
  • +4
Ssoftalpha0 avatarsoftalpha0
v1.4.0
7
6 months ago
ethers-v6-bridge

Migrate Ethers.js v5 to v6 with Rigorous Math Sentinel

  • ethers
  • web3
  • +2
SSkywalkingzulu1 avatarSkywalkingzulu1
v0.1.0
0
6 months ago
ethers-v5-to-v6-codemod

Automatically migrates ethers.js v5 code to v6 using jssg. Supports JavaScript and TypeScript.

  • upgrade
  • breaking-change
  • +2
DDeewakarBora avatarDeewakarBora
v1.2.2
0
6 months ago

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.