ex3-dft-client 0.17.1

Dfinity fungible token standard canister client-rs/client-canister.
Documentation
use async_trait::async_trait;
use candid::Nat;
use ex3_canister_client::CanisterResult;

pub use types::{
    AccountIdentifier, ArchivedBlocksRange, Block, BlockHash, BlockHeight, BlockResult, Operation,
    OperationResult, QueryBlocksResult, TokenFee, TokenHolder, TokenReceiver, Transaction,
    TransactionId,
};

use crate::types::Subaccount;

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

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

#[async_trait]
pub trait DFT: Send + Sync {
    async fn block_by_height(&self, block_height: &BlockHeight) -> CanisterResult<BlockResult>;
    async fn blocks_by_query(
        &self,
        start: &BlockHeight,
        count: &usize,
    ) -> CanisterResult<QueryBlocksResult>;
    async fn transfer_from(
        &self,
        spender_sub_account: Option<Subaccount>,
        from: String,
        to: String,
        value: Nat,
        created_at: Option<u64>,
    ) -> CanisterResult<OperationResult>;

    async fn transfer(
        &self,
        from_sub_account: Option<Subaccount>,
        to: String,
        value: Nat,
        created_at: Option<u64>,
    ) -> CanisterResult<OperationResult>;

    async fn balance_of(&self, token_holder: String) -> CanisterResult<Nat>;
}

#[async_trait]
pub trait DFTArchive: Send + Sync {
    async fn block_by_height(&self, block_height: &BlockHeight) -> CanisterResult<BlockResult>;
    async fn blocks_by_query(
        &self,
        start: &BlockHeight,
        count: &usize,
    ) -> CanisterResult<Vec<Block>>;
}