@etherisc/gif-next 0.0.2-9d3eab3-323 → 0.0.2-9dd1984-554

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 (222) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  2. package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → Component.sol/Component.json} +51 -6
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +51 -104
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  6. package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → IComponent.sol/IComponent.json} +51 -6
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +5 -5
  11. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.json +51 -132
  13. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  14. package/artifacts/contracts/components/Product.sol/Product.json +56 -120
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  35. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
  36. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  38. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +90 -13
  41. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +75 -1
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +56 -616
  46. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +221 -114
  48. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +2 -2
  50. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  52. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +126 -229
  54. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -126
  56. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  57. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  58. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  59. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +98 -24
  60. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -13
  62. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  68. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +219 -48
  76. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +20 -24
  78. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +131 -38
  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/IBundleService.sol/IBundleService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +51 -0
  84. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +107 -0
  87. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +308 -60
  91. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +48 -20
  93. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +131 -38
  95. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -21
  97. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +131 -38
  99. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -9
  101. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  102. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  103. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +72 -1
  104. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +3 -3
  106. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  107. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/Registry.sol/Registry.json +85 -59
  109. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  110. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +33 -23
  111. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  112. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -17
  113. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  114. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +13 -13
  115. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  116. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +84 -101
  117. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  118. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  119. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  120. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  121. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  122. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  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 +2 -2
  127. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  129. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  131. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  132. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  133. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  134. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  135. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  137. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  138. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  139. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  140. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
  142. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  145. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  146. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  147. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  148. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  152. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  154. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  160. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  166. package/contracts/components/Component.sol +177 -0
  167. package/contracts/components/Distribution.sol +5 -14
  168. package/contracts/components/{IBaseComponent.sol → IComponent.sol} +12 -6
  169. package/contracts/components/IProductComponent.sol +2 -2
  170. package/contracts/components/Pool.sol +7 -20
  171. package/contracts/components/Product.sol +21 -18
  172. package/contracts/instance/IInstance.sol +3 -3
  173. package/contracts/instance/IInstanceBase.sol +0 -1
  174. package/contracts/instance/IInstanceService.sol +10 -4
  175. package/contracts/instance/Instance.sol +6 -208
  176. package/contracts/instance/InstanceAccessManager.sol +92 -77
  177. package/contracts/instance/InstanceBase.sol +0 -2
  178. package/contracts/instance/InstanceService.sol +117 -71
  179. package/contracts/instance/InstanceServiceManager.sol +5 -9
  180. package/contracts/instance/base/ComponentService.sol +133 -0
  181. package/contracts/instance/base/IInstanceBase.sol +0 -2
  182. package/contracts/instance/module/IAccess.sol +27 -17
  183. package/contracts/instance/service/BundleService.sol +38 -5
  184. package/contracts/instance/service/BundleServiceManager.sol +5 -9
  185. package/contracts/instance/service/DistributionService.sol +33 -32
  186. package/contracts/instance/service/DistributionServiceManager.sol +6 -10
  187. package/contracts/instance/service/IBundleService.sol +5 -6
  188. package/contracts/instance/service/IPolicyService.sol +7 -0
  189. package/contracts/instance/service/PolicyService.sol +62 -27
  190. package/contracts/instance/service/PoolService.sol +46 -26
  191. package/contracts/instance/service/PoolServiceManager.sol +5 -9
  192. package/contracts/instance/service/ProductService.sol +104 -31
  193. package/contracts/registry/IRegistry.sol +17 -3
  194. package/contracts/registry/IRegistryService.sol +5 -5
  195. package/contracts/registry/Registry.sol +30 -19
  196. package/contracts/registry/RegistryAccessManager.sol +27 -27
  197. package/contracts/registry/RegistryService.sol +22 -32
  198. package/contracts/registry/RegistryServiceManager.sol +4 -2
  199. package/contracts/registry/ReleaseManager.sol +87 -123
  200. package/contracts/registry/TokenRegistry.sol +4 -4
  201. package/contracts/shared/IRegisterable.sol +0 -2
  202. package/contracts/shared/NftOwnable.sol +2 -0
  203. package/contracts/shared/Service.sol +4 -2
  204. package/contracts/types/RoleId.sol +6 -7
  205. package/package.json +1 -1
  206. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  207. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  208. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  209. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  210. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  211. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  212. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
  213. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  214. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  215. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  216. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
  217. package/contracts/components/BaseComponent.sol +0 -132
  218. package/contracts/instance/IAccessManagerSimple.sol +0 -391
  219. package/contracts/instance/base/ComponentServiceBase.sol +0 -72
  220. package/contracts/instance/service/ComponentOwnerService.sol +0 -315
  221. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  222. 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";
@@ -20,11 +19,11 @@ import {TokenHandler} from "../../shared/TokenHandler.sol";
20
19
  import {IVersionable} from "../../shared/IVersionable.sol";
21
20
  import {Versionable} from "../../shared/Versionable.sol";
22
21
 
23
- import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
22
+ import {Timestamp, TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
24
23
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
25
24
  import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
26
25
  import {ObjectType, INSTANCE, PRODUCT, POOL, POLICY, BUNDLE} from "../../types/ObjectType.sol";
27
- import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
26
+ import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE, CLOSED} from "../../types/StateId.sol";
28
27
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
29
28
  import {Fee, FeeLib} from "../../types/Fee.sol";
30
29
  import {ReferralId} from "../../types/Referral.sol";
@@ -35,15 +34,16 @@ 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;
46
+ using TimestampLib for Timestamp;
47
47
 
48
48
  IPoolService internal _poolService;
49
49
  IBundleService internal _bundleService;
@@ -81,7 +81,7 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
81
81
  (productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
82
82
  product = Product(productInfo.objectAddress);
83
83
  }
84
- // TODO no access restrictions
84
+ // TODO: no access restrictions
85
85
  function calculatePremium(
86
86
  RiskId riskId,
87
87
  uint256 sumInsuredAmount,
@@ -179,7 +179,7 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
179
179
  ReferralId referralId
180
180
  ) external override returns (NftId policyNftId) {
181
181
  (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
182
- // TODO add validations (see create bundle in pool service)
182
+ // TODO: add validations (see create bundle in pool service)
183
183
 
184
184
  policyNftId = getRegistryService().registerPolicy(
185
185
  IRegistry.ObjectInfo(
@@ -224,7 +224,7 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
224
224
  instance.createPolicy(policyNftId, policyInfo);
225
225
  instance.updatePolicyState(policyNftId, APPLIED());
226
226
 
227
- // TODO add logging
227
+ // TODO: add logging
228
228
  }
229
229
 
230
230
  function _getAndVerifyUnderwritingSetup(
@@ -384,7 +384,7 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
384
384
  }
385
385
  }
386
386
 
387
- // TODO add logging
387
+ // TODO: add logging
388
388
  }
389
389
 
390
390
  function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
@@ -397,28 +397,30 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
397
397
  // check caller is registered product
398
398
  (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
399
399
  InstanceReader instanceReader = instance.getInstanceReader();
400
+ IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
400
401
 
401
- // TODO: check if not paid
402
- // TODO: transfer premium
403
- // TODO: optionally activate
402
+ if (policyInfo.premiumPaidAmount == policyInfo.premiumAmount) {
403
+ revert ErrorIPolicyServicePremiumAlreadyPaid(policyNftId, policyInfo.premiumPaidAmount);
404
+ }
404
405
 
405
- // // perform actual token transfers (this code is probably not complete)
406
- // IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
407
-
408
- // uint256 premiumAmount = policyInfo.premiumAmount;
409
- // _processPremiumByTreasury(instance, productInfo.nftId, policyNftId, premiumAmount);
406
+ uint256 unpaidPremiumAmount = policyInfo.premiumAmount - policyInfo.premiumPaidAmount;
410
407
 
411
- // // policy level book keeping for premium paid
412
- // policyInfo.premiumPaidAmount += premiumAmount;
408
+ uint256 netPremiumAmount = _processPremiumByTreasury(
409
+ instance,
410
+ productInfo.nftId,
411
+ policyNftId,
412
+ unpaidPremiumAmount);
413
413
 
414
- // instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
414
+ policyInfo.premiumPaidAmount += unpaidPremiumAmount;
415
415
 
416
- // // optional activation of policy
417
- // if(activateAt > zeroTimestamp()) {
418
- // activate(policyNftId, activateAt);
419
- // }
416
+ _bundleService.increaseBalance(instance, policyInfo.bundleNftId, netPremiumAmount);
417
+ instance.updatePolicy(policyNftId, policyInfo, KEEP_STATE());
420
418
 
421
- // TODO add logging
419
+ if(activateAt.gtz() && policyInfo.activatedAt.eqz()) {
420
+ activate(policyNftId, activateAt);
421
+ }
422
+
423
+ // TODO: add logging
422
424
  }
423
425
 
424
426
  function activate(NftId policyNftId, Timestamp activateAt) public override {
@@ -437,14 +439,47 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
437
439
 
438
440
  instance.updatePolicy(policyNftId, policyInfo, ACTIVE());
439
441
 
440
- // TODO add logging
442
+ // TODO: add logging
441
443
  }
442
444
 
443
445
  function close(
444
446
  NftId policyNftId
445
447
  ) external override // solhint-disable-next-line no-empty-blocks
446
448
  {
449
+ (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
450
+ InstanceReader instanceReader = instance.getInstanceReader();
451
+
452
+ IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
453
+
454
+ if (policyInfo.activatedAt.eqz()) {
455
+ revert ErrorIPolicyServicePolicyNotActivated(policyNftId);
456
+ }
457
+
458
+ StateId state = instanceReader.getPolicyState(policyNftId);
459
+ if (state != ACTIVE()) {
460
+ revert ErrorIPolicyServicePolicyNotActive(policyNftId, state);
461
+ }
462
+
463
+ if (policyInfo.closedAt.gtz()) {
464
+ revert ErrorIPolicyServicePolicyAlreadyClosed(policyNftId);
465
+ }
466
+
467
+ if (policyInfo.premiumAmount != policyInfo.premiumPaidAmount) {
468
+ revert ErrorIPolicyServicePremiumNotFullyPaid(policyNftId, policyInfo.premiumAmount, policyInfo.premiumPaidAmount);
469
+ }
470
+
471
+ if (policyInfo.openClaimsCount > 0) {
472
+ revert ErrorIPolicyServiceOpenClaims(policyNftId, policyInfo.openClaimsCount);
473
+ }
474
+
475
+ if (TimestampLib.blockTimestamp().lte(policyInfo.expiredAt) && (policyInfo.payoutAmount < policyInfo.sumInsuredAmount)) {
476
+ revert ErrorIPolicyServicePolicyHasNotExpired(policyNftId, policyInfo.expiredAt);
477
+ }
478
+
479
+ policyInfo.closedAt = TimestampLib.blockTimestamp();
447
480
 
481
+ _bundleService.closePolicy(instance, policyNftId, policyInfo.bundleNftId, policyInfo.sumInsuredAmount);
482
+ instance.updatePolicy(policyNftId, policyInfo, CLOSED());
448
483
  }
449
484
 
450
485
  function _getPoolNftId(
@@ -498,6 +533,6 @@ contract PolicyService is ComponentServiceBase, IPolicyService {
498
533
  }
499
534
  }
500
535
 
501
- // TODO add logging
536
+ // TODO: add logging
502
537
  }
503
538
  }
@@ -24,17 +24,17 @@ 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
33
 
34
34
  string constant POOL_SERVICE_NAME = "PoolService";
35
35
 
36
36
  contract PoolService is
37
- ComponentServiceBase,
37
+ ComponentService,
38
38
  IPoolService
39
39
  {
40
40
  using NftIdLib for NftId;
@@ -67,37 +67,57 @@ contract PoolService is
67
67
  external
68
68
  returns(NftId poolNftId)
69
69
  {
70
- address poolOwner = msg.sender;
71
- IBaseComponent pool = IBaseComponent(poolAddress);
70
+ (
71
+ IComponent pool,
72
+ address owner,
73
+ IInstance instance,
74
+ NftId instanceNftId
75
+ ) = _checkComponentForRegistration(
76
+ poolAddress,
77
+ POOL(),
78
+ POOL_OWNER_ROLE());
79
+
80
+ (
81
+ IRegistry.ObjectInfo memory poolInfo,
82
+ bytes memory data
83
+ ) = getRegistryService().registerPool(pool, owner);
84
+ pool.linkToRegisteredNftId();
85
+ poolNftId = poolInfo.nftId;
86
+
87
+ (
88
+ string memory name,
89
+ ISetup.PoolSetupInfo memory initialSetup
90
+ ) = _decodeAndVerifyPoolData(data);
91
+ instance.createPoolSetup(poolNftId, initialSetup);
72
92
 
73
- IRegistry.ObjectInfo memory info;
74
- bytes memory data;
75
- (info, data) = getRegistryService().registerPool(pool, poolOwner);
93
+ getInstanceService().createTarget(instanceNftId, poolAddress, name);
94
+ }
76
95
 
77
- IInstance instance = _getInstance(info);
96
+ function _decodeAndVerifyPoolData(bytes memory data)
97
+ internal
98
+ returns(string memory name, ISetup.PoolSetupInfo memory setup)
99
+ {
100
+ (name, setup) = abi.decode(
101
+ data,
102
+ (string, ISetup.PoolSetupInfo)
103
+ );
78
104
 
79
- bool hasRole = getInstanceService().hasRole(
80
- poolOwner,
81
- POOL_OWNER_ROLE(),
82
- address(instance));
105
+ // TODO add checks
106
+ /*IRegistry _registry = getRegistry();
83
107
 
84
- if(!hasRole) {
85
- revert ExpectedRoleMissing(POOL_OWNER_ROLE(), poolOwner);
108
+ if(wallet == address(0)) {
109
+ revert WalletIsZero();
86
110
  }
87
111
 
88
- poolNftId = info.nftId;
89
- ISetup.PoolSetupInfo memory initialSetup = _decodeAndVerifyPoolSetup(data);
90
- instance.createPoolSetup(poolNftId, initialSetup);
91
- }
112
+ ObjectType tokenType = _registry.getObjectInfo(address(token)).objectType;
92
113
 
93
- function _decodeAndVerifyPoolSetup(bytes memory data) internal returns(ISetup.PoolSetupInfo memory setup)
94
- {
95
- setup = abi.decode(
96
- data,
97
- (ISetup.PoolSetupInfo)
98
- );
114
+ if(tokenType != TOKEN()) {
115
+ revert InvalidToken();
116
+ }
99
117
 
100
- // TODO add checks if applicable
118
+ if(UFixedLib.eqz(info.collateralizationLevel)) {
119
+ revert CollateralizationLevelIsZero();
120
+ }*/
101
121
  }
102
122
 
103
123
  function setFees(
@@ -6,8 +6,7 @@ import {ProxyManager} from "../../shared/ProxyManager.sol";
6
6
  import {PoolService} from "./PoolService.sol";
7
7
  import {Registry} from "../../registry/Registry.sol";
8
8
  import {RegistryService} from "../../registry/RegistryService.sol";
9
- import {VersionLib} from "../../types/Version.sol";
10
- import {SERVICE} from "../../types/ObjectType.sol";
9
+ import {REGISTRY} from "../../types/ObjectType.sol";
11
10
 
12
11
  contract PoolServiceManager is ProxyManager {
13
12
 
@@ -27,10 +26,10 @@ contract PoolServiceManager is ProxyManager {
27
26
 
28
27
  _poolService = PoolService(address(versionable));
29
28
 
30
- Registry registry = Registry(registryAddress);
31
- address registryServiceAddress = registry.getServiceAddress(SERVICE(), VersionLib.toVersion(3, 0, 0).toMajorPart());
32
- RegistryService registryService = RegistryService(registryServiceAddress);
33
- // TODO this must have a role or own nft to register service
29
+ // TODO `this` must have a role or own nft to register service
30
+ //Registry registry = Registry(registryAddress);
31
+ //address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _poolService.getMajorVersion());
32
+ //RegistryService registryService = RegistryService(registryServiceAddress);
34
33
  //registryService.registerService(_poolService);
35
34
 
36
35
  // TODO no nft to link yet
@@ -38,9 +37,6 @@ contract PoolServiceManager is ProxyManager {
38
37
  //_linkToNftOwnable(
39
38
  // address(registryAddress),
40
39
  // address(_poolService));
41
-
42
- // implies that after this constructor call only upgrade functionality is available
43
- _isDeployed = true;
44
40
  }
45
41
 
46
42
  //--- view functions ----------------------------------------------------//
@@ -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,117 @@ 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
- IInstance instance = _getInstance(info);
87
- bool hasRole = getInstanceService().hasRole(
88
- productOwner,
89
- PRODUCT_OWNER_ROLE(),
90
- address(instance));
91
-
92
- if(!hasRole) {
93
- revert ExpectedRoleMissing(PRODUCT_OWNER_ROLE(), productOwner);
94
- }
95
-
96
- productNftId = info.nftId;
97
- ISetup.ProductSetupInfo memory initialSetup = _decodeAndVerifyProductSetup(data);
98
- instance.createProductSetup(productNftId, initialSetup);
75
+ (
76
+ IComponent product,
77
+ address owner,
78
+ IInstance instance,
79
+ NftId instanceNftId
80
+ ) = _checkComponentForRegistration(
81
+ productAddress,
82
+ PRODUCT(),
83
+ PRODUCT_OWNER_ROLE());
84
+
85
+ (
86
+ IRegistry.ObjectInfo memory productInfo,
87
+ bytes memory data
88
+ ) = getRegistryService().registerProduct(product, owner);
89
+
90
+ productNftId = productInfo.nftId;
91
+ _createProductSetup(
92
+ instance,
93
+ product,
94
+ productNftId,
95
+ data);
96
+ }
97
+
98
+
99
+ function _createProductSetup(
100
+ IInstance instance,
101
+ IComponent product,
102
+ NftId productNftId,
103
+ bytes memory data
104
+ )
105
+ internal
106
+ returns (string memory name)
107
+ {
108
+ (
109
+ string memory name,
110
+ ISetup.ProductSetupInfo memory setup
111
+ ) = _decodeAndVerifyProductData(data);
112
+
113
+ // wire distribution and pool components to product component
114
+ IComponent distribution = IComponent(_registry.getObjectInfo(setup.distributionNftId).objectAddress);
115
+ IComponent pool = IComponent(_registry.getObjectInfo(setup.poolNftId).objectAddress);
116
+
117
+ distribution.setProductNftId(productNftId);
118
+ pool.setProductNftId(productNftId);
119
+ product.setProductNftId(productNftId);
120
+ product.linkToRegisteredNftId();
121
+
122
+ // create product setup in instance
123
+ instance.createProductSetup(productNftId, setup);
124
+
125
+ // create target for instane access manager
126
+ getInstanceService().createTarget(
127
+ _registry.getNftId(address(instance)),
128
+ address(product),
129
+ name);
99
130
  }
100
131
 
101
- function _decodeAndVerifyProductSetup(bytes memory data) internal returns(ISetup.ProductSetupInfo memory setup)
132
+ function getDomain() public pure override(IService, Service) returns(ObjectType) {
133
+ return PRODUCT();
134
+ }
135
+
136
+
137
+ function _decodeAndVerifyProductData(bytes memory data)
138
+ internal
139
+ returns(string memory name, ISetup.ProductSetupInfo memory setup)
102
140
  {
103
- setup = abi.decode(
141
+ (name, setup) = abi.decode(
104
142
  data,
105
- (ISetup.ProductSetupInfo)
143
+ (string, ISetup.ProductSetupInfo)
106
144
  );
107
145
 
108
- // TODO add checks if applicable
146
+ // TODO add checks
147
+ // if(wallet == address(0)) {
148
+ // revert WalletIsZero();
149
+ // }
150
+
151
+ // IRegistry.ObjectInfo memory tokenInfo = _registry.getObjectInfo(address(info.token));
152
+
153
+ // if(tokenInfo.objectType != TOKEN()) {
154
+ // revert InvalidToken();
155
+ // }
156
+
157
+ // IRegistry.ObjectInfo memory poolInfo = _registry.getObjectInfo(info.poolNftId);
158
+
159
+ // if(poolInfo.objectType != POOL()) {
160
+ // revert InvalidPool();
161
+ // }
162
+
163
+ // if(poolInfo.parentNftId != instanceNftId) {
164
+ // revert InvalidPoolsInstance();
165
+ // }
166
+ // // TODO pool have the same token
167
+ // //ITreasury.PoolSetup memory poolSetup = instance.getPoolSetup(info.poolNftId);
168
+ // //require(tokenInfo.objectAddress == address(poolSetup.token), "ERROR:COS-018:PRODUCT_POOL_TOKEN_MISMATCH");
169
+ // // TODO pool is not linked
170
+
171
+ // IRegistry.ObjectInfo memory distributionInfo = _registry.getObjectInfo(info.distributionNftId);
172
+
173
+ // if(distributionInfo.objectType != DISTRIBUTION()) {
174
+ // revert InvalidDistribution();
175
+ // }
176
+
177
+ // if(distributionInfo.parentNftId != instanceNftId) {
178
+ // revert InvalidDistributionsInstance();
179
+ // }
180
+ // // TODO distribution have the same token
181
+ // // TODO distribution is not linked
109
182
  }
110
183
 
111
184
  function setFees(
@@ -7,11 +7,12 @@ import {ChainNft} from "./ChainNft.sol";
7
7
  import {NftId} from "../types/NftId.sol";
8
8
  import {ObjectType} from "../types/ObjectType.sol";
9
9
  import {VersionPart} from "../types/Version.sol";
10
+ import {Timestamp} from "../types/Timestamp.sol";
10
11
 
11
12
  interface IRegistry is IERC165 {
12
13
 
13
14
  event LogRegistration(NftId nftId, NftId parentNftId, ObjectType objectType, bool isInterceptor, address objectAddress, address initialOwner);
14
-
15
+ event LogServiceRegistration(VersionPart majorVersion, ObjectType domain);
15
16
 
16
17
  // register()
17
18
  error CallerNotRegistryService();
@@ -19,6 +20,7 @@ interface IRegistry is IERC165 {
19
20
 
20
21
  // registerService()
21
22
  error CallerNotReleaseManager();
23
+ error ServiceAlreadyRegistered(address service);
22
24
 
23
25
  // _register()
24
26
  error ZeroParentAddress();
@@ -36,7 +38,17 @@ interface IRegistry is IERC165 {
36
38
  }// TODO delete nftId and initialOwner(if not used) from struct
37
39
  // TODO strong disagree, keep nftId there (lets keep get object info return object consistent)
38
40
 
39
- function registerService(ObjectInfo memory serviceInfo) external returns(NftId nftId);
41
+ struct ReleaseInfo {
42
+ ObjectType[] domains;
43
+ Timestamp createdAt;
44
+ //Timestamp updatedAt;
45
+ }
46
+
47
+ function registerService(
48
+ ObjectInfo memory serviceInfo,
49
+ VersionPart serviceVersion,
50
+ ObjectType serviceDomain
51
+ ) external returns(NftId nftId);
40
52
 
41
53
  function register(ObjectInfo memory info) external returns (NftId nftId);
42
54
 
@@ -46,6 +58,8 @@ interface IRegistry is IERC165 {
46
58
 
47
59
  function getMajorVersion() external view returns (VersionPart);
48
60
 
61
+ function getReleaseInfo(VersionPart version) external view returns (ReleaseInfo memory);
62
+
49
63
  function getObjectCount() external view returns (uint256);
50
64
 
51
65
  function getNftId() external view returns (NftId nftId);
@@ -67,7 +81,7 @@ interface IRegistry is IERC165 {
67
81
  function isRegisteredService(address contractAddress) external view returns (bool);
68
82
 
69
83
  function getServiceAddress(
70
- ObjectType serviceType,
84
+ ObjectType serviceDomain,
71
85
  VersionPart releaseVersion
72
86
  ) external view returns (address serviceAddress);
73
87
 
@@ -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,
@@ -35,20 +35,20 @@ interface IRegistryService is
35
35
  struct FunctionConfig
36
36
  {
37
37
  ObjectType serviceDomain;
38
- bytes4[] selector;
38
+ bytes4 selector;
39
39
  }
40
40
 
41
41
  // TODO used by service -> add owner arg
42
42
  function registerInstance(IRegisterable instance)
43
43
  external returns(IRegistry.ObjectInfo memory info, bytes memory data);
44
44
 
45
- function registerProduct(IBaseComponent product, address owner)
45
+ function registerProduct(IComponent product, address owner)
46
46
  external returns(IRegistry.ObjectInfo memory info, bytes memory data);
47
47
 
48
- function registerPool(IBaseComponent pool, address owner)
48
+ function registerPool(IComponent pool, address owner)
49
49
  external returns(IRegistry.ObjectInfo memory info, bytes memory data);
50
50
 
51
- function registerDistribution(IBaseComponent distribution, address owner)
51
+ function registerDistribution(IComponent distribution, address owner)
52
52
  external returns(IRegistry.ObjectInfo memory info, bytes memory data);
53
53
 
54
54
  function registerPolicy(IRegistry.ObjectInfo memory info) external returns(NftId nftId);