worldcoin / worldcoin/walletkit

Refactor `blobs.rs` to accept generic `Connection` or `Transaction`

Open
#426 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

otto-report
Dominant language
Rust
Stars
19
Forks
7
Avg merge
1d 7h
Merged PRs (30d)
35

Description

Context

In credential_vault/mod.rs, blobs::put(conn, ...) is called while an active transaction is open on the same connection. This works correctly in SQLite (same connection object), but it's confusing to readers since blobs.rs functions currently take a &Connection directly rather than a type that makes the transactional context explicit.

Proposed Refactor

Refactor blobs.rs (and similar helper modules) to accept a generic parameter — e.g. something implementing a Deref<Target = rusqlite::Connection> or a rusqlite::ToSql-style abstraction — so the same functions can be called with either a bare Connection or an active Transaction without ambiguity.

This would make call-sites like:

let tx = conn.transaction()?;
blobs::put(&tx, ...)?;   // clearly operating inside the transaction
tx.commit()?;

…unambiguous and self-documenting.

References

Flagged during review of #400. Not blocking that PR — tracking here for a follow-up refactor.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading credential_vault/mod.rs and blobs.rs, especially the blobs::put call made while a transaction is active. Identify similar helper modules that take &Connection, then make the refactor support both bare connections and transactions while keeping the transactional call site explicit; done means the relevant code builds and its existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.