Skip to content

likenft-indexer: record token acquisition time and expose token_updat… - #315

Merged
williamchong merged 1 commit into
likecoin:mainfrom
williamchong:main
Jul 27, 2026
Merged

likenft-indexer: record token acquisition time and expose token_updat…#315
williamchong merged 1 commit into
likecoin:mainfrom
williamchong:main

Conversation

@williamchong

Copy link
Copy Markdown
Member

…ed_at

  • Set nfts.updated_at to the transfer event's block time in UpdateOwner so it means "when the current owner acquired the token"
  • Add optional token_updated_at (max across the account's owned copies) to /account/{address}/token-booknfts rows
  • Return the token's real updated_at (was minted_at) in /account/tokens
  • Add backfill-nft-updated-at CLI to stamp existing rows from stored Transfer/TransferWithMemo events

…ed_at

- Set nfts.updated_at to the transfer event's block time in UpdateOwner
  so it means "when the current owner acquired the token"
- Add optional token_updated_at (max across the account's owned copies)
  to /account/{address}/token-booknfts rows
- Return the token's real updated_at (was minted_at) in /account/tokens
- Add backfill-nft-updated-at CLI to stamp existing rows from stored
  Transfer/TransferWithMemo events

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the indexer’s semantics for nfts.updated_at to represent “when the current owner acquired the token”, exposes that timestamp through the OpenAPI responses, and provides a CLI backfill to stamp historical rows based on stored transfer events.

Changes:

  • Set nfts.updated_at from the transfer event block timestamp during ownership updates, and return this real updated_at in /account/tokens.
  • Add token_updated_at (latest acquisition time across an account’s owned copies for a class) to /account/{address}/token-booknfts responses and OpenAPI schema/types.
  • Add backfill-nft-updated-at CLI + repository backfill logic with accompanying database tests.

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
likenft-indexer/openapi/schema.yaml Adds token_updated_at to the BookNFT schema as an optional date-time field.
likenft-indexer/openapi/api/oas_schemas_gen.go Regenerates OpenAPI Go schema types to include TokenUpdatedAt and OptDateTime.
likenft-indexer/openapi/api/oas_json_gen.go Regenerates JSON encode/decode to support token_updated_at and OptDateTime.
likenft-indexer/internal/logic/evmeventprocessor/transfer.go Passes event timestamp into NFT ownership update to stamp acquisition time.
likenft-indexer/internal/logic/evmeventprocessor/transfer_with_memo.go Same as above for TransferWithMemo.
likenft-indexer/internal/database/nftclass.go Computes TokenUpdatedAt as max nfts.updated_at across owned copies per class.
likenft-indexer/internal/database/nft.go Extends UpdateOwner to set updated_at; adds backfill method from transfer events.
likenft-indexer/internal/database/nft_test.go Adds tests for updated-at stamping, token_updated_at aggregation, and backfill behavior.
likenft-indexer/internal/api/openapi/token_book_nfts_by_account.go Uses updated model mapping to include token_updated_at in response rows.
likenft-indexer/internal/api/openapi/model/opt_date_time.go Adds helper to map *time.Time into generated api.OptDateTime.
likenft-indexer/internal/api/openapi/model/nftclass.go Extends BookNFT mapping to include TokenUpdatedAt.
likenft-indexer/internal/api/openapi/model/nft.go Fixes /account/tokens to return e.UpdatedAt (not MintedAt).
likenft-indexer/cmd/cli/cmd/root.go Registers the new backfill CLI command.
likenft-indexer/cmd/cli/cmd/backfill_nft_updated_at.go Adds backfill-nft-updated-at CLI implementation.
Files not reviewed (2)
  • likenft-indexer/openapi/api/oas_json_gen.go: Generated file
  • likenft-indexer/openapi/api/oas_schemas_gen.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +287 to +293
// Update by primary key: matching on contract_address would compile
// EqualFold to ILIKE, which cannot use the btree index and would turn
// every update into a full table scan.
nfts, err := r.dbService.Client().NFT.Query().
Select(nft.FieldID, nft.FieldContractAddress, nft.FieldTokenID, nft.FieldUpdatedAt).
All(ctx)
if err != nil {
@williamchong
williamchong merged commit 95aa6dc into likecoin:main Jul 27, 2026
9 checks passed
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.

2 participants