Skip to content
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

chore(script): merge from release/v0.3.7 #283

Open
wants to merge 14 commits into
base: feature/script
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
script: add bulk renew script
TuDo1403 committed Nov 4, 2024

Verified

This commit was signed with the committer’s verified signature.
TuDo1403 tu-do.ron
commit 12db5637e203a89f3618afb6179dbfe746312ca2
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
],
"devDependencies": {
"dotenv": "^16.3.1",
"ethers": "6.13.3",
"hardhat": "^2.12.7",
"hardhat-deploy": "0.11.29",
"husky": "^8.0.3",
@@ -24,5 +25,6 @@
},
"scripts": {
"prepare": "husky install"
}
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@rns-contracts/=src/
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=dependencies/@fdk-0.3.0-beta/dependencies/forge-std-1.8.2/src/
@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-4.9.3/
@openzeppelin/contracts/=dependencies/openzeppelin-4.9.3/contracts/
contract-template/=lib/contract-template/src/
@solady/=dependencies/@fdk-0.3.0-beta/dependencies/solady-0.0.206/src/
@ensdomains/ens-contracts/=lib/ens-contracts/contracts/
57 changes: 57 additions & 0 deletions script/operations/bulk-renew.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ethers } from "ethers";
import fs from "fs";
import dotenv from "dotenv";

dotenv.config();

const provider = new ethers.JsonRpcProvider("https://api-archived.roninchain.com/rpc");
const wallet = new ethers.Wallet(process.env.RONIN_MAINNET_PK, provider);
const renewList = JSON.parse(fs.readFileSync("renew-list.json", "utf8"));
// Verify: https://app.roninchain.com/address/0x662852853614cbbb5d04bf2e29955b97e3c50b69
const ronRegistrarControllerAddr = "0x662852853614cbbb5d04bf2e29955b97e3c50b69";
const abi = ["function renew(string calldata name, uint64 duration) external payable"];
const defaultRenewDuration = 5 * 365 * 24 * 60 * 60; // 5 years
// Structure of data.json is assumed to be like this:
// ["label1", "label2", "label3", ...]
const durations = renewList.map(() => defaultRenewDuration);
// Get current nonce of account
let nonce = await wallet.getNonce();
console.log(`Current nonce: ${nonce}`);
const account = wallet.address;
const shouldSimulate = true;
// Assert the list is unique
if (new Set(renewList).size !== renewList.length) {
console.error("List is not unique");
process.exit(1);
}

async function bulkRenew() {
const contract = new ethers.Contract(ronRegistrarControllerAddr, abi, provider);

const promises = renewList.map(async (label) => {
if (shouldSimulate) {
console.log(`nonce: ${nonce++}`);
try {
await contract.renew.staticCall(label, defaultRenewDuration, {
from: account,
});
} catch (error) {
console.error(`Failed to simulate renew for ${label} - ${defaultRenewDuration}`, error);
}
} else {
console.log(`nonce: ${nonce}`);
try {
await contract.connect(wallet).renew(label, defaultRenewDuration, {
nonce: nonce++,
});
console.log(`Renew for label ${label} - duration: ${defaultRenewDuration} success`);
} catch (error) {
console.error(`Failed to renew label ${label} - duration ${defaultRenewDuration}:`, error);
}
}
});

await Promise.all(promises);
}

bulkRenew();
7,418 changes: 2,821 additions & 4,597 deletions yarn.lock

Large diffs are not rendered by default.