Skip to content

Commit

Permalink
WIP: specialize SettlerIntent on Sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
duncancmt committed Aug 28, 2024
1 parent 584e4d6 commit 1f6ebb8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.
5 changes: 0 additions & 5 deletions src/Settler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ abstract contract Settler is Permit2PaymentTakerSubmitted, SettlerBase {
using UnsafeMath for uint256;
using CalldataDecoder for bytes[];

// When/if you change this, you must make corresponding changes to
// `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set
// `constructor_args`.
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _tokenId() internal pure override returns (uint256) {
return 2;
}
Expand Down
3 changes: 3 additions & 0 deletions src/SettlerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ abstract contract SettlerBase is Basic, RfqOrderSettlement, UniswapV3Fork, Unisw

event GitCommit(bytes20 indexed);

// When/if you change this, you must make corresponding changes to
// `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set
// `constructor_args`.
constructor(bytes20 gitCommit) {
if (block.chainid != 31337) {
emit GitCommit(gitCommit);
Expand Down
9 changes: 2 additions & 7 deletions src/SettlerIntent.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import {SettlerMetaTxn} from "./SettlerMetaTxn.sol";
import {Permit2PaymentIntent, Permit2PaymentMetaTxn} from "./core/Permit2Payment.sol";

abstract contract SettlerIntent is Permit2PaymentIntent, SettlerMetaTxn {
// When/if you change this, you must make corresponding changes to
// `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set
// `constructor_args`.
constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {}

function _tokenId() internal pure override(SettlerAbstract, SettlerMetaTxn) returns (uint256) {
function _tokenId() internal pure virtual override(SettlerAbstract, SettlerMetaTxn) returns (uint256) {
return 4;
}

Expand All @@ -29,7 +24,7 @@ abstract contract SettlerIntent is Permit2PaymentIntent, SettlerMetaTxn {
}

// Solidity inheritance is so stupid
function _witnessTypeSuffix() internal pure override(Permit2PaymentMetaTxn, Permit2PaymentIntent) returns (string memory) {
function _witnessTypeSuffix() internal pure virtual override(Permit2PaymentMetaTxn, Permit2PaymentIntent) returns (string memory) {
return super._witnessTypeSuffix();
}

Expand Down
5 changes: 0 additions & 5 deletions src/SettlerMetaTxn.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ abstract contract SettlerMetaTxn is Permit2PaymentMetaTxn, SettlerBase {
using UnsafeMath for uint256;
using CalldataDecoder for bytes[];

// When/if you change this, you must make corresponding changes to
// `sh/deploy_new_chain.sh` and 'sh/common_deploy_settler.sh' to set
// `constructor_args`.
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _tokenId() internal pure virtual override returns (uint256) {
return 3;
}
Expand Down
40 changes: 37 additions & 3 deletions src/chains/Sepolia.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.25;
import {SettlerBase} from "../SettlerBase.sol";
import {Settler} from "../Settler.sol";
import {SettlerMetaTxn} from "../SettlerMetaTxn.sol";
import {SettlerIntent} from "../SettlerIntent.sol";

import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {MaverickV2, IMaverickV2Pool} from "../core/MaverickV2.sol";
Expand All @@ -24,6 +25,7 @@ import {
import {SettlerAbstract} from "../SettlerAbstract.sol";
import {AbstractContext} from "../Context.sol";
import {Permit2PaymentAbstract} from "../core/Permit2PaymentAbstract.sol";
import {Permit2PaymentMetaTxn} from "../core/Permit2Payment.sol";

abstract contract SepoliaMixin is FreeMemory, SettlerBase, MaverickV2 {
constructor() {
Expand Down Expand Up @@ -74,7 +76,7 @@ abstract contract SepoliaMixin is FreeMemory, SettlerBase, MaverickV2 {

/// @custom:security-contact [email protected]
contract SepoliaSettler is Settler, SepoliaMixin {
constructor(bytes20 gitCommit) Settler(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) {
if (super._dispatchVIP(action, data)) {
Expand Down Expand Up @@ -121,10 +123,11 @@ contract SepoliaSettler is Settler, SepoliaMixin {

/// @custom:security-contact [email protected]
contract SepoliaSettlerMetaTxn is SettlerMetaTxn, SepoliaMixin {
constructor(bytes20 gitCommit) SettlerMetaTxn(gitCommit) {}
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig)
internal
virtual
override
DANGEROUS_freeMemory
returns (bool)
Expand All @@ -150,13 +153,44 @@ contract SepoliaSettlerMetaTxn is SettlerMetaTxn, SepoliaMixin {
// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, SepoliaMixin)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerMetaTxn, AbstractContext) returns (address) {
function _msgSender() internal view virtual override(SettlerMetaTxn, AbstractContext) returns (address) {
return super._msgSender();
}
}

/// @custom:security-contact [email protected]
contract SepoliaSettlerIntent is SettlerIntent, SepoliaSettlerMetaTxn {
constructor(bytes20 gitCommit) SepoliaSettlerMetaTxn(gitCommit) {}

// Solidity inheritance is stupid
function _dispatch(uint256 i, bytes4 action, bytes calldata data)
internal
override(SepoliaSettlerMetaTxn, SettlerBase, SettlerAbstract)
returns (bool)
{
return super._dispatch(i, action, data);
}

function _msgSender() internal view override(SettlerIntent, SepoliaSettlerMetaTxn) returns (address) {
return super._msgSender();
}

function _witnessTypeSuffix() internal pure override(SettlerIntent, Permit2PaymentMetaTxn) returns (string memory) {
return super._witnessTypeSuffix();
}

function _tokenId() internal pure override(SettlerIntent, SettlerMetaTxn, SettlerAbstract) returns (uint256) {
return super._tokenId();
}

function _dispatchVIP(bytes4 action, bytes calldata data, bytes calldata sig) internal override(SepoliaSettlerMetaTxn, SettlerMetaTxn) returns (bool) {
return super._dispatchVIP(action, data, sig);
}
}

0 comments on commit 1f6ebb8

Please sign in to comment.