Repository navigation
feat(solana): add guarded Pack Partner purchase signing - #655
Open
0xEdouardEth wants to merge 1 commit into
Open
0xEdouardEth wants to merge 1 commit into
0xEdouardEth wants to merge 1 commit into
Conversation
## Explanation Add `signPackPartnerBuy` to the MetaMask-only client entrypoint so Collectibles can sign the exact user-confirmed USDC purchase without another confirmation screen. The existing handler resolves the keyring account and delegates through `WalletService` to a stateless `PackPartnerSigner`. The Snap returns signed bytes and the transaction signature; Mobile owns broadcasting, pack opening and recovery. Require a valid partner presignature, the configured mainnet/devnet authorities and USDC mint, a positive base-unit amount, the exact user debit and bounded fees. Validate the instruction allowlist and simulated account effects before deriving the user's key. A sponsored user need not hold SOL. Policy overrides, unconfigured networks and dapp/keyring/multichain access are rejected. Client logs retain the method name without logging transaction parameters. This is part 1 of 4. No buyback method or NFT validator is enabled in this PR. Read the README contract, then `PackPartnerSigner.ts`, followed by its purchase tests and client/entrypoint tests. ### Validation - 341 targeted tests passed. Covers the available Pack Partner guards, client request handlers, WalletService and entrypoint boundaries. - Package TypeScript check, Snap build, changed-file Oxlint/formatting and changelog validation passed. - Tests use synthetic keys and mocked RPC. No live purchase, buyback or fund transfer was performed. ## References - Part 1/4 of the Pack Partner signing stack. Base: `main`. - Original implementation: `0xEdouardEth/pack-partner-guarded-signing` (preserved for comparison). - Contract and invariants: `packages/solana-wallet-snap/README.md`, “Pack Partner signing (MetaMask client only)”. | Order | Branch | Scope | | --- | --- | --- | | 1 | `0xEdouardEth/collectibles-1-pack-partner-buy` | Purchase and common guards | | 2 | `0xEdouardEth/collectibles-2-pack-partner-cnft-core` | Buyback and Bubblegum V2 compressed NFTs | | 3 | `0xEdouardEth/collectibles-3-pack-partner-core` | Metaplex Core buybacks | | 4 | `0xEdouardEth/collectibles-4-pack-partner-nft-pnft` | Token Metadata classic NFT and pNFT buybacks | ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/internal-snaps/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/internal-snaps/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them No breaking changes; the signing capabilities are additive.
|
This branch was successfully deployed
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.



Explanation
Add
signPackPartnerBuyto the MetaMask-only client entrypoint so Collectibles can sign the exact user-confirmed USDC purchase without another confirmation screen. The existing handler resolves the keyring account and delegates throughWalletServiceto a statelessPackPartnerSigner. The Snap returns signed bytes and the transaction signature; Mobile owns broadcasting, pack opening and recovery.Require a valid partner presignature, the configured mainnet/devnet authorities and USDC mint, a positive base-unit amount, the exact user debit and bounded fees. Validate the instruction allowlist and simulated account effects before deriving the user's key. A sponsored user need not hold SOL. Policy overrides, unconfigured networks and dapp/keyring/multichain access are rejected. Client logs retain the method name without logging transaction parameters.
This is part 1 of 4. No buyback method or NFT validator is enabled in this PR. Read the README contract, then
PackPartnerSigner.ts, followed by its purchase tests and client/entrypoint tests.Validation
References
main.0xEdouardEth/pack-partner-guarded-signing(preserved for comparison).packages/solana-wallet-snap/README.md, “Pack Partner signing (MetaMask client only)”.0xEdouardEth/collectibles-1-pack-partner-buyChecklist
No breaking changes; the signing capabilities are additive.
Explanation
References
Checklist