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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  2. package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → Component.sol/Component.json} +230 -14
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +141 -10
  5. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  6. package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +107 -87
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +543 -0
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +623 -45
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +643 -5
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +227 -73
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +146 -15
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
  39. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +181 -15
  42. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +0 -5
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +113 -76
  46. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  47. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +47 -60
  48. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +42 -83
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +59 -58
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +37 -24
  54. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
  56. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  57. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +102 -31
  58. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  60. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +229 -93
  71. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +31 -18
  73. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +126 -47
  75. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +31 -14
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +98 -38
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +0 -5
  81. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +0 -5
  83. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +0 -5
  85. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +0 -5
  87. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +153 -82
  89. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +44 -31
  91. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +126 -47
  93. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +31 -14
  95. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +126 -47
  97. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +31 -14
  99. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  101. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +83 -3
  102. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  103. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +33 -28
  104. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  105. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  106. package/artifacts/contracts/registry/Registry.sol/Registry.json +96 -24
  107. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  108. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
  109. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  110. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -56
  111. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  112. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +28 -15
  113. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  114. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -53
  115. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +23 -26
  117. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  118. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  119. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
  122. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IService.sol/IService.json +0 -5
  124. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
  127. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
  129. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
  131. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  132. package/artifacts/contracts/shared/Service.sol/Service.json +13 -5
  133. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  134. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  137. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
  139. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  141. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestService.sol/TestService.json +29 -21
  143. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  146. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  147. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  148. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  149. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  153. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  155. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  161. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  167. package/contracts/components/Component.sol +247 -0
  168. package/contracts/components/Distribution.sol +27 -48
  169. package/contracts/components/IComponent.sol +50 -0
  170. package/contracts/components/IDistributionComponent.sol +5 -2
  171. package/contracts/components/IPoolComponent.sol +40 -29
  172. package/contracts/components/IProductComponent.sol +7 -3
  173. package/contracts/components/Pool.sol +123 -138
  174. package/contracts/components/Product.sol +48 -86
  175. package/contracts/instance/BundleManager.sol +7 -11
  176. package/contracts/instance/IInstance.sol +20 -10
  177. package/contracts/instance/IInstanceService.sol +1 -1
  178. package/contracts/instance/Instance.sol +28 -31
  179. package/contracts/instance/InstanceAccessManager.sol +6 -11
  180. package/contracts/instance/InstanceReader.sol +3 -25
  181. package/contracts/instance/InstanceService.sol +31 -14
  182. package/contracts/instance/ObjectManager.sol +7 -24
  183. package/contracts/instance/base/ComponentService.sol +134 -0
  184. package/contracts/instance/module/ISetup.sol +2 -2
  185. package/contracts/instance/service/BundleService.sol +11 -6
  186. package/contracts/instance/service/DistributionService.sol +22 -36
  187. package/contracts/instance/service/IBundleService.sol +11 -1
  188. package/contracts/instance/service/PolicyService.sol +56 -76
  189. package/contracts/instance/service/PoolService.sol +19 -55
  190. package/contracts/instance/service/ProductService.sol +49 -30
  191. package/contracts/registry/IRegistry.sol +13 -6
  192. package/contracts/registry/IRegistryService.sol +16 -9
  193. package/contracts/registry/Registry.sol +100 -44
  194. package/contracts/registry/RegistryAccessManager.sol +31 -25
  195. package/contracts/registry/RegistryService.sol +27 -85
  196. package/contracts/registry/ReleaseManager.sol +72 -82
  197. package/contracts/registry/TokenRegistry.sol +5 -3
  198. package/contracts/shared/IRegisterable.sol +1 -3
  199. package/contracts/shared/NftOwnable.sol +5 -0
  200. package/contracts/shared/Registerable.sol +10 -14
  201. package/contracts/shared/Service.sol +4 -2
  202. package/contracts/types/RoleId.sol +2 -2
  203. package/package.json +1 -1
  204. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  205. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  206. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  207. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  208. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  209. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
  210. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  211. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
  212. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  213. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  214. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  215. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  216. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
  217. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  218. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  219. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  220. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
  221. package/contracts/components/BaseComponent.sol +0 -159
  222. package/contracts/components/IBaseComponent.sol +0 -34
  223. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
  224. package/contracts/instance/IInstanceBase.sol +0 -26
  225. package/contracts/instance/InstanceBase.sol +0 -41
  226. package/contracts/instance/base/ComponentServiceBase.sol +0 -76
  227. package/contracts/instance/base/IInstanceBase.sol +0 -23
  228. package/contracts/instance/service/ComponentOwnerService.sol +0 -315
  229. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  230. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -10,7 +10,7 @@ import {IInstanceService} from "./IInstanceService.sol";
10
10
  import {InstanceReader} from "./InstanceReader.sol";
11
11
  import {BundleManager} from "./BundleManager.sol";
12
12
  import {IRegistry} from "../registry/IRegistry.sol";
13
- import {RegistryService} from "../registry/RegistryService.sol";
13
+ import {IRegistryService} from "../registry/IRegistryService.sol";
14
14
  import {ChainNft} from "../registry/ChainNft.sol";
15
15
  import {Service} from "../../contracts/shared/Service.sol";
16
16
  import {IService} from "../shared/IService.sol";
@@ -28,7 +28,6 @@ contract InstanceService is Service, IInstanceService {
28
28
 
29
29
  // TODO update to real hash when instance is stable
30
30
  bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
31
- string public constant NAME = "InstanceService";
32
31
 
33
32
  modifier onlyInstanceOwner(NftId instanceNftId) {
34
33
  IRegistry registry = getRegistry();
@@ -63,25 +62,23 @@ contract InstanceService is Service, IInstanceService {
63
62
  address registryAddress = address(registry);
64
63
  NftId registryNftId = registry.getNftId(registryAddress);
65
64
  address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getMajorVersion());
66
- RegistryService registryService = RegistryService(registryServiceAddress);
65
+ IRegistryService registryService = IRegistryService(registryServiceAddress);
67
66
 
68
67
  // initially set the authority of the access managar to this (being the instance service).
69
68
  // This will allow the instance service to bootstrap the authorizations of the instance
70
69
  // and then transfer the ownership of the access manager to the instance owner once everything is setup
71
70
  clonedAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
72
- clonedAccessManager.__InstanceAccessManager_initialize(address(this));
71
+ clonedAccessManager.initialize(address(this));
73
72
 
74
73
  clonedInstance = Instance(Clones.clone(_masterInstance));
75
74
  clonedInstance.initialize(address(clonedAccessManager), registryAddress, registryNftId, msg.sender);
76
- ( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
77
- clonedInstanceNftId = info.nftId;
78
75
 
79
76
  clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
80
- clonedInstanceReader.initialize(registryAddress, clonedInstanceNftId);
77
+ clonedInstanceReader.initialize(registryAddress, address(clonedInstance));
81
78
  clonedInstance.setInstanceReader(clonedInstanceReader);
82
79
 
83
80
  clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
84
- clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, clonedInstanceNftId);
81
+ clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, address(clonedInstance));
85
82
  clonedInstance.setBundleManager(clonedBundleManager);
86
83
 
87
84
  // TODO amend setters with instance specific , policy manager ...
@@ -93,6 +90,10 @@ contract InstanceService is Service, IInstanceService {
93
90
  clonedAccessManager.grantRole(ADMIN_ROLE(), instanceOwner);
94
91
  clonedAccessManager.revokeRole(ADMIN_ROLE(), address(this));
95
92
 
93
+ IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
94
+ clonedInstanceNftId = info.nftId;
95
+ // clonedInstance.linkToRegisteredNftId();
96
+
96
97
  emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
97
98
  }
98
99
 
@@ -219,7 +220,15 @@ contract InstanceService is Service, IInstanceService {
219
220
  INSTANCE_SERVICE_ROLE());
220
221
  }
221
222
 
222
- function setMasterInstance(address accessManagerAddress, address instanceAddress, address instanceReaderAddress, address bundleManagerAddress) external onlyOwner {
223
+ function setAndRegisterMasterInstance(
224
+ address accessManagerAddress,
225
+ address instanceAddress,
226
+ address instanceReaderAddress,
227
+ address bundleManagerAddress)
228
+ external
229
+ onlyOwner
230
+ returns(NftId masterInstanceNftId)
231
+ {
223
232
  require(_masterInstanceAccessManager == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
224
233
  require(_masterInstance == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
225
234
  require(_masterInstanceBundleManager == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
@@ -229,18 +238,25 @@ contract InstanceService is Service, IInstanceService {
229
238
  require (instanceReaderAddress != address(0), "ERROR:CRD-007:INSTANCE_READER_ZERO");
230
239
  require (bundleManagerAddress != address(0), "ERROR:CRD-008:BUNDLE_MANAGER_ZERO");
231
240
 
232
- Instance instance = Instance(instanceAddress);
241
+ IInstance instance = IInstance(instanceAddress);
233
242
  InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
234
243
  BundleManager bundleManager = BundleManager(bundleManagerAddress);
235
244
 
236
245
  require(instance.authority() == accessManagerAddress, "ERROR:CRD-009:INSTANCE_AUTHORITY_MISMATCH");
237
- require(instanceReader.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-010:INSTANCE_READER_INSTANCE_MISMATCH");
238
- require(bundleManager.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-011:BUNDLE_MANAGER_INSTANCE_MISMATCH");
246
+ require(instanceReader.getInstance() == instance, "ERROR:CRD-010:INSTANCE_READER_INSTANCE_MISMATCH");
247
+ require(bundleManager.getInstance() == instance, "ERROR:CRD-011:BUNDLE_MANAGER_INSTANCE_MISMATCH");
239
248
 
240
249
  _masterInstanceAccessManager = accessManagerAddress;
241
250
  _masterInstance = instanceAddress;
242
251
  _masterInstanceReader = instanceReaderAddress;
243
252
  _masterInstanceBundleManager = bundleManagerAddress;
253
+
254
+ IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(), getMajorVersion()));
255
+ IInstance masterInstance = IInstance(_masterInstance);
256
+ IRegistry.ObjectInfo memory info = registryService.registerInstance(masterInstance, getOwner());
257
+ masterInstanceNftId = info.nftId;
258
+
259
+ // masterInstance.linkToRegisteredNftId();
244
260
  }
245
261
 
246
262
  function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
@@ -249,11 +265,12 @@ contract InstanceService is Service, IInstanceService {
249
265
  require(instanceReaderAddress != _masterInstanceReader, "ERROR:CRD-014:INSTANCE_READER_MASTER_SAME_AS_NEW");
250
266
 
251
267
  InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
252
- require(instanceReader.getInstanceNftId() == Instance(_masterInstance).getNftId(), "ERROR:CRD-015:INSTANCE_READER_INSTANCE_MISMATCH");
268
+ require(instanceReader.getInstance() == IInstance(_masterInstance), "ERROR:CRD-015:INSTANCE_READER_INSTANCE_MISMATCH");
253
269
 
254
270
  _masterInstanceReader = instanceReaderAddress;
255
271
  }
256
272
 
273
+ // TODO access restriction
257
274
  function upgradeInstanceReader(NftId instanceNftId) external {
258
275
  IRegistry registry = getRegistry();
259
276
  IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
@@ -265,7 +282,7 @@ contract InstanceService is Service, IInstanceService {
265
282
  }
266
283
 
267
284
  InstanceReader upgradedInstanceReaderClone = InstanceReader(Clones.clone(address(_masterInstanceReader)));
268
- upgradedInstanceReaderClone.initialize(address(registry), instanceNftId);
285
+ upgradedInstanceReaderClone.initialize(address(registry), address(instance));
269
286
  instance.setInstanceReader(upgradedInstanceReaderClone);
270
287
  }
271
288
 
@@ -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,134 @@
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
+ view
53
+ returns (
54
+ IComponent component,
55
+ address owner,
56
+ IInstance instance,
57
+ NftId instanceNftId
58
+ )
59
+ {
60
+ // component may only be registerd by initial owner of component
61
+ owner = msg.sender;
62
+
63
+ // check component has not already been registerd
64
+ NftId compoentNftId = _registry.getNftId(componentAddress);
65
+ if(compoentNftId.gtz()) {
66
+ revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
67
+ }
68
+
69
+ // check this is a component
70
+ component = IComponent(componentAddress);
71
+ if(!component.supportsInterface(type(IComponent).interfaceId)) {
72
+ revert ErrorComponentServiceNotComponent(componentAddress);
73
+ }
74
+
75
+ // check component is of required type
76
+ IRegistry.ObjectInfo memory componentInfo = component.getInitialInfo();
77
+ if(componentInfo.objectType != requiredType) {
78
+ revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
79
+ }
80
+
81
+ // check msg.sender is component owner
82
+ address initialOwner = componentInfo.initialOwner;
83
+ if(owner != initialOwner) {
84
+ revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
85
+ }
86
+
87
+ // check instance has assigned required role to owner
88
+ instanceNftId = componentInfo.parentNftId;
89
+ instance = _getInstance(instanceNftId);
90
+ bool hasRole = getInstanceService().hasRole(
91
+ owner,
92
+ requiredRole,
93
+ address(instance));
94
+
95
+ if(!hasRole) {
96
+ revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
97
+ }
98
+ }
99
+
100
+ // internal view functions
101
+
102
+ function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
103
+ IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
104
+ return IInstance(instanceInfo.objectAddress);
105
+ }
106
+
107
+ function _getAndVerifyComponentInfoAndInstance(
108
+ //address component,
109
+ ObjectType expectedType
110
+ )
111
+ internal
112
+ view
113
+ returns(
114
+ IRegistry.ObjectInfo memory info,
115
+ IInstance instance
116
+ )
117
+ {
118
+ IRegistry registry = getRegistry();
119
+ //TODO redundant check -> just check type
120
+ //NftId componentNftId = registry.getNftId(component);
121
+ //require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
122
+
123
+ info = registry.getObjectInfo(msg.sender);
124
+ require(info.objectType == expectedType, "OBJECT_TYPE_INVALID");
125
+
126
+ address instanceAddress = registry.getObjectInfo(info.parentNftId).objectAddress;
127
+ instance = IInstance(instanceAddress);
128
+
129
+ InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
130
+ if (accessManager.isTargetLocked(info.objectAddress)) {
131
+ revert IAccess.ErrorIAccessTargetLocked(info.objectAddress);
132
+ }
133
+ }
134
+ }
@@ -39,8 +39,8 @@ interface ISetup {
39
39
  Fee poolFee; // pool fee on net premium
40
40
  Fee stakingFee; // pool fee on staked capital from investor
41
41
  Fee performanceFee; // pool fee on profits from capital investors
42
- bool isIntercepting; // intercepts nft transfers (for bundles)
43
- bool isConfirmingApplication; // confirms applications before they are underwritten
42
+ bool isIntercepting; // intercepts nft transfers for bundles
43
+ bool isVerifyingApplications; // confirms applications before they are underwritten
44
44
  address wallet;
45
45
  }
46
46
  }
@@ -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;
@@ -165,17 +164,23 @@ contract BundleService is
165
164
  bundleManager.unlock(bundleNftId);
166
165
  }
167
166
 
168
- function underwritePolicy(IInstance instance,
167
+ function lockCollateral(
168
+ IInstance instance,
169
169
  NftId policyNftId,
170
170
  NftId bundleNftId,
171
171
  uint256 collateralAmount,
172
172
  uint256 netPremiumAmount
173
173
  )
174
174
  external
175
- onlyService
175
+ onlyService
176
+ returns (
177
+ IBundle.BundleInfo memory bundleInfo
178
+ )
176
179
  {
177
180
  InstanceReader instanceReader = instance.getInstanceReader();
178
- IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
181
+ bundleInfo = instanceReader.getBundleInfo(bundleNftId);
182
+
183
+ // TODO add validation
179
184
 
180
185
  // lock collateral
181
186
  bundleInfo.lockedAmount += collateralAmount;
@@ -19,14 +19,15 @@ import {Versionable} from "../../shared/Versionable.sol";
19
19
 
20
20
  import {IService} from "../../shared/IService.sol";
21
21
  import {Service} from "../../shared/Service.sol";
22
- import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
22
+ import {ComponentService} from "../base/ComponentService.sol";
23
23
  import {InstanceService} from "../InstanceService.sol";
24
+ import {IComponent} from "../../components/IComponent.sol";
25
+ import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
24
26
  import {IDistributionService} from "./IDistributionService.sol";
25
- import {IBaseComponent} from "../../components/IBaseComponent.sol";
26
27
 
27
28
 
28
29
  contract DistributionService is
29
- ComponentServiceBase,
30
+ ComponentService,
30
31
  IDistributionService
31
32
  {
32
33
  using NftIdLib for NftId;
@@ -59,45 +60,30 @@ contract DistributionService is
59
60
  external
60
61
  returns(NftId distributionNftId)
61
62
  {
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);
87
-
88
- instanceService.createTarget(instanceNftId, distributionAddress, distributionName);
89
-
63
+ (
64
+ IComponent component,
65
+ address owner,
66
+ IInstance instance,
67
+ NftId instanceNftId
68
+ ) = _checkComponentForRegistration(
69
+ distributionAddress,
70
+ DISTRIBUTION(),
71
+ DISTRIBUTION_OWNER_ROLE());
72
+
73
+ IRegistry.ObjectInfo memory distributionInfo = getRegistryService().registerDistribution(component, owner);
74
+ IDistributionComponent distribution = IDistributionComponent(distributionAddress);
90
75
  distribution.linkToRegisteredNftId();
76
+ distributionNftId = distributionInfo.nftId;
77
+
78
+ instance.createDistributionSetup(distributionNftId, distribution.getSetupInfo());
79
+ getInstanceService().createTarget(instanceNftId, distributionAddress, distribution.getName());
91
80
  }
92
81
 
93
82
  function _decodeAndVerifyDistributionData(bytes memory data)
94
83
  internal
95
- returns(string memory name, ISetup.DistributionSetupInfo memory setup)
84
+ returns(string memory name)
96
85
  {
97
- (name, setup) = abi.decode(
98
- data,
99
- (string, ISetup.DistributionSetupInfo)
100
- );
86
+ (name) = abi.decode(data, (string));
101
87
 
102
88
  // TODO add checks if applicable
103
89
  }
@@ -26,7 +26,17 @@ 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, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount, uint256 netPremium) external;
29
+ function lockCollateral(
30
+ IInstance instanceNftId,
31
+ NftId policyNftId,
32
+ NftId bundleNftId,
33
+ uint256 collateralAmount,
34
+ uint256 netPremium
35
+ )
36
+ external
37
+ returns (
38
+ IBundle.BundleInfo memory bundleInfo
39
+ );
30
40
 
31
41
  function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
32
42