diff --git a/script/operations/bulk-override-renewal-fee.mjs b/script/operations/bulk-override-renewal-fee.mjs new file mode 100644 index 0000000..68dca0f --- /dev/null +++ b/script/operations/bulk-override-renewal-fee.mjs @@ -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"); +} diff --git a/script/operations/bulk-renew.mjs b/script/operations/bulk-renew.mjs index a79ae95..a4f0a6e 100644 --- a/script/operations/bulk-renew.mjs +++ b/script/operations/bulk-renew.mjs @@ -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}`);