Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const walletFactory: WalletFactory<Metadata, Metadata> = {
};

const storesFactory: StoresFactory = {
create: ({ name }) => storage.createPouchDbWalletStores(name, { logger })
create: async ({ name }) => storage.createPouchDbWalletStores(name, { logger })
};

const walletRepository = new WalletRepository<Metadata, Metadata>({
Expand Down
8 changes: 4 additions & 4 deletions packages/web-extension/src/walletManager/walletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class WalletManager<WalletMetadata extends { name: string }, AccountMetad
this.#activeWalletProps = props;

const walletStoreId = getWalletStoreId(walletId, chainId, accountIndex);
const stores = this.#getStores(walletStoreId);
const stores = await this.#getStores(walletStoreId);

const witnesser = this.#buildWitnesser(activeWallet, walletId, chainId, accountIndex);

Expand Down Expand Up @@ -202,10 +202,10 @@ export class WalletManager<WalletMetadata extends { name: string }, AccountMetad
}

/** Gets store if wallet was activated previously or creates one when wallet is activated for the first time. */
#getStores(walletStoreName: string): storage.WalletStores {
async #getStores(walletStoreName: string): Promise<storage.WalletStores> {
let stores = this.#walletStores.get(walletStoreName);
if (!stores) {
stores = this.#storesFactory.create({ name: walletStoreName });
stores = await this.#storesFactory.create({ name: walletStoreName });
this.#walletStores.set(walletStoreName, stores);
}
return stores;
Expand Down Expand Up @@ -237,7 +237,7 @@ export class WalletManager<WalletMetadata extends { name: string }, AccountMetad
if (!storeIds || storeIds.length === 0) return;

for (const walletStoreId of storeIds) {
const walletStores = this.#getStores(walletStoreId);
const walletStores = await this.#getStores(walletStoreId);

this.#logger.debug(`Destroying wallet store ${walletStoreId}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ export interface WalletFactory<WalletMetadata extends { name: string }, AccountM
}

export interface StoresFactory {
create: (props: { name: string }) => storage.WalletStores;
create: (props: { name: string }) => Promise<storage.WalletStores>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('WalletManager', () => {
runtime,
signingCoordinatorApi,
storesFactory: {
create: (props) =>
create: async (props) =>
({
destroy: jest.fn().mockReturnValue(
from(
Expand Down
Loading