feat: add notes pagination - #336
Conversation
|
hey @Patrick-Ehimen! ✋ Let's merge to the latest and fix the CI? |
|
Thank you @Patrick-Ehimen 👍 On the Rust side looks good. |
# Conflicts: # app/crates/platforms/web/src/client/mod.rs # app/js/disclosure.js # app/js/ui/notes-table.js
| /// `spent` filters to spent-only (`Some(true)`), unspent-only | ||
| /// (`Some(false)`), or all notes (`None`) — applied in SQL so `offset`/ | ||
| /// `limit` page over the filtered set, matching [`Self::count_user_notes`]. | ||
| pub fn list_user_notes( |
There was a problem hiding this comment.
probably it makes sense to have a single method to return the notes page and the total count (because for example in some databases which can be used later) the both queries can be combined into one with window functions?
Here in sqlite we can use a wrapping transaction to ensure we look at the same db state (as between the 2 queries there is a gap when new notes arrive)?
|
|
||
| /// All notes for `address` in `pool_contract_id` (newest first), spent and | ||
| /// unspent. | ||
| pub fn list_pool_user_notes( |
There was a problem hiding this comment.
this can be removed with the changes introduced, right?
| StorageWorkerRequest::UserNotes(address, limit) => { | ||
| log::trace!("[{WORKER_NAME}] list user notes for the account {address}"); | ||
| let list = with_storage!(s => s.list_user_notes(&address, limit)?)?; | ||
| StorageWorkerRequest::UserNotes { |
There was a problem hiding this comment.
let's combine a page and a total count?
| UserKeys(Address), | ||
| AspSecret(Address), | ||
| UserNotes(Address, u32), | ||
| UserNotes { |
There was a problem hiding this comment.
let's combine in a single request?
|
hey @Patrick-Ehimen ! ✋ thanks a lot! some comments to address |
Addresses review from maksimryndin on NethermindEth#336: list_user_notes and count_user_notes ran as two separate queries (and two separate worker round trips over WASM), which could observe different DB snapshots if a note landed between them. Merge them into list_user_notes_page, wrapped in a single read transaction, and collapse the worker protocol/JS facade down to one request per page fetch.
Reconcile the paginated user notes API with upstream's new Account SDK:
- Move `list_user_notes_page` (offset/limit/spent → UserNotesPage) onto the
Storage trait and Account SDK so pagination flows through the wallet
session, not the top-level client.
- Update the WASM `Account::userNotes` to take
`{ offset?, limit?, spent? }` and return `{ notes, total }`.
- Point `disclosure.js` and `notes-table.js` at `client().account().userNotes(...)`.
maksimryndin
left a comment
There was a problem hiding this comment.
LGTM! thanks a lot @Patrick-Ehimen !
asking for the review of the team :)
|
@maksimryndin Heads up on the failing
GitHub doesn't expose If you'd like to silence it for fork PRs, guarding the job with something like: would skip it on forks while still running on internal branches and on |
cc @v0-e |
|
Thank you @Patrick-Ehimen, yeah if you can, we can have just push to main like https://github.com/NethermindEth/stellar-private-payments/blob/main/.github/workflows/deployment.yml 👍 On this PR, I didn't test with real notes, but I'm getting similar issues to #336 (comment) with 20 > notes in the two deployed pools. |
|
Hey @Patrick-Ehimen ! Thanks so much for your contributions 🙌 The repo has advanced a bit since the last time you tried this, and you shouldn't be getting any errors now. Would you be willing to try again? Or should I tackle this one? |
|
@maksimryndin i will look into it asap |
|
@maksimryndin i will get on it ASAP |
Resolve conflicts from upstream's tracing/privacy refactor: - sdk/web/src/workers/storage.rs: keep the paginated UserNotes arm (offset/limit/spent -> list_user_notes_page), adopt upstream's tracing::trace! and wrap the account address in Sensitive(..) so it is redacted in logs. Union the type imports (Sensitive + UserNotesPage). - sdk/web/src/client/account.rs: keep UserNotesOptions, drop DeriveAspUserLeafOptions (removed upstream; deriveAspUserLeaf now takes no arguments). - sdk/web/js/types/index.d.ts: same, keep UserNotesOptions and drop the DeriveAspUserLeafOptions declaration.
v0-e
left a comment
There was a problem hiding this comment.
Same issues in the UI when we have more than 20 notes.

Closes #299
Summary
OFFSET/LIMITsupport tolist_user_notes(SQL layer, 20 entries per page)count_user_notes()to support total page count calculationgetUserNotes(address, offset, limit)andgetUserNotesCount(address)via WASM bindingsNote
The disclosure page fetches up to 200 notes in a single call (pre-existing limit) and paginates client-side. This is a reasonable tradeoff since the note picker requires cross-page selection state (up to 4 notes).