Skip to content

Commit

Permalink
Add delegate to lockProof()
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Sep 26, 2024
1 parent 713dcce commit 5ae387b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions solidity/contracts/lib/zeto_common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ abstract contract ZetoCommon is OwnableUpgradeable {
// should be called by escrow contracts that will use uploaded proofs
// to execute transactions, in order to prevent the proof from being used
// by parties other than the escrow contract
function lockProof(Commonlib.Proof calldata proof) public {
function lockProof(
Commonlib.Proof calldata proof,
address delegate
) public {
bytes32 proofHash = Commonlib.getProofHash(proof);
lockedProofs[proofHash] = msg.sender;
require(lockedProofs[proofHash] == address(0), "Proof already locked");
if (delegate != address(0)) {
lockedProofs[proofHash] = delegate;
} else {
lockedProofs[proofHash] = msg.sender;
}
}

function sortInputsAndOutputs(
Expand Down
2 changes: 2 additions & 0 deletions solidity/contracts/zkDvP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ contract zkDvP {
bytes32 proofHash = getProofHash(proof);
if (trade.paymentProofHash == proofHash) {
trade.paymentProof = proof;
paymentToken.lockProof(proof, address(this));
} else if (trade.assetProofHash == proofHash) {
trade.assetProof = proof;
assetToken.lockProof(proof, address(this));
} else {
revert("Invalid proof");
}
Expand Down

0 comments on commit 5ae387b

Please sign in to comment.