Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,52 @@ DelegatecallGuardTest:test_direct_call_reverts_NotDelegateCall() (gas: 8420)
DelegatecallGuardTest:test_multiple_delegatecall_guards() (gas: 298825)
DelegatecallGuardTest:test_onlyDelegatecall_modifier_usage() (gas: 98867)
DelegatecallGuardTest:test_self_address_immutable() (gas: 2877)
TrailsIntentEntrypointDeploymentTest:test_DeployIntentEntrypoint_SameAddress() (gas: 823979)
TrailsIntentEntrypointDeploymentTest:test_DeployIntentEntrypoint_Success() (gas: 816517)
TrailsIntentEntrypointDeploymentTest:test_DeployedIntentEntrypoint_HasCorrectConfiguration() (gas: 819316)
TrailsIntentEntrypointTest:testAssemblyCodeExecution() (gas: 89389)
TrailsIntentEntrypointDeploymentTest:test_DeployIntentEntrypoint_SameAddress() (gas: 850262)
TrailsIntentEntrypointDeploymentTest:test_DeployIntentEntrypoint_Success() (gas: 843491)
TrailsIntentEntrypointDeploymentTest:test_DeployedIntentEntrypoint_HasCorrectConfiguration() (gas: 846367)
TrailsIntentEntrypointTest:testAssemblyCodeExecution() (gas: 90651)
TrailsIntentEntrypointTest:testConstructor() (gas: 3375)
TrailsIntentEntrypointTest:testConstructorAndDomainSeparator() (gas: 7775)
TrailsIntentEntrypointTest:testDepositToIntentAlreadyUsed() (gas: 114213)
TrailsIntentEntrypointTest:testDepositToIntentCannotReuseDigest() (gas: 94919)
TrailsIntentEntrypointTest:testDepositToIntentExpiredDeadline() (gas: 56099)
TrailsIntentEntrypointTest:testDepositToIntentReentrancyProtection() (gas: 114191)
TrailsIntentEntrypointTest:testDepositToIntentRequiresNonZeroAmount() (gas: 27419)
TrailsIntentEntrypointTest:testDepositToIntentRequiresValidToken() (gas: 30824)
TrailsIntentEntrypointTest:testDepositToIntentTransferFromFails() (gas: 58487)
TrailsIntentEntrypointTest:testDepositToIntentWithFeeAmountButNoCollector_Reverts() (gas: 112145)
TrailsIntentEntrypointTest:testDepositToIntentWithFeeCollectorButNoAmount_Reverts() (gas: 90113)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitAlreadyUsed() (gas: 132840)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitExpiredDeadline() (gas: 36541)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitReentrancyProtection() (gas: 124239)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitRequiresNonZeroAmount() (gas: 35255)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitRequiresPermitAmount() (gas: 60824)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitRequiresValidToken() (gas: 35981)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitTransferFromFails() (gas: 60031)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitWithFeeAmountButNoCollector_Reverts() (gas: 140717)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitWithFeeCollectorButNoAmount_Reverts() (gas: 120296)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitWrongSigner() (gas: 40532)
TrailsIntentEntrypointTest:testDepositToIntentWithoutPermit_RequiresIntentAddress() (gas: 31533)
TrailsIntentEntrypointTest:testDepositToIntentWrongSigner() (gas: 57349)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20AndFee_Success() (gas: 809616)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20_InsufficientAllowance_Reverts() (gas: 772365)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20_InsufficientBalance_Reverts() (gas: 772324)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20_Success() (gas: 780514)
TrailsIntentEntrypointTest:testExactApprovalFlow() (gas: 150550)
TrailsIntentEntrypointTest:testExecuteIntentWithFee() (gas: 153720)
TrailsIntentEntrypointTest:testExecuteIntentWithPermit() (gas: 123362)
TrailsIntentEntrypointTest:testExecuteIntentWithPermitExpired() (gas: 36460)
TrailsIntentEntrypointTest:testExecuteIntentWithPermitInvalidSignature() (gas: 37754)
TrailsIntentEntrypointTest:testExecuteIntentWithPermit_permit_frontrun() (gas: 128224)
TrailsIntentEntrypointTest:testFeeCollectorReceivesFees() (gas: 147872)
TrailsIntentEntrypointTest:testFeeCollectorReceivesFeesWithoutPermit() (gas: 117534)
TrailsIntentEntrypointTest:testInfiniteApprovalFlow() (gas: 144843)
TrailsIntentEntrypointTest:testConstructorAndDomainSeparator() (gas: 8493)
TrailsIntentEntrypointTest:testDepositToIntentAlreadyUsed() (gas: 115475)
TrailsIntentEntrypointTest:testDepositToIntentCannotReuseDigest() (gas: 96181)
TrailsIntentEntrypointTest:testDepositToIntentExpiredDeadline() (gas: 56739)
TrailsIntentEntrypointTest:testDepositToIntentReentrancyProtection() (gas: 115453)
TrailsIntentEntrypointTest:testDepositToIntentRequiresNonZeroAmount() (gas: 28059)
TrailsIntentEntrypointTest:testDepositToIntentRequiresValidToken() (gas: 31464)
TrailsIntentEntrypointTest:testDepositToIntentTransferFromFails() (gas: 59749)
TrailsIntentEntrypointTest:testDepositToIntentWithFeeAmountButNoCollector_Reverts() (gas: 113407)
TrailsIntentEntrypointTest:testDepositToIntentWithFeeCollectorButNoAmount_Reverts() (gas: 91375)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitAlreadyUsed() (gas: 134736)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitExpiredDeadline() (gas: 37181)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitReentrancyProtection() (gas: 125513)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitRequiresNonZeroAmount() (gas: 35895)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitRequiresPermitAmount() (gas: 62086)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitRequiresValidToken() (gas: 36621)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitTransferFromFails() (gas: 61293)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitWithFeeAmountButNoCollector_Reverts() (gas: 141991)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitWithFeeCollectorButNoAmount_Reverts() (gas: 121570)
TrailsIntentEntrypointTest:testDepositToIntentWithPermitWrongSigner() (gas: 41794)
TrailsIntentEntrypointTest:testDepositToIntentWithoutPermit_RequiresIntentAddress() (gas: 32173)
TrailsIntentEntrypointTest:testDepositToIntentWrongSigner() (gas: 58611)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20AndFee_Success() (gas: 810878)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20_InsufficientAllowance_Reverts() (gas: 773627)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20_InsufficientBalance_Reverts() (gas: 773586)
TrailsIntentEntrypointTest:testDepositToIntent_WithNonStandardERC20_Success() (gas: 781776)
TrailsIntentEntrypointTest:testExactApprovalFlow() (gas: 152588)
TrailsIntentEntrypointTest:testExecuteIntentWithFee() (gas: 154994)
TrailsIntentEntrypointTest:testExecuteIntentWithPermit() (gas: 124636)
TrailsIntentEntrypointTest:testExecuteIntentWithPermitExpired() (gas: 37100)
TrailsIntentEntrypointTest:testExecuteIntentWithPermitInvalidSignature() (gas: 39016)
TrailsIntentEntrypointTest:testExecuteIntentWithPermit_permit_frontrun() (gas: 129498)
TrailsIntentEntrypointTest:testFeeCollectorReceivesFees() (gas: 149146)
TrailsIntentEntrypointTest:testFeeCollectorReceivesFeesWithoutPermit() (gas: 118796)
TrailsIntentEntrypointTest:testInfiniteApprovalFlow() (gas: 146872)
TrailsIntentEntrypointTest:testIntentTypehashConstant() (gas: 5732)
TrailsIntentEntrypointTest:testInvalidNonceReverts() (gas: 54704)
TrailsIntentEntrypointTest:testNonceIncrementsOnDeposit() (gas: 90568)
TrailsIntentEntrypointTest:testPermitAmountExcessiveWithFee() (gas: 60617)
TrailsIntentEntrypointTest:testPermitAmountInsufficientWithFee() (gas: 59627)
TrailsIntentEntrypointTest:testVersionConstant() (gas: 10428)
TrailsIntentEntrypointTest:testInvalidNonceReverts() (gas: 55344)
TrailsIntentEntrypointTest:testNonceIncrementsOnDeposit() (gas: 91830)
TrailsIntentEntrypointTest:testPermitAmountExcessiveWithFee() (gas: 61879)
TrailsIntentEntrypointTest:testPermitAmountInsufficientWithFee() (gas: 60889)
TrailsIntentEntrypointTest:testVersionConstant() (gas: 10506)
TrailsRouterDeploymentTest:test_DeployTrailsRouter_SameAddress() (gas: 1856117)
TrailsRouterDeploymentTest:test_DeployTrailsRouter_Success() (gas: 1846511)
TrailsRouterDeploymentTest:test_DeployedRouter_HasCorrectConfiguration() (gas: 1846307)
Expand Down
33 changes: 11 additions & 22 deletions src/TrailsIntentEntrypoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ contract TrailsIntentEntrypoint is ReentrancyGuard, ITrailsIntentEntrypoint {
);
string public constant VERSION = "1";

bytes32 private constant EIP712_DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
bytes32 private constant EIP712_DOMAIN_NAME = keccak256(bytes("TrailsIntentEntrypoint"));
bytes32 private constant EIP712_DOMAIN_VERSION = keccak256(bytes(VERSION));

// -------------------------------------------------------------------------
// Errors
// -------------------------------------------------------------------------
Expand All @@ -40,13 +45,6 @@ contract TrailsIntentEntrypoint is ReentrancyGuard, ITrailsIntentEntrypoint {
error InvalidFeeParameters();
error PermitAmountMismatch();

// -------------------------------------------------------------------------
// Immutable Variables
// -------------------------------------------------------------------------

/// @notice EIP-712 domain separator used for intent signatures.
bytes32 public immutable DOMAIN_SEPARATOR;

// -------------------------------------------------------------------------
// State Variables
// -------------------------------------------------------------------------
Expand All @@ -55,25 +53,16 @@ contract TrailsIntentEntrypoint is ReentrancyGuard, ITrailsIntentEntrypoint {
mapping(address => uint256) public nonces;

// -------------------------------------------------------------------------
// Constructor
// Functions
// -------------------------------------------------------------------------

constructor() {
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes("TrailsIntentEntrypoint")),
keccak256(bytes(VERSION)),
block.chainid,
address(this)
)
/// @inheritdoc ITrailsIntentEntrypoint
function DOMAIN_SEPARATOR() public view returns (bytes32 _domainSeparator) {
return keccak256(
abi.encode(EIP712_DOMAIN_TYPEHASH, EIP712_DOMAIN_NAME, EIP712_DOMAIN_VERSION, block.chainid, address(this))
);
}

// -------------------------------------------------------------------------
// Functions
// -------------------------------------------------------------------------

/// @inheritdoc ITrailsIntentEntrypoint
function depositToIntentWithPermit(
address user,
Expand Down Expand Up @@ -202,7 +191,7 @@ contract TrailsIntentEntrypoint is ReentrancyGuard, ITrailsIntentEntrypoint {
intentHash := keccak256(ptr, 0x140)
}

bytes32 _domainSeparator = DOMAIN_SEPARATOR;
bytes32 _domainSeparator = DOMAIN_SEPARATOR();
bytes32 digest;
// keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, intentHash));
assembly {
Expand Down