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

adding fallback when indexer is down to fetch nfts owners #671

Conversation

Viterbo
Copy link
Collaborator

@Viterbo Viterbo commented Nov 16, 2023

Fixes #659

Description

This Pull Request addresses the issue of stale NFT indexer data. It implements a backup query mechanism and user notifications for cases where the indexer data is stale. The main enhancements include:

  • Adding an indexer health check.
  • Implementing backup queries for fetching the current NFT owner.
  • Notifying users on the collection inventory page about the indexer being not healthy.
  • Querying ERC721 and ERC1155 contracts directly for ownerOf and balanceOf updates when needed.
    These changes ensure that NFT ownership and quantity are accurately reflected, even when the indexer data is not up-to-date.

Test Scenarios

Currently, the indexer is up to date so I created a way to simulate the indexer is not healthy.

  • go to this page and login
  • go to demo section (left-bottom)
  • go to "Simulation indexer down"
  • press the button "Simulate indexer down" and wait for it to go down
  • press Homepage link (don't refresh the page)
  • login again
  • go to inventory page
    • you should get a warning notification about indexer being down
  • go to any ERC1155 detail page
  • check the owner list
  • transfer the NFT and wait for the page to reload NFT owners
    • it only updates your balance of that ERC1155
    • other owner balances stay the same (because we don't use the indexer)

Videocapture

Owners-When-Indexer-Down.mp4

Checklist:

  • Implemented indexer health check and user notifications for stale data.
  • Added backup queries to fetch current NFT data from contracts directly.
  • Ensured that the solution works for both ERC721 and ERC1155 contracts.
  • Conducted thorough testing to confirm the accuracy of NFT data.
  • Reviewed and cleaned up the code in the affected areas.
  • No new warnings generated by the changes.
  • All changes merged and published in downstream modules.
  • Code and comments reviewed for clarity and comprehensibility.
  • English text included in the translation file or new issue created for required translations.
  • Mobile functionality and responsiveness tested.
  • Appropriate test coverage added.

@Viterbo Viterbo linked an issue Nov 16, 2023 that may be closed by this pull request
3 tasks
Copy link

netlify bot commented Nov 16, 2023

Deploy Preview for wallet-develop-mainnet ready!

Name Link
🔨 Latest commit 1be75e2
🔍 Latest deploy log https://app.netlify.com/sites/wallet-develop-mainnet/deploys/65590e8b1481720008f016e9
😎 Deploy Preview https://deploy-preview-671--wallet-develop-mainnet.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 16, 2023

Deploy Preview for wallet-staging ready!

Name Link
🔨 Latest commit 1be75e2
🔍 Latest deploy log https://app.netlify.com/sites/wallet-staging/deploys/65590e8b71e96a0008582e8f
😎 Deploy Preview https://deploy-preview-671--wallet-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Viterbo Viterbo self-assigned this Nov 16, 2023
@donnyquixotic donnyquixotic marked this pull request as ready for review November 16, 2023 16:03
donnyquixotic
donnyquixotic previously approved these changes Nov 16, 2023
@@ -383,6 +411,14 @@ export default abstract class EVMChainSettings implements ChainSettings {

this.processNftContractsCalldata(response.contracts);
const shapedNftData = this.shapeNftRawData(shapedIndexerNftData, response.contracts);

// if the owner does not comes from the indexer, let's set it
shapedNftData.forEach((nft) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should only be set for erc721, which is why line 409 has a ternary like
owner: isErc1155 ? undefined : nftResponse.owner,
so here we should also only set owner if it's 1155

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this forEach and just set it in the original mapping?

owner: isErc1155 ? account : nftResponse.owner,

Copy link
Contributor

@donnyquixotic donnyquixotic Nov 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to use owner: nftResponse.owner ?? account in mapping and remove forEach

const getAccount = jest.fn().mockImplementation(() => null);
const getAccount = jest.fn().mockImplementation(() => ({
authenticator: jest.fn().mockImplementation(() => ({
web3Provider: jest.fn().mockImplementation(() => 'do you need to get deeper?'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

@ezra-sg
Copy link
Contributor

ezra-sg commented Nov 16, 2023

when i click Demos, it kicks me back to the home page

Recording.2023-11-16.162443.mp4

donnyquixotic
donnyquixotic previously approved these changes Nov 16, 2023
@donnyquixotic donnyquixotic mentioned this pull request Nov 17, 2023
@donnyquixotic donnyquixotic merged commit c7b4f0d into develop Nov 18, 2023
9 checks passed
@donnyquixotic donnyquixotic deleted the 659-implement-back-up-query-notification-for-stale-nft-indexer-data branch November 18, 2023 19:22
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.

Implement back up query & notification for stale NFT indexer data
3 participants