diff --git a/src/lib/FunctionCastLib.sol b/src/lib/FunctionCastLib.sol index 0f2faed..80f5b9b 100644 --- a/src/lib/FunctionCastLib.sol +++ b/src/lib/FunctionCastLib.sol @@ -2764,20 +2764,4 @@ library FunctionCastLib { fnOut := fnIn } } - - /** - * @notice Function cast to provide a SplitBatchTransfer calldata struct while - * treating it as a BatchTransfer calldata struct. - * @param fnIn Function pointer to HashLib.toBatchTransferMessageHashUsingIdsAndAmountsHash(BatchTransfer calldata, uint256) - * @return fnOut Modified function for HashLib.toBatchTransferMessageHashUsingIdsAndAmountsHash(SplitBatchTransfer calldata, uint256) - */ - function usingSplitBatchTransfer(function(BatchTransfer calldata, uint256) internal view returns (bytes32) fnIn) - internal - pure - returns (function(SplitBatchTransfer calldata, uint256) internal view returns (bytes32) fnOut) - { - assembly ("memory-safe") { - fnOut := fnIn - } - } } diff --git a/src/lib/HashLib.sol b/src/lib/HashLib.sol index 40b93b2..53eb005 100644 --- a/src/lib/HashLib.sol +++ b/src/lib/HashLib.sol @@ -27,7 +27,7 @@ import { } from "../types/EIP712Types.sol"; import { EfficiencyLib } from "./EfficiencyLib.sol"; -import { FunctionCastLib } from "./FunctionCastLib.sol"; +import { TransferFunctionCastLib } from "./TransferFunctionCastLib.sol"; /** * @title HashLib @@ -39,7 +39,7 @@ import { FunctionCastLib } from "./FunctionCastLib.sol"; library HashLib { using EfficiencyLib for bool; using EfficiencyLib for uint256; - using FunctionCastLib for function (BatchTransfer calldata, uint256) internal view returns (bytes32); + using TransferFunctionCastLib for function (BatchTransfer calldata, uint256) internal view returns (bytes32); using HashLib for uint256; using HashLib for BatchTransfer; diff --git a/src/lib/TransferLogicFunctionCastLib.sol b/src/lib/TransferFunctionCastLib.sol similarity index 53% rename from src/lib/TransferLogicFunctionCastLib.sol rename to src/lib/TransferFunctionCastLib.sol index de53686..089585a 100644 --- a/src/lib/TransferLogicFunctionCastLib.sol +++ b/src/lib/TransferFunctionCastLib.sol @@ -6,21 +6,21 @@ import { BasicTransfer, SplitTransfer } from "../types/Claims.sol"; import { TransferComponent, SplitByIdComponent } from "../types/Components.sol"; /** - * @title TransferLogicFunctionCastLib - * @notice Libray contract implementing function casts used in TransferLogic. - * The input function operates on a function that takes some argument that differs - * from what is currently available. The output function modifies one or more argument - * types so that they match the arguments that are being used to call the function. - * Note that from the perspective of the function being modified, the original type is - * still in force; great care should be taken to preserve offsets and general structure - * between the two structs. + * @title TransferFunctionCastLib + * @notice Libray contract implementing function casts used in TransferLogic as well as + * in HashLib. The input function operates on a function that takes some argument that + * differs from what is currently available. The output function modifies one or more + * argument types so that they match the arguments that are being used to call the + * function. Note that from the perspective of the function being modified, the original + * type is still in force; great care should be taken to preserve offsets and general + * structure between the two structs. */ -library TransferLogicFunctionCastLib { +library TransferFunctionCastLib { /** * @notice Function cast to provide a SplitTransfer calldata struct while * treating it as a BasicTransfer calldata struct. - * @param fnIn Function pointer to `_notExpiredAndSignedByAllocator`. - * @return fnOut Modified function used in `_processSplitTransfer`. + * @param fnIn Function pointer to `TransferLogic._notExpiredAndSignedByAllocator`. + * @return fnOut Modified function used in `TransferLogic._processSplitTransfer`. */ function usingSplitTransfer(function (bytes32, address, BasicTransfer calldata) internal fnIn) internal pure returns (function (bytes32, address, SplitTransfer calldata) internal fnOut) { assembly ("memory-safe") { @@ -31,8 +31,8 @@ library TransferLogicFunctionCastLib { /** * @notice Function cast to provide a BatchTransfer calldata struct while * treating it as a BasicTransfer calldata struct. - * @param fnIn Function pointer to `_notExpiredAndSignedByAllocator`. - * @return fnOut Modified function used in `_processBatchTransfer`. + * @param fnIn Function pointer to `TransferLogic._notExpiredAndSignedByAllocator`. + * @return fnOut Modified function used in `TransferLogic._processBatchTransfer`. */ function usingBatchTransfer(function (bytes32, address, BasicTransfer calldata) internal fnIn) internal pure returns (function (bytes32, address, BatchTransfer calldata) internal fnOut) { assembly ("memory-safe") { @@ -43,8 +43,8 @@ library TransferLogicFunctionCastLib { /** * @notice Function cast to provide a SplitBatchTransfer calldata struct while * treating it as a BasicTransfer calldata struct. - * @param fnIn Function pointer to `_notExpiredAndSignedByAllocator`. - * @return fnOut Modified function used in `_processSplitBatchTransfer`. + * @param fnIn Function pointer to `TransferLogic._notExpiredAndSignedByAllocator`. + * @return fnOut Modified function used in `TransferLogic._processSplitBatchTransfer`. */ function usingSplitBatchTransfer(function (bytes32, address, BasicTransfer calldata) internal fnIn) internal @@ -59,8 +59,8 @@ library TransferLogicFunctionCastLib { /** * @notice Function cast to provide a SplitByIdComponent array while treating it * as a TransferComponent array. - * @param fnIn Function pointer to `_deriveConsistentAllocatorAndConsumeNonce`. - * @return fnOut Modified function used in `_processSplitBatchTransfer`. + * @param fnIn Function pointer to `TransferLogic._deriveConsistentAllocatorAndConsumeNonce`. + * @return fnOut Modified function used in `TransferLogic._processSplitBatchTransfer`. */ function usingSplitByIdComponent(function(TransferComponent[] calldata, uint256, function (TransferComponent[] calldata, uint256) internal pure returns (uint96)) internal returns (address) fnIn) internal @@ -71,4 +71,20 @@ library TransferLogicFunctionCastLib { fnOut := fnIn } } + + /** + * @notice Function cast to provide a SplitBatchTransfer calldata struct while + * treating it as a BatchTransfer calldata struct. + * @param fnIn Function pointer to `HashLib.toBatchTransferMessageHashUsingIdsAndAmountsHash`. + * @return fnOut Modified function for `HashLib.toSplitBatchTransferMessageHash`. + */ + function usingSplitBatchTransfer(function(BatchTransfer calldata, uint256) internal view returns (bytes32) fnIn) + internal + pure + returns (function(SplitBatchTransfer calldata, uint256) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } } diff --git a/src/lib/TransferLogic.sol b/src/lib/TransferLogic.sol index 174bc58..6a89241 100644 --- a/src/lib/TransferLogic.sol +++ b/src/lib/TransferLogic.sol @@ -9,7 +9,7 @@ import { ClaimHashLib } from "./ClaimHashLib.sol"; import { ComponentLib } from "./ComponentLib.sol"; import { EfficiencyLib } from "./EfficiencyLib.sol"; import { EventLib } from "./EventLib.sol"; -import { TransferLogicFunctionCastLib } from "./TransferLogicFunctionCastLib.sol"; +import { TransferFunctionCastLib } from "./TransferFunctionCastLib.sol"; import { IdLib } from "./IdLib.sol"; import { SharedLogic } from "./SharedLogic.sol"; import { ValidityLib } from "./ValidityLib.sol"; @@ -36,8 +36,8 @@ contract TransferLogic is SharedLogic { using ValidityLib for uint96; using ValidityLib for uint256; using ValidityLib for bytes32; - using TransferLogicFunctionCastLib for function (bytes32, address, BasicTransfer calldata) internal; - using TransferLogicFunctionCastLib for function(TransferComponent[] calldata, uint256, function (TransferComponent[] calldata, uint256) internal pure returns (uint96)) internal returns (address); + using TransferFunctionCastLib for function (bytes32, address, BasicTransfer calldata) internal; + using TransferFunctionCastLib for function(TransferComponent[] calldata, uint256, function (TransferComponent[] calldata, uint256) internal pure returns (uint96)) internal returns (address); // bytes4(keccak256("attest(address,address,address,uint256,uint256)")). uint32 private constant _ATTEST_SELECTOR = 0x1a808f91;