Skip to content

ICA Client testing #486

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

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
38d7965
Cherry Pick
Kayanski Sep 18, 2024
e434b5f
new
Kayanski Sep 18, 2024
b627a91
added patch
Kayanski Sep 23, 2024
8e840d3
With new interchain version
Kayanski Sep 23, 2024
9bd87bb
Nit collection and module update
Kayanski Sep 24, 2024
15f490a
Merge remote-tracking branch 'origin/develop/v2' into nicolas/abs-534…
CyberHoward Sep 27, 2024
0771cca
Updated cw-orch
Kayanski Oct 4, 2024
f5682f4
Moved ica-client
Kayanski Oct 4, 2024
d922020
Fix clippy
Kayanski Oct 7, 2024
04c0bbf
Merge branch 'develop/v2' into nicolas/abs-534-review-interchain-abst…
Kayanski Oct 7, 2024
89182bb
Integration test start
Kayanski Oct 7, 2024
421021c
Fix and update
Kayanski Oct 8, 2024
743af86
Update cw-orch cw-orch-interchain, polytone
Kayanski Oct 8, 2024
340ab11
formatting [skip ci]
Kayanski Oct 8, 2024
279e7b1
Merge branch 'develop/v2' into nicolas/abs-534-review-interchain-abst…
Kayanski Oct 8, 2024
00d6584
Re-added cw-orch-proto dependent tests
Kayanski Oct 8, 2024
452add9
Merge branch 'nicolas/abs-534-review-interchain-abstract-testing-setu…
Kayanski Oct 8, 2024
42b837b
Merge remote-tracking branch 'origin/nicolas/abs-534-review-interchai…
Kayanski Oct 8, 2024
ba0fd34
small-wasm
Buckram123 Oct 8, 2024
b7e9d8c
compiling wasm
Kayanski Oct 9, 2024
1f41822
remove ibc client message
Buckram123 Oct 9, 2024
b253c0a
Avoid usage of instantiate msg for sub account creation
Buckram123 Oct 9, 2024
836f3b4
Final ica client test
Kayanski Oct 9, 2024
317c71e
Merge remote-tracking branch 'origin/v2/small-wasm' into ica-client/t…
Kayanski Oct 9, 2024
52214cd
Removed local patch
Kayanski Oct 9, 2024
a2a1a7e
Working full script with ica client
Kayanski Oct 10, 2024
a230f20
Merge remote-tracking branch 'origin/develop/v2' into nicolas/abs-534…
Kayanski Oct 11, 2024
10e3e30
helper for interchain client mock
Buckram123 Oct 11, 2024
1116360
add admin assertion
Buckram123 Oct 11, 2024
72a628a
Added call as to interface and client
Kayanski Oct 11, 2024
dcd2071
Merge branch 'nicolas/abs-534-review-interchain-abstract-testing-setu…
Kayanski Oct 11, 2024
4e62a5d
Fix interchain clippyé
Kayanski Oct 14, 2024
ee82171
Funds in test
Kayanski Oct 14, 2024
ddf335e
Moved send back logic
Kayanski Oct 14, 2024
b67edb4
Merge remote-tracking branch 'origin/develop/v2' into nicolas/abs-534…
Kayanski Oct 14, 2024
3f6ee36
Merge remote-tracking branch 'origin/nicolas/abs-534-review-interchai…
Kayanski Oct 14, 2024
104741b
Fix
Kayanski Oct 14, 2024
8f92c2d
More helpers in remote crate
Kayanski Oct 15, 2024
eccad1f
Merge remote-tracking branch 'origin/develop/v2' into ica-client/test…
Kayanski Oct 15, 2024
bb21968
Restore union deployment
Kayanski Oct 15, 2024
29e5a79
Fixes and state
Kayanski Oct 15, 2024
c6d7ad5
Update state
Kayanski Oct 16, 2024
2c43df7
Merge remote-tracking branch 'origin/main' into ica-client/tests-move
Kayanski Oct 22, 2024
ed3e161
Less diff
Kayanski Oct 22, 2024
23209a5
Less diff and fixes
Kayanski Oct 22, 2024
3ab47a5
Merge remote-tracking branch 'origin/main' into ica-client/tests-move
Kayanski Oct 22, 2024
20b0558
Take comments into account
Kayanski Oct 22, 2024
d7fee18
formatting [skip ci]
Kayanski Oct 22, 2024
39c1d69
Merge remote-tracking branch 'origin/main' into ica-client/tests-move
Kayanski Oct 25, 2024
819a724
Merge remote-tracking branch 'origin/main' into ica-client/tests-move
Kayanski Nov 6, 2024
1d4f0a8
Started adding docs
Kayanski Nov 25, 2024
d9235d4
Merge remote-tracking branch 'origin/main' into ica-client/tests-move
Buckram123 Apr 29, 2025
13874d7
format taplo
Buckram123 Apr 29, 2025
7e078c2
update to ucs03
Buckram123 Apr 29, 2025
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
4,491 changes: 3,754 additions & 737 deletions framework/Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ cw-orch-polytone = { package = "abstract-cw-orch-polytone", version = "6.0.1" }
polytone = { package = "abstract-polytone", version = "2.0.0" }
polytone-note = { package = "abstract-polytone-note", version = "5.0.0" }

## evm
evm-note = { version = "0.3.1", features = ["library"] }
polytone-evm = { version = "0.3.0" }

## crates in order of publishing ## see docs/Publishing.md

Expand All @@ -71,6 +74,7 @@ abstract-standalone = { path = "packages/abstract-standalone", version = "0.26.0

# Keep these as path, creates cirular dependency otherwise
# Only need to re-publish all contracts if a re-publish of abstract-interface is required
abstract-client = { path = "packages/abstract-client" }
abstract-interface = { path = "packages/abstract-interface" }
ans-host = { package = "abstract-ans-host", path = "contracts/native/ans-host" }
module-factory = { package = "abstract-module-factory", path = "contracts/native/module-factory" }
Expand All @@ -82,7 +86,6 @@ ibc-host = { package = "abstract-ibc-host", path = "contracts/native/ibc-host"

abstract-account = { path = "contracts/account", default-features = false }

abstract-ica = { version = "0.26.0", path = "packages/abstract-ica" }
abstract-sdk = { version = "0.26.0", path = "packages/abstract-sdk" }
abstract-std = { version = "0.26.0", path = "packages/abstract-std" }
abstract-testing = { version = "0.26.0", path = "packages/abstract-testing" }
Expand Down
2 changes: 0 additions & 2 deletions framework/contracts/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ cw2 = { workspace = true }
semver = { workspace = true }
thiserror = { workspace = true }

abstract-ica = { workspace = true }

abstract-xion = { workspace = true, optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions framework/contracts/account/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn ica_action(
))
})?;

let res: abstract_ica::msg::IcaActionResult = deps.querier.query(
let res: abstract_std::ica_client::IcaActionResult = deps.querier.query(
&WasmQuery::Smart {
contract_addr: ica_client_address.into(),
msg: action_query,
Expand Down Expand Up @@ -508,7 +508,7 @@ mod test {
}

mod ica_action {
use abstract_ica::msg::IcaActionResult;
use abstract_std::ica_client::IcaActionResult;
use abstract_std::ICA_CLIENT;
use cosmwasm_std::{Binary, Empty};

Expand Down
11 changes: 8 additions & 3 deletions framework/contracts/native/ica-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ default = ["export"]
export = []

[dependencies]
abstract-ica = { workspace = true }
abstract-macros = { workspace = true }
abstract-sdk = { workspace = true }
abstract-std = { workspace = true }
Expand All @@ -30,8 +29,14 @@ cw2 = { workspace = true }
semver = { workspace = true }
thiserror = { workspace = true }

evm-note = { version = "0.1.0", features = ["library"] }
polytone-evm = "0.1.0"
evm-note = { workspace = true }
polytone-evm = { workspace = true }

alloy = { version = "0.12.6", default-features = false }
alloy-sol-types = { version = "0.8.23", default-features = false }
ibc-union-spec = { git = "https://github.com/AbstractSDK/union", branch = "adair/ibc-query-responses" }
ucs03-zkgm = { git = "https://github.com/AbstractSDK/union", branch = "adair/ibc-query-responses", features = ["library"] }
ucs03-zkgm-token-minter-api = { git = "https://github.com/AbstractSDK/union", branch = "adair/ibc-query-responses" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
workspace-hack = { version = "0.1", path = "../../../workspace-hack" }
Expand Down
2 changes: 1 addition & 1 deletion framework/contracts/native/ica-client/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use abstract_ica::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use abstract_std::ica_client::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use cosmwasm_schema::write_api;

fn main() {
Expand Down
114 changes: 86 additions & 28 deletions framework/contracts/native/ica-client/src/chain_types/evm.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
use abstract_ica::EVM_NOTE_ID;
use std::{num::NonZeroU32, str::FromStr};

use abstract_sdk::{
feature_objects::{AnsHost, RegistryContract},
Resolve,
};
use abstract_std::{
ibc::PACKET_LIFETIME,
ica_client::EVM_NOTE_ID,
native_addrs,
objects::{module::ModuleInfo, ChannelEntry, ContractEntry, TruncatedChainId},
};
use alloy::primitives::U256;
use alloy_sol_types::SolValue;
use cosmwasm_std::{
wasm_execute, Addr, Binary, Coin, CosmosMsg, Deps, Env, HexBinary, QuerierWrapper, WasmMsg,
wasm_execute, Addr, Binary, Coin, CosmosMsg, Deps, Env, HexBinary, QuerierWrapper, StdError,
Uint256, Uint64, WasmMsg,
};
use evm_note::msg::{CallbackRequest, EvmMsg};

Expand Down Expand Up @@ -39,15 +44,21 @@ pub fn send_funds(
deps: Deps,
env: &Env,
evm_chain: &TruncatedChainId,
funds: Vec<Coin>,
account_address: &Addr,
mut funds: Vec<Coin>,
receiver: Option<Binary>,
memo: Option<String>,
salt: Uint256,
) -> IcaClientResult<CosmosMsg> {
if funds.len() != 1 {
panic!("Currently only single funds supported");
}
let funds = funds.pop().unwrap();
// Identify the remote recipient for the funds
let abstract_code_id =
native_addrs::abstract_code_id(&deps.querier, env.contract.address.clone())?;

let receiver: HexBinary = match receiver {
let receiver: Vec<u8> = match receiver {
Some(r) => r.into(),
None => {
let registry = RegistryContract::new(deps, abstract_code_id)?;
Expand All @@ -62,7 +73,7 @@ pub fn send_funds(
)?;

match remote_acc {
Some(remote) => HexBinary::from_hex(&remote)?,
Some(remote) => remote.into_bytes(),
None => return Err(IcaClientError::NoRecipient {}),
}
}
Expand All @@ -73,48 +84,95 @@ pub fn send_funds(
// Resolve the transfer channel id for the given chain
let ucs_channel_entry = ChannelEntry {
connected_chain: evm_chain.clone(),
protocol: types::UCS01_PROTOCOL.to_string(),
protocol: types::UCS03_ZKGM_PROTOCOL.to_string(),
};
let ics20_channel_id = ucs_channel_entry.resolve(&deps.querier, &ans_host)?;
let channel_id = ucs_channel_entry.resolve(&deps.querier, &ans_host)?;
let channel_id =
NonZeroU32::from_str(&channel_id).map_err(|e| StdError::generic_err(e.to_string()))?;

// Resolve the transfer channel id for the given chain
let ucs_contract_entry = ContractEntry {
contract: types::UCS01_FORWARDER_CONTRACT.to_string(),
protocol: types::UCS01_PROTOCOL.to_string(),
contract: types::UCS03_ZKGM_CONTRACT.to_string(),
protocol: types::UCS03_ZKGM_PROTOCOL.to_string(),
};
let ucs_forwarder_addr = ucs_contract_entry.resolve(&deps.querier, &ans_host)?;

// Construct forward packet on the forwarder
let forwarder_msg = wasm_execute(
ucs_forwarder_addr.clone(),
&types::Ucs01ForwarderExecuteMsg::Transfer {
channel: ics20_channel_id.clone(),
receiver: receiver.clone(),
memo: memo.unwrap_or_default(),
timeout: Some(3600),
let ucs03_zkgm_addr = ucs_contract_entry.resolve(&deps.querier, &ans_host)?;

let quote_token: ucs03_zkgm::msg::PredictWrappedTokenResponse = deps.querier.query_wasm_smart(
&ucs03_zkgm_addr,
&ucs03_zkgm::msg::QueryMsg::PredictWrappedToken {
path: U256::ZERO.to_string(),
channel_id: channel_id.into(),
token: funds.denom.clone().into_bytes().into(),
},
funds,
)?
.into();
)?;

let minter: Addr = deps
.querier
.query_wasm_smart(&ucs03_zkgm_addr, &ucs03_zkgm::msg::QueryMsg::GetMinter {})?;

let metadata_response: ucs03_zkgm_token_minter_api::MetadataResponse =
deps.querier.query_wasm_smart(
&minter,
&ucs03_zkgm_token_minter_api::QueryMsg::Metadata {
denom: funds.denom.clone(),
},
)?;

let timeout_timestamp = env.block.time.plus_days(2).nanos();
let amount: U256 = funds.amount.u128().try_into().unwrap();

// Construct instruction
let instruction = ucs03_zkgm::com::Instruction {
version: ucs03_zkgm::com::INSTR_VERSION_1,
opcode: ucs03_zkgm::com::OP_FUNGIBLE_ASSET_ORDER,
operand: ucs03_zkgm::com::FungibleAssetOrder {
sender: account_address.to_string().into_bytes().into(),
receiver: receiver.into(),
base_token: funds.denom.clone().into_bytes().into(),
base_amount: amount,
base_token_symbol: metadata_response.symbol,
base_token_name: metadata_response.name,
base_token_decimals: metadata_response.decimals,
// origin on this chain
base_token_path: U256::ZERO,
quote_token: quote_token.wrapped_token.into(),
quote_amount: amount,
}
.abi_encode_params()
.into(),
};
// Construct send packet on the ucs03zkgm
let msg = ucs03_zkgm::msg::ExecuteMsg::Send {
channel_id: channel_id.into(),
// Setting non zero timeout height results in revert
timeout_height: Uint64::zero(),
timeout_timestamp: ibc_union_spec::Timestamp::from_nanos(timeout_timestamp),
salt: salt.to_be_bytes().into(),
instruction: instruction.abi_encode_params().into(),
};

let send_msg = wasm_execute(ucs03_zkgm_addr, &msg, vec![funds])?;

Ok(forwarder_msg)
Ok(send_msg.into())
}

fn evm_note_addr(vc: &RegistryContract, querier: &QuerierWrapper) -> IcaClientResult<Addr> {
let evm_note_entry =
ModuleInfo::from_id(EVM_NOTE_ID, abstract_ica::POLYTONE_EVM_VERSION.parse()?)?;
let evm_note_entry = ModuleInfo::from_id(
EVM_NOTE_ID,
abstract_std::ica_client::POLYTONE_EVM_VERSION.parse()?,
)?;

vc.query_module(evm_note_entry, querier)?
.reference
.unwrap_native()
.map_err(Into::into)
}

pub(crate) mod types {
pub mod types {
use super::*;

pub const UCS01_PROTOCOL: &str = "ucs01";
pub const UCS01_FORWARDER_CONTRACT: &str = "forwarder";
pub const UCS03_ZKGM_PROTOCOL: &str = "ucs03";
pub const UCS03_ZKGM_CONTRACT: &str = "ucs03zkgm";

#[cosmwasm_schema::cw_serde]
pub enum Ucs01ForwarderExecuteMsg {
Expand Down
5 changes: 1 addition & 4 deletions framework/contracts/native/ica-client/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ mod tests {
let mut deps = mock_dependencies();
let env = mock_env_validated(deps.api);
let abstr = AbstractMockAddrs::new(deps.api);
let msg = InstantiateMsg {
ans_host_address: abstr.ans_host.to_string(),
registry_address: abstr.registry.to_string(),
};
let msg = InstantiateMsg {};
let info = message_info(&abstr.owner, &[]);
let res = instantiate(deps.as_mut(), env.clone(), info, msg).unwrap();
assert!(res.messages.is_empty());
Expand Down
9 changes: 3 additions & 6 deletions framework/contracts/native/ica-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pub mod contract;
pub mod error;
pub use abstract_ica::msg;
mod chain_types;
pub use abstract_std::ica_client as msg;
pub mod chain_types;
mod queries;

#[cfg(test)]
Expand All @@ -19,10 +19,7 @@ mod test_common {

pub fn mock_init(deps: &mut OwnedDeps<MockStorage, MockApi, MockQuerier>) -> IcaClientResult {
let abstr = AbstractMockAddrs::new(deps.api);
let msg = InstantiateMsg {
ans_host_address: abstr.ans_host.to_string(),
registry_address: abstr.registry.to_string(),
};
let msg = InstantiateMsg {};
let info = message_info(&abstr.owner, &[]);
let env = mock_env_validated(deps.api);

Expand Down
Loading
Loading