Skip to content

Add additional functions to IERC7984ERC20Wrapper#323

Merged
arr00 merged 15 commits intomasterfrom
chore/update-ierc7984erc20wrapper
Mar 11, 2026
Merged

Add additional functions to IERC7984ERC20Wrapper#323
arr00 merged 15 commits intomasterfrom
chore/update-ierc7984erc20wrapper

Conversation

@arr00
Copy link
Copy Markdown
Member

@arr00 arr00 commented Mar 10, 2026

This PR adds finalizeUnwrap, rate, and unwrapAmount to the wrapper interface. We keep it unopinionated by moving away from directly using a euint64 of the unwrap amount to a bytes32 unwrapRequestId. In our implementation the unwrapRequestId is still simply the unwrap amount.

This interface is enough now to solely use it to interact with a wrapper contract.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added finalization function for token unwrapping with decryption proof validation
    • Added rate query function to token wrapper interface
  • Updates

    • Modified unwrap operation to return request identifier instead of amount value
    • Updated tests and interface definitions to reflect new unwrap workflow

@arr00 arr00 requested a review from a team as a code owner March 10, 2026 14:18
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 10, 2026

Deploy Preview for confidential-tokens ready!

Name Link
🔨 Latest commit 2f9d572
🔍 Latest deploy log https://app.netlify.com/projects/confidential-tokens/deploys/69b0e49fde34f30008b016d6
😎 Deploy Preview https://deploy-preview-323--confidential-tokens.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04f96bd8-d54b-4a6d-93a2-d16e95bce8e7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

Refactors the unwrap mechanism in ERC7984 wrapper contracts and BatcherConfidential, replacing the stored unwrapAmount (euint64) with unwrapRequestId (bytes32), updating method signatures, return types, and related getter functions throughout the contracts and tests.

Changes

Cohort / File(s) Summary
Core Contract Refactoring
contracts/finance/BatcherConfidential.sol
Renamed Batch.unwrapAmount field from euint64 to unwrapRequestId (bytes32). Updated dispatchBatch to store the request ID, replaced unwrapAmount(batchId) getter with unwrapRequestId(batchId), and updated batchState logic to check the new request ID field.
Wrapper Interface Updates
contracts/interfaces/IERC7984ERC20Wrapper.sol
Changed unwrap() return type from euint64 to bytes32. Added new finalizeUnwrap(bytes32 unwrapRequestId, uint64 unwrapAmountCleartext, bytes calldata decryptionProof) method and rate() view function to the interface.
Wrapper Implementation Changes
contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol
Updated both unwrap() overloads to return bytes32 instead of euint64. Modified finalizeUnwrap() signature to accept unwrapRequestId (bytes32) instead of unwrapAmount (euint64), with internal logic deriving the euint64 amount from the request ID.
Test Updates
test/finance/BatcherConfidential.test.ts
Updated test calls from unwrapAmount(batchId) to unwrapRequestId(batchId) to reflect the renamed public getter method.
Interface Test Helpers
test/helpers/interface.ts
Extended ERC7984ERC20Wrapper signature list in SIGNATURES mapping to include finalizeUnwrap(bytes32,uint64,bytes) and rate() methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ignore-changeset

Suggested reviewers

  • james-toussaint
  • Amxx

Poem

🐰 Request IDs dance where amounts once stood,
Unwrapping secrets as a rabbit should,
Bytes32 replaces euint with grace,
Finalized and wrapped—a cleaner space! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and does not adequately summarize the main changes. The PR involves significant API refactoring including renaming unwrapAmount to unwrapRequestId across multiple contracts and changing return types, not just adding functions. Consider a more specific title that reflects the key change, such as 'Refactor unwrap API to use request IDs instead of amounts' or 'Update unwrap interface to return bytes32 requestId'.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/update-ierc7984erc20wrapper

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@contracts/interfaces/IERC7984ERC20Wrapper.sol`:
- Around line 33-44: The contract exposes finalizeUnwrap(unwrapRequestId,
unwrapAmountCleartext, decryptionProof) but lacks a way to validate or resolve
an opaque unwrapRequestId into the decryptable handle/amount; add a companion
API such as resolveUnwrapRequest(bytes32 unwrapRequestId) external view returns
(uint64 unwrapAmountCleartext, bytes decryptableHandle) or
validateUnwrapRequest(bytes32 unwrapRequestId, uint64 unwrapAmountCleartext,
bytes calldata proof) external view returns (bool) so callers (e.g.,
BatcherConfidential.dispatchBatchCallback()) can either resolve the id to the
original cleartext/handle or verify (unwrapRequestId, cleartext, proof) before
retry/finalize; implement the function signature in the interface and ensure
downstream code uses it to check matching amounts/handles prior to calling
finalizeUnwrap.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f76e0c4b-9620-48af-b8db-6677a951ad4d

📥 Commits

Reviewing files that changed from the base of the PR and between 60c00db and 6e89b8c.

📒 Files selected for processing (5)
  • contracts/finance/BatcherConfidential.sol
  • contracts/interfaces/IERC7984ERC20Wrapper.sol
  • contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol
  • test/finance/BatcherConfidential.test.ts
  • test/helpers/interface.ts

@arr00 arr00 merged commit 9b47bca into master Mar 11, 2026
16 checks passed
@arr00 arr00 deleted the chore/update-ierc7984erc20wrapper branch March 11, 2026 04:41
arr00 added a commit that referenced this pull request Mar 11, 2026
* remove incorrect docs on `unwrap` function

* add finalize unwrap and rate to wrapper interface

* update batcher to use unwrap request ids instead of unwrap amounts

* add `unwrapAmount` to wrapper interface for unwrap request introspection

* additional docs

* call getter for `unwrapAmount` in `finalizeUnwrap`

* update events and errors appropriately

* remove `ERC7984ERC20Wrapper` import

* fix import order

* Move events to interface from `ERC7984ERC20Wrapper`

* add note on request id for `unwrap`

* change mapping to be of `bytes32` identifiers

* add changeset
@coderabbitai coderabbitai bot mentioned this pull request Mar 30, 2026
arr00 added a commit that referenced this pull request Apr 1, 2026
* Start release candidate

* Fix local docs generation (#320)

* remove properties symlink

* add properties.js

* lint fix

* Remove backwards compatibility from Batcher (#321)

* Remove backwards compatibility from Batcher

* Apply suggestion from @arr00

* Validate `fromToken` and `toToken` on construction (#322)

* Validate `fromToken` on construction

* use `ERC165Checker`

* check toToken as well

* directly validate to and from token

* Add additional functions to `IERC7984ERC20Wrapper` (#323)

* remove incorrect docs on `unwrap` function

* add finalize unwrap and rate to wrapper interface

* update batcher to use unwrap request ids instead of unwrap amounts

* add `unwrapAmount` to wrapper interface for unwrap request introspection

* additional docs

* call getter for `unwrapAmount` in `finalizeUnwrap`

* update events and errors appropriately

* remove `ERC7984ERC20Wrapper` import

* fix import order

* Move events to interface from `ERC7984ERC20Wrapper`

* add note on request id for `unwrap`

* change mapping to be of `bytes32` identifiers

* add changeset

* Allow claiming on behalf of another account in batcher (#324)

* Allow claiming on behalf of another account in batcher

* revert on claim if users not part of the batch

* add error on quit too

* Add additional warnings to the batcher (#325)

* Return a bytes32 unwrap id from the `_unwrap` function in `BatcherConfidential` (#326)

* Return a bytes32 unwrap id from the `_unwrap` function in `BatcherConfidential`

* modify warning

* Document possible rounding down of user deposits (#327)

* Document possible rounding down of user deposits

* add contract level comment as well

* up

* Release v0.4.0 (rc) (#318)

* Release v0.4.0 (rc)

* update changelog

* update changelog

* Apply suggestion from @james-toussaint

Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>
Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>

* Update node version to 24.x in CI (#328)

* Exit release candidate

* Release v0.4.0 (#335)

* Release v0.4.0

* update changelog

* remove changelog duplicate

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>
Co-authored-by: James Toussaint <33313130+james-toussaint@users.noreply.github.com>
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