Skip to content

Implement direct support for EIP-7702 and EIP-5792 in WallyWatcherV1 contract#2

Draft
schmrdty with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-6dd1b720-9445-4a88-8c06-05d5f9ef51ae
Draft

Implement direct support for EIP-7702 and EIP-5792 in WallyWatcherV1 contract#2
schmrdty with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-6dd1b720-9445-4a88-8c06-05d5f9ef51ae

Conversation

Copilot AI commented Jun 11, 2025

Copy link
Copy Markdown

This PR implements comprehensive support for EIP-7702 (Set EOA code for one transaction) and EIP-5792 (Wallet API) in the WallyWatcherV1 contract, enabling advanced wallet automation capabilities while maintaining full backward compatibility.

🚀 Features Implemented

EIP-7702: Temporary Contract Code

  • Temporary Code Setting: EOAs can temporarily install contract code with time-bound expiration
  • Atomic Execution: Complex operations execute atomically with temporary code context
  • Automatic Cleanup: Temporary code expires automatically with proper event emission
  • Permission Integration: All existing permission and session checks remain atomic with code changes

EIP-5792: Wallet API

  • Standardized Methods: eth_sendTransaction, eth_sign, wallet_requestPermissions, wallet_getPermissions
  • Permission Mapping: Internal permission system mapped to EIP-5792 standard
  • Granular Control: Method-specific permissions with expiration management
  • dApp Integration: Standardized interface for seamless dApp interaction

🔧 Technical Implementation

Smart Contract Enhancements

New Functions:

// EIP-7702 Functions
function setTemporaryCode(address account, bytes32 codeHash, uint256 expiresAt, uint256 nonce, bytes memory signature)
function resetTemporaryCode(address account)
function executeWithTemporaryCode(address account, address target, bytes calldata data, uint256 value)
function getTemporaryCode(address account) view returns (bool active, bytes32 codeHash, uint256 expiresAt)

// EIP-5792 Functions  
function wallet_requestPermissions(address account, string[] calldata methods, uint256 expiresAt, uint256 nonce, bytes memory signature)
function wallet_getPermissions(address account) view returns (string[] memory methods, uint256 expiresAt, bool active)
function eth_sendTransaction(address account, address to, uint256 value, bytes calldata data)
function eth_sign(address account, bytes32 dataHash) view returns (bytes memory signature)
function wallet_revokePermissions(address account)

Enhanced Transfer Functions:

  • triggerTransfers() and miniAppTriggerTransfers() now leverage temporary code context when active
  • Atomic execution ensures all operations maintain consistency

Backend API Endpoints

// EIP-7702 Routes
POST /api/eip7702/setTemporaryCode
POST /api/eip7702/resetTemporaryCode  
POST /api/eip7702/executeWithTemporaryCode
GET  /api/eip7702/getTemporaryCode/:account

// EIP-5792 Routes
POST /api/eip5792/wallet_requestPermissions
GET  /api/eip5792/wallet_getPermissions/:account
POST /api/eip5792/eth_sendTransaction
POST /api/eip5792/eth_sign
POST /api/eip5792/wallet_revokePermissions

Frontend Integration

React Hook:

const {
    setTemporaryCode, resetTemporaryCode, executeWithTemporaryCode, getTemporaryCode,
    requestWalletPermissions, getWalletPermissions, sendTransaction, signData, revokeWalletPermissions
} = useEIPSupport();

🔒 Security & Quality Assurance

  • EIP-712 Signatures: All operations require proper signature verification
  • Time-bounded Operations: Temporary code and permissions have expiration timestamps
  • Non-reentrancy Protection: Critical functions protected against reentrancy attacks
  • Rate Limiting: All functions subject to existing rate limiting controls
  • Access Controls: Granular permission checks for all operations
  • Event Logging: Comprehensive audit trail with new events:
    • TemporaryCodeSet, TemporaryCodeReset, TemporaryCodeExpired
    • WalletPermissionGranted, WalletPermissionRevoked, WalletMethodCalled

📚 Documentation

Added comprehensive documentation in docs/EIP_IMPLEMENTATION.md covering:

  • Detailed function specifications
  • Usage examples and integration guides
  • Security considerations and best practices
  • Migration guide ensuring backward compatibility

🔄 Backward Compatibility

Zero Breaking Changes

  • All existing functionality preserved unchanged
  • Original transfer functions enhanced but maintain same API
  • Session management and permission system fully compatible
  • Event structure extended without modifying existing events

📁 Files Modified

  • contracts/wallyv1.sol - Core contract implementation
  • backend/src/services/wallyService.ts - Service layer integration
  • backend/src/routes/eipRoutes.ts - New API endpoints
  • frontend/src/abis/wallyv1ExtendedAbi.ts - Extended contract ABI
  • frontend/src/hooks/useEIPSupport.ts - React integration hook
  • docs/EIP_IMPLEMENTATION.md - Comprehensive documentation

🎯 Usage Example

// EIP-7702: Atomic multi-step operation
await setTemporaryCode(account, codeHash, expiresAt, nonce, signature);
await executeWithTemporaryCode(account, target, encodedCall, value);

// EIP-5792: Standardized wallet interaction
await requestWalletPermissions(account, ["eth_sendTransaction"], expiresAt, nonce, signature);
const permissions = await getWalletPermissions(account);
if (permissions.active) {
    await sendTransaction(account, recipient, "0.1", "0x");
}

This implementation provides a solid foundation for advanced wallet automation while maintaining the security and reliability that users expect from the WallyWatcherV1 system.

Copilot AI and others added 2 commits June 11, 2025 02:21
Co-authored-by: schmrdty <157736992+schmrdty@users.noreply.github.com>
Co-authored-by: schmrdty <157736992+schmrdty@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
21.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copilot AI changed the title [WIP] Implement direct EIP-7702 and EIP-5792 support in WallyWatcherV1 contract Implement direct support for EIP-7702 and EIP-5792 in WallyWatcherV1 contract Jun 11, 2025
Copilot AI requested a review from schmrdty June 11, 2025 02:24
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