Skip to content

feat: add wallet-scoped activity tag reads (#136) - #141

Open
coreyphillips wants to merge 1 commit into
masterfrom
issue-136
Open

feat: add wallet-scoped activity tag reads (#136)#141
coreyphillips wants to merge 1 commit into
masterfrom
issue-136

Conversation

@coreyphillips

Copy link
Copy Markdown
Collaborator

Closes #136

Add get_activities_tags(wallet_id) and get_pre_activity_metadata_list(wallet_id), wallet-scoped reads of the tag-backup tables where None returns every scope.

The two tag-backup readers, get_all_activities_tags() and get_all_pre_activity_metadata(), take no wallet id, and the only scoped tag getter is get_tags(wallet_id, activity_id) for a single activity. An app that wants one wallet's tags has to fetch every scope and filter client-side, which makes a one-line app-side .filter { it.walletId == ... } the whole backup-scoping policy for records that go to a remote backup server. Dropping that line is invisible in review and silently widens what leaves the device.

What changed

  • ActivityDb::get_activities_tags(Option<&str>) in src/modules/activity/implementation.rs builds the same tag query with an optional WHERE wallet_id = ?1; get_all_activities_tags() now just calls it with None.
  • ActivityDb::get_pre_activity_metadata_list(Option<&str>) does the same for pre_activity_metadata; get_all_pre_activity_metadata() delegates to it with None.
  • Both scoped readers run the wallet id through the existing normalize_wallet_id, so a blank or whitespace-only scope is a typed error rather than a silent full-table read.
  • New UniFFI exports get_activities_tags(wallet_id: Option<String>) and get_pre_activity_metadata_list(wallet_id: Option<String>) in src/lib.rs. The existing unscoped exports are untouched, so no caller breaks.
  • README, module README and CHANGELOG document the new calls.

How to test

  • cargo test modules::activity, 193 pass, including the four new tests.
  • test_get_activities_tags_wallet_scoped and test_get_pre_activity_metadata_list_wallet_scoped each store one record under the default scope and one under a trezor:{64-hex} scope, then assert each scope returns only its own record, that None matches the legacy unscoped getter, and that an unknown scope returns empty.
  • test_get_activities_tags_rejects_blank_wallet_id and test_get_pre_activity_metadata_list_rejects_blank_wallet_id cover the whitespace-scope error.
  • cargo clippy --all-targets and cargo fmt --check are clean for the touched code.

Notes

Naming: the issue asks for get_activities_tags, which I used verbatim. The metadata equivalent could not drop all_ the same way because get_pre_activity_metadata(wallet_id, search_key, search_by_address) already exists and UniFFI function names are global, hence get_pre_activity_metadata_list. I added new functions rather than changing the existing signatures, so bitkit-android and bitkit-ios keep compiling; the acceptance criterion that unscoped behaviour stays available is met by both the old calls and by passing None. Generated bindings under bindings/ are not regenerated here. This repo does that in separate chore: regenerate bindings commits at release time via build.sh -r, and it needs the iOS/Android cross-compile toolchain, so the new functions are not yet visible to Swift/Kotlin/Python until that step runs. cargo test (full suite) has 11 pre-existing failures, all in modules::blocktank, from api.stag.blocktank.to being unreachable in this environment. They are unrelated to this change; the other 497 pass.

get_all_activities_tags() and get_all_pre_activity_metadata() take no wallet
id, so an app backing up a single wallet scope had to fetch every scope and
filter client-side. That filter is the app's entire backup-scoping policy and
is easy to drop in review, which silently changes which records leave the
device.

Add get_activities_tags(wallet_id) and get_pre_activity_metadata_list(wallet_id),
where None returns every scope. The unscoped getters are unchanged and delegate
to the new ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add wallet-scoped activity tag reads

1 participant