AlphaWallet / alpha-wallet-android

An advanced Ethereum mobile wallet
https://www.alphawallet.com
MIT License
603 stars 535 forks source link

NFT count are all 0 in wallet tab #2719

Open seabornlee opened 2 years ago

seabornlee commented 2 years ago
image
hboon commented 2 years ago

If you haven't, when you see that, hit the OpenSea API from the same IP address to see if it's rate limited to help narrow it down

seabornlee commented 2 years ago

Thanks Boon!

I got rate limited error with Ether Scan API:

2022-07-12 15:30:59.490 20669-22059/io.stormbird.wallet E/TransactionsNetworkClient: org.json.JSONException: Value Max rate limit reached, please use API Key for higher rate limit at result of type java.lang.String cannot be converted to JSONArray
        at org.json.JSON.typeMismatch(JSON.java:101)
        at org.json.JSONObject.getJSONArray(JSONObject.java:598)
        at com.alphawallet.app.service.TransactionsNetworkClient.getEtherscanTransactions(TransactionsNetworkClient.java:319)
        at com.alphawallet.app.service.TransactionsNetworkClient.readTransactions(TransactionsNetworkClient.java:451)
        at com.alphawallet.app.service.TransactionsNetworkClient.syncUpwards(TransactionsNetworkClient.java:274)
        at com.alphawallet.app.service.TransactionsNetworkClient.lambda$storeNewTransactions$1$com-alphawallet-app-service-TransactionsNetworkClient(TransactionsNetworkClient.java:181)
        at com.alphawallet.app.service.TransactionsNetworkClient$$ExternalSyntheticLambda8.call(Unknown Source:10)

I checked the OpenSea API key is configured properly, does rate limit happend even with a production API key?

seabornlee commented 2 years ago

You are right. I am blocked to access assets API on mainnet, but not blocked from accessing matic assets.

hboon commented 2 years ago

I checked the OpenSea API key is configured properly, does rate limit happend even with a production API key?

I think so.

JamesSmartCell commented 2 years ago

@seabornlee "It's not a bug, it's a feature"

This stems from when we decided to display all known contracts, so if you open up a new wallet it will show zero balance. There used to be an option in 'Add/Hide Tokens' to not show zero balance tokens but for some reason we removed it (maybe people didn't understand what it did). It has nothing to do with Opensea API key (to save you some time).

If it's an account with the NFT, but without the Opensea API key, it will gradually discover the NFTs in your account using the node directly, scanning the event list.

If you click on the NFT it will discover them from the event list.

The process looks like this:

So, to fix this, maybe add the 'show zero balance tokens' option back into the add/hide tokens menu, and default to 'show'.

It's not a bug, it's a feature; at the moment.

JamesSmartCell commented 2 years ago

As an aside, are we being etherscan rate limited now? It makes sense. They will want to monetise their API.

We do have an Etherscan API key but it's free tier.

seabornlee commented 2 years ago

Thanks @JamesSmartCell When the balance is 0, I click the collection, it shows my NFTs, so should we update the balance before user clicking the collection?

JamesSmartCell commented 2 years ago

It should do a balance update before it even displays in the wallet view.

I've spent a lot of time in that area, it should be perfect (almost) - we haven't seen any issues like this for some time.

Edit: Actually I need to check if it does do the check balance before it adds to the wallet view. If there's data from opensea and it's displaying then it should show the balance correctly.

Is this in your wallet? This could also be a result of the API call failing.

seabornlee commented 2 years ago

When I switched to Oppo ColorOS, it performs much better than my Huawei with Harmony OS.

  1. Assets fetch is much faster
  2. When refreshing the assets list, some assets disappeared on Huawei and come back in a very long time