@etherisc/gif-next 0.0.2-e37834a-021 → 0.0.2-e43a6c3-340

Sign up to get free protection for your applications and to get access to all the features.
Files changed (363) hide show
  1. package/README.md +108 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +116 -2
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +204 -31
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +106 -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 +0 -59
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -50
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +245 -65
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +314 -41
  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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +4 -0
  45. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +101 -0
  46. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +4 -0
  47. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +1132 -0
  48. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +4 -0
  49. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +1082 -0
  50. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  51. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +325 -1744
  52. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  53. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
  54. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  55. package/artifacts/contracts/instance/Instance.sol/Instance.json +2300 -1340
  56. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  57. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +917 -0
  58. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  59. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1388 -0
  60. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  61. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +891 -0
  62. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  63. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +488 -0
  64. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +149 -2
  66. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +27 -158
  69. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  70. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  71. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +37 -245
  72. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  73. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  74. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  75. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +211 -0
  76. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  77. package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
  78. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/{distribution/IDistribution.sol → IDistribution.sol}/IDistribution.json +1 -1
  80. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  81. package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
  82. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
  84. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  85. package/artifacts/contracts/instance/{base/ModuleBase.sol/ModuleBase.json → module/ISetup.sol/ISetup.json} +2 -2
  86. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  87. package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
  88. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +178 -41
  90. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +212 -22
  92. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  93. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +444 -0
  94. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +81 -4
  96. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +80 -3
  98. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +80 -3
  100. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -3
  102. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +230 -24
  104. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +456 -0
  106. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  107. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  109. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +294 -99
  110. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  111. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +297 -18
  112. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  113. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/Registry.sol/Registry.json +249 -137
  115. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  116. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +447 -39
  117. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  118. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +107 -42
  119. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  120. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
  121. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  122. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  123. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  124. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  125. package/artifacts/contracts/{instance/module/component/ComponentModule.sol/ComponentModule.json → shared/INftOwnable.sol/INftOwnable.json} +67 -57
  126. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +80 -3
  128. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  129. package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/IService.sol/IService.json} +76 -35
  130. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +32 -6
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +21 -16
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +120 -6
  137. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
  138. package/artifacts/contracts/{instance/base/IService.sol/IService.json → shared/RegisterableUpgradable.sol/RegisterableUpgradable.json} +137 -39
  139. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  140. package/artifacts/contracts/{instance/base/InstanceBase.sol/InstanceBase.json → shared/Service.sol/Service.json} +106 -94
  141. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  142. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  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/test/TestFee.sol/TestFee.dbg.json +1 -1
  147. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  148. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +120 -6
  150. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +14 -14
  152. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestService.sol/TestService.json +142 -14
  154. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  156. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  158. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +18 -2
  160. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  161. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  162. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  166. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  167. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
  169. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +31 -17
  171. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  173. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  174. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  175. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  176. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  177. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  179. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  180. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  181. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  183. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +134 -8
  185. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  187. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +15 -2
  189. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  190. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  191. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  192. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  193. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  194. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  195. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  197. package/contracts/components/BaseComponent.sol +16 -4
  198. package/contracts/components/Distribution.sol +21 -16
  199. package/contracts/components/IBaseComponent.sol +9 -3
  200. package/contracts/components/IDistributionComponent.sol +2 -4
  201. package/contracts/components/IPoolComponent.sol +0 -2
  202. package/contracts/components/IProductComponent.sol +2 -4
  203. package/contracts/components/Pool.sol +24 -27
  204. package/contracts/components/Product.sol +41 -43
  205. package/contracts/experiment/cloning/Cloner.sol +47 -0
  206. package/contracts/instance/AccessManagedSimple.sol +115 -0
  207. package/contracts/instance/AccessManagerSimple.sol +692 -0
  208. package/contracts/instance/IAccessManagerSimple.sol +391 -0
  209. package/contracts/instance/IInstance.sol +32 -47
  210. package/contracts/instance/IInstanceService.sol +30 -0
  211. package/contracts/instance/Instance.sol +423 -65
  212. package/contracts/instance/InstanceAccessManager.sol +288 -0
  213. package/contracts/instance/InstanceReader.sol +306 -0
  214. package/contracts/instance/InstanceService.sol +183 -0
  215. package/contracts/instance/InstanceServiceManager.sol +57 -0
  216. package/contracts/instance/base/ComponentServiceBase.sol +83 -8
  217. package/contracts/instance/base/IKeyValueStore.sol +13 -14
  218. package/contracts/instance/base/ILifecycle.sol +3 -3
  219. package/contracts/instance/base/KeyValueStore.sol +49 -38
  220. package/contracts/instance/base/Lifecycle.sol +1 -1
  221. package/contracts/instance/module/IAccess.sol +38 -0
  222. package/contracts/instance/module/IBundle.sol +20 -0
  223. package/contracts/instance/module/IDistribution.sol +39 -0
  224. package/contracts/instance/module/IPolicy.sol +45 -0
  225. package/contracts/instance/module/IRisk.sol +11 -0
  226. package/contracts/instance/module/ISetup.sol +44 -0
  227. package/contracts/instance/module/ITreasury.sol +23 -0
  228. package/contracts/instance/service/ComponentOwnerService.sol +145 -100
  229. package/contracts/instance/service/DistributionService.sol +49 -15
  230. package/contracts/instance/service/DistributionServiceManager.sol +54 -0
  231. package/contracts/instance/service/IComponentOwnerService.sol +1 -1
  232. package/contracts/instance/service/IDistributionService.sol +1 -1
  233. package/contracts/instance/service/IPoolService.sol +1 -1
  234. package/contracts/instance/service/IProductService.sol +3 -3
  235. package/contracts/instance/service/PoolService.sol +97 -52
  236. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  237. package/contracts/registry/ChainNft.sol +40 -25
  238. package/contracts/registry/IRegistry.sol +48 -27
  239. package/contracts/registry/IRegistryService.sol +36 -15
  240. package/contracts/registry/Registry.sol +167 -168
  241. package/contracts/registry/RegistryService.sol +149 -166
  242. package/contracts/registry/RegistryServiceManager.sol +38 -10
  243. package/contracts/registry/TokenRegistry.sol +111 -0
  244. package/contracts/shared/ERC165.sol +7 -3
  245. package/contracts/shared/INftOwnable.sol +22 -0
  246. package/contracts/shared/IRegisterable.sol +3 -8
  247. package/contracts/{instance/base → shared}/IService.sol +3 -3
  248. package/contracts/shared/NftOwnable.sol +83 -34
  249. package/contracts/shared/ProxyManager.sol +3 -12
  250. package/contracts/shared/Registerable.sol +15 -42
  251. package/contracts/shared/RegisterableUpgradable.sol +16 -0
  252. package/contracts/shared/Service.sol +55 -0
  253. package/contracts/shared/TokenHandler.sol +27 -0
  254. package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
  255. package/contracts/shared/Versionable.sol +3 -3
  256. package/contracts/test/TestFee.sol +2 -2
  257. package/contracts/test/TestRoleId.sol +1 -1
  258. package/contracts/test/TestService.sol +3 -5
  259. package/contracts/types/DistributorType.sol +55 -0
  260. package/contracts/types/Fee.sol +3 -3
  261. package/contracts/types/Key32.sol +8 -3
  262. package/contracts/types/NumberId.sol +52 -0
  263. package/contracts/types/ObjectType.sol +35 -14
  264. package/contracts/types/Referral.sol +85 -0
  265. package/contracts/types/RoleId.sol +60 -9
  266. package/contracts/types/StateId.sol +5 -1
  267. package/contracts/types/Timestamp.sol +7 -3
  268. package/contracts/types/UFixed.sol +128 -12
  269. package/contracts/types/Version.sol +4 -1
  270. package/package.json +4 -3
  271. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
  272. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
  273. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  274. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  275. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +0 -4
  276. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  277. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  278. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  279. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  280. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
  281. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  282. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  283. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
  284. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -297
  285. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
  286. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
  287. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -297
  288. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  289. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
  290. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
  291. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  292. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +0 -117
  293. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +0 -4
  294. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +0 -10
  295. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +0 -4
  296. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +0 -4
  297. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +0 -10
  298. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  299. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  300. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -284
  301. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  302. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -284
  303. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  304. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.json +0 -10
  305. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  306. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -164
  307. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  308. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -164
  309. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
  310. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
  311. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -113
  312. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
  313. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -131
  314. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
  315. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
  316. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -638
  317. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
  318. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
  319. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
  320. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -638
  321. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +0 -4
  322. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +0 -964
  323. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  324. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
  325. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  326. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  327. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +0 -4
  328. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +0 -445
  329. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
  330. package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -602
  331. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
  332. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -632
  333. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +0 -4
  334. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +0 -99
  335. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  336. package/contracts/instance/IInstanceLinked.sol +0 -8
  337. package/contracts/instance/base/InstanceBase.sol +0 -89
  338. package/contracts/instance/base/ModuleBase.sol +0 -57
  339. package/contracts/instance/base/ServiceBase.sol +0 -43
  340. package/contracts/instance/module/access/Access.sol +0 -149
  341. package/contracts/instance/module/access/IAccess.sol +0 -53
  342. package/contracts/instance/module/bundle/BundleModule.sol +0 -134
  343. package/contracts/instance/module/bundle/IBundle.sol +0 -53
  344. package/contracts/instance/module/component/ComponentModule.sol +0 -71
  345. package/contracts/instance/module/component/IComponent.sol +0 -28
  346. package/contracts/instance/module/distribution/DistributionModule.sol +0 -17
  347. package/contracts/instance/module/distribution/IDistribution.sol +0 -10
  348. package/contracts/instance/module/policy/IPolicy.sol +0 -63
  349. package/contracts/instance/module/policy/PolicyModule.sol +0 -91
  350. package/contracts/instance/module/pool/IPoolModule.sol +0 -41
  351. package/contracts/instance/module/pool/PoolModule.sol +0 -95
  352. package/contracts/instance/module/risk/IRisk.sol +0 -26
  353. package/contracts/instance/module/risk/RiskModule.sol +0 -62
  354. package/contracts/instance/module/treasury/ITreasury.sol +0 -84
  355. package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
  356. package/contracts/instance/module/treasury/TreasuryModule.sol +0 -131
  357. package/contracts/instance/service/ProductService.sol +0 -510
  358. package/contracts/registry/IChainNft.sol +0 -22
  359. package/contracts/shared/IOwnable.sol +0 -6
  360. package/contracts/test/TestDistribution.sol +0 -22
  361. package/contracts/test/TestPool.sol +0 -27
  362. package/contracts/test/TestProduct.sol +0 -74
  363. 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";
@@ -19,228 +18,195 @@ import {Versionable} from "../../contracts/shared/Versionable.sol";
19
18
  import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
20
19
 
21
20
  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";
21
+ import {ObjectType, REGISTRY, SERVICE, PRODUCT, ORACLE, POOL, INSTANCE, DISTRIBUTION, POLICY, BUNDLE, STAKE} from "../../contracts/types/ObjectType.sol";
23
22
  import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
24
23
  import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
25
24
  import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
26
25
  import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
27
26
 
28
- import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
29
- import {IService} from "../../contracts/instance/base/IService.sol";
27
+ import {Service} from "../shared/Service.sol";
28
+ import {IService} from "../shared/IService.sol";
30
29
  import {IRegistryService} from "./IRegistryService.sol";
31
- import {Registry} from "../registry/Registry.sol";
30
+ import {Registry} from "./Registry.sol";
32
31
 
33
32
  contract RegistryService is
34
- ServiceBase,
33
+ AccessManagedUpgradeable,
34
+ Service,
35
35
  IRegistryService
36
36
  {
37
37
  using NftIdLib for NftId;
38
38
 
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
39
 
40
+ // Initial value for constant variable has to be compile-time constant
41
+ // TODO define types as constants?
42
+ //ObjectType public constant SERVICE_TYPE = REGISTRY();
52
43
  string public constant NAME = "RegistryService";
53
44
 
54
45
  // TODO update to real hash when registry is stable
55
46
  bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
56
47
 
57
- address constant public NFT_LOCK_ADDRESS = address(0x1);
48
+ address public constant NFT_LOCK_ADDRESS = address(0x1);
58
49
 
59
50
  /// @dev
60
51
  // msg.sender - ONLY registry owner
61
- // CAN register ANY non IRegisterable address
62
- // CAN register ONLY valid object-parent types combinations for TOKEN
63
52
  // 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
- }
85
-
86
- IRegistry registry = getRegistry();
87
-
88
- if(msg.sender != registry.ownerOf(address(registry))) {
89
- revert NotRegistryOwner();
90
- }
91
-
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);
103
- }
104
-
105
- /// @dev
106
- // msg.sender - ONLY registry owner
107
53
  // CAN register ONLY valid object-parent types combinations for SERVICE
108
54
  // CAN register ONLY IRegisterable address he owns
109
- // CAN NOT register itself
110
55
  // IMPORTANT: MUST NOT check owner before calling external contract
111
56
  function registerService(IService service)
112
57
  external
58
+ restricted
113
59
  returns(
114
60
  IRegistry.ObjectInfo memory info,
115
61
  bytes memory data
116
62
  )
117
63
  {
118
- if(service.supportsInterface(type(IService).interfaceId) == false) {
64
+
65
+ // CAN revert if no ERC165 support -> will revert with empty message
66
+ if(!service.supportsInterface(type(IService).interfaceId)) {
119
67
  revert NotService();
120
- }
68
+ }
121
69
 
122
70
  (
123
71
  info,
124
72
  data
125
73
  ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
126
74
 
127
- IRegistry registry = getRegistry();
75
+ info.nftId = _registry.register(info);
76
+ service.linkToRegisteredNftId();
77
+ return (info, data);
78
+ }
128
79
 
129
- if(msg.sender != registry.ownerOf(address(registry))) {
130
- revert NotRegistryOwner();
80
+ function registerInstance(IRegisterable instance)
81
+ external
82
+ returns(
83
+ IRegistry.ObjectInfo memory info,
84
+ bytes memory data
85
+ )
86
+ {
87
+ if(!instance.supportsInterface(type(IInstance).interfaceId)) {
88
+ revert NotInstance();
131
89
  }
132
90
 
133
- info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
134
- info.nftId = registry.register(info);
135
-
136
- return (
137
- info,
91
+ (
92
+ info,
138
93
  data
139
- );
94
+ ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);
95
+
96
+ info.nftId = _registry.register(info);
97
+ instance.linkToRegisteredNftId(); // asume safe
98
+
99
+ return (info, data);
140
100
  }
141
101
 
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)
102
+ function registerProduct(IBaseComponent product, address owner)
145
103
  external
104
+ restricted
146
105
  returns(
147
106
  IRegistry.ObjectInfo memory info,
148
107
  bytes memory data
149
108
  )
150
109
  {
151
- if(component.supportsInterface(type(IBaseComponent).interfaceId) == false) {
152
- revert NotComponent();
110
+ // CAN revert if no ERC165 support -> will revert with empty message
111
+ if(!product.supportsInterface(type(IProductComponent).interfaceId)) {
112
+ revert NotProduct();
153
113
  }
154
114
 
155
115
  (
156
116
  info,
157
117
  data
158
- ) = _getAndVerifyContractInfo(component, componentType, owner);
118
+ ) = _getAndVerifyContractInfo(product, PRODUCT(), owner);
159
119
 
160
- IRegistry registry = getRegistry();
161
- NftId serviceNftId = registry.getNftId(msg.sender);
120
+ info.nftId = _registry.register(info);
121
+ // TODO unsafe, let component or its owner derive nftId latter, when state assumptions and modifications of GIF contracts are finished
122
+ product.linkToRegisteredNftId();
162
123
 
163
- if(registry.allowance(serviceNftId, componentType) == false) {
164
- revert MissingAllowance();
165
- }
124
+ return (info, data);
125
+ }
166
126
 
167
- info.nftId = registry.register(info);
127
+ function registerPool(IBaseComponent pool, address owner)
128
+ external
129
+ restricted
130
+ returns(
131
+ IRegistry.ObjectInfo memory info,
132
+ bytes memory data
133
+ )
134
+ {
135
+ if(!pool.supportsInterface(type(IPoolComponent).interfaceId)) {
136
+ revert NotPool();
137
+ }
168
138
 
169
- return (
170
- info,
139
+ (
140
+ info,
171
141
  data
172
- );
142
+ ) = _getAndVerifyContractInfo(pool, POOL(), owner);
143
+
144
+ info.nftId = _registry.register(info);
145
+ pool.linkToRegisteredNftId();
146
+
147
+ return (info, data);
173
148
  }
174
149
 
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
150
+ function registerDistribution(IBaseComponent distribution, address owner)
151
+ external
152
+ restricted
179
153
  returns(
180
154
  IRegistry.ObjectInfo memory info,
181
155
  bytes memory data
182
156
  )
183
157
  {
184
- if(instance.supportsInterface(type(IInstance).interfaceId) == false) {
185
- revert NotInstance();
158
+ if(!distribution.supportsInterface(type(IDistributionComponent).interfaceId)) {
159
+ revert NotDistribution();
186
160
  }
187
161
 
188
162
  (
189
163
  info,
190
164
  data
191
- ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);// owner);
192
-
193
- IRegistry registry = getRegistry();
165
+ ) = _getAndVerifyContractInfo(distribution, DISTRIBUTION(), owner);
194
166
 
195
- //if(registry.allowance(registry.getNftId(msg.sender), INSTANCE()) == false) {
196
- // revert MissingAllowance();
197
- //}
167
+ info.nftId = _registry.register(info);
168
+ distribution.linkToRegisteredNftId();
198
169
 
199
- info.nftId = registry.register(info);
200
-
201
- return (
202
- info,
203
- data
204
- );
170
+ return (info, data);
205
171
  }
206
172
 
207
173
  function registerPolicy(IRegistry.ObjectInfo memory info)
208
- external
174
+ external
175
+ restricted
209
176
  returns(NftId nftId)
210
177
  {
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
178
  _verifyObjectInfo(info, POLICY());
219
179
 
220
- nftId = registry.register(info);
180
+ nftId = _registry.register(info);
221
181
  }
222
182
 
223
183
  function registerBundle(IRegistry.ObjectInfo memory info)
224
- external
184
+ external
185
+ restricted
225
186
  returns(NftId nftId)
226
187
  {
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
188
  _verifyObjectInfo(info, BUNDLE());
235
189
 
236
- nftId = registry.register(info);
190
+ nftId = _registry.register(info);
237
191
  }
238
192
 
193
+ function registerStake(IRegistry.ObjectInfo memory info)
194
+ external
195
+ restricted
196
+ returns(NftId nftId)
197
+ {
198
+ _verifyObjectInfo(info, STAKE());
199
+
200
+ nftId = _registry.register(info);
201
+ }
239
202
 
240
203
  // From IService
241
- function getName() public pure override(IService, ServiceBase) returns(string memory) {
204
+ function getName() public pure override(IService, Service) returns(string memory) {
242
205
  return NAME;
243
206
  }
207
+ //function getType() public pure override(IService, ServiceBase) returns(ObjectType serviceType) {
208
+ // return SERVICE_TYPE;
209
+ //}
244
210
 
245
211
 
246
212
  // from Versionable
@@ -252,12 +218,19 @@ contract RegistryService is
252
218
  // registry is getting instantiated and locked to registry service address forever
253
219
  function _initialize(
254
220
  address owner,
255
- bytes memory registryByteCodeWithInitCode
221
+ bytes memory data
256
222
  )
257
223
  internal
258
224
  initializer
259
225
  virtual override
260
226
  {
227
+ (
228
+ address initialAuthority,
229
+ bytes memory registryByteCodeWithInitCode
230
+ ) = abi.decode(data, (address, bytes));
231
+
232
+ __AccessManaged_init(initialAuthority);
233
+
261
234
  bytes memory encodedConstructorArguments = abi.encode(
262
235
  owner,
263
236
  getMajorVersion());
@@ -266,25 +239,27 @@ contract RegistryService is
266
239
  registryByteCodeWithInitCode,
267
240
  encodedConstructorArguments);
268
241
 
269
- address registryAddress = ContractDeployerLib.deploy(
242
+ IRegistry registry = IRegistry(ContractDeployerLib.deploy(
270
243
  registryCreationCode,
271
- REGISTRY_CREATION_CODE_HASH);
244
+ REGISTRY_CREATION_CODE_HASH));
272
245
 
273
- IRegistry registry = IRegistry(registryAddress);
274
- NftId registryNftId = registry.getNftId(registryAddress);
246
+ NftId registryNftId = registry.getNftId(address(registry));
275
247
 
276
- _initializeServiceBase(registryAddress, registryNftId, owner);
248
+ _initializeService(address(registry), owner);
277
249
 
250
+ // TODO why do registry service proxy need to keep its nftId??? -> no registryServiceNftId checks in implementation
251
+ // if they are -> use registry address to obtain owner of registry service nft (works the same with any registerable and(or) implementation)
252
+ linkToRegisteredNftId();
278
253
  _registerInterface(type(IRegistryService).interfaceId);
279
254
  }
280
255
 
281
- // parent check done in registry because of approve()
282
256
  function _getAndVerifyContractInfo(
283
257
  IRegisterable registerable,
284
- ObjectType objectType,
285
- address owner
258
+ ObjectType expectedType, // assume can be valid only
259
+ address expectedOwner // assume can be 0
286
260
  )
287
261
  internal
262
+ view
288
263
  returns(
289
264
  IRegistry.ObjectInfo memory info,
290
265
  bytes memory data
@@ -294,23 +269,33 @@ contract RegistryService is
294
269
  info,
295
270
  data
296
271
  ) = registerable.getInitialInfo();
272
+ info.objectAddress = address(registerable);
297
273
 
298
- if(info.objectAddress != address(registerable)) {
299
- revert InvalidAddress(info.objectAddress);
274
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
275
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
300
276
  }
301
277
 
302
- if(
303
- getRegistry().isRegistered(owner) ||
304
- info.initialOwner != owner) { // contract owner protection
305
- revert InvalidInitialOwner(info.initialOwner);
278
+ address owner = info.initialOwner;
279
+
280
+ // solhint-disable-next-line
281
+ if(expectedType == INSTANCE()) {
282
+ // any address may create a new instance via instance service
283
+ } else {
284
+ if(owner != expectedOwner) { // registerable owner protection
285
+ revert NotRegisterableOwner(expectedOwner);
286
+ }
306
287
  }
307
288
 
308
- if(msg.sender == address(registerable)) {
289
+ if(owner == address(registerable)) {
309
290
  revert SelfRegistration();
310
291
  }
292
+
293
+ if(owner == address(0)) {
294
+ revert RegisterableOwnerIsZero();
295
+ }
311
296
 
312
- if(info.objectType != objectType) {
313
- revert InvalidType(info.objectType);
297
+ if(getRegistry().isRegistered(owner)) {
298
+ revert RegisterableOwnerIsRegistered();
314
299
  }
315
300
 
316
301
  /*NftId parentNftId = info.parentNftId;
@@ -326,25 +311,28 @@ contract RegistryService is
326
311
  );
327
312
  }
328
313
 
329
- // parent checks done in registry because of approve()
330
314
  function _verifyObjectInfo(
331
315
  IRegistry.ObjectInfo memory info,
332
- ObjectType objectType
316
+ ObjectType expectedType
333
317
  )
334
318
  internal
335
319
  view
336
320
  {
337
- if(info.objectAddress > address(0)) {
338
- revert InvalidAddress(info.objectAddress);
321
+ // enforce instead of check
322
+ info.objectAddress = address(0);
323
+
324
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
325
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
326
+ }
327
+
328
+ address owner = info.initialOwner;
329
+
330
+ if(owner == address(0)) {
331
+ revert RegisterableOwnerIsZero();
339
332
  }
340
333
 
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);
334
+ if(getRegistry().isRegistered(owner)) {
335
+ revert RegisterableOwnerIsRegistered();
348
336
  }
349
337
 
350
338
  // can catch all 3 if check that initialOwner is not registered
@@ -360,11 +348,6 @@ contract RegistryService is
360
348
  revert InitialOwnerIsRegistry();
361
349
  }*/
362
350
 
363
-
364
- if(info.objectType != objectType) {
365
- revert InvalidType(info.objectType);
366
- }
367
-
368
351
  /*NftId parentNftId = info.parentNftId;
369
352
  IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
370
353
 
@@ -372,4 +355,4 @@ contract RegistryService is
372
355
  revert InvalidParent(parentNftId);
373
356
  }*/
374
357
  }
375
- }
358
+ }
@@ -1,47 +1,67 @@
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
+ AccessManager private _accessManager;
21
+ RegistryService private _registryService;
22
+ TokenRegistry private _tokenRegistry;
17
23
 
18
24
  /// @dev initializes proxy manager with registry service implementation and deploys registry
19
25
  constructor(
20
- // address registryServiceImplementationAddress,
21
- // bytes memory registryBytecodeWithInitCode // type(Registry).creationCode
26
+ address accessManager
22
27
  )
23
28
  ProxyManager()
24
29
  {
25
- // if (registryServiceImplementationAddress == address(0)) {
26
- // revert ErrorRegistryServiceWithZeroAddress();
27
- // }
30
+ _accessManager = AccessManager(accessManager);
31
+
32
+ bytes memory initializationData = abi.encode(accessManager, type(Registry).creationCode);
28
33
 
29
34
  IVersionable versionable = deploy(
30
35
  address(new RegistryService()),
31
- type(Registry).creationCode);
36
+ initializationData);
32
37
 
33
38
  _registryService = RegistryService(address(versionable));
34
39
 
35
40
  // link ownership of registry service manager ot nft owner of registry service
36
- linkToRegistry(
41
+ _linkToNftOwnable(
37
42
  address(_registryService.getRegistry()),
38
43
  address(_registryService));
39
44
 
45
+ // deploy token registry
46
+
47
+ // _tokenRegistry = new TokenRegistry(
48
+ // address(_registryService.getRegistry()),
49
+ // address(_registryService));
50
+
40
51
  // implies that after this constructor call only upgrade functionality is available
41
52
  _isDeployed = true;
42
53
  }
43
54
 
44
55
  //--- view functions ----------------------------------------------------//
56
+
57
+ function getAccessManager()
58
+ external
59
+ view
60
+ returns (AccessManager)
61
+ {
62
+ return _accessManager;
63
+ }
64
+
45
65
  function getRegistryService()
46
66
  external
47
67
  view
@@ -49,4 +69,12 @@ contract RegistryServiceManager is
49
69
  {
50
70
  return _registryService;
51
71
  }
72
+
73
+ function getTokenRegistry()
74
+ external
75
+ view
76
+ returns (TokenRegistry)
77
+ {
78
+ return _tokenRegistry;
79
+ }
52
80
  }