Skip to content

Commit

Permalink
fix getChainId startup request (#296)
Browse files Browse the repository at this point in the history
Co-authored-by: turbocrime <[email protected]>
  • Loading branch information
turbocrime and turbocrime authored Feb 19, 2025
1 parent f921a3b commit 30f0b0a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/extension/src/wallet-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ export const startWalletServices = async () => {
};

/**
* Get the chain id from local storage, or the rpc endpoint if no chain id is in
* local storage.
* Get chainId from the rpc endpoint, or fall back to chainId from storage.
*
* It's possible that the remote endpoint may suddenly serve a new chainId.
* @see https://github.com/prax-wallet/prax/pull/65
*/
const getChainId = async (baseUrl: string) => {
const serviceClient = createPromiseClient(AppService, createGrpcWebTransport({ baseUrl }));
const params =
(await createPromiseClient(AppService, createGrpcWebTransport({ baseUrl })).appParameters({}))
.appParameters ??
(await serviceClient.appParameters({}).then(
({ appParameters }) => appParameters,
() => undefined,
)) ??
(await localExtStorage
.get('params')
.then(jsonParams => (jsonParams ? AppParameters.fromJsonString(jsonParams) : undefined)));
Expand Down

0 comments on commit 30f0b0a

Please sign in to comment.