Skip to content

Commit

Permalink
Merge branch 'master' of github.com:GoodDollar/GoodCollective into 22…
Browse files Browse the repository at this point in the history
…4-new-homepage
  • Loading branch information
L03TJ3 committed Oct 25, 2024
2 parents 0b6eefa + 549b9d2 commit d1a291b
Show file tree
Hide file tree
Showing 11 changed files with 11,178 additions and 728 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ contract DirectPaymentsFactory is AccessControlUpgradeable, UUPSUpgradeable {

nft.grantRole(nft.getManagerRole(nextNftType), _settings.manager);
nft.grantRole(nft.getManagerRole(nextNftType), address(pool));
pool.grantRole(pool.MINTER_ROLE(), _settings.manager);

//access control to project is determinted by the first pool access control rules
if (address(projectIdToControlPool[keccak256(bytes(_projectId))]) == address(0))
projectIdToControlPool[keccak256(bytes(_projectId))] = pool;
registry[address(pool)].ipfs = _ipfs;
registry[address(pool)].projectId = _projectId;

pool.grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
pool.renounceRole(DEFAULT_ADMIN_ROLE, address(this));
pools.push(address(pool));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ contract DirectPaymentsPool is
settings = _settings;
limits = _limits;
nft = _nft;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, _settings.manager);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender); // when using factory this gives factory role which then set role to the real msg.sender
_setupRole(MANAGER_ROLE, _settings.manager);
_setupRole(MINTER_ROLE, _settings.manager);

setSuperToken(ISuperToken(address(settings.rewardToken)));
}

Expand Down Expand Up @@ -398,7 +400,7 @@ contract DirectPaymentsPool is
* @dev Sets the safety limits for the pool.
* @param _limits The new safety limits.
*/
function setPoolLimits(SafetyLimits memory _limits) public onlyRole(DEFAULT_ADMIN_ROLE) {
function setPoolLimits(SafetyLimits memory _limits) public onlyRole(MANAGER_ROLE) {
limits = _limits;
emit PoolLimitsChanged(_limits);
}
Expand All @@ -407,7 +409,7 @@ contract DirectPaymentsPool is
* @dev Sets the settings for the pool.
* @param _settings The new pool settings.
*/
function setPoolSettings(PoolSettings memory _settings) public onlyRole(DEFAULT_ADMIN_ROLE) {
function setPoolSettings(PoolSettings memory _settings) public onlyRole(MANAGER_ROLE) {
if (_settings.nftType != settings.nftType) revert NFTTYPE_CHANGED();
if (_settings.manager == address(0)) revert EMPTY_MANAGER();

Expand Down
7 changes: 4 additions & 3 deletions packages/contracts/contracts/UBI/UBIPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract UBIPool is AccessControlUpgradeable, GoodCollectiveSuperApp, UUPSUpgrad

error CLAIMFOR_DISABLED();
error NOT_MEMBER(address claimer);
error NOT_MANAGER(address manager);
error NOT_WHITELISTED(address whitelistedRoot);
error ALREADY_CLAIMED(address whitelistedRoot);
error INVALID_0_VALUE();
Expand Down Expand Up @@ -126,7 +127,7 @@ contract UBIPool is AccessControlUpgradeable, GoodCollectiveSuperApp, UUPSUpgrad
ubiSettings = _ubiSettings;
_verifyPoolSettings(_settings);
_verifyUBISettings(_ubiSettings);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender); // when using factory this gives factory role which then set role to the real msg.sender
_setupRole(MANAGER_ROLE, _settings.manager);
setSuperToken(ISuperToken(address(settings.rewardToken)));
}
Expand Down Expand Up @@ -273,7 +274,7 @@ contract UBIPool is AccessControlUpgradeable, GoodCollectiveSuperApp, UUPSUpgrad
}
// if no members validator then if members only only manager can add members
else if (ubiSettings.onlyMembers && hasRole(MANAGER_ROLE, msg.sender) == false) {
revert NOT_MEMBER(member);
revert NOT_MANAGER(member);
}

_grantRole(MEMBER_ROLE, member);
Expand Down Expand Up @@ -394,6 +395,6 @@ contract UBIPool is AccessControlUpgradeable, GoodCollectiveSuperApp, UUPSUpgrad
}

function nextClaimTime() public view returns (uint256) {
return (getCurrentDay() + 1) * (1 days);
return (getCurrentDay() + ubiSettings.claimPeriodDays) * (1 days) + 12 hours;
}
}
14 changes: 14 additions & 0 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ const config: HardhatUserConfig = {
},
},
},
'production-celo': {
chainId: 42220,
url: `https://forno.celo.org`,
gasPrice: 5000000000,
accounts: {
mnemonic,
},
verify: {
etherscan: {
apiKey: process.env.CELOSCAN_KEY,
apiUrl: 'https://api.celoscan.io/',
},
},
},
'development-celo': {
chainId: 42220,
url: `https://forno.celo.org`,
Expand Down
11,749 changes: 11,072 additions & 677 deletions packages/contracts/releases/deployment.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('DirectPaymentsPool Superapp', () => {
path: '0x',
}, '0x')

console.log((await tx.wait()).events)
// console.log((await tx.wait()).events)

expect(await mockToken.balanceOf(signer.address)).eq(0);
expect(await gdframework.GoodDollar.balanceOf(signer.address)).eq(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ describe('DirectPaymentsFactory', () => {
expect(await nft.hasRole(await nft.getManagerRole('1'), signers[1].address)).to.be.true;
expect(await nft.hasRole(await nft.getManagerRole('1'), pool.address)).to.be.true;

expect(await pool.hasRole(nft.DEFAULT_ADMIN_ROLE(), signers[1].address)).to.be.true;
expect(await pool.hasRole(nft.DEFAULT_ADMIN_ROLE(), factory.address)).to.be.false;
expect(await pool.hasRole(pool.DEFAULT_ADMIN_ROLE(), signer.address)).to.be.true;
expect(await pool.hasRole(pool.MANAGER_ROLE(), signers[1].address)).to.be.true;
expect(await pool.hasRole(pool.DEFAULT_ADMIN_ROLE(), factory.address)).to.be.false;

// datastructures
expect(await factory.projectIdToControlPool(ethers.utils.keccak256(ethers.utils.toUtf8Bytes('test')))).to.be.equal(
Expand All @@ -119,7 +120,7 @@ describe('DirectPaymentsFactory', () => {
});

it("should not be able to create pool if not project's manager", async () => {
const tx = await factory.createPool('test', 'pool1', poolSettings, poolLimits);
const tx = await factory.connect(signers[1]).createPool('test', 'pool1', poolSettings, poolLimits);

// signer 1 is the pool manager so it should not revert
await expect(factory.connect(signers[1]).createPool('test', 'pool2', poolSettings, poolLimits)).not.reverted;
Expand Down
105 changes: 67 additions & 38 deletions packages/sdk-js/scripts/createPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ const main = async () => {
if (process.argv[2] === 'ubi') {
return createUbiPool();
}
if (process.argv[2] === 'update') {
return updatePool('0xDd1c12f197E6D1E2FBA15487AaAE500eF6e07BCA');
}
return createPool();
// return updatePool('0x5dd23da6e1635928fa7f4fa2d8d8d623aa9c89ee');
};

const getMemberPools = async (address: string) => {
Expand Down Expand Up @@ -73,22 +75,44 @@ const createPool = async () => {
};

const updatePool = async (pool: string) => {
// const poolAttributes = {
// name: 'Test ipfs single donation with swap (Real G$)',
// description:
// 'This Collective directly supports smallholder farmers around Kenya’s Kakamega forest. These farmers are acting as nurseries, growing and nurturing native trees to maturity for subsequent reforestation. In partnership with Silvi.',
// email: '[email protected]',
// website: 'https://www.silvi.earth',
// twitter: 'https://twitter.com/SilviProtocol',
// instagram: 'https://instagram.com/x',
// threads: '',
// headerImage:
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c75ac7830faf70f9469_FooterBackground.jpg',
// logo: 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c4586b18e3e276db342_SilviLogo.png',
// images: [
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/6507cb24ffa8a438ccf13d70_Screen%20Shot%202023-09-17%20at%208.59.00%20PM-p-500.png',
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/650352d39dde89c0fd676908_RuralPlanting.jpg',
// ],
// };

const poolAttributes = {
name: 'Test ipfs single donation with swap (Real G$)',
name: 'Red Tent Women in Nigeria',
description:
'This Collective directly supports smallholder farmers around Kenya’s Kakamega forest. These farmers are acting as nurseries, growing and nurturing native trees to maturity for subsequent reforestation. In partnership with Silvi.',
email: '[email protected]',
website: 'https://www.silvi.earth',
twitter: 'https://twitter.com/SilviProtocol',
instagram: 'https://instagram.com/x',
threads: '',
headerImage:
'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c75ac7830faf70f9469_FooterBackground.jpg',
logo: 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c4586b18e3e276db342_SilviLogo.png',
images: [
'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/6507cb24ffa8a438ccf13d70_Screen%20Shot%202023-09-17%20at%208.59.00%20PM-p-500.png',
'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/650352d39dde89c0fd676908_RuralPlanting.jpg',
],
'The Red Tent Women’s Basic Income is designed to flow money unencumbered and unconditionally from women and allies who have it to women who need it. Red Tent’s goal is to create a decentralized, automated and highly personalized system that measures and improves collaboration and wellbeing in communities. Women are the keepers of family and community, yet continue to be disproportionately affected by lack of access to capital and influence in all systems.',
rewardDescription: 'Up to 500 women in Nigeria may claim G$ every day ',
goodidDescription: 'Verified women from Nigeria',
// email: '',
website: 'https://redtent.io',
// twitter: '',
// instagram: '',
// twitter: 'https://twitter.com/SilviProtocol',
// instagram: 'https://instagram.com/x',
// threads: '',
headerImage: 'https://bafybeigo4ef4czy3rscoukfccgilzkzjchsr5cbhesz7sdc2komkqcibxu.ipfs.w3s.link/RedTent.tiny.png',
logo: 'https://bafybeigo4ef4czy3rscoukfccgilzkzjchsr5cbhesz7sdc2komkqcibxu.ipfs.w3s.link/RedTent.tiny.png',
// logo: 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c4586b18e3e276db342_SilviLogo.png',
// images: [
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/6507cb24ffa8a438ccf13d70_Screen%20Shot%202023-09-17%20at%208.59.00%20PM-p-500.png',
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/650352d39dde89c0fd676908_RuralPlanting.jpg',
// ],
};

const cid = await sdk.savePoolToIPFS(poolAttributes);
Expand All @@ -98,44 +122,49 @@ const updatePool = async (pool: string) => {
const res = await tx.wait();
console.log('updated pool', res);
};

const createUbiPool = async () => {
const projectId = 'testing';
const projectId = 'redtent';
const poolAttributes = {
name: 'Test subgraph events UBI Pool (Dev token)',
name: 'Red Tent Women in Nigeria',
description:
'This Collective directly supports smallholder farmers around Kenya’s Kakamega forest. These farmers are acting as nurseries, growing and nurturing native trees to maturity for subsequent reforestation. In partnership with Silvi.',
rewardDescription: 'Daily UBI',
goodidDescription: 'Verified women from kenya',
email: '[email protected]',
website: 'https://www.gooddollar.org',
twitter: 'https://twitter.com/SilviProtocol',
instagram: 'https://instagram.com/x',
threads: '',
headerImage:
'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c75ac7830faf70f9469_FooterBackground.jpg',
logo: 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c4586b18e3e276db342_SilviLogo.png',
images: [
'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/6507cb24ffa8a438ccf13d70_Screen%20Shot%202023-09-17%20at%208.59.00%20PM-p-500.png',
'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/650352d39dde89c0fd676908_RuralPlanting.jpg',
],
'The Red Tent Women’s Basic Income is designed to flow money unencumbered and unconditionally from women and allies who have it to women who need it. Red Tent’s goal is to create a decentralized, automated and highly personalized system that measures and improves collaboration and wellbeing in communities. Women are the keepers of family and community, yet continue to be disproportionately affected by lack of access to capital and influence in all systems.',
rewardDescription: 'Up to 500 women in Nigeria may claim G$ every day ',
goodidDescription: 'Verified women from Nigeria',
// email: '',
website: 'https://redtent.io',
// twitter: '',
// instagram: '',
// twitter: 'https://twitter.com/SilviProtocol',
// instagram: 'https://instagram.com/x',
// threads: '',
headerImage: 'https://bafybeigo4ef4czy3rscoukfccgilzkzjchsr5cbhesz7sdc2komkqcibxu.ipfs.w3s.link/RedTent.tiny.png',
logo: 'https://bafybeigo4ef4czy3rscoukfccgilzkzjchsr5cbhesz7sdc2komkqcibxu.ipfs.w3s.link/RedTent.tiny.png',
// logo: 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/65032c4586b18e3e276db342_SilviLogo.png',
// images: [
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/6507cb24ffa8a438ccf13d70_Screen%20Shot%202023-09-17%20at%208.59.00%20PM-p-500.png',
// 'https://uploads-ssl.webflow.com/639e611ba0716a170111fe96/650352d39dde89c0fd676908_RuralPlanting.jpg',
// ],
};

const poolSettings: UBIPoolSettings = {
manager: wallet.address,
membersValidator: ethers.constants.AddressZero,
uniquenessValidator: '0xF25fA0D4896271228193E782831F6f3CFCcF169C',
rewardToken: '0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475',
uniquenessValidator: '0xC361A6E67822a0EDc17D899227dd9FC50BD62F42',
// uniquenessValidator: '0xF25fA0D4896271228193E782831F6f3CFCcF169C',
// rewardToken: '0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475',
rewardToken: '0x62B8B11039FcfE5aB0C56E502b1C372A3d2a9c7A',
// network === 'development-celo'
// ? '0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475'
// : '0x62B8B11039FcfE5aB0C56E502b1C372A3d2a9c7A', //celo production token
};

const ubiSettings: UBISettings = {
cycleLengthDays: ethers.BigNumber.from(60),
cycleLengthDays: ethers.BigNumber.from(7),
claimPeriodDays: ethers.BigNumber.from(1),
minActiveUsers: ethers.BigNumber.from(100),
claimForEnabled: true,
maxClaimAmount: ethers.utils.parseEther('100'),
minActiveUsers: ethers.BigNumber.from(500),
claimForEnabled: false,
maxClaimAmount: ethers.utils.parseEther('437'),
maxClaimers: 500,
onlyMembers: true,
};
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/subgraph/config/celo-prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"network": "celo",
"UBIPoolFactoryAddress": "0x7af4A611FFA07644C3FE93aA49230e2BD2Ec8dBf",
"DirectPaymentsFactoryAddress": "0x55B06783023D8bfAB28ddb823098f1485b15Bf22",
"ProvableNFTAddress": "0x62AFaF745425fd2b67b358083068d3802e9EF04d",
"startBlock": 28352452,
"startBlockUbi": 28352452
}
2 changes: 1 addition & 1 deletion packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codegen": "graph codegen",
"build": "yarn build:copyabi && yarn codegen && graph build",
"build:copyabi": "find ../contracts/artifacts/contracts/ -type f -not -name '*.dbg.json' -exec cp '{}' ./abis/ \\;",
"deploy": "yarn prepare celo; yarn prepare celo; graph auth --studio $STUDIO_PROD_KEY; graph deploy --studio goodcollective --version-label=v$npm_package_version",
"deploy": "yarn prepare celo-prod; graph auth --studio $STUDIO_PROD_KEY; graph deploy --studio goodcollective --version-label=v$npm_package_version",
"deploy-dev": "yarn prepare celo-dev;graph auth --studio $STUDIO_PROD_KEY; graph deploy --studio goodcollective --version-label= --version-label=dev-v$npm_package_version",
"create-local": "graph create --node http://localhost:8020/ scaffold-eth/your-contract",
"remove-local": "graph remove --node http://localhost:8020/ scaffold-eth/your-contract",
Expand Down

0 comments on commit d1a291b

Please sign in to comment.