farcasterxyz / contracts

Implementation of the Farcaster contracts
https://www.farcaster.xyz/
MIT License
340 stars 122 forks source link

chore: extract shared EIP712 base contract #370

Closed horsefacts closed 1 year ago

horsefacts commented 1 year ago

Motivation

As we've worked on consuming these contracts from Warpcast, we've added a few EIP-712 helper views. These are useful for clients debugging their own EIP-712 signatures. This PR cleans up our EIP712-related functionality and adds consistent helper views everywhere by extracting a shared abstract base contract.

Change Summary

Refactor all contracts using EIP-712 signatures to use our own EIP712 base contract, which inherits OZ EIP712 and exposes hashTypedDataV4 and domainSeparatorV4. Expose typehashes as public constants. Remove most test harness wrappers, which are no longer needed.

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review


PR-Codex overview

Detailed summary

This PR focuses on making several changes and improvements to the codebase. The notable changes include:

The following files were skipped due to too many changes: test/FnameResolver/FnameResolverTestSuite.sol, src/KeyRegistry.sol, src/validators/SignedKeyRequestValidator.sol, src/FnameResolver.sol, test/IdRegistry/IdRegistryTestSuite.sol, test/Deploy/DeployL1.t.sol, test/Utils.sol, src/IdRegistry.sol

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

github-actions[bot] commented 1 year ago

Coverage after merging horsefacts/shared-eip-712-contract into main will be

98.65%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   Bundler.sol100%100%100%100%
   FnameResolver.sol100%100%100%100%
   IdRegistry.sol100%100%100%100%
   KeyRegistry.sol100%100%100%100%
   StorageRegistry.sol100%100%100%100%
src/lib
   EIP712.sol50%100%50%50%19
   Signatures.sol100%100%100%100%
   TransferHelper.sol0%0%0%0%12, 17, 20, 20, 20
   TrustedCaller.sol100%100%100%100%
src/validators
   SignedKeyRequestValidator.sol100%100%100%100%