feat: request-withdraw, complete-withdraw#464
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
713b7b8 to
2260ab4
Compare
5860732 to
b151e25
Compare
a82f2a9 to
20c0f62
Compare
Spacesai1or
reviewed
Jan 30, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds withdrawal functionality enabling users to withdraw tokens from their agent smart accounts back to their controller wallets. The implementation follows a two-step flow: request-withdraw prepares unsigned UserOperations, and complete-withdraw submits the signed operations to the blockchain.
Changes:
- Added two new REST API endpoints for initiating and completing token withdrawals from agent smart accounts
- Implemented optional gas sponsorship via ZeroDev paymaster controlled by SPONSOR_WITHDRAW_GAS environment variable
- Created reusable utilities for chain configuration and Alchemy token balance fetching
Reviewed changes
Copilot reviewed 18 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/libs/registry-sdk/src/lib/schemas/withdraw.ts | Defines Zod schemas and TypeScript types for withdrawal request/response structures |
| packages/libs/registry-sdk/src/lib/openApi/user.ts | Registers OpenAPI endpoint definitions for request-withdraw and complete-withdraw |
| packages/libs/registry-sdk/src/index.ts | Exports withdrawal schemas and types for public API consumption |
| packages/libs/registry-sdk/src/generated/vincentApiClientReact.ts | Auto-generated React RTK Query hooks for withdrawal endpoints |
| packages/libs/registry-sdk/src/generated/vincentApiClientNode.ts | Auto-generated Node.js RTK Query client for withdrawal endpoints |
| packages/libs/registry-sdk/src/generated/openapi.json | Auto-generated OpenAPI specification including withdrawal schemas |
| packages/apps/registry-backend/src/lib/requestWithdraw.ts | Implements UserOperation preparation logic with balance validation and optional paymaster |
| packages/apps/registry-backend/src/lib/completeWithdraw.ts | Handles UserOperation submission to bundler with polling for transaction confirmation |
| packages/apps/registry-backend/src/lib/utils/chainConfig.ts | Provides network configuration mapping and RPC URL resolution utilities |
| packages/apps/registry-backend/src/lib/utils/alchemy.ts | Abstracts Alchemy Portfolio API calls for token balance fetching |
| packages/apps/registry-backend/src/lib/getAgentFunds.ts | Minor formatting fix (newline) |
| packages/apps/registry-backend/src/lib/express/user/routes.ts | Registers Express routes for withdrawal endpoints with middleware |
| packages/apps/registry-backend/src/env.ts | Adds SPONSOR_WITHDRAW_GAS boolean environment variable |
| packages/apps/registry-backend/package.json | Updates registry-sdk to workspace reference for local development |
| packages/apps/registry-backend/jest.config.js | Includes withdraw.spec.ts in test file patterns |
| packages/apps/registry-backend/test/integration/withdraw.spec.ts | Comprehensive integration tests covering validation and full withdrawal flow |
| packages/apps/registry-backend/test/integration/global-setup.ts | Adds withdrawal-related environment variables to test setup |
| docs/wallet-providers/request-withdraw.mdx | Documents request-withdraw API endpoint with examples |
| docs/wallet-providers/complete-withdraw.mdx | Documents complete-withdraw API endpoint with examples |
| docs/wallet-providers/introduction.mdx | Adds withdrawal endpoints to wallet provider API overview |
| docs/docs.json | Adds "Withdraw Funds" section to documentation navigation |
| pnpm-lock.yaml | Updates registry-sdk reference from published version to workspace link |
| .nx/version-plans/version-plan-1768873657320.md | Version plan documenting minor version bumps for both packages |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Spacesai1or
approved these changes
Jan 30, 2026
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.
Description
Add withdrawal endpoints for users to withdraw tokens from their agent smart accounts
registry-backend:
POST /user/:appId/request-withdrawendpoint to prepare unsigned UserOperations for withdrawing tokensPOST /user/:appId/complete-withdrawendpoint to submit signed UserOperations and execute withdrawalsSPONSOR_WITHDRAW_GASenv var to optionally sponsor gas fees via ZeroDev paymasterregistry-sdk:
POST /user/:appId/request-withdrawendpoint schemaPOST /user/:appId/complete-withdrawendpoint schemaAsset,RequestWithdrawRequest,RequestWithdrawResponse,SignedWithdrawal,CompleteWithdrawRequest,CompleteWithdrawResponseType of change
How Has This Been Tested?
A
withdraw.spec.tsintegration test exists, which test both endpoints sending0.1USDC on Base Sepolia to the user's EOA controller address. It has been tested both with and without gas sponsorshipChecklist:
nx release plan) describing my changes and the version bump