Skip to content

Commit

Permalink
finish implementing all claim methods (still need to add batch tests …
Browse files Browse the repository at this point in the history
…& fix issues)
  • Loading branch information
0age committed Oct 20, 2024
1 parent 661a715 commit 4cac73e
Show file tree
Hide file tree
Showing 3 changed files with 362 additions and 15 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 = 1_000
bytecode_hash = 'none'
src = "src"
out = "out"
Expand Down
100 changes: 100 additions & 0 deletions src/TheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 4cac73e

Please sign in to comment.