Skip to content

Commit

Permalink
fix token look up pagination logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ramakser committed Mar 11, 2024
1 parent 5e4060c commit 8d8efee
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ final class CIS2TokenSelectViewModel: ObservableObject {
Task {
do {
let ids = allContractTokens.dropFirst((currentPage - 1) * batchSize).prefix(batchSize)

guard !ids.isEmpty else {
return await MainActor.run {
hasMore = false
isLoading = false
}
}

let metadata = try await service.fetchTokensMetadata(contractIndex: contractIndex, contractSubindex: "0", tokenId: ids.map { $0.token }.joined(separator: ","))
let metadataPairs = try await getTokenMetadataPair(metadata: metadata)
let balances = try await service.fetchTokensBalance(contractIndex: contractIndex, contractSubindex: "0", accountAddress: accountAddress, tokenId: ids.map { $0.token }.joined(separator: ","))
Expand Down

0 comments on commit 8d8efee

Please sign in to comment.