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
Ready to evolve your codebase?
Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.