tangle-network / relayer

🕸️ The Webb Relayer Network
https://webb-tools.github.io/relayer/
Apache License 2.0
22 stars 13 forks source link

[feat] Add Webb Chains Info crate #416

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Summary of changes

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 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"), }, }, ), ]; } ```

Code Checklist