diff --git a/.gitignore b/.gitignore index cfe7373..ca5f099 100644 --- a/.gitignore +++ b/.gitignore @@ -132,4 +132,5 @@ dist # Hardhat artifacts cache -cache_hardhat \ No newline at end of file +cache_hardhat +typechain-types \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index bb5dc17..7d79f7c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,9 @@ cache coverage node_modules out +typechain-types +cache_hardhat +artifacts # files *.env diff --git a/package.json b/package.json index 6d2af8b..2245747 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "author": "", "license": "ISC", "dependencies": { + "@ethsign/sign-protocol-evm": "1.1.1", "@openzeppelin/contracts": "5.0.1", "@openzeppelin/contracts-upgradeable": "5.0.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index db62e48..408f083 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@ethsign/sign-protocol-evm': + specifier: 1.1.1 + version: 1.1.1 '@openzeppelin/contracts': specifier: 5.0.1 version: 5.0.1 @@ -514,6 +517,13 @@ packages: '@ethersproject/strings': 5.7.0 dev: true + /@ethsign/sign-protocol-evm@1.1.1: + resolution: {integrity: sha512-ldbWofDEMY0v8l8EF/2aa0fV2mEyRXlm54it6PNwYkeKuNuosY/CWuBgK8P7tMb0K5HS1gOuplMRC6Ky3VoXPw==} + dependencies: + '@openzeppelin/contracts': 5.0.1 + '@openzeppelin/contracts-upgradeable': 5.0.1(@openzeppelin/contracts@5.0.1) + dev: false + /@fastify/busboy@2.1.0: resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==} engines: {node: '>=14'} diff --git a/remappings.txt b/remappings.txt index 0cf26ce..95c57f2 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,4 +1,5 @@ @openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ @openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/ +@ethsign/sign-protocol-evm/=node_modules/@ethsign/sign-protocol-evm/ ds-test/=node_modules/ds-test/src forge-std/=node_modules/forge-std/src \ No newline at end of file diff --git a/scripts/01-deploy-upgradeable.ts b/scripts/01-deploy-upgradeable.ts deleted file mode 100644 index b7cb81d..0000000 --- a/scripts/01-deploy-upgradeable.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {ethers, upgrades} from 'hardhat' - -async function main() { - const Factory = await ethers.getContractFactory('${ContractName}') - const instance = await upgrades.deployProxy(Factory, []) - await instance.waitForDeployment() -} - -void main() diff --git a/scripts/01-deploy.ts b/scripts/01-deploy.ts new file mode 100644 index 0000000..b51a78a --- /dev/null +++ b/scripts/01-deploy.ts @@ -0,0 +1,11 @@ +/* eslint-disable no-console */ +import {ethers} from 'hardhat' + +async function main() { + const Factory = await ethers.getContractFactory('ActuallyMetIRL') + const instance = await Factory.deploy() + const contract = await instance.waitForDeployment() + console.log(await contract.getAddress()) +} + +void main() diff --git a/src/ActuallyMetIRL.sol b/src/ActuallyMetIRL.sol new file mode 100644 index 0000000..9c2a7c9 --- /dev/null +++ b/src/ActuallyMetIRL.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; +import { ISP } from "@ethsign/sign-protocol-evm/src/interfaces/ISP.sol"; +import { Attestation } from "@ethsign/sign-protocol-evm/src/models/Attestation.sol"; +import { DataLocation } from "@ethsign/sign-protocol-evm/src/models/DataLocation.sol"; + +// [x] Have a way to link to the existing on-chain SP instance and schema +// 2. Force both parties to confirm they've met each other IRL before making an attestation + +contract ActuallyMetIRL is Ownable { + ISP public spInstance; + uint64 public schemaId; + mapping(address partyA => address partyB) public metIRLMapping; + + error ConfirmationAddressMismatch(); + + event DidMetIRL(address partyA, address partyB, uint64 attestationId); + + constructor() Ownable(_msgSender()) { } + + function setSPInstance(address instance) external onlyOwner { + spInstance = ISP(instance); + } + + function setSchemaID(uint64 schemaId_) external onlyOwner { + schemaId = schemaId_; + } + + function claimMetIRL(address partyB) external { + metIRLMapping[_msgSender()] = partyB; + } + + function confirmMetIRL(address partyA) external returns (uint64) { + address partyB = _msgSender(); + if (metIRLMapping[partyA] == partyB) { + // B has confirm A's claim of having met them IRL + // We now make an attestation of having actually met IRL + bytes[] memory recipients = new bytes[](2); + recipients[0] = abi.encode(partyA); + recipients[1] = abi.encode(partyB); + Attestation memory a = Attestation({ + schemaId: schemaId, + linkedAttestationId: 0, + attestTimestamp: 0, + revokeTimestamp: 0, + attester: address(this), + validUntil: 0, + dataLocation: DataLocation.ONCHAIN, + revoked: false, + recipients: recipients, + data: "" + }); + uint64 attestationId = spInstance.attest(a, "", "", ""); + emit DidMetIRL(partyA, partyB, attestationId); + return attestationId; + } else { + revert ConfirmationAddressMismatch(); + } + } +} diff --git a/src/Counter.sol b/src/Counter.sol deleted file mode 100644 index aded799..0000000 --- a/src/Counter.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -contract Counter { - uint256 public number; - - function setNumber(uint256 newNumber) public { - number = newNumber; - } - - function increment() public { - number++; - } -} diff --git a/test/Counter.t.sol b/test/Counter.t.sol deleted file mode 100644 index b51380d..0000000 --- a/test/Counter.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import { Test, console } from "forge-std/Test.sol"; -import { Counter } from "../src/Counter.sol"; - -contract CounterTest is Test { - Counter public counter; - - function setUp() public { - counter = new Counter(); - counter.setNumber(0); - } - - function test_Increment() public { - counter.increment(); - assertEq(counter.number(), 1); - } - - function testFuzz_SetNumber(uint256 x) public { - counter.setNumber(x); - assertEq(counter.number(), x); - } -}