diff --git a/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift b/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift index 15741528a6..eabe981cd2 100644 --- a/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift +++ b/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift @@ -93,16 +93,15 @@ extension TransactionClient { func getAllFeePayerCandidates(refreshingBalances: Bool) async throws -> NonEmpty> { let networkID = await gatewaysClient.getCurrentNetworkID() let allAccounts = try await accountsClient.getAccountsOnNetwork(networkID) + let entities = try await onLedgerEntitiesClient.getAccounts(allAccounts.map(\.address), cachingStrategy: .forceUpdate) - let allFeePayerCandidates = try await onLedgerEntitiesClient.getAccounts(allAccounts.map(\.address), cachingStrategy: .forceUpdate).compactMap { portfolio -> FeePayerCandidate? in - guard - let account = allAccounts.first(where: { account in account.address == portfolio.address }) - else { + let allFeePayerCandidates = allAccounts.compactMap { account -> FeePayerCandidate? in + guard let entity = entities.first(where: { $0.address == account.address }) else { assertionFailure("Failed to find account or no balance, this should never happen.") return nil } - guard let xrdBalance = portfolio.fungibleResources.xrdResource?.amount else { + guard let xrdBalance = entity.fungibleResources.xrdResource?.amount else { return nil } diff --git a/RadixWallet/Features/TransactionReviewFeature/SelectFeePayer/SelectFeePayer+View.swift b/RadixWallet/Features/TransactionReviewFeature/SelectFeePayer/SelectFeePayer+View.swift index 85e46e09c0..97b8f7249b 100644 --- a/RadixWallet/Features/TransactionReviewFeature/SelectFeePayer/SelectFeePayer+View.swift +++ b/RadixWallet/Features/TransactionReviewFeature/SelectFeePayer/SelectFeePayer+View.swift @@ -56,27 +56,33 @@ extension SelectFeePayer { .padding(.horizontal, .large3) .padding(.bottom, .small1) - ScrollView { - loadable(viewStore.feePayerCandidates) { - ProgressView() - } successContent: { candidates in - VStack(spacing: .small1) { - Selection( - viewStore.binding( - get: \.selectedPayer, - send: { .selectedPayer($0) } - ), - from: candidates - ) { item in - SelectAccountToPayForFeeRow.View( - viewState: .init(candidate: item.value), - isSelected: item.isSelected, - action: item.action - ) + ScrollViewReader { proxy in + ScrollView { + loadable(viewStore.feePayerCandidates) { + ProgressView() + } successContent: { candidates in + VStack(spacing: .small1) { + Selection( + viewStore.binding( + get: \.selectedPayer, + send: { .selectedPayer($0) } + ), + from: candidates + ) { item in + SelectAccountToPayForFeeRow.View( + viewState: .init(candidate: item.value), + isSelected: item.isSelected, + action: item.action + ) + .id(item.value.id) + } + } + .padding(.horizontal, .medium1) + .padding(.bottom, .medium2) + .onFirstAppear { + proxy.scrollTo(viewStore.selectedPayer?.id, anchor: .center) } } - .padding(.horizontal, .medium1) - .padding(.bottom, .medium2) } } .refreshable { @MainActor in