Skip to content

Commit f4b5118

Browse files
authored
Merge pull request #302 from GoodDollar/ipfs-manager-role
add: update ipfs by manager + new registerapp
2 parents 2e2f8ad + 41a2b95 commit f4b5118

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

packages/contracts/contracts/DirectPayments/DirectPaymentsFactory.sol

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ pragma solidity >=0.8.0;
44
// import the DirectPayments contract
55
import "./DirectPaymentsPool.sol";
66
import "./ProvableNFT.sol";
7+
import "../GoodCollective/SuperAppBaseFlow.sol";
78
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
89
import "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
910
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
10-
1111
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
1212
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
1313

1414
// import "hardhat/console.sol";
1515

1616
contract DirectPaymentsFactory is AccessControlUpgradeable, UUPSUpgradeable {
1717
error NOT_PROJECT_OWNER();
18+
error NOT_PROJECT_MANAGER();
1819
error NOT_POOL();
1920

2021
event PoolCreated(
@@ -60,9 +61,9 @@ contract DirectPaymentsFactory is AccessControlUpgradeable, UUPSUpgradeable {
6061
_;
6162
}
6263

63-
modifier onlyPoolOwner(DirectPaymentsPool pool) {
64-
if (pool.hasRole(pool.DEFAULT_ADMIN_ROLE(), msg.sender) == false) {
65-
revert NOT_PROJECT_OWNER();
64+
modifier onlyPoolManager(DirectPaymentsPool pool) {
65+
if (pool.hasRole(pool.MANAGER_ROLE(), msg.sender) == false) {
66+
revert NOT_PROJECT_MANAGER();
6667
}
6768

6869
_;
@@ -136,6 +137,9 @@ contract DirectPaymentsFactory is AccessControlUpgradeable, UUPSUpgradeable {
136137
pool = DirectPaymentsPool(address(new ERC1967Proxy(impl.implementation(), initCall)));
137138
}
138139

140+
// Register the app with the host
141+
IRegisterSuperapp(address(pool.host())).registerApp(address(pool), SuperAppDefinitions.APP_LEVEL_FINAL);
142+
139143
nft.grantRole(nft.getManagerRole(nextNftType), address(pool));
140144

141145
//access control to project is determinted by the first pool access control rules
@@ -153,7 +157,7 @@ contract DirectPaymentsFactory is AccessControlUpgradeable, UUPSUpgradeable {
153157
nextNftType++;
154158
}
155159

156-
function changePoolDetails(DirectPaymentsPool _pool, string memory _ipfs) external onlyPoolOwner(_pool) {
160+
function changePoolDetails(DirectPaymentsPool _pool, string memory _ipfs) external onlyPoolManager(_pool) {
157161
registry[address(_pool)].ipfs = _ipfs;
158162
emit PoolDetailsChanged(address(_pool), _ipfs);
159163
}

packages/contracts/contracts/GoodCollective/GoodCollectiveSuperApp.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pragma solidity >=0.8.0;
44

55
import { SuperAppBaseFlow } from "./SuperAppBaseFlow.sol";
6-
import { ISuperfluid, ISuperToken, SuperAppDefinitions } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
6+
import { ISuperfluid, ISuperToken, SuperAppDefinitions, ISuperApp } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
77
import { ISuperGoodDollar } from "@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol";
88
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
99
import { CFAv1Library, IConstantFlowAgreementV1 } from "@superfluid-finance/ethereum-contracts/contracts/apps/CFAv1Library.sol";
@@ -90,11 +90,11 @@ abstract contract GoodCollectiveSuperApp is SuperAppBaseFlow {
9090
// Set the super token address
9191
superToken = _superToken;
9292

93-
// Define the callback definitions for the app
94-
uint256 callBackDefinitions = SuperAppDefinitions.APP_LEVEL_FINAL;
93+
// // Define the callback definitions for the app
94+
// uint256 callBackDefinitions = SuperAppDefinitions.APP_LEVEL_FINAL;
9595

96-
// Register the app with the host
97-
host.registerApp(callBackDefinitions);
96+
// // Register the app with the host
97+
// host.registerApp(callBackDefinitions);
9898

9999
//initialize InitData struct, and set equal to cfaV1
100100
cfaV1 = CFAv1Library.InitData(

packages/contracts/contracts/GoodCollective/SuperAppBaseFlow.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/cont
66

77
// import "hardhat/console.sol";
88

9+
interface IRegisterSuperapp {
10+
function registerApp(address app, uint256 configWord) external;
11+
}
12+
913
abstract contract SuperAppBaseFlow is ISuperApp {
1014
using SuperTokenV1Library for ISuperToken;
1115

packages/contracts/contracts/UBI/UBIPoolFactory.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/ac
1111
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
1212

1313
import "../Interfaces.sol";
14+
import "../GoodCollective/GoodCollectiveSuperApp.sol";
15+
import "../GoodCollective/SuperAppBaseFlow.sol";
1416

1517
// import "hardhat/console.sol";
1618

1719
contract UBIPoolFactory is AccessControlUpgradeable, UUPSUpgradeable {
1820
error NOT_PROJECT_OWNER();
21+
error NOT_PROJECT_MANAGER();
1922
error NOT_POOL();
2023

2124
event PoolCreated(
@@ -58,8 +61,8 @@ contract UBIPoolFactory is AccessControlUpgradeable, UUPSUpgradeable {
5861
_;
5962
}
6063

61-
modifier onlyPoolOwner(UBIPool pool) {
62-
if (pool.hasRole(pool.DEFAULT_ADMIN_ROLE(), msg.sender) == false) {
64+
modifier onlyPoolManager(UBIPool pool) {
65+
if (pool.hasRole(pool.MANAGER_ROLE(), msg.sender) == false) {
6366
revert NOT_PROJECT_OWNER();
6467
}
6568

@@ -121,6 +124,9 @@ contract UBIPoolFactory is AccessControlUpgradeable, UUPSUpgradeable {
121124
pool = UBIPool(address(new ERC1967Proxy(impl.implementation(), initCall)));
122125
}
123126

127+
// Register the app with the host
128+
IRegisterSuperapp(address(pool.host())).registerApp(address(pool), SuperAppDefinitions.APP_LEVEL_FINAL);
129+
124130
//access control to project is determinted by the first pool access control rules
125131
if (address(projectIdToControlPool[keccak256(bytes(_projectId))]) == address(0))
126132
projectIdToControlPool[keccak256(bytes(_projectId))] = pool;
@@ -134,7 +140,7 @@ contract UBIPoolFactory is AccessControlUpgradeable, UUPSUpgradeable {
134140
emit PoolCreated(address(pool), _projectId, _ipfs, _settings, _limits);
135141
}
136142

137-
function changePoolDetails(UBIPool _pool, string memory _ipfs) external onlyPoolOwner(_pool) {
143+
function changePoolDetails(UBIPool _pool, string memory _ipfs) external onlyPoolManager(_pool) {
138144
registry[address(_pool)].ipfs = _ipfs;
139145
emit PoolDetailsChanged(address(_pool), _ipfs);
140146
}

packages/contracts/hardhat.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const config: HardhatUserConfig = {
8282
'production-celo': {
8383
chainId: 42220,
8484
url: `https://forno.celo.org`,
85-
gasPrice: 5000000000,
85+
gasPrice: 25.1e9,
8686
accounts: [privateKey],
8787
verify: {
8888
etherscan: {
@@ -94,7 +94,7 @@ const config: HardhatUserConfig = {
9494
'development-celo': {
9595
chainId: 42220,
9696
url: `https://forno.celo.org`,
97-
gasPrice: 5000000000,
97+
gasPrice: 25.1e9,
9898
accounts: {
9999
mnemonic,
100100
},

0 commit comments

Comments
 (0)