@etherisc/gif-next 0.0.2-8a352ce → 0.0.2-8d47fa1-080

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 (387) hide show
  1. package/README.md +193 -6
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
  3. package/artifacts/contracts/components/{IProduct.sol/IProductComponent.json → BaseComponent.sol/BaseComponent.json} +88 -67
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +445 -0
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/{IPool.sol/IPoolComponent.json → IBaseComponent.sol/IBaseComponent.json} +69 -71
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +343 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +474 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +373 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +445 -56
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +324 -53
  18. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  22. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  24. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  26. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  33. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  34. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  35. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  37. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  38. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  39. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  40. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  41. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  42. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  43. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  44. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  45. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  46. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  47. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1575 -295
  48. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +4 -0
  49. package/artifacts/contracts/instance/{component/IComponent.sol → IInstanceLinked.sol}/IInstanceLinked.json +1 -1
  50. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  51. package/artifacts/contracts/instance/Instance.sol/Instance.json +1888 -376
  52. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  53. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +393 -0
  54. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  55. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  56. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  57. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +560 -0
  58. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  59. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
  60. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
  61. package/artifacts/contracts/instance/{component/ComponentModule.sol/ComponentModule.json → base/IService.sol/IService.json} +171 -154
  62. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  63. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +456 -0
  64. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  65. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +710 -0
  66. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  67. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  68. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
  69. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.json +10 -0
  70. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  71. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +380 -0
  72. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +4 -0
  73. package/artifacts/contracts/instance/{access → module/access}/Access.sol/AccessModule.json +85 -152
  74. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +4 -0
  75. package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccess.json +1 -1
  76. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +4 -0
  77. package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccessModule.json +96 -99
  78. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +297 -0
  80. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +4 -0
  81. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.json +10 -0
  82. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +297 -0
  84. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +4 -0
  85. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +117 -0
  86. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +4 -0
  87. package/artifacts/contracts/instance/{component → module/component}/IComponent.sol/IComponent.json +1 -1
  88. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +4 -0
  89. package/artifacts/contracts/instance/{product/IProductService.sol/IProductService.json → module/component/IComponent.sol/IComponentModule.json} +56 -53
  90. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  92. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.json +10 -0
  94. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +10 -0
  96. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +4 -0
  97. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicy.json +1 -1
  98. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +4 -0
  99. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicyModule.json +159 -106
  100. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +4 -0
  101. package/artifacts/contracts/instance/{policy → module/policy}/PolicyModule.sol/PolicyModule.json +159 -106
  102. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +4 -0
  103. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPool.json +1 -1
  104. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +4 -0
  105. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPoolModule.json +74 -59
  106. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +4 -0
  107. package/artifacts/contracts/instance/{pool → module/pool}/PoolModule.sol/PoolModule.json +64 -62
  108. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
  109. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.json +10 -0
  110. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
  111. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +113 -0
  112. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
  113. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +131 -0
  114. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
  115. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.json +10 -0
  116. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
  117. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +638 -0
  118. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  119. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +76 -0
  120. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
  121. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +638 -0
  122. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +690 -0
  124. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  125. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +526 -0
  126. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
  127. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +389 -0
  128. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  129. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +369 -0
  130. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  131. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +484 -0
  132. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  133. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +674 -0
  134. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  135. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +649 -0
  136. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  137. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +964 -0
  138. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  139. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +194 -2
  140. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  141. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +5 -0
  142. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  143. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +364 -72
  144. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  145. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +24 -0
  146. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  147. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +668 -0
  148. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  149. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  150. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  151. package/artifacts/contracts/registry/Registry.sol/Registry.json +570 -82
  152. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.dbg.json +4 -0
  153. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.json +344 -0
  154. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  155. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +861 -0
  156. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  157. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
  158. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +4 -0
  159. package/artifacts/contracts/{registry/IRegistry.sol → shared/IOwnable.sol}/IOwnable.json +1 -1
  160. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  161. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +124 -0
  162. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  163. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
  164. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  165. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +310 -0
  166. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  167. package/artifacts/contracts/{registry/Registry.sol → shared/Registerable.sol}/Registerable.json +71 -77
  168. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  169. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  170. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  171. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
  172. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  173. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +445 -0
  174. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  175. package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
  176. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +4 -0
  177. package/artifacts/contracts/test/TestPool.sol/TestPool.json +602 -0
  178. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +4 -0
  179. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +632 -0
  180. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  181. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +191 -0
  182. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  183. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
  184. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  185. package/artifacts/contracts/test/TestService.sol/TestService.json +472 -0
  186. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  187. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +338 -0
  188. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  189. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
  190. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  191. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +270 -0
  192. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  193. package/artifacts/contracts/test/Usdc.sol/USDC.json +338 -0
  194. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  195. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  196. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  197. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
  198. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  200. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  201. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  202. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  203. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
  204. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  205. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  206. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  207. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
  208. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  209. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  210. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  211. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  212. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  213. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  214. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  215. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
  216. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  217. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  218. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
  219. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +236 -0
  220. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +4 -0
  221. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +479 -0
  222. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  223. package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
  224. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  225. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +30 -0
  226. package/contracts/components/BaseComponent.sol +79 -0
  227. package/contracts/components/Distribution.sol +155 -0
  228. package/contracts/components/IBaseComponent.sol +19 -0
  229. package/contracts/components/IDistributionComponent.sol +47 -0
  230. package/contracts/components/IPoolComponent.sol +65 -0
  231. package/contracts/components/IProductComponent.sol +39 -0
  232. package/contracts/components/Pool.sol +235 -18
  233. package/contracts/components/Product.sol +268 -35
  234. package/contracts/experiment/errors/Require.sol +10 -5
  235. package/contracts/experiment/errors/Revert.sol +13 -8
  236. package/contracts/experiment/inheritance/A.sol +8 -11
  237. package/contracts/experiment/inheritance/B.sol +10 -5
  238. package/contracts/experiment/inheritance/C.sol +11 -5
  239. package/contracts/experiment/inheritance/IA.sol +2 -7
  240. package/contracts/experiment/inheritance/IB.sol +3 -2
  241. package/contracts/experiment/inheritance/IC.sol +4 -3
  242. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  243. package/contracts/experiment/statemachine/ISM.sol +25 -0
  244. package/contracts/experiment/statemachine/SM.sol +57 -0
  245. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  246. package/contracts/experiment/types/TypeA.sol +14 -9
  247. package/contracts/experiment/types/TypeB.sol +14 -9
  248. package/contracts/instance/IInstance.sol +42 -8
  249. package/contracts/instance/IInstanceLinked.sol +8 -0
  250. package/contracts/instance/Instance.sol +62 -41
  251. package/contracts/instance/base/ComponentServiceBase.sol +49 -0
  252. package/contracts/instance/base/IInstanceBase.sol +23 -0
  253. package/contracts/instance/base/IKeyValueStore.sol +50 -0
  254. package/contracts/instance/base/ILifecycle.sol +30 -0
  255. package/contracts/instance/base/IService.sol +15 -0
  256. package/contracts/instance/base/InstanceBase.sol +89 -0
  257. package/contracts/instance/base/KeyValueStore.sol +161 -0
  258. package/contracts/instance/base/Lifecycle.sol +100 -0
  259. package/contracts/instance/base/ModuleBase.sol +57 -0
  260. package/contracts/instance/base/ServiceBase.sol +43 -0
  261. package/contracts/instance/module/access/Access.sol +149 -0
  262. package/contracts/instance/module/access/IAccess.sol +53 -0
  263. package/contracts/instance/module/bundle/BundleModule.sol +134 -0
  264. package/contracts/instance/module/bundle/IBundle.sol +53 -0
  265. package/contracts/instance/module/component/ComponentModule.sol +71 -0
  266. package/contracts/instance/module/component/IComponent.sol +28 -0
  267. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  268. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  269. package/contracts/instance/module/policy/IPolicy.sol +63 -0
  270. package/contracts/instance/module/policy/PolicyModule.sol +91 -0
  271. package/contracts/instance/module/pool/IPoolModule.sol +41 -0
  272. package/contracts/instance/module/pool/PoolModule.sol +95 -0
  273. package/contracts/instance/module/risk/IRisk.sol +26 -0
  274. package/contracts/instance/module/risk/RiskModule.sol +62 -0
  275. package/contracts/instance/module/treasury/ITreasury.sol +84 -0
  276. package/contracts/instance/module/treasury/TokenHandler.sol +48 -0
  277. package/contracts/instance/module/treasury/TreasuryModule.sol +131 -0
  278. package/contracts/instance/service/ComponentOwnerService.sol +272 -0
  279. package/contracts/instance/service/DistributionService.sol +54 -0
  280. package/contracts/instance/service/IComponentOwnerService.sol +20 -0
  281. package/contracts/instance/service/IDistributionService.sol +12 -0
  282. package/contracts/instance/service/IPoolService.sol +37 -0
  283. package/contracts/instance/service/IProductService.sol +107 -0
  284. package/contracts/instance/service/PoolService.sol +149 -0
  285. package/contracts/instance/service/ProductService.sol +509 -0
  286. package/contracts/registry/ChainNft.sol +111 -97
  287. package/contracts/registry/IChainNft.sol +13 -9
  288. package/contracts/registry/IRegistry.sol +61 -56
  289. package/contracts/registry/IRegistryLinked.sol +8 -0
  290. package/contracts/registry/IRegistryService.sol +29 -0
  291. package/contracts/registry/ITransferInterceptor.sol +6 -0
  292. package/contracts/registry/Registry.sol +443 -120
  293. package/contracts/registry/RegistryInstaller.sol +100 -0
  294. package/contracts/registry/RegistryService.sol +383 -0
  295. package/contracts/shared/ERC165.sol +21 -0
  296. package/contracts/shared/IOwnable.sol +6 -0
  297. package/contracts/shared/IRegisterable.sol +22 -0
  298. package/contracts/shared/IVersionable.sol +96 -0
  299. package/contracts/shared/ProxyManager.sol +115 -0
  300. package/contracts/shared/Registerable.sol +117 -0
  301. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  302. package/contracts/shared/Versionable.sol +147 -0
  303. package/contracts/test/TestDistribution.sol +22 -0
  304. package/contracts/test/TestFee.sol +25 -0
  305. package/contracts/test/TestPool.sol +27 -0
  306. package/contracts/test/TestProduct.sol +74 -0
  307. package/contracts/test/TestRegisterable.sol +18 -0
  308. package/contracts/test/TestRoleId.sol +14 -0
  309. package/contracts/test/TestService.sol +26 -0
  310. package/contracts/test/TestToken.sol +26 -0
  311. package/contracts/test/TestVersion.sol +44 -0
  312. package/contracts/test/TestVersionable.sol +17 -0
  313. package/contracts/test/Usdc.sol +26 -0
  314. package/contracts/types/AddressSet.sol +58 -0
  315. package/contracts/types/Blocknumber.sol +118 -0
  316. package/contracts/types/ChainId.sol +18 -10
  317. package/contracts/types/Fee.sol +56 -0
  318. package/contracts/types/Key32.sol +45 -0
  319. package/contracts/types/NftId.sol +48 -11
  320. package/contracts/types/NftIdSet.sol +60 -0
  321. package/contracts/types/ObjectType.sol +131 -0
  322. package/contracts/types/ReferralId.sol +48 -0
  323. package/contracts/types/RiskId.sol +43 -0
  324. package/contracts/types/RoleId.sol +38 -0
  325. package/contracts/types/StateId.sol +101 -0
  326. package/contracts/types/Timestamp.sol +123 -0
  327. package/contracts/types/UFixed.sol +209 -0
  328. package/contracts/types/Version.sol +104 -0
  329. package/package.json +19 -5
  330. package/artifacts/contracts/components/Component.sol/Component.dbg.json +0 -4
  331. package/artifacts/contracts/components/Component.sol/Component.json +0 -179
  332. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
  333. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
  334. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
  335. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
  336. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
  337. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
  338. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
  339. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
  340. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
  341. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +0 -50
  342. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  343. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  344. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
  345. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -147
  346. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
  347. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
  348. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +0 -179
  349. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  350. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +0 -245
  351. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
  352. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -94
  353. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
  354. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  355. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  356. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  357. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  358. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  359. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  360. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
  361. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
  362. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
  363. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
  364. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +0 -75
  365. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
  366. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -167
  367. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
  368. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
  369. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +0 -166
  370. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
  371. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +0 -49
  372. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
  373. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
  374. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
  375. package/contracts/components/Component.sol +0 -62
  376. package/contracts/components/IPool.sol +0 -9
  377. package/contracts/components/IProduct.sol +0 -12
  378. package/contracts/instance/access/Access.sol +0 -218
  379. package/contracts/instance/access/IAccess.sol +0 -83
  380. package/contracts/instance/component/ComponentModule.sol +0 -248
  381. package/contracts/instance/component/IComponent.sol +0 -95
  382. package/contracts/instance/policy/IPolicy.sol +0 -66
  383. package/contracts/instance/policy/PolicyModule.sol +0 -107
  384. package/contracts/instance/pool/IPoolModule.sol +0 -41
  385. package/contracts/instance/pool/PoolModule.sol +0 -86
  386. package/contracts/instance/product/IProductService.sol +0 -46
  387. package/contracts/instance/product/ProductService.sol +0 -108
@@ -0,0 +1,100 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC721Receiver} from "@openzeppelin5/contracts/token/ERC721/IERC721Receiver.sol";
5
+ import {Ownable} from "@openzeppelin5/contracts/access/Ownable.sol";
6
+
7
+ import {IChainNft} from "./IChainNft.sol";
8
+ import {IRegistry} from "./IRegistry.sol";
9
+ import {IVersionable} from "../shared/IVersionable.sol";
10
+ import {NftId} from "../types/NftId.sol";
11
+ import {ProxyManager} from "../shared/ProxyManager.sol";
12
+ import {Registry} from "./Registry.sol";
13
+ import {RegistryService} from "./RegistryService.sol";
14
+
15
+
16
+ contract RegistryInstaller is
17
+ Ownable,
18
+ IERC721Receiver
19
+ {
20
+ error ErrorProxyManagerWithZeroAddress();
21
+ error ErrorRegistryServiceWithZeroAddress();
22
+ error ErrorProxyManagerUnexpectedOwner(address expectedOwner, address actualOwner);
23
+ error ErrorInstallerNotProxyManagerOwner(address installer, address actualOwner);
24
+
25
+ ProxyManager private _proxyManager;
26
+ address private _implementation;
27
+ RegistryService private _registryService;
28
+ IRegistry private _registry;
29
+ IChainNft private _chainNft;
30
+
31
+ /// @dev initializes proxy manager with registry service implementation and deploys registry
32
+ constructor(
33
+ address proxyManagerAddress,
34
+ address registryServiceImplementationAddress
35
+ )
36
+ Ownable(msg.sender)
37
+ {
38
+ if (proxyManagerAddress == address(0)) { revert ErrorProxyManagerWithZeroAddress(); }
39
+ if (registryServiceImplementationAddress == address(0)) { revert ErrorRegistryServiceWithZeroAddress(); }
40
+
41
+ _proxyManager = ProxyManager(proxyManagerAddress);
42
+ // check proxy manager owner is owner of installer
43
+ if (_proxyManager.owner() != owner()) { revert ErrorProxyManagerUnexpectedOwner(_proxyManager.owner(), owner()); }
44
+
45
+ _implementation = registryServiceImplementationAddress;
46
+ }
47
+
48
+ function installRegistryServiceWithRegistry()
49
+ external
50
+ onlyOwner()
51
+ {
52
+ // check that this contract is now proxy manager owner
53
+ if (_proxyManager.owner() != address(this)) { revert ErrorInstallerNotProxyManagerOwner(address(this), _proxyManager.owner()); }
54
+
55
+ IVersionable versionable = _proxyManager.deploy(_implementation, type(Registry).creationCode);
56
+ _registryService = RegistryService(address(versionable));
57
+ _registry = _registryService.getRegistry();
58
+ _chainNft = _registry.getChainNft();
59
+
60
+ // transfer registry ownership back to owner
61
+ NftId registryNftId = _registry.getNftId(address(_registry));
62
+ _chainNft.safeTransferFrom(
63
+ address(this),
64
+ owner(),
65
+ registryNftId.toInt(),
66
+ "");
67
+
68
+ // transfer proxy manager back to owner
69
+ _proxyManager.transferOwnership(owner());
70
+ }
71
+
72
+ function getRegistryService()
73
+ external
74
+ view
75
+ returns (RegistryService registryService)
76
+ {
77
+ return _registryService;
78
+ }
79
+
80
+ function getRegistry()
81
+ external
82
+ view
83
+ returns (RegistryService registryService)
84
+ {
85
+ return _registryService;
86
+ }
87
+
88
+ //--- IERC721Receiver -----------------------------------//
89
+ function onERC721Received(
90
+ address operator,
91
+ address from,
92
+ uint256 tokenId,
93
+ bytes calldata data
94
+ )
95
+ external
96
+ returns (bytes4)
97
+ {
98
+ return IERC721Receiver.onERC721Received.selector;
99
+ }
100
+ }
@@ -0,0 +1,383 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
6
+ import {IRegistry} from "../registry/IRegistry.sol";
7
+ import {IInstance} from "../instance/IInstance.sol";
8
+
9
+ //import {ITreasury, ITreasuryModule} from "../../contracts/instance/module/treasury/ITreasury.sol";
10
+ //import {TreasuryModule} from "../../contracts/instance/module/treasury/TreasuryModule.sol";
11
+ import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
12
+ import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
13
+ import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
14
+ import {IPoolComponent} from "../../contracts/components/IPoolComponent.sol";
15
+ import {IProductComponent} from "../../contracts/components/IProductComponent.sol";
16
+ import {IDistributionComponent} from "../../contracts/components/IDistributionComponent.sol";
17
+
18
+ import {IVersionable} from "../../contracts/shared/IVersionable.sol";
19
+ import {Versionable} from "../../contracts/shared/Versionable.sol";
20
+ import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
21
+
22
+ import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
23
+ import {ObjectType, REGISTRY, TOKEN, SERVICE, PRODUCT, ORACLE, POOL, TOKEN, INSTANCE, DISTRIBUTION, POLICY, BUNDLE} from "../../contracts/types/ObjectType.sol";
24
+ import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
25
+ import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
26
+ import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
27
+ import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
28
+ //import {UFixed, UFixedMathLib} from "../../contracts/types/UFixed.sol";
29
+
30
+
31
+ import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
32
+ import {IService} from "../../contracts/instance/base/IService.sol";
33
+ import {IRegistryService} from "./IRegistryService.sol";
34
+ import {Registry} from "../registry/Registry.sol";
35
+
36
+ contract RegistryService is
37
+ ServiceBase,
38
+ IRegistryService
39
+ {
40
+ using NftIdLib for NftId;
41
+
42
+ error NotRegistryOwner();
43
+ error MissingAllowance();
44
+
45
+ error NotToken();
46
+ error NotService();
47
+ error NotComponent();
48
+ error NotInstance();
49
+
50
+ error InvalidAddress(address registerableAddress);
51
+ error InvalidInitialOwner(address initialOwner);
52
+ error SelfRegistration();
53
+ error InvalidType(ObjectType objectType);
54
+
55
+ string public constant NAME = "RegistryService";
56
+
57
+ bytes32 public constant REGISTRY_CREATIONCODE_HASH = 0x7e569c7200a12c63728b648d78f84be7e32ef6804f9ee723e15363ce34d01251;
58
+
59
+ address constant public NFT_LOCK_ADDRESS = address(0x1);
60
+
61
+ /// @dev
62
+ // msg.sender - ONLY registry owner
63
+ // CAN register ANY non IRegisterable address
64
+ // CAN register ONLY valid object-parent types combinations for TOKEN
65
+ // CAN NOT register itself
66
+ // IMPORTANT: MUST NOT call untrusted contract inbetween calls to registry/instance (trusted contracts)
67
+ // motivation: registry/instance state may change during external call
68
+ // TODO it may be usefull to have transferable token nft in order to delist token, make it invalid for new beginings
69
+ // TODO: MUST prohibit registration of precompiles addresses
70
+ function registerToken(address tokenAddress)
71
+ external
72
+ returns(NftId nftId)
73
+ {
74
+ IRegisterable registerable = IRegisterable(tokenAddress);
75
+ bool isRegisterable;
76
+
77
+ // registryOwner can not register IRegisterable as TOKEN
78
+ try registerable.supportsInterface(type(IRegisterable).interfaceId) returns(bool result) {
79
+ isRegisterable = result;
80
+ } catch {
81
+ isRegisterable = false;
82
+ }
83
+
84
+ if(isRegisterable) {
85
+ revert NotToken();
86
+ }
87
+
88
+ IRegistry registry = getRegistry();
89
+
90
+ if(msg.sender != registry.ownerOf(address(registry))) {
91
+ revert NotRegistryOwner();
92
+ }
93
+
94
+ IRegistry.ObjectInfo memory info = IRegistry.ObjectInfo(
95
+ zeroNftId(), // any value
96
+ registry.getNftId(address(registry)),
97
+ TOKEN(),
98
+ false, // isInterceptor
99
+ tokenAddress,
100
+ NFT_LOCK_ADDRESS,
101
+ "" // any value
102
+ );
103
+
104
+ nftId = registry.register(info);
105
+ }
106
+
107
+ /// @dev
108
+ // msg.sender - ONLY registry owner
109
+ // CAN register ONLY valid object-parent types combinations for SERVICE
110
+ // CAN register ONLY IRegisterable address he owns
111
+ // CAN NOT register itself
112
+ // IMPORTANT: MUST NOT check owner before calling external contract
113
+ function registerService(IService service)
114
+ external
115
+ returns(
116
+ IRegistry.ObjectInfo memory info,
117
+ bytes memory data
118
+ )
119
+ {
120
+ if(service.supportsInterface(type(IService).interfaceId) == false) {
121
+ revert NotService();
122
+ }
123
+
124
+ (
125
+ info,
126
+ data
127
+ ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
128
+
129
+ IRegistry registry = getRegistry();
130
+
131
+ if(msg.sender != registry.ownerOf(address(registry))) {
132
+ revert NotRegistryOwner();
133
+ }
134
+
135
+ info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
136
+ info.nftId = registry.register(info);
137
+
138
+ return (
139
+ info,
140
+ data
141
+ );
142
+ }
143
+
144
+ // anybody can register component if instance gives a corresponding role
145
+ //function registerComponent(IBaseComponent component, ObjectType componentType)
146
+ function registerComponent(IBaseComponent component, ObjectType componentType, address owner)
147
+ external
148
+ returns(
149
+ IRegistry.ObjectInfo memory info,
150
+ bytes memory data
151
+ )
152
+ {
153
+ if(component.supportsInterface(type(IBaseComponent).interfaceId) == false) {
154
+ revert NotComponent();
155
+ }
156
+
157
+ (
158
+ info,
159
+ data
160
+ ) = _getAndVerifyContractInfo(component, componentType, owner);
161
+
162
+ IRegistry registry = getRegistry();
163
+ NftId serviceNftId = registry.getNftId(msg.sender);
164
+
165
+ if(registry.allowance(serviceNftId, componentType) == false) {
166
+ revert MissingAllowance();
167
+ }
168
+
169
+ info.nftId = registry.register(info);
170
+
171
+ return (
172
+ info,
173
+ data
174
+ );
175
+ }
176
+
177
+ // TODO: when called by approved service: add owner arg (service must pass it's msg.sender as owner) & check service allowance
178
+ //function registerInstance(IRegisterable instance, address owner)
179
+ function registerInstance(IRegisterable instance)
180
+ external
181
+ returns(
182
+ IRegistry.ObjectInfo memory info,
183
+ bytes memory data
184
+ )
185
+ {
186
+ if(instance.supportsInterface(type(IInstance).interfaceId) == false) {
187
+ revert NotInstance();
188
+ }
189
+
190
+ (
191
+ info,
192
+ data
193
+ ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);// owner);
194
+
195
+ IRegistry registry = getRegistry();
196
+
197
+ //if(registry.allowance(registry.getNftId(msg.sender), INSTANCE()) == false) {
198
+ // revert MissingAllowance();
199
+ //}
200
+
201
+ info.nftId = registry.register(info);
202
+
203
+ return (
204
+ info,
205
+ data
206
+ );
207
+ }
208
+
209
+ function registerPolicy(IRegistry.ObjectInfo memory info)
210
+ external
211
+ returns(NftId nftId)
212
+ {
213
+ IRegistry registry = getRegistry();
214
+ NftId senderNftId = registry.getNftId(msg.sender);
215
+
216
+ if(registry.allowance(senderNftId, POLICY()) == false) {
217
+ revert MissingAllowance();
218
+ }
219
+
220
+ _verifyObjectInfo(info, POLICY());
221
+
222
+ nftId = registry.register(info);
223
+ }
224
+
225
+ function registerBundle(IRegistry.ObjectInfo memory info)
226
+ external
227
+ returns(NftId nftId)
228
+ {
229
+ IRegistry registry = getRegistry();
230
+ NftId senderNftId = registry.getNftId(msg.sender);
231
+
232
+ if(registry.allowance(senderNftId, BUNDLE()) == false) {
233
+ revert MissingAllowance();
234
+ }
235
+
236
+ _verifyObjectInfo(info, BUNDLE());
237
+
238
+ nftId = registry.register(info);
239
+ }
240
+
241
+
242
+ // From IService
243
+ function getName() public pure override(IService, ServiceBase) returns(string memory) {
244
+ return NAME;
245
+ }
246
+
247
+
248
+ // from Versionable
249
+
250
+ /// @dev top level initializer
251
+ // 1) registry is non upgradeable -> don't need a proxy and uses constructor !
252
+ // 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
253
+ // 3) deploy registry -> pass registry service address as constructor argument
254
+ // registry is getting instantiated and locked to registry service address forever
255
+ function _initialize(address protocolOwner, bytes memory registryCreationCode)
256
+ internal
257
+ initializer
258
+ virtual override
259
+ {
260
+ // TODO check when stable
261
+ //require(keccak256(registryCreationCode) == REGISTRY_CREATIONCODE_HASH, "INVALID_REGISTRY_CREATIONCODE");
262
+
263
+ bytes memory bytecode = abi.encodePacked(
264
+ registryCreationCode,
265
+ abi.encode(
266
+ protocolOwner,
267
+ getMajorVersion()
268
+ )
269
+ );
270
+
271
+ address registryAddress;
272
+
273
+ assembly {
274
+ registryAddress := create(0, add(bytecode, 0x20), mload(bytecode))
275
+
276
+ if iszero(extcodesize(registryAddress)) {
277
+ revert(0, 0)
278
+ }
279
+ }
280
+
281
+ IRegistry registry = IRegistry(registryAddress);
282
+ NftId registryNftId = registry.getNftId(registryAddress);
283
+
284
+ _initializeServiceBase(registryAddress, registryNftId, protocolOwner);
285
+
286
+ _registerInterface(type(IRegistryService).interfaceId);
287
+ }
288
+
289
+ // parent check done in registry because of approve()
290
+ function _getAndVerifyContractInfo(
291
+ IRegisterable registerable,
292
+ ObjectType objectType,
293
+ address owner
294
+ )
295
+ internal
296
+ returns(
297
+ IRegistry.ObjectInfo memory info,
298
+ bytes memory data
299
+ )
300
+ {
301
+ (
302
+ info,
303
+ data
304
+ ) = registerable.getInitialInfo();
305
+
306
+ if(info.objectAddress != address(registerable)) {
307
+ revert InvalidAddress(info.objectAddress);
308
+ }
309
+
310
+ if(
311
+ getRegistry().isRegistered(owner) ||
312
+ info.initialOwner != owner) { // contract owner protection
313
+ revert InvalidInitialOwner(info.initialOwner);
314
+ }
315
+
316
+ if(msg.sender == address(registerable)) {
317
+ revert SelfRegistration();
318
+ }
319
+
320
+ if(info.objectType != objectType) {
321
+ revert InvalidType(info.objectType);
322
+ }
323
+
324
+ /*NftId parentNftId = info.parentNftId;
325
+ IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
326
+
327
+ if(parentInfo.objectType != parentType) { // parent registration + type
328
+ revert InvalidParent(parentNftId);
329
+ }*/
330
+
331
+ return(
332
+ info,
333
+ data
334
+ );
335
+ }
336
+
337
+ // parent checks done in registry because of approve()
338
+ function _verifyObjectInfo(
339
+ IRegistry.ObjectInfo memory info,
340
+ ObjectType objectType
341
+ )
342
+ internal
343
+ view
344
+ {
345
+ if(info.objectAddress > address(0)) {
346
+ revert InvalidAddress(info.objectAddress);
347
+ }
348
+
349
+ if(
350
+ getRegistry().isRegistered(info.initialOwner) ||
351
+ info.initialOwner == address(0)) {
352
+ // TODO non registered address can register object(e.g. POLICY()) and then transfer associated nft to registered contract
353
+ // what are motivations to do so?
354
+ // at least registered contract can not register objects by itself, SERVICE,
355
+ revert InvalidInitialOwner(info.initialOwner);
356
+ }
357
+
358
+ // can catch all 3 if check that initialOwner is not registered
359
+ /*if(info.initialOwner == msg.sender) {
360
+ revert InitialOwnerIsParent();
361
+ }
362
+
363
+ if(info.initialOwner == address(this)) {
364
+ revert InitialOwnerIsService();
365
+ }
366
+
367
+ if(info.initialOwner == address(getRegistry())) {
368
+ revert InitialOwnerIsRegistry();
369
+ }*/
370
+
371
+
372
+ if(info.objectType != objectType) {
373
+ revert InvalidType(info.objectType);
374
+ }
375
+
376
+ /*NftId parentNftId = info.parentNftId;
377
+ IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
378
+
379
+ if(parentInfo.objectType != parentType) { // parent registration + type
380
+ revert InvalidParent(parentNftId);
381
+ }*/
382
+ }
383
+ }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
5
+
6
+ contract ERC165 is IERC165 {
7
+ mapping(bytes4 => bool) private _isSupported;
8
+
9
+ constructor() {
10
+ // register support for ERC165
11
+ _registerInterface(type(IERC165).interfaceId);
12
+ }
13
+
14
+ function supportsInterface(bytes4 interfaceId) external view override returns (bool) {
15
+ return _isSupported[interfaceId];
16
+ }
17
+
18
+ function _registerInterface(bytes4 interfaceId) internal {
19
+ _isSupported[interfaceId] = true;
20
+ }
21
+ }
@@ -0,0 +1,6 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ interface IOwnable {
5
+ function getOwner() external view returns (address owner);
6
+ }
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
5
+
6
+ import {IRegistry} from "../registry/IRegistry.sol";
7
+ import {NftId} from "../types/NftId.sol";
8
+ import {ObjectType} from "../types/ObjectType.sol";
9
+
10
+ import {IOwnable} from "./IOwnable.sol";
11
+
12
+ interface IRegisterable is IERC165, IOwnable {
13
+ function getRegistry() external view returns (IRegistry registry);
14
+
15
+ function getNftId() external view returns (NftId nftId);
16
+
17
+ function getInitialInfo()
18
+ external
19
+ view
20
+ returns (IRegistry.ObjectInfo memory, bytes memory data);
21
+
22
+ }
@@ -0,0 +1,96 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Blocknumber} from "../types/Blocknumber.sol";
5
+ import {Timestamp} from "../types/Timestamp.sol";
6
+ import {Version} from "../types/Version.sol";
7
+
8
+
9
+ /// IMPORTANT
10
+ // Upgradeable contract MUST:
11
+ // 1) inherit from Versionable
12
+ // 2) implement version() function
13
+ // 3) implement internal _initialize() function with onlyInitializing modifier
14
+ // 4) implement internal _upgrade() function with onlyInitializing modifier (1st version MUST revert)
15
+ // 5) have onlyInitialising modifier for each function callable inside _initialize()/_upgrade() (MUST use different functions for initialization/upgrade and normal operations)
16
+ // 6) use default empty constructor -> _disableInitializer() is called from Versionable contructor
17
+ // 7) use namespace storage
18
+ // 8) since now inheritance is used for upgradability, contract MUST BE inherited ONLY by the next version
19
+ // Upgradeable contract SHOULD:
20
+ // 9) define all non private methods as virtual (in order to be able to upgrade them latter)
21
+ // otherwise, it is still possible to upgrade contract, but everyone who is using it will have to switch to a new fucntions
22
+ // in some cases this ok but not in the others...
23
+ //
24
+ // IMPORTANT
25
+ // Each version MUST:
26
+ // 1) define namespace storage struct if accessing storage
27
+ // - DO NOT use structs inside, except
28
+ // - CAN use structs ONLY inside mappings
29
+ // 2) ALWAYS define private getter if accessing storage
30
+ // - MUST use default implementation, CAN change ONLY return type
31
+ // - MUST use the same "LOCATION_V1"
32
+
33
+ interface IVersionable {
34
+
35
+ struct VersionInfo {
36
+ Version version;
37
+ address implementation;
38
+ address activatedBy;
39
+ Timestamp activatedAt;
40
+ Blocknumber activatedIn;
41
+ }
42
+
43
+ event LogVersionableInitialized(Version version, address implementation, address activatedBy);
44
+
45
+ // TODO uncomment when all implementations are ready
46
+ /**
47
+ * @dev IMPORTANT
48
+ * implementation MUST be guarded by initializer modifier
49
+ * implementation MUST call internal function Versionable._updateVersionHistory
50
+ * new version MUST inherit from previous version
51
+ */
52
+ function initialize(address implementation, address activatedBy, bytes memory activationData) external;
53
+
54
+ /**
55
+ * @dev
56
+ * implementation MUST be guarded by reinitializer(version().toUint64()) modifier
57
+ * implementation MUST call internal function Versionable._updateVersionHistory
58
+ * new version MUST inherit from previous version
59
+ * the first verion MUST revert
60
+ */
61
+ function upgrade(address implementation, address activatedBy, bytes memory upgradeData) external;
62
+
63
+ /**
64
+ * @dev returns true if the specified version has been activated for the current contract
65
+ */
66
+ function isInitialized(Version version) external view returns(bool);
67
+
68
+ /**
69
+ * @dev returns version of this contract
70
+ * each new implementation MUST implement this function
71
+ * version number MUST increase
72
+ */
73
+ function getVersion() external pure returns(Version);
74
+
75
+ /**
76
+ * @dev returns the number of all deployed versions of this contract
77
+ */
78
+ function getVersionCount() external view returns(uint256 numberOfVersions);
79
+
80
+ /**
81
+ * @dev returns the i-th (index) version of this contract
82
+ */
83
+ function getVersion(uint256 index) external view returns(Version version);
84
+
85
+ /**
86
+ * @dev returns the i-th (index) version info of this contract
87
+ */
88
+ function getVersionInfo(Version version) external view returns(VersionInfo memory versionInfo);
89
+
90
+ // TODO make sure it is needed here
91
+ /**
92
+ * @dev returns currently active version
93
+ */
94
+ function getInitializedVersion() external view returns(uint64);
95
+
96
+ }