ex3_dft_client/
lib.rs

1use async_trait::async_trait;
2use candid::Nat;
3use ex3_canister_client::CanisterResult;
4
5pub use types::{
6    AccountIdentifier, ArchivedBlocksRange, Block, BlockHash, BlockHeight, BlockResult, Operation,
7    OperationResult, QueryBlocksResult, TokenFee, TokenHolder, TokenReceiver, Transaction,
8    TransactionId,
9};
10
11use crate::types::Subaccount;
12
13#[cfg(feature = "mock")]
14pub mod mock;
15
16#[cfg(feature = "canister")]
17pub mod canister_impl;
18#[cfg(feature = "agent")]
19pub mod client_impl;
20mod types;
21
22#[async_trait]
23pub trait DFT: Send + Sync {
24    async fn block_by_height(&self, block_height: &BlockHeight) -> CanisterResult<BlockResult>;
25    async fn blocks_by_query(
26        &self,
27        start: &BlockHeight,
28        count: &usize,
29    ) -> CanisterResult<QueryBlocksResult>;
30    async fn transfer_from(
31        &self,
32        spender_sub_account: Option<Subaccount>,
33        from: String,
34        to: String,
35        value: Nat,
36        created_at: Option<u64>,
37    ) -> CanisterResult<OperationResult>;
38
39    async fn transfer(
40        &self,
41        from_sub_account: Option<Subaccount>,
42        to: String,
43        value: Nat,
44        created_at: Option<u64>,
45    ) -> CanisterResult<OperationResult>;
46
47    async fn balance_of(&self, token_holder: String) -> CanisterResult<Nat>;
48}
49
50#[async_trait]
51pub trait DFTArchive: Send + Sync {
52    async fn block_by_height(&self, block_height: &BlockHeight) -> CanisterResult<BlockResult>;
53    async fn blocks_by_query(
54        &self,
55        start: &BlockHeight,
56        count: &usize,
57    ) -> CanisterResult<Vec<Block>>;
58}