-
-
Notifications
You must be signed in to change notification settings - Fork 265
Open
Description
Overview
Add support for Privy server wallets to enable wallet-level transaction policies (allowlisted contracts, max amounts, time restrictions). Policies are managed in Privy Dashboard; Gateway just registers wallets and signs transactions.
Design Document
Full implementation spec: privy-gateway-design.md
Why Privy?
The main value is wallet-level policies:
- Restrict transactions to specific contracts (DEX routers only)
- Set maximum transfer amounts per transaction
- Allowlist/denylist recipient addresses
- Time-based access controls
- Block private key exports
Policies are configured in the Privy Dashboard and enforced server-side on every signing request.
Implementation Summary
Files to Create
src/wallet/privy/privy-client.ts- REST client for Privy APIsrc/wallet/privy/privy-evm-signer.ts- ethers.Signer implementation for EVM chainssrc/wallet/privy/privy-solana-signer.ts- Solana transaction signer
Files to Modify
src/templates/apiKeys.yml- Add privyAppId, privyAppSecretsrc/templates/namespace/apiKeys-schema.json- Add Privy propertiessrc/wallet/utils.ts- Add Privy wallet utilities (mirrors hardware wallet pattern)src/chains/ethereum/ethereum.ts- AddisPrivyWallet()andgetPrivySigner()methodssrc/chains/solana/solana.ts- AddisPrivyWallet()andgetPrivySigner()methodssrc/wallet/wallet.routes.ts- Add/wallet/add-privyand/wallet/remove-privyroutes- Connectors (Jupiter, Raydium, Meteora, Uniswap) - Add Privy wallet branching
Key Design Decisions
- Uses existing
apiKeys.yml- No new config namespace; Privy credentials go in centralized API keys - Follows existing hardware wallet pattern - Uses
isPrivyWallet()check and branching like existingisHardwareWallet()pattern - Policies managed in Privy Dashboard - Gateway doesn't manage policies; it just registers wallets and signs transactions
- Minimal connector changes - Connectors add
else if (isPrivyWallet)branch to existing hardware wallet logic - No new dependencies - Uses native
fetchfor Privy API calls
API Endpoints
POST /wallet/add-privy- Register a Privy wallet (chain, privyWalletId)DELETE /wallet/remove-privy- Unregister a Privy wallet (chain, address)
Connector Update Pattern
const isHardwareWallet = await solana.isHardwareWallet(walletAddress);
const isPrivyWallet = await solana.isPrivyWallet(walletAddress);
if (isHardwareWallet) {
// existing hardware wallet code...
} else if (isPrivyWallet) {
transaction = await jupiter.buildSwapTransactionForHardwareWallet(walletAddress, quote, ...);
const privySigner = await solana.getPrivySigner(walletAddress);
transaction = await privySigner.signTransaction(transaction);
} else {
// existing local wallet code...
}Implementation Checklist
- Add Privy credentials to
src/templates/apiKeys.yml - Add Privy properties to
src/templates/namespace/apiKeys-schema.json - Create
src/wallet/privy/directory - Create
src/wallet/privy/privy-client.ts - Create
src/wallet/privy/privy-evm-signer.ts - Create
src/wallet/privy/privy-solana-signer.ts - Add Privy wallet functions to
src/wallet/utils.ts - Add
isPrivyWallet()andgetPrivySigner()tosrc/chains/ethereum/ethereum.ts - Add
isPrivyWallet()andgetPrivySigner()tosrc/chains/solana/solana.ts - Add
/wallet/add-privyand/wallet/remove-privyroutes - Update Jupiter connector with Privy support
- Update Raydium connector with Privy support
- Update Meteora connector with Privy support
- Update Uniswap connector with Privy support (if needed)
- Run
pnpm buildto verify no TypeScript errors - Run
pnpm testto verify existing tests pass - Create unit tests for Privy client and signers
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels