1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use async_trait::async_trait;
#[cfg(feature = "canister")]
use ex3_asset_vault_public_types::CandidWithdrawalConsensusReport;
use ex3_canister_client::{ActorResult, CanisterResult};
use ex3_node_types::chain::CandidChain;
#[cfg(feature = "canister")]
use ex3_node_types::{CandidBlockHeight, CanisterId, TransactionHash};

#[cfg(feature = "canister")]
pub mod canister_impl;
#[cfg(feature = "agent")]
pub mod client_impl;
#[cfg(feature = "mock")]
pub mod mock;

#[async_trait]
pub trait AssetVault: Send + Sync {
    async fn get_deposit_address(&self, chain: CandidChain) -> CanisterResult<ActorResult<String>>;

    /// Update gas price
    /// This method is only available for the core registry canister
    /// # Arguments
    /// * `gas_prices` - A list of gas prices for each chain Vec(Chain, GasPrice)
    #[cfg(feature = "canister")]
    async fn update_gas_price(
        &self,
        gas_prices: Vec<(CandidChain, ex3_node_types::CandidAssetAmount)>,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn accept_new_balance_vault(
        &self,
        new_balance_vault_id: CanisterId,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn accept_withdrawal_consensus_report(
        &self,
        height: CandidBlockHeight,
        report: CandidWithdrawalConsensusReport,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn accept_withdrawal_forward_report(
        &self,
        height: CandidBlockHeight,
        report: ex3_balance_vault_public_types::AcceptedWithdrawalShardingSubReport,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn forward_force_withdrawal(
        &self,
        withdrawal: ex3_node_types::transaction::EncodedTransaction,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn notify_force_withdrawal_processed(
        &self,
        tx_hash: TransactionHash,
    ) -> CanisterResult<ActorResult<()>>;
}