Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- feat: Osmosis Token Factory ADO [(#929)](https://github.com/andromedaprotocol/andromeda-core/pull/929)
- feat: Wildcard in Permissions [(#949)](https://github.com/andromedaprotocol/andromeda-core/pull/949)
- feat: Additional Permission Queries [(#960)](https://github.com/andromedaprotocol/andromeda-core/pull/960)
- feat: Proxy ADO [(#961)](https://github.com/andromedaprotocol/andromeda-core/pull/961)
- feat: Standardized events in ADOS [(#970)](https://github.com/andromedaprotocol/andromeda-core/pull/970)

### Changed
Expand Down
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions contracts/os/andromeda-kernel/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,25 @@ pub fn handle_local(
let sub_msg = if config.direct || ado_type.is_none() {
amp_message.generate_sub_msg_direct(recipient_addr, ReplyId::AMPMsg.repr())
} else {
let origin = ctx.map_or(info.sender.to_string(), |ctx| ctx.get_origin());
let origin = ctx
.clone()
.map_or(info.sender.to_string(), |ctx| ctx.get_origin());
let previous_sender = info.sender.to_string();

AMPPkt::new(origin, previous_sender, vec![amp_message.clone()]).to_sub_msg(
recipient_addr,
Some(funds.clone()),
ReplyId::AMPMsg.repr(),
)?
println!("origin: {origin}");
println!("prev sender: {previous_sender}");
if let Some(ctx) = ctx {
AMPPkt::new_with_ctx(ctx, vec![amp_message.clone()]).to_sub_msg(
recipient_addr,
Some(funds.clone()),
ReplyId::AMPMsg.repr(),
)?
} else {
AMPPkt::new(origin, previous_sender, vec![amp_message.clone()]).to_sub_msg(
recipient_addr,
Some(funds.clone()),
ReplyId::AMPMsg.repr(),
)?
}
};

Ok(Response::default()
Expand Down
34 changes: 18 additions & 16 deletions contracts/os/andromeda-kernel/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use cosmwasm_schema::cw_serde;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
ensure, from_json, to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env,
Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg,
IbcChannelConnectMsg, IbcChannelOpenMsg, IbcOrder, IbcPacketAckMsg, IbcPacketReceiveMsg,
IbcPacketTimeoutMsg, IbcReceiveResponse, MessageInfo, SubMsg, WasmMsg,
ensure, from_json, to_json_binary, Binary, Deps, DepsMut, Empty, Env, Ibc3ChannelOpenResponse,
IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg,
IbcOrder, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse,
MessageInfo, SubMsg, WasmMsg,
};

pub const PACKET_LIFETIME: u64 = 604_800u64;
Expand Down Expand Up @@ -138,14 +138,13 @@ pub fn do_ibc_packet_receive(
deps.branch(),
MessageInfo {
funds: vec![],
sender: Addr::unchecked(
"cosmwasm122xa328nvn93rsemr980psc9m9qwh8xj8rdje4qtp68m5tyt7yusajjrpz",
),
sender: env.clone().contract.address,
},
env.clone(),
);
match packet_msg {
IbcExecuteMsg::SendMessage { amp_packet } => {
let previous_hops = amp_packet.ctx.get_previous_hops();
// Try to pull the username's address from the packet
match amp_packet.ctx.get_origin_username() {
Some(username) => {
Expand All @@ -163,12 +162,14 @@ pub fn do_ibc_packet_receive(
}
}
None => {
// Added this to keep track of original sender, even if the address is invalid on the receiving chain
let new_amp_packet = AMPPkt::new(
amp_packet.ctx.get_origin(),
let ctx = AMPCtx::new_with_hops(
env.clone().contract.address,
env.contract.address,
amp_packet.messages.clone(),
None,
previous_hops,
);

let new_amp_packet = AMPPkt::new_with_ctx(ctx, amp_packet.messages.clone());
execute_env.amp_ctx = Some(new_amp_packet);
}
}
Expand Down Expand Up @@ -209,11 +210,12 @@ pub fn do_ibc_packet_receive(
match username_addr {
Some(addr) => {
// Add potential username to the context
let mut ctx = AMPCtx::new(addr, env.contract.address, original_sender_username);
// Add previous hops to the context
for hop in previous_hops {
ctx.add_hop(hop);
}
let ctx = AMPCtx::new_with_hops(
addr,
env.contract.address,
original_sender_username,
previous_hops,
);

let amp_packet = AMPPkt::new_with_ctx(ctx, vec![msg.clone()]);
execute_env.amp_ctx = Some(amp_packet.clone());
Expand Down
4 changes: 2 additions & 2 deletions contracts/os/andromeda-kernel/src/tests/test_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn test_handle_local() {
ctx: Some(AMPCtx::new("origin", MOCK_APP_CONTRACT, None)),
expected_submessage: AMPPkt::new(
"origin",
SENDER,
"cosmwasm1t3hmmkn74pqs5htv9swgzpjf7np9z8zc98hgj8hx879cp5juk4eqmnwcm4",
vec![AMPMsg::new(
MOCK_APP_CONTRACT,
to_json_binary(&true).unwrap(),
Expand All @@ -101,7 +101,7 @@ fn test_handle_local() {
ctx: Some(AMPCtx::new("origin", MOCK_APP_CONTRACT, None)),
expected_submessage: AMPPkt::new(
"origin",
SENDER,
"cosmwasm1t3hmmkn74pqs5htv9swgzpjf7np9z8zc98hgj8hx879cp5juk4eqmnwcm4",
vec![AMPMsg::new(
MOCK_APP_CONTRACT,
to_json_binary(&true).unwrap(),
Expand Down
4 changes: 4 additions & 0 deletions contracts/socket/andromeda-proxy/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example schema"
39 changes: 39 additions & 0 deletions contracts/socket/andromeda-proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "andromeda-proxy"
version = "0.1.0"
edition = "2021"
rust-version = "1.86.0"


exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

[lib]
crate-type = ["cdylib", "rlib"]

[features]
library = []
testing = ["cw-multi-test", "andromeda-testing"]

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
schemars = "0.8.16"
serde = { workspace = true }
thiserror = { workspace = true }
cw-utils = { workspace = true }
andromeda-std = { workspace = true }
cw20 = { workspace = true }
andromeda-socket = { workspace = true }
osmosis-std = "0.27.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
cw-multi-test = { workspace = true, optional = true }
cw-orch = { workspace = true }
andromeda-testing = { workspace = true, optional = true }
cw-orch-daemon = "0.24.2"
13 changes: 13 additions & 0 deletions contracts/socket/andromeda-proxy/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use andromeda_socket::proxy::{ExecuteMsg, InstantiateMsg, QueryMsg};
use cosmwasm_schema::write_api;
use std::env::current_dir;

fn main() {
let mut out_dir = current_dir().unwrap();
out_dir.push("schema");
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
};
}
Loading