Skip to content

Commit

Permalink
script: update bulk override renewal fee script
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Nov 5, 2024
1 parent 94103fc commit 8aea87b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
42 changes: 42 additions & 0 deletions script/operations/bulk-override-renewal-fee.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ethers } from "ethers";
import fs from "fs";
import dotenv from "dotenv";

dotenv.config();

const provider = new ethers.JsonRpcProvider(process.env.RONIN_MAINNET_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/0xcd245263eddee593a5a66f93f74c58c544957339
const rnsOperation = "0xcd245263eddee593a5a66f93f74c58c544957339";
const abi = ["function bulkOverrideRenewalFees(string[] calldata labels, uint256[] calldata yearlyUSDPrices) external"];
// 0 if we want to bulk renew all labels
// 5 if we want to reset renewal fee back to 5 usd
const defaultFee = 0;
const fees = renewList.map((_) => defaultFee);
const account = "0x4BFEc2a63B72c67e6c3f599fCc40E1d42AE519ff";

console.log({ fees });

const contract = new ethers.Contract(rnsOperation, abi, provider);
const shouldSimulate = true;

if (shouldSimulate) {
try {
await contract.bulkOverrideRenewalFees.staticCall(renewList, fees, {
from: account,
});
} catch (error) {
console.error("Failed to simulate bulk override renewal fees", error);
}
console.log("Simulate Bulk override renewal fees success");
} else {
try {
const tx = await contract.connect(wallet).bulkOverrideRenewalFees(renewList, fees);
await tx.wait();
} catch (error) {
console.error("Failed to bulk override renewal fees", error);
}

console.log("Bulk override renewal fees success");
}
1 change: 0 additions & 1 deletion script/operations/bulk-renew.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const abi = ["function renew(string calldata name, uint64 duration) external pay
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}`);
Expand Down

0 comments on commit 8aea87b

Please sign in to comment.