From 820b2e345679999f043938169b378e089f487f86 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 15:38:13 -0400 Subject: [PATCH 1/8] migration suins --- packages/suins/Move.lock | 13 +- packages/suins/Move.toml | 1 + packages/suins/migration.patch | 827 ++++++++++++++++++ .../suins/sources/actions/update_image.move | 4 +- packages/suins/sources/admin.move | 4 +- packages/suins/sources/auction.move | 20 +- packages/suins/sources/config.move | 2 +- packages/suins/sources/controller.move | 6 +- packages/suins/sources/domain.move | 24 +- packages/suins/sources/name_record.move | 2 +- packages/suins/sources/registry.move | 2 +- .../suins/sources/subdomain_registration.move | 10 +- packages/suins/sources/suins.move | 16 +- .../suins/sources/suins_registration.move | 14 +- packages/suins/tests/auction_tests.move | 88 +- packages/suins/tests/controller_tests.move | 78 +- packages/suins/tests/register_tests.move | 46 +- packages/suins/tests/renew_tests.move | 46 +- packages/suins/tests/unit/admin_tests.move | 10 +- packages/suins/tests/unit/config_tests.move | 4 +- .../suins/tests/unit/name_record_tests.move | 10 +- .../tests/unit/registration_nft_tests.move | 8 +- packages/suins/tests/unit/registry_tests.move | 94 +- packages/suins/tests/unit/sub_name_tests.move | 16 +- packages/suins/tests/unit/suins_tests.move | 40 +- packages/suins/tests/v2/register.move | 2 +- packages/suins/tests/v2/renew.move | 2 +- 27 files changed, 1112 insertions(+), 277 deletions(-) create mode 100644 packages/suins/migration.patch diff --git a/packages/suins/Move.lock b/packages/suins/Move.lock index 20efbe69..9af478d5 100644 --- a/packages/suins/Move.lock +++ b/packages/suins/Move.lock @@ -1,7 +1,9 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 0 +version = 1 +manifest_digest = "178A4915582E27315742698835D4E01F3DABCD4D043FFB8A7B12C68A2CFDA138" +deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082" dependencies = [ { name = "Sui" }, @@ -9,12 +11,17 @@ dependencies = [ [[move.package]] name = "MoveStdlib" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "2d985a3", subdir = "crates/sui-framework/packages/move-stdlib" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] name = "Sui" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "2d985a3", subdir = "crates/sui-framework/packages/sui-framework" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ { name = "MoveStdlib" }, ] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/suins/Move.toml b/packages/suins/Move.toml index 0a512a8d..4cf12c9a 100644 --- a/packages/suins/Move.toml +++ b/packages/suins/Move.toml @@ -3,6 +3,7 @@ name = "suins" version = "0.0.2" #mainnet published-at="0xb7004c7914308557f7afbaf0dca8dd258e18e306cb7a45b28019f3d0a693f162" +edition = "2024.beta" #testnet #published-at="0x8ea50d1974a257d3ed8e94fbe4f280d8df1a0a9b1eb511773e74d613d2c2afe3" diff --git a/packages/suins/migration.patch b/packages/suins/migration.patch new file mode 100644 index 00000000..2033b79c --- /dev/null +++ b/packages/suins/migration.patch @@ -0,0 +1,827 @@ +--- sources/actions/update_image.move ++++ sources/actions/update_image.move +@@ -25 +25 @@ +- struct UpdateImage has drop {} ++ public struct UpdateImage has drop {} +@@ -72 +72 @@ +- let bcs = bcs::new(msg_bytes); ++ let mut bcs = bcs::new(msg_bytes); +--- sources/admin.move ++++ sources/admin.move +@@ -19 +19 @@ +- struct Admin has drop {} ++ public struct Admin has drop {} +@@ -47 +47 @@ +- domains: vector, ++ mut domains: vector, +--- sources/auction.move ++++ sources/auction.move +@@ -49 +49 @@ +- struct App has drop {} ++ public struct App has drop {} +@@ -52 +52 @@ +- struct AuctionHouse has key, store { ++ public struct AuctionHouse has key, store { +@@ -59 +59 @@ +- struct Auction has store { ++ public struct Auction has store { +@@ -146 +146 @@ +- end_timestamp_ms, ++ mut end_timestamp_ms, +@@ -364 +364 @@ +- operation_limit: u64, ++ mut operation_limit: u64, +@@ -367 +367 @@ +- let next_domain = *linked_table::back(&self.auctions); ++ let mut next_domain = *linked_table::back(&self.auctions); +@@ -394 +394 @@ +- struct AuctionStartedEvent has copy, drop { ++ public struct AuctionStartedEvent has copy, drop { +@@ -402 +402 @@ +- struct AuctionFinalizedEvent has copy, drop { ++ public struct AuctionFinalizedEvent has copy, drop { +@@ -410 +410 @@ +- struct BidEvent has copy, drop { ++ public struct BidEvent has copy, drop { +@@ -416 +416 @@ +- struct AuctionExtendedEvent has copy, drop { ++ public struct AuctionExtendedEvent has copy, drop { +--- sources/config.move ++++ sources/config.move +@@ -44 +44 @@ +- struct Config has store, drop { ++ public struct Config has store, drop { +--- sources/controller.move ++++ sources/controller.move +@@ -23 +23 @@ +- struct Controller has drop {} ++ public struct Controller has drop {} +@@ -60 +60 @@ +- let data = *registry::get_data(registry, nft::domain(nft)); ++ let mut data = *registry::get_data(registry, nft::domain(nft)); +@@ -80 +80 @@ +- let data = *registry::get_data(registry, nft::domain(nft)); ++ let mut data = *registry::get_data(registry, nft::domain(nft)); +--- sources/domain.move ++++ sources/domain.move +@@ -23 +23 @@ +- struct Domain has copy, drop, store { ++ public struct Domain has copy, drop, store { +@@ -35 +35 @@ +- let labels = split_by_dot(domain); ++ let mut labels = split_by_dot(domain); +@@ -47,2 +47,2 @@ +- let i = 0; +- let out = string::utf8(vector::empty()); ++ let mut i = 0; ++ let mut out = string::utf8(vector::empty()); +@@ -100 +100 @@ +- let labels = domain.labels; ++ let mut labels = domain.labels; +@@ -119 +119 @@ +- let index = 0; ++ let mut index = 0; +@@ -131 +131 @@ +- let index = 0; ++ let mut index = 0; +@@ -155 +155 @@ +- fun split_by_dot(s: String): vector { ++ fun split_by_dot(mut s: String): vector { +@@ -157 +157 @@ +- let parts: vector = vector[]; ++ let mut parts: vector = vector[]; +@@ -191 +191 @@ +- let index = 0; ++ let mut index = 0; +@@ -201,2 +201,2 @@ +- fun prep_expected_labels(labels: vector>): vector { +- let out = vector[]; ++ fun prep_expected_labels(mut labels: vector>): vector { ++ let mut out = vector[]; +--- sources/name_record.move ++++ sources/name_record.move +@@ -19 +19 @@ +- struct NameRecord has copy, store, drop { ++ public struct NameRecord has copy, store, drop { +--- sources/registry.move ++++ sources/registry.move +@@ -43 +43 @@ +- struct Registry has store { ++ public struct Registry has store { +--- sources/subdomain_registration.move ++++ sources/subdomain_registration.move +@@ -19,2 +19,2 @@ +- friend suins::registry; +- #[test_only] friend suins::sub_name_tests; ++ /* friend suins::registry; */ ++ /* #[test_only] */ /* friend suins::sub_name_tests; */ +@@ -32 +32 @@ +- struct SubDomainRegistration has key, store { ++ public struct SubDomainRegistration has key, store { +@@ -39 +39 @@ +- public(friend) fun new(nft: SuinsRegistration, clock: &Clock, ctx: &mut TxContext): SubDomainRegistration { ++ public(package) fun new(nft: SuinsRegistration, clock: &Clock, ctx: &mut TxContext): SubDomainRegistration { +@@ -53 +53 @@ +- public(friend) fun burn(name: SubDomainRegistration, clock: &Clock): SuinsRegistration { ++ public(package) fun burn(name: SubDomainRegistration, clock: &Clock): SuinsRegistration { +--- sources/suins.move ++++ sources/suins.move +@@ -39 +39 @@ +- struct AdminCap has key, store { id: UID } ++ public struct AdminCap has key, store { id: UID } +@@ -47 +47 @@ +- struct SuiNS has key { ++ public struct SuiNS has key { +@@ -55 +55 @@ +- struct SUINS has drop {} ++ public struct SUINS has drop {} +@@ -62 +62 @@ +- struct ConfigKey has copy, store, drop {} ++ public struct ConfigKey has copy, store, drop {} +@@ -69 +69 @@ +- struct RegistryKey has copy, store, drop {} ++ public struct RegistryKey has copy, store, drop {} +@@ -108 +108 @@ +- struct AppKey has copy, store, drop {} ++ public struct AppKey has copy, store, drop {} +@@ -184 +184 @@ +- #[test_only] struct Test has drop {} ++ #[test_only] public struct Test has drop {} +@@ -198 +198 @@ +- let suins = SuiNS { ++ let mut suins = SuiNS { +--- sources/suins_registration.move ++++ sources/suins_registration.move +@@ -22,2 +22,2 @@ +- friend suins::registry; +- friend suins::update_image; ++ /* friend suins::registry; */ ++ /* friend suins::update_image; */ +@@ -26 +26 @@ +- struct SuinsRegistration has key, store { ++ public struct SuinsRegistration has key, store { +@@ -42 +42 @@ +- public(friend) fun new( ++ public(package) fun new( +@@ -58 +58 @@ +- public(friend) fun set_expiration_timestamp_ms(self: &mut SuinsRegistration, expiration_timestamp_ms: u64) { ++ public(package) fun set_expiration_timestamp_ms(self: &mut SuinsRegistration, expiration_timestamp_ms: u64) { +@@ -63 +63 @@ +- public(friend) fun update_image_url(self: &mut SuinsRegistration, image_url: String) { ++ public(package) fun update_image_url(self: &mut SuinsRegistration, image_url: String) { +@@ -70 +70 @@ +- public(friend) fun burn(self: SuinsRegistration) { ++ public(package) fun burn(self: SuinsRegistration) { +--- tests/auction_tests.move ++++ tests/auction_tests.move +@@ -35 +35 @@ +- let scenario_val = test_scenario::begin(SUINS_ADDRESS); ++ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); +@@ -38 +38 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -48 +48 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -65,2 +65,2 @@ +- let auction_house = test_scenario::take_shared(scenario); +- let suins = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -86 +86 @@ +- let auction_house = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); +@@ -88 +88 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -104,2 +104,2 @@ +- let auction_house = test_scenario::take_shared(scenario); +- let clock = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -123,2 +123,2 @@ +- let auction_house = test_scenario::take_shared(scenario); +- let clock = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -140,2 +140,2 @@ +- let auction_house = test_scenario::take_shared(scenario); +- let clock = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -154,2 +154,2 @@ +- let auction_house = test_scenario::take_shared(scenario); +- let clock = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -168 +168 @@ +- let auction_house = test_scenario::take_shared(scenario); ++ let mut auction_house = test_scenario::take_shared(scenario); +@@ -180 +180 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -205 +205 @@ +- let (start_ms, end_ms, winner, highest_amount) = auction::get_auction_metadata(&auction_house, domain_name); ++ let (mut start_ms, mut end_ms, mut winner, mut highest_amount) = auction::get_auction_metadata(&auction_house, domain_name); +@@ -256 +256 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -264 +264 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -283 +283 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -299 +299 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -314 +314 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -331 +331 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -364 +364 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -397 +397 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -412 +412 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -428 +428 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -448 +448 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -457 +457 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -470 +470 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -483 +483 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -496 +496 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -509 +509 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -522 +522 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -535 +535 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -543 +543 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -556 +556 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -595 +595 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -607 +607 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -609 +609 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -623 +623 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -662 +662 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -696 +696 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +--- tests/controller_tests.move ++++ tests/controller_tests.move +@@ -35 +35 @@ +- let scenario_val = test_scenario::begin(SUINS_ADDRESS); ++ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); +@@ -38 +38 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -48 +48 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -65 +65 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -67 +67 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -79 +79 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -88 +88 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -97 +97 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -99 +99 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -111 +111 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -113 +113 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -160 +160 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -170 +170 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -186 +186 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -197 +197 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -209 +209 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -220 +220 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -222 +222 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -234 +234 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -255 +255 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -267 +267 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -278 +278 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -280 +280 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -293 +293 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -306 +306 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -308 +308 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -322 +322 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -333 +333 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -355 +355 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -366 +366 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -377 +377 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -389 +389 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -402 +402 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -404 +404 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -416 +416 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -437 +437 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -448 +448 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -457 +457 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -459 +459 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +--- tests/register_tests.move ++++ tests/register_tests.move +@@ -30 +30 @@ +- let scenario_val = test_scenario::begin(SUINS_ADDRESS); ++ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); +@@ -33 +33 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -43 +43 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -61 +61 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -63 +63 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -77 +77 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -94 +94 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -120 +120 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -131 +131 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -142 +142 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -153 +153 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -164 +164 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -175 +175 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -204 +204 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -221 +221 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -232 +232 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -243 +243 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -254 +254 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -265 +265 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -276 +276 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -289 +289 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -308 +308 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -310 +310 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +--- tests/renew_tests.move ++++ tests/renew_tests.move +@@ -25 +25 @@ +- let scenario_val = test_scenario::begin(SUINS_ADDRESS); ++ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); +@@ -28 +28 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -38 +38 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -50 +50 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -52 +52 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -64 +64 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -74 +74 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -77 +77 @@ +- let nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0); ++ let mut nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0); +@@ -83 +83 @@ +- let nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0); ++ let mut nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0); +@@ -89 +89 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); +@@ -105 +105 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -108 +108 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); +@@ -117 +117 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -120 +120 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); +@@ -129 +129 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -132 +132 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); +@@ -141 +141 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -144 +144 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); +@@ -153 +153 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -156 +156 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); +@@ -164 +164 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -166 +166 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -169 +169 @@ +- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); ++ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); +--- tests/unit/admin_tests.move ++++ tests/unit/admin_tests.move +@@ -27 +27 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -29,2 +29,2 @@ +- let ctx = tx_context::dummy(); +- let suins = suins::init_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let mut suins = suins::init_for_testing(&mut ctx); +@@ -48,2 +48,2 @@ +- let ctx = tx_context::dummy(); +- let suins = suins::init_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let mut suins = suins::init_for_testing(&mut ctx); +--- tests/unit/config_tests.move ++++ tests/unit/config_tests.move +@@ -23 +23 @@ +- let config = default(); ++ let mut config = default(); +@@ -91 +91 @@ +- let config = default(); ++ let mut config = default(); +--- tests/unit/name_record_tests.move ++++ tests/unit/name_record_tests.move +@@ -27 +27 @@ +- let ctx = tx_context::dummy(); ++ let mut ctx = tx_context::dummy(); +@@ -29 +29 @@ +- let record = record::new(nft_id, 0); ++ let mut record = record::new(nft_id, 0); +@@ -37 +37 @@ +- let data = vec_map::empty(); ++ let mut data = vec_map::empty(); +@@ -55 +55 @@ +- let ctx = tx_context::dummy(); ++ let mut ctx = tx_context::dummy(); +@@ -58 +58 @@ +- let clock = clock::create_for_testing(&mut ctx); ++ let mut clock = clock::create_for_testing(&mut ctx); +--- tests/unit/registration_nft_tests.move ++++ tests/unit/registration_nft_tests.move +@@ -23,2 +23,2 @@ +- let ctx = tx_context::dummy(); +- let clock = clock::create_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let mut clock = clock::create_for_testing(&mut ctx); +@@ -53 +53 @@ +- let ctx = tx_context::dummy(); ++ let mut ctx = tx_context::dummy(); +@@ -55 +55 @@ +- let nft = new(utf8(b"test.sui"), 5, &clock, &mut ctx); ++ let mut nft = new(utf8(b"test.sui"), 5, &clock, &mut ctx); +--- tests/unit/registry_tests.move ++++ tests/unit/registry_tests.move +@@ -24,2 +24,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -48,2 +48,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -86,2 +86,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, _domain) = setup(&mut ctx); +@@ -114,2 +114,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -142,2 +142,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -170,2 +170,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -185,2 +185,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -204,2 +204,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -233,2 +233,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -258,2 +258,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -266 +266 @@ +- let search = registry::lookup(®istry, domain); ++ let mut search = registry::lookup(®istry, domain); +@@ -285,2 +285,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -294 +294 @@ +- let search = registry::reverse_lookup(®istry, @0xB0B); ++ let mut search = registry::reverse_lookup(®istry, @0xB0B); +@@ -309,2 +309,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, _domain) = setup(&mut ctx); +@@ -325,2 +325,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -342,2 +342,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, mut clock, domain) = setup(&mut ctx); +@@ -367,2 +367,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -382,2 +382,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -396,2 +396,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, _domain) = setup(&mut ctx); +@@ -407,2 +407,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, _domain) = setup(&mut ctx); +@@ -418,2 +418,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, _domain) = setup(&mut ctx); +@@ -431,2 +431,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, _domain) = setup(&mut ctx); +@@ -445,2 +445,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, _domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, _domain) = setup(&mut ctx); +@@ -460,2 +460,2 @@ +- let ctx = tx_context::dummy(); +- let (registry, clock, domain) = setup(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut registry, clock, domain) = setup(&mut ctx); +@@ -494 +494 @@ +- public fun burn_nfts(nfts: vector) { ++ public fun burn_nfts(mut nfts: vector) { +--- tests/unit/sub_name_tests.move ++++ tests/unit/sub_name_tests.move +@@ -17,2 +17,2 @@ +- let ctx = tx_context::dummy(); +- let clock = clock::create_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let mut clock = clock::create_for_testing(&mut ctx); +@@ -22 +22 @@ +- let nft = suins_registration::new_for_testing(domain, 1, &clock, &mut ctx); ++ let mut nft = suins_registration::new_for_testing(domain, 1, &clock, &mut ctx); +@@ -25 +25 @@ +- let sub_nft = subdomain::new(nft, &clock, &mut ctx); ++ let mut sub_nft = subdomain::new(nft, &clock, &mut ctx); +@@ -41 +41 @@ +- let ctx = tx_context::dummy(); ++ let mut ctx = tx_context::dummy(); +@@ -54,2 +54,2 @@ +- let ctx = tx_context::dummy(); +- let clock = clock::create_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let mut clock = clock::create_for_testing(&mut ctx); +@@ -68 +68 @@ +- let ctx = tx_context::dummy(); ++ let mut ctx = tx_context::dummy(); +--- tests/unit/suins_tests.move ++++ tests/unit/suins_tests.move +@@ -16 +16 @@ +- struct TestConfig has store, drop { a: u8 } ++ public struct TestConfig has store, drop { a: u8 } +@@ -21,2 +21,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, cap) = suins::new_for_testing(&mut ctx); +@@ -34 +34 @@ +- struct TestRegistry has store { counter: u8 } ++ public struct TestRegistry has store { counter: u8 } +@@ -39,2 +39,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, cap) = suins::new_for_testing(&mut ctx); +@@ -51 +51 @@ +- struct TestApp has drop {} ++ public struct TestApp has drop {} +@@ -53 +53 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -56,2 +56,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, _cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, _cap) = suins::new_for_testing(&mut ctx); +@@ -62 +62 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -65,2 +65,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, _cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, _cap) = suins::new_for_testing(&mut ctx); +@@ -75,2 +75,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, cap) = suins::new_for_testing(&mut ctx); +@@ -103,2 +103,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, cap) = suins::new_for_testing(&mut ctx); +@@ -116 +116 @@ +- #[test, expected_failure(abort_code = suins::suins::ENoProfits)] ++ #[test, expected_failure(abort_code = ::suins::suins::ENoProfits)] +@@ -120,2 +120,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, cap) = suins::new_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, cap) = suins::new_for_testing(&mut ctx); +--- tests/v2/register.move ++++ tests/v2/register.move +@@ -25 +25 @@ +- struct Register has drop {} ++ public struct Register has drop {} +--- tests/v2/renew.move ++++ tests/v2/renew.move +@@ -31 +31 @@ +- struct Renew has drop {} ++ public struct Renew has drop {} diff --git a/packages/suins/sources/actions/update_image.move b/packages/suins/sources/actions/update_image.move index a7633f18..b3a882c4 100644 --- a/packages/suins/sources/actions/update_image.move +++ b/packages/suins/sources/actions/update_image.move @@ -22,7 +22,7 @@ module suins::update_image { const ESignatureNotMatch: u64 = 2; /// Authorization token for the app. - struct UpdateImage has drop {} + public struct UpdateImage has drop {} /// Updates the image attached to a `SuinsRegistration`. entry fun update_image_url( @@ -69,7 +69,7 @@ module suins::update_image { /// } /// ``` fun image_data_from_bcs(msg_bytes: vector): (String, String, u64, String) { - let bcs = bcs::new(msg_bytes); + let mut bcs = bcs::new(msg_bytes); let ipfs_hash = utf8(bcs::peel_vec_u8(&mut bcs)); let domain_name = utf8(bcs::peel_vec_u8(&mut bcs)); diff --git a/packages/suins/sources/admin.move b/packages/suins/sources/admin.move index 783ce224..e6960758 100644 --- a/packages/suins/sources/admin.move +++ b/packages/suins/sources/admin.move @@ -16,7 +16,7 @@ module suins::admin { use suins::registry::{Self, Registry}; /// The authorization witness. - struct Admin has drop {} + public struct Admin has drop {} /// Authorize the admin application in the SuiNS to get access /// to protected functions. Must be called in order to use the rest @@ -44,7 +44,7 @@ module suins::admin { entry fun reserve_domains( _: &AdminCap, suins: &mut SuiNS, - domains: vector, + mut domains: vector, no_years: u8, clock: &Clock, ctx: &mut TxContext diff --git a/packages/suins/sources/auction.move b/packages/suins/sources/auction.move index f6462553..8d97a320 100644 --- a/packages/suins/sources/auction.move +++ b/packages/suins/sources/auction.move @@ -46,17 +46,17 @@ module suins::auction { const ENoProfits: u64 = 13; /// Authorization witness to call protected functions of suins. - struct App has drop {} + public struct App has drop {} /// The AuctionHouse application. - struct AuctionHouse has key, store { + public struct AuctionHouse has key, store { id: UID, balance: Balance, auctions: LinkedTable, } /// The Auction application. - struct Auction has store { + public struct Auction has store { domain: Domain, start_timestamp_ms: u64, end_timestamp_ms: u64, @@ -143,7 +143,7 @@ module suins::auction { let Auction { domain, start_timestamp_ms, - end_timestamp_ms, + mut end_timestamp_ms, winner, current_bid, nft, @@ -361,10 +361,10 @@ module suins::auction { public fun admin_try_finalize_auctions( admin: &AdminCap, self: &mut AuctionHouse, - operation_limit: u64, + mut operation_limit: u64, clock: &Clock, ) { - let next_domain = *linked_table::back(&self.auctions); + let mut next_domain = *linked_table::back(&self.auctions); while (is_some(&next_domain)) { if (operation_limit == 0) { @@ -391,7 +391,7 @@ module suins::auction { // === Events === - struct AuctionStartedEvent has copy, drop { + public struct AuctionStartedEvent has copy, drop { domain: Domain, start_timestamp_ms: u64, end_timestamp_ms: u64, @@ -399,7 +399,7 @@ module suins::auction { bidder: address, } - struct AuctionFinalizedEvent has copy, drop { + public struct AuctionFinalizedEvent has copy, drop { domain: Domain, start_timestamp_ms: u64, end_timestamp_ms: u64, @@ -407,13 +407,13 @@ module suins::auction { winner: address, } - struct BidEvent has copy, drop { + public struct BidEvent has copy, drop { domain: Domain, bid: u64, bidder: address, } - struct AuctionExtendedEvent has copy, drop { + public struct AuctionExtendedEvent has copy, drop { domain: Domain, end_timestamp_ms: u64, } diff --git a/packages/suins/sources/config.move b/packages/suins/sources/config.move index 4959772d..1e93be3d 100644 --- a/packages/suins/sources/config.move +++ b/packages/suins/sources/config.move @@ -41,7 +41,7 @@ module suins::config { /// application. Does not carry any business logic and can easily /// be replaced with any other module providing similar interface /// and fitting the needs of the application. - struct Config has store, drop { + public struct Config has store, drop { public_key: vector, three_char_price: u64, four_char_price: u64, diff --git a/packages/suins/sources/controller.move b/packages/suins/sources/controller.move index 920833a1..12ba9073 100644 --- a/packages/suins/sources/controller.move +++ b/packages/suins/sources/controller.move @@ -20,7 +20,7 @@ module suins::controller { const EUnsupportedKey: u64 = 0; /// Authorization token for the controller. - struct Controller has drop {} + public struct Controller has drop {} // === Update Records Functionality === @@ -57,7 +57,7 @@ module suins::controller { ) { let registry = suins::app_registry_mut(Controller {}, suins); - let data = *registry::get_data(registry, nft::domain(nft)); + let mut data = *registry::get_data(registry, nft::domain(nft)); let domain = nft::domain(nft); registry::assert_nft_is_authorized(registry, nft, clock); @@ -77,7 +77,7 @@ module suins::controller { suins: &mut SuiNS, nft: &SuinsRegistration, key: String, clock: &Clock ) { let registry = suins::app_registry_mut(Controller {}, suins); - let data = *registry::get_data(registry, nft::domain(nft)); + let mut data = *registry::get_data(registry, nft::domain(nft)); let domain = nft::domain(nft); registry::assert_nft_is_authorized(registry, nft, clock); diff --git a/packages/suins/sources/domain.move b/packages/suins/sources/domain.move index 43526b32..e28172de 100644 --- a/packages/suins/sources/domain.move +++ b/packages/suins/sources/domain.move @@ -20,7 +20,7 @@ module suins::domain { const MAX_LABEL_LENGTH: u64 = 63; /// Representation of a valid SuiNS `Domain`. - struct Domain has copy, drop, store { + public struct Domain has copy, drop, store { /// Vector of labels that make up a domain. /// /// Labels are stored in reverse order such that the TLD is always in position `0`. @@ -32,7 +32,7 @@ module suins::domain { public fun new(domain: String): Domain { assert!(string::length(&domain) <= MAX_DOMAIN_LENGTH, EInvalidDomain); - let labels = split_by_dot(domain); + let mut labels = split_by_dot(domain); validate_labels(&labels); vector::reverse(&mut labels); Domain { @@ -44,8 +44,8 @@ module suins::domain { public fun to_string(self: &Domain): String { let dot = utf8(b"."); let len = vector::length(&self.labels); - let i = 0; - let out = string::utf8(vector::empty()); + let mut i = 0; + let mut out = string::utf8(vector::empty()); while (i < len) { let part = vector::borrow(&self.labels, (len - i) - 1); @@ -97,7 +97,7 @@ module suins::domain { /// Derive the parent of a subdomain. /// e.g. `subdomain.example.sui` -> `example.sui` public fun parent(domain: &Domain): Domain { - let labels = domain.labels; + let mut labels = domain.labels; // we pop the last element and construct the parent from the remaining labels. vector::pop_back(&mut labels); @@ -116,7 +116,7 @@ module suins::domain { assert!(!vector::is_empty(labels), EInvalidDomain); let len = vector::length(labels); - let index = 0; + let mut index = 0; while (index < len) { let label = vector::borrow(labels, index); @@ -128,7 +128,7 @@ module suins::domain { fun is_valid_label(label: &String): bool { let len = string::length(label); let label_bytes = string::bytes(label); - let index = 0; + let mut index = 0; if (!(len >= MIN_LABEL_LENGTH && len <= MAX_LABEL_LENGTH)) { return false @@ -152,9 +152,9 @@ module suins::domain { } /// Splits a string `s` by the character `.` into a vector of subslices, excluding the `.` - fun split_by_dot(s: String): vector { + fun split_by_dot(mut s: String): vector { let dot = utf8(b"."); - let parts: vector = vector[]; + let mut parts: vector = vector[]; while (!string::is_empty(&s)) { let index_of_next_dot = string::index_of(&s, &dot); let part = string::sub_string(&s, 0, index_of_next_dot); @@ -188,7 +188,7 @@ module suins::domain { // Validate `domain::label` function let len = vector::length(&expected_labels); - let index = 0; + let mut index = 0; while (index < len) { let label = vector::borrow(&expected_labels, index); @@ -198,8 +198,8 @@ module suins::domain { } #[test_only] - fun prep_expected_labels(labels: vector>): vector { - let out = vector[]; + fun prep_expected_labels(mut labels: vector>): vector { + let mut out = vector[]; while (!vector::is_empty(&labels)) { let label = vector::pop_back(&mut labels); vector::push_back(&mut out, utf8(label)); diff --git a/packages/suins/sources/name_record.move b/packages/suins/sources/name_record.move index d4442dd1..91f2383e 100644 --- a/packages/suins/sources/name_record.move +++ b/packages/suins/sources/name_record.move @@ -16,7 +16,7 @@ module suins::name_record { use suins::constants; /// A single record in the registry. - struct NameRecord has copy, store, drop { + public struct NameRecord has copy, store, drop { /// The ID of the `SuinsRegistration` assigned to this record. /// /// The owner of the corrisponding `SuinsRegistration` has the rights to diff --git a/packages/suins/sources/registry.move b/packages/suins/sources/registry.move index d6611f62..1f8e680a 100644 --- a/packages/suins/sources/registry.move +++ b/packages/suins/sources/registry.move @@ -40,7 +40,7 @@ module suins::registry { /// and the `suins` module controls the access to the `Registry`. /// /// Contains two tables necessary for the lookup. - struct Registry has store { + public struct Registry has store { /// The `registry` table maps `Domain` to `NameRecord`. /// Added / replaced in the `add_record` function. registry: Table, diff --git a/packages/suins/sources/subdomain_registration.move b/packages/suins/sources/subdomain_registration.move index a43b975d..5a28b601 100644 --- a/packages/suins/sources/subdomain_registration.move +++ b/packages/suins/sources/subdomain_registration.move @@ -16,8 +16,8 @@ module suins::subdomain_registration { use suins::suins_registration::{Self, SuinsRegistration}; use suins::domain; - friend suins::registry; - #[test_only] friend suins::sub_name_tests; + /* friend suins::registry; */ + /* #[test_only] */ /* friend suins::sub_name_tests; */ /// === Error codes === /// @@ -29,14 +29,14 @@ module suins::subdomain_registration { const ENameNotExpired: u64 = 3; /// A wrapper for SuinsRegistration object specifically for SubNames. - struct SubDomainRegistration has key, store { + public struct SubDomainRegistration has key, store { id: UID, nft: SuinsRegistration } /// Creates a `SubName` wrapper for SuinsRegistration object /// (as long as it's used for a subdomain). - public(friend) fun new(nft: SuinsRegistration, clock: &Clock, ctx: &mut TxContext): SubDomainRegistration { + public(package) fun new(nft: SuinsRegistration, clock: &Clock, ctx: &mut TxContext): SubDomainRegistration { // Can't wrap a non-subdomain NFT. assert!(domain::is_subdomain(&suins_registration::domain(&nft)), ENotSubdomain); // Can't wrap an expired NFT. @@ -50,7 +50,7 @@ module suins::subdomain_registration { /// Destroys the wrapper and returns the SuinsRegistration object. /// Fails if the subname is not expired. - public(friend) fun burn(name: SubDomainRegistration, clock: &Clock): SuinsRegistration { + public(package) fun burn(name: SubDomainRegistration, clock: &Clock): SuinsRegistration { // tries to unwrap a non-expired subname. assert!(suins_registration::has_expired(&name.nft, clock), ENameNotExpired); diff --git a/packages/suins/sources/suins.move b/packages/suins/sources/suins.move index bdf8ccbf..4b1e3993 100644 --- a/packages/suins/sources/suins.move +++ b/packages/suins/sources/suins.move @@ -36,7 +36,7 @@ module suins::suins { /// An admin capability. The admin has full control over the application. /// This object must be issued only once during module initialization. - struct AdminCap has key, store { id: UID } + public struct AdminCap has key, store { id: UID } /// The main application object. Stores the state of the application, /// used for adding / removing and reading name records. @@ -44,7 +44,7 @@ module suins::suins { /// Dynamic fields: /// - `registry: RegistryKey -> R` /// - `config: ConfigKey -> C` - struct SuiNS has key { + public struct SuiNS has key { id: UID, /// The total balance of the SuiNS. Can be added to by authorized apps. /// Can be withdrawn only by the application Admin. @@ -52,21 +52,21 @@ module suins::suins { } /// The one-time-witness used to claim Publisher object. - struct SUINS has drop {} + public struct SUINS has drop {} // === Keys === /// Key under which a configuration is stored. It is type dependent, so /// that different configurations can be stored at the same time. Eg /// currently we store application `Config` (and `Promotion` configuration). - struct ConfigKey has copy, store, drop {} + public struct ConfigKey has copy, store, drop {} /// Key under which the Registry object is stored. /// /// In the V1, the object stored under this key is `Registry`, however, for /// future migration purposes (if we ever need to change the Registry), we /// keep the phantom parameter so two different Registries can co-exist. - struct RegistryKey has copy, store, drop {} + public struct RegistryKey has copy, store, drop {} /// Module initializer: /// - create SuiNS object @@ -105,7 +105,7 @@ module suins::suins { /// protected features of the SuiNS (such as app_add_balance, etc.) /// The `App` type parameter is a witness which should be defined in the /// original module (Controller, Registry, Registrar - whatever). - struct AppKey has copy, store, drop {} + public struct AppKey has copy, store, drop {} /// Authorize an application to access protected features of the SuiNS. public fun authorize_app(_: &AdminCap, self: &mut SuiNS) { @@ -181,7 +181,7 @@ module suins::suins { // === Testing === #[test_only] use suins::config; - #[test_only] struct Test has drop {} + #[test_only] public struct Test has drop {} #[test_only] public fun new_for_testing(ctx: &mut TxContext): (SuiNS, AdminCap) { @@ -195,7 +195,7 @@ module suins::suins { /// Wrapper of module initializer for testing public fun init_for_testing(ctx: &mut TxContext): SuiNS { let admin_cap = AdminCap { id: object::new(ctx) }; - let suins = SuiNS { + let mut suins = SuiNS { id: object::new(ctx), balance: balance::zero(), }; diff --git a/packages/suins/sources/suins_registration.move b/packages/suins/sources/suins_registration.move index 8445015e..a154753c 100644 --- a/packages/suins/sources/suins_registration.move +++ b/packages/suins/sources/suins_registration.move @@ -19,11 +19,11 @@ module suins::suins_registration { use suins::constants; use suins::domain::{Self, Domain}; - friend suins::registry; - friend suins::update_image; + /* friend suins::registry; */ + /* friend suins::update_image; */ /// The main access point for the user. - struct SuinsRegistration has key, store { + public struct SuinsRegistration has key, store { id: UID, /// The parsed domain. domain: Domain, @@ -39,7 +39,7 @@ module suins::suins_registration { /// Creates a new `SuinsRegistration`. /// Can only be called by the `registry` module. - public(friend) fun new( + public(package) fun new( domain: Domain, no_years: u8, clock: &Clock, @@ -55,19 +55,19 @@ module suins::suins_registration { } /// Sets the `expiration_timestamp_ms` for this NFT. - public(friend) fun set_expiration_timestamp_ms(self: &mut SuinsRegistration, expiration_timestamp_ms: u64) { + public(package) fun set_expiration_timestamp_ms(self: &mut SuinsRegistration, expiration_timestamp_ms: u64) { self.expiration_timestamp_ms = expiration_timestamp_ms; } /// Updates the `image_url` field for this NFT. Is only called in the `update_image` for now. - public(friend) fun update_image_url(self: &mut SuinsRegistration, image_url: String) { + public(package) fun update_image_url(self: &mut SuinsRegistration, image_url: String) { self.image_url = image_url; } /// Destroys the `SuinsRegistration` by deleting it from the store, returning /// storage rebates to the caller. /// Can only be called by the `registry` module. - public(friend) fun burn(self: SuinsRegistration) { + public(package) fun burn(self: SuinsRegistration) { let SuinsRegistration { id, image_url: _, diff --git a/packages/suins/tests/auction_tests.move b/packages/suins/tests/auction_tests.move index e63cb642..9a3d5ad6 100644 --- a/packages/suins/tests/auction_tests.move +++ b/packages/suins/tests/auction_tests.move @@ -32,10 +32,10 @@ module suins::auction_tests { const AUCTION_MIN_QUIET_PERIOD_MS: u64 = 10 * 60 * 1000; // 10 minutes of quiet time public fun test_init(): Scenario { - let scenario_val = test_scenario::begin(SUINS_ADDRESS); + let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); auction::init_for_testing(ctx(scenario)); @@ -45,7 +45,7 @@ module suins::auction_tests { { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -62,8 +62,8 @@ module suins::auction_tests { amount: u64 ) { test_scenario::next_tx(scenario, sender); - let auction_house = test_scenario::take_shared(scenario); - let suins = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let payment = coin::mint_for_testing(amount, ctx(scenario)); let clock = test_scenario::take_shared(scenario); @@ -83,9 +83,9 @@ module suins::auction_tests { fun place_bid_util(scenario: &mut Scenario, sender: address, domain_name: String, value: u64, clock_tick: u64) { test_scenario::next_tx(scenario, sender); - let auction_house = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); let payment = coin::mint_for_testing(value, ctx(scenario)); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); place_bid(&mut auction_house, domain_name, payment, &clock, ctx(scenario)); @@ -101,8 +101,8 @@ module suins::auction_tests { clock_tick: u64 ): SuinsRegistration { test_scenario::next_tx(scenario, sender); - let auction_house = test_scenario::take_shared(scenario); - let clock = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); let nft = claim(&mut auction_house, domain_name, &clock, ctx(scenario)); @@ -120,8 +120,8 @@ module suins::auction_tests { fun admin_collect_fund_util(scenario: &mut Scenario, domain_name: String, clock_tick: u64) { test_scenario::next_tx(scenario, SUINS_ADDRESS); - let auction_house = test_scenario::take_shared(scenario); - let clock = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); collect_winning_auction_fund(&mut auction_house, domain_name, &clock, ctx(scenario)); @@ -137,8 +137,8 @@ module suins::auction_tests { ) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let auction_house = test_scenario::take_shared(scenario); - let clock = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); admin_finalize_auction(&admin_cap, &mut auction_house, domain, &clock); @@ -151,8 +151,8 @@ module suins::auction_tests { fun admin_try_finalize_auctions_util(scenario: &mut Scenario, operation_limit: u64, clock_tick: u64) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let auction_house = test_scenario::take_shared(scenario); - let clock = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); admin_try_finalize_auctions(&admin_cap, &mut auction_house, operation_limit, &clock); @@ -165,7 +165,7 @@ module suins::auction_tests { fun admin_withdraw_funds_util(scenario: &mut Scenario): Coin { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let auction_house = test_scenario::take_shared(scenario); + let mut auction_house = test_scenario::take_shared(scenario); let funds = admin_withdraw_funds(&admin_cap, &mut auction_house, ctx(scenario)); @@ -177,7 +177,7 @@ module suins::auction_tests { fun deauthorize_app_util(scenario: &mut Scenario) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); suins::deauthorize_app(&admin_cap, &mut suins); @@ -202,7 +202,7 @@ module suins::auction_tests { ) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let auction_house = test_scenario::take_shared(scenario); - let (start_ms, end_ms, winner, highest_amount) = auction::get_auction_metadata(&auction_house, domain_name); + let (mut start_ms, mut end_ms, mut winner, mut highest_amount) = auction::get_auction_metadata(&auction_house, domain_name); assert!(option::extract(&mut start_ms) == expected_start_ms, 0); assert!(option::extract(&mut end_ms) == expected_end_ms, 0); assert!(option::extract(&mut winner) == expected_winner, 0); @@ -253,7 +253,7 @@ module suins::auction_tests { #[test] fun test_normal_auction_flow() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; normal_auction_flow(scenario); test_scenario::end(scenario_val); @@ -261,7 +261,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = sui::dynamic_field::EFieldDoesNotExist)] fun test_claim_aborts_if_winner_claims_twice() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -280,7 +280,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EWinnerCannotPlaceBid)] fun test_winner_cannot_place_bid() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -296,7 +296,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EBidAmountTooLow)] fun test_place_bid_aborts_if_value_is_too_low() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -311,7 +311,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::ENotWinner)] fun test_non_winner_cannot_claim() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -328,7 +328,7 @@ module suins::auction_tests { #[test] fun test_admin_try_finalize_auction() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -361,7 +361,7 @@ module suins::auction_tests { #[test] fun test_admin_try_finalize_auction_2_auctions() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -394,7 +394,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EAuctionNotEndedYet)] fun test_admin_try_finalize_auction_too_early() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -409,7 +409,7 @@ module suins::auction_tests { #[test] fun test_admin_try_finalize_auctions_too_early() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -425,7 +425,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EAuctionEnded)] fun test_place_bid_aborts_if_too_late() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -445,7 +445,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::ENoProfits)] fun test_admin_withdraw_funds_aborts_if_no_profits() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let funds = admin_withdraw_funds_util(scenario); coin::burn_for_testing(funds); @@ -454,7 +454,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = config::EInvalidTld)] fun test_start_auction_aborts_with_wrong_tld() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -467,7 +467,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = config::ELabelTooShort)] fun test_start_auction_aborts_if_domain_name_too_short() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -480,7 +480,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_start_auction_aborts_if_domain_name_too_long() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -493,7 +493,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_start_auction_aborts_if_domain_name_starts_with_dash() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -506,7 +506,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_start_auction_aborts_if_domain_name_ends_with_dash() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -519,7 +519,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_start_auction_aborts_if_domain_name_contains_uppercase_characters() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -532,7 +532,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EAuctionNotStarted)] fun test_place_bid_aborts_if_auction_not_started() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; place_bid_util(scenario, SECOND_ADDRESS, utf8(FIRST_DOMAIN_NAME), 1210 * mist_per_sui(), 0); test_scenario::end(scenario_val); @@ -540,7 +540,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EInvalidBidValue)] fun test_start_auction_aborts_if_not_enough_fee() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -553,7 +553,7 @@ module suins::auction_tests { #[test] fun test_admin_collect_fund() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -592,7 +592,7 @@ module suins::auction_tests { #[test, expected_failure(abort_code = auction::EAuctionNotEndedYet)] fun test_admin_collect_fund_aborts_if_too_early() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -604,9 +604,9 @@ module suins::auction_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_start_auction_and_place_bid_aborts_if_auction_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; deauthorize_app_util(scenario); start_auction_and_place_bid_util( @@ -620,7 +620,7 @@ module suins::auction_tests { #[test] fun test_place_bid_and_claim_and_withdraw_works_even_if_auction_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -659,7 +659,7 @@ module suins::auction_tests { #[test] fun test_admin_try_finalize_auction_works_even_if_auction_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, @@ -693,7 +693,7 @@ module suins::auction_tests { #[test] fun test_admin_collect_fund_even_if_auction_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; start_auction_and_place_bid_util( scenario, diff --git a/packages/suins/tests/controller_tests.move b/packages/suins/tests/controller_tests.move index 9ab04bea..11260b23 100644 --- a/packages/suins/tests/controller_tests.move +++ b/packages/suins/tests/controller_tests.move @@ -32,10 +32,10 @@ module suins::controller_tests { const CONTENT_HASH: vector = b"content_hash"; fun test_init(): Scenario { - let scenario_val = test_scenario::begin(SUINS_ADDRESS); + let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); @@ -45,7 +45,7 @@ module suins::controller_tests { { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -62,9 +62,9 @@ module suins::controller_tests { public fun set_target_address_util(scenario: &mut Scenario, sender: address, target: Option
, clock_tick: u64) { test_scenario::next_tx(scenario, sender); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let nft = test_scenario::take_from_sender(scenario); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); set_target_address_for_testing(&mut suins, &nft, target, &clock); @@ -76,7 +76,7 @@ module suins::controller_tests { public fun set_reverse_lookup_util(scenario: &mut Scenario, sender: address, domain_name: String) { test_scenario::next_tx(scenario, sender); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); set_reverse_lookup_for_testing(&mut suins, domain_name, ctx(scenario)); @@ -85,7 +85,7 @@ module suins::controller_tests { public fun unset_reverse_lookup_util(scenario: &mut Scenario, sender: address) { test_scenario::next_tx(scenario, sender); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); unset_reverse_lookup_for_testing(&mut suins, ctx(scenario)); @@ -94,9 +94,9 @@ module suins::controller_tests { public fun set_user_data_util(scenario: &mut Scenario, sender: address, key: String, value: String, clock_tick: u64) { test_scenario::next_tx(scenario, sender); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let nft = test_scenario::take_from_sender(scenario); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); set_user_data_for_testing(&mut suins, &nft, key, value, &clock); @@ -108,9 +108,9 @@ module suins::controller_tests { public fun unset_user_data_util(scenario: &mut Scenario, sender: address, key: String, clock_tick: u64) { test_scenario::next_tx(scenario, sender); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let nft = test_scenario::take_from_sender(scenario); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); unset_user_data_for_testing(&mut suins, &nft, key, &clock); @@ -157,7 +157,7 @@ module suins::controller_tests { fun deauthorize_app_util(scenario: &mut Scenario) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); suins::deauthorize_app(&admin_cap, &mut suins); @@ -167,7 +167,7 @@ module suins::controller_tests { #[test] fun test_set_target_address() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -183,7 +183,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::ERecordExpired)] fun test_set_target_address_aborts_if_nft_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -194,7 +194,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::EIdMismatch)] fun test_set_target_address_aborts_if_nft_expired_2() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); setup(scenario, SECOND_ADDRESS, 2 * year_ms()); @@ -206,7 +206,7 @@ module suins::controller_tests { #[test] fun test_set_target_address_works_if_domain_is_registered_again() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); setup(scenario, SECOND_ADDRESS, 2 * year_ms()); @@ -217,9 +217,9 @@ module suins::controller_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_set_target_address_aborts_if_controller_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -231,7 +231,7 @@ module suins::controller_tests { #[test] fun test_set_reverse_lookup() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -252,7 +252,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::ETargetNotSet)] fun test_set_reverse_lookup_aborts_if_target_address_not_set() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -264,7 +264,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::ERecordMismatch)] fun test_set_reverse_lookup_aborts_if_target_address_not_match() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -275,9 +275,9 @@ module suins::controller_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_set_reverse_lookup_aborts_if_controller_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -290,7 +290,7 @@ module suins::controller_tests { #[test] fun test_unset_reverse_lookup() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -303,9 +303,9 @@ module suins::controller_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_unset_reverse_lookup_if_controller_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -319,7 +319,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = dynamic_field::EFieldDoesNotExist)] fun test_unset_reverse_lookup_aborts_if_not_set() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -330,7 +330,7 @@ module suins::controller_tests { #[test] fun test_set_user_data() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -352,7 +352,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = controller::EUnsupportedKey)] fun test_set_user_data_aborts_if_key_is_unsupported() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -363,7 +363,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::ERecordExpired)] fun test_set_user_data_aborts_if_nft_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -374,7 +374,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::EIdMismatch)] fun test_set_user_data_aborts_if_nft_expired_2() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); setup(scenario, SECOND_ADDRESS, 2 * year_ms()); @@ -386,7 +386,7 @@ module suins::controller_tests { #[test] fun test_set_user_data_works_if_domain_is_registered_again() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); setup(scenario, SECOND_ADDRESS, 2 * year_ms()); @@ -399,9 +399,9 @@ module suins::controller_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_set_user_data_aborts_if_controller_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -413,7 +413,7 @@ module suins::controller_tests { #[test] fun test_unset_user_data() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -434,7 +434,7 @@ module suins::controller_tests { #[test] fun test_unset_user_data_works_if_key_not_exists() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -445,7 +445,7 @@ module suins::controller_tests { #[test, expected_failure(abort_code = registry::ERecordExpired)] fun test_unset_user_data_aborts_if_nft_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); @@ -454,9 +454,9 @@ module suins::controller_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_unset_user_data_works_if_controller_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; setup(scenario, FIRST_ADDRESS, 0); diff --git a/packages/suins/tests/register_tests.move b/packages/suins/tests/register_tests.move index 4a609b4a..1ac3520f 100644 --- a/packages/suins/tests/register_tests.move +++ b/packages/suins/tests/register_tests.move @@ -27,10 +27,10 @@ module suins::register_sample_tests { const DOMAIN_NAME: vector = b"abc.sui"; public fun test_init(): Scenario { - let scenario_val = test_scenario::begin(SUINS_ADDRESS); + let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); @@ -40,7 +40,7 @@ module suins::register_sample_tests { { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -58,9 +58,9 @@ module suins::register_sample_tests { clock_tick: u64 ): SuinsRegistration { test_scenario::next_tx(scenario, SUINS_ADDRESS); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let payment = coin::mint_for_testing(amount, ctx(scenario)); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); let nft = register(&mut suins, domain_name, no_years, payment, &clock, ctx(scenario)); @@ -74,7 +74,7 @@ module suins::register_sample_tests { fun deauthorize_app_util(scenario: &mut Scenario) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); suins::deauthorize_app(&admin_cap, &mut suins); @@ -91,7 +91,7 @@ module suins::register_sample_tests { #[test] fun test_register() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); @@ -117,7 +117,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = config::EInvalidTld)] fun test_register_if_not_sui_tld() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"abc.move"), 1, 1200 * mist_per_sui(), 10); @@ -128,7 +128,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = register::EIncorrectAmount)] fun test_register_if_incorrect_amount() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1210 * mist_per_sui(), 10); @@ -139,7 +139,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = register::EIncorrectAmount)] fun test_register_if_incorrect_amount_2() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 90 * mist_per_sui(), 10); @@ -150,7 +150,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = register::EInvalidYearsArgument)] fun test_register_if_no_years_more_than_5_years() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 6, 6 * 1200 * mist_per_sui(), 10); @@ -161,7 +161,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = register::EInvalidYearsArgument)] fun test_register_if_no_years_is_zero() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 0, 1200 * mist_per_sui(), 10); @@ -172,7 +172,7 @@ module suins::register_sample_tests { #[test] fun test_register_if_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); @@ -201,7 +201,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = registry::ERecordNotExpired)] fun test_register_if_not_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); @@ -218,7 +218,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_register_if_domain_name_starts_with_dash() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"-ab.sui"), 1, 1200 * mist_per_sui(), 10); @@ -229,7 +229,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_register_if_domain_name_ends_with_dash() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"ab-.sui"), 1, 1200 * mist_per_sui(), 10); @@ -240,7 +240,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_register_if_domain_name_contains_uppercase_character() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"Abc.com"), 1, 1200 * mist_per_sui(), 10); @@ -251,7 +251,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = config::ELabelTooShort)] fun test_register_if_domain_name_too_short() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"ab.sui"), 1, 1200 * mist_per_sui(), 10); @@ -262,7 +262,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = config::EInvalidDomain)] fun test_register_if_domain_name_contains_subdomain() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"abc.xyz.sui"), 1, 1200 * mist_per_sui(), 10); @@ -273,7 +273,7 @@ module suins::register_sample_tests { #[test, expected_failure(abort_code = registry::ERecordNotExpired)] fun test_register_aborts_if_domain_name_went_through_auction() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; auction::init_for_testing(ctx(scenario)); @@ -286,7 +286,7 @@ module suins::register_sample_tests { #[test] fun test_register_works_if_auctioned_domain_name_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; auction::init_for_testing(ctx(scenario)); @@ -305,9 +305,9 @@ module suins::register_sample_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_register_aborts_if_register_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; deauthorize_app_util(scenario); diff --git a/packages/suins/tests/renew_tests.move b/packages/suins/tests/renew_tests.move index b29eef9b..3bbec113 100644 --- a/packages/suins/tests/renew_tests.move +++ b/packages/suins/tests/renew_tests.move @@ -22,10 +22,10 @@ module suins::renew_tests { const DOMAIN_NAME: vector = b"abc.sui"; public fun test_init(): Scenario { - let scenario_val = test_scenario::begin(SUINS_ADDRESS); + let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); @@ -35,7 +35,7 @@ module suins::renew_tests { { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -47,9 +47,9 @@ module suins::renew_tests { fun renew_util(scenario: &mut Scenario, nft: &mut SuinsRegistration, no_years: u8, amount: u64, clock_tick: u64) { test_scenario::next_tx(scenario, SUINS_ADDRESS); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let payment = coin::mint_for_testing(amount, ctx(scenario)); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); renew(&mut suins, nft, no_years, payment, &clock); @@ -61,7 +61,7 @@ module suins::renew_tests { fun deauthorize_app_util(scenario: &mut Scenario) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); suins::deauthorize_app(&admin_cap, &mut suins); @@ -71,22 +71,22 @@ module suins::renew_tests { #[test] fun test_renew() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0); + let mut nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0); assert!(suins_registration::expiration_timestamp_ms(&nft) == year_ms(), 0); renew_util(scenario, &mut nft, 1, 200 * mist_per_sui(), 0); assert_balance(scenario, 400 * mist_per_sui()); suins_registration::burn_for_testing(nft); - let nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0); + let mut nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0); assert!(suins_registration::expiration_timestamp_ms(&nft) == year_ms(), 0); renew_util(scenario, &mut nft, 1, 50 * mist_per_sui(), 0); assert_balance(scenario, 500 * mist_per_sui()); suins_registration::burn_for_testing(nft); - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); assert!(suins_registration::expiration_timestamp_ms(&nft) == year_ms() + 10, 0); renew_util(scenario, &mut nft, 1, 1200 * mist_per_sui(), 0); assert_balance(scenario, 2900 * mist_per_sui()); @@ -102,10 +102,10 @@ module suins::renew_tests { #[test, expected_failure(abort_code = renew::EIncorrectAmount)] fun test_renew_aborts_if_incorrect_amount() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); renew_util(scenario, &mut nft, 1, 1210 * mist_per_sui(), 0); suins_registration::burn_for_testing(nft); @@ -114,10 +114,10 @@ module suins::renew_tests { #[test, expected_failure(abort_code = renew::EIncorrectAmount)] fun test_renew_aborts_if_incorrect_amount_2() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); renew_util(scenario, &mut nft, 1, 10 * mist_per_sui(), 0); suins_registration::burn_for_testing(nft); @@ -126,10 +126,10 @@ module suins::renew_tests { #[test, expected_failure(abort_code = renew::EGracePeriodPassed)] fun test_renew_aborts_if_nft_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); renew_util(scenario, &mut nft, 1, 1200 * mist_per_sui(), 2 * year_ms() + 20); suins_registration::burn_for_testing(nft); @@ -138,10 +138,10 @@ module suins::renew_tests { #[test, expected_failure(abort_code = renew::EInvalidYearsArgument)] fun test_renew_aborts_no_years_more_than_5_years() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); renew_util(scenario, &mut nft, 6, 7200 * mist_per_sui(), 0); suins_registration::burn_for_testing(nft); @@ -150,10 +150,10 @@ module suins::renew_tests { #[test, expected_failure(abort_code = renew::EInvalidNewExpiredAt)] fun test_renew_aborts_new_expiry_more_than_5_years() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); renew_util(scenario, &mut nft, 2, 2400 * mist_per_sui(), 0); renew_util(scenario, &mut nft, 4, 4800 * mist_per_sui(), 0); suins_registration::burn_for_testing(nft); @@ -161,12 +161,12 @@ module suins::renew_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_renew_aborts_if_renew_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); + let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); deauthorize_app_util(scenario); renew_util(scenario, &mut nft, 2, 2400 * mist_per_sui(), 0); suins_registration::burn_for_testing(nft); diff --git a/packages/suins/tests/unit/admin_tests.move b/packages/suins/tests/unit/admin_tests.move index cd5351f7..b5c5a4c5 100644 --- a/packages/suins/tests/unit/admin_tests.move +++ b/packages/suins/tests/unit/admin_tests.move @@ -24,10 +24,10 @@ module suins::admin_tests { /// The admin account. const ADMIN: address = @suins; - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun try_unathorized_fail() { - let ctx = tx_context::dummy(); - let suins = suins::init_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let mut suins = suins::init_for_testing(&mut ctx); let cap = suins::create_admin_cap_for_testing(&mut ctx); let clock = clock::create_for_testing(&mut ctx); @@ -45,8 +45,8 @@ module suins::admin_tests { #[test] fun authorized() { - let ctx = tx_context::dummy(); - let suins = suins::init_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let mut suins = suins::init_for_testing(&mut ctx); let cap = suins::create_admin_cap_for_testing(&mut ctx); let clock = clock::create_for_testing(&mut ctx); registry::init_for_testing(&cap, &mut suins, &mut ctx); diff --git a/packages/suins/tests/unit/config_tests.move b/packages/suins/tests/unit/config_tests.move index 691c8649..193748d0 100644 --- a/packages/suins/tests/unit/config_tests.move +++ b/packages/suins/tests/unit/config_tests.move @@ -20,7 +20,7 @@ module suins::config_tests { #[test] fun create_and_update_config() { - let config = default(); + let mut config = default(); // check that the values are set correctly in the `new` function assert!(config::public_key(&config) == &b"000000000000000000000000000000000", 0); @@ -88,7 +88,7 @@ module suins::config_tests { #[test] #[expected_failure(abort_code = suins::config::EInvalidPublicKey)] fun set_public_key_invalid_fail() { - let config = default(); + let mut config = default(); config::set_public_key(&mut config, vector[]); } diff --git a/packages/suins/tests/unit/name_record_tests.move b/packages/suins/tests/unit/name_record_tests.move index 08dcab43..6f88bee7 100644 --- a/packages/suins/tests/unit/name_record_tests.move +++ b/packages/suins/tests/unit/name_record_tests.move @@ -24,9 +24,9 @@ module suins::name_record_tests { /// Make sure that the fields are empty by default. That they are updated /// correctly and the values match. fun create_and_update() { - let ctx = tx_context::dummy(); + let mut ctx = tx_context::dummy(); let nft_id = fresh_id(&mut ctx); - let record = record::new(nft_id, 0); + let mut record = record::new(nft_id, 0); // check default values assert_eq(record::nft_id(&record), nft_id); @@ -34,7 +34,7 @@ module suins::name_record_tests { assert_eq(record::target_address(&record), none()); assert_eq(record::expiration_timestamp_ms(&record), 0); - let data = vec_map::empty(); + let mut data = vec_map::empty(); vec_map::insert(&mut data, utf8(b"user_name"), utf8(b"Brandon")); vec_map::insert(&mut data, utf8(b"age"), utf8(b"forever young")); @@ -52,10 +52,10 @@ module suins::name_record_tests { #[test] fun has_expired() { - let ctx = tx_context::dummy(); + let mut ctx = tx_context::dummy(); let nft_id = fresh_id(&mut ctx); let record = record::new(nft_id, 1000); // expires in 1 second - let clock = clock::create_for_testing(&mut ctx); + let mut clock = clock::create_for_testing(&mut ctx); // clock is 0, record expires in 1 second with a 30 days (grace period) assert_eq(record::has_expired(&record, &clock), false); diff --git a/packages/suins/tests/unit/registration_nft_tests.move b/packages/suins/tests/unit/registration_nft_tests.move index fc65f54e..8f98730a 100644 --- a/packages/suins/tests/unit/registration_nft_tests.move +++ b/packages/suins/tests/unit/registration_nft_tests.move @@ -20,8 +20,8 @@ module suins::registation_nft_tests { #[test] fun test_new() { - let ctx = tx_context::dummy(); - let clock = clock::create_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let mut clock = clock::create_for_testing(&mut ctx); let nft = new(utf8(b"test.sui"), 1, &clock, &mut ctx); // expiration date for 1 year should be 365 days from now @@ -50,9 +50,9 @@ module suins::registation_nft_tests { #[test] fun test_update_values() { - let ctx = tx_context::dummy(); + let mut ctx = tx_context::dummy(); let clock = clock::create_for_testing(&mut ctx); - let nft = new(utf8(b"test.sui"), 5, &clock, &mut ctx); + let mut nft = new(utf8(b"test.sui"), 5, &clock, &mut ctx); nft::set_expiration_timestamp_ms_for_testing(&mut nft, 0); assert_eq(nft::expiration_timestamp_ms(&nft), 0); diff --git a/packages/suins/tests/unit/registry_tests.move b/packages/suins/tests/unit/registry_tests.move index e61010c3..46e319e7 100644 --- a/packages/suins/tests/unit/registry_tests.move +++ b/packages/suins/tests/unit/registry_tests.move @@ -21,8 +21,8 @@ module suins::registry_tests { #[test] fun test_registry() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -45,8 +45,8 @@ module suins::registry_tests { /// 2. Add a leaf subdomain for that parent /// 3. Validate valid scenarios of using that leaf_node. fun test_leaf_records() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); // leaf subdomain to be added let subdomain_one = domain::new(utf8(b"test.hahaha.sui")); @@ -83,8 +83,8 @@ module suins::registry_tests { /// Overrides a leaf record (by just adding it again) as a new domain owner, /// while this leaf name existed before. fun override_leaf_record_after_change_of_parent_owner() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, _domain) = setup(&mut ctx); let nft = registry::add_record(&mut registry, domain::new(utf8(b"test.sui")), 1, &clock, &mut ctx); @@ -111,8 +111,8 @@ module suins::registry_tests { /// 2. Increment the clock to 1 year so that the record is expired; /// 3. Override the record and discard the old data; fun test_registry_expired_override() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -139,8 +139,8 @@ module suins::registry_tests { /// 2. Increment the clock to 1 year so that the record is expired, ignoring the grace period /// 3. Override the record and discard the old data; fun test_registry_expired_without_grace_period_override() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -167,8 +167,8 @@ module suins::registry_tests { /// 2. Increment the clock to less than 1 year so that the record is expired; /// 3. Try to override the record and fail - not expired; fun test_registry_expired_override_fail() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let _nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -182,8 +182,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::ERecordNotExpired)] /// Check that `add_record` preserves the fun test_registry_grace_period() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let _nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -201,8 +201,8 @@ module suins::registry_tests { /// Checks that `burn_registration_object` burns `SuinsRegistration` object /// but doesn't touch the NameRecord, as this name has been re-registered by a different user (after its expiration). fun test_registry_burn_name() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -230,8 +230,8 @@ module suins::registry_tests { /// `burn_registration_object` burns the SuinsRegistration object as well as removes the record, /// since it still points to the old owner. fun test_registry_burn_name_and_removes_record() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); @@ -255,15 +255,15 @@ module suins::registry_tests { /// 2. Call `set_target_address` and make sure that the address is set; /// 3. Check target address lookup; check that record has correct target; fun set_target_address() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); // create a record for the test domain with expiration set to 1 year let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); registry::set_target_address(&mut registry, domain, some(@0x2)); // try to find a record and then get a record - let search = registry::lookup(®istry, domain); + let mut search = registry::lookup(®istry, domain); let record = registry::remove_record_for_testing(&mut registry, domain); // make sure the search is a success @@ -282,8 +282,8 @@ module suins::registry_tests { /// 2. Call `set_target_address` and make sure that the address is set; /// 3. Call `set_reverse_lookup` and make sure that reverse registry updated; fun set_reverse_lookup() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); // set the `domain` points to @0x0; set the reverse lookup too @@ -291,7 +291,7 @@ module suins::registry_tests { registry::set_reverse_lookup(&mut registry, @0xB0B, domain); // search for the reverse_lookup record - let search = registry::reverse_lookup(®istry, @0xB0B); + let mut search = registry::reverse_lookup(®istry, @0xB0B); assert!(option::is_some(&search), 0); assert!(option::extract(&mut search) == domain, 0); @@ -306,8 +306,8 @@ module suins::registry_tests { #[test] fun burn_expired_subdomain() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, _domain) = setup(&mut ctx); let nft = registry::add_record(&mut registry, domain::new(utf8(b"node.test.sui")), 1, &clock, &mut ctx); @@ -322,8 +322,8 @@ module suins::registry_tests { #[test] fun burn_expired_suins_registration() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); // increment the clock to 1 years + grace period clock::increment_for_testing(&mut clock, constants::year_ms() + 1); @@ -339,8 +339,8 @@ module suins::registry_tests { #[test] fun burn_expired_registration_without_overriding() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, mut clock, domain) = setup(&mut ctx); let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); // increment the clock to 1 years + grace period clock::increment_for_testing(&mut clock, constants::year_ms() + constants::grace_period_ms() + 1); @@ -364,8 +364,8 @@ module suins::registry_tests { /// 1. Create a registry, add a record; /// 2. Try calling `set_reverse_lookup` and fail fun set_reverse_lookup_fail_target_not_set() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); let _nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); // set the `domain` points to @0x0 @@ -379,8 +379,8 @@ module suins::registry_tests { /// 2. Set target_address to address Alice /// 2. Try calling `set_reverse_lookup` and use address Bob fun set_reverse_lookup_fail_record_mismatch() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); let _nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); // set the `domain` points to @0x0 @@ -393,8 +393,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::EInvalidDepth)] /// Attempt to add a SLD record as a `leaf` record. fun add_sld_as_leaf_record_failure() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, _domain) = setup(&mut ctx); registry::add_leaf_record(&mut registry, domain::new(utf8(b"test.sui")), &clock,@0x0, &mut ctx); @@ -404,8 +404,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::ERecordNotFound)] /// Attempt to add a leaf record without a valid parent existing. fun add_leaf_record_without_valid_parent_failure() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, _domain) = setup(&mut ctx); registry::add_leaf_record(&mut registry, domain::new(utf8(b"test.test.sui")), &clock,@0x0, &mut ctx); @@ -415,8 +415,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::ENotLeafRecord)] /// Attempts to remove a non leaf record. fun remove_non_leaf_record_failure() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, _domain) = setup(&mut ctx); let _nft = registry::add_record(&mut registry, domain::new(utf8(b"test.test.sui")), 1, &clock, &mut ctx); @@ -428,8 +428,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::ERecordNotExpired)] /// Tries to add a `leaf` record on-top of an existing subdomain (fails). fun try_to_override_existing_node_subdomain() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, _domain) = setup(&mut ctx); let _nft = registry::add_record(&mut registry, domain::new(utf8(b"test.sui")), 1, &clock, &mut ctx); let _existing = registry::add_record(&mut registry, domain::new(utf8(b"test.test.sui")), 1, &clock, &mut ctx); @@ -442,8 +442,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::ERecordNotExpired)] /// Tries to add a `node` record on-top of an existing subdomain (fails). fun try_to_override_existing_leaf_subdomain() { - let ctx = tx_context::dummy(); - let (registry, clock, _domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, _domain) = setup(&mut ctx); let _nft = registry::add_record(&mut registry, domain::new(utf8(b"test.sui")), 1, &clock, &mut ctx); @@ -457,8 +457,8 @@ module suins::registry_tests { #[test, expected_failure(abort_code = suins::registry::ERecordNotExpired)] fun burn_non_expired_domain_failure() { - let ctx = tx_context::dummy(); - let (registry, clock, domain) = setup(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut registry, clock, domain) = setup(&mut ctx); let nft = registry::add_record(&mut registry, domain, 1, &clock, &mut ctx); // burn the expired object @@ -491,7 +491,7 @@ module suins::registry_tests { } #[test_only] - public fun burn_nfts(nfts: vector) { + public fun burn_nfts(mut nfts: vector) { while (vector::length(&nfts) > 0) { nft::burn_for_testing(vector::pop_back(&mut nfts)); }; diff --git a/packages/suins/tests/unit/sub_name_tests.move b/packages/suins/tests/unit/sub_name_tests.move index c676d1a7..b3ba253b 100644 --- a/packages/suins/tests/unit/sub_name_tests.move +++ b/packages/suins/tests/unit/sub_name_tests.move @@ -14,15 +14,15 @@ module suins::sub_name_tests { #[test] fun test_wrap_and_destroy(){ - let ctx = tx_context::dummy(); - let clock = clock::create_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let mut clock = clock::create_for_testing(&mut ctx); let domain = domain::new(utf8(b"sub.example.sui")); - let nft = suins_registration::new_for_testing(domain, 1, &clock, &mut ctx); + let mut nft = suins_registration::new_for_testing(domain, 1, &clock, &mut ctx); // create subdomain from name - let sub_nft = subdomain::new(nft, &clock, &mut ctx); + let mut sub_nft = subdomain::new(nft, &clock, &mut ctx); assert!(suins_registration::domain(subdomain::nft(&sub_nft)) == domain, 1); @@ -38,7 +38,7 @@ module suins::sub_name_tests { #[test, expected_failure(abort_code=suins::subdomain_registration::ENotSubdomain)] fun try_wrap_non_subdomain() { - let ctx = tx_context::dummy(); + let mut ctx = tx_context::dummy(); let clock = clock::create_for_testing(&mut ctx); let nft = suins_registration::new_for_testing(domain::new(utf8(b"example.sui")), 1, &clock, &mut ctx); @@ -51,8 +51,8 @@ module suins::sub_name_tests { #[test, expected_failure(abort_code=suins::subdomain_registration::EExpired)] fun try_wrap_expired_subname() { - let ctx = tx_context::dummy(); - let clock = clock::create_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let mut clock = clock::create_for_testing(&mut ctx); let nft = suins_registration::new_for_testing(domain::new(utf8(b"sub.example.sui")), 1, &clock, &mut ctx); clock::set_for_testing(&mut clock, suins_registration::expiration_timestamp_ms(&nft) + 1); @@ -65,7 +65,7 @@ module suins::sub_name_tests { #[test, expected_failure(abort_code=suins::subdomain_registration::ENameNotExpired)] fun try_unwrap_non_expired_subdomain() { - let ctx = tx_context::dummy(); + let mut ctx = tx_context::dummy(); let clock = clock::create_for_testing(&mut ctx); let nft = suins_registration::new_for_testing(domain::new(utf8(b"sub.example.sui")), 1, &clock, &mut ctx); diff --git a/packages/suins/tests/unit/suins_tests.move b/packages/suins/tests/unit/suins_tests.move index 105c127e..488af7bc 100644 --- a/packages/suins/tests/unit/suins_tests.move +++ b/packages/suins/tests/unit/suins_tests.move @@ -13,13 +13,13 @@ module suins::suins_tests { // === Config management === - struct TestConfig has store, drop { a: u8 } + public struct TestConfig has store, drop { a: u8 } #[test] /// Add a configuration; get it back; remove it. fun config_management() { - let ctx = tx_context::dummy(); - let (suins, cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, cap) = suins::new_for_testing(&mut ctx); suins::add_config(&cap, &mut suins, TestConfig { a: 1 }); let _cfg = suins::get_config(&suins); @@ -31,13 +31,13 @@ module suins::suins_tests { // === Registry === - struct TestRegistry has store { counter: u8 } + public struct TestRegistry has store { counter: u8 } #[test] /// Add a registry; read it. fun registry_management() { - let ctx = tx_context::dummy(); - let (suins, cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, cap) = suins::new_for_testing(&mut ctx); suins::add_registry(&cap, &mut suins, TestRegistry { counter: 1 }); let reg = suins::registry(&suins); @@ -48,22 +48,22 @@ module suins::suins_tests { // === Application Auth === - struct TestApp has drop {} + public struct TestApp has drop {} - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] /// Only authorized applications can add balance to SuiNS. fun app_add_to_balance_fail() { - let ctx = tx_context::dummy(); - let (suins, _cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, _cap) = suins::new_for_testing(&mut ctx); suins::app_add_balance(TestApp {}, &mut suins, balance::zero()); abort 1337 } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] /// Only authorized applications can access the registry mut. fun app_registry_mut_fail() { - let ctx = tx_context::dummy(); - let (suins, _cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, _cap) = suins::new_for_testing(&mut ctx); suins::app_registry_mut(TestApp {}, &mut suins); abort 1337 } @@ -72,8 +72,8 @@ module suins::suins_tests { /// 1. Authorize TestApp; /// 2. Adds balance to SuiNS, access registry mut. fun authorize_and_access() { - let ctx = tx_context::dummy(); - let (suins, cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, cap) = suins::new_for_testing(&mut ctx); suins::add_registry(&cap, &mut suins, TestRegistry { counter: 1 }); // authorize and check right away @@ -100,8 +100,8 @@ module suins::suins_tests { /// 1. Authorize TestApp and add to balance; /// 2. Admin withdraws the balance. fun balance_and_withdraw() { - let ctx = tx_context::dummy(); - let (suins, cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, cap) = suins::new_for_testing(&mut ctx); suins::authorize_app(&cap, &mut suins); let paid = balance::create_for_testing(1000); @@ -113,12 +113,12 @@ module suins::suins_tests { wrapup(suins, cap); } - #[test, expected_failure(abort_code = suins::suins::ENoProfits)] + #[test, expected_failure(abort_code = ::suins::suins::ENoProfits)] /// 1. Authorize TestApp and add to balance; /// 2. Admin tries to withdraw an empty balance. fun balance_and_withdraw_fail_no_profits() { - let ctx = tx_context::dummy(); - let (suins, cap) = suins::new_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, cap) = suins::new_for_testing(&mut ctx); let _withdrawn = suins::withdraw(&cap, &mut suins, &mut ctx); abort 1337 diff --git a/packages/suins/tests/v2/register.move b/packages/suins/tests/v2/register.move index db2b9d17..f53a19e6 100644 --- a/packages/suins/tests/v2/register.move +++ b/packages/suins/tests/v2/register.move @@ -22,7 +22,7 @@ module suins::register_sample { const EIncorrectAmount: u64 = 4; /// Authorization token for the app. - struct Register has drop {} + public struct Register has drop {} // Allows direct purchases of domains // diff --git a/packages/suins/tests/v2/renew.move b/packages/suins/tests/v2/renew.move index 48f13b0a..5c5d76af 100644 --- a/packages/suins/tests/v2/renew.move +++ b/packages/suins/tests/v2/renew.move @@ -28,7 +28,7 @@ module suins::renew { const EGracePeriodPassed: u64 = 3; /// Authorization token for the app. - struct Renew has drop {} + public struct Renew has drop {} /// Renew a registered domain name by a number of years (not exceeding 5). /// The domain name must be already registered and active; `SuinsRegistration` From 60156d80b5c95dee08a85c6e4480374601546b52 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 16:03:50 -0400 Subject: [PATCH 2/8] renewal --- packages/renewal/Move.lock | 13 +++- packages/renewal/Move.toml | 1 + packages/renewal/migration.patch | 90 +++++++++++++++++++++++++ packages/renewal/sources/renew.move | 6 +- packages/renewal/tests/renew_tests.move | 58 ++++++++-------- 5 files changed, 133 insertions(+), 35 deletions(-) create mode 100644 packages/renewal/migration.patch diff --git a/packages/renewal/Move.lock b/packages/renewal/Move.lock index a88ee9e2..875b3ad3 100644 --- a/packages/renewal/Move.lock +++ b/packages/renewal/Move.lock @@ -1,7 +1,9 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 0 +version = 1 +manifest_digest = "89903875E757C9574D9586E22B8484CF8818E1C1EE6401A688B7B167A6517195" +deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" dependencies = [ { name = "Sui" }, @@ -10,11 +12,11 @@ dependencies = [ [[move.package]] name = "MoveStdlib" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] name = "Sui" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/sui-framework" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ { name = "MoveStdlib" }, @@ -27,3 +29,8 @@ source = { local = "../suins" } dependencies = [ { name = "Sui" }, ] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/renewal/Move.toml b/packages/renewal/Move.toml index 820bd7c4..5e9aba77 100644 --- a/packages/renewal/Move.toml +++ b/packages/renewal/Move.toml @@ -1,6 +1,7 @@ [package] name = "renewal" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet", override=true } diff --git a/packages/renewal/migration.patch b/packages/renewal/migration.patch new file mode 100644 index 00000000..5e005e69 --- /dev/null +++ b/packages/renewal/migration.patch @@ -0,0 +1,90 @@ +--- sources/renew.move ++++ sources/renew.move +@@ -41 +41 @@ +- struct Renew has drop {} ++ public struct Renew has drop {} +@@ -44 +44 @@ +- struct NameRenewed has copy, drop { ++ public struct NameRenewed has copy, drop { +@@ -50 +50 @@ +- struct RenewalConfig has store, drop { ++ public struct RenewalConfig has store, drop { +--- tests/renew_tests.move ++++ tests/renew_tests.move +@@ -28,2 +28,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, nft) = prepare_registry(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, mut nft) = prepare_registry(&mut ctx); +@@ -31 +31 @@ +- let clock = clock::create_for_testing(&mut ctx); ++ let mut clock = clock::create_for_testing(&mut ctx); +@@ -46 +46 @@ +- #[test, expected_failure(abort_code= renewal::renew::EMoreThanSixYears)] ++ #[test, expected_failure(abort_code= ::renewal::renew::EMoreThanSixYears)] +@@ -48,2 +48,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, nft) = prepare_registry(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, mut nft) = prepare_registry(&mut ctx); +@@ -58 +58 @@ +- #[test, expected_failure(abort_code= renewal::renew::EInvalidYearsArgument)] ++ #[test, expected_failure(abort_code= ::renewal::renew::EInvalidYearsArgument)] +@@ -60,2 +60,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, nft) = prepare_registry(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, mut nft) = prepare_registry(&mut ctx); +@@ -70 +70 @@ +- #[test, expected_failure(abort_code= renewal::renew::ERecordNftIDMismatch)] ++ #[test, expected_failure(abort_code= ::renewal::renew::ERecordNftIDMismatch)] +@@ -72,2 +72,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, _nft) = prepare_registry(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, _nft) = prepare_registry(&mut ctx); +@@ -75 +75 @@ +- let nft = nft::new_for_testing(domain::new(utf8(DOMAIN_NAME)), 1, &clock, &mut ctx); ++ let mut nft = nft::new_for_testing(domain::new(utf8(DOMAIN_NAME)), 1, &clock, &mut ctx); +@@ -81 +81 @@ +- #[test, expected_failure(abort_code= renewal::renew::ERecordNotFound)] ++ #[test, expected_failure(abort_code= ::renewal::renew::ERecordNotFound)] +@@ -83,2 +83,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, _nft) = prepare_registry(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, _nft) = prepare_registry(&mut ctx); +@@ -86 +86 @@ +- let nft = nft::new_for_testing(domain::new(utf8(b"hehehe.sui")), 1, &clock, &mut ctx); ++ let mut nft = nft::new_for_testing(domain::new(utf8(b"hehehe.sui")), 1, &clock, &mut ctx); +@@ -92 +92 @@ +- #[test, expected_failure(abort_code= renewal::renew::ERecordExpired)] ++ #[test, expected_failure(abort_code= ::renewal::renew::ERecordExpired)] +@@ -94,3 +94,3 @@ +- let ctx = tx_context::dummy(); +- let (suins, nft) = prepare_registry(&mut ctx); +- let clock = clock::create_for_testing(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, mut nft) = prepare_registry(&mut ctx); ++ let mut clock = clock::create_for_testing(&mut ctx); +@@ -104 +104 @@ +- #[test, expected_failure(abort_code= renewal::renew::EIncorrectAmount)] ++ #[test, expected_failure(abort_code= ::renewal::renew::EIncorrectAmount)] +@@ -106,2 +106,2 @@ +- let ctx = tx_context::dummy(); +- let (suins, nft) = prepare_registry(&mut ctx); ++ let mut ctx = tx_context::dummy(); ++ let (mut suins, mut nft) = prepare_registry(&mut ctx); +@@ -122,2 +122,2 @@ +- let suins = suins::init_for_testing(ctx); +- let registry = registry::new_for_testing(ctx); ++ let mut suins = suins::init_for_testing(ctx); ++ let mut registry = registry::new_for_testing(ctx); +@@ -138 +138 @@ +- 1200 * suins::constants::mist_per_sui(), ++ 1200 * ::suins::constants::mist_per_sui(), +@@ -140,2 +140,2 @@ +- 200 * suins::constants::mist_per_sui(), +- REGULAR_PRICE * suins::constants::mist_per_sui(), ++ 200 * ::suins::constants::mist_per_sui(), ++ REGULAR_PRICE * ::suins::constants::mist_per_sui(), diff --git a/packages/renewal/sources/renew.move b/packages/renewal/sources/renew.move index e0df493c..0851f8bb 100644 --- a/packages/renewal/sources/renew.move +++ b/packages/renewal/sources/renew.move @@ -38,16 +38,16 @@ module renewal::renew { const ERecordExpired: u64 = 5; /// Authorization token for the app. - struct Renew has drop {} + public struct Renew has drop {} /// An event to help track financial transactions - struct NameRenewed has copy, drop { + public struct NameRenewed has copy, drop { domain: Domain, amount: u64 } /// The renewal's package configuration. - struct RenewalConfig has store, drop { + public struct RenewalConfig has store, drop { config: Config } diff --git a/packages/renewal/tests/renew_tests.move b/packages/renewal/tests/renew_tests.move index e4855b90..36e7e780 100644 --- a/packages/renewal/tests/renew_tests.move +++ b/packages/renewal/tests/renew_tests.move @@ -25,10 +25,10 @@ module renewal::renew_tests { #[test] fun regular_renewal_5_years() { - let ctx = tx_context::dummy(); - let (suins, nft) = prepare_registry(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, mut nft) = prepare_registry(&mut ctx); - let clock = clock::create_for_testing(&mut ctx); + let mut clock = clock::create_for_testing(&mut ctx); clock::increment_for_testing(&mut clock, 10); @@ -43,10 +43,10 @@ module renewal::renew_tests { wrapup_name(nft); } - #[test, expected_failure(abort_code= renewal::renew::EMoreThanSixYears)] + #[test, expected_failure(abort_code= ::renewal::renew::EMoreThanSixYears)] fun fail_to_go_beyond_6_years() { - let ctx = tx_context::dummy(); - let (suins, nft) = prepare_registry(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, mut nft) = prepare_registry(&mut ctx); let clock = clock::create_for_testing(&mut ctx); @@ -55,10 +55,10 @@ module renewal::renew_tests { abort 1337 } - #[test, expected_failure(abort_code= renewal::renew::EInvalidYearsArgument)] + #[test, expected_failure(abort_code= ::renewal::renew::EInvalidYearsArgument)] fun fail_invalid_arg() { - let ctx = tx_context::dummy(); - let (suins, nft) = prepare_registry(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, mut nft) = prepare_registry(&mut ctx); let clock = clock::create_for_testing(&mut ctx); @@ -67,33 +67,33 @@ module renewal::renew_tests { } - #[test, expected_failure(abort_code= renewal::renew::ERecordNftIDMismatch)] + #[test, expected_failure(abort_code= ::renewal::renew::ERecordNftIDMismatch)] fun failed_record_id_missmatch() { - let ctx = tx_context::dummy(); - let (suins, _nft) = prepare_registry(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, _nft) = prepare_registry(&mut ctx); let clock = clock::create_for_testing(&mut ctx); - let nft = nft::new_for_testing(domain::new(utf8(DOMAIN_NAME)), 1, &clock, &mut ctx); + let mut nft = nft::new_for_testing(domain::new(utf8(DOMAIN_NAME)), 1, &clock, &mut ctx); renew_util(&mut suins, &mut nft, 3, &clock, &mut ctx); abort 1337 } - #[test, expected_failure(abort_code= renewal::renew::ERecordNotFound)] + #[test, expected_failure(abort_code= ::renewal::renew::ERecordNotFound)] fun failed_record_not_exist() { - let ctx = tx_context::dummy(); - let (suins, _nft) = prepare_registry(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, _nft) = prepare_registry(&mut ctx); let clock = clock::create_for_testing(&mut ctx); - let nft = nft::new_for_testing(domain::new(utf8(b"hehehe.sui")), 1, &clock, &mut ctx); + let mut nft = nft::new_for_testing(domain::new(utf8(b"hehehe.sui")), 1, &clock, &mut ctx); renew_util(&mut suins, &mut nft, 3, &clock, &mut ctx); abort 1337 } - #[test, expected_failure(abort_code= renewal::renew::ERecordExpired)] + #[test, expected_failure(abort_code= ::renewal::renew::ERecordExpired)] fun failed_expired_record() { - let ctx = tx_context::dummy(); - let (suins, nft) = prepare_registry(&mut ctx); - let clock = clock::create_for_testing(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, mut nft) = prepare_registry(&mut ctx); + let mut clock = clock::create_for_testing(&mut ctx); clock::increment_for_testing(&mut clock, year_ms() + grace_period_ms() + 1); @@ -101,10 +101,10 @@ module renewal::renew_tests { abort 1337 } - #[test, expected_failure(abort_code= renewal::renew::EIncorrectAmount)] + #[test, expected_failure(abort_code= ::renewal::renew::EIncorrectAmount)] fun failed_not_enough_money() { - let ctx = tx_context::dummy(); - let (suins, nft) = prepare_registry(&mut ctx); + let mut ctx = tx_context::dummy(); + let (mut suins, mut nft) = prepare_registry(&mut ctx); let clock = clock::create_for_testing(&mut ctx); renewal::renew(&mut suins, &mut nft, 2,coin::mint_for_testing((1 as u64) * REGULAR_PRICE * mist_per_sui(), &mut ctx), &clock); @@ -119,8 +119,8 @@ module renewal::renew_tests { /// Authorizes registry, adds domain, and burns admin cap. public fun prepare_registry(ctx: &mut TxContext): (SuiNS, SuinsRegistration) { - let suins = suins::init_for_testing(ctx); - let registry = registry::new_for_testing(ctx); + let mut suins = suins::init_for_testing(ctx); + let mut registry = registry::new_for_testing(ctx); let domain = domain::new(utf8(DOMAIN_NAME)); suins::authorize_app_for_testing(&mut suins); @@ -135,10 +135,10 @@ module renewal::renew_tests { // We re-use the type to be able to use the same utilities. b"000000000000000000000000000000000", // random price, not being tested in renewal tests. - 1200 * suins::constants::mist_per_sui(), + 1200 * ::suins::constants::mist_per_sui(), // Random price, not being tested in renewal tests. - 200 * suins::constants::mist_per_sui(), - REGULAR_PRICE * suins::constants::mist_per_sui(), + 200 * ::suins::constants::mist_per_sui(), + REGULAR_PRICE * ::suins::constants::mist_per_sui(), ); renewal::setup(&cap, &mut suins, config); From 20262baa5098447782e76ac258bcd523d4c1d113 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 16:06:19 -0400 Subject: [PATCH 3/8] coupons --- packages/coupons/Move.lock | 13 +- packages/coupons/Move.toml | 1 + packages/coupons/migration.patch | 239 ++++++++++++++++++ packages/coupons/sources/coupons.move | 30 +-- packages/coupons/sources/range.move | 2 +- packages/coupons/sources/rules.move | 10 +- .../coupons/tests/authorization_tests.move | 14 +- packages/coupons/tests/coupons_tests.move | 72 +++--- packages/coupons/tests/setup.move | 26 +- 9 files changed, 327 insertions(+), 80 deletions(-) create mode 100644 packages/coupons/migration.patch diff --git a/packages/coupons/Move.lock b/packages/coupons/Move.lock index 27c31c87..33f6f4db 100644 --- a/packages/coupons/Move.lock +++ b/packages/coupons/Move.lock @@ -1,7 +1,9 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 0 +version = 1 +manifest_digest = "F6F1ED65982D6E0324AD5094A06FB092A7A055409AB912038DC0D2DA42E13854" +deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" dependencies = [ { name = "Sui" }, @@ -10,11 +12,11 @@ dependencies = [ [[move.package]] name = "MoveStdlib" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "testnet", subdir = "crates/sui-framework/packages/move-stdlib" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] name = "Sui" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "testnet", subdir = "crates/sui-framework/packages/sui-framework" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ { name = "MoveStdlib" }, @@ -27,3 +29,8 @@ source = { local = "../suins" } dependencies = [ { name = "Sui" }, ] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/coupons/Move.toml b/packages/coupons/Move.toml index def922a2..31f6d5a6 100644 --- a/packages/coupons/Move.toml +++ b/packages/coupons/Move.toml @@ -1,6 +1,7 @@ [package] name = "coupons" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet", override=true } diff --git a/packages/coupons/migration.patch b/packages/coupons/migration.patch new file mode 100644 index 00000000..93d56072 --- /dev/null +++ b/packages/coupons/migration.patch @@ -0,0 +1,239 @@ +--- sources/coupons.move ++++ sources/coupons.move +@@ -52 +52 @@ +- struct CouponsApp has drop {} ++ public struct CouponsApp has drop {} +@@ -54 +54 @@ +- struct AppKey has copy, store, drop {} ++ public struct AppKey has copy, store, drop {} +@@ -59 +59 @@ +- struct Data has store { ++ public struct Data has store { +@@ -65 +65 @@ +- struct CouponHouse has key, store { ++ public struct CouponHouse has key, store { +@@ -75,2 +75,2 @@ +- struct Coupon has copy, store, drop { +- type: u8, // 0 -> Percentage Discount | 1 -> Fixed Discount ++ public struct Coupon has copy, store, drop { ++ `type`: u8, // 0 -> Percentage Discount | 1 -> Fixed Discount +@@ -212 +212 @@ +- type: u8, ++ `type`: u8, +@@ -218 +218 @@ +- internal_save_coupon(&mut self.data, code, internal_create_coupon(type, amount, rules, ctx)); ++ internal_save_coupon(&mut self.data, code, internal_create_coupon(`type`, amount, rules, ctx)); +@@ -230 +230 @@ +- type: u8, ++ `type`: u8, +@@ -235 +235 @@ +- internal_save_coupon(self, code, internal_create_coupon(type, amount, rules, ctx)); ++ internal_save_coupon(self, code, internal_create_coupon(`type`, amount, rules, ctx)); +@@ -247 +247 @@ +- if(coupon.type == constants::fixed_price_discount_type()){ ++ if(coupon.`type` == constants::fixed_price_discount_type()){ +@@ -271 +271 @@ +- type: u8, ++ `type`: u8, +@@ -276,2 +276,2 @@ +- rules::assert_is_valid_amount(type, amount); +- rules::assert_is_valid_discount_type(type); ++ rules::assert_is_valid_amount(`type`, amount); ++ rules::assert_is_valid_discount_type(`type`); +@@ -279 +279 @@ +- type, amount, rules ++ `type`, amount, rules +--- sources/range.move ++++ sources/range.move +@@ -14 +14 @@ +- struct Range has copy, store, drop { ++ public struct Range has copy, store, drop { +--- sources/rules.move ++++ sources/rules.move +@@ -42 +42 @@ +- struct CouponRules has copy, store, drop { ++ public struct CouponRules has copy, store, drop { +@@ -121,2 +121,2 @@ +- public fun assert_is_valid_discount_type(type: u8) { +- assert!(vector::contains(&constants::discount_rule_types(), &type), EInvalidType); ++ public fun assert_is_valid_discount_type(`type`: u8) { ++ assert!(vector::contains(&constants::discount_rule_types(), &`type`), EInvalidType); +@@ -127 +127 @@ +- public fun assert_is_valid_amount(type: u8, amount: u64) { ++ public fun assert_is_valid_amount(`type`: u8, amount: u64) { +@@ -129 +129 @@ +- if(type == constants::percentage_discount_type()){ ++ if(`type` == constants::percentage_discount_type()){ +--- tests/authorization_tests.move ++++ tests/authorization_tests.move +@@ -17 +17 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -22 +22 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -32 +32 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -37 +37 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -52 +52 @@ +- #[test, expected_failure(abort_code=coupons::coupons::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code=::coupons::coupons::EAppNotAuthorized)] +@@ -54 +54 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -58 +58 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +--- tests/coupons_tests.move ++++ tests/coupons_tests.move +@@ -22 +22 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -33 +33 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -60 +60 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -80 +80 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidYears)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidYears)] +@@ -90 +90 @@ +- #[test, expected_failure(abort_code=coupons::range::EInvalidRange)] ++ #[test, expected_failure(abort_code=::coupons::range::EInvalidRange)] +@@ -103 +103 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -108 +108 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -117 +117 @@ +- #[test, expected_failure(abort_code=coupons::coupons::EIncorrectAmount)] ++ #[test, expected_failure(abort_code=::coupons::coupons::EIncorrectAmount)] +@@ -119 +119 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -127 +127 @@ +- #[test, expected_failure(abort_code=coupons::coupons::ECouponNotExists)] ++ #[test, expected_failure(abort_code=::coupons::coupons::ECouponNotExists)] +@@ -129 +129 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -136 +136 @@ +- #[test, expected_failure(abort_code=coupons::coupons::EInvalidYearsArgument)] ++ #[test, expected_failure(abort_code=::coupons::coupons::EInvalidYearsArgument)] +@@ -138 +138 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -144 +144 @@ +- #[test, expected_failure(abort_code=coupons::coupons::EInvalidYearsArgument)] ++ #[test, expected_failure(abort_code=::coupons::coupons::EInvalidYearsArgument)] +@@ -146 +146 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -153 +153 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidUser)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidUser)] +@@ -155 +155 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -162 +162 @@ +- #[test, expected_failure(abort_code=coupons::rules::ECouponExpired)] ++ #[test, expected_failure(abort_code=::coupons::rules::ECouponExpired)] +@@ -164 +164 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -171 +171 @@ +- #[test, expected_failure(abort_code=coupons::rules::ENotValidYears)] ++ #[test, expected_failure(abort_code=::coupons::rules::ENotValidYears)] +@@ -173 +173 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -180 +180 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] +@@ -182 +182 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -189 +189 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] +@@ -191 +191 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -199 +199 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] +@@ -201 +201 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -211 +211 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -221 +221 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidType)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidType)] +@@ -223 +223 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -230 +230 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidAmount)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidAmount)] +@@ -232 +232 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -238 +238 @@ +- #[test, expected_failure(abort_code=coupons::rules::EInvalidAmount)] ++ #[test, expected_failure(abort_code=::coupons::rules::EInvalidAmount)] +@@ -240 +240 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +@@ -247 +247 @@ +- #[test, expected_failure(abort_code=coupons::coupons::ECouponAlreadyExists)] ++ #[test, expected_failure(abort_code=::coupons::coupons::ECouponAlreadyExists)] +@@ -249 +249 @@ +- let scenario_val = setup::test_init(); ++ let mut scenario_val = setup::test_init(); +--- tests/setup.move ++++ tests/setup.move +@@ -21 +21 @@ +- struct TestApp has drop {} ++ public struct TestApp has drop {} +@@ -23 +23 @@ +- struct UnauthorizedTestApp has drop {} ++ public struct UnauthorizedTestApp has drop {} +@@ -35 +35 @@ +- let scenario_val = test_scenario::begin(ADMIN_ADDRESS); ++ let mut scenario_val = test_scenario::begin(ADMIN_ADDRESS); +@@ -38 +38 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -48 +48 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -52 +52 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -196 +196 @@ +- public fun admin_add_coupon(code_name: String, type: u8, value: u64, scenario: &mut Scenario) { ++ public fun admin_add_coupon(code_name: String, `type`: u8, value: u64, scenario: &mut Scenario) { +@@ -198 +198 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -204 +204 @@ +- type, ++ `type`, +@@ -215 +215 @@ +- let coupon_house = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); +@@ -234 +234 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -236,2 +236,2 @@ +- let coupon_house = test_scenario::take_shared(scenario); +- let suins = test_scenario::take_shared(scenario); ++ let mut coupon_house = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); diff --git a/packages/coupons/sources/coupons.move b/packages/coupons/sources/coupons.move index cb8b9531..976617cd 100644 --- a/packages/coupons/sources/coupons.move +++ b/packages/coupons/sources/coupons.move @@ -49,20 +49,20 @@ module coupons::coupons { use suins::registry::{Self, Registry}; // Authorization for the Coupons on SuiNS, to be able to register names on the app. - struct CouponsApp has drop {} + public struct CouponsApp has drop {} /// Authorization Key for secondary apps (e.g. Discord) connected to this module. - struct AppKey has copy, store, drop {} + public struct AppKey has copy, store, drop {} /// Create a `Data` struct that only authorized apps can get mutable access to. /// We don't save the coupon's table directly on the shared object, because we want authorized apps to only perform /// certain actions with the table (and not give full `mut` access to it). - struct Data has store { + public struct Data has store { // hold a list of all coupons in the system. coupons: Table } /// The CouponHouse Shared Object which holds a table of coupon codes available for claim. - struct CouponHouse has key, store { + public struct CouponHouse has key, store { id: UID, data: Data, version: u8 @@ -72,8 +72,8 @@ module coupons::coupons { /// - `Rules` are defined on the module `rules`, and covers a variety of everything we needed for the service. /// - `type` is a u8 constant, defined on `constants` which makes a coupon fixed price or discount percentage /// - `value` is a u64 constant, which can be in the range of (0,100] for discount percentage, or any value > 0 for fixed price. - struct Coupon has copy, store, drop { - type: u8, // 0 -> Percentage Discount | 1 -> Fixed Discount + public struct Coupon has copy, store, drop { + `type`: u8, // 0 -> Percentage Discount | 1 -> Fixed Discount amount: u64, // if type == 0, we need it to be between 0, 100. We only allow int stlye (not 0.5% discount). rules: CouponRules, // A list of base Rules for the coupon. } @@ -209,13 +209,13 @@ module coupons::coupons { _: &AdminCap, self: &mut CouponHouse, code: String, - type: u8, + `type`: u8, amount: u64, rules: CouponRules, ctx: &mut TxContext ) { assert_version_is_valid(self); - internal_save_coupon(&mut self.data, code, internal_create_coupon(type, amount, rules, ctx)); + internal_save_coupon(&mut self.data, code, internal_create_coupon(`type`, amount, rules, ctx)); } // Remove a coupon as a system's admin. @@ -227,12 +227,12 @@ module coupons::coupons { public fun app_add_coupon( self: &mut Data, code: String, - type: u8, + `type`: u8, amount: u64, rules: CouponRules, ctx: &mut TxContext ){ - internal_save_coupon(self, code, internal_create_coupon(type, amount, rules, ctx)); + internal_save_coupon(self, code, internal_create_coupon(`type`, amount, rules, ctx)); } // Remove a coupon as a registered app. @@ -244,7 +244,7 @@ module coupons::coupons { /// A helper to calculate the final price after the discount. fun internal_calculate_sale_price(price: u64, coupon: &Coupon): u64{ // If it's fixed price, we just deduce the amount. - if(coupon.type == constants::fixed_price_discount_type()){ + if(coupon.`type` == constants::fixed_price_discount_type()){ if(coupon.amount > price) return 0; // protect underflow case. return price - coupon.amount }; @@ -268,15 +268,15 @@ module coupons::coupons { /// An internal function to create a coupon object. fun internal_create_coupon( - type: u8, + `type`: u8, amount: u64, rules: CouponRules, _ctx: &mut TxContext ): Coupon { - rules::assert_is_valid_amount(type, amount); - rules::assert_is_valid_discount_type(type); + rules::assert_is_valid_amount(`type`, amount); + rules::assert_is_valid_discount_type(`type`); Coupon { - type, amount, rules + `type`, amount, rules } } diff --git a/packages/coupons/sources/range.move b/packages/coupons/sources/range.move index e19f5043..4643fc86 100644 --- a/packages/coupons/sources/range.move +++ b/packages/coupons/sources/range.move @@ -11,7 +11,7 @@ module coupons::range { const EInvalidRange: u64 = 0; /// A Range for u8 helper - struct Range has copy, store, drop { + public struct Range has copy, store, drop { vec: vector } diff --git a/packages/coupons/sources/rules.move b/packages/coupons/sources/rules.move index 6136538d..59504e23 100644 --- a/packages/coupons/sources/rules.move +++ b/packages/coupons/sources/rules.move @@ -39,7 +39,7 @@ module coupons::rules { /// The Struct that holds the coupon's rules. /// All rules are combined in `AND` fashion. /// All of the checks have to pass for a coupon to be used. - struct CouponRules has copy, store, drop { + public struct CouponRules has copy, store, drop { length: Option, available_claims: Option, user: Option
, @@ -118,15 +118,15 @@ module coupons::rules { range::is_in_range(option::borrow(&rules.years), target) } - public fun assert_is_valid_discount_type(type: u8) { - assert!(vector::contains(&constants::discount_rule_types(), &type), EInvalidType); + public fun assert_is_valid_discount_type(`type`: u8) { + assert!(vector::contains(&constants::discount_rule_types(), &`type`), EInvalidType); } // verify that we are creating the coupons correctly (based on amount & type). // for amounts, if we have a percentage discount, our max num is 100. - public fun assert_is_valid_amount(type: u8, amount: u64) { + public fun assert_is_valid_amount(`type`: u8, amount: u64) { assert!(amount > 0, EInvalidAmount); // protect from division by 0. 0 doesn't make sense in any scenario. - if(type == constants::percentage_discount_type()){ + if(`type` == constants::percentage_discount_type()){ assert!(amount<=100, EInvalidAmount) } } diff --git a/packages/coupons/tests/authorization_tests.move b/packages/coupons/tests/authorization_tests.move index f4069dcb..631e5ac7 100644 --- a/packages/coupons/tests/authorization_tests.move +++ b/packages/coupons/tests/authorization_tests.move @@ -14,12 +14,12 @@ module coupons::app_authorization_tests { #[test] fun admin_get_app_success() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; // auth style as authorized app { test_scenario::next_tx(scenario, user()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); coupons::app_data_mut(setup::test_app(), &mut coupon_house); test_scenario::return_shared(coupon_house); }; @@ -29,12 +29,12 @@ module coupons::app_authorization_tests { #[test] fun authorized_app_get_app_success(){ - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; { test_scenario::next_tx(scenario, admin()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); let admin_cap = test_scenario::take_from_sender(scenario); // test app deauthorization. @@ -49,13 +49,13 @@ module coupons::app_authorization_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::coupons::EAppNotAuthorized)] + #[test, expected_failure(abort_code=::coupons::coupons::EAppNotAuthorized)] fun unauthorized_app_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; { test_scenario::next_tx(scenario, user()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); coupons::app_data_mut(setup::unauthorized_test_app(), &mut coupon_house); test_scenario::return_shared(coupon_house); }; diff --git a/packages/coupons/tests/coupons_tests.move b/packages/coupons/tests/coupons_tests.move index 17793fe2..3204a791 100644 --- a/packages/coupons/tests/coupons_tests.move +++ b/packages/coupons/tests/coupons_tests.move @@ -19,7 +19,7 @@ module coupons::coupon_tests { // This populates the coupon as an authorized app fun populate_coupons(scenario: &mut Scenario) { test_scenario::next_tx(scenario, user()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); let data_mut = coupons::app_data_mut(setup::test_app(), &mut coupon_house); setup::populate_coupons(data_mut, ctx(scenario)); @@ -30,7 +30,7 @@ module coupons::coupon_tests { // Tests the e2e experience for coupons (a list of different coupons with different rules) #[test] fun test_e2e() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; // populate all coupons. populate_coupons(scenario); @@ -57,7 +57,7 @@ module coupons::coupon_tests { } #[test] fun zero_fee_purchase(){ - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; // populate all coupons. populate_coupons(scenario); @@ -77,7 +77,7 @@ module coupons::coupon_tests { option::some(range::new(1,1)) ); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidYears)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidYears)] fun max_years_failure(){ rules::new_coupon_rules( option::none(), @@ -87,7 +87,7 @@ module coupons::coupon_tests { option::some(range::new(0,1)) ); } - #[test, expected_failure(abort_code=coupons::range::EInvalidRange)] + #[test, expected_failure(abort_code=::coupons::range::EInvalidRange)] fun max_years_two_failure(){ rules::new_coupon_rules( option::none(), @@ -100,12 +100,12 @@ module coupons::coupon_tests { #[test] fun test_price_calculation(){ - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); { test_scenario::next_tx(scenario, user()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); let sale_price = coupons::calculate_sale_price(&mut coupon_house, 100, utf8(b"50_PERCENT_5_PLUS_NAMES")); assert!(sale_price == 50, 1); @@ -114,9 +114,9 @@ module coupons::coupon_tests { test_scenario::end(scenario_val); } // Tests the e2e experience for coupons (a list of different coupons with different rules) - #[test, expected_failure(abort_code=coupons::coupons::EIncorrectAmount)] + #[test, expected_failure(abort_code=::coupons::coupons::EIncorrectAmount)] fun test_invalid_coin_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; // populate all coupons. populate_coupons(scenario); @@ -124,71 +124,71 @@ module coupons::coupon_tests { setup::register_with_coupon(utf8(b"5_SUI_DISCOUNT"), utf8(b"test.sui"), 1, 200 * mist_per_sui(), 0, user(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::coupons::ECouponNotExists)] + #[test, expected_failure(abort_code=::coupons::coupons::ECouponNotExists)] fun no_more_available_claims_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"25_PERCENT_DISCOUNT_USER_ONLY"), utf8(b"test.sui"), 1, 150 * mist_per_sui(), 0, user(), scenario); setup::register_with_coupon(utf8(b"25_PERCENT_DISCOUNT_USER_ONLY"), utf8(b"tost.sui"), 1, 150 * mist_per_sui(), 0, user(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::coupons::EInvalidYearsArgument)] + #[test, expected_failure(abort_code=::coupons::coupons::EInvalidYearsArgument)] fun invalid_years_claim_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"25_PERCENT_DISCOUNT_USER_ONLY"), utf8(b"test.sui"), 6, 150 * mist_per_sui(), 0, user(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::coupons::EInvalidYearsArgument)] + #[test, expected_failure(abort_code=::coupons::coupons::EInvalidYearsArgument)] fun invalid_years_claim_1_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"25_PERCENT_DISCOUNT_USER_ONLY"), utf8(b"test.sui"), 0, 150 * mist_per_sui(), 0, user(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidUser)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidUser)] fun invalid_user_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"25_PERCENT_DISCOUNT_USER_ONLY"), utf8(b"test.sui"), 1, 150 * mist_per_sui(), 0, user_two(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::ECouponExpired)] + #[test, expected_failure(abort_code=::coupons::rules::ECouponExpired)] fun coupon_expired_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"50_PERCENT_3_DIGITS"), utf8(b"tes.sui"), 1, 150 * mist_per_sui(), 2, user_two(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::ENotValidYears)] + #[test, expected_failure(abort_code=::coupons::rules::ENotValidYears)] fun coupon_not_valid_for_years_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"50_DISCOUNT_SALAD"), utf8(b"tes.sui"), 3, 150 * mist_per_sui(), 0, user(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] fun coupon_invalid_length_1_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::register_with_coupon(utf8(b"50_PERCENT_3_DIGITS"), utf8(b"test.sui"), 1, 150 * mist_per_sui(), 2, user_two(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] fun coupon_invalid_length_2_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); // Tries to use 5 digit name for a <=4 digit one. @@ -196,9 +196,9 @@ module coupons::coupon_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] fun coupon_invalid_length_3_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); // Tries to use 4 digit name for a 5+ chars coupon. @@ -208,7 +208,7 @@ module coupons::coupon_tests { #[test] fun add_coupon_as_admin() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); // add a no rule coupon as an admin @@ -218,35 +218,35 @@ module coupons::coupon_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidType)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidType)] fun add_coupon_invalid_type_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::admin_add_coupon(utf8(b"TEST_SUCCESS_ADDITION"), 5, 100 * mist_per_sui(), scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidAmount)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidAmount)] fun add_coupon_invalid_amount_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::admin_add_coupon(utf8(b"TEST_SUCCESS_ADDITION"), constants::percentage_discount_type(), 101, scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::rules::EInvalidAmount)] + #[test, expected_failure(abort_code=::coupons::rules::EInvalidAmount)] fun add_coupon_invalid_amount_2_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::admin_add_coupon(utf8(b"TEST_SUCCESS_ADDITION"), constants::percentage_discount_type(), 0, scenario); test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code=coupons::coupons::ECouponAlreadyExists)] + #[test, expected_failure(abort_code=::coupons::coupons::ECouponAlreadyExists)] fun add_coupon_twice_failure() { - let scenario_val = setup::test_init(); + let mut scenario_val = setup::test_init(); let scenario = &mut scenario_val; populate_coupons(scenario); setup::admin_add_coupon(utf8(b"TEST_SUCCESS_ADDITION"), constants::percentage_discount_type(), 100, scenario); diff --git a/packages/coupons/tests/setup.move b/packages/coupons/tests/setup.move index 77123823..fb04be92 100644 --- a/packages/coupons/tests/setup.move +++ b/packages/coupons/tests/setup.move @@ -18,9 +18,9 @@ module coupons::setup { use coupons::constants; use coupons::range; - struct TestApp has drop {} + public struct TestApp has drop {} - struct UnauthorizedTestApp has drop {} + public struct UnauthorizedTestApp has drop {} const MIST_PER_SUI: u64 = 1_000_000_000; @@ -32,10 +32,10 @@ module coupons::setup { use suins::registry; public fun test_init(): Scenario { - let scenario_val = test_scenario::begin(ADMIN_ADDRESS); + let mut scenario_val = test_scenario::begin(ADMIN_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); // initialize coupon data. coupons::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); @@ -45,11 +45,11 @@ module coupons::setup { }; { test_scenario::next_tx(scenario, ADMIN_ADDRESS); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); // get admin cap let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); // authorize TestApp to CouponHouse. coupons::authorize_app(&admin_cap, &mut coupon_house); @@ -193,15 +193,15 @@ module coupons::setup { } // Adds a 0 rule coupon that gives 15% discount to test admin additions. - public fun admin_add_coupon(code_name: String, type: u8, value: u64, scenario: &mut Scenario) { + public fun admin_add_coupon(code_name: String, `type`: u8, value: u64, scenario: &mut Scenario) { test_scenario::next_tx(scenario, admin()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); let cap = test_scenario::take_from_sender(scenario); coupons::admin_add_coupon( &cap, &mut coupon_house, code_name, - type, + `type`, value, rules::new_empty_rules(), ctx(scenario) @@ -212,7 +212,7 @@ module coupons::setup { // Adds a 0 rule coupon that gives 15% discount to test admin additions. public fun admin_remove_coupon(code_name: String, scenario: &mut Scenario) { test_scenario::next_tx(scenario, admin()); - let coupon_house = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); let cap = test_scenario::take_from_sender(scenario); coupons::admin_remove_coupon( &cap, @@ -231,10 +231,10 @@ module coupons::setup { // A helper to easily register a name with a coupon code. public fun register_with_coupon(coupon_code: String, domain_name: String, no_years: u8, amount: u64, clock_value: u64, user: address, scenario: &mut Scenario) { test_scenario::next_tx(scenario, user); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_value); - let coupon_house = test_scenario::take_shared(scenario); - let suins = test_scenario::take_shared(scenario); + let mut coupon_house = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let payment = coin::mint_for_testing(amount, ctx(scenario)); From 4194bb9cf0938fe630af2815d987c87f31127f82 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 16:10:16 -0400 Subject: [PATCH 4/8] day_one --- packages/day_one/Move.lock | 13 ++- packages/day_one/Move.toml | 3 +- packages/day_one/migration.patch | 131 ++++++++++++++++++++++ packages/day_one/sources/bogo.move | 6 +- packages/day_one/sources/day_one.move | 18 +-- packages/day_one/tests/day_one_tests.move | 66 +++++------ 6 files changed, 188 insertions(+), 49 deletions(-) create mode 100644 packages/day_one/migration.patch diff --git a/packages/day_one/Move.lock b/packages/day_one/Move.lock index 7c852c80..96a5ef96 100644 --- a/packages/day_one/Move.lock +++ b/packages/day_one/Move.lock @@ -1,7 +1,9 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 0 +version = 1 +manifest_digest = "D244D0348EDE5A28C535D82B1117C3ECAC42C62FC57BEF1660922CF084A246E0" +deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" dependencies = [ { name = "Sui" }, @@ -10,11 +12,11 @@ dependencies = [ [[move.package]] name = "MoveStdlib" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "2d985a3", subdir = "crates/sui-framework/packages/move-stdlib" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] name = "Sui" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "2d985a3", subdir = "crates/sui-framework/packages/sui-framework" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ { name = "MoveStdlib" }, @@ -27,3 +29,8 @@ source = { local = "../suins" } dependencies = [ { name = "Sui" }, ] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/day_one/Move.toml b/packages/day_one/Move.toml index 0757228a..3dfe1439 100644 --- a/packages/day_one/Move.toml +++ b/packages/day_one/Move.toml @@ -2,9 +2,10 @@ name = "day_one" version = "0.0.1" published-at="0xbf1431324a4a6eadd70e0ac6c5a16f36492f255ed4d011978b2cf34ad738efe6" +edition = "2024.beta" [dependencies] -Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "2d985a3" } +Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } suins = { local = "../suins" } diff --git a/packages/day_one/migration.patch b/packages/day_one/migration.patch new file mode 100644 index 00000000..84a3f05d --- /dev/null +++ b/packages/day_one/migration.patch @@ -0,0 +1,131 @@ +--- sources/bogo.move ++++ sources/bogo.move +@@ -25 +25 @@ +- struct BogoApp has drop {} ++ public struct BogoApp has drop {} +@@ -29 +29 @@ +- struct UsedInDayOnePromo has copy, store, drop { } ++ public struct UsedInDayOnePromo has copy, store, drop { } +@@ -84 +84 @@ +- let nft = registry::add_record(registry, new_domain, DEFAULT_DURATION, clock, ctx); ++ let mut nft = registry::add_record(registry, new_domain, DEFAULT_DURATION, clock, ctx); +--- sources/day_one.move ++++ sources/day_one.move +@@ -20 +20 @@ +- friend day_one::bogo; ++ /* friend day_one::bogo; */ +@@ -23 +23 @@ +- struct DropList has key { ++ public struct DropList has key { +@@ -30 +30 @@ +- struct SetupCap has key { id: UID } ++ public struct SetupCap has key { id: UID } +@@ -40 +40 @@ +- struct DAY_ONE has drop {} ++ public struct DAY_ONE has drop {} +@@ -55 +55 @@ +- struct DayOne has key, store { ++ public struct DayOne has key, store { +@@ -66 +66 @@ +- recipients: vector
, ++ mut recipients: vector
, +@@ -77 +77 @@ +- let i: u32 = self.total_minted; ++ let mut i: u32 = self.total_minted; +@@ -99 +99 @@ +- hashes: vector
, ++ mut hashes: vector
, +@@ -117 +117 @@ +- public(friend) fun activate(self: &mut DayOne) { ++ public(package) fun activate(self: &mut DayOne) { +--- tests/day_one_tests.move ++++ tests/day_one_tests.move +@@ -22 +22 @@ +- let scenario_val = test_scenario::begin(SUINS_ADDRESS); ++ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); +@@ -25 +25 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -34 +34 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -47 +47 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -51,2 +51,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (mut domain1, mut domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -77 +77 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -81,2 +81,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -99 +99 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -103,2 +103,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -106 +106 @@ +- let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); ++ let mut new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); +@@ -124 +124 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -128,2 +128,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -146 +146 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -149,3 +149,3 @@ +- let clock = test_scenario::take_shared(scenario); +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); ++ let (domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -156 +156 @@ +- let fresh_domain = new_domain(utf8(b"exp.sui"), 1, &clock, ctx(scenario)); ++ let mut fresh_domain = new_domain(utf8(b"exp.sui"), 1, &clock, ctx(scenario)); +@@ -174 +174 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -178,2 +178,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (domain1, mut domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -197 +197 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -201,2 +201,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (domain1, domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -220 +220 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -224,2 +224,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -242 +242 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -246,2 +246,2 @@ +- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); +- let suins = test_scenario::take_shared(scenario); ++ let (domain1, domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); ++ let mut suins = test_scenario::take_shared(scenario); diff --git a/packages/day_one/sources/bogo.move b/packages/day_one/sources/bogo.move index a607b398..f2fb25e2 100644 --- a/packages/day_one/sources/bogo.move +++ b/packages/day_one/sources/bogo.move @@ -22,11 +22,11 @@ module day_one::bogo { /// Authorization token for the BOGO app. /// Used to authorize the app to claim free names by using a DayOne object. - struct BogoApp has drop {} + public struct BogoApp has drop {} /// Dynamic field key which shows that the `SuinsRegistration` object was /// minted from a Day1 promotion. - struct UsedInDayOnePromo has copy, store, drop { } + public struct UsedInDayOnePromo has copy, store, drop { } // This will define if a domain name was bought in an auction. // The only way to understand that, is to check that the expiration day is @@ -81,7 +81,7 @@ module day_one::bogo { if(!day_one::is_active(day_one_nft)) day_one::activate(day_one_nft); let registry = suins::app_registry_mut(BogoApp {}, suins); - let nft = registry::add_record(registry, new_domain, DEFAULT_DURATION, clock, ctx); + let mut nft = registry::add_record(registry, new_domain, DEFAULT_DURATION, clock, ctx); // mark both the new and the current domain presented as used, so that they can't // be redeemed twice in this deal. diff --git a/packages/day_one/sources/day_one.move b/packages/day_one/sources/day_one.move index 166e7f79..6503afba 100644 --- a/packages/day_one/sources/day_one.move +++ b/packages/day_one/sources/day_one.move @@ -17,17 +17,17 @@ module day_one::day_one { // We mark as friend just the BOGO module. // This is the only one that can activate a DayOne object. // This is a one-time operation that won't happen from any other modules. - friend day_one::bogo; + /* friend day_one::bogo; */ /// The shared object that stores the receivers destination. - struct DropList has key { + public struct DropList has key { id: UID, total_minted: u32 } /// The Setup Capability for the airdrop module. Sent to the publisher on /// publish. Consumed in the setup call. - struct SetupCap has key { id: UID } + public struct SetupCap has key { id: UID } /// == ERRORS == // Error emitted when trying to mint with invalid addresses (non existent DF). @@ -37,7 +37,7 @@ module day_one::day_one { const ETooManyHashes: u64 = 1; /// OTW for the Publisher object - struct DAY_ONE has drop {} + public struct DAY_ONE has drop {} /// Share the `DropList` object, send the `SetupCap` to the publisher. fun init(otw: DAY_ONE, ctx: &mut TxContext) { @@ -52,7 +52,7 @@ module day_one::day_one { /// The DayOne object, granting participants special offers in /// different future promotions. - struct DayOne has key, store { + public struct DayOne has key, store { id: UID, active: bool, serial: u32 @@ -63,7 +63,7 @@ module day_one::day_one { /// that is part of the list. public fun mint( self: &mut DropList, - recipients: vector
, + mut recipients: vector
, ctx: &mut TxContext ) { @@ -74,7 +74,7 @@ module day_one::day_one { let lookup = df::remove_if_exists(&mut self.id, sui::address::from_bytes(hash)); assert!(option::is_some(&lookup), ENotFound); - let i: u32 = self.total_minted; + let mut i: u32 = self.total_minted; while (vector::length(&recipients) > 0) { let recipient = vector::pop_back(&mut recipients); @@ -96,7 +96,7 @@ module day_one::day_one { public fun setup( self: &mut DropList, cap: SetupCap, - hashes: vector
, + mut hashes: vector
, ) { // verify we only pass less than 1000 hashes at the setup. // That's the max amount of DFs we can create in a single run. @@ -114,7 +114,7 @@ module day_one::day_one { // Private helper to activate the DayOne object // Will only be called by the `bogo` module (friend), which marks the // beggining of the DayOne promotions. - public(friend) fun activate(self: &mut DayOne) { + public(package) fun activate(self: &mut DayOne) { self.active = true } diff --git a/packages/day_one/tests/day_one_tests.move b/packages/day_one/tests/day_one_tests.move index 616678bb..96f6f3e1 100644 --- a/packages/day_one/tests/day_one_tests.move +++ b/packages/day_one/tests/day_one_tests.move @@ -19,10 +19,10 @@ module suins::day_one_tests { const ATTACH_DOMAINS_PERIOD_MS: u64 = 1 * 24 * 60 * 60 * 1000; fun test_init(): Scenario { - let scenario_val = test_scenario::begin(SUINS_ADDRESS); + let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); let clock = clock::create_for_testing(ctx(scenario)); @@ -31,7 +31,7 @@ module suins::day_one_tests { { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -44,12 +44,12 @@ module suins::day_one_tests { #[test] fun test_e2e() { // an e2e scenario were we just purchase 3 domains normally using 3 registered ones. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (mut domain1, mut domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); let new_name_2 = bogo::claim(&mut day_one, &mut suins, &mut domain2, utf8(b"wow1.sui"), &clock, ctx(scenario)); @@ -74,12 +74,12 @@ module suins::day_one_tests { #[expected_failure(abort_code = bogo::EDomainAlreadyUsed)] fun failure_test_domain_already_used() { // tries to reuse the same SuinsRegistration for a second time. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); let new_name_2 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wop.sui"), &clock, ctx(scenario)); @@ -96,14 +96,14 @@ module suins::day_one_tests { #[expected_failure(abort_code = bogo::EDomainAlreadyUsed)] fun failure_test_free_minted_domain_use() { // an e2e scenario were we just purchase 3 domains normally using 3 registered ones. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); - let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); + let mut new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); let new_name_2 = bogo::claim(&mut day_one, &mut suins, &mut new_name_1, utf8(b"wop.sui"), &clock, ctx(scenario)); burn_domain(new_name_1); @@ -121,12 +121,12 @@ module suins::day_one_tests { #[expected_failure(abort_code = bogo::ESizeMissMatch)] fun failure_test_length_missmatch() { // Tries to register a 4 letter domain while presenting a 3 letter one. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow1.sui"), &clock, ctx(scenario)); burn_domain(new_name_1); @@ -143,17 +143,17 @@ module suins::day_one_tests { #[expected_failure(abort_code = bogo::ENotPurchasedInAuction)] fun failure_test_domain_not_bought_in_auction() { // tries to use a fresh domain to get another one for free. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); - let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); + let (domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); // increment the clock by a lot. clock::increment_for_testing(&mut clock, bogo::last_valid_expiration()); - let fresh_domain = new_domain(utf8(b"exp.sui"), 1, &clock, ctx(scenario)); + let mut fresh_domain = new_domain(utf8(b"exp.sui"), 1, &clock, ctx(scenario)); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut fresh_domain, utf8(b"wow.sui"), &clock, ctx(scenario)); burn_domain(new_name_1); @@ -171,12 +171,12 @@ module suins::day_one_tests { #[expected_failure(abort_code = bogo::ESizeMissMatch)] fun failure_test_length_missmatch_2() { // Tries to claim a 3 letter name using a 4 letter domain. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (domain1, mut domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); // using a 4 digit domain and trying to get a 3 digit one. let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain2, utf8(b"wow.sui"), &clock, ctx(scenario)); @@ -194,12 +194,12 @@ module suins::day_one_tests { #[expected_failure(abort_code = bogo::ESizeMissMatch)] fun failure_test_length_missmatch_3() { // tries to get a 4 digit name using a 5 digit one. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (domain1, domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain3, utf8(b"woww.sui"), &clock, ctx(scenario)); burn_domain(new_name_1); @@ -217,12 +217,12 @@ module suins::day_one_tests { fun failure_test_length_missmatch_4() { // tries to get an 8 digit name using a 3 digit one. // protects the user from mistakes. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wowowowo.sui"), &clock, ctx(scenario)); burn_domain(new_name_1); @@ -239,12 +239,12 @@ module suins::day_one_tests { fun test_acceptable_length_missmatch() { // We allow purchasing a domain of size 5+ if we pass a 5 length domain. // we only care about 3 & 4 digits. - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; test_scenario::next_tx(scenario, USER_ADDRESS); let clock = test_scenario::take_shared(scenario); - let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); - let suins = test_scenario::take_shared(scenario); + let (domain1, domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); + let mut suins = test_scenario::take_shared(scenario); let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain3, utf8(b"wowwowowo.sui"), &clock, ctx(scenario)); burn_domain(new_name_1); From 9931ad0b691d1d1997b8846823e99458eba853f2 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 16:11:46 -0400 Subject: [PATCH 5/8] denylist --- packages/denylist/Move.lock | 36 ++++++++++++ packages/denylist/Move.toml | 1 + packages/denylist/migration.patch | 64 +++++++++++++++++++++ packages/denylist/sources/denylist.move | 8 +-- packages/denylist/tests/denylist_tests.move | 32 +++++------ 5 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 packages/denylist/Move.lock create mode 100644 packages/denylist/migration.patch diff --git a/packages/denylist/Move.lock b/packages/denylist/Move.lock new file mode 100644 index 00000000..8629c2cb --- /dev/null +++ b/packages/denylist/Move.lock @@ -0,0 +1,36 @@ +# @generated by Move, please check-in and do not edit manually. + +[move] +version = 1 +manifest_digest = "B8615E598606BDBFAC467C1EA7E9AF684DFDFC94BFCF9B83EDC096C543918704" +deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" + +dependencies = [ + { name = "Sui" }, + { name = "suins" }, +] + +[[move.package]] +name = "MoveStdlib" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/move-stdlib" } + +[[move.package]] +name = "Sui" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/testnet", subdir = "crates/sui-framework/packages/sui-framework" } + +dependencies = [ + { name = "MoveStdlib" }, +] + +[[move.package]] +name = "suins" +source = { local = "../suins" } + +dependencies = [ + { name = "Sui" }, +] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/denylist/Move.toml b/packages/denylist/Move.toml index ba99faf9..aba8751e 100644 --- a/packages/denylist/Move.toml +++ b/packages/denylist/Move.toml @@ -1,6 +1,7 @@ [package] name = "denylist" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } diff --git a/packages/denylist/migration.patch b/packages/denylist/migration.patch new file mode 100644 index 00000000..f5ef5c99 --- /dev/null +++ b/packages/denylist/migration.patch @@ -0,0 +1,64 @@ +--- sources/denylist.move ++++ sources/denylist.move +@@ -17 +17 @@ +- struct Denylist has store { ++ public struct Denylist has store { +@@ -27 +27 @@ +- struct DenyListAuth has drop {} ++ public struct DenyListAuth has drop {} +@@ -80 +80 @@ +- let i = vector::length(&words); ++ let mut i = vector::length(&words); +@@ -93 +93 @@ +- let i = vector::length(&words); ++ let mut i = vector::length(&words); +--- tests/denylist_tests.move ++++ tests/denylist_tests.move +@@ -18 +18 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -22 +22 @@ +- let suins = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); +@@ -44 +44 @@ +- #[test, expected_failure(abort_code = denylist::denylist::ENoWordsInList)] ++ #[test, expected_failure(abort_code = ::denylist::denylist::ENoWordsInList)] +@@ -46 +46 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -50 +50 @@ +- let suins = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); +@@ -59 +59 @@ +- #[test, expected_failure(abort_code = denylist::denylist::ENoWordsInList)] ++ #[test, expected_failure(abort_code = ::denylist::denylist::ENoWordsInList)] +@@ -61 +61 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -65 +65 @@ +- let suins = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); +@@ -75 +75 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -79 +79 @@ +- let suins = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); +@@ -98 +98 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -102 +102 @@ +- let suins = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); +@@ -124 +124 @@ +- let scenario = ts::begin(ADDR); ++ let mut scenario = ts::begin(ADDR); +@@ -128 +128 @@ +- let (suins, cap) = suins::new_for_testing(ctx(&mut scenario)); ++ let (mut suins, cap) = suins::new_for_testing(ctx(&mut scenario)); +@@ -143 +143 @@ +- let vec: vector = vector::empty(); ++ let mut vec: vector = vector::empty(); +@@ -152 +152 @@ +- let vec: vector = vector::empty(); ++ let mut vec: vector = vector::empty(); diff --git a/packages/denylist/sources/denylist.move b/packages/denylist/sources/denylist.move index 8e777a57..97cfd89b 100644 --- a/packages/denylist/sources/denylist.move +++ b/packages/denylist/sources/denylist.move @@ -14,7 +14,7 @@ module denylist::denylist { const ENoWordsInList: u64 = 1; /// A wrapper that holds the reserved and blocked names. - struct Denylist has store { + public struct Denylist has store { // The list of reserved names. // Our public SLD registrations will be checking against it. reserved: Table, @@ -24,7 +24,7 @@ module denylist::denylist { } /// The authorization for the denylist registry. - struct DenyListAuth has drop {} + public struct DenyListAuth has drop {} public fun setup(suins: &mut SuiNS, cap: &AdminCap, ctx: &mut TxContext) { suins::add_registry(cap, suins, Denylist { @@ -77,7 +77,7 @@ module denylist::denylist { fun internal_add_names_to_list(table: &mut Table, words: vector) { assert!(vector::length(&words) > 0, ENoWordsInList); - let i = vector::length(&words); + let mut i = vector::length(&words); while (i > 0) { i = i - 1; @@ -90,7 +90,7 @@ module denylist::denylist { fun internal_remove_names_from_list(table: &mut Table, words: vector) { assert!(vector::length(&words) > 0, ENoWordsInList); - let i = vector::length(&words); + let mut i = vector::length(&words); while (i > 0) { i = i - 1; diff --git a/packages/denylist/tests/denylist_tests.move b/packages/denylist/tests/denylist_tests.move index cdb634fb..a0c71c2a 100644 --- a/packages/denylist/tests/denylist_tests.move +++ b/packages/denylist/tests/denylist_tests.move @@ -15,11 +15,11 @@ module denylist::denylist_tests { #[test] fun test() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; ts::next_tx(scenario, ADDR); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let cap = suins::create_admin_cap_for_testing(ctx(scenario)); denylist::add_reserved_names(&mut suins, &cap, some_reserved_names()); @@ -41,13 +41,13 @@ module denylist::denylist_tests { ts::end(scenario_val); } - #[test, expected_failure(abort_code = denylist::denylist::ENoWordsInList)] + #[test, expected_failure(abort_code = ::denylist::denylist::ENoWordsInList)] fun test_empty_addition_failure(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; ts::next_tx(scenario, ADDR); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let cap = suins::create_admin_cap_for_testing(ctx(scenario)); denylist::add_reserved_names(&mut suins, &cap, vector[]); @@ -56,13 +56,13 @@ module denylist::denylist_tests { } // coverage.. :) - #[test, expected_failure(abort_code = denylist::denylist::ENoWordsInList)] + #[test, expected_failure(abort_code = ::denylist::denylist::ENoWordsInList)] fun test_empty_addition_blocked_failure(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; ts::next_tx(scenario, ADDR); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let cap = suins::create_admin_cap_for_testing(ctx(scenario)); denylist::add_blocked_names(&mut suins, &cap, vector[]); @@ -72,11 +72,11 @@ module denylist::denylist_tests { #[test] fun remove_blocked_word(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; ts::next_tx(scenario, ADDR); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let cap = suins::create_admin_cap_for_testing(ctx(scenario)); denylist::add_blocked_names(&mut suins, &cap, some_offensive_names()); @@ -95,11 +95,11 @@ module denylist::denylist_tests { #[test] fun remove_reserved_word(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; ts::next_tx(scenario, ADDR); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let cap = suins::create_admin_cap_for_testing(ctx(scenario)); denylist::add_reserved_names(&mut suins, &cap, some_reserved_names()); @@ -121,11 +121,11 @@ module denylist::denylist_tests { // data preparation public fun test_init(): (Scenario) { - let scenario = ts::begin(ADDR); + let mut scenario = ts::begin(ADDR); { ts::next_tx(&mut scenario, ADDR); - let (suins, cap) = suins::new_for_testing(ctx(&mut scenario)); + let (mut suins, cap) = suins::new_for_testing(ctx(&mut scenario)); suins::authorize_app_for_testing(&mut suins); @@ -140,7 +140,7 @@ module denylist::denylist_tests { } fun some_reserved_names(): vector { - let vec: vector = vector::empty(); + let mut vec: vector = vector::empty(); vector::push_back(&mut vec, utf8(b"test")); vector::push_back(&mut vec, utf8(b"test2")); @@ -149,7 +149,7 @@ module denylist::denylist_tests { } fun some_offensive_names(): vector { - let vec: vector = vector::empty(); + let mut vec: vector = vector::empty(); vector::push_back(&mut vec, utf8(b"bad_test")); vector::push_back(&mut vec, utf8(b"bad_test2")); vector::push_back(&mut vec, utf8(b"bad_test3")); From 7239ae1c7328bcca38dff093c41654d825b8f70e Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 16:14:46 -0400 Subject: [PATCH 6/8] discounts --- packages/discounts/Move.lock | 5 + packages/discounts/Move.toml | 1 + packages/discounts/migration.patch | 172 ++++++++++++++++++ packages/discounts/sources/discounts.move | 8 +- packages/discounts/sources/free_claims.move | 12 +- packages/discounts/sources/house.move | 14 +- packages/discounts/tests/discount_tests.move | 42 ++--- .../discounts/tests/free_claims_test.move | 36 ++-- 8 files changed, 234 insertions(+), 56 deletions(-) create mode 100644 packages/discounts/migration.patch diff --git a/packages/discounts/Move.lock b/packages/discounts/Move.lock index 200def0f..9723f7ca 100644 --- a/packages/discounts/Move.lock +++ b/packages/discounts/Move.lock @@ -39,3 +39,8 @@ source = { local = "../suins" } dependencies = [ { name = "Sui" }, ] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/discounts/Move.toml b/packages/discounts/Move.toml index 74a113d5..05cdd9a3 100644 --- a/packages/discounts/Move.toml +++ b/packages/discounts/Move.toml @@ -1,6 +1,7 @@ [package] name = "discounts" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override=true } diff --git a/packages/discounts/migration.patch b/packages/discounts/migration.patch new file mode 100644 index 00000000..e2796b31 --- /dev/null +++ b/packages/discounts/migration.patch @@ -0,0 +1,172 @@ +--- sources/discounts.move ++++ sources/discounts.move +@@ -13 +13 @@ +- use std::type_name::{Self as type}; ++ use std::type_name::{Self as `type`}; +@@ -42 +42 @@ +- struct DiscountKey has copy, store, drop {} ++ public struct DiscountKey has copy, store, drop {} +@@ -46 +46 @@ +- struct DiscountConfig has copy, store, drop { ++ public struct DiscountConfig has copy, store, drop { +@@ -65 +65 @@ +- assert!(type::into_string(type::get()) != type::into_string(type::get()), ENotValidForDayOne); ++ assert!(`type`::into_string(`type`::get()) != `type`::into_string(`type`::get()), ENotValidForDayOne); +--- sources/free_claims.move ++++ sources/free_claims.move +@@ -16 +16 @@ +- use std::type_name::{Self as type}; ++ use std::type_name::{Self as `type`}; +@@ -47 +47 @@ +- struct FreeClaimsApp has drop {} ++ public struct FreeClaimsApp has drop {} +@@ -50 +50 @@ +- struct FreeClaimsKey has copy, store, drop {} ++ public struct FreeClaimsKey has copy, store, drop {} +@@ -55 +55 @@ +- struct FreeClaimsConfig has store { ++ public struct FreeClaimsConfig has store { +@@ -71 +71 @@ +- assert!(type::into_string(type::get()) != type::into_string(type::get()), ENotValidForDayOne); ++ assert!(`type`::into_string(`type`::get()) != `type`::into_string(`type`::get()), ENotValidForDayOne); +@@ -148 +148 @@ +- let FreeClaimsConfig { used_objects, domain_length_range: _ } = df::remove, FreeClaimsConfig>(house::uid_mut(self), FreeClaimsKey{}); ++ let FreeClaimsConfig { mut used_objects, domain_length_range: _ } = df::remove, FreeClaimsConfig>(house::uid_mut(self), FreeClaimsKey{}); +--- sources/house.move ++++ sources/house.move +@@ -20 +20 @@ +- friend discounts::free_claims; ++ /* friend discounts::free_claims; */ +@@ -22 +22 @@ +- friend discounts::discounts; ++ /* friend discounts::discounts; */ +@@ -34 +34 @@ +- struct DiscountHouseApp has drop {} ++ public struct DiscountHouseApp has drop {} +@@ -37 +37 @@ +- struct DiscountHouse has key, store { ++ public struct DiscountHouse has key, store { +@@ -64 +64 @@ +- public(friend) fun friend_add_registry_entry( ++ public(package) fun friend_add_registry_entry( +@@ -82 +82 @@ +- public(friend) fun uid_mut(self: &mut DiscountHouse): &mut UID { ++ public(package) fun uid_mut(self: &mut DiscountHouse): &mut UID { +@@ -87 +87 @@ +- public(friend) fun suins_app_auth(): DiscountHouseApp { ++ public(package) fun suins_app_auth(): DiscountHouseApp { +--- tests/discount_tests.move ++++ tests/discount_tests.move +@@ -24 +24 @@ +- struct TestAuthorized has copy, store, drop {} ++ public struct TestAuthorized has copy, store, drop {} +@@ -27 +27 @@ +- struct AnotherAuthorized has copy, store, drop {} ++ public struct AnotherAuthorized has copy, store, drop {} +@@ -30 +30 @@ +- struct TestUnauthorized has copy, store, drop {} ++ public struct TestUnauthorized has copy, store, drop {} +@@ -38 +38 @@ +- let scenario_val = ts::begin(SUINS_ADDRESS); ++ let mut scenario_val = ts::begin(SUINS_ADDRESS); +@@ -41 +41 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -51,2 +51,2 @@ +- let suins = ts::take_shared(scenario); +- let discount_house = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -77,2 +77,2 @@ +- let suins = ts::take_shared(scenario); +- let discount_house = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -98,2 +98,2 @@ +- let suins = ts::take_shared(scenario); +- let discount_house = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -113 +113 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -130 +130 @@ +- #[test, expected_failure(abort_code = discounts::discounts::EConfigNotExists)] ++ #[test, expected_failure(abort_code = ::discounts::discounts::EConfigNotExists)] +@@ -132 +132 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -150 +150 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -153 +153 @@ +- let day_one = day_one::mint_for_testing(ctx(scenario)); ++ let mut day_one = day_one::mint_for_testing(ctx(scenario)); +@@ -169 +169 @@ +- #[test, expected_failure(abort_code = discounts::discounts::ENotValidForDayOne)] ++ #[test, expected_failure(abort_code = ::discounts::discounts::ENotValidForDayOne)] +@@ -171 +171 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -174 +174 @@ +- let day_one = day_one::mint_for_testing(ctx(scenario)); ++ let mut day_one = day_one::mint_for_testing(ctx(scenario)); +@@ -190 +190 @@ +- #[test, expected_failure(abort_code = discounts::discounts::ENotActiveDayOne)] ++ #[test, expected_failure(abort_code = ::discounts::discounts::ENotActiveDayOne)] +@@ -192 +192 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +--- tests/free_claims_test.move ++++ tests/free_claims_test.move +@@ -23 +23 @@ +- struct TestAuthorized has key, store { id: UID } ++ public struct TestAuthorized has key, store { id: UID } +@@ -26 +26 @@ +- struct TestUnauthorized has key { id: UID } ++ public struct TestUnauthorized has key { id: UID } +@@ -32 +32 @@ +- let scenario_val = ts::begin(SUINS_ADDRESS); ++ let mut scenario_val = ts::begin(SUINS_ADDRESS); +@@ -35 +35 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -45,2 +45,2 @@ +- let suins = ts::take_shared(scenario); +- let discount_house = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -60 +60 @@ +- fun test_end(scenario_val: Scenario) { ++ fun test_end(mut scenario_val: Scenario) { +@@ -65 +65 @@ +- let discount_house = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -87,2 +87,2 @@ +- let suins = ts::take_shared(scenario); +- let discount_house = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -107,2 +107,2 @@ +- let suins = ts::take_shared(scenario); +- let discount_house = ts::take_shared(scenario); ++ let mut suins = ts::take_shared(scenario); ++ let mut discount_house = ts::take_shared(scenario); +@@ -122 +122 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -142 +142 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -145 +145 @@ +- let day_one = day_one::mint_for_testing(ctx(scenario)); ++ let mut day_one = day_one::mint_for_testing(ctx(scenario)); +@@ -161 +161 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -189 +189 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -209 +209 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); diff --git a/packages/discounts/sources/discounts.move b/packages/discounts/sources/discounts.move index 014dd889..24e71fae 100644 --- a/packages/discounts/sources/discounts.move +++ b/packages/discounts/sources/discounts.move @@ -10,7 +10,7 @@ module discounts::discounts { use std::option::{Option}; use std::string::{Self, String}; - use std::type_name::{Self as type}; + use std::type_name::{Self as `type`}; use sui::tx_context::{TxContext}; use sui::dynamic_field::{Self as df}; @@ -39,11 +39,11 @@ module discounts::discounts { const ENotActiveDayOne: u64 = 5; /// A key that opens up discounts for type T. - struct DiscountKey has copy, store, drop {} + public struct DiscountKey has copy, store, drop {} /// The Discount config for type T. /// We save the sale price for each letter configuration (3 chars, 4 chars, 5+ chars) - struct DiscountConfig has copy, store, drop { + public struct DiscountConfig has copy, store, drop { three_char_price: u64, four_char_price: u64, five_plus_char_price: u64, @@ -62,7 +62,7 @@ module discounts::discounts { ): SuinsRegistration { // For normal flow, we do not allow DayOne to be used. // DayOne can only be used on `register_with_day_one` function. - assert!(type::into_string(type::get()) != type::into_string(type::get()), ENotValidForDayOne); + assert!(`type`::into_string(`type`::get()) != `type`::into_string(`type`::get()), ENotValidForDayOne); internal_register_name(self, suins, domain_name, payment, clock, ctx) } diff --git a/packages/discounts/sources/free_claims.move b/packages/discounts/sources/free_claims.move index 3790b74d..89b94248 100644 --- a/packages/discounts/sources/free_claims.move +++ b/packages/discounts/sources/free_claims.move @@ -13,7 +13,7 @@ module discounts::free_claims { use std::string; use std::string::{String}; - use std::type_name::{Self as type}; + use std::type_name::{Self as `type`}; use sui::object::{Self, ID}; use sui::tx_context::{TxContext}; @@ -44,15 +44,15 @@ module discounts::free_claims { const ENotActiveDayOne: u64 = 6; /// A key to authorize DiscountHouse to register names on SuiNS. - struct FreeClaimsApp has drop {} + public struct FreeClaimsApp has drop {} /// A key that opens up free claims for type T. - struct FreeClaimsKey has copy, store, drop {} + public struct FreeClaimsKey has copy, store, drop {} /// We hold the configuration for the promotion /// We only allow 1 claim / per configuration / per promotion. /// We keep the used ids as a LinkedTable so we can get our rebates when closing the promotion. - struct FreeClaimsConfig has store { + public struct FreeClaimsConfig has store { domain_length_range: vector, used_objects: LinkedTable } @@ -68,7 +68,7 @@ module discounts::free_claims { ): SuinsRegistration { // For normal flow, we do not allow DayOne to be used. // DayOne can only be used on `register_with_day_one` function. - assert!(type::into_string(type::get()) != type::into_string(type::get()), ENotValidForDayOne); + assert!(`type`::into_string(`type`::get()) != `type`::into_string(`type`::get()), ENotValidForDayOne); internal_claim_free_name(self, suins, domain_name, clock, object, ctx) } @@ -145,7 +145,7 @@ module discounts::free_claims { public fun deauthorize_type(_: &AdminCap, self: &mut DiscountHouse) { house::assert_version_is_valid(self); assert_config_exists(self); - let FreeClaimsConfig { used_objects, domain_length_range: _ } = df::remove, FreeClaimsConfig>(house::uid_mut(self), FreeClaimsKey{}); + let FreeClaimsConfig { mut used_objects, domain_length_range: _ } = df::remove, FreeClaimsConfig>(house::uid_mut(self), FreeClaimsKey{}); // parse each entry and remove it. Gives us storage rebates. while(linked_table::length(&used_objects) > 0) { diff --git a/packages/discounts/sources/house.move b/packages/discounts/sources/house.move index d6c32b2b..6b475a78 100644 --- a/packages/discounts/sources/house.move +++ b/packages/discounts/sources/house.move @@ -17,9 +17,9 @@ module discounts::house { use suins::suins_registration::SuinsRegistration; // The `free_claims` module can use the shared object to attach configuration & claim names. - friend discounts::free_claims; + /* friend discounts::free_claims; */ // The `discounts` module can use the shared object to attach configuration & claim names. - friend discounts::discounts; + /* friend discounts::discounts; */ /// Tries to register with invalid version of the app const ENotValidVersion: u64 = 1; @@ -31,10 +31,10 @@ module discounts::house { const REGISTRATION_YEARS: u8 = 1; /// A key to authorize DiscountHouse to register names on SuiNS. - struct DiscountHouseApp has drop {} + public struct DiscountHouseApp has drop {} // The Shared object responsible for the discounts. - struct DiscountHouse has key, store { + public struct DiscountHouse has key, store { id: UID, version: u8 } @@ -61,7 +61,7 @@ module discounts::house { /// A function to save a new SuiNS name in the registry. /// Helps re-use the same code for all discounts based on type T of the package. - public(friend) fun friend_add_registry_entry( + public(package) fun friend_add_registry_entry( suins: &mut SuiNS, domain: Domain, clock: &Clock, @@ -79,12 +79,12 @@ module discounts::house { /// Returns the UID of the shared object so we can add custom configuration. /// from different modules we have. but keep using the same shared object. - public(friend) fun uid_mut(self: &mut DiscountHouse): &mut UID { + public(package) fun uid_mut(self: &mut DiscountHouse): &mut UID { &mut self.id } /// Allows the friend modules to call functions to the SuiNS registry. - public(friend) fun suins_app_auth(): DiscountHouseApp { + public(package) fun suins_app_auth(): DiscountHouseApp { DiscountHouseApp {} } diff --git a/packages/discounts/tests/discount_tests.move b/packages/discounts/tests/discount_tests.move index 8d4ad025..cdfbeebd 100644 --- a/packages/discounts/tests/discount_tests.move +++ b/packages/discounts/tests/discount_tests.move @@ -21,13 +21,13 @@ module discounts::discount_tests { use day_one::day_one::{Self, DayOne}; // an authorized type to test. - struct TestAuthorized has copy, store, drop {} + public struct TestAuthorized has copy, store, drop {} // another authorized type to test. - struct AnotherAuthorized has copy, store, drop {} + public struct AnotherAuthorized has copy, store, drop {} // an unauthorized type to test. - struct TestUnauthorized has copy, store, drop {} + public struct TestUnauthorized has copy, store, drop {} const SUINS_ADDRESS: address = @0xA001; const USER_ADDRESS: address = @0xA002; @@ -35,10 +35,10 @@ module discounts::discount_tests { const MIST_PER_SUI: u64 = 1_000_000_000; fun test_init(): Scenario { - let scenario_val = ts::begin(SUINS_ADDRESS); + let mut scenario_val = ts::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); house::init_for_testing(ctx(scenario)); @@ -48,8 +48,8 @@ module discounts::discount_tests { { ts::next_tx(scenario, SUINS_ADDRESS); let admin_cap = ts::take_from_sender(scenario); - let suins = ts::take_shared(scenario); - let discount_house = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); // a more expensive alternative. discounts::authorize_type(&admin_cap, &mut discount_house, 3*MIST_PER_SUI, 2*MIST_PER_SUI, 1*MIST_PER_SUI); @@ -74,8 +74,8 @@ module discounts::discount_tests { user: address ) { ts::next_tx(scenario, user); - let suins = ts::take_shared(scenario); - let discount_house = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); let clock = ts::take_shared(scenario); let name = discounts::register(&mut discount_house, &mut suins, item, domain_name, payment, &clock, option::none(), ctx(scenario)); @@ -95,8 +95,8 @@ module discounts::discount_tests { user: address ) { ts::next_tx(scenario, user); - let suins = ts::take_shared(scenario); - let discount_house = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); let clock = ts::take_shared(scenario); let name = discounts::register_with_day_one(&mut discount_house, &mut suins, item, domain_name, payment, &clock, option::none(), ctx(scenario)); @@ -110,7 +110,7 @@ module discounts::discount_tests { #[test] fun test_e2e() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let test_item = TestAuthorized {}; @@ -127,9 +127,9 @@ module discounts::discount_tests { ts::end(scenario_val); } - #[test, expected_failure(abort_code = discounts::discounts::EConfigNotExists)] + #[test, expected_failure(abort_code = ::discounts::discounts::EConfigNotExists)] fun register_with_unauthorized_type() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let test_item = TestUnauthorized {}; @@ -147,10 +147,10 @@ module discounts::discount_tests { #[test] fun use_day_one(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let day_one = day_one::mint_for_testing(ctx(scenario)); + let mut day_one = day_one::mint_for_testing(ctx(scenario)); day_one::set_is_active_for_testing(&mut day_one, true); let payment: Coin = coin::mint_for_testing(MIST_PER_SUI, ctx(scenario)); @@ -166,12 +166,12 @@ module discounts::discount_tests { ts::end(scenario_val); } - #[test, expected_failure(abort_code = discounts::discounts::ENotValidForDayOne)] + #[test, expected_failure(abort_code = ::discounts::discounts::ENotValidForDayOne)] fun use_day_one_for_casual_flow_failure(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let day_one = day_one::mint_for_testing(ctx(scenario)); + let mut day_one = day_one::mint_for_testing(ctx(scenario)); day_one::set_is_active_for_testing(&mut day_one, true); let payment: Coin = coin::mint_for_testing(MIST_PER_SUI, ctx(scenario)); @@ -187,9 +187,9 @@ module discounts::discount_tests { ts::end(scenario_val); } - #[test, expected_failure(abort_code = discounts::discounts::ENotActiveDayOne)] + #[test, expected_failure(abort_code = ::discounts::discounts::ENotActiveDayOne)] fun use_inactive_day_one_failure(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let day_one = day_one::mint_for_testing(ctx(scenario)); diff --git a/packages/discounts/tests/free_claims_test.move b/packages/discounts/tests/free_claims_test.move index b6416482..5367fe9a 100644 --- a/packages/discounts/tests/free_claims_test.move +++ b/packages/discounts/tests/free_claims_test.move @@ -20,19 +20,19 @@ module discounts::free_claims_tests { use day_one::day_one::{Self, DayOne}; // An authorized type to test. - struct TestAuthorized has key, store { id: UID } + public struct TestAuthorized has key, store { id: UID } // An unauthorized type to test. - struct TestUnauthorized has key { id: UID } + public struct TestUnauthorized has key { id: UID } const SUINS_ADDRESS: address = @0xA001; const USER_ADDRESS: address = @0xA002; fun test_init(): Scenario { - let scenario_val = ts::begin(SUINS_ADDRESS); + let mut scenario_val = ts::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); house::init_for_testing(ctx(scenario)); @@ -42,8 +42,8 @@ module discounts::free_claims_tests { { ts::next_tx(scenario, SUINS_ADDRESS); let admin_cap = ts::take_from_sender(scenario); - let suins = ts::take_shared(scenario); - let discount_house = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); // a more expensive alternative. free_claims::authorize_type(&admin_cap, &mut discount_house, vector[10,63], ctx(scenario)); @@ -57,12 +57,12 @@ module discounts::free_claims_tests { scenario_val } - fun test_end(scenario_val: Scenario) { + fun test_end(mut scenario_val: Scenario) { let scenario = &mut scenario_val; { ts::next_tx(scenario, SUINS_ADDRESS); let admin_cap = ts::take_from_sender(scenario); - let discount_house = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); free_claims::deauthorize_type(&admin_cap, &mut discount_house); free_claims::deauthorize_type(&admin_cap, &mut discount_house); ts::return_shared(discount_house); @@ -84,8 +84,8 @@ module discounts::free_claims_tests { user: address ) { ts::next_tx(scenario, user); - let suins = ts::take_shared(scenario); - let discount_house = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); let clock = ts::take_shared(scenario); let name = free_claims::free_claim(&mut discount_house, &mut suins, item, domain_name, &clock, ctx(scenario)); @@ -104,8 +104,8 @@ module discounts::free_claims_tests { user: address ) { ts::next_tx(scenario, user); - let suins = ts::take_shared(scenario); - let discount_house = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); + let mut discount_house = ts::take_shared(scenario); let clock = ts::take_shared(scenario); let name = free_claims::free_claim_with_day_one(&mut discount_house, &mut suins, item, domain_name, &clock, ctx(scenario)); @@ -119,7 +119,7 @@ module discounts::free_claims_tests { #[test] fun test_e2e() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let test_item = TestAuthorized { @@ -139,10 +139,10 @@ module discounts::free_claims_tests { #[test] fun use_day_one(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; - let day_one = day_one::mint_for_testing(ctx(scenario)); + let mut day_one = day_one::mint_for_testing(ctx(scenario)); day_one::set_is_active_for_testing(&mut day_one, true); free_claim_with_day_one( @@ -158,7 +158,7 @@ module discounts::free_claims_tests { #[test, expected_failure(abort_code = discounts::free_claims::EAlreadyClaimed)] fun test_tries_to_claim_again_with_same_object_failure() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let test_item = TestAuthorized { @@ -186,7 +186,7 @@ module discounts::free_claims_tests { #[test, expected_failure(abort_code = discounts::free_claims::EInvalidCharacterRange)] fun test_invalid_size_failure() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let test_item = TestAuthorized { @@ -206,7 +206,7 @@ module discounts::free_claims_tests { #[test, expected_failure(abort_code = discounts::free_claims::EConfigNotExists)] fun register_with_unauthorized_type() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let test_item = TestUnauthorized { From 9f78c7f3f0d4794ad9daa400fda6001dfad25d58 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 21 Mar 2024 16:16:32 -0400 Subject: [PATCH 7/8] registration --- packages/registration/Move.lock | 9 ++- packages/registration/Move.toml | 1 + packages/registration/migration.patch | 76 +++++++++++++++++++ packages/registration/sources/register.move | 2 +- .../registration/tests/register_tests.move | 46 +++++------ 5 files changed, 109 insertions(+), 25 deletions(-) create mode 100644 packages/registration/migration.patch diff --git a/packages/registration/Move.lock b/packages/registration/Move.lock index a88ee9e2..eabd68c1 100644 --- a/packages/registration/Move.lock +++ b/packages/registration/Move.lock @@ -1,7 +1,9 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 0 +version = 1 +manifest_digest = "75434D5374AE0B76DFC7B2C8B1D93D92E43B7C10C03782CF67925E35F379A78A" +deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" dependencies = [ { name = "Sui" }, @@ -27,3 +29,8 @@ source = { local = "../suins" } dependencies = [ { name = "Sui" }, ] + +[move.toolchain-version] +compiler-version = "1.22.0" +edition = "legacy" +flavor = "sui" diff --git a/packages/registration/Move.toml b/packages/registration/Move.toml index 628138c6..78da1311 100644 --- a/packages/registration/Move.toml +++ b/packages/registration/Move.toml @@ -1,6 +1,7 @@ [package] name = "registration" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet", override=true } diff --git a/packages/registration/migration.patch b/packages/registration/migration.patch new file mode 100644 index 00000000..6422dae7 --- /dev/null +++ b/packages/registration/migration.patch @@ -0,0 +1,76 @@ +--- sources/register.move ++++ sources/register.move +@@ -24 +24 @@ +- struct Register has drop {} ++ public struct Register has drop {} +--- tests/register_tests.move ++++ tests/register_tests.move +@@ -30 +30 @@ +- let scenario_val = test_scenario::begin(SUINS_ADDRESS); ++ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); +@@ -33 +33 @@ +- let suins = suins::init_for_testing(ctx(scenario)); ++ let mut suins = suins::init_for_testing(ctx(scenario)); +@@ -43 +43 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -61 +61 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -63 +63 @@ +- let clock = test_scenario::take_shared(scenario); ++ let mut clock = test_scenario::take_shared(scenario); +@@ -77 +77 @@ +- let suins = test_scenario::take_shared(scenario); ++ let mut suins = test_scenario::take_shared(scenario); +@@ -94 +94 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -120 +120 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -131 +131 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -142 +142 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -153 +153 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -164 +164 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -175 +175 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -204 +204 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -221 +221 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -232 +232 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -243 +243 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -254 +254 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -265 +265 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -276 +276 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -289 +289 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); +@@ -308 +308 @@ +- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] ++ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] +@@ -310 +310 @@ +- let scenario_val = test_init(); ++ let mut scenario_val = test_init(); diff --git a/packages/registration/sources/register.move b/packages/registration/sources/register.move index e57d08cb..4e4ae173 100644 --- a/packages/registration/sources/register.move +++ b/packages/registration/sources/register.move @@ -21,7 +21,7 @@ module registration::register { const EIncorrectAmount: u64 = 4; /// Authorization token for the app. - struct Register has drop {} + public struct Register has drop {} // Allows direct purchases of domains // diff --git a/packages/registration/tests/register_tests.move b/packages/registration/tests/register_tests.move index cd383c5e..2a4e2196 100644 --- a/packages/registration/tests/register_tests.move +++ b/packages/registration/tests/register_tests.move @@ -27,10 +27,10 @@ module registration::register_tests { const DOMAIN_NAME: vector = b"abc.sui"; public fun test_init(): Scenario { - let scenario_val = test_scenario::begin(SUINS_ADDRESS); + let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); @@ -40,7 +40,7 @@ module registration::register_tests { { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -58,9 +58,9 @@ module registration::register_tests { clock_tick: u64 ): SuinsRegistration { test_scenario::next_tx(scenario, SUINS_ADDRESS); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); let payment = coin::mint_for_testing(amount, ctx(scenario)); - let clock = test_scenario::take_shared(scenario); + let mut clock = test_scenario::take_shared(scenario); clock::increment_for_testing(&mut clock, clock_tick); let nft = register(&mut suins, domain_name, no_years, payment, &clock, ctx(scenario)); @@ -74,7 +74,7 @@ module registration::register_tests { fun deauthorize_app_util(scenario: &mut Scenario) { test_scenario::next_tx(scenario, SUINS_ADDRESS); let admin_cap = test_scenario::take_from_sender(scenario); - let suins = test_scenario::take_shared(scenario); + let mut suins = test_scenario::take_shared(scenario); suins::deauthorize_app(&admin_cap, &mut suins); @@ -91,7 +91,7 @@ module registration::register_tests { #[test] fun test_register() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); @@ -117,7 +117,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = config::EInvalidTld)] fun test_register_if_not_sui_tld() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"abc.move"), 1, 1200 * mist_per_sui(), 10); @@ -128,7 +128,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = register::EIncorrectAmount)] fun test_register_if_incorrect_amount() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1210 * mist_per_sui(), 10); @@ -139,7 +139,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = register::EIncorrectAmount)] fun test_register_if_incorrect_amount_2() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 90 * mist_per_sui(), 10); @@ -150,7 +150,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = register::EInvalidYearsArgument)] fun test_register_if_no_years_more_than_5_years() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 6, 6 * 1200 * mist_per_sui(), 10); @@ -161,7 +161,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = register::EInvalidYearsArgument)] fun test_register_if_no_years_is_zero() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 0, 1200 * mist_per_sui(), 10); @@ -172,7 +172,7 @@ module registration::register_tests { #[test] fun test_register_if_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); @@ -201,7 +201,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = registry::ERecordNotExpired)] fun test_register_if_not_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); @@ -218,7 +218,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_register_if_domain_name_starts_with_dash() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"-ab.sui"), 1, 1200 * mist_per_sui(), 10); @@ -229,7 +229,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_register_if_domain_name_ends_with_dash() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"ab-.sui"), 1, 1200 * mist_per_sui(), 10); @@ -240,7 +240,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = domain::EInvalidDomain)] fun test_register_if_domain_name_contains_uppercase_character() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"Abc.com"), 1, 1200 * mist_per_sui(), 10); @@ -251,7 +251,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = config::ELabelTooShort)] fun test_register_if_domain_name_too_short() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"ab.sui"), 1, 1200 * mist_per_sui(), 10); @@ -262,7 +262,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = config::EInvalidDomain)] fun test_register_if_domain_name_contains_subdomain() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let nft = register_util(scenario, utf8(b"abc.xyz.sui"), 1, 1200 * mist_per_sui(), 10); @@ -273,7 +273,7 @@ module registration::register_tests { #[test, expected_failure(abort_code = registry::ERecordNotExpired)] fun test_register_aborts_if_domain_name_went_through_auction() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; auction::init_for_testing(ctx(scenario)); @@ -286,7 +286,7 @@ module registration::register_tests { #[test] fun test_register_works_if_auctioned_domain_name_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; auction::init_for_testing(ctx(scenario)); @@ -305,9 +305,9 @@ module registration::register_tests { test_scenario::end(scenario_val); } - #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] + #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] fun test_register_aborts_if_register_is_deauthorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; deauthorize_app_util(scenario); From 86c0f8ecc4bf9493817ca92304ceb75adf8222b3 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Wed, 27 Mar 2024 17:18:17 -0400 Subject: [PATCH 8/8] migration updates --- packages/coupons/migration.patch | 239 ----- packages/day_one/migration.patch | 131 --- packages/denylist/migration.patch | 64 -- packages/discounts/migration.patch | 172 ---- packages/managed_names/Move.toml | 1 + packages/managed_names/sources/managed.move | 12 +- .../managed_names/tests/managed_tests.move | 42 +- packages/registration/migration.patch | 76 -- packages/renewal/migration.patch | 90 -- packages/subdomains/Move.toml | 1 + packages/subdomains/sources/config.move | 4 +- packages/subdomains/sources/subdomains.move | 10 +- .../subdomains/tests/subdomain_tests.move | 62 +- packages/suins/migration.patch | 827 ------------------ packages/temp_subdomain_proxy/Move.toml | 1 + packages/utils/Move.toml | 1 + packages/utils/sources/direct_setup.move | 2 +- 17 files changed, 70 insertions(+), 1665 deletions(-) delete mode 100644 packages/coupons/migration.patch delete mode 100644 packages/day_one/migration.patch delete mode 100644 packages/denylist/migration.patch delete mode 100644 packages/discounts/migration.patch delete mode 100644 packages/registration/migration.patch delete mode 100644 packages/renewal/migration.patch delete mode 100644 packages/suins/migration.patch diff --git a/packages/coupons/migration.patch b/packages/coupons/migration.patch deleted file mode 100644 index 93d56072..00000000 --- a/packages/coupons/migration.patch +++ /dev/null @@ -1,239 +0,0 @@ ---- sources/coupons.move -+++ sources/coupons.move -@@ -52 +52 @@ -- struct CouponsApp has drop {} -+ public struct CouponsApp has drop {} -@@ -54 +54 @@ -- struct AppKey has copy, store, drop {} -+ public struct AppKey has copy, store, drop {} -@@ -59 +59 @@ -- struct Data has store { -+ public struct Data has store { -@@ -65 +65 @@ -- struct CouponHouse has key, store { -+ public struct CouponHouse has key, store { -@@ -75,2 +75,2 @@ -- struct Coupon has copy, store, drop { -- type: u8, // 0 -> Percentage Discount | 1 -> Fixed Discount -+ public struct Coupon has copy, store, drop { -+ `type`: u8, // 0 -> Percentage Discount | 1 -> Fixed Discount -@@ -212 +212 @@ -- type: u8, -+ `type`: u8, -@@ -218 +218 @@ -- internal_save_coupon(&mut self.data, code, internal_create_coupon(type, amount, rules, ctx)); -+ internal_save_coupon(&mut self.data, code, internal_create_coupon(`type`, amount, rules, ctx)); -@@ -230 +230 @@ -- type: u8, -+ `type`: u8, -@@ -235 +235 @@ -- internal_save_coupon(self, code, internal_create_coupon(type, amount, rules, ctx)); -+ internal_save_coupon(self, code, internal_create_coupon(`type`, amount, rules, ctx)); -@@ -247 +247 @@ -- if(coupon.type == constants::fixed_price_discount_type()){ -+ if(coupon.`type` == constants::fixed_price_discount_type()){ -@@ -271 +271 @@ -- type: u8, -+ `type`: u8, -@@ -276,2 +276,2 @@ -- rules::assert_is_valid_amount(type, amount); -- rules::assert_is_valid_discount_type(type); -+ rules::assert_is_valid_amount(`type`, amount); -+ rules::assert_is_valid_discount_type(`type`); -@@ -279 +279 @@ -- type, amount, rules -+ `type`, amount, rules ---- sources/range.move -+++ sources/range.move -@@ -14 +14 @@ -- struct Range has copy, store, drop { -+ public struct Range has copy, store, drop { ---- sources/rules.move -+++ sources/rules.move -@@ -42 +42 @@ -- struct CouponRules has copy, store, drop { -+ public struct CouponRules has copy, store, drop { -@@ -121,2 +121,2 @@ -- public fun assert_is_valid_discount_type(type: u8) { -- assert!(vector::contains(&constants::discount_rule_types(), &type), EInvalidType); -+ public fun assert_is_valid_discount_type(`type`: u8) { -+ assert!(vector::contains(&constants::discount_rule_types(), &`type`), EInvalidType); -@@ -127 +127 @@ -- public fun assert_is_valid_amount(type: u8, amount: u64) { -+ public fun assert_is_valid_amount(`type`: u8, amount: u64) { -@@ -129 +129 @@ -- if(type == constants::percentage_discount_type()){ -+ if(`type` == constants::percentage_discount_type()){ ---- tests/authorization_tests.move -+++ tests/authorization_tests.move -@@ -17 +17 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -22 +22 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -32 +32 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -37 +37 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -52 +52 @@ -- #[test, expected_failure(abort_code=coupons::coupons::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code=::coupons::coupons::EAppNotAuthorized)] -@@ -54 +54 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -58 +58 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); ---- tests/coupons_tests.move -+++ tests/coupons_tests.move -@@ -22 +22 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -33 +33 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -60 +60 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -80 +80 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidYears)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidYears)] -@@ -90 +90 @@ -- #[test, expected_failure(abort_code=coupons::range::EInvalidRange)] -+ #[test, expected_failure(abort_code=::coupons::range::EInvalidRange)] -@@ -103 +103 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -108 +108 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -117 +117 @@ -- #[test, expected_failure(abort_code=coupons::coupons::EIncorrectAmount)] -+ #[test, expected_failure(abort_code=::coupons::coupons::EIncorrectAmount)] -@@ -119 +119 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -127 +127 @@ -- #[test, expected_failure(abort_code=coupons::coupons::ECouponNotExists)] -+ #[test, expected_failure(abort_code=::coupons::coupons::ECouponNotExists)] -@@ -129 +129 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -136 +136 @@ -- #[test, expected_failure(abort_code=coupons::coupons::EInvalidYearsArgument)] -+ #[test, expected_failure(abort_code=::coupons::coupons::EInvalidYearsArgument)] -@@ -138 +138 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -144 +144 @@ -- #[test, expected_failure(abort_code=coupons::coupons::EInvalidYearsArgument)] -+ #[test, expected_failure(abort_code=::coupons::coupons::EInvalidYearsArgument)] -@@ -146 +146 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -153 +153 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidUser)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidUser)] -@@ -155 +155 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -162 +162 @@ -- #[test, expected_failure(abort_code=coupons::rules::ECouponExpired)] -+ #[test, expected_failure(abort_code=::coupons::rules::ECouponExpired)] -@@ -164 +164 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -171 +171 @@ -- #[test, expected_failure(abort_code=coupons::rules::ENotValidYears)] -+ #[test, expected_failure(abort_code=::coupons::rules::ENotValidYears)] -@@ -173 +173 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -180 +180 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] -@@ -182 +182 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -189 +189 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] -@@ -191 +191 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -199 +199 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidForDomainLength)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidForDomainLength)] -@@ -201 +201 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -211 +211 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -221 +221 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidType)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidType)] -@@ -223 +223 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -230 +230 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidAmount)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidAmount)] -@@ -232 +232 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -238 +238 @@ -- #[test, expected_failure(abort_code=coupons::rules::EInvalidAmount)] -+ #[test, expected_failure(abort_code=::coupons::rules::EInvalidAmount)] -@@ -240 +240 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); -@@ -247 +247 @@ -- #[test, expected_failure(abort_code=coupons::coupons::ECouponAlreadyExists)] -+ #[test, expected_failure(abort_code=::coupons::coupons::ECouponAlreadyExists)] -@@ -249 +249 @@ -- let scenario_val = setup::test_init(); -+ let mut scenario_val = setup::test_init(); ---- tests/setup.move -+++ tests/setup.move -@@ -21 +21 @@ -- struct TestApp has drop {} -+ public struct TestApp has drop {} -@@ -23 +23 @@ -- struct UnauthorizedTestApp has drop {} -+ public struct UnauthorizedTestApp has drop {} -@@ -35 +35 @@ -- let scenario_val = test_scenario::begin(ADMIN_ADDRESS); -+ let mut scenario_val = test_scenario::begin(ADMIN_ADDRESS); -@@ -38 +38 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -48 +48 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -52 +52 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -196 +196 @@ -- public fun admin_add_coupon(code_name: String, type: u8, value: u64, scenario: &mut Scenario) { -+ public fun admin_add_coupon(code_name: String, `type`: u8, value: u64, scenario: &mut Scenario) { -@@ -198 +198 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -204 +204 @@ -- type, -+ `type`, -@@ -215 +215 @@ -- let coupon_house = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -@@ -234 +234 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -236,2 +236,2 @@ -- let coupon_house = test_scenario::take_shared(scenario); -- let suins = test_scenario::take_shared(scenario); -+ let mut coupon_house = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); diff --git a/packages/day_one/migration.patch b/packages/day_one/migration.patch deleted file mode 100644 index 84a3f05d..00000000 --- a/packages/day_one/migration.patch +++ /dev/null @@ -1,131 +0,0 @@ ---- sources/bogo.move -+++ sources/bogo.move -@@ -25 +25 @@ -- struct BogoApp has drop {} -+ public struct BogoApp has drop {} -@@ -29 +29 @@ -- struct UsedInDayOnePromo has copy, store, drop { } -+ public struct UsedInDayOnePromo has copy, store, drop { } -@@ -84 +84 @@ -- let nft = registry::add_record(registry, new_domain, DEFAULT_DURATION, clock, ctx); -+ let mut nft = registry::add_record(registry, new_domain, DEFAULT_DURATION, clock, ctx); ---- sources/day_one.move -+++ sources/day_one.move -@@ -20 +20 @@ -- friend day_one::bogo; -+ /* friend day_one::bogo; */ -@@ -23 +23 @@ -- struct DropList has key { -+ public struct DropList has key { -@@ -30 +30 @@ -- struct SetupCap has key { id: UID } -+ public struct SetupCap has key { id: UID } -@@ -40 +40 @@ -- struct DAY_ONE has drop {} -+ public struct DAY_ONE has drop {} -@@ -55 +55 @@ -- struct DayOne has key, store { -+ public struct DayOne has key, store { -@@ -66 +66 @@ -- recipients: vector
, -+ mut recipients: vector
, -@@ -77 +77 @@ -- let i: u32 = self.total_minted; -+ let mut i: u32 = self.total_minted; -@@ -99 +99 @@ -- hashes: vector
, -+ mut hashes: vector
, -@@ -117 +117 @@ -- public(friend) fun activate(self: &mut DayOne) { -+ public(package) fun activate(self: &mut DayOne) { ---- tests/day_one_tests.move -+++ tests/day_one_tests.move -@@ -22 +22 @@ -- let scenario_val = test_scenario::begin(SUINS_ADDRESS); -+ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); -@@ -25 +25 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -34 +34 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -47 +47 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -51,2 +51,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (mut domain1, mut domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -77 +77 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -81,2 +81,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -99 +99 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -103,2 +103,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -106 +106 @@ -- let new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); -+ let mut new_name_1 = bogo::claim(&mut day_one, &mut suins, &mut domain1, utf8(b"wow.sui"), &clock, ctx(scenario)); -@@ -124 +124 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -128,2 +128,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -146 +146 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -149,3 +149,3 @@ -- let clock = test_scenario::take_shared(scenario); -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -+ let (domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -156 +156 @@ -- let fresh_domain = new_domain(utf8(b"exp.sui"), 1, &clock, ctx(scenario)); -+ let mut fresh_domain = new_domain(utf8(b"exp.sui"), 1, &clock, ctx(scenario)); -@@ -174 +174 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -178,2 +178,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (domain1, mut domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -197 +197 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -201,2 +201,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (domain1, domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -220 +220 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -224,2 +224,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (mut domain1, domain2, domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -242 +242 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -246,2 +246,2 @@ -- let (domain1, domain2, domain3, day_one) = prepare(ctx(scenario), &clock); -- let suins = test_scenario::take_shared(scenario); -+ let (domain1, domain2, mut domain3, mut day_one) = prepare(ctx(scenario), &clock); -+ let mut suins = test_scenario::take_shared(scenario); diff --git a/packages/denylist/migration.patch b/packages/denylist/migration.patch deleted file mode 100644 index f5ef5c99..00000000 --- a/packages/denylist/migration.patch +++ /dev/null @@ -1,64 +0,0 @@ ---- sources/denylist.move -+++ sources/denylist.move -@@ -17 +17 @@ -- struct Denylist has store { -+ public struct Denylist has store { -@@ -27 +27 @@ -- struct DenyListAuth has drop {} -+ public struct DenyListAuth has drop {} -@@ -80 +80 @@ -- let i = vector::length(&words); -+ let mut i = vector::length(&words); -@@ -93 +93 @@ -- let i = vector::length(&words); -+ let mut i = vector::length(&words); ---- tests/denylist_tests.move -+++ tests/denylist_tests.move -@@ -18 +18 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -22 +22 @@ -- let suins = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -@@ -44 +44 @@ -- #[test, expected_failure(abort_code = denylist::denylist::ENoWordsInList)] -+ #[test, expected_failure(abort_code = ::denylist::denylist::ENoWordsInList)] -@@ -46 +46 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -50 +50 @@ -- let suins = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -@@ -59 +59 @@ -- #[test, expected_failure(abort_code = denylist::denylist::ENoWordsInList)] -+ #[test, expected_failure(abort_code = ::denylist::denylist::ENoWordsInList)] -@@ -61 +61 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -65 +65 @@ -- let suins = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -@@ -75 +75 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -79 +79 @@ -- let suins = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -@@ -98 +98 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -102 +102 @@ -- let suins = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -@@ -124 +124 @@ -- let scenario = ts::begin(ADDR); -+ let mut scenario = ts::begin(ADDR); -@@ -128 +128 @@ -- let (suins, cap) = suins::new_for_testing(ctx(&mut scenario)); -+ let (mut suins, cap) = suins::new_for_testing(ctx(&mut scenario)); -@@ -143 +143 @@ -- let vec: vector = vector::empty(); -+ let mut vec: vector = vector::empty(); -@@ -152 +152 @@ -- let vec: vector = vector::empty(); -+ let mut vec: vector = vector::empty(); diff --git a/packages/discounts/migration.patch b/packages/discounts/migration.patch deleted file mode 100644 index e2796b31..00000000 --- a/packages/discounts/migration.patch +++ /dev/null @@ -1,172 +0,0 @@ ---- sources/discounts.move -+++ sources/discounts.move -@@ -13 +13 @@ -- use std::type_name::{Self as type}; -+ use std::type_name::{Self as `type`}; -@@ -42 +42 @@ -- struct DiscountKey has copy, store, drop {} -+ public struct DiscountKey has copy, store, drop {} -@@ -46 +46 @@ -- struct DiscountConfig has copy, store, drop { -+ public struct DiscountConfig has copy, store, drop { -@@ -65 +65 @@ -- assert!(type::into_string(type::get()) != type::into_string(type::get()), ENotValidForDayOne); -+ assert!(`type`::into_string(`type`::get()) != `type`::into_string(`type`::get()), ENotValidForDayOne); ---- sources/free_claims.move -+++ sources/free_claims.move -@@ -16 +16 @@ -- use std::type_name::{Self as type}; -+ use std::type_name::{Self as `type`}; -@@ -47 +47 @@ -- struct FreeClaimsApp has drop {} -+ public struct FreeClaimsApp has drop {} -@@ -50 +50 @@ -- struct FreeClaimsKey has copy, store, drop {} -+ public struct FreeClaimsKey has copy, store, drop {} -@@ -55 +55 @@ -- struct FreeClaimsConfig has store { -+ public struct FreeClaimsConfig has store { -@@ -71 +71 @@ -- assert!(type::into_string(type::get()) != type::into_string(type::get()), ENotValidForDayOne); -+ assert!(`type`::into_string(`type`::get()) != `type`::into_string(`type`::get()), ENotValidForDayOne); -@@ -148 +148 @@ -- let FreeClaimsConfig { used_objects, domain_length_range: _ } = df::remove, FreeClaimsConfig>(house::uid_mut(self), FreeClaimsKey{}); -+ let FreeClaimsConfig { mut used_objects, domain_length_range: _ } = df::remove, FreeClaimsConfig>(house::uid_mut(self), FreeClaimsKey{}); ---- sources/house.move -+++ sources/house.move -@@ -20 +20 @@ -- friend discounts::free_claims; -+ /* friend discounts::free_claims; */ -@@ -22 +22 @@ -- friend discounts::discounts; -+ /* friend discounts::discounts; */ -@@ -34 +34 @@ -- struct DiscountHouseApp has drop {} -+ public struct DiscountHouseApp has drop {} -@@ -37 +37 @@ -- struct DiscountHouse has key, store { -+ public struct DiscountHouse has key, store { -@@ -64 +64 @@ -- public(friend) fun friend_add_registry_entry( -+ public(package) fun friend_add_registry_entry( -@@ -82 +82 @@ -- public(friend) fun uid_mut(self: &mut DiscountHouse): &mut UID { -+ public(package) fun uid_mut(self: &mut DiscountHouse): &mut UID { -@@ -87 +87 @@ -- public(friend) fun suins_app_auth(): DiscountHouseApp { -+ public(package) fun suins_app_auth(): DiscountHouseApp { ---- tests/discount_tests.move -+++ tests/discount_tests.move -@@ -24 +24 @@ -- struct TestAuthorized has copy, store, drop {} -+ public struct TestAuthorized has copy, store, drop {} -@@ -27 +27 @@ -- struct AnotherAuthorized has copy, store, drop {} -+ public struct AnotherAuthorized has copy, store, drop {} -@@ -30 +30 @@ -- struct TestUnauthorized has copy, store, drop {} -+ public struct TestUnauthorized has copy, store, drop {} -@@ -38 +38 @@ -- let scenario_val = ts::begin(SUINS_ADDRESS); -+ let mut scenario_val = ts::begin(SUINS_ADDRESS); -@@ -41 +41 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -51,2 +51,2 @@ -- let suins = ts::take_shared(scenario); -- let discount_house = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -77,2 +77,2 @@ -- let suins = ts::take_shared(scenario); -- let discount_house = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -98,2 +98,2 @@ -- let suins = ts::take_shared(scenario); -- let discount_house = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -113 +113 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -130 +130 @@ -- #[test, expected_failure(abort_code = discounts::discounts::EConfigNotExists)] -+ #[test, expected_failure(abort_code = ::discounts::discounts::EConfigNotExists)] -@@ -132 +132 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -150 +150 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -153 +153 @@ -- let day_one = day_one::mint_for_testing(ctx(scenario)); -+ let mut day_one = day_one::mint_for_testing(ctx(scenario)); -@@ -169 +169 @@ -- #[test, expected_failure(abort_code = discounts::discounts::ENotValidForDayOne)] -+ #[test, expected_failure(abort_code = ::discounts::discounts::ENotValidForDayOne)] -@@ -171 +171 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -174 +174 @@ -- let day_one = day_one::mint_for_testing(ctx(scenario)); -+ let mut day_one = day_one::mint_for_testing(ctx(scenario)); -@@ -190 +190 @@ -- #[test, expected_failure(abort_code = discounts::discounts::ENotActiveDayOne)] -+ #[test, expected_failure(abort_code = ::discounts::discounts::ENotActiveDayOne)] -@@ -192 +192 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); ---- tests/free_claims_test.move -+++ tests/free_claims_test.move -@@ -23 +23 @@ -- struct TestAuthorized has key, store { id: UID } -+ public struct TestAuthorized has key, store { id: UID } -@@ -26 +26 @@ -- struct TestUnauthorized has key { id: UID } -+ public struct TestUnauthorized has key { id: UID } -@@ -32 +32 @@ -- let scenario_val = ts::begin(SUINS_ADDRESS); -+ let mut scenario_val = ts::begin(SUINS_ADDRESS); -@@ -35 +35 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -45,2 +45,2 @@ -- let suins = ts::take_shared(scenario); -- let discount_house = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -60 +60 @@ -- fun test_end(scenario_val: Scenario) { -+ fun test_end(mut scenario_val: Scenario) { -@@ -65 +65 @@ -- let discount_house = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -87,2 +87,2 @@ -- let suins = ts::take_shared(scenario); -- let discount_house = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -107,2 +107,2 @@ -- let suins = ts::take_shared(scenario); -- let discount_house = ts::take_shared(scenario); -+ let mut suins = ts::take_shared(scenario); -+ let mut discount_house = ts::take_shared(scenario); -@@ -122 +122 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -142 +142 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -145 +145 @@ -- let day_one = day_one::mint_for_testing(ctx(scenario)); -+ let mut day_one = day_one::mint_for_testing(ctx(scenario)); -@@ -161 +161 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -189 +189 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -209 +209 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); diff --git a/packages/managed_names/Move.toml b/packages/managed_names/Move.toml index ccbef6df..29624359 100644 --- a/packages/managed_names/Move.toml +++ b/packages/managed_names/Move.toml @@ -1,6 +1,7 @@ [package] name = "managed_names" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override=true } diff --git a/packages/managed_names/sources/managed.move b/packages/managed_names/sources/managed.move index 94aedbfb..5784d740 100644 --- a/packages/managed_names/sources/managed.move +++ b/packages/managed_names/sources/managed.move @@ -42,13 +42,13 @@ module managed_names::managed { const EInvalidReturnedNFT: u64 = 5; /// Authorizes the `ManagedNames` to add a `registry` under the main SuiNS object. - struct ManagedNamesApp has drop {} + public struct ManagedNamesApp has drop {} /// The `registry` that holds the managed names per domain. /// To simplify, we can only hold a single managed name per domain. /// If a valid NFT is passed, the previous name is returned to the owner (who can burn it, as it's an expired one). - struct ManagedNames has store { + public struct ManagedNames has store { names: Table } @@ -56,14 +56,14 @@ module managed_names::managed { /// `owner`: the only address that can get the `NFT` back /// `allowlist`: A list of allowed addresses (that can borrow + return the `NFT`) /// `nft`: The `SuinsRegistration` object that can be borrowed. - struct ManagedName has store { + public struct ManagedName has store { owner: address, allowed_addresses: vector
, nft: Option } /// A hot-potato promise that the NFT will be returned upon borrowing. - struct ReturnPromise { + public struct ReturnPromise { id: ID } @@ -134,7 +134,7 @@ module managed_names::managed { public fun allow_addresses( suins: &mut SuiNS, name: String, - addresses: vector
, + mut addresses: vector
, ctx: &mut TxContext ) { let existing = internal_get_managed_name(managed_names_mut(suins), domain::new(name)); @@ -153,7 +153,7 @@ module managed_names::managed { public fun revoke_addresses( suins: &mut SuiNS, name: String, - addresses: vector
, + mut addresses: vector
, ctx: &mut TxContext ) { let existing = internal_get_managed_name(managed_names_mut(suins), domain::new(name)); diff --git a/packages/managed_names/tests/managed_tests.move b/packages/managed_names/tests/managed_tests.move index cfcd5690..279367c4 100644 --- a/packages/managed_names/tests/managed_tests.move +++ b/packages/managed_names/tests/managed_tests.move @@ -22,7 +22,7 @@ module managed_names::managed_tests { #[test] fun e2e() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -43,7 +43,7 @@ module managed_names::managed_tests { #[test] fun deattach_expired_to_attach_non_expired() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -66,7 +66,7 @@ module managed_names::managed_tests { // the original `owner` should have received back the expired NFT. { ts::next_tx(scenario, USER); - let nft_transferred_back = ts::most_recent_id_for_address(USER); + let mut nft_transferred_back = ts::most_recent_id_for_address(USER); assert!(option::is_some(&nft_transferred_back), 0); assert!(option::extract(&mut nft_transferred_back) == id, 0); @@ -80,7 +80,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::EExpiredNFT)] fun attach_expired_failure() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -95,7 +95,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENameNotExists)] fun borrow_non_existing_name_failure() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -105,7 +105,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::EInvalidReturnedNFT)] fun borrow_and_return_different_nft() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -123,7 +123,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENotAuthorized)] fun try_to_borrow_as_unauthorized_user() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -137,7 +137,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENotAuthorized)] fun try_to_remove_not_being_owner_but_being_authorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -152,7 +152,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENotAuthorized)] fun try_to_remove_not_being_owner_not_authorized() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -167,7 +167,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENotAuthorized)] fun remove_from_authorized_and_fail_to_borrow() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -186,7 +186,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENotAuthorized)] fun revoke_addresses_as_non_owner() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -200,7 +200,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENotAuthorized)] fun add_addresses_as_non_owner() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -214,7 +214,7 @@ module managed_names::managed_tests { #[test, expected_failure(abort_code=managed_names::managed::ENameNotExists)] fun remove_name_that_does_not_exist() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let domain_name = utf8(b"example.sui"); @@ -226,7 +226,7 @@ module managed_names::managed_tests { /// == Helpers == /// public fun test_init(): (Scenario) { - let scenario = ts::begin(USER); + let mut scenario = ts::begin(USER); { ts::next_tx(&mut scenario, USER); @@ -234,7 +234,7 @@ module managed_names::managed_tests { let clock = clock::create_for_testing(ctx(&mut scenario)); clock::share_for_testing(clock); - let (suins, cap) = suins::new_for_testing(ctx(&mut scenario)); + let (mut suins, cap) = suins::new_for_testing(ctx(&mut scenario)); suins::authorize_app_for_testing(&mut suins); @@ -249,7 +249,7 @@ module managed_names::managed_tests { public fun attach_name(nft: SuinsRegistration, addresses: vector
, addr: address, scenario: &mut Scenario) { ts::next_tx(scenario, addr); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); managed::attach_managed_name(&mut suins, nft, &clock, addresses, ctx(scenario)); @@ -260,7 +260,7 @@ module managed_names::managed_tests { public fun remove_attached_name(domain_name: String, addr: address, scenario: &mut Scenario): SuinsRegistration { ts::next_tx(scenario, addr); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let nft = managed::remove_attached_name(&mut suins, domain_name, ctx(scenario)); @@ -270,7 +270,7 @@ module managed_names::managed_tests { public fun add_or_remove_addresses(name: String, addresses: vector
, add: bool, addr: address, scenario: &mut Scenario) { ts::next_tx(scenario, addr); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); if(add){ @@ -285,7 +285,7 @@ module managed_names::managed_tests { public fun simulate_borrow(domain_name: String, addr: address, scenario: &mut Scenario): (SuinsRegistration, ReturnPromise) { ts::next_tx(scenario, addr); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let (name, promise) = managed::borrow_val(&mut suins, domain_name, ctx(scenario)); @@ -298,7 +298,7 @@ module managed_names::managed_tests { public fun simulate_return(nft: SuinsRegistration, promise: ReturnPromise, scenario: &mut Scenario) { ts::next_tx(scenario, USER); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); managed::return_val(&mut suins, nft, promise); @@ -314,7 +314,7 @@ module managed_names::managed_tests { public fun advance_clock_post_expiration_of_nft(nft: &SuinsRegistration, scenario: &mut Scenario) { ts::next_tx(scenario, USER); - let clock = ts::take_shared(scenario); + let mut clock = ts::take_shared(scenario); // expire name clock::increment_for_testing(&mut clock, suins_registration::expiration_timestamp_ms(nft) + 1); ts::return_shared(clock); diff --git a/packages/registration/migration.patch b/packages/registration/migration.patch deleted file mode 100644 index 6422dae7..00000000 --- a/packages/registration/migration.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- sources/register.move -+++ sources/register.move -@@ -24 +24 @@ -- struct Register has drop {} -+ public struct Register has drop {} ---- tests/register_tests.move -+++ tests/register_tests.move -@@ -30 +30 @@ -- let scenario_val = test_scenario::begin(SUINS_ADDRESS); -+ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); -@@ -33 +33 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -43 +43 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -61 +61 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -63 +63 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -77 +77 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -94 +94 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -120 +120 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -131 +131 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -142 +142 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -153 +153 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -164 +164 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -175 +175 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -204 +204 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -221 +221 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -232 +232 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -243 +243 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -254 +254 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -265 +265 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -276 +276 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -289 +289 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -308 +308 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -310 +310 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); diff --git a/packages/renewal/migration.patch b/packages/renewal/migration.patch deleted file mode 100644 index 5e005e69..00000000 --- a/packages/renewal/migration.patch +++ /dev/null @@ -1,90 +0,0 @@ ---- sources/renew.move -+++ sources/renew.move -@@ -41 +41 @@ -- struct Renew has drop {} -+ public struct Renew has drop {} -@@ -44 +44 @@ -- struct NameRenewed has copy, drop { -+ public struct NameRenewed has copy, drop { -@@ -50 +50 @@ -- struct RenewalConfig has store, drop { -+ public struct RenewalConfig has store, drop { ---- tests/renew_tests.move -+++ tests/renew_tests.move -@@ -28,2 +28,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, nft) = prepare_registry(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, mut nft) = prepare_registry(&mut ctx); -@@ -31 +31 @@ -- let clock = clock::create_for_testing(&mut ctx); -+ let mut clock = clock::create_for_testing(&mut ctx); -@@ -46 +46 @@ -- #[test, expected_failure(abort_code= renewal::renew::EMoreThanSixYears)] -+ #[test, expected_failure(abort_code= ::renewal::renew::EMoreThanSixYears)] -@@ -48,2 +48,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, nft) = prepare_registry(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, mut nft) = prepare_registry(&mut ctx); -@@ -58 +58 @@ -- #[test, expected_failure(abort_code= renewal::renew::EInvalidYearsArgument)] -+ #[test, expected_failure(abort_code= ::renewal::renew::EInvalidYearsArgument)] -@@ -60,2 +60,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, nft) = prepare_registry(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, mut nft) = prepare_registry(&mut ctx); -@@ -70 +70 @@ -- #[test, expected_failure(abort_code= renewal::renew::ERecordNftIDMismatch)] -+ #[test, expected_failure(abort_code= ::renewal::renew::ERecordNftIDMismatch)] -@@ -72,2 +72,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, _nft) = prepare_registry(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, _nft) = prepare_registry(&mut ctx); -@@ -75 +75 @@ -- let nft = nft::new_for_testing(domain::new(utf8(DOMAIN_NAME)), 1, &clock, &mut ctx); -+ let mut nft = nft::new_for_testing(domain::new(utf8(DOMAIN_NAME)), 1, &clock, &mut ctx); -@@ -81 +81 @@ -- #[test, expected_failure(abort_code= renewal::renew::ERecordNotFound)] -+ #[test, expected_failure(abort_code= ::renewal::renew::ERecordNotFound)] -@@ -83,2 +83,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, _nft) = prepare_registry(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, _nft) = prepare_registry(&mut ctx); -@@ -86 +86 @@ -- let nft = nft::new_for_testing(domain::new(utf8(b"hehehe.sui")), 1, &clock, &mut ctx); -+ let mut nft = nft::new_for_testing(domain::new(utf8(b"hehehe.sui")), 1, &clock, &mut ctx); -@@ -92 +92 @@ -- #[test, expected_failure(abort_code= renewal::renew::ERecordExpired)] -+ #[test, expected_failure(abort_code= ::renewal::renew::ERecordExpired)] -@@ -94,3 +94,3 @@ -- let ctx = tx_context::dummy(); -- let (suins, nft) = prepare_registry(&mut ctx); -- let clock = clock::create_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, mut nft) = prepare_registry(&mut ctx); -+ let mut clock = clock::create_for_testing(&mut ctx); -@@ -104 +104 @@ -- #[test, expected_failure(abort_code= renewal::renew::EIncorrectAmount)] -+ #[test, expected_failure(abort_code= ::renewal::renew::EIncorrectAmount)] -@@ -106,2 +106,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, nft) = prepare_registry(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, mut nft) = prepare_registry(&mut ctx); -@@ -122,2 +122,2 @@ -- let suins = suins::init_for_testing(ctx); -- let registry = registry::new_for_testing(ctx); -+ let mut suins = suins::init_for_testing(ctx); -+ let mut registry = registry::new_for_testing(ctx); -@@ -138 +138 @@ -- 1200 * suins::constants::mist_per_sui(), -+ 1200 * ::suins::constants::mist_per_sui(), -@@ -140,2 +140,2 @@ -- 200 * suins::constants::mist_per_sui(), -- REGULAR_PRICE * suins::constants::mist_per_sui(), -+ 200 * ::suins::constants::mist_per_sui(), -+ REGULAR_PRICE * ::suins::constants::mist_per_sui(), diff --git a/packages/subdomains/Move.toml b/packages/subdomains/Move.toml index ba2e48c4..c35e4730 100644 --- a/packages/subdomains/Move.toml +++ b/packages/subdomains/Move.toml @@ -1,6 +1,7 @@ [package] name = "subdomains" version = "0.0.1" +edition = "2024.beta" #mainnet #published-at="TODO: Fill this in once published" diff --git a/packages/subdomains/sources/config.move b/packages/subdomains/sources/config.move index c428eda9..702b75f0 100644 --- a/packages/subdomains/sources/config.move +++ b/packages/subdomains/sources/config.move @@ -26,7 +26,7 @@ module subdomains::config { /// A Subdomain configuration object. /// Holds the allow-listed tlds, the max depth and the minimum label size. - struct SubDomainConfig has copy, store, drop { + public struct SubDomainConfig has copy, store, drop { allowed_tlds: vector, max_depth: u8, min_label_size: u8, @@ -79,7 +79,7 @@ module subdomains::config { /// want to add support for others (or not allow). /// (E.g., with `.move` service, we might want to restrict how subdomains are created) public fun is_valid_tld(domain: &Domain, config: &SubDomainConfig): bool { - let i=0; + let mut i=0; while (i < vector::length(&config.allowed_tlds)) { if (domain::tld(domain) == vector::borrow(&config.allowed_tlds, i)) { return true diff --git a/packages/subdomains/sources/subdomains.move b/packages/subdomains/sources/subdomains.move index 3f71c5a8..bddb2295 100644 --- a/packages/subdomains/sources/subdomains.move +++ b/packages/subdomains/sources/subdomains.move @@ -63,13 +63,13 @@ module subdomains::subdomains { const ACTIVE_METADATA_VALUE: vector = b"1"; /// The authentication scheme for SuiNS. - struct SubDomains has drop {} + public struct SubDomains has drop {} /// The key to store the parent's ID in the subdomain object. - struct ParentKey has copy, store, drop {} + public struct ParentKey has copy, store, drop {} /// The subdomain's config (specifies allowed TLDs, depth, sizes). - struct App has store { + public struct App has store { config: SubDomainConfig } @@ -253,7 +253,7 @@ module subdomains::subdomains { key: String, enable: bool ) { - let config = record_metadata(self, subdomain); + let mut config = record_metadata(self, subdomain); let is_enabled = vec_map::contains(&config, &key); if (enable && !is_enabled) { @@ -341,7 +341,7 @@ module subdomains::subdomains { clock: &Clock, ctx: &mut TxContext, ): SubDomainRegistration { - let nft = registry::add_record_ignoring_grace_period(registry, subdomain, 1, clock, ctx); + let mut nft = registry::add_record_ignoring_grace_period(registry, subdomain, 1, clock, ctx); // set the timestamp to the correct one. `add_record` only works with years but we can correct it easily here. registry::set_expiration_timestamp_ms(registry, &mut nft, subdomain, expiration_timestamp_ms); diff --git a/packages/subdomains/tests/subdomain_tests.move b/packages/subdomains/tests/subdomain_tests.move index 82ec575e..08685260 100644 --- a/packages/subdomains/tests/subdomain_tests.move +++ b/packages/subdomains/tests/subdomain_tests.move @@ -30,12 +30,12 @@ module subdomains::subdomain_tests { /// A test scenario fun test_multiple_operation_cases() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); - let child = create_node_subdomain(&parent, utf8(b"node.test.sui"), MIN_SUBDOMAIN_DURATION, true, true, scenario); + let mut child = create_node_subdomain(&parent, utf8(b"node.test.sui"), MIN_SUBDOMAIN_DURATION, true, true, scenario); create_leaf_subdomain(&parent, utf8(b"leaf.test.sui"), TEST_ADDRESS, scenario); remove_leaf_subdomain(&parent, utf8(b"leaf.test.sui"), scenario); @@ -61,9 +61,9 @@ module subdomains::subdomain_tests { ts::end(scenario_val); } - #[test, expected_failure(abort_code=subdomains::subdomains::EInvalidExpirationDate)] + #[test, expected_failure(abort_code=::subdomains::subdomains::EInvalidExpirationDate)] fun expiration_past_parents_expiration() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); @@ -72,10 +72,10 @@ module subdomains::subdomain_tests { abort 1337 } - #[test, expected_failure(abort_code=subdomains::config::EInvalidParent)] + #[test, expected_failure(abort_code=::subdomains::config::EInvalidParent)] /// tries to create a child node using an invalid parent. fun invalid_parent_failure(){ - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); @@ -85,9 +85,9 @@ module subdomains::subdomain_tests { } - #[test, expected_failure(abort_code=subdomains::subdomains::ECreationDisabledForSubDomain)] + #[test, expected_failure(abort_code=::subdomains::subdomains::ECreationDisabledForSubDomain)] fun tries_to_create_subdomain_with_disallowed_node_parent() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); @@ -99,27 +99,27 @@ module subdomains::subdomain_tests { abort 1337 } - #[test, expected_failure(abort_code=subdomains::subdomains::EExtensionDisabledForSubDomain)] + #[test, expected_failure(abort_code=::subdomains::subdomains::EExtensionDisabledForSubDomain)] fun tries_to_extend_without_permissions() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); - let child = create_node_subdomain(&parent, utf8(b"node.test.sui"), MIN_SUBDOMAIN_DURATION, false, false, scenario); + let mut child = create_node_subdomain(&parent, utf8(b"node.test.sui"), MIN_SUBDOMAIN_DURATION, false, false, scenario); extend_node_subdomain(&mut child, 2, scenario); abort 1337 } - #[test, expected_failure(abort_code=subdomains::subdomains::EParentChanged)] + #[test, expected_failure(abort_code=::subdomains::subdomains::EParentChanged)] fun tries_to_extend_while_parent_changed() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); // child is an expired name ofc. - let child = create_node_subdomain(&parent, utf8(b"node.test.sui"), MIN_SUBDOMAIN_DURATION, true, true, scenario); + let mut child = create_node_subdomain(&parent, utf8(b"node.test.sui"), MIN_SUBDOMAIN_DURATION, true, true, scenario); increment_clock(suins_registration::expiration_timestamp_ms(&parent) +grace_period_ms() + 1 , scenario); @@ -131,9 +131,9 @@ module subdomains::subdomain_tests { abort 1337 } - #[test, expected_failure(abort_code=suins::registry::ERecordExpired)] + #[test, expected_failure(abort_code=::suins::registry::ERecordExpired)] fun tries_to_use_expired_subdomain_to_create_new() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); @@ -145,9 +145,9 @@ module subdomains::subdomain_tests { abort 1337 } - #[test, expected_failure(abort_code=subdomains::subdomains::EInvalidExpirationDate)] + #[test, expected_failure(abort_code=::subdomains::subdomains::EInvalidExpirationDate)] fun tries_to_create_too_short_subdomain() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); @@ -156,9 +156,9 @@ module subdomains::subdomain_tests { abort 1337 } - #[test, expected_failure(abort_code=subdomains::config::EInvalidParent)] + #[test, expected_failure(abort_code=::subdomains::config::EInvalidParent)] fun tries_to_created_nested_leaf_subdomain() { - let scenario_val = test_init(); + let mut scenario_val = test_init(); let scenario = &mut scenario_val; let parent = create_sld_name(utf8(b"test.sui"), scenario); create_leaf_subdomain(&parent, utf8(b"node.node.test.sui"), TEST_ADDRESS, scenario); @@ -171,10 +171,10 @@ module subdomains::subdomain_tests { // == Helpers == public fun test_init(): Scenario { - let scenario_val = ts::begin(USER_ADDRESS); + let mut scenario_val = ts::begin(USER_ADDRESS); let scenario = &mut scenario_val; { - let suins = suins::init_for_testing(ctx(scenario)); + let mut suins = suins::init_for_testing(ctx(scenario)); suins::authorize_app_for_testing(&mut suins); suins::share_for_testing(suins); let clock = clock::create_for_testing(ctx(scenario)); @@ -183,7 +183,7 @@ module subdomains::subdomain_tests { { ts::next_tx(scenario, USER_ADDRESS); let admin_cap = ts::take_from_sender(scenario); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); subdomains::setup(&mut suins, &admin_cap, ctx(scenario)); registry::init_for_testing(&admin_cap, &mut suins, ctx(scenario)); @@ -206,7 +206,7 @@ module subdomains::subdomain_tests { /// Create a regular name to help with our tests. public fun create_sld_name(name: String, scenario: &mut Scenario): SuinsRegistration { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); let registry_mut = registry_mut(&mut suins); @@ -220,7 +220,7 @@ module subdomains::subdomain_tests { /// Create a leaf subdomain public fun create_leaf_subdomain(parent: &SuinsRegistration, name: String, target: address, scenario: &mut Scenario) { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); subdomains::new_leaf(&mut suins, parent, &clock, name, target, ctx(scenario)); @@ -232,7 +232,7 @@ module subdomains::subdomain_tests { /// Remove a leaf subdomain public fun remove_leaf_subdomain(parent: &SuinsRegistration, name: String, scenario: &mut Scenario) { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); subdomains::remove_leaf(&mut suins, parent, &clock, name); @@ -244,7 +244,7 @@ module subdomains::subdomain_tests { /// Create a node subdomain public fun create_node_subdomain(parent: &SuinsRegistration, name: String, expiration: u64, allow_creation: bool, allow_extension: bool, scenario: &mut Scenario): SubDomainRegistration { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); let nft = subdomains::new(&mut suins, parent, &clock, name, expiration, allow_creation, allow_extension, ctx(scenario)); @@ -258,7 +258,7 @@ module subdomains::subdomain_tests { /// Extend a node subdomain's expiration. public fun extend_node_subdomain(nft: &mut SubDomainRegistration, expiration: u64, scenario: &mut Scenario) { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); subdomains::extend_expiration(&mut suins, nft, expiration); @@ -269,7 +269,7 @@ module subdomains::subdomain_tests { public fun update_subdomain_setup(parent: &SuinsRegistration, subdomain: String, allow_creation: bool, allow_extension: bool, scenario: &mut Scenario) { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); @@ -282,7 +282,7 @@ module subdomains::subdomain_tests { public fun burn_subdomain(nft: SubDomainRegistration, scenario: &mut Scenario) { ts::next_tx(scenario, USER_ADDRESS); - let suins = ts::take_shared(scenario); + let mut suins = ts::take_shared(scenario); let clock = ts::take_shared(scenario); subdomains::burn(&mut suins, nft, &clock); @@ -294,7 +294,7 @@ module subdomains::subdomain_tests { public fun increment_clock(to: u64, scenario: &mut Scenario){ ts::next_tx(scenario, USER_ADDRESS); - let clock = ts::take_shared(scenario); + let mut clock = ts::take_shared(scenario); clock::increment_for_testing(&mut clock, to); ts::return_shared(clock); } diff --git a/packages/suins/migration.patch b/packages/suins/migration.patch deleted file mode 100644 index 2033b79c..00000000 --- a/packages/suins/migration.patch +++ /dev/null @@ -1,827 +0,0 @@ ---- sources/actions/update_image.move -+++ sources/actions/update_image.move -@@ -25 +25 @@ -- struct UpdateImage has drop {} -+ public struct UpdateImage has drop {} -@@ -72 +72 @@ -- let bcs = bcs::new(msg_bytes); -+ let mut bcs = bcs::new(msg_bytes); ---- sources/admin.move -+++ sources/admin.move -@@ -19 +19 @@ -- struct Admin has drop {} -+ public struct Admin has drop {} -@@ -47 +47 @@ -- domains: vector, -+ mut domains: vector, ---- sources/auction.move -+++ sources/auction.move -@@ -49 +49 @@ -- struct App has drop {} -+ public struct App has drop {} -@@ -52 +52 @@ -- struct AuctionHouse has key, store { -+ public struct AuctionHouse has key, store { -@@ -59 +59 @@ -- struct Auction has store { -+ public struct Auction has store { -@@ -146 +146 @@ -- end_timestamp_ms, -+ mut end_timestamp_ms, -@@ -364 +364 @@ -- operation_limit: u64, -+ mut operation_limit: u64, -@@ -367 +367 @@ -- let next_domain = *linked_table::back(&self.auctions); -+ let mut next_domain = *linked_table::back(&self.auctions); -@@ -394 +394 @@ -- struct AuctionStartedEvent has copy, drop { -+ public struct AuctionStartedEvent has copy, drop { -@@ -402 +402 @@ -- struct AuctionFinalizedEvent has copy, drop { -+ public struct AuctionFinalizedEvent has copy, drop { -@@ -410 +410 @@ -- struct BidEvent has copy, drop { -+ public struct BidEvent has copy, drop { -@@ -416 +416 @@ -- struct AuctionExtendedEvent has copy, drop { -+ public struct AuctionExtendedEvent has copy, drop { ---- sources/config.move -+++ sources/config.move -@@ -44 +44 @@ -- struct Config has store, drop { -+ public struct Config has store, drop { ---- sources/controller.move -+++ sources/controller.move -@@ -23 +23 @@ -- struct Controller has drop {} -+ public struct Controller has drop {} -@@ -60 +60 @@ -- let data = *registry::get_data(registry, nft::domain(nft)); -+ let mut data = *registry::get_data(registry, nft::domain(nft)); -@@ -80 +80 @@ -- let data = *registry::get_data(registry, nft::domain(nft)); -+ let mut data = *registry::get_data(registry, nft::domain(nft)); ---- sources/domain.move -+++ sources/domain.move -@@ -23 +23 @@ -- struct Domain has copy, drop, store { -+ public struct Domain has copy, drop, store { -@@ -35 +35 @@ -- let labels = split_by_dot(domain); -+ let mut labels = split_by_dot(domain); -@@ -47,2 +47,2 @@ -- let i = 0; -- let out = string::utf8(vector::empty()); -+ let mut i = 0; -+ let mut out = string::utf8(vector::empty()); -@@ -100 +100 @@ -- let labels = domain.labels; -+ let mut labels = domain.labels; -@@ -119 +119 @@ -- let index = 0; -+ let mut index = 0; -@@ -131 +131 @@ -- let index = 0; -+ let mut index = 0; -@@ -155 +155 @@ -- fun split_by_dot(s: String): vector { -+ fun split_by_dot(mut s: String): vector { -@@ -157 +157 @@ -- let parts: vector = vector[]; -+ let mut parts: vector = vector[]; -@@ -191 +191 @@ -- let index = 0; -+ let mut index = 0; -@@ -201,2 +201,2 @@ -- fun prep_expected_labels(labels: vector>): vector { -- let out = vector[]; -+ fun prep_expected_labels(mut labels: vector>): vector { -+ let mut out = vector[]; ---- sources/name_record.move -+++ sources/name_record.move -@@ -19 +19 @@ -- struct NameRecord has copy, store, drop { -+ public struct NameRecord has copy, store, drop { ---- sources/registry.move -+++ sources/registry.move -@@ -43 +43 @@ -- struct Registry has store { -+ public struct Registry has store { ---- sources/subdomain_registration.move -+++ sources/subdomain_registration.move -@@ -19,2 +19,2 @@ -- friend suins::registry; -- #[test_only] friend suins::sub_name_tests; -+ /* friend suins::registry; */ -+ /* #[test_only] */ /* friend suins::sub_name_tests; */ -@@ -32 +32 @@ -- struct SubDomainRegistration has key, store { -+ public struct SubDomainRegistration has key, store { -@@ -39 +39 @@ -- public(friend) fun new(nft: SuinsRegistration, clock: &Clock, ctx: &mut TxContext): SubDomainRegistration { -+ public(package) fun new(nft: SuinsRegistration, clock: &Clock, ctx: &mut TxContext): SubDomainRegistration { -@@ -53 +53 @@ -- public(friend) fun burn(name: SubDomainRegistration, clock: &Clock): SuinsRegistration { -+ public(package) fun burn(name: SubDomainRegistration, clock: &Clock): SuinsRegistration { ---- sources/suins.move -+++ sources/suins.move -@@ -39 +39 @@ -- struct AdminCap has key, store { id: UID } -+ public struct AdminCap has key, store { id: UID } -@@ -47 +47 @@ -- struct SuiNS has key { -+ public struct SuiNS has key { -@@ -55 +55 @@ -- struct SUINS has drop {} -+ public struct SUINS has drop {} -@@ -62 +62 @@ -- struct ConfigKey has copy, store, drop {} -+ public struct ConfigKey has copy, store, drop {} -@@ -69 +69 @@ -- struct RegistryKey has copy, store, drop {} -+ public struct RegistryKey has copy, store, drop {} -@@ -108 +108 @@ -- struct AppKey has copy, store, drop {} -+ public struct AppKey has copy, store, drop {} -@@ -184 +184 @@ -- #[test_only] struct Test has drop {} -+ #[test_only] public struct Test has drop {} -@@ -198 +198 @@ -- let suins = SuiNS { -+ let mut suins = SuiNS { ---- sources/suins_registration.move -+++ sources/suins_registration.move -@@ -22,2 +22,2 @@ -- friend suins::registry; -- friend suins::update_image; -+ /* friend suins::registry; */ -+ /* friend suins::update_image; */ -@@ -26 +26 @@ -- struct SuinsRegistration has key, store { -+ public struct SuinsRegistration has key, store { -@@ -42 +42 @@ -- public(friend) fun new( -+ public(package) fun new( -@@ -58 +58 @@ -- public(friend) fun set_expiration_timestamp_ms(self: &mut SuinsRegistration, expiration_timestamp_ms: u64) { -+ public(package) fun set_expiration_timestamp_ms(self: &mut SuinsRegistration, expiration_timestamp_ms: u64) { -@@ -63 +63 @@ -- public(friend) fun update_image_url(self: &mut SuinsRegistration, image_url: String) { -+ public(package) fun update_image_url(self: &mut SuinsRegistration, image_url: String) { -@@ -70 +70 @@ -- public(friend) fun burn(self: SuinsRegistration) { -+ public(package) fun burn(self: SuinsRegistration) { ---- tests/auction_tests.move -+++ tests/auction_tests.move -@@ -35 +35 @@ -- let scenario_val = test_scenario::begin(SUINS_ADDRESS); -+ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); -@@ -38 +38 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -48 +48 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -65,2 +65,2 @@ -- let auction_house = test_scenario::take_shared(scenario); -- let suins = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -86 +86 @@ -- let auction_house = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -@@ -88 +88 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -104,2 +104,2 @@ -- let auction_house = test_scenario::take_shared(scenario); -- let clock = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -123,2 +123,2 @@ -- let auction_house = test_scenario::take_shared(scenario); -- let clock = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -140,2 +140,2 @@ -- let auction_house = test_scenario::take_shared(scenario); -- let clock = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -154,2 +154,2 @@ -- let auction_house = test_scenario::take_shared(scenario); -- let clock = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -168 +168 @@ -- let auction_house = test_scenario::take_shared(scenario); -+ let mut auction_house = test_scenario::take_shared(scenario); -@@ -180 +180 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -205 +205 @@ -- let (start_ms, end_ms, winner, highest_amount) = auction::get_auction_metadata(&auction_house, domain_name); -+ let (mut start_ms, mut end_ms, mut winner, mut highest_amount) = auction::get_auction_metadata(&auction_house, domain_name); -@@ -256 +256 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -264 +264 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -283 +283 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -299 +299 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -314 +314 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -331 +331 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -364 +364 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -397 +397 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -412 +412 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -428 +428 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -448 +448 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -457 +457 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -470 +470 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -483 +483 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -496 +496 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -509 +509 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -522 +522 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -535 +535 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -543 +543 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -556 +556 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -595 +595 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -607 +607 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -609 +609 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -623 +623 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -662 +662 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -696 +696 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); ---- tests/controller_tests.move -+++ tests/controller_tests.move -@@ -35 +35 @@ -- let scenario_val = test_scenario::begin(SUINS_ADDRESS); -+ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); -@@ -38 +38 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -48 +48 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -65 +65 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -67 +67 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -79 +79 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -88 +88 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -97 +97 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -99 +99 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -111 +111 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -113 +113 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -160 +160 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -170 +170 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -186 +186 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -197 +197 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -209 +209 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -220 +220 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -222 +222 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -234 +234 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -255 +255 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -267 +267 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -278 +278 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -280 +280 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -293 +293 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -306 +306 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -308 +308 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -322 +322 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -333 +333 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -355 +355 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -366 +366 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -377 +377 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -389 +389 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -402 +402 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -404 +404 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -416 +416 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -437 +437 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -448 +448 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -457 +457 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -459 +459 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); ---- tests/register_tests.move -+++ tests/register_tests.move -@@ -30 +30 @@ -- let scenario_val = test_scenario::begin(SUINS_ADDRESS); -+ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); -@@ -33 +33 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -43 +43 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -61 +61 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -63 +63 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -77 +77 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -94 +94 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -120 +120 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -131 +131 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -142 +142 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -153 +153 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -164 +164 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -175 +175 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -204 +204 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -221 +221 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -232 +232 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -243 +243 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -254 +254 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -265 +265 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -276 +276 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -289 +289 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -308 +308 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -310 +310 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); ---- tests/renew_tests.move -+++ tests/renew_tests.move -@@ -25 +25 @@ -- let scenario_val = test_scenario::begin(SUINS_ADDRESS); -+ let mut scenario_val = test_scenario::begin(SUINS_ADDRESS); -@@ -28 +28 @@ -- let suins = suins::init_for_testing(ctx(scenario)); -+ let mut suins = suins::init_for_testing(ctx(scenario)); -@@ -38 +38 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -50 +50 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -52 +52 @@ -- let clock = test_scenario::take_shared(scenario); -+ let mut clock = test_scenario::take_shared(scenario); -@@ -64 +64 @@ -- let suins = test_scenario::take_shared(scenario); -+ let mut suins = test_scenario::take_shared(scenario); -@@ -74 +74 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -77 +77 @@ -- let nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0); -+ let mut nft = register_util(scenario, utf8(b"abcd.sui"), 1, 200 * mist_per_sui(), 0); -@@ -83 +83 @@ -- let nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0); -+ let mut nft = register_util(scenario, utf8(b"abcde.sui"), 1, 50 * mist_per_sui(), 0); -@@ -89 +89 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -@@ -105 +105 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -108 +108 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -@@ -117 +117 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -120 +120 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -@@ -129 +129 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -132 +132 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 10); -@@ -141 +141 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -144 +144 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); -@@ -153 +153 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -156 +156 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); -@@ -164 +164 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -166 +166 @@ -- let scenario_val = test_init(); -+ let mut scenario_val = test_init(); -@@ -169 +169 @@ -- let nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); -+ let mut nft = register_util(scenario, utf8(DOMAIN_NAME), 1, 1200 * mist_per_sui(), 0); ---- tests/unit/admin_tests.move -+++ tests/unit/admin_tests.move -@@ -27 +27 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -29,2 +29,2 @@ -- let ctx = tx_context::dummy(); -- let suins = suins::init_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let mut suins = suins::init_for_testing(&mut ctx); -@@ -48,2 +48,2 @@ -- let ctx = tx_context::dummy(); -- let suins = suins::init_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let mut suins = suins::init_for_testing(&mut ctx); ---- tests/unit/config_tests.move -+++ tests/unit/config_tests.move -@@ -23 +23 @@ -- let config = default(); -+ let mut config = default(); -@@ -91 +91 @@ -- let config = default(); -+ let mut config = default(); ---- tests/unit/name_record_tests.move -+++ tests/unit/name_record_tests.move -@@ -27 +27 @@ -- let ctx = tx_context::dummy(); -+ let mut ctx = tx_context::dummy(); -@@ -29 +29 @@ -- let record = record::new(nft_id, 0); -+ let mut record = record::new(nft_id, 0); -@@ -37 +37 @@ -- let data = vec_map::empty(); -+ let mut data = vec_map::empty(); -@@ -55 +55 @@ -- let ctx = tx_context::dummy(); -+ let mut ctx = tx_context::dummy(); -@@ -58 +58 @@ -- let clock = clock::create_for_testing(&mut ctx); -+ let mut clock = clock::create_for_testing(&mut ctx); ---- tests/unit/registration_nft_tests.move -+++ tests/unit/registration_nft_tests.move -@@ -23,2 +23,2 @@ -- let ctx = tx_context::dummy(); -- let clock = clock::create_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let mut clock = clock::create_for_testing(&mut ctx); -@@ -53 +53 @@ -- let ctx = tx_context::dummy(); -+ let mut ctx = tx_context::dummy(); -@@ -55 +55 @@ -- let nft = new(utf8(b"test.sui"), 5, &clock, &mut ctx); -+ let mut nft = new(utf8(b"test.sui"), 5, &clock, &mut ctx); ---- tests/unit/registry_tests.move -+++ tests/unit/registry_tests.move -@@ -24,2 +24,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -48,2 +48,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -86,2 +86,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, _domain) = setup(&mut ctx); -@@ -114,2 +114,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -142,2 +142,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -170,2 +170,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -185,2 +185,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -204,2 +204,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -233,2 +233,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -258,2 +258,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -266 +266 @@ -- let search = registry::lookup(®istry, domain); -+ let mut search = registry::lookup(®istry, domain); -@@ -285,2 +285,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -294 +294 @@ -- let search = registry::reverse_lookup(®istry, @0xB0B); -+ let mut search = registry::reverse_lookup(®istry, @0xB0B); -@@ -309,2 +309,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, _domain) = setup(&mut ctx); -@@ -325,2 +325,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -342,2 +342,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, mut clock, domain) = setup(&mut ctx); -@@ -367,2 +367,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -382,2 +382,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -396,2 +396,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, _domain) = setup(&mut ctx); -@@ -407,2 +407,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, _domain) = setup(&mut ctx); -@@ -418,2 +418,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, _domain) = setup(&mut ctx); -@@ -431,2 +431,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, _domain) = setup(&mut ctx); -@@ -445,2 +445,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, _domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, _domain) = setup(&mut ctx); -@@ -460,2 +460,2 @@ -- let ctx = tx_context::dummy(); -- let (registry, clock, domain) = setup(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut registry, clock, domain) = setup(&mut ctx); -@@ -494 +494 @@ -- public fun burn_nfts(nfts: vector) { -+ public fun burn_nfts(mut nfts: vector) { ---- tests/unit/sub_name_tests.move -+++ tests/unit/sub_name_tests.move -@@ -17,2 +17,2 @@ -- let ctx = tx_context::dummy(); -- let clock = clock::create_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let mut clock = clock::create_for_testing(&mut ctx); -@@ -22 +22 @@ -- let nft = suins_registration::new_for_testing(domain, 1, &clock, &mut ctx); -+ let mut nft = suins_registration::new_for_testing(domain, 1, &clock, &mut ctx); -@@ -25 +25 @@ -- let sub_nft = subdomain::new(nft, &clock, &mut ctx); -+ let mut sub_nft = subdomain::new(nft, &clock, &mut ctx); -@@ -41 +41 @@ -- let ctx = tx_context::dummy(); -+ let mut ctx = tx_context::dummy(); -@@ -54,2 +54,2 @@ -- let ctx = tx_context::dummy(); -- let clock = clock::create_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let mut clock = clock::create_for_testing(&mut ctx); -@@ -68 +68 @@ -- let ctx = tx_context::dummy(); -+ let mut ctx = tx_context::dummy(); ---- tests/unit/suins_tests.move -+++ tests/unit/suins_tests.move -@@ -16 +16 @@ -- struct TestConfig has store, drop { a: u8 } -+ public struct TestConfig has store, drop { a: u8 } -@@ -21,2 +21,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, cap) = suins::new_for_testing(&mut ctx); -@@ -34 +34 @@ -- struct TestRegistry has store { counter: u8 } -+ public struct TestRegistry has store { counter: u8 } -@@ -39,2 +39,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, cap) = suins::new_for_testing(&mut ctx); -@@ -51 +51 @@ -- struct TestApp has drop {} -+ public struct TestApp has drop {} -@@ -53 +53 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -56,2 +56,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, _cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, _cap) = suins::new_for_testing(&mut ctx); -@@ -62 +62 @@ -- #[test, expected_failure(abort_code = suins::suins::EAppNotAuthorized)] -+ #[test, expected_failure(abort_code = ::suins::suins::EAppNotAuthorized)] -@@ -65,2 +65,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, _cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, _cap) = suins::new_for_testing(&mut ctx); -@@ -75,2 +75,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, cap) = suins::new_for_testing(&mut ctx); -@@ -103,2 +103,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, cap) = suins::new_for_testing(&mut ctx); -@@ -116 +116 @@ -- #[test, expected_failure(abort_code = suins::suins::ENoProfits)] -+ #[test, expected_failure(abort_code = ::suins::suins::ENoProfits)] -@@ -120,2 +120,2 @@ -- let ctx = tx_context::dummy(); -- let (suins, cap) = suins::new_for_testing(&mut ctx); -+ let mut ctx = tx_context::dummy(); -+ let (mut suins, cap) = suins::new_for_testing(&mut ctx); ---- tests/v2/register.move -+++ tests/v2/register.move -@@ -25 +25 @@ -- struct Register has drop {} -+ public struct Register has drop {} ---- tests/v2/renew.move -+++ tests/v2/renew.move -@@ -31 +31 @@ -- struct Renew has drop {} -+ public struct Renew has drop {} diff --git a/packages/temp_subdomain_proxy/Move.toml b/packages/temp_subdomain_proxy/Move.toml index 2c1dbcb3..4e0ae670 100644 --- a/packages/temp_subdomain_proxy/Move.toml +++ b/packages/temp_subdomain_proxy/Move.toml @@ -1,6 +1,7 @@ [package] name = "temp_subdomain_proxy" version = "0.0.1" +edition = "2024.beta" #testnet #published-at="0x471adb89c0b5094febfcde87f0a90ec32daea71755dd9eed9e68bc3e527562b5" diff --git a/packages/utils/Move.toml b/packages/utils/Move.toml index 9d0e283a..94754b41 100644 --- a/packages/utils/Move.toml +++ b/packages/utils/Move.toml @@ -1,6 +1,7 @@ [package] name = "utils" version = "0.0.1" +edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet", override=true } diff --git a/packages/utils/sources/direct_setup.move b/packages/utils/sources/direct_setup.move index 88439d34..f589f222 100644 --- a/packages/utils/sources/direct_setup.move +++ b/packages/utils/sources/direct_setup.move @@ -16,7 +16,7 @@ module utils::direct_setup { use suins::suins_registration::{Self as nft, SuinsRegistration}; /// Authorization token for the controller. - struct DirectSetup has drop {} + public struct DirectSetup has drop {} /// Set the target address of a domain. public fun set_target_address(