@etherisc/gif-next 0.0.2-edf4742-498 → 0.0.2-ee7cb16-393

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 (200) hide show
  1. package/README.md +63 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +126 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +136 -10
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +88 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +28 -2
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +168 -11
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +144 -64
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  37. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  40. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  41. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
  42. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  44. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +963 -18
  45. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  46. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  47. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  48. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +6 -1
  49. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  50. package/artifacts/contracts/instance/Instance.sol/Instance.json +143 -139
  51. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  52. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +55 -32
  53. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  54. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  55. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  56. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +74 -40
  57. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  58. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +145 -64
  59. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  60. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +52 -32
  61. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  62. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  63. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
  78. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +2 -2
  80. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +17 -21
  82. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +167 -0
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
  88. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +238 -28
  90. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +33 -21
  92. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  93. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
  94. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  95. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -0
  96. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  97. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  98. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  99. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
  101. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  102. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  103. package/artifacts/contracts/registry/Registry.sol/Registry.json +45 -18
  104. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  105. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
  106. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  107. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +29 -25
  108. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  109. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
  110. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  111. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  112. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  113. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  114. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  115. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  116. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  117. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  118. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  119. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  120. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  122. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  124. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  125. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  126. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  127. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  128. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  129. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  130. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  131. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  132. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  133. package/artifacts/contracts/test/TestService.sol/TestService.json +9 -9
  134. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  135. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  137. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  138. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  139. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  140. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  141. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  142. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  143. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  144. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  145. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  146. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  147. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  148. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  153. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  159. package/contracts/components/BaseComponent.sol +49 -8
  160. package/contracts/components/Distribution.sol +6 -3
  161. package/contracts/components/IBaseComponent.sol +6 -0
  162. package/contracts/components/IPoolComponent.sol +5 -1
  163. package/contracts/components/Pool.sol +33 -9
  164. package/contracts/components/Product.sol +33 -41
  165. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  166. package/contracts/instance/BundleManager.sol +129 -0
  167. package/contracts/instance/Cloneable.sol +46 -0
  168. package/contracts/instance/IInstance.sol +21 -4
  169. package/contracts/instance/IInstanceBase.sol +26 -0
  170. package/contracts/instance/IInstanceService.sol +5 -3
  171. package/contracts/instance/Instance.sol +30 -18
  172. package/contracts/instance/InstanceAccessManager.sol +6 -6
  173. package/contracts/instance/InstanceBase.sol +41 -0
  174. package/contracts/instance/InstanceReader.sol +9 -0
  175. package/contracts/instance/InstanceService.sol +95 -32
  176. package/contracts/instance/InstanceServiceManager.sol +6 -5
  177. package/contracts/instance/ObjectManager.sol +101 -0
  178. package/contracts/instance/base/ComponentServiceBase.sol +12 -2
  179. package/contracts/instance/module/ISetup.sol +3 -1
  180. package/contracts/instance/service/DistributionService.sol +3 -2
  181. package/contracts/instance/service/DistributionServiceManager.sol +6 -5
  182. package/contracts/instance/service/IPoolService.sol +16 -2
  183. package/contracts/instance/service/IProductService.sol +6 -3
  184. package/contracts/instance/service/PoolService.sol +111 -17
  185. package/contracts/instance/service/PoolServiceManager.sol +6 -5
  186. package/contracts/instance/service/ProductService.sol +570 -0
  187. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  188. package/contracts/registry/IRegistry.sol +2 -0
  189. package/contracts/registry/IRegistryService.sol +28 -11
  190. package/contracts/registry/Registry.sol +4 -0
  191. package/contracts/registry/RegistryService.sol +30 -71
  192. package/contracts/shared/NftOwnable.sol +2 -4
  193. package/contracts/types/NftIdSet.sol +26 -24
  194. package/contracts/types/RoleId.sol +1 -0
  195. package/package.json +1 -1
  196. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  197. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  198. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  199. package/contracts/instance/AccessManagedSimple.sol +0 -115
  200. package/contracts/instance/AccessManagerSimple.sol +0 -692
@@ -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 _isVerifying;
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
 
@@ -58,7 +60,7 @@ contract Pool is BaseComponent, IPoolComponent {
58
60
  // TODO refactor into tokenNftId
59
61
  address token,
60
62
  bool isInterceptor,
61
- bool verifying,
63
+ bool isConfirmingApplication,
62
64
  UFixed collateralizationLevel,
63
65
  Fee memory poolFee,
64
66
  Fee memory stakingFee,
@@ -67,16 +69,17 @@ contract Pool is BaseComponent, IPoolComponent {
67
69
  )
68
70
  BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
69
71
  {
70
- _isVerifying = verifying;
72
+ _isConfirmingApplication = isConfirmingApplication;
71
73
  // TODO add validation
72
74
  _collateralizationLevel = collateralizationLevel;
73
75
  _initialPoolFee = poolFee;
74
76
  _initialStakingFee = stakingFee;
75
77
  _initialPerformanceFee = performanceFee;
76
78
 
79
+ _tokenHandler = new TokenHandler(token);
80
+
77
81
  _poolService = _instance.getPoolService();
78
- // TODO: reactivate when services are available again
79
- // _productService = _instance.getProductService();
82
+ _productService = _instance.getProductService();
80
83
 
81
84
  _registerInterface(type(IPoolComponent).interfaceId);
82
85
  }
@@ -137,8 +140,8 @@ contract Pool is BaseComponent, IPoolComponent {
137
140
  }
138
141
 
139
142
 
140
- function isVerifying() external view override returns (bool verifying) {
141
- return _isVerifying;
143
+ function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
144
+ return _isConfirmingApplication;
142
145
  }
143
146
 
144
147
  function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
@@ -168,6 +171,26 @@ contract Pool is BaseComponent, IPoolComponent {
168
171
  _poolService.setBundleFee(bundleNftId, fee);
169
172
  }
170
173
 
174
+ function lockBundle(
175
+ NftId bundleNftId
176
+ )
177
+ external
178
+ override
179
+ // TODO add onlyBundleOwner
180
+ {
181
+ _poolService.lockBundle(bundleNftId);
182
+ }
183
+
184
+ function unlockBundle(
185
+ NftId bundleNftId
186
+ )
187
+ external
188
+ override
189
+ // TODO add onlyBundleOwner
190
+ {
191
+ _poolService.unlockBundle(bundleNftId);
192
+ }
193
+
171
194
  function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
172
195
  InstanceReader reader = _instance.getInstanceReader();
173
196
  return reader.getPoolSetupInfo(getNftId());
@@ -192,12 +215,13 @@ contract Pool is BaseComponent, IPoolComponent {
192
215
  abi.encode(
193
216
  ISetup.PoolSetupInfo(
194
217
  _productNftId,
195
- TokenHandler(address(_token)),
218
+ _tokenHandler,
196
219
  _collateralizationLevel,
197
220
  _initialPoolFee,
198
221
  _initialStakingFee,
199
222
  _initialPerformanceFee,
200
- _isVerifying,
223
+ false,
224
+ _isConfirmingApplication,
201
225
  _wallet
202
226
  )
203
227
  )
@@ -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
- address internal _distribution;
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;
@@ -51,15 +53,16 @@ contract Product is BaseComponent, IProductComponent {
51
53
  address initialOwner
52
54
  ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
53
55
  // TODO add validation
54
- // TODO: reactivate when services are available again
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 _setRiskInfo(
124
+ function _updateRisk(
122
125
  RiskId id,
123
- IRisk.RiskInfo memory info
126
+ bytes memory data
124
127
  ) internal {
125
- _productService.setRiskInfo(
128
+ _productService.updateRisk(
126
129
  id,
127
- info
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
- IRegistry.ObjectInfo memory poolInfo,
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
- /*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));
261
+ ,
262
+ bytes memory distributionData
263
+ ) = _distribution.getInitialInfo();
276
264
 
277
- // TODO from DistributionComponent
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
- TokenHandler(address(0)),
274
+ _tokenHandler,
285
275
  _distributionNftId,
286
276
  _poolNftId,
287
- FeeLib.zeroFee(), //_instance.getDistributionFee(_distributionNftId)
277
+ distributionSetupInfo.distributionFee,
288
278
  _initialProductFee,
289
279
  _initialProcessingFee,
290
- initialPoolFee,
291
- initialStakingFee,
292
- initialPerformanceFee
280
+ poolSetupInfo.poolFee,
281
+ poolSetupInfo.stakingFee,
282
+ poolSetupInfo.performanceFee,
283
+ false,
284
+ _wallet
293
285
  )
294
286
  )
295
287
  );
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
5
+
6
+
7
+ contract AccessManagerUpgradeableInitializeable is AccessManagerUpgradeable {
8
+
9
+ bool private _initialized;
10
+
11
+ function __AccessManagerUpgradeableInitializeable_init(address initialAdmin) public {
12
+ require(!_initialized, "AccessManager: already initialized");
13
+
14
+ if (initialAdmin == address(0)) {
15
+ revert AccessManagerInvalidInitialAdmin(address(0));
16
+ }
17
+
18
+ // admin is active immediately and without any execution delay.
19
+ _grantRole(ADMIN_ROLE, initialAdmin, 0, 0);
20
+ _initialized = true;
21
+ }
22
+
23
+ }
@@ -0,0 +1,129 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IInstance} from "./IInstance.sol";
5
+ import {INSTANCE} from "../types/ObjectType.sol";
6
+ import {InstanceReader} from "./InstanceReader.sol";
7
+ import {IPolicy} from "../instance/module/IPolicy.sol";
8
+ import {IRegistry} from "../registry/IRegistry.sol";
9
+ import {LibNftIdSet} from "../types/NftIdSet.sol";
10
+ import {NftId} from "../types/NftId.sol";
11
+ import {TimestampLib} from "../types/Timestamp.sol";
12
+
13
+ import {ObjectManager} from "./ObjectManager.sol";
14
+
15
+ contract BundleManager is
16
+ ObjectManager
17
+ {
18
+
19
+ event LogBundleManagerPolicyLinked(NftId bundleNftId, NftId policyNftId);
20
+ event LogBundleManagerPolicyUnlinked(NftId bundleNftId, NftId policyNftId);
21
+
22
+ event LogBundleManagerBundleAdded(NftId poolNftId, NftId bundleNftId);
23
+ event LogBundleManagerBundleUnlocked(NftId poolNftId, NftId bundleNftId);
24
+ event LogBundleManagerBundleLocked(NftId poolNftId, NftId bundleNftId);
25
+
26
+ error ErrorBundleManagerErrorPolicyAlreadyActivated(NftId policyNftId);
27
+ error ErrorBundleManagerErrorBundleLocked(NftId bundleNftId, NftId policyNftId);
28
+ error ErrorBundleManagerPolicyWithOpenClaims(NftId policyNftId, uint256 openClaimsCount);
29
+ error ErrorBundleManagerPolicyNotCloseable(NftId policyNftId);
30
+ error ErrorBundleManagerBundleUnknown(NftId bundleNftId);
31
+ error ErrorBundleManagerBundleNotRegistered(NftId bundleNftId);
32
+
33
+ mapping(NftId bundleNftId => LibNftIdSet.Set policies) internal _activePolicies;
34
+
35
+ constructor() ObjectManager() {
36
+ }
37
+
38
+
39
+ /// @dev links a policy with its bundle
40
+ // to link a policy it MUST NOT yet have been activated
41
+ // the bundle MUST be unlocked (active) for linking (underwriting) and registered with this instance
42
+ function linkPolicy(NftId policyNftId) external restricted() {
43
+ NftId bundleNftId = _instanceReader.getPolicyInfo(policyNftId).bundleNftId;
44
+ // decision will likely depend on the decision what to check here and what in the service
45
+ NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
46
+
47
+ // ensure bundle is unlocked (in active set) and registered with this instance
48
+ if (!_isActive(poolNftId, bundleNftId)) {
49
+ revert ErrorBundleManagerErrorBundleLocked(bundleNftId, policyNftId);
50
+ }
51
+
52
+ LibNftIdSet.add(_activePolicies[bundleNftId], policyNftId);
53
+ emit LogBundleManagerPolicyLinked(bundleNftId, policyNftId);
54
+ }
55
+
56
+
57
+ /// @dev unlinks a policy from its bundle
58
+ // to unlink a policy it must closable, ie. meet one of the following criterias
59
+ // - the policy MUST be past its expiry period and it MUST NOT have any open claims
60
+ // - the policy's payoutAmount MUST be equal to its sumInsuredAmount and MUST NOT have any open claims
61
+ function unlinkPolicy(NftId policyNftId) external restricted() {
62
+ IPolicy.PolicyInfo memory policyInfo = _instanceReader.getPolicyInfo(policyNftId);
63
+
64
+ NftId bundleNftId = policyInfo.bundleNftId;
65
+ // decision will likely depend on the decision what to check here and what in the service
66
+ NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
67
+
68
+ // ensure bundle is registered with this instance
69
+ if (!_contains(poolNftId, bundleNftId)) {
70
+ revert ErrorBundleManagerBundleUnknown(bundleNftId);
71
+ }
72
+
73
+ LibNftIdSet.remove(_activePolicies[bundleNftId], policyNftId);
74
+ emit LogBundleManagerPolicyUnlinked(policyInfo.bundleNftId, policyNftId);
75
+ }
76
+
77
+
78
+ /// @dev add a new bundle to a riskpool registerd with this instance
79
+ // the corresponding pool is fetched via instance reader
80
+ function add(NftId bundleNftId) external restricted() {
81
+ NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
82
+
83
+ // ensure pool is registered with instance
84
+ if(poolNftId.eqz()) {
85
+ revert ErrorBundleManagerBundleNotRegistered(bundleNftId);
86
+ }
87
+
88
+ _add(poolNftId, bundleNftId);
89
+ emit LogBundleManagerBundleAdded(poolNftId, bundleNftId);
90
+ }
91
+
92
+ /// @dev unlocked (active) bundles are available to underwrite new policies
93
+ function unlock(NftId bundleNftId) external restricted() {
94
+ NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
95
+ _activate(poolNftId, bundleNftId);
96
+ emit LogBundleManagerBundleUnlocked(poolNftId, bundleNftId);
97
+ }
98
+
99
+ /// @dev locked (deactivated) bundles may not underwrite any new policies
100
+ function lock(NftId bundleNftId) external restricted() {
101
+ NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
102
+ _deactivate(poolNftId, bundleNftId);
103
+ emit LogBundleManagerBundleLocked(poolNftId, bundleNftId);
104
+ }
105
+
106
+ function bundles(NftId poolNftId) external view returns(uint256) {
107
+ return _objects(poolNftId);
108
+ }
109
+
110
+ function getBundleNftId(NftId poolNftId, uint256 idx) external view returns(NftId bundleNftId) {
111
+ return _getObject(poolNftId, idx);
112
+ }
113
+
114
+ function activeBundles(NftId poolNftId) external view returns(uint256) {
115
+ return _activeObjs(poolNftId);
116
+ }
117
+
118
+ function getActiveBundleNftId(NftId poolNftId, uint256 idx) external view returns(NftId bundleNftId) {
119
+ return _getActiveObject(poolNftId, idx);
120
+ }
121
+
122
+ function activePolicies(NftId bundleNftId) external view returns(uint256) {
123
+ return LibNftIdSet.size(_activePolicies[bundleNftId]);
124
+ }
125
+
126
+ function getActivePolicy(NftId bundleNftId, uint256 idx) external view returns(NftId policyNftId) {
127
+ return LibNftIdSet.getElementAt(_activePolicies[bundleNftId], idx);
128
+ }
129
+ }
@@ -0,0 +1,46 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
+
7
+ import {IRegistry} from "../registry/IRegistry.sol";
8
+
9
+ abstract contract Cloneable is
10
+ AccessManagedUpgradeable
11
+ {
12
+ event CloneableInitialized(address authority, address registry);
13
+
14
+ error CloneableRegistryInvalid(address registry);
15
+
16
+ IRegistry internal _registry;
17
+
18
+ constructor() {
19
+ _registry = IRegistry(address(0));
20
+ }
21
+
22
+ /// @dev call to initialize MUST be made in the same transaction as cloning of the contract
23
+ function initialize(
24
+ address authority,
25
+ address registry
26
+ )
27
+ public
28
+ initializer
29
+ {
30
+ // check/handle access managed
31
+ __AccessManaged_init(authority);
32
+
33
+ // check/handle registry
34
+ if (registry.code.length == 0) {
35
+ revert CloneableRegistryInvalid(registry);
36
+ }
37
+
38
+ _registry = IRegistry(registry);
39
+
40
+ emit CloneableInitialized(authority, registry);
41
+ }
42
+
43
+ function getRegistry() external view returns (IRegistry) {
44
+ return _registry;
45
+ }
46
+ }
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
 
6
+ import {BundleManager} from "./BundleManager.sol";
6
7
  import {InstanceReader} from "./InstanceReader.sol";
7
8
 
8
9
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
@@ -13,16 +14,19 @@ import {IBundle} from "./module/IBundle.sol";
13
14
  import {ISetup} from "./module/ISetup.sol";
14
15
  import {NftId} from "../types/NftId.sol";
15
16
  import {StateId} from "../types/StateId.sol";
17
+ import {RiskId} from "../types/RiskId.sol";
18
+ import {IRisk} from "./module/IRisk.sol";
19
+ import {IPolicy} from "./module/IPolicy.sol";
20
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
16
21
 
17
- interface IInstance is IERC165 {
22
+
23
+ interface IInstance is IERC165, IKeyValueStore {
18
24
 
19
25
  function getComponentOwnerService() external view returns (IComponentOwnerService);
20
26
  function getDistributionService() external view returns (IDistributionService);
21
- // function getProductService() external view returns (IProductService);
27
+ function getProductService() external view returns (IProductService);
22
28
  function getPoolService() external view returns (IPoolService);
23
29
 
24
- function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
25
-
26
30
  function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
27
31
  function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
28
32
  function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
@@ -35,5 +39,18 @@ interface IInstance is IERC165 {
35
39
  function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external;
36
40
  function updateBundleState(NftId bundleNftId, StateId newState) external;
37
41
 
42
+ function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
43
+ function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external;
44
+ function updateProductSetupState(NftId productNftId, StateId newState) external;
45
+
46
+ function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external;
47
+ function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external;
48
+ function updateRiskState(RiskId riskId, StateId newState) external;
49
+
50
+ function createPolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy) external;
51
+ function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
52
+ function updatePolicyState(NftId policyNftId, StateId newState) external;
53
+
38
54
  function getInstanceReader() external view returns (InstanceReader);
55
+ function getBundleManager() external view returns (BundleManager);
39
56
  }
@@ -0,0 +1,26 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
+
6
+ import {BundleManager} from "./BundleManager.sol";
7
+ import {InstanceReader} from "./InstanceReader.sol";
8
+
9
+ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
10
+ import {IDistributionService} from "./service/IDistributionService.sol";
11
+ import {IPoolService} from "./service/IPoolService.sol";
12
+ import {IProductService} from "./service/IProductService.sol";
13
+ import {IBundle} from "./module/IBundle.sol";
14
+ import {ISetup} from "./module/ISetup.sol";
15
+ import {NftId} from "../types/NftId.sol";
16
+ import {StateId} from "../types/StateId.sol";
17
+ import {RiskId} from "../types/RiskId.sol";
18
+ import {IRisk} from "./module/IRisk.sol";
19
+ import {IPolicy} from "./module/IPolicy.sol";
20
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
21
+
22
+
23
+ interface IInstanceBase is IERC165, IKeyValueStore {
24
+
25
+
26
+ }
@@ -10,9 +10,10 @@ import {IRegistry} from "../registry/IRegistry.sol";
10
10
  import {IRegisterable} from "../shared/IRegisterable.sol";
11
11
  import {IBaseComponent} from "../components/IBaseComponent.sol";
12
12
 
13
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
13
+ import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
14
14
  import {Instance} from "./Instance.sol";
15
15
  import {InstanceReader} from "./InstanceReader.sol";
16
+ import {BundleManager} from "./BundleManager.sol";
16
17
 
17
18
  interface IInstanceService is IService {
18
19
 
@@ -21,10 +22,11 @@ interface IInstanceService is IService {
21
22
  function createInstanceClone()
22
23
  external
23
24
  returns (
24
- AccessManagerSimple clonedAccessManager,
25
+ AccessManagerUpgradeableInitializeable clonedAccessManager,
25
26
  Instance clonedInstance,
26
27
  NftId instanceNftId,
27
- InstanceReader clonedInstanceReader
28
+ InstanceReader clonedInstanceReader,
29
+ BundleManager clonedBundleManager
28
30
  );
29
31
  }
30
32
 
@@ -3,9 +3,10 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
5
  import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
+ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
7
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
8
+ import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
6
9
 
7
- import {AccessManagedSimple} from "./AccessManagedSimple.sol";
8
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
9
10
  import {IAccess} from "./module/IAccess.sol";
10
11
  import {IBundle} from "./module/IBundle.sol";
11
12
  import {IPolicy} from "./module/IPolicy.sol";
@@ -15,6 +16,7 @@ import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
15
16
  import {KeyValueStore} from "./base/KeyValueStore.sol";
16
17
  import {IInstance} from "./IInstance.sol";
17
18
  import {InstanceReader} from "./InstanceReader.sol";
19
+ import {BundleManager} from "./BundleManager.sol";
18
20
  import {NftId} from "../types/NftId.sol";
19
21
  import {NumberId} from "../types/NumberId.sol";
20
22
  import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
@@ -27,14 +29,15 @@ import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
27
29
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
28
30
  import {IDistributionService} from "./service/IDistributionService.sol";
29
31
  import {IPoolService} from "./service/IPoolService.sol";
32
+ import {IProductService} from "./service/IProductService.sol";
30
33
  import {VersionPart} from "../types/Version.sol";
34
+ import {InstanceBase} from "./InstanceBase.sol";
31
35
 
32
36
  contract Instance is
33
- AccessManagedSimple,
34
- KeyValueStore,
37
+ AccessManagedUpgradeable,
35
38
  IInstance,
36
- ERC165,
37
- Registerable
39
+ // Initializable,
40
+ InstanceBase
38
41
  {
39
42
 
40
43
  uint64 public constant ADMIN_ROLE = type(uint64).min;
@@ -51,20 +54,19 @@ contract Instance is
51
54
 
52
55
  mapping(ShortString name => address target) internal _target;
53
56
 
54
- AccessManagerSimple internal _accessManager;
57
+ AccessManagerUpgradeable internal _accessManager;
55
58
  InstanceReader internal _instanceReader;
59
+ BundleManager internal _bundleManager;
56
60
 
57
- constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
61
+ function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner)
62
+ public
63
+ initializer
58
64
  {
59
- initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
60
- }
61
-
62
- function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
63
65
  require(!_initialized, "Contract instance has already been initialized");
64
66
 
65
- initializeAccessManagedSimple(accessManagerAddress);
67
+ __AccessManaged_init(accessManagerAddress);
66
68
 
67
- _accessManager = AccessManagerSimple(accessManagerAddress);
69
+ _accessManager = AccessManagerUpgradeable(accessManagerAddress);
68
70
  _createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
69
71
  _createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
70
72
 
@@ -423,10 +425,9 @@ contract Instance is
423
425
  return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
424
426
  }
425
427
 
426
- // TODO reactivate when services are available
427
- // function getProductService() external view returns (IProductService) {
428
- // return ProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
429
- // }
428
+ function getProductService() external view returns (IProductService) {
429
+ return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
430
+ }
430
431
 
431
432
  function getPoolService() external view returns (IPoolService) {
432
433
  return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
@@ -434,10 +435,21 @@ contract Instance is
434
435
 
435
436
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
436
437
  require(address(_instanceReader) == address(0), "InstanceReader is set");
438
+ require(instanceReader.getInstanceNftId() == getNftId(), "NFT ID of InstanceReader does not match");
437
439
  _instanceReader = instanceReader;
438
440
  }
439
441
 
440
442
  function getInstanceReader() external view returns (InstanceReader) {
441
443
  return _instanceReader;
442
444
  }
445
+
446
+ function setBundleManager(BundleManager bundleManager) external restricted() {
447
+ require(address(_bundleManager) == address(0), "BundleManager is set");
448
+ require(bundleManager.getInstanceNftId() == getNftId(), "NFT ID of BundleManager does not match");
449
+ _bundleManager = bundleManager;
450
+ }
451
+
452
+ function getBundleManager() external view returns (BundleManager) {
453
+ return _bundleManager;
454
+ }
443
455
  }