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/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)); 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 a272faa5..87ed29e3 100644 --- a/packages/day_one/Move.toml +++ b/packages/day_one/Move.toml @@ -2,6 +2,7 @@ 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", override=true } 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); 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/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")); 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/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 { 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/Move.lock b/packages/registration/Move.lock index 9e1d8db2..eabd68c1 100644 --- a/packages/registration/Move.lock +++ b/packages/registration/Move.lock @@ -1,7 +1,7 @@ # @generated by Move, please check-in and do not edit manually. [move] -version = 0 +version = 1 manifest_digest = "75434D5374AE0B76DFC7B2C8B1D93D92E43B7C10C03782CF67925E35F379A78A" deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" @@ -31,6 +31,6 @@ dependencies = [ ] [move.toolchain-version] -compiler-version = "1.19.0" +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/sources/register.move b/packages/registration/sources/register.move index ffe15345..1fe43d78 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 a365b9ca..9899714c 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); diff --git a/packages/renewal/Move.lock b/packages/renewal/Move.lock index 8bb8a576..ac6482ef 100644 --- a/packages/renewal/Move.lock +++ b/packages/renewal/Move.lock @@ -29,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 fc4f5639..b2c13f37 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/mainnet", override=true } 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); 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/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 2a77f4d9..0effd2fe 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/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` 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(