SubAccount V2 (3/3): rust-sdk V2 + SDK integration tests - #189
Open
santy311 wants to merge 6 commits into
Open
Conversation
Collaborator
Author
|
Stacked PRs — review/merge bottom → top:
|
santy311
force-pushed
the
santhosh/subaccount-v2-sdk
branch
from
July 27, 2026 15:20
c5490f1 to
49dcf1d
Compare
santy311
force-pushed
the
santhosh/subaccount-v2-sdk
branch
3 times, most recently
from
July 28, 2026 12:09
e6364b5 to
3e274d0
Compare
santy311
force-pushed
the
santhosh/subaccount-v2-program
branch
from
July 29, 2026 11:22
e67d530 to
d794d3c
Compare
santy311
force-pushed
the
santhosh/subaccount-v2-sdk
branch
from
July 29, 2026 12:30
3e274d0 to
cba2e26
Compare
tracy-codes
requested changes
Jul 29, 2026
tracy-codes
left a comment
Contributor
There was a problem hiding this comment.
The "known gaps" part of the PR seems outdated. sub-accounts_v2_test at line 311 and 368 both create and withdraw with Secp256k1/r1. It also says 5 tests but there's 9.
There's no session authority tests, which we need to have for coverage.
santy311
force-pushed
the
santhosh/subaccount-v2-program
branch
from
July 30, 2026 11:55
d794d3c to
5300b41
Compare
santy311
force-pushed
the
santhosh/subaccount-v2-sdk
branch
from
July 30, 2026 14:16
cba2e26 to
fabbbb2
Compare
- `types::Permission`: five V2 variants (Create + scoped All/Sign/Withdraw/ Toggle) with `to_client_actions` / `from_role` / `to_action_type` mappings. - `ClientRole`: four V2 methods (create/sign/withdraw/toggle) with default "unsupported" impls, overridden for Ed25519, Secp256k1, Secp256r1, and the three session variants (which delegate to the Ed25519 builders via the session key). Secp256k1/r1 thread the odometer as the replay counter. - `SwigInstructionBuilder` + `SwigWallet`: V2 create/sign/withdraw/toggle plus a counter reader and `get_sub_account_v2`. Create reads the on-chain counter to derive the next sub-account's PDAs.
SDK-level tests via the `SwigWallet` API (rust_sdk_test feature), mirroring the program matrix at the wallet layer: - create/counter, sign + withdraw, toggle kill-switch, All-default-deny, and a Secp256k1 sign path. - Secp256k1/r1 `create` is deferred — see the note in the test file.
Ed25519SessionClientRole, Secp256k1SessionClientRole and Secp256r1SessionClientRole implemented create, SOL withdraw and toggle for V2 sub-accounts but not withdraw_token_from_sub_account_v2_instruction, so it fell through to the trait default and returned "V2 sub-accounts not supported for this authority type". Session authorities could move SOL out of a sub-account but not tokens. Each delegates to the Ed25519 token-withdraw builder via the session key, matching how the other three V2 methods on these roles already work. Add session coverage for V2, which was absent entirely: create plus SOL withdraw, token withdraw, and the toggle kill-switch. The helper has to make the session root the fee payer while opening the session, because create_session signs with the fee payer alone and ignores the acting authority keypair.
santy311
force-pushed
the
santhosh/subaccount-v2-sdk
branch
from
July 30, 2026 14:46
aa8c526 to
dc39326
Compare
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.
Summary
The rust-sdk V2 sub-account API and its SDK-level integration tests. (The interface builders these depend on live in #188.)
rust-sdk
types::Permission: five V2 variants (Create + scoped All/Sign/Withdraw/Toggle) withto_client_actions/from_role/to_action_type.ClientRole: four V2 methods (create/sign/withdraw/toggle) with default "unsupported" impls, overridden for Ed25519, Secp256k1, Secp256r1, and the three session variants (which delegate to the Ed25519 builders via the session key). Secp256k1/r1 thread the odometer as the replay counter. ProgramExec uses the default impl.SwigInstructionBuilder+SwigWallet: V2 create/sign/withdraw/toggle, a counter reader, andget_sub_account_v2. Create reads the on-chain counter to derive the next sub-account's PDAs.tests (rust_sdk_test)
Thirteen SDK integration tests via the
SwigWalletAPI:enabledwire byteAllalone cannot create (default-deny)Test
Stack
main)🤖 Generated with Claude Code