eth_icons/lib.rs
1/*!
2 * `eth-icons` is an icon fetching library for EVM icons.
3 *
4 * Network (Mainnet, Sepolia, etc.), Native Asset (ETH, sepETH, etc.), and ERC20 (wETH, etc.) icons are an inherit non-standardized extension of the ethereum protocol.
5 *
6 * To allow for easily integrating these into your application eth-icons aims to bring a set of helpers to obtain iconography from various sources.
7 *
8 * ```rust
9 * use eth_icons::{IconClient, IconQuery};
10 *
11 * #[tokio::main]
12 * pub async fn main() {
13 * // Create a client
14 * let client = reqwest::Client::new();
15 *
16 * // Create an icon client
17 * let icons = IconClient::builder()
18 * .with_reqwest(client)
19 * .with_defaults()
20 * .build();
21 *
22 * let weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string();
23 * let weth_icons = icons.resolve(IconQuery::ERC20(1u64, weth)).await;
24 * }
25 * ```
26 *
27 * ## Selecting Sources
28 *
29 * Every source is opt-in by default.
30 *
31 * ```rust
32 * use eth_icons::{Address, IconClient, IconQuery, modules::{Blockscout, Zerion}};
33 *
34 * #[tokio::main]
35 * pub async fn main() {
36 * let icons = IconClient::builder()
37 * .with_reqwest(reqwest::Client::new())
38 * .with_source(Blockscout)
39 * .with_source(Zerion)
40 * .build();
41 *
42 * let weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string();
43 * let results = icons.resolve(IconQuery::ERC20(1, weth)).await;
44 *
45 * for source in &results {
46 * println!("{}: {:?}", source.source, source.result);
47 * }
48 * }
49 * ```
50 *
51 * ## Available Sources
52 *
53 * - [Avara](crate::modules::Avara) - supports ERC20s
54 * - [Blockscout](crate::modules::Blockscout) - supports ERC20s
55 * - [SafeWallet](crate::modules::SafeWallet) - supports network and native token icons
56 * - [Smoldapp](crate::modules::Smoldapp) - supports network, native tokens, and ERC20s
57 * - [Zerion](crate::modules::Zerion) - supports ERC20s
58 *
59 *
60 */
61
62pub mod client;
63pub mod error;
64pub mod fetcher;
65pub mod icon;
66pub mod identity;
67pub mod modules;
68pub mod result;
69pub mod source;
70
71pub use {
72 client::{IconClient, builder::IconClientBuilder},
73 error::Error,
74 fetcher::IconFetcher,
75 icon::Icon,
76 identity::{Address, NetworkId},
77 result::{IconResult, SourceResult},
78 source::{IconQuery, IconSource},
79};