Skip to content

Refactor usage of repositories #193

Open

Description

@bordalix
  • Double check calls to getVtxos are using the db
  • Double check calls to getUtxos are using the db
  • Investigate possible saving of tx history in db
  • Save boarding txs (and outspents) in db
  • Check possible sync issues between net and db

Activity

  1. shubertm commented on Feb 5, 2026

    @shubertm
    Contributor

    @bordalix can I take up this issue?

  2. bordalix commented on Feb 5, 2026

    @bordalix
    ContributorAuthor
  3. shubertm commented on Feb 7, 2026

    @shubertm
    Contributor

    DB Usage Verification

    WalletRepositoryImpl

    There are 4 usages of WalletRepositoryImpl, in 3 of these usages it is explicitly supplied with db instances. Only one adds a fallback in to in-memory storage, the default for this place is db as well.

    const createCommon = (options: ServiceWorkerWalletCreateOptions) => {
    // Default to IndexedDB for service worker context
    const storage = new IndexedDBStorageAdapter(
    options.dbName || DEFAULT_DB_NAME,
    options.dbVersion
    );
    // Create repositories
    return {
    walletRepo: new WalletRepositoryImpl(storage),
    contractRepo: new ContractRepositoryImpl(storage),
    };
    };

    constructor(
    readonly dbName: string = DEFAULT_DB_NAME,
    readonly dbVersion: number = 1,
    private readonly messageCallback: (
    message: ExtendableMessageEvent
    ) => void = () => {}
    ) {
    this.storage = new IndexedDBStorageAdapter(dbName, dbVersion);
    this.walletRepository = new WalletRepositoryImpl(this.storage);
    }

    async clear() {
    if (this.incomingFundsSubscription) this.incomingFundsSubscription();
    // Clear storage - this replaces vtxoRepository.close()
    await this.storage.clear();
    // Reset in-memory caches by recreating the repository
    this.walletRepository = new WalletRepositoryImpl(this.storage);
    this.handler = undefined;
    this.arkProvider = undefined;
    this.indexerProvider = undefined;
    }

    ts-sdk/src/wallet/wallet.ts

    Lines 221 to 224 in f139452

    // Set up storage and repositories
    const storage = config.storage || new InMemoryStorageAdapter();
    const walletRepository = new WalletRepositoryImpl(storage);
    const contractRepository = new ContractRepositoryImpl(storage);

    ContractRepositoryImpl

    There are 2 usages of ContractRepositoryImpl, both of them are supplied with db instances

    const createCommon = (options: ServiceWorkerWalletCreateOptions) => {
    // Default to IndexedDB for service worker context
    const storage = new IndexedDBStorageAdapter(
    options.dbName || DEFAULT_DB_NAME,
    options.dbVersion
    );
    // Create repositories
    return {
    walletRepo: new WalletRepositoryImpl(storage),
    contractRepo: new ContractRepositoryImpl(storage),
    };
    };

    ts-sdk/src/wallet/wallet.ts

    Lines 221 to 224 in f139452

    // Set up storage and repositories
    const storage = config.storage || new InMemoryStorageAdapter();
    const walletRepository = new WalletRepositoryImpl(storage);
    const contractRepository = new ContractRepositoryImpl(storage);

  4. ghost added
    enhancementNew feature or request
    on Apr 13, 2026
  5. pietro909 commented on Jul 16, 2026

    @pietro909
    Contributor

    Status update (2026-07)

    This umbrella predates the offline-first ContractManager/repository architecture, which has since absorbed most of it. Mapping the original checklist to where things stand on master:

    What's genuinely left under this issue (not covered elsewhere): persisting boarding txs + outspents in the DB instead of re-fetching from Esplora, and closing out the last direct-indexer getVtxos reads (the latter = #550).

    Keeping this open as the tracking umbrella. The two concrete unaddressed items above are the actionable remainder; everything else here is either done or has a dedicated issue (#550, #493, #585).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions