diff --git a/input/penumbra-testnet-deimos-6/images/penumbra-favicon.png b/images/penumbra-favicon.png similarity index 100% rename from input/penumbra-testnet-deimos-6/images/penumbra-favicon.png rename to images/penumbra-favicon.png diff --git a/input/penumbra-testnet-deimos-6/images/pizza.svg b/images/pizza.svg similarity index 100% rename from input/penumbra-testnet-deimos-6/images/pizza.svg rename to images/pizza.svg diff --git a/input/penumbra-testnet-deimos-6/images/test-usd.svg b/images/test-usd.svg similarity index 100% rename from input/penumbra-testnet-deimos-6/images/test-usd.svg rename to images/test-usd.svg diff --git a/input/penumbra-testnet-deimos-6/images/um.svg b/images/um.svg similarity index 100% rename from input/penumbra-testnet-deimos-6/images/um.svg rename to images/um.svg diff --git a/input/penumbra-testnet-deimos-6.json b/input/penumbra-testnet-deimos-6.json new file mode 100644 index 0000000..8e3f840 --- /dev/null +++ b/input/penumbra-testnet-deimos-6.json @@ -0,0 +1,203 @@ +{ + "chainId": "penumbra-testnet-deimos-6", + "rpcs": [ + { + "name": "Penumbra Labs Testnet RPC", + "url": "https://grpc.testnet.penumbra.zone", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png" + } + ] + } + ], + "ibcConnections": [ + { + "chainId": "osmo-test-5", + "ibcChannel": "channel-0", + "addressPrefix": "osmo", + "cosmosRegistryDir": "testnets/osmosistestnet" + }, + { + "chainId": "grand-1", + "ibcChannel": "channel-3", + "addressPrefix": "noble", + "cosmosRegistryDir": "testnets/nobletestnet" + } + ], + "nativeAssets": [ + { + "denomUnits": [ + { + "denom": "penumbra", + "exponent": 6 + }, + { + "denom": "mpenumbra", + "exponent": 3 + }, + { + "denom": "upenumbra" + } + ], + "base": "upenumbra", + "display": "penumbra", + "symbol": "UM", + "penumbraAssetId": { + "inner": "KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=" + }, + "images": [ + { + "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/um.svg" + } + ] + }, + { + "denomUnits": [ + { + "denom": "gm", + "exponent": 6 + }, + { + "denom": "mgm", + "exponent": 3 + }, + { + "denom": "ugm" + } + ], + "base": "ugm", + "display": "gm", + "symbol": "GM", + "penumbraAssetId": { + "inner": "HW2Eq3UZVSBttoUwUi/MUtE7rr2UU7/UH500byp7OAc=" + } + }, + { + "denomUnits": [ + { + "denom": "gn", + "exponent": 6 + }, + { + "denom": "mgn", + "exponent": 3 + }, + { + "denom": "ugn" + } + ], + "base": "ugn", + "display": "gn", + "symbol": "GN", + "penumbraAssetId": { + "inner": "nwPDkQq3OvLnBwGTD+nmv1Ifb2GEmFCgNHrU++9BsRE=" + } + }, + { + "denomUnits": [ + { + "denom": "test_usd", + "exponent": 18 + }, + { + "denom": "wtest_usd" + } + ], + "base": "wtest_usd", + "display": "test_usd", + "symbol": "TestUSD", + "penumbraAssetId": { + "inner": "reum7wQmk/owgvGMWMZn/6RFPV24zIKq3W6In/WwZgg=" + }, + "images": [ + { + "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/test-usd.svg" + } + ] + }, + { + "denomUnits": [ + { + "denom": "cube" + } + ], + "base": "cube", + "display": "cube", + "symbol": "CUBE", + "penumbraAssetId": { + "inner": "6KBVsPINa8gWSHhfH+kAFJC4afEJA3EtuB2HyCqJUws=" + } + }, + { + "denomUnits": [ + { + "denom": "pizza" + } + ], + "base": "pizza", + "display": "pizza", + "symbol": "PIZZA", + "penumbraAssetId": { + "inner": "nDjzm+ldIrNMJha1anGMDVxpA5cLCPnUYQ1clmHF1gw=" + }, + "images": [ + { + "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/pizza.svg" + } + ] + }, + { + "denomUnits": [ + { + "denom": "delegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", + "exponent": 6 + }, + { + "denom": "mdelegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", + "exponent": 3 + }, + { + "denom": "udelegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20" + } + ], + "base": "udelegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", + "display": "delegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", + "penumbraAssetId": { + "inner": "CwpUYIdQ9H5Dnf3oQ1l7ISeVMVahWbVNNvMA0dBSdwI=" + }, + "symbol": "Delegation (Penumbra Labs CI 1)", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png" + } + ] + }, + { + "denomUnits": [ + { + "denom": "delegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", + "exponent": 6 + }, + { + "denom": "mdelegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", + "exponent": 3 + }, + { + "denom": "udelegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050" + } + ], + "base": "udelegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", + "display": "delegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", + "penumbraAssetId": { + "inner": "qUn70lKZ3qQlCT5gj5sakux4daiTPKj0AN6ZuuFldQU=" + }, + "symbol": "Delegation (Penumbra Labs CI 2)", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png" + } + ] + } + ] +} \ No newline at end of file diff --git a/input/penumbra-testnet-deimos-6/ibc-assets.json b/input/penumbra-testnet-deimos-6/ibc-assets.json deleted file mode 100644 index 8ecbd11..0000000 --- a/input/penumbra-testnet-deimos-6/ibc-assets.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "chainId": "osmo-test-5", - "ibcChannel": "channel-0", - "addressPrefix": "osmo", - "cosmosRegistryDir": "testnets/osmosistestnet" - }, - { - "chainId": "grand-1", - "ibcChannel": "channel-3", - "addressPrefix": "noble", - "cosmosRegistryDir": "testnets/nobletestnet" - } -] \ No newline at end of file diff --git a/input/penumbra-testnet-deimos-6/native-assets.json b/input/penumbra-testnet-deimos-6/native-assets.json deleted file mode 100644 index ef92563..0000000 --- a/input/penumbra-testnet-deimos-6/native-assets.json +++ /dev/null @@ -1,175 +0,0 @@ -[ - { - "denomUnits": [ - { - "denom": "penumbra", - "exponent": 6 - }, - { - "denom": "mpenumbra", - "exponent": 3 - }, - { - "denom": "upenumbra" - } - ], - "base": "upenumbra", - "display": "penumbra", - "symbol": "UM", - "penumbraAssetId": { - "inner": "KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=" - }, - "images": [ - { - "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/um.svg" - } - ] - }, - { - "denomUnits": [ - { - "denom": "gm", - "exponent": 6 - }, - { - "denom": "mgm", - "exponent": 3 - }, - { - "denom": "ugm" - } - ], - "base": "ugm", - "display": "gm", - "symbol": "GM", - "penumbraAssetId": { - "inner": "HW2Eq3UZVSBttoUwUi/MUtE7rr2UU7/UH500byp7OAc=" - } - }, - { - "denomUnits": [ - { - "denom": "gn", - "exponent": 6 - }, - { - "denom": "mgn", - "exponent": 3 - }, - { - "denom": "ugn" - } - ], - "base": "ugn", - "display": "gn", - "symbol": "GN", - "penumbraAssetId": { - "inner": "nwPDkQq3OvLnBwGTD+nmv1Ifb2GEmFCgNHrU++9BsRE=" - } - }, - { - "denomUnits": [ - { - "denom": "test_usd", - "exponent": 18 - }, - { - "denom": "wtest_usd" - } - ], - "base": "wtest_usd", - "display": "test_usd", - "symbol": "TestUSD", - "penumbraAssetId": { - "inner": "reum7wQmk/owgvGMWMZn/6RFPV24zIKq3W6In/WwZgg=" - }, - "images": [ - { - "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/test-usd.svg" - } - ] - }, - { - "denomUnits": [ - { - "denom": "cube" - } - ], - "base": "cube", - "display": "cube", - "symbol": "CUBE", - "penumbraAssetId": { - "inner": "6KBVsPINa8gWSHhfH+kAFJC4afEJA3EtuB2HyCqJUws=" - } - }, - { - "denomUnits": [ - { - "denom": "pizza" - } - ], - "base": "pizza", - "display": "pizza", - "symbol": "PIZZA", - "penumbraAssetId": { - "inner": "nDjzm+ldIrNMJha1anGMDVxpA5cLCPnUYQ1clmHF1gw=" - }, - "images": [ - { - "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/pizza.svg" - } - ] - }, - { - "denomUnits": [ - { - "denom": "delegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", - "exponent": 6 - }, - { - "denom": "mdelegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", - "exponent": 3 - }, - { - "denom": "udelegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20" - } - ], - "base": "udelegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", - "display": "delegation_penumbravalid18nkv0r3sfp2seleq6du5kt3mhfce3k6cqm77kj2e7mhakmyw9v9qx42a20", - "penumbraAssetId": { - "inner": "CwpUYIdQ9H5Dnf3oQ1l7ISeVMVahWbVNNvMA0dBSdwI=" - }, - "symbol": "Delegation (Penumbra Labs CI 1)", - "images": [ - { - "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/penumbra-favicon.png" - } - ] - }, - { - "denomUnits": [ - { - "denom": "delegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", - "exponent": 6 - }, - { - "denom": "mdelegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", - "exponent": 3 - }, - { - "denom": "udelegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050" - } - ], - "base": "udelegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", - "display": "delegation_penumbravalid1qfxldejdhanmu302kcn5fm98q5d7d2upfhzqhaz95hyjdn82pqysqfq050", - "penumbraAssetId": { - "inner": "qUn70lKZ3qQlCT5gj5sakux4daiTPKj0AN6ZuuFldQU=" - }, - "symbol": "Delegation (Penumbra Labs CI 2)", - "images": [ - { - "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/penumbra-favicon.png" - } - ] - } -] \ No newline at end of file diff --git a/registry/penumbra-testnet-deimos-6.json b/registry/penumbra-testnet-deimos-6.json index 9a8df50..388b8d6 100644 --- a/registry/penumbra-testnet-deimos-6.json +++ b/registry/penumbra-testnet-deimos-6.json @@ -1,6 +1,6 @@ { "chainId": "penumbra-testnet-deimos-6", - "ibc": [ + "ibcConfig": [ { "addressPrefix": "osmo", "chainId": "osmo-test-5", @@ -12,6 +12,18 @@ "ibcChannel": "channel-3" } ], + "rpcs": [ + { + "name": "Penumbra Labs Testnet RPC", + "url": "https://grpc.testnet.penumbra.zone", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png", + "svg": null + } + ] + } + ], "assetById": { "+jDercxZxs90BjC91PrWyA53/p7uN3ZcSJj3N0mHjhI=": { "description": "USDLR is a fiat-backed stablecoin issued by Stable. Stable pays DeFi protocols who distribute USDLR.", @@ -97,7 +109,7 @@ }, "images": [ { - "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/penumbra-favicon.png" + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png" } ] }, @@ -187,7 +199,7 @@ }, "images": [ { - "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/um.svg" + "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/um.svg" } ] }, @@ -249,7 +261,7 @@ }, "images": [ { - "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/pizza.svg" + "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/pizza.svg" } ] }, @@ -296,7 +308,7 @@ }, "images": [ { - "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/penumbra-favicon.png" + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png" } ] }, @@ -342,7 +354,7 @@ }, "images": [ { - "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/input/penumbra-testnet-deimos-6/images/test-usd.svg" + "svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/test-usd.svg" } ] } diff --git a/tools/compiler/src/parser.rs b/tools/compiler/src/parser.rs index 70fcec6..ae28d8d 100644 --- a/tools/compiler/src/parser.rs +++ b/tools/compiler/src/parser.rs @@ -1,7 +1,6 @@ use std::fs; use std::path::Path; -use anyhow::anyhow; use penumbra_asset::asset::Metadata; use serde::{Deserialize, Serialize}; @@ -11,13 +10,27 @@ use crate::error::AppResult; #[serde(rename_all = "camelCase")] pub struct ChainConfig { pub chain_id: String, - pub ibc_assets: Vec, + pub rpcs: Vec, + pub ibc_connections: Vec, pub native_assets: Vec, } +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Rpc { + pub name: String, + pub url: String, + pub images: Vec, +} + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Image { + pub png: Option, + pub svg: Option, +} + #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct IbcConfig { +pub struct IbcConnection { pub chain_id: String, pub ibc_channel: String, pub address_prefix: String, @@ -26,54 +39,36 @@ pub struct IbcConfig { pub const LOCAL_REGISTRY_DIR: &str = "../../registry"; const LOCAL_INPUT_DIR: &str = "../../input"; -const IBC_ASSETS_FILE: &str = "ibc-assets.json"; -const NATIVE_ASSETS_FILE: &str = "native-assets.json"; /// Retrieves a list of `ChainConfig` objects representing the configuration for various chains. -/// This function assumes a specific directory structure and set of files: +/// This function assumes a specific directory structure and configs inside: /// /// input/ -/// ├── osmosis-test-5/ -/// │ ├── ibc-assets.json -/// │ └── native-assets.json -/// └── mars-1/ -/// ├── ibc-assets.json -/// └── native-assets.json -/// +/// ├── penumbra-testnet-deimos-6.json +/// └── mars-1.json pub fn get_chain_configs() -> AppResult> { + // Clear registry output dir let registry_dir = Path::new(LOCAL_REGISTRY_DIR); if registry_dir.exists() { fs::remove_dir_all(registry_dir)?; } fs::create_dir_all(registry_dir)?; - let chain_dirs = fs::read_dir(LOCAL_INPUT_DIR)?; - Ok(chain_dirs + let chain_configs = fs::read_dir(LOCAL_INPUT_DIR)?; + Ok(chain_configs .into_iter() - .map(|dir_entry| -> AppResult { - let chain_path = dir_entry?.path(); - let chain_id = chain_path - .file_name() - .ok_or_else(|| anyhow!("Failed to get the file name from the path"))? - .to_str() - .ok_or_else(|| anyhow!("Failed to convert OsStr to str"))? - .to_owned(); - - // Read the IBC assets and native assets from their respective JSON files - let ibc_assets_path = chain_path.join(IBC_ASSETS_FILE); - let native_assets_path = chain_path.join(NATIVE_ASSETS_FILE); - - // You might need to adjust the logic here if the files can be optional - let ibc_assets_contents = fs::read_to_string(ibc_assets_path)?; - let native_assets_contents = fs::read_to_string(native_assets_path)?; - - let chain_config = ChainConfig { - chain_id, - ibc_assets: serde_json::from_str(&ibc_assets_contents)?, - native_assets: serde_json::from_str(&native_assets_contents)?, - }; + .map(|input| -> AppResult { + let input_path = input?.path(); + let input_contents = fs::read_to_string(input_path)?; + let chain_config = serde_json::from_str(&input_contents)?; Ok(chain_config) }) - .filter_map(|result| result.ok()) + .filter_map(|result| match result { + Ok(config) => Some(config), + Err(e) => { + tracing::info!("{}", e.to_string()); + None + } + }) .collect()) } diff --git a/tools/compiler/src/processor.rs b/tools/compiler/src/processor.rs index a6632ec..91bf84b 100644 --- a/tools/compiler/src/processor.rs +++ b/tools/compiler/src/processor.rs @@ -10,20 +10,20 @@ use tokio::task; use crate::error::AppResult; use crate::github::assetlist_schema::AssetTypeAsset; -use crate::parser::{get_chain_configs, ChainConfig, IbcConfig, LOCAL_REGISTRY_DIR}; +use crate::parser::{get_chain_configs, ChainConfig, IbcConnection, Rpc, LOCAL_REGISTRY_DIR}; use crate::querier::query_github_assets; #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct IbcChains { +pub struct IbcConfig { pub address_prefix: String, pub chain_id: String, pub ibc_channel: String, } -impl From for IbcChains { - fn from(config: IbcConfig) -> Self { - IbcChains { +impl From for IbcConfig { + fn from(config: IbcConnection) -> Self { + IbcConfig { address_prefix: config.address_prefix, chain_id: config.chain_id, ibc_channel: config.ibc_channel, @@ -35,9 +35,9 @@ impl From for IbcChains { #[serde(rename_all = "camelCase")] pub struct Registry { pub chain_id: String, - pub ibc: Vec, - // Use a BTreeMap to have sorted (deterministic) output - pub asset_by_id: BTreeMap, + pub ibc_config: Vec, + pub rpcs: Vec, + pub asset_by_id: BTreeMap, // Using a BTreeMap to have sorted (deterministic) output } pub async fn generate_registry() -> AppResult<()> { @@ -66,7 +66,7 @@ pub async fn generate_registry() -> AppResult<()> { /// Given `ibc_data` describing a channel and `source_asset` on the source chain, /// compute the metadata for the asset when it is transported along the channel onto a Penumbra chain. fn transport_metadata_along_channel( - ibc_data: &IbcConfig, + ibc_data: &IbcConnection, source_asset: Metadata, ) -> AppResult { // The `Metadata` structure doesn't allow modifying the internals, so drop to raw proto data @@ -128,8 +128,9 @@ async fn process_chain_config(chain_config: ChainConfig) -> AppResult Ok(Registry { chain_id: chain_config.chain_id, - ibc: chain_config - .ibc_assets + rpcs: chain_config.rpcs, + ibc_config: chain_config + .ibc_connections .into_iter() .map(Into::into) .collect(), diff --git a/tools/compiler/src/querier.rs b/tools/compiler/src/querier.rs index dd9f627..5d3b89e 100644 --- a/tools/compiler/src/querier.rs +++ b/tools/compiler/src/querier.rs @@ -2,18 +2,18 @@ use reqwest::Client; use crate::error::AppResult; use crate::github::types::{AssetList, GitHubContent}; -use crate::parser::{ChainConfig, IbcConfig}; +use crate::parser::{ChainConfig, IbcConnection}; const GITHUB_API_BASE_URL: &str = "https://api.github.com/repos/cosmos/chain-registry/contents"; /// Queries asset metadata from the cosmos asset registry pub async fn query_github_assets( chain_config: &ChainConfig, -) -> AppResult> { +) -> AppResult> { let client = Client::new(); let mut futures = Vec::new(); - for ibc_asset in &chain_config.ibc_assets { + for ibc_asset in &chain_config.ibc_connections { let url = format!( "{}/{}/assetlist.json", GITHUB_API_BASE_URL, ibc_asset.cosmos_registry_dir @@ -29,8 +29,8 @@ pub async fn query_github_assets( async fn fetch_asset_list( client: &Client, url: String, - ibc_asset: &IbcConfig, -) -> AppResult<(IbcConfig, AssetList)> { + ibc_asset: &IbcConnection, +) -> AppResult<(IbcConnection, AssetList)> { let res = client .get(&url) .header(reqwest::header::USER_AGENT, "request")