From a203759e86052a898fcc87c985d976df969179cd Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Thu, 26 Sep 2024 13:58:48 -0400 Subject: [PATCH] Allow existing locks to be cleared Signed-off-by: Jim Zhang --- solidity/contracts/lib/zeto_common.sol | 6 +----- solidity/test/zkDvP.ts | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/solidity/contracts/lib/zeto_common.sol b/solidity/contracts/lib/zeto_common.sol index 0b2ea79..602afab 100644 --- a/solidity/contracts/lib/zeto_common.sol +++ b/solidity/contracts/lib/zeto_common.sol @@ -53,11 +53,7 @@ abstract contract ZetoCommon is OwnableUpgradeable { lockedProofs[proofHash] == msg.sender, "Proof already locked by another party" ); - if (delegate != address(0)) { - lockedProofs[proofHash] = delegate; - } else { - lockedProofs[proofHash] = msg.sender; - } + lockedProofs[proofHash] = delegate; } function sortInputsAndOutputs( diff --git a/solidity/test/zkDvP.ts b/solidity/test/zkDvP.ts index 4540473..4919d68 100644 --- a/solidity/test/zkDvP.ts +++ b/solidity/test/zkDvP.ts @@ -226,9 +226,10 @@ describe("DvP flows between fungible and non-fungible tokens based on Zeto with const utxo1 = newUTXO(100, Alice); const proof = await zetoAnonTests.prepareProof(circuit1, provingKey1, Alice, [utxo1, ZERO_UTXO], [utxo1, ZERO_UTXO], [Alice, {}]); - await expect(zkPayment.connect(Alice.signer).lockProof(proof.encodedProof, "0x0000000000000000000000000000000000000000")).fulfilled; + await expect(zkPayment.connect(Alice.signer).lockProof(proof.encodedProof, await Alice.signer.getAddress())).fulfilled; await expect(zkPayment.connect(Bob.signer).lockProof(proof.encodedProof, await Bob.signer.getAddress())).rejectedWith("Proof already locked by another party"); await expect(zkPayment.connect(Alice.signer).lockProof(proof.encodedProof, await Bob.signer.getAddress())).fulfilled; + await expect(zkPayment.connect(Bob.signer).lockProof(proof.encodedProof, "0x0000000000000000000000000000000000000000")).fulfilled; }); });