Skip to content

Conversation

benjamin852
Copy link
Contributor

@benjamin852 benjamin852 commented Sep 20, 2025

why?

  • missing mint functionality for sui coins
  • buggy interchain transfer experience if transferring without minting

how?

  • added standalone minter function for individual coin mints
  • integrated minter function into interchain transfer so you can call interchain transfer without needing to mint beforehand

testing

tested working interchain transfer without mint
tested mint function works

  • ...

Greptile Summary

Updated On: 2025-09-22 01:21:34 UTC

This PR adds mint functionality to the Sui blockchain implementation in the Axelar contract deployments repository. The changes introduce two key capabilities:

  1. Automatic minting during interchain transfers: The interchainTransfer function now accepts a special zero ID (0x0000000000000000000000000000000000000000000000000000000000000000) as the coinObjectId parameter. When this sentinel value is provided, the system automatically mints the required tokens before proceeding with the transfer, eliminating the need for users to pre-mint tokens.

  2. Standalone coin minting: A new mintCoins function provides direct minting capability for users who need to mint tokens outside of the transfer workflow.

The implementation maintains backward compatibility - existing workflows using actual coin object IDs continue to work unchanged. The zero ID acts as a trigger for the new auto-minting behavior, creating a seamless user experience. The changes integrate well with the existing Sui ITS (Interchain Token Service) architecture, leveraging the same transaction building patterns and configuration management used throughout the codebase.

Documentation has been updated to reflect both the new standalone minting command and the auto-minting capability within interchain transfers, providing clear guidance for users on how to utilize these new features.

Important Files Changed

Changed Files
Filename Score Overview
sui/its.js 4/5 Added automatic minting logic to interchainTransfer function and new standalone mintCoins function
sui/README.md 5/5 Updated documentation to include new mint-coins command and auto-minting feature usage

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it maintains backward compatibility and adds useful functionality
  • Score reflects well-implemented logic with proper integration patterns, though the zero ID approach could benefit from additional validation
  • Pay close attention to the automatic minting logic in sui/its.js to ensure proper error handling and edge cases are covered

Sequence Diagram

sequenceDiagram
    participant User
    participant Script as "sui/its.js"
    participant TxBuilder as "TxBuilder"
    participant SuiClient as "Sui Client"
    participant TreasuryCap as "TreasuryCap<T>"
    participant CoinModule as "Coin Module"
    participant Network as "Sui Network"

    Note over User, Network: Standalone Mint Coins Flow
    User->>Script: "mint-coins <coinPackageId> <coinPackageName> <coinModName> <amount> <receiver>"
    Script->>SuiClient: "checkIfCoinExists(coinPackageId, coinType)"
    SuiClient-->>Script: "coin validation result"
    Script->>SuiClient: "getOwnedObjects() - find TreasuryCap"
    SuiClient-->>Script: "treasury cap object id"
    Script->>TxBuilder: "create new TxBuilder"
    Script->>TxBuilder: "moveCall(mint function)"
    TxBuilder->>CoinModule: "mint(treasury, amount, receiver)"
    Script->>Network: "broadcastFromTxBuilder()"
    Network-->>Script: "transaction response"
    Script->>SuiClient: "getBalance(coinType)"
    SuiClient-->>Script: "updated balance"
    Script-->>User: "💰 token balance, new coin object id"

    Note over User, Network: Interchain Transfer with Auto-Mint Flow
    User->>Script: "interchain-transfer ... <coinObjectId=0x000...> ..."
    Script->>Script: "check if coinObjectId is ZERO_ID"
    alt coinObjectId is ZERO_ID
        Script->>Script: "mintCoins(args)"
        Script->>SuiClient: "checkIfCoinExists()"
        Script->>SuiClient: "getOwnedObjects() - find TreasuryCap"
        Script->>TxBuilder: "moveCall(mint function)"
        Script->>Network: "broadcast mint transaction"
        Network-->>Script: "minted coin object id and amount"
        Script->>Script: "update coinObjectId and amount"
    end
    Script->>TxBuilder: "splitCoins(coinObjectId, amount)"
    Script->>TxBuilder: "prepare_interchain_transfer()"
    Script->>TxBuilder: "send_interchain_transfer()"
    Script->>TxBuilder: "pay_gas()"
    Script->>TxBuilder: "gateway::send_message()"
    Script->>Network: "broadcast interchain transfer"
    Network-->>User: "Interchain Transfer completed"
Loading

Note

Add Sui coin minting CLI and integrate balance validation and dynamic gas estimation into interchain transfers, with docs updated.

  • Sui CLI/ITS (sui/its.js):
    • New Minting: Add mintCoins function and mint-coins <coinPackageId> <coinPackageName> <coinModName> <amount> <receiver> command; mints via TreasuryCap, prints receiver balance and new coin object ID.
    • Interchain Transfer: Replace coin object-type check with checkIfSenderHasSufficientBalance; dynamically compute gas via estimateITSFee instead of fixed amount; minor log message tweak.
  • Token Utils (sui/utils/token-utils.js):
    • Replace checkIfCoinIsMinted with checkIfSenderHasSufficientBalance to validate ownership and balance of the specified coin object.
  • Docs (sui/README.md):
    • Add Mint Coin section with command, example, and sample output; minor formatting fixes.

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

@benjamin852 benjamin852 changed the title feat: added mint token functionality standalone and integrated into t… feat: mint sui coin standalone + in interchain transfer Sep 20, 2025
@benjamin852 benjamin852 marked this pull request as ready for review September 22, 2025 01:20
@benjamin852 benjamin852 requested a review from a team as a code owner September 22, 2025 01:20
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.

2 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

benjamin852 and others added 2 commits September 30, 2025 03:13
add safer chainName for `estimateItsFee`

Co-authored-by: Milap Sheth <[email protected]>
cleaner query for sui coin balance

Co-authored-by: Milap Sheth <[email protected]>
remove hard-coded sui package id

Co-authored-by: Milap Sheth <[email protected]>
cursor[bot]

This comment was marked as outdated.

@benjamin852 benjamin852 merged commit 4821799 into main Sep 30, 2025
10 checks passed
@benjamin852 benjamin852 deleted the feat/sui-mint-coin branch September 30, 2025 02:35
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