Skip to content

Commit

Permalink
save app params, prefer remote params
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime committed Jun 27, 2024
1 parent 4480b31 commit 6249c29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-frogs-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'chrome-extension': patch
---

save app params
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 6249c29

Please sign in to comment.