Skip to content

Commit

Permalink
Set two versions of OpenZeppelin contracts-upgradeable package
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriian Chestnykh committed Feb 5, 2024
1 parent b08c19b commit 4cb20af
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 72 deletions.
2 changes: 1 addition & 1 deletion contracts/identitytreestore/IdentityTreeStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {PoseidonUnit2L, PoseidonUnit3L} from "../lib/Poseidon.sol";
import {IState} from "../interfaces/IState.sol";
import {IOnchainCredentialStatusResolver} from "../interfaces/IOnchainCredentialStatusResolver.sol";
import {IRHSStorage} from "../interfaces/IRHSStorage.sol";
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol";

contract IdentityTreeStore is
Ownable2StepUpgradeable,
Expand Down
4 changes: 2 additions & 2 deletions contracts/state/State.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol";
import {IState, MAX_SMT_DEPTH} from "../interfaces/IState.sol";
import {IStateTransitionVerifier} from "../interfaces/IStateTransitionVerifier.sol";
import {SmtLib} from "../lib/SmtLib.sol";
Expand Down Expand Up @@ -70,7 +70,7 @@ contract State is Ownable2StepUpgradeable, IState {
verifier = verifierContractAddr;
_setDefaultIdType(defaultIdType);
_gistData.initialize(MAX_SMT_DEPTH);
__Ownable_init(msg.sender);
__Ownable_init();
}

/**
Expand Down
14 changes: 2 additions & 12 deletions contracts/test-helpers/IdentityExample.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/OwnableUpgradeable.sol";
import {IState} from "../interfaces/IState.sol";
import {ClaimBuilder} from "../lib/ClaimBuilder.sol";
import {IdentityLib} from "../lib/IdentityLib.sol";
Expand All @@ -13,19 +13,9 @@ import {IdentityBase} from "../lib/IdentityBase.sol";
contract IdentityExample is IdentityBase, OwnableUpgradeable {
using IdentityLib for IdentityLib.Data;

// This empty reserved space is put in place to allow future versions
// of the State contract to inherit from other contracts without a risk of
// breaking the storage layout. This is necessary because the parent contracts in the
// future may introduce some storage variables, which are placed before the State
// contract's storage variables.
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
// slither-disable-next-line shadowing-state
// slither-disable-next-line unused-state
uint256[500] private __gap;

function initialize(address _stateContractAddr) public override initializer {
super.initialize(_stateContractAddr);
__Ownable_init(msg.sender);
__Ownable_init();
}

function addClaimAndTransit(uint256[8] calldata claim) public onlyOwner {
Expand Down
18 changes: 0 additions & 18 deletions contracts/validators/CredentialAtomicQueryMTPValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ contract CredentialAtomicQueryMTPValidator is CredentialAtomicQueryValidator {

string internal constant CIRCUIT_ID = "credentialAtomicQueryMTPV2OnChain";

// This empty reserved space is put in place to allow future versions
// of the CredentialAtomicQuerySigValidator contract to inherit from other contracts without a risk of
// breaking the storage layout. This is necessary because the parent contracts in the
// future may introduce some storage variables, which are placed before the CredentialAtomicQuerySigValidator
// contract's storage variables.
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
// slither-disable-next-line shadowing-state
// slither-disable-next-line unused-state
uint256[500] private __gap_before;

// PUT NEW STATE VARIABLES HERE

// This empty reserved space is put in place to allow future versions
// of this contract to add new variables without shifting down
// storage of child contracts that use this contract as a base
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
uint256[50] __gap_after;

function initialize(
address _verifierContractAddr,
address _stateContractAddr
Expand Down
18 changes: 0 additions & 18 deletions contracts/validators/CredentialAtomicQuerySigValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ contract CredentialAtomicQuerySigValidator is CredentialAtomicQueryValidator {

string internal constant CIRCUIT_ID = "credentialAtomicQuerySigV2OnChain";

// This empty reserved space is put in place to allow future versions
// of the CredentialAtomicQuerySigValidator contract to inherit from other contracts without a risk of
// breaking the storage layout. This is necessary because the parent contracts in the
// future may introduce some storage variables, which are placed before the CredentialAtomicQuerySigValidator
// contract's storage variables.
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
// slither-disable-next-line shadowing-state
// slither-disable-next-line unused-state
uint256[500] private __gap_before;

// PUT NEW STATE VARIABLES HERE

// This empty reserved space is put in place to allow future versions
// of this contract to add new variables without shifting down
// storage of child contracts that use this contract as a base
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
uint256[50] __gap_after;

function initialize(
address _verifierContractAddr,
address _stateContractAddr
Expand Down
18 changes: 0 additions & 18 deletions contracts/validators/CredentialAtomicQueryV3Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,6 @@ contract CredentialAtomicQueryV3Validator is CredentialAtomicQueryValidator {

string internal constant CIRCUIT_ID = "credentialAtomicQueryV3OnChain-beta.0";

// This empty reserved space is put in place to allow future versions
// of the CredentialAtomicQueryV3Validator contract to inherit from other contracts without a risk of
// breaking the storage layout. This is necessary because the parent contracts in the
// future may introduce some storage variables, which are placed before the CredentialAtomicQueryV3Validator
// contract's storage variables.
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
// slither-disable-next-line shadowing-state
// slither-disable-next-line unused-state
uint256[500] private __gap_before;

// PUT NEW STATE VARIABLES HERE

// This empty reserved space is put in place to allow future versions
// of this contract to add new variables without shifting down
// storage of child contracts that use this contract as a base
// (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps)
uint256[50] __gap_after;

function initialize(
address _verifierContractAddr,
address _stateContractAddr
Expand Down
4 changes: 2 additions & 2 deletions contracts/validators/CredentialAtomicQueryValidator.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/OwnableUpgradeable.sol";
import {GenesisUtils} from "../lib/GenesisUtils.sol";
import {ICircuitValidator} from "../interfaces/ICircuitValidator.sol";
import {IVerifier} from "../interfaces/IVerifier.sol";
Expand Down Expand Up @@ -72,7 +72,7 @@ abstract contract CredentialAtomicQueryValidator is OwnableUpgradeable, ICircuit
proofExpirationTimeout = 1 hours;
gistRootExpirationTimeout = 1 hours;
state = IState(_stateContractAddr);
__Ownable_init(msg.sender);
__Ownable_init();
}

function parseCommonPubSignals(
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@openzeppelin/contracts": "^5.0.1",
"@openzeppelin/contracts-upgradeable": "^5.0.1",
"@openzeppelin/contracts-upgradeable-v4": "npm:@openzeppelin/contracts-upgradeable@^4.9.5",
"circomlibjs": "^0.1.6",
"codecov": "^3.8.2",
"node-jq": "^2.3.5",
Expand Down
2 changes: 1 addition & 1 deletion test/state/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ describe("Set Verifier", () => {
"0x8ba1f109551bd432803012645ac136ddd64dba72"
);
await expect(state.connect(notOwner).setVerifier(newVerifierAddress)).to.be.revertedWith(
"OwnableUnauthorizedAccount"
"Ownable: caller is not the owner"
);
});

Expand Down

0 comments on commit 4cb20af

Please sign in to comment.