Skip to content

Commit

Permalink
Merge pull request #55 from sismo-core/temporary-testing-improvements…
Browse files Browse the repository at this point in the history
…-with-no-tests

feat: merge main to benefit from new deployment configs file
  • Loading branch information
leosayous21 authored Dec 22, 2022
2 parents 1e95405 + f14392b commit f85b0ab
Show file tree
Hide file tree
Showing 156 changed files with 10,416 additions and 42,983 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ This repository contains the smart contracts of the Sismo Protocol.

There are three core contracts:

- `core/AttestationsRegistry.sol`: The registry stores all attestations. It is owned by the governance that authorize/unauthorize issuers to record in it
- `core/AttestationsRegistry.sol`: The registry stores all attestations. It is owned by the governance that authorizes/unauthorize issuers to record in it
- `core/Attester.sol` The standard abstract contract must be inherited by attesters. Attesters are issuers of attestations. They verify user requests and build attestations that will be recorded in the registry
- `core/Badges.sol` Reads the registry. Stateless Non Transferable Token view of attestations (ERC1155)

It also contains implementations of attester in `attesters/`:
- `HydraS1SimpleAttester.sol`: ZK Attester using the [Hydra S1 Proving Scheme](https://hydra-s1.docs.sismo.io) and the notion of nullifiers. Users must provide a ZK Proof along their request to generate attestations
- `HydraS1SimpleAttester.sol`: ZK Attester using the [Hydra S1 Proving Scheme](https://hydra-s1.docs.sismo.io) and the notion of nullifiers. Users must provide a ZK Proof along with their request to generate attestations
- `HydraS1AccountboundAttester.sol`: Accountbound version of the Simple Hydra S1 Simple Attester. (Users can update at will where the attestation is stored)

<br/><br/>
Expand Down Expand Up @@ -92,7 +92,7 @@ To develop a new attester, you must inherit the `core/Attester.sol` abstract con
- `_verifyRequest(request, proofData)`: You must implement the user request verification against the proof provided by the user
- `buildAttestations(request, proofData)`: You must build the attestations that will be recorded from a verified user request

There are other optional hook functions that can be implemented:
Other optional hook functions that can be implemented:

- `_beforeRecordAttestations(request, proofData)`
- `_afterRecordAttestations(request, proofData)`
Expand Down
27 changes: 27 additions & 0 deletions contracts/periphery/utils/FrontendLib.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.14;

import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {HydraS1AccountboundAttester} from '../../attesters/hydra-s1/HydraS1AccountboundAttester.sol';
import {Initializable} from '@openzeppelin/contracts/proxy/utils/Initializable.sol';

contract FrontendLib {
address private immutable _hydraS1AccountboundAttester;

constructor(address hydraS1AccountboundAttester) {
_hydraS1AccountboundAttester = hydraS1AccountboundAttester;
}

function getHydraS1AccountboundAttesterDestinationOfNullifierBatch(
uint256[] calldata nullifiers
) external view returns (address[] memory) {
address[] memory destinations = new address[](nullifiers.length);

for (uint256 i = 0; i < nullifiers.length; i++) {
destinations[i] = HydraS1AccountboundAttester(_hydraS1AccountboundAttester)
.getDestinationOfNullifier(nullifiers[i]);
}

return destinations;
}
}
20 changes: 20 additions & 0 deletions contracts/tests/MockHydraS1SimpleAttester.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.14;

import {Attestation, Request} from '../core/libs/Structs.sol';
import {Attester} from '../core/Attester.sol';
import {IAttester} from '../core/interfaces/IAttester.sol';
import {IHydraS1AccountboundAttester} from '../attesters/hydra-s1/interfaces/IHydraS1AccountboundAttester.sol';

contract MockHydraS1SimpleAttester {
mapping(uint256 => address) internal _nullifiersDestinations;

function getDestinationOfNullifier(uint256 nullifier) external view returns (address) {
return _nullifiersDestinations[nullifier];
}

function setDestinationOfNullifier(uint256 nullifier, address destination) external {
_nullifiersDestinations[nullifier] = destination;
}
}
1 change: 1 addition & 0 deletions deployments/gnosis/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100

Large diffs are not rendered by default.

Large diffs are not rendered by default.

261 changes: 261 additions & 0 deletions deployments/gnosis/AttestationsRegistryProxy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

261 changes: 261 additions & 0 deletions deployments/gnosis/AvailableRootsRegistryProxy.json

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions deployments/goerli/Badges.json → deployments/gnosis/Badges.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

262 changes: 262 additions & 0 deletions deployments/gnosis/BadgesProxy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions deployments/gnosis/CommitmentMapperRegistryProxy.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions deployments/goerli/Front.json → deployments/gnosis/Front.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

235 changes: 235 additions & 0 deletions deployments/gnosis/FrontProxy.json

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions deployments/gnosis/FrontendLib.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

261 changes: 261 additions & 0 deletions deployments/gnosis/HydraS1AccountboundAttesterProxy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions deployments/gnosis/Pythia1SimpleAttesterProxy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@
"contracts/periphery/utils/CommitmentMapperRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.14;\n\nimport {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';\nimport {Initializable} from '@openzeppelin/contracts/proxy/utils/Initializable.sol';\nimport {ICommitmentMapperRegistry} from './interfaces/ICommitmentMapperRegistry.sol';\n\n/**\n * @title Commitment Mapper Registry Contract\n * @author Sismo\n * @notice This contract stores information about the commitment mapper.\n * Its ethereum address and its EdDSA public key\n * For more information: https://commitment-mapper.docs.sismo.io\n *\n **/\ncontract CommitmentMapperRegistry is ICommitmentMapperRegistry, Initializable, Ownable {\n uint8 public constant IMPLEMENTATION_VERSION = 2;\n\n uint256[2] internal _commitmentMapperPubKey;\n address _commitmentMapperAddress;\n\n /**\n * @dev Constructor\n * @param owner Owner of the contract, can update public key and address\n * @param commitmentMapperEdDSAPubKey EdDSA public key of the commitment mapper\n * @param commitmentMapperAddress Address of the commitment mapper\n */\n constructor(\n address owner,\n uint256[2] memory commitmentMapperEdDSAPubKey,\n address commitmentMapperAddress\n ) {\n initialize(owner, commitmentMapperEdDSAPubKey, commitmentMapperAddress);\n }\n\n /**\n * @dev Initializes the contract, to be called by the proxy delegating calls to this implementation\n * @param ownerAddress Owner of the contract, can update public key and address\n * @param commitmentMapperEdDSAPubKey EdDSA public key of the commitment mapper\n * @param commitmentMapperAddress Address of the commitment mapper\n * @notice The reinitializer modifier is needed to configure modules that are added through upgrades and that require initialization.\n */\n function initialize(\n address ownerAddress,\n uint256[2] memory commitmentMapperEdDSAPubKey,\n address commitmentMapperAddress\n ) public reinitializer(IMPLEMENTATION_VERSION) {\n // if proxy did not setup owner yet or if called by constructor (for implem setup)\n if (owner() == address(0) || address(this).code.length == 0) {\n _transferOwnership(ownerAddress);\n _updateCommitmentMapperEdDSAPubKey(commitmentMapperEdDSAPubKey);\n _updateCommitmentMapperAddress(commitmentMapperAddress);\n }\n }\n\n /**\n * @dev Updates the EdDSA public key\n * @param newEdDSAPubKey new EdDSA pubic key\n */\n function updateCommitmentMapperEdDSAPubKey(uint256[2] memory newEdDSAPubKey) external onlyOwner {\n _updateCommitmentMapperEdDSAPubKey(newEdDSAPubKey);\n }\n\n /**\n * @dev Updates the address\n * @param newAddress new address\n */\n function updateCommitmentMapperAddress(address newAddress) external onlyOwner {\n _updateCommitmentMapperAddress(newAddress);\n }\n\n /**\n * @dev Getter of the EdDSA public key of the commitment mapper\n */\n function getEdDSAPubKey() external view override returns (uint256[2] memory) {\n return _commitmentMapperPubKey;\n }\n\n /**\n * @dev Getter of the address of the commitment mapper\n */\n function getAddress() external view override returns (address) {\n return _commitmentMapperAddress;\n }\n\n function _updateCommitmentMapperAddress(address newAddress) internal {\n _commitmentMapperAddress = newAddress;\n emit UpdatedCommitmentMapperAddress(newAddress);\n }\n\n function _updateCommitmentMapperEdDSAPubKey(uint256[2] memory pubKey) internal {\n _commitmentMapperPubKey = pubKey;\n emit UpdatedCommitmentMapperEdDSAPubKey(pubKey);\n }\n}\n"
},
"contracts/periphery/utils/FrontendLib.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.14;\n\nimport {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';\nimport {HydraS1AccountboundAttester} from '../../attesters/hydra-s1/HydraS1AccountboundAttester.sol';\nimport {Initializable} from '@openzeppelin/contracts/proxy/utils/Initializable.sol';\n\ncontract FrontendLib {\n address private immutable _hydraS1AccountboundAttester;\n\n constructor(address hydraS1AccountboundAttester) {\n _hydraS1AccountboundAttester = hydraS1AccountboundAttester;\n }\n\n function getHydraS1AccountboundAttesterDestinationOfNullifierBatch(\n uint256[] calldata nullifiers\n ) external view returns (address[] memory) {\n address[] memory destinations = new address[](nullifiers.length);\n\n for (uint256 i = 0; i < nullifiers.length; i++) {\n destinations[i] = HydraS1AccountboundAttester(_hydraS1AccountboundAttester)\n .getDestinationOfNullifier(nullifiers[i]);\n }\n\n return destinations;\n }\n}\n"
},
"contracts/periphery/utils/interfaces/IAvailableRootsRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.14;\n\n/**\n * @title IAvailableRootsRegistry\n * @author Sismo\n * @notice Interface for (Merkle) Roots Registry\n */\ninterface IAvailableRootsRegistry {\n event RegisteredRootForAttester(address attester, uint256 root);\n event RegisteredRootForAll(uint256 root);\n event UnregisteredRootForAttester(address attester, uint256 root);\n event UnregisteredRootForAll(uint256 root);\n\n error CannotRegisterForZeroAddress();\n error CannotUnregisterForZeroAddress();\n\n /**\n * @dev Initializes the contract, to be called by the proxy delegating calls to this implementation\n * @param owner Owner of the contract, can update public key and address\n * @notice The reinitializer modifier is needed to configure modules that are added through upgrades and that require initialization.\n */\n function initialize(address owner) external;\n\n /**\n * @dev Register a root available for an attester\n * @param attester Attester which will have the root available\n * @param root Root to register\n */\n function registerRootForAttester(address attester, uint256 root) external;\n\n /**\n * @dev Unregister a root for an attester\n * @param attester Attester which will no longer have the root available\n * @param root Root to unregister\n */\n function unregisterRootForAttester(address attester, uint256 root) external;\n\n /**\n * @dev Registers a root, available for all contracts\n * @param root Root to register\n */\n function registerRootForAll(uint256 root) external;\n\n /**\n * @dev Unregister a root, available for all contracts\n * @param root Root to unregister\n */\n function unregisterRootForAll(uint256 root) external;\n\n /**\n * @dev returns whether a root is available for a caller (msg.sender)\n * @param root root to check whether it is registered for me or not\n */\n function isRootAvailableForMe(uint256 root) external view returns (bool);\n\n /**\n * @dev Initializes the contract, to be called by the proxy delegating calls to this implementation\n * @param attester Owner of the contract, can update public key and address\n * @param root Owner of the contract, can update public key and address\n */\n function isRootAvailableForAttester(address attester, uint256 root) external view returns (bool);\n}\n"
},
Expand All @@ -204,6 +207,9 @@
},
"contracts/tests/MockAttester.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.14;\n\nimport {Attestation, Request} from '../core/libs/Structs.sol';\nimport {Attester} from '../core/Attester.sol';\nimport {IAttester} from '../core/interfaces/IAttester.sol';\n\ncontract MockAttester is IAttester, Attester {\n uint256 public immutable ATTESTATION_ID_MIN;\n uint256 public immutable ATTESTATION_ID_MAX;\n\n constructor(\n address ATTESTATION_REGISTRY_ADDRESS,\n uint256 collectionIdFirst,\n uint256 collectionIdLast\n ) Attester(ATTESTATION_REGISTRY_ADDRESS) {\n ATTESTATION_ID_MIN = collectionIdFirst;\n ATTESTATION_ID_MAX = collectionIdLast;\n }\n\n function _verifyRequest(\n Request calldata request,\n bytes calldata proofData\n ) internal virtual override {}\n\n function buildAttestations(\n Request calldata request,\n bytes calldata /*data*/\n ) public view virtual override(Attester, IAttester) returns (Attestation[] memory) {\n uint256 collectionId = ATTESTATION_ID_MIN + request.claims[0].groupId;\n Attestation[] memory attestations = new Attestation[](1);\n attestations[0] = Attestation(\n collectionId,\n request.destination,\n address(this),\n request.claims[0].claimedValue,\n abi.decode(request.claims[0].extraData, (uint32)),\n 'Mock Attester v0'\n );\n return (attestations);\n }\n}\n"
},
"contracts/tests/MockHydraS1SimpleAttester.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.14;\n\nimport {Attestation, Request} from '../core/libs/Structs.sol';\nimport {Attester} from '../core/Attester.sol';\nimport {IAttester} from '../core/interfaces/IAttester.sol';\nimport {IHydraS1AccountboundAttester} from '../attesters/hydra-s1/interfaces/IHydraS1AccountboundAttester.sol';\n\ncontract MockHydraS1SimpleAttester {\n mapping(uint256 => address) internal _nullifiersDestinations;\n\n function getDestinationOfNullifier(uint256 nullifier) external view returns (address) {\n return _nullifiersDestinations[nullifier];\n }\n\n function setDestinationOfNullifier(uint256 nullifier, address destination) external {\n _nullifiersDestinations[nullifier] = destination;\n }\n}\n"
}
},
"settings": {
Expand Down
1 change: 0 additions & 1 deletion deployments/goerli/.chainId

This file was deleted.

249 changes: 0 additions & 249 deletions deployments/goerli/AttestationsRegistryProxy.json

This file was deleted.

249 changes: 0 additions & 249 deletions deployments/goerli/AvailableRootsRegistryProxy.json

This file was deleted.

250 changes: 0 additions & 250 deletions deployments/goerli/BadgesProxy.json

This file was deleted.

Loading

0 comments on commit f85b0ab

Please sign in to comment.