Skip to content

Commit

Permalink
custom grpcEndpoint migration (#994)
Browse files Browse the repository at this point in the history
* custom grpcEndpoint migration

* lint
  • Loading branch information
Valentine1898 authored Apr 26, 2024
1 parent fdd4303 commit 41bf56c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/extension/src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ import {
import { fvkCtx } from '@penumbra-zone/services/ctx/full-viewing-key';
import { WalletJson } from '@penumbra-zone/types/src/wallet';

/**
This fixes an issue where some users do not have 'grpcEndpoint' set after they have finished onboarding
*/
const fixEmptyGrpcEndpointAfterOnboarding = async () => {
//TODO change to mainnet default RPC
const DEFAULT_GRPC_URL = 'https://grpc.testnet.penumbra.zone';
const grpcEndpoint = await localExtStorage.get('grpcEndpoint');
const wallets = await localExtStorage.get('wallets');
if (!grpcEndpoint && wallets[0]) {
await localExtStorage.set('grpcEndpoint', DEFAULT_GRPC_URL);
}
};

/**
* When a user first onboards with the extension, they won't have chosen a gRPC
* endpoint yet. So we'll wait until they've chosen one to start trying to make
Expand Down Expand Up @@ -120,6 +133,7 @@ const getServiceHandler = async () => {
});
};

await fixEmptyGrpcEndpointAfterOnboarding();
await waitUntilGrpcEndpointExists();
const handler = await getServiceHandler();
CRSessionManager.init(PRAX, handler);

0 comments on commit 41bf56c

Please sign in to comment.