Skip to content

Commit

Permalink
remove some allocated transfer & withdrawal functions to get it under…
Browse files Browse the repository at this point in the history
… the limit
  • Loading branch information
0age committed Oct 30, 2024
1 parent dcd1d9b commit 54b5a49
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 170 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ solc = '0.8.28'
evm_version='cancun'
via_ir = true
# optimizer_runs = 4_294_967_295
optimizer_runs = 200
optimizer_runs = 50
bytecode_hash = 'none'
src = "src"
out = "out"
Expand Down
74 changes: 35 additions & 39 deletions snapshots/TheCompactTest.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
{
"basicTransfer": "57341",
"basicWithdrawal": "60321",
"batchClaim": "112382",
"batchClaimRegisteredWithDeposit": "112382",
"batchClaimRegisteredWithDepositWithWitness": "113117",
"batchClaimWithWitness": "113111",
"batchDepositAndRegisterViaPermit2": "221918",
"batchDepositAndRegisterWithWitnessViaPermit2": "221896",
"batchTransfer": "82919",
"batchWithdrawal": "101334",
"claim": "57533",
"claimAndWithdraw": "73824",
"claimWithWitness": "59977",
"depositAndRegisterViaPermit2": "124252",
"depositBatchSingleERC20": "67846",
"depositBatchSingleNative": "28149",
"depositBatchViaPermit2NativeAndERC20": "129562",
"depositBatchViaPermit2SingleERC20": "104689",
"depositERC20AndURI": "67095",
"depositERC20Basic": "67124",
"depositERC20ViaPermit2AndURI": "98277",
"depositETHAndURI": "26755",
"depositETHBasic": "28318",
"qualifiedBatchClaim": "113797",
"qualifiedBatchClaimWithWitness": "113240",
"qualifiedClaim": "60795",
"basicTransfer": "57278",
"basicWithdrawal": "60320",
"batchClaim": "112360",
"batchClaimRegisteredWithDeposit": "112360",
"batchClaimRegisteredWithDepositWithWitness": "113051",
"batchClaimWithWitness": "113045",
"batchDepositAndRegisterViaPermit2": "221954",
"batchDepositAndRegisterWithWitnessViaPermit2": "221932",
"claim": "57501",
"claimAndWithdraw": "73758",
"claimWithWitness": "59955",
"depositAndRegisterViaPermit2": "124302",
"depositBatchSingleERC20": "67822",
"depositBatchSingleNative": "28086",
"depositBatchViaPermit2NativeAndERC20": "129587",
"depositBatchViaPermit2SingleERC20": "104714",
"depositERC20AndURI": "67145",
"depositERC20Basic": "67152",
"depositERC20ViaPermit2AndURI": "98349",
"depositETHAndURI": "26769",
"depositETHBasic": "28288",
"qualifiedBatchClaim": "113731",
"qualifiedBatchClaimWithWitness": "113174",
"qualifiedClaim": "60773",
"qualifiedClaimWithWitness": "59336",
"qualifiedSplitBatchClaim": "141343",
"qualifiedSplitBatchClaimWithWitness": "141314",
"qualifiedSplitClaim": "87067",
"qualifiedSplitClaimWithWitness": "87390",
"register": "25357",
"splitBatchClaim": "140830",
"splitBatchClaimWithWitness": "140767",
"splitBatchTransfer": "113620",
"splitBatchWithdrawal": "142828",
"splitClaim": "86993",
"splitClaimWithWitness": "86447",
"splitTransfer": "83253",
"splitWithdrawal": "94163"
"qualifiedSplitBatchClaim": "141307",
"qualifiedSplitBatchClaimWithWitness": "141278",
"qualifiedSplitClaim": "87001",
"qualifiedSplitClaimWithWitness": "87324",
"register": "25335",
"splitBatchClaim": "140794",
"splitBatchClaimWithWitness": "140731",
"splitBatchTransfer": "113570",
"splitBatchWithdrawal": "142818",
"splitClaim": "86927",
"splitClaimWithWitness": "86403"
}
8 changes: 5 additions & 3 deletions src/TheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,16 @@ contract TheCompact is ITheCompact, ITheCompactClaims, ERC6909, Tstorish {
}

function deposit(address token, address allocator, uint256 amount) external returns (uint256) {
return _performBasicERC20Deposit(token, allocator, amount, msg.sender);
return _performBasicERC20Deposit(token, allocator, amount);
}

function depositAndRegister(address token, address allocator, uint256 amount, bytes32 claimHash, bytes32 typehash) external returns (uint256 id) {
id = _performBasicERC20Deposit(token, allocator, amount, msg.sender);
id = _performBasicERC20Deposit(token, allocator, amount);

_register(msg.sender, claimHash, typehash, 0x258);
}

function _performBasicERC20Deposit(address token, address allocator, uint256 amount, address recipient) internal returns (uint256 id) {
function _performBasicERC20Deposit(address token, address allocator, uint256 amount) internal returns (uint256 id) {
_setTstorish(_REENTRANCY_GUARD_SLOT, 1);
id = token.excludingNative().toIdIfRegistered(Scope.Multichain, ResetPeriod.TenMinutes, allocator);

Expand Down Expand Up @@ -463,6 +463,7 @@ contract TheCompact is ITheCompact, ITheCompactClaims, ERC6909, Tstorish {
return _processBasicTransfer(withdrawal, _withdraw);
}

/*
function allocatedTransfer(SplitTransfer calldata transfer) external returns (bool) {
return _processSplitTransfer(transfer, _release);
}
Expand All @@ -478,6 +479,7 @@ contract TheCompact is ITheCompact, ITheCompactClaims, ERC6909, Tstorish {
function allocatedWithdrawal(BatchTransfer calldata withdrawal) external returns (bool) {
return _processBatchTransfer(withdrawal, _withdraw);
}
*/

function allocatedTransfer(SplitBatchTransfer calldata transfer) external returns (bool) {
return _processSplitBatchTransfer(transfer, _release);
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/ITheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ interface ITheCompact {

function allocatedWithdrawal(BasicTransfer calldata withdrawal) external returns (bool);

/*
function allocatedTransfer(SplitTransfer calldata transfer) external returns (bool);
function allocatedWithdrawal(SplitTransfer calldata withdrawal) external returns (bool);
function allocatedTransfer(BatchTransfer calldata transfer) external returns (bool);
function allocatedWithdrawal(BatchTransfer calldata withdrawal) external returns (bool);
*/

function allocatedTransfer(SplitBatchTransfer calldata transfer) external returns (bool);

Expand Down
14 changes: 0 additions & 14 deletions src/lib/HashLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -580,20 +580,6 @@ library HashLib {
}

///// CATEGORY 6: miscellaneous utilities /////

function toPermit2DepositWitnessHash(address allocator, ResetPeriod resetPeriod, Scope scope, address recipient) internal pure returns (bytes32 witnessHash) {
assembly ("memory-safe") {
let m := mload(0x40) // Grab the free memory pointer; memory will be left dirtied.

mstore(m, PERMIT2_DEPOSIT_WITNESS_FRAGMENT_HASH)
mstore(add(m, 0x20), allocator)
mstore(add(m, 0x40), resetPeriod)
mstore(add(m, 0x60), scope)
mstore(add(m, 0x80), recipient)
witnessHash := keccak256(m, 0xa0)
}
}

function toLatest(bytes32 initialDomainSeparator, uint256 initialChainId) external view returns (bytes32 domainSeparator) {
domainSeparator = initialDomainSeparator;

Expand Down
Loading

0 comments on commit 54b5a49

Please sign in to comment.