@etherisc/gif-next 0.0.2-7238c82-474 → 0.0.2-72dc555-736

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  2. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.json +10 -62
  4. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  5. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -52
  7. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  10. package/artifacts/contracts/components/Pool.sol/Pool.json +8 -16
  11. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  12. package/artifacts/contracts/components/Product.sol/Product.json +8 -64
  13. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  14. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  33. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
  34. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
  35. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  36. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  37. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +488 -1
  38. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/Instance.sol/Instance.json +120 -84
  41. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  42. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
  43. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  44. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +143 -38
  45. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  46. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +58 -18
  47. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  48. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +43 -27
  49. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +56 -2
  51. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  53. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  55. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  64. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
  65. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +83 -24
  67. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +26 -18
  69. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  74. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +839 -0
  75. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  76. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +448 -0
  77. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  78. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1058 -0
  79. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  80. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +448 -0
  81. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  82. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  83. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +0 -127
  84. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  85. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
  86. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  87. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  88. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -169
  89. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  90. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
  91. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  92. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +25 -37
  93. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  94. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
  95. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  96. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  97. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  98. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  99. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  100. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  101. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  102. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  103. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  104. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  105. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  106. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  107. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  108. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  109. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  110. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  111. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  112. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  113. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  114. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  115. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  116. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  117. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  118. package/artifacts/contracts/test/TestService.sol/TestService.json +9 -9
  119. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  120. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  121. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  122. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  123. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  124. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  125. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  126. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  127. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  128. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  129. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  130. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  131. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  132. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  133. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  134. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  135. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  136. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  137. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  138. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  139. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  140. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  141. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  142. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  143. package/contracts/components/Distribution.sol +8 -15
  144. package/contracts/components/IDistributionComponent.sol +0 -2
  145. package/contracts/components/Pool.sol +4 -20
  146. package/contracts/components/Product.sol +22 -34
  147. package/contracts/instance/IInstance.sol +14 -5
  148. package/contracts/instance/Instance.sol +14 -14
  149. package/contracts/instance/InstanceReader.sol +17 -1
  150. package/contracts/instance/InstanceService.sol +17 -4
  151. package/contracts/instance/InstanceServiceManager.sol +6 -5
  152. package/contracts/instance/base/ComponentServiceBase.sol +85 -2
  153. package/contracts/instance/module/IBundle.sol +1 -0
  154. package/contracts/instance/module/ISetup.sol +1 -0
  155. package/contracts/instance/service/DistributionService.sol +8 -25
  156. package/contracts/instance/service/DistributionServiceManager.sol +6 -5
  157. package/contracts/instance/service/PoolService.sol +194 -0
  158. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  159. package/contracts/instance/service/ProductService.sol +548 -0
  160. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  161. package/contracts/registry/IRegistry.sol +4 -19
  162. package/contracts/registry/IRegistryService.sol +28 -11
  163. package/contracts/registry/Registry.sol +2 -47
  164. package/contracts/registry/RegistryService.sol +30 -71
  165. package/contracts/shared/NftOwnable.sol +2 -4
  166. package/contracts/shared/Service.sol +1 -0
  167. package/contracts/types/RoleId.sol +1 -0
  168. package/package.json +1 -1
@@ -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,7 +33,7 @@ contract Product is BaseComponent, IProductComponent {
32
33
 
33
34
  IProductService internal _productService;
34
35
  Pool internal _pool;
35
- address internal _distribution;
36
+ Distribution internal _distribution;
36
37
  Fee internal _initialProductFee;
37
38
  Fee internal _initialProcessingFee;
38
39
 
@@ -54,12 +55,12 @@ contract Product is BaseComponent, IProductComponent {
54
55
  // TODO: reactivate when services are available again
55
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
 
61
62
  _poolNftId = getRegistry().getNftId(address(_pool));
62
- _distributionNftId = getRegistry().getNftId(_distribution);
63
+ _distributionNftId = getRegistry().getNftId(address(_distribution));
63
64
 
64
65
  _registerInterface(type(IProductComponent).interfaceId);
65
66
  }
@@ -202,7 +203,7 @@ contract Product is BaseComponent, IProductComponent {
202
203
  }
203
204
 
204
205
  function getDistributionNftId() external view override returns (NftId distributionNftId) {
205
- return getRegistry().getNftId(_distribution);
206
+ return getRegistry().getNftId(address(_distribution));
206
207
  }
207
208
 
208
209
  // from product component
@@ -218,28 +219,12 @@ contract Product is BaseComponent, IProductComponent {
218
219
  }
219
220
 
220
221
  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
222
  InstanceReader reader = _instance.getInstanceReader();
237
223
  return reader.getProductSetupInfo(getNftId());
238
224
  }
239
225
 
240
226
  // from IRegisterable
241
227
 
242
- // TODO used only once, occupies space
243
228
  function getInitialInfo()
244
229
  public
245
230
  view
@@ -261,35 +246,38 @@ contract Product is BaseComponent, IProductComponent {
261
246
 
262
247
  // from PoolComponent
263
248
  (
264
- IRegistry.ObjectInfo memory poolInfo,
249
+ ,
265
250
  bytes memory poolData
266
251
  ) = _pool.getInitialInfo();
267
252
 
268
253
  (
269
- /*IPool.PoolInfo memory info*/,
270
- /*address wallet*/,
271
- /*IERC20Metadata token*/,
272
- Fee memory initialPoolFee,
273
- Fee memory initialStakingFee,
274
- Fee memory initialPerformanceFee
275
- ) = abi.decode(poolData, (ISetup.PoolSetupInfo, address, IERC20Metadata, Fee, Fee, Fee));
254
+ ISetup.PoolSetupInfo memory poolSetupInfo
255
+ ) = abi.decode(poolData, (ISetup.PoolSetupInfo));
256
+
257
+ // from DistributionComponent
258
+ (
259
+ ,
260
+ bytes memory distributionData
261
+ ) = _distribution.getInitialInfo();
276
262
 
277
- // TODO from DistributionComponent
263
+ (
264
+ ISetup.DistributionSetupInfo memory distributionSetupInfo
265
+ ) = abi.decode(distributionData, (ISetup.DistributionSetupInfo));
278
266
 
279
267
  return (
280
268
  productInfo,
281
269
  abi.encode(
282
270
  ISetup.ProductSetupInfo(
283
271
  _token,
284
- TokenHandler(address(0)),
272
+ TokenHandler(address(_token)),
285
273
  _distributionNftId,
286
274
  _poolNftId,
287
- FeeLib.zeroFee(), //_instance.getDistributionFee(_distributionNftId)
275
+ distributionSetupInfo.distributionFee,
288
276
  _initialProductFee,
289
277
  _initialProcessingFee,
290
- initialPoolFee,
291
- initialStakingFee,
292
- initialPerformanceFee
278
+ poolSetupInfo.poolFee,
279
+ poolSetupInfo.stakingFee,
280
+ poolSetupInfo.performanceFee
293
281
  )
294
282
  )
295
283
  );
@@ -9,6 +9,7 @@ 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";
14
15
  import {StateId} from "../types/StateId.sol";
@@ -17,16 +18,24 @@ interface IInstance is IERC165 {
17
18
 
18
19
  function getComponentOwnerService() external view returns (IComponentOwnerService);
19
20
  function getDistributionService() external view returns (IDistributionService);
20
- // function getProductService() external view returns (IProductService);
21
- // function getPoolService() external view returns (IPoolService);
22
-
23
- function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
21
+ function getProductService() external view returns (IProductService);
22
+ function getPoolService() external view returns (IPoolService);
24
23
 
25
24
  function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
26
25
  function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
27
26
  function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
28
27
 
29
- function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external;
28
+ function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external;
29
+ function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external;
30
+ function updatePoolSetupState(NftId poolNftId, StateId newState) external;
31
+
32
+ function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external;
33
+ function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external;
34
+ function updateBundleState(NftId bundleNftId, StateId newState) external;
35
+
36
+ function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
37
+ function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external;
38
+ function updateProductSetupState(NftId productNftId, StateId newState) external;
30
39
 
31
40
  function getInstanceReader() external view returns (InstanceReader);
32
41
  }
@@ -26,6 +26,8 @@ import {Registerable} from "../shared/Registerable.sol";
26
26
  import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
27
27
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
28
28
  import {IDistributionService} from "./service/IDistributionService.sol";
29
+ import {IPoolService} from "./service/IPoolService.sol";
30
+ import {IProductService} from "./service/IProductService.sol";
29
31
  import {VersionPart} from "../types/Version.sol";
30
32
 
31
33
  contract Instance is
@@ -220,16 +222,16 @@ contract Instance is
220
222
  }
221
223
 
222
224
  //--- PoolSetup ------------------------------------------------------//
223
- function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
224
- create(_toNftKey32(distributionNftId, POOL()), abi.encode(setup));
225
+ function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
226
+ create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
225
227
  }
226
228
 
227
- function updatePoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
228
- update(_toNftKey32(distributionNftId, POOL()), abi.encode(setup), newState);
229
+ function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
230
+ update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
229
231
  }
230
232
 
231
- function updatePoolSetupState(NftId distributionNftId, StateId newState) external restricted() {
232
- updateState(_toNftKey32(distributionNftId, POOL()), newState);
233
+ function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
234
+ updateState(_toNftKey32(poolNftId, POOL()), newState);
233
235
  }
234
236
 
235
237
  //--- DistributorType ---------------------------------------------------//
@@ -422,15 +424,13 @@ contract Instance is
422
424
  return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
423
425
  }
424
426
 
425
- // TODO reactivate when services are available
426
- // function getProductService() external view returns (IProductService) {
427
- // return ProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
428
- // }
427
+ function getProductService() external view returns (IProductService) {
428
+ return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
429
+ }
429
430
 
430
- // TODO reactivate when services are available
431
- // function getPoolService() external view returns (IPoolService) {
432
- // return PoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
433
- // }
431
+ function getPoolService() external view returns (IPoolService) {
432
+ return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
433
+ }
434
434
 
435
435
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
436
436
  require(address(_instanceReader) == address(0), "InstanceReader is set");
@@ -7,7 +7,7 @@ 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";
@@ -15,6 +15,7 @@ import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
15
15
  import {Version} from "../types/Version.sol";
16
16
 
17
17
  import {IRegistry} from "../registry/IRegistry.sol";
18
+ import {IBundle} from "../instance/module/IBundle.sol";
18
19
  import {IDistribution} from "../instance/module/IDistribution.sol";
19
20
  import {IInstance} from "./IInstance.sol";
20
21
  import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
@@ -114,6 +115,17 @@ contract InstanceReader {
114
115
  return abi.decode(data, (ITreasury.TreasuryInfo));
115
116
  }
116
117
  }
118
+
119
+ function getBundleInfo(NftId bundleNftId)
120
+ public
121
+ view
122
+ returns (IBundle.BundleInfo memory info)
123
+ {
124
+ bytes memory data = _store.getData(toBundleKey(bundleNftId));
125
+ if (data.length > 0) {
126
+ return abi.decode(data, (IBundle.BundleInfo));
127
+ }
128
+ }
117
129
 
118
130
  function getDistributorTypeInfo(DistributorType distributorType)
119
131
  public
@@ -259,6 +271,10 @@ contract InstanceReader {
259
271
  return distributionNftId.toKey32(DISTRIBUTION());
260
272
  }
261
273
 
274
+ function toBundleKey(NftId poolNftId) public pure returns (Key32) {
275
+ return poolNftId.toKey32(BUNDLE());
276
+ }
277
+
262
278
  function toPoolKey(NftId poolNftId) public pure returns (Key32) {
263
279
  return poolNftId.toKey32(POOL());
264
280
  }
@@ -17,7 +17,7 @@ import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
17
17
  import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
18
18
  import {RoleId} from "../types/RoleId.sol";
19
19
  import {VersionLib} from "../types/Version.sol";
20
- import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE} from "../types/RoleId.sol";
20
+ import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE} from "../types/RoleId.sol";
21
21
 
22
22
  contract InstanceService is Service, IInstanceService {
23
23
 
@@ -73,7 +73,6 @@ contract InstanceService is Service, IInstanceService {
73
73
 
74
74
  function _grantInitialAuthorizations(AccessManagerSimple clonedAccessManager, Instance clonedInstance) internal {
75
75
  address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
76
-
77
76
  clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
78
77
  bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
79
78
  instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
@@ -82,6 +81,19 @@ contract InstanceService is Service, IInstanceService {
82
81
  address(clonedInstance),
83
82
  instanceDistributionServiceSelectors,
84
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
+
85
97
  }
86
98
 
87
99
  function setAccessManagerMaster(address accessManagerMaster) external {
@@ -148,8 +160,9 @@ contract InstanceService is Service, IInstanceService {
148
160
 
149
161
  address initialOwner = address(0);
150
162
  (_registryAddress, initialOwner) = abi.decode(data, (address, address));
151
-
152
- _initializeService(_registryAddress, initialOwner);
163
+ // TODO while InstanceService is not deployed in InstanceServiceManager constructor
164
+ // owner is InstanceServiceManager deployer
165
+ _initializeService(_registryAddress, owner);
153
166
 
154
167
  _registerInterface(type(IService).interfaceId);
155
168
  _registerInterface(type(IInstanceService).interfaceId);
@@ -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
- address(registryAddress),
41
- address(_instanceService));
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;
@@ -4,15 +4,98 @@ pragma solidity ^0.8.19;
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
5
  import {IRegistryService} from "../../registry/IRegistryService.sol";
6
6
  import {IInstance} from "../../instance/IInstance.sol";
7
- import {ObjectType, INSTANCE, PRODUCT, POOL} from "../../types/ObjectType.sol";
7
+ import {ObjectType, INSTANCE, PRODUCT, POOL, DISTRIBUTION, ORACLE} from "../../types/ObjectType.sol";
8
8
  import {NftId, NftIdLib} from "../../types/NftId.sol";
9
+ import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../types/RoleId.sol";
9
10
 
11
+ import {BaseComponent} from "../../components/BaseComponent.sol";
12
+ import {INftOwnable} from "../../shared/INftOwnable.sol";
10
13
  import {Service} from "../../shared/Service.sol";
14
+ import {InstanceService} from "../InstanceService.sol";
11
15
  import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
12
16
 
13
17
  abstract contract ComponentServiceBase is Service {
14
18
 
15
- error CallerIsNotComponentOwner();
19
+ error ExpectedRoleMissing(RoleId expected, address caller);
20
+ error ComponentTypeInvalid(ObjectType componentType);
21
+
22
+ mapping (ObjectType => RoleId) internal _objectTypeToExpectedRole;
23
+
24
+ /// @dev modifier to check if caller has a role on the instance the component is registered in
25
+ modifier onlyComponentOwnerRole(address componentAddress) {
26
+ BaseComponent component = BaseComponent(componentAddress);
27
+ ObjectType objectType = _getObjectType(component);
28
+ RoleId expectedRole = _objectTypeToExpectedRole[objectType];
29
+
30
+ address componentOwner = msg.sender;
31
+ INftOwnable nftOwnable = INftOwnable(address(component.getInstance()));
32
+ if(! getInstanceService().hasRole(componentOwner, expectedRole, nftOwnable.getNftId())) {
33
+ revert ExpectedRoleMissing(expectedRole, componentOwner);
34
+ }
35
+ _;
36
+ }
37
+
38
+ function _initializeService(
39
+ address registry,
40
+ address initialOwner
41
+ )
42
+ internal
43
+ override
44
+ {
45
+ super._initializeService(registry, initialOwner);
46
+ _objectTypeToExpectedRole[PRODUCT()] = PRODUCT_OWNER_ROLE();
47
+ _objectTypeToExpectedRole[POOL()] = POOL_OWNER_ROLE();
48
+ _objectTypeToExpectedRole[DISTRIBUTION()] = DISTRIBUTION_OWNER_ROLE();
49
+ _objectTypeToExpectedRole[ORACLE()] = ORACLE_OWNER_ROLE();
50
+ }
51
+
52
+ function getInstanceService() public view returns (InstanceService) {
53
+ return InstanceService(getRegistry().getServiceAddress("InstanceService", getMajorVersion()));
54
+ }
55
+
56
+ function register(address componentAddress)
57
+ external
58
+ onlyComponentOwnerRole(componentAddress)
59
+ returns (NftId componentNftId)
60
+ {
61
+ address componentOwner = msg.sender;
62
+ BaseComponent component = BaseComponent(componentAddress);
63
+ ObjectType objectType = _getObjectType(component);
64
+ IRegistryService registryService = getRegistryService();
65
+
66
+ IRegistry.ObjectInfo memory objInfo;
67
+ bytes memory initialObjData;
68
+
69
+ if (objectType == DISTRIBUTION()) {
70
+ (objInfo, initialObjData) = registryService.registerDistribution(component, componentOwner);
71
+ } else if (objectType == PRODUCT()) {
72
+ (objInfo, initialObjData) = registryService.registerProduct(component, componentOwner);
73
+ } else if (objectType == POOL()) {
74
+ (objInfo, initialObjData) = registryService.registerPool(component, componentOwner);
75
+ // TODO: implement this for oracle - currently missing in registry
76
+ // } else if (objectType == ORACLE()) {
77
+ // (objInfo, initialObjData) = registryService.registerOracle(component, componentOwner);
78
+ } else {
79
+ revert ComponentTypeInvalid(objectType);
80
+ }
81
+
82
+ componentNftId = objInfo.nftId;
83
+ IInstance instance = _getInstance(objInfo);
84
+ _finalizeComponentRegistration(componentNftId, initialObjData, instance);
85
+ }
86
+
87
+ function _finalizeComponentRegistration(NftId componentNftId, bytes memory initialObjData, IInstance instance) internal virtual;
88
+
89
+ function _getObjectType(BaseComponent component) internal view returns (ObjectType) {
90
+ (IRegistry.ObjectInfo memory compInitialInfo, ) = component.getInitialInfo();
91
+ return compInitialInfo.objectType;
92
+ }
93
+
94
+ function _getInstance(IRegistry.ObjectInfo memory compObjInfo) internal view returns (IInstance) {
95
+ IRegistry registry = getRegistry();
96
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(compObjInfo.parentNftId);
97
+ return IInstance(instanceInfo.objectAddress);
98
+ }
16
99
 
17
100
  function _getAndVerifyComponentInfoAndInstance(
18
101
  ObjectType objectType
@@ -13,6 +13,7 @@ interface IBundle {
13
13
  uint256 capitalAmount; // net investment capital + net premiums - payouts
14
14
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
15
15
  uint256 balanceAmount; // total amount of funds: capitalAmount + fees (balance >= captial)
16
+ uint256 lifetime;
16
17
  Timestamp expiredAt; // no new policies
17
18
  Timestamp closedAt; // no open policies, locked amount = 0
18
19
  }
@@ -5,6 +5,7 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
5
5
 
6
6
  import {Fee} from "../../types/Fee.sol";
7
7
  import {NftId} from "../../types/NftId.sol";
8
+ import {LibNftIdSet} from "../../types/NftIdSet.sol";
8
9
  import {UFixed} from "../../types/UFixed.sol";
9
10
  import {TokenHandler} from "../../shared/TokenHandler.sol";
10
11
 
@@ -38,7 +38,6 @@ contract DistributionService is
38
38
  string public constant NAME = "DistributionService";
39
39
 
40
40
  address internal _registryAddress;
41
- InstanceService internal _instanceService;
42
41
 
43
42
  function _initialize(
44
43
  address owner,
@@ -50,11 +49,9 @@ contract DistributionService is
50
49
  {
51
50
  address initialOwner = address(0);
52
51
  (_registryAddress, initialOwner) = abi.decode(data, (address, address));
53
-
54
- IRegistry registry = IRegistry(_registryAddress);
55
- _instanceService = InstanceService(registry.getServiceAddress("InstanceService", getMajorVersion()));
56
-
57
- _initializeService(_registryAddress, initialOwner);
52
+ // TODO while DistributionService is not deployed in DistributionServiceManager constructor
53
+ // owner is DistributionServiceManager deployer
54
+ _initializeService(_registryAddress, owner);
58
55
 
59
56
  _registerInterface(type(IService).interfaceId);
60
57
  _registerInterface(type(IDistributionService).interfaceId);
@@ -65,26 +62,12 @@ contract DistributionService is
65
62
  return NAME;
66
63
  }
67
64
 
68
- function register(address distributionComponentAddress)
69
- external
70
- returns (NftId distributionNftId)
71
- {
72
- address componentOwner = msg.sender;
73
- Distribution distribution = Distribution(distributionComponentAddress);
74
- IInstance instance = distribution.getInstance();
75
- INftOwnable nftOwnable = INftOwnable(address(instance));
76
-
77
- require(_instanceService.hasRole(componentOwner, DISTRIBUTION_OWNER_ROLE(), nftOwnable.getNftId()), "ERROR:POL-002:NOT_DISTRIBUTION_OWNER");
78
-
79
- IRegistryService registryService = getRegistryService();
80
- (IRegistry.ObjectInfo memory distributionObjInfo, ) = registryService.registerDistribution(
81
- distribution,
82
- componentOwner
65
+ function _finalizeComponentRegistration(NftId componentNftId, bytes memory initialObjData, IInstance instance) internal override {
66
+ ISetup.DistributionSetupInfo memory initialSetup = abi.decode(
67
+ initialObjData,
68
+ (ISetup.DistributionSetupInfo)
83
69
  );
84
- distributionNftId = distributionObjInfo.nftId;
85
-
86
- ISetup.DistributionSetupInfo memory initialSetup = distribution.getInitialSetupInfo();
87
- instance.createDistributionSetup(distributionNftId, initialSetup);
70
+ instance.createDistributionSetup(componentNftId, initialSetup);
88
71
  }
89
72
 
90
73
  function setFees(
@@ -29,13 +29,14 @@ contract DistributionServiceManager is ProxyManager {
29
29
  Registry registry = Registry(registryAddress);
30
30
  address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
31
31
  RegistryService registryService = RegistryService(registryServiceAddress);
32
+ // TODO this must have a role or own nft to register service
33
+ //registryService.registerService(_distributionService);
32
34
 
33
- registryService.registerService(_distributionService);
34
-
35
+ // TODO no nft to link yet
35
36
  // link ownership of instance service manager ot nft owner of instance service
36
- _linkToNftOwnable(
37
- address(registryAddress),
38
- address(_distributionService));
37
+ //_linkToNftOwnable(
38
+ // address(registryAddress),
39
+ // address(_distributionService));
39
40
 
40
41
  // implies that after this constructor call only upgrade functionality is available
41
42
  _isDeployed = true;