From 2a74e30fde2edaf7a916ec9c2228b6573d371ee1 Mon Sep 17 00:00:00 2001 From: Max Korsunov Date: Wed, 24 Jul 2024 13:07:53 +0200 Subject: [PATCH] feat: #60: add `websites` to globals (#64) * feat: #60: add `websites` to globals * chore: changesets * fix: #60: add `deprecated` JSDoc to `frontends` field * update globals * Frontends v2 pairing * add changeset --------- Co-authored-by: Gabe Rodriguez --- input/globals.json | 20 ++++++ npm/.changeset/clever-keys-impress.md | 5 ++ npm/src/github.ts | 4 +- npm/src/globals.test.ts | 3 +- npm/src/globals.ts | 8 +-- npm/src/json.ts | 6 +- npm/src/registry.ts | 2 +- npm/src/remote.test.ts | 2 +- registry/globals.json | 20 ++++++ tools/compiler/Cargo.lock | 68 ++++++++----------- tools/compiler/Cargo.toml | 12 ++-- tools/compiler/src/parser.rs | 6 +- tools/compiler/src/processor.rs | 10 ++- tools/compiler/tests/test_copy_globals.rs | 12 +++- .../compiler/tests/test_get_chain_configs.rs | 3 + 15 files changed, 117 insertions(+), 64 deletions(-) create mode 100644 npm/.changeset/clever-keys-impress.md diff --git a/input/globals.json b/input/globals.json index 0538fed..e7f8d02 100644 --- a/input/globals.json +++ b/input/globals.json @@ -41,6 +41,26 @@ "https://penumbra.silentvalidator.com", "https://stake.with.starlingcyber.net" ], + "frontendsV2": [ + { + "name": "Silent Validator", + "url": "https://penumbra.silentvalidator.com", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/silent-validator.png" + } + ] + }, + { + "name": "Starling Cybernetics", + "url": "https://stake.with.starlingcyber.net", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/starling-cybernetics.svg" + } + ] + } + ], "stakingAssetId": { "inner": "KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=" } diff --git a/npm/.changeset/clever-keys-impress.md b/npm/.changeset/clever-keys-impress.md new file mode 100644 index 0000000..be01f46 --- /dev/null +++ b/npm/.changeset/clever-keys-impress.md @@ -0,0 +1,5 @@ +--- +'@penumbra-labs/registry': major +--- + +New frontends data structure w/ images diff --git a/npm/src/github.ts b/npm/src/github.ts index be02d7e..cc6bac5 100644 --- a/npm/src/github.ts +++ b/npm/src/github.ts @@ -1,11 +1,11 @@ -import { Base64AssetId, Chain, Registry, Rpc } from './registry'; +import { Base64AssetId, Chain, Registry, EntityMetadata } from './registry'; import { JsonGlobals, JsonMetadata } from './json'; import { RegistryGlobals } from './globals'; export interface GithubRegistryResponse { chainId: string; ibcConnections: Chain[]; - rpcs: Rpc[]; + rpcs: EntityMetadata[]; assetById: Record; stakingAssetId: Base64AssetId; numeraires: Base64AssetId[]; diff --git a/npm/src/globals.test.ts b/npm/src/globals.test.ts index f616c02..f7b0273 100644 --- a/npm/src/globals.test.ts +++ b/npm/src/globals.test.ts @@ -4,6 +4,7 @@ import { JsonGlobals } from './json'; const testGlobals: JsonGlobals = { rpcs: [{ name: 'rpc1', images: [], url: 'http://rpc1.com' }], + frontendsV2: [{ name: 'frontend1', images: [], url: 'http://example.com' }], frontends: ['frontend1', 'frontend2', 'frontend3'], stakingAssetId: { inner: 'KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=', @@ -14,6 +15,6 @@ describe('Globals', () => { it('versions correctly', async () => { const registry = new RegistryGlobals(testGlobals); const version = await registry.version(); - expect(version).toEqual('7e4059f5641482cfc817222cb5cbd6f62174d578d8473ff4b0a13ef643363b7e'); + expect(version).toEqual('fb3fb559596710d33d3a52946c6280162db1cbca7cc385fe9a3a320ebca40009'); }); }); diff --git a/npm/src/globals.ts b/npm/src/globals.ts index 3afce5e..cf4b1ee 100644 --- a/npm/src/globals.ts +++ b/npm/src/globals.ts @@ -1,16 +1,16 @@ -import { Rpc } from './registry'; +import { EntityMetadata } from './registry'; import { AssetId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; import { JsonGlobals } from './json'; import { sha256Hash } from './utils/sha256'; export class RegistryGlobals { readonly stakingAssetId: AssetId; - readonly rpcs: Rpc[]; - readonly frontends: string[]; + readonly rpcs: EntityMetadata[]; + readonly frontends: EntityMetadata[]; constructor(json: JsonGlobals) { this.rpcs = json.rpcs; - this.frontends = json.frontends; + this.frontends = json.frontendsV2; this.stakingAssetId = AssetId.fromJson(json.stakingAssetId); } diff --git a/npm/src/json.ts b/npm/src/json.ts index 36d3911..8d63c36 100644 --- a/npm/src/json.ts +++ b/npm/src/json.ts @@ -1,6 +1,6 @@ import * as Deimos8 from '../../registry/chains/penumbra-testnet-deimos-8.json'; import * as Penumbra1 from '../../registry/chains/penumbra-1.json'; -import { Base64AssetId, Chain, Rpc } from './registry'; +import { Base64AssetId, Chain, EntityMetadata } from './registry'; export interface JsonRegistry { chainId: string; @@ -10,8 +10,10 @@ export interface JsonRegistry { } export interface JsonGlobals { - rpcs: Rpc[]; + rpcs: EntityMetadata[]; + /** @deprecated use `frontendsV2` instead */ frontends: string[]; + frontendsV2: EntityMetadata[]; stakingAssetId: { inner: string }; } diff --git a/npm/src/registry.ts b/npm/src/registry.ts index 2fe15d8..6b66515 100644 --- a/npm/src/registry.ts +++ b/npm/src/registry.ts @@ -23,7 +23,7 @@ export interface Chain { displayName: string; } -export interface Rpc { +export interface EntityMetadata { name: string; url: string; images: Image[]; diff --git a/npm/src/remote.test.ts b/npm/src/remote.test.ts index 3bd987e..73b3fbf 100644 --- a/npm/src/remote.test.ts +++ b/npm/src/remote.test.ts @@ -55,7 +55,7 @@ describe('RemoteClient', () => { expect(fetchMock.called(endpoint)).toBe(true); expect(registry.stakingAssetId.toJson()).toEqual(GlobalsJson.stakingAssetId); - expect(registry.frontends).toEqual(GlobalsJson.frontends); + expect(registry.frontends).toEqual(GlobalsJson.frontendsV2); expect(registry.rpcs).toEqual(GlobalsJson.rpcs); }); }); diff --git a/registry/globals.json b/registry/globals.json index 3e4dba7..880de21 100644 --- a/registry/globals.json +++ b/registry/globals.json @@ -41,6 +41,26 @@ "https://penumbra.silentvalidator.com", "https://stake.with.starlingcyber.net" ], + "frontendsV2": [ + { + "name": "Silent Validator", + "url": "https://penumbra.silentvalidator.com", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/silent-validator.png" + } + ] + }, + { + "name": "Starling Cybernetics", + "url": "https://stake.with.starlingcyber.net", + "images": [ + { + "png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/starling-cybernetics.svg" + } + ] + } + ], "stakingAssetId": { "inner": "KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=" } diff --git a/tools/compiler/Cargo.lock b/tools/compiler/Cargo.lock index 3f19739..c8a70fe 100644 --- a/tools/compiler/Cargo.lock +++ b/tools/compiler/Cargo.lock @@ -651,8 +651,8 @@ dependencies = [ [[package]] name = "decaf377-fmd" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.0#54d114c668bd8ec78762ac7d682610b356f57fc8" +version = "0.79.2" +source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.2#88a021eb715f21b3990c78e8df42c7c19e618c38" dependencies = [ "ark-ff", "ark-serialize", @@ -1514,9 +1514,9 @@ dependencies = [ [[package]] name = "ics23" -version = "0.11.1" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc3b8be84e7285c73b88effdc3294b552277d6b0ec728ee016c861b7b9a2c19c" +checksum = "18798160736c1e368938ba6967dbcb3c7afb3256b442a5506ba5222eebb68a5a" dependencies = [ "anyhow", "blake2", @@ -1749,13 +1749,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1884,16 +1885,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -2059,8 +2050,8 @@ dependencies = [ [[package]] name = "penumbra-asset" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.0#54d114c668bd8ec78762ac7d682610b356f57fc8" +version = "0.79.2" +source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.2#88a021eb715f21b3990c78e8df42c7c19e618c38" dependencies = [ "anyhow", "ark-ff", @@ -2097,8 +2088,8 @@ dependencies = [ [[package]] name = "penumbra-num" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.0#54d114c668bd8ec78762ac7d682610b356f57fc8" +version = "0.79.2" +source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.2#88a021eb715f21b3990c78e8df42c7c19e618c38" dependencies = [ "anyhow", "ark-ff", @@ -2133,8 +2124,8 @@ dependencies = [ [[package]] name = "penumbra-proto" -version = "0.79.0" -source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.0#54d114c668bd8ec78762ac7d682610b356f57fc8" +version = "0.79.2" +source = "git+https://github.com/penumbra-zone/penumbra.git?tag=v0.79.2#88a021eb715f21b3990c78e8df42c7c19e618c38" dependencies = [ "anyhow", "async-trait", @@ -2815,9 +2806,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -2833,9 +2824,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2 1.0.79", "quote", @@ -2844,9 +2835,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -3177,18 +3168,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2 1.0.79", "quote", @@ -3253,28 +3244,27 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2 1.0.79", "quote", diff --git a/tools/compiler/Cargo.toml b/tools/compiler/Cargo.toml index 3f38e2c..3c876a7 100644 --- a/tools/compiler/Cargo.toml +++ b/tools/compiler/Cargo.toml @@ -4,17 +4,17 @@ version = "1.0.0" edition = "2021" [dependencies] -penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.79.0", package = "penumbra-asset" } -penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.79.0", package = "penumbra-proto", default-features = false } +penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.79.2", package = "penumbra-asset" } +penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.79.2", package = "penumbra-proto", default-features = false } anyhow = "1.0.86" futures = "0.3.30" -serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.118" +serde = { version = "1.0.204", features = ["derive"] } +serde_json = "1.0.120" regress = "0.10.0" reqwest = { version = "0.12.5", features = ["json"] } tempdir = "0.3.7" -thiserror = "1.0.61" -tokio = { version = "1.38.0", features = ["full"] } +thiserror = "1.0.63" +tokio = { version = "1.39.1", features = ["full"] } tracing-subscriber = "0.3.18" tracing = "0.1.40" diff --git a/tools/compiler/src/parser.rs b/tools/compiler/src/parser.rs index 1e08f7e..955294e 100644 --- a/tools/compiler/src/parser.rs +++ b/tools/compiler/src/parser.rs @@ -11,8 +11,10 @@ use crate::processor::Globals; #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct GlobalsInput { - pub rpcs: Vec, + pub rpcs: Vec, + #[deprecated] pub frontends: Vec, + pub frontends_v2: Vec, } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -26,7 +28,7 @@ pub struct ChainConfig { } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Rpc { +pub struct EntityMetadata { pub name: String, pub url: String, pub images: Vec, diff --git a/tools/compiler/src/processor.rs b/tools/compiler/src/processor.rs index c1b155c..37bf520 100644 --- a/tools/compiler/src/processor.rs +++ b/tools/compiler/src/processor.rs @@ -6,8 +6,8 @@ use std::path::Path; use crate::error::{AppError, AppResult}; use crate::github::assetlist_schema::AssetTypeAsset; use crate::parser::{ - copy_globals, get_chain_configs, reset_registry_dir, ChainConfig, GlobalsInput, IbcInput, - Image, Rpc, LOCAL_INPUT_DIR, LOCAL_REGISTRY_DIR, + copy_globals, get_chain_configs, reset_registry_dir, ChainConfig, EntityMetadata, GlobalsInput, + IbcInput, Image, LOCAL_INPUT_DIR, LOCAL_REGISTRY_DIR, }; use crate::querier::query_github_assets; use crate::validator::generate_metadata_from_validators; @@ -44,8 +44,10 @@ impl From for Chain { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Globals { - pub rpcs: Vec, + pub rpcs: Vec, + #[deprecated] pub frontends: Vec, + pub frontends_v2: Vec, pub staking_asset_id: Id, } @@ -53,9 +55,11 @@ impl TryFrom for Globals { type Error = AppError; fn try_from(g: GlobalsInput) -> AppResult { + #![allow(deprecated)] Ok(Globals { rpcs: g.rpcs, frontends: g.frontends, + frontends_v2: g.frontends_v2, staking_asset_id: *STAKING_TOKEN_ASSET_ID, }) } diff --git a/tools/compiler/tests/test_copy_globals.rs b/tools/compiler/tests/test_copy_globals.rs index 6dde5b0..d2f18bb 100644 --- a/tools/compiler/tests/test_copy_globals.rs +++ b/tools/compiler/tests/test_copy_globals.rs @@ -1,5 +1,5 @@ use penumbra_asset::STAKING_TOKEN_ASSET_ID; -use penumbra_registry::parser::{copy_globals, GlobalsInput, Rpc}; +use penumbra_registry::parser::{copy_globals, EntityMetadata, GlobalsInput}; use penumbra_registry::processor::Globals; use std::fs::{self, File}; use std::io::Write; @@ -13,11 +13,17 @@ fn create_file_with_content(dir: &Path, file_name: &str, content: &str) { } #[test] +#[allow(deprecated)] fn test_successful_copy() { let temp_input_dir = TempDir::new("").unwrap(); let temp_output_dir = TempDir::new("").unwrap(); let globals = GlobalsInput { - rpcs: vec![Rpc { + rpcs: vec![EntityMetadata { + name: "cybernetics".to_string(), + url: "http://api.zone".to_string(), + images: vec![], + }], + frontends_v2: vec![EntityMetadata { name: "cybernetics".to_string(), url: "http://api.zone".to_string(), images: vec![], @@ -40,8 +46,8 @@ fn test_successful_copy() { let output_contents = fs::read_to_string(output_path).unwrap(); let output_globals: Globals = serde_json::from_str(&output_contents).unwrap(); - assert_eq!(output_globals.frontends, globals.frontends); assert_eq!(output_globals.rpcs, globals.rpcs); + assert_eq!(output_globals.frontends_v2, globals.frontends_v2); assert_eq!(output_globals.staking_asset_id, *STAKING_TOKEN_ASSET_ID); } diff --git a/tools/compiler/tests/test_get_chain_configs.rs b/tools/compiler/tests/test_get_chain_configs.rs index a37682c..f54e8ff 100644 --- a/tools/compiler/tests/test_get_chain_configs.rs +++ b/tools/compiler/tests/test_get_chain_configs.rs @@ -20,6 +20,7 @@ fn test_get_chain_configs_reads_configs_correctly() { let config_content = serde_json::json!({ "chainId": "test-chain-1", "rpcs": [], + "frontendsV2": [], "frontends": [], "ibcConnections": [], "validators": [], @@ -41,6 +42,7 @@ fn test_get_chain_configs_reads_multiple_configs_correctly() { let config_content_1 = serde_json::json!({ "chainId": "test-chain-1", "rpcs": [], + "frontendsV2": [], "frontends": [], "ibcConnections": [], "validators": [], @@ -58,6 +60,7 @@ fn test_get_chain_configs_reads_multiple_configs_correctly() { let config_content_2 = serde_json::json!({ "chainId": "test-chain-2", "rpcs": [], + "frontendsV2": [], "frontends": [], "ibcConnections": [], "validators": [],