Adds a new crate webb-chains-info that contains the chain information of the supported chains by the relayer.
bundles the chains.json from https://chainid.network/chains.json
bundles the coingecko_coins_list.json from https://api.coingecko.com/api/v3/coins/list?include_platform=false
added a simple file to control which chains are supported internally by the relayer (see supported_chains.toml file)
updated the fees endpoint to not relay on the hardcoded coingecko-specific coin ids and instead use the new package.
updated the coingecko price oracle backend to use the new package to map the token symbols to coingecko's coin ids.
Reference issue to close (if applicable)
Closes #412
How to add a new chain?
Just add the Chain Id to the list of chain ids inside the supported_chains.toml file and rebuild the relayer. The generated file is not included in the git history, but it gets generated during the build of the webb-chains-info crate.
Here is an example of the generated file:
Click to view
```rs
mod chains {
//! Chains Information
//!
//! This file is generated by the `build.rs` script.
//! Do not edit this file manually.
//!
//! This file contains the information about the chains that are supported by the relayer.
//! The information is used to generate the `chains.rs` file and could be used by
//! the relayer to get the information about the chains.
/// The Chain Information.
pub struct ChainInfo {
/// Chain Identifier.
pub chain_id: u64,
/// Chain Name.
pub name: &'static str,
/// Chain Short Name, usually the ticker.
pub short_name: &'static str,
/// Chain Native Currency Information.
pub native_currency: CurrencyInfo,
}
/// The Currency Information.
pub struct CurrencyInfo {
/// Currency Name.
pub name: &'static str,
/// Currency Symbol.
pub symbol: &'static str,
/// Currency Decimals.
pub decimals: u8,
/// Coingecko's Coin Identifier.
///
/// This is `None` if the chain is not supported by Coingecko.
pub coingecko_coin_id: Option<&'static str>,
}
pub type ChainsInfo = [(u64, ChainInfo); 6usize];
/// List of all the supported chains.
pub const CHAINS_INFO: ChainsInfo = [
(
5u64,
ChainInfo {
chain_id: 5u64,
name: "Goerli",
short_name: "gor",
native_currency: CurrencyInfo {
name: "Goerli Ether",
symbol: "ETH",
decimals: 18u8,
coingecko_coin_id: Some("ethereum"),
},
},
),
(
1287u64,
ChainInfo {
chain_id: 1287u64,
name: "Moonbase Alpha",
short_name: "mbase",
native_currency: CurrencyInfo {
name: "Dev",
symbol: "DEV",
decimals: 18u8,
coingecko_coin_id: Some("moonbeam"),
},
},
),
(
80001u64,
ChainInfo {
chain_id: 80001u64,
name: "Mumbai",
short_name: "maticmum",
native_currency: CurrencyInfo {
name: "MATIC",
symbol: "MATIC",
decimals: 18u8,
coingecko_coin_id: Some("matic-network"),
},
},
),
(
421613u64,
ChainInfo {
chain_id: 421613u64,
name: "Arbitrum Goerli",
short_name: "arb-goerli",
native_currency: CurrencyInfo {
name: "Arbitrum Goerli Ether",
symbol: "AGOR",
decimals: 18u8,
coingecko_coin_id: Some("arbitrum"),
},
},
),
(
534353u64,
ChainInfo {
chain_id: 534353u64,
name: "Scroll Alpha Testnet",
short_name: "scr-alpha",
native_currency: CurrencyInfo {
name: "Ether",
symbol: "ETH",
decimals: 18u8,
coingecko_coin_id: Some("ethereum"),
},
},
),
(
11155111u64,
ChainInfo {
chain_id: 11155111u64,
name: "Sepolia",
short_name: "sep",
native_currency: CurrencyInfo {
name: "Sepolia Ether",
symbol: "ETH",
decimals: 18u8,
coingecko_coin_id: Some("ethereum"),
},
},
),
];
}
```
Summary of changes
webb-chains-info
that contains the chain information of the supported chains by the relayer.chains.json
fromhttps://chainid.network/chains.json
coingecko_coins_list.json
fromhttps://api.coingecko.com/api/v3/coins/list?include_platform=false
supported_chains.toml
file)Reference issue to close (if applicable)
How to add a new chain?
Just add the Chain Id to the list of chain ids inside the
supported_chains.toml
file and rebuild the relayer. The generated file is not included in the git history, but it gets generated during the build of thewebb-chains-info
crate.Here is an example of the generated file:
Click to view
```rs mod chains { //! Chains Information //! //! This file is generated by the `build.rs` script. //! Do not edit this file manually. //! //! This file contains the information about the chains that are supported by the relayer. //! The information is used to generate the `chains.rs` file and could be used by //! the relayer to get the information about the chains. /// The Chain Information. pub struct ChainInfo { /// Chain Identifier. pub chain_id: u64, /// Chain Name. pub name: &'static str, /// Chain Short Name, usually the ticker. pub short_name: &'static str, /// Chain Native Currency Information. pub native_currency: CurrencyInfo, } /// The Currency Information. pub struct CurrencyInfo { /// Currency Name. pub name: &'static str, /// Currency Symbol. pub symbol: &'static str, /// Currency Decimals. pub decimals: u8, /// Coingecko's Coin Identifier. /// /// This is `None` if the chain is not supported by Coingecko. pub coingecko_coin_id: Option<&'static str>, } pub type ChainsInfo = [(u64, ChainInfo); 6usize]; /// List of all the supported chains. pub const CHAINS_INFO: ChainsInfo = [ ( 5u64, ChainInfo { chain_id: 5u64, name: "Goerli", short_name: "gor", native_currency: CurrencyInfo { name: "Goerli Ether", symbol: "ETH", decimals: 18u8, coingecko_coin_id: Some("ethereum"), }, }, ), ( 1287u64, ChainInfo { chain_id: 1287u64, name: "Moonbase Alpha", short_name: "mbase", native_currency: CurrencyInfo { name: "Dev", symbol: "DEV", decimals: 18u8, coingecko_coin_id: Some("moonbeam"), }, }, ), ( 80001u64, ChainInfo { chain_id: 80001u64, name: "Mumbai", short_name: "maticmum", native_currency: CurrencyInfo { name: "MATIC", symbol: "MATIC", decimals: 18u8, coingecko_coin_id: Some("matic-network"), }, }, ), ( 421613u64, ChainInfo { chain_id: 421613u64, name: "Arbitrum Goerli", short_name: "arb-goerli", native_currency: CurrencyInfo { name: "Arbitrum Goerli Ether", symbol: "AGOR", decimals: 18u8, coingecko_coin_id: Some("arbitrum"), }, }, ), ( 534353u64, ChainInfo { chain_id: 534353u64, name: "Scroll Alpha Testnet", short_name: "scr-alpha", native_currency: CurrencyInfo { name: "Ether", symbol: "ETH", decimals: 18u8, coingecko_coin_id: Some("ethereum"), }, }, ), ( 11155111u64, ChainInfo { chain_id: 11155111u64, name: "Sepolia", short_name: "sep", native_currency: CurrencyInfo { name: "Sepolia Ether", symbol: "ETH", decimals: 18u8, coingecko_coin_id: Some("ethereum"), }, }, ), ]; } ```Code Checklist