Our ADOs have a set of execute and query messages referred to as the "base executes" and "base queries". These messages are common to every ADO in our Andromeda Digital Library (Except AMP ADOs). They are listed in the AndromedaMsg and AndromedaQuery enums which we will discuss next.
Migrate Message
All of our ADOs contain a migrate message to allowing migrating an ADO to a newer version:
pubfnmigrate(&self, deps:DepsMut, contract_name:&str, contract_version:&str, ) ->Result<Response, ContractError> {// New versionlet version:Version= contract_version.parse().map_err(from_semver)?;// Old versionlet stored =get_contract_version(deps.storage)?;let storage_version:Version= stored.version.parse().map_err(from_semver)?;let contract_name =if contract_name.starts_with("crates.io:andromeda-") { contract_name.strip_prefix("crates.io:andromeda-").unwrap() } elseif contract_name.starts_with("crates.io:") { contract_name.strip_prefix("crates.io:").unwrap() } else { contract_name };ensure!( stored.contract == contract_name,ContractError::CannotMigrate { previous_contract: stored.contract, } );// New version has to be newer/greater than the old versionensure!( storage_version < version,ContractError::CannotMigrate { previous_contract: stored.version, } );set_contract_version(deps.storage, contract_name, contract_version)?;Ok(Response::default()) }