Skip to content

Commit

Permalink
Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
boyuanx committed Mar 22, 2024
1 parent 151cdc3 commit 278c3a6
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ dist
# Hardhat
artifacts
cache
cache_hardhat
cache_hardhat
typechain-types
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ cache
coverage
node_modules
out
typechain-types
cache_hardhat
artifacts

# files
*.env
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -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
9 changes: 0 additions & 9 deletions scripts/01-deploy-upgradeable.ts

This file was deleted.

11 changes: 11 additions & 0 deletions scripts/01-deploy.ts
Original file line number Diff line number Diff line change
@@ -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()
62 changes: 62 additions & 0 deletions src/ActuallyMetIRL.sol
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

0 comments on commit 278c3a6

Please sign in to comment.