Skip to content

Commit 68ef822

Browse files
ref: Kernel Handle Local (#820)
Co-authored-by: Dimitrije Dragasevic <[email protected]>
1 parent 40eb944 commit 68ef822

File tree

21 files changed

+2399
-568
lines changed

21 files changed

+2399
-568
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- chore: remove unused contracts & code [(#790)](https://github.com/andromedaprotocol/andromeda-core/pull/790)
2828
- feat: Recipient in rate limiting withdrawals [(#804)](https://github.com/andromedaprotocol/andromeda-core/pull/804)
2929
- feat: deploy script validate & build steps [(#736)](https://github.com/andromedaprotocol/andromeda-core/pull/736)
30+
- ref: Simplify the kernel's handling of its Send ExecuteMsg [(#736)](https://github.com/andromedaprotocol/andromeda-core/pull/736)
3031

3132
### Fixed
3233

contracts/finance/andromeda-fixed-amount-splitter/src/contract.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ use andromeda_finance::{
1010
};
1111
use andromeda_std::{
1212
ado_base::{InstantiateMsg as BaseInstantiateMsg, MigrateMsg},
13-
amp::{messages::AMPPkt, Recipient},
13+
amp::{
14+
messages::{AMPMsg, AMPPkt},
15+
Recipient,
16+
},
1417
andr_execute_fn,
1518
common::{encode_binary, expiration::Expiry, Milliseconds},
1619
error::ContractError,
1720
};
1821
use andromeda_std::{ado_contract::ADOContract, common::context::ExecuteContext};
1922
use cosmwasm_std::{
20-
attr, coin, coins, ensure, entry_point, from_json, Binary, Coin, Deps, DepsMut, Env,
21-
MessageInfo, Reply, Response, StdError, SubMsg, Uint128,
23+
attr, coin, coins, ensure, entry_point, from_json, to_json_binary, Binary, Coin, Deps, DepsMut,
24+
Env, MessageInfo, Reply, Response, StdError, SubMsg, Uint128,
2225
};
2326
use cw20::{Cw20Coin, Cw20ReceiveMsg};
2427

@@ -105,7 +108,7 @@ pub fn handle_receive_cw20(
105108
let ExecuteContext { ref info, .. } = ctx;
106109
let asset_sent = info.sender.clone().into_string();
107110
let amount_sent = receive_msg.amount;
108-
let sender = receive_msg.sender;
111+
let sender = receive_msg.sender.clone();
109112

110113
ensure!(
111114
!amount_sent.is_zero(),
@@ -118,6 +121,17 @@ pub fn handle_receive_cw20(
118121
Cw20HookMsg::Send { config } => {
119122
execute_send_cw20(ctx, sender, amount_sent, asset_sent, config)
120123
}
124+
Cw20HookMsg::AmpReceive(mut packet) => {
125+
let msg = to_json_binary(&ExecuteMsg::Receive(Cw20ReceiveMsg {
126+
sender: sender.clone(),
127+
amount: amount_sent,
128+
msg: to_json_binary(&Cw20HookMsg::Send { config: None })?,
129+
}))?;
130+
let funds = packet.messages[0].funds.clone();
131+
let recipient = packet.messages[0].recipient.clone();
132+
packet.messages = vec![AMPMsg::new(recipient, msg, Some(funds))];
133+
execute(ctx.deps, ctx.env, ctx.info, ExecuteMsg::AMPReceive(packet))
134+
}
121135
}
122136
}
123137

contracts/finance/andromeda-fixed-amount-splitter/src/interface.rs

+43
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,46 @@ contract_interface!(
88
CONTRACT_ID,
99
"andromeda_fixed_amount_splitter.wasm"
1010
);
11+
12+
/// Macro to create a fixed amount splitter instantiate message
13+
///
14+
/// # Arguments
15+
/// * `$env` - The test environment (e.g., juno.aos)
16+
/// * `$recipients` - A vector of (recipient, denom, amount) tuples
17+
#[macro_export]
18+
macro_rules! fixed_amount_splitter_instantiate {
19+
// Single recipient with default amount (100)
20+
($env:expr, $recipient:expr, $denom:expr) => {
21+
fixed_amount_splitter_instantiate!($env, [($recipient, $denom, Uint128::new(100))])
22+
};
23+
24+
// Single recipient with custom amount
25+
($env:expr, $recipient:expr, $denom:expr, $amount:expr) => {
26+
fixed_amount_splitter_instantiate!($env, [($recipient, $denom, $amount)])
27+
};
28+
29+
// Multiple recipients with array syntax
30+
($env:expr, [$(($recipient:expr, $denom:expr, $amount:expr)),*]) => {
31+
&andromeda_finance::fixed_amount_splitter::InstantiateMsg {
32+
recipients: vec![
33+
$(
34+
andromeda_finance::fixed_amount_splitter::AddressAmount {
35+
recipient: Recipient {
36+
address: AndrAddr::from_string($recipient.clone()),
37+
msg: None,
38+
ibc_recovery_address: None,
39+
},
40+
coins: vec![Coin {
41+
denom: $denom.to_string(),
42+
amount: $amount,
43+
}],
44+
}
45+
),*
46+
],
47+
default_recipient: None,
48+
lock_time: None,
49+
kernel_address: $env.kernel.address().unwrap().into_string(),
50+
owner: None,
51+
}
52+
};
53+
}

contracts/os/andromeda-adodb/src/interface.rs

+28
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,31 @@ use andromeda_std::{
88
pub const CONTRACT_ID: &str = "adodb";
99

1010
contract_interface!(ADODBContract, CONTRACT_ID, "andromeda_adodb.wasm");
11+
12+
/// Macro to register a contract with the ADODB
13+
///
14+
/// # Arguments
15+
/// * `$env` - The test environment (e.g., juno.aos)
16+
/// * `$contract` - The contract instance
17+
/// * `$ado_type` - The ADO type as a string
18+
/// * `$version` - The version string (defaults to "1.0.0")
19+
#[macro_export]
20+
macro_rules! register_contract {
21+
($env:expr, $contract:expr, $ado_type:expr) => {
22+
register_contract!($env, $contract, $ado_type, "1.0.0")
23+
};
24+
($env:expr, $contract:expr, $ado_type:expr, $version:expr) => {
25+
$env.adodb
26+
.execute(
27+
&os::adodb::ExecuteMsg::Publish {
28+
code_id: $contract.code_id().unwrap(),
29+
ado_type: $ado_type.to_string(),
30+
action_fees: None,
31+
version: $version.to_string(),
32+
publisher: None,
33+
},
34+
None,
35+
)
36+
.unwrap()
37+
};
38+
}

contracts/os/andromeda-kernel/src/contract.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use cosmwasm_std::{
1111
};
1212

1313
use crate::execute::handle_receive_cw20;
14+
// use crate::execute::handle_receive_cw20;
1415
use crate::ibc::{IBCLifecycleComplete, SudoMsg};
1516
use crate::reply::{
1617
on_reply_create_ado, on_reply_ibc_hooks_packet_send, on_reply_ibc_transfer,

0 commit comments

Comments
 (0)