Skip to content

Commit

Permalink
registry: default frontend selection (#270)
Browse files Browse the repository at this point in the history
* default frontend selection

* bump registry version to v13.0

* downgrade to patch version 12.0.1

* linting

* upgrade registry dep to minor version 12.1.0

* lockfile
  • Loading branch information
TalDerei authored Jan 23, 2025
1 parent bc5fabe commit 48245aa
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@bufbuild/protobuf": "^1.x",
"@connectrpc/connect": "^1.x",
"@connectrpc/connect-web": "^1.x",
"@penumbra-labs/registry": "^12.0.0",
"@penumbra-labs/registry": "^12.1.0",
"@penumbra-zone/bech32m": "11.0.0",
"@penumbra-zone/client": "22.0.0",
"@penumbra-zone/crypto-web": "32.0.0",
Expand Down
20 changes: 16 additions & 4 deletions apps/extension/src/routes/page/onboarding/password/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Location } from 'react-router-dom';
import { LocationState, SEED_PHRASE_ORIGIN } from './types';
import { PagePath } from '../../paths';
import { usePageNav } from '../../../../utils/navigate';
import { ChainRegistryClient } from '@penumbra-labs/registry';
import { ChainRegistryClient, EntityMetadata } from '@penumbra-labs/registry';
import { sample } from 'lodash';
import { createPromiseClient } from '@connectrpc/connect';
import { createGrpcWebTransport } from '@connectrpc/connect-web';
Expand Down Expand Up @@ -34,8 +34,20 @@ const DEFAULT_TRANSPORT_OPTS = { timeoutMs: 5000 };
export const setOnboardingValuesInStorage = async (seedPhraseOrigin: SEED_PHRASE_ORIGIN) => {
const chainRegistryClient = new ChainRegistryClient();
const { rpcs, frontends } = await chainRegistryClient.remote.globals();
const randomFrontend = sample(frontends);
if (!randomFrontend) {

// Define a canconcial default frontend
const defaultFront = 'Radiant Commons';

let selectedFrontend: EntityMetadata | undefined = frontends.find(
frontend => frontend.name === defaultFront,
);

// If default frontend is not found, randomly select a frontend
if (!selectedFrontend) {
selectedFrontend = sample(frontends);
}

if (!selectedFrontend) {
throw new Error('Registry missing frontends');
}

Expand All @@ -57,7 +69,7 @@ export const setOnboardingValuesInStorage = async (seedPhraseOrigin: SEED_PHRASE
const { numeraires } = await chainRegistryClient.remote.get(appParameters.chainId);

await localExtStorage.set('grpcEndpoint', rpc);
await localExtStorage.set('frontendUrl', randomFrontend.url);
await localExtStorage.set('frontendUrl', selectedFrontend.url);
await localExtStorage.set(
'numeraires',
numeraires.map(n => n.toJsonString()),
Expand Down
2 changes: 1 addition & 1 deletion packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"peerDependencies": {
"@bufbuild/protobuf": "^1.x",
"@penumbra-labs/registry": "^12.0.0",
"@penumbra-labs/registry": "^12.1.0",
"@penumbra-zone/bech32m": "11.0.0",
"@penumbra-zone/crypto-web": "32.0.0",
"@penumbra-zone/getters": "21.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@penumbra-labs/registry": "^12.0.0",
"@penumbra-labs/registry": "^12.1.0",
"@penumbra-zone/bech32m": "11.0.0",
"@penumbra-zone/getters": "21.0.0",
"@penumbra-zone/perspective": "42.0.0",
Expand Down
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

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

0 comments on commit 48245aa

Please sign in to comment.