Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Abstract 0.25 #19

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
msrv: [1.72.0] # cosmrs v0.15.0 requires 1.72.0 or newer
msrv: [1.76.0] # cosmrs v0.15.0 requires 1.76.0 or newer
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v4
Expand Down
29 changes: 15 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,32 @@ members = ["contracts/*", "packages/ibcmail", "tests"]
resolver = "2"

[workspace.package]
version = "0.2.0"
version = "0.3.1"

[workspace.dependencies]
cosmwasm-std = "1.5.3"
cosmwasm-schema = "1.5.3"
cw-controllers = "1.1.2"
cw-storage-plus = "1.2.0"
cosmwasm-std = { version = "2.0.7", features = ["cosmwasm_2_0"] }
cosmwasm-schema = { version = "2.0.7" }
cw-controllers = { version = "2.0.0" }
cw-storage-plus = "2.0.0"
thiserror = "1.0.50"
cw-paginate = "0.2.1"
cw-paginate = "2.0.0"
schemars = "0.8"
cw-asset = "3.0.0"
cw-semver = { version = "1.0", features = ["serde"] }
cw-orch = "0.24.1"
cw-asset = "4.0.0"
cw-orch = "0.26.0"
cw-orch-interchain = { version = "0.8.1" }
abstract-cw-orch-polytone = "6.0.0"

ibcmail = { path = "packages/ibcmail", package = "ibcmail" }
client = { path = "contracts/client", package = "ibcmail-client" }
server = { path = "contracts/server", package = "ibcmail-server" }
abstract-client = "0.23.0"
abstract-app = "0.23.0"
abstract-adapter = "0.23.0"
abstract-interface = "0.23.0"
abstract-client = { version = "0.25.0", git = "https://github.com/AbstractSDK/abstract", tag = "v0.25.0" }
abstract-app = { version = "0.25.0", git = "https://github.com/AbstractSDK/abstract", tag = "v0.25.0" }
abstract-adapter = { version = "0.25.0", git = "https://github.com/AbstractSDK/abstract", tag = "v0.25.0" }
abstract-interface = { version = "0.25.0", git = "https://github.com/AbstractSDK/abstract", tag = "v0.25.0" }
speculoos = "0.11.0"
semver = "1.0"
dotenv = "0.15.0"
env_logger = "0.10.0"
env_logger = { package = "pretty_env_logger", version = "0.5.0" }
clap = "4.3.7"
const_format = "0.2.32"

Expand Down
2 changes: 2 additions & 0 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0e19c3986fb452816aabde50ee78302fbd9dc444bcb63090e43dcbb6417aa9b1 ibcmail_client.wasm
29576933ccd938bf26b4fa2837cc62b4babbe0d373429218ce81bb55a704aeb4 ibcmail_server.wasm
Binary file modified artifacts/ibcmail_client.wasm
100755 → 100644
Binary file not shown.
Binary file modified artifacts/ibcmail_server.wasm
100755 → 100644
Binary file not shown.
6 changes: 5 additions & 1 deletion contracts/client/examples/local_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ fn main() -> anyhow::Result<()> {

// Get the [`Publisher`] that owns the namespace.
// If there isn't one, it creates an Account and claims the namespace.
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;

// Ensure the current sender owns the namespace
if publisher.account().owner()? != daemon.sender().address() {
Expand Down
7 changes: 5 additions & 2 deletions contracts/client/examples/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//! $ just publish uni-6 osmo-test-5
//! ```

use abstract_app::objects::module::ModuleVersion;
use abstract_app::objects::namespace::Namespace;
use abstract_client::{AbstractClient, Publisher};
use clap::Parser;
Expand All @@ -35,7 +34,11 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
let abstract_client: AbstractClient<Daemon> = AbstractClient::new(chain.clone())?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher = Publisher::new(&publisher_acc)?;

if publisher.account().owner()? != chain.sender().address() {
panic!("The current sender can not publish to this namespace. Please use the wallet that owns the Account that owns the Namespace.")
Expand Down
2 changes: 1 addition & 1 deletion contracts/client/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
"null"
]
},
"version_control_address": {
"registry_address": {
"type": [
"string",
"null"
Expand Down
4 changes: 2 additions & 2 deletions contracts/client/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"required": [
"account_base",
"ans_host_address",
"version_control_address"
"registry_address"
],
"properties": {
"account_base": {
Expand All @@ -62,7 +62,7 @@
"ans_host_address": {
"type": "string"
},
"version_control_address": {
"registry_address": {
"type": "string"
}
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/client/src/dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use abstract_app::objects::dependency::StaticDependency;
#[cfg(feature = "interface")]
use abstract_app::{objects::module::ModuleInfo, std::manager::ModuleInstallConfig};
use abstract_app::{objects::module::ModuleInfo, std::account::ModuleInstallConfig};
use ibcmail::IBCMAIL_SERVER_ID;

pub const MAIL_SERVER_DEP: StaticDependency =
Expand Down
27 changes: 24 additions & 3 deletions contracts/client/src/handlers/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use abstract_app::sdk::cw_helpers::load_many;
use cosmwasm_std::{to_json_binary, Binary, Deps, Env};
use cw_storage_plus::Bound;
use cosmwasm_schema::serde::de::DeserializeOwned;
use cosmwasm_schema::serde::Serialize;
use cosmwasm_std::{to_json_binary, Binary, Deps, Env, StdResult, Storage};
use cw_storage_plus::{Bound, Map, PrimaryKey};
use ibcmail::{
client::{
error::ClientError,
Expand Down Expand Up @@ -41,6 +42,26 @@ pub fn query_handler(
.map_err(Into::into)
}

/// Load a batch of values by their keys from a [`Map`].
pub fn load_many<'a, K, V>(
map: Map<K, V>,
storage: &dyn Storage,
keys: Vec<K>,
) -> StdResult<Vec<(K, V)>>
where
K: PrimaryKey<'a>,
V: DeserializeOwned + Serialize,
{
let mut res: Vec<(K, V)> = vec![];

for key in keys.into_iter() {
let value = map.load(storage, key.clone())?;
res.push((key, value));
}

Ok(res)
}

fn query_messages(
deps: Deps,
status: MessageStatus,
Expand Down
6 changes: 5 additions & 1 deletion contracts/server/examples/local_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ fn main() -> anyhow::Result<()> {

// Get the [`Publisher`] that owns the namespace.
// If there isn't one, it creates an Account and claims the namespace.
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;

// Ensure the current sender owns the namespace
if publisher.account().owner()? != daemon.sender().address() {
Expand Down
6 changes: 5 additions & 1 deletion contracts/server/examples/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
let abstract_client: AbstractClient<Daemon> = AbstractClient::new(chain.clone())?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher = Publisher::new(&publisher_acc)?;

if publisher.account().owner()? != chain.sender().address() {
panic!("The current sender can not publish to this namespace. Please use the wallet that owns the Account that owns the Namespace.")
Expand Down
6 changes: 3 additions & 3 deletions contracts/server/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
"additionalProperties": false,
"definitions": {
"BaseInstantiateMsg": {
"description": "Used by Abstract to instantiate the contract The contract is then registered on the version control contract using [`crate::version_control::ExecuteMsg::ProposeModules`].",
"description": "Used by Abstract to instantiate the contract The contract is then registered on the version control contract using [`crate::registry::ExecuteMsg::ProposeModules`].",
"type": "object",
"required": [
"ans_host_address",
"version_control_address"
"registry_address"
],
"properties": {
"ans_host_address": {
"description": "Used to easily perform address translation",
"type": "string"
},
"version_control_address": {
"registry_address": {
"description": "Used to verify senders",
"type": "string"
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/server/schema/raw/response_to_base_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"required": [
"ans_host_address",
"dependencies",
"version_control_address"
"registry_address"
],
"properties": {
"ans_host_address": {
Expand All @@ -17,7 +17,7 @@
"type": "string"
}
},
"version_control_address": {
"registry_address": {
"$ref": "#/definitions/Addr"
}
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/server/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub type ServerResult<T = Response> = Result<T, ServerError>;
const ADAPTER: Adapter = Adapter::new(IBCMAIL_SERVER_ID, APP_VERSION, None)
.with_execute(handlers::execute_handler)
.with_module_ibc(handlers::module_ibc_handler)
.with_dependencies(&[MAIL_CLIENT]);
.with_dependencies(&[]);

// Export handlers
#[cfg(feature = "export")]
Expand Down
6 changes: 3 additions & 3 deletions contracts/server/src/handlers/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use abstract_adapter::objects::TruncatedChainId;
use abstract_adapter::sdk::{
features::ModuleIdentification, AccountVerification, ModuleRegistryInterface,
};
use abstract_adapter::std::version_control::AccountBase;
use abstract_adapter::std::registry::Account;
use abstract_adapter::std::{
ibc_client,
objects::{account::AccountTrace, module::ModuleInfo},
version_control::NamespaceResponse,
registry::NamespaceResponse,
IBC_CLIENT,
};
use abstract_adapter::traits::AbstractResponse;
Expand Down Expand Up @@ -197,7 +197,7 @@ fn route_to_local_account(

// ANCHOR: set_acc_and_send
// Set target account for actions, is used by APIs to retrieve mail client address.
let recipient_acc: AccountBase = app.account_registry(deps)?.account_base(&account_id)?;
let recipient_acc: Account = app.account_registry(deps)?.account(&account_id)?;
app.target_account = Some(recipient_acc);

let mail_client: MailClient<_> = app.mail_client(deps);
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ wasm:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
${image}:0.14.0
${image}:0.16.0

# Generate the schemas for the client contract
#schema:
Expand Down
1 change: 0 additions & 1 deletion packages/ibcmail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ cw-orch = { workspace = true }
thiserror = { workspace = true }
cw-asset = { workspace = true }
cw-controllers = { workspace = true }
cw-semver = { workspace = true }
const_format = { workspace = true }
12 changes: 8 additions & 4 deletions packages/ibcmail/src/client/api.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use abstract_adapter::{sdk::AbstractSdkResult, std::objects::module::ModuleId};

use abstract_app::sdk::AppInterface;

use cosmwasm_std::{CosmosMsg, Deps};
use abstract_app::std::app;
use cosmwasm_std::{wasm_execute, CosmosMsg, Deps};

use crate::{
client::msg::ClientExecuteMsg, Header, IbcMailMessage, Message, Route, IBCMAIL_CLIENT_ID,
Expand All @@ -11,7 +11,7 @@
// API for Abstract SDK users
pub trait ClientInterface: AppInterface {
/// Construct a new mail_client interface.
fn mail_client<'a>(&'a self, deps: Deps<'a>) -> MailClient<Self> {

Check failure on line 14 in packages/ibcmail/src/client/api.rs

View workflow job for this annotation

GitHub Actions / clippy

elided lifetime has a name

error: elided lifetime has a name --> packages/ibcmail/src/client/api.rs:14:63 | 14 | fn mail_client<'a>(&'a self, deps: Deps<'a>) -> MailClient<Self> { | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` | = note: `-D elided-named-lifetimes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(elided_named_lifetimes)]`
MailClient {
base: self,
deps,
Expand All @@ -29,7 +29,7 @@
pub deps: Deps<'a>,
}

impl<'a, T: ClientInterface> MailClient<'a, T> {

Check failure on line 32 in packages/ibcmail/src/client/api.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'a

error: the following explicit lifetimes could be elided: 'a --> packages/ibcmail/src/client/api.rs:32:6 | 32 | impl<'a, T: ClientInterface> MailClient<'a, T> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `-D clippy::needless-lifetimes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` help: elide the lifetimes | 32 - impl<'a, T: ClientInterface> MailClient<'a, T> { 32 + impl<T: ClientInterface> MailClient<'_, T> { |
/// returns the module id
fn module_id(&self) -> ModuleId {
self.module_id
Expand All @@ -37,8 +37,12 @@

// Execute a request on the ibc mail client
fn request(&self, msg: ClientExecuteMsg) -> AbstractSdkResult<CosmosMsg> {
let apps = self.base.apps(self.deps);
apps.execute(self.module_id(), msg)
let app_msg: app::ExecuteMsg<_> = msg.into();

let modules = self.base.modules(self.deps);
let app_address = modules.module_address(self.module_id())?;

Ok(wasm_execute(app_address, &app_msg, vec![])?.into())
}

/// Send message
Expand Down
4 changes: 2 additions & 2 deletions packages/ibcmail/src/client/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct ClientInstantiateMsg {}
// # ANCHOR: execute_msg
#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::ExecuteFns)]
#[cw_orch(impl_into(ExecuteMsg))]
// #[cw_orch(impl_into(ExecuteMsg))]
pub enum ClientExecuteMsg {
/// Receive a message from the server
ReceiveMessage(IbcMailMessage),
Expand All @@ -30,7 +30,7 @@ pub enum ClientExecuteMsg {
/// App query messages
#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::QueryFns)]
#[cw_orch(impl_into(QueryMsg))]
// #[cw_orch(impl_into(QueryMsg))]
#[derive(QueryResponses)]
pub enum ClientQueryMsg {
#[returns(MessagesResponse)]
Expand Down
12 changes: 9 additions & 3 deletions packages/ibcmail/src/server/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct ServerInstantiateMsg {}

/// App execute messages
#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::ExecuteFns)]
pub enum ServerExecuteMsg {
/// Route a message
ProcessMessage {
Expand All @@ -29,14 +30,19 @@ pub enum ServerIbcMessage {

/// App query messages
#[cosmwasm_schema::cw_serde]
#[derive(cw_orch::QueryFns)]
#[cw_orch(impl_into(QueryMsg))]
#[derive(QueryResponses)]
#[derive(QueryResponses, cw_orch::QueryFns)]
// #[cw_orch(impl_into(QueryMsg))]
pub enum ServerQueryMsg {
#[returns(ConfigResponse)]
Config {},
}

// impl From<ServerQueryMsg> for QueryMsg {
// fn from(msg: ServerQueryMsg) -> Self {
// QueryMsg::Module(msg)
// }
// }

#[cosmwasm_schema::cw_serde]
pub struct ConfigResponse {}

Expand Down
10 changes: 4 additions & 6 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ default = []

[dependencies]
abstract-app = { workspace = true, features = ["test-utils"] }
abstract-cw-orch-polytone = "4.0.1"
abstract-cw-orch-polytone = { workspace = true }
abstract-interface = { workspace = true }
abstract-interchain-tests = { git = "https://github.com/AbstractSDK/abstract", version = "0.23.0", tag = "v0.23.0" }
#abstract-interchain-tests = { git = "https://github.com/AbstractSDK/abstract", version = "0.22.1", branch = "removemm" }
#cw-orch = { workspace = true }
cw-orch-interchain = { version = "0.3.1", features = ["daemon"] }
cw-orch-interchain = { workspace = true, features = ["daemon"] }
cw-orch = { workspace = true, features = ["daemon"] }
ibcmail = { workspace = true }
cosmwasm-std = { workspace = true }
Expand All @@ -30,7 +28,7 @@ client = { workspace = true, features = ["interface"] }
speculoos = { workspace = true }
server = { workspace = true, features = ["interface"] }
abstract-client = { workspace = true, features = ["interchain"] }
clap.workspace = true
env_logger = "0.11.3"
clap = { workspace = true, features = ["derive"] }
env_logger = { workspace = true }
dotenv = { workspace = true }
anyhow = "1.0.86"
6 changes: 3 additions & 3 deletions tests/src/bin/approve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use abstract_interface::Abstract;
use clap::Parser;
use cw_orch::{
anyhow,
environment::TxHandler,
prelude::{*, DaemonBuilder, networks::parse_network},
prelude::{networks::parse_network, DaemonBuilder, *},
tokio::runtime::Runtime,
};

Expand All @@ -32,7 +31,8 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
// Create an [`AbstractClient`]
let abs = Abstract::new(chain.clone());

abs.version_control.approve_all_modules_for_namespace(app_namespace)?;
abs.registry
.approve_all_modules_for_namespace(app_namespace)?;
}
Ok(())
}
Expand Down
Loading
Loading