ex3_core_registry_client/
lib.rs

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
use async_trait::async_trait;
use candid::Principal;
use ex3_canister_client::{ActorResult, CanisterResult};
use ex3_canister_types::pager::{GetPageInput, GetPageOutput};
use ex3_core_registry_public_types::{
    BalanceVaultInfo, CandidChainNetworkConfirmationTime, SecretVaultInfo,
    ShardingReportProgressInfo, ShardingSubReport, WalletRegistryInfo,
};
use ex3_node_types::asset::CandidRegisteredCryptoAsset;
use ex3_node_types::market::{
    CandidMemeMarketTradingFee, CandidMemeMarketTradingSettings, CandidRegisteredMemeMarket,
    CandidRegisteredSpotMarket, CandidSpotMarketTradingFee,
};
use ex3_node_types::settings::{
    CandidBalanceVaultSetting, CandidSecretVaultSetting, CandidWalletRegistrySetting,
};
use ex3_node_types::{CandidAssetId, CandidBlockHeight, CandidWalletRegisterId, CanisterId};

#[cfg(feature = "mock")]
pub mod mock;

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

#[async_trait]
pub trait CoreRegistry: Send + Sync {
    /// Get asset information by asset id
    /// * asset_id - the asset id
    /// If the asset is not registered, return None
    /// If the asset is registered, return the asset information
    async fn get_asset_by_id(
        &self,
        asset_id: CandidAssetId,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidRegisteredCryptoAsset>>>;

    async fn get_assets_by_page(
        &self,
        pager: GetPageInput,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidRegisteredCryptoAsset>>>;

    async fn get_global_withdrawal_fee_to(
        &self,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidWalletRegisterId>>>;

    async fn get_chains_confirmation_times_by_page(
        &self,
        pager: GetPageInput,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidChainNetworkConfirmationTime>>>;

    async fn get_spot_market_initial_fee_to(
        &self,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidWalletRegisterId>>>;
    async fn get_spot_market_initial_trading_fee(
        &self,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidSpotMarketTradingFee>>>;
    async fn get_spot_markets_by_page(
        &self,
        input: GetPageInput,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidRegisteredSpotMarket>>>;

    async fn get_meme_market_initial_trading_settings(
        &self,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidMemeMarketTradingSettings>>>;
    async fn get_meme_market_initial_trading_fee(
        &self,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidMemeMarketTradingFee>>>;
    async fn get_meme_market_initial_fee_to(
        &self,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<Option<CandidWalletRegisterId>>>;
    async fn get_meme_markets_by_page(
        &self,
        input: GetPageInput,
        height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidRegisteredMemeMarket>>>;

    async fn get_node_providers(&self) -> CanisterResult<Vec<Principal>>;
    async fn get_node_provider_count(&self) -> CanisterResult<u64>;

    async fn get_wallet_registry_ids(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<GetPageOutput<CanisterId>>;
    async fn get_wallet_registries(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<GetPageOutput<WalletRegistryInfo>>;
    async fn get_wallet_registry_count(&self) -> CanisterResult<u64>;
    async fn get_wallet_registry_setting(
        &self,
        wallet_registry_id: CanisterId,
    ) -> CanisterResult<Option<CandidWalletRegistrySetting>>;
    #[cfg(feature = "canister")]
    async fn register_new_wallet_registry(
        &self,
        wallet_registry_canister_id: CanisterId,
        wallet_registry_seq_id: u64,
        wallet_registry_setting: CandidWalletRegistrySetting,
    ) -> CanisterResult<ActorResult<()>>;

    async fn get_secret_vault_count(&self) -> CanisterResult<u64>;
    async fn get_secret_vault_ids(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<GetPageOutput<CanisterId>>;
    async fn get_secret_vaults(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<GetPageOutput<SecretVaultInfo>>;
    async fn get_secret_vault_setting(
        &self,
        secret_vault_id: CanisterId,
    ) -> CanisterResult<Option<CandidSecretVaultSetting>>;

    #[cfg(feature = "canister")]
    async fn register_new_secret_vault(
        &self,
        secret_vault_canister_id: CanisterId,
        secret_vault_seq_id: u64,
        secret_vault_setting: CandidWalletRegistrySetting,
    ) -> CanisterResult<ActorResult<()>>;

    async fn get_balance_vault_count(&self) -> CanisterResult<u64>;
    async fn get_balance_vault_ids(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<GetPageOutput<CanisterId>>;
    async fn get_balance_vaults(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<GetPageOutput<BalanceVaultInfo>>;
    async fn get_balance_vault_setting(
        &self,
        balance_vault_id: CanisterId,
    ) -> CanisterResult<Option<CandidBalanceVaultSetting>>;

    #[cfg(feature = "canister")]
    async fn register_new_balance_vault(
        &self,
        balance_vault_canister_id: CanisterId,
        balance_vault_seq_id: u64,
        balance_vault_setting: CandidWalletRegistrySetting,
    ) -> CanisterResult<ActorResult<()>>;

    async fn get_current_block_height(&self) -> CanisterResult<CandidBlockHeight>;
    async fn get_current_snapshot_height(&self) -> CanisterResult<Option<CandidBlockHeight>>;
    async fn get_sharding_report_progress_info(&self)
        -> CanisterResult<ShardingReportProgressInfo>;
    async fn apply_to_be_a_submitter(
        &self,
        height: CandidBlockHeight,
    ) -> CanisterResult<ActorResult<()>>;
    async fn submit_sharding_sub_report(
        &self,
        block_height: CandidBlockHeight,
        sub_report: ShardingSubReport,
    ) -> CanisterResult<ActorResult<()>>;
    async fn validate_or_drop_sharding_report(
        &self,
        block_height: CandidBlockHeight,
    ) -> CanisterResult<ActorResult<()>>;
    async fn commit_sharding_report(
        &self,
        block_height: CandidBlockHeight,
    ) -> CanisterResult<ActorResult<bool>>;

    async fn report_gas_price(
        &self,
        chain: ex3_node_types::chain::CandidChain,
        gas_price: ex3_node_types::CandidAssetAmount,
    ) -> CanisterResult<ActorResult<()>>;
}