Skip to content

Commit

Permalink
Fix/zkp verifier get proof status (#221)
Browse files Browse the repository at this point in the history
* add isProofSubmitted to ZKPVerifier

* fix

* make ZKPVerifier abstract class
  • Loading branch information
volodymyr-basiuk authored Mar 11, 2024
1 parent a59b9b5 commit 4d952ac
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 14 deletions.
26 changes: 18 additions & 8 deletions contracts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"url": "https://github.com/iden3/contracts/issues"
},
"dependencies": {
"@openzeppelin/contracts": "^4.7.3",
"@openzeppelin/contracts-upgradeable": "^4.8.2"
"@openzeppelin/contracts": "^5.0.1",
"@openzeppelin/contracts-upgradeable": "^5.0.1",
"@openzeppelin/contracts-upgradeable-v4": "npm:@openzeppelin/contracts-upgradeable@^4.9.5"
}
}
10 changes: 10 additions & 0 deletions contracts/test-helpers/ZKPVerifierWrapper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {ZKPVerifier} from "../verifiers/ZKPVerifier.sol";

contract ZKPVerifierWrapper is ZKPVerifier {
function initialize(address initialOwner) public initializer {
super.__ZKPVerifier_init(initialOwner);
}
}
18 changes: 16 additions & 2 deletions contracts/verifiers/ZKPVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ICircuitValidator} from "../interfaces/ICircuitValidator.sol";
import {IZKPVerifier} from "../interfaces/IZKPVerifier.sol";
import {ArrayUtils} from "../lib/ArrayUtils.sol";

contract ZKPVerifier is IZKPVerifier, Ownable2StepUpgradeable {
abstract contract ZKPVerifier is IZKPVerifier, Ownable2StepUpgradeable {
/**
* @dev Max return array length for request queries
*/
Expand All @@ -33,7 +33,17 @@ contract ZKPVerifier is IZKPVerifier, Ownable2StepUpgradeable {
}
}

function initialize(address initialOwner) public initializer {
/**
* @dev Sets the value for {initialOwner}.
*
* This value is immutable: it can only be set once during
* construction.
*/
function __ZKPVerifier_init(address initialOwner) internal onlyInitializing {
___ZKPVerifier_init_unchained(initialOwner);
}

function ___ZKPVerifier_init_unchained(address initialOwner) internal onlyInitializing {
__Ownable_init(initialOwner);
}

Expand Down Expand Up @@ -110,6 +120,10 @@ contract ZKPVerifier is IZKPVerifier, Ownable2StepUpgradeable {
return result;
}

function isProofSubmitted(address sender, uint64 requestID) public view returns (bool) {
return _getMainStorage().proofs[sender][requestID];
}

/**
* @dev Hook that is called before any proof response submit
*/
Expand Down
4 changes: 2 additions & 2 deletions helpers/DeployHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,12 @@ export class DeployHelper {
address: string;
}> {
const Verifier = await ethers.getContractFactory(
"ZKPVerifier"
"ZKPVerifierWrapper"
);
// const zkpVerifier = await ZKPVerifier.deploy(owner.address);
const verifier = await upgrades.deployProxy(Verifier, [owner.address]);
await verifier.deployed();
console.log("ZKPVerifier deployed to:", verifier.address);
console.log("ZKPVerifierWrapper deployed to:", verifier.address);
return verifier;
}

Expand Down

0 comments on commit 4d952ac

Please sign in to comment.