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

feat(bulk-renew): implement add-bulk-renew #278

Open
wants to merge 16 commits into
base: feature/bulk-renew
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
script: update bulk override renewal fee script
TuDo1403 committed Nov 5, 2024
commit 8aea87b0ac55bb852e99dc18bada17c06caa73d7
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
@@ -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}`);