Skip to content

feat: add collection data - #30

Merged
evilpeach merged 1 commit into
mainfrom
feat/collection-data
Jul 5, 2025
Merged

feat: add collection data#30
evilpeach merged 1 commit into
mainfrom
feat/collection-data

Conversation

@evilpeach

@evilpeach evilpeach commented Jul 5, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Decoded NFT messages now include comprehensive collection metadata (creator, description, name, and URI) instead of just a collection URI.
    • Collection details are now available in NFT mint, burn, transfer, and IBC NFT send/receive messages and related metadata.
  • Bug Fixes

    • Improved error messages when collection or NFT metadata is missing during decoding.
  • Tests

    • Expanded and updated test cases to verify inclusion of detailed collection metadata in decoded messages and metadata.
  • Chores

    • Enhanced mock API fixtures to support richer NFT and collection metadata scenarios.

@evilpeach
evilpeach requested review from Poafs1 and simcheolhwan July 5, 2025 03:01
@coderabbitai

coderabbitai Bot commented Jul 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The update introduces asynchronous fetching and decoding of NFT collection metadata throughout the codebase. Decoders for NFT mint, burn, and IBC transfer messages now retrieve and return detailed collection information, enriching interfaces and test fixtures accordingly. New Zod schemas and type definitions for collections are added, and tests are updated to validate the expanded metadata.

Changes

File(s) Change Summary
src/api.ts Added findCollectionFromCollectionAddr method to ApiClient for fetching and parsing collection resources by address.
src/decoders/ibc/nft.ts
src/decoders/move/nft.ts
Updated decoder signatures to use apiClient (not _apiClient). Decoders now fetch collection metadata via the new API method, throw errors if missing, and return detailed collection objects instead of just URIs. Error messages improved with relevant addresses.
src/interfaces/decoded-messages.ts
src/interfaces/metadata.ts
Extended interfaces to include a nested collection object with creator, description, name, and URI fields. Updated imports to reference new collection types.
src/metadata-resolver.ts Now fetches both NFT and collection metadata for each token address, logging and skipping entries if either is missing. Metadata objects now include detailed collection fields.
src/schema/resources.ts Added zCollectionResource Zod schema and CollectionResource type for collection parsing and validation.
src/tests/fixtures/ibc/receive-nft.fixture.ts Renamed and split mocks for IBC receive NFT scenarios; added new fixture data for both source and remote token cases with detailed collection resources.
src/tests/fixtures/ibc/send-nft.fixture.ts
src/tests/fixtures/move/nft-mint.fixture.ts
src/tests/fixtures/move/nft-burn.fixture.ts
src/tests/fixtures/move/object-transfer.fixture.ts
Added or extended mock API response entries for account resource endpoints, providing detailed collection and NFT-related Move resources for testing.
src/tests/ibc/receive-nft.test.ts Refactored tests to separately cover source and remote token receive scenarios, using new mocks and asserting on detailed collection metadata in decoded messages and metadata. Consolidated assertions into fewer, comprehensive tests.
src/tests/ibc/send-nft.test.ts
src/tests/move/nft-burn.test.ts
src/tests/move/nft-mint.test.ts
src/tests/move/object-transfer.test.ts
Updated tests to expect and validate detailed collection metadata in decoded messages and metadata. Adjusted assertions to match new structure.

Sequence Diagram(s)

sequenceDiagram
    participant Decoder as Decoder (Mint/Burn/IBC)
    participant ApiClient
    participant CollectionAPI
    participant NFTAPI

    Decoder->>ApiClient: findCollectionFromCollectionAddr(collectionAddr)
    ApiClient->>CollectionAPI: GET /accounts/{collectionAddr}/resources
    CollectionAPI-->>ApiClient: Collection resource data
    ApiClient-->>Decoder: Parsed CollectionResource or null

    alt Mint Decoder
        Decoder->>ApiClient: findNftFromTokenAddr(tokenAddr)
        ApiClient->>NFTAPI: GET /accounts/{tokenAddr}/resources
        NFTAPI-->>ApiClient: NFT resource data
        ApiClient-->>Decoder: Parsed NFT data
    end

    Decoder-->>Caller: Decoded message with detailed collection metadata
Loading

Poem

A hop, a skip, across the chain,
Now collections have a name!
With creator, uri, and lore,
Our NFTs tell so much more.
Decoders fetch, the tests delight,
In metadata shining bright.
🐰✨

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
src/api.ts (1)

32-46: LGTM: Well-implemented collection metadata fetching method.

The new findCollectionFromCollectionAddr method follows the established patterns in the ApiClient class with proper error handling, null checks, and Zod schema validation. The implementation correctly searches for the "0x1::collection::Collection" struct tag and returns typed results.

Consider the performance implications when this method is called for multiple tokens simultaneously, as noted in the metadata resolver where it's used in a Promise.allSettled pattern.

src/metadata-resolver.ts (1)

14-25: LGTM: Proper sequential fetching of NFT and collection metadata.

The implementation correctly fetches NFT metadata first, then uses the collection address to fetch collection details. The Promise.allSettled approach ensures all token addresses are processed even if individual requests fail.

Consider the performance impact of making two API calls per token address. For scenarios with many tokens, you might want to implement batching or caching strategies to reduce API load.

src/decoders/ibc/nft.ts (1)

119-126: Consider standardizing error message format.

The error message format is slightly different from the send decoder. Consider using a consistent format across both decoders.

-        `Collection data not found for collection address ${collection_id}`
+        `Collection data not found for collection address ${toBech32(collection_id)}`
src/decoders/move/nft.ts (2)

48-49: Consider adding error handling for NFT data fetching.

The NFT data fetching doesn't include error handling like the collection data fetching. While this might be intentional (since tokenUri is optional), consider whether consistency in error handling would be beneficial.

If error handling is needed, you could add:

 const nftData = await apiClient.findNftFromTokenAddr(mintEvent.nft);
+if (!nftData) {
+  throw new Error(
+    `NFT data not found for token address ${mintEvent.nft}`
+  );
+}

63-64: Misleading comment placement.

The comment "in case of burn, the tokenUri is not available" appears in the mint decoder, which is confusing. Consider updating the comment to better reflect its purpose in the mint context.

-        // in case of burn, the tokenUri is not available
+        // tokenUri is optional and may not be available
         tokenUri: nftData?.data.uri,
src/tests/ibc/receive-nft.test.ts (1)

24-89: Consider adding error scenario test coverage.

The tests comprehensively cover successful scenarios but don't test error cases such as when collection data is not found. This would help ensure the error handling in the decoders works as expected.

Consider adding test cases like:

it("should throw error when collection data is not found", async () => {
  // Setup mock to return null for collection data
  const mockApiResponses = {
    ...mockApiResponsesForIbcReceiveNftSourceToken,
    // Override collection response to return null
  };
  setupMockApi(mockedAxios, mockApiResponses);
  
  await expect(decoder.decodeTransaction(mockMsgIbcReceiveNftSourceToken))
    .rejects.toThrow("Collection data not found");
});

Also applies to: 93-180

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between a1d63a7 and e3b892d.

📒 Files selected for processing (17)
  • src/api.ts (2 hunks)
  • src/decoders/ibc/nft.ts (4 hunks)
  • src/decoders/move/nft.ts (4 hunks)
  • src/interfaces/decoded-messages.ts (4 hunks)
  • src/interfaces/metadata.ts (1 hunks)
  • src/metadata-resolver.ts (1 hunks)
  • src/schema/resources.ts (1 hunks)
  • src/tests/fixtures/ibc/receive-nft.fixture.ts (3 hunks)
  • src/tests/fixtures/ibc/send-nft.fixture.ts (1 hunks)
  • src/tests/fixtures/move/nft-burn.fixture.ts (1 hunks)
  • src/tests/fixtures/move/nft-mint.fixture.ts (1 hunks)
  • src/tests/fixtures/move/object-transfer.fixture.ts (1 hunks)
  • src/tests/ibc/receive-nft.test.ts (5 hunks)
  • src/tests/ibc/send-nft.test.ts (3 hunks)
  • src/tests/move/nft-burn.test.ts (1 hunks)
  • src/tests/move/nft-mint.test.ts (2 hunks)
  • src/tests/move/object-transfer.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: evilpeach
PR: initia-labs/tx-decoder#28
File: src/metadata-resolver.ts:27-32
Timestamp: 2025-07-03T01:32:16.425Z
Learning: In the tx-decoder project, Zod is used for data validation at the input layer, which means direct property access is safe in functions like `resolveMetadata` since the data structure is already validated. Optional chaining is not needed in such cases.
src/tests/move/object-transfer.test.ts (1)
Learnt from: evilpeach
PR: initia-labs/tx-decoder#28
File: src/metadata-resolver.ts:27-32
Timestamp: 2025-07-03T01:32:16.425Z
Learning: In the tx-decoder project, Zod is used for data validation at the input layer, which means direct property access is safe in functions like `resolveMetadata` since the data structure is already validated. Optional chaining is not needed in such cases.
src/schema/resources.ts (2)
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:38-43
Timestamp: 2025-02-06T07:15:49.671Z
Learning: The TypeScript types and Zod schemas in `_packages/types/src/types/` and `_packages/types/src/zods/` are auto-generated from JSON Schema files in the root directory using json-schema-to-typescript and json-schema-to-zod libraries. Changes should be made to the source schema files, not the generated code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:12-17
Timestamp: 2025-02-06T07:15:46.189Z
Learning: The TypeScript types and Zod schemas in `@initia/initia-registry-types` package are auto-generated from JSON Schema files in the root directory. Modifications should be made to the schema files rather than the generated code.
src/tests/move/nft-mint.test.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: evilpeach
PR: initia-labs/tx-decoder#28
File: src/metadata-resolver.ts:27-32
Timestamp: 2025-07-03T01:32:16.425Z
Learning: In the tx-decoder project, Zod is used for data validation at the input layer, which means direct property access is safe in functions like `resolveMetadata` since the data structure is already validated. Optional chaining is not needed in such cases.
src/tests/move/nft-burn.test.ts (1)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
src/tests/ibc/send-nft.test.ts (4)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: evilpeach
PR: initia-labs/tx-decoder#28
File: src/metadata-resolver.ts:27-32
Timestamp: 2025-07-03T01:32:16.425Z
Learning: In the tx-decoder project, Zod is used for data validation at the input layer, which means direct property access is safe in functions like `resolveMetadata` since the data structure is already validated. Optional chaining is not needed in such cases.
src/tests/fixtures/ibc/send-nft.fixture.ts (2)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#113
File: src/client/rest/RESTClient.ts:178-178
Timestamp: 2025-03-04T07:53:30.367Z
Learning: In the `RESTClient` class of Initia.js, the `gasPrices()` method is designed to return `undefined` when both API calls (opchild and move) fail, which is an intentional design choice.
src/tests/fixtures/move/nft-burn.fixture.ts (2)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#113
File: src/client/rest/RESTClient.ts:178-178
Timestamp: 2025-03-04T07:53:30.367Z
Learning: In the `RESTClient` class of Initia.js, the `gasPrices()` method is designed to return `undefined` when both API calls (opchild and move) fail, which is an intentional design choice.
src/decoders/ibc/nft.ts (2)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
src/tests/fixtures/move/object-transfer.fixture.ts (1)
Learnt from: joon9823
PR: initia-labs/initia.js#113
File: src/client/rest/RESTClient.ts:178-178
Timestamp: 2025-03-04T07:53:30.367Z
Learning: In the `RESTClient` class of Initia.js, the `gasPrices()` method is designed to return `undefined` when both API calls (opchild and move) fail, which is an intentional design choice.
src/interfaces/decoded-messages.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: evilpeach
PR: initia-labs/tx-decoder#28
File: src/metadata-resolver.ts:27-32
Timestamp: 2025-07-03T01:32:16.425Z
Learning: In the tx-decoder project, Zod is used for data validation at the input layer, which means direct property access is safe in functions like `resolveMetadata` since the data structure is already validated. Optional chaining is not needed in such cases.
src/tests/ibc/receive-nft.test.ts (4)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: ALPAC-4
PR: initia-labs/rapid-relayer#20
File: src/db/controller/client.ts:54-66
Timestamp: 2024-12-17T07:59:34.765Z
Learning: In `src/db/controller/client.ts`, `consensusHeights` must exist and follow the `number-number` format as per the IBC-Go specification. If it doesn't exist or the format is incorrect, the process should throw an error and terminate.
src/tests/fixtures/move/nft-mint.fixture.ts (1)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
src/tests/fixtures/ibc/receive-nft.fixture.ts (4)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#113
File: src/client/rest/RESTClient.ts:178-178
Timestamp: 2025-03-04T07:53:30.367Z
Learning: In the `RESTClient` class of Initia.js, the `gasPrices()` method is designed to return `undefined` when both API calls (opchild and move) fail, which is an intentional design choice.
src/decoders/move/nft.ts (2)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
🧬 Code Graph Analysis (5)
src/schema/resources.ts (1)
src/schema/common.ts (1)
  • zJsonString (20-30)
src/tests/move/nft-burn.test.ts (3)
src/tests/helpers/initialize.ts (1)
  • initialize (3-8)
src/tests/helpers/api.ts (3)
  • resetMockApi (21-24)
  • mockedAxios (10-10)
  • setupMockApi (12-19)
src/tests/fixtures/move/nft-burn.fixture.ts (2)
  • mockApiResponsesForNftBurn (304-366)
  • mockMsgNftBurn (1-302)
src/interfaces/metadata.ts (1)
src/schema/resources.ts (1)
  • CollectionResource (65-65)
src/api.ts (1)
src/schema/resources.ts (2)
  • CollectionResource (65-65)
  • zCollectionResource (54-64)
src/interfaces/decoded-messages.ts (1)
src/schema/resources.ts (1)
  • CollectionResource (65-65)
🔇 Additional comments (32)
src/tests/fixtures/move/object-transfer.fixture.ts (1)

351-408: LGTM! Comprehensive mock data for collection resources.

The mock API response data is well-structured and includes all the necessary Move resources (ObjectCore, Royalty, Collection, FixedSupply, InitiaNftCollection, SimpleNftCollection) with proper JSON data, raw bytes, and struct tags. This effectively supports testing the enhanced collection metadata functionality.

src/interfaces/metadata.ts (2)

1-1: LGTM! Proper import and type usage.

The import correctly references the CollectionResource type from the schema module.


5-5: LGTM! Correct type reference for collection data.

The collection property correctly uses CollectionResource["data"] type, which aligns with the Zod schema structure and follows the established pattern in the codebase.

src/tests/move/object-transfer.test.ts (1)

63-69: LGTM! Test expectations updated correctly for enhanced collection metadata.

The test now expects a detailed collection object with all the necessary fields (creator, description, name, uri) instead of just a URI string. This correctly reflects the enhanced collection metadata functionality.

src/schema/resources.ts (1)

54-65: LGTM! Well-defined schema for collection resources.

The zCollectionResource schema correctly:

  • Uses zJsonString.pipe() to parse JSON strings following the established pattern
  • Validates all necessary collection fields (creator, description, name, uri)
  • Uses the correct type literal "0x1::collection::Collection" for Move resources
  • Exports the properly inferred TypeScript type

This provides robust validation for collection metadata throughout the codebase.

src/tests/ibc/send-nft.test.ts (3)

28-35: LGTM! Test expectations updated for enhanced collection metadata.

The test correctly expects a detailed collection object with all necessary fields (creator, description, name, uri) instead of just a collectionUri string. This aligns with the enhanced IBC NFT decoding functionality.


74-81: LGTM! Metadata expectations updated consistently.

The metadata test expectations correctly include the detailed collection object, maintaining consistency with the decoded message structure.


109-109: LGTM! Property access updated correctly.

The property access is correctly updated from collectionUri to collection.uri to match the new nested collection structure.

src/tests/move/nft-mint.test.ts (1)

30-36: LGTM: Comprehensive test coverage for collection metadata enhancement.

The test correctly validates the new enriched data structure that includes detailed collection metadata (creator, description, name, uri) in both the decoded message and metadata objects. The addition of tokenUri field and the structured collection object aligns well with the enhanced NFT decoding functionality.

Also applies to: 43-43, 68-74

src/tests/move/nft-burn.test.ts (1)

1-10: LGTM: Proper test setup for asynchronous collection metadata fetching.

The test correctly imports and configures mock API responses to support the new collection metadata fetching functionality. The beforeEach hook ensures clean test state, and the expected decoded message structure properly validates the enriched collection data.

Also applies to: 16-18, 21-21, 28-34

src/tests/fixtures/ibc/send-nft.fixture.ts (1)

434-465: LGTM: Comprehensive mock collection resource data.

The fixture provides realistic and complete mock data for collection resources, including all required fields (creator, description, name, uri) that align with the CollectionResource schema. The mock response structure properly supports testing of the new asynchronous collection metadata fetching functionality.

src/metadata-resolver.ts (1)

27-59: LGTM: Robust error handling and metadata construction.

The error handling properly distinguishes between missing NFT and collection metadata with specific logging, and the metadata construction correctly uses toBech32 for address conversion while preserving all collection details from the API response.

src/tests/fixtures/move/nft-burn.fixture.ts (1)

304-366: LGTM! Comprehensive mock data for collection metadata.

The mock API responses provide excellent test coverage for the enhanced NFT burn decoder with detailed collection metadata. The fixture includes all necessary Move resource types and properly structured collection data.

src/decoders/ibc/nft.ts (5)

18-18: Decoder parameter updated correctly.

Good change from unused _apiClient to actively used apiClient parameter for collection data fetching.


41-50: Proper async collection fetching with error handling.

The collection fetching logic is well-implemented with appropriate error handling for missing data. The error message provides clear context about which collection address failed.


55-60: Enhanced collection metadata structure.

The new collection object structure provides much richer metadata compared to the previous simple collectionUri string. The fallback to parsedData.data.classUri is a good design choice.


82-82: Consistent parameter update for receive decoder.

The parameter change is consistent with the send decoder implementation.


131-136: Consistent enhanced metadata structure.

The receive decoder now provides the same rich collection metadata structure as the send decoder, ensuring consistency across IBC NFT operations.

src/tests/fixtures/move/nft-mint.fixture.ts (1)

329-386: Excellent test fixture for enhanced NFT mint decoder.

The mock API responses provide comprehensive collection metadata that aligns perfectly with the enhanced decoding functionality. The data structure is consistent and includes all necessary Move resource types.

src/interfaces/decoded-messages.ts (4)

1-1: Proper import of CollectionResource type.

The import statement correctly includes the CollectionResource type needed for the enhanced interface definitions.


155-155: Enhanced NFT mint interface with collection metadata.

The addition of collection: CollectionResource["data"] provides rich collection metadata for mint operations, replacing the previous simpler structure.


186-191: Rich collection metadata for IBC send operations.

The replacement of collectionUri with a detailed collection object containing creator, description, name, and uri fields significantly enhances the metadata available for IBC NFT send operations.


205-210: Consistent collection metadata for IBC receive operations.

The IBC receive interface now matches the send interface structure, ensuring consistency across IBC NFT operations with the same rich collection metadata.

src/tests/fixtures/ibc/receive-nft.fixture.ts (4)

1564-1564: Good fixture organization for different IBC scenarios.

The renaming to mockApiResponsesForIbcReceiveNftSourceToken clearly indicates this fixture is for source token scenarios, improving test organization.


1615-1672: Comprehensive collection metadata for source tokens.

The mock API responses include all necessary Move resource types with detailed collection metadata, supporting thorough testing of the enhanced decoder functionality.


1677-1677: Clear separation for remote token scenarios.

The new mockApiResponsesForIbcReceiveNftRemoteToken fixture provides distinct test data for remote token scenarios, enhancing test coverage.


1712-1759: Detailed collection data for remote token testing.

The mock responses for remote tokens include comprehensive collection metadata with proper structure, enabling thorough testing of the collection data enrichment functionality.

src/decoders/move/nft.ts (3)

17-17: LGTM! Proper parameter usage update.

The decoders now correctly use the apiClient parameter instead of the unused _apiClient, enabling the collection data fetching functionality.

Also applies to: 79-79


39-46: Excellent addition of collection data fetching with proper error handling.

The asynchronous collection data fetching is well-implemented with appropriate error handling and descriptive error messages that include the collection address for debugging.

Also applies to: 90-97


53-58: Well-structured collection data enrichment.

The nested collection object with detailed metadata (creator, description, name, uri) provides comprehensive information and follows a consistent structure across both decoders.

Also applies to: 102-107

src/tests/ibc/receive-nft.test.ts (2)

23-90: Excellent test restructuring with comprehensive validation.

The separation of source and remote token scenarios into dedicated test blocks improves clarity and maintainability. The comprehensive assertions validate the new collection data structure thoroughly.


92-181: Well-organized remote token test with detailed assertions.

The remote token test properly validates the enriched collection metadata, including the handling of null URI values being transformed to empty strings.

@evilpeach
evilpeach merged commit f7604f1 into main Jul 5, 2025
@evilpeach
evilpeach deleted the feat/collection-data branch July 5, 2025 04:53
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