diff --git a/contracts/Move.lock b/contracts/Move.lock index 8b03988..644bc53 100644 --- a/contracts/Move.lock +++ b/contracts/Move.lock @@ -2,20 +2,32 @@ [move] version = 3 -manifest_digest = "06BB9182CE131DFC0277880DBB6779C784DA52BA09DB1E0750169ED16A80D678" -deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" +manifest_digest = "AE832443B65D117CD4F334CE369001B6C6285F8B7044CE77B78BF4048CD6B31C" +deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C" dependencies = [ + { id = "Bridge", name = "Bridge" }, + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "SuiSystem", name = "SuiSystem" }, +] + +[[move.package]] +id = "Bridge" +source = { git = "https://github.com/MystenLabs/sui.git", rev = "664b05b3b047c5bb03979d093660176176ea6175", subdir = "crates/sui-framework/packages/bridge" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, { id = "Sui", name = "Sui" }, { id = "SuiSystem", name = "SuiSystem" }, ] [[move.package]] id = "MoveStdlib" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/move-stdlib" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "664b05b3b047c5bb03979d093660176176ea6175", subdir = "crates/sui-framework/packages/move-stdlib" } [[move.package]] id = "Sui" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-framework" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "664b05b3b047c5bb03979d093660176176ea6175", subdir = "crates/sui-framework/packages/sui-framework" } dependencies = [ { id = "MoveStdlib", name = "MoveStdlib" }, @@ -23,7 +35,7 @@ dependencies = [ [[move.package]] id = "SuiSystem" -source = { git = "https://github.com/MystenLabs/sui.git", rev = "framework/mainnet", subdir = "crates/sui-framework/packages/sui-system" } +source = { git = "https://github.com/MystenLabs/sui.git", rev = "664b05b3b047c5bb03979d093660176176ea6175", subdir = "crates/sui-framework/packages/sui-system" } dependencies = [ { id = "MoveStdlib", name = "MoveStdlib" }, @@ -31,20 +43,6 @@ dependencies = [ ] [move.toolchain-version] -compiler-version = "1.51.5" +compiler-version = "1.56.2" edition = "2024.beta" flavor = "sui" - -[env] - -[env.testnet] -chain-id = "4c78adac" -original-published-id = "0x054acc66b4e75276f5c0adc18468170b9d46ccd83cfd00d148af82982a2c0fc6" -latest-published-id = "0x054acc66b4e75276f5c0adc18468170b9d46ccd83cfd00d148af82982a2c0fc6" -published-version = "1" - -[env.mainnet] -chain-id = "35834a8a" -original-published-id = "0xb0575765166030556a6eafd3b1b970eba8183ff748860680245b9edd41c716e7" -latest-published-id = "0xc89f4edb8f4dafb97934dbfce11ac132c07759c3bdda6f31d09c7fdca3b80b76" -published-version = "7" diff --git a/contracts/Move.toml b/contracts/Move.toml index 6117cd8..f71bfa3 100644 --- a/contracts/Move.toml +++ b/contracts/Move.toml @@ -6,8 +6,6 @@ published-at = "0xc89f4edb8f4dafb97934dbfce11ac132c07759c3bdda6f31d09c7fdca3b80b # authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] [dependencies] -Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } -SuiSystem = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-system", rev = "framework/mainnet" } # For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. diff --git a/contracts/tests/liquid_staking_tests.move b/contracts/tests/liquid_staking_tests.move index dbf0134..a4bfbb9 100644 --- a/contracts/tests/liquid_staking_tests.move +++ b/contracts/tests/liquid_staking_tests.move @@ -1,3 +1,4 @@ +#[allow(deprecated_usage)] #[test_only] module liquid_staking::liquid_staking_tests { // uncomment this line to import the module @@ -11,9 +12,9 @@ module liquid_staking::liquid_staking_tests { use liquid_staking::fees::{Self}; use sui_system::governance_test_utils::{ advance_epoch_with_reward_amounts, - create_validators_with_stakes, create_sui_system_state_for_testing, }; + use liquid_staking::test_utils::create_validators_with_stakes; /* Constants */ const MIST_PER_SUI: u64 = 1_000_000_000; @@ -55,7 +56,7 @@ module liquid_staking::liquid_staking_tests { scenario.next_tx(@0x0); - let mut system_state = scenario.take_shared(); + let system_state = scenario.take_shared(); let (admin_cap, lst_info) = create_lst( fees::new_builder(scenario.ctx()) @@ -125,7 +126,7 @@ module liquid_staking::liquid_staking_tests { setup_sui_system(&mut scenario, vector[100, 100]); - let mut system_state = scenario.take_shared(); + let system_state = scenario.take_shared(); let mut treasury_cap = coin::create_treasury_cap_for_testing(scenario.ctx()); let coins = treasury_cap.mint(1000 * MIST_PER_SUI, scenario.ctx()); @@ -537,7 +538,7 @@ module liquid_staking::liquid_staking_tests { scenario.next_tx(@0x0); - let mut system_state = scenario.take_shared(); + let system_state = scenario.take_shared(); let (admin_cap, mut lst_info) = create_lst( fees::new_builder(scenario.ctx()) diff --git a/contracts/tests/storage_tests.move b/contracts/tests/storage_tests.move index 2bcffda..5eb4251 100644 --- a/contracts/tests/storage_tests.move +++ b/contracts/tests/storage_tests.move @@ -1,3 +1,4 @@ +#[allow(deprecated_usage)] #[test_only] module liquid_staking::storage_tests { /* Tests */ @@ -13,15 +14,12 @@ module liquid_staking::storage_tests { use sui::balance::{Self}; use liquid_staking::storage::{new}; use sui::sui::SUI; - use std::macros::do; + use liquid_staking::test_utils::create_validators_with_stakes; + use sui_system::governance_test_utils::create_sui_system_state_for_testing; + #[test_only] fun setup_sui_system(scenario: &mut Scenario, stakes: vector) { - use sui_system::governance_test_utils::{ - create_validators_with_stakes, - create_sui_system_state_for_testing, - }; - let validators = create_validators_with_stakes(stakes, scenario.ctx()); create_sui_system_state_for_testing(validators, 0, 0, scenario.ctx()); @@ -199,8 +197,6 @@ module liquid_staking::storage_tests { let mut system_state = scenario.take_shared(); storage.refresh(&mut system_state, scenario.ctx()); - std::debug::print(&storage); - assert!(storage.validators().length() == 1, 0); assert!(storage.total_sui_supply() == 150 * MIST_PER_SUI, 0); assert!(storage.validators()[0].total_sui_amount() == 150 * MIST_PER_SUI, 0); diff --git a/contracts/tests/test_utils.move b/contracts/tests/test_utils.move new file mode 100644 index 0000000..4a189e7 --- /dev/null +++ b/contracts/tests/test_utils.move @@ -0,0 +1,24 @@ +#[allow(deprecated_usage)] +#[test_only] +module liquid_staking::test_utils { + use sui::address; + use sui_system::governance_test_utils::{ + create_validator_for_testing, + }; + use sui_system::validator::{Validator}; + + /// Create a validator set with the given stake amounts + public fun create_validators_with_stakes( + stakes: vector, + ctx: &mut TxContext, + ): vector { + let mut i = 0; + let mut validators = vector[]; + while (i < stakes.length()) { + let validator = create_validator_for_testing(address::from_u256(i as u256), stakes[i], ctx); + validators.push_back(validator); + i = i + 1 + }; + validators + } +} \ No newline at end of file diff --git a/contracts/tests/weight_tests.move b/contracts/tests/weight_tests.move index 2ddb07b..d4d8adf 100644 --- a/contracts/tests/weight_tests.move +++ b/contracts/tests/weight_tests.move @@ -6,7 +6,6 @@ module liquid_staking::weight_tests { use sui::coin::{Self}; use sui::address; use sui_system::governance_test_utils::{ - create_validators_with_stakes, create_sui_system_state_for_testing, advance_epoch_with_reward_amounts, }; @@ -16,6 +15,7 @@ module liquid_staking::weight_tests { use liquid_staking::fees::{Self}; use liquid_staking::liquid_staking::{create_lst}; use liquid_staking::weight::{Self, WeightHook}; + use liquid_staking::test_utils::create_validators_with_stakes; public struct TEST has drop {} @@ -39,6 +39,7 @@ module liquid_staking::weight_tests { staked_sui } + #[allow(deprecated_usage)] #[test_only] fun setup_sui_system(scenario: &mut Scenario, stakes: vector) { let validators = create_validators_with_stakes(stakes, scenario.ctx()); @@ -83,8 +84,6 @@ module liquid_staking::weight_tests { weight_hook.rebalance(&mut system_state, &mut lst_info, scenario.ctx()); - std::debug::print(&lst_info); - assert!(lst_info.storage().validators().borrow(0).total_sui_amount() == 25 * MIST_PER_SUI, 0); assert!(lst_info.storage().validators().borrow(1).total_sui_amount() == 75 * MIST_PER_SUI, 0); @@ -170,8 +169,6 @@ module liquid_staking::weight_tests { weight_hook.rebalance(&mut system_state, &mut lst_info, scenario.ctx()); - std::debug::print(lst_info.storage().validators()); - assert!(lst_info.storage().validators().borrow(0).total_sui_amount() == 25 * MIST_PER_SUI, 0); assert!(lst_info.storage().validators().borrow(1).total_sui_amount() == 75 * MIST_PER_SUI, 0); @@ -179,7 +176,6 @@ module liquid_staking::weight_tests { let mut custom_redeem_request = lst_info.custom_redeem_request(lst_to_unstake,&mut system_state, scenario.ctx()); weight_hook.handle_custom_redeem_request(&mut system_state, &mut lst_info, &mut custom_redeem_request, scenario.ctx()); - // std::debug::print(lst_info.storage().validators()); assert!(lst_info.storage().validators().borrow(0).total_sui_amount() == 25 * MIST_PER_SUI - 2_500_000_000, 0); assert!(lst_info.storage().validators().borrow(1).total_sui_amount() == 75 * MIST_PER_SUI - 7_500_000_000, 0);