generated from EthSign/forge-hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
90 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,4 +132,5 @@ dist | |
# Hardhat | ||
artifacts | ||
cache | ||
cache_hardhat | ||
cache_hardhat | ||
typechain-types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ cache | |
coverage | ||
node_modules | ||
out | ||
typechain-types | ||
cache_hardhat | ||
artifacts | ||
|
||
# files | ||
*.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.