RPC
RPC client for interacting with Saline nodes.
This module provides a unified client for submitting transactions and querying the Saline network.
IMPORTANT: Saline nodes and Tendermint RPC endpoints have specific behaviors:
Transaction Broadcasting: - broadcast_tx_commit and broadcast_tx_sync will return errors like
“Failed decode: Error in $: not enough input” even for valid transactions if decoded incorrectly.
broadcast_tx_async is more permissive and will accept transactions, returning a transaction hash even if the transaction cannot be decoded.
Transaction Format: - Transactions must be properly serialized as JSON and base64 encoded. - POST requests with parameters in the body are more reliable than GET requests
with URL parameters.
Error Handling: - Error responses often include hex-encoded error messages which need to be
decoded for human readability.
Note on method naming conventions: - Transaction broadcasting methods use descriptive names (tx_fire, tx_broadcast, tx_commit)
that match the behavior rather than the RPC endpoint names
- class saline_sdk.rpc.client.Client(http_url='http://localhost:26657', debug=False)[source]
Bases:
objectUnified client for interacting with Saline nodes.
Provides HTTP RPC connectivity to Saline nodes with functionality for: - Transaction broadcasting - Block and transaction querying - Balance querying - Intent querying and parsing - Wallet information retrieval - Aggregate balance queries
Methods are provided in both asynchronous and synchronous versions: - Asynchronous methods (default) have no suffix - Synchronous wrappers have the _sync suffix
Transaction broadcasting methods use descriptive names: - tx_fire: Fire-and-forget transaction (broadcast_tx_async RPC) - tx_broadcast: Submit and check transaction (broadcast_tx_sync RPC) - tx_commit: Submit and wait for block commit (broadcast_tx_commit RPC)
Initialize the client.
- async abci_query_async(path, data, height=0, prove=False)[source]
Make a direct ABCI query asynchronously.
- async get_all_balances_async(address)[source]
Get balances for all tokens for an address asynchronously.
- async get_all_intents()[source]
Get all intents in the system asynchronously.
This method queries the node for all registered intents and parses them into specialized Intent objects from the SDK. It handles various intent types including All, Any, Restriction, Finite, Temporary and Signature intents.
- Return type:
- Returns:
ParsedAllIntentsResponse object containing a dictionary of ParsedIntentInfo objects.
- async get_balance_async(address, token='USDC')[source]
Get the balance of a specific token for an address asynchronously.
- async get_transactions(height=None)[source]
Get transactions from a block at specified height or latest if not specified.
- async get_wallet_info_async(address)[source]
Get wallet information for an address asynchronously.
This method retrieves comprehensive information about a wallet, including: - All token balances - The wallet’s intent (parsed into an SDK Intent object)
- Parameters:
address (
str) – Address to get wallet info for- Return type:
- Returns:
ParsedWalletInfo dataclass containing parsed balances and intent.
- async tx_broadcast(tx_bytes)[source]
Broadcast a transaction and wait for validation (using broadcast_tx_sync RPC).
Submit and check - waits for the transaction to be validated but not committed.
Dataclasses for structured RPC query responses, using bindings.py types for intents.
- class saline_sdk.rpc.query_responses.ParsedAllIntentsResponse(intents=<factory>)[source]
Bases:
objectWrapper for the result of get_all_intents.
- Parameters:
intents (Dict[str, ParsedIntentInfo])
-
intents:
Dict[str,ParsedIntentInfo]
- class saline_sdk.rpc.query_responses.ParsedIntentInfo(intent_id, parsed_intent, addresses=<factory>, raw_intent_data=None, error=None)[source]
Bases:
objectHolds information about a single intent fetched from the node.
- Parameters:
- class saline_sdk.rpc.query_responses.ParsedWalletInfo(address, balances=<factory>, parsed_intent=None, raw_wallet_data=None, error=None)[source]
Bases:
objectStructure holding parsed info from get_wallet_info.
- Parameters:
- saline_sdk.rpc.query_responses.contains_binding_type(node, target_type)[source]
(Optimized) Recursively check if an intent/expression tree contains a node of target_type.
- saline_sdk.rpc.query_responses.parse_dict_to_binding_intent(raw_intent_data)[source]
Attempts to parse a raw dictionary/list structure into an Intent object from bindings.py using its from_json methods.
Handles potential nesting in the raw data. Returns None if parsing fails or input is invalid.
RPC error handling for Saline SDK.