-
Notifications
You must be signed in to change notification settings - Fork 299
chore: support tokenApproval for MPC #6161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2e4c831 to
40efbfd
Compare
f95933e to
edbe6f3
Compare
bfe731d to
82c51de
Compare
|
@claude can you review? |
sampras-saha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
82c51de to
92c040f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for ERC20 token approvals within MPC flows and the Wallet API.
- Introduces a new
tokenApprovalintent across TSS utils and MPC utilities. - Updates
PopulatedIntentandAbstractEthLikeNewCoinsto recognize and passtokenName. - Adds unit tests covering
populateIntentandapproveErc20Tokenfor Ethereum, Polygon, and BSC.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/sdk-core/src/bitgo/wallet/wallet.ts | Added tokenApproval case in the prebuild transaction switch. |
| modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts | Extended PopulatedIntent interface with optional tokenName. |
| modules/sdk-core/src/bitgo/utils/mpcUtils.ts | Supported tokenApproval in populateIntent and included tokenName. |
| modules/abstract-eth/src/abstractEthLikeNewCoins.ts | Allowed tokenApproval in missing-params validation logic. |
| modules/bitgo/test/v2/unit/wallet.ts | Added tests for populateIntent and the approveErc20Token method. |
Comments suppressed due to low confidence (3)
modules/sdk-core/src/bitgo/wallet/wallet.ts:3358
- Consider adding a unit test to verify that
prebuildTxWithIntentis called with the correctintentTypeandtokenNamefor thetokenApprovalcase, ensuring this branch remains covered.
case 'tokenApproval':
modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts:259
- [nitpick] The new
tokenNamefield should be documented in the interface JSDoc to explain its purpose and any constraints (e.g., valid tokens, format).
tokenName?: string;
modules/bitgo/test/v2/unit/wallet.ts:5096
- This test checks for a generic rejection but doesn't assert the specific error message. To strengthen validation, specify the expected error message when required parameters are missing.
await ethWallet.approveErc20Token('', tokenName).should.be.rejectedWith();
| case 'tokenApproval': | ||
| return { | ||
| ...baseIntent, | ||
| tokenName: params.tokenName, |
Copilot
AI
Jul 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The tokenApproval branch re-adds tokenName to the returned intent even though it's already included in baseIntent. Consider merging feeOptions and tokenName into baseIntent or extracting common fields to reduce duplication.
| tokenName: params.tokenName, |
| !( | ||
| txParams.prebuildTx?.consolidateId || | ||
| (txParams.type && ['acceleration', 'fillNonce', 'transferToken'].includes(txParams.type)) | ||
| (txParams.type && ['acceleration', 'fillNonce', 'transferToken', 'tokenApproval'].includes(txParams.type)) |
Copilot
AI
Jul 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The list of supported transaction types is hard-coded in multiple places. Extract this array into a shared constant to ensure consistency and simplify future updates.
| (txParams.type && ['acceleration', 'fillNonce', 'transferToken', 'tokenApproval'].includes(txParams.type)) | |
| (txParams.type && SUPPORTED_TRANSACTION_TYPES.includes(txParams.type)) |
Ticket: COIN-4071