Skip to content

Commit

Permalink
Merge pull request #19 from 0xPolygonID/feature/update-to-v-1-3
Browse files Browse the repository at this point in the history
update on-chain-verification to 1.3.2 contracts package
  • Loading branch information
vmidyllic authored Nov 21, 2023
2 parents dabd26b + e0135e0 commit 23e0a17
Show file tree
Hide file tree
Showing 9 changed files with 5,183 additions and 1,288 deletions.
12 changes: 4 additions & 8 deletions on-chain-verification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,14 @@ This tutorial uses [Hardhat](https://hardhat.org/) as a development environment
## current pre-deployed contracts


**mtp verifier address** - 0x357Bb671fEb5577d310410eab93291B4De04a834
**mtp verifier address** - 0xF71d97Fc0262bB2e5B20912a6861da0B617a07Aa

**sig verifier address** - 0xf635aCA4E8B5268aA9Bf8E226907C27383fC9686
**sig verifier address** - 0x8024014f73BcCAEe048784d835A36c49e96F2806

**default mtp validator** - 0x3DcAe4c8d94359D31e4C89D7F2b944859408C618
**default mtp validator** - 0x0682fbaA2E4C478aD5d24d992069dba409766121

**default sig validator** - 0xF2D4Eeb4d455fb673104902282Ce68B9ce4Ac450
**default sig validator** - 0x1E4a22540E293C0e5E8c33DAfd6f523889cFd878

**default state address** - 0x134B1BE34911E39A8397ec6289782989729807a4

**poseidon6 library** - 0xb588b8f07012Dc958aa90EFc7d3CF943057F17d7

**spongeHash library** - 0x12d8C87A61dAa6DD31d8196187cFa37d1C647153


23 changes: 12 additions & 11 deletions on-chain-verification/contracts/ERC20Verifier.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity 0.8.16;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {GenesisUtils} from "@iden3/contracts/lib/GenesisUtils.sol";
import {PrimitiveTypeUtils} from "@iden3/contracts/lib/PrimitiveTypeUtils.sol";
import {ICircuitValidator} from "@iden3/contracts/interfaces/ICircuitValidator.sol";
import {ZKPVerifier} from "@iden3/contracts/verifiers/ZKPVerifier.sol";

Expand All @@ -13,20 +13,21 @@ contract ERC20Verifier is ERC20, ZKPVerifier {
mapping(address => uint256) public addressToId;

uint256 public TOKEN_AMOUNT_FOR_AIRDROP_PER_ID =
5 * 10**uint256(decimals());
5 * 10 ** uint256(decimals());

constructor(string memory name_, string memory symbol_)
ERC20(name_, symbol_)
{}
constructor(
string memory name_,
string memory symbol_
) ERC20(name_, symbol_) {}

function _beforeProofSubmit(
uint64, /* requestId */
uint64 /* requestId */,
uint256[] memory inputs,
ICircuitValidator validator
) internal view override {
// check that challenge input is address of sender
address addr = GenesisUtils.int256ToAddress(
inputs[validator.getChallengeInputIndex()]
address addr = PrimitiveTypeUtils.int256ToAddress(
inputs[validator.inputIndexOf("challenge")]
);
// this is linking between msg.sender and
require(
Expand All @@ -48,15 +49,15 @@ contract ERC20Verifier is ERC20, ZKPVerifier {
// get user id
uint256 id = inputs[1];
// additional check didn't get airdrop tokens before
if (idToAddress[id] == address(0) && addressToId[_msgSender()] == 0 ) {
if (idToAddress[id] == address(0) && addressToId[_msgSender()] == 0) {
super._mint(_msgSender(), TOKEN_AMOUNT_FOR_AIRDROP_PER_ID);
addressToId[_msgSender()] = id;
idToAddress[id] = _msgSender();
}
}

function _beforeTokenTransfer(
address, /* from */
address /* from */,
address to,
uint256 /* amount */
) internal view override {
Expand Down
5 changes: 5 additions & 0 deletions on-chain-verification/contracts/Imports.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.16;

import {CredentialAtomicQueryMTPValidator} from "@iden3/contracts/validators/CredentialAtomicQueryMTPValidator.sol";
import {CredentialAtomicQuerySigValidator} from "@iden3/contracts/validators/CredentialAtomicQuerySigValidator.sol";

This file was deleted.

This file was deleted.

Loading

0 comments on commit 23e0a17

Please sign in to comment.