Skip to content

feat: enhance IBC NFT and transfer decoders - #32

Merged
evilpeach merged 1 commit into
mainfrom
improve/add-ibc-timeout-nft-data
Jul 5, 2025
Merged

feat: enhance IBC NFT and transfer decoders#32
evilpeach merged 1 commit into
mainfrom
improve/add-ibc-timeout-nft-data

Conversation

@evilpeach

@evilpeach evilpeach commented Jul 5, 2025

Copy link
Copy Markdown
Collaborator
  • Added timeout height and timestamp to IBC NFT send and receive decoders.
  • Included token address extraction for NFT send and receive messages.
  • Updated interfaces and schema to accommodate new fields.
  • Enhanced tests to cover new timeout and token address functionalities.

Summary by CodeRabbit

  • New Features

    • Decoded IBC NFT and fungible token messages now include timeout information and token address details, providing more comprehensive data for each transfer.
  • Bug Fixes

    • Improved error handling for missing token address events during NFT decoding.
  • Tests

    • Updated test cases to verify the presence of timeout and token address fields in decoded IBC NFT and transfer messages.

- Added timeout height and timestamp to IBC NFT send and receive decoders.
- Included token address extraction for NFT send and receive messages.
- Updated interfaces and schema to accommodate new fields.
- Enhanced tests to cover new timeout and token address functionalities.
@evilpeach
evilpeach requested review from Poafs1 and simcheolhwan July 5, 2025 13:43
@coderabbitai

coderabbitai Bot commented Jul 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Timeout-related fields (timeoutHeight, timeoutTimestamp) and tokenAddress were added to the decoding logic and interfaces for IBC NFT and fungible token send/receive messages. The schema for IBC transfer messages was updated to include timeout_height. Corresponding tests were modified to assert the presence and correctness of these new fields.

Changes

Files/Groups Change Summary
src/decoders/ibc/nft.ts Enhanced NFT IBC send/receive decoders to extract and return timeoutHeight, timeoutTimestamp, and tokenAddress from messages and logs. Added error checks for event presence.
src/decoders/ibc/transfer.ts Extended FT IBC send/receive decoders to extract and return timeoutHeight and timeoutTimestamp.
src/interfaces/decoded-messages.ts Added timeoutHeight, timeoutTimestamp, and tokenAddress to NFT IBC send/receive decoded message interfaces.
src/schema/messages.ts Updated zMsgIbcTransfer schema to include a required timeout_height field.
src/tests/ibc/receive-nft.test.ts
src/tests/ibc/send-nft.test.ts
Updated NFT IBC send/receive tests to assert new timeoutHeight, timeoutTimestamp, and tokenAddress fields in decoded output.
src/tests/ibc/transfer.test.ts Updated FT IBC send/receive tests to assert new timeoutHeight and timeoutTimestamp fields in decoded output.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Decoder
    participant Schema
    participant LogParser

    User->>Decoder: Decode IBC NFT Send/Receive Message
    Decoder->>Schema: Validate message structure (including timeout_height)
    Decoder->>LogParser: Find TransferEvent for tokenAddress
    LogParser-->>Decoder: Return tokenAddress (error if not found)
    Decoder-->>User: Return decoded data with timeoutHeight, timeoutTimestamp, tokenAddress
Loading

Poem

A hop and a skip, a timeout to find,
Now tokens and timeouts are perfectly aligned.
With addresses clear in Bech32 delight,
The decoders leap forward, their output more bright.
In tests and in schemas, the fields now appear—
A rabbit’s proud code-hop brings clarity near!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 76a81cb and 3fb7efa.

📒 Files selected for processing (7)
  • src/decoders/ibc/nft.ts (7 hunks)
  • src/decoders/ibc/transfer.ts (4 hunks)
  • src/interfaces/decoded-messages.ts (2 hunks)
  • src/schema/messages.ts (1 hunks)
  • src/tests/ibc/receive-nft.test.ts (2 hunks)
  • src/tests/ibc/send-nft.test.ts (1 hunks)
  • src/tests/ibc/transfer.test.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
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#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: 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/ibc/transfer.test.ts (3)
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#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: 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/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-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#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: 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.
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/receive-nft.test.ts (3)
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#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: 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/decoders/ibc/transfer.ts (3)
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#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: 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/schema/messages.ts (5)
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#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: 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.
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.
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.
src/interfaces/decoded-messages.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/decoders/ibc/nft.ts (3)
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#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: 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.
🔇 Additional comments (15)
src/interfaces/decoded-messages.ts (1)

205-207: LGTM: Consistent interface enhancements for IBC NFT messages.

The addition of timeoutHeight, timeoutTimestamp, and tokenAddress fields to both send and receive IBC NFT message interfaces is well-structured and maintains consistency between the two message types.

Also applies to: 231-233

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

46-49: LGTM: Test coverage updated for new IBC NFT fields.

The test assertions properly validate the presence and values of the newly added timeout and token address fields, ensuring the decoder functionality works as expected.

src/tests/ibc/transfer.test.ts (1)

43-44: LGTM: Timeout fields properly tested for IBC transfer messages.

The addition of timeout field assertions in both send and receive transfer tests ensures proper handling of timeout conditions in IBC fungible token transfers.

Also applies to: 92-93

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

56-59: LGTM: Comprehensive test coverage for IBC NFT receive scenarios.

Both source token and remote token receive test cases properly validate the new timeout and token address fields, with appropriate variation in values between different test scenarios.

Also applies to: 134-137

src/schema/messages.ts (1)

84-87: LGTM: Schema validation aligned with IBC timeout specifications.

The addition of the timeout_height object to the zMsgIbcTransfer schema maintains consistency with existing IBC NFT message schemas and follows proper validation structure for IBC timeout handling.

src/decoders/ibc/transfer.ts (4)

18-26: LGTM! Correct destructuring of timeout fields.

The addition of timeout_height and timeout_timestamp fields aligns with the PR objectives to enhance timeout handling for IBC transfers.


64-65: Correct implementation of timeout fields in decoded data.

The use of timeout_height.revision_height follows IBC standards, and the direct use of timeout_timestamp is appropriate.


87-88: Consistent timeout field extraction for receive decoder.

The implementation mirrors the send decoder, maintaining consistency across the codebase.


118-119: Consistent timeout field implementation in receive decoder output.

The timeout fields follow the same pattern as the send decoder, ensuring uniformity.

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

10-10: Required import for token address extraction.

The zMsgMoveObjectTransferEvent schema is needed for the new findMoveEvent functionality.


21-29: Consistent timeout field extraction for NFT send decoder.

The implementation aligns with the transfer decoder pattern.


113-115: Correct implementation of enhanced NFT send decoder output.

The timeout fields are consistent with other decoders, and the token address is properly formatted using Bech32.


134-139: Consistent timeout field extraction for NFT receive decoder.

The implementation follows the established pattern from other decoders.


235-237: Complete and consistent NFT receive decoder output.

All new fields are properly implemented following the same pattern as the send decoder.


86-93: TransferEvent emission confirmed for all IBC NFT paths

  • 0x1::object::TransferEvent is present in both send and receive fixtures (src/tests/fixtures/ibc/send-nft.fixture.ts, src/tests/fixtures/ibc/receive-nft.fixture.ts).
  • The core object-transfer decoder (src/decoders/move/object-transfer.ts) also relies on the same event.
  • Error handling in src/decoders/ibc/nft.ts is aligned with existing patterns and won’t break existing transactions.

🪧 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.

@evilpeach
evilpeach merged commit 57980d7 into main Jul 5, 2025
1 check passed
@evilpeach
evilpeach deleted the improve/add-ibc-timeout-nft-data branch July 5, 2025 13:51
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