Skip to content

Commit

Permalink
Remove value calculation logic from proxy contract (#432)
Browse files Browse the repository at this point in the history
* Remove value calculation logic from proxy

* update changelog

* remove holding amount query

* move ans_balance to the AnsHost API

* changelog update

* update migrate methods

* update snapshots

---------

Co-authored-by: CyberHoward <[email protected]>
  • Loading branch information
Buckram123 and CyberHoward authored Aug 14, 2024
1 parent 7c128cd commit bdf8c26
Show file tree
Hide file tree
Showing 94 changed files with 87 additions and 3,378 deletions.
4 changes: 1 addition & 3 deletions framework/contracts/account/manager/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use abstract_std::{
salt::generate_instantiate_salt,
validation::{validate_description, validate_link, validate_name},
version_control::VersionControlContract,
AccountId, AssetEntry,
AccountId,
},
proxy::{state::ACCOUNT_ID, ExecuteMsg as ProxyMsg},
version_control::ModuleResponse,
Expand Down Expand Up @@ -290,7 +290,6 @@ pub fn create_sub_account(
name: String,
description: Option<String>,
link: Option<String>,
base_asset: Option<AssetEntry>,
namespace: Option<String>,
install_modules: Vec<ModuleInstallConfig>,
account_id: Option<u32>,
Expand All @@ -307,7 +306,6 @@ pub fn create_sub_account(
name,
description,
link,
base_asset,
namespace,
install_modules,
account_id: account_id.map(AccountId::local),
Expand Down
2 changes: 0 additions & 2 deletions framework/contracts/account/manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ pub fn execute(mut deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg)
name,
description,
link,
base_asset,
namespace,
install_modules,
account_id,
Expand All @@ -157,7 +156,6 @@ pub fn execute(mut deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg)
name,
description,
link,
base_asset,
namespace,
install_modules,
account_id,
Expand Down
44 changes: 2 additions & 42 deletions framework/contracts/account/manager/src/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,57 +1,17 @@
use abstract_std::{
manager::{
state::{AccountInfo, CONFIG, INFO},
MigrateMsg,
},
objects::{gov_type::GovernanceDetails, module_version::assert_contract_upgrade, ownership},
MANAGER,
manager::MigrateMsg, objects::module_version::assert_contract_upgrade, MANAGER,
};
use cosmwasm_std::{DepsMut, Env};
use cw2::set_contract_version;
use cw_storage_plus::Item;
use semver::Version;

use crate::{
commands::ManagerResponse,
contract::{ManagerResult, CONTRACT_VERSION},
};

/// Abstract Account details.
#[cosmwasm_schema::cw_serde]
struct AccountInfo0_22 {
pub name: String,
pub governance_details: GovernanceDetails<String>,
pub chain_id: String,
pub description: Option<String>,
pub link: Option<String>,
}

const INFO0_22: Item<AccountInfo0_22> = Item::new("\u{0}{4}info");

#[cfg_attr(feature = "export", cosmwasm_std::entry_point)]
pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> ManagerResult {
// If old account info stored that includes governance details
// We need to update account info and store new ownership
if let Some(info) = INFO0_22.may_load(deps.storage)? {
// Update account info
INFO.save(
deps.storage,
&AccountInfo {
name: info.name,
chain_id: info.chain_id,
description: info.description,
link: info.link,
},
)?;
// Update ownership
let config = CONFIG.load(deps.storage)?;
ownership::initialize_owner(
deps.branch(),
info.governance_details,
config.version_control_address,
)?;
}

pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> ManagerResult {
let version: Version = CONTRACT_VERSION.parse().unwrap();

assert_contract_upgrade(deps.storage, MANAGER, version)?;
Expand Down
1 change: 0 additions & 1 deletion framework/contracts/account/manager/tests/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ fn subaccount_adapter_ownership() -> AResult {
None,
None,
None,
None,
&[],
)?;

Expand Down
1 change: 0 additions & 1 deletion framework/contracts/account/manager/tests/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ fn subaccount_app_ownership() -> AResult {
None,
None,
None,
None,
&[],
)?;

Expand Down
7 changes: 0 additions & 7 deletions framework/contracts/account/manager/tests/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ fn renounce_cleans_namespace() -> AResult {
description: None,
link: None,
namespace: Some("bar".to_owned()),
base_asset: None,
install_modules: vec![],
account_id: None,
},
Expand Down Expand Up @@ -477,7 +476,6 @@ fn nft_owner_success() -> Result<(), Error> {
description: None,
link: None,
namespace: None,
base_asset: None,
install_modules: vec![],
account_id: None,
},
Expand Down Expand Up @@ -578,7 +576,6 @@ fn nft_owner_immutable() -> Result<(), Error> {
description: None,
link: None,
namespace: None,
base_asset: None,
install_modules: vec![],
account_id: None,
},
Expand Down Expand Up @@ -624,7 +621,6 @@ fn nft_owner_immutable() -> Result<(), Error> {
description: None,
link: None,
namespace: None,
base_asset: None,
install_modules: vec![],
account_id: None,
},
Expand Down Expand Up @@ -797,7 +793,6 @@ fn can_take_any_last_two_billion_accounts() -> AResult {
description: None,
link: None,
namespace: Some("bar".to_owned()),
base_asset: None,
install_modules: vec![],
account_id: Some(2147483648),
},
Expand All @@ -813,7 +808,6 @@ fn can_take_any_last_two_billion_accounts() -> AResult {
description: None,
link: None,
namespace: Some("bar".to_owned()),
base_asset: None,
install_modules: vec![],
// same id
account_id: Some(2147483648),
Expand Down Expand Up @@ -843,7 +837,6 @@ fn increment_not_effected_by_claiming() -> AResult {
description: None,
link: None,
namespace: Some("bar".to_owned()),
base_asset: None,
install_modules: vec![],
account_id: Some(2147483648),
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bdf8c26

Please sign in to comment.