Skip to content

Commit 8aea87b

Browse files
committed
script: update bulk override renewal fee script
1 parent 94103fc commit 8aea87b

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ethers } from "ethers";
2+
import fs from "fs";
3+
import dotenv from "dotenv";
4+
5+
dotenv.config();
6+
7+
const provider = new ethers.JsonRpcProvider(process.env.RONIN_MAINNET_RPC);
8+
const wallet = new ethers.Wallet(process.env.RONIN_MAINNET_PK, provider);
9+
const renewList = JSON.parse(fs.readFileSync("renew-list.json", "utf8"));
10+
// Verify: https://app.roninchain.com/address/0xcd245263eddee593a5a66f93f74c58c544957339
11+
const rnsOperation = "0xcd245263eddee593a5a66f93f74c58c544957339";
12+
const abi = ["function bulkOverrideRenewalFees(string[] calldata labels, uint256[] calldata yearlyUSDPrices) external"];
13+
// 0 if we want to bulk renew all labels
14+
// 5 if we want to reset renewal fee back to 5 usd
15+
const defaultFee = 0;
16+
const fees = renewList.map((_) => defaultFee);
17+
const account = "0x4BFEc2a63B72c67e6c3f599fCc40E1d42AE519ff";
18+
19+
console.log({ fees });
20+
21+
const contract = new ethers.Contract(rnsOperation, abi, provider);
22+
const shouldSimulate = true;
23+
24+
if (shouldSimulate) {
25+
try {
26+
await contract.bulkOverrideRenewalFees.staticCall(renewList, fees, {
27+
from: account,
28+
});
29+
} catch (error) {
30+
console.error("Failed to simulate bulk override renewal fees", error);
31+
}
32+
console.log("Simulate Bulk override renewal fees success");
33+
} else {
34+
try {
35+
const tx = await contract.connect(wallet).bulkOverrideRenewalFees(renewList, fees);
36+
await tx.wait();
37+
} catch (error) {
38+
console.error("Failed to bulk override renewal fees", error);
39+
}
40+
41+
console.log("Bulk override renewal fees success");
42+
}

script/operations/bulk-renew.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const abi = ["function renew(string calldata name, uint64 duration) external pay
1313
const defaultRenewDuration = 5 * 365 * 24 * 60 * 60; // 5 years
1414
// Structure of data.json is assumed to be like this:
1515
// ["label1", "label2", "label3", ...]
16-
const durations = renewList.map(() => defaultRenewDuration);
1716
// Get current nonce of account
1817
let nonce = await wallet.getNonce();
1918
console.log(`Current nonce: ${nonce}`);

0 commit comments

Comments
 (0)