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

ready to accept Neutron (test-tube) #41

Merged
merged 3 commits into from
Oct 10, 2023
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
10 changes: 3 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
[workspace]
members = [
"contracts/*",
"packages/router",
"packages/ownable",
"packages/interface",
"integration-test",
]
members = ["contracts/*", "packages/*", "integration-test"]
resolver = "2"

[profile.test]
Expand Down Expand Up @@ -67,6 +61,8 @@ k256 = { version = "0.13.1", default-features = false, features = ["ecdsa"] }
anyhow = { version = "1.0.71", features = ["backtrace"] }
digest = { version = "0.10.7" }
hex-literal = { version = "0.4.1" }

test-tube = { version = "0.1.7" }
osmosis-test-tube = { version = "19.2.0" }

tokio = { version = "1", features = ["full"] }
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ schema:
build:
cargo wasm

build-dev:
cargo cw-optimizoor

check:
ls artifacts | grep .wasm | xargs -n 1 -I x -t cosmwasm-check ./artifacts/x
ls -d ./artifacts/*.wasm | xargs -I x cosmwasm-check x
1 change: 0 additions & 1 deletion contracts/default-hook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
cw-utils = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
cosmwasm-schema = { workspace = true }
serde-json-wasm = { workspace = true }
Expand Down
35 changes: 12 additions & 23 deletions contracts/default-hook/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response};
use cosmwasm_std::{Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response};
use cw2::set_contract_version;
use hpl_interface::default_hook::ExecuteMsg;
use hpl_interface::domain_routing_hook::{
ExecuteMsg as DomainRoutingExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg,
};
use hpl_interface::default_hook::{ExecuteMsg, InstantiateMsg, QueryMsg};

use crate::{
event::emit_instantiated,
Expand Down Expand Up @@ -33,7 +30,7 @@ pub fn instantiate(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
Ok(Response::default())
}

Expand All @@ -47,23 +44,15 @@ pub fn execute(
use crate::execute::{dispatch, gov, hook};

match msg {
ExecuteMsg::DomainRoutingHookMsg(msg) => match msg {
DomainRoutingExecuteMsg::Ownership(msg) => {
Ok(hpl_ownable::handle(deps, env, info, msg)?)
}
DomainRoutingExecuteMsg::Pause {} => gov::pause(deps, info),
DomainRoutingExecuteMsg::Unpause {} => gov::unpause(deps, info),
DomainRoutingExecuteMsg::UpdateMailbox { mailbox } => {
gov::update_mailbox(deps, info, mailbox)
}
DomainRoutingExecuteMsg::SetHook { destination, hook } => {
hook::set_hook(deps, info, destination, hook)
}
DomainRoutingExecuteMsg::SetHooks { hooks } => hook::set_hooks(deps, info, hooks),
DomainRoutingExecuteMsg::PostDispatch { metadata, message } => {
dispatch::dispatch(deps, metadata, message)
}
},
ExecuteMsg::Ownership(msg) => Ok(hpl_ownable::handle(deps, env, info, msg)?),
ExecuteMsg::Pause {} => gov::pause(deps, info),
ExecuteMsg::Unpause {} => gov::unpause(deps, info),
ExecuteMsg::UpdateMailbox { mailbox } => gov::update_mailbox(deps, info, mailbox),
ExecuteMsg::SetHook { destination, hook } => hook::set_hook(deps, info, destination, hook),
ExecuteMsg::SetHooks { hooks } => hook::set_hooks(deps, info, hooks),
ExecuteMsg::PostDispatch { metadata, message } => {
dispatch::dispatch(deps, metadata, message)
}
ExecuteMsg::ConfigCustomHook {
destination_domain,
recipient,
Expand Down
11 changes: 9 additions & 2 deletions contracts/default-hook/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{Addr, Event, HexBinary};
use hpl_interface::domain_routing_hook::HookConfig;
use hpl_interface::hook::HookConfig;

pub fn emit_instantiated(owner: Addr, mailbox: Addr) -> Event {
Event::new("domain_routing_hook_instantiated")
Expand All @@ -21,7 +21,14 @@ pub fn emit_set_hooks(hooks: Vec<HookConfig>) -> Event {
pub fn emit_post_dispatch(addr: Addr, metadata: HexBinary, message: HexBinary) -> Event {
Event::new("domain_routing_hook_post_dispatch")
.add_attribute("addr", addr.to_string())
.add_attribute("metadata", metadata.to_string())
.add_attribute(
"metadata",
if metadata.is_empty() {
"0x".to_string()
} else {
metadata.to_string()
},
)
.add_attribute("message", message.to_string())
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/default-hook/src/execute/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn dispatch(
#[cfg(test)]
mod test {
use cosmwasm_std::{testing::mock_dependencies, Addr};
use hpl_interface::{domain_routing_hook::HookConfig, post_dispatch_hook::PostDispatchMsg};
use hpl_interface::{hook::HookConfig, post_dispatch_hook::PostDispatchMsg};

use super::*;
const HOOK_ADDR: &str = "osmoaddress";
Expand Down
2 changes: 1 addition & 1 deletion contracts/default-hook/src/execute/hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{ensure, ensure_eq, DepsMut, HexBinary, MessageInfo, Response};
use hpl_interface::{domain_routing_hook::HookConfig, types::keccak256_hash};
use hpl_interface::{hook::HookConfig, types::keccak256_hash};

use crate::{
event::{emit_config_custom_hook, emit_set_hook, emit_set_hooks},
Expand Down
4 changes: 2 additions & 2 deletions contracts/default-hook/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{to_binary, Deps, Env, QueryResponse};
use hpl_interface::{
domain_routing_hook::{OwnerResponse, PauseInfoResponse},
hook::{OwnerResponse, PauseInfoResponse},
igp_core::QuoteGasPaymentResponse,
post_dispatch_hook::PostDispatchQueryMsg,
types::message::Message,
Expand Down Expand Up @@ -55,7 +55,7 @@ mod test {
testing::{mock_dependencies, mock_env},
Addr, HexBinary, Uint256,
};
use hpl_interface::domain_routing_hook::HookConfig;
use hpl_interface::hook::HookConfig;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion contracts/default-hook/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{Addr, Binary};
use cw_storage_plus::{Item, Map};
use hpl_interface::{domain_routing_hook::HookConfig, types::keccak256_hash};
use hpl_interface::{hook::HookConfig, types::keccak256_hash};

pub const MAILBOX_KEY: &str = "mailbox";
pub const MAILBOX: Item<Addr> = Item::new(MAILBOX_KEY);
Expand Down
11 changes: 9 additions & 2 deletions contracts/domain-routing-hook/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{Addr, Event, HexBinary};
use hpl_interface::domain_routing_hook::HookConfig;
use hpl_interface::hook::HookConfig;

pub fn emit_set_hook(destination: u32, hook: Addr) -> Event {
Event::new("domain-routing-hook-set-hook")
Expand All @@ -15,6 +15,13 @@ pub fn emit_set_hooks(hooks: Vec<HookConfig>) -> Event {
pub fn emit_post_dispatch(addr: Addr, metadata: HexBinary, message: HexBinary) -> Event {
Event::new("domain-routing-hook-post-dispatch")
.add_attribute("addr", addr.to_string())
.add_attribute("metadata", metadata.to_string())
.add_attribute(
"metadata",
if metadata.is_empty() {
"0x".to_string()
} else {
metadata.to_string()
},
)
.add_attribute("message", message.to_string())
}
2 changes: 1 addition & 1 deletion contracts/domain-routing-hook/src/execute/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn dispatch(
#[cfg(test)]
mod test {
use cosmwasm_std::{testing::mock_dependencies, Addr};
use hpl_interface::{domain_routing_hook::HookConfig, post_dispatch_hook::PostDispatchMsg};
use hpl_interface::{hook::HookConfig, post_dispatch_hook::PostDispatchMsg};

use super::*;
const HOOK_ADDR: &str = "osmoaddress";
Expand Down
2 changes: 1 addition & 1 deletion contracts/domain-routing-hook/src/execute/hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{ensure, ensure_eq, DepsMut, Env, MessageInfo, Response};
use hpl_interface::domain_routing_hook::HookConfig;
use hpl_interface::hook::HookConfig;

use crate::{
event::{emit_set_hook, emit_set_hooks},
Expand Down
4 changes: 2 additions & 2 deletions contracts/domain-routing-hook/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{to_binary, Deps, Env, QueryResponse};
use hpl_interface::{
domain_routing_hook::{OwnerResponse, PauseInfoResponse},
hook::{OwnerResponse, PauseInfoResponse},
igp_core::QuoteGasPaymentResponse,
post_dispatch_hook::PostDispatchQueryMsg,
types::message::Message,
Expand Down Expand Up @@ -55,7 +55,7 @@ mod test {
testing::{mock_dependencies, mock_env},
Addr, HexBinary, Uint256,
};
use hpl_interface::domain_routing_hook::HookConfig;
use hpl_interface::hook::HookConfig;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion contracts/domain-routing-hook/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::Addr;
use cw_storage_plus::{Item, Map};
use hpl_interface::domain_routing_hook::HookConfig;
use hpl_interface::hook::HookConfig;

pub const MAILBOX_KEY: &str = "mailbox";
pub const MAILBOX: Item<Addr> = Item::new(MAILBOX_KEY);
Expand Down
11 changes: 9 additions & 2 deletions contracts/igp-core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ pub fn emit_claim(beneficiary: Addr, balance: Coin) -> Event {

pub fn emit_post_dispatch(metadata: Binary, message: Binary) -> Event {
Event::new("igp-core-post-dispatch")
.add_attribute("metadata", metadata.to_string())
.add_attribute(
"metadata",
if metadata.is_empty() {
"0x".to_string()
} else {
metadata.to_string()
},
)
.add_attribute("message", message.to_string())
}

Expand All @@ -39,4 +46,4 @@ pub fn emit_pay_for_gas(
.add_attribute("gas_refunded", gas_refunded)
.add_attribute("gas_required", gas_required)
.add_attribute("payment", payment)
}
}
4 changes: 3 additions & 1 deletion contracts/mailbox/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ pub fn process(
mod tests {
use cosmwasm_std::testing::{mock_dependencies, mock_info};

use crate::state::Config;

use super::*;

const DEST_DOMAIN: u32 = 11155111;
Expand Down Expand Up @@ -168,7 +170,7 @@ mod tests {

// Invalid message version
let wrong_version_message: HexBinary = HexBinary::from(Message {
version: 0,
version: 99,
nonce: 2,
origin_domain: 3,
sender: hex("000000000000000000000000477d860f8f41bc69ddd32821f2bf2c2af0243f16"),
Expand Down
2 changes: 1 addition & 1 deletion contracts/mailbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod verify;

pub use crate::error::ContractError;

pub const MAILBOX_VERSION: u8 = 3;
pub const MAILBOX_VERSION: u8 = 0;

// version info for migration info
pub const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME");
Expand Down
32 changes: 32 additions & 0 deletions contracts/mock-hook/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "hpl-test-mock-hook"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
documentation = { workspace = true }
keywords = { workspace = true }

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

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
cosmwasm-schema = { workspace = true }

cw2 = { workspace = true }
cw-storage-plus = { workspace = true }

hpl-interface = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
Loading