Skip to content

Conversation

blockchainguyy
Copy link
Contributor

@blockchainguyy blockchainguyy commented Oct 9, 2025

why?

  • add helper to set list trusted chains command on sui

how?

  • ...

testing

  • ...

Note

Adds a list-trusted-chains CLI command to display trusted chains from InterchainTokenService and documents it in the README.

  • ITS CLI (sui/its.js):
    • Adds listTrustedChains to read trusted_chains from InterchainTokenServicev0 via dynamic fields and print them.
    • Registers new command list-trusted-chains that invokes listTrustedChains.
  • Docs (sui/README.md):
    • Documents usage: ts-node sui/its list-trusted-chains.

Written by Cursor Bugbot for commit 9b5574d. This will update automatically on new commits. Configure here.

@blockchainguyy blockchainguyy requested a review from a team as a code owner October 9, 2025 14:13
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR adds a new `list-trusted-chains` command to the Sui ITS (Interchain Token Service) toolkit. The implementation provides a read-only utility that queries the on-chain state to retrieve and display all currently configured trusted chains in the InterchainTokenService.

The change consists of two main components:

  1. Core functionality: A new listTrustedChains function that accesses the ITS object's trusted_chains bag structure, iterates through dynamic fields using proper pagination, and extracts chain names from the nested data structure.
  2. CLI integration: A new command registration that follows the established patterns in the codebase, using the same parameter structure and processing pipeline as other ITS commands.

The function integrates seamlessly with the existing ITS management commands (add-trusted-chains and remove-trusted-chains) by providing visibility into the current configuration. It uses the standard printInfo utility for consistent output formatting and handles Sui's complex dynamic field structures appropriately with proper error handling for missing bag IDs.

Important Files Changed

Changed Files
Filename Score Overview
sui/README.md 5/5 Added documentation for the new list-trusted-chains command in the Setup Trusted Chains section
sui/its.js 5/5 Implemented listTrustedChains function with proper pagination and CLI command registration

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only adds read-only functionality without modifying any existing state
  • Score reflects the simple, well-structured implementation that follows established codebase patterns and includes proper error handling
  • No files require special attention as both changes are straightforward additions with clear, defensive coding practices

Sequence Diagram

sequenceDiagram
    participant User
    participant ITS_CLI as ITS CLI
    participant Client as Sui Client
    participant ITS_Contract as InterchainTokenService Contract
    participant Bag as Trusted Chains Bag

    User->>ITS_CLI: "ts-node sui/its list-trusted-chains"
    ITS_CLI->>Client: "getObject(InterchainTokenServicev0)"
    Client->>ITS_Contract: "Fetch ITS object data"
    ITS_Contract-->>Client: "Return object with trusted_chains bag ID"
    Client-->>ITS_CLI: "Object data with bag ID"
    
    alt Bag ID found
        ITS_CLI->>Client: "getDynamicFields(bagId)"
        Client->>Bag: "Fetch dynamic fields (trusted chains)"
        Bag-->>Client: "Return paginated chain entries"
        Client-->>ITS_CLI: "Chain entries data"
        
        loop For each page
            ITS_CLI->>Client: "getDynamicFields(bagId, cursor)"
            Client->>Bag: "Fetch next page of chains"
            Bag-->>Client: "Return more chain entries"
            Client-->>ITS_CLI: "More chain entries data"
        end
        
        ITS_CLI->>ITS_CLI: "Parse chain names from entries"
        ITS_CLI->>User: "Display trusted chains list"
    else Bag ID not found
        ITS_CLI->>User: "Throw error: Unable to locate trusted_chains bag"
    end
Loading

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

k4m4 and others added 2 commits October 9, 2025 10:20
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@blockchainguyy blockchainguyy merged commit d9ea3f5 into fix/sui-link-coin-encoding Oct 9, 2025
@blockchainguyy blockchainguyy deleted the feat/list-trusted-chains-helper branch October 9, 2025 15:29
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.

3 participants