@etherisc/gif-next 0.0.2-e9148e0-933 → 0.0.2-e922e07-736

Sign up to get free protection for your applications and to get access to all the features.
Files changed (352) hide show
  1. package/README.md +136 -2
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  3. package/artifacts/contracts/components/Component.sol/Component.json +774 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +879 -236
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  7. package/artifacts/contracts/{shared/RegisterableUpgradable.sol/RegisterableUpgradable.json → components/IComponent.sol/IComponent.json} +164 -159
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +689 -30
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +838 -58
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +524 -9
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +950 -281
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +568 -188
  18. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  19. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
  20. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  21. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
  22. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  23. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1912 -421
  24. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  25. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +194 -165
  26. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  27. package/artifacts/contracts/instance/Instance.sol/Instance.json +901 -1127
  28. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  29. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +211 -144
  30. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  31. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +126 -159
  32. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  33. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +420 -305
  34. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +297 -112
  36. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  37. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
  38. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  39. package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +189 -177
  40. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
  44. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  46. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  47. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  48. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  52. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  54. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
  55. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +968 -0
  56. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
  57. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +665 -0
  58. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  59. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1096 -0
  60. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  61. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +661 -0
  62. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
  63. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +754 -0
  64. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
  65. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +637 -0
  66. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1221 -213
  68. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +436 -79
  70. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
  71. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +556 -0
  72. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  73. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +633 -0
  74. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
  75. package/artifacts/contracts/instance/service/{IComponentOwnerService.sol/IComponentOwnerService.json → IClaimService.sol/IClaimService.json} +150 -207
  76. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +727 -160
  78. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  79. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +540 -0
  80. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +37 -251
  82. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +47 -414
  84. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1021 -0
  86. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  87. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +689 -0
  88. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +209 -321
  90. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +296 -95
  92. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +218 -499
  94. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +299 -98
  96. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  97. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  98. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  99. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +242 -131
  100. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  101. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +158 -215
  102. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  103. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  104. package/artifacts/contracts/registry/Registry.sol/Registry.json +256 -226
  105. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  106. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  107. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  108. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +202 -318
  109. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  110. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +298 -141
  111. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  112. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
  113. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +141 -53
  115. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  116. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  117. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
  118. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  119. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +40 -29
  120. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
  121. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
  122. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +21 -34
  124. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  125. package/artifacts/contracts/{experiment/inheritance/IB.sol/IB.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +18 -20
  126. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IService.sol/IService.json +31 -183
  128. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -152
  130. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +120 -27
  132. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
  133. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +248 -0
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  135. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +294 -61
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +129 -51
  138. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
  139. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +84 -0
  140. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Service.sol/Service.json +127 -170
  142. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  143. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  144. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  145. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  146. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -152
  147. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +129 -51
  150. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  152. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestService.sol/TestService.json +148 -227
  154. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -190
  158. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  159. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  160. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
  163. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +100 -0
  164. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  166. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  169. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  171. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  172. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  173. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  176. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
  177. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +100 -0
  178. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  180. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  182. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  184. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
  185. package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
  186. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
  189. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  192. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  193. package/contracts/components/Component.sol +221 -0
  194. package/contracts/components/Distribution.sol +200 -79
  195. package/contracts/components/IComponent.sol +68 -0
  196. package/contracts/components/IDistributionComponent.sol +44 -17
  197. package/contracts/components/IPoolComponent.sol +126 -37
  198. package/contracts/components/IProductComponent.sol +10 -5
  199. package/contracts/components/Pool.sol +288 -152
  200. package/contracts/components/Product.sol +124 -119
  201. package/contracts/instance/BundleManager.sol +125 -0
  202. package/contracts/instance/Cloneable.sol +46 -0
  203. package/contracts/instance/IInstance.sol +56 -5
  204. package/contracts/instance/IInstanceService.sol +33 -4
  205. package/contracts/instance/Instance.sol +109 -261
  206. package/contracts/instance/InstanceAccessManager.sol +87 -78
  207. package/contracts/instance/InstanceReader.sol +12 -25
  208. package/contracts/instance/InstanceService.sol +401 -104
  209. package/contracts/instance/InstanceServiceManager.sol +6 -9
  210. package/contracts/instance/ObjectManager.sol +84 -0
  211. package/contracts/instance/base/ComponentService.sol +134 -0
  212. package/contracts/instance/module/IAccess.sol +27 -18
  213. package/contracts/instance/module/IBundle.sol +2 -1
  214. package/contracts/instance/module/IDistribution.sol +2 -0
  215. package/contracts/instance/module/IPolicy.sol +30 -3
  216. package/contracts/instance/module/ISetup.sol +12 -10
  217. package/contracts/instance/service/ApplicationService.sol +349 -0
  218. package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
  219. package/contracts/instance/service/BundleService.sol +299 -0
  220. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  221. package/contracts/instance/service/ClaimService.sol +151 -0
  222. package/contracts/instance/service/ClaimServiceManager.sol +35 -0
  223. package/contracts/instance/service/DistributionService.sol +390 -28
  224. package/contracts/instance/service/DistributionServiceManager.sol +7 -10
  225. package/contracts/instance/service/IApplicationService.sol +82 -0
  226. package/contracts/instance/service/IBundleService.sol +55 -0
  227. package/contracts/instance/service/IClaimService.sol +61 -0
  228. package/contracts/instance/service/IDistributionService.sol +86 -0
  229. package/contracts/instance/service/IPolicyService.sol +72 -0
  230. package/contracts/instance/service/IPoolService.sol +6 -23
  231. package/contracts/instance/service/IProductService.sol +6 -73
  232. package/contracts/instance/service/PolicyService.sol +394 -0
  233. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  234. package/contracts/instance/service/PoolService.sol +38 -123
  235. package/contracts/instance/service/PoolServiceManager.sol +6 -9
  236. package/contracts/instance/service/ProductService.sol +133 -448
  237. package/contracts/instance/service/ProductServiceManager.sol +2 -2
  238. package/contracts/registry/ChainNft.sol +1 -1
  239. package/contracts/registry/IRegistry.sol +39 -19
  240. package/contracts/registry/IRegistryService.sol +30 -13
  241. package/contracts/registry/Registry.sol +236 -216
  242. package/contracts/registry/RegistryAccessManager.sol +216 -0
  243. package/contracts/registry/RegistryService.sol +96 -171
  244. package/contracts/registry/RegistryServiceManager.sol +21 -39
  245. package/contracts/registry/ReleaseManager.sol +322 -0
  246. package/contracts/registry/TokenRegistry.sol +22 -17
  247. package/contracts/shared/ERC165.sol +14 -12
  248. package/contracts/shared/INftOwnable.sol +11 -10
  249. package/contracts/shared/IPolicyHolder.sol +26 -0
  250. package/contracts/shared/IRegisterable.sol +4 -6
  251. package/contracts/shared/IRegistryLinked.sol +12 -0
  252. package/contracts/shared/IService.sol +4 -1
  253. package/contracts/shared/IVersionable.sol +4 -47
  254. package/contracts/shared/NftOwnable.sol +66 -80
  255. package/contracts/shared/PolicyHolder.sol +81 -0
  256. package/contracts/shared/ProxyManager.sol +100 -25
  257. package/contracts/shared/Registerable.sol +16 -32
  258. package/contracts/shared/RegistryLinked.sol +48 -0
  259. package/contracts/shared/Service.sol +25 -22
  260. package/contracts/shared/Versionable.sol +4 -92
  261. package/contracts/test/TestRegisterable.sol +1 -1
  262. package/contracts/test/TestService.sol +4 -3
  263. package/contracts/types/ClaimId.sol +52 -0
  264. package/contracts/types/DistributorType.sol +2 -2
  265. package/contracts/types/NftIdSet.sol +26 -24
  266. package/contracts/types/ObjectType.sol +9 -5
  267. package/contracts/types/PayoutId.sol +54 -0
  268. package/contracts/types/Referral.sol +4 -0
  269. package/contracts/types/RoleId.sol +19 -14
  270. package/contracts/types/Seconds.sol +54 -0
  271. package/contracts/types/Timestamp.sol +12 -13
  272. package/package.json +3 -3
  273. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  274. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -327
  275. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  276. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -280
  277. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
  278. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
  279. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
  280. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
  281. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
  282. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
  283. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
  284. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
  285. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
  286. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
  287. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
  288. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
  289. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
  290. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
  291. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
  292. package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
  293. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
  294. package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
  295. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
  296. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
  297. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
  298. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
  299. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
  300. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
  301. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
  302. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
  303. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
  304. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
  305. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
  306. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
  307. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
  308. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
  309. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
  310. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
  311. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
  312. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
  313. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
  314. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
  315. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
  316. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  317. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  318. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  319. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  320. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  321. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  322. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
  323. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
  324. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  325. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
  326. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  327. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
  328. package/contracts/components/BaseComponent.sol +0 -91
  329. package/contracts/components/IBaseComponent.sol +0 -25
  330. package/contracts/experiment/cloning/Cloner.sol +0 -47
  331. package/contracts/experiment/errors/Require.sol +0 -38
  332. package/contracts/experiment/errors/Revert.sol +0 -44
  333. package/contracts/experiment/inheritance/A.sol +0 -53
  334. package/contracts/experiment/inheritance/B.sol +0 -28
  335. package/contracts/experiment/inheritance/C.sol +0 -34
  336. package/contracts/experiment/inheritance/IA.sol +0 -13
  337. package/contracts/experiment/inheritance/IB.sol +0 -10
  338. package/contracts/experiment/inheritance/IC.sol +0 -12
  339. package/contracts/experiment/statemachine/Dummy.sol +0 -27
  340. package/contracts/experiment/statemachine/ISM.sol +0 -25
  341. package/contracts/experiment/statemachine/SM.sol +0 -57
  342. package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
  343. package/contracts/experiment/types/TypeA.sol +0 -47
  344. package/contracts/experiment/types/TypeB.sol +0 -29
  345. package/contracts/instance/AccessManagedSimple.sol +0 -115
  346. package/contracts/instance/AccessManagerSimple.sol +0 -692
  347. package/contracts/instance/IAccessManagerSimple.sol +0 -391
  348. package/contracts/instance/base/ComponentServiceBase.sol +0 -124
  349. package/contracts/instance/base/IInstanceBase.sol +0 -23
  350. package/contracts/instance/service/ComponentOwnerService.sol +0 -317
  351. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  352. package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -3,151 +3,366 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
5
5
 
6
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
7
- import {InstanceAccessManager} from "./InstanceAccessManager.sol";
8
6
  import {Instance} from "./Instance.sol";
7
+ import {IInstance} from "./IInstance.sol";
8
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
9
9
  import {IInstanceService} from "./IInstanceService.sol";
10
10
  import {InstanceReader} from "./InstanceReader.sol";
11
+ import {BundleManager} from "./BundleManager.sol";
11
12
  import {IRegistry} from "../registry/IRegistry.sol";
12
- import {Registry} from "../registry/Registry.sol";
13
- import {RegistryService} from "../registry/RegistryService.sol";
13
+ import {IRegistryService} from "../registry/IRegistryService.sol";
14
+ import {ChainNft} from "../registry/ChainNft.sol";
14
15
  import {Service} from "../../contracts/shared/Service.sol";
15
16
  import {IService} from "../shared/IService.sol";
16
- import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
17
- import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
17
+ import {NftId} from "../../contracts/types/NftId.sol";
18
18
  import {RoleId} from "../types/RoleId.sol";
19
- import {VersionLib} from "../types/Version.sol";
20
- import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE} from "../types/RoleId.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
- address internal _registryAddress;
25
- address internal _accessManagerMaster;
26
- address internal _instanceMaster;
27
- address internal _instanceReaderMaster;
30
+ address internal _masterInstanceAccessManager;
31
+ address internal _masterInstance;
32
+ address internal _masterInstanceReader;
33
+ address internal _masterInstanceBundleManager;
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";
37
+
38
+ modifier onlyInstanceOwner(NftId instanceNftId) {
39
+ IRegistry registry = getRegistry();
40
+ ChainNft chainNft = ChainNft(registry.getChainNftAddress());
41
+
42
+ if( msg.sender != chainNft.ownerOf(instanceNftId.toInt())) {
43
+ revert ErrorInstanceServiceNotInstanceOwner(msg.sender, instanceNftId);
44
+ }
45
+ _;
46
+ }
47
+
48
+ modifier onlyRegisteredService() {
49
+ address caller = msg.sender;
50
+ if (! getRegistry().isRegisteredService(caller)) {
51
+ revert ErrorInstanceServiceRequestUnauhorized(caller);
52
+ }
53
+ _;
54
+ }
32
55
 
33
56
  function createInstanceClone()
34
57
  external
35
58
  returns (
36
- AccessManagerSimple clonedAccessManager,
59
+ InstanceAccessManager clonedAccessManager,
37
60
  Instance clonedInstance,
38
- NftId instanceNftId,
39
- InstanceReader clonedInstanceReader
61
+ NftId clonedInstanceNftId,
62
+ InstanceReader clonedInstanceReader,
63
+ BundleManager clonedBundleManager
40
64
  )
41
65
  {
42
66
  address instanceOwner = msg.sender;
43
- Registry registry = Registry(_registryAddress);
44
- NftId registryNftId = registry.getNftId(_registryAddress);
45
- address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
46
- RegistryService registryService = RegistryService(registryServiceAddress);
67
+ IRegistry registry = getRegistry();
68
+ address registryAddress = address(registry);
69
+ NftId registryNftId = registry.getNftId(registryAddress);
70
+ address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getMajorVersion());
71
+ IRegistryService registryService = IRegistryService(registryServiceAddress);
47
72
 
48
73
  // initially set the authority of the access managar to this (being the instance service).
49
74
  // This will allow the instance service to bootstrap the authorizations of the instance
50
75
  // and then transfer the ownership of the access manager to the instance owner once everything is setup
51
- clonedAccessManager = AccessManagerSimple(Clones.clone(_accessManagerMaster));
76
+ clonedAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
52
77
  clonedAccessManager.initialize(address(this));
53
78
 
54
- clonedInstance = Instance(Clones.clone(_instanceMaster));
55
- clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
56
- ( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
57
- instanceNftId = info.nftId;
79
+ clonedInstance = Instance(Clones.clone(_masterInstance));
80
+ clonedInstance.initialize(address(clonedAccessManager), registryAddress, registryNftId, msg.sender);
58
81
 
59
- clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
60
- clonedInstanceReader.initialize(_registryAddress, instanceNftId);
82
+ clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
83
+ clonedInstanceReader.initialize(registryAddress, address(clonedInstance));
84
+ clonedInstance.setInstanceReader(clonedInstanceReader);
61
85
 
62
- _grantInitialAuthorizations(clonedAccessManager, clonedInstance);
86
+ clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
87
+ clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, address(clonedInstance));
88
+ clonedInstance.setBundleManager(clonedBundleManager);
89
+
90
+ // TODO amend setters with instance specific , policy manager ...
91
+
92
+ _grantInitialAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
63
93
 
64
- clonedInstance.setInstanceReader(clonedInstanceReader);
65
-
66
94
  // to complete setup switch instance ownership to the instance owner
67
95
  // TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
68
- clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
69
- clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
96
+ clonedAccessManager.grantRole(ADMIN_ROLE(), instanceOwner);
97
+ clonedAccessManager.revokeRole(ADMIN_ROLE(), address(this));
98
+
99
+ IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
100
+ clonedInstanceNftId = info.nftId;
101
+ // clonedInstance.linkToRegisteredNftId();
102
+
103
+ emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
104
+ }
70
105
 
71
- emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), instanceNftId);
106
+ function _grantInitialAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
107
+ _createGifRoles(clonedAccessManager);
108
+ _createGifTargets(clonedAccessManager, clonedInstance, clonedBundleManager);
109
+ _grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstance);
110
+ _grantPoolServiceAuthorizations(clonedAccessManager, clonedInstance);
111
+ _grantProductServiceAuthorizations(clonedAccessManager, clonedInstance);
112
+ _grantApplicationServiceAuthorizations(clonedAccessManager, clonedInstance);
113
+ _grantPolicyServiceAuthorizations(clonedAccessManager, clonedInstance);
114
+ _grantClaimServiceAuthorizations(clonedAccessManager, clonedInstance);
115
+ _grantBundleServiceAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
116
+ _grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance);
72
117
  }
73
118
 
74
- function _grantInitialAuthorizations(AccessManagerSimple clonedAccessManager, Instance clonedInstance) internal {
75
- address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
76
- clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
77
- bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
119
+ function _createGifRoles(InstanceAccessManager clonedAccessManager) internal {
120
+ clonedAccessManager.createGifRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole");
121
+ clonedAccessManager.createGifRole(POOL_OWNER_ROLE(), "PoolOwnerRole");
122
+ clonedAccessManager.createGifRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole");
123
+
124
+ clonedAccessManager.createGifRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole");
125
+ clonedAccessManager.createGifRole(POOL_SERVICE_ROLE(), "PoolServiceRole");
126
+ clonedAccessManager.createGifRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole");
127
+ clonedAccessManager.createGifRole(APPLICATION_SERVICE_ROLE(), "ApplicationServiceRole");
128
+ clonedAccessManager.createGifRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole");
129
+ clonedAccessManager.createGifRole(CLAIM_SERVICE_ROLE(), "ClaimServiceRole");
130
+ clonedAccessManager.createGifRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole");
131
+ clonedAccessManager.createGifRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole");
132
+ }
133
+
134
+ function _createGifTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
135
+ clonedAccessManager.createGifTarget(address(clonedAccessManager), "InstanceAccessManager");
136
+ clonedAccessManager.createGifTarget(address(clonedInstance), "Instance");
137
+ clonedAccessManager.createGifTarget(address(clonedBundleManager), "BundleManager");
138
+ }
139
+
140
+ function _grantDistributionServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
141
+ // configure authorization for distribution service on instance
142
+ IRegistry registry = getRegistry();
143
+ address distributionServiceAddress = registry.getServiceAddress(DISTRIBUTION(), getMajorVersion());
144
+ clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), distributionServiceAddress);
145
+ bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](11);
78
146
  instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
79
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;
80
157
  clonedAccessManager.setTargetFunctionRole(
81
- address(clonedInstance),
158
+ "Instance",
82
159
  instanceDistributionServiceSelectors,
83
- DISTRIBUTION_SERVICE_ROLE().toInt());
160
+ DISTRIBUTION_SERVICE_ROLE());
161
+ }
84
162
 
85
- address poolServiceAddress = _registry.getServiceAddress("PoolService", VersionLib.toVersion(3, 0, 0).toMajorPart());
86
- clonedAccessManager.grantRole(POOL_SERVICE_ROLE().toInt(), address(poolServiceAddress), 0);
163
+ function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
164
+ // configure authorization for pool service on instance
165
+ address poolServiceAddress = getRegistry().getServiceAddress(POOL(), getMajorVersion());
166
+ clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
87
167
  bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
88
168
  instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
89
169
  instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
90
- instancePoolServiceSelectors[2] = clonedInstance.createBundle.selector;
91
- instancePoolServiceSelectors[3] = clonedInstance.updateBundle.selector;
92
170
  clonedAccessManager.setTargetFunctionRole(
93
- address(clonedInstance),
171
+ "Instance",
94
172
  instancePoolServiceSelectors,
95
- POOL_SERVICE_ROLE().toInt());
173
+ POOL_SERVICE_ROLE());
174
+ }
96
175
 
97
- address productServiceAddress = _registry.getServiceAddress("ProductService", VersionLib.toVersion(3, 0, 0).toMajorPart());
98
- clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE().toInt(), address(productServiceAddress), 0);
99
- bytes4[] memory instanceProductServiceSelectors = new bytes4[](2);
176
+ function _grantProductServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
177
+ // configure authorization for product service on instance
178
+ address productServiceAddress = getRegistry().getServiceAddress(PRODUCT(), getMajorVersion());
179
+ clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
180
+ bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
100
181
  instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
101
182
  instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
183
+ instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
184
+ instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
185
+ instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
102
186
  clonedAccessManager.setTargetFunctionRole(
103
- address(clonedInstance),
187
+ "Instance",
104
188
  instanceProductServiceSelectors,
105
- PRODUCT_SERVICE_ROLE().toInt());
189
+ PRODUCT_SERVICE_ROLE());
106
190
  }
107
191
 
108
- function setAccessManagerMaster(address accessManagerMaster) external {
109
- require(
110
- _accessManagerMaster == address(0),
111
- "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
112
- _accessManagerMaster = accessManagerMaster;
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());
113
204
  }
114
205
 
115
- function setInstanceMaster(address instanceMaster) external {
116
- require(
117
- _instanceMaster == address(0),
118
- "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
119
- _instanceMaster = instanceMaster;
206
+ function _grantPolicyServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
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;
213
+ clonedAccessManager.setTargetFunctionRole(
214
+ "Instance",
215
+ instancePolicyServiceSelectors,
216
+ POLICY_SERVICE_ROLE());
120
217
  }
121
218
 
122
- function setInstanceReaderMaster(address instanceReaderMaster) external {
123
- require(
124
- _instanceReaderMaster == address(0),
125
- "ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
126
- _instanceReaderMaster = instanceReaderMaster;
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());
127
231
  }
128
232
 
129
- function getInstanceReaderMaster() external view returns (address) {
130
- return _instanceReaderMaster;
233
+ function _grantBundleServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
234
+ // configure authorization for bundle service on instance
235
+ address bundleServiceAddress = getRegistry().getServiceAddress(BUNDLE(), getMajorVersion());
236
+ clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
237
+ bytes4[] memory instanceBundleServiceSelectors = new bytes4[](2);
238
+ instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
239
+ instanceBundleServiceSelectors[1] = clonedInstance.updateBundle.selector;
240
+ clonedAccessManager.setTargetFunctionRole(
241
+ "Instance",
242
+ instanceBundleServiceSelectors,
243
+ BUNDLE_SERVICE_ROLE());
244
+
245
+ // configure authorization for bundle service on bundle manager
246
+ bytes4[] memory bundleManagerBundleServiceSelectors = new bytes4[](5);
247
+ bundleManagerBundleServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
248
+ bundleManagerBundleServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
249
+ bundleManagerBundleServiceSelectors[2] = clonedBundleManager.add.selector;
250
+ bundleManagerBundleServiceSelectors[3] = clonedBundleManager.lock.selector;
251
+ bundleManagerBundleServiceSelectors[4] = clonedBundleManager.unlock.selector;
252
+ clonedAccessManager.setTargetFunctionRole(
253
+ "BundleManager",
254
+ bundleManagerBundleServiceSelectors,
255
+ BUNDLE_SERVICE_ROLE());
131
256
  }
132
257
 
133
- function getInstanceMaster() external view returns (address) {
134
- return _instanceMaster;
258
+ function _grantInstanceServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
259
+ // configure authorization for instance service on instance
260
+ address instanceServiceAddress = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
261
+ clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
262
+ bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
263
+ instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
264
+ clonedAccessManager.setTargetFunctionRole(
265
+ "Instance",
266
+ instanceInstanceServiceSelectors,
267
+ INSTANCE_SERVICE_ROLE());
268
+
269
+ bytes4[] memory instanceAccessManagerInstanceServiceSelectors = new bytes4[](1);
270
+ instanceAccessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
271
+ clonedAccessManager.setTargetFunctionRole(
272
+ "InstanceAccessManager",
273
+ instanceAccessManagerInstanceServiceSelectors,
274
+ INSTANCE_SERVICE_ROLE());
135
275
  }
136
276
 
137
- function getAccessManagerMaster() external view returns (address) {
138
- return _accessManagerMaster;
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(); }
285
+
286
+ if(instanceAddress == address(0)) { revert ErrorInstanceServiceInstanceAddressZero(); }
287
+
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(); }
303
+
304
+ _masterInstanceAccessManager = accessManagerAddress;
305
+ _masterInstance = instanceAddress;
306
+ _masterInstanceReader = instanceReaderAddress;
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();
315
+ }
316
+
317
+ function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
318
+ if(_masterInstanceReader == address(0)) { revert ErrorInstanceServiceMasterInstanceReaderNotSet(); }
319
+ if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderAddressZero(); }
320
+ if(instanceReaderAddress == _masterInstanceReader) { revert ErrorInstanceServiceInstanceReaderSameAsMasterInstanceReader(); }
321
+
322
+ InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
323
+ if(instanceReader.getInstance() != IInstance(_masterInstance)) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch(); }
324
+
325
+ _masterInstanceReader = instanceReaderAddress;
326
+ }
327
+
328
+ // TODO access restriction
329
+ function upgradeInstanceReader(NftId instanceNftId) external {
330
+ IRegistry registry = getRegistry();
331
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
332
+ Instance instance = Instance(instanceInfo.objectAddress);
333
+ address owner = instance.getOwner();
334
+
335
+ if (msg.sender != owner) {
336
+ revert ErrorInstanceServiceRequestUnauhorized(msg.sender);
337
+ }
338
+
339
+ InstanceReader upgradedInstanceReaderClone = InstanceReader(Clones.clone(address(_masterInstanceReader)));
340
+ upgradedInstanceReaderClone.initialize(address(registry), address(instance));
341
+ instance.setInstanceReader(upgradedInstanceReaderClone);
342
+ }
343
+
344
+ function getMasterInstanceReader() external view returns (address) {
345
+ return _masterInstanceReader;
346
+ }
347
+
348
+ function getMasterInstance() external view returns (address) {
349
+ return _masterInstance;
350
+ }
351
+
352
+ function getMasterInstanceAccessManager() external view returns (address) {
353
+ return _masterInstanceAccessManager;
354
+ }
355
+
356
+ function getMasterInstanceBundleManager() external view returns (address) {
357
+ return _masterInstanceBundleManager;
139
358
  }
140
359
 
141
360
  // From IService
142
- function getName() public pure override(IService, Service) returns(string memory) {
143
- return NAME;
361
+ function getDomain() public pure override(Service, IService) returns(ObjectType) {
362
+ return INSTANCE();
144
363
  }
145
364
 
146
365
  /// @dev top level initializer
147
- // 1) registry is non upgradeable -> don't need a proxy and uses constructor !
148
- // 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
149
- // 3) deploy registry -> pass registry service address as constructor argument
150
- // registry is getting instantiated and locked to registry service address forever
151
366
  function _initialize(
152
367
  address owner,
153
368
  bytes memory data
@@ -156,37 +371,119 @@ contract InstanceService is Service, IInstanceService {
156
371
  initializer
157
372
  virtual override
158
373
  {
159
- // bytes memory encodedConstructorArguments = abi.encode(
160
- // _registryAddress);
161
-
162
- // bytes memory instanceCreationCode = ContractDeployerLib.getCreationCode(
163
- // instanceByteCodeWithInitCode,
164
- // encodedConstructorArguments);
165
-
166
- // address instanceAddress = ContractDeployerLib.deploy(
167
- // instanceCreationCode,
168
- // INSTANCE_CREATION_CODE_HASH);
169
-
170
- address initialOwner = address(0);
171
- (_registryAddress, initialOwner) = abi.decode(data, (address, address));
374
+ address initialOwner;
375
+ address registryAddress;
376
+ (registryAddress, initialOwner) = abi.decode(data, (address, address));
172
377
  // TODO while InstanceService is not deployed in InstanceServiceManager constructor
173
378
  // owner is InstanceServiceManager deployer
174
- _initializeService(_registryAddress, owner);
175
-
176
- _registerInterface(type(IService).interfaceId);
177
- _registerInterface(type(IInstanceService).interfaceId);
379
+ initializeService(registryAddress, owner);
380
+ registerInterface(type(IInstanceService).interfaceId);
178
381
  }
179
382
 
180
- function hasRole(address account, RoleId role, NftId instanceNftId) external view returns (bool) {
181
- IRegistry.ObjectInfo memory instanceObjectInfo = getRegistry().getObjectInfo(instanceNftId);
182
- address instanceAddress = instanceObjectInfo.objectAddress;
383
+ function hasRole(address account, RoleId role, address instanceAddress) public view returns (bool) {
183
384
  Instance instance = Instance(instanceAddress);
184
- AccessManagerSimple accessManager = AccessManagerSimple(instance.authority());
185
- (bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
186
- if (executionDelay > 0) {
187
- return false;
188
- }
189
- return isMember;
385
+ InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
386
+ return accessManager.hasRole(role, account);
387
+ }
388
+
389
+ function createGifTarget(NftId instanceNftId, address targetAddress, string memory targetName) external onlyRegisteredService {
390
+ IRegistry registry = getRegistry();
391
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
392
+ Instance instance = Instance(instanceInfo.objectAddress);
393
+ InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
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[](1);
414
+ fctSelectors2[0] = IDistributionComponent.processRenewal.selector;
415
+ instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors2, PRODUCT_SERVICE_ROLE());
190
416
  }
417
+
418
+ function grantPoolDefaultPermissions(NftId instanceNftId, address poolAddress, string memory poolName) external onlyRegisteredService {
419
+ IRegistry registry = getRegistry();
420
+ IRegistry.ObjectInfo memory poolInfo = registry.getObjectInfo(poolAddress);
421
+
422
+ if (poolInfo.objectType != POOL()) {
423
+ revert ErrorInstanceServiceInvalidComponentType(poolAddress, POOL(), poolInfo.objectType);
424
+ }
425
+
426
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
427
+ Instance instance = Instance(instanceInfo.objectAddress);
428
+ InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
429
+
430
+ bytes4[] memory fctSelectors = new bytes4[](1);
431
+ fctSelectors[0] = IPoolComponent.setFees.selector;
432
+ instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors, POOL_OWNER_ROLE());
433
+
434
+ bytes4[] memory fctSelectors2 = new bytes4[](1);
435
+ fctSelectors2[0] = IPoolComponent.verifyApplication.selector;
436
+ instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors2, POLICY_SERVICE_ROLE());
437
+
438
+ // bundle owner specific functions
439
+ bytes4[] memory fctSelectors3 = new bytes4[](7);
440
+ fctSelectors3[0] = IPoolComponent.stake.selector;
441
+ fctSelectors3[1] = IPoolComponent.unstake.selector;
442
+ fctSelectors3[2] = IPoolComponent.extend.selector;
443
+ fctSelectors3[3] = IPoolComponent.lockBundle.selector;
444
+ fctSelectors3[4] = IPoolComponent.unlockBundle.selector;
445
+ fctSelectors3[5] = IPoolComponent.close.selector;
446
+ fctSelectors3[6] = IPoolComponent.setBundleFee.selector;
447
+ instanceAccessManager.setTargetFunctionRole(
448
+ poolName,
449
+ fctSelectors3,
450
+ IPoolComponent(poolAddress).getBundleOwnerRole());
451
+ }
452
+
453
+ function grantProductDefaultPermissions(NftId instanceNftId, address productAddress, string memory productName) external onlyRegisteredService {
454
+ IRegistry registry = getRegistry();
455
+ IRegistry.ObjectInfo memory productInfo = registry.getObjectInfo(productAddress);
456
+
457
+ if (productInfo.objectType != PRODUCT()) {
458
+ revert ErrorInstanceServiceInvalidComponentType(productAddress, PRODUCT(), productInfo.objectType);
459
+ }
460
+
461
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
462
+ Instance instance = Instance(instanceInfo.objectAddress);
463
+ InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
464
+
465
+ bytes4[] memory fctSelectors = new bytes4[](1);
466
+ fctSelectors[0] = IProductComponent.setFees.selector;
467
+ instanceAccessManager.setTargetFunctionRole(productName, fctSelectors, PRODUCT_OWNER_ROLE());
468
+ }
469
+
470
+ function setTargetLocked(string memory targetName, bool locked) external {
471
+ address componentAddress = msg.sender;
472
+ IRegistry registry = getRegistry();
473
+ IRegistry.ObjectInfo memory componentInfo = registry.getObjectInfo(componentAddress);
474
+ if (componentInfo.nftId.eqz()) {
475
+ revert ErrorInstanceServiceComponentNotRegistered(componentAddress);
476
+ }
477
+
478
+ // TODO validate component type
479
+
480
+
481
+ address instanceAddress = registry.getObjectInfo(componentInfo.parentNftId).objectAddress;
482
+ IInstance instance = IInstance(instanceAddress);
483
+
484
+ InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
485
+ accessManager.setTargetClosed(targetName, locked);
486
+ }
487
+
191
488
  }
192
489
 
@@ -7,7 +7,7 @@ import {ProxyManager} from "../shared/ProxyManager.sol";
7
7
  import {InstanceService} from "./InstanceService.sol";
8
8
  import {Registry} from "../registry/Registry.sol";
9
9
  import {RegistryService} from "../registry/RegistryService.sol";
10
- import {VersionLib} from "../types/Version.sol";
10
+ import {REGISTRY} from "../types/ObjectType.sol";
11
11
 
12
12
  contract InstanceServiceManager is ProxyManager {
13
13
 
@@ -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;
@@ -28,10 +28,10 @@ contract InstanceServiceManager is ProxyManager {
28
28
 
29
29
  _instanceService = InstanceService(address(versionable));
30
30
 
31
- Registry registry = Registry(registryAddress);
32
- address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
33
- RegistryService registryService = RegistryService(registryServiceAddress);
34
- // TODO this must have a role or own nft to register service
31
+ // TODO `this` must have a role or own nft to register service
32
+ //Registry registry = Registry(registryAddress);
33
+ //address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _instanceService.getMajorVersion());
34
+ //RegistryService registryService = RegistryService(registryServiceAddress);
35
35
  //registryService.registerService(_instanceService);
36
36
  // RegistryService registryService = _instanceService.getRegistryService();
37
37
 
@@ -40,9 +40,6 @@ contract InstanceServiceManager is ProxyManager {
40
40
  //_linkToNftOwnable(
41
41
  // address(registryAddress),
42
42
  // address(_instanceService));
43
-
44
- // implies that after this constructor call only upgrade functionality is available
45
- _isDeployed = true;
46
43
  }
47
44
 
48
45
  //--- view functions ----------------------------------------------------//