feat: integrate Anchor program for deposits#30
Conversation
- Replace direct USDC transfers with proper Anchor program calls - Add vault initialization on first deposit - Support both TOKEN_PROGRAM_ID and TOKEN_2022_PROGRAM_ID - Add error handling for vault initialization - Update deposit flow to call program instruction - Track deposits in UserDeposit PDA - Update VaultState with total deposits
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe changes add a pre-deposit vault initialization check to the deposit hook that automatically initializes the vault if not already initialized, and introduce dynamic SPL Token program detection to automatically select between TOKEN_PROGRAM_ID and TOKEN_2022 based on the USDC mint configuration. Helper functions are exposed for vault addresses and token program resolution. Changes
Sequence DiagramsequenceDiagram
participant Hook as Deposit Hook
participant Conn as Solana Connection
participant Vault as Vault Program
participant Tx as Transaction
Hook->>Conn: isVaultInitialized(connection)
Conn-->>Hook: false (not initialized)
Hook->>Conn: buildInitializeTransaction(connection, admin)
Conn->>Conn: getTokenProgramForMint(USDC mint)
Conn-->>Hook: Initialize Tx (with correct token program)
Hook->>Hook: Sign transaction with keypair
Hook->>Conn: Send raw transaction
Conn->>Vault: Process initialization
Vault-->>Conn: Confirmation
Conn-->>Hook: tx confirmed
Hook->>Hook: Proceed with deposit flow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
✨ Finishing touches
Comment |
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.