feat(sdk): native-SOL transaction builders#346
Merged
Conversation
Design for adding native-SOL builders to @sipher/sdk, mirroring the existing SPL builders. The vault program exposes deposit_sol / withdraw_private_sol / refund_sol / authority_refund_sol on-chain, but the SDK only builds the token path. Adds buildDepositSolTx, buildPrivateSendSolTx, buildRefundSolTx, buildAuthorityRefundSolTx, the SolVault/SolFee PDA derivations, and the NATIVE_SOL_MINT sentinel. Decisions: separate *Sol builders (vs unified asset param); withdraw throws on a below-rent-exempt stealth recipient by default; @sipher/sdk publish deferred. PDA + sentinel fixtures verified against the live devnet deployment.
Five-task plan (constants+PDAs, deposit, refund family, withdraw, optional create+barrel gate) with complete code per step, mirroring the existing SPL builders. Account orders and instruction-data layouts byte-exact from the program; real devnet PDA fixtures for the derivation tests.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
sipher_vaultis a universal-asset vault — it custodies classic SPL tokens, Token-2022, and native SOL — but@sipher/sdkonly shipped transaction builders for the token path. This PR adds the native-SOL builders, mirroring the existing SPL ones one-for-one. Purely additive: no existing export, signature, or behavior changes.What's added (
@sipher/sdk)NATIVE_SOL_MINT,VAULT_SOL_SEED,FEE_SOL_SEEDderiveSolVaultPDA,deriveSolFeePDAbuildDepositSolTxdeposit_solbuildRefundSolTx,buildAuthorityRefundSolTxrefund_sol/authority_refund_solbuildPrivateSendSolTxwithdraw_private_sol(stealth payout + Pedersen commitment + announcement CPI)buildCreateSolVaultTxcreate_sol_vault(one-time PDA init)SolDepositResult,SolRefundResultWithdrawResultreused for withdraw)Native-SOL balance reads reuse the existing
getVaultBalance(connection, depositor, NATIVE_SOL_MINT)— no new read function.Design notes
NATIVE_SOL_MINTis the all-zeros sentinel (Pubkey::new_from_array([0u8; 32])), not wrapped SOL — the native path never wraps; kept distinct fromWSOL_MINT.withdraw_private_solpays a plainSystemAccount, so a small payout to a never-funded stealth address would be rejected by the runtime.buildPrivateSendSolTxpre-flights the recipient's balance against the rent-exempt minimum and throws an actionable error (caller pre-funds) instead of letting the tx fail opaquely.Testing
vault-soltests + 5 newprivacy-soltests. Full suite: 118 passing;tsc --noEmit: 0 errors.Review
Built test-first via per-task implement→review cycles; a final whole-branch review verified every account flag, instruction-data layout, and struct offset (
fee_bps@40,total_transfers@43) against the deployed program.Design + plan:
docs/superpowers/specs/2026-06-24-sipher-sdk-native-sol-builders-design.md,docs/superpowers/plans/2026-06-24-sipher-sdk-native-sol-builders.md.Deferred (non-blocking) polish: a few additional validation-throw test cases, and sharing the withdraw
fixedSizeconstant with the SPL path.