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
impl TridentClient
Sourcepub const DEFAULT_MAX_BLOCK_HEIGHT_BUFFER_PERCENTAGE: u64 = 10u64
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.
Sourcepub async fn connect<D>(endpoint: D) -> Result<Self, Error>
pub async fn connect<D>(endpoint: D) -> Result<Self, Error>
Connects to the attester endpoint, loads deployments and supported deposit tokens.
pub async fn connect_testnet() -> Result<Self, Error>
Sourcepub fn with_max_block_height_buffer_percentage(self, buffer: u64) -> Self
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
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>
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>
Sourcepub 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>
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
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub async fn resolve_destination_tokens<T1, T2>(
&mut self,
source_chain_id: TidesChainId,
destination_chain_id: TidesChainId,
source_token: T1,
) -> Result<Vec<T2>, Error>where
T1: Into<FixedBytes32>,
T2: TryFrom<FixedBytes32>,
<T2 as TryFrom<FixedBytes32>>::Error: Display,
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>where
T1: Into<FixedBytes32>,
T2: TryFrom<FixedBytes32>,
<T2 as TryFrom<FixedBytes32>>::Error: Display,
Resolves the given source token into destination token(s) for destination_chain.
T1 must convert into FixedBytes32; T2 must convert from FixedBytes32.
Sourcepub 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>
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.
Sourcepub fn make_spend_intent(
&self,
max_fee: U256,
max_block_height: u64,
spend_spec: SpendSpec,
) -> SpendIntent
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.
Sourcepub 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>
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.
Sourcepub async fn suggest_spend_intent_max_block_height(
&mut self,
src_chain_id: TidesChainId,
) -> Result<u64, Error>
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).
Sourcepub async fn evm_faucet<N: Network, P: Provider<N>>(
&self,
provider: &P,
token: Address,
recipient: Address,
amount: U256,
) -> Result<N::ReceiptResponse, Error>
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.
pub fn get_deployments(&self) -> &HashMap<TidesChainId, TridentDeployment>
pub fn get_deployment_by_name( &self, name: impl AsRef<str>, ) -> Option<&TridentDeployment>
pub async fn evm_balances( &mut self, chain_id: TidesChainId, address: impl Into<Address>, ) -> Result<HashMap<Address, U256>, Error>
pub async fn evm_balance( &mut self, chain_id: TidesChainId, address: impl Into<Address>, want: impl Into<Address>, ) -> Result<U256, Error>
Auto Trait Implementations§
impl !Freeze for TridentClient
impl !RefUnwindSafe for TridentClient
impl Send for TridentClient
impl Sync for TridentClient
impl Unpin for TridentClient
impl !UnwindSafe for TridentClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request