From 4cac73e09c4c92f48a66d2dd78cd99db3f40910b Mon Sep 17 00:00:00 2001 From: 0age <37939117+0age@users.noreply.github.com> Date: Sat, 19 Oct 2024 19:02:15 -0700 Subject: [PATCH] finish implementing all claim methods (still need to add batch tests & fix issues) --- foundry.toml | 2 +- src/TheCompact.sol | 100 ++++++++++++++++ src/lib/HashLib.sol | 275 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 362 insertions(+), 15 deletions(-) diff --git a/foundry.toml b/foundry.toml index d9e7d95..e179a00 100644 --- a/foundry.toml +++ b/foundry.toml @@ -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 = 1_000 bytecode_hash = 'none' src = "src" out = "out" diff --git a/src/TheCompact.sol b/src/TheCompact.sol index fa23ec2..7771ef0 100644 --- a/src/TheCompact.sol +++ b/src/TheCompact.sol @@ -675,6 +675,54 @@ contract TheCompact is ITheCompact, ERC6909, Extsload { return _processExogenousBatchMultichainClaim(claimPayload, _withdraw); } + function claim(QualifiedBatchMultichainClaim calldata claimPayload) external returns (bool) { + return _processQualifiedBatchMultichainClaim(claimPayload, _release); + } + + function claimAndWithdraw(QualifiedBatchMultichainClaim calldata claimPayload) external returns (bool) { + return _processQualifiedBatchMultichainClaim(claimPayload, _withdraw); + } + + function claim(ExogenousQualifiedBatchMultichainClaim calldata claimPayload) external returns (bool) { + return _processExogenousQualifiedBatchMultichainClaim(claimPayload, _release); + } + + function claimAndWithdraw(ExogenousQualifiedBatchMultichainClaim calldata claimPayload) external returns (bool) { + return _processExogenousQualifiedBatchMultichainClaim(claimPayload, _withdraw); + } + + function claim(BatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processBatchMultichainClaimWithWitness(claimPayload, _release); + } + + function claimAndWithdraw(BatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processBatchMultichainClaimWithWitness(claimPayload, _withdraw); + } + + function claim(ExogenousBatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processExogenousBatchMultichainClaimWithWitness(claimPayload, _release); + } + + function claimAndWithdraw(ExogenousBatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processExogenousBatchMultichainClaimWithWitness(claimPayload, _withdraw); + } + + function claim(QualifiedBatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processQualifiedBatchMultichainClaimWithWitness(claimPayload, _release); + } + + function claimAndWithdraw(QualifiedBatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processQualifiedBatchMultichainClaimWithWitness(claimPayload, _withdraw); + } + + function claim(ExogenousQualifiedBatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processExogenousQualifiedBatchMultichainClaimWithWitness(claimPayload, _release); + } + + function claimAndWithdraw(ExogenousQualifiedBatchMultichainClaimWithWitness calldata claimPayload) external returns (bool) { + return _processExogenousQualifiedBatchMultichainClaimWithWitness(claimPayload, _withdraw); + } + function claim(SplitBatchMultichainClaim calldata claimPayload) external returns (bool) { return _processSplitBatchMultichainClaim(claimPayload, _release); } @@ -1341,6 +1389,58 @@ contract TheCompact is ITheCompact, ERC6909, Extsload { return _processSimpleBatchClaim.usingBatchMultichainClaim()(claimPayload.toMessageHash(), claimPayload, 0xc0, operation); } + function _processQualifiedBatchMultichainClaim(QualifiedBatchMultichainClaim calldata claimPayload, function(address, address, uint256, uint256) internal returns (bool) operation) + internal + returns (bool) + { + (bytes32 messageHash, bytes32 qualificationMessageHash) = claimPayload.toMessageHash(); + return _processBatchClaimWithQualification.usingQualifiedBatchMultichainClaim()(messageHash, qualificationMessageHash, claimPayload, 0xe0, operation); + } + + function _processBatchMultichainClaimWithWitness(BatchMultichainClaimWithWitness calldata claimPayload, function(address, address, uint256, uint256) internal returns (bool) operation) + internal + returns (bool) + { + return _processSimpleBatchClaim.usingBatchMultichainClaimWithWitness()(claimPayload.toMessageHash(), claimPayload, 0xe0, operation); + } + + function _processQualifiedBatchMultichainClaimWithWitness( + QualifiedBatchMultichainClaimWithWitness calldata claimPayload, + function(address, address, uint256, uint256) internal returns (bool) operation + ) internal returns (bool) { + (bytes32 messageHash, bytes32 qualificationMessageHash) = claimPayload.toMessageHash(); + return _processBatchClaimWithQualification.usingQualifiedBatchMultichainClaimWithWitness()(messageHash, qualificationMessageHash, claimPayload, 0x120, operation); + } + + function _processExogenousQualifiedBatchMultichainClaim( + ExogenousQualifiedBatchMultichainClaim calldata claimPayload, + function(address, address, uint256, uint256) internal returns (bool) operation + ) internal returns (bool) { + (bytes32 messageHash, bytes32 qualificationMessageHash) = claimPayload.toMessageHash(); + return _processBatchClaimWithQualificationAndSponsorDomain.usingExogenousQualifiedBatchMultichainClaim()( + messageHash, qualificationMessageHash, claimPayload, 0x120, claimPayload.notarizedChainId.toNotarizedDomainSeparator(), operation + ); + } + + function _processExogenousBatchMultichainClaimWithWitness( + ExogenousBatchMultichainClaimWithWitness calldata claimPayload, + function(address, address, uint256, uint256) internal returns (bool) operation + ) internal returns (bool) { + return _processBatchClaimWithSponsorDomain.usingExogenousBatchMultichainClaimWithWitness()( + claimPayload.toMessageHash(), claimPayload, 0x120, claimPayload.notarizedChainId.toNotarizedDomainSeparator(), operation + ); + } + + function _processExogenousQualifiedBatchMultichainClaimWithWitness( + ExogenousQualifiedBatchMultichainClaimWithWitness calldata claimPayload, + function(address, address, uint256, uint256) internal returns (bool) operation + ) internal returns (bool) { + (bytes32 messageHash, bytes32 qualificationMessageHash) = claimPayload.toMessageHash(); + return _processBatchClaimWithQualificationAndSponsorDomain.usingExogenousQualifiedBatchMultichainClaimWithWitness()( + messageHash, qualificationMessageHash, claimPayload, 0x160, claimPayload.notarizedChainId.toNotarizedDomainSeparator(), operation + ); + } + function _processExogenousMultichainClaim(ExogenousMultichainClaim calldata claimPayload, function(address, address, uint256, uint256) internal returns (bool) operation) internal returns (bool) { return _processClaimWithSponsorDomain.usingExogenousMultichainClaim()(claimPayload.toMessageHash(), claimPayload, 0x100, claimPayload.notarizedChainId.toNotarizedDomainSeparator(), operation); } diff --git a/src/lib/HashLib.sol b/src/lib/HashLib.sol index b462468..701ec50 100644 --- a/src/lib/HashLib.sol +++ b/src/lib/HashLib.sol @@ -539,6 +539,23 @@ library HashLib { messageHash = usingBatchMultichainClaim(toMultichainClaimMessageHash)(claim, 0, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, toIdsAndAmountsHash(claim.claims)); } + function toMessageHash(QualifiedBatchMultichainClaim calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { + messageHash = usingQualifiedBatchMultichainClaim(toMultichainClaimMessageHash)(claim, 0x40, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, toIdsAndAmountsHash(claim.claims)); + qualificationMessageHash = usingQualifiedBatchMultichainClaim(toQualificationMessageHash)(claim, messageHash, 0); + } + + function toMessageHash(BatchMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash) { + (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingBatchMultichainClaimWithWitness(getMultichainTypehashes)(claim); + messageHash = usingBatchMultichainClaimWithWitness(toMultichainClaimMessageHash)(claim, 0x40, allocationTypehash, multichainCompactTypehash, toIdsAndAmountsHash(claim.claims)); + } + + function toMessageHash(QualifiedBatchMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { + (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingQualifiedBatchMultichainClaimWithWitness(getMultichainTypehashes)(claim); + + messageHash = usingQualifiedBatchMultichainClaimWithWitness(toMultichainClaimMessageHash)(claim, 0x80, allocationTypehash, multichainCompactTypehash, toIdsAndAmountsHash(claim.claims)); + qualificationMessageHash = usingQualifiedBatchMultichainClaimWithWitness(toQualificationMessageHash)(claim, messageHash, 0x40); + } + function toMessageHash(SplitBatchMultichainClaim calldata claim) internal view returns (bytes32 messageHash) { messageHash = usingSplitBatchMultichainClaim(toMultichainClaimMessageHash)(claim, 0, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, toSplitIdsAndAmountsHash(claim.claims)); } @@ -612,6 +629,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaimWithWitness(function (MultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaimWithWitness calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingQualifiedMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -632,6 +659,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaimWithWitness calldata, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingQualifiedSplitMultichainClaim(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -642,6 +679,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaim(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaim calldata, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousQualifiedSplitMultichainClaim(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -652,6 +699,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaim(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousQualifiedBatchMultichainClaim calldata, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousQualifiedMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -672,6 +729,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousQualifiedBatchMultichainClaimWithWitness calldata, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingQualifiedMultichainClaimWithWitness(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -692,6 +759,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaimWithWitness(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaimWithWitness calldata, bytes32, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingQualifiedSplitBatchMultichainClaimWithWitness(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -762,6 +839,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaim(function (MultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousQualifiedSplitMultichainClaim(function (ExogenousMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) internal pure @@ -772,6 +859,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaim(function (ExogenousMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousQualifiedBatchMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingBatchMultichainClaim(function (MultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) internal pure @@ -872,6 +969,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaim(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousQualifiedSplitMultichainClaim(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -882,6 +989,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaim(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousQualifiedBatchMultichainClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function toMessageHash(SplitMultichainClaim calldata claim) internal view returns (bytes32 messageHash) { messageHash = usingSplitMultichainClaim(toMultichainClaimMessageHash)(claim, 0, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, usingSplitMultichainClaim(deriveIdsAndAmountsHash)(claim, 0)); } @@ -906,6 +1023,16 @@ library HashLib { } } + function usingExogenousBatchMultichainClaimWithWitness(function (ExogenousMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousBatchMultichainClaimWithWitness calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousQualifiedMultichainClaimWithWitness(function (ExogenousMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) internal pure @@ -926,6 +1053,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaimWithWitness(function (ExogenousMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousQualifiedBatchMultichainClaimWithWitness calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousSplitMultichainClaim(function (ExogenousMultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) internal pure @@ -986,6 +1123,16 @@ library HashLib { } } + function usingExogenousBatchMultichainClaimWithWitness(function (QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousBatchMultichainClaimWithWitness calldata, bytes32, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingMultichainClaimWithWitness(function (MultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) internal pure @@ -1006,6 +1153,16 @@ library HashLib { } } + function usingBatchMultichainClaimWithWitness(function (MultichainClaim calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnIn) + internal + pure + returns (function (BatchMultichainClaimWithWitness calldata, uint256, bytes32, bytes32, bytes32) internal view returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -1026,6 +1183,16 @@ library HashLib { } } + function usingBatchMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (BatchMultichainClaimWithWitness calldata, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingSplitMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) internal pure @@ -1036,6 +1203,16 @@ library HashLib { } } + function usingBatchMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) + internal + pure + returns (function (BatchMultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -1056,6 +1233,16 @@ library HashLib { } } + function usingExogenousBatchMultichainClaimWithWitness(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function (ExogenousBatchMultichainClaimWithWitness calldata, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousMultichainClaim(function (MultichainClaim calldata, uint256) internal pure returns (bytes32) fnIn) internal pure @@ -1073,13 +1260,6 @@ library HashLib { ); } - function toMessageHash(SplitMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash) { - (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingSplitMultichainClaimWithWitness(getMultichainTypehashes)(claim); - messageHash = usingSplitMultichainClaimWithWitness(toMultichainClaimMessageHash)( - claim, 0x40, allocationTypehash, multichainCompactTypehash, usingSplitMultichainClaimWithWitness(deriveIdsAndAmountsHash)(claim, 0x40) - ); - } - function toMessageHash(ExogenousMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash) { (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingExogenousMultichainClaimWithWitness(getMultichainTypehashes)(claim); messageHash = usingExogenousMultichainClaimWithWitness(toExogenousMultichainClaimMessageHash)( @@ -1103,6 +1283,20 @@ library HashLib { qualificationMessageHash = usingQualifiedMultichainClaimWithWitness(toQualificationMessageHash)(claim, messageHash, 0x40); } + function toMessageHash(QualifiedSplitMultichainClaim calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { + messageHash = usingQualifiedSplitMultichainClaim(toMultichainClaimMessageHash)( + claim, 0x40, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, usingQualifiedSplitMultichainClaim(deriveIdsAndAmountsHash)(claim, 0x40) + ); + qualificationMessageHash = usingQualifiedSplitMultichainClaim(toQualificationMessageHash)(claim, messageHash, 0); + } + + function toMessageHash(SplitMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash) { + (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingSplitMultichainClaimWithWitness(getMultichainTypehashes)(claim); + messageHash = usingSplitMultichainClaimWithWitness(toMultichainClaimMessageHash)( + claim, 0x40, allocationTypehash, multichainCompactTypehash, usingSplitMultichainClaimWithWitness(deriveIdsAndAmountsHash)(claim, 0x40) + ); + } + function toMessageHash(QualifiedSplitMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingQualifiedSplitMultichainClaimWithWitness(getMultichainTypehashes)(claim); @@ -1112,13 +1306,6 @@ library HashLib { qualificationMessageHash = usingQualifiedSplitMultichainClaimWithWitness(toQualificationMessageHash)(claim, messageHash, 0x40); } - function toMessageHash(QualifiedSplitMultichainClaim calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { - messageHash = usingQualifiedSplitMultichainClaim(toMultichainClaimMessageHash)( - claim, 0x40, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, usingQualifiedSplitMultichainClaim(deriveIdsAndAmountsHash)(claim, 0x40) - ); - qualificationMessageHash = usingQualifiedSplitMultichainClaim(toQualificationMessageHash)(claim, messageHash, 0); - } - function toMessageHash(QualifiedMultichainClaim calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { messageHash = usingQualifiedMultichainClaim(toMultichainClaimMessageHash)( claim, 0x40, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, usingQualifiedMultichainClaim(deriveIdsAndAmountsHash)(claim, 0x40) @@ -1176,6 +1363,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaimWithWitness(function(QualifiedClaim calldata, bytes32, uint256) internal pure returns (bytes32) fnIn) + internal + pure + returns (function(ExogenousQualifiedBatchMultichainClaimWithWitness calldata, bytes32, uint256) internal pure returns (bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) internal pure @@ -1196,6 +1393,16 @@ library HashLib { } } + function usingExogenousBatchMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) + internal + pure + returns (function (ExogenousBatchMultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingExogenousQualifiedMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) internal pure @@ -1216,6 +1423,16 @@ library HashLib { } } + function usingExogenousQualifiedBatchMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) + internal + pure + returns (function (ExogenousQualifiedBatchMultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingQualifiedMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) internal pure @@ -1236,6 +1453,16 @@ library HashLib { } } + function usingQualifiedBatchMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) + internal + pure + returns (function (QualifiedBatchMultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnOut) + { + assembly ("memory-safe") { + fnOut := fnIn + } + } + function usingQualifiedSplitBatchMultichainClaimWithWitness(function (MultichainClaimWithWitness calldata) internal pure returns (bytes32, bytes32) fnIn) internal pure @@ -1397,6 +1624,26 @@ library HashLib { qualificationMessageHash = usingExogenousQualifiedSplitMultichainClaimWithWitness(toQualificationMessageHash)(claim, messageHash, 0x40); } + function toMessageHash(ExogenousQualifiedBatchMultichainClaim calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { + messageHash = + usingExogenousQualifiedBatchMultichainClaim(toExogenousMultichainClaimMessageHash)(claim, 0x40, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, toIdsAndAmountsHash(claim.claims)); + qualificationMessageHash = usingExogenousQualifiedBatchMultichainClaim(toQualificationMessageHash)(claim, messageHash, 0); + } + + function toMessageHash(ExogenousBatchMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash) { + (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingExogenousBatchMultichainClaimWithWitness(getMultichainTypehashes)(claim); + messageHash = + usingExogenousBatchMultichainClaimWithWitness(toExogenousMultichainClaimMessageHash)(claim, 0x40, allocationTypehash, multichainCompactTypehash, toIdsAndAmountsHash(claim.claims)); + } + + function toMessageHash(ExogenousQualifiedBatchMultichainClaimWithWitness calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { + (bytes32 allocationTypehash, bytes32 multichainCompactTypehash) = usingExogenousQualifiedBatchMultichainClaimWithWitness(getMultichainTypehashes)(claim); + + messageHash = + usingExogenousQualifiedBatchMultichainClaimWithWitness(toExogenousMultichainClaimMessageHash)(claim, 0x80, allocationTypehash, multichainCompactTypehash, toIdsAndAmountsHash(claim.claims)); + qualificationMessageHash = usingExogenousQualifiedBatchMultichainClaimWithWitness(toQualificationMessageHash)(claim, messageHash, 0x40); + } + function toMessageHash(ExogenousQualifiedSplitBatchMultichainClaim calldata claim) internal view returns (bytes32 messageHash, bytes32 qualificationMessageHash) { messageHash = usingExogenousQualifiedSplitBatchMultichainClaim(toExogenousMultichainClaimMessageHash)( claim, 0x40, ALLOCATION_TYPEHASH, MULTICHAIN_COMPACT_TYPEHASH, toSplitIdsAndAmountsHash(claim.claims)