From ee2f9a93c0aa501f69f74e57e563ddd7fd4a074d Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Thu, 12 Mar 2026 13:58:31 +0900 Subject: [PATCH 1/6] Add Cosmos WASM execute swap signing Add Decodable models (CosmosExecuteContractValue, CosmosCoinData, CosmosExecuteContractData) to parse execute contract JSON payloads and implement signSwap(in:privateKey:) in CosmosSigner. The new method decodes swap data, builds a CosmosMessage.wasmExecuteContractGeneric (setting sender, contract, executeMsg and mapping funds to CosmosAmount), and calls the existing sign(...) flow to produce a signed transaction string (preserving the memo). --- .../Signer/Sources/Chains/CosmosSigner.swift | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Packages/Signer/Sources/Chains/CosmosSigner.swift b/Packages/Signer/Sources/Chains/CosmosSigner.swift index db7a50541..53927c240 100644 --- a/Packages/Signer/Sources/Chains/CosmosSigner.swift +++ b/Packages/Signer/Sources/Chains/CosmosSigner.swift @@ -5,6 +5,21 @@ import WalletCore import Primitives import Keystore +struct CosmosExecuteContractValue: Decodable { + let contract: String + let msg: String + let funds: [CosmosCoinData] +} + +struct CosmosCoinData: Decodable { + let denom: String + let amount: String +} + +struct CosmosExecuteContractData: Decodable { + let value: CosmosExecuteContractValue +} + // https://github.com/trustwallet/wallet-core/blob/master/swift/Tests/Blockchains/THORChainTests.swift#L27 struct CosmosSigner: Signable { @@ -63,6 +78,26 @@ struct CosmosSigner: Signable { return output.serialized } + func signSwap(input: SignerInput, privateKey: Data) throws -> [String] { + let chain = try CosmosChain.from(string: input.asset.chain.rawValue) + let swapData = try input.type.swap().data.data + let cosmosData = try JSONDecoder().decode(CosmosExecuteContractData.self, from: Data(swapData.data.utf8)) + let message = CosmosMessage.with { + $0.wasmExecuteContractGeneric = .with { + $0.senderAddress = input.senderAddress + $0.contractAddress = cosmosData.value.contract + $0.executeMsg = cosmosData.value.msg + $0.coins = cosmosData.value.funds.map { fund in + CosmosAmount.with { + $0.denom = fund.denom + $0.amount = fund.amount + } + } + } + } + return [try sign(input: input, messages: [message], chain: chain, memo: input.memo, privateKey: privateKey)] + } + func signData(input: Primitives.SignerInput, privateKey: Data) throws -> String { fatalError() } From 77c29eac227237716a4c17950a77590dbbeb0a7e Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Mon, 16 Mar 2026 00:22:44 +0900 Subject: [PATCH 2/6] add squid icon and rust chain signer --- .../Primitives/Sources/SwapProvider.swift | 1 + .../SwapProviderType+Gemstone.swift | 1 + .../Signer/Sources/Chains/CosmosSigner.swift | 36 ------------------- Packages/Signer/Sources/Signer.swift | 3 +- Packages/Style/Sources/Images.swift | 1 + .../squid.imageset/Contents.json | 15 ++++++++ .../swap_providers/squid.imageset/squid.svg | 5 +++ core | 2 +- 8 files changed, 26 insertions(+), 38 deletions(-) create mode 100644 Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/Contents.json create mode 100644 Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/squid.svg diff --git a/Packages/Primitives/Sources/SwapProvider.swift b/Packages/Primitives/Sources/SwapProvider.swift index 526867012..09415ce7d 100644 --- a/Packages/Primitives/Sources/SwapProvider.swift +++ b/Packages/Primitives/Sources/SwapProvider.swift @@ -25,4 +25,5 @@ public enum SwapProvider: String, Codable, Equatable, Hashable, Sendable { case relay case hyperliquid case orca + case squid } diff --git a/Packages/PrimitivesComponents/Sources/Extensions/SwapProviderType+Gemstone.swift b/Packages/PrimitivesComponents/Sources/Extensions/SwapProviderType+Gemstone.swift index bbdf6218c..6db0254cd 100644 --- a/Packages/PrimitivesComponents/Sources/Extensions/SwapProviderType+Gemstone.swift +++ b/Packages/PrimitivesComponents/Sources/Extensions/SwapProviderType+Gemstone.swift @@ -26,6 +26,7 @@ public extension SwapProvider { case .orca: Images.SwapProviders.orca case .panora: Images.SwapProviders.panora case .okx: Images.SwapProviders.okx + case .squid: Images.SwapProviders.squid } } } diff --git a/Packages/Signer/Sources/Chains/CosmosSigner.swift b/Packages/Signer/Sources/Chains/CosmosSigner.swift index 53927c240..b502c6a6e 100644 --- a/Packages/Signer/Sources/Chains/CosmosSigner.swift +++ b/Packages/Signer/Sources/Chains/CosmosSigner.swift @@ -3,22 +3,6 @@ import Foundation import WalletCore import Primitives -import Keystore - -struct CosmosExecuteContractValue: Decodable { - let contract: String - let msg: String - let funds: [CosmosCoinData] -} - -struct CosmosCoinData: Decodable { - let denom: String - let amount: String -} - -struct CosmosExecuteContractData: Decodable { - let value: CosmosExecuteContractValue -} // https://github.com/trustwallet/wallet-core/blob/master/swift/Tests/Blockchains/THORChainTests.swift#L27 struct CosmosSigner: Signable { @@ -78,26 +62,6 @@ struct CosmosSigner: Signable { return output.serialized } - func signSwap(input: SignerInput, privateKey: Data) throws -> [String] { - let chain = try CosmosChain.from(string: input.asset.chain.rawValue) - let swapData = try input.type.swap().data.data - let cosmosData = try JSONDecoder().decode(CosmosExecuteContractData.self, from: Data(swapData.data.utf8)) - let message = CosmosMessage.with { - $0.wasmExecuteContractGeneric = .with { - $0.senderAddress = input.senderAddress - $0.contractAddress = cosmosData.value.contract - $0.executeMsg = cosmosData.value.msg - $0.coins = cosmosData.value.funds.map { fund in - CosmosAmount.with { - $0.denom = fund.denom - $0.amount = fund.amount - } - } - } - } - return [try sign(input: input, messages: [message], chain: chain, memo: input.memo, privateKey: privateKey)] - } - func signData(input: Primitives.SignerInput, privateKey: Data) throws -> String { fatalError() } diff --git a/Packages/Signer/Sources/Signer.swift b/Packages/Signer/Sources/Signer.swift index 429f2f26a..6d9631a21 100644 --- a/Packages/Signer/Sources/Signer.swift +++ b/Packages/Signer/Sources/Signer.swift @@ -43,7 +43,8 @@ public struct Signer: Sendable { privateKey: privateKey ) } - return try signer.signSwap(input: input, privateKey: privateKey) + let chainSwapSigner: Signable = chain.type == .cosmos ? ChainSigner(chain: chain) : signer + return try chainSwapSigner.signSwap(input: input, privateKey: privateKey) case .generic: return try [signer.signData(input: input, privateKey: privateKey)] case .stake: diff --git a/Packages/Style/Sources/Images.swift b/Packages/Style/Sources/Images.swift index fa49ef283..feab27d68 100644 --- a/Packages/Style/Sources/Images.swift +++ b/Packages/Style/Sources/Images.swift @@ -83,6 +83,7 @@ public enum Images { public static let panora = Image(.panora) public static let okx = Image(.okx) public static let nearIntents = Image(.nearIntents) + public static let squid = Image(.squid) } public enum EarnProviders { diff --git a/Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/Contents.json b/Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/Contents.json new file mode 100644 index 000000000..3ad41ee30 --- /dev/null +++ b/Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "squid.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/squid.svg b/Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/squid.svg new file mode 100644 index 000000000..05762c1f8 --- /dev/null +++ b/Packages/Style/Sources/Resources/Assets.xcassets/swap_providers/squid.imageset/squid.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/core b/core index 3202aeffd..c882c9aa3 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3202aeffd1efa3f7295a0d82da8fb49424a22b50 +Subproject commit c882c9aa3a75801e52f592a55097fceee73e1370 From 16927d4427c5e48049567dff75cb96d3b3f7a844 Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Mon, 16 Mar 2026 22:20:18 +0900 Subject: [PATCH 3/6] Update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index c882c9aa3..58c121d1a 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c882c9aa3a75801e52f592a55097fceee73e1370 +Subproject commit 58c121d1a5a85676c3f7fa9da4038c43b711e725 From 741bfb2f55f05b5d3332d3b5ba3536ed257ba927 Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Mon, 16 Mar 2026 22:38:05 +0900 Subject: [PATCH 4/6] fix signSwap in cosmos signer --- Packages/Signer/Sources/Chains/CosmosSigner.swift | 4 ++++ Packages/Signer/Sources/Signer.swift | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Packages/Signer/Sources/Chains/CosmosSigner.swift b/Packages/Signer/Sources/Chains/CosmosSigner.swift index b502c6a6e..847c08fe4 100644 --- a/Packages/Signer/Sources/Chains/CosmosSigner.swift +++ b/Packages/Signer/Sources/Chains/CosmosSigner.swift @@ -62,6 +62,10 @@ struct CosmosSigner: Signable { return output.serialized } + func signSwap(input: SignerInput, privateKey: Data) throws -> [String] { + try ChainSigner(chain: input.asset.chain).signSwap(input: input, privateKey: privateKey) + } + func signData(input: Primitives.SignerInput, privateKey: Data) throws -> String { fatalError() } diff --git a/Packages/Signer/Sources/Signer.swift b/Packages/Signer/Sources/Signer.swift index 6d9631a21..429f2f26a 100644 --- a/Packages/Signer/Sources/Signer.swift +++ b/Packages/Signer/Sources/Signer.swift @@ -43,8 +43,7 @@ public struct Signer: Sendable { privateKey: privateKey ) } - let chainSwapSigner: Signable = chain.type == .cosmos ? ChainSigner(chain: chain) : signer - return try chainSwapSigner.signSwap(input: input, privateKey: privateKey) + return try signer.signSwap(input: input, privateKey: privateKey) case .generic: return try [signer.signData(input: input, privateKey: privateKey)] case .stake: From 4a283937c563d009faa792608570358868f511e6 Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Thu, 19 Mar 2026 14:40:16 +0900 Subject: [PATCH 5/6] Update core: merge main into squid --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 58e3d4b46..22da5f61a 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 58e3d4b46a390b36312d29ab4e7097c488480dc4 +Subproject commit 22da5f61affb5e189f0cb14e498d1936d9bb25a0 From cb0b4cebe1d381990da54613f9d294205b384d2a Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Thu, 19 Mar 2026 16:24:44 +0900 Subject: [PATCH 6/6] Update core: merge refactor-swap-referral --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 22da5f61a..42a437806 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 22da5f61affb5e189f0cb14e498d1936d9bb25a0 +Subproject commit 42a43780688291811f8997b85e6590301a524084