near / near-enhanced-api-server

https://console.pagoda.co/apis?tab=enhancedApi#/
18 stars 6 forks source link

[QUESTION] Why does not all tokens show up as shown in wallet? #9

Open munanadi opened 2 years ago

munanadi commented 2 years ago

Using the endpoint `/accounts/

{account_id}

/coins Only tokens likeUSNorwNEAR` show up and

 "balances": [
 {
 "standard": "nearprotocol",
 "balance": "1874403883412938099999974",
 "contract_account_id": null,
 "metadata": 

 { "name": "NEAR blockchain native token", "symbol": "NEAR", "icon": "https://raw.githubusercontent.com/near/near-wallet/7ef3c824404282b76b36da2dff4f3e593e7f928d/packages/frontend/src/images/near.svg", "decimals": 24 } 

 }, {} , ],

tokens like USDT and USDC are ignored which is not the case on wallet.near.org as shown below ![image](https://user-images.githubusercontent.com/22261173/177594238-73c6b7bf-ab95-4e38-9468-f62e4f5c0990.png)

Does this happen because of the spec differences in both?

Also, Would like to contribute and help. Please help with resources I can get started with.

telezhnaya commented 2 years ago

Hey @pisomanik , In API, for now, we have only the support of the contracts that implement Events NEP. So, wrap.near is not in the response for sure. We remember about it, we have a plan to support it separately.

If it's OK, could you please share your account_id? It would be nice to test on it later.

Thank you for your readiness to contribute! I'll try to write some docs and write down the issues that I have in todos/in my head 🙂

munanadi commented 2 years ago

The account Id I used is spoiler.near.

Yes wrap.near doesn't show up but it is rather straightforward to query for that because we know the account id. It becomes hard for finding the other tokens for a given account id.

Is there any other way to find tokens given only an account id? Yep, docs and todo will help a lot. Thanks! Meanwhile, I'll source dive and do what I can.

telezhnaya commented 2 years ago

We've introduced Events NEP, but not all the contracts updated to it, unfortunately. Theoretically, any account_id could deploy the contract and we will miss the updates from it.

The DB collects all the valid events, so we can easily find all the contracts that follow Events NEP. Please share contract_ids that you know who implement the core standard, but does not implement Events (if you will find them accidentally by any chance). I know about wrap.near and aurora.

The good news here is that the vast majority of the new contracts are built based on our SDK, it implements the Events perfectly, so it shouldn't be a problem with the new contracts. For the old ones, we are trying to find the solution right now.

munanadi commented 2 years ago

Some of the common tokens I found are

Also, is there a better way to find out what tokens belong to an account right now?

One way that kinda works is using https://api.kitwallet.app/account/{ACCOUNT_ID}/likelyTokens but this has some exceptions too.

frol commented 2 years ago

@pisomanik Those are Aurora-bridged tokens and we are surely working on adding the support with custom indexing

munanadi commented 2 years ago

@frol Ahh Aurora backed tokens. Now it makes sense. Thank you for the explanations. Appreciate it.

telezhnaya commented 2 years ago

@pisomanik you helped a lot by providing your account_id. It's perfect for testing purposes: you have just the right number of different transactions to check the code 👍

I prefer to keep this issue open till we release the legacy support!