Skip to content

feat: add decryption delegation support for zama#8765

Merged
MohammedRyaan786 merged 1 commit into
masterfrom
CHALO-434
May 14, 2026
Merged

feat: add decryption delegation support for zama#8765
MohammedRyaan786 merged 1 commit into
masterfrom
CHALO-434

Conversation

@MohammedRyaan786
Copy link
Copy Markdown
Contributor

@MohammedRyaan786 MohammedRyaan786 commented May 13, 2026

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

  • Added DecryptionDelegationBuilder in decryptionDelegationBuilder.ts to 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.
  • Introduced zamaUtils.ts with encoding helpers for delegateForUserDecryption, multicall batching, and forwarder wrapping, as well as constants for ABI method selectors.

2. Transaction Builder and Type Handling

  • Updated TransactionBuilder to support the new DecryptionDelegation transaction type, allowing it to be built and to accept calldata via the existing contract call mechanism. [1] [2]
  • Extended the transaction type mapping in utils.ts to recognize the delegateForUserDecryption selector and route it to the new transaction type. [1] [2]

3. Exports and Test Coverage

  • Exported the new builder and utility functions from the module entry point for external use.
  • Added thorough unit tests for the builder, covering both root wallet and forwarder scenarios, parameter isolation, error handling, and value field correctness.
  • Included the new test files in the test index for proper test suite coverage.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 13, 2026

CHALO-434

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 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.DecryptionDelegation to sdk-core.
  • Introduced zamaUtils calldata encoders and a DecryptionDelegationBuilder in abstract-eth (with unit tests).
  • Wired abstract-eth transaction building/classification paths to recognize the new transaction type (plus sdk-coin-eth token-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.

Comment thread modules/sdk-core/src/account-lib/baseCoin/enum.ts
Comment thread modules/abstract-eth/src/lib/utils.ts
Comment thread modules/sdk-coin-eth/test/unit/transactionBuilder/decryptionDelegation.ts Outdated
Comment thread modules/sdk-coin-eth/test/unit/transactionBuilder/decryptionDelegation.ts Outdated
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

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 to DecryptionDelegation will classify any contract call whose outer selector is multicall as a Zama delegation. classifyTransaction() only looks at the first 4 bytes of data and has no contract-address context, so unrelated multicall transactions will get the new type and may hit unsupported-type paths instead of remaining generic ContractCalls. 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-TransactionType mapping (for example by calling classifyTransaction or deserializing through TransactionBuilder.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 is callFromParent.
  describe('decryption delegation calldata selectors', () => {

modules/abstract-eth/src/lib/transactionBuilder.ts:160

  • A builder explicitly typed as DecryptionDelegation still cannot be built because BaseTransactionBuilder.build() calls validateTransaction() before this switch, and validateTransaction() has no DecryptionDelegation case. Even with data() allowed here, build() will throw Unsupported transaction type instead of reaching buildGenericContractCallTransaction(). Add the same contract-address/data validation used for ContractCall.
      case TransactionType.DecryptionDelegation:

Comment thread modules/abstract-eth/src/lib/transactionBuilder.ts
Comment thread modules/abstract-eth/src/lib/utils.ts Outdated
Comment thread modules/abstract-eth/src/lib/zamaUtils.ts
Comment thread modules/abstract-eth/src/lib/zamaUtils.ts Outdated
Comment thread modules/sdk-coin-eth/test/unit/transactionBuilder/decryptionDelegation.ts Outdated
Comment thread modules/abstract-eth/src/lib/decryptionDelegationBuilder.ts
@MohammedRyaan786 MohammedRyaan786 force-pushed the CHALO-434 branch 4 times, most recently from 6cb180a to f11864d Compare May 14, 2026 07:54
@MohammedRyaan786 MohammedRyaan786 marked this pull request as ready for review May 14, 2026 14:02
@MohammedRyaan786 MohammedRyaan786 requested review from a team as code owners May 14, 2026 14:02
@MohammedRyaan786 MohammedRyaan786 merged commit d697e42 into master May 14, 2026
33 of 34 checks passed
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.

3 participants