From 4608c05d16ffbd4a7d9b436dd3cd24ca60070bb2 Mon Sep 17 00:00:00 2001 From: TD Date: Thu, 5 Oct 2023 14:32:50 +0200 Subject: [PATCH] fix cis 2 bugs --- .../AccountsView/AccountDetails/ButtonSlider.swift | 8 ++++---- .../AccountDetails/TokenDetails/TokenDetailsView.swift | 8 -------- .../AccountDetails/TokenLookup/CIS2Service.swift | 10 ++++++---- .../AccountDetails/TokenLookup/TokenLookupView.swift | 4 ++-- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ConcordiumWallet/Views/AccountsView/AccountDetails/ButtonSlider.swift b/ConcordiumWallet/Views/AccountsView/AccountDetails/ButtonSlider.swift index aafa12f3..016c235d 100644 --- a/ConcordiumWallet/Views/AccountsView/AccountDetails/ButtonSlider.swift +++ b/ConcordiumWallet/Views/AccountsView/AccountDetails/ButtonSlider.swift @@ -25,10 +25,10 @@ struct ButtonSlider: View { imageName: "ccd_coins", action: didTapTokensButton ), -// ActionButton( -// imageName: "button_slider_send", -// action: actionSend -// ), + ActionButton( + imageName: "button_slider_send", + action: actionSend + ), ActionButton( imageName: "transaction_list", action: didTapTransactionList diff --git a/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenDetails/TokenDetailsView.swift b/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenDetails/TokenDetailsView.swift index 31d05423..b2ecf37b 100644 --- a/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenDetails/TokenDetailsView.swift +++ b/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenDetails/TokenDetailsView.swift @@ -25,7 +25,6 @@ struct TokenDetailsView: View { var sendFunds: () -> Void var context: Context @State private var isAlertShown = false - @State private var isMetadataShown = false @State var isOwned = false @State private var error: TokenError? = nil @@ -150,19 +149,12 @@ struct TokenDetailsView: View { .foregroundColor(.gray) Text("\(token.decimals)").font(.body) } - - Button { - isMetadataShown = true - } label: { - Text("Show raw metadata") - } } .padding() } .alert(item: $error) { error in Alert(title: Text("Error"), message: Text(error.errorMessage), dismissButton: .default(Text("OK"))) } - .sheet(isPresented: $isMetadataShown) {} .onReceive(service.observedTokensPublisher(for: token.accountAddress, filteredBy: token.tokenId).asResult()) { result in switch result { case let .success(items): diff --git a/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/CIS2Service.swift b/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/CIS2Service.swift index 6c57d823..4fb76f82 100644 --- a/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/CIS2Service.swift +++ b/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/CIS2Service.swift @@ -38,9 +38,10 @@ class CIS2Service: CIS2ServiceProtocol { .map { $0.filter { $0.contractIndex == contractIndex } } .eraseToAnyPublisher() } + func observedTokens(for accountAddress: String, filteredBy contractIndex: String) -> [CIS2TokenSelectionRepresentable] { storageManager.getUserStoredCIS2Tokens(for: accountAddress, filteredBy: contractIndex).map { - map(entity: $0) + transformCIS2Token(from: $0) } } @@ -68,8 +69,8 @@ class CIS2Service: CIS2ServiceProtocol { .eraseToAnyPublisher() } - private func map(entity: CIS2TokenOwnershipEntity) -> CIS2TokenSelectionRepresentable { - return CIS2TokenSelectionRepresentable( + private func transformCIS2Token(from entity: CIS2TokenOwnershipEntity) -> CIS2TokenSelectionRepresentable { + CIS2TokenSelectionRepresentable( contractName: entity.contractName, tokenId: entity.tokenId, balance: .zero, @@ -97,7 +98,8 @@ class CIS2Service: CIS2ServiceProtocol { ResourceRequest( url: ApiConstants.cis2Tokens .appendingPathComponent(contractIndex) - .appendingPathComponent(contractSubindex) + .appendingPathComponent(contractSubindex), + parameters: ["limit" : "1000"] ) ) } diff --git a/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/TokenLookupView.swift b/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/TokenLookupView.swift index de19d08f..516f97d3 100644 --- a/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/TokenLookupView.swift +++ b/ConcordiumWallet/Views/AccountsView/AccountDetails/TokenLookup/TokenLookupView.swift @@ -3,9 +3,9 @@ // ConcordiumWallet // +import BigInt import Combine import SwiftUI -import BigInt enum TokenError: Error, Identifiable { var id: String { errorMessage } @@ -52,7 +52,7 @@ struct TokenLookupView: View { ) } } - .debounce(for: 0.5, scheduler: RunLoop.main) + .debounce(for: 1, scheduler: RunLoop.main) .flatMapLatest { token -> AnyPublisher<[CIS2Token], TokenError> in service.fetchTokens(contractIndex: token, contractSubindex: "0") .map { $0.tokens }