Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: nft service #250

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

chore: nft service #250

wants to merge 1 commit into from

Conversation

shane-moore
Copy link
Collaborator

Changes

  • nft collection and token queries/types/transformers were added to sdk-ts
  • NftService.ts was added to sdk-ui-ts as to make it easy to query for token metadata for nft's created via mainnet codeId 49 or testnet codeId 582
    • the flow is as follows:
      1. query all smart contracts instantiated via the network specific codeId since each contract is a different NFT collection, and we pass the injectiveAddress to determine which nfts a user owns in each collection
      2. the contract calls return ipfs content identifiers (CIDs), which can then be used to query an ipfs gateway and get back metadata associated with each token as json. We also receive back a CID for the NFT's image, which can be used by the FE in an img tag for example
    • the NftService also provides a helper function for querying the contracts to obtain the name of the collection, as to be used for filtering on the FE

Optimizations

  • querying IPFS can be quite slow, so it's paramount that we make the calls consecutively. It's also possible that some of the calls fail or timeout. In this scenario, we send back the successful token metadata to the FE and allow the user to pass in an error handler callback function to the service, which triggers when an ipfs query fails. Then, the FE can render the successful images and also show some error message to notify the user of missing NFTS from the query. Some additional context on IPFS complications and potential solutions are detailed in notion doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant