@etherisc/gif-next 0.0.2-84e1050-545 → 0.0.2-86f4673-518

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 (284) hide show
  1. package/README.md +73 -1
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  3. package/artifacts/contracts/components/Component.sol/Component.json +884 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +480 -112
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +137 -86
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +556 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +662 -43
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +661 -5
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +590 -204
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +525 -131
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  33. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  40. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
  41. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +327 -43
  44. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  45. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +146 -59
  46. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  47. package/artifacts/contracts/instance/Instance.sol/Instance.json +278 -111
  48. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +103 -184
  50. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +61 -97
  52. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +412 -245
  54. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +175 -101
  56. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  57. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
  58. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  59. package/artifacts/contracts/{shared/RegisterableUpgradable.sol/RegisterableUpgradable.json → instance/base/ComponentService.sol/ComponentService.json} +321 -9
  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/KeyValueStore.sol/KeyValueStore.json +2 -2
  64. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  66. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +24 -13
  68. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
  75. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
  76. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +495 -100
  78. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +172 -26
  80. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +301 -62
  82. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +169 -23
  84. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
  85. package/artifacts/contracts/instance/{base/ComponentServiceBase.sol/ComponentServiceBase.json → service/IApplicationService.sol/IApplicationService.json} +221 -104
  86. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +181 -52
  88. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +32 -19
  90. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +152 -32
  92. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +32 -19
  94. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +32 -19
  96. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +481 -87
  98. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +203 -25
  100. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +301 -62
  102. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +169 -23
  104. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  105. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +301 -62
  106. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  107. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +169 -15
  108. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  109. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  110. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  111. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +225 -133
  112. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  113. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +146 -94
  114. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  115. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/Registry.sol/Registry.json +238 -235
  117. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  118. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  119. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  120. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +214 -156
  121. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  122. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +181 -97
  123. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  124. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
  125. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  126. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +150 -29
  127. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  128. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  129. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
  130. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +37 -0
  132. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
  133. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
  134. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  135. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +18 -5
  136. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  137. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +69 -0
  138. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  139. package/artifacts/contracts/shared/IService.sol/IService.json +32 -19
  140. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  141. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -2
  142. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  143. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +156 -11
  144. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
  145. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
  146. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  147. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +156 -6
  148. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  149. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +152 -11
  150. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
  151. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
  152. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  153. package/artifacts/contracts/shared/Service.sol/Service.json +178 -19
  154. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  155. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  156. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  157. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  158. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -2
  159. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  160. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  161. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +152 -11
  162. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  163. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  164. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  165. package/artifacts/contracts/test/TestService.sol/TestService.json +196 -37
  166. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  167. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  168. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  169. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -8
  170. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  171. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  172. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  176. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  178. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  179. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  181. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  182. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  183. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  186. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  188. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  190. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  192. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  194. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  198. package/contracts/components/Component.sol +230 -0
  199. package/contracts/components/Distribution.sol +53 -60
  200. package/contracts/components/IComponent.sol +50 -0
  201. package/contracts/components/IDistributionComponent.sol +5 -2
  202. package/contracts/components/IPoolComponent.sol +50 -29
  203. package/contracts/components/IProductComponent.sol +7 -3
  204. package/contracts/components/Pool.sol +135 -152
  205. package/contracts/components/Product.sol +103 -117
  206. package/contracts/instance/BundleManager.sol +7 -11
  207. package/contracts/instance/IInstance.sol +21 -9
  208. package/contracts/instance/IInstanceService.sol +23 -6
  209. package/contracts/instance/Instance.sol +37 -45
  210. package/contracts/instance/InstanceAccessManager.sol +31 -39
  211. package/contracts/instance/InstanceReader.sol +3 -25
  212. package/contracts/instance/InstanceService.sol +200 -78
  213. package/contracts/instance/InstanceServiceManager.sol +5 -8
  214. package/contracts/instance/ObjectManager.sol +7 -24
  215. package/contracts/instance/base/ComponentService.sol +134 -0
  216. package/contracts/instance/module/IAccess.sol +4 -5
  217. package/contracts/instance/module/ISetup.sol +5 -4
  218. package/contracts/instance/service/ApplicationService.sol +268 -0
  219. package/contracts/instance/service/BundleService.sol +52 -14
  220. package/contracts/instance/service/BundleServiceManager.sol +5 -8
  221. package/contracts/instance/service/DistributionService.sol +33 -46
  222. package/contracts/instance/service/DistributionServiceManager.sol +6 -9
  223. package/contracts/instance/service/IApplicationService.sol +82 -0
  224. package/contracts/instance/service/IBundleService.sol +12 -3
  225. package/contracts/instance/service/IPolicyService.sol +17 -16
  226. package/contracts/instance/service/PolicyService.sol +148 -132
  227. package/contracts/instance/service/PoolService.sol +27 -42
  228. package/contracts/instance/service/PoolServiceManager.sol +5 -8
  229. package/contracts/instance/service/ProductService.sol +100 -40
  230. package/contracts/registry/ChainNft.sol +1 -1
  231. package/contracts/registry/IRegistry.sol +37 -19
  232. package/contracts/registry/IRegistryService.sol +28 -13
  233. package/contracts/registry/Registry.sol +231 -217
  234. package/contracts/registry/RegistryAccessManager.sol +216 -0
  235. package/contracts/registry/RegistryService.sol +65 -162
  236. package/contracts/registry/RegistryServiceManager.sol +18 -36
  237. package/contracts/registry/ReleaseManager.sol +332 -0
  238. package/contracts/registry/TokenRegistry.sol +11 -9
  239. package/contracts/shared/ERC165.sol +12 -11
  240. package/contracts/shared/INftOwnable.sol +12 -6
  241. package/contracts/shared/IPolicyHolder.sol +26 -0
  242. package/contracts/shared/IRegisterable.sol +4 -6
  243. package/contracts/shared/IRegistryLinked.sol +15 -0
  244. package/contracts/shared/IService.sol +2 -1
  245. package/contracts/shared/IVersionable.sol +2 -2
  246. package/contracts/shared/NftOwnable.sol +113 -57
  247. package/contracts/shared/PolicyHolder.sol +81 -0
  248. package/contracts/shared/ProxyManager.sol +6 -5
  249. package/contracts/shared/Registerable.sol +15 -24
  250. package/contracts/shared/RegistryLinked.sol +64 -0
  251. package/contracts/shared/Service.sol +18 -13
  252. package/contracts/shared/Versionable.sol +3 -2
  253. package/contracts/test/TestRegisterable.sol +1 -1
  254. package/contracts/test/TestService.sol +4 -3
  255. package/contracts/types/ObjectType.sol +5 -1
  256. package/contracts/types/RoleId.sol +4 -7
  257. package/package.json +3 -3
  258. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  259. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  260. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -384
  261. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  262. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  263. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  264. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
  265. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  266. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
  267. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  268. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  269. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  270. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  271. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
  272. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  273. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
  274. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  275. package/contracts/components/BaseComponent.sol +0 -145
  276. package/contracts/components/IBaseComponent.sol +0 -32
  277. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
  278. package/contracts/instance/IInstanceBase.sol +0 -26
  279. package/contracts/instance/InstanceBase.sol +0 -41
  280. package/contracts/instance/base/ComponentServiceBase.sol +0 -72
  281. package/contracts/instance/base/IInstanceBase.sol +0 -23
  282. package/contracts/instance/service/ComponentOwnerService.sol +0 -317
  283. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  284. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -4,22 +4,17 @@ pragma solidity ^0.8.19;
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
6
  import {IRisk} from "../instance/module/IRisk.sol";
7
- import {ITreasury} from "../instance/module/ITreasury.sol";
8
- import {IProductService} from "../instance/service/IProductService.sol";
9
7
  import {IPolicyService} from "../instance/service/IPolicyService.sol";
10
8
  import {IProductComponent} from "./IProductComponent.sol";
11
- import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
12
- import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
9
+ import {NftId, NftIdLib} from "../types/NftId.sol";
10
+ import {PRODUCT} from "../types/ObjectType.sol";
13
11
  import {ReferralId} from "../types/Referral.sol";
14
12
  import {RiskId, RiskIdLib} from "../types/RiskId.sol";
15
13
  import {StateId} from "../types/StateId.sol";
16
14
  import {Timestamp} from "../types/Timestamp.sol";
17
- import {Fee, FeeLib} from "../types/Fee.sol";
18
- import {BaseComponent} from "./BaseComponent.sol";
15
+ import {Fee} from "../types/Fee.sol";
16
+ import {Component} from "./Component.sol";
19
17
 
20
- import {IRegistry} from "../registry/IRegistry.sol";
21
- import {IRegisterable} from "../shared/IRegisterable.sol";
22
- import {Registerable} from "../shared/Registerable.sol";
23
18
  import {TokenHandler} from "../shared/TokenHandler.sol";
24
19
 
25
20
  import {InstanceReader} from "../instance/InstanceReader.sol";
@@ -27,47 +22,55 @@ import {ISetup} from "../instance/module/ISetup.sol";
27
22
  import {Pool} from "../components/Pool.sol";
28
23
  import {Distribution} from "../components/Distribution.sol";
29
24
 
30
- import {zeroNftId} from "../types/NftId.sol";
31
-
32
- contract Product is BaseComponent, IProductComponent {
33
- using NftIdLib for NftId;
34
-
35
- IProductService internal _productService;
36
- IPolicyService internal _policyService;
37
- Pool internal _pool;
38
- Distribution internal _distribution;
39
- Fee internal _initialProductFee;
40
- Fee internal _initialProcessingFee;
41
- TokenHandler internal _tokenHandler;
42
-
43
- NftId internal _poolNftId;
44
- NftId internal _distributionNftId;
25
+ abstract contract Product is
26
+ Component,
27
+ IProductComponent
28
+ {
29
+ // keccak256(abi.encode(uint256(keccak256("etherisc.storage.Product")) - 1)) & ~bytes32(uint256(0xff));
30
+ bytes32 public constant PRODUCT_STORAGE_LOCATION_V1 = 0x0bb7aafdb8e380f81267337bc5b5dfdf76e6d3a380ecadb51ec665246d9d6800;
31
+
32
+ struct ProductStorage {
33
+ IPolicyService _policyService;
34
+ Pool _pool;
35
+ Distribution _distribution;
36
+ Fee _initialProductFee;
37
+ Fee _initialProcessingFee;
38
+ TokenHandler _tokenHandler;
39
+ NftId _poolNftId;
40
+ NftId _distributionNftId;
41
+ }
45
42
 
46
- constructor(
43
+ function initializeProduct(
47
44
  address registry,
48
- NftId instanceNftid,
45
+ NftId instanceNftId,
46
+ string memory name,
49
47
  address token,
50
48
  bool isInterceptor,
51
49
  address pool,
52
50
  address distribution,
53
51
  Fee memory productFee,
54
52
  Fee memory processingFee,
55
- address initialOwner
56
- ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
57
- // TODO add validation
58
- _productService = _instance.getProductService();
59
- _policyService = _instance.getPolicyService();
60
- _pool = Pool(pool);
61
- _distribution = Distribution(distribution);
62
- _initialProductFee = productFee;
63
- _initialProcessingFee = processingFee;
64
-
65
- _tokenHandler = new TokenHandler(token);
66
-
67
- _poolNftId = getRegistry().getNftId(address(_pool));
68
- _distributionNftId = getRegistry().getNftId(address(_distribution));
53
+ address initialOwner,
54
+ bytes memory data
55
+ )
56
+ public
57
+ virtual
58
+ onlyInitializing()
59
+ {
60
+ initializeComponent(registry, instanceNftId, name, token, PRODUCT(), isInterceptor, initialOwner, data);
69
61
 
70
- _registerInterface(type(IProductComponent).interfaceId);
62
+ ProductStorage storage $ = _getProductStorage();
63
+ // TODO add validation
64
+ $._policyService = getInstance().getPolicyService();
65
+ $._pool = Pool(pool);
66
+ $._distribution = Distribution(distribution);
67
+ $._initialProductFee = productFee;
68
+ $._initialProcessingFee = processingFee;
69
+ $._tokenHandler = new TokenHandler(token);
70
+ $._poolNftId = getRegistry().getNftId(pool);
71
+ $._distributionNftId = getRegistry().getNftId(distribution);
72
+
73
+ registerInterface(type(IProductComponent).interfaceId);
71
74
  }
72
75
 
73
76
 
@@ -76,15 +79,15 @@ contract Product is BaseComponent, IProductComponent {
76
79
  RiskId riskId,
77
80
  uint256 lifetime,
78
81
  bytes memory applicationData,
79
- ReferralId referralId,
80
- NftId bundleNftId
82
+ NftId bundleNftId,
83
+ ReferralId referralId
81
84
  )
82
85
  external
83
86
  view
84
87
  override
85
88
  returns (uint256 premiumAmount)
86
89
  {
87
- (premiumAmount,,,,) = _policyService.calculatePremium(
90
+ (premiumAmount,,,,) = _getProductStorage()._policyService.calculatePremium(
88
91
  riskId,
89
92
  sumInsuredAmount,
90
93
  lifetime,
@@ -118,7 +121,7 @@ contract Product is BaseComponent, IProductComponent {
118
121
  RiskId id,
119
122
  bytes memory data
120
123
  ) internal {
121
- _productService.createRisk(
124
+ getProductService().createRisk(
122
125
  id,
123
126
  data
124
127
  );
@@ -128,7 +131,7 @@ contract Product is BaseComponent, IProductComponent {
128
131
  RiskId id,
129
132
  bytes memory data
130
133
  ) internal {
131
- _productService.updateRisk(
134
+ getProductService().updateRisk(
132
135
  id,
133
136
  data
134
137
  );
@@ -138,14 +141,14 @@ contract Product is BaseComponent, IProductComponent {
138
141
  RiskId id,
139
142
  StateId state
140
143
  ) internal {
141
- _productService.updateRiskState(
144
+ getProductService().updateRiskState(
142
145
  id,
143
146
  state
144
147
  );
145
148
  }
146
149
 
147
150
  function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
148
- return _instance.getInstanceReader().getRiskInfo(id);
151
+ return getInstance().getInstanceReader().getRiskInfo(id);
149
152
  }
150
153
 
151
154
  function _createApplication(
@@ -156,8 +159,11 @@ contract Product is BaseComponent, IProductComponent {
156
159
  bytes memory applicationData,
157
160
  NftId bundleNftId,
158
161
  ReferralId referralId
159
- ) internal returns (NftId nftId) {
160
- nftId = _policyService.createApplication(
162
+ )
163
+ internal
164
+ returns (NftId nftId)
165
+ {
166
+ return _getProductStorage()._policyService.createApplication(
161
167
  applicationOwner,
162
168
  riskId,
163
169
  sumInsuredAmount,
@@ -175,7 +181,7 @@ contract Product is BaseComponent, IProductComponent {
175
181
  )
176
182
  internal
177
183
  {
178
- _policyService.underwrite(
184
+ _getProductStorage()._policyService.underwrite(
179
185
  policyNftId,
180
186
  requirePremiumPayment,
181
187
  activateAt);
@@ -187,7 +193,7 @@ contract Product is BaseComponent, IProductComponent {
187
193
  )
188
194
  internal
189
195
  {
190
- _policyService.collectPremium(
196
+ _getProductStorage()._policyService.collectPremium(
191
197
  policyNftId,
192
198
  activateAt);
193
199
  }
@@ -198,17 +204,25 @@ contract Product is BaseComponent, IProductComponent {
198
204
  )
199
205
  internal
200
206
  {
201
- _policyService.activate(
207
+ _getProductStorage()._policyService.activate(
202
208
  policyNftId,
203
209
  activateAt);
204
210
  }
205
211
 
212
+ function _close(
213
+ NftId policyNftId
214
+ )
215
+ internal
216
+ {
217
+ _getProductStorage()._policyService.close(policyNftId);
218
+ }
219
+
206
220
  function getPoolNftId() external view override returns (NftId poolNftId) {
207
- return getRegistry().getNftId(address(_pool));
221
+ return getRegistry().getNftId(address(_getProductStorage()._pool));
208
222
  }
209
223
 
210
224
  function getDistributionNftId() external view override returns (NftId distributionNftId) {
211
- return getRegistry().getNftId(address(_distribution));
225
+ return getRegistry().getNftId(address(_getProductStorage()._distribution));
212
226
  }
213
227
 
214
228
  // from product component
@@ -218,75 +232,47 @@ contract Product is BaseComponent, IProductComponent {
218
232
  )
219
233
  external
220
234
  onlyOwner
235
+ restricted()
221
236
  override
222
237
  {
223
- _productService.setFees(productFee, processingFee);
238
+ getProductService().setFees(productFee, processingFee);
224
239
  }
225
240
 
226
241
  function getSetupInfo() public view returns (ISetup.ProductSetupInfo memory setupInfo) {
227
- InstanceReader reader = _instance.getInstanceReader();
228
- return reader.getProductSetupInfo(getNftId());
229
- }
242
+ InstanceReader reader = getInstance().getInstanceReader();
243
+ setupInfo = reader.getProductSetupInfo(getNftId());
230
244
 
231
- // from IRegisterable
245
+ // fallback to initial setup info (wallet is always != address(0))
246
+ if(setupInfo.wallet == address(0)) {
247
+ setupInfo = _getInitialSetupInfo();
248
+ }
249
+ }
232
250
 
233
- function getInitialInfo()
234
- public
235
- view
236
- override (IRegisterable, Registerable)
237
- returns (IRegistry.ObjectInfo memory, bytes memory)
238
- {
239
- // from Registerable
240
- (
241
- IRegistry.ObjectInfo memory productInfo,
242
- bytes memory data
243
- ) = super.getInitialInfo();
244
-
245
- // TODO read pool & distribution fees
246
- // 1) from pool -> the only option -> pool must be registered first?
247
- // 2) from instance -> all fees are set into instance at product registration which is ongoing here
248
- // checks are done in registryProduct() where THIS function is called
249
- //require(getRegistry().getObjectInfo(_poolNftId).objectType == POOL(), "POOL_NOT_REGISTERED");
250
- //require(getRegistry().getObjectInfo(_distributionNftId).objectType == DISTRIBUTION(), "DISTRIBUTION_NOT_REGISTERED");
251
-
252
- // from PoolComponent
253
- (
254
- ,
255
- bytes memory poolData
256
- ) = _pool.getInitialInfo();
257
-
258
- (
259
- ISetup.PoolSetupInfo memory poolSetupInfo
260
- ) = abi.decode(poolData, (ISetup.PoolSetupInfo));
261
-
262
- // from DistributionComponent
263
- (
264
- ,
265
- bytes memory distributionData
266
- ) = _distribution.getInitialInfo();
267
-
268
- (
269
- ISetup.DistributionSetupInfo memory distributionSetupInfo
270
- ) = abi.decode(distributionData, (ISetup.DistributionSetupInfo));
271
-
272
- return (
273
- productInfo,
274
- abi.encode(
275
- ISetup.ProductSetupInfo(
276
- _token,
277
- _tokenHandler,
278
- _distributionNftId,
279
- _poolNftId,
280
- distributionSetupInfo.distributionFee,
281
- _initialProductFee,
282
- _initialProcessingFee,
283
- poolSetupInfo.poolFee,
284
- poolSetupInfo.stakingFee,
285
- poolSetupInfo.performanceFee,
286
- false,
287
- _wallet
288
- )
289
- )
251
+ function _getInitialSetupInfo() internal view returns (ISetup.ProductSetupInfo memory setupInfo) {
252
+ ProductStorage storage $ = _getProductStorage();
253
+
254
+ ISetup.DistributionSetupInfo memory distributionSetupInfo = $._distribution.getSetupInfo();
255
+ ISetup.PoolSetupInfo memory poolSetupInfo = $._pool.getSetupInfo();
256
+
257
+ return ISetup.ProductSetupInfo(
258
+ getToken(),
259
+ $._tokenHandler,
260
+ $._distributionNftId,
261
+ $._poolNftId,
262
+ distributionSetupInfo.distributionFee,
263
+ $._initialProductFee,
264
+ $._initialProcessingFee,
265
+ poolSetupInfo.poolFee,
266
+ poolSetupInfo.stakingFee,
267
+ poolSetupInfo.performanceFee,
268
+ false,
269
+ getWallet()
290
270
  );
291
271
  }
272
+
273
+ function _getProductStorage() private pure returns (ProductStorage storage $) {
274
+ assembly {
275
+ $.slot := PRODUCT_STORAGE_LOCATION_V1
276
+ }
277
+ }
292
278
  }
@@ -32,17 +32,13 @@ contract BundleManager is
32
32
 
33
33
  mapping(NftId bundleNftId => LibNftIdSet.Set policies) internal _activePolicies;
34
34
 
35
- constructor() ObjectManager() {
36
- }
37
-
38
-
39
35
  /// @dev links a policy with its bundle
40
36
  // to link a policy it MUST NOT yet have been activated
41
37
  // the bundle MUST be unlocked (active) for linking (underwriting) and registered with this instance
42
38
  function linkPolicy(NftId policyNftId) external restricted() {
43
- NftId bundleNftId = _instanceReader.getPolicyInfo(policyNftId).bundleNftId;
39
+ NftId bundleNftId = _instance.getInstanceReader().getPolicyInfo(policyNftId).bundleNftId;
44
40
  // decision will likely depend on the decision what to check here and what in the service
45
- NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
41
+ NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
46
42
 
47
43
  // ensure bundle is unlocked (in active set) and registered with this instance
48
44
  if (!_isActive(poolNftId, bundleNftId)) {
@@ -59,11 +55,11 @@ contract BundleManager is
59
55
  // - the policy MUST be past its expiry period and it MUST NOT have any open claims
60
56
  // - the policy's payoutAmount MUST be equal to its sumInsuredAmount and MUST NOT have any open claims
61
57
  function unlinkPolicy(NftId policyNftId) external restricted() {
62
- IPolicy.PolicyInfo memory policyInfo = _instanceReader.getPolicyInfo(policyNftId);
58
+ IPolicy.PolicyInfo memory policyInfo = _instance.getInstanceReader().getPolicyInfo(policyNftId);
63
59
 
64
60
  NftId bundleNftId = policyInfo.bundleNftId;
65
61
  // decision will likely depend on the decision what to check here and what in the service
66
- NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
62
+ NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
67
63
 
68
64
  // ensure bundle is registered with this instance
69
65
  if (!_contains(poolNftId, bundleNftId)) {
@@ -78,7 +74,7 @@ contract BundleManager is
78
74
  /// @dev add a new bundle to a riskpool registerd with this instance
79
75
  // the corresponding pool is fetched via instance reader
80
76
  function add(NftId bundleNftId) external restricted() {
81
- NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
77
+ NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
82
78
 
83
79
  // ensure pool is registered with instance
84
80
  if(poolNftId.eqz()) {
@@ -91,14 +87,14 @@ contract BundleManager is
91
87
 
92
88
  /// @dev unlocked (active) bundles are available to underwrite new policies
93
89
  function unlock(NftId bundleNftId) external restricted() {
94
- NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
90
+ NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
95
91
  _activate(poolNftId, bundleNftId);
96
92
  emit LogBundleManagerBundleUnlocked(poolNftId, bundleNftId);
97
93
  }
98
94
 
99
95
  /// @dev locked (deactivated) bundles may not underwrite any new policies
100
96
  function lock(NftId bundleNftId) external restricted() {
101
- NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
97
+ NftId poolNftId = _instance.getInstanceReader().getBundleInfo(bundleNftId).poolNftId;
102
98
  _deactivate(poolNftId, bundleNftId);
103
99
  emit LogBundleManagerBundleLocked(poolNftId, bundleNftId);
104
100
  }
@@ -1,30 +1,41 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
4
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
5
5
 
6
+ import {NftId} from "../types/NftId.sol";
7
+ import {StateId} from "../types/StateId.sol";
8
+ import {RiskId} from "../types/RiskId.sol";
9
+
10
+ import {IRegisterable} from "../shared/IRegisterable.sol";
11
+
12
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
6
13
  import {BundleManager} from "./BundleManager.sol";
7
14
  import {InstanceReader} from "./InstanceReader.sol";
8
15
 
9
- import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
16
+ import {IBundle} from "./module/IBundle.sol";
17
+ import {IBundleService} from "./service/IBundleService.sol";
10
18
  import {IDistributionService} from "./service/IDistributionService.sol";
19
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
20
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
21
+ import {IPolicy} from "./module/IPolicy.sol";
22
+ import {IPolicyService} from "./service/IPolicyService.sol";
11
23
  import {IPoolService} from "./service/IPoolService.sol";
12
24
  import {IProductService} from "./service/IProductService.sol";
13
25
  import {IPolicyService} from "./service/IPolicyService.sol";
14
26
  import {IBundleService} from "./service/IBundleService.sol";
15
- import {IBundle} from "./module/IBundle.sol";
27
+ import {IRisk} from "./module/IRisk.sol";
16
28
  import {ISetup} from "./module/ISetup.sol";
17
29
  import {NftId} from "../types/NftId.sol";
18
- import {StateId} from "../types/StateId.sol";
19
30
  import {RiskId} from "../types/RiskId.sol";
20
- import {IRisk} from "./module/IRisk.sol";
21
- import {IPolicy} from "./module/IPolicy.sol";
22
- import {IKeyValueStore} from "./base/IKeyValueStore.sol";
31
+ import {StateId} from "../types/StateId.sol";
32
+ import {VersionPart} from "../types/Version.sol";
33
+
34
+
23
35
 
24
36
 
25
- interface IInstance is IERC165, IKeyValueStore {
37
+ interface IInstance is IRegisterable, IKeyValueStore, IAccessManaged {
26
38
 
27
- function getComponentOwnerService() external view returns (IComponentOwnerService);
28
39
  function getDistributionService() external view returns (IDistributionService);
29
40
  function getProductService() external view returns (IProductService);
30
41
  function getPoolService() external view returns (IPoolService);
@@ -55,6 +66,7 @@ interface IInstance is IERC165, IKeyValueStore {
55
66
  function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
56
67
  function updatePolicyState(NftId policyNftId, StateId newState) external;
57
68
 
69
+ function getMajorVersion() external pure returns (VersionPart majorVersion);
58
70
  function getInstanceReader() external view returns (InstanceReader);
59
71
  function getBundleManager() external view returns (BundleManager);
60
72
  }
@@ -8,7 +8,7 @@ import {IService} from "../shared/IService.sol";
8
8
  import {IRegistry} from "../registry/IRegistry.sol";
9
9
 
10
10
  import {IRegisterable} from "../shared/IRegisterable.sol";
11
- import {IBaseComponent} from "../components/IBaseComponent.sol";
11
+ import {IComponent} from "../components/IComponent.sol";
12
12
 
13
13
  import {InstanceAccessManager} from "./InstanceAccessManager.sol";
14
14
  import {Instance} from "./Instance.sol";
@@ -17,9 +17,29 @@ import {BundleManager} from "./BundleManager.sol";
17
17
 
18
18
  interface IInstanceService is IService {
19
19
 
20
+ error ErrorInstanceServiceMasterInstanceAlreadySet();
21
+ error ErrorInstanceServiceMasterInstanceAccessManagerAlreadySet();
22
+ error ErrorInstanceServiceMasterBundleManagerAlreadySet();
23
+ error ErrorInstanceServiceInstanceAddressZero();
24
+
25
+ error ErrorInstanceServiceMasterInstanceReaderNotSet();
26
+ error ErrorInstanceServiceInstanceReaderAddressZero();
27
+ error ErrorInstanceServiceInstanceReaderSameAsMasterInstanceReader();
28
+ error ErrorInstanceServiceInstanceReaderInstanceMismatch();
29
+
30
+ error ErrorInstanceServiceAccessManagerZero();
31
+ error ErrorInstanceServiceInstanceReaderZero();
32
+ error ErrorInstanceServiceBundleManagerZero();
33
+
34
+ error ErrorInstanceServiceInstanceAuthorityMismatch();
35
+ error ErrorInstanceServiceInstanceReaderInstanceMismatch2();
36
+ error ErrorInstanceServiceBundleMangerInstanceMismatch();
37
+
20
38
  error ErrorInstanceServiceRequestUnauhorized(address caller);
21
39
  error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
22
-
40
+ error ErrorInstanceServiceComponentNotRegistered(address componentAddress);
41
+ error ErrorInstanceServiceInvalidComponentType(address componentAddress, ObjectType expectedType, ObjectType componentType);
42
+
23
43
  event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
24
44
 
25
45
  function createInstanceClone()
@@ -32,11 +52,8 @@ interface IInstanceService is IService {
32
52
  BundleManager clonedBundleManager
33
53
  );
34
54
 
35
- function createRole(RoleId role, string memory name, NftId instanceNftId) external;
36
-
37
- function grantRole(RoleId role, address member, NftId instanceNftId) external;
38
-
39
55
  function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
56
+ function setTargetLocked(string memory targetName, bool locked) external;
40
57
 
41
58
  }
42
59
 
@@ -1,48 +1,50 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
- import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
- import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
7
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
8
5
 
9
- import {IAccess} from "./module/IAccess.sol";
10
- import {IBundle} from "./module/IBundle.sol";
11
- import {IPolicy} from "./module/IPolicy.sol";
12
- import {IRisk} from "./module/IRisk.sol";
13
- import {ISetup} from "./module/ISetup.sol";
14
6
  import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
15
- import {KeyValueStore} from "./base/KeyValueStore.sol";
16
- import {IInstance} from "./IInstance.sol";
17
- import {InstanceReader} from "./InstanceReader.sol";
18
- import {InstanceAccessManager} from "./InstanceAccessManager.sol";
19
- import {BundleManager} from "./BundleManager.sol";
20
7
  import {NftId} from "../types/NftId.sol";
21
8
  import {NumberId} from "../types/NumberId.sol";
22
- import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
9
+ import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT} from "../types/ObjectType.sol";
23
10
  import {RiskId, RiskIdLib} from "../types/RiskId.sol";
24
11
  import {RoleId, RoleIdLib} from "../types/RoleId.sol";
25
12
  import {StateId, ACTIVE} from "../types/StateId.sol";
26
13
  import {TimestampLib} from "../types/Timestamp.sol";
14
+ import {VersionPart} from "../types/Version.sol";
15
+
27
16
  import {ERC165} from "../shared/ERC165.sol";
28
17
  import {Registerable} from "../shared/Registerable.sol";
29
- import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
30
- import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
18
+
19
+ import {IInstance} from "./IInstance.sol";
20
+ import {InstanceReader} from "./InstanceReader.sol";
21
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
22
+ import {BundleManager} from "./BundleManager.sol";
23
+
24
+ import {KeyValueStore} from "./base/KeyValueStore.sol";
25
+
26
+ import {IAccess} from "./module/IAccess.sol";
27
+ import {IBundle} from "./module/IBundle.sol";
28
+ import {IPolicy} from "./module/IPolicy.sol";
29
+ import {IRisk} from "./module/IRisk.sol";
30
+ import {ISetup} from "./module/ISetup.sol";
31
+
31
32
  import {IDistributionService} from "./service/IDistributionService.sol";
32
33
  import {IPoolService} from "./service/IPoolService.sol";
33
34
  import {IProductService} from "./service/IProductService.sol";
34
35
  import {IPolicyService} from "./service/IPolicyService.sol";
35
36
  import {IBundleService} from "./service/IBundleService.sol";
36
- import {VersionPart} from "../types/Version.sol";
37
- import {InstanceBase} from "./InstanceBase.sol";
37
+ import {VersionPart, VersionPartLib} from "../types/Version.sol";
38
38
 
39
39
  contract Instance is
40
- AccessManagedUpgradeable,
41
40
  IInstance,
42
- // Initializable,
43
- InstanceBase
41
+ AccessManagedUpgradeable,
42
+ Registerable,
43
+ KeyValueStore
44
44
  {
45
45
 
46
+ uint256 public constant GIF_MAJOR_VERSION = 3;
47
+
46
48
  uint64 public constant ADMIN_ROLE = type(uint64).min;
47
49
  uint64 public constant PUBLIC_ROLE = type(uint64).max;
48
50
  uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
@@ -57,18 +59,12 @@ contract Instance is
57
59
 
58
60
  function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner)
59
61
  public
60
- initializer
62
+ initializer()
61
63
  {
62
- require(!_initialized, "Contract instance has already been initialized");
63
-
64
64
  __AccessManaged_init(accessManagerAddress);
65
-
66
- _accessManager = InstanceAccessManager(accessManagerAddress);
67
65
 
68
- _initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
69
-
70
- _registerInterface(type(IInstance).interfaceId);
71
- _initialized = true;
66
+ initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
67
+ registerInterface(type(IInstance).interfaceId);
72
68
  }
73
69
 
74
70
  //--- ProductSetup ------------------------------------------------------//
@@ -227,46 +223,42 @@ contract Instance is
227
223
  return policyNftId.toKey32(POLICY());
228
224
  }
229
225
 
230
- function getComponentOwnerService() external view returns (IComponentOwnerService) {
231
- return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
232
- }
233
-
234
226
  function getDistributionService() external view returns (IDistributionService) {
235
- return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
227
+ return IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
236
228
  }
237
229
 
238
230
  function getProductService() external view returns (IProductService) {
239
- return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
231
+ return IProductService(getRegistry().getServiceAddress(PRODUCT(), VersionPart.wrap(3)));
240
232
  }
241
233
 
242
234
  function getPoolService() external view returns (IPoolService) {
243
- return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
235
+ return IPoolService(getRegistry().getServiceAddress(POOL(), VersionPart.wrap(3)));
244
236
  }
245
237
 
246
238
  function getPolicyService() external view returns (IPolicyService) {
247
- return IPolicyService(_registry.getServiceAddress("PolicyService", VersionPart.wrap(3)));
239
+ return IPolicyService(getRegistry().getServiceAddress(POLICY(), VersionPart.wrap(3)));
248
240
  }
249
241
 
250
242
  function getBundleService() external view returns (IBundleService) {
251
- return IBundleService(_registry.getServiceAddress("BundleService", VersionPart.wrap(3)));
252
- }
253
-
254
- function getInstanceAccessManager() external view returns (InstanceAccessManager) {
255
- return _accessManager;
243
+ return IBundleService(getRegistry().getServiceAddress(BUNDLE(), VersionPart.wrap(3)));
256
244
  }
257
245
 
258
246
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
259
- require(instanceReader.getInstanceNftId() == getNftId(), "NFT ID of InstanceReader does not match");
247
+ require(instanceReader.getInstance() == Instance(this), "InstanceReader instance mismatch");
260
248
  _instanceReader = instanceReader;
261
249
  }
262
250
 
251
+ function getMajorVersion() external pure returns (VersionPart majorVersion) {
252
+ return VersionPartLib.toVersionPart(GIF_MAJOR_VERSION);
253
+ }
254
+
263
255
  function getInstanceReader() external view returns (InstanceReader) {
264
256
  return _instanceReader;
265
257
  }
266
258
 
267
259
  function setBundleManager(BundleManager bundleManager) external restricted() {
268
260
  require(address(_bundleManager) == address(0), "BundleManager is set");
269
- require(bundleManager.getInstanceNftId() == getNftId(), "NFT ID of BundleManager does not match");
261
+ require(bundleManager.getInstance() == Instance(this), "BundleManager instance mismatch");
270
262
  _bundleManager = bundleManager;
271
263
  }
272
264