Skip to content

Commit

Permalink
feat: fixed finally
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrobot committed Jan 20, 2025
1 parent a6d84bf commit 6613b1a
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ optimize:
docker run --rm -v "$(PWD)":/code \
--mount type=volume,source="$(BASE)_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0
cosmwasm/optimizer:0.16.1

optimize-fast:
cargo cw-optimizoor
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

## Prerequisites

- rename
- foundry
- rust (wasm32-wasm32-unknown target)
- go 1.20 or higher
- llvm-cov
Expand Down
2 changes: 1 addition & 1 deletion contracts/igps/core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn instantiate(

GAS_TOKEN.save(deps.storage, &msg.gas_token)?;
HRP.save(deps.storage, &msg.hrp)?;
DEFAULT_GAS_USAGE.save(deps.storage, &msg.default_gas_usage)?;
DEFAULT_GAS_USAGE.save(deps.storage, &msg.default_gas_usage.into())?;

Ok(Response::new().add_event(
new_event("initialize")
Expand Down
4 changes: 2 additions & 2 deletions contracts/igps/core/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_std::{
from_json,
testing::{mock_info, MockApi, MockQuerier, MockStorage},
Addr, Coin, Deps, DepsMut, Empty, Env, HexBinary, MessageInfo, OwnedDeps, Response,
Addr, Coin, Deps, DepsMut, Empty, Env, HexBinary, MessageInfo, OwnedDeps, Response, Uint128,
};
use hpl_interface::{
hook::PostDispatchMsg,
Expand Down Expand Up @@ -54,7 +54,7 @@ impl IGP {
owner: owner.to_string(),
gas_token: gas_token.to_string(),
beneficiary: beneficiary.to_string(),
default_gas_usage: 250_000,
default_gas_usage: Uint128::from(250_000u128),
},
)
}
Expand Down
66 changes: 37 additions & 29 deletions contracts/warp/native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,55 +1,63 @@
[package]
name = "hpl-warp-native"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true
documentation.workspace = true
keywords.workspace = true
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "hpl-warp-native"
repository.workspace = true
version.workspace = true

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

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

injective = [ ]
osmosis = [ ]

[package.metadata.optimizer]
builds = [ { name = "injective", features = [ "injective" ], default-features = false }, { name = "osmosis", features = [ "osmosis" ], default-features = false } ]
default-build = true

[dependencies]
cosmwasm-std.workspace = true
cosmwasm-schema.workspace = true
cosmwasm-std.workspace = true
cosmwasm-storage.workspace = true
cosmwasm-schema.workspace = true

cw-storage-plus.workspace = true
cw-utils.workspace = true
cw2.workspace = true
cw-utils.workspace = true
cw2.workspace = true

sha2.workspace = true
ripemd.workspace = true
sha2.workspace = true

bech32.workspace = true
schemars.workspace = true
prost.workspace = true
prost-types.workspace = true
serde.workspace = true
bech32.workspace = true
prost.workspace = true
prost-types.workspace = true
schemars.workspace = true
serde.workspace = true
serde-json-wasm.workspace = true

thiserror.workspace = true

hpl-utils.workspace = true
hpl-connection.workspace = true
hpl-ownable.workspace = true
hpl-router.workspace = true
hpl-interface.workspace = true
hpl-interface.workspace = true
hpl-ownable.workspace = true
hpl-router.workspace = true
hpl-utils.workspace = true

[dev-dependencies]
serde-json-wasm.workspace = true

anyhow.workspace = true
ibcx-test-utils.workspace = true
rstest.workspace = true
anyhow.workspace = true
k256.workspace = true
sha3.workspace = true
k256.workspace = true
rstest.workspace = true
sha3.workspace = true
60 changes: 56 additions & 4 deletions contracts/warp/native/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,25 @@ pub struct MsgCreateDenom {
impl From<MsgCreateDenom> for CosmosMsg {
fn from(v: MsgCreateDenom) -> Self {
CosmosMsg::Stargate {
type_url: "/osmosis.tokenfactory.v1beta1.MsgCreateDenom".to_string(),
type_url: MsgCreateDenom::type_url(),
value: Binary(v.encode_to_vec()),
}
}
}

impl MsgCreateDenom {
fn type_url() -> String {
#[cfg(feature = "osmosis")]
{
"/osmosis.tokenfactory.v1beta1.MsgCreateDenom".to_string()
}
#[cfg(feature = "injective")]
{
"/injective.tokenfactory.v1beta1.MsgCreateDenom".to_string()
}
}
}

#[derive(serde::Serialize, serde::Deserialize, ::prost::Message)]
pub struct MsgCreateDenomResponse {
#[prost(string, tag = "1")]
Expand Down Expand Up @@ -60,12 +73,25 @@ pub struct MsgMint {
impl From<MsgMint> for CosmosMsg {
fn from(v: MsgMint) -> Self {
CosmosMsg::Stargate {
type_url: "/osmosis.tokenfactory.v1beta1.MsgMint".to_string(),
type_url: MsgMint::type_url(),
value: Binary(v.encode_to_vec()),
}
}
}

impl MsgMint {
fn type_url() -> String {
#[cfg(feature = "osmosis")]
{
"/osmosis.tokenfactory.v1beta1.MsgMint".to_string()
}
#[cfg(feature = "injective")]
{
"/injective.tokenfactory.v1beta1.MsgMint".to_string()
}
}
}

#[derive(serde::Serialize, serde::Deserialize, ::prost::Message)]
pub struct MsgBurn {
#[prost(string, tag = "1")]
Expand All @@ -77,12 +103,25 @@ pub struct MsgBurn {
impl From<MsgBurn> for CosmosMsg {
fn from(v: MsgBurn) -> Self {
CosmosMsg::Stargate {
type_url: "/osmosis.tokenfactory.v1beta1.MsgBurn".to_string(),
type_url: MsgBurn::type_url(),
value: Binary(v.encode_to_vec()),
}
}
}

impl MsgBurn {
fn type_url() -> String {
#[cfg(feature = "osmosis")]
{
"/osmosis.tokenfactory.v1beta1.MsgBurn".to_string()
}
#[cfg(feature = "injective")]
{
"/injective.tokenfactory.v1beta1.MsgBurn".to_string()
}
}
}

#[derive(serde::Serialize, serde::Deserialize, ::prost::Message)]
pub struct DenomUnit {
/// denom represents the string name of the given denom unit (e.g uatom).
Expand Down Expand Up @@ -142,12 +181,25 @@ pub struct MsgSetDenomMetadata {
impl From<MsgSetDenomMetadata> for CosmosMsg {
fn from(v: MsgSetDenomMetadata) -> Self {
CosmosMsg::Stargate {
type_url: "/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata".to_string(),
type_url: MsgSetDenomMetadata::type_url(),
value: Binary(v.encode_to_vec()),
}
}
}

impl MsgSetDenomMetadata {
fn type_url() -> String {
#[cfg(feature = "osmosis")]
{
"/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata".to_string()
}
#[cfg(feature = "injective")]
{
"/injective.tokenfactory.v1beta1.MsgSetDenomMetadata".to_string()
}
}
}

mod as_str {
use serde::{de, Deserialize, Deserializer, Serializer};
use std::{fmt::Display, str::FromStr};
Expand Down
3 changes: 2 additions & 1 deletion integration-test/tests/contracts/cw/igp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cosmwasm_std::Uint128;
use hpl_interface::{
igp::{self, oracle::RemoteGasDataConfig},
router::{DomainRouteSet, RouterMsg},
Expand Down Expand Up @@ -36,7 +37,7 @@ impl Igp {
owner: owner.address(),
gas_token: self.gas_token,
beneficiary: self.beneficiary,
default_gas_usage: 25_000,
default_gas_usage: Uint128::from(25_000u128),
},
Some(deployer.address().as_str()),
Some("cw-hpl-igp"),
Expand Down
6 changes: 3 additions & 3 deletions integration-test/tests/contracts/cw/ism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Ism {
owner: owner.address(),
},
None,
None,
Some("None"),
&[],
deployer,
)?
Expand Down Expand Up @@ -112,7 +112,7 @@ impl Ism {
.collect::<eyre::Result<Vec<_>>>()?,
},
None,
None,
Some("None"),
&[],
deployer,
)?
Expand Down Expand Up @@ -146,7 +146,7 @@ impl Ism {
threshold,
},
None,
None,
Some("None"),
&[],
deployer,
)?
Expand Down
2 changes: 2 additions & 0 deletions integration-test/tests/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ where
}

#[tokio::test]
#[ignore]
async fn test_mailbox_cw_to_evm() -> eyre::Result<()> {
// init Osmosis env
let osmo_app = OsmosisTestApp::new();
Expand All @@ -179,6 +180,7 @@ async fn test_mailbox_cw_to_evm() -> eyre::Result<()> {
}

#[tokio::test]
#[ignore]
async fn test_mailbox_evm_to_cw() -> eyre::Result<()> {
// init Osmosis env
let osmo_app = OsmosisTestApp::new();
Expand Down
8 changes: 4 additions & 4 deletions integration-test/tests/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn test_cw20_colleteral() -> eyre::Result<()> {
let osmo = cw::setup_env(
&osmo_app,
|app, coins| app.init_account(coins).unwrap(),
None::<&str>,
Some("../artifacts/"),
"osmo",
DOMAIN_OSMO,
&[TestValidators::new(DOMAIN_EVM, 5, 3)],
Expand Down Expand Up @@ -115,7 +115,7 @@ async fn test_cw20_bridged() -> eyre::Result<()> {
let osmo = cw::setup_env(
&osmo_app,
|app, coins| app.init_account(coins).unwrap(),
None::<&str>,
Some("../artifacts/"),
"osmo",
DOMAIN_OSMO,
&[TestValidators::new(DOMAIN_EVM, 5, 3)],
Expand Down Expand Up @@ -167,7 +167,7 @@ async fn test_native_collateral(#[case] denom: &str) -> eyre::Result<()> {
let osmo = cw::setup_env(
&osmo_app,
|app, coins| app.init_account(coins).unwrap(),
None::<&str>,
Some("../artifacts/"),
"osmo",
DOMAIN_OSMO,
&[TestValidators::new(DOMAIN_EVM, 5, 3)],
Expand Down Expand Up @@ -240,7 +240,7 @@ async fn test_native_bridged(#[case] denom: &str) -> eyre::Result<()> {
let osmo = cw::setup_env(
&osmo_app,
|app, coins| app.init_account(coins).unwrap(),
None::<&str>,
Some("../artifacts/"),
"osmo",
DOMAIN_OSMO,
&[TestValidators::new(DOMAIN_EVM, 5, 3)],
Expand Down
4 changes: 2 additions & 2 deletions packages/interface/src/igp/core.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Addr, HexBinary, Uint256};
use cosmwasm_std::{Addr, HexBinary, Uint128, Uint256};

use crate::{
hook::{HookQueryMsg, PostDispatchMsg},
Expand All @@ -16,7 +16,7 @@ pub struct InstantiateMsg {
pub owner: String,
pub gas_token: String,
pub beneficiary: String,
pub default_gas_usage: u128,
pub default_gas_usage: Uint128,
}

#[cw_serde]
Expand Down

0 comments on commit 6613b1a

Please sign in to comment.