pub struct TaiClient { /* private fields */ }Expand description
Implementations§
Source§impl TaiClient
impl TaiClient
Sourcepub fn new(config: TaiConfig, signer: Arc<dyn Signer>) -> Self
pub fn new(config: TaiConfig, signer: Arc<dyn Signer>) -> Self
Construct a client for the given config and signer.
Sourcepub fn sender(&self) -> SuiAddress
pub fn sender(&self) -> SuiAddress
Access the signer’s address (the sender of any submitted tx).
Sourcepub async fn execute_move_call(
&self,
call: MoveCall,
request_type: RequestType,
) -> Result<ExecutionResult, TaiError>
pub async fn execute_move_call( &self, call: MoveCall, request_type: RequestType, ) -> Result<ExecutionResult, TaiError>
Submit an arbitrary Move call as the configured signer.
Three round-trips to the RPC:
unsafe_moveCallto build the unsignedTransactionData.- Compute the intent digest locally and sign with
Signer. sui_executeTransactionBlockwith the signature.
Source§impl TaiClient
impl TaiClient
Sourcepub async fn launch_agent_coin(
&self,
coin_type: &str,
treasury_cap_id: ObjectId,
coin_metadata_id: ObjectId,
coin_type_name: String,
linked_identity: Option<ObjectId>,
owner_cap_recipient: SuiAddress,
operator_recipient: Option<SuiAddress>,
operator_daily_limit_sui: u64,
operator_daily_limit_token: u64,
operator_allowed_targets: &[SuiAddress],
operator_ttl_ms: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn launch_agent_coin( &self, coin_type: &str, treasury_cap_id: ObjectId, coin_metadata_id: ObjectId, coin_type_name: String, linked_identity: Option<ObjectId>, owner_cap_recipient: SuiAddress, operator_recipient: Option<SuiAddress>, operator_daily_limit_sui: u64, operator_daily_limit_token: u64, operator_allowed_targets: &[SuiAddress], operator_ttl_ms: u64, ) -> Result<ExecutionResult, TaiError>
launch_agent_coin<T>(config, treasury_cap, metadata, coin_type_name, linked_identity, owner_cap_recipient, operator_recipient, operator_daily_limit_sui, operator_daily_limit_token, operator_allowed_targets, operator_ttl_ms, clock).
Consumes the freshly-minted TreasuryCap<T>; borrows CoinMetadata<T>
immutably (the metadata object survives the call).
Emits a LaunchEvent; the caller can pull the resulting object ids
from the tx effects.
Sourcepub async fn record_service_payment_sui(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
payment_coin_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn record_service_payment_sui( &self, coin_type: &str, launchpad_account_id: ObjectId, payment_coin_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
record_service_payment_sui<T>(config, account, payment, clock).
Sourcepub async fn buy(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
payment_coin_id: ObjectId,
min_tokens_out: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn buy( &self, coin_type: &str, launchpad_account_id: ObjectId, payment_coin_id: ObjectId, min_tokens_out: u64, ) -> Result<ExecutionResult, TaiError>
buy<T>(config, account, payment_coin, min_tokens_out, clock).
Sourcepub async fn sell(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
tokens_coin_id: ObjectId,
min_sui_out: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn sell( &self, coin_type: &str, launchpad_account_id: ObjectId, tokens_coin_id: ObjectId, min_sui_out: u64, ) -> Result<ExecutionResult, TaiError>
sell<T>(config, account, tokens_coin, min_sui_out, clock).
Sourcepub async fn set_access_config(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
threshold: u64,
accept_coin_payments: bool,
) -> Result<ExecutionResult, TaiError>
pub async fn set_access_config( &self, coin_type: &str, launchpad_account_id: ObjectId, threshold: u64, accept_coin_payments: bool, ) -> Result<ExecutionResult, TaiError>
set_access_config<T>(account, threshold, accept_coin). Creator-only.
Sourcepub async fn withdraw_sui(
&self,
coin_type: &str,
treasury_id: ObjectId,
owner_cap_id: ObjectId,
amount: u64,
to: SuiAddress,
) -> Result<ExecutionResult, TaiError>
pub async fn withdraw_sui( &self, coin_type: &str, treasury_id: ObjectId, owner_cap_id: ObjectId, amount: u64, to: SuiAddress, ) -> Result<ExecutionResult, TaiError>
withdraw_sui<T>(treasury, owner_cap, amount, to). OwnerCap-gated.
Sourcepub async fn top_up_sui(
&self,
coin_type: &str,
treasury_id: ObjectId,
payment_coin_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn top_up_sui( &self, coin_type: &str, treasury_id: ObjectId, payment_coin_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
top_up_sui<T>(treasury, payment) — permissionless.
Sourcepub async fn top_up_token(
&self,
coin_type: &str,
treasury_id: ObjectId,
payment_coin_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn top_up_token( &self, coin_type: &str, treasury_id: ObjectId, payment_coin_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
top_up_token<T>(treasury, payment) — permissionless.
Sourcepub async fn withdraw_token(
&self,
coin_type: &str,
treasury_id: ObjectId,
owner_cap_id: ObjectId,
amount: u64,
to: SuiAddress,
) -> Result<ExecutionResult, TaiError>
pub async fn withdraw_token( &self, coin_type: &str, treasury_id: ObjectId, owner_cap_id: ObjectId, amount: u64, to: SuiAddress, ) -> Result<ExecutionResult, TaiError>
withdraw_token<T>(treasury, owner_cap, amount, to). OwnerCap-gated.
Sourcepub async fn claim_received_sui(
&self,
coin_type: &str,
treasury_id: ObjectId,
received_coin_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn claim_received_sui( &self, coin_type: &str, treasury_id: ObjectId, received_coin_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
claim_received_sui<T>(treasury, Receiving<Coin<SUI>>).
The received_coin_id argument is the id of a Coin<SUI> that has
been transferred-to-object to the treasury’s address.
Sourcepub async fn claim_received_token(
&self,
coin_type: &str,
treasury_id: ObjectId,
received_coin_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn claim_received_token( &self, coin_type: &str, treasury_id: ObjectId, received_coin_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
claim_received_token<T>(treasury, Receiving<Coin<T>>).
Sourcepub async fn issue_operator_cap(
&self,
coin_type: &str,
treasury_id: ObjectId,
owner_cap_id: ObjectId,
recipient: SuiAddress,
daily_limit_sui: u64,
daily_limit_token: u64,
allowed_targets: &[SuiAddress],
ttl_ms: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn issue_operator_cap( &self, coin_type: &str, treasury_id: ObjectId, owner_cap_id: ObjectId, recipient: SuiAddress, daily_limit_sui: u64, daily_limit_token: u64, allowed_targets: &[SuiAddress], ttl_ms: u64, ) -> Result<ExecutionResult, TaiError>
issue_operator_cap<T>(treasury, owner_cap, recipient, daily_limit_sui, daily_limit_token, allowed_targets, ttl_ms, clock). OwnerCap-gated.
Arg count mirrors the on-chain function arity.
Sourcepub async fn revoke_operator_cap(
&self,
coin_type: &str,
treasury_id: ObjectId,
owner_cap_id: ObjectId,
cap_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn revoke_operator_cap( &self, coin_type: &str, treasury_id: ObjectId, owner_cap_id: ObjectId, cap_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
revoke_operator_cap<T>(treasury, owner_cap, cap_id). OwnerCap-gated.
Sourcepub async fn operator_spend_sui(
&self,
coin_type: &str,
treasury_id: ObjectId,
operator_cap_id: ObjectId,
amount: u64,
to: SuiAddress,
) -> Result<ExecutionResult, TaiError>
pub async fn operator_spend_sui( &self, coin_type: &str, treasury_id: ObjectId, operator_cap_id: ObjectId, amount: u64, to: SuiAddress, ) -> Result<ExecutionResult, TaiError>
operator_spend_sui<T>(treasury, op_cap, amount, to, clock).
OperatorCap-gated; subject to Move-enforced policy (revocation, TTL,
allowlist, daily limit).
Sourcepub async fn record_service_payment_token(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
treasury_cap_holder_id: ObjectId,
payment_coin_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn record_service_payment_token( &self, coin_type: &str, launchpad_account_id: ObjectId, treasury_cap_holder_id: ObjectId, payment_coin_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
record_service_payment_token<T>(config, account, holder, payment, clock).
Sourcepub async fn set_linked_identity(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
identity: Option<ObjectId>,
) -> Result<ExecutionResult, TaiError>
pub async fn set_linked_identity( &self, coin_type: &str, launchpad_account_id: ObjectId, identity: Option<ObjectId>, ) -> Result<ExecutionResult, TaiError>
set_linked_identity<T>(account, Option<ID>). Creator-only.
Sourcepub async fn admin_set_platform_treasury(
&self,
new_treasury: SuiAddress,
) -> Result<ExecutionResult, TaiError>
pub async fn admin_set_platform_treasury( &self, new_treasury: SuiAddress, ) -> Result<ExecutionResult, TaiError>
set_platform_treasury(config, new_treasury). Admin-only.
set_trade_shares(config, nav_bps, creator_bps, platform_bps). Admin-only.
set_service_shares(config, nav_bps, creator_bps, platform_bps). Admin-only.
set_token_service_shares(config, nav_bps, burn_bps, creator_bps). Admin-only.
Sourcepub async fn admin_set_trade_fee_bps(
&self,
bps: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn admin_set_trade_fee_bps( &self, bps: u64, ) -> Result<ExecutionResult, TaiError>
set_trade_fee_bps(config, bps). Admin-only.
Sourcepub async fn admin_set_cred_revenue_target(
&self,
target: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn admin_set_cred_revenue_target( &self, target: u64, ) -> Result<ExecutionResult, TaiError>
set_cred_revenue_target(config, target). Admin-only.
Sourcepub async fn propose_admin(
&self,
new_admin: SuiAddress,
) -> Result<ExecutionResult, TaiError>
pub async fn propose_admin( &self, new_admin: SuiAddress, ) -> Result<ExecutionResult, TaiError>
propose_admin(config, new_admin). Admin-only — step 1 of two-step
transfer. Pending admin must then call accept_admin.
Sourcepub async fn accept_admin(&self) -> Result<ExecutionResult, TaiError>
pub async fn accept_admin(&self) -> Result<ExecutionResult, TaiError>
accept_admin(config). Must be called by the pending-admin address.
Sourcepub async fn cancel_pending_admin(&self) -> Result<ExecutionResult, TaiError>
pub async fn cancel_pending_admin(&self) -> Result<ExecutionResult, TaiError>
cancel_pending_admin(config). Admin-only.
Sourcepub async fn set_creator(
&self,
coin_type: &str,
launchpad_account_id: ObjectId,
new_creator: SuiAddress,
) -> Result<ExecutionResult, TaiError>
pub async fn set_creator( &self, coin_type: &str, launchpad_account_id: ObjectId, new_creator: SuiAddress, ) -> Result<ExecutionResult, TaiError>
set_creator<T>(account, new_creator). Creator-only.
Sourcepub async fn work_order_create(
&self,
coin_type: &str,
payee_launchpad_account_id: ObjectId,
payment_coin_id: ObjectId,
spec_hash: &[u8],
spec_url: &str,
deadline_ms: u64,
dispute_window_ms: u64,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_create( &self, coin_type: &str, payee_launchpad_account_id: ObjectId, payment_coin_id: ObjectId, spec_hash: &[u8], spec_url: &str, deadline_ms: u64, dispute_window_ms: u64, ) -> Result<ExecutionResult, TaiError>
create_work_order<T>(payee_account, payment, spec_hash, spec_url, deadline_ms, dispute_window_ms, clock).
Buyer locks SUI; returns an ExecutionResult whose effects expose the
newly-shared WorkOrder
Sourcepub async fn work_order_accept_with_owner(
&self,
coin_type: &str,
order_id: ObjectId,
owner_cap_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_accept_with_owner( &self, coin_type: &str, order_id: ObjectId, owner_cap_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
accept_work_order_with_owner<T>(order, owner_cap, clock).
Sourcepub async fn work_order_accept_with_operator(
&self,
coin_type: &str,
order_id: ObjectId,
op_cap_id: ObjectId,
treasury_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_accept_with_operator( &self, coin_type: &str, order_id: ObjectId, op_cap_id: ObjectId, treasury_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
accept_work_order_with_operator_v2<T>(order, op_cap, treasury, clock).
The payee AgentTreasury<T> is required so the cap is verified against
the live active set (revoked/expired caps are rejected).
Sourcepub async fn work_order_submit_receipt_with_owner(
&self,
coin_type: &str,
order_id: ObjectId,
owner_cap_id: ObjectId,
receipt_hash: &[u8],
receipt_url: &str,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_submit_receipt_with_owner( &self, coin_type: &str, order_id: ObjectId, owner_cap_id: ObjectId, receipt_hash: &[u8], receipt_url: &str, ) -> Result<ExecutionResult, TaiError>
submit_receipt_with_owner<T>(order, owner_cap, receipt_hash, receipt_url, clock).
Sourcepub async fn work_order_submit_receipt_with_operator(
&self,
coin_type: &str,
order_id: ObjectId,
op_cap_id: ObjectId,
treasury_id: ObjectId,
receipt_hash: &[u8],
receipt_url: &str,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_submit_receipt_with_operator( &self, coin_type: &str, order_id: ObjectId, op_cap_id: ObjectId, treasury_id: ObjectId, receipt_hash: &[u8], receipt_url: &str, ) -> Result<ExecutionResult, TaiError>
submit_receipt_with_operator_v2<T>(order, op_cap, treasury, receipt_hash, url, clk). The payee
AgentTreasury<T> is required for the revocation/expiry checks.
Sourcepub async fn work_order_release(
&self,
coin_type: &str,
order_id: ObjectId,
payee_launchpad_account_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_release( &self, coin_type: &str, order_id: ObjectId, payee_launchpad_account_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
release_work_order<T>(order, config, payee_account, clock).
Buyer may call any time after receipt; anyone may call after window.
Routes locked SUI through record_service_payment_sui<T>.
Sourcepub async fn work_order_refund(
&self,
coin_type: &str,
order_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_refund( &self, coin_type: &str, order_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
refund_work_order<T>(order, clock). Buyer-only, after deadline.
Sourcepub async fn work_order_open_dispute(
&self,
coin_type: &str,
order_id: ObjectId,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_open_dispute( &self, coin_type: &str, order_id: ObjectId, ) -> Result<ExecutionResult, TaiError>
open_dispute<T>(order, clock). Buyer-only, during dispute window.
Sourcepub async fn work_order_admin_resolve(
&self,
coin_type: &str,
order_id: ObjectId,
payee_launchpad_account_id: ObjectId,
in_favor_of_payee: bool,
) -> Result<ExecutionResult, TaiError>
pub async fn work_order_admin_resolve( &self, coin_type: &str, order_id: ObjectId, payee_launchpad_account_id: ObjectId, in_favor_of_payee: bool, ) -> Result<ExecutionResult, TaiError>
admin_resolve_dispute<T>(order, config, payee_account, in_favor_of_payee, clock).
Sourcepub async fn split_off_coin(
&self,
coin_type: &str,
amount: u64,
) -> Result<ObjectId, TaiError>
pub async fn split_off_coin( &self, coin_type: &str, amount: u64, ) -> Result<ObjectId, TaiError>
Split a fresh coin of amount base units of coin_type off one of the
signer’s owned coins, and return the new coin’s object id. coin_type
is the full Move type string (e.g. "0x2::sui::SUI" for SUI, or an
agent coin type such as "0xabc::larry::LARRY").
§Workflow
- Fetches the signer’s coins of
coin_typeviasuix_getCoins. - Picks a source coin with
balance >= amount(prefers balance strictly greater so another coin can cover gas; ties broken by first-found). - Builds the split transaction via
unsafe_splitCoin, signs, and executes it. - Extracts and returns the newly-created coin’s object id from the
objectChangesblock.
Returns TaiError::Rpc if no suitable source coin exists.
Gas note: gas is auto-selected (gas_object = null). When splitting
SUI, the chosen coin is consumed for the split, so the wallet needs
another SUI coin (or a strictly-greater coin) to cover gas — otherwise
the validator rejects the tx for insufficient gas. Splitting a non-SUI
coin type is unaffected (gas is paid from a separate SUI coin).