1use crate::evm;
2use crate::evm::EvmDepositError;
3use alloy_primitives::{Address, U256};
4use alloy_provider::network::AnyNetwork;
5use alloy_provider::{DynProvider, PendingTransactionBuilder};
6use std::marker::PhantomData;
7
8#[derive(Debug)]
10pub(crate) enum DepositContext {
11 Evm {
12 provider: DynProvider<AnyNetwork>,
13 signer_address: Address,
14 deposit_contract: Address,
15 token: Address,
16 amount: U256,
17 },
18}
19
20#[derive(Debug)]
26pub struct Deposit<T> {
27 inner: DepositContext,
28 _chain_type: PhantomData<T>,
29}
30
31impl<T> Deposit<T> {
32 pub(crate) fn new(inner: DepositContext) -> Self {
33 Self {
34 inner,
35 _chain_type: PhantomData,
36 }
37 }
38}
39
40impl Deposit<Address> {
41 pub async fn send(self) -> Result<PendingTransactionBuilder<AnyNetwork>, EvmDepositError> {
46 let DepositContext::Evm {
47 provider,
48 signer_address,
49 deposit_contract,
50 token,
51 amount,
52 } = self.inner;
53
54 evm::deposit(provider, deposit_contract, signer_address, token, amount).await
55 }
56}