Skip to content

Commit

Permalink
Make rpcs+frontends global values (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 authored Jun 6, 2024
1 parent 1327472 commit 1d61fc5
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 161 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{
"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"
}
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
],
"ibcConnections": [
{
"displayName": "Osmosis",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{
"chainId": "penumbra-testnet-deimos-7",
"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"
}
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
],
"ibcConnections": [
{
"displayName": "Osmosis",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{
"chainId": "penumbra-testnet-deimos-8",
"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"
}
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
],
"ibcConnections": [
{
"displayName": "Osmosis",
Expand Down
16 changes: 16 additions & 0 deletions input/globals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"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"
}
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
]
}
6 changes: 6 additions & 0 deletions npm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @penumbra-labs/registry

## 8.0.0

### Major Changes

- New API for global rpcs & frontends

## 7.7.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@penumbra-labs/registry",
"version": "7.7.0",
"version": "8.0.0",
"description": "Chain and asset registry for Penumbra",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
6 changes: 5 additions & 1 deletion npm/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deriveTestnetChainIdFromPreview, isTestnetPreviewChainId } from './utils/testnet-parser';
import { Registry } from './registry';
import { allJsonRegistries } from './json';
import { allJsonRegistries, registryGlobals, RegistryGlobals } from './json';

export class ChainRegistryClient {
get(chainId: string): Registry {
Expand All @@ -13,6 +13,10 @@ export class ChainRegistryClient {
return new Registry(jsonRegistry);
}

globals(): RegistryGlobals {
return registryGlobals;
}

version() {
return {
commit: __COMMIT_HASH__,
Expand Down
16 changes: 11 additions & 5 deletions npm/src/json.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import * as Deimos6 from '../../registry/penumbra-testnet-deimos-6.json';
import * as Deimos7 from '../../registry/penumbra-testnet-deimos-7.json';
import * as Deimos8 from '../../registry/penumbra-testnet-deimos-8.json';
import * as Deimos6 from '../../registry/chains/penumbra-testnet-deimos-6.json';
import * as Deimos7 from '../../registry/chains/penumbra-testnet-deimos-7.json';
import * as Deimos8 from '../../registry/chains/penumbra-testnet-deimos-8.json';
import * as GlobalsJson from '../../registry/globals.json';

import { Base64AssetId, Chain, Rpc } from './registry';

export interface RegistryGlobals {
rpcs: Rpc[];
frontends: string[];
}

export interface JsonRegistry {
chainId: string;
ibcConnections: Chain[];
rpcs: Rpc[];
frontends: string[];
assetById: Record<Base64AssetId, JsonMetadata>;
stakingAssetId: Base64AssetId;
numeraires: Base64AssetId[];
Expand Down Expand Up @@ -44,3 +48,5 @@ export const allJsonRegistries: Record<string, JsonRegistry> = {
'penumbra-testnet-deimos-7': Deimos7,
'penumbra-testnet-deimos-8': Deimos8,
};

export const registryGlobals = GlobalsJson;
18 changes: 0 additions & 18 deletions npm/src/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ const testRegistry: JsonRegistry = {
],
},
],
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',
},
],
},
],
frontends: ['https://app.testnet.penumbra.zone'],
assetById: {
'KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=': {
denomUnits: [
Expand Down Expand Up @@ -106,10 +94,4 @@ describe('Registry', () => {
const res = registry.getAllAssets();
expect(res.length).toEqual(2);
});

it('frontends are accessible', () => {
const registry = new Registry(testRegistry);
expect(registry.frontends.length).toEqual(1);
expect(registry.frontends[0]).toEqual('https://app.testnet.penumbra.zone');
});
});
4 changes: 0 additions & 4 deletions npm/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export interface Image {
export class Registry {
public readonly chainId: string;
public readonly ibcConnections: Chain[];
public readonly rpcs: Rpc[];
public readonly frontends: string[];
public readonly stakingAssetId: AssetId;
public readonly numeraires: AssetId[];

Expand All @@ -46,8 +44,6 @@ export class Registry {
constructor(r: JsonRegistry) {
this.chainId = r.chainId;
this.ibcConnections = r.ibcConnections;
this.rpcs = r.rpcs;
this.frontends = r.frontends;
this.assetById = mapObjectValues(r.assetById, jsonMetadata =>
Metadata.fromJson(jsonMetadata as unknown as JsonValue),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
],
"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"
}
]
}
],
"assetById": {
"+jDercxZxs90BjC91PrWyA53/p7uN3ZcSJj3N0mHjhI=": {
"description": "USDLR is a fiat-backed stablecoin issued by Stable. Stable pays DeFi protocols who distribute USDLR.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
],
"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"
}
]
}
],
"assetById": {
"+jDercxZxs90BjC91PrWyA53/p7uN3ZcSJj3N0mHjhI=": {
"description": "USDLR is a fiat-backed stablecoin issued by Stable. Stable pays DeFi protocols who distribute USDLR.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
],
"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"
}
]
}
],
"assetById": {
"/5AHh95RAybBbUhQ5zXMWCvstH4rRK/5KMVIVGQltAw=": {
"denomUnits": [
Expand Down
16 changes: 16 additions & 0 deletions registry/globals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"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"
}
]
}
],
"frontends": [
"https://app.testnet.penumbra.zone"
]
}
16 changes: 8 additions & 8 deletions tools/compiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tools/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "1.0.0"
edition = "2021"

[dependencies]
penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.77.1", package = "penumbra-asset" }
penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.77.1", package = "penumbra-proto", default-features = false }
penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.77.2", package = "penumbra-asset" }
penumbra-proto = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.77.2", package = "penumbra-proto", default-features = false }

anyhow = "1.0.86"
futures = "0.3.30"
Expand Down
Loading

0 comments on commit 1d61fc5

Please sign in to comment.