@etherisc/gif-next 0.0.2-979c9aa-391 → 0.0.2-984cc08-642

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 (232) 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} +36 -7
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +38 -119
  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} +36 -7
  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 +38 -147
  13. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  14. package/artifacts/contracts/components/Product.sol/Product.json +43 -135
  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 +38 -62
  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 +261 -26
  41. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +171 -0
  43. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  44. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +42 -13
  45. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  46. package/artifacts/contracts/instance/Instance.sol/Instance.json +56 -82
  47. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  48. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +101 -111
  49. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  50. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +11 -11
  51. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  52. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +41 -82
  53. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  54. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +116 -183
  55. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  56. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -90
  57. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  58. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
  59. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  60. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +111 -37
  61. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  62. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -13
  63. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +11 -0
  69. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +232 -61
  77. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +20 -24
  79. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +140 -60
  81. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +17 -21
  83. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +64 -13
  85. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  87. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +120 -13
  89. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +13 -13
  91. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +13 -13
  93. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +321 -86
  95. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +51 -23
  97. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +140 -60
  99. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -21
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +146 -66
  103. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +17 -13
  105. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  106. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +132 -133
  109. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  110. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +102 -68
  111. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  112. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/Registry.sol/Registry.json +145 -227
  114. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  115. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  116. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  117. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +37 -143
  118. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  119. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
  120. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  121. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +530 -0
  122. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  123. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
  124. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  125. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  126. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
  130. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  137. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  138. package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
  139. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  140. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  145. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  147. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.json +31 -31
  149. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  152. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  153. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  154. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  161. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  167. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  173. package/contracts/components/{BaseComponent.sol → Component.sol} +69 -40
  174. package/contracts/components/Distribution.sol +5 -14
  175. package/contracts/components/{IBaseComponent.sol → IComponent.sol} +12 -7
  176. package/contracts/components/IProductComponent.sol +2 -2
  177. package/contracts/components/Pool.sol +7 -20
  178. package/contracts/components/Product.sol +21 -18
  179. package/contracts/instance/BundleManager.sol +7 -11
  180. package/contracts/instance/IInstance.sol +4 -4
  181. package/contracts/instance/IInstanceBase.sol +3 -2
  182. package/contracts/instance/IInstanceService.sol +4 -2
  183. package/contracts/instance/Instance.sol +11 -28
  184. package/contracts/instance/InstanceAccessManager.sol +15 -16
  185. package/contracts/instance/InstanceBase.sol +0 -3
  186. package/contracts/instance/InstanceReader.sol +3 -25
  187. package/contracts/instance/InstanceService.sol +115 -47
  188. package/contracts/instance/InstanceServiceManager.sol +5 -8
  189. package/contracts/instance/ObjectManager.sol +7 -24
  190. package/contracts/instance/base/ComponentService.sol +133 -0
  191. package/contracts/instance/base/IInstanceBase.sol +0 -2
  192. package/contracts/instance/module/IAccess.sol +1 -1
  193. package/contracts/instance/service/BundleService.sol +41 -8
  194. package/contracts/instance/service/BundleServiceManager.sol +5 -8
  195. package/contracts/instance/service/DistributionService.sol +36 -39
  196. package/contracts/instance/service/DistributionServiceManager.sol +6 -9
  197. package/contracts/instance/service/IBundleService.sol +5 -6
  198. package/contracts/instance/service/IPolicyService.sol +7 -0
  199. package/contracts/instance/service/PolicyService.sol +67 -37
  200. package/contracts/instance/service/PoolService.sol +49 -31
  201. package/contracts/instance/service/PoolServiceManager.sol +5 -8
  202. package/contracts/instance/service/ProductService.sol +106 -38
  203. package/contracts/registry/ChainNft.sol +1 -1
  204. package/contracts/registry/IRegistry.sol +26 -16
  205. package/contracts/registry/IRegistryService.sol +17 -10
  206. package/contracts/registry/Registry.sol +149 -201
  207. package/contracts/registry/RegistryAccessManager.sol +210 -0
  208. package/contracts/registry/RegistryService.sol +55 -96
  209. package/contracts/registry/RegistryServiceManager.sol +18 -36
  210. package/contracts/registry/ReleaseManager.sol +342 -0
  211. package/contracts/registry/TokenRegistry.sol +5 -6
  212. package/contracts/shared/IRegisterable.sol +0 -2
  213. package/contracts/shared/IService.sol +2 -1
  214. package/contracts/shared/NftOwnable.sol +2 -0
  215. package/contracts/shared/ProxyManager.sol +1 -1
  216. package/contracts/shared/Service.sol +13 -8
  217. package/contracts/test/TestService.sol +3 -2
  218. package/contracts/types/RoleId.sol +4 -5
  219. package/package.json +1 -1
  220. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  221. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  222. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  223. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  224. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
  225. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  226. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  227. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  228. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
  229. package/contracts/instance/base/ComponentServiceBase.sol +0 -72
  230. package/contracts/instance/service/ComponentOwnerService.sol +0 -317
  231. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  232. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -14,49 +14,32 @@ contract ObjectManager is
14
14
  Cloneable
15
15
  {
16
16
 
17
- event LogObjectManagerInitialized(NftId instanceNftId, address instanceReader);
17
+ event LogObjectManagerInitialized(address instance);
18
18
 
19
19
  error ErrorObjectManagerNftIdInvalid(NftId instanceNftId);
20
20
  error ErrorObjectManagerAlreadyAdded(NftId componentNftId, NftId objectNftId);
21
21
 
22
22
  mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _activeObjects;
23
23
  mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _allObjects;
24
- NftId internal _instanceNftId;
25
- InstanceReader internal _instanceReader;
26
-
27
- constructor() Cloneable() {
28
- _instanceReader = InstanceReader(address(0));
29
- }
24
+ IInstance internal _instance; // store instance address -> more flexible, instance may not be registered during ObjectManager initialization
30
25
 
31
26
  /// @dev call to initialize MUST be made in the same transaction as cloning of the contract
32
27
  function initialize(
33
28
  address authority,
34
29
  address registry,
35
- NftId instanceNftId
30
+ address instance
36
31
  )
37
32
  external
38
33
  {
39
34
  initialize(authority, registry);
40
35
 
41
- // check/handle instance nft id/instance reader
42
- IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(instanceNftId);
43
- if (instanceInfo.objectType != INSTANCE()) {
44
- revert ErrorObjectManagerNftIdInvalid(instanceNftId);
45
- }
46
-
47
- IInstance instance = IInstance(instanceInfo.objectAddress);
48
- _instanceReader = instance.getInstanceReader();
49
- _instanceNftId = instanceNftId;
36
+ _instance = IInstance(instance);
50
37
 
51
- emit LogObjectManagerInitialized(instanceNftId, address(_instanceReader));
52
- }
53
-
54
- function getInstanceReader() external view returns (InstanceReader) {
55
- return _instanceReader;
38
+ emit LogObjectManagerInitialized(instance);
56
39
  }
57
40
 
58
- function getInstanceNftId() external view returns (NftId) {
59
- return _instanceNftId;
41
+ function getInstance() external view returns (IInstance) {
42
+ return _instance;
60
43
  }
61
44
 
62
45
  function _add(NftId componentNftId, NftId objectNftId) internal {
@@ -0,0 +1,133 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IComponent} from "../../components/IComponent.sol";
5
+ import {IRegistry} from "../../registry/IRegistry.sol";
6
+ import {IRegistryService} from "../../registry/IRegistryService.sol";
7
+ import {IInstance} from "../../instance/IInstance.sol";
8
+ import {IAccess} from "../module/IAccess.sol";
9
+ import {ObjectType, INSTANCE, REGISTRY} from "../../types/ObjectType.sol";
10
+ import {NftId} from "../../types/NftId.sol";
11
+ import {RoleId} from "../../types/RoleId.sol";
12
+
13
+ import {Service} from "../../shared/Service.sol";
14
+ import {InstanceService} from "../InstanceService.sol";
15
+ import {InstanceAccessManager} from "../InstanceAccessManager.sol";
16
+
17
+ abstract contract ComponentService is Service {
18
+
19
+ error ErrorComponentServiceAlreadyRegistered(address component, NftId nftId);
20
+ error ErrorComponentServiceNotComponent(address component);
21
+ error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
22
+ error ErrorComponentServiceSenderNotOwner(address component, address initialOwner, address sender);
23
+ error ErrorComponentServiceExpectedRoleMissing(NftId instanceNftId, RoleId requiredRole, address sender);
24
+ error ErrorComponentServiceComponentLocked(address component);
25
+
26
+ /// @dev modifier to check if caller is a registered service
27
+ modifier onlyService() {
28
+ address caller = msg.sender;
29
+ require(getRegistry().isRegisteredService(caller), "ERROR_NOT_SERVICE");
30
+ _;
31
+ }
32
+
33
+ // view functions
34
+
35
+ function getRegistryService() public view virtual returns (IRegistryService) {
36
+ address service = getRegistry().getServiceAddress(REGISTRY(), getMajorVersion());
37
+ return IRegistryService(service);
38
+ }
39
+
40
+ function getInstanceService() public view returns (InstanceService) {
41
+ address service = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
42
+ return InstanceService(service);
43
+ }
44
+
45
+ // internal functions
46
+ function _checkComponentForRegistration(
47
+ address componentAddress,
48
+ ObjectType requiredType,
49
+ RoleId requiredRole
50
+ )
51
+ internal
52
+ returns (
53
+ IComponent component,
54
+ address owner,
55
+ IInstance instance,
56
+ NftId instanceNftId
57
+ )
58
+ {
59
+ // component may only be registerd by initial owner of component
60
+ owner = msg.sender;
61
+
62
+ // check component has not already been registerd
63
+ NftId compoentNftId = _registry.getNftId(componentAddress);
64
+ if(compoentNftId.gtz()) {
65
+ revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
66
+ }
67
+
68
+ // check this is a component
69
+ component = IComponent(componentAddress);
70
+ if(!component.supportsInterface(type(IComponent).interfaceId)) {
71
+ revert ErrorComponentServiceNotComponent(componentAddress);
72
+ }
73
+
74
+ // check component is of required type
75
+ (IRegistry.ObjectInfo memory componentInfo, ) = component.getInitialInfo();
76
+ if(componentInfo.objectType != requiredType) {
77
+ revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
78
+ }
79
+
80
+ // check msg.sender is component owner
81
+ address initialOwner = componentInfo.initialOwner;
82
+ if(owner != initialOwner) {
83
+ revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
84
+ }
85
+
86
+ // check instance has assigned required role to owner
87
+ instanceNftId = componentInfo.parentNftId;
88
+ instance = _getInstance(instanceNftId);
89
+ bool hasRole = getInstanceService().hasRole(
90
+ owner,
91
+ requiredRole,
92
+ address(instance));
93
+
94
+ if(!hasRole) {
95
+ revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
96
+ }
97
+ }
98
+
99
+ // internal view functions
100
+
101
+ function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
102
+ IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
103
+ return IInstance(instanceInfo.objectAddress);
104
+ }
105
+
106
+ function _getAndVerifyComponentInfoAndInstance(
107
+ //address component,
108
+ ObjectType expectedType
109
+ )
110
+ internal
111
+ view
112
+ returns(
113
+ IRegistry.ObjectInfo memory info,
114
+ IInstance instance
115
+ )
116
+ {
117
+ IRegistry registry = getRegistry();
118
+ //TODO redundant check -> just check type
119
+ //NftId componentNftId = registry.getNftId(component);
120
+ //require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
121
+
122
+ info = registry.getObjectInfo(msg.sender);
123
+ require(info.objectType == expectedType, "OBJECT_TYPE_INVALID");
124
+
125
+ address instanceAddress = registry.getObjectInfo(info.parentNftId).objectAddress;
126
+ instance = IInstance(instanceAddress);
127
+
128
+ InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
129
+ if (accessManager.isTargetLocked(info.objectAddress)) {
130
+ revert IAccess.ErrorIAccessTargetLocked(info.objectAddress);
131
+ }
132
+ }
133
+ }
@@ -6,7 +6,6 @@ import {StateId} from "../../types/StateId.sol";
6
6
 
7
7
  import {IKeyValueStore} from "./IKeyValueStore.sol";
8
8
 
9
- import {IComponentOwnerService} from "../service/IComponentOwnerService.sol";
10
9
  import {IDistributionService} from "../service/IDistributionService.sol";
11
10
  import {IProductService} from "../service/IProductService.sol";
12
11
  import {IPoolService} from "../service/IPoolService.sol";
@@ -16,7 +15,6 @@ interface IInstanceBase {
16
15
  function updateState(Key32 key, StateId state) external;
17
16
  function getState(Key32 key) external view returns (StateId state);
18
17
 
19
- function getComponentOwnerService() external view returns(IComponentOwnerService);
20
18
  function getDistributionService() external view returns(IDistributionService);
21
19
  function getProductService() external view returns(IProductService service);
22
20
  function getPoolService() external view returns(IPoolService service);
@@ -44,5 +44,5 @@ interface IAccess {
44
44
  error ErrorIAccessTargetNameEmpty(address target);
45
45
  error ErrorIAccessTargetNameExists(address target, address existingTarget, ShortString name);
46
46
  error ErrorIAccessSetLockedForNonexstentTarget(address target);
47
-
47
+ error ErrorIAccessTargetLocked(address target);
48
48
  }
@@ -14,7 +14,7 @@ import {Versionable} from "../../shared/Versionable.sol";
14
14
  import {INftOwnable} from "../../shared/INftOwnable.sol";
15
15
 
16
16
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
17
- import {POOL, BUNDLE} from "../../types/ObjectType.sol";
17
+ import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
18
18
  import {POOL_OWNER_ROLE, RoleId} from "../../types/RoleId.sol";
19
19
  import {Fee, FeeLib} from "../../types/Fee.sol";
20
20
  import {Version, VersionLib} from "../../types/Version.sol";
@@ -24,17 +24,16 @@ 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 {IBundleService} from "./IBundleService.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";
33
32
 
34
33
  string constant BUNDLE_SERVICE_NAME = "BundleService";
35
34
 
36
35
  contract BundleService is
37
- ComponentServiceBase,
36
+ ComponentService,
38
37
  IBundleService
39
38
  {
40
39
  using NftIdLib for NftId;
@@ -61,8 +60,8 @@ contract BundleService is
61
60
  _registerInterface(type(IBundleService).interfaceId);
62
61
  }
63
62
 
64
- function getName() public pure override(Service, IService) returns(string memory name) {
65
- return NAME;
63
+ function getDomain() public pure override(Service, IService) returns(ObjectType) {
64
+ return BUNDLE();
66
65
  }
67
66
 
68
67
  function createBundle(
@@ -186,6 +185,40 @@ contract BundleService is
186
185
  linkPolicy(instance, policyNftId);
187
186
  }
188
187
 
188
+ function increaseBalance(IInstance instance,
189
+ NftId bundleNftId,
190
+ uint256 amount
191
+ )
192
+ external
193
+ onlyService
194
+ {
195
+ InstanceReader instanceReader = instance.getInstanceReader();
196
+ IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
197
+
198
+ bundleInfo.balanceAmount += amount;
199
+
200
+ instance.updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
201
+ }
202
+
203
+ function closePolicy(IInstance instance,
204
+ NftId policyNftId,
205
+ NftId bundleNftId,
206
+ uint256 collateralAmount
207
+ )
208
+ external
209
+ onlyService
210
+ {
211
+ InstanceReader instanceReader = instance.getInstanceReader();
212
+ IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
213
+
214
+ // lock collateral
215
+ bundleInfo.lockedAmount -= collateralAmount;
216
+
217
+ instance.updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
218
+
219
+ unlinkPolicy(instance, policyNftId);
220
+ }
221
+
189
222
  /// @dev links policy to bundle
190
223
  function linkPolicy(IInstance instance, NftId policyNftId)
191
224
  internal
@@ -219,8 +252,8 @@ contract BundleService is
219
252
  }
220
253
 
221
254
  // ensure policy is closeable
222
- if (policyInfo.expiredAt < TimestampLib.blockTimestamp()
223
- || policyInfo.payoutAmount < policyInfo.sumInsuredAmount)
255
+ if ( TimestampLib.blockTimestamp() < policyInfo.expiredAt
256
+ && policyInfo.payoutAmount < policyInfo.sumInsuredAmount)
224
257
  {
225
258
  revert BundleManager.ErrorBundleManagerPolicyNotCloseable(policyNftId);
226
259
  }
@@ -6,7 +6,7 @@ import {ProxyManager} from "../../shared/ProxyManager.sol";
6
6
  import {BundleService} from "./BundleService.sol";
7
7
  import {Registry} from "../../registry/Registry.sol";
8
8
  import {RegistryService} from "../../registry/RegistryService.sol";
9
- import {VersionLib} from "../../types/Version.sol";
9
+ import {ObjectType, REGISTRY} from "../../types/ObjectType.sol";
10
10
 
11
11
  contract BundleServiceManager is ProxyManager {
12
12
 
@@ -26,10 +26,10 @@ contract BundleServiceManager is ProxyManager {
26
26
 
27
27
  _bundleService = BundleService(address(versionable));
28
28
 
29
- Registry registry = Registry(registryAddress);
30
- address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
31
- RegistryService registryService = RegistryService(registryServiceAddress);
32
- // 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(), _bundleService.getMajorVersion());
32
+ //RegistryService registryService = RegistryService(registryServiceAddress);
33
33
  //registryService.registerService(_poolService);
34
34
 
35
35
  // TODO no nft to link yet
@@ -37,9 +37,6 @@ contract BundleServiceManager is ProxyManager {
37
37
  //_linkToNftOwnable(
38
38
  // address(registryAddress),
39
39
  // address(_poolService));
40
-
41
- // implies that after this constructor call only upgrade functionality is available
42
- _isDeployed = true;
43
40
  }
44
41
 
45
42
  //--- view functions ----------------------------------------------------//
@@ -2,17 +2,16 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
- import {IRegistryService} from "../../registry/IRegistryService.sol";
6
5
  import {IInstance} from "../../instance/IInstance.sol";
6
+ import {InstanceAccessManager} from "../InstanceAccessManager.sol";
7
7
  import {InstanceReader} from "../../instance/InstanceReader.sol";
8
8
  import {ISetup} from "../../instance/module/ISetup.sol";
9
- import {ITreasury} from "../../instance/module/ITreasury.sol";
10
9
 
11
10
  import {NftId, NftIdLib} from "../../types/NftId.sol";
12
11
  import {Fee} from "../../types/Fee.sol";
13
12
  import {DISTRIBUTION_OWNER_ROLE} from "../../types/RoleId.sol";
14
13
  import {KEEP_STATE} from "../../types/StateId.sol";
15
- import {DISTRIBUTION} from "../../types/ObjectType.sol";
14
+ import {ObjectType, DISTRIBUTION} from "../../types/ObjectType.sol";
16
15
  import {Version, VersionLib} from "../../types/Version.sol";
17
16
 
18
17
  import {IVersionable} from "../../shared/IVersionable.sol";
@@ -20,24 +19,18 @@ import {Versionable} from "../../shared/Versionable.sol";
20
19
 
21
20
  import {IService} from "../../shared/IService.sol";
22
21
  import {Service} from "../../shared/Service.sol";
23
- import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
24
- import {IDistributionService} from "./IDistributionService.sol";
25
- import {Distribution} from "../../components/Distribution.sol";
22
+ import {ComponentService} from "../base/ComponentService.sol";
26
23
  import {InstanceService} from "../InstanceService.sol";
27
- import {Instance} from "../Instance.sol";
28
- import {INftOwnable} from "../../shared/INftOwnable.sol";
29
- import {IBaseComponent} from "../../components/IBaseComponent.sol";
24
+ import {IDistributionService} from "./IDistributionService.sol";
25
+ import {IComponent} from "../../components/IComponent.sol";
30
26
 
31
- string constant DISTRIBUTION_SERVICE_NAME = "DistributionService";
32
27
 
33
28
  contract DistributionService is
34
- ComponentServiceBase,
29
+ ComponentService,
35
30
  IDistributionService
36
31
  {
37
32
  using NftIdLib for NftId;
38
33
 
39
- string public constant NAME = "DistributionService";
40
-
41
34
  address internal _registryAddress;
42
35
 
43
36
  function _initialize(
@@ -58,43 +51,47 @@ contract DistributionService is
58
51
  _registerInterface(type(IDistributionService).interfaceId);
59
52
  }
60
53
 
61
-
62
- function getName() public pure override(IService, Service) returns(string memory name) {
63
- return NAME;
54
+ function getDomain() public pure override(Service, IService) returns(ObjectType) {
55
+ return DISTRIBUTION();
64
56
  }
65
57
 
66
58
  function register(address distributionAddress)
67
59
  external
68
60
  returns(NftId distributionNftId)
69
61
  {
70
- address distributionOwner = msg.sender;
71
- IBaseComponent distribution = IBaseComponent(distributionAddress);
72
-
73
- IRegistry.ObjectInfo memory info;
74
- bytes memory data;
75
- (info, data) = getRegistryService().registerDistribution(distribution, distributionOwner);
76
-
77
- IInstance instance = _getInstance(info);
78
-
79
- bool hasRole = getInstanceService().hasRole(
80
- distributionOwner,
81
- DISTRIBUTION_OWNER_ROLE(),
82
- address(instance));
83
-
84
- if(!hasRole) {
85
- revert ExpectedRoleMissing(DISTRIBUTION_OWNER_ROLE(), distributionOwner);
86
- }
87
-
88
- distributionNftId = info.nftId;
89
- ISetup.DistributionSetupInfo memory initialSetup = _decodeAndVerifyDistributionSetup(data);
62
+ (
63
+ IComponent distribution,
64
+ address owner,
65
+ IInstance instance,
66
+ NftId instanceNftId
67
+ ) = _checkComponentForRegistration(
68
+ distributionAddress,
69
+ DISTRIBUTION(),
70
+ DISTRIBUTION_OWNER_ROLE());
71
+
72
+ (
73
+ IRegistry.ObjectInfo memory distributionInfo,
74
+ bytes memory data
75
+ ) = getRegistryService().registerDistribution(distribution, owner);
76
+ distribution.linkToRegisteredNftId();
77
+ distributionNftId = distributionInfo.nftId;
78
+
79
+ (
80
+ string memory name,
81
+ ISetup.DistributionSetupInfo memory initialSetup
82
+ ) = _decodeAndVerifyDistributionData(data);
90
83
  instance.createDistributionSetup(distributionNftId, initialSetup);
84
+
85
+ getInstanceService().createTarget(instanceNftId, distributionAddress, name);
91
86
  }
92
87
 
93
- function _decodeAndVerifyDistributionSetup(bytes memory data) internal returns(ISetup.DistributionSetupInfo memory setup)
88
+ function _decodeAndVerifyDistributionData(bytes memory data)
89
+ internal
90
+ returns(string memory name, ISetup.DistributionSetupInfo memory setup)
94
91
  {
95
- setup = abi.decode(
92
+ (name, setup) = abi.decode(
96
93
  data,
97
- (ISetup.DistributionSetupInfo)
94
+ (string, ISetup.DistributionSetupInfo)
98
95
  );
99
96
 
100
97
  // TODO add checks if applicable
@@ -6,7 +6,7 @@ import {ProxyManager} from "../../shared/ProxyManager.sol";
6
6
  import {DistributionService} from "./DistributionService.sol";
7
7
  import {Registry} from "../../registry/Registry.sol";
8
8
  import {RegistryService} from "../../registry/RegistryService.sol";
9
- import {VersionLib} from "../../types/Version.sol";
9
+ import {REGISTRY} from "../../types/ObjectType.sol";
10
10
 
11
11
  contract DistributionServiceManager is ProxyManager {
12
12
 
@@ -25,11 +25,11 @@ contract DistributionServiceManager is ProxyManager {
25
25
  data);
26
26
 
27
27
  _distributionService = DistributionService(address(versionable));
28
-
29
- Registry registry = Registry(registryAddress);
30
- address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
31
- RegistryService registryService = RegistryService(registryServiceAddress);
32
- // TODO this must have a role or own nft to register service
28
+
29
+ // TODO `thi` must have a role or own nft to register service
30
+ //Registry registry = Registry(registryAddress);
31
+ //address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _distributionService.getMajorVersion());
32
+ //RegistryService registryService = RegistryService(registryServiceAddress);
33
33
  //registryService.registerService(_distributionService);
34
34
 
35
35
  // TODO no nft to link yet
@@ -37,9 +37,6 @@ contract DistributionServiceManager is ProxyManager {
37
37
  //_linkToNftOwnable(
38
38
  // address(registryAddress),
39
39
  // address(_distributionService));
40
-
41
- // implies that after this constructor call only upgrade functionality is available
42
- _isDeployed = true;
43
40
  }
44
41
 
45
42
  //--- view functions ----------------------------------------------------//
@@ -26,12 +26,11 @@ interface IBundleService is IService {
26
26
 
27
27
  function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
28
28
 
29
- function underwritePolicy(IInstance instanceNftId,
30
- NftId policyNftId,
31
- NftId bundleNftId,
32
- uint256 collateralAmount,
33
- uint256 netPremium
34
- ) external;
29
+ function underwritePolicy(IInstance instanceNftId, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount, uint256 netPremium) external;
30
+
31
+ function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
32
+
33
+ function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
35
34
 
36
35
  // function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
37
36
 
@@ -15,6 +15,13 @@ import {Fee} from "../../types/Fee.sol";
15
15
  interface IPolicyService is IService {
16
16
 
17
17
  error ErrorIPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
18
+ error ErrorIPolicyServicePremiumAlreadyPaid(NftId policyNftId, uint256 premiumPaidAmount);
19
+ error ErrorIPolicyServicePolicyNotActivated(NftId policyNftId);
20
+ error ErrorIPolicyServicePolicyAlreadyClosed(NftId policyNftId);
21
+ error ErrorIPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
22
+ error ErrorIPolicyServicePremiumNotFullyPaid(NftId policyNftId, uint256 premiumAmount, uint256 premiumPaidAmount);
23
+ error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
24
+ error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
18
25
 
19
26
  function calculatePremium(
20
27
  RiskId riskId,