feat: add decryption delegation support for zama#8765
Conversation
3a15e27 to
88f9261
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for constructing (and partially classifying) Zama ERC-7984 “decryption delegation” transactions by introducing a new TransactionType, adding Zama calldata helpers + a dedicated builder in abstract-eth, and exposing that builder from the sdk-coin-eth ERC7984 token implementation.
Changes:
- Added
TransactionType.DecryptionDelegationtosdk-core. - Introduced
zamaUtilscalldata encoders and aDecryptionDelegationBuilderinabstract-eth(with unit tests). - Wired
abstract-ethtransaction building/classification paths to recognize the new transaction type (plussdk-coin-ethtoken-level access + a small integration test).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/sdk-core/src/account-lib/baseCoin/enum.ts | Adds new TransactionType.DecryptionDelegation. |
| modules/sdk-coin-eth/test/unit/transactionBuilder/decryptionDelegation.ts | Adds unit tests for enum presence + selector expectations. |
| modules/sdk-coin-eth/src/erc7984Token.ts | Exposes getDecryptionDelegationBuilder() on ERC7984 token coin class. |
| modules/abstract-eth/test/unit/zamaUtils.ts | Adds unit tests validating method IDs and calldata encoding helpers. |
| modules/abstract-eth/test/unit/index.ts | Exports new unit tests. |
| modules/abstract-eth/test/unit/decryptionDelegationBuilder.ts | Adds unit tests for DecryptionDelegationBuilder output in root + forwarder scenarios. |
| modules/abstract-eth/src/lib/zamaUtils.ts | Adds Zama ACL calldata helpers (single call, multicall, forwarder wrapping). |
| modules/abstract-eth/src/lib/utils.ts | Extends transaction classification map with the new method ID. |
| modules/abstract-eth/src/lib/transactionBuilder.ts | Treats DecryptionDelegation as a generic contract call for building + allows setting data(). |
| modules/abstract-eth/src/lib/index.ts | Exports the new utils/builder from the lib barrel. |
| modules/abstract-eth/src/lib/decryptionDelegationBuilder.ts | Adds builder producing {to,data,value} requests for Zama ACL delegation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
88f9261 to
efb8bdc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (3)
modules/abstract-eth/src/lib/utils.ts:735
- Mapping the global
multicall(bytes[])selector toDecryptionDelegationwill classify any contract call whose outer selector ismulticallas a Zama delegation.classifyTransaction()only looks at the first 4 bytes ofdataand has no contract-address context, so unrelated multicall transactions will get the new type and may hit unsupported-type paths instead of remaining genericContractCalls. Avoid classifying a ubiquitous selector this broadly, or decode/validate the inner calls before assigning this type.
[aclMulticallMethodId]: TransactionType.DecryptionDelegation,
modules/sdk-coin-eth/test/unit/transactionBuilder/decryptionDelegation.ts:45
- These tests verify the calldata selectors but never exercise the actual selector-to-
TransactionTypemapping (for example by callingclassifyTransactionor deserializing throughTransactionBuilder.from). As a result, the integration this file is meant to cover can regress even while these tests pass, especially for the forwarder-wrapped path whose outer selector iscallFromParent.
describe('decryption delegation calldata selectors', () => {
modules/abstract-eth/src/lib/transactionBuilder.ts:160
- A builder explicitly typed as
DecryptionDelegationstill cannot be built becauseBaseTransactionBuilder.build()callsvalidateTransaction()before this switch, andvalidateTransaction()has noDecryptionDelegationcase. Even withdata()allowed here,build()will throwUnsupported transaction typeinstead of reachingbuildGenericContractCallTransaction(). Add the same contract-address/data validation used forContractCall.
case TransactionType.DecryptionDelegation:
6cb180a to
f11864d
Compare
TICKET: CHALO-434
f11864d to
ac54106
Compare
TICKET: CHALO-434
This pull request introduces support for Zama ERC-7984 ACL decryption delegation transactions in the abstract-eth module. It adds a new builder and encoding utilities for constructing delegation transactions, updates transaction building logic to recognize and handle this new transaction type, and provides comprehensive unit tests to ensure correctness. The changes are grouped as follows:
1. Decryption Delegation Transaction Support
DecryptionDelegationBuilderindecryptionDelegationBuilder.tsto build wallet-provider-agnostic decryption delegation transactions, supporting both direct ACL calls and forwarder contract wrapping. This builder ensures all delegations are encoded as multicalls for consistency.zamaUtils.tswith encoding helpers fordelegateForUserDecryption, multicall batching, and forwarder wrapping, as well as constants for ABI method selectors.2. Transaction Builder and Type Handling
TransactionBuilderto support the newDecryptionDelegationtransaction type, allowing it to be built and to accept calldata via the existing contract call mechanism. [1] [2]utils.tsto recognize thedelegateForUserDecryptionselector and route it to the new transaction type. [1] [2]3. Exports and Test Coverage