feat(sdk-coin-eth): add zama token withdrawal support#8919
Draft
MohammedRyaan786 wants to merge 1 commit into
Draft
feat(sdk-coin-eth): add zama token withdrawal support#8919MohammedRyaan786 wants to merge 1 commit into
MohammedRyaan786 wants to merge 1 commit into
Conversation
4c46e97 to
4e456c8
Compare
TICKET: CHALO-529
4e456c8 to
a0d23d4
Compare
There was a problem hiding this comment.
Pull request overview
Adds first-class support in the Ethereum SDK for ERC-7984 “confidentialTransfer” token withdrawals by introducing a dedicated transfer builder, decoding utilities, new transaction typing/classification, and coin-level verification logic for ERC-7984 confidential transfers.
Changes:
- Introduces
TransferBuilderERC7984to build/signsendMultiSig-wrappedconfidentialTransfer(...)calldata and exports it throughabstract-ethandsdk-coin-eth. - Adds
SendERC7984transaction type and updates tx builders / classification logic to recognize confidential transfers by inspecting inner calldata. - Extends
Erc7984Token.verifyTransactionwith confidential transfer verification and adds unit tests for builder, decoding, classification, and verification flows.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/sdk-core/src/account-lib/baseCoin/enum.ts | Adds TransactionType.SendERC7984. |
| modules/sdk-coin-eth/test/unit/transactionBuilder/sendERC7984Token.ts | Adds unit/integration tests for the ERC-7984 builder, decoding, and classification. |
| modules/sdk-coin-eth/test/unit/erc7984Token.ts | Adds confidential transfer verification tests for Erc7984Token.verifyTransaction. |
| modules/sdk-coin-eth/src/lib/transferBuilders/index.ts | Re-exports TransferBuilderERC7984 for SDK consumers. |
| modules/sdk-coin-eth/src/lib/transactionBuilder.ts | Allows TransactionBuilder.transfer() to instantiate TransferBuilderERC7984 for SendERC7984. |
| modules/sdk-coin-eth/src/erc7984Token.ts | Routes non-enabletoken verification to confidential-transfer-specific verification; switches send method to sendMultiSig. |
| modules/abstract-eth/src/lib/walletUtil.ts | Adds method IDs / ABI types for confidential transfer decoding. |
| modules/abstract-eth/src/lib/utils.ts | Adds decodeConfidentialTransferData and enhances classifyTransaction to detect SendERC7984 via inner calldata. |
| modules/abstract-eth/src/lib/transferBuilders/transferBuilderERC7984.ts | Implements ERC-7984 confidential transfer builder/signing + decode-from-calldata support. |
| modules/abstract-eth/src/lib/transferBuilders/index.ts | Exports the new transferBuilderERC7984. |
| modules/abstract-eth/src/lib/transactionBuilder.ts | Treats SendERC7984 as a “send” type throughout build/from/validate flows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+105
to
+118
| private validateMandatoryFields(): void { | ||
| if (!this._toAddress) { | ||
| throw new BuildTransactionError('Missing mandatory field: destination (to) address'); | ||
| } | ||
| if (!this._tokenContractAddress) { | ||
| throw new BuildTransactionError('Missing mandatory field: token contract address'); | ||
| } | ||
| if (!this._encryptedHandle) { | ||
| throw new BuildTransactionError('Missing mandatory field: encryptedHandle'); | ||
| } | ||
| if (!this._inputProof) { | ||
| throw new BuildTransactionError('Missing mandatory field: inputProof'); | ||
| } | ||
| } |
Comment on lines
+171
to
+175
| // Cross-check against buildParams when the server has already stored the intent | ||
| const buildParamsAmount = txPrebuild?.buildParams?.recipients?.[0]?.amount; | ||
| if (buildParamsAmount !== undefined && buildParamsAmount !== amountStr) { | ||
| throw new Error( | ||
| `verifyConfidentialTransfer: amount mismatch — txParams has '${amountStr}' but buildParams has '${buildParamsAmount}'` |
Comment on lines
+204
to
+210
| // 2. Recipient address must match txParams.recipients[0] when supplied | ||
| const expectedRecipient = txParams?.recipients?.[0]?.address; | ||
| if (expectedRecipient && decoded.toAddress.toLowerCase() !== expectedRecipient.toLowerCase()) { | ||
| throw new Error( | ||
| `verifyConfidentialTransfer: recipient address mismatch — ` + | ||
| `expected ${expectedRecipient}, got ${decoded.toAddress}` | ||
| ); |
Comment on lines
+701
to
+714
| export function decodeConfidentialTransferData(data: string): ConfidentialTransferData { | ||
| if (!data.startsWith(sendMultisigMethodId)) { | ||
| throw new BuildTransactionError(`Invalid confidential transfer bytecode: ${data}`); | ||
| } | ||
|
|
||
| const [tokenContractAddress, , internalData, expireTime, sequenceId, signature] = getRawDecoded( | ||
| sendMultiSigTypes, | ||
| getBufferedByteCode(sendMultisigMethodId, data) | ||
| ); | ||
|
|
||
| const internalDataHex = bufferToHex(internalData as Buffer); | ||
| if (!internalDataHex.startsWith(confidentialTransferWithProofMethodId)) { | ||
| throw new BuildTransactionError(`Invalid confidential transfer inner calldata: ${internalDataHex}`); | ||
| } |
Comment on lines
+439
to
+442
| txBuilder.sign({ key: testData.PRIVATE_KEY }); | ||
| const tx = await txBuilder.build(); | ||
| console.log('here is tx: ', tx); | ||
| return tx.toBroadcastFormat(); |
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.
TICKET: CHALO-529
This pull request adds support for confidential ERC-7984 token transfers to the Ethereum SDK. The main changes introduce a new
TransferBuilderERC7984class, extend transaction building and verification logic to handle the new confidential transfer type, and provide decoding utilities for confidential transfer calldata. Unit tests are also updated to cover the new functionality.ERC-7984 Confidential Transfer Support:
TransferBuilderERC7984inabstract-eth, enabling construction and serialization of confidential ERC-7984 token transfers, with validation for required fields likeencryptedHandleandinputProof.TransferBuilderERC7984from transfer builder index files for bothabstract-ethandsdk-coin-ethmodules. (F010bc2dR1, modules/sdk-coin-eth/src/lib/transferBuilders/index.tsL1-R8)Transaction Builder and Type Handling:
TransactionBuilderclasses in bothabstract-ethandsdk-coin-ethto support the newSendERC7984transaction type, including type checks, instantiation, and handling in relevant methods. [1] [2] [3] [4] [5] [6] [7] [8] [9]Confidential Transfer Decoding and Classification:
decodeConfidentialTransferDatautility to parse confidential transfer calldata from raw transaction data, extracting recipient, contract, handle, proof, and signature.SendERC7984by inspecting inner calldata.walletUtil.Verification Logic:
verifyConfidentialTransfermethod toErc7984Token, verifying contract address, recipient, and presence of confidential fields in decoded calldata, and integrated this check into the main transaction verification flow. [1] [2]Testing:
These changes collectively enable secure construction, parsing, and verification of confidential ERC-7984 token transfers within the SDK.