INNER CODE UNIT · Rust
get_block_explorer
gemwalletcom/wallet · core/crates/block_explorers/src/lib.rs:47
pub fn get_block_explorer(chain: Chain, name: &str) -> Box<dyn BlockExplorer> {
let mut explorers = get_block_explorers(chain);
let index = explorers.iter().position(|explorer| explorer.name() == name).unwrap_or_default();
explorers.swap_remove(index)
}
pub fn get_block_explorers(chain: Chain) -> Vec<Box<dyn BlockExplorer>> {
match chain {
Chain::Bitcoin => vec![blockchair::new_bitcoin(), mempool::new(), threexpl::new_bitcoin()],
Chain::BitcoinCash => vec![blockchair::new_bitcoin_cash(), threexpl::new_bitcoin_cash()],
Chain::Litecoin => vec![blockchair::new_litecoin(), threexpl::new_litecoin()],
Chain::Doge => vec![blockchair::new_doge(), threexpl::new_doge()],
Chain::Dash => vec![blockchair::new_dash(), Explorer::boxed(Metadata::new("Dash Explorer", "https://explorer.dash.org/insight"))],
Chain::Zcash => vec![threexpl::new_zcash(), blockchair::new_zcash(), Explorer::boxed(Metadata::new("ZecBlock", "https://zecblock.com"))],
Chain::Ethereum => vec![EtherScan::boxed(EVMChain::Ethereum), blockchair::new_ethereum(), Blocksec::new_ethereum()],
Chain::SmartChain => vec![EtherScan::boxed(EVMChain::SmartChain), blockchair::new_bnb(), Blocksec::new_bsc()],
Chain::Polygon => vec![EtherScan::boxed(EVMChain::Polygon), blockchair::new_polygon(), Blocksec::new_polygon()],