Skip to content

feat(sdk-coin-eth): add zama token withdrawal support#8919

Draft
MohammedRyaan786 wants to merge 1 commit into
masterfrom
CHALO-529
Draft

feat(sdk-coin-eth): add zama token withdrawal support#8919
MohammedRyaan786 wants to merge 1 commit into
masterfrom
CHALO-529

Conversation

@MohammedRyaan786
Copy link
Copy Markdown
Contributor

@MohammedRyaan786 MohammedRyaan786 commented Jun 2, 2026

TICKET: CHALO-529

This pull request adds support for confidential ERC-7984 token transfers to the Ethereum SDK. The main changes introduce a new TransferBuilderERC7984 class, 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:

  • Introduced TransferBuilderERC7984 in abstract-eth, enabling construction and serialization of confidential ERC-7984 token transfers, with validation for required fields like encryptedHandle and inputProof.
  • Exported TransferBuilderERC7984 from transfer builder index files for both abstract-eth and sdk-coin-eth modules. (F010bc2dR1, modules/sdk-coin-eth/src/lib/transferBuilders/index.tsL1-R8)

Transaction Builder and Type Handling:

  • Updated TransactionBuilder classes in both abstract-eth and sdk-coin-eth to support the new SendERC7984 transaction type, including type checks, instantiation, and handling in relevant methods. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Confidential Transfer Decoding and Classification:

  • Added decodeConfidentialTransferData utility to parse confidential transfer calldata from raw transaction data, extracting recipient, contract, handle, proof, and signature.
  • Enhanced transaction classification logic to detect and classify confidential transfers as SendERC7984 by inspecting inner calldata.
  • Defined new method IDs and ABI types for confidential transfer calls in walletUtil.

Verification Logic:

  • Added verifyConfidentialTransfer method to Erc7984Token, 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:

  • Updated unit tests to cover confidential transfer verification and the new builder. [1] [2]

These changes collectively enable secure construction, parsing, and verification of confidential ERC-7984 token transfers within the SDK.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 2, 2026

CHALO-529

Copy link
Copy Markdown

Copilot AI left a 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 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 TransferBuilderERC7984 to build/sign sendMultiSig-wrapped confidentialTransfer(...) calldata and exports it through abstract-eth and sdk-coin-eth.
  • Adds SendERC7984 transaction type and updates tx builders / classification logic to recognize confidential transfers by inspecting inner calldata.
  • Extends Erc7984Token.verifyTransaction with 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants