feat: add wallet-scoped activity tag reads (#136) - #141
Open
coreyphillips wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #136
Add
get_activities_tags(wallet_id)andget_pre_activity_metadata_list(wallet_id), wallet-scoped reads of the tag-backup tables whereNonereturns every scope.The two tag-backup readers,
get_all_activities_tags()andget_all_pre_activity_metadata(), take no wallet id, and the only scoped tag getter isget_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>)insrc/modules/activity/implementation.rsbuilds the same tag query with an optionalWHERE wallet_id = ?1;get_all_activities_tags()now just calls it withNone.ActivityDb::get_pre_activity_metadata_list(Option<&str>)does the same forpre_activity_metadata;get_all_pre_activity_metadata()delegates to it withNone.normalize_wallet_id, so a blank or whitespace-only scope is a typed error rather than a silent full-table read.get_activities_tags(wallet_id: Option<String>)andget_pre_activity_metadata_list(wallet_id: Option<String>)insrc/lib.rs. The existing unscoped exports are untouched, so no caller breaks.How to test
cargo test modules::activity, 193 pass, including the four new tests.test_get_activities_tags_wallet_scopedandtest_get_pre_activity_metadata_list_wallet_scopedeach store one record under the default scope and one under atrezor:{64-hex}scope, then assert each scope returns only its own record, thatNonematches the legacy unscoped getter, and that an unknown scope returns empty.test_get_activities_tags_rejects_blank_wallet_idandtest_get_pre_activity_metadata_list_rejects_blank_wallet_idcover the whitespace-scope error.cargo clippy --all-targetsandcargo fmt --checkare clean for the touched code.Notes
Naming: the issue asks for
get_activities_tags, which I used verbatim. The metadata equivalent could not dropall_the same way becauseget_pre_activity_metadata(wallet_id, search_key, search_by_address)already exists and UniFFI function names are global, henceget_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 passingNone. Generated bindings underbindings/are not regenerated here. This repo does that in separatechore: regenerate bindingscommits at release time viabuild.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 inmodules::blocktank, fromapi.stag.blocktank.tobeing unreachable in this environment. They are unrelated to this change; the other 497 pass.