feat(wallet): add reusable program account selector - #242
Closed
3esmit wants to merge 5 commits into
Closed
Conversation
Collaborator
3esmit
force-pushed
the
feat/shared-wallet-token-holding-selector
branch
from
August 3, 2026 16:02
00b5328 to
db0c0b8
Compare
Collaborator
Author
|
rebased to main, fixed failing test, and loosened coupling to IDL code from humanized wallet. |
3esmit
force-pushed
the
feat/shared-wallet-token-holding-selector
branch
from
August 4, 2026 13:54
db0c0b8 to
6086d65
Compare
3esmit
marked this pull request as ready for review
August 4, 2026 16:08
There was a problem hiding this comment.
Pull request overview
Adds a shared-wallet “program account selector” UI primitive and wires it through the AMM UI so users can pick which wallet-owned TokenHolding accounts to use as inputs/outputs (including “create new” outputs), while extending the AMM swap instruction path to support swapping into a fresh, authorized output holding.
Changes:
- Add
ProgramAccountSelectorQML control (with C++/QML tests) that filters by account type + decoded state field and auto-selects highest-balance matches. - Expose wallet TokenHoldings as generic
programAccountsin AMM context/quote flows; add holding selection + LP destination selection fields to requests. - Update AMM swap to accept a fresh authorized output holding, with new unit/integration tests and updated instruction docs.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| programs/integration_tests/tests/amm.rs | Adds an integration test proving swap-exact-input can initialize a fresh output holding. |
| programs/amm/src/tests.rs | Adds unit tests for accepting/rejecting fresh output holdings in swap-exact-input. |
| programs/amm/src/swap.rs | Implements “owned-by-token-program OR fresh+authorized” validation for swap holdings. |
| programs/amm/methods/guest/src/bin/amm.rs | Updates guest-facing instruction documentation for fresh output holdings. |
| programs/amm/core/src/lib.rs | Updates core instruction docs to reflect fresh+signed output holding option. |
| modules/amm/ffi/src/api/tests.rs | Expands FFI tests for holding selection defaults/overrides and LP destination behaviors. |
| modules/amm/ffi/src/api/swap.rs | Updates swap plan generation to require output-holding signing (see review comment). |
| modules/amm/ffi/src/api/request.rs | Extends PositionRequest to carry selected holding IDs + LP destination choice flags. |
| modules/amm/ffi/src/api/quote.rs | Adds holding/LP destination selection logic and exposes LP destination options in quote JSON. |
| modules/amm/ffi/src/api/holding.rs | Refactors holding selection to support explicit requested holding IDs and sorted options. |
| modules/amm/ffi/src/api/context.rs | Exposes wallet TokenHoldings as generic programAccounts and includes per-token holdings. |
| modules/amm/ffi/src/api/accounts.rs | Threads LP holding selection into the missing-account plan and source tracking. |
| apps/shared/wallet/tests/qml/tst_ProgramAccountSelector.qml | Adds QML coverage for selector filtering, auto-selection, create-new behavior, and u128-safe comparisons. |
| apps/shared/wallet/tests/cpp/LogosWalletProviderTest.cpp | Adjusts expectation for instruction serialization representation. |
| apps/shared/wallet/qml/ProgramAccountSelector.qml | Introduces reusable selector control used by AMM swap and liquidity flows. |
| apps/shared/wallet/CMakeLists.txt | Exposes the new selector as part of the shared wallet QML public surface. |
| apps/amm/tests/qml/tst_TokenAmountInput.qml | Adds QML tests validating holding auto-selection and manual selection. |
| apps/amm/tests/qml/tst_NewPositionForm.qml | Updates tests to include programAccounts and verify holding IDs propagate into requests. |
| apps/amm/src/AmmUiBackend.rep | Updates token list config docs to deprecate legacy “holding” and use wallet TokenHoldings. |
| apps/amm/README.md | Updates user-facing docs: token config no longer requires per-token holding addresses. |
| apps/amm/qml/pages/SwapPage.qml | Wires programAccounts from backend context into the swap UI. |
| apps/amm/qml/components/swap/TokenVisuals.js | Updates comment to reflect token config no longer includes holdings. |
| apps/amm/qml/components/swap/TokenInput.qml | Adds holding selector UI for swap inputs/outputs using ProgramAccountSelector. |
| apps/amm/qml/components/swap/SwapCard.qml | Uses selected holdings for swap submission; supports creating a fresh output holding before swap. |
| apps/amm/qml/components/liquidity/TokenAmountInput.qml | Adds holding selector UI for liquidity token inputs and exposes selected holding state to the form. |
| apps/amm/qml/components/liquidity/NewPositionForm.qml | Adds holding selection + LP destination selector and threads selections into quote requests and submission gating. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3esmit
force-pushed
the
feat/shared-wallet-token-holding-selector
branch
from
August 10, 2026 14:25
6086d65 to
9233eff
Compare
Collaborator
|
This has landed with #284 |
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 #241.
Adds a generic shared-wallet program account selector. It can filter any program account type by a decoded state field, so it can be reused for more than TokenHoldings.
The first use covers every AMM TokenHolding choice:
The highest-balance matching holding is selected automatically. Users can choose another holding. Outputs also offer Create new TokenHolding, which is selected automatically when no matching output exists.
Screenshots
Swap input — highest balance selected from two matching holdings:
Swap output — existing destination or new TokenHolding:
Liquidity token A input:
Liquidity token B input:
LP TokenHolding output — Create new selected when no matching holding exists:
Checks: formatting, Clippy, workspace unit tests, full integration tests, QML tests, IDL drift, AMM UI build, and live AMM UI walkthrough against a synced testnet wallet.