TridentClient

Struct TridentClient 

Source
pub struct TridentClient {
    pub attester: AttesterServiceClient<Channel>,
    /* private fields */
}
Expand description

Client for interacting with Trident attester services and EVM contracts. Maintains deployments, supported tokens, and exposes high-level operations.

Fields§

§attester: AttesterServiceClient<Channel>

gRPC client to the Trident Attester service.

Implementations§

Source§

impl TridentClient

Source

pub const DEFAULT_MAX_BLOCK_HEIGHT_BUFFER_PERCENTAGE: u64 = 10u64

Default buffer percentage applied to the minimum validity blocks when suggesting a spend intent’s max block height.

Source

pub async fn connect<D>(endpoint: D) -> Result<Self, Error>
where D: TryInto<Endpoint>, D::Error: Into<StdError>,

Connects to the attester endpoint, loads deployments and supported deposit tokens.

Source

pub async fn connect_testnet() -> Result<Self, Error>

Source

pub fn with_max_block_height_buffer_percentage(self, buffer: u64) -> Self

Sets the buffer percentage applied to the minimum validity blocks when suggesting spend intent expirations.

Source

pub async fn evm_deposit_with_approval<N: Network, P: Provider<N>>( &self, provider: P, tides_chain_id: u32, token: Address, amount: U256, ) -> Result<DepositInEvmChainWithApprovalResponse<N>, Error>

Approves and deposits amount of token into the Trident deposits contract on an EVM chain. Returns receipts for both the approval and deposit transactions.

Source

pub async fn evm_deposit_token<N: Network, P: Provider<N>>( &self, provider: &P, deposits_contract: Address, token: Address, amount: U256, ) -> Result<<N as Network>::ReceiptResponse, Error>

Submits a deposit transaction to the Trident deposits contract for the given ERC-20 token and amount.

Source

pub async fn evm_sign_and_deposit_with_permit<N: Network, P: Provider<N>, S: Signer + Send + Sync>( &self, provider: P, signer: S, tides_chain_id: u32, token: Address, amount: U256, deadline: U256, ) -> Result<N::ReceiptResponse, Error>

Source

pub async fn evm_sign_deposit_with_permit_request<S: Signer + Send + Sync>( &self, signer: S, domain: Eip712Domain, spender: Address, amount: U256, nonce: U256, deadline: U256, ) -> Result<Signature, Error>

Source

pub async fn evm_deposit_with_permit<N: Network, P: Provider<N>>( &self, provider: &P, deposits_contract: Address, token: Address, owner: Address, amount: U256, deadline: U256, signature: Bytes, ) -> Result<<N as Network>::ReceiptResponse, Error>

Deposit tokens with an EIP-7597 permit, passing the signature as bytes to allow for SCA deposits

Source

pub async fn evm_deliver<N: Network, P: Provider<N>>( &mut self, provider: &P, destination_chain: TidesChainId, attestation_payload: Vec<u8>, signature: Vec<u8>, ) -> Result<<N as Network>::ReceiptResponse, Error>

Executes a spend attestation on the destination chain by calling TridentDelivery.deliverToken.

Source

pub async fn evm_to_evm_spend<'a, DN: Network, S: Signer, DP: Provider<DN>>( &mut self, req: EvmToEvmSpendRequest<'a, S, DP, DN>, ) -> Result<EvmToEvmSpendResponse<DN>, Error>

Creates, signs, and submits an EVM-to-EVM spend intent, then triggers delivery on the destination chain. Resolves destination token (if omitted), checks balances/fees, and returns the delivery receipt.

Source

pub async fn resolve_destination_tokens<T1, T2>( &mut self, source_chain_id: TidesChainId, destination_chain_id: TidesChainId, source_token: T1, ) -> Result<Vec<T2>, Error>

Resolves the given source token into destination token(s) for destination_chain. T1 must convert into FixedBytes32; T2 must convert from FixedBytes32.

Source

pub fn make_spend_spec( &self, source_chain: TidesChainId, source_depositor: Address, source_token: impl Into<FixedBytes32>, source_token_amount: U256, destination_chain: TidesChainId, destination_token: impl Into<FixedBytes32>, destination_recipient: impl Into<FixedBytes32>, destination_caller: impl Into<FixedBytes32>, salt: impl Into<FixedBytes32>, callback_data: Option<Vec<u8>>, ) -> Result<SpendSpec, Error>

Builds a SpendSpec after validating the source and destination chains.

Source

pub fn make_spend_intent( &self, max_fee: U256, max_block_height: u64, spend_spec: SpendSpec, ) -> SpendIntent

Wraps a SpendSpec into a SpendIntent with fee cap and expiration height.

Source

pub async fn get_suggested_fee( &mut self, _source_chain: TidesChainId, _source_token: impl Into<FixedBytes32>, _source_token_amount: U256, _destination_chain: TidesChainId, _destination_token: impl Into<FixedBytes32>, ) -> Result<U256, Error>

Suggests a source-side fee for the given route and amount. Placeholder returning zero for now.

Source

pub async fn suggest_spend_intent_max_block_height( &mut self, src_chain_id: TidesChainId, ) -> Result<u64, Error>

Suggests a spend intent’s max block height using: last finalized block + (min validity blocks + buffered min validity blocks).

Source

pub async fn evm_faucet<N: Network, P: Provider<N>>( &self, provider: &P, token: Address, recipient: Address, amount: U256, ) -> Result<N::ReceiptResponse, Error>

Faucets tokens by calling mint(address,uint256) on an open‑mint token. amount is provided in the token’s smallest unit.

Source

pub fn get_deployment_by_name( &self, name: impl AsRef<str>, ) -> Option<&TridentDeployment>

Source

pub async fn evm_balances( &mut self, chain_id: TidesChainId, address: impl Into<Address>, ) -> Result<HashMap<Address, U256>, Error>

Source

pub async fn evm_balance( &mut self, chain_id: TidesChainId, address: impl Into<Address>, want: impl Into<Address>, ) -> Result<U256, Error>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,