elrond-sdk-erdjs icon indicating copy to clipboard operation
elrond-sdk-erdjs copied to clipboard

Tokens are missing properties from the API

Open keyur555 opened this issue 2 years ago • 5 comments

Hello Team,

I work with the Tokens FungibleTokenOfAccountOnNetwork and NonFungibleTokenOfAccountOnNetwork and I notice they are missing a lot of properties from the API. I try to get the Assets from it with the Token Logo and so but it is not possible at the moment.

Thank you!

keyur555 avatar Mar 11 '22 13:03 keyur555

Is the import incorrect too? Because I need to import like this import { FungibleTokenOfAccountOnNetwork } from '@elrondnetwork/erdjs/out/networkProvider/tokens'

But this is the normal I think which is not working import { FungibleTokenOfAccountOnNetwork } from '@elrondnetwork/erdjs'

keyur555 avatar Mar 11 '22 13:03 keyur555

Hello @keyur555!

Please use getToken() / getNFTToken() from the old (current) provider for the moment: https://github.com/ElrondNetwork/elrond-sdk-erdjs/blob/main/src/apiProvider.ts.

The new INetworkProvider interface is designed to be a replacement for IApiProvider and IProxyProvider. Though, it's not finalized yet.

andreibancioiu avatar Mar 14 '22 09:03 andreibancioiu

Hello @keyur555!

Do you think you can specify which function of the provider do you use?

In erdjs 10, the network providers have been extracted to a separate repository:

  • https://github.com/ElrondNetwork/elrond-sdk-erdjs-network-providers/blob/main/src/proxyNetworkProvider.ts
  • https://github.com/ElrondNetwork/elrond-sdk-erdjs-network-providers/blob/main/src/apiNetworkProvider.ts

Extra reference:

  • https://docs.elrond.com/sdk-and-tools/erdjs/erdjs-cookbook/#creating-network-providers

andreibancioiu avatar Apr 14 '22 18:04 andreibancioiu

@andreibancioiu Sorry to reopen this again. I use the ApiNetworkProvider from ErdJs 10 and the method getFungibleTokensOfAccount and I would like to access all properties of the Tokens. Including the Assets like the Logo image URL of the tokens.

I don't know it but i think it is just missing properties in the code because the API returns it?

keyur555 avatar Apr 22 '22 12:04 keyur555

Indeed, the API returns it: https://devnet-api.elrond.com/tokens/WEB-5d08be

We will add the missing fields in https://github.com/ElrondNetwork/elrond-sdk-erdjs-network-providers, as well. Thanks for raising the issue :pray:

However, until then, you can switch to performing direct HTTP requests against the API (and using your own, tailored data structures). This is our current recommendation:

The default classes ApiNetworkProvider / ProxyNetworkProvider should only be used as a starting point. As your dApp matures, make sure you switch to using your own network provider, tailored to your requirements (whether deriving from the default ones or writing a new one, from scratch) that directly interacts with the Elrond API (or Gateway).

Further reference:

  • https://docs.elrond.com/sdk-and-tools/erdjs/extending-erdjs/

andreibancioiu avatar Apr 28 '22 20:04 andreibancioiu

Close the issue, thanks to: https://github.com/multiversx/mx-sdk-js-network-providers/pull/14.

schimih avatar Mar 17 '23 13:03 schimih