web3swift
web3swift copied to clipboard
Promise.wait() performs infinite time
Hello.
My code gets a balance of ERC721 on wallet and after trying to go through getTokenOwnedByIndex
.
6 request simultaneously runs and wait.
I connected proxy and see the balance request was sent and returned. getTokenOwnedByIndex
requests event don't make any network request.

Code stucks after some made token. After reset wallet code starts work well, but after some count it stucks.
Code:
guard let web3Provider = web3Provider else {
throw Web3NetworkError.noProvider
}
guard let contractABI = contractABI else {
throw Web3NetworkError.invalidContractABI
}
let contract = web3Provider.contract(contractABI, at: contractAddress)!
var transactionOptions = TransactionOptions()
transactionOptions.callOnBlock = .latest
let result = try contract.read("tokenOfOwnerByIndex", parameters: [owner, index] as [AnyObject])!.call(transactionOptions: transactionOptions)
guard let res = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Failed to get result of expected type from the Ethereum node")}
return res
Extra info: usually reproducible when tokens are requested by id, but kill the app and launch these requests again. Is there any caching inside lib?
Strange, that balance request finished successfully, but next tokenOfOwnerByIndex
are stucks.
Also, investigated a bit more. Looks like the issue is in queue.
When there are 6 requests for tokenOfOwnerByIndex
they're stuck.
When there are 5 requests for tokenOfOwnerByIndex
they're pass, but when trying to fetch TokenURI, only 3 pass.
When there are 3 requests, every request passes.
So, should requests be performed in serial queue?
Thank you for that. There'll be no Promise
s in version 3.0.0 which is currently in deep development. So the issue would be resolved itself.
ETA 3.0.0 is about 3 months, but there's RC available (pretty unstable yet).