Skip to content

Commit

Permalink
put the function casts in HashLib in FunctionCastLib too
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Oct 16, 2024
1 parent 0d46880 commit 3271522
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 178 deletions.
169 changes: 168 additions & 1 deletion src/lib/FunctionCastLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ import {
QualifiedSplitBatchClaimWithWitness
} from "../types/BatchClaims.sol";

import { TransferComponent, SplitByIdComponent } from "../types/Components.sol";
import {
TransferComponent,
SplitByIdComponent,
BatchClaimComponent,
SplitBatchClaimComponent
} from "../types/Components.sol";

library FunctionCastLib {
function usingSplitTransfer(
Expand Down Expand Up @@ -66,6 +71,168 @@ library FunctionCastLib {
}
}

function usingSplitBatchTransfer(
function(BatchTransfer calldata, bytes32) internal view returns (bytes32) fnIn
)
internal
pure
returns (
function(SplitBatchTransfer calldata, bytes32) internal view returns (bytes32) fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedSplitClaim(
function(QualifiedClaim calldata) internal view returns (bytes32, bytes32) fnIn
)
internal
pure
returns (
function(QualifiedSplitClaim calldata) internal view returns (bytes32, bytes32) fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedClaimWithWitness(
function(ClaimWithWitness calldata, uint256) internal view returns (bytes32) fnIn
)
internal
pure
returns (
function(QualifiedClaimWithWitness calldata, uint256) internal view returns (bytes32) fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedClaimWithWitness(
function(QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn
)
internal
pure
returns (
function(QualifiedClaimWithWitness calldata, bytes32, uint256)
internal
pure
returns (bytes32) fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedSplitClaimWithWitness(
function (QualifiedClaimWithWitness calldata) internal view returns (bytes32, bytes32) fnIn
)
internal
pure
returns (
function (QualifiedSplitClaimWithWitness calldata) internal view returns (bytes32, bytes32)
fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedSplitBatchClaim(
function (SplitBatchClaim calldata, SplitBatchClaimComponent[] calldata) internal view returns (bytes32)
fnIn
)
internal
pure
returns (
function (QualifiedSplitBatchClaim calldata, SplitBatchClaimComponent[] calldata) internal view returns (bytes32)
fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedSplitBatchClaimWithWitness(
function (SplitBatchClaimWithWitness calldata, SplitBatchClaimComponent[] calldata) internal view returns (bytes32)
fnIn
)
internal
pure
returns (
function (QualifiedSplitBatchClaimWithWitness calldata, SplitBatchClaimComponent[] calldata) internal view returns (bytes32)
fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedBatchClaim(
function(BatchClaim calldata, BatchClaimComponent[] calldata) internal view returns (bytes32)
fnIn
)
internal
pure
returns (
function(QualifiedBatchClaim calldata, BatchClaimComponent[] calldata) internal view returns (bytes32)
fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingQualifiedBatchClaimWithWitness(
function(BatchClaimWithWitness calldata, BatchClaimComponent[] calldata) internal view returns (bytes32)
fnIn
)
internal
pure
returns (
function(QualifiedBatchClaimWithWitness calldata, BatchClaimComponent[] calldata) internal view returns (bytes32)
fnOut
)
{
assembly {
fnOut := fnIn
}
}

function usingSplitClaim(function (Claim calldata) internal view returns (bytes32) fnIn)
internal
pure
returns (function (SplitClaim calldata) internal view returns (bytes32) fnOut)
{
assembly {
fnOut := fnIn
}
}

function usingSplitClaimWithWitness(
function (ClaimWithWitness calldata, uint256) internal view returns (bytes32) fnIn
)
internal
pure
returns (
function (SplitClaimWithWitness calldata, uint256) internal view returns (bytes32) fnOut
)
{
assembly {
fnOut := fnIn
}
}

// NOTE: the id field needs to be at the exact same struct offset for this to work!
function usingSplitByIdComponent(
function (TransferComponent[] memory, uint256) internal returns (address) fnIn
Expand Down
Loading

0 comments on commit 3271522

Please sign in to comment.