Skip to main content

TaiClient

Struct TaiClient 

Source
pub struct TaiClient { /* private fields */ }
Expand description

High-level Tai client.

Wraps a RpcClient + a Signer (boxed) + a TaiConfig (so the package + LaunchpadConfig IDs are always available without re-passing).

Implementations§

Source§

impl TaiClient

Source

pub fn new(config: TaiConfig, signer: Arc<dyn Signer>) -> Self

Construct a client for the given config and signer.

Source

pub fn rpc(&self) -> &RpcClient

Access the underlying RPC client (e.g. for read calls).

Source

pub fn config(&self) -> &TaiConfig

Access the underlying config.

Source

pub fn sender(&self) -> SuiAddress

Access the signer’s address (the sender of any submitted tx).

Source

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:

  1. unsafe_moveCall to build the unsigned TransactionData.
  2. Compute the intent digest locally and sign with Signer.
  3. sui_executeTransactionBlock with the signature.
Source§

impl TaiClient

Source

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.

Source

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).

Source

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).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>>).

Source

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.

Source

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.

Source

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).

Source

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).

Source

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.

Source

pub async fn admin_set_platform_treasury( &self, new_treasury: SuiAddress, ) -> Result<ExecutionResult, TaiError>

set_platform_treasury(config, new_treasury). Admin-only.

Source

pub async fn admin_set_trade_shares( &self, nav_bps: u64, creator_bps: u64, platform_bps: u64, ) -> Result<ExecutionResult, TaiError>

set_trade_shares(config, nav_bps, creator_bps, platform_bps). Admin-only.

Source

pub async fn admin_set_service_shares( &self, nav_bps: u64, creator_bps: u64, platform_bps: u64, ) -> Result<ExecutionResult, TaiError>

set_service_shares(config, nav_bps, creator_bps, platform_bps). Admin-only.

Source

pub async fn admin_set_token_service_shares( &self, nav_bps: u64, burn_bps: u64, creator_bps: u64, ) -> Result<ExecutionResult, TaiError>

set_token_service_shares(config, nav_bps, burn_bps, creator_bps). Admin-only.

Source

pub async fn admin_set_trade_fee_bps( &self, bps: u64, ) -> Result<ExecutionResult, TaiError>

set_trade_fee_bps(config, bps). Admin-only.

Source

pub async fn admin_set_cred_revenue_target( &self, target: u64, ) -> Result<ExecutionResult, TaiError>

set_cred_revenue_target(config, target). Admin-only.

Source

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.

Source

pub async fn accept_admin(&self) -> Result<ExecutionResult, TaiError>

accept_admin(config). Must be called by the pending-admin address.

Source

pub async fn cancel_pending_admin(&self) -> Result<ExecutionResult, TaiError>

cancel_pending_admin(config). Admin-only.

Source

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.

Source

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 object id. Arg count mirrors the on-chain fn.

Source

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).

Source

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).

Source

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).

Source

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.

Source

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>.

Source

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.

Source

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.

Source

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).

Source

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
  1. Fetches the signer’s coins of coin_type via suix_getCoins.
  2. Picks a source coin with balance >= amount (prefers balance strictly greater so another coin can cover gas; ties broken by first-found).
  3. Builds the split transaction via unsafe_splitCoin, signs, and executes it.
  4. Extracts and returns the newly-created coin’s object id from the objectChanges block.

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).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more