Skip to content

Commit 5faa945

Browse files
CyberHowardKayanskiCircleCI
authored
Allow multiple ibc messages to be executed on host chain (#316)
* Added multiple messages to ibc action * Removed multiple ibc client messages per proxy call * Changelog * Added multiple message data forwarding * Resolve merge issue * Update WASM & Schemas [skip ci] * Update CI --------- Co-authored-by: Kayanski <kowalski.kowalskin@gmail.com> Co-authored-by: Kayanski <44806566+Kayanski@users.noreply.github.com> Co-authored-by: CircleCI <circleci@example.com>
1 parent 3b67473 commit 5faa945

File tree

61 files changed

+180
-1193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+180
-1193
lines changed
292 Bytes
Binary file not shown.
404 Bytes
Binary file not shown.
-49.2 KB
Binary file not shown.
-3.24 KB
Binary file not shown.
-1.47 KB
Binary file not shown.
404 Bytes
Binary file not shown.
-40.9 KB
Binary file not shown.
Binary file not shown.

framework/artifacts/checksums.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
e87f5611c58944512dd88d26441d97d61ae1d459be6c3835e1e4181ed9df1f40 abstract_account_factory.wasm
2-
336233ca7487dd5a557ca69650d2e5f8fce499d81b39773b9c0c6abd403f2bb5 abstract_ans_host.wasm
3-
b3822190e0ab5b49e65587ccceaa88664134325bbdfd9b080c35d2eca9e098ba abstract_ibc_client.wasm
4-
31ba0dd2f903205822ad068ec734a72f615b813a318017510939504802352fec abstract_ibc_host.wasm
5-
02d314a4de51756f8d306e0596076bceb684e29eec576b1b3895f215b3b96b12 abstract_manager.wasm
6-
8ddb7cc45c35aed03c016f437f4130f0f0096b9bba6814b6a4a058afb6df6fcb abstract_module_factory.wasm
7-
7d2af1e6592a3f2d468e2958c02de21ad2573528d961a77a3bc91a3c8612e087 abstract_proxy.wasm
8-
46de44a932793283046b65f3900aeaf8ca92b67a21d24fc6740e42f35987b701 abstract_version_control.wasm
1+
72aa875df6c2a783d4593352e466cfbd72a58a96408e3a7d5d121304ba08ab12 abstract_account_factory.wasm
2+
eb93f35d6aa8b9ad96ae641e77c51dd8efb89981c512a4d21df655b0e5235b27 abstract_ans_host.wasm
3+
7f86b7486fcc4430763f303ee18c0f0ad170991edfdad639819539871142836b abstract_ibc_client.wasm
4+
dea2280769325f2f8804273077c9552fe95e06f3b765c78394c4f2d82686f3d4 abstract_ibc_host.wasm
5+
794ba247cf1dbb8647d505fcb1ec08b6411fe91ec9afcf80e36cd5024e878ec5 abstract_manager.wasm
6+
108b0f2994f3e249a4ecd1101e7c3d81beb941bd92e520840572d42deccb178f abstract_module_factory.wasm
7+
a6c81713723ae5ab5b9e9b8f476e30d8aefad16760250dde8305791c33fad389 abstract_proxy.wasm
8+
cd1785ac5e325c3302c487a7d8b7797241fb711de2f20631cc75cd17b6005c75 abstract_version_control.wasm

framework/contracts/account/proxy/src/commands.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ pub fn execute_module_action_response(
4747

4848
/// Executes IBC actions forwarded by whitelisted contracts
4949
/// Calls the messages on the IBC client (ensuring permission)
50-
pub fn execute_ibc_action(
51-
deps: DepsMut,
52-
msg_info: MessageInfo,
53-
msgs: Vec<IbcClientMsg>,
54-
) -> ProxyResult {
50+
pub fn execute_ibc_action(deps: DepsMut, msg_info: MessageInfo, msg: IbcClientMsg) -> ProxyResult {
5551
let state = STATE.load(deps.storage)?;
5652
if !state.modules.contains(&msg_info.sender) {
5753
return Err(ProxyError::SenderNotWhitelisted {});
@@ -64,19 +60,15 @@ pub fn execute_ibc_action(
6460
"ibc_client not found on manager. Add it under the {IBC_CLIENT} name."
6561
))
6662
})?;
67-
let client_msgs: Result<Vec<_>, _> = msgs
68-
.into_iter()
69-
.map(|execute_msg| {
70-
let funds_to_send = if let IbcClientMsg::SendFunds { funds, .. } = &execute_msg {
71-
funds.to_vec()
72-
} else {
73-
vec![]
74-
};
75-
wasm_execute(&ibc_client_address, &execute_msg, funds_to_send)
76-
})
77-
.collect();
7863

79-
Ok(ProxyResponse::action("execute_ibc_action").add_messages(client_msgs?))
64+
let funds_to_send = if let IbcClientMsg::SendFunds { funds, .. } = &msg {
65+
funds.to_vec()
66+
} else {
67+
vec![]
68+
};
69+
let client_msg = wasm_execute(ibc_client_address, &msg, funds_to_send)?;
70+
71+
Ok(ProxyResponse::action("execute_ibc_action").add_message(client_msg))
8072
}
8173

8274
/// Update the stored vault asset information
@@ -415,12 +407,12 @@ mod test {
415407
.unwrap();
416408

417409
let msg = ExecuteMsg::IbcAction {
418-
msgs: vec![abstract_std::ibc_client::ExecuteMsg::Register {
410+
msg: abstract_std::ibc_client::ExecuteMsg::Register {
419411
host_chain: "juno".into(),
420412
base_asset: None,
421413
namespace: None,
422414
install_modules: vec![],
423-
}],
415+
},
424416
};
425417

426418
let not_whitelisted_info = mock_info(TEST_MANAGER, &[]);
@@ -471,10 +463,10 @@ mod test {
471463

472464
let funds = coins(10, "denom");
473465
let msg = ExecuteMsg::IbcAction {
474-
msgs: vec![abstract_std::ibc_client::ExecuteMsg::SendFunds {
466+
msg: abstract_std::ibc_client::ExecuteMsg::SendFunds {
475467
host_chain: "juno".to_owned(),
476468
funds: funds.clone(),
477-
}],
469+
},
478470
};
479471

480472
let not_whitelisted_info = mock_info(TEST_MANAGER, &[]);

framework/contracts/account/proxy/src/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn execute(deps: DepsMut, _env: Env, info: MessageInfo, msg: ExecuteMsg) ->
7676
match msg {
7777
ExecuteMsg::ModuleAction { msgs } => execute_module_action(deps, info, msgs),
7878
ExecuteMsg::ModuleActionWithData { msg } => execute_module_action_response(deps, info, msg),
79-
ExecuteMsg::IbcAction { msgs } => execute_ibc_action(deps, info, msgs),
79+
ExecuteMsg::IbcAction { msg } => execute_ibc_action(deps, info, msg),
8080
ExecuteMsg::SetAdmin { admin } => set_admin(deps, info, &admin),
8181
ExecuteMsg::AddModules { modules } => add_modules(deps, info, modules),
8282
ExecuteMsg::RemoveModule { module } => remove_module(deps, info, module),

framework/contracts/native/ibc-client/src/contract.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ mod tests {
444444

445445
mod remote_action {
446446
use super::*;
447+
use std::str::FromStr;
447448

448449
use abstract_std::{
449450
ibc_host::{self, HostAction, InternalAction},
@@ -465,11 +466,11 @@ mod tests {
465466
let msg = ExecuteMsg::RemoteAction {
466467
host_chain: chain_name.to_string(),
467468
action: HostAction::Dispatch {
468-
manager_msg: manager::ExecuteMsg::UpdateInfo {
469+
manager_msgs: vec![manager::ExecuteMsg::UpdateInfo {
469470
name: None,
470471
description: None,
471472
link: None,
472-
},
473+
}],
473474
},
474475
};
475476

@@ -533,11 +534,11 @@ mod tests {
533534
)?;
534535

535536
let action = HostAction::Dispatch {
536-
manager_msg: manager::ExecuteMsg::UpdateInfo {
537+
manager_msgs: vec![manager::ExecuteMsg::UpdateInfo {
537538
name: None,
538539
description: None,
539540
link: None,
540-
},
541+
}],
541542
};
542543

543544
let msg = ExecuteMsg::RemoteAction {

framework/contracts/native/ibc-host/src/account_commands.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,24 @@ pub fn receive_register(
8080
pub fn receive_dispatch(
8181
_deps: DepsMut,
8282
account: AccountBase,
83-
manager_msg: manager::ExecuteMsg,
83+
manager_msgs: Vec<manager::ExecuteMsg>,
8484
) -> HostResult {
8585
// execute the message on the manager
86-
let manager_call_msg = wasm_execute(account.manager, &manager_msg, vec![])?;
86+
let msgs = manager_msgs
87+
.into_iter()
88+
.map(|msg| wasm_execute(&account.manager, &msg, vec![]))
89+
.collect::<Result<Vec<_>, _>>()?;
8790

88-
// We want to forward the data that this execution gets
89-
let submsg = SubMsg::reply_on_success(manager_call_msg, RESPONSE_REPLY_ID);
91+
let response = Response::new()
92+
.add_attribute("action", "receive_dispatch")
93+
// This is used to forward the data of the calling message
94+
// This means that only the last present data of will be forwarded
95+
.add_submessages(
96+
msgs.into_iter()
97+
.map(|m| SubMsg::reply_on_success(m.clone(), RESPONSE_REPLY_ID)),
98+
);
9099

91-
// Polytone handles all the necessary
92-
Ok(Response::new()
93-
.add_submessage(submsg)
94-
.add_attribute("action", "receive_dispatch"))
100+
Ok(response)
95101
}
96102

97103
/// processes PacketMsg::SendAllBack variant

framework/contracts/native/ibc-host/src/endpoints/packet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ pub fn handle_host_action(
5454
// If this account already exists, we can propagate the action
5555
if let Ok(account) = account_commands::get_account(deps.as_ref(), &account_id) {
5656
match action {
57-
HostAction::Dispatch { manager_msg } => {
58-
receive_dispatch(deps, account, manager_msg)
57+
HostAction::Dispatch { manager_msgs } => {
58+
receive_dispatch(deps, account, manager_msgs)
5959
}
6060
HostAction::Helpers(helper_action) => match helper_action {
6161
HelperAction::SendAllBack => {

framework/contracts/native/ibc-host/tests/integration.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ fn account_action() -> anyhow::Result<()> {
284284
.ibc_execute(
285285
AccountId::local(account_sequence),
286286
HostAction::Dispatch {
287-
manager_msg: abstract_std::manager::ExecuteMsg::ProposeOwner {
287+
manager_msgs: vec![abstract_std::manager::ExecuteMsg::ProposeOwner {
288288
owner: GovernanceDetails::Monarchy {
289289
monarch: mock.addr_make("new_owner").to_string(),
290290
},
291-
},
291+
}],
292292
},
293293
proxy_addr.to_string(),
294294
)
@@ -336,11 +336,11 @@ fn execute_action_with_account_creation() -> anyhow::Result<()> {
336336
.ibc_execute(
337337
AccountId::local(account_sequence),
338338
HostAction::Dispatch {
339-
manager_msg: abstract_std::manager::ExecuteMsg::ProposeOwner {
339+
manager_msgs: vec![abstract_std::manager::ExecuteMsg::ProposeOwner {
340340
owner: GovernanceDetails::Monarchy {
341341
monarch: mock.addr_make("new_owner").to_string(),
342342
},
343-
},
343+
}],
344344
},
345345
mock.addr_make("proxy_address").to_string(),
346346
)

framework/docs/src/releases/v0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Added helper functions `assert_registered` and `is_registered` to the ANS client API.
1010
- Added method `module_info` for querying and verifying wether an address is a module to the ModuleRegistry API.
1111
- Added default IBC-Client installation on remote modules inside Client and Account interfaces
12+
- Send multiple message simultaneously through IBC
1213

1314
### Changed
1415

@@ -20,6 +21,7 @@
2021
### Removed
2122

2223
- unused `custom_swap` of `DexCommand`
24+
- Send multiple messages to multiple IBC connected chains in one manager message.
2325

2426
## [0.21.0] - 2024-02-20
2527

framework/packages/abstract-client/src/account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,12 @@ impl<Chain: CwEnv> Account<Chain> {
576576
&abstract_std::manager::ExecuteMsg::ExecOnModule {
577577
module_id: PROXY.to_owned(),
578578
exec_msg: to_json_binary(&abstract_std::proxy::ExecuteMsg::IbcAction {
579-
msgs: vec![ibc_client::ExecuteMsg::Register {
579+
msg: ibc_client::ExecuteMsg::Register {
580580
host_chain: host_chain.into(),
581581
base_asset,
582582
namespace,
583583
install_modules,
584-
}],
584+
},
585585
})
586586
.map_err(AbstractInterfaceError::from)?,
587587
},

framework/packages/abstract-interface/src/account/manager.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ impl<Chain: CwEnv> Manager<Chain> {
200200
{
201201
let result = self.exec_on_module(
202202
to_json_binary(&abstract_std::proxy::ExecuteMsg::IbcAction {
203-
msgs: vec![abstract_std::ibc_client::ExecuteMsg::Register {
203+
msg: abstract_std::ibc_client::ExecuteMsg::Register {
204204
host_chain: host_chain.into(),
205205
base_asset: None,
206206
namespace: None,
207207
install_modules: vec![ModuleInstallConfig::new(
208208
ModuleInfo::from_id_latest(IBC_CLIENT)?,
209209
None,
210210
)],
211-
}],
211+
},
212212
})?,
213213
PROXY.to_string(),
214214
&[],
@@ -224,10 +224,12 @@ impl<Chain: CwEnv> Manager<Chain> {
224224
) -> Result<<Chain as cw_orch::prelude::TxHandler>::Response, crate::AbstractInterfaceError>
225225
{
226226
let msg = abstract_std::proxy::ExecuteMsg::IbcAction {
227-
msgs: vec![abstract_std::ibc_client::ExecuteMsg::RemoteAction {
227+
msg: abstract_std::ibc_client::ExecuteMsg::RemoteAction {
228228
host_chain: host_chain.into(),
229-
action: HostAction::Dispatch { manager_msg: msg },
230-
}],
229+
action: HostAction::Dispatch {
230+
manager_msgs: vec![msg],
231+
},
232+
},
231233
};
232234

233235
self.execute_on_module(PROXY, msg)
@@ -241,15 +243,15 @@ impl<Chain: CwEnv> Manager<Chain> {
241243
) -> Result<<Chain as cw_orch::prelude::TxHandler>::Response, crate::AbstractInterfaceError>
242244
{
243245
let msg = abstract_std::proxy::ExecuteMsg::IbcAction {
244-
msgs: vec![abstract_std::ibc_client::ExecuteMsg::RemoteAction {
246+
msg: abstract_std::ibc_client::ExecuteMsg::RemoteAction {
245247
host_chain: host_chain.into(),
246248
action: HostAction::Dispatch {
247-
manager_msg: ExecuteMsg::ExecOnModule {
249+
manager_msgs: vec![ExecuteMsg::ExecOnModule {
248250
module_id: module_id.to_string(),
249251
exec_msg: msg,
250-
},
252+
}],
251253
},
252-
}],
254+
},
253255
};
254256

255257
self.execute_on_module(PROXY, msg)
@@ -261,10 +263,10 @@ impl<Chain: CwEnv> Manager<Chain> {
261263
) -> Result<<Chain as cw_orch::prelude::TxHandler>::Response, crate::AbstractInterfaceError>
262264
{
263265
let msg = abstract_std::proxy::ExecuteMsg::IbcAction {
264-
msgs: vec![abstract_std::ibc_client::ExecuteMsg::RemoteAction {
266+
msg: abstract_std::ibc_client::ExecuteMsg::RemoteAction {
265267
host_chain: host_chain.into(),
266268
action: HostAction::Helpers(HelperAction::SendAllBack),
267-
}],
269+
},
268270
};
269271

270272
self.execute_on_module(PROXY, msg)

0 commit comments

Comments
 (0)