diff --git a/Cargo.toml b/Cargo.toml index edae905e6..dc7b532d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = [ # Packages "packages/shade_protocol", - "packages/secretcli", + # "packages/secretcli", "packages/multi_test", "packages/multi_derive", "packages/contract_derive", @@ -13,11 +13,6 @@ members = [ # Protocol contracts "contracts/snip20", - "contracts/governance", - # "contracts/bonds", //TODO: migrate to v1 - # "contracts/liability_mint", //TODO: migrate - "contracts/sky", - "contracts/peg_stability", "contracts/query_auth", "contracts/admin", "contracts/basic_staking", @@ -34,11 +29,9 @@ members = [ # - Adapters "contracts/dao/scrt_staking", "contracts/dao/stkd_scrt", - "contracts/dao/rewards_emission", - "contracts/dao/lp_shdswap", + # "contracts/dao/rewards_emission", + # "contracts/dao/lp_shdswap", - # "contracts/snip20_staking", //TODO: migrate to v1 - # Mock contracts # "contracts/mock/mock_band", //TODO: migrate to v1 # "contracts/mock/mock_secretswap_pair", //TODO: migrate to v1 @@ -47,8 +40,8 @@ members = [ "contracts/mock/mock_stkd_derivative", # Tools - "tools/doc2book", - "launch" + # "tools/doc2book", + # "launch" ] exclude = ["packages/network_integration"] diff --git a/contracts/dao/lp_shdswap/.cargo/config b/archived-contracts/dao/lp_shdswap/.cargo/config similarity index 100% rename from contracts/dao/lp_shdswap/.cargo/config rename to archived-contracts/dao/lp_shdswap/.cargo/config diff --git a/contracts/dao/lp_shdswap/.circleci/config.yml b/archived-contracts/dao/lp_shdswap/.circleci/config.yml similarity index 100% rename from contracts/dao/lp_shdswap/.circleci/config.yml rename to archived-contracts/dao/lp_shdswap/.circleci/config.yml diff --git a/contracts/dao/lp_shdswap/Cargo.toml b/archived-contracts/dao/lp_shdswap/Cargo.toml similarity index 100% rename from contracts/dao/lp_shdswap/Cargo.toml rename to archived-contracts/dao/lp_shdswap/Cargo.toml diff --git a/contracts/dao/lp_shdswap/Makefile b/archived-contracts/dao/lp_shdswap/Makefile similarity index 100% rename from contracts/dao/lp_shdswap/Makefile rename to archived-contracts/dao/lp_shdswap/Makefile diff --git a/contracts/dao/lp_shdswap/README.md b/archived-contracts/dao/lp_shdswap/README.md similarity index 100% rename from contracts/dao/lp_shdswap/README.md rename to archived-contracts/dao/lp_shdswap/README.md diff --git a/contracts/dao/lp_shdswap/src/contract.rs b/archived-contracts/dao/lp_shdswap/src/contract.rs similarity index 100% rename from contracts/dao/lp_shdswap/src/contract.rs rename to archived-contracts/dao/lp_shdswap/src/contract.rs diff --git a/contracts/dao/lp_shdswap/src/execute.rs b/archived-contracts/dao/lp_shdswap/src/execute.rs similarity index 100% rename from contracts/dao/lp_shdswap/src/execute.rs rename to archived-contracts/dao/lp_shdswap/src/execute.rs diff --git a/contracts/dao/lp_shdswap/src/lib.rs b/archived-contracts/dao/lp_shdswap/src/lib.rs similarity index 100% rename from contracts/dao/lp_shdswap/src/lib.rs rename to archived-contracts/dao/lp_shdswap/src/lib.rs diff --git a/contracts/dao/lp_shdswap/src/query.rs b/archived-contracts/dao/lp_shdswap/src/query.rs similarity index 100% rename from contracts/dao/lp_shdswap/src/query.rs rename to archived-contracts/dao/lp_shdswap/src/query.rs diff --git a/contracts/dao/lp_shdswap/src/storage.rs b/archived-contracts/dao/lp_shdswap/src/storage.rs similarity index 100% rename from contracts/dao/lp_shdswap/src/storage.rs rename to archived-contracts/dao/lp_shdswap/src/storage.rs diff --git a/contracts/dao/lp_shdswap/src/test.rs b/archived-contracts/dao/lp_shdswap/src/test.rs similarity index 100% rename from contracts/dao/lp_shdswap/src/test.rs rename to archived-contracts/dao/lp_shdswap/src/test.rs diff --git a/contracts/dao/rewards_emission/.cargo/config b/archived-contracts/dao/rewards_emission/.cargo/config similarity index 100% rename from contracts/dao/rewards_emission/.cargo/config rename to archived-contracts/dao/rewards_emission/.cargo/config diff --git a/contracts/dao/rewards_emission/.circleci/config.yml b/archived-contracts/dao/rewards_emission/.circleci/config.yml similarity index 100% rename from contracts/dao/rewards_emission/.circleci/config.yml rename to archived-contracts/dao/rewards_emission/.circleci/config.yml diff --git a/contracts/dao/rewards_emission/Cargo.toml b/archived-contracts/dao/rewards_emission/Cargo.toml similarity index 100% rename from contracts/dao/rewards_emission/Cargo.toml rename to archived-contracts/dao/rewards_emission/Cargo.toml diff --git a/contracts/dao/rewards_emission/Makefile b/archived-contracts/dao/rewards_emission/Makefile similarity index 100% rename from contracts/dao/rewards_emission/Makefile rename to archived-contracts/dao/rewards_emission/Makefile diff --git a/contracts/dao/rewards_emission/README.md b/archived-contracts/dao/rewards_emission/README.md similarity index 100% rename from contracts/dao/rewards_emission/README.md rename to archived-contracts/dao/rewards_emission/README.md diff --git a/contracts/dao/rewards_emission/src/contract.rs b/archived-contracts/dao/rewards_emission/src/contract.rs similarity index 100% rename from contracts/dao/rewards_emission/src/contract.rs rename to archived-contracts/dao/rewards_emission/src/contract.rs diff --git a/contracts/dao/rewards_emission/src/execute.rs b/archived-contracts/dao/rewards_emission/src/execute.rs similarity index 100% rename from contracts/dao/rewards_emission/src/execute.rs rename to archived-contracts/dao/rewards_emission/src/execute.rs diff --git a/contracts/dao/rewards_emission/src/lib.rs b/archived-contracts/dao/rewards_emission/src/lib.rs similarity index 100% rename from contracts/dao/rewards_emission/src/lib.rs rename to archived-contracts/dao/rewards_emission/src/lib.rs diff --git a/contracts/dao/rewards_emission/src/query.rs b/archived-contracts/dao/rewards_emission/src/query.rs similarity index 100% rename from contracts/dao/rewards_emission/src/query.rs rename to archived-contracts/dao/rewards_emission/src/query.rs diff --git a/contracts/dao/rewards_emission/src/storage.rs b/archived-contracts/dao/rewards_emission/src/storage.rs similarity index 100% rename from contracts/dao/rewards_emission/src/storage.rs rename to archived-contracts/dao/rewards_emission/src/storage.rs diff --git a/contracts/dao/rewards_emission/src/test.rs b/archived-contracts/dao/rewards_emission/src/test.rs similarity index 100% rename from contracts/dao/rewards_emission/src/test.rs rename to archived-contracts/dao/rewards_emission/src/test.rs diff --git a/contracts/governance/.cargo/config b/archived-contracts/governance/.cargo/config similarity index 100% rename from contracts/governance/.cargo/config rename to archived-contracts/governance/.cargo/config diff --git a/contracts/governance/.circleci/config.yml b/archived-contracts/governance/.circleci/config.yml similarity index 100% rename from contracts/governance/.circleci/config.yml rename to archived-contracts/governance/.circleci/config.yml diff --git a/contracts/governance/Cargo.toml b/archived-contracts/governance/Cargo.toml similarity index 100% rename from contracts/governance/Cargo.toml rename to archived-contracts/governance/Cargo.toml diff --git a/contracts/governance/Makefile b/archived-contracts/governance/Makefile similarity index 100% rename from contracts/governance/Makefile rename to archived-contracts/governance/Makefile diff --git a/contracts/governance/src/contract.rs b/archived-contracts/governance/src/contract.rs similarity index 100% rename from contracts/governance/src/contract.rs rename to archived-contracts/governance/src/contract.rs diff --git a/contracts/governance/src/handle/assembly.rs b/archived-contracts/governance/src/handle/assembly.rs similarity index 100% rename from contracts/governance/src/handle/assembly.rs rename to archived-contracts/governance/src/handle/assembly.rs diff --git a/contracts/governance/src/handle/assembly_msg.rs b/archived-contracts/governance/src/handle/assembly_msg.rs similarity index 100% rename from contracts/governance/src/handle/assembly_msg.rs rename to archived-contracts/governance/src/handle/assembly_msg.rs diff --git a/contracts/governance/src/handle/contract.rs b/archived-contracts/governance/src/handle/contract.rs similarity index 100% rename from contracts/governance/src/handle/contract.rs rename to archived-contracts/governance/src/handle/contract.rs diff --git a/contracts/governance/src/handle/migration.rs b/archived-contracts/governance/src/handle/migration.rs similarity index 100% rename from contracts/governance/src/handle/migration.rs rename to archived-contracts/governance/src/handle/migration.rs diff --git a/contracts/governance/src/handle/mod.rs b/archived-contracts/governance/src/handle/mod.rs similarity index 100% rename from contracts/governance/src/handle/mod.rs rename to archived-contracts/governance/src/handle/mod.rs diff --git a/contracts/governance/src/handle/profile.rs b/archived-contracts/governance/src/handle/profile.rs similarity index 100% rename from contracts/governance/src/handle/profile.rs rename to archived-contracts/governance/src/handle/profile.rs diff --git a/contracts/governance/src/handle/proposal.rs b/archived-contracts/governance/src/handle/proposal.rs similarity index 100% rename from contracts/governance/src/handle/proposal.rs rename to archived-contracts/governance/src/handle/proposal.rs diff --git a/contracts/governance/src/lib.rs b/archived-contracts/governance/src/lib.rs similarity index 100% rename from contracts/governance/src/lib.rs rename to archived-contracts/governance/src/lib.rs diff --git a/contracts/governance/src/query.rs b/archived-contracts/governance/src/query.rs similarity index 100% rename from contracts/governance/src/query.rs rename to archived-contracts/governance/src/query.rs diff --git a/contracts/governance/src/tests/handle/assembly.rs b/archived-contracts/governance/src/tests/handle/assembly.rs similarity index 100% rename from contracts/governance/src/tests/handle/assembly.rs rename to archived-contracts/governance/src/tests/handle/assembly.rs diff --git a/contracts/governance/src/tests/handle/assembly_msg.rs b/archived-contracts/governance/src/tests/handle/assembly_msg.rs similarity index 100% rename from contracts/governance/src/tests/handle/assembly_msg.rs rename to archived-contracts/governance/src/tests/handle/assembly_msg.rs diff --git a/contracts/governance/src/tests/handle/contract.rs b/archived-contracts/governance/src/tests/handle/contract.rs similarity index 100% rename from contracts/governance/src/tests/handle/contract.rs rename to archived-contracts/governance/src/tests/handle/contract.rs diff --git a/contracts/governance/src/tests/handle/migration.rs b/archived-contracts/governance/src/tests/handle/migration.rs similarity index 100% rename from contracts/governance/src/tests/handle/migration.rs rename to archived-contracts/governance/src/tests/handle/migration.rs diff --git a/contracts/governance/src/tests/handle/mod.rs b/archived-contracts/governance/src/tests/handle/mod.rs similarity index 100% rename from contracts/governance/src/tests/handle/mod.rs rename to archived-contracts/governance/src/tests/handle/mod.rs diff --git a/contracts/governance/src/tests/handle/profile.rs b/archived-contracts/governance/src/tests/handle/profile.rs similarity index 100% rename from contracts/governance/src/tests/handle/profile.rs rename to archived-contracts/governance/src/tests/handle/profile.rs diff --git a/contracts/governance/src/tests/handle/proposal/assembly_voting.rs b/archived-contracts/governance/src/tests/handle/proposal/assembly_voting.rs similarity index 100% rename from contracts/governance/src/tests/handle/proposal/assembly_voting.rs rename to archived-contracts/governance/src/tests/handle/proposal/assembly_voting.rs diff --git a/contracts/governance/src/tests/handle/proposal/funding.rs b/archived-contracts/governance/src/tests/handle/proposal/funding.rs similarity index 100% rename from contracts/governance/src/tests/handle/proposal/funding.rs rename to archived-contracts/governance/src/tests/handle/proposal/funding.rs diff --git a/contracts/governance/src/tests/handle/proposal/mod.rs b/archived-contracts/governance/src/tests/handle/proposal/mod.rs similarity index 100% rename from contracts/governance/src/tests/handle/proposal/mod.rs rename to archived-contracts/governance/src/tests/handle/proposal/mod.rs diff --git a/contracts/governance/src/tests/handle/proposal/voting.rs b/archived-contracts/governance/src/tests/handle/proposal/voting.rs similarity index 100% rename from contracts/governance/src/tests/handle/proposal/voting.rs rename to archived-contracts/governance/src/tests/handle/proposal/voting.rs diff --git a/contracts/governance/src/tests/handle/runstate.rs b/archived-contracts/governance/src/tests/handle/runstate.rs similarity index 100% rename from contracts/governance/src/tests/handle/runstate.rs rename to archived-contracts/governance/src/tests/handle/runstate.rs diff --git a/contracts/governance/src/tests/mod.rs b/archived-contracts/governance/src/tests/mod.rs similarity index 100% rename from contracts/governance/src/tests/mod.rs rename to archived-contracts/governance/src/tests/mod.rs diff --git a/contracts/governance/src/tests/query/mod.rs b/archived-contracts/governance/src/tests/query/mod.rs similarity index 100% rename from contracts/governance/src/tests/query/mod.rs rename to archived-contracts/governance/src/tests/query/mod.rs diff --git a/contracts/governance/src/tests/query/public.rs b/archived-contracts/governance/src/tests/query/public.rs similarity index 100% rename from contracts/governance/src/tests/query/public.rs rename to archived-contracts/governance/src/tests/query/public.rs diff --git a/contracts/governance/src/tests/query/user.rs b/archived-contracts/governance/src/tests/query/user.rs similarity index 100% rename from contracts/governance/src/tests/query/user.rs rename to archived-contracts/governance/src/tests/query/user.rs diff --git a/contracts/peg_stability/Cargo.toml b/archived-contracts/peg_stability/Cargo.toml similarity index 100% rename from contracts/peg_stability/Cargo.toml rename to archived-contracts/peg_stability/Cargo.toml diff --git a/contracts/peg_stability/Makefile b/archived-contracts/peg_stability/Makefile similarity index 100% rename from contracts/peg_stability/Makefile rename to archived-contracts/peg_stability/Makefile diff --git a/contracts/peg_stability/src/contract.rs b/archived-contracts/peg_stability/src/contract.rs similarity index 100% rename from contracts/peg_stability/src/contract.rs rename to archived-contracts/peg_stability/src/contract.rs diff --git a/contracts/peg_stability/src/handle.rs b/archived-contracts/peg_stability/src/handle.rs similarity index 100% rename from contracts/peg_stability/src/handle.rs rename to archived-contracts/peg_stability/src/handle.rs diff --git a/contracts/peg_stability/src/lib.rs b/archived-contracts/peg_stability/src/lib.rs similarity index 100% rename from contracts/peg_stability/src/lib.rs rename to archived-contracts/peg_stability/src/lib.rs diff --git a/contracts/peg_stability/src/query.rs b/archived-contracts/peg_stability/src/query.rs similarity index 100% rename from contracts/peg_stability/src/query.rs rename to archived-contracts/peg_stability/src/query.rs diff --git a/contracts/peg_stability/src/tests/handle.rs b/archived-contracts/peg_stability/src/tests/handle.rs similarity index 100% rename from contracts/peg_stability/src/tests/handle.rs rename to archived-contracts/peg_stability/src/tests/handle.rs diff --git a/contracts/peg_stability/src/tests/mod.rs b/archived-contracts/peg_stability/src/tests/mod.rs similarity index 100% rename from contracts/peg_stability/src/tests/mod.rs rename to archived-contracts/peg_stability/src/tests/mod.rs diff --git a/contracts/peg_stability/src/tests/query.rs b/archived-contracts/peg_stability/src/tests/query.rs similarity index 100% rename from contracts/peg_stability/src/tests/query.rs rename to archived-contracts/peg_stability/src/tests/query.rs diff --git a/contracts/sky/.cargo/config b/archived-contracts/sky/.cargo/config similarity index 100% rename from contracts/sky/.cargo/config rename to archived-contracts/sky/.cargo/config diff --git a/contracts/sky/.circleci/config.yml b/archived-contracts/sky/.circleci/config.yml similarity index 100% rename from contracts/sky/.circleci/config.yml rename to archived-contracts/sky/.circleci/config.yml diff --git a/contracts/sky/Cargo.toml b/archived-contracts/sky/Cargo.toml similarity index 100% rename from contracts/sky/Cargo.toml rename to archived-contracts/sky/Cargo.toml diff --git a/contracts/sky/Makefile b/archived-contracts/sky/Makefile similarity index 100% rename from contracts/sky/Makefile rename to archived-contracts/sky/Makefile diff --git a/contracts/sky/src/contract.rs b/archived-contracts/sky/src/contract.rs similarity index 100% rename from contracts/sky/src/contract.rs rename to archived-contracts/sky/src/contract.rs diff --git a/contracts/sky/src/execute.rs b/archived-contracts/sky/src/execute.rs similarity index 100% rename from contracts/sky/src/execute.rs rename to archived-contracts/sky/src/execute.rs diff --git a/contracts/sky/src/lib.rs b/archived-contracts/sky/src/lib.rs similarity index 100% rename from contracts/sky/src/lib.rs rename to archived-contracts/sky/src/lib.rs diff --git a/contracts/sky/src/query.rs b/archived-contracts/sky/src/query.rs similarity index 100% rename from contracts/sky/src/query.rs rename to archived-contracts/sky/src/query.rs diff --git a/contracts/sky/tests/integration.rs b/archived-contracts/sky/tests/integration.rs similarity index 100% rename from contracts/sky/tests/integration.rs rename to archived-contracts/sky/tests/integration.rs diff --git a/contracts/admin/src/contract.rs b/contracts/admin/src/contract.rs index 47688e6a3..666d52110 100644 --- a/contracts/admin/src/contract.rs +++ b/contracts/admin/src/contract.rs @@ -1,36 +1,18 @@ use shade_protocol::{ admin::{ - errors::unauthorized_super, - AdminAuthStatus, - AdminsResponse, - ConfigResponse, - ExecuteMsg, - InstantiateMsg, - PermissionsResponse, - QueryMsg, + errors::unauthorized_super, AdminAuthStatus, AdminsResponse, ConfigResponse, ExecuteMsg, + InstantiateMsg, PermissionsResponse, QueryMsg, }, c_std::{ - shd_entry_point, - to_binary, - Addr, - Deps, - DepsMut, - Env, - MessageInfo, - QueryResponse, - Response, - StdResult, - Storage, + shd_entry_point, to_binary, Addr, Deps, DepsMut, Env, MessageInfo, QueryResponse, Response, + StdResult, Storage, }, utils::pad_handle_result, }; use crate::{ execute::{ - try_self_destruct, - try_toggle_status, - try_transfer_super, - try_update_registry, + try_self_destruct, try_toggle_status, try_transfer_super, try_update_registry, try_update_registry_bulk, }, query::query_validate_permission, diff --git a/contracts/admin/src/execute.rs b/contracts/admin/src/execute.rs index c9bff1d61..f23d22de0 100644 --- a/contracts/admin/src/execute.rs +++ b/contracts/admin/src/execute.rs @@ -1,7 +1,7 @@ +use crate::shared::{validate_permissions, ADMINS, PERMISSIONS, STATUS, SUPER}; use shade_protocol::admin::errors::{no_permission, unregistered_admin}; -use shade_protocol::c_std::{DepsMut, Response, Storage, Api, Addr, StdResult}; -use shade_protocol::admin::{RegistryAction, AdminAuthStatus}; -use crate::shared::{STATUS, ADMINS, PERMISSIONS, SUPER, validate_permissions}; +use shade_protocol::admin::{AdminAuthStatus, RegistryAction}; +use shade_protocol::c_std::{Addr, Api, DepsMut, Response, StdResult, Storage}; /// Performs one registry update. Cannot be run during a shutdown. pub fn try_update_registry( @@ -164,4 +164,4 @@ fn verify_registered(admins: &[Addr], user: &Addr) -> StdResult<()> { return Err(no_permission(user.as_str())); } Ok(()) -} \ No newline at end of file +} diff --git a/contracts/admin/src/shared.rs b/contracts/admin/src/shared.rs index e43d8aea3..cb73a4be1 100644 --- a/contracts/admin/src/shared.rs +++ b/contracts/admin/src/shared.rs @@ -1,6 +1,9 @@ use shade_protocol::c_std::Addr; -use shade_protocol::{admin::{AdminAuthStatus, errors::invalid_permission_format}, c_std::StdResult}; -use shade_protocol::utils::storage::plus::{Map, Item}; +use shade_protocol::utils::storage::plus::{Item, Map}; +use shade_protocol::{ + admin::{errors::invalid_permission_format, AdminAuthStatus}, + c_std::StdResult, +}; /// Maps user to permissions for which they have user. pub const PERMISSIONS: Map<&Addr, Vec> = Map::new("permissions"); @@ -20,17 +23,13 @@ pub fn validate_permissions(permissions: &[String]) -> StdResult<()> { pub fn is_valid_permission(permission: &str) -> StdResult<()> { if permission.len() <= 10 { - return Err(invalid_permission_format( - permission - )); + return Err(invalid_permission_format(permission)); } let valid_chars = permission.bytes().all(|byte| { (b'A'..=b'Z').contains(&byte) || (b'0'..=b'9').contains(&byte) || b'_'.eq(&byte) }); if !valid_chars { - return Err(invalid_permission_format( - permission - )); + return Err(invalid_permission_format(permission)); } Ok(()) -} \ No newline at end of file +} diff --git a/contracts/admin/src/test.rs b/contracts/admin/src/test.rs index 56f486180..fa6eb5c6b 100644 --- a/contracts/admin/src/test.rs +++ b/contracts/admin/src/test.rs @@ -1,19 +1,10 @@ -use crate::{ - shared::is_valid_permission, -}; +use crate::shared::is_valid_permission; use rstest::*; use shade_multi_test::multi::admin::Admin; use shade_protocol::{ admin::{ - AdminAuthStatus, - AdminsResponse, - ConfigResponse, - ExecuteMsg, - InstantiateMsg, - PermissionsResponse, - QueryMsg, - RegistryAction, - ValidateAdminPermissionResponse, + AdminAuthStatus, AdminsResponse, ConfigResponse, ExecuteMsg, InstantiateMsg, + PermissionsResponse, QueryMsg, RegistryAction, ValidateAdminPermissionResponse, }, c_std::Addr, multi_test::App, @@ -43,51 +34,80 @@ fn test_is_valid_permission(#[case] permission: String, #[case] is_valid: bool) #[case(AdminAuthStatus::Maintenance, vec![true, true, true, false, true, true, true])] #[case(AdminAuthStatus::Shutdown, vec![false, false, false, false, false, false, true])] fn test_status(#[case] status: AdminAuthStatus, #[case] expect_success: Vec) { - //init - let mut chain: App = App::default(); - let contract = InstantiateMsg { super_admin: None } - .test_init( - Admin::default(), - &mut chain, - Addr::unchecked("admin"), - "admin_contract", - &[], - ) - .unwrap(); - //set state - ExecuteMsg::ToggleStatus { new_status: status }.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]).unwrap(); - - //register 'super' as admin - let action = RegistryAction::RegisterAdmin { user: "super".to_string() }; - let result = ExecuteMsg::UpdateRegistry { action: action.clone() }.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(0).unwrap()); - - //test bulk update - let actions = vec![action.clone()]; - let result = ExecuteMsg::UpdateRegistryBulk { actions }.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(1).unwrap()); - - //set super admin to 'super' - let result = ExecuteMsg::TransferSuper { new_super: "super".to_string() }.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(2).unwrap()); - - //register 'admin' as admin without being the super user - let action = RegistryAction::RegisterAdmin { user: "admin".to_string() }; - let result = ExecuteMsg::UpdateRegistry { action: action.clone() }.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(3).unwrap()); - - //register admin as admin with correct permissions - let action = RegistryAction::RegisterAdmin { user: "admin".to_string() }; - let result = ExecuteMsg::UpdateRegistry { action: action.clone() }.test_exec(&contract, &mut chain, Addr::unchecked("super"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(4).unwrap()); - - //set super admin to 'admin' - let result = ExecuteMsg::TransferSuper { new_super: "admin".to_string() }.test_exec(&contract, &mut chain, Addr::unchecked("super"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(5).unwrap()); - - //self destruct - let result = ExecuteMsg::SelfDestruct { }.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); - assert_eq!(&result.is_ok(), expect_success.get(6).unwrap()); + //init + let mut chain: App = App::default(); + let contract = InstantiateMsg { super_admin: None } + .test_init( + Admin::default(), + &mut chain, + Addr::unchecked("admin"), + "admin_contract", + &[], + ) + .unwrap(); + //set state + ExecuteMsg::ToggleStatus { new_status: status } + .test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]) + .unwrap(); + + //register 'super' as admin + let action = RegistryAction::RegisterAdmin { + user: "super".to_string(), + }; + let result = ExecuteMsg::UpdateRegistry { + action: action.clone(), + } + .test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); + assert_eq!(&result.is_ok(), expect_success.get(0).unwrap()); + + //test bulk update + let actions = vec![action.clone()]; + let result = ExecuteMsg::UpdateRegistryBulk { actions }.test_exec( + &contract, + &mut chain, + Addr::unchecked("admin"), + &[], + ); + assert_eq!(&result.is_ok(), expect_success.get(1).unwrap()); + + //set super admin to 'super' + let result = ExecuteMsg::TransferSuper { + new_super: "super".to_string(), + } + .test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); + assert_eq!(&result.is_ok(), expect_success.get(2).unwrap()); + + //register 'admin' as admin without being the super user + let action = RegistryAction::RegisterAdmin { + user: "admin".to_string(), + }; + let result = ExecuteMsg::UpdateRegistry { + action: action.clone(), + } + .test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); + assert_eq!(&result.is_ok(), expect_success.get(3).unwrap()); + + //register admin as admin with correct permissions + let action = RegistryAction::RegisterAdmin { + user: "admin".to_string(), + }; + let result = ExecuteMsg::UpdateRegistry { + action: action.clone(), + } + .test_exec(&contract, &mut chain, Addr::unchecked("super"), &[]); + assert_eq!(&result.is_ok(), expect_success.get(4).unwrap()); + + //set super admin to 'admin' + let result = ExecuteMsg::TransferSuper { + new_super: "admin".to_string(), + } + .test_exec(&contract, &mut chain, Addr::unchecked("super"), &[]); + assert_eq!(&result.is_ok(), expect_success.get(5).unwrap()); + + //self destruct + let result = + ExecuteMsg::SelfDestruct {}.test_exec(&contract, &mut chain, Addr::unchecked("admin"), &[]); + assert_eq!(&result.is_ok(), expect_success.get(6).unwrap()); } #[rstest] @@ -235,19 +255,15 @@ fn test_permissions( } // Check that only super admin chan do this - assert!( - ExecuteMsg::UpdateRegistryBulk { - actions: actions.clone() - } - .test_exec(&admin, &mut chain, Addr::unchecked("user"), &[]) - .is_err() - ); + assert!(ExecuteMsg::UpdateRegistryBulk { + actions: actions.clone() + } + .test_exec(&admin, &mut chain, Addr::unchecked("user"), &[]) + .is_err()); - assert!( - ExecuteMsg::UpdateRegistryBulk { actions } - .test_exec(&admin, &mut chain, Addr::unchecked("admin"), &[]) - .is_ok() - ); + assert!(ExecuteMsg::UpdateRegistryBulk { actions } + .test_exec(&admin, &mut chain, Addr::unchecked("admin"), &[]) + .is_ok()); // Confirm that all permissions are set for permission in permissions.iter() { @@ -282,21 +298,17 @@ fn test_permissions( }) .collect(); - assert!( - ExecuteMsg::UpdateRegistryBulk { - actions: revoke_actions.clone() - } - .test_exec(&admin, &mut chain, Addr::unchecked("user"), &[]) - .is_err() - ); + assert!(ExecuteMsg::UpdateRegistryBulk { + actions: revoke_actions.clone() + } + .test_exec(&admin, &mut chain, Addr::unchecked("user"), &[]) + .is_err()); - assert!( - ExecuteMsg::UpdateRegistryBulk { - actions: revoke_actions - } - .test_exec(&admin, &mut chain, Addr::unchecked("admin"), &[]) - .is_ok() - ); + assert!(ExecuteMsg::UpdateRegistryBulk { + actions: revoke_actions + } + .test_exec(&admin, &mut chain, Addr::unchecked("admin"), &[]) + .is_ok()); for permission in permissions.iter() { // Check that the permissions are correctly returned diff --git a/makefile b/makefile index bb62f3e4e..c6303b070 100755 --- a/makefile +++ b/makefile @@ -13,22 +13,19 @@ rm ./$(1).wasm endef CONTRACTS = \ - airdrop governance \ - treasury treasury_manager scrt_staking rewards_emission \ - oracle snip20 query_auth sky peg_stability admin\ - mock_band mock_secretswap_pair mock_sienna_pair mock_adapter\ - mock_stkd_derivative basic_staking snip20_migration lp_shdswap stkd_scrt\ + airdrop treasury treasury_manager scrt_staking \ + snip20 query_auth admin \ + mock_sienna_pair mock_adapter \ + mock_stkd_derivative basic_staking snip20_migration stkd_scrt \ snip20_derivative -PACKAGES = \ - shade_protocol contract_harness cosmwasm_math_compat \ - network_integration network_tester secretcli +PACKAGES = shade_protocol contract_harness cosmwasm_math_compat release: setup ${build-release} @$(MAKE) compress_all -dao: treasury treasury_manager scrt_staking rewards_emission +dao: treasury treasury_manager scrt_staking compress_all: setup @$(MAKE) $(addprefix compress-,$(CONTRACTS)) diff --git a/packages/multi_test/Cargo.toml b/packages/multi_test/Cargo.toml index 8a40f9d85..af3b535b1 100644 --- a/packages/multi_test/Cargo.toml +++ b/packages/multi_test/Cargo.toml @@ -20,7 +20,7 @@ snip20 = ["dep:snip20"] #mock_band= ["dep:mock_band"] mock_stkd = ["dep:mock_stkd"] mock_sienna = ["dep:mock_sienna"] -governance = ["dep:governance"] +# governance = ["dep:governance"] # snip20_staking = ["dep:spip_stkd_0"] # scrt_staking = ["dep:scrt_staking"] # bonds = ["dep:bonds"] @@ -32,7 +32,7 @@ treasury_manager = ["dep:treasury_manager"] stkd_scrt = ["dep:stkd_scrt"] dao = ["mock_adapter", "treasury", "treasury_manager", "snip20"] # shade-oracles = ["dep:shade-oracles"] -peg_stability = ["dep:peg_stability"] +# peg_stability = ["dep:peg_stability"] snip20_migration = ["dep:snip20_migration"] [dependencies] @@ -42,7 +42,7 @@ snip20 = { version = "0.1.0", path = "../../contracts/snip20", optional = true } #mint = { version = "0.1.0", path = "../../contracts/mint", optional = true } #oracle = { version = "0.1.0", path = "../../contracts/oracle", optional = true } #mock_band = { version = "0.1.0", path = "../../contracts/mock_band", optional = true } -governance = { version = "0.1.0", path = "../../contracts/governance", optional = true } +# governance = { version = "0.1.0", path = "../../contracts/governance", optional = true } basic_staking = { version = "0.1.0", path = "../../contracts/basic_staking", optional = true } # spip_stkd_0 = { version = "0.1.0", path = "../../contracts/snip20_staking", optional = true } # bonds = { version = "0.1.0", path = "../../contracts/bonds", optional = true } @@ -53,7 +53,7 @@ scrt_staking = { version = "0.1.0", path = "../../contracts/dao/scrt_staking", o treasury = { version = "0.1.0", path = "../../contracts/dao/treasury", optional = true } treasury_manager = { version = "0.1.0", path = "../../contracts/dao/treasury_manager", optional = true } admin = { version = "0.2.0", path = "../../contracts/admin", optional = true } -peg_stability = { version = "0.1.0", path = "../../contracts/peg_stability", optional = true } +# peg_stability = { version = "0.1.0", path = "../../contracts/peg_stability", optional = true } mock_stkd = { version = "0.1.0", package = "mock_stkd_derivative", path = "../../contracts/mock/mock_stkd_derivative", optional = true } mock_sienna = { version = "0.1.0", package = "mock_sienna_pair", path = "../../contracts/mock/mock_sienna_pair", optional = true } snip20_migration = { version = "0.1.0", path = "../../contracts/snip20_migration", optional = true } diff --git a/packages/shade_protocol/Cargo.toml b/packages/shade_protocol/Cargo.toml index 5e7ff80fc..61c1643be 100644 --- a/packages/shade_protocol/Cargo.toml +++ b/packages/shade_protocol/Cargo.toml @@ -73,8 +73,8 @@ scrt_staking = ["adapter", "treasury"] stkd_scrt = ["adapter"] treasury = ["adapter", "dao-utils"] treasury_manager = ["adapter"] -rewards_emission = ["adapter"] -lp_shdswap = ["interface"] +# rewards_emission = ["adapter"] +# lp_shdswap = ["interface"] adapter = ["interface"] manager = ["interface"] snip20 = ["query_auth_impl", "dep:base64"]