Skip to content

feat(tokenDetails): ERC721 token navigation and recent tokens list#362

Open
AugustoL wants to merge 3 commits intoopenscan-explorer:devfrom
AugustoL:feat/erc721-token-navigation
Open

feat(tokenDetails): ERC721 token navigation and recent tokens list#362
AugustoL wants to merge 3 commits intoopenscan-explorer:devfrom
AugustoL:feat/erc721-token-navigation

Conversation

@AugustoL
Copy link
Copy Markdown
Collaborator

Description

Adds prev/next token navigation to the ERC-721 token detail page and a "Recent Tokens" table to the ERC-721 collection (address) page. Also fixes link color contrast on the token detail page in dark mode, where several links were falling back to the browser default (poor contrast on the dark card).

Related Issue

Closes #345

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

  • Prev/next token navigation (ERC721TokenDisplay.tsx): arrow buttons in the header, BigInt-safe math for uint256 IDs. Disabled state when at edges or when totalSupply isn't available.
  • Recent Tokens table (CollectionTokenList.tsx): queries ERC721Enumerable's tokenByIndex for the latest N tokens on the collection page. Silently hides itself if the contract doesn't implement Enumerable (e.g., Nouns DAO reverts on tokenByIndex), so non-Enumerable collections aren't affected.
  • New helper in erc721Metadata.ts: fetchTokenByIndex(address, index, rpcUrl) — selector 0x4f6ccce5, returns the token ID as a decimal string or null on revert.
  • Dark-mode link fixes in styles/components.css:
    • Added missing .address-link rule (Collection/Contract/Owner/Approved inline links) — was falling back to browser default blue/purple on dark bg.
    • Replaced undefined --primary-color fallback in .nft-collection-link with --color-primary for brand consistency.
    • Tightened .nft-link-button contrast (alpha-15 bg + border, --badge-info-text hover).
    • Swapped hardcoded rgba(0,0,0,0.03) URI-code bg for --overlay-light-5 + --border-primary so the block is visible in both themes.
  • i18n: added recentTokens, tableTokenId, tableOwner to address namespace, and previousToken, nextToken to tokenDetails, across all 5 locales (en, es, ja, pt-BR, zh).

Screenshots (if applicable)

Verified in dark and light modes against Nouns DAO (0x9C8fF…eDC03). All four inline links on the token detail page now render in --color-primary (#10b981) and match the .link-accent styling used on the tx/block pages.

Checklist

  • I have run npm run format:fix and npm run lint:fix
  • I have run npm run typecheck with no errors
  • I have run tests with npm run test:run
  • I have tested my changes locally
  • I have updated documentation if needed
  • My code follows the project's architecture patterns

Additional Notes

  • The CollectionTokenList section only appears for collections that implement ERC721Enumerable. The first tokenByIndex(totalSupply-1) probe is used to detect Enumerable support; if it reverts, the component sets enumerable=false and renders nothing. Collections like Nouns (not Enumerable) therefore show the usual NFT Collection card without the recent-tokens list — no regression.
  • Potential follow-up (separate issue): fall back to scanning Transfer events from address(0) for non-Enumerable collections, so the recent-tokens table can also work for contracts that skip ERC721Enumerable for gas reasons.

…lay (openscan-explorer#345)

Add arrow buttons next to the token ID header that navigate to adjacent
tokens in the collection. Uses BigInt arithmetic for uint256 safety and
respects collection totalSupply when available; disabled states render
when no neighbor exists or totalSupply is undefined.
…openscan-explorer#345)

Surface the latest minted tokens on the ERC721 address/collection page
using ERC721Enumerable's tokenByIndex. Renders a compact table with
token IDs and owners linking into each token's detail page; silently
hidden when the contract doesn't implement Enumerable or totalSupply
is unavailable.
- Add missing .address-link rule (was falling back to browser default blue/purple)
- Replace undefined --primary-color var in .nft-collection-link with --color-primary
- Brighten .nft-link-button contrast and use --badge-info-text for dark-mode hover
- Fix invisible .nft-token-uri-code background on dark bg via --overlay-light-5
@github-actions
Copy link
Copy Markdown

🚀 Preview: https://pr-362--openscan.netlify.app
📝 Commit: 246cb85225a479de8bc8571eb5f4f04bcd23adba

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.

1 participant