Contract Architecture
Contract architecture thats used in Email Wallet
Core
EmailWalletCore.sol
- The main contract that implements functions likehandleEmailOp
. To keep the contract simple, we have split other functionalities to many "handlers".handlers/RelayerHandler.sol
- Handles operations to register and update Relayer config.handlers/AccountHandler.sol
- Handles account related operations likecreateAccount
,initAccount
,transpotAccount
, and wallet related functions.handlers/UnclaimsHandler.sol
- Handles operations related to Unclaimed Funds and Unclaimed States.handlers/ExtensionHandler.sol
- Handles operations related to publishing and installing Extensions.
Wallet
Wallet.sol
- Wallet contract deployed for each user (account). The owner of the wallet contract can execute any call data on a target. By default Core contract is the owner of the wallet contract.
Interfaces
interfaces/Types.sol
- Contains all the structs used in the contract including EmailOp.interfaces/Commands.sol
- Defines the commands used for EmailOps.interfaces/Events.sol
- Defines all events emitted by the contract.interfaces/IVerifier.sol
- Defines the interface for the ZK proof verifier contract.interfaces/IPriceOracle.sol
- Defines the interface for price oracle used for fee calculation.interfaces/Extension.sol
- Defines the interface for an Extension contract.
Libraries
libraries/SubjectUtils.sol
- Contains helper functions to compute the subject line from an EmailOp.libraries/DecimalUtils.sol
- Contains helper functions to convert uint to decimal string.
Util contracts
utils/TokenRegistry.sol
- TokenRegistry contract that stores the address of ERC20 tokens by their names (and reverse) across multiple chains.utils/UniswapTWAPOracle.sol
- UniswapTWAPOracle contract that provides the TWAP price of a token in ETH.utils/ECDSAOwnedDKIMRegistry.sol
- A custom DKIM registry that allows a ECDSA signer to set the DKIM public key for a domain.
Default extensions
extensions/NFTExtension.sol
- NFT wallet extensions to send NFTs.extensions/UniswapExtension.sol
- Uniswap wallet extension to swap tokens on Uniswap.
Circuit verifiers
verifier/Verifier.sol
- All verifiersverifier/AccountCreationVerifier.sol
- Verifier forAccountCreation
circuit.verifier/AccountInitVerifier.sol
- Verifier forAccountInit
circuit.verifier/EmailSenderVerifier.sol
- Verifier forEmailSender
circuit.verifier/ClaimVerifier.sol
- Verifier forClaim
circuit.verifier/AccountTransportVerifier.sol
- Verifier forAccountTransport
circuit.verifier/AnnouncementVerifier.sol
- Verifier forAnnouncement
circuit.
Tests
tests/*.t.sol
- Contains unit tests for all contracts/functionalities.tests/Integration.t.sol
- Contains all integration tests. Integration tests generate the proof using the circuit and verify it using contracts. Before running those tests, you need to make apackages/contracts/test/build_integration
directory, download the zip file from the following link, and place its unziped files under that directory. https://drive.google.com/file/d/1pe07fwKbtjMLHoQSY8Bcr4rg9aN06mFP/view?usp=sharing
Build and Test
Make sure you have Foundry installed
Build the contracts using the below command.
Run unit tests
Run integration tests Run each integration tests one by one as each test will consume lot of memory.
Deploy Contracts
You can either deploy all contracts at once or deploy each contract separately.
Deploy all contracts at once
Create .env
Run
Deploy each contract separately
Run the below commands to deploy each contracts. Ensure address of WETH and Uniswap Price oracle on the target chain.
Deploy Token Registry
Copy the address from log TokenRegistry implementation deployed at: 0x9f44be9F69aF1e049dCeCDb2d9296f36C49Ceafb
Deploy All Verifiers
Copy the address from log AllVerifiers implementation deployed at: 0x9f44be9F69aF1e049dCeCDb2d9296f36C49Ceafb
Deploy DKIM Registry
Copy the address from log DKIMRegistry implementation deployed at: 0xbE66454b0Fa9E6b3D53DC1b0f9D21978bb864531
Deploy Uniswap TWAP Oracle
Copy the address from log UniswapTWAPOracle deployed at: 0x0000000000000000000000000000000000000000
Deploy Wallet
Copy the address from log Wallet proxy deployed at: 0x0000000000000000000000000000000000000000
Deploy Handlers
Copy the addresses from log
Deploy Email Wallet Core
Copy the addresses from log:
Deploy Extensions
Copy the addresses from log:
Deploy ECDSAOwnedDKIMRegistry
Set the SIGNER
to the address of the Ethereum wallet who will be setting the DKIM public key for a domain.
Copy the address from log ECDSAOwnedDKIMRegistry deployed at: 0xB50a02E2Da524feC1209542985b2ae2917aF7265
Upgrade Contracts
Upgrade Token Registry
Run
Last updated