Skip to content

Commit

Permalink
strip out lots of unused imports and libs
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Oct 31, 2024
1 parent 0fbcc2d commit 37080e2
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 353 deletions.
29 changes: 0 additions & 29 deletions src/lib/AllocatorLogic.sol
Original file line number Diff line number Diff line change
@@ -1,50 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import { BatchTransfer, SplitBatchTransfer } from "../types/BatchClaims.sol";
import { BasicTransfer, SplitTransfer } from "../types/Claims.sol";
import { CompactCategory } from "../types/CompactCategory.sol";
import { SplitComponent, TransferComponent, SplitByIdComponent } from "../types/Components.sol";
import { ForcedWithdrawalStatus } from "../types/ForcedWithdrawalStatus.sol";
import { Lock } from "../types/Lock.sol";
import { ResetPeriod } from "../types/ResetPeriod.sol";
import { Scope } from "../types/Scope.sol";

import { ConsumerLib } from "./ConsumerLib.sol";
import { EfficiencyLib } from "./EfficiencyLib.sol";
import { FunctionCastLib } from "./FunctionCastLib.sol";
import { HashLib } from "./HashLib.sol";
import { IdLib } from "./IdLib.sol";
import { MetadataRenderer } from "./MetadataRenderer.sol";
import { ValidityLib } from "./ValidityLib.sol";

import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
import { Tstorish } from "tstorish/Tstorish.sol";
import { ISignatureTransfer } from "permit2/src/interfaces/ISignatureTransfer.sol";

contract AllocatorLogic {
using HashLib for address;
using HashLib for bytes32;
using HashLib for uint256;
using HashLib for BasicTransfer;
using HashLib for SplitTransfer;
using HashLib for BatchTransfer;
using HashLib for SplitBatchTransfer;
using IdLib for uint96;
using IdLib for uint256;
using IdLib for address;
using IdLib for Lock;
using IdLib for ResetPeriod;
using SafeTransferLib for address;
using ConsumerLib for uint256;
using EfficiencyLib for bool;
using EfficiencyLib for bytes32;
using EfficiencyLib for uint256;
using ValidityLib for address;
using ValidityLib for uint96;
using ValidityLib for uint256;
using ValidityLib for bytes32;
using FunctionCastLib for function(bytes32, address, BasicTransfer calldata) internal;

function _consume(uint256[] calldata nonces) internal returns (bool) {
// NOTE: this may not be necessary, consider removing
Expand Down
5 changes: 1 addition & 4 deletions src/lib/ClaimProcessorLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ import { EfficiencyLib } from "./EfficiencyLib.sol";
import { FunctionCastLib } from "./FunctionCastLib.sol";
import { HashLib } from "./HashLib.sol";
import { IdLib } from "./IdLib.sol";
import { WithdrawalLogic } from "./WithdrawalLogic.sol";
import { ValidityLib } from "./ValidityLib.sol";
import { WithdrawalLogic } from "./WithdrawalLogic.sol";

contract ClaimProcessorLogic is WithdrawalLogic {
using HashLib for address;
Expand Down Expand Up @@ -111,13 +111,10 @@ contract ClaimProcessorLogic is WithdrawalLogic {
using HashLib for ExogenousSplitBatchMultichainClaimWithWitness;
using HashLib for ExogenousQualifiedSplitBatchMultichainClaim;
using HashLib for ExogenousQualifiedSplitBatchMultichainClaimWithWitness;
using IdLib for uint96;
using IdLib for uint256;
using IdLib for address;
using EfficiencyLib for bool;
using EfficiencyLib for bytes32;
using EfficiencyLib for uint256;
using ValidityLib for address;
using ValidityLib for uint96;
using ValidityLib for uint256;
using ValidityLib for bytes32;
Expand Down
75 changes: 75 additions & 0 deletions src/lib/ConstructorLogic.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import { Lock } from "../types/Lock.sol";
import { ResetPeriod } from "../types/ResetPeriod.sol";
import { Scope } from "../types/Scope.sol";

import { HashLib } from "./HashLib.sol";
import { IdLib } from "./IdLib.sol";
import { MetadataRenderer } from "./MetadataRenderer.sol";

import { Tstorish } from "tstorish/Tstorish.sol";

contract ConstructorLogic is Tstorish {
using HashLib for bytes32;
using HashLib for uint256;
using IdLib for uint256;

address private constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

uint256 private constant _REENTRANCY_GUARD_SLOT = 0x929eee149b4bd21268;

uint256 private immutable _INITIAL_CHAIN_ID;
bytes32 private immutable _INITIAL_DOMAIN_SEPARATOR;
MetadataRenderer private immutable _METADATA_RENDERER;
bool private immutable _PERMIT2_INITIALLY_DEPLOYED;

constructor() {
_INITIAL_CHAIN_ID = block.chainid;
_INITIAL_DOMAIN_SEPARATOR = block.chainid.toNotarizedDomainSeparator();
_METADATA_RENDERER = new MetadataRenderer();
_PERMIT2_INITIALLY_DEPLOYED = _checkPermit2Deployment();
}

function _setReentrancyGuard() internal {
_setTstorish(_REENTRANCY_GUARD_SLOT, 1);
}

function _clearReentrancyGuard() internal {
_clearTstorish(_REENTRANCY_GUARD_SLOT);
}

function _isPermit2Deployed() internal view returns (bool) {
if (_PERMIT2_INITIALLY_DEPLOYED) {
return true;
}

return _checkPermit2Deployment();
}

function _domainSeparator() internal view returns (bytes32) {
return _INITIAL_DOMAIN_SEPARATOR.toLatest(_INITIAL_CHAIN_ID);
}

/// @dev Returns the symbol for token `id`.
function _name(uint256 id) internal view returns (string memory) {
return _METADATA_RENDERER.name(id);
}

/// @dev Returns the symbol for token `id`.
function _symbol(uint256 id) internal view returns (string memory) {
return _METADATA_RENDERER.symbol(id);
}

/// @dev Returns the Uniform Resource Identifier (URI) for token `id`.
function _tokenURI(uint256 id) internal view returns (string memory) {
return _METADATA_RENDERER.uri(id.toLock(), id);
}

function _checkPermit2Deployment() private view returns (bool permit2Deployed) {
assembly ("memory-safe") {
permit2Deployed := iszero(iszero(extcodesize(_PERMIT2)))
}
}
}
32 changes: 4 additions & 28 deletions src/lib/DepositLogic.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import { TransferLogic } from "./TransferLogic.sol";

import { BatchTransfer, SplitBatchTransfer } from "../types/BatchClaims.sol";
import { BasicTransfer, SplitTransfer } from "../types/Claims.sol";
import { CompactCategory } from "../types/CompactCategory.sol";
import { SplitComponent, TransferComponent, SplitByIdComponent } from "../types/Components.sol";
import {
COMPACT_TYPEHASH,
BATCH_COMPACT_TYPEHASH,
Expand Down Expand Up @@ -44,46 +39,27 @@ import {
COMPACT_DEPOSIT_TYPESTRING_FRAGMENT_FOUR,
COMPACT_DEPOSIT_TYPESTRING_FRAGMENT_FIVE
} from "../types/EIP712Types.sol";
import { ForcedWithdrawalStatus } from "../types/ForcedWithdrawalStatus.sol";
import { Lock } from "../types/Lock.sol";
import { ResetPeriod } from "../types/ResetPeriod.sol";
import { Scope } from "../types/Scope.sol";

import { ConsumerLib } from "./ConsumerLib.sol";
import { EfficiencyLib } from "./EfficiencyLib.sol";
import { FunctionCastLib } from "./FunctionCastLib.sol";
import { HashLib } from "./HashLib.sol";
import { IdLib } from "./IdLib.sol";
import { MetadataRenderer } from "./MetadataRenderer.sol";
import { RegistrationLogic } from "./RegistrationLogic.sol";
import { TransferLogic } from "./TransferLogic.sol";
import { ValidityLib } from "./ValidityLib.sol";

import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
import { Tstorish } from "tstorish/Tstorish.sol";
import { ISignatureTransfer } from "permit2/src/interfaces/ISignatureTransfer.sol";

contract DepositLogic is TransferLogic {
using HashLib for address;
using HashLib for bytes32;
using HashLib for uint256;
using HashLib for BasicTransfer;
using HashLib for SplitTransfer;
using HashLib for BatchTransfer;
using HashLib for SplitBatchTransfer;
contract DepositLogic is TransferLogic, RegistrationLogic {
using IdLib for uint96;
using IdLib for uint256;
using IdLib for address;
using IdLib for Lock;
using IdLib for ResetPeriod;
using SafeTransferLib for address;
using ConsumerLib for uint256;
using EfficiencyLib for bool;
using EfficiencyLib for bytes32;
using EfficiencyLib for uint256;
using ValidityLib for address;
using ValidityLib for uint96;
using ValidityLib for uint256;
using ValidityLib for bytes32;
using FunctionCastLib for function(bytes32, address, BasicTransfer calldata) internal;
using SafeTransferLib for address;

uint32 private constant _PERMIT_WITNESS_TRANSFER_FROM_SELECTOR = 0x137c29fe;
uint32 private constant _BATCH_PERMIT_WITNESS_TRANSFER_FROM_SELECTOR = 0xfe8ec1a7;
Expand Down
127 changes: 0 additions & 127 deletions src/lib/InternalLogic.sol

This file was deleted.

Loading

0 comments on commit 37080e2

Please sign in to comment.