Skip to content

Commit 518bf84

Browse files
committed
wallet connect fixes
1 parent 5abd75a commit 518bf84

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

fearless/Modules/WalletConnectConfirmation/WalletConnectConfirmationPresenter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ final class WalletConnectConfirmationPresenter {
108108
private func approveTonConnect() async throws {
109109
_ = try await interactor.approve()
110110
Task { @MainActor in
111-
router.dismiss(view: view)
112-
view?.controller.onInteractionDismiss()
111+
showAllDone(hash: nil)
112+
view?.didStopLoading()
113113
}
114114
}
115115

fearless/Modules/WalletConnectProposal/Model/WalletConnectProposalViewModel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ enum WalletConnectProposalCellModel {
114114
let metaId: String
115115
let walletName: String
116116
var isSelected: Bool
117+
let icon: UIImage
117118

118119
func toggle() -> Self {
119120
WalletViewModel(
120121
metaId: metaId,
121122
walletName: walletName,
122-
isSelected: !isSelected
123+
isSelected: !isSelected,
124+
icon: icon
123125
)
124126
}
125127
}

fearless/Modules/WalletConnectProposal/Model/WalletConnectProposalViewModelFactory.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ final class WalletConnectProposalViewModelFactoryImpl: WalletConnectProposalView
3232
wallets: [MetaAccountModel],
3333
locale: Locale
3434
) throws -> WalletConnectProposalViewModel {
35+
let wallets = filterWallets(wallets: wallets)
3536
switch status {
3637
case let .proposal(connectProposal):
3738
switch connectProposal {
@@ -109,6 +110,27 @@ final class WalletConnectProposalViewModelFactoryImpl: WalletConnectProposalView
109110
}
110111

111112
// MARK: - Private methods
113+
114+
private func filterWallets(wallets: [MetaAccountModel]) -> [MetaAccountModel] {
115+
return wallets.filter { wallet in
116+
switch status {
117+
case .proposal(let connectProposal):
118+
switch connectProposal {
119+
case .walletConnect:
120+
return wallet.ecosystem.isRegular
121+
case .tonJsBridge, .tonConnect:
122+
return wallet.ecosystem.isTon
123+
}
124+
case .active(let actionConnect):
125+
switch actionConnect {
126+
case .walletConnect:
127+
return wallet.ecosystem.isRegular
128+
case .tonConnect:
129+
return wallet.ecosystem.isTon
130+
}
131+
}
132+
}
133+
}
112134

113135
private func createDAppViewModel() -> WalletConnectProposalCellModel.DetailsViewModel {
114136
switch status {
@@ -376,11 +398,13 @@ final class WalletConnectProposalViewModelFactoryImpl: WalletConnectProposalView
376398
from wallets: [MetaAccountModel],
377399
forActiveSession: Bool
378400
) -> [WalletConnectProposalCellModel] {
379-
wallets.enumerated().map { index, wallet in
401+
let selectedWallet = SelectedWalletSettings.shared.value
402+
return wallets.enumerated().map { index, wallet in
380403
let viewModel = WalletConnectProposalCellModel.WalletViewModel(
381404
metaId: wallet.metaId,
382405
walletName: wallet.name,
383-
isSelected: forActiveSession ? true : index == 0
406+
isSelected: forActiveSession ? true : wallet.metaId == selectedWallet?.metaId,
407+
icon: wallet.ecosystem.isRegular ? R.image.iconBirdGreen()! : R.image.tonIcon()!
384408
)
385409
return WalletConnectProposalCellModel.wallet(viewModel)
386410
}

fearless/Modules/WalletConnectProposal/WalletConnectProposalWalletsTableCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ final class WalletConnectProposalWalletsTableCell: UITableViewCell {
1515
view.borderWidth = 2
1616
view.layout = .singleTitle
1717
view.highlightedStrokeColor = R.color.colorPink()!
18-
view.iconImage = R.image.iconBirdGreen()
1918
view.isUserInteractionEnabled = false
2019
view.triangularedBackgroundView?.gradientBorderColors = UIColor.walletBorderGradientColors
2120
return view
@@ -38,6 +37,7 @@ final class WalletConnectProposalWalletsTableCell: UITableViewCell {
3837
view.title = viewModel.walletName
3938
view.layoutIfNeeded()
4039
view.triangularedBackgroundView?.setGradientBorder(highlighted: viewModel.isSelected, animated: true)
40+
view.iconImage = viewModel.icon
4141
}
4242

4343
// MARK: - Private methods

0 commit comments

Comments
 (0)