Skip to content

Commit

Permalink
fix: add providers without incrementing version. fix break check
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schultz committed Nov 8, 2023
1 parent 8493a62 commit 9abea2d
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 109 deletions.
26 changes: 22 additions & 4 deletions contracts/GitcoinPassportDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ contract GitcoinPassportDecoder is
// Mapping of the current version to provider arrays
mapping(uint32 => string[]) public providerVersions;

// Mapping of previously stored providers
mapping(string => uint256) public savedProviders;

// Current version number
uint32 public currentVersion;

Expand All @@ -36,6 +39,9 @@ contract GitcoinPassportDecoder is
// Passport attestation schema UID
bytes32 public schemaUID;

// Errors
error ProviderAlreadyExists();

function initialize() public initializer {
__Ownable_init();
__Pausable_init();
Expand Down Expand Up @@ -77,10 +83,21 @@ contract GitcoinPassportDecoder is

/**
* @dev Adds a new provider to the end of the providerVersions mapping
* @param provider Name of individual provider
* @param providers provider name
*/
function addProvider(string memory provider) public onlyOwner {
providerVersions[currentVersion].push(provider);
function addProviders(string[] memory providers) public onlyOwner {
for (uint256 i = 0; i < providers.length; ) {
if (savedProviders[providers[i]] == 1) {
revert ProviderAlreadyExists();
}

providerVersions[currentVersion].push(providers[i]);
savedProviders[providers[i]] = 1;

unchecked {
++i;
}
}
}

/**
Expand Down Expand Up @@ -172,7 +189,7 @@ contract GitcoinPassportDecoder is

uint256 mappedProvidersIndex = i * 256 + j;

if (mappedProvidersIndex < mappedProviders.length) {
if (mappedProvidersIndex > mappedProviders.length) {
break;
}

Expand All @@ -194,6 +211,7 @@ contract GitcoinPassportDecoder is

hashIndex += 1;
}

unchecked {
bit <<= 1;
++j;
Expand Down
94 changes: 94 additions & 0 deletions deployments/abi/GitcoinPassportDecoder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"0xe704": [
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
"event Initialized(uint8 version)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Paused(address account)",
"event Unpaused(address account)",
"event Upgraded(address indexed implementation)",
"function addProvider(string provider)",
"function createNewVersion(string[] providerNames)",
"function currentVersion() view returns (uint32)",
"function getAttestation(bytes32 attestationUID) view returns (tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address recipient, address attester, bool revocable, bytes data))",
"function getPassport(address userAddress) view returns (tuple(string provider, bytes32 hash, uint64 issuanceDate, uint64 expirationDate)[])",
"function gitcoinResolver() view returns (address)",
"function initialize()",
"function owner() view returns (address)",
"function pause()",
"function paused() view returns (bool)",
"function providerVersions(uint32, uint256) view returns (string)",
"function proxiableUUID() view returns (bytes32)",
"function renounceOwnership()",
"function schemaUID() view returns (bytes32)",
"function setEASAddress(address _easContractAddress)",
"function setGitcoinResolver(address _gitcoinResolver)",
"function setSchemaUID(bytes32 _schemaUID)",
"function transferOwnership(address newOwner)",
"function unpause()",
"function upgradeTo(address newImplementation)",
"function upgradeToAndCall(address newImplementation, bytes data) payable"
],
"0x1a4": [
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
"event Initialized(uint8 version)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Paused(address account)",
"event Unpaused(address account)",
"event Upgraded(address indexed implementation)",
"function addProvider(string provider)",
"function createNewVersion(string[] providerNames)",
"function currentVersion() view returns (uint32)",
"function getAttestation(bytes32 attestationUID) view returns (tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address recipient, address attester, bool revocable, bytes data))",
"function getPassport(address userAddress) view returns (tuple(string provider, bytes32 hash, uint64 issuanceDate, uint64 expirationDate)[])",
"function gitcoinResolver() view returns (address)",
"function initialize()",
"function owner() view returns (address)",
"function pause()",
"function paused() view returns (bool)",
"function providerVersions(uint32, uint256) view returns (string)",
"function proxiableUUID() view returns (bytes32)",
"function renounceOwnership()",
"function schemaUID() view returns (bytes32)",
"function setEASAddress(address _easContractAddress)",
"function setGitcoinResolver(address _gitcoinResolver)",
"function setSchemaUID(bytes32 _schemaUID)",
"function transferOwnership(address newOwner)",
"function unpause()",
"function upgradeTo(address newImplementation)",
"function upgradeToAndCall(address newImplementation, bytes data) payable"
],
"0x14a33": [
"error ProviderAlreadyExists()",
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
"event Initialized(uint8 version)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Paused(address account)",
"event Unpaused(address account)",
"event Upgraded(address indexed implementation)",
"function addProviders(string[] providers)",
"function createNewVersion(string[] providerNames)",
"function currentVersion() view returns (uint32)",
"function getAttestation(bytes32 attestationUID) view returns (tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address recipient, address attester, bool revocable, bytes data))",
"function getPassport(address userAddress) view returns (tuple(string provider, bytes32 hash, uint64 issuanceDate, uint64 expirationDate)[])",
"function gitcoinResolver() view returns (address)",
"function initialize()",
"function owner() view returns (address)",
"function pause()",
"function paused() view returns (bool)",
"function providerVersions(uint32, uint256) view returns (string)",
"function proxiableUUID() view returns (bytes32)",
"function renounceOwnership()",
"function savedProviders(string) view returns (uint256)",
"function schemaUID() view returns (bytes32)",
"function setEASAddress(address _easContractAddress)",
"function setGitcoinResolver(address _gitcoinResolver)",
"function setSchemaUID(bytes32 _schemaUID)",
"function transferOwnership(address newOwner)",
"function unpause()",
"function upgradeTo(address newImplementation)",
"function upgradeToAndCall(address newImplementation, bytes data) payable"
]
}
7 changes: 6 additions & 1 deletion deployments/abi/GitcoinResolver.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"0x14a33": [
"error AccessDenied()",
"error InsufficientValue()",
"error InvalidAttester()",
"error InvalidEAS()",
"error NotAllowlisted()",
"error NotPayable()",
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
Expand All @@ -13,8 +15,10 @@
"event Upgraded(address indexed implementation)",
"function _eas() view returns (address)",
"function _gitcoinAttester() view returns (address)",
"function aNewPublicVairable() view returns (uint256)",
"function addToAllowlist(address addr)",
"function allowlist(address) view returns (bool)",
"function attest(tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address recipient, address attester, bool revocable, bytes data) attestation) payable returns (bool)",
"function getUserAttestation(address user, bytes32 schema) view returns (bytes32)",
"function initialize(address eas, address gitcoinAttester)",
"function isPayable() pure returns (bool)",
"function multiAttest(tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address recipient, address attester, bool revocable, bytes data)[] attestations, uint256[]) payable returns (bool)",
Expand All @@ -23,6 +27,7 @@
"function pause()",
"function paused() view returns (bool)",
"function proxiableUUID() view returns (bytes32)",
"function removeFromAllowlist(address addr)",
"function renounceOwnership()",
"function revoke(tuple(bytes32 uid, bytes32 schema, uint64 time, uint64 expirationTime, uint64 revocationTime, bytes32 refUID, address recipient, address attester, bool revocable, bytes data) attestation) payable returns (bool)",
"function transferOwnership(address newOwner)",
Expand Down
3 changes: 3 additions & 0 deletions deployments/abi/GitcoinVerifier.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"0x14a33": [
"error InsufficientFee()",
"error InvalidNonce()",
"error InvalidSignature()",
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
"event Initialized(uint8 version)",
Expand Down
14 changes: 7 additions & 7 deletions deployments/onchainInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
"address": "0xAcfE09Fd03f7812F022FBf636700AdEA18Fd2A7A"
},
"GitcoinResolver": {
"address": "0xAb4124548751C15d002b9c7cb9488190847b1fe1"
"address": "0xDCBD32496495aB389b72741Aa4aAAda6Ae817321"
},
"GitcoinVerifier": {
"address": "0x5bC95C6e11520D25BE8c7bDf7AAc3E2eEAbD8564"
"address": "0xA6FB077602B5A9C13893ce5F50CD24B660cf717C"
},
"GitcoinAttester": {
"address": "0x5bbbc733e12f50e6834c40a90066f2f9ffb820e0"
"address": "0xE018e14023a134Ebf4b48CE1ba2b10204209612e"
},
"easSchemas": {
"passport": {
"uid": "0x9d43e5c201404b9ab0913bcd6475c78e32d32a4d78233b2c309e9b6828f59e45"
"uid": "0x8787ce9766a61683acc9b94cb469e22ea21fc27ea24f6224fd5239efa3332302"
},
"score": {
"uid": "0xf72ba57b5fb4c12a5f967574bc44a11efb8be76bcfbf47ced36e1afe226ba702"
"uid": "0x537b498843f447aea33d6a79595fa1a8137edfc82802d909d9f8f81d4bdf6f44"
}
},
"GitcoinPassportDecoder": {
"address": "0x6BDb1C8EDa7cC998435598E43ddd346A3a9aC832"
"address": "0x21221bFCf485c1658470017EA3bD02f238d6e8d3"
}
},
"0xa": {
Expand Down Expand Up @@ -134,4 +134,4 @@
"address": "0xCAa9E817f02486cE076560B77A86235Ef91c5d5D"
}
}
}
}
1 change: 1 addition & 0 deletions deployments/providerBitMapInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"bit":0,"index":0,"name":"SelfStakingBronze"},{"bit":1,"index":0,"name":"SelfStakingSilver"},{"bit":2,"index":0,"name":"SelfStakingGold"},{"bit":3,"index":0,"name":"CommunityStakingBronze"},{"bit":4,"index":0,"name":"CommunityStakingSilver"},{"bit":5,"index":0,"name":"CommunityStakingGold"},{"bit":6,"index":0,"name":"GitcoinContributorStatistics#numGrantsContributeToGte#1"},{"bit":7,"index":0,"name":"GitcoinContributorStatistics#numGrantsContributeToGte#10"},{"bit":8,"index":0,"name":"GitcoinContributorStatistics#numGrantsContributeToGte#25"},{"bit":9,"index":0,"name":"GitcoinContributorStatistics#numGrantsContributeToGte#100"},{"bit":10,"index":0,"name":"GitcoinContributorStatistics#totalContributionAmountGte#10"},{"bit":11,"index":0,"name":"GitcoinContributorStatistics#totalContributionAmountGte#100"},{"bit":12,"index":0,"name":"GitcoinContributorStatistics#totalContributionAmountGte#1000"},{"bit":13,"index":0,"name":"GitcoinContributorStatistics#numGr14ContributionsGte#1"},{"bit":14,"index":0,"name":"GitcoinContributorStatistics#numRoundsContributedToGte#1"},{"bit":15,"index":0,"name":"twitterAccountAgeGte#180"},{"bit":16,"index":0,"name":"twitterAccountAgeGte#365"},{"bit":17,"index":0,"name":"twitterAccountAgeGte#730"},{"bit":18,"index":0,"name":"Discord"},{"bit":19,"index":0,"name":"Google"},{"bit":20,"index":0,"name":"githubAccountCreationGte#90"},{"bit":21,"index":0,"name":"githubAccountCreationGte#180"},{"bit":22,"index":0,"name":"githubAccountCreationGte#365"},{"bit":23,"index":0,"name":"githubContributionActivityGte#30"},{"bit":24,"index":0,"name":"githubContributionActivityGte#60"},{"bit":25,"index":0,"name":"githubContributionActivityGte#120"},{"bit":26,"index":0,"name":"Facebook"},{"bit":27,"index":0,"name":"FacebookProfilePicture"},{"bit":28,"index":0,"name":"Linkedin"},{"bit":29,"index":0,"name":"Ens"},{"bit":30,"index":0,"name":"Brightid"},{"bit":31,"index":0,"name":"Poh"},{"bit":32,"index":0,"name":"ethPossessionsGte#1"},{"bit":33,"index":0,"name":"ethPossessionsGte#10"},{"bit":34,"index":0,"name":"ethPossessionsGte#32"},{"bit":35,"index":0,"name":"FirstEthTxnProvider"},{"bit":36,"index":0,"name":"EthGTEOneTxnProvider"},{"bit":37,"index":0,"name":"EthGasProvider"},{"bit":38,"index":0,"name":"SnapshotVotesProvider"},{"bit":39,"index":0,"name":"SnapshotProposalsProvider"},{"bit":40,"index":0,"name":"NFT"},{"bit":41,"index":0,"name":"ZkSync"},{"bit":42,"index":0,"name":"ZkSyncEra"},{"bit":43,"index":0,"name":"Lens"},{"bit":44,"index":0,"name":"GnosisSafe"},{"bit":45,"index":0,"name":"Coinbase"},{"bit":46,"index":0,"name":"GuildMember"},{"bit":47,"index":0,"name":"GuildAdmin"},{"bit":48,"index":0,"name":"GuildPassportMember"},{"bit":49,"index":0,"name":"Hypercerts"},{"bit":50,"index":0,"name":"PHIActivitySilver"},{"bit":51,"index":0,"name":"PHIActivityGold"},{"bit":52,"index":0,"name":"HolonymGovIdProvider"},{"bit":53,"index":0,"name":"IdenaState#Newbie"},{"bit":54,"index":0,"name":"IdenaState#Verified"},{"bit":55,"index":0,"name":"IdenaState#Human"},{"bit":56,"index":0,"name":"IdenaStake#1k"},{"bit":57,"index":0,"name":"IdenaStake#10k"},{"bit":58,"index":0,"name":"IdenaStake#100k"},{"bit":59,"index":0,"name":"IdenaAge#5"},{"bit":60,"index":0,"name":"IdenaAge#10"},{"bit":61,"index":0,"name":"CivicCaptchaPass"},{"bit":62,"index":0,"name":"CivicUniquenessPass"},{"bit":63,"index":0,"name":"CivicLivenessPass"},{"bit":64,"index":0,"name":"CyberProfilePremium"},{"bit":65,"index":0,"name":"CyberProfilePaid"},{"bit":66,"index":0,"name":"CyberProfileOrgMember"},{"bit":67,"index":0,"name":"GrantsStack3Projects"},{"bit":68,"index":0,"name":"GrantsStack5Projects"},{"bit":69,"index":0,"name":"GrantsStack7Projects"},{"bit":70,"index":0,"name":"GrantsStack2Programs"},{"bit":71,"index":0,"name":"GrantsStack4Programs"},{"bit":72,"index":0,"name":"GrantsStack6Programs"},{"bit":73,"index":0,"name":"TrustaLabs"}]
14 changes: 8 additions & 6 deletions docs/03-new-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ This is the process to deploy these contracts to a new chain:
2. Run `initializeChainInfo.ts` and follow instructions
3. Run `deployVerifierAndAttester.ts` (this calls addVerifier and setEASAddress)
4. Run `deployResolver.ts`
5. Verify contracts, make sure everything looks good
6. Ensure `PASSPORT_MULTISIG_ADDRESS` is set in your .env, then run `transferOwnership.ts`
7. Create EAS schemas pointing to the new resolver,
5. Run `deployPassportDecoder.ts`
6. Run `setupDecoder.ts`
7. Verify contracts, make sure everything looks good
8. Ensure `PASSPORT_MULTISIG_ADDRESS` is set in your .env, then run `transferOwnership.ts`
9. Create EAS schemas pointing to the new resolver,
add to `onChainInfo.json`
8. In the Passport app, copy over the new `deployments` directory and
configure `NEXT_PUBLIC_ACTIVE_ON_CHAIN_PASSPORT_CHAINIDS`
and `NEXT_PUBLIC_POSSIBLE_ON_CHAIN_PASSPORT_CHAINIDS`
10. In the Passport app, copy over the new `deployments` directory and
configure `NEXT_PUBLIC_ACTIVE_ON_CHAIN_PASSPORT_CHAINIDS`
and `NEXT_PUBLIC_POSSIBLE_ON_CHAIN_PASSPORT_CHAINIDS`

## Notes

Expand Down
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ if (
) {
if (config.networks) {
config.networks["baseGoerli"] = {
gasPrice: 1000005,
url: process.env.CB_PROVIDER_URL as string,
accounts: [process.env.CB_PRIVATE_KEY as string],
chainId: 84531,
Expand Down
2 changes: 1 addition & 1 deletion scripts/setupDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function main() {
);

const providers = newBitMap.map((bit) => bit.name);
await passportDecoder.createNewVersion(providers);
await passportDecoder.addProviders(providers);

console.log(`✅ Added providers to GitcoinPassportDecoder.`);
}
Expand Down
Loading

0 comments on commit 9abea2d

Please sign in to comment.