Skip to content

Commit

Permalink
[ans] add script for bulk renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
angieyth committed Oct 3, 2023
1 parent 84d0167 commit afa8551
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bulk_force_renewal/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = 'aptos_names_bulk_force_renewal'
version = '1.0.0'

[addresses]
repository = "_"

[dependencies.aptos_names_v2_1]
local = "../core_v2"
11 changes: 11 additions & 0 deletions bulk_force_renewal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This script helps with bulk name renewal as an admin. It will overrule the renewal window and the max renewal period.

Preparation:
1. Update `Move.toml` with the correct `repository` account.
2. Use the admin account to run the script.

Each iteration:
1. Update the script with the appropriate names to renew
2. Update the time period to renew the names for
3. Compile the script: `aptos move compile`
4. Run the script: `aptos move run-script --compiled-script-path bulk_force_renewal/build/aptos_names_bulk_force_renewal/bytecode_scripts/main.mv --profile admin`
24 changes: 24 additions & 0 deletions bulk_force_renewal/sources/script.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
script {
use std::option;
use aptos_framework::timestamp;

const SECONDS_PER_YEAR: u64 = 60 * 60 * 24 * 365;

fun main(admin: &signer) {
let names = vector [
b"name01",
b"name02",
];
let years_to_expire = 100;

while (!std::vector::is_empty(&names)) {
let name = std::string::utf8(std::vector::pop_back(&mut names));
aptos_names_v2_1::v2_1_domains::force_set_name_expiration(
admin,
name,
option::none(),
timestamp::now_seconds() + SECONDS_PER_YEAR * years_to_expire,
)
}
}
}

0 comments on commit afa8551

Please sign in to comment.