Skip to content

Commit

Permalink
save app params
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime committed Jun 27, 2024
1 parent 4480b31 commit 2fe1e7d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions apps/extension/src/wallet-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,17 @@ export const startWalletServices = async () => {
* local storage.
*/
const getChainId = async (baseUrl: string) => {
const localChainId = await localExtStorage
.get('params')
.then(json => json && AppParameters.fromJsonString(json).chainId);
const params =
(await createPromiseClient(AppService, createGrpcWebTransport({ baseUrl })).appParameters({}))
.appParameters ??
(await localExtStorage
.get('params')
.then(jsonParams => (jsonParams ? AppParameters.fromJsonString(jsonParams) : undefined)));

if (localChainId) return localChainId;
if (params?.chainId) void localExtStorage.set('params', params.toJsonString());
else throw new Error('No chainId available');

const remoteChainId = (
await createPromiseClient(AppService, createGrpcWebTransport({ baseUrl })).appParameters({})
).appParameters?.chainId;

if (remoteChainId) return remoteChainId;

throw new Error('No chainId available');
return params.chainId;
};

/**
Expand Down

0 comments on commit 2fe1e7d

Please sign in to comment.