Skip to content

[SDK] buildUnwrapCalldata + UnwrapERC7984 explain/verify - #9509

Merged
0xPrabh merged 1 commit into
masterfrom
CHALO-1155
Aug 18, 2026
Merged

[SDK] buildUnwrapCalldata + UnwrapERC7984 explain/verify#9509
0xPrabh merged 1 commit into
masterfrom
CHALO-1155

Conversation

@0xPrabh

@0xPrabh 0xPrabh commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Adds buildUnwrapCalldata(from, to, encryptedAmount, inputProof) and UnwrapERC7984 transaction support for the ERC-7984 unshield path.

  • Encodes unwrap(address,address,bytes32,bytes) with selector 0x5bf4ef06
  • Validates checksummed from/to, 32-byte encryptedAmount, non-empty inputProof
  • Adds TransactionType.UnwrapERC7984 with builder + classifyTransaction mapping
  • Erc7984Token.verifyTransaction unwrap branch (direct + sendMultiSig); self-directed from == to == baseAddress
  • Does not set gasLimit (WP owns gas)

Issue Number

CHALO-1155

Parent: CHALO-1135

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • yarn workspace @bitgo/abstract-eth unit-test --grep "buildUnwrapCalldata|Method IDs" (13 passing)
  • BITGOJS_TEST_PASSWORD=password yarn workspace @bitgo/sdk-coin-eth unit-test --grep "UnwrapERC7984|verifyTransaction – Unwrap" (12 passing)
  • eslint on touched files

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My commits follow Conventional Commits and I have properly described any BREAKING CHANGES
  • The ticket or github issue was included in the commit message as a reference
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Made with Cursor

@0xPrabh
0xPrabh requested review from a team as code owners August 17, 2026 06:36
@linear-code

linear-code Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

CHALO-1155

…/verify

Encode unwrap(from, to, encryptedAmount, inputProof) for ERC-7984 unshield
(selector 0x5bf4ef06), add UnwrapERC7984 tx type with builder classification,
and verify self-directed unwrap calldata (from/to == wallet base address).

Ticket: CHALO-1155
Co-authored-by: Cursor <cursoragent@cursor.com>
@Venkat-Annavazzala

Copy link
Copy Markdown
Contributor

@claude

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Claude finished @Venkat-Annavazzala's task —— View job


Code Review for ERC-7984 Unwrap Implementation ✅

Todo List:

  • Read repository guidelines (CLAUDE.md)
  • Review core implementation in abstract-eth
  • Review ERC-7984 token integration in sdk-coin-eth
  • Review test coverage and quality
  • Check enum additions in sdk-core
  • Provide comprehensive feedback

Code Review Summary

This PR implements comprehensive ERC-7984 unwrap (unshield) functionality across the BitGoJS SDK. The implementation is well-structured, thoroughly tested, and follows established patterns.

Strengths

  1. Comprehensive Implementation

    • Properly integrates across all layers: abstract-eth, sdk-coin-eth, and sdk-core
    • Follows existing patterns from WrapERC7984 implementation
    • Maintains consistency with the codebase architecture
  2. Robust Validation

    • Proper address validation with EIP-55 checksum support (modules/abstract-eth/src/lib/zamaUtils.ts:226-234)
    • Input validation for 32-byte encryptedAmount and non-empty inputProof (zamaUtils.ts:236-241)
    • Self-directed transaction validation (from == to == baseAddress) (modules/sdk-coin-eth/src/erc7984Token.ts:354-364)
  3. Strong Security Checks

    • Validates wrapper contract address matches expected token contract (erc7984Token.ts:340-347)
    • Enforces zero-value transactions to prevent ETH loss (erc7984Token.ts:367-370)
    • Validates transaction structure for both TSS and multisig paths (erc7984Token.ts:323-347)
  4. Excellent Test Coverage

    • 25+ unit tests across both abstract-eth and sdk-coin-eth modules
    • Tests round-trip encoding/decoding (modules/abstract-eth/test/unit/zamaUtils.ts:260-266)
    • Validates both TSS and multisig transaction shapes (modules/sdk-coin-eth/test/unit/erc7984Token.ts:1651-1675)
    • Comprehensive error handling tests for invalid inputs
  5. Proper ABI Implementation

    • Correct method ID calculation: 0x5bf4ef06 for unwrap(address,address,bytes32,bytes) (zamaUtils.ts:64)
    • Proper ABI encoding/decoding with buffer handling (zamaUtils.ts:244-248)
    • Transaction classification support (modules/abstract-eth/src/lib/utils.ts:957)

🔍 Technical Details

  • Function Signature: unwrap(address from, address to, bytes32 encryptedAmount, bytes inputProof)
  • Transaction Types: Supports both direct calls (TSS) and sendMultiSig wrapped calls
  • Validation: Self-directed only (Phase 1) - from == to == wallet.baseAddress
  • Gas Handling: Correctly omits gasLimit setting as WP owns gas

📚 Code Quality

  • Documentation: Comprehensive JSDoc comments explaining functionality and parameters
  • Error Messages: Clear, descriptive error messages with context
  • TypeScript: Proper interface definitions (UnwrapERC7984Data) and type safety
  • Patterns: Follows established SDK patterns for transaction builders and verification

Repository Compliance

  • Follows BitGoJS conventional commit standards
  • Adheres to TypeScript guidelines (no any types)
  • Maintains modular architecture with appropriate abstractions
  • Proper enum additions in sdk-core for TransactionType.UnwrapERC7984

Recommendation: APPROVE

This is a high-quality implementation that demonstrates strong engineering practices. The code is production-ready with excellent test coverage, proper validation, and clear documentation. The implementation correctly follows the ERC-7984 standard and integrates seamlessly with the existing BitGoJS architecture.


Job Run | Branch: CHALO-1155

@0xPrabh
0xPrabh merged commit d55d580 into master Aug 18, 2026
25 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.

2 participants