@etherisc/gif-next 0.0.2-e545d2c-624 → 0.0.2-e5a2253-213

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 (178) hide show
  1. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +11 -0
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +11 -0
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +11 -0
  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 +11 -0
  13. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  14. package/artifacts/contracts/components/Product.sol/Product.json +16 -5
  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 +0 -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/Instance.sol/Instance.dbg.json +1 -1
  44. package/artifacts/contracts/instance/Instance.sol/Instance.json +56 -69
  45. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  46. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +2 -2
  48. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +2 -2
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
  54. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  56. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +90 -0
  58. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -13
  60. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +92 -2
  73. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +2 -2
  75. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +114 -16
  77. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -9
  79. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +92 -2
  86. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +2 -2
  88. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +114 -16
  90. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -9
  92. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +114 -16
  94. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -9
  96. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  97. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  98. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  99. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  100. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  101. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  102. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  103. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  104. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  105. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
  106. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  107. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
  108. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  109. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +2 -2
  110. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  111. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  112. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  113. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  114. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  115. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  116. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  117. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  118. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  119. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  120. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  122. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  124. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  125. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  126. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  127. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  128. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  129. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  130. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  131. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  132. package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
  133. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  134. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  135. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  136. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  137. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  138. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  139. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  140. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  141. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  142. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  143. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  144. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  145. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  146. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  147. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  148. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  156. package/contracts/components/BaseComponent.sol +15 -6
  157. package/contracts/components/Distribution.sol +0 -10
  158. package/contracts/components/IBaseComponent.sol +3 -2
  159. package/contracts/components/IProductComponent.sol +2 -2
  160. package/contracts/components/Pool.sol +3 -17
  161. package/contracts/components/Product.sol +5 -11
  162. package/contracts/instance/IInstance.sol +0 -2
  163. package/contracts/instance/IInstanceBase.sol +0 -1
  164. package/contracts/instance/Instance.sol +2 -12
  165. package/contracts/instance/InstanceBase.sol +0 -2
  166. package/contracts/instance/base/ComponentServiceBase.sol +62 -0
  167. package/contracts/instance/base/IInstanceBase.sol +0 -2
  168. package/contracts/instance/service/DistributionService.sol +22 -27
  169. package/contracts/instance/service/PoolService.sol +21 -24
  170. package/contracts/instance/service/ProductService.sol +20 -24
  171. package/contracts/shared/IRegisterable.sol +0 -2
  172. package/package.json +1 -1
  173. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  174. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
  175. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  176. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  177. package/contracts/instance/service/ComponentOwnerService.sol +0 -315
  178. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
@@ -8,7 +8,6 @@ import {BundleManager} from "./BundleManager.sol";
8
8
  import {InstanceReader} from "./InstanceReader.sol";
9
9
 
10
10
  import {InstanceAccessManager} from "./InstanceAccessManager.sol";
11
- import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
12
11
  import {IDistributionService} from "./service/IDistributionService.sol";
13
12
  import {IPoolService} from "./service/IPoolService.sol";
14
13
  import {IProductService} from "./service/IProductService.sol";
@@ -26,7 +25,6 @@ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
26
25
 
27
26
  interface IInstance is IERC165, IKeyValueStore, IAccessManaged {
28
27
 
29
- function getComponentOwnerService() external view returns (IComponentOwnerService);
30
28
  function getDistributionService() external view returns (IDistributionService);
31
29
  function getProductService() external view returns (IProductService);
32
30
  function getPoolService() external view returns (IPoolService);
@@ -6,7 +6,6 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
6
  import {BundleManager} from "./BundleManager.sol";
7
7
  import {InstanceReader} from "./InstanceReader.sol";
8
8
 
9
- import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
10
9
  import {IDistributionService} from "./service/IDistributionService.sol";
11
10
  import {IPoolService} from "./service/IPoolService.sol";
12
11
  import {IProductService} from "./service/IProductService.sol";
@@ -20,14 +20,8 @@ import {BundleManager} from "./BundleManager.sol";
20
20
  import {NftId} from "../types/NftId.sol";
21
21
  import {NumberId} from "../types/NumberId.sol";
22
22
  import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT} from "../types/ObjectType.sol";
23
- import {RiskId, RiskIdLib} from "../types/RiskId.sol";
24
- import {RoleId, RoleIdLib} from "../types/RoleId.sol";
25
- import {StateId, ACTIVE} from "../types/StateId.sol";
26
- import {TimestampLib} from "../types/Timestamp.sol";
27
- import {ERC165} from "../shared/ERC165.sol";
28
- import {Registerable} from "../shared/Registerable.sol";
29
- import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
30
- import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
23
+ import {RiskId} from "../types/RiskId.sol";
24
+ import {StateId} from "../types/StateId.sol";
31
25
  import {IDistributionService} from "./service/IDistributionService.sol";
32
26
  import {IPoolService} from "./service/IPoolService.sol";
33
27
  import {IProductService} from "./service/IProductService.sol";
@@ -227,10 +221,6 @@ contract Instance is
227
221
  return policyNftId.toKey32(POLICY());
228
222
  }
229
223
 
230
- function getComponentOwnerService() external view returns (IComponentOwnerService) {
231
- return ComponentOwnerService(_registry.getServiceAddress(COMPONENT(), VersionPart.wrap(3)));
232
- }
233
-
234
224
  function getDistributionService() external view returns (IDistributionService) {
235
225
  return IDistributionService(_registry.getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
236
226
  }
@@ -22,8 +22,6 @@ import {RoleId, RoleIdLib} from "../types/RoleId.sol";
22
22
  import {StateId, ACTIVE} from "../types/StateId.sol";
23
23
  import {ERC165} from "../shared/ERC165.sol";
24
24
  import {Registerable} from "../shared/Registerable.sol";
25
- import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
26
- import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
27
25
  import {IDistributionService} from "./service/IDistributionService.sol";
28
26
  import {IPoolService} from "./service/IPoolService.sol";
29
27
  import {IProductService} from "./service/IProductService.sol";
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {IBaseComponent} from "../../components/IBaseComponent.sol";
4
5
  import {IRegistry} from "../../registry/IRegistry.sol";
5
6
  import {IRegistryService} from "../../registry/IRegistryService.sol";
6
7
  import {IInstance} from "../../instance/IInstance.sol";
@@ -15,6 +16,13 @@ import {InstanceAccessManager} from "../InstanceAccessManager.sol";
15
16
 
16
17
  abstract contract ComponentServiceBase is Service {
17
18
 
19
+
20
+ error ErrorComponentServiceAlreadyRegistered(address component, NftId nftId);
21
+ error ErrorComponentServiceNotComponent(address component);
22
+ error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
23
+ error ErrorComponentServiceSenderNotOwner(address component, address initialOwner, address sender);
24
+ error ErrorComponentServiceExpectedRoleMissing(NftId instanceNftId, RoleId requiredRole, address sender);
25
+
18
26
  error ErrorComponentServiceBaseComponentLocked(address componentAddress);
19
27
  error ExpectedRoleMissing(RoleId expected, address caller);
20
28
  error ComponentTypeInvalid(ObjectType componentType);
@@ -39,6 +47,60 @@ abstract contract ComponentServiceBase is Service {
39
47
  return InstanceService(service);
40
48
  }
41
49
 
50
+ // internal functions
51
+ function _checkComponentForRegistration(
52
+ address componentAddress,
53
+ ObjectType requiredType,
54
+ RoleId requiredRole
55
+ )
56
+ internal
57
+ returns (
58
+ IBaseComponent component,
59
+ address owner,
60
+ IInstance instance,
61
+ NftId instanceNftId
62
+ )
63
+ {
64
+ // component may only be registerd by initial owner of component
65
+ owner = msg.sender;
66
+
67
+ // check component has not already been registerd
68
+ NftId compoentNftId = _registry.getNftId(componentAddress);
69
+ if(compoentNftId.gtz()) {
70
+ revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
71
+ }
72
+
73
+ // check this is a component
74
+ component = IBaseComponent(componentAddress);
75
+ if(!component.supportsInterface(type(IBaseComponent).interfaceId)) {
76
+ revert ErrorComponentServiceNotComponent(componentAddress);
77
+ }
78
+
79
+ // check component is of required type
80
+ (IRegistry.ObjectInfo memory componentInfo, ) = component.getInitialInfo();
81
+ if(componentInfo.objectType != requiredType) {
82
+ revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
83
+ }
84
+
85
+ // check msg.sender is component owner
86
+ address initialOwner = componentInfo.initialOwner;
87
+ if(owner != initialOwner) {
88
+ revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
89
+ }
90
+
91
+ // check instance has assigned required role to owner
92
+ instanceNftId = componentInfo.parentNftId;
93
+ instance = _getInstance(instanceNftId);
94
+ bool hasRole = getInstanceService().hasRole(
95
+ owner,
96
+ requiredRole,
97
+ address(instance));
98
+
99
+ if(!hasRole) {
100
+ revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
101
+ }
102
+ }
103
+
42
104
  // internal view functions
43
105
 
44
106
  function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
@@ -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);
@@ -59,35 +59,30 @@ contract DistributionService is
59
59
  external
60
60
  returns(NftId distributionNftId)
61
61
  {
62
- address distributionOwner = msg.sender;
63
- IBaseComponent distribution = IBaseComponent(distributionAddress);
64
-
65
- IRegistry.ObjectInfo memory info;
66
- bytes memory data;
67
- (info, data) = getRegistryService().registerDistribution(distribution, distributionOwner);
68
-
69
- NftId instanceNftId = info.parentNftId;
70
- IInstance instance = _getInstance(instanceNftId);
71
- InstanceService instanceService = getInstanceService();
72
-
73
- bool hasRole = instanceService.hasRole(
74
- distributionOwner,
75
- DISTRIBUTION_OWNER_ROLE(),
76
- address(instance));
77
-
78
- if(!hasRole) {
79
- revert ExpectedRoleMissing(DISTRIBUTION_OWNER_ROLE(), distributionOwner);
80
- }
81
-
82
- distributionNftId = info.nftId;
83
- string memory distributionName;
84
- ISetup.DistributionSetupInfo memory initialSetup;
85
- (distributionName, initialSetup) = _decodeAndVerifyDistributionData(data);
86
- instance.createDistributionSetup(distributionNftId, initialSetup);
62
+ (
63
+ IBaseComponent 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;
87
78
 
88
- instanceService.createTarget(instanceNftId, distributionAddress, distributionName);
79
+ (
80
+ string memory name,
81
+ ISetup.DistributionSetupInfo memory initialSetup
82
+ ) = _decodeAndVerifyDistributionData(data);
83
+ instance.createDistributionSetup(distributionNftId, initialSetup);
89
84
 
90
- distribution.linkToRegisteredNftId();
85
+ getInstanceService().createTarget(instanceNftId, distributionAddress, name);
91
86
  }
92
87
 
93
88
  function _decodeAndVerifyDistributionData(bytes memory data)
@@ -67,33 +67,30 @@ contract PoolService is
67
67
  external
68
68
  returns(NftId poolNftId)
69
69
  {
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
- }
70
+ (
71
+ IBaseComponent 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;
87
86
 
88
- poolNftId = info.nftId;
89
- string memory poolName;
90
- ISetup.PoolSetupInfo memory initialSetup;
91
- (poolName, initialSetup) = _decodeAndVerifyPoolData(data);
87
+ (
88
+ string memory name,
89
+ ISetup.PoolSetupInfo memory initialSetup
90
+ ) = _decodeAndVerifyPoolData(data);
92
91
  instance.createPoolSetup(poolNftId, initialSetup);
93
92
 
94
- getInstanceService().createTarget(instanceNftId, poolAddress, poolName);
95
-
96
- pool.linkToRegisteredNftId();
93
+ getInstanceService().createTarget(instanceNftId, poolAddress, name);
97
94
  }
98
95
 
99
96
  function _decodeAndVerifyPoolData(bytes memory data)
@@ -76,34 +76,30 @@ contract ProductService is ComponentServiceBase, IProductService {
76
76
  external
77
77
  returns(NftId productNftId)
78
78
  {
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));
92
-
93
- if(!hasRole) {
94
- revert ExpectedRoleMissing(PRODUCT_OWNER_ROLE(), productOwner);
95
- }
79
+ (
80
+ IBaseComponent product,
81
+ address productOwner,
82
+ IInstance instance,
83
+ NftId instanceNftId
84
+ ) = _checkComponentForRegistration(
85
+ productAddress,
86
+ PRODUCT(),
87
+ PRODUCT_OWNER_ROLE());
96
88
 
97
- productNftId = info.nftId;
98
- string memory productName;
99
- ISetup.ProductSetupInfo memory initialSetup;
100
- (productName, initialSetup) = _decodeAndVerifyProductData(data);
89
+ (
90
+ IRegistry.ObjectInfo memory productInfo,
91
+ bytes memory data
92
+ ) = getRegistryService().registerProduct(product, productOwner);
93
+ product.linkToRegisteredNftId();
94
+ productNftId = productInfo.nftId;
101
95
 
96
+ (
97
+ string memory name,
98
+ ISetup.ProductSetupInfo memory initialSetup
99
+ ) = _decodeAndVerifyProductData(data);
102
100
  instance.createProductSetup(productNftId, initialSetup);
103
101
 
104
- getInstanceService().createTarget(instanceNftId, productAddress, productName);
105
-
106
- product.linkToRegisteredNftId();
102
+ getInstanceService().createTarget(instanceNftId, productAddress, name);
107
103
  }
108
104
 
109
105
  function _decodeAndVerifyProductData(bytes memory data)
@@ -5,8 +5,6 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
 
6
6
  import {INftOwnable} from "./INftOwnable.sol";
7
7
  import {IRegistry} from "../registry/IRegistry.sol";
8
- import {NftId} from "../types/NftId.sol";
9
- import {ObjectType} from "../types/ObjectType.sol";
10
8
 
11
9
  interface IRegisterable is IERC165, INftOwnable {
12
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-e545d2c-624",
3
+ "version": "0.0.2-e5a2253-213",
4
4
  "description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/e5530b5c57be84d76caaa584abf46dd1.json"
4
- }