Skip to content

Commit

Permalink
IOS-8096 Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyachesl0ve committed Oct 21, 2024
1 parent 3a13473 commit 7a0e1fd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// WalletConnectSolanaMessageSignDTO.swift
// WalletConnectSolanaSignMessageDTO.swift
// Tangem
//
// Created by GuitarKitty on 20.10.2024.
Expand All @@ -8,7 +8,7 @@

import Foundation

enum WalletConnectSolanaMessageSignDTO {
enum WalletConnectSolanaSignMessageDTO {
struct Body: Codable {
/// `Signature` is a signed message from response, encoded as base-58 string
let signature: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// WalletConnectSolanaMessageSignHandler.swift
// WalletConnectSolanaSignMessageHandler.swift
// Tangem
//
// Created by GuitarKitty on 15.10.2024.
Expand All @@ -10,7 +10,7 @@ import JSONRPC
import Foundation
import Commons

struct WalletConnectSolanaMessageSignHandler {
struct WalletConnectSolanaSignMessageHandler {
private let message: String
private let signer: WalletConnectSigner
private let walletModel: WalletModel
Expand All @@ -21,7 +21,7 @@ struct WalletConnectSolanaMessageSignHandler {
blockchainId: String,
walletModelProvider: some WalletConnectWalletModelProvider
) throws {
let parameters = try request.get(WalletConnectSolanaMessageSignDTO.Response.self)
let parameters = try request.get(WalletConnectSolanaSignMessageDTO.Response.self)

do {
guard let walletModel = walletModelProvider.getModel(with: blockchainId) else {
Expand All @@ -40,7 +40,7 @@ struct WalletConnectSolanaMessageSignHandler {
}
}

extension WalletConnectSolanaMessageSignHandler: WalletConnectMessageHandler {
extension WalletConnectSolanaSignMessageHandler: WalletConnectMessageHandler {
var event: WalletConnectEvent {
.sign
}
Expand All @@ -54,7 +54,7 @@ extension WalletConnectSolanaMessageSignHandler: WalletConnectMessageHandler {
do {
let signature = try await signer.sign(data: message.base58DecodedData, using: walletModel)
return .response(
AnyCodable(WalletConnectSolanaMessageSignDTO.Body(signature: signature))
AnyCodable(WalletConnectSolanaSignMessageDTO.Body(signature: signature))
)
} catch {
AppLog.shared.debug("[WC 2.0] Failed to sign message. \(error)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ final class WalletConnectHandlersFactory: WalletConnectHandlersCreator {
uiDelegate: uiDelegate
)
case .solanaSignMessage:
return try WalletConnectSolanaMessageSignHandler(
return try WalletConnectSolanaSignMessageHandler(
request: params,
signer: SolanaWalletConnectSigner(signer: signer),
blockchainId: blockchainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,23 @@ struct WalletConnectV2Utils {
/// Array of Strings with unsupported blockchain names
func extractUnsupportedBlockchainNames(from namespaces: [String: ProposalNamespace]) -> [String] {
var blockchains = [String]()

for (namespace, proposal) in namespaces {
guard let chains = proposal.chains else {
continue
}

guard let _ = WalletConnectSupportedNamespaces(rawValue: namespace) else {
if WalletConnectSupportedNamespaces(rawValue: namespace) != nil {
let notSupportedEVMChainIds: [String] = chains.compactMap { chain in
guard createBlockchain(for: chain) == nil else {
return nil
}

return chain.absoluteString
}

blockchains.append(contentsOf: notSupportedEVMChainIds)
} else {
let notEVMChainNames = chains.map { chain in
return createBlockchain(for: chain)?.displayName ?? namespace.capitalizingFirstLetter()
}
Expand All @@ -62,16 +73,6 @@ struct WalletConnectV2Utils {

continue
}

let notSupportedEVMChainIds: [String] = chains.compactMap { chain in
guard createBlockchain(for: chain) == nil else {
return nil
}

return chain.absoluteString
}

blockchains.append(contentsOf: notSupportedEVMChainIds)
}

return blockchains
Expand Down Expand Up @@ -153,7 +154,7 @@ struct WalletConnectV2Utils {
}

func createBlockchain(for wcBlockchain: WalletConnectUtils.Blockchain) -> BlockchainMeta? {
guard let _ = WalletConnectSupportedNamespaces(rawValue: wcBlockchain.namespace) else {
guard WalletConnectSupportedNamespaces(rawValue: wcBlockchain.namespace) != nil else {
return nil
}

Expand Down Expand Up @@ -185,7 +186,7 @@ struct WalletConnectV2Utils {
walletModelProvider: WalletConnectWalletModelProvider
) -> BlockchainNetwork? {
guard
let _ = WalletConnectSupportedNamespaces(rawValue: wcBlockchain.namespace),
WalletConnectSupportedNamespaces(rawValue: wcBlockchain.namespace) != nil,
let blockchain = createBlockchain(for: wcBlockchain),
let walletModel = try? walletModelProvider.getModel(with: address, blockchainId: blockchain.id)
else {
Expand Down
16 changes: 8 additions & 8 deletions TangemApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2214,12 +2214,12 @@
DCD9CBA529F7F4EF00440C93 /* LogFileProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD9CBA429F7F4EF00440C93 /* LogFileProvider.swift */; };
DCDBDA062A27C16C0000EBA2 /* LockedUserWalletModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCDBDA052A27C16C0000EBA2 /* LockedUserWalletModel.swift */; };
DCDE745C2C1374AC00C19A23 /* WelcomeOnboardingTOSDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCDE745B2C1374AC00C19A23 /* WelcomeOnboardingTOSDelegate.swift */; };
DCE0E2BD2CBE43C2009A4007 /* WalletConnectSolanaMessageSignHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE0E2BC2CBE43C2009A4007 /* WalletConnectSolanaMessageSignHandler.swift */; };
DCE0E2BD2CBE43C2009A4007 /* WalletConnectSolanaSignMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE0E2BC2CBE43C2009A4007 /* WalletConnectSolanaSignMessageHandler.swift */; };
DCE0E2C22CBE4804009A4007 /* WalletConnectSigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE0E2C12CBE4804009A4007 /* WalletConnectSigner.swift */; };
DCE0E2C52CBE486A009A4007 /* CommonWalletConnectSigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE0E2C42CBE486A009A4007 /* CommonWalletConnectSigner.swift */; };
DCE0E2C72CBE4891009A4007 /* SolanaWalletConnectSigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE0E2C62CBE4891009A4007 /* SolanaWalletConnectSigner.swift */; };
DCE0E2C92CBE49BF009A4007 /* BlockchainSDK+WalletConnectChainId.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE0E2C82CBE49BF009A4007 /* BlockchainSDK+WalletConnectChainId.swift */; };
DCE317B62CC499DB0069C641 /* WalletConnectSolanaMessageSignDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE317B52CC499DB0069C641 /* WalletConnectSolanaMessageSignDTO.swift */; };
DCE317B62CC499DB0069C641 /* WalletConnectSolanaSignMessageDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE317B52CC499DB0069C641 /* WalletConnectSolanaSignMessageDTO.swift */; };
DCE317B82CC4F7FE0069C641 /* WalletConnectSolanaSignTransactionDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE317B72CC4F7FE0069C641 /* WalletConnectSolanaSignTransactionDTO.swift */; };
DCE317BB2CC4F8860069C641 /* WalletConnectSolanaSignTransactionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE317BA2CC4F8860069C641 /* WalletConnectSolanaSignTransactionHandler.swift */; };
DCE317BD2CC4F9440069C641 /* WalletConnectV2Utils+BlockchainMeta.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE317BC2CC4F9440069C641 /* WalletConnectV2Utils+BlockchainMeta.swift */; };
Expand Down Expand Up @@ -5238,7 +5238,7 @@
DCDECB942C88D78700E10564 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = es; path = es.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
DCDECB952C88D78700E10564 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
DCDECB962C88D78700E10564 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Intents.strings; sourceTree = "<group>"; };
DCE0E2BC2CBE43C2009A4007 /* WalletConnectSolanaMessageSignHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSolanaMessageSignHandler.swift; sourceTree = "<group>"; };
DCE0E2BC2CBE43C2009A4007 /* WalletConnectSolanaSignMessageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSolanaSignMessageHandler.swift; sourceTree = "<group>"; };
DCE0E2C12CBE4804009A4007 /* WalletConnectSigner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSigner.swift; sourceTree = "<group>"; };
DCE0E2C42CBE486A009A4007 /* CommonWalletConnectSigner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonWalletConnectSigner.swift; sourceTree = "<group>"; };
DCE0E2C62CBE4891009A4007 /* SolanaWalletConnectSigner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SolanaWalletConnectSigner.swift; sourceTree = "<group>"; };
Expand All @@ -5249,7 +5249,7 @@
DCE1E82D2C542B1100A6BDDE /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Intents.strings; sourceTree = "<group>"; };
DCE1E82E2C542B1200A6BDDE /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Intents.strings; sourceTree = "<group>"; };
DCE1E82F2C542B1300A6BDDE /* uk-UA */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "uk-UA"; path = "uk-UA.lproj/Intents.strings"; sourceTree = "<group>"; };
DCE317B52CC499DB0069C641 /* WalletConnectSolanaMessageSignDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSolanaMessageSignDTO.swift; sourceTree = "<group>"; };
DCE317B52CC499DB0069C641 /* WalletConnectSolanaSignMessageDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSolanaSignMessageDTO.swift; sourceTree = "<group>"; };
DCE317B72CC4F7FE0069C641 /* WalletConnectSolanaSignTransactionDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSolanaSignTransactionDTO.swift; sourceTree = "<group>"; };
DCE317BA2CC4F8860069C641 /* WalletConnectSolanaSignTransactionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletConnectSolanaSignTransactionHandler.swift; sourceTree = "<group>"; };
DCE317BC2CC4F9440069C641 /* WalletConnectV2Utils+BlockchainMeta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WalletConnectV2Utils+BlockchainMeta.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -12575,8 +12575,8 @@
DCE0E2BB2CBE43B7009A4007 /* Solana */ = {
isa = PBXGroup;
children = (
DCE0E2BC2CBE43C2009A4007 /* WalletConnectSolanaMessageSignHandler.swift */,
DCE317B52CC499DB0069C641 /* WalletConnectSolanaMessageSignDTO.swift */,
DCE0E2BC2CBE43C2009A4007 /* WalletConnectSolanaSignMessageHandler.swift */,
DCE317B52CC499DB0069C641 /* WalletConnectSolanaSignMessageDTO.swift */,
);
path = Solana;
sourceTree = "<group>";
Expand Down Expand Up @@ -15737,7 +15737,7 @@
2DB8E1162B29068C0044BF7D /* CustomSearchBar.swift in Sources */,
EFB932032C3EAF7900C999E9 /* SendStepType.swift in Sources */,
EF4BEFDF28AD3EE500C5D1BE /* ContentState.swift in Sources */,
DCE317B62CC499DB0069C641 /* WalletConnectSolanaMessageSignDTO.swift in Sources */,
DCE317B62CC499DB0069C641 /* WalletConnectSolanaSignMessageDTO.swift in Sources */,
B0BE30652A7BA74000B3AD13 /* MultiWalletTokenItemsSectionFactory.swift in Sources */,
2D5DCC362C330A33000EE379 /* WalletSelectorItemViewModel.swift in Sources */,
EF2FE49E2C6BB5390015940A /* TransactionCreator+.swift in Sources */,
Expand Down Expand Up @@ -15818,7 +15818,7 @@
EF977CBF2C788965006BB27C /* PendingActionMapper.swift in Sources */,
B645BF3F2C59239700D8A2A5 /* MarketsHistoryChartProvider.swift in Sources */,
EFD39C992A6A916C0055D215 /* EnvironmentSetupRoutable.swift in Sources */,
DCE0E2BD2CBE43C2009A4007 /* WalletConnectSolanaMessageSignHandler.swift in Sources */,
DCE0E2BD2CBE43C2009A4007 /* WalletConnectSolanaSignMessageHandler.swift in Sources */,
DA7444252A27889600F926A9 /* PromotionServiceProtocol.swift in Sources */,
DA559C352B0261F400F59584 /* SendFeeView.swift in Sources */,
EF7000812A94BE7300C56E8A /* CardanoWalletManagerFactory.swift in Sources */,
Expand Down

0 comments on commit 7a0e1fd

Please sign in to comment.