Skip to content

feat: enhance ibc data - #31

Merged
evilpeach merged 2 commits into
mainfrom
feat/enhance-ibc-data
Jul 5, 2025
Merged

feat: enhance ibc data#31
evilpeach merged 2 commits into
mainfrom
feat/enhance-ibc-data

Conversation

@evilpeach

@evilpeach evilpeach commented Jul 5, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Decoded IBC token and NFT transfer messages now include explicit source and destination chain, port, and channel identifiers for improved clarity.
    • Added new API methods to retrieve chain IDs and resolve IBC counterparty chain IDs.
  • Bug Fixes

    • Enhanced error handling for missing IBC channel or chain information during message decoding.
  • Tests

    • Updated and expanded mock API responses and test cases to reflect the new chain/channel identifier fields in decoded messages.
  • Documentation

    • Improved message data structures to provide more detailed IBC context in interfaces and test expectations.

@evilpeach
evilpeach requested review from Poafs1 and simcheolhwan July 5, 2025 04:41
@coderabbitai

coderabbitai Bot commented Jul 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce explicit source and destination chain, port, and channel identifiers into the decoding and interface definitions for IBC fungible token and NFT messages. Methods for resolving chain IDs and node information are added to the API client, schemas are updated to support richer metadata, and tests and fixtures are revised to reflect the new data structures and API interactions.

Changes

File(s) Change Summary
src/api.ts, src/schema/rest.ts, src/schema/index.ts Added findIbcCounterPartyChainId and getChainId methods to ApiClient; imported and exported new zNodeInfo schema for node info REST endpoint.
src/decoders/ibc/transfer.ts, src/decoders/ibc/nft.ts Enhanced IBC FT/NFT decoders to extract and resolve both source and destination chain, port, and channel IDs via API calls; updated returned data structures accordingly.
src/interfaces/decoded-messages.ts Updated IBC message interfaces: replaced sourceChannel/sourcePort and destinationChannel/destinationPort with srcChainId/srcChannel/srcPort and dstChainId/dstChannel/dstPort.
src/schema/registry.ts Added zIbcChannel schema; extended zMetadata to include an ibc_channels array.
src/tests/fixtures/ibc/send-ft.fixture.ts, src/tests/fixtures/ibc/send-nft.fixture.ts, src/tests/fixtures/ibc/receive-ft.fixture.ts, src/tests/fixtures/ibc/receive-nft.fixture.ts Added mock API responses for /chains.json and /cosmos/base/tendermint/v1beta1/node_info endpoints with IBC channel and node info data to various fixtures.
src/tests/fixtures/op-init/finalize-token-withdrawal.fixture.ts, src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts Added empty ibc_channels array to chain metadata in mock API fixture responses.
src/tests/ibc/receive-nft.test.ts, src/tests/ibc/send-nft.test.ts, src/tests/ibc/transfer.test.ts Updated test cases to use new src* and dst* fields for chain, port, and channel IDs in expected decoded data and assertions.

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant Decoder
    participant ApiClient
    participant ChainRegistry

    Test->>Decoder: decode(IBC message, apiClient)
    Decoder->>ApiClient: getChainId()
    ApiClient->>ApiClient: fetch /cosmos/base/tendermint/v1beta1/node_info
    ApiClient-->>Decoder: chainId

    alt Need counterparty chain ID
        Decoder->>ApiClient: findIbcCounterPartyChainId(chainId, portId, channelId)
        ApiClient->>ChainRegistry: ensure registries loaded
        ChainRegistry-->>ApiClient: registry data
        ApiClient-->>Decoder: counterpartyChainId or null
    end

    Decoder-->>Test: Decoded message with srcChainId, dstChainId, srcPort, dstPort, etc.
Loading

Poem

In tunnels of chains, the packets now roam,
With ports and IDs, they always find home.
Decoders are wiser, the schemas are neat,
Mock rabbits test channels with nimble feet.
Source and destination, both clear in the light—
Hopping through networks, all fields now in sight!
🐇✨


📜 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 bf3045f and e9a2ffe.

📒 Files selected for processing (1)
  • src/api.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/api.ts

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

Poafs1
Poafs1 previously approved these changes Jul 5, 2025
Base automatically changed from feat/collection-data to main July 5, 2025 04:53
@evilpeach
evilpeach dismissed Poafs1’s stale review July 5, 2025 04:53

The base branch was changed.

@evilpeach
evilpeach force-pushed the feat/enhance-ibc-data branch from ac487ea to bf3045f Compare July 5, 2025 04:56
@evilpeach
evilpeach requested a review from Poafs1 July 5, 2025 04:56

@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: 1

🧹 Nitpick comments (2)
src/schema/rest.ts (1)

3-7: Consider allowing unknown keys to avoid brittle parsing

The /node_info response contains many additional fields (e.g., protocol_version, liteserver_address, etc.).
If the API adds new keys later, strict validation will start failing. Appending .passthrough() (or .strict(false)) on the outer object keeps the schema future-proof while still validating the fields we care about.

-export const zNodeInfo = z.object({
-  default_node_info: z.object({
-    network: z.string(),
-  }),
-});
+export const zNodeInfo = z
+  .object({
+    default_node_info: z
+      .object({
+        network: z.string(),
+      })
+      .passthrough(),
+  })
+  .passthrough();
src/api.ts (1)

63-88: Implement error handling and consider performance optimizations.

The method logic correctly searches for IBC counterparty chains, but could benefit from enhanced error handling and performance considerations.

Consider adding error handling for the registry loading operation:

 public async findIbcCounterPartyChainId(
   chainId: string,
   portId: string,
   channelId: string
 ): Promise<string | null> {
+  try {
     await this._getRegistries();
+  } catch (error) {
+    console.error('Failed to load registries:', error);
+    return null;
+  }

   const registry = this.registries.find(
     (registry) => registry.chain_id === chainId
   );

   if (!registry) {
     return null;
   }

   const channel = registry.metadata.ibc_channels.find(
     (channel) =>
       channel.port_id === portId && channel.channel_id === channelId
   );

   if (!channel) {
     return null;
   }

   return channel.chain_id;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7604f1 and bf3045f.

📒 Files selected for processing (16)
  • src/api.ts (3 hunks)
  • src/decoders/ibc/nft.ts (4 hunks)
  • src/decoders/ibc/transfer.ts (3 hunks)
  • src/interfaces/decoded-messages.ts (4 hunks)
  • src/schema/index.ts (1 hunks)
  • src/schema/registry.ts (1 hunks)
  • src/schema/rest.ts (1 hunks)
  • src/tests/fixtures/ibc/receive-ft.fixture.ts (1 hunks)
  • src/tests/fixtures/ibc/receive-nft.fixture.ts (2 hunks)
  • src/tests/fixtures/ibc/send-ft.fixture.ts (1 hunks)
  • src/tests/fixtures/ibc/send-nft.fixture.ts (1 hunks)
  • src/tests/fixtures/op-init/finalize-token-withdrawal.fixture.ts (1 hunks)
  • src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts (1 hunks)
  • src/tests/ibc/receive-nft.test.ts (2 hunks)
  • src/tests/ibc/send-nft.test.ts (3 hunks)
  • src/tests/ibc/transfer.test.ts (4 hunks)
🧰 Additional context used
🧠 Learnings (17)
📓 Common learnings
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
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: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/marketmap/msgs/MsgUpsertMarkets.ts:33-33
Timestamp: 2024-10-07T09:11:45.236Z
Learning: In the `initia.js` codebase, the Amino message type identifiers use the `x` in the path as per the original protobuf definitions. For example, `'connect/x/marketmap/MsgUpsertMarkets'` is correct.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/marketmap/msgs/MsgUpsertMarkets.ts:33-33
Timestamp: 2024-10-10T16:15:27.381Z
Learning: In the `initia.js` codebase, the Amino message type identifiers use the `x` in the path as per the original protobuf definitions. For example, `'connect/x/marketmap/MsgUpsertMarkets'` is correct.
src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts (5)
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
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.
src/schema/index.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/schema/rest.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/fixtures/op-init/finalize-token-withdrawal.fixture.ts (3)
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/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
src/schema/registry.ts (6)
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.
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: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
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/send-nft.test.ts (6)
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: 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/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
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/ibc/receive-ft.fixture.ts (3)
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.
src/tests/fixtures/ibc/send-nft.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/send-ft.fixture.ts (3)
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.
src/tests/ibc/transfer.test.ts (5)
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/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
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/nft.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: ALPAC-4
PR: initia-labs/rapid-relayer#20
File: src/workers/chain.ts:148-163
Timestamp: 2024-12-17T07:46:51.776Z
Learning: Error handling for `feedUpdateClientEvent` is already implemented at line 129 in `src/workers/chain.ts` within the `feedEvents` method of the `SyncWorker` class.
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/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
src/decoders/ibc/transfer.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/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: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
src/api.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: 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 (3)
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.
🧬 Code Graph Analysis (3)
src/tests/ibc/send-nft.test.ts (2)
src/tests/helpers/api.ts (2)
  • setupMockApi (12-19)
  • mockedAxios (10-10)
src/tests/fixtures/ibc/send-nft.fixture.ts (1)
  • mockApiResponsesForIbcSendNft (432-512)
src/decoders/ibc/transfer.ts (3)
src/schema/messages.ts (2)
  • Message (16-16)
  • zMsgIbcTransfer (77-86)
src/schema/transaction.ts (1)
  • Log (96-96)
src/api.ts (1)
  • ApiClient (21-253)
src/api.ts (1)
src/schema/rest.ts (1)
  • zNodeInfo (3-7)
🔇 Additional comments (23)
src/schema/index.ts (1)

7-7: Barrel export looks good

Re-exporting the new REST schema makes it accessible to callers and keeps the index file in alphabetical order.
Nothing else to flag here.

src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts (1)

460-462: Empty ibc_channels array is fine but double-check schema expectations

If the updated zMetadata schema now requires objects inside ibc_channels, an empty array will validate but downstream logic that assumes at least one entry might break.
Please verify tests that iterate over ibc_channels handle the empty case gracefully.

src/tests/fixtures/op-init/finalize-token-withdrawal.fixture.ts (1)

468-470: Mirror the same verification for this fixture

Same note as above—confirm that consumer code tolerates an empty ibc_channels list so tests remain representative of main-net data.

src/tests/fixtures/ibc/receive-ft.fixture.ts (1)

1798-1843: LGTM! Well-structured mock API responses for enhanced IBC testing.

The new fixture properly supports the enhanced IBC data structure with detailed chain and channel information, enabling comprehensive testing of the new chain ID resolution features.

src/schema/registry.ts (2)

3-8: LGTM! Well-defined IBC channel schema.

The schema properly captures all necessary IBC channel fields with appropriate string types.


11-11: LGTM! Proper integration of IBC channels into metadata schema.

The addition of the required ibc_channels field enhances the metadata structure to support the new IBC functionality.

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

18-18: LGTM! Better test organization.

Moving the mock API setup to beforeEach improves test consistency and follows best practices.


38-46: LGTM! Enhanced IBC data structure with clear source/destination separation.

The new fields provide better clarity and completeness for IBC channel and chain information in the decoded message.


130-135: LGTM! Comprehensive validation of enhanced IBC channel information.

The updated assertions properly verify all the new source and destination chain, channel, and port fields.

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

48-55: LGTM! Enhanced IBC data structure for source token receive scenario.

The updated expected data properly captures the source and destination chain/channel information for the IBC NFT receive flow.


121-129: LGTM! Enhanced IBC data structure for remote token receive scenario.

The updated expected data properly handles the remote token scenario with WASM contract ports and different chain relationships, providing comprehensive test coverage.

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

1-4: LGTM! Proper import organization for enhanced IBC testing.

The addition of mockApiResponsesForMsgIbcRecvPacket from the receive fixture properly separates concerns between send and receive test scenarios.


35-42: Field naming changes align with new IBC interface structure.

The transition from verbose field names (e.g., destinationChannel) to abbreviated names (e.g., dstChannel) and the addition of explicit chain IDs (srcChainId, dstChainId) properly reflects the enhanced IBC data structure mentioned in the PR objectives.


72-72: Proper separation of mock responses for different IBC scenarios.

Using mockApiResponsesForMsgIbcRecvPacket for receive message tests ensures the mock data aligns with the specific requirements of each test case.

src/tests/fixtures/ibc/send-ft.fixture.ts (2)

545-581: Comprehensive mock chain registry data for IBC testing.

The mock /chains.json response provides well-structured chain metadata with bidirectional IBC channel mappings. The inclusion of both chains ("interwoven-1" and "moo-1") with proper channel, port, and version information supports comprehensive testing of the new chain ID resolution functionality.


582-586: Proper node info mock response structure.

The /cosmos/base/tendermint/v1beta1/node_info mock response correctly provides the network identifier, enabling the new getChainId method to be tested effectively.

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

434-454: Appropriate NFT-specific mock data structure.

The mock responses properly reflect NFT transfer requirements with the correct nft-transfer port and ics721-1 version identifier. The structure is consistent with the FT fixture while being tailored for NFT use cases.

src/api.ts (1)

14-14: LGTM! Proper schema import for validation.

The addition of zNodeInfo import supports the new getChainId method's response validation.

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

1566-1593: LGTM! Mock data additions are well-structured.

The new mock API endpoints provide the necessary chain metadata and node info for the enhanced IBC decoding logic. The IBC channel data structure correctly includes all required fields (chain_id, channel_id, port_id, version) for resolving counterparty chain IDs.

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

52-76: Well-implemented chain ID resolution for NFT send decoder.

The decoder correctly:

  • Fetches the source chain ID from the current node
  • Extracts destination port/channel from packet event attributes
  • Resolves the destination chain ID using IBC channel metadata
  • Includes comprehensive error handling with descriptive messages

Also applies to: 87-94


157-181: Consistent implementation for NFT receive decoder.

The decoder correctly handles the receive packet flow:

  • Destination chain ID is the current node's chain
  • Source port/channel are extracted from packet event attributes
  • Source chain ID is resolved using the counterparty lookup
  • Error handling matches the send decoder pattern

Also applies to: 192-199

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

16-60: Fungible token decoders properly enhanced with chain ID resolution.

The implementation follows the same robust pattern as the NFT decoders:

  • Proper extraction of channel/port from packet events
  • Correct chain ID resolution for both send and receive flows
  • Consistent error handling with descriptive messages
  • Updated data structures align with the new interface definitions

Also applies to: 68-110

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

38-68: Interface updates provide clearer and more complete IBC routing information.

The consistent renaming and additions across all IBC message interfaces:

  • Improves clarity with src/dst prefixes instead of source/destination
  • Adds explicit chain IDs alongside ports and channels for complete routing context
  • Maintains consistency across fungible token and NFT message types

Also applies to: 187-231

Comment thread src/api.ts
@evilpeach
evilpeach requested a review from songwongtp July 5, 2025 05:00
@evilpeach
evilpeach merged commit 88e71b6 into main Jul 5, 2025
1 check passed
@evilpeach
evilpeach deleted the feat/enhance-ibc-data branch July 5, 2025 05:28
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