Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Conversation

@abdullahabro
Copy link
Contributor

@abdullahabro abdullahabro commented Feb 21, 2025

Overview

This PR introduces comprehensive support for the Coin Module in the SDK, providing a set of utilities for managing SUI coins.

Key Changes

1. New Coin Interfaces (src/sui_utils/sui_interfaces.py)

  • Added structured interfaces for SUI objects and responses:
    • Coin: Represents a SUI coin with properties like type, object ID, balance
    • CoinMetadata: Contains coin metadata (decimals, name, symbol)
    • TransactionResult: Structured transaction response with effects
    • SuiGetResponse: Handles paginated responses for coin queries
    • Supporting classes for gas, owner, reference, and effects

2. Coin Utilities (src/sui_utils/coin_utils.py)

  • New CoinUtils class with methods for:
    • create_coin_with_balance: Creates a new coin with specified balance
    • merge_coins: Merges multiple coins into a primary coin
    • split_coin: Splits a coin into multiple coins of specified amounts
    • find_coin_with_balance: Finds a coin with exact or sufficient balance
    • sort_ascending: Sorts coins by balance
    • sum_coins: Calculates total balance of multiple coins
    • get_all_coins: Retrieves all coins for an address

3. RPC Enhancements (src/sui_utils/rpc.py)

  • Added new RPC methods:
    • rpc_sui_createSplitCoinsTransaction: Creates transaction for splitting coins
    • rpc_sui_createMergeCoinsTransaction: Creates transaction for merging coins
    • rpc_sui_getTransactionBytes: Generic method for getting transaction bytes
    • get_coin_metadata: Fetches metadata for coin types
  • Improved existing methods:
    • Enhanced get_coins_with_type with pagination support
    • Updated get_coin_balance to use new response structures
    • Refactored get_coin_having_balance to work with new interfaces

4. Signer Improvements (src/sui_utils/signer.py)

  • Enhanced Signer class with new features:
    • Added constructor to optionally initialize with a SuiWallet
    • New sign_and_execute_tx method for one-step transaction signing and execution
    • Improved method signatures with optional wallet parameters
    • Added comprehensive docstrings and type hints
    • Enhanced error handling and validation
    • Improved signature verification and parsing
    • Better support for personal message signing
    • Added flexibility in private key handling

@abdullahabro abdullahabro requested a review from a team as a code owner February 21, 2025 23:38
@abdullahabro abdullahabro changed the title [BFS-847] Add Support for Coin Module in SDK [WIP] [BFS-847] Add Support for Coin Module in SDK [DO NOT MERGE] Apr 5, 2025
@YameenMalik YameenMalik enabled auto-merge (squash) April 5, 2025 00:52
@YameenMalik YameenMalik disabled auto-merge April 5, 2025 00:52
@YameenMalik YameenMalik enabled auto-merge (squash) April 5, 2025 00:52
@abdullahabro abdullahabro disabled auto-merge April 5, 2025 01:08
@abdullahabro abdullahabro changed the title [BFS-847] Add Support for Coin Module in SDK [DO NOT MERGE] [BFS-847] Add Support for Coin Module in SDK Apr 5, 2025
@abdullahabro abdullahabro added enhancement New feature or request and removed DO NOT MERGE labels Apr 5, 2025
@abdullahabro abdullahabro merged commit 9c1ffe6 into main Apr 5, 2025
@abdullahabro abdullahabro deleted the BFS-847 branch April 5, 2025 22:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants