Skip to content

Commit

Permalink
Rename version control to registry (#479)
Browse files Browse the repository at this point in the history
* initial renames

* some auto-renames

* modules tests

* fix xion test

* name optional

* cleanup

* nit rename fn

* formatting [skip ci]

* update workspace hack

* fmt

* fix cw-blob version

* fix clippy

---------

Co-authored-by: cyberhoward <[email protected]>
  • Loading branch information
Buckram123 and CyberHoward authored Oct 2, 2024
1 parent 4ccfe7b commit 7f11b2f
Show file tree
Hide file tree
Showing 161 changed files with 1,164 additions and 1,431 deletions.
353 changes: 93 additions & 260 deletions framework/Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract-standalone = { path = "packages/abstract-standalone" }
abstract-interface = { path = "packages/abstract-interface" }
module-factory = { package = "abstract-module-factory", path = "contracts/native/module-factory" }
ans-host = { package = "abstract-ans-host", path = "contracts/native/ans-host" }
version-control = { package = "abstract-version-control", path = "contracts/native/version-control" }
registry = { package = "abstract-registry", path = "contracts/native/registry" }

# Ibc
ibc-client = { package = "abstract-ibc-client", path = "contracts/native/ibc-client" }
Expand Down Expand Up @@ -100,7 +100,7 @@ speculoos = "0.11.0"
anyhow = "1"

# Predictable abstract addresses
cw-blob = { version = "0.1.1" }
cw-blob = { version = "=0.1.1" }

[profile.dev]
opt-level = 1
Expand Down
2 changes: 1 addition & 1 deletion framework/contracts/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ abstract-interface = { workspace = true }
cw-orch = { workspace = true, features = ["snapshot-testing"] }
anyhow = { workspace = true }
ans-host = { workspace = true }
version-control = { workspace = true }
registry = { workspace = true }
module-factory = { workspace = true }
rstest = { workspace = true }
speculoos = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions framework/contracts/account/src/absacc/auth/sign_arb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod tests {
use super::super::util;
use crate::contract::instantiate;
use abstract_std::account::InstantiateMsg;
use abstract_std::version_control::state::LOCAL_ACCOUNT_SEQUENCE;
use abstract_std::registry::state::LOCAL_ACCOUNT_SEQUENCE;
use abstract_testing::abstract_mock_querier_builder;
use abstract_testing::prelude::AbstractMockAddrs;
use base64::{engine::general_purpose, Engine as _};
Expand Down Expand Up @@ -100,7 +100,7 @@ mod tests {
deps.api = deps.api.with_prefix("xion");
let abstr = AbstractMockAddrs::new(deps.api);
deps.querier = abstract_mock_querier_builder(deps.api)
.with_contract_item(&abstr.version_control, LOCAL_ACCOUNT_SEQUENCE, &0)
.with_contract_item(&abstr.registry, LOCAL_ACCOUNT_SEQUENCE, &0)
.build();
let mut env = mock_env();
// This is the local faucet address to simplify reuse
Expand Down
2 changes: 1 addition & 1 deletion framework/contracts/account/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ mod tests {
.is_err()
.is_equal_to(AccountError::Ownership(GovOwnershipError::NotOwner));

let vc_res = execute_as(deps.as_mut(), &abstr.version_control, msg.clone());
let vc_res = execute_as(deps.as_mut(), &abstr.registry, msg.clone());
assert_that!(&vc_res).is_err();

let owner_res = execute_as(deps.as_mut(), &owner, msg);
Expand Down
32 changes: 16 additions & 16 deletions framework/contracts/account/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use abstract_macros::abstract_response;
use abstract_sdk::{
feature_objects::VersionControlContract,
feature_objects::RegistryContract,
std::{
account::state::ACCOUNT_ID,
objects::validation::{validate_description, validate_link, validate_name},
Expand All @@ -19,7 +19,7 @@ use abstract_std::{
ownership::{self, GovOwnershipError},
AccountId,
},
version_control::state::LOCAL_ACCOUNT_SEQUENCE,
registry::state::LOCAL_ACCOUNT_SEQUENCE,
};
use cosmwasm_std::{
ensure_eq, wasm_execute, Addr, Binary, Coins, Deps, DepsMut, Env, MessageInfo, Reply, Response,
Expand Down Expand Up @@ -83,14 +83,14 @@ pub fn instantiate(
// Use CW2 to set the contract version, this is needed for migrations
cw2::set_contract_version(deps.storage, ACCOUNT, CONTRACT_VERSION)?;

let version_control = VersionControlContract::new(deps.api)?;
let registry = RegistryContract::new(deps.api)?;
let module_factory = ModuleFactoryContract::new(deps.api)?;

let account_id = match account_id {
Some(account_id) => account_id,
None => AccountId::local(
LOCAL_ACCOUNT_SEQUENCE.query(&deps.querier, version_control.address.clone())?,
),
None => {
AccountId::local(LOCAL_ACCOUNT_SEQUENCE.query(&deps.querier, registry.address.clone())?)
}
};

let mut response = AccountResponse::new(
Expand All @@ -105,7 +105,7 @@ pub fn instantiate(
validate_description(description.as_deref())?;
validate_link(link.as_deref())?;
if let Some(name) = name.as_deref() {
validate_name(&name)?;
validate_name(name)?;
}

let account_info = AccountInfo {
Expand All @@ -121,7 +121,7 @@ pub fn instantiate(

let governance = owner
.clone()
.verify(deps.as_ref(), version_control.address.clone())?;
.verify(deps.as_ref(), registry.address.clone())?;
match governance {
// Check if the caller is the manager the proposed owner account when creating a sub-account.
// This prevents other users from creating sub-accounts for accounts they don't own.
Expand Down Expand Up @@ -181,15 +181,15 @@ pub fn instantiate(
// TODO: support no owner here (ownership handled in SUDO)
// Or do we want to add a `Sudo` governance type?
owner.clone(),
version_control.address.clone(),
registry.address.clone(),
)?;

SUSPENSION_STATUS.save(deps.storage, &false)?;

response = response.add_attribute("owner".to_owned(), cw_gov_owner.owner.to_string());

let funds_for_namespace_fee = if namespace.is_some() {
version_control
registry
.namespace_registration_fee(&deps.querier)?
.into_iter()
.collect()
Expand All @@ -200,8 +200,8 @@ pub fn instantiate(
let mut total_fee = Coins::try_from(funds_for_namespace_fee.clone()).unwrap();

response = response.add_message(wasm_execute(
version_control.address,
&abstract_std::version_control::ExecuteMsg::AddAccount {
registry.address,
&abstract_std::registry::ExecuteMsg::AddAccount {
namespace,
creator: info.sender.to_string(),
},
Expand Down Expand Up @@ -324,13 +324,13 @@ pub fn execute(mut deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg)
remove_account_from_contracts(deps.branch())?
}
};
let version_control = VersionControlContract::new(deps.api)?;
let registry = RegistryContract::new(deps.api)?;

let new_owner_attributes = ownership::update_ownership(
deps,
&env.block,
&info.sender,
version_control.address,
registry.address,
action,
)?
.into_attributes();
Expand Down Expand Up @@ -497,8 +497,8 @@ mod tests {
assert!(resp.is_ok());

let expected_msg: CosmosMsg = wasm_execute(
abstr.version_control,
&abstract_std::version_control::ExecuteMsg::AddAccount {
abstr.registry,
&abstract_std::registry::ExecuteMsg::AddAccount {
creator: abstr.owner.to_string(),
namespace: None,
},
Expand Down
6 changes: 3 additions & 3 deletions framework/contracts/account/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use abstract_sdk::{std::objects::module::ModuleInfo, AbstractSdkError};
use abstract_std::{
objects::{validation::ValidationError, version_control::VersionControlError},
objects::{registry::RegistryError, validation::ValidationError},
AbstractError,
};
use cosmwasm_std::{Instantiate2AddressError, StdError};
Expand All @@ -27,14 +27,14 @@ pub enum AccountError {
Instantiate2AddressError(#[from] Instantiate2AddressError),

#[error("{0}")]
VersionControlError(#[from] VersionControlError),
RegistryError(#[from] RegistryError),

#[error("Your account is currently suspended")]
AccountSuspended {},

// ** Modules Error ** //
#[error("Failed to query modules to install: {error}")]
QueryModulesFailed { error: VersionControlError },
QueryModulesFailed { error: RegistryError },

#[error("Module with id: {0} is already installed")]
ModuleAlreadyInstalled(String),
Expand Down
21 changes: 10 additions & 11 deletions framework/contracts/account/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use abstract_std::{
module::{Module, ModuleInfo, ModuleVersion},
module_reference::ModuleReference,
ownership::{self},
registry::RegistryContract,
salt::generate_instantiate_salt,
storage_namespaces,
version_control::VersionControlContract,
},
version_control::ModuleResponse,
registry::ModuleResponse,
};
use cosmwasm_std::{
ensure, wasm_execute, Addr, Attribute, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut,
Expand Down Expand Up @@ -67,14 +67,14 @@ pub fn _install_modules(
let mut installed_modules = Vec::with_capacity(modules.len());
let mut manager_modules = Vec::with_capacity(modules.len());
let account_id = ACCOUNT_ID.load(deps.storage)?;
let version_control = VersionControlContract::new(deps.api)?;
let registry = RegistryContract::new(deps.api)?;

let canonical_module_factory = CanonicalAddr::from(native_addrs::MODULE_FACTORY_ADDR);
let module_factory_address = deps.api.addr_humanize(&canonical_module_factory)?;

let (infos, init_msgs): (Vec<_>, Vec<_>) =
modules.into_iter().map(|m| (m.module, m.init_msg)).unzip();
let modules = version_control
let modules = registry
.query_modules_configs(infos, &deps.querier)
.map_err(|error| AccountError::QueryModulesFailed { error })?;

Expand Down Expand Up @@ -203,7 +203,7 @@ pub fn uninstall_module(mut deps: DepsMut, info: MessageInfo, module_id: String)
crate::versioning::remove_as_dependent(deps.storage, &module_id, module_dependencies)?;

// Remove for proxy if needed
let vc = VersionControlContract::new(deps.api)?;
let vc = RegistryContract::new(deps.api)?;

let module = vc.query_module(
ModuleInfo::from_id(&module_data.module, module_data.version.into())?,
Expand Down Expand Up @@ -237,7 +237,7 @@ pub fn query_module(
old_contract_version: Option<ContractVersion>,
) -> Result<ModuleResponse, AccountError> {
// Construct feature object to access registry functions
let version_control = VersionControlContract::new(deps.api)?;
let registry = RegistryContract::new(deps.api)?;

let module = match &module_info.version {
ModuleVersion::Version(new_version) => {
Expand All @@ -254,13 +254,12 @@ pub fn query_module(
}
Module {
info: module_info.clone(),
reference: version_control
.query_module_reference_raw(&module_info, &deps.querier)?,
reference: registry.query_module_reference_raw(&module_info, &deps.querier)?,
}
}
ModuleVersion::Latest => {
// Query latest version of contract
version_control.query_module(module_info.clone(), &deps.querier)?
registry.query_module(module_info.clone(), &deps.querier)?
}
};

Expand All @@ -269,7 +268,7 @@ pub fn query_module(
info: module.info,
reference: module.reference,
},
config: version_control.query_config(module_info, &deps.querier)?,
config: registry.query_config(module_info, &deps.querier)?,
})
}

Expand Down Expand Up @@ -471,7 +470,7 @@ mod tests {
let msg = ExecuteMsg::UpdateInternalConfig(action_add);

// the version control can not call this
let res = execute_as(deps.as_mut(), &abstr.version_control, msg.clone());
let res = execute_as(deps.as_mut(), &abstr.registry, msg.clone());
assert_that!(&res).is_err();

// only the owner can
Expand Down
11 changes: 5 additions & 6 deletions framework/contracts/account/src/modules/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use abstract_std::{
module::ModuleInfo,
module_reference::ModuleReference,
ownership::{self},
registry::{RegistryContract, RegistryError},
storage_namespaces,
version_control::{VersionControlContract, VersionControlError},
},
ACCOUNT,
};
Expand Down Expand Up @@ -115,11 +115,10 @@ pub fn set_migrate_msgs_and_context(
migrate_msg: Option<Binary>,
msgs: &mut Vec<CosmosMsg>,
) -> Result<(), AccountError> {
let version_control = VersionControlContract::new(deps.api)?;
let registry = RegistryContract::new(deps.api)?;

let old_module_addr = load_module_addr(deps.storage, &module_info.id())?;
let old_module_cw2 =
query_module_version(deps.as_ref(), old_module_addr.clone(), &version_control)?;
let old_module_cw2 = query_module_version(deps.as_ref(), old_module_addr.clone(), &registry)?;
let requested_module = query_module(deps.as_ref(), module_info.clone(), Some(old_module_cw2))?;

let migrate_msgs = match requested_module.module.reference {
Expand Down Expand Up @@ -300,8 +299,8 @@ pub(crate) fn self_upgrade_msg(
});
Ok(migration_msg)
} else {
Err(AccountError::VersionControlError(
VersionControlError::InvalidReference(module_info),
Err(AccountError::RegistryError(
RegistryError::InvalidReference(module_info),
))
}
}
Expand Down
Loading

0 comments on commit 7f11b2f

Please sign in to comment.