use alloy_primitives::{Address, U256};
use alloy_provider::network::Ethereum;
use alloy_provider::{Network, Provider};
use std::marker::PhantomData;
use tides_core_types::TidesChainId;
use trident_types::core::FixedBytes32;
pub struct DepositInEvmChainWithApprovalResponse<N: Network = Ethereum> {
pub approval_tx_receipt: N::ReceiptResponse,
pub deposit_tx_receipt: N::ReceiptResponse,
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct EvmToEvmSpendRequest<
'a,
S: alloy_signer::Signer + ?Sized,
DP: Provider<DN> + ?Sized,
DN: Network = Ethereum,
> {
pub source_signer: &'a S,
pub source_chain_id: TidesChainId,
pub source_token: Address,
pub source_token_amount: U256,
pub source_max_fees: Option<U256>,
pub destination_provider: &'a DP,
pub destination_chain_id: TidesChainId,
pub destination_recipient: Address,
pub destination_token: Option<Address>,
pub destination_callback: Option<EvmDestinationCallback>,
pub destination_caller: Option<Address>,
pub max_block_height: Option<u64>,
pub salt: Option<FixedBytes32>,
pub _phantoms: PhantomData<DN>,
}
impl<'a, S, DP, DN> EvmToEvmSpendRequest<'a, S, DP, DN>
where
DP: Provider<DN>,
S: alloy_signer::Signer + ?Sized,
DN: Network,
{
pub fn new(
source_signer: &'a S,
source_chain_id: TidesChainId,
source_token: Address,
source_token_amount: U256,
destination_provider: &'a DP,
destination_chain_id: TidesChainId,
destination_recipient: Address,
) -> Self {
Self {
source_signer,
source_chain_id,
source_token,
source_token_amount,
source_max_fees: None,
destination_provider,
destination_chain_id,
destination_recipient,
destination_token: None,
destination_callback: None,
destination_caller: None,
max_block_height: None,
salt: None,
_phantoms: PhantomData,
}
}
pub fn with_destination_token(mut self, destination_token: Address) -> Self {
self.destination_token = Some(destination_token);
self
}
pub fn with_destination_callback(
mut self,
destination_callback: EvmDestinationCallback,
) -> Self {
self.destination_callback = Some(destination_callback);
self
}
pub fn with_source_chain_max_fees(mut self, max_fees: U256) -> Self {
self.source_max_fees = Some(max_fees);
self
}
pub fn with_max_block_height(mut self, max_block_height: u64) -> Self {
self.max_block_height = Some(max_block_height);
self
}
pub fn with_destination_caller(mut self, destination_caller: Address) -> Self {
self.destination_caller = Some(destination_caller);
self
}
pub fn with_salt(mut self, salt: impl Into<FixedBytes32>) -> Self {
self.salt = Some(salt.into());
self
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EvmDestinationCallback;
impl EvmDestinationCallback {
pub(crate) fn to_vec(&self) -> Vec<u8> {
Vec::new()
}
}
#[derive(Debug, Clone)]
pub struct EvmToEvmSpendResponse<N: Network = Ethereum> {
pub destination_token: Address,
pub applied_fees: U256,
pub max_block_height: u64,
pub delivery_tx_receipt: N::ReceiptResponse,
}