Skip to content

Commit 0777ecc

Browse files
authored
feat(ibc-union): add newtypes for ids (#4054)
2 parents 06524ec + 97de035 commit 0777ecc

File tree

58 files changed

+1464
-949
lines changed

Some content is hidden

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

58 files changed

+1464
-949
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmwasm/cw20-token-minter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ cosmwasm-std = { workspace = true, features = ["cosmwasm_1_3"] }
1717
cw-storage-plus = { workspace = true }
1818
cw20 = { version = "2.0" }
1919
cw20-base = { version = "2.0", features = ["library"] }
20+
ibc-union-spec = { workspace = true }
2021
serde = { workspace = true, features = ["derive"] }
2122
thiserror = { workspace = true }
2223
token-factory-api = { workspace = true }

cosmwasm/cw20-token-minter/src/contract.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use cosmwasm_std::{
66
QueryRequest, Response, StdResult, WasmMsg,
77
};
88
use cw20::{Cw20QueryMsg, TokenInfoResponse};
9+
use ibc_union_spec::ChannelId;
910
use ucs03_zkgm_token_minter_api::{
1011
ExecuteMsg, LocalTokenMsg, MetadataResponse, PredictWrappedTokenResponse, QueryMsg,
1112
WrappedTokenMsg, DISPATCH_EVENT, DISPATCH_EVENT_ATTR,
@@ -73,7 +74,7 @@ pub fn execute(
7374
metadata,
7475
subdenom: denom,
7576
path,
76-
channel,
77+
channel_id,
7778
token,
7879
} => {
7980
let token_name = if metadata.name.is_empty() {
@@ -99,7 +100,7 @@ pub fn execute(
99100
U256::from_be_bytes::<{ U256::BYTES }>(
100101
path.as_slice().try_into().expect("correctly encoded; qed"),
101102
),
102-
channel,
103+
channel_id,
103104
token.to_vec(),
104105
)),
105106
},
@@ -247,7 +248,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, Error> {
247248
match msg {
248249
QueryMsg::PredictWrappedToken {
249250
path,
250-
channel,
251+
channel_id,
251252
token,
252253
} => {
253254
let Config { dummy_code_id, .. } = CONFIG.load(deps.storage)?;
@@ -257,7 +258,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, Error> {
257258
&deps.api.addr_canonicalize(env.contract.address.as_str())?,
258259
&calculate_salt(
259260
path.parse::<U256>().map_err(Error::U256Parse)?,
260-
channel,
261+
channel_id,
261262
token.to_vec(),
262263
),
263264
)?;
@@ -325,8 +326,8 @@ fn query_token_info(deps: Deps, addr: &str) -> StdResult<TokenInfoResponse> {
325326
}))
326327
}
327328

328-
fn calculate_salt(path: U256, channel: u32, token: Vec<u8>) -> Vec<u8> {
329-
keccak256((path, channel, token.to_vec()).abi_encode_params())
329+
fn calculate_salt(path: U256, channel_id: ChannelId, token: Vec<u8>) -> Vec<u8> {
330+
keccak256((path, channel_id.raw(), token.to_vec()).abi_encode_params())
330331
.into_bytes()
331332
.to_vec()
332333
}

cosmwasm/ibc-union/app/ucs00-pingpong/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ cosmwasm-std = { workspace = true, features = ["stargate"] }
2323
cw-storage-plus = { workspace = true }
2424
ethabi = { workspace = true }
2525
ibc-union-msg = { workspace = true }
26+
ibc-union-spec = { workspace = true }
2627
serde = { workspace = true, features = ["derive"] }
2728
thiserror = { workspace = true }
2829

cosmwasm/ibc-union/app/ucs00-pingpong/src/msg.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use cosmwasm_schema::cw_serde;
22
use ethabi::{ParamType, Token};
33
use ibc_union_msg::msg::MsgSendPacket;
4+
use ibc_union_spec::ChannelId;
45

56
use crate::{state::Config, ContractError};
67

@@ -37,14 +38,14 @@ impl UCS00PingPong {
3738
&self,
3839
config: &Config,
3940
current_timestamp: u64,
40-
source_channel: u32,
41+
source_channel: ChannelId,
4142
) -> ibc_union_msg::msg::ExecuteMsg {
4243
let counterparty_packet = UCS00PingPong {
4344
ping: !self.ping,
4445
// counterparty_timeout: config.seconds_before_timeout * 1_000_000_000 + current_timestamp,
4546
};
4647
ibc_union_msg::msg::ExecuteMsg::PacketSend(MsgSendPacket {
47-
source_channel,
48+
source_channel_id: source_channel,
4849
timeout_height: 0,
4950
timeout_timestamp: current_timestamp + config.seconds_before_timeout * 1_000_000_000,
5051
data: counterparty_packet.encode().into(),
@@ -61,7 +62,7 @@ pub struct InitMsg {
6162
#[serde(rename_all = "snake_case")]
6263
pub enum ExecuteMsg {
6364
Initiate {
64-
channel_id: u32,
65+
channel_id: ChannelId,
6566
packet: UCS00PingPong,
6667
},
6768
IbcUnionMsg(ibc_union_msg::module::IbcUnionMsg),

0 commit comments

Comments
 (0)