@etherisc/gif-next 0.0.2-b9e43cf-870 → 0.0.2-bb1081a-994

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  2. package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → Component.sol/Component.json} +230 -14
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +141 -10
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  6. package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +107 -87
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +543 -0
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +623 -45
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +643 -5
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +227 -73
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +146 -15
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
  39. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +181 -15
  42. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +0 -5
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +113 -76
  46. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +47 -60
  48. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +42 -83
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +59 -58
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +37 -24
  54. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
  56. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  57. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +102 -31
  58. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  60. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +229 -93
  71. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +31 -18
  73. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +126 -47
  75. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +31 -14
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +98 -38
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +0 -5
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +0 -5
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +0 -5
  85. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +0 -5
  87. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +153 -82
  89. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +44 -31
  91. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +126 -47
  93. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +31 -14
  95. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +126 -47
  97. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +31 -14
  99. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  101. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +83 -3
  102. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  103. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +33 -28
  104. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  105. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  106. package/artifacts/contracts/registry/Registry.sol/Registry.json +96 -24
  107. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  108. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
  109. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  110. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -56
  111. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  112. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +28 -15
  113. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  114. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -53
  115. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +23 -26
  117. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  118. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  119. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
  122. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IService.sol/IService.json +0 -5
  124. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
  127. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
  129. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
  131. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  132. package/artifacts/contracts/shared/Service.sol/Service.json +13 -5
  133. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  134. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  137. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
  139. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  141. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestService.sol/TestService.json +29 -21
  143. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  146. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  147. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  148. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  153. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  155. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  161. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  167. package/contracts/components/Component.sol +247 -0
  168. package/contracts/components/Distribution.sol +27 -48
  169. package/contracts/components/IComponent.sol +50 -0
  170. package/contracts/components/IDistributionComponent.sol +5 -2
  171. package/contracts/components/IPoolComponent.sol +40 -29
  172. package/contracts/components/IProductComponent.sol +7 -3
  173. package/contracts/components/Pool.sol +123 -138
  174. package/contracts/components/Product.sol +48 -86
  175. package/contracts/instance/BundleManager.sol +7 -11
  176. package/contracts/instance/IInstance.sol +20 -10
  177. package/contracts/instance/IInstanceService.sol +1 -1
  178. package/contracts/instance/Instance.sol +28 -31
  179. package/contracts/instance/InstanceAccessManager.sol +6 -11
  180. package/contracts/instance/InstanceReader.sol +3 -25
  181. package/contracts/instance/InstanceService.sol +31 -14
  182. package/contracts/instance/ObjectManager.sol +7 -24
  183. package/contracts/instance/base/ComponentService.sol +134 -0
  184. package/contracts/instance/module/ISetup.sol +2 -2
  185. package/contracts/instance/service/BundleService.sol +11 -6
  186. package/contracts/instance/service/DistributionService.sol +22 -36
  187. package/contracts/instance/service/IBundleService.sol +11 -1
  188. package/contracts/instance/service/PolicyService.sol +56 -76
  189. package/contracts/instance/service/PoolService.sol +19 -55
  190. package/contracts/instance/service/ProductService.sol +49 -30
  191. package/contracts/registry/IRegistry.sol +13 -6
  192. package/contracts/registry/IRegistryService.sol +16 -9
  193. package/contracts/registry/Registry.sol +100 -44
  194. package/contracts/registry/RegistryAccessManager.sol +31 -25
  195. package/contracts/registry/RegistryService.sol +27 -85
  196. package/contracts/registry/ReleaseManager.sol +72 -82
  197. package/contracts/registry/TokenRegistry.sol +5 -3
  198. package/contracts/shared/IRegisterable.sol +1 -3
  199. package/contracts/shared/NftOwnable.sol +5 -0
  200. package/contracts/shared/Registerable.sol +10 -14
  201. package/contracts/shared/Service.sol +4 -2
  202. package/contracts/types/RoleId.sol +2 -2
  203. package/package.json +1 -1
  204. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  205. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  206. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  207. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  208. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  209. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
  210. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  211. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
  212. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  213. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  214. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  215. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  216. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
  217. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  218. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  219. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  220. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
  221. package/contracts/components/BaseComponent.sol +0 -159
  222. package/contracts/components/IBaseComponent.sol +0 -34
  223. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
  224. package/contracts/instance/IInstanceBase.sol +0 -26
  225. package/contracts/instance/InstanceBase.sol +0 -41
  226. package/contracts/instance/base/ComponentServiceBase.sol +0 -76
  227. package/contracts/instance/base/IInstanceBase.sol +0 -23
  228. package/contracts/instance/service/ComponentOwnerService.sol +0 -315
  229. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  230. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -4,7 +4,6 @@ pragma solidity ^0.8.19;
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
5
  import {IProductComponent} from "../../components/IProductComponent.sol";
6
6
  import {Product} from "../../components/Product.sol";
7
- import {IBaseComponent} from "../../components/IBaseComponent.sol";
8
7
  import {IPoolComponent} from "../../components/IPoolComponent.sol";
9
8
  import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
10
9
  import {IInstance} from "../IInstance.sol";
@@ -35,14 +34,14 @@ import {Version, VersionLib} from "../../types/Version.sol";
35
34
 
36
35
  import {IService} from "../../shared/IService.sol";
37
36
  import {Service} from "../../shared/Service.sol";
38
- import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
37
+ import {ComponentService} from "../base/ComponentService.sol";
39
38
  import {IPolicyService} from "./IPolicyService.sol";
40
39
  import {InstanceReader} from "../InstanceReader.sol";
41
40
  import {IPoolService} from "./IPoolService.sol";
42
41
  import {IBundleService} from "./IBundleService.sol";
43
42
 
44
43
 
45
- contract PolicyService is ComponentServiceBase, IPolicyService {
44
+ contract PolicyService is ComponentService, IPolicyService {
46
45
  using NftIdLib for NftId;
47
46
  using TimestampLib for Timestamp;
48
47
 
@@ -237,18 +236,19 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
237
236
  internal
238
237
  view
239
238
  returns (
239
+ NftId poolNftId,
240
240
  NftId bundleNftId,
241
241
  IBundle.BundleInfo memory bundleInfo,
242
242
  uint256 collateralAmount
243
243
  )
244
244
  {
245
245
  // check match between policy and bundle (via pool)
246
+ poolNftId = productSetupInfo.poolNftId;
246
247
  bundleNftId = policyInfo.bundleNftId;
247
248
  bundleInfo = instanceReader.getBundleInfo(bundleNftId);
248
- require(bundleInfo.poolNftId == productSetupInfo.poolNftId, "POLICY_BUNDLE_MISMATCH");
249
+ require(bundleInfo.poolNftId == poolNftId, "POLICY_BUNDLE_MISMATCH");
249
250
 
250
251
  // calculate required collateral
251
- NftId poolNftId = productSetupInfo.poolNftId;
252
252
  ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(poolNftId);
253
253
 
254
254
  // obtain remaining return values
@@ -270,24 +270,6 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
270
270
  return bundleInfo;
271
271
  }
272
272
 
273
- function _underwriteByPool(
274
- NftId poolNftId,
275
- NftId policyNftId,
276
- IPolicy.PolicyInfo memory policyInfo,
277
- bytes memory bundleFilter,
278
- uint256 collateralAmount
279
- )
280
- internal
281
- {
282
- address poolAddress = getRegistry().getObjectInfo(poolNftId).objectAddress;
283
- IPoolComponent pool = IPoolComponent(poolAddress);
284
- pool.underwrite(
285
- policyNftId,
286
- policyInfo.applicationData,
287
- bundleFilter,
288
- collateralAmount);
289
- }
290
-
291
273
 
292
274
  function revoke(
293
275
  NftId policyNftId
@@ -300,7 +282,7 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
300
282
 
301
283
 
302
284
  function underwrite(
303
- NftId policyNftId,
285
+ NftId applicationNftId, // = policyNftId
304
286
  bool requirePremiumPayment,
305
287
  Timestamp activateAt
306
288
  )
@@ -308,47 +290,37 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
308
290
  override
309
291
  {
310
292
  // check caller is registered product
311
- (
312
- IRegistry.ObjectInfo memory productInfo,
313
- IInstance instance
314
- ) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
315
- InstanceReader instanceReader = instance.getInstanceReader();
293
+ IInstance instance;
294
+ InstanceReader instanceReader;
295
+ NftId productNftId;
296
+ {
297
+ IRegistry.ObjectInfo memory productInfo;
298
+ (productInfo, instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
299
+ instanceReader = instance.getInstanceReader();
300
+ productNftId = productInfo.nftId;
301
+ }
316
302
 
317
- // check match between policy and calling product
318
- NftId productNftId = productInfo.nftId;
319
- IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
303
+ // check policy matches with calling product
304
+ IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(applicationNftId);
320
305
  require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
321
- require(instanceReader.getPolicyState(policyNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
322
306
 
323
- NftId bundleNftId;
324
- IBundle.BundleInfo memory bundleInfo;
325
- uint256 collateralAmount;
326
- uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
327
- {
328
- ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
329
- IBundle.BundleInfo memory bundleInfo;
330
-
331
- (
332
- bundleNftId,
333
- bundleInfo,
334
- collateralAmount
335
- ) = _getAndVerifyUnderwritingSetup(
336
- instance,
337
- instanceReader,
338
- policyInfo,
339
- productSetupInfo
340
- );
341
- }
307
+ // check policy is in state applied
308
+ require(instanceReader.getPolicyState(applicationNftId) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
342
309
 
343
- // lock bundle collateral
344
- bundleInfo = _lockCollateralInBundle(
310
+ (
311
+ NftId poolNftId,
312
+ NftId bundleNftId,
313
+ IBundle.BundleInfo memory bundleInfo,
314
+ uint256 collateralAmount
315
+ ) = _getAndVerifyUnderwritingSetup(
345
316
  instance,
346
- bundleNftId,
347
- bundleInfo,
348
- policyNftId,
349
- collateralAmount);
350
- StateId newPolicyState = UNDERWRITTEN();
317
+ instanceReader,
318
+ policyInfo,
319
+ instanceReader.getProductSetupInfo(productNftId)
320
+ );
351
321
 
322
+ StateId newPolicyState = UNDERWRITTEN();
323
+
352
324
  // optional activation of policy
353
325
  if(activateAt > zeroTimestamp()) {
354
326
  newPolicyState = ACTIVE();
@@ -356,38 +328,46 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
356
328
  policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
357
329
  }
358
330
 
331
+ // lock bundle collateral
332
+ uint256 netPremiumAmount = 0; // > 0 if immediate premium payment
333
+
359
334
  // optional collection of premium
360
335
  if(requirePremiumPayment) {
361
336
  netPremiumAmount = _processPremiumByTreasury(
362
337
  instance,
363
- productInfo.nftId,
364
- policyNftId,
338
+ productNftId,
339
+ applicationNftId,
365
340
  policyInfo.premiumAmount);
366
341
 
367
342
  policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
368
343
  }
369
344
 
370
- _bundleService.underwritePolicy(instance, policyNftId, bundleNftId, collateralAmount, netPremiumAmount);
371
- instance.updatePolicy(policyNftId, policyInfo, newPolicyState);
345
+ // lock collateral and update bundle book keeping
346
+ bundleInfo = _bundleService.lockCollateral(
347
+ instance,
348
+ applicationNftId,
349
+ bundleNftId,
350
+ collateralAmount,
351
+ netPremiumAmount);
372
352
 
373
- // involve pool if necessary
374
- {
375
- ISetup.PoolSetupInfo memory poolInfo = instanceReader.getPoolSetupInfo(bundleInfo.poolNftId);
376
-
377
- if(poolInfo.isConfirmingApplication) {
378
- _underwriteByPool(
379
- bundleInfo.poolNftId,
380
- policyNftId,
381
- policyInfo,
382
- bundleInfo.filter,
383
- collateralAmount
384
- );
385
- }
353
+ instance.updatePolicy(applicationNftId, policyInfo, newPolicyState);
354
+
355
+ // also verify/confirm application by pool if necessary
356
+ if(instanceReader.getPoolSetupInfo(poolNftId).isVerifyingApplications) {
357
+ IPoolComponent pool = IPoolComponent(
358
+ getRegistry().getObjectInfo(poolNftId).objectAddress);
359
+
360
+ pool.verifyApplication(
361
+ applicationNftId,
362
+ policyInfo.applicationData,
363
+ bundleInfo.filter,
364
+ collateralAmount);
386
365
  }
387
366
 
388
367
  // TODO: add logging
389
368
  }
390
369
 
370
+
391
371
  function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
392
372
  UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
393
373
  UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
@@ -24,17 +24,18 @@ import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
24
24
  import {IService} from "../../shared/IService.sol";
25
25
  import {Service} from "../../shared/Service.sol";
26
26
  import {BundleManager} from "../BundleManager.sol";
27
- import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
27
+ import {ComponentService} from "../base/ComponentService.sol";
28
28
  import {IPoolService} from "./IPoolService.sol";
29
29
  import {IRegistryService} from "../../registry/IRegistryService.sol";
30
30
  import {InstanceService} from "../InstanceService.sol";
31
31
  import {InstanceReader} from "../InstanceReader.sol";
32
- import {IBaseComponent} from "../../components/IBaseComponent.sol";
32
+ import {IComponent} from "../../components/IComponent.sol";
33
+ import {IPoolComponent} from "../../components/IPoolComponent.sol";
33
34
 
34
35
  string constant POOL_SERVICE_NAME = "PoolService";
35
36
 
36
37
  contract PoolService is
37
- ComponentServiceBase,
38
+ ComponentService,
38
39
  IPoolService
39
40
  {
40
41
  using NftIdLib for NftId;
@@ -67,60 +68,23 @@ contract PoolService is
67
68
  external
68
69
  returns(NftId poolNftId)
69
70
  {
70
- address poolOwner = msg.sender;
71
- IBaseComponent pool = IBaseComponent(poolAddress);
72
-
73
- IRegistry.ObjectInfo memory info;
74
- bytes memory data;
75
- (info, data) = getRegistryService().registerPool(pool, poolOwner);
76
-
77
- NftId instanceNftId = info.parentNftId;
78
- IInstance instance = _getInstance(instanceNftId);
79
- bool hasRole = getInstanceService().hasRole(
80
- poolOwner,
81
- POOL_OWNER_ROLE(),
82
- address(instance));
83
-
84
- if(!hasRole) {
85
- revert ExpectedRoleMissing(POOL_OWNER_ROLE(), poolOwner);
86
- }
87
-
88
- poolNftId = info.nftId;
89
- string memory poolName;
90
- ISetup.PoolSetupInfo memory initialSetup;
91
- (poolName, initialSetup) = _decodeAndVerifyPoolData(data);
92
- instance.createPoolSetup(poolNftId, initialSetup);
93
-
94
- getInstanceService().createTarget(instanceNftId, poolAddress, poolName);
95
-
71
+ (
72
+ IComponent component,
73
+ address owner,
74
+ IInstance instance,
75
+ NftId instanceNftId
76
+ ) = _checkComponentForRegistration(
77
+ poolAddress,
78
+ POOL(),
79
+ POOL_OWNER_ROLE());
80
+
81
+ IPoolComponent pool = IPoolComponent(poolAddress);
82
+ IRegistry.ObjectInfo memory poolInfo = getRegistryService().registerPool(pool, owner);
96
83
  pool.linkToRegisteredNftId();
97
- }
98
-
99
- function _decodeAndVerifyPoolData(bytes memory data)
100
- internal
101
- returns(string memory name, ISetup.PoolSetupInfo memory setup)
102
- {
103
- (name, setup) = abi.decode(
104
- data,
105
- (string, ISetup.PoolSetupInfo)
106
- );
107
-
108
- // TODO add checks
109
- /*IRegistry _registry = getRegistry();
110
-
111
- if(wallet == address(0)) {
112
- revert WalletIsZero();
113
- }
114
-
115
- ObjectType tokenType = _registry.getObjectInfo(address(token)).objectType;
116
-
117
- if(tokenType != TOKEN()) {
118
- revert InvalidToken();
119
- }
84
+ poolNftId = poolInfo.nftId;
120
85
 
121
- if(UFixedLib.eqz(info.collateralizationLevel)) {
122
- revert CollateralizationLevelIsZero();
123
- }*/
86
+ instance.createPoolSetup(poolNftId, pool.getSetupInfo());
87
+ getInstanceService().createTarget(instanceNftId, poolAddress, pool.getName());
124
88
  }
125
89
 
126
90
  function setFees(
@@ -4,7 +4,7 @@ pragma solidity ^0.8.19;
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
5
  import {IProductComponent} from "../../components/IProductComponent.sol";
6
6
  import {Product} from "../../components/Product.sol";
7
- import {IBaseComponent} from "../../components/IBaseComponent.sol";
7
+ import {IComponent} from "../../components/IComponent.sol";
8
8
  import {IPoolComponent} from "../../components/IPoolComponent.sol";
9
9
  import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
10
10
  import {IInstance} from "../IInstance.sol";
@@ -35,13 +35,13 @@ import {RoleId, PRODUCT_OWNER_ROLE} from "../../types/RoleId.sol";
35
35
 
36
36
  import {IService} from "../../shared/IService.sol";
37
37
  import {Service} from "../../shared/Service.sol";
38
- import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
38
+ import {ComponentService} from "../base/ComponentService.sol";
39
39
  import {IProductService} from "./IProductService.sol";
40
40
  import {InstanceReader} from "../InstanceReader.sol";
41
41
  import {IPoolService} from "./PoolService.sol";
42
42
 
43
43
  // TODO or name this ProtectionService to have Product be something more generic (loan, savings account, ...)
44
- contract ProductService is ComponentServiceBase, IProductService {
44
+ contract ProductService is ComponentService, IProductService {
45
45
  using NftIdLib for NftId;
46
46
 
47
47
  IPoolService internal _poolService;
@@ -68,44 +68,63 @@ contract ProductService is ComponentServiceBase, IProductService {
68
68
  }
69
69
 
70
70
 
71
- function getDomain() public pure override(IService, Service) returns(ObjectType) {
72
- return PRODUCT();
73
- }
74
-
75
71
  function register(address productAddress)
76
72
  external
77
73
  returns(NftId productNftId)
78
74
  {
79
- address productOwner = msg.sender;
80
- IBaseComponent product = IBaseComponent(productAddress);
81
-
82
- IRegistry.ObjectInfo memory info;
83
- bytes memory data;
84
- (info, data) = getRegistryService().registerProduct(product, productOwner);
85
-
86
- NftId instanceNftId = info.parentNftId;
87
- IInstance instance = _getInstance(instanceNftId);
88
- bool hasRole = getInstanceService().hasRole(
89
- productOwner,
90
- PRODUCT_OWNER_ROLE(),
91
- address(instance));
75
+ (
76
+ IComponent component,
77
+ address owner,
78
+ IInstance instance,
79
+ NftId instanceNftId
80
+ ) = _checkComponentForRegistration(
81
+ productAddress,
82
+ PRODUCT(),
83
+ PRODUCT_OWNER_ROLE());
84
+
85
+ IProductComponent product = IProductComponent(productAddress);
86
+ IRegistry.ObjectInfo memory productInfo = getRegistryService().registerProduct(product, owner);
87
+ productNftId = productInfo.nftId;
88
+ _createProductSetup(
89
+ instance,
90
+ product,
91
+ productNftId);
92
+ }
92
93
 
93
- if(!hasRole) {
94
- revert ExpectedRoleMissing(PRODUCT_OWNER_ROLE(), productOwner);
95
- }
96
94
 
97
- productNftId = info.nftId;
98
- string memory productName;
99
- ISetup.ProductSetupInfo memory initialSetup;
100
- (productName, initialSetup) = _decodeAndVerifyProductData(data);
95
+ function _createProductSetup(
96
+ IInstance instance,
97
+ IProductComponent product,
98
+ NftId productNftId
99
+ )
100
+ internal
101
+ returns (string memory name)
102
+ {
103
+ // wire distribution and pool components to product component
104
+ ISetup.ProductSetupInfo memory setup = product.getSetupInfo();
105
+ IComponent distribution = IComponent(_registry.getObjectInfo(setup.distributionNftId).objectAddress);
106
+ IComponent pool = IComponent(_registry.getObjectInfo(setup.poolNftId).objectAddress);
107
+
108
+ distribution.setProductNftId(productNftId);
109
+ pool.setProductNftId(productNftId);
110
+ product.setProductNftId(productNftId);
111
+ product.linkToRegisteredNftId();
101
112
 
102
- instance.createProductSetup(productNftId, initialSetup);
113
+ // create product setup in instance
114
+ instance.createProductSetup(productNftId, product.getSetupInfo());
103
115
 
104
- getInstanceService().createTarget(instanceNftId, productAddress, productName);
116
+ // create target for instane access manager
117
+ getInstanceService().createTarget(
118
+ _registry.getNftId(address(instance)),
119
+ address(product),
120
+ product.getName());
121
+ }
105
122
 
106
- product.linkToRegisteredNftId();
123
+ function getDomain() public pure override(IService, Service) returns(ObjectType) {
124
+ return PRODUCT();
107
125
  }
108
126
 
127
+
109
128
  function _decodeAndVerifyProductData(bytes memory data)
110
129
  internal
111
130
  returns(string memory name, ISetup.ProductSetupInfo memory setup)
@@ -14,13 +14,16 @@ interface IRegistry is IERC165 {
14
14
  event LogRegistration(NftId nftId, NftId parentNftId, ObjectType objectType, bool isInterceptor, address objectAddress, address initialOwner);
15
15
  event LogServiceRegistration(VersionPart majorVersion, ObjectType domain);
16
16
 
17
+ // registerService()
18
+ error CallerNotReleaseManager();
19
+ error ServiceAlreadyRegistered(address service);
20
+
17
21
  // register()
18
22
  error CallerNotRegistryService();
19
23
  error ServiceRegistration();
20
24
 
21
- // registerService()
22
- error CallerNotReleaseManager();
23
- error ServiceAlreadyRegistered(address service);
25
+ // registerWithCustomTypes()
26
+ error CoreTypeRegistration();
24
27
 
25
28
  // _register()
26
29
  error ZeroParentAddress();
@@ -52,11 +55,13 @@ interface IRegistry is IERC165 {
52
55
 
53
56
  function register(ObjectInfo memory info) external returns (NftId nftId);
54
57
 
55
- function getMajorVersionMin() external view returns (VersionPart);
58
+ function registerWithCustomType(ObjectInfo memory info) external returns (NftId nftId);
56
59
 
57
- function getMajorVersionMax() external view returns (VersionPart);
60
+ function getInitialVersion() external view returns (VersionPart);
58
61
 
59
- function getMajorVersion() external view returns (VersionPart);
62
+ function getNextVersion() external view returns (VersionPart);
63
+
64
+ function getLatestVersion() external view returns (VersionPart);
60
65
 
61
66
  function getReleaseInfo(VersionPart version) external view returns (ReleaseInfo memory);
62
67
 
@@ -80,6 +85,8 @@ interface IRegistry is IERC165 {
80
85
 
81
86
  function isRegisteredService(address contractAddress) external view returns (bool);
82
87
 
88
+ function isValidRelease(VersionPart version) external view returns (bool);
89
+
83
90
  function getServiceAddress(
84
91
  ObjectType serviceDomain,
85
92
  VersionPart releaseVersion
@@ -10,7 +10,7 @@ import {IService} from "../shared/IService.sol";
10
10
  import {IRegistry} from "./IRegistry.sol";
11
11
 
12
12
  import {IRegisterable} from "../shared/IRegisterable.sol";
13
- import {IBaseComponent} from "../components/IBaseComponent.sol";
13
+ import {IComponent} from "../components/IComponent.sol";
14
14
 
15
15
  interface IRegistryService is
16
16
  IService,
@@ -38,18 +38,25 @@ interface IRegistryService is
38
38
  bytes4 selector;
39
39
  }
40
40
 
41
+ function getFunctionConfigs()
42
+ external
43
+ pure
44
+ returns(
45
+ FunctionConfig[] memory config
46
+ );
47
+
41
48
  // TODO used by service -> add owner arg
42
- function registerInstance(IRegisterable instance)
43
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
49
+ function registerInstance(IRegisterable instance, address owner)
50
+ external returns(IRegistry.ObjectInfo memory info);
44
51
 
45
- function registerProduct(IBaseComponent product, address owner)
46
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
52
+ function registerProduct(IComponent product, address owner)
53
+ external returns(IRegistry.ObjectInfo memory info);
47
54
 
48
- function registerPool(IBaseComponent pool, address owner)
49
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
55
+ function registerPool(IComponent pool, address owner)
56
+ external returns(IRegistry.ObjectInfo memory info);
50
57
 
51
- function registerDistribution(IBaseComponent distribution, address owner)
52
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
58
+ function registerDistribution(IComponent distribution, address owner)
59
+ external returns(IRegistry.ObjectInfo memory info);
53
60
 
54
61
  function registerPolicy(IRegistry.ObjectInfo memory info) external returns(NftId nftId);
55
62