@etherisc/gif-next 0.0.2-b81ff84-640 → 0.0.2-b97394c-442
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +13 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +23 -15
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +13 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +2 -2
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +29 -16
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +31 -56
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +0 -13
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1356 -22
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +167 -101
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -47
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +177 -38
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +209 -33
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +91 -15
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +59 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +716 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +444 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +108 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +971 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +460 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +2 -110
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +35 -146
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +26 -34
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +9 -9
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/BaseComponent.sol +8 -3
- package/contracts/components/Distribution.sol +15 -18
- package/contracts/components/IBaseComponent.sol +1 -0
- package/contracts/components/IDistributionComponent.sol +1 -0
- package/contracts/components/IPoolComponent.sol +1 -1
- package/contracts/components/Pool.sol +16 -28
- package/contracts/components/Product.sol +34 -42
- package/contracts/instance/AccessManagedSimple.sol +1 -8
- package/contracts/instance/IInstance.sol +33 -7
- package/contracts/instance/Instance.sol +20 -19
- package/contracts/instance/InstanceAccessManager.sol +1 -1
- package/contracts/instance/InstanceReader.sol +26 -1
- package/contracts/instance/InstanceService.sol +69 -9
- package/contracts/instance/InstanceServiceManager.sol +6 -5
- package/contracts/instance/base/ComponentServiceBase.sol +91 -6
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/ISetup.sol +4 -0
- package/contracts/instance/service/DistributionService.sol +88 -0
- package/contracts/instance/service/DistributionServiceManager.sol +54 -0
- package/contracts/instance/service/IPoolService.sol +6 -0
- package/contracts/instance/service/IProductService.sol +6 -3
- package/contracts/instance/service/PoolService.sol +204 -0
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +561 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/IRegistry.sol +5 -18
- package/contracts/registry/IRegistryService.sol +28 -11
- package/contracts/registry/Registry.sol +4 -45
- package/contracts/registry/RegistryService.sol +30 -71
- package/contracts/shared/NftOwnable.sol +2 -4
- package/contracts/shared/Service.sol +1 -0
- package/contracts/types/RoleId.sol +8 -0
- package/contracts/types/StateId.sol +4 -0
- package/package.json +1 -1
@@ -25,13 +25,15 @@ import {Registerable} from "../shared/Registerable.sol";
|
|
25
25
|
contract Pool is BaseComponent, IPoolComponent {
|
26
26
|
using NftIdLib for NftId;
|
27
27
|
|
28
|
-
bool internal
|
28
|
+
bool internal _isConfirmingApplication;
|
29
29
|
UFixed internal _collateralizationLevel;
|
30
30
|
|
31
31
|
Fee internal _initialPoolFee;
|
32
32
|
Fee internal _initialStakingFee;
|
33
33
|
Fee internal _initialPerformanceFee;
|
34
34
|
|
35
|
+
TokenHandler internal _tokenHandler;
|
36
|
+
|
35
37
|
// may be used to interact with instance by derived contracts
|
36
38
|
IPoolService internal _poolService;
|
37
39
|
|
@@ -55,29 +57,29 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
55
57
|
constructor(
|
56
58
|
address registry,
|
57
59
|
NftId instanceNftId,
|
58
|
-
NftId productNftId,
|
59
60
|
// TODO refactor into tokenNftId
|
60
61
|
address token,
|
61
62
|
bool isInterceptor,
|
62
|
-
bool
|
63
|
+
bool isConfirmingApplication,
|
63
64
|
UFixed collateralizationLevel,
|
64
65
|
Fee memory poolFee,
|
65
66
|
Fee memory stakingFee,
|
66
67
|
Fee memory performanceFee,
|
67
68
|
address initialOwner
|
68
69
|
)
|
69
|
-
BaseComponent(registry, instanceNftId,
|
70
|
+
BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
|
70
71
|
{
|
71
|
-
|
72
|
+
_isConfirmingApplication = isConfirmingApplication;
|
72
73
|
// TODO add validation
|
73
74
|
_collateralizationLevel = collateralizationLevel;
|
74
75
|
_initialPoolFee = poolFee;
|
75
76
|
_initialStakingFee = stakingFee;
|
76
77
|
_initialPerformanceFee = performanceFee;
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
_tokenHandler = new TokenHandler(token);
|
80
|
+
|
81
|
+
_poolService = _instance.getPoolService();
|
82
|
+
_productService = _instance.getProductService();
|
81
83
|
|
82
84
|
_registerInterface(type(IPoolComponent).interfaceId);
|
83
85
|
}
|
@@ -138,8 +140,8 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
138
140
|
}
|
139
141
|
|
140
142
|
|
141
|
-
function
|
142
|
-
return
|
143
|
+
function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
|
144
|
+
return _isConfirmingApplication;
|
143
145
|
}
|
144
146
|
|
145
147
|
function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
|
@@ -170,20 +172,6 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
170
172
|
}
|
171
173
|
|
172
174
|
function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
|
173
|
-
// TODO fix this
|
174
|
-
if (getNftId().eq(zeroNftId())) {
|
175
|
-
return ISetup.PoolSetupInfo(
|
176
|
-
_productNftId,
|
177
|
-
TokenHandler(address(0)),
|
178
|
-
_collateralizationLevel,
|
179
|
-
_initialPoolFee,
|
180
|
-
_initialStakingFee,
|
181
|
-
_initialPerformanceFee,
|
182
|
-
_isVerifying,
|
183
|
-
_wallet
|
184
|
-
);
|
185
|
-
}
|
186
|
-
|
187
175
|
InstanceReader reader = _instance.getInstanceReader();
|
188
176
|
return reader.getPoolSetupInfo(getNftId());
|
189
177
|
}
|
@@ -200,20 +188,20 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
200
188
|
{
|
201
189
|
(
|
202
190
|
IRegistry.ObjectInfo memory info,
|
203
|
-
bytes memory data
|
204
191
|
) = super.getInitialInfo();
|
205
192
|
|
206
193
|
return (
|
207
194
|
info,
|
208
195
|
abi.encode(
|
209
196
|
ISetup.PoolSetupInfo(
|
210
|
-
|
211
|
-
|
197
|
+
_productNftId,
|
198
|
+
_tokenHandler,
|
212
199
|
_collateralizationLevel,
|
213
200
|
_initialPoolFee,
|
214
201
|
_initialStakingFee,
|
215
202
|
_initialPerformanceFee,
|
216
|
-
|
203
|
+
false,
|
204
|
+
_isConfirmingApplication,
|
217
205
|
_wallet
|
218
206
|
)
|
219
207
|
)
|
@@ -24,6 +24,7 @@ import {TokenHandler} from "../shared/TokenHandler.sol";
|
|
24
24
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
25
25
|
import {ISetup} from "../instance/module/ISetup.sol";
|
26
26
|
import {Pool} from "../components/Pool.sol";
|
27
|
+
import {Distribution} from "../components/Distribution.sol";
|
27
28
|
|
28
29
|
import {zeroNftId} from "../types/NftId.sol";
|
29
30
|
|
@@ -32,9 +33,10 @@ contract Product is BaseComponent, IProductComponent {
|
|
32
33
|
|
33
34
|
IProductService internal _productService;
|
34
35
|
Pool internal _pool;
|
35
|
-
|
36
|
+
Distribution internal _distribution;
|
36
37
|
Fee internal _initialProductFee;
|
37
38
|
Fee internal _initialProcessingFee;
|
39
|
+
TokenHandler internal _tokenHandler;
|
38
40
|
|
39
41
|
NftId internal _poolNftId;
|
40
42
|
NftId internal _distributionNftId;
|
@@ -49,17 +51,18 @@ contract Product is BaseComponent, IProductComponent {
|
|
49
51
|
Fee memory productFee,
|
50
52
|
Fee memory processingFee,
|
51
53
|
address initialOwner
|
52
|
-
) BaseComponent(registry, instanceNftid,
|
54
|
+
) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
|
53
55
|
// TODO add validation
|
54
|
-
|
55
|
-
// _productService = _instance.getProductService();
|
56
|
+
_productService = _instance.getProductService();
|
56
57
|
_pool = Pool(pool);
|
57
|
-
_distribution = distribution;
|
58
|
+
_distribution = Distribution(distribution);
|
58
59
|
_initialProductFee = productFee;
|
59
60
|
_initialProcessingFee = processingFee;
|
60
61
|
|
62
|
+
_tokenHandler = new TokenHandler(token);
|
63
|
+
|
61
64
|
_poolNftId = getRegistry().getNftId(address(_pool));
|
62
|
-
_distributionNftId = getRegistry().getNftId(_distribution);
|
65
|
+
_distributionNftId = getRegistry().getNftId(address(_distribution));
|
63
66
|
|
64
67
|
_registerInterface(type(IProductComponent).interfaceId);
|
65
68
|
}
|
@@ -118,13 +121,13 @@ contract Product is BaseComponent, IProductComponent {
|
|
118
121
|
);
|
119
122
|
}
|
120
123
|
|
121
|
-
function
|
124
|
+
function _updateRisk(
|
122
125
|
RiskId id,
|
123
|
-
|
126
|
+
bytes memory data
|
124
127
|
) internal {
|
125
|
-
_productService.
|
128
|
+
_productService.updateRisk(
|
126
129
|
id,
|
127
|
-
|
130
|
+
data
|
128
131
|
);
|
129
132
|
}
|
130
133
|
|
@@ -202,7 +205,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
202
205
|
}
|
203
206
|
|
204
207
|
function getDistributionNftId() external view override returns (NftId distributionNftId) {
|
205
|
-
return getRegistry().getNftId(_distribution);
|
208
|
+
return getRegistry().getNftId(address(_distribution));
|
206
209
|
}
|
207
210
|
|
208
211
|
// from product component
|
@@ -218,28 +221,12 @@ contract Product is BaseComponent, IProductComponent {
|
|
218
221
|
}
|
219
222
|
|
220
223
|
function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
|
221
|
-
if (getNftId().eq(zeroNftId())) {
|
222
|
-
return ISetup.ProductSetupInfo(
|
223
|
-
_token,
|
224
|
-
TokenHandler(address(0)),
|
225
|
-
_distributionNftId,
|
226
|
-
_poolNftId,
|
227
|
-
FeeLib.zeroFee(), //_instance.getDistributionFee(_distributionNftId)
|
228
|
-
_initialProductFee,
|
229
|
-
_initialProcessingFee,
|
230
|
-
FeeLib.zeroFee(), //_instance.getPoolFee(_poolNftId)
|
231
|
-
FeeLib.zeroFee(), //_instance.getStakingFee(_poolNftId)
|
232
|
-
FeeLib.zeroFee() //_instance.getPerformanceFee(_poolNftId)
|
233
|
-
);
|
234
|
-
}
|
235
|
-
|
236
224
|
InstanceReader reader = _instance.getInstanceReader();
|
237
225
|
return reader.getProductSetupInfo(getNftId());
|
238
226
|
}
|
239
227
|
|
240
228
|
// from IRegisterable
|
241
229
|
|
242
|
-
// TODO used only once, occupies space
|
243
230
|
function getInitialInfo()
|
244
231
|
public
|
245
232
|
view
|
@@ -251,7 +238,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
251
238
|
IRegistry.ObjectInfo memory productInfo,
|
252
239
|
bytes memory data
|
253
240
|
) = super.getInitialInfo();
|
254
|
-
|
241
|
+
|
255
242
|
// TODO read pool & distribution fees
|
256
243
|
// 1) from pool -> the only option -> pool must be registered first?
|
257
244
|
// 2) from instance -> all fees are set into instance at product registration which is ongoing here
|
@@ -261,35 +248,40 @@ contract Product is BaseComponent, IProductComponent {
|
|
261
248
|
|
262
249
|
// from PoolComponent
|
263
250
|
(
|
264
|
-
|
251
|
+
,
|
265
252
|
bytes memory poolData
|
266
253
|
) = _pool.getInitialInfo();
|
254
|
+
|
255
|
+
(
|
256
|
+
ISetup.PoolSetupInfo memory poolSetupInfo
|
257
|
+
) = abi.decode(poolData, (ISetup.PoolSetupInfo));
|
267
258
|
|
259
|
+
// from DistributionComponent
|
268
260
|
(
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
Fee memory initialPoolFee,
|
273
|
-
Fee memory initialStakingFee,
|
274
|
-
Fee memory initialPerformanceFee
|
275
|
-
) = abi.decode(poolData, (ISetup.PoolSetupInfo, address, IERC20Metadata, Fee, Fee, Fee));
|
261
|
+
,
|
262
|
+
bytes memory distributionData
|
263
|
+
) = _distribution.getInitialInfo();
|
276
264
|
|
277
|
-
|
265
|
+
(
|
266
|
+
ISetup.DistributionSetupInfo memory distributionSetupInfo
|
267
|
+
) = abi.decode(distributionData, (ISetup.DistributionSetupInfo));
|
278
268
|
|
279
269
|
return (
|
280
270
|
productInfo,
|
281
271
|
abi.encode(
|
282
272
|
ISetup.ProductSetupInfo(
|
283
273
|
_token,
|
284
|
-
|
274
|
+
_tokenHandler,
|
285
275
|
_distributionNftId,
|
286
276
|
_poolNftId,
|
287
|
-
|
277
|
+
distributionSetupInfo.distributionFee,
|
288
278
|
_initialProductFee,
|
289
279
|
_initialProcessingFee,
|
290
|
-
|
291
|
-
|
292
|
-
|
280
|
+
poolSetupInfo.poolFee,
|
281
|
+
poolSetupInfo.stakingFee,
|
282
|
+
poolSetupInfo.performanceFee,
|
283
|
+
false,
|
284
|
+
_wallet
|
293
285
|
)
|
294
286
|
)
|
295
287
|
);
|
@@ -24,14 +24,7 @@ abstract contract AccessManagedSimple is Context, IAccessManaged {
|
|
24
24
|
|
25
25
|
bool private _consumingSchedule;
|
26
26
|
|
27
|
-
|
28
|
-
* @dev Initializes the contract connected to an initial authority.
|
29
|
-
*/
|
30
|
-
constructor(address initialAuthority) {
|
31
|
-
initialize(initialAuthority);
|
32
|
-
}
|
33
|
-
|
34
|
-
function initialize(address initialAuthority) public {
|
27
|
+
function initializeAccessManagedSimple(address initialAuthority) internal {
|
35
28
|
require(!_initialized, "AccessManaged: already initialized");
|
36
29
|
_setAuthority(initialAuthority);
|
37
30
|
_initialized = true;
|
@@ -9,20 +9,46 @@ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
|
9
9
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
10
10
|
import {IPoolService} from "./service/IPoolService.sol";
|
11
11
|
import {IProductService} from "./service/IProductService.sol";
|
12
|
+
import {IBundle} from "./module/IBundle.sol";
|
12
13
|
import {ISetup} from "./module/ISetup.sol";
|
13
14
|
import {NftId} from "../types/NftId.sol";
|
15
|
+
import {StateId} from "../types/StateId.sol";
|
16
|
+
import {RiskId} from "../types/RiskId.sol";
|
17
|
+
import {IRisk} from "./module/IRisk.sol";
|
18
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
19
|
+
import {IKeyValueStore} from "./base/IKeyValueStore.sol";
|
14
20
|
|
15
|
-
|
21
|
+
|
22
|
+
interface IInstance is IERC165, IKeyValueStore {
|
16
23
|
|
17
24
|
function getComponentOwnerService() external view returns (IComponentOwnerService);
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
// function getPoolService() external view returns (IPoolService);
|
25
|
+
function getDistributionService() external view returns (IDistributionService);
|
26
|
+
function getProductService() external view returns (IProductService);
|
27
|
+
function getPoolService() external view returns (IPoolService);
|
22
28
|
|
23
|
-
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
|
24
29
|
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
|
25
|
-
function
|
30
|
+
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
|
31
|
+
function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
|
32
|
+
|
33
|
+
function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external;
|
34
|
+
function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external;
|
35
|
+
function updatePoolSetupState(NftId poolNftId, StateId newState) external;
|
36
|
+
|
37
|
+
function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external;
|
38
|
+
function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external;
|
39
|
+
function updateBundleState(NftId bundleNftId, StateId newState) external;
|
40
|
+
|
41
|
+
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
|
42
|
+
function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external;
|
43
|
+
function updateProductSetupState(NftId productNftId, StateId newState) external;
|
44
|
+
|
45
|
+
function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external;
|
46
|
+
function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external;
|
47
|
+
function updateRiskState(RiskId riskId, StateId newState) external;
|
48
|
+
|
49
|
+
function createPolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy) external;
|
50
|
+
function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
|
51
|
+
function updatePolicyState(NftId policyNftId, StateId newState) external;
|
26
52
|
|
27
53
|
function getInstanceReader() external view returns (InstanceReader);
|
28
54
|
}
|
@@ -25,6 +25,9 @@ import {ERC165} from "../shared/ERC165.sol";
|
|
25
25
|
import {Registerable} from "../shared/Registerable.sol";
|
26
26
|
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
27
27
|
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
28
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
29
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
30
|
+
import {IProductService} from "./service/IProductService.sol";
|
28
31
|
import {VersionPart} from "../types/Version.sol";
|
29
32
|
|
30
33
|
contract Instance is
|
@@ -53,7 +56,6 @@ contract Instance is
|
|
53
56
|
InstanceReader internal _instanceReader;
|
54
57
|
|
55
58
|
constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
|
56
|
-
AccessManagedSimple(accessManagerAddress)
|
57
59
|
{
|
58
60
|
initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
|
59
61
|
}
|
@@ -61,6 +63,8 @@ contract Instance is
|
|
61
63
|
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
|
62
64
|
require(!_initialized, "Contract instance has already been initialized");
|
63
65
|
|
66
|
+
initializeAccessManagedSimple(accessManagerAddress);
|
67
|
+
|
64
68
|
_accessManager = AccessManagerSimple(accessManagerAddress);
|
65
69
|
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
66
70
|
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
@@ -218,16 +222,16 @@ contract Instance is
|
|
218
222
|
}
|
219
223
|
|
220
224
|
//--- PoolSetup ------------------------------------------------------//
|
221
|
-
function createPoolSetup(NftId
|
222
|
-
create(_toNftKey32(
|
225
|
+
function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
|
226
|
+
create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
|
223
227
|
}
|
224
228
|
|
225
|
-
function updatePoolSetup(NftId
|
226
|
-
update(_toNftKey32(
|
229
|
+
function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
|
230
|
+
update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
|
227
231
|
}
|
228
232
|
|
229
|
-
function updatePoolSetupState(NftId
|
230
|
-
updateState(_toNftKey32(
|
233
|
+
function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
|
234
|
+
updateState(_toNftKey32(poolNftId, POOL()), newState);
|
231
235
|
}
|
232
236
|
|
233
237
|
//--- DistributorType ---------------------------------------------------//
|
@@ -416,20 +420,17 @@ contract Instance is
|
|
416
420
|
return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
|
417
421
|
}
|
418
422
|
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
// }
|
423
|
+
function getDistributionService() external view returns (IDistributionService) {
|
424
|
+
return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
|
425
|
+
}
|
423
426
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
// }
|
427
|
+
function getProductService() external view returns (IProductService) {
|
428
|
+
return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
|
429
|
+
}
|
428
430
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
// }
|
431
|
+
function getPoolService() external view returns (IPoolService) {
|
432
|
+
return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
|
433
|
+
}
|
433
434
|
|
434
435
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
435
436
|
require(address(_instanceReader) == address(0), "InstanceReader is set");
|
@@ -79,9 +79,9 @@ contract InstanceAccessManager is
|
|
79
79
|
AccessManagerSimple internal _accessManager;
|
80
80
|
|
81
81
|
constructor(address accessManager)
|
82
|
-
AccessManagedSimple(accessManager)
|
83
82
|
{
|
84
83
|
_accessManager = AccessManagerSimple(accessManager);
|
84
|
+
initializeAccessManagedSimple(accessManager);
|
85
85
|
|
86
86
|
_createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
|
87
87
|
_createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
|
@@ -7,14 +7,16 @@ import {DistributorType} from "../types/DistributorType.sol";
|
|
7
7
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
8
8
|
import {Key32} from "../types/Key32.sol";
|
9
9
|
import {NftId} from "../types/NftId.sol";
|
10
|
-
import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY} from "../types/ObjectType.sol";
|
10
|
+
import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY, BUNDLE} from "../types/ObjectType.sol";
|
11
11
|
import {ReferralId, ReferralStatus, ReferralLib, REFERRAL_OK, REFERRAL_ERROR_UNKNOWN, REFERRAL_ERROR_EXPIRED, REFERRAL_ERROR_EXHAUSTED} from "../types/Referral.sol";
|
12
12
|
import {Registerable} from "../shared/Registerable.sol";
|
13
13
|
import {RiskId} from "../types/RiskId.sol";
|
14
14
|
import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
|
15
15
|
import {Version} from "../types/Version.sol";
|
16
|
+
import {StateId} from "../types/StateId.sol";
|
16
17
|
|
17
18
|
import {IRegistry} from "../registry/IRegistry.sol";
|
19
|
+
import {IBundle} from "../instance/module/IBundle.sol";
|
18
20
|
import {IDistribution} from "../instance/module/IDistribution.sol";
|
19
21
|
import {IInstance} from "./IInstance.sol";
|
20
22
|
import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
|
@@ -80,6 +82,14 @@ contract InstanceReader {
|
|
80
82
|
}
|
81
83
|
}
|
82
84
|
|
85
|
+
function getPolicyState(NftId policyNftId)
|
86
|
+
public
|
87
|
+
view
|
88
|
+
returns (StateId state)
|
89
|
+
{
|
90
|
+
return _instance.getState(toPolicyKey(policyNftId));
|
91
|
+
}
|
92
|
+
|
83
93
|
function getRiskInfo(RiskId riskId)
|
84
94
|
public
|
85
95
|
view
|
@@ -114,6 +124,17 @@ contract InstanceReader {
|
|
114
124
|
return abi.decode(data, (ITreasury.TreasuryInfo));
|
115
125
|
}
|
116
126
|
}
|
127
|
+
|
128
|
+
function getBundleInfo(NftId bundleNftId)
|
129
|
+
public
|
130
|
+
view
|
131
|
+
returns (IBundle.BundleInfo memory info)
|
132
|
+
{
|
133
|
+
bytes memory data = _store.getData(toBundleKey(bundleNftId));
|
134
|
+
if (data.length > 0) {
|
135
|
+
return abi.decode(data, (IBundle.BundleInfo));
|
136
|
+
}
|
137
|
+
}
|
117
138
|
|
118
139
|
function getDistributorTypeInfo(DistributorType distributorType)
|
119
140
|
public
|
@@ -259,6 +280,10 @@ contract InstanceReader {
|
|
259
280
|
return distributionNftId.toKey32(DISTRIBUTION());
|
260
281
|
}
|
261
282
|
|
283
|
+
function toBundleKey(NftId poolNftId) public pure returns (Key32) {
|
284
|
+
return poolNftId.toKey32(BUNDLE());
|
285
|
+
}
|
286
|
+
|
262
287
|
function toPoolKey(NftId poolNftId) public pure returns (Key32) {
|
263
288
|
return poolNftId.toKey32(POOL());
|
264
289
|
}
|
@@ -15,7 +15,9 @@ import {Service} from "../../contracts/shared/Service.sol";
|
|
15
15
|
import {IService} from "../shared/IService.sol";
|
16
16
|
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
17
17
|
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
18
|
+
import {RoleId} from "../types/RoleId.sol";
|
18
19
|
import {VersionLib} from "../types/Version.sol";
|
20
|
+
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE} from "../types/RoleId.sol";
|
19
21
|
|
20
22
|
contract InstanceService is Service, IInstanceService {
|
21
23
|
|
@@ -37,13 +39,17 @@ contract InstanceService is Service, IInstanceService {
|
|
37
39
|
InstanceReader clonedInstanceReader
|
38
40
|
)
|
39
41
|
{
|
42
|
+
address instanceOwner = msg.sender;
|
40
43
|
Registry registry = Registry(_registryAddress);
|
41
44
|
NftId registryNftId = registry.getNftId(_registryAddress);
|
42
45
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
43
46
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
44
47
|
|
48
|
+
// initially set the authority of the access managar to this (being the instance service).
|
49
|
+
// This will allow the instance service to bootstrap the authorizations of the instance
|
50
|
+
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
45
51
|
clonedAccessManager = AccessManagerSimple(Clones.clone(_accessManagerMaster));
|
46
|
-
clonedAccessManager.initialize(
|
52
|
+
clonedAccessManager.initialize(address(this));
|
47
53
|
|
48
54
|
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
49
55
|
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
@@ -53,9 +59,58 @@ contract InstanceService is Service, IInstanceService {
|
|
53
59
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
54
60
|
clonedInstanceReader.initialize(_registryAddress, instanceNftId);
|
55
61
|
|
62
|
+
_grantInitialAuthorizations(clonedAccessManager, clonedInstance);
|
63
|
+
|
64
|
+
clonedInstance.setInstanceReader(clonedInstanceReader);
|
65
|
+
|
66
|
+
// to complete setup switch instance ownership to the instance owner
|
67
|
+
// TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
|
68
|
+
clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
|
69
|
+
clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
|
70
|
+
|
56
71
|
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), instanceNftId);
|
57
72
|
}
|
58
73
|
|
74
|
+
function _grantInitialAuthorizations(AccessManagerSimple clonedAccessManager, Instance clonedInstance) internal {
|
75
|
+
address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
76
|
+
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
|
77
|
+
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
|
78
|
+
instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
|
79
|
+
instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
|
80
|
+
clonedAccessManager.setTargetFunctionRole(
|
81
|
+
address(clonedInstance),
|
82
|
+
instanceDistributionServiceSelectors,
|
83
|
+
DISTRIBUTION_SERVICE_ROLE().toInt());
|
84
|
+
|
85
|
+
address poolServiceAddress = _registry.getServiceAddress("PoolService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
86
|
+
clonedAccessManager.grantRole(POOL_SERVICE_ROLE().toInt(), address(poolServiceAddress), 0);
|
87
|
+
bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
|
88
|
+
instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
|
89
|
+
instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
|
90
|
+
instancePoolServiceSelectors[2] = clonedInstance.createBundle.selector;
|
91
|
+
instancePoolServiceSelectors[3] = clonedInstance.updateBundle.selector;
|
92
|
+
clonedAccessManager.setTargetFunctionRole(
|
93
|
+
address(clonedInstance),
|
94
|
+
instancePoolServiceSelectors,
|
95
|
+
POOL_SERVICE_ROLE().toInt());
|
96
|
+
|
97
|
+
address productServiceAddress = _registry.getServiceAddress("ProductService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
98
|
+
clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE().toInt(), address(productServiceAddress), 0);
|
99
|
+
bytes4[] memory instanceProductServiceSelectors = new bytes4[](9);
|
100
|
+
instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
|
101
|
+
instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
|
102
|
+
instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
|
103
|
+
instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
|
104
|
+
instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
|
105
|
+
instanceProductServiceSelectors[5] = clonedInstance.createPolicy.selector;
|
106
|
+
instanceProductServiceSelectors[6] = clonedInstance.updatePolicy.selector;
|
107
|
+
instanceProductServiceSelectors[7] = clonedInstance.updatePolicyState.selector;
|
108
|
+
clonedAccessManager.setTargetFunctionRole(
|
109
|
+
address(clonedInstance),
|
110
|
+
instanceProductServiceSelectors,
|
111
|
+
PRODUCT_SERVICE_ROLE().toInt());
|
112
|
+
}
|
113
|
+
|
59
114
|
function setAccessManagerMaster(address accessManagerMaster) external {
|
60
115
|
require(
|
61
116
|
_accessManagerMaster == address(0),
|
@@ -120,19 +175,24 @@ contract InstanceService is Service, IInstanceService {
|
|
120
175
|
|
121
176
|
address initialOwner = address(0);
|
122
177
|
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
123
|
-
|
124
|
-
//
|
125
|
-
|
126
|
-
NftId registryNftId = registry.getNftId(_registryAddress);
|
127
|
-
|
128
|
-
_initializeService(_registryAddress, initialOwner);
|
178
|
+
// TODO while InstanceService is not deployed in InstanceServiceManager constructor
|
179
|
+
// owner is InstanceServiceManager deployer
|
180
|
+
_initializeService(_registryAddress, owner);
|
129
181
|
|
130
182
|
_registerInterface(type(IService).interfaceId);
|
131
183
|
_registerInterface(type(IInstanceService).interfaceId);
|
132
184
|
}
|
133
185
|
|
134
|
-
function
|
135
|
-
|
186
|
+
function hasRole(address account, RoleId role, NftId instanceNftId) external view returns (bool) {
|
187
|
+
IRegistry.ObjectInfo memory instanceObjectInfo = getRegistry().getObjectInfo(instanceNftId);
|
188
|
+
address instanceAddress = instanceObjectInfo.objectAddress;
|
189
|
+
Instance instance = Instance(instanceAddress);
|
190
|
+
AccessManagerSimple accessManager = AccessManagerSimple(instance.authority());
|
191
|
+
(bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
|
192
|
+
if (executionDelay > 0) {
|
193
|
+
return false;
|
194
|
+
}
|
195
|
+
return isMember;
|
136
196
|
}
|
137
197
|
}
|
138
198
|
|
@@ -31,14 +31,15 @@ contract InstanceServiceManager is ProxyManager {
|
|
31
31
|
Registry registry = Registry(registryAddress);
|
32
32
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
33
33
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
34
|
-
|
35
|
-
registryService.registerService(_instanceService);
|
34
|
+
// TODO this must have a role or own nft to register service
|
35
|
+
//registryService.registerService(_instanceService);
|
36
36
|
// RegistryService registryService = _instanceService.getRegistryService();
|
37
37
|
|
38
|
+
// TODO no nft to link yet
|
38
39
|
// link ownership of instance service manager ot nft owner of instance service
|
39
|
-
_linkToNftOwnable(
|
40
|
-
|
41
|
-
|
40
|
+
//_linkToNftOwnable(
|
41
|
+
// address(registryAddress),
|
42
|
+
// address(_instanceService));
|
42
43
|
|
43
44
|
// implies that after this constructor call only upgrade functionality is available
|
44
45
|
_isDeployed = true;
|