@etherisc/gif-next 0.0.2-e37834a-021 → 0.0.2-e38b7e6-931

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/README.md +171 -2
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +282 -2
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +313 -72
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +234 -3
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -25
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +24 -57
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +5 -55
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +378 -127
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +391 -107
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
  21. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
  22. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
  23. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
  24. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  40. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  41. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  42. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  43. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  44. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  45. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  46. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  47. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  48. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  49. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  50. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  51. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +813 -1184
  52. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  53. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  54. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  55. package/artifacts/contracts/instance/{base/IService.sol/IService.json → IInstanceService.sol/IInstanceService.json} +244 -18
  56. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  57. package/artifacts/contracts/instance/Instance.sol/Instance.json +1762 -1332
  58. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  59. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +1047 -0
  60. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  61. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  62. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  63. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1422 -0
  64. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  65. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +963 -0
  66. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  67. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +460 -0
  68. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  69. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  70. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  71. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +240 -11
  72. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  73. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -13
  74. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  75. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
  76. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  77. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  78. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +37 -245
  79. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  80. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  81. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  82. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
  83. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  84. package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
  85. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  86. package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
  87. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  88. package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
  89. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  90. package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
  91. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  92. package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
  93. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  94. package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
  95. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  96. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1121 -0
  97. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  98. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +436 -0
  99. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +304 -39
  101. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  102. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +424 -0
  103. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  104. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +720 -0
  105. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  106. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +93 -16
  107. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  108. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +771 -0
  109. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  110. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +95 -80
  111. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  112. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +89 -227
  113. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  114. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1246 -0
  115. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  116. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +492 -0
  117. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  118. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +287 -111
  119. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  120. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +424 -0
  121. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  122. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +258 -347
  123. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  124. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +424 -0
  125. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  126. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
  127. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  128. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +157 -71
  129. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  130. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +339 -31
  131. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  132. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  133. package/artifacts/contracts/registry/Registry.sol/Registry.json +131 -212
  134. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  135. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  136. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  137. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +382 -72
  138. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  139. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +68 -77
  140. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  141. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +530 -0
  142. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  143. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +397 -0
  144. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  145. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  146. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  147. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  148. package/artifacts/contracts/{instance/module/component/ComponentModule.sol/ComponentModule.json → shared/INftOwnable.sol/INftOwnable.json} +67 -57
  149. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  150. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +80 -3
  151. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  152. package/artifacts/contracts/{instance/service/IComponentOwnerService.sol/IComponentOwnerService.json → shared/IService.sol/IService.json} +90 -58
  153. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  154. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  155. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +32 -6
  156. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  157. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +21 -16
  158. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  159. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +120 -6
  160. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
  161. package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/RegisterableUpgradable.sol/RegisterableUpgradable.json} +92 -30
  162. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  163. package/artifacts/contracts/{instance/base/InstanceBase.sol/InstanceBase.json → shared/Service.sol/Service.json} +100 -88
  164. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  165. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  166. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  167. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  168. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  169. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  170. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  171. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  172. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +120 -6
  173. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  174. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
  175. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  176. package/artifacts/contracts/test/TestService.sol/TestService.json +155 -27
  177. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  178. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  179. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  180. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  181. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  182. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +18 -2
  183. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  184. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  185. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  186. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  189. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  190. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
  192. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
  194. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  196. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  197. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  198. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  199. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  200. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  201. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  202. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  203. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  204. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  205. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  206. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  207. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
  208. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  209. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  210. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  211. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
  212. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  213. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  214. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  215. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  216. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  217. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  218. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  219. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  220. package/contracts/components/BaseComponent.sol +107 -18
  221. package/contracts/components/Distribution.sol +24 -25
  222. package/contracts/components/IBaseComponent.sol +20 -4
  223. package/contracts/components/IDistributionComponent.sol +2 -4
  224. package/contracts/components/IPoolComponent.sol +5 -3
  225. package/contracts/components/IProductComponent.sol +4 -6
  226. package/contracts/components/Pool.sol +58 -46
  227. package/contracts/components/Product.sol +71 -75
  228. package/contracts/experiment/cloning/Cloner.sol +47 -0
  229. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  230. package/contracts/instance/BundleManager.sol +129 -0
  231. package/contracts/instance/Cloneable.sol +46 -0
  232. package/contracts/instance/IInstance.sol +54 -48
  233. package/contracts/instance/IInstanceBase.sol +25 -0
  234. package/contracts/instance/IInstanceService.sol +40 -0
  235. package/contracts/instance/Instance.sol +245 -68
  236. package/contracts/instance/InstanceAccessManager.sol +303 -0
  237. package/contracts/instance/InstanceBase.sol +39 -0
  238. package/contracts/instance/InstanceReader.sol +315 -0
  239. package/contracts/instance/InstanceService.sol +345 -0
  240. package/contracts/instance/InstanceServiceManager.sol +54 -0
  241. package/contracts/instance/ObjectManager.sol +101 -0
  242. package/contracts/instance/base/ComponentServiceBase.sol +109 -20
  243. package/contracts/instance/base/IInstanceBase.sol +0 -2
  244. package/contracts/instance/base/IKeyValueStore.sol +13 -14
  245. package/contracts/instance/base/ILifecycle.sol +3 -3
  246. package/contracts/instance/base/KeyValueStore.sol +49 -38
  247. package/contracts/instance/base/Lifecycle.sol +1 -1
  248. package/contracts/instance/module/IAccess.sol +48 -0
  249. package/contracts/instance/module/IBundle.sol +20 -0
  250. package/contracts/instance/module/IDistribution.sol +39 -0
  251. package/contracts/instance/module/IPolicy.sol +45 -0
  252. package/contracts/instance/module/IRisk.sol +11 -0
  253. package/contracts/instance/module/ISetup.sol +46 -0
  254. package/contracts/instance/module/ITreasury.sol +23 -0
  255. package/contracts/instance/service/BundleService.sol +294 -0
  256. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  257. package/contracts/instance/service/DistributionService.sol +79 -18
  258. package/contracts/instance/service/DistributionServiceManager.sol +51 -0
  259. package/contracts/instance/service/IBundleService.sol +44 -0
  260. package/contracts/instance/service/IDistributionService.sol +1 -1
  261. package/contracts/instance/service/IPolicyService.sol +94 -0
  262. package/contracts/instance/service/IPoolService.sol +7 -24
  263. package/contracts/instance/service/IProductService.sol +9 -76
  264. package/contracts/instance/service/PolicyService.sol +539 -0
  265. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  266. package/contracts/instance/service/PoolService.sol +101 -108
  267. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  268. package/contracts/instance/service/ProductService.sol +130 -431
  269. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  270. package/contracts/registry/ChainNft.sol +41 -26
  271. package/contracts/registry/IRegistry.sol +48 -30
  272. package/contracts/registry/IRegistryService.sol +53 -24
  273. package/contracts/registry/Registry.sol +212 -306
  274. package/contracts/registry/RegistryAccessManager.sol +210 -0
  275. package/contracts/registry/RegistryService.sol +151 -206
  276. package/contracts/registry/RegistryServiceManager.sol +26 -16
  277. package/contracts/registry/ReleaseManager.sol +342 -0
  278. package/contracts/registry/TokenRegistry.sol +110 -0
  279. package/contracts/shared/ERC165.sol +7 -3
  280. package/contracts/shared/INftOwnable.sol +22 -0
  281. package/contracts/shared/IRegisterable.sol +3 -10
  282. package/contracts/shared/IService.sol +16 -0
  283. package/contracts/shared/NftOwnable.sol +85 -38
  284. package/contracts/shared/ProxyManager.sol +4 -13
  285. package/contracts/shared/Registerable.sol +15 -42
  286. package/contracts/shared/RegisterableUpgradable.sol +16 -0
  287. package/contracts/shared/Service.sol +58 -0
  288. package/contracts/shared/TokenHandler.sol +27 -0
  289. package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
  290. package/contracts/shared/Versionable.sol +3 -3
  291. package/contracts/test/TestFee.sol +2 -2
  292. package/contracts/test/TestRoleId.sol +1 -1
  293. package/contracts/test/TestService.sol +6 -7
  294. package/contracts/types/DistributorType.sol +55 -0
  295. package/contracts/types/Fee.sol +3 -3
  296. package/contracts/types/Key32.sol +8 -3
  297. package/contracts/types/NftIdSet.sol +26 -24
  298. package/contracts/types/NumberId.sol +52 -0
  299. package/contracts/types/ObjectType.sol +35 -14
  300. package/contracts/types/Referral.sol +85 -0
  301. package/contracts/types/RoleId.sol +61 -9
  302. package/contracts/types/StateId.sol +5 -1
  303. package/contracts/types/Timestamp.sol +7 -3
  304. package/contracts/types/UFixed.sol +128 -12
  305. package/contracts/types/Version.sol +4 -1
  306. package/package.json +4 -3
  307. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
  308. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
  309. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  310. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  311. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
  312. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  313. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  314. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  315. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  316. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
  317. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  318. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  319. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
  320. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
  321. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
  322. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
  323. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
  324. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  325. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
  326. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
  327. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  328. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +0 -117
  329. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
  330. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
  331. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
  332. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
  333. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
  334. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  335. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  336. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -284
  337. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  338. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -284
  339. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  340. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
  341. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  342. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -164
  343. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  344. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -164
  345. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
  346. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
  347. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
  348. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
  349. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
  350. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
  351. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
  352. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -638
  353. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
  354. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
  355. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
  356. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -638
  357. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  358. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -690
  359. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  360. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  361. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
  362. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  363. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  364. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
  365. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -445
  366. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
  367. package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -602
  368. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
  369. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -632
  370. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
  371. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
  372. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  373. package/contracts/instance/IInstanceLinked.sol +0 -8
  374. package/contracts/instance/base/IService.sol +0 -15
  375. package/contracts/instance/base/InstanceBase.sol +0 -89
  376. package/contracts/instance/base/ModuleBase.sol +0 -57
  377. package/contracts/instance/base/ServiceBase.sol +0 -43
  378. package/contracts/instance/module/access/Access.sol +0 -149
  379. package/contracts/instance/module/access/IAccess.sol +0 -53
  380. package/contracts/instance/module/bundle/BundleModule.sol +0 -134
  381. package/contracts/instance/module/bundle/IBundle.sol +0 -53
  382. package/contracts/instance/module/component/ComponentModule.sol +0 -71
  383. package/contracts/instance/module/component/IComponent.sol +0 -28
  384. package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
  385. package/contracts/instance/module/distribution/IDistribution.sol +0 -10
  386. package/contracts/instance/module/policy/IPolicy.sol +0 -63
  387. package/contracts/instance/module/policy/PolicyModule.sol +0 -91
  388. package/contracts/instance/module/pool/IPoolModule.sol +0 -41
  389. package/contracts/instance/module/pool/PoolModule.sol +0 -95
  390. package/contracts/instance/module/risk/IRisk.sol +0 -26
  391. package/contracts/instance/module/risk/RiskModule.sol +0 -62
  392. package/contracts/instance/module/treasury/ITreasury.sol +0 -84
  393. package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
  394. package/contracts/instance/module/treasury/TreasuryModule.sol +0 -131
  395. package/contracts/instance/service/ComponentOwnerService.sol +0 -272
  396. package/contracts/instance/service/IComponentOwnerService.sol +0 -20
  397. package/contracts/registry/IChainNft.sol +0 -22
  398. package/contracts/shared/IOwnable.sol +0 -6
  399. package/contracts/test/TestDistribution.sol +0 -22
  400. package/contracts/test/TestPool.sol +0 -27
  401. package/contracts/test/TestProduct.sol +0 -74
  402. package/contracts/types/ReferralId.sol +0 -48
@@ -1,14 +1,13 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
4
+ import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
5
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
6
 
6
- import {IRegistry} from "../registry/IRegistry.sol";
7
+ import {IRegistry} from "./IRegistry.sol";
7
8
  import {IInstance} from "../instance/IInstance.sol";
8
9
 
9
10
  import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
10
- import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
11
- import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
12
11
  import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
13
12
  import {IPoolComponent} from "../../contracts/components/IPoolComponent.sol";
14
13
  import {IProductComponent} from "../../contracts/components/IProductComponent.sol";
@@ -17,274 +16,215 @@ import {IDistributionComponent} from "../../contracts/components/IDistributionCo
17
16
  import {IVersionable} from "../../contracts/shared/IVersionable.sol";
18
17
  import {Versionable} from "../../contracts/shared/Versionable.sol";
19
18
  import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
19
+ import {Registerable} from "../../contracts/shared/Registerable.sol";
20
20
 
21
21
  import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
22
- import {ObjectType, REGISTRY, TOKEN, SERVICE, PRODUCT, ORACLE, POOL, TOKEN, INSTANCE, DISTRIBUTION, POLICY, BUNDLE} from "../../contracts/types/ObjectType.sol";
22
+ import {ObjectType, REGISTRY, SERVICE, PRODUCT, ORACLE, POOL, INSTANCE, DISTRIBUTION, POLICY, BUNDLE, STAKE} from "../../contracts/types/ObjectType.sol";
23
23
  import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
24
24
  import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
25
25
  import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
26
26
  import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
27
27
 
28
- import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
29
- import {IService} from "../../contracts/instance/base/IService.sol";
28
+ import {Service} from "../shared/Service.sol";
29
+ import {IService} from "../shared/IService.sol";
30
30
  import {IRegistryService} from "./IRegistryService.sol";
31
- import {Registry} from "../registry/Registry.sol";
31
+ import {Registry} from "./Registry.sol";
32
32
 
33
33
  contract RegistryService is
34
- ServiceBase,
34
+ AccessManagedUpgradeable,
35
+ Service,
35
36
  IRegistryService
36
37
  {
37
38
  using NftIdLib for NftId;
38
39
 
39
- error NotRegistryOwner();
40
- error MissingAllowance();
41
-
42
- error NotToken();
43
- error NotService();
44
- error NotComponent();
45
- error NotInstance();
46
-
47
- error InvalidAddress(address registerableAddress);
48
- error InvalidInitialOwner(address initialOwner);
49
- error SelfRegistration();
50
- error InvalidType(ObjectType objectType);
51
-
52
- string public constant NAME = "RegistryService";
53
-
54
40
  // TODO update to real hash when registry is stable
55
41
  bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
56
42
 
57
- address constant public NFT_LOCK_ADDRESS = address(0x1);
58
-
59
- /// @dev
60
- // msg.sender - ONLY registry owner
61
- // CAN register ANY non IRegisterable address
62
- // CAN register ONLY valid object-parent types combinations for TOKEN
63
- // CAN NOT register itself
64
- // IMPORTANT: MUST NOT call untrusted contract inbetween calls to registry/instance (trusted contracts)
65
- // motivation: registry/instance state may change during external call
66
- // TODO it may be usefull to have transferable token nft in order to delist token, make it invalid for new beginings
67
- // TODO: MUST prohibit registration of precompiles addresses
68
- function registerToken(address tokenAddress)
69
- external
70
- returns(NftId nftId)
71
- {
72
- IRegisterable registerable = IRegisterable(tokenAddress);
73
- bool isRegisterable;
74
-
75
- // registryOwner can not register IRegisterable as TOKEN
76
- try registerable.supportsInterface(type(IRegisterable).interfaceId) returns(bool result) {
77
- isRegisterable = result;
78
- } catch {
79
- isRegisterable = false;
80
- }
81
-
82
- if(isRegisterable) {
83
- revert NotToken();
84
- }
43
+ address public constant NFT_LOCK_ADDRESS = address(0x1);
85
44
 
86
- IRegistry registry = getRegistry();
87
45
 
88
- if(msg.sender != registry.ownerOf(address(registry))) {
89
- revert NotRegistryOwner();
46
+ function registerInstance(IRegisterable instance)
47
+ external
48
+ returns(
49
+ IRegistry.ObjectInfo memory info,
50
+ bytes memory data
51
+ )
52
+ {
53
+ if(!instance.supportsInterface(type(IInstance).interfaceId)) {
54
+ revert NotInstance();
90
55
  }
91
56
 
92
- IRegistry.ObjectInfo memory info = IRegistry.ObjectInfo(
93
- zeroNftId(), // any value
94
- registry.getNftId(address(registry)),
95
- TOKEN(),
96
- false, // isInterceptor
97
- tokenAddress,
98
- NFT_LOCK_ADDRESS,
99
- "" // any value
100
- );
101
-
102
- nftId = registry.register(info);
57
+ (info, data) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);
58
+
59
+ info.nftId = _registry.register(info);
60
+ instance.linkToRegisteredNftId(); // asume safe
61
+
62
+ return (info, data);
103
63
  }
104
64
 
105
- /// @dev
106
- // msg.sender - ONLY registry owner
107
- // CAN register ONLY valid object-parent types combinations for SERVICE
108
- // CAN register ONLY IRegisterable address he owns
109
- // CAN NOT register itself
110
- // IMPORTANT: MUST NOT check owner before calling external contract
111
- function registerService(IService service)
65
+ function registerProduct(IBaseComponent product, address owner)
112
66
  external
67
+ restricted
113
68
  returns(
114
69
  IRegistry.ObjectInfo memory info,
115
70
  bytes memory data
116
71
  )
117
72
  {
118
- if(service.supportsInterface(type(IService).interfaceId) == false) {
119
- revert NotService();
120
- }
121
-
122
- (
123
- info,
124
- data
125
- ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
126
-
127
- IRegistry registry = getRegistry();
128
-
129
- if(msg.sender != registry.ownerOf(address(registry))) {
130
- revert NotRegistryOwner();
73
+ // CAN revert if no ERC165 support -> will revert with empty message
74
+ if(!product.supportsInterface(type(IProductComponent).interfaceId)) {
75
+ revert NotProduct();
131
76
  }
132
77
 
133
- info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
134
- info.nftId = registry.register(info);
78
+ (info, data) = _getAndVerifyContractInfo(product, PRODUCT(), owner);
135
79
 
136
- return (
137
- info,
138
- data
139
- );
80
+ info.nftId = _registry.register(info);
81
+
82
+ return (info, data);
140
83
  }
141
84
 
142
- // anybody can register component if instance gives a corresponding role
143
- //function registerComponent(IBaseComponent component, ObjectType componentType)
144
- function registerComponent(IBaseComponent component, ObjectType componentType, address owner)
85
+ function registerPool(IBaseComponent pool, address owner)
145
86
  external
87
+ restricted
146
88
  returns(
147
89
  IRegistry.ObjectInfo memory info,
148
90
  bytes memory data
149
91
  )
150
92
  {
151
- if(component.supportsInterface(type(IBaseComponent).interfaceId) == false) {
152
- revert NotComponent();
93
+ if(!pool.supportsInterface(type(IPoolComponent).interfaceId)) {
94
+ revert NotPool();
153
95
  }
154
96
 
155
- (
156
- info,
157
- data
158
- ) = _getAndVerifyContractInfo(component, componentType, owner);
159
-
160
- IRegistry registry = getRegistry();
161
- NftId serviceNftId = registry.getNftId(msg.sender);
162
-
163
- if(registry.allowance(serviceNftId, componentType) == false) {
164
- revert MissingAllowance();
165
- }
97
+ (info, data) = _getAndVerifyContractInfo(pool, POOL(), owner);
166
98
 
167
- info.nftId = registry.register(info);
99
+ info.nftId = _registry.register(info);
168
100
 
169
- return (
170
- info,
171
- data
172
- );
101
+ return (info, data);
173
102
  }
174
103
 
175
- // TODO: when called by approved service: add owner arg (service must pass it's msg.sender as owner) & check service allowance
176
- //function registerInstance(IRegisterable instance, address owner)
177
- function registerInstance(IRegisterable instance)
178
- external
104
+ function registerDistribution(IBaseComponent distribution, address owner)
105
+ external
106
+ restricted
179
107
  returns(
180
108
  IRegistry.ObjectInfo memory info,
181
109
  bytes memory data
182
110
  )
183
111
  {
184
- if(instance.supportsInterface(type(IInstance).interfaceId) == false) {
185
- revert NotInstance();
112
+ if(!distribution.supportsInterface(type(IDistributionComponent).interfaceId)) {
113
+ revert NotDistribution();
186
114
  }
187
115
 
188
- (
189
- info,
190
- data
191
- ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);// owner);
192
-
193
- IRegistry registry = getRegistry();
116
+ (info, data) = _getAndVerifyContractInfo(distribution, DISTRIBUTION(), owner);
194
117
 
195
- //if(registry.allowance(registry.getNftId(msg.sender), INSTANCE()) == false) {
196
- // revert MissingAllowance();
197
- //}
118
+ info.nftId = _registry.register(info);
198
119
 
199
- info.nftId = registry.register(info);
200
-
201
- return (
202
- info,
203
- data
204
- );
120
+ return (info, data);
205
121
  }
206
122
 
207
123
  function registerPolicy(IRegistry.ObjectInfo memory info)
208
- external
124
+ external
125
+ restricted
209
126
  returns(NftId nftId)
210
127
  {
211
- IRegistry registry = getRegistry();
212
- NftId senderNftId = registry.getNftId(msg.sender);
213
-
214
- if(registry.allowance(senderNftId, POLICY()) == false) {
215
- revert MissingAllowance();
216
- }
217
-
218
128
  _verifyObjectInfo(info, POLICY());
219
129
 
220
- nftId = registry.register(info);
130
+ nftId = _registry.register(info);
221
131
  }
222
132
 
223
133
  function registerBundle(IRegistry.ObjectInfo memory info)
224
- external
134
+ external
135
+ restricted
225
136
  returns(NftId nftId)
226
137
  {
227
- IRegistry registry = getRegistry();
228
- NftId senderNftId = registry.getNftId(msg.sender);
229
-
230
- if(registry.allowance(senderNftId, BUNDLE()) == false) {
231
- revert MissingAllowance();
232
- }
233
-
234
138
  _verifyObjectInfo(info, BUNDLE());
235
139
 
236
- nftId = registry.register(info);
140
+ nftId = _registry.register(info);
237
141
  }
238
142
 
143
+ function registerStake(IRegistry.ObjectInfo memory info)
144
+ external
145
+ restricted
146
+ returns(NftId nftId)
147
+ {
148
+ _verifyObjectInfo(info, STAKE());
239
149
 
240
- // From IService
241
- function getName() public pure override(IService, ServiceBase) returns(string memory) {
242
- return NAME;
150
+ nftId = _registry.register(info);
243
151
  }
244
152
 
153
+ // From IService
154
+ function getDomain() public pure override(IService, Service) returns(ObjectType serviceDomain) {
155
+ return REGISTRY();
156
+ }
245
157
 
246
158
  // from Versionable
247
159
 
248
160
  /// @dev top level initializer
249
- // 1) registry is non upgradeable -> don't need a proxy and uses constructor !
250
- // 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
251
- // 3) deploy registry -> pass registry service address as constructor argument
252
- // registry is getting instantiated and locked to registry service address forever
253
161
  function _initialize(
254
162
  address owner,
255
- bytes memory registryByteCodeWithInitCode
163
+ bytes memory data
256
164
  )
257
165
  internal
258
166
  initializer
259
167
  virtual override
260
168
  {
261
- bytes memory encodedConstructorArguments = abi.encode(
262
- owner,
263
- getMajorVersion());
169
+ (
170
+ address initialAuthority,
171
+ address registry
172
+ ) = abi.decode(data, (address, address));
173
+
174
+ __AccessManaged_init(initialAuthority);
175
+
176
+ _initializeService(address(registry), owner);
264
177
 
265
- bytes memory registryCreationCode = ContractDeployerLib.getCreationCode(
266
- registryByteCodeWithInitCode,
267
- encodedConstructorArguments);
178
+ _registerInterface(type(IRegistryService).interfaceId);
179
+ }
268
180
 
269
- address registryAddress = ContractDeployerLib.deploy(
270
- registryCreationCode,
271
- REGISTRY_CREATION_CODE_HASH);
181
+ // from IRegisterable
272
182
 
273
- IRegistry registry = IRegistry(registryAddress);
274
- NftId registryNftId = registry.getNftId(registryAddress);
183
+ function getInitialInfo()
184
+ public
185
+ view
186
+ override(IRegisterable, Registerable)
187
+ returns (IRegistry.ObjectInfo memory info, bytes memory data)
188
+ {
189
+ (info , data) = super.getInitialInfo();
275
190
 
276
- _initializeServiceBase(registryAddress, registryNftId, owner);
191
+ FunctionConfig[] memory config = new FunctionConfig[](6);
277
192
 
278
- _registerInterface(type(IRegistryService).interfaceId);
193
+ // order of service registrations MUST be reverse to this array
194
+ /*config[-1].serviceDomain = STAKE();
195
+ config[-1].selector = RegistryService.registerStake.selector;*/
196
+
197
+ config[0].serviceDomain = POLICY();
198
+ config[0].selector = RegistryService.registerPolicy.selector;
199
+
200
+ config[1].serviceDomain = BUNDLE();
201
+ config[1].selector = RegistryService.registerBundle.selector;
202
+
203
+ config[2].serviceDomain = PRODUCT();
204
+ config[2].selector = RegistryService.registerProduct.selector;
205
+
206
+ config[3].serviceDomain = POOL();
207
+ config[3].selector = RegistryService.registerPool.selector;
208
+
209
+ config[4].serviceDomain = DISTRIBUTION();
210
+ config[4].selector = RegistryService.registerDistribution.selector;
211
+
212
+ // registerInstance() have no restriction
213
+ config[5].serviceDomain = INSTANCE();
214
+ config[5].selector = RegistryService.registerInstance.selector;
215
+
216
+ data = abi.encode(config);
279
217
  }
280
218
 
281
- // parent check done in registry because of approve()
219
+ // Internal
220
+
282
221
  function _getAndVerifyContractInfo(
283
222
  IRegisterable registerable,
284
- ObjectType objectType,
285
- address owner
223
+ ObjectType expectedType, // assume can be valid only
224
+ address expectedOwner // assume can be 0 when given by other service
286
225
  )
287
226
  internal
227
+ view
288
228
  returns(
289
229
  IRegistry.ObjectInfo memory info,
290
230
  bytes memory data
@@ -294,23 +234,33 @@ contract RegistryService is
294
234
  info,
295
235
  data
296
236
  ) = registerable.getInitialInfo();
237
+ info.objectAddress = address(registerable);
297
238
 
298
- if(info.objectAddress != address(registerable)) {
299
- revert InvalidAddress(info.objectAddress);
239
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
240
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
300
241
  }
301
242
 
302
- if(
303
- getRegistry().isRegistered(owner) ||
304
- info.initialOwner != owner) { // contract owner protection
305
- revert InvalidInitialOwner(info.initialOwner);
243
+ address owner = info.initialOwner;
244
+
245
+ // solhint-disable-next-line
246
+ if(expectedType == INSTANCE()) {
247
+ // any address may create a new instance via instance service
248
+ } else {
249
+ if(owner != expectedOwner) { // registerable owner protection
250
+ revert NotRegisterableOwner(expectedOwner);
251
+ }
306
252
  }
307
253
 
308
- if(msg.sender == address(registerable)) {
254
+ if(owner == address(registerable)) {
309
255
  revert SelfRegistration();
310
256
  }
257
+
258
+ if(owner == address(0)) {
259
+ revert RegisterableOwnerIsZero();
260
+ }
311
261
 
312
- if(info.objectType != objectType) {
313
- revert InvalidType(info.objectType);
262
+ if(getRegistry().isRegistered(owner)) {
263
+ revert RegisterableOwnerIsRegistered();
314
264
  }
315
265
 
316
266
  /*NftId parentNftId = info.parentNftId;
@@ -320,31 +270,31 @@ contract RegistryService is
320
270
  revert InvalidParent(parentNftId);
321
271
  }*/
322
272
 
323
- return(
324
- info,
325
- data
326
- );
273
+ return(info, data);
327
274
  }
328
275
 
329
- // parent checks done in registry because of approve()
330
276
  function _verifyObjectInfo(
331
277
  IRegistry.ObjectInfo memory info,
332
- ObjectType objectType
278
+ ObjectType expectedType
333
279
  )
334
280
  internal
335
281
  view
336
282
  {
337
- if(info.objectAddress > address(0)) {
338
- revert InvalidAddress(info.objectAddress);
283
+ // enforce instead of check
284
+ info.objectAddress = address(0);
285
+
286
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
287
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
288
+ }
289
+
290
+ address owner = info.initialOwner;
291
+
292
+ if(owner == address(0)) {
293
+ revert RegisterableOwnerIsZero();
339
294
  }
340
295
 
341
- if(
342
- getRegistry().isRegistered(info.initialOwner) ||
343
- info.initialOwner == address(0)) {
344
- // TODO non registered address can register object(e.g. POLICY()) and then transfer associated nft to registered contract
345
- // what are motivations to do so?
346
- // at least registered contract can not register objects by itself, SERVICE,
347
- revert InvalidInitialOwner(info.initialOwner);
296
+ if(getRegistry().isRegistered(owner)) {
297
+ revert RegisterableOwnerIsRegistered();
348
298
  }
349
299
 
350
300
  // can catch all 3 if check that initialOwner is not registered
@@ -360,11 +310,6 @@ contract RegistryService is
360
310
  revert InitialOwnerIsRegistry();
361
311
  }*/
362
312
 
363
-
364
- if(info.objectType != objectType) {
365
- revert InvalidType(info.objectType);
366
- }
367
-
368
313
  /*NftId parentNftId = info.parentNftId;
369
314
  IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
370
315
 
@@ -372,4 +317,4 @@ contract RegistryService is
372
317
  revert InvalidParent(parentNftId);
373
318
  }*/
374
319
  }
375
- }
320
+ }
@@ -1,47 +1,57 @@
1
1
  // SPDX-License-Identifier: UNLICENSED
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
5
+
6
+ import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
7
+
4
8
  import {Registry} from "./Registry.sol";
5
- import {IRegistry} from "./IRegistry.sol";
6
9
  import {IVersionable} from "../shared/IVersionable.sol";
7
10
  import {ProxyManager} from "../shared/ProxyManager.sol";
8
11
  import {RegistryService} from "./RegistryService.sol";
12
+ import {TokenRegistry} from "./TokenRegistry.sol";
9
13
 
10
14
 
11
15
  contract RegistryServiceManager is
12
16
  ProxyManager
13
17
  {
14
- error ErrorRegistryServiceWithZeroAddress();
18
+ bytes32 constant public ACCESS_MANAGER_CREATION_CODE_HASH = 0x0;
15
19
 
16
- RegistryService private _registryService;
20
+ RegistryService private immutable _registryService;
17
21
 
18
22
  /// @dev initializes proxy manager with registry service implementation and deploys registry
19
23
  constructor(
20
- // address registryServiceImplementationAddress,
21
- // bytes memory registryBytecodeWithInitCode // type(Registry).creationCode
22
- )
24
+ address initialAuthority, // used by implementation
25
+ address registry) // used by implementation
23
26
  ProxyManager()
24
27
  {
25
- // if (registryServiceImplementationAddress == address(0)) {
26
- // revert ErrorRegistryServiceWithZeroAddress();
27
- // }
28
+ require(initialAuthority > address(0), "RegistryServiceManager: initial authority is 0");
29
+ require(registry > address(0), "RegistryServiceManager: registry is 0");
30
+
31
+ // implementation's initializer func `data` argument
32
+ bytes memory initializationData = abi.encode(
33
+ initialAuthority,
34
+ registry);
28
35
 
29
36
  IVersionable versionable = deploy(
30
37
  address(new RegistryService()),
31
- type(Registry).creationCode);
38
+ initializationData);
32
39
 
33
40
  _registryService = RegistryService(address(versionable));
41
+ }
34
42
 
35
- // link ownership of registry service manager ot nft owner of registry service
36
- linkToRegistry(
37
- address(_registryService.getRegistry()),
38
- address(_registryService));
43
+ // from IRegisterable
39
44
 
40
- // implies that after this constructor call only upgrade functionality is available
41
- _isDeployed = true;
45
+ // IMPORTANT: registry here and in constructor MUST be the same
46
+ function linkToNftOwnable(address registry)
47
+ public
48
+ onlyOwner
49
+ {
50
+ _linkToNftOwnable(registry, address(_registryService));
42
51
  }
43
52
 
44
53
  //--- view functions ----------------------------------------------------//
54
+
45
55
  function getRegistryService()
46
56
  external
47
57
  view