Skip to content

Commit

Permalink
fix: fix balances not displaying on initial connection (anoma#581)
Browse files Browse the repository at this point in the history
It was failing because there was no chain config present in the store.

Fixes anoma#575.
  • Loading branch information
emccorson committed Jan 24, 2024
1 parent e9bfcfb commit ae1f412
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/extension/src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ const init = new Promise<void>(async (resolve) => {
cryptoMemory,
broadcaster
);
const sdkService = new SdkService(chainStore);
const chainsService = new ChainsService(chainStore, broadcaster);
const sdkService = new SdkService(chainsService);
const keyRingService = new KeyRingService(
vaultService,
sdkService,
Expand Down
8 changes: 3 additions & 5 deletions apps/extension/src/background/sdk/service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { Query, Sdk } from "@namada/shared";
import { KVStore } from "@namada/storage";
import { Chain } from "@namada/types";
import { CHAINS_KEY } from "background/chains";
import { ChainsService } from "background/chains";

export class SdkService {
constructor(protected readonly chainStore: KVStore<Chain>) { }
constructor(protected readonly chainsService: ChainsService) {}

private async _getRpc(): Promise<string> {
// Pull chain config from store, as the RPC value may have changed:
const chain = await this.chainStore.get(CHAINS_KEY);
const chain = await this.chainsService.getChain();

if (!chain) {
throw new Error("No chain found!");
Expand Down
6 changes: 4 additions & 2 deletions apps/extension/src/test/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
init as initApprovals,
} from "../background/approvals";

import { ChainsService } from "background/chains";
import { LedgerService } from "background/ledger";
import { SdkService } from "background/sdk";
import { Namada } from "provider";
Expand All @@ -42,7 +43,7 @@ const cryptoMemory = require("@namada/crypto").__wasm.memory;
export class KVStoreMock<T> implements KVStore<T> {
private storage: { [key: string]: T | null } = {};

constructor(readonly _prefix: string) { }
constructor(readonly _prefix: string) {}

get<U extends T>(key: string): Promise<U | undefined> {
return new Promise((resolve) => {
Expand Down Expand Up @@ -106,7 +107,8 @@ export const init = async (): Promise<{
sessionStore,
cryptoMemory
);
const sdkService = new SdkService(chainStore);
const chainsService = new ChainsService(chainStore, broadcaster);
const sdkService = new SdkService(chainsService);

const keyRingService = new KeyRingService(
vaultService,
Expand Down

0 comments on commit ae1f412

Please sign in to comment.