@etherisc/gif-next 0.0.2-e5a2253-213 → 0.0.2-e69072e-892

Sign up to get free protection for your applications and to get access to all the features.
Files changed (337) 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/{BaseComponent.sol/BaseComponent.json → Component.sol/Component.json} +340 -59
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +804 -211
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → IComponent.sol/IComponent.json} +95 -56
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +699 -22
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +814 -60
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +519 -4
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +896 -298
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +442 -129
  18. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  19. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
  20. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  21. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  22. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +910 -289
  23. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  24. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +110 -171
  25. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  26. package/artifacts/contracts/instance/Instance.sol/Instance.json +874 -557
  27. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  28. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +52 -115
  29. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  30. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +101 -168
  31. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  32. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +346 -263
  33. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  34. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +319 -86
  35. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  36. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
  37. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  38. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +119 -189
  39. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  40. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
  43. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  45. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  46. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +13 -13
  47. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  48. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  52. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  53. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
  54. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +968 -0
  55. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
  56. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +665 -0
  57. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +258 -283
  59. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  60. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +305 -80
  61. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
  62. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +754 -0
  63. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
  64. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +637 -0
  65. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +983 -221
  67. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +441 -72
  69. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
  70. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +556 -0
  71. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +130 -217
  73. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
  74. package/artifacts/contracts/{shared/RegisterableUpgradable.sol/RegisterableUpgradable.json → instance/service/IClaimService.sol/IClaimService.json} +146 -179
  75. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +552 -140
  77. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +40 -292
  79. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +22 -174
  81. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +22 -174
  83. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +161 -407
  85. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +311 -114
  87. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +139 -237
  89. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +302 -77
  91. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +139 -237
  93. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +302 -77
  95. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  96. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  97. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +98 -5
  98. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  99. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +112 -198
  100. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  101. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  102. package/artifacts/contracts/registry/Registry.sol/Registry.json +112 -27
  103. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  104. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
  105. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  106. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +216 -234
  107. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  108. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +300 -81
  109. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  110. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -53
  111. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  112. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +151 -50
  113. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  114. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  115. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
  116. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  117. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +40 -29
  118. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
  119. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
  120. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +21 -34
  122. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  123. package/artifacts/contracts/{experiment/inheritance/IB.sol/IB.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +18 -20
  124. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IService.sol/IService.json +22 -174
  126. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -152
  128. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +120 -27
  130. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
  131. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +248 -0
  132. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +294 -61
  134. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +129 -51
  136. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
  137. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +84 -0
  138. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  139. package/artifacts/contracts/shared/Service.sol/Service.json +114 -157
  140. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  141. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  142. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  143. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  144. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -152
  145. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  147. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +129 -51
  148. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  150. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestService.sol/TestService.json +135 -214
  152. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -190
  156. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  157. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  158. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
  161. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +100 -0
  162. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  164. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  167. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  169. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  170. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  171. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  174. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
  175. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +100 -0
  176. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  178. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  180. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  182. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
  183. package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
  184. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
  187. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  191. package/contracts/components/Component.sol +221 -0
  192. package/contracts/components/Distribution.sol +206 -67
  193. package/contracts/components/IComponent.sol +68 -0
  194. package/contracts/components/IDistributionComponent.sol +44 -9
  195. package/contracts/components/IPoolComponent.sol +124 -39
  196. package/contracts/components/IProductComponent.sol +8 -3
  197. package/contracts/components/Pool.sol +284 -164
  198. package/contracts/components/Product.sol +110 -116
  199. package/contracts/instance/BundleManager.sol +8 -12
  200. package/contracts/instance/IInstance.sol +41 -9
  201. package/contracts/instance/IInstanceService.sol +20 -1
  202. package/contracts/instance/Instance.sol +90 -61
  203. package/contracts/instance/InstanceAccessManager.sol +18 -24
  204. package/contracts/instance/InstanceReader.sol +3 -25
  205. package/contracts/instance/InstanceService.sol +195 -50
  206. package/contracts/instance/InstanceServiceManager.sol +1 -1
  207. package/contracts/instance/ObjectManager.sol +7 -24
  208. package/contracts/instance/base/{ComponentServiceBase.sol → ComponentService.sol} +9 -13
  209. package/contracts/instance/module/IAccess.sol +3 -4
  210. package/contracts/instance/module/IBundle.sol +2 -1
  211. package/contracts/instance/module/IDistribution.sol +2 -0
  212. package/contracts/instance/module/IPolicy.sol +30 -3
  213. package/contracts/instance/module/ISetup.sol +10 -10
  214. package/contracts/instance/service/ApplicationService.sol +350 -0
  215. package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
  216. package/contracts/instance/service/BundleService.sol +17 -12
  217. package/contracts/instance/service/BundleServiceManager.sol +1 -1
  218. package/contracts/instance/service/ClaimService.sol +151 -0
  219. package/contracts/instance/service/ClaimServiceManager.sol +35 -0
  220. package/contracts/instance/service/DistributionService.sol +312 -33
  221. package/contracts/instance/service/DistributionServiceManager.sol +1 -1
  222. package/contracts/instance/service/IApplicationService.sol +82 -0
  223. package/contracts/instance/service/IBundleService.sol +14 -3
  224. package/contracts/instance/service/IClaimService.sol +61 -0
  225. package/contracts/instance/service/IDistributionService.sol +74 -0
  226. package/contracts/instance/service/IPolicyService.sol +26 -50
  227. package/contracts/instance/service/PolicyService.sol +127 -262
  228. package/contracts/instance/service/PolicyServiceManager.sol +2 -2
  229. package/contracts/instance/service/PoolService.sol +12 -45
  230. package/contracts/instance/service/PoolServiceManager.sol +1 -1
  231. package/contracts/instance/service/ProductService.sol +50 -26
  232. package/contracts/instance/service/ProductServiceManager.sol +2 -2
  233. package/contracts/registry/IRegistry.sol +16 -8
  234. package/contracts/registry/IRegistryService.sol +19 -10
  235. package/contracts/registry/Registry.sol +120 -52
  236. package/contracts/registry/RegistryAccessManager.sol +31 -25
  237. package/contracts/registry/RegistryService.sol +91 -128
  238. package/contracts/registry/RegistryServiceManager.sol +13 -13
  239. package/contracts/registry/ReleaseManager.sol +86 -106
  240. package/contracts/registry/TokenRegistry.sol +19 -13
  241. package/contracts/shared/ERC165.sol +14 -12
  242. package/contracts/shared/INftOwnable.sol +11 -10
  243. package/contracts/shared/IPolicyHolder.sol +26 -0
  244. package/contracts/shared/IRegisterable.sol +4 -4
  245. package/contracts/shared/IRegistryLinked.sol +12 -0
  246. package/contracts/shared/IService.sol +2 -0
  247. package/contracts/shared/IVersionable.sol +4 -47
  248. package/contracts/shared/NftOwnable.sol +66 -80
  249. package/contracts/shared/PolicyHolder.sol +81 -0
  250. package/contracts/shared/ProxyManager.sol +100 -25
  251. package/contracts/shared/Registerable.sol +16 -32
  252. package/contracts/shared/RegistryLinked.sol +48 -0
  253. package/contracts/shared/Service.sol +19 -19
  254. package/contracts/shared/Versionable.sol +4 -92
  255. package/contracts/test/TestRegisterable.sol +1 -1
  256. package/contracts/test/TestService.sol +1 -1
  257. package/contracts/types/ClaimId.sol +52 -0
  258. package/contracts/types/DistributorType.sol +2 -2
  259. package/contracts/types/ObjectType.sol +9 -5
  260. package/contracts/types/PayoutId.sol +54 -0
  261. package/contracts/types/RoleId.sol +12 -7
  262. package/contracts/types/Seconds.sol +54 -0
  263. package/contracts/types/Timestamp.sol +12 -13
  264. package/package.json +3 -3
  265. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  266. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  267. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
  268. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
  269. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
  270. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
  271. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
  272. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
  273. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
  274. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
  275. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
  276. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
  277. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
  278. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
  279. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
  280. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
  281. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
  282. package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
  283. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
  284. package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
  285. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
  286. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
  287. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
  288. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
  289. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
  290. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
  291. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
  292. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
  293. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
  294. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
  295. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
  296. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
  297. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
  298. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
  299. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
  300. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
  301. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
  302. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
  303. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
  304. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
  305. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
  306. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  307. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  308. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  309. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
  310. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  311. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
  312. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  313. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  314. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -100
  315. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  316. package/contracts/components/BaseComponent.sol +0 -168
  317. package/contracts/components/IBaseComponent.sol +0 -35
  318. package/contracts/experiment/cloning/Cloner.sol +0 -47
  319. package/contracts/experiment/errors/Require.sol +0 -38
  320. package/contracts/experiment/errors/Revert.sol +0 -44
  321. package/contracts/experiment/inheritance/A.sol +0 -53
  322. package/contracts/experiment/inheritance/B.sol +0 -28
  323. package/contracts/experiment/inheritance/C.sol +0 -34
  324. package/contracts/experiment/inheritance/IA.sol +0 -13
  325. package/contracts/experiment/inheritance/IB.sol +0 -10
  326. package/contracts/experiment/inheritance/IC.sol +0 -12
  327. package/contracts/experiment/statemachine/Dummy.sol +0 -27
  328. package/contracts/experiment/statemachine/ISM.sol +0 -25
  329. package/contracts/experiment/statemachine/SM.sol +0 -57
  330. package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
  331. package/contracts/experiment/types/TypeA.sol +0 -47
  332. package/contracts/experiment/types/TypeB.sol +0 -29
  333. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
  334. package/contracts/instance/IInstanceBase.sol +0 -25
  335. package/contracts/instance/InstanceBase.sol +0 -39
  336. package/contracts/instance/base/IInstanceBase.sol +0 -21
  337. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -10,16 +10,22 @@ 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";
17
17
  import {NftId} from "../../contracts/types/NftId.sol";
18
18
  import {RoleId} from "../types/RoleId.sol";
19
- import {ADMIN_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, POLICY_SERVICE_ROLE, BUNDLE_SERVICE_ROLE} from "../types/RoleId.sol";
20
- import {ObjectType, INSTANCE, BUNDLE, POLICY, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
19
+ import {ADMIN_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, PUBLIC_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, APPLICATION_SERVICE_ROLE, POLICY_SERVICE_ROLE, CLAIM_SERVICE_ROLE, BUNDLE_SERVICE_ROLE} from "../types/RoleId.sol";
20
+ import {ObjectType, INSTANCE, BUNDLE, APPLICATION, POLICY, CLAIM, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
21
+ import {IDistributionComponent} from "../components/IDistributionComponent.sol";
22
+ import {IPoolComponent} from "../components/IPoolComponent.sol";
23
+ import {IProductComponent} from "../components/IProductComponent.sol";
21
24
 
22
- contract InstanceService is Service, IInstanceService {
25
+ contract InstanceService is
26
+ Service,
27
+ IInstanceService
28
+ {
23
29
 
24
30
  address internal _masterInstanceAccessManager;
25
31
  address internal _masterInstance;
@@ -28,11 +34,10 @@ contract InstanceService is Service, IInstanceService {
28
34
 
29
35
  // TODO update to real hash when instance is stable
30
36
  bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
31
- string public constant NAME = "InstanceService";
32
37
 
33
38
  modifier onlyInstanceOwner(NftId instanceNftId) {
34
39
  IRegistry registry = getRegistry();
35
- ChainNft chainNft = registry.getChainNft();
40
+ ChainNft chainNft = ChainNft(registry.getChainNftAddress());
36
41
 
37
42
  if( msg.sender != chainNft.ownerOf(instanceNftId.toInt())) {
38
43
  revert ErrorInstanceServiceNotInstanceOwner(msg.sender, instanceNftId);
@@ -63,25 +68,23 @@ contract InstanceService is Service, IInstanceService {
63
68
  address registryAddress = address(registry);
64
69
  NftId registryNftId = registry.getNftId(registryAddress);
65
70
  address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getMajorVersion());
66
- RegistryService registryService = RegistryService(registryServiceAddress);
71
+ IRegistryService registryService = IRegistryService(registryServiceAddress);
67
72
 
68
73
  // initially set the authority of the access managar to this (being the instance service).
69
74
  // This will allow the instance service to bootstrap the authorizations of the instance
70
75
  // and then transfer the ownership of the access manager to the instance owner once everything is setup
71
76
  clonedAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
72
- clonedAccessManager.__InstanceAccessManager_initialize(address(this));
77
+ clonedAccessManager.initialize(address(this));
73
78
 
74
79
  clonedInstance = Instance(Clones.clone(_masterInstance));
75
80
  clonedInstance.initialize(address(clonedAccessManager), registryAddress, registryNftId, msg.sender);
76
- ( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
77
- clonedInstanceNftId = info.nftId;
78
81
 
79
82
  clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
80
- clonedInstanceReader.initialize(registryAddress, clonedInstanceNftId);
83
+ clonedInstanceReader.initialize(registryAddress, address(clonedInstance));
81
84
  clonedInstance.setInstanceReader(clonedInstanceReader);
82
85
 
83
86
  clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
84
- clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, clonedInstanceNftId);
87
+ clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, address(clonedInstance));
85
88
  clonedInstance.setBundleManager(clonedBundleManager);
86
89
 
87
90
  // TODO amend setters with instance specific , policy manager ...
@@ -93,6 +96,10 @@ contract InstanceService is Service, IInstanceService {
93
96
  clonedAccessManager.grantRole(ADMIN_ROLE(), instanceOwner);
94
97
  clonedAccessManager.revokeRole(ADMIN_ROLE(), address(this));
95
98
 
99
+ IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
100
+ clonedInstanceNftId = info.nftId;
101
+ // clonedInstance.linkToRegisteredNftId();
102
+
96
103
  emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
97
104
  }
98
105
 
@@ -102,7 +109,9 @@ contract InstanceService is Service, IInstanceService {
102
109
  _grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstance);
103
110
  _grantPoolServiceAuthorizations(clonedAccessManager, clonedInstance);
104
111
  _grantProductServiceAuthorizations(clonedAccessManager, clonedInstance);
112
+ _grantApplicationServiceAuthorizations(clonedAccessManager, clonedInstance);
105
113
  _grantPolicyServiceAuthorizations(clonedAccessManager, clonedInstance);
114
+ _grantClaimServiceAuthorizations(clonedAccessManager, clonedInstance);
106
115
  _grantBundleServiceAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
107
116
  _grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance);
108
117
  }
@@ -115,12 +124,15 @@ contract InstanceService is Service, IInstanceService {
115
124
  clonedAccessManager.createGifRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole");
116
125
  clonedAccessManager.createGifRole(POOL_SERVICE_ROLE(), "PoolServiceRole");
117
126
  clonedAccessManager.createGifRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole");
127
+ clonedAccessManager.createGifRole(APPLICATION_SERVICE_ROLE(), "ApplicationServiceRole");
118
128
  clonedAccessManager.createGifRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole");
129
+ clonedAccessManager.createGifRole(CLAIM_SERVICE_ROLE(), "ClaimServiceRole");
119
130
  clonedAccessManager.createGifRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole");
120
131
  clonedAccessManager.createGifRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole");
121
132
  }
122
133
 
123
134
  function _createGifTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
135
+ clonedAccessManager.createGifTarget(address(clonedAccessManager), "InstanceAccessManager");
124
136
  clonedAccessManager.createGifTarget(address(clonedInstance), "Instance");
125
137
  clonedAccessManager.createGifTarget(address(clonedBundleManager), "BundleManager");
126
138
  }
@@ -130,18 +142,27 @@ contract InstanceService is Service, IInstanceService {
130
142
  IRegistry registry = getRegistry();
131
143
  address distributionServiceAddress = registry.getServiceAddress(DISTRIBUTION(), getMajorVersion());
132
144
  clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), distributionServiceAddress);
133
- bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
145
+ bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](11);
134
146
  instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
135
147
  instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
148
+ instanceDistributionServiceSelectors[2] = clonedInstance.createDistributorType.selector;
149
+ instanceDistributionServiceSelectors[3] = clonedInstance.updateDistributorType.selector;
150
+ instanceDistributionServiceSelectors[4] = clonedInstance.updateDistributorTypeState.selector;
151
+ instanceDistributionServiceSelectors[5] = clonedInstance.createDistributor.selector;
152
+ instanceDistributionServiceSelectors[6] = clonedInstance.updateDistributor.selector;
153
+ instanceDistributionServiceSelectors[7] = clonedInstance.updateDistributorState.selector;
154
+ instanceDistributionServiceSelectors[8] = clonedInstance.createReferral.selector;
155
+ instanceDistributionServiceSelectors[9] = clonedInstance.updateReferral.selector;
156
+ instanceDistributionServiceSelectors[10] = clonedInstance.updateReferralState.selector;
136
157
  clonedAccessManager.setTargetFunctionRole(
137
158
  "Instance",
138
159
  instanceDistributionServiceSelectors,
139
- DISTRIBUTION_SERVICE_ROLE());
160
+ DISTRIBUTION_SERVICE_ROLE());
140
161
  }
141
162
 
142
163
  function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
143
164
  // configure authorization for pool service on instance
144
- address poolServiceAddress = _registry.getServiceAddress(POOL(), getMajorVersion());
165
+ address poolServiceAddress = getRegistry().getServiceAddress(POOL(), getMajorVersion());
145
166
  clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
146
167
  bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
147
168
  instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
@@ -154,7 +175,7 @@ contract InstanceService is Service, IInstanceService {
154
175
 
155
176
  function _grantProductServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
156
177
  // configure authorization for product service on instance
157
- address productServiceAddress = _registry.getServiceAddress(PRODUCT(), getMajorVersion());
178
+ address productServiceAddress = getRegistry().getServiceAddress(PRODUCT(), getMajorVersion());
158
179
  clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
159
180
  bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
160
181
  instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
@@ -168,23 +189,50 @@ contract InstanceService is Service, IInstanceService {
168
189
  PRODUCT_SERVICE_ROLE());
169
190
  }
170
191
 
192
+ function _grantApplicationServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
193
+ // configure authorization for application services on instance
194
+ address applicationServiceAddress = getRegistry().getServiceAddress(APPLICATION(), getMajorVersion());
195
+ clonedAccessManager.grantRole(APPLICATION_SERVICE_ROLE(), applicationServiceAddress);
196
+ bytes4[] memory instanceApplicationServiceSelectors = new bytes4[](3);
197
+ instanceApplicationServiceSelectors[0] = clonedInstance.createApplication.selector;
198
+ instanceApplicationServiceSelectors[1] = clonedInstance.updateApplication.selector;
199
+ instanceApplicationServiceSelectors[2] = clonedInstance.updateApplicationState.selector;
200
+ clonedAccessManager.setTargetFunctionRole(
201
+ "Instance",
202
+ instanceApplicationServiceSelectors,
203
+ APPLICATION_SERVICE_ROLE());
204
+ }
205
+
171
206
  function _grantPolicyServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
172
- // configure authorization for policy service on instance
173
- address policyServiceAddress = _registry.getServiceAddress(POLICY(), getMajorVersion());
174
- clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), address(policyServiceAddress));
175
- bytes4[] memory instancePolicyServiceSelectors = new bytes4[](3);
176
- instancePolicyServiceSelectors[0] = clonedInstance.createPolicy.selector;
177
- instancePolicyServiceSelectors[1] = clonedInstance.updatePolicy.selector;
178
- instancePolicyServiceSelectors[2] = clonedInstance.updatePolicyState.selector;
207
+ // configure authorization for policy services on instance
208
+ address policyServiceAddress = getRegistry().getServiceAddress(POLICY(), getMajorVersion());
209
+ clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), policyServiceAddress);
210
+ bytes4[] memory instancePolicyServiceSelectors = new bytes4[](2);
211
+ instancePolicyServiceSelectors[0] = clonedInstance.updatePolicy.selector;
212
+ instancePolicyServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
179
213
  clonedAccessManager.setTargetFunctionRole(
180
214
  "Instance",
181
215
  instancePolicyServiceSelectors,
182
216
  POLICY_SERVICE_ROLE());
183
217
  }
184
218
 
219
+ function _grantClaimServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
220
+ // configure authorization for claim/payout services on instance
221
+ address claimServiceAddress = getRegistry().getServiceAddress(CLAIM(), getMajorVersion());
222
+ clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), claimServiceAddress);
223
+ // TODO add claims function authz
224
+ bytes4[] memory instanceClaimServiceSelectors = new bytes4[](0);
225
+ // instanceClaimServiceSelectors[0] = clonedInstance.updatePolicy.selector;
226
+ // instanceClaimServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
227
+ clonedAccessManager.setTargetFunctionRole(
228
+ "Instance",
229
+ instanceClaimServiceSelectors,
230
+ CLAIM_SERVICE_ROLE());
231
+ }
232
+
185
233
  function _grantBundleServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
186
234
  // configure authorization for bundle service on instance
187
- address bundleServiceAddress = _registry.getServiceAddress(BUNDLE(), getMajorVersion());
235
+ address bundleServiceAddress = getRegistry().getServiceAddress(BUNDLE(), getMajorVersion());
188
236
  clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
189
237
  bytes4[] memory instanceBundleServiceSelectors = new bytes4[](2);
190
238
  instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
@@ -209,7 +257,7 @@ contract InstanceService is Service, IInstanceService {
209
257
 
210
258
  function _grantInstanceServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
211
259
  // configure authorization for instance service on instance
212
- address instanceServiceAddress = _registry.getServiceAddress(INSTANCE(), getMajorVersion());
260
+ address instanceServiceAddress = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
213
261
  clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
214
262
  bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
215
263
  instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
@@ -217,43 +265,67 @@ contract InstanceService is Service, IInstanceService {
217
265
  "Instance",
218
266
  instanceInstanceServiceSelectors,
219
267
  INSTANCE_SERVICE_ROLE());
220
- }
221
268
 
222
- function setMasterInstance(address accessManagerAddress, address instanceAddress, address instanceReaderAddress, address bundleManagerAddress) external onlyOwner {
223
- require(_masterInstanceAccessManager == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
224
- require(_masterInstance == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
225
- require(_masterInstanceBundleManager == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
269
+ bytes4[] memory instanceAccessManagerInstanceServiceSelectors = new bytes4[](1);
270
+ instanceAccessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
271
+ clonedAccessManager.setTargetFunctionRole(
272
+ "InstanceAccessManager",
273
+ instanceAccessManagerInstanceServiceSelectors,
274
+ INSTANCE_SERVICE_ROLE());
275
+ }
226
276
 
227
- require (accessManagerAddress != address(0), "ERROR:CRD-005:ACCESS_MANAGER_ZERO");
228
- require (instanceAddress != address(0), "ERROR:CRD-006:INSTANCE_ZERO");
229
- require (instanceReaderAddress != address(0), "ERROR:CRD-007:INSTANCE_READER_ZERO");
230
- require (bundleManagerAddress != address(0), "ERROR:CRD-008:BUNDLE_MANAGER_ZERO");
277
+ function setAndRegisterMasterInstance(address instanceAddress)
278
+ external
279
+ onlyOwner
280
+ returns(NftId masterInstanceNftId)
281
+ {
282
+ if(_masterInstance != address(0)) { revert ErrorInstanceServiceMasterInstanceAlreadySet(); }
283
+ if(_masterInstanceAccessManager != address(0)) { revert ErrorInstanceServiceMasterInstanceAccessManagerAlreadySet(); }
284
+ if(_masterInstanceBundleManager != address(0)) { revert ErrorInstanceServiceMasterBundleManagerAlreadySet(); }
231
285
 
232
- Instance instance = Instance(instanceAddress);
233
- InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
234
- BundleManager bundleManager = BundleManager(bundleManagerAddress);
286
+ if(instanceAddress == address(0)) { revert ErrorInstanceServiceInstanceAddressZero(); }
235
287
 
236
- 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");
288
+ IInstance instance = IInstance(instanceAddress);
289
+ InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
290
+ address accessManagerAddress = address(accessManager);
291
+ InstanceReader instanceReader = instance.getInstanceReader();
292
+ address instanceReaderAddress = address(instanceReader);
293
+ BundleManager bundleManager = instance.getBundleManager();
294
+ address bundleManagerAddress = address(bundleManager);
295
+
296
+ if(accessManagerAddress == address(0)) { revert ErrorInstanceServiceAccessManagerZero(); }
297
+ if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderZero(); }
298
+ if(bundleManagerAddress == address(0)) { revert ErrorInstanceServiceBundleManagerZero(); }
299
+
300
+ if(instance.authority() != accessManagerAddress) { revert ErrorInstanceServiceInstanceAuthorityMismatch(); }
301
+ if(instanceReader.getInstance() != instance) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch2(); }
302
+ if(bundleManager.getInstance() != instance) { revert ErrorInstanceServiceBundleMangerInstanceMismatch(); }
239
303
 
240
304
  _masterInstanceAccessManager = accessManagerAddress;
241
305
  _masterInstance = instanceAddress;
242
306
  _masterInstanceReader = instanceReaderAddress;
243
307
  _masterInstanceBundleManager = bundleManagerAddress;
308
+
309
+ IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(), getMajorVersion()));
310
+ IInstance masterInstance = IInstance(_masterInstance);
311
+ IRegistry.ObjectInfo memory info = registryService.registerInstance(masterInstance, getOwner());
312
+ masterInstanceNftId = info.nftId;
313
+
314
+ // masterInstance.linkToRegisteredNftId();
244
315
  }
245
316
 
246
317
  function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
247
- require(_masterInstanceReader != address(0), "ERROR:CRD-003:INSTANCE_READER_MASTER_NOT_SET");
248
- require (instanceReaderAddress != address(0), "ERROR:CRD-012:INSTANCE_READER_ZERO");
249
- require(instanceReaderAddress != _masterInstanceReader, "ERROR:CRD-014:INSTANCE_READER_MASTER_SAME_AS_NEW");
318
+ if(_masterInstanceReader == address(0)) { revert ErrorInstanceServiceMasterInstanceReaderNotSet(); }
319
+ if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderAddressZero(); }
320
+ if(instanceReaderAddress == _masterInstanceReader) { revert ErrorInstanceServiceInstanceReaderSameAsMasterInstanceReader(); }
250
321
 
251
322
  InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
252
- require(instanceReader.getInstanceNftId() == Instance(_masterInstance).getNftId(), "ERROR:CRD-015:INSTANCE_READER_INSTANCE_MISMATCH");
323
+ if(instanceReader.getInstance() != IInstance(_masterInstance)) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch(); }
253
324
 
254
325
  _masterInstanceReader = instanceReaderAddress;
255
326
  }
256
327
 
328
+ // TODO access restriction
257
329
  function upgradeInstanceReader(NftId instanceNftId) external {
258
330
  IRegistry registry = getRegistry();
259
331
  IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
@@ -265,7 +337,7 @@ contract InstanceService is Service, IInstanceService {
265
337
  }
266
338
 
267
339
  InstanceReader upgradedInstanceReaderClone = InstanceReader(Clones.clone(address(_masterInstanceReader)));
268
- upgradedInstanceReaderClone.initialize(address(registry), instanceNftId);
340
+ upgradedInstanceReaderClone.initialize(address(registry), address(instance));
269
341
  instance.setInstanceReader(upgradedInstanceReaderClone);
270
342
  }
271
343
 
@@ -304,9 +376,8 @@ contract InstanceService is Service, IInstanceService {
304
376
  (registryAddress, initialOwner) = abi.decode(data, (address, address));
305
377
  // TODO while InstanceService is not deployed in InstanceServiceManager constructor
306
378
  // owner is InstanceServiceManager deployer
307
- _initializeService(registryAddress, owner);
308
-
309
- _registerInterface(type(IInstanceService).interfaceId);
379
+ initializeService(registryAddress, owner);
380
+ registerInterface(type(IInstanceService).interfaceId);
310
381
  }
311
382
 
312
383
  function hasRole(address account, RoleId role, address instanceAddress) public view returns (bool) {
@@ -315,12 +386,86 @@ contract InstanceService is Service, IInstanceService {
315
386
  return accessManager.hasRole(role, account);
316
387
  }
317
388
 
318
- function createTarget(NftId instanceNftId, address targetAddress, string memory targetName) external onlyRegisteredService {
389
+ function createGifTarget(NftId instanceNftId, address targetAddress, string memory targetName) external onlyRegisteredService {
319
390
  IRegistry registry = getRegistry();
320
391
  IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
321
392
  Instance instance = Instance(instanceInfo.objectAddress);
322
393
  InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
323
- accessManager.createTarget(targetAddress, targetName);
394
+ accessManager.createGifTarget(targetAddress, targetName);
395
+ }
396
+
397
+ function grantDistributionDefaultPermissions(NftId instanceNftId, address distributionAddress, string memory distributionName) external onlyRegisteredService {
398
+ IRegistry registry = getRegistry();
399
+ IRegistry.ObjectInfo memory distributionInfo = registry.getObjectInfo(distributionAddress);
400
+
401
+ if (distributionInfo.objectType != DISTRIBUTION()) {
402
+ revert ErrorInstanceServiceInvalidComponentType(distributionAddress, DISTRIBUTION(), distributionInfo.objectType);
403
+ }
404
+
405
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
406
+ Instance instance = Instance(instanceInfo.objectAddress);
407
+ InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
408
+
409
+ bytes4[] memory fctSelectors = new bytes4[](1);
410
+ fctSelectors[0] = IDistributionComponent.setFees.selector;
411
+ instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors, DISTRIBUTION_OWNER_ROLE());
412
+
413
+ bytes4[] memory fctSelectors2 = new bytes4[](2);
414
+ fctSelectors2[0] = IDistributionComponent.processSale.selector;
415
+ fctSelectors2[1] = IDistributionComponent.processRenewal.selector;
416
+ instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors2, PRODUCT_SERVICE_ROLE());
417
+ }
418
+
419
+ function grantPoolDefaultPermissions(NftId instanceNftId, address poolAddress, string memory poolName) external onlyRegisteredService {
420
+ IRegistry registry = getRegistry();
421
+ IRegistry.ObjectInfo memory poolInfo = registry.getObjectInfo(poolAddress);
422
+
423
+ if (poolInfo.objectType != POOL()) {
424
+ revert ErrorInstanceServiceInvalidComponentType(poolAddress, POOL(), poolInfo.objectType);
425
+ }
426
+
427
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
428
+ Instance instance = Instance(instanceInfo.objectAddress);
429
+ InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
430
+
431
+ bytes4[] memory fctSelectors = new bytes4[](1);
432
+ fctSelectors[0] = IPoolComponent.setFees.selector;
433
+ instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors, POOL_OWNER_ROLE());
434
+
435
+ bytes4[] memory fctSelectors2 = new bytes4[](1);
436
+ fctSelectors2[0] = IPoolComponent.verifyApplication.selector;
437
+ instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors2, POLICY_SERVICE_ROLE());
438
+
439
+ // bundle owner specific functions
440
+ bytes4[] memory fctSelectors3 = new bytes4[](7);
441
+ fctSelectors3[0] = IPoolComponent.stake.selector;
442
+ fctSelectors3[1] = IPoolComponent.unstake.selector;
443
+ fctSelectors3[2] = IPoolComponent.extend.selector;
444
+ fctSelectors3[3] = IPoolComponent.lockBundle.selector;
445
+ fctSelectors3[4] = IPoolComponent.unlockBundle.selector;
446
+ fctSelectors3[5] = IPoolComponent.close.selector;
447
+ fctSelectors3[6] = IPoolComponent.setBundleFee.selector;
448
+ instanceAccessManager.setTargetFunctionRole(
449
+ poolName,
450
+ fctSelectors3,
451
+ IPoolComponent(poolAddress).getBundleOwnerRole());
452
+ }
453
+
454
+ function grantProductDefaultPermissions(NftId instanceNftId, address productAddress, string memory productName) external onlyRegisteredService {
455
+ IRegistry registry = getRegistry();
456
+ IRegistry.ObjectInfo memory productInfo = registry.getObjectInfo(productAddress);
457
+
458
+ if (productInfo.objectType != PRODUCT()) {
459
+ revert ErrorInstanceServiceInvalidComponentType(productAddress, PRODUCT(), productInfo.objectType);
460
+ }
461
+
462
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
463
+ Instance instance = Instance(instanceInfo.objectAddress);
464
+ InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
465
+
466
+ bytes4[] memory fctSelectors = new bytes4[](1);
467
+ fctSelectors[0] = IProductComponent.setFees.selector;
468
+ instanceAccessManager.setTargetFunctionRole(productName, fctSelectors, PRODUCT_OWNER_ROLE());
324
469
  }
325
470
 
326
471
  function setTargetLocked(string memory targetName, bool locked) external {
@@ -17,7 +17,7 @@ contract InstanceServiceManager is ProxyManager {
17
17
  constructor(
18
18
  address registryAddress
19
19
  )
20
- ProxyManager()
20
+ ProxyManager(registryAddress)
21
21
  {
22
22
  InstanceService instSrv = new InstanceService();
23
23
  // bytes memory initCode = type(InstanceService).creationCode;
@@ -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 {
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IBaseComponent} from "../../components/IBaseComponent.sol";
4
+ import {IComponent} from "../../components/IComponent.sol";
5
5
  import {IRegistry} from "../../registry/IRegistry.sol";
6
6
  import {IRegistryService} from "../../registry/IRegistryService.sol";
7
7
  import {IInstance} from "../../instance/IInstance.sol";
@@ -14,19 +14,14 @@ import {Service} from "../../shared/Service.sol";
14
14
  import {InstanceService} from "../InstanceService.sol";
15
15
  import {InstanceAccessManager} from "../InstanceAccessManager.sol";
16
16
 
17
- abstract contract ComponentServiceBase is Service {
18
-
17
+ abstract contract ComponentService is Service {
19
18
 
20
19
  error ErrorComponentServiceAlreadyRegistered(address component, NftId nftId);
21
20
  error ErrorComponentServiceNotComponent(address component);
22
21
  error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
23
22
  error ErrorComponentServiceSenderNotOwner(address component, address initialOwner, address sender);
24
23
  error ErrorComponentServiceExpectedRoleMissing(NftId instanceNftId, RoleId requiredRole, address sender);
25
-
26
- error ErrorComponentServiceBaseComponentLocked(address componentAddress);
27
- error ExpectedRoleMissing(RoleId expected, address caller);
28
- error ComponentTypeInvalid(ObjectType componentType);
29
-
24
+ error ErrorComponentServiceComponentLocked(address component);
30
25
 
31
26
  /// @dev modifier to check if caller is a registered service
32
27
  modifier onlyService() {
@@ -54,8 +49,9 @@ abstract contract ComponentServiceBase is Service {
54
49
  RoleId requiredRole
55
50
  )
56
51
  internal
52
+ view
57
53
  returns (
58
- IBaseComponent component,
54
+ IComponent component,
59
55
  address owner,
60
56
  IInstance instance,
61
57
  NftId instanceNftId
@@ -65,19 +61,19 @@ abstract contract ComponentServiceBase is Service {
65
61
  owner = msg.sender;
66
62
 
67
63
  // check component has not already been registerd
68
- NftId compoentNftId = _registry.getNftId(componentAddress);
64
+ NftId compoentNftId = getRegistry().getNftId(componentAddress);
69
65
  if(compoentNftId.gtz()) {
70
66
  revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
71
67
  }
72
68
 
73
69
  // check this is a component
74
- component = IBaseComponent(componentAddress);
75
- if(!component.supportsInterface(type(IBaseComponent).interfaceId)) {
70
+ component = IComponent(componentAddress);
71
+ if(!component.supportsInterface(type(IComponent).interfaceId)) {
76
72
  revert ErrorComponentServiceNotComponent(componentAddress);
77
73
  }
78
74
 
79
75
  // check component is of required type
80
- (IRegistry.ObjectInfo memory componentInfo, ) = component.getInitialInfo();
76
+ IRegistry.ObjectInfo memory componentInfo = component.getInitialInfo();
81
77
  if(componentInfo.objectType != requiredType) {
82
78
  revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
83
79
  }
@@ -1,7 +1,6 @@
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
4
  import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
5
 
7
6
  import {RoleId} from "../../types/RoleId.sol";
@@ -34,15 +33,15 @@ interface IAccess {
34
33
  error ErrorIAccessRoleNameNotUnique(RoleId roleId, ShortString name);
35
34
  error ErrorIAccessRoleInvalidUpdate(RoleId roleId, bool isCustom);
36
35
  error ErrorIAccessRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
37
- error ErrorIAccessSetLockedForNonexstentRole(RoleId roleId);
38
36
  error ErrorIAccessGrantNonexstentRole(RoleId roleId);
39
37
  error ErrorIAccessRevokeNonexstentRole(RoleId roleId);
40
38
  error ErrorIAccessRenounceNonexstentRole(RoleId roleId);
41
39
 
42
40
  error ErrorIAccessTargetAddressZero();
43
- error ErrorIAccessTargetAlreadyExists(address target, ShortString name);
41
+ error ErrorIAccessTargetDoesNotExist(ShortString name);
42
+ error ErrorIAccessTargetAddressDoesNotExist(address target);
43
+ error ErrorIAccessTargetExists(address target, ShortString name);
44
44
  error ErrorIAccessTargetNameEmpty(address target);
45
45
  error ErrorIAccessTargetNameExists(address target, address existingTarget, ShortString name);
46
- error ErrorIAccessSetLockedForNonexstentTarget(address target);
47
46
  error ErrorIAccessTargetLocked(address target);
48
47
  }
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {NftId} from "../../types/NftId.sol";
5
5
  import {Fee} from "../../types/Fee.sol";
6
+ import {Seconds} from "../../types/Seconds.sol";
6
7
  import {Timestamp} from "../../types/Timestamp.sol";
7
8
 
8
9
  interface IBundle {
@@ -13,7 +14,7 @@ interface IBundle {
13
14
  uint256 capitalAmount; // net investment capital + net premiums - payouts
14
15
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
15
16
  uint256 balanceAmount; // total amount of funds: capitalAmount + fees (balance >= captial)
16
- uint256 lifetime;
17
+ Seconds lifetime;
17
18
  Timestamp expiredAt; // no new policies
18
19
  Timestamp closedAt; // no open policies, locked amount = 0
19
20
  }
@@ -24,6 +24,8 @@ interface IDistribution {
24
24
  DistributorType distributorType;
25
25
  bool active;
26
26
  bytes data;
27
+ uint256 sumCommisions;
28
+ uint256 numPoliciesSold;
27
29
  }
28
30
 
29
31
  struct ReferralInfo {