Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1928 onchain exact humanity score 90 day validity #46

Merged
merged 40 commits into from
Jan 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9e2b09c
feat(contracts): adds updated getScore and setMaxScoreAge functions
nebulaic-labs Nov 28, 2023
eefbe9f
feat(contracts, test): adds isHuman functionality and threshold setter
nebulaic-labs Nov 30, 2023
7c4d0dd
fix(resolver): fix recipient variable used in test
nutrina Dec 4, 2023
3f50d3a
fix(resolver,caching): handle & test caching with attest, revoke, mul…
nutrina Dec 4, 2023
22168d8
fix(docs): fix function doc
nutrina Dec 4, 2023
de80a52
fix: remove onlys
tim-schultz Dec 4, 2023
a4b671a
Revert "fix(resolver): add failing test when using multiAttest with a…
nutrina Dec 4, 2023
0ffdad1
feat(contracts): adds updated getScore and setMaxScoreAge functions
nebulaic-labs Nov 28, 2023
50b0fb0
fix: compiler issues
nutrina Dec 5, 2023
b336bb0
fix: writing unittests and fixing bugs in the decoder
nutrina Dec 5, 2023
ff8422e
fix: add missing tests, cleanup & reorganise unittests
nutrina Dec 6, 2023
cc3b7c0
wip: refactor test/GitcoinPassportDecoder.ts
nutrina Dec 6, 2023
333ee0d
wip: rework unittests for GitcoinPassportDecoder
nutrina Dec 6, 2023
d82a733
fix: rework unittest, rename structure attributes for consistency
nutrina Dec 6, 2023
75c369e
fix: remove for test suite
nutrina Dec 6, 2023
92d9dd3
fix: use correct type for decimals when decoding scores
nutrina Dec 7, 2023
f86602c
docs: updating docs
nutrina Dec 7, 2023
1cd2595
deploy: Attester, Verifier and Resolver to baseGoerli
nutrina Dec 8, 2023
6c6d479
contracts: adding TODOs
nutrina Dec 10, 2023
7618934
deploy: adding script to deploy schemas, including schema registry in…
nutrina Dec 10, 2023
f53f182
deploy: have deployed GitcoinPassportDecode to baseGoerli
nutrina Dec 10, 2023
25fa1b2
New deployment to baseGoerli
nutrina Dec 13, 2023
e1ab71e
feat: adding script to check for recipient
nutrina Dec 14, 2023
b78e9c5
fix: update setupDecoder.ts script to also set threshold and maxScoreAge
nutrina Dec 14, 2023
d4f858e
fix: remove debug file & fix typo
nutrina Dec 18, 2023
cb7a609
Test for emitting event in GitcoinAttester.setEASAddress
nutrina Dec 20, 2023
02aa99d
Testing that an event is emitted when setting the score schema
nutrina Dec 20, 2023
5f1e360
Fixing TODOs
nutrina Dec 21, 2023
cee5c69
wip: script * changes to set up decoder SC
nutrina Dec 21, 2023
de12511
Have updated the implementation of 'isHuman' in 'GitcoinPassportDecod…
nutrina Dec 22, 2023
7eab28e
Fixing tests for isHuman
nutrina Dec 22, 2023
82e84ec
Using uint8 instead of uint256 in reversedMappingVersions, to track s…
nutrina Dec 26, 2023
b3cec4e
Adding tests to check for setting threshold and maxScoreAge in Passpo…
nutrina Dec 26, 2023
99f9389
Deployment to optimism-goerli
nutrina Dec 26, 2023
e3e1ec1
Fixing deployment of attestation, verifier & setup of decoder
nutrina Dec 26, 2023
c988c44
fix: removig TODO
nutrina Dec 28, 2023
af3bf8d
Deployment to optimism-sepolia
nutrina Jan 8, 2024
5956f95
Remove yarn-error.log
nutrina Jan 9, 2024
4b719bf
Adding comments and error handling to the script
nutrina Jan 9, 2024
ffb815d
Adding to allow setting the score schema for smart contracts owned b…
nutrina Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Testing that an event is emitted when setting the score schema
nutrina committed Dec 20, 2023
commit 02aa99d8c0cd1a451fdbb8d98f9649e08eb4329d
9 changes: 5 additions & 4 deletions contracts/GitcoinResolver.sol
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ contract GitcoinResolver is
error NotAllowlisted();
error InvalidAttester();

event ScoreSchemaSet(bytes32 schema);

// Mapping of addresses to schemas to an attestation UID
mapping(address => mapping(bytes32 => bytes32)) public userAttestations;

@@ -44,11 +46,10 @@ contract GitcoinResolver is
mapping(address => bool) public allowlist;

// Mapping of addresses to scores
mapping(address => CachedScore) private scores;
mapping(address => CachedScore) public scores;

// Mapping of active passport score schemas - used when storing scores to state
// TODO: make this public
bytes32 private scoreSchema;
bytes32 public scoreSchema;

/**
* @dev Creates a new resolver.
@@ -100,8 +101,8 @@ contract GitcoinResolver is
* @param _schema The score schema uid
*/
function setScoreSchema(bytes32 _schema) external onlyOwner {
// TODO: emit event
scoreSchema = _schema;
emit ScoreSchemaSet(_schema);
}

// solhint-disable-next-line no-empty-blocks
63 changes: 39 additions & 24 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -7,16 +7,31 @@ import "hardhat-gas-reporter";
import "solidity-coverage";
import "@openzeppelin/hardhat-upgrades";
import "hardhat-contract-sizer";
import { HttpNetworkHDAccountsConfig } from "hardhat/types";

dotenv.config();


// this is already a public mnemonic ...
const MNEMONIC = "chief loud snack trend chief net field husband vote message decide replace";
const testAccounts:HttpNetworkHDAccountsConfig = {
mnemonic: MNEMONIC,
path: "m/44'/60'/0'/0",
initialIndex: 0,
// We will use different recipients for some of the tests (like GitcoinResolver for example),
// hence we need t ohave enough accounts
count: 30,
passphrase: "",
};

let config: HardhatUserConfig = {
networks: {
hardhat: {
forking: {
url: process.env.PROVIDER_URL as string,
url: process.env.PROVIDER_URL as string
},
},
accounts: testAccounts
}
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY as string,
@@ -26,55 +41,55 @@ let config: HardhatUserConfig = {
chainId: 59144,
urls: {
apiURL: "https://api.lineascan.build/api",
browserURL: "https://lineascan.build/",
},
browserURL: "https://lineascan.build/"
}
},
{
network: "baseGoerli",
chainId: 84531,
urls: {
apiURL: "https://api-goerli.basescan.org/api",
browserURL: "https://goerli.basescan.org/",
},
browserURL: "https://goerli.basescan.org/"
}
},
{
network: "linea-goerli",
chainId: 59140,
urls: {
apiURL: "https://api.lineascan.build/api",
browserURL: "https://goerli.lineascan.build/",
},
},
],
browserURL: "https://goerli.lineascan.build/"
}
}
]
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
solidity: {
settings: {
optimizer: {
enabled: true,
runs: 200,
runs: 200
},
viaIR: true,
viaIR: true
},

compilers: [
{
version: "0.8.0",
version: "0.8.0"
},
{
version: "0.8.9",
version: "0.8.9"
},
{
version: "0.8.18",
version: "0.8.18"
},
{
version: "0.8.19",
},
],
},
version: "0.8.19"
}
]
}
};

if (process.env.DEPLOYER_PRIVATE_KEY && process.env.DEPLOYER_ADDRESS) {
@@ -84,23 +99,23 @@ if (process.env.DEPLOYER_PRIVATE_KEY && process.env.DEPLOYER_ADDRESS) {
url: process.env.PROVIDER_URL as string,
accounts: [process.env.DEPLOYER_PRIVATE_KEY as string],
chainId: 11155111,
from: process.env.DEPLOYER_ADDRESS as string,
from: process.env.DEPLOYER_ADDRESS as string
};
}
if (process.env.OP_PROVIDER_URL) {
config.networks["optimism"] = {
url: process.env.OP_PROVIDER_URL as string,
accounts: [process.env.DEPLOYER_PRIVATE_KEY as string],
chainId: 10,
from: process.env.DEPLOYER_ADDRESS as string,
from: process.env.DEPLOYER_ADDRESS as string
};
}
if (process.env.OP_GOERLI_PROVIDER_URL) {
config.networks["optimism-goerli"] = {
url: process.env.OP_GOERLI_PROVIDER_URL as string,
accounts: [process.env.DEPLOYER_PRIVATE_KEY as string],
chainId: 420,
from: process.env.DEPLOYER_ADDRESS as string,
from: process.env.DEPLOYER_ADDRESS as string
};
}
}
@@ -135,7 +150,7 @@ if (
url: process.env.CB_PROVIDER_URL as string,
accounts: [process.env.CB_PRIVATE_KEY as string],
chainId: 84531,
from: process.env.CB_ADDRESS as string,
from: process.env.CB_ADDRESS as string
};
}
}
20 changes: 20 additions & 0 deletions test/GitcoinResolver.ts
Original file line number Diff line number Diff line change
@@ -125,6 +125,26 @@ describe("GitcoinResolver", function () {
};
});

describe("Setup", function () {
it("should revert if non-wner tries to set a score schema", async function () {
await expect(
gitcoinResolver
.connect(nonOwnerOrVerifier)
.setScoreSchema(this.scoreSchemaId)
).to.be.revertedWith("Ownable: caller is not the owner");
});
it("should emit event when a score schema is set", async function () {
const tx = await gitcoinResolver
.connect(owner)
.setScoreSchema(this.scoreSchemaId);
const receipt = await tx.wait();
const EasSetEvent = receipt.logs.filter((log: any) => {
return log.fragment.name == "ScoreSchemaSet";
});
expect(EasSetEvent.length).to.equal(1);
expect(EasSetEvent[0].args[0]).to.equal(this.scoreSchemaId);
});
});
describe("Attestations", function () {
it("should make 1 attestation", async function () {
await gitcoinResolver.connect(mockEas).attest(this.validAttestation);