clementine_core::citrea

Trait CitreaClientT

Source
pub trait CitreaClientT:
    Send
    + Sync
    + Debug
    + Clone
    + 'static {
    // Required methods
    fn new<'async_trait>(
        citrea_rpc_url: String,
        light_client_prover_url: String,
        chain_id: u32,
        secret_key: Option<PrivateKeySigner>,
    ) -> Pin<Box<dyn Future<Output = Result<Self, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait;
    fn withdrawal_utxos<'life0, 'async_trait>(
        &'life0 self,
        withdrawal_index: u64,
    ) -> Pin<Box<dyn Future<Output = Result<OutPoint, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn collect_deposit_move_txids<'life0, 'async_trait>(
        &'life0 self,
        last_deposit_idx: Option<u32>,
        to_height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, Txid)>, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn collect_withdrawal_utxos<'life0, 'async_trait>(
        &'life0 self,
        last_withdrawal_idx: Option<u32>,
        to_height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, OutPoint)>, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_light_client_proof<'life0, 'async_trait>(
        &'life0 self,
        l1_height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(LightClientProof, Receipt, u64)>, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_citrea_l2_height_range<'life0, 'async_trait>(
        &'life0 self,
        block_height: u64,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<(u64, u64), BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_replacement_deposit_move_txids<'life0, 'async_trait>(
        &'life0 self,
        from_height: u64,
        to_height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(u32, Txid)>, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn check_nofn_correctness<'life0, 'async_trait>(
        &'life0 self,
        nofn_xonly_pk: XOnlyPublicKey,
    ) -> Pin<Box<dyn Future<Output = Result<(), BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_storage_proof<'life0, 'async_trait>(
        &'life0 self,
        l2_height: u64,
        deposit_index: u32,
    ) -> Pin<Box<dyn Future<Output = Result<StorageProof, BridgeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}

Required Methods§

Source

fn new<'async_trait>( citrea_rpc_url: String, light_client_prover_url: String, chain_id: u32, secret_key: Option<PrivateKeySigner>, ) -> Pin<Box<dyn Future<Output = Result<Self, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait,

§Parameters
  • citrea_rpc_url: URL of the Citrea RPC.
  • light_client_prover_url: URL of the Citrea light client prover RPC.
  • chain_id: Citrea’s EVM chain id.
  • secret_key: EVM secret key of the EVM user. If not given, random secret key is used (wallet is not required). This is given mostly for testing purposes.
Source

fn withdrawal_utxos<'life0, 'async_trait>( &'life0 self, withdrawal_index: u64, ) -> Pin<Box<dyn Future<Output = Result<OutPoint, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches an UTXO from Citrea for the given withdrawal index.

§Parameters
  • withdrawal_index: Index of the withdrawal.
§Returns
  • [OutPoint]: UTXO for the given withdrawal.
Source

fn collect_deposit_move_txids<'life0, 'async_trait>( &'life0 self, last_deposit_idx: Option<u32>, to_height: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, Txid)>, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns deposit move txids, starting from the last deposit index.

§Parameters
  • last_deposit_idx: Last deposit index. None if no deposit
  • to_height: End block height (inclusive)
Source

fn collect_withdrawal_utxos<'life0, 'async_trait>( &'life0 self, last_withdrawal_idx: Option<u32>, to_height: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, OutPoint)>, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns withdrawal utxos, starting from the last withdrawal index.

§Parameters
  • last_withdrawal_idx: Last withdrawal index. None if no withdrawal
  • to_height: End block height (inclusive)
Source

fn get_light_client_proof<'life0, 'async_trait>( &'life0 self, l1_height: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<(LightClientProof, Receipt, u64)>, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the light client proof and its L2 height for the given L1 block height.

§Returns

A tuple, wrapped around a Some if present:

  • u64: Last L2 block height.

If not present, None is returned.

Source

fn get_citrea_l2_height_range<'life0, 'async_trait>( &'life0 self, block_height: u64, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(u64, u64), BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the L2 block height range for the given L1 block height.

TODO: This is not the best way to do this, but it’s a quick fix for now it will attempt to fetch the light client proof max_attempts times with 1 second intervals.

§Parameters
  • block_height: L1 block height.
  • timeout: Timeout duration.
§Returns

A tuple of:

  • u64: Start of the L2 block height (not inclusive)
  • u64: End of the L2 block height (inclusive)
Source

fn get_replacement_deposit_move_txids<'life0, 'async_trait>( &'life0 self, from_height: u64, to_height: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<(u32, Txid)>, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the replacement deposit move txids for the given range of blocks.

§Parameters
  • from_height: Start block height (inclusive)
  • to_height: End block height (inclusive)
§Returns

A vector of tuples, each containing:

  • [Txid]: The original move txid.
  • [Txid]: The replacement move txid.
Source

fn check_nofn_correctness<'life0, 'async_trait>( &'life0 self, nofn_xonly_pk: XOnlyPublicKey, ) -> Pin<Box<dyn Future<Output = Result<(), BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_storage_proof<'life0, 'async_trait>( &'life0 self, l2_height: u64, deposit_index: u32, ) -> Pin<Box<dyn Future<Output = Result<StorageProof, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§