Skip to main content

DataProvider

Trait DataProvider 

Source
pub trait DataProvider: Send + Sync {
    // Provided methods
    fn resolve_token(
        &self,
        chain_id: u64,
        address: &str,
    ) -> Pin<Box<dyn Future<Output = Option<TokenMeta>> + Send + '_>> { ... }
    fn resolve_ens_name(
        &self,
        address: &str,
        chain_id: u64,
        types: Option<&[String]>,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>> { ... }
    fn resolve_local_name(
        &self,
        address: &str,
        chain_id: u64,
        types: Option<&[String]>,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>> { ... }
    fn resolve_nft_collection_name(
        &self,
        collection_address: &str,
        chain_id: u64,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>> { ... }
    fn resolve_block_timestamp(
        &self,
        chain_id: u64,
        block_number: u64,
    ) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + '_>> { ... }
}
Expand description

Async data provider for external data resolution during formatting.

Wallets implement this trait to supply token metadata, ENS/local address names, and NFT collection names. All methods have default implementations returning None, so implementors only need to override the methods they support.

Provided Methods§

Source

fn resolve_token( &self, chain_id: u64, address: &str, ) -> Pin<Box<dyn Future<Output = Option<TokenMeta>> + Send + '_>>

Resolve token metadata (symbol, decimals, name) for a given chain and address.

Source

fn resolve_ens_name( &self, address: &str, chain_id: u64, types: Option<&[String]>, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>>

Resolve an ENS name for an address.

types hints the expected address role (e.g. ["eoa"], ["contract"]).

Source

fn resolve_local_name( &self, address: &str, chain_id: u64, types: Option<&[String]>, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>>

Resolve a local/contact name for an address.

types hints the expected address role (e.g. ["eoa"], ["contract"]).

Source

fn resolve_nft_collection_name( &self, collection_address: &str, chain_id: u64, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>>

Resolve an NFT collection name for a collection contract address.

Source

fn resolve_block_timestamp( &self, chain_id: u64, block_number: u64, ) -> Pin<Box<dyn Future<Output = Option<u64>> + Send + '_>>

Resolve an approximate unix timestamp for a given block number.

Implementors§