-
Notifications
You must be signed in to change notification settings - Fork 29
feat(sui): list trusted chains helper #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sui): list trusted chains helper #1080
Conversation
There was a problem hiding this 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:
- Core functionality: A new
listTrustedChains
function that accesses the ITS object'strusted_chains
bag structure, iterates through dynamic fields using proper pagination, and extracts chain names from the nested data structure. - 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
2 files reviewed, 1 comment
#1064) Co-authored-by: isi8787 <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
why?
how?
testing
Note
Adds a
list-trusted-chains
CLI command to display trusted chains from InterchainTokenService and documents it in the README.listTrustedChains
to readtrusted_chains
fromInterchainTokenServicev0
via dynamic fields and print them.list-trusted-chains
that invokeslistTrustedChains
.ts-node sui/its list-trusted-chains
.Written by Cursor Bugbot for commit 9b5574d. This will update automatically on new commits. Configure here.