From 6c185c8cd1a2e01f21c7f959f7ce56f185d9d221 Mon Sep 17 00:00:00 2001 From: bonedaddy Date: Mon, 20 Jan 2025 10:46:54 -0800 Subject: [PATCH 1/2] fix token factory inflows --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/packet.rs | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf42f95..dae2de4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1178,7 +1178,7 @@ dependencies = [ [[package]] name = "rate-limiter" -version = "0.1.0" +version = "0.1.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std 2.1.3", diff --git a/Cargo.toml b/Cargo.toml index 2e8b210..82e9f65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rate-limiter" -version = "0.1.0" +version = "0.1.1" authors = ["Nicolas Lara "] edition = "2021" diff --git a/src/packet.rs b/src/packet.rs index e85527c..27e6a12 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -146,8 +146,8 @@ impl Packet { .strip_prefix(&format!("transfer/{}/", self.source_channel)) .unwrap_or_default(); let split: Vec<&str> = unprefixed.split('/').collect(); - if split[0] == unprefixed { - // This is a native token. Return the unprefixed token + if split[0] == unprefixed || split[0] == "factory" { + // This is a native token or a tokenfactory token. Return the unprefixed token unprefixed.to_string() } else { // This is a non-native that was sent to the counterparty. @@ -266,6 +266,17 @@ pub mod tests { ); assert_eq!(packet.local_denom(&FlowType::In), "uosmo"); } + #[test] + fn receive_tokenfactory_token() { + // The counterparty chain sends us back our native token that they had wrapped + let packet = Packet::mock( + "channel-42-counterparty".to_string(), // The counterparty's channel is the source here + "channel-17-local".to_string(), // Our channel is the dest channel + "transfer/channel-42-counterparty/factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT".to_string(), + 0_u128.into(), + ); + assert_eq!(packet.local_denom(&FlowType::In), "factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT"); + } // Let's assume we have two chains A and B (local and counterparty) connected in the following way: // From 90a90dd90ae4efccc721fc2b87afab28acbd2914 Mon Sep 17 00:00:00 2001 From: bonedaddy Date: Mon, 20 Jan 2025 14:00:04 -0800 Subject: [PATCH 2/2] update schema --- schema/rate-limiter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/rate-limiter.json b/schema/rate-limiter.json index 0d6b3b5..c96b8b9 100644 --- a/schema/rate-limiter.json +++ b/schema/rate-limiter.json @@ -1,6 +1,6 @@ { "contract_name": "rate-limiter", - "contract_version": "0.1.0", + "contract_version": "0.1.1", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#",