@etherisc/gif-next 0.0.2-ed4dd55 → 0.0.2-efdb520-159

Sign up to get free protection for your applications and to get access to all the features.
Files changed (319) hide show
  1. package/README.md +125 -0
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
  3. package/artifacts/contracts/components/{IPool.sol/IPoolComponent.json → BaseComponent.sol/BaseComponent.json} +55 -60
  4. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
  5. package/artifacts/contracts/{instance/component/IComponent.sol/IComponentContract.json → components/IBaseComponent.sol/IBaseComponent.json} +54 -59
  6. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +356 -0
  8. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +279 -0
  10. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.json +225 -33
  12. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  13. package/artifacts/contracts/components/Product.sol/Product.json +154 -62
  14. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
  15. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
  16. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  20. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  22. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  33. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  34. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  35. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  36. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  37. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  38. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  40. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  41. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1364 -234
  44. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +4 -0
  45. package/artifacts/contracts/instance/{component/IComponent.sol → IInstanceLinked.sol}/IInstanceLinked.json +1 -1
  46. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +4 -0
  47. package/artifacts/contracts/instance/{access/IAccess.sol/IAccessComponentTypeRoles.json → IServiceLinked.sol/IServiceLinked.json} +14 -14
  48. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  49. package/artifacts/contracts/instance/Instance.sol/Instance.json +1652 -373
  50. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  51. package/artifacts/contracts/instance/{component/ComponentModule.sol/ComponentModule.json → InstanceBase.sol/InstanceBase.json} +130 -144
  52. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +4 -0
  53. package/artifacts/contracts/instance/{access → module/access}/Access.sol/AccessModule.json +85 -152
  54. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +4 -0
  55. package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccess.json +1 -1
  56. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +4 -0
  57. package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccessModule.json +96 -99
  58. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +4 -0
  59. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +276 -0
  60. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +4 -0
  61. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.json +10 -0
  62. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +4 -0
  63. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +276 -0
  64. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +4 -0
  65. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +188 -0
  66. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +4 -0
  67. package/artifacts/contracts/instance/{component → module/component}/IComponent.sol/IComponent.json +1 -1
  68. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +4 -0
  69. package/artifacts/contracts/instance/{component → module/component}/IComponent.sol/IComponentModule.json +54 -111
  70. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  71. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +134 -0
  72. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +4 -0
  73. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.json +182 -0
  74. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +4 -0
  75. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +221 -0
  76. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +4 -0
  77. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicy.json +1 -1
  78. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +4 -0
  79. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicyModule.json +146 -116
  80. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +4 -0
  81. package/artifacts/contracts/instance/{policy → module/policy}/PolicyModule.sol/PolicyModule.json +146 -116
  82. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +4 -0
  83. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPool.json +1 -1
  84. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +4 -0
  85. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPoolModule.json +63 -63
  86. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +4 -0
  87. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +149 -0
  88. package/artifacts/contracts/instance/module/product/IProductModule.sol/IProductModule.dbg.json +4 -0
  89. package/artifacts/contracts/instance/module/product/IProductModule.sol/IProductModule.json +10 -0
  90. package/artifacts/contracts/instance/module/product/ProductModule.sol/ProductModule.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/product/ProductModule.sol/ProductModule.json +10 -0
  92. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.json +10 -0
  94. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +538 -0
  96. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  97. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +76 -0
  98. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
  99. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +538 -0
  100. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
  101. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +519 -0
  102. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.json +300 -0
  104. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +364 -0
  106. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  107. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +376 -0
  108. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  109. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +477 -0
  110. package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +4 -0
  111. package/artifacts/contracts/instance/service/IService.sol/IService.json +300 -0
  112. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  113. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +499 -0
  114. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  115. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +685 -0
  116. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  117. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.json +300 -0
  118. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  119. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +65 -2
  120. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  121. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  122. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +115 -89
  123. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  124. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +24 -0
  125. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  126. package/artifacts/contracts/registry/Registry.sol/Registry.json +244 -77
  127. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  128. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
  129. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +4 -0
  130. package/artifacts/contracts/{registry/IRegistry.sol → shared/IOwnable.sol}/IOwnable.json +1 -1
  131. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  132. package/artifacts/contracts/{registry/IRegistry.sol → shared/IRegisterable.sol}/IRegisterable.json +22 -67
  133. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  134. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +164 -0
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  136. package/artifacts/contracts/{registry/Registry.sol → shared/Registerable.sol}/Registerable.json +23 -68
  137. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  138. package/artifacts/contracts/{instance/pool/PoolModule.sol/PoolModule.json → shared/Versionable.sol/Versionable.json} +72 -70
  139. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  140. package/artifacts/contracts/test/TestFee.sol/TestFee.json +95 -0
  141. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +4 -0
  142. package/artifacts/contracts/test/TestPool.sol/TestPool.json +387 -0
  143. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +4 -0
  144. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +393 -0
  145. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  146. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +137 -0
  147. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  148. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +82 -0
  149. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  150. package/artifacts/contracts/test/TestService.sol/TestService.json +407 -0
  151. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  152. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +338 -0
  153. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  154. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +222 -0
  155. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  156. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +230 -0
  157. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  158. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  159. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  160. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
  161. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  163. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +85 -3
  165. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  166. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
  167. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  168. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  169. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  170. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  171. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
  172. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +236 -0
  173. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +4 -0
  174. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +453 -0
  175. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  176. package/artifacts/contracts/types/Version.sol/VersionLib.json +78 -0
  177. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  178. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +30 -0
  179. package/contracts/components/BaseComponent.sol +89 -0
  180. package/contracts/components/IBaseComponent.sol +19 -0
  181. package/contracts/components/IPoolComponent.sol +57 -0
  182. package/contracts/components/IProductComponent.sol +19 -0
  183. package/contracts/components/Pool.sol +161 -16
  184. package/contracts/components/Product.sol +79 -27
  185. package/contracts/experiment/errors/Require.sol +38 -0
  186. package/contracts/experiment/errors/Revert.sol +44 -0
  187. package/contracts/experiment/inheritance/A.sol +8 -11
  188. package/contracts/experiment/inheritance/B.sol +10 -5
  189. package/contracts/experiment/inheritance/C.sol +11 -5
  190. package/contracts/experiment/inheritance/IA.sol +2 -7
  191. package/contracts/experiment/inheritance/IB.sol +3 -2
  192. package/contracts/experiment/inheritance/IC.sol +4 -3
  193. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  194. package/contracts/experiment/statemachine/ISM.sol +25 -0
  195. package/contracts/experiment/statemachine/README.md +112 -0
  196. package/contracts/experiment/statemachine/SM.sol +57 -0
  197. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  198. package/contracts/experiment/types/TypeA.sol +14 -9
  199. package/contracts/experiment/types/TypeB.sol +14 -9
  200. package/contracts/instance/IInstance.sol +38 -8
  201. package/contracts/instance/IInstanceLinked.sol +8 -0
  202. package/contracts/instance/IServiceLinked.sol +12 -0
  203. package/contracts/instance/Instance.sol +43 -44
  204. package/contracts/instance/InstanceBase.sol +74 -0
  205. package/contracts/instance/module/access/Access.sol +149 -0
  206. package/contracts/instance/module/access/IAccess.sol +53 -0
  207. package/contracts/instance/module/bundle/BundleModule.sol +228 -0
  208. package/contracts/instance/module/bundle/IBundle.sol +53 -0
  209. package/contracts/instance/module/component/ComponentModule.sol +104 -0
  210. package/contracts/instance/module/component/IComponent.sol +53 -0
  211. package/contracts/instance/module/lifecycle/ILifecycle.sol +47 -0
  212. package/contracts/instance/module/lifecycle/LifecycleModule.sol +89 -0
  213. package/contracts/instance/module/policy/IPolicy.sol +60 -0
  214. package/contracts/instance/module/policy/PolicyModule.sol +84 -0
  215. package/contracts/instance/module/pool/IPoolModule.sol +41 -0
  216. package/contracts/instance/module/pool/PoolModule.sol +87 -0
  217. package/contracts/instance/module/product/IProductModule.sol +6 -0
  218. package/contracts/instance/module/product/ProductModule.sol +8 -0
  219. package/contracts/instance/module/treasury/ITreasury.sol +104 -0
  220. package/contracts/instance/module/treasury/TokenHandler.sol +48 -0
  221. package/contracts/instance/module/treasury/TreasuryModule.sol +148 -0
  222. package/contracts/instance/service/ComponentOwnerService.sol +174 -0
  223. package/contracts/instance/service/ComponentServiceBase.sol +41 -0
  224. package/contracts/instance/service/IComponentOwnerService.sol +22 -0
  225. package/contracts/instance/service/IPoolService.sol +30 -0
  226. package/contracts/instance/service/IProductService.sol +58 -0
  227. package/contracts/instance/service/IService.sol +15 -0
  228. package/contracts/instance/service/PoolService.sol +98 -0
  229. package/contracts/instance/service/ProductService.sol +358 -0
  230. package/contracts/instance/service/ServiceBase.sol +39 -0
  231. package/contracts/registry/ChainNft.sol +80 -94
  232. package/contracts/registry/IChainNft.sol +10 -7
  233. package/contracts/registry/IRegistry.sol +40 -51
  234. package/contracts/registry/IRegistryLinked.sol +8 -0
  235. package/contracts/registry/Registry.sol +312 -107
  236. package/contracts/shared/ERC165.sol +21 -0
  237. package/contracts/shared/IOwnable.sol +6 -0
  238. package/contracts/shared/IRegisterable.sol +24 -0
  239. package/contracts/shared/IVersionable.sol +52 -0
  240. package/contracts/shared/Registerable.sol +86 -0
  241. package/contracts/shared/Versionable.sol +92 -0
  242. package/contracts/test/TestFee.sol +25 -0
  243. package/contracts/test/TestPool.sol +22 -0
  244. package/contracts/test/TestProduct.sol +44 -0
  245. package/contracts/test/TestRegisterable.sol +19 -0
  246. package/contracts/test/TestRoleId.sol +14 -0
  247. package/contracts/test/TestService.sol +35 -0
  248. package/contracts/test/TestToken.sol +26 -0
  249. package/contracts/test/TestVersion.sol +47 -0
  250. package/contracts/test/TestVersionable.sol +20 -0
  251. package/contracts/types/AddressSet.sol +58 -0
  252. package/contracts/types/Blocknumber.sol +118 -0
  253. package/contracts/types/ChainId.sol +24 -10
  254. package/contracts/types/Fee.sol +32 -0
  255. package/contracts/types/NftId.sol +40 -8
  256. package/contracts/types/NftIdSet.sol +60 -0
  257. package/contracts/types/ObjectType.sol +115 -0
  258. package/contracts/types/RoleId.sol +36 -0
  259. package/contracts/types/StateId.sol +95 -0
  260. package/contracts/types/Timestamp.sol +123 -0
  261. package/contracts/types/UFixed.sol +206 -0
  262. package/contracts/types/Version.sol +91 -0
  263. package/package.json +19 -5
  264. package/artifacts/contracts/components/Component.sol/Component.dbg.json +0 -4
  265. package/artifacts/contracts/components/Component.sol/Component.json +0 -179
  266. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
  267. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
  268. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
  269. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
  270. package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +0 -192
  271. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
  272. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
  273. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
  274. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
  275. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
  276. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  277. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  278. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
  279. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -105
  280. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
  281. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
  282. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  283. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
  284. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -94
  285. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
  286. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  287. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  288. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  289. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  290. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  291. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  292. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
  293. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
  294. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
  295. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.json +0 -114
  296. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
  297. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +0 -75
  298. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
  299. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -125
  300. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
  301. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
  302. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
  303. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +0 -49
  304. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
  305. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
  306. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
  307. package/contracts/components/Component.sol +0 -62
  308. package/contracts/components/IPool.sol +0 -9
  309. package/contracts/components/IProduct.sol +0 -11
  310. package/contracts/instance/access/Access.sol +0 -218
  311. package/contracts/instance/access/IAccess.sol +0 -83
  312. package/contracts/instance/component/ComponentModule.sol +0 -259
  313. package/contracts/instance/component/IComponent.sol +0 -94
  314. package/contracts/instance/policy/IPolicy.sol +0 -66
  315. package/contracts/instance/policy/PolicyModule.sol +0 -106
  316. package/contracts/instance/pool/IPoolModule.sol +0 -40
  317. package/contracts/instance/pool/PoolModule.sol +0 -83
  318. package/contracts/instance/product/IProductService.sol +0 -45
  319. package/contracts/instance/product/ProductService.sol +0 -105
@@ -1,68 +1,57 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- interface IOwnable {
5
- function getOwner() external view returns(address owner);
6
- }
4
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
+
6
+ import {NftId} from "../types/NftId.sol";
7
+ import {ObjectType} from "../types/ObjectType.sol";
8
+ import {VersionPart} from "../types/Version.sol";
9
+ import {IChainNft} from "./IChainNft.sol";
10
+
11
+ interface IRegistry is IERC165 {
12
+ struct ObjectInfo {
13
+ NftId nftId;
14
+ NftId parentNftId;
15
+ ObjectType objectType;
16
+ address objectAddress;
17
+ address initialOwner;
18
+ bytes data;
19
+ }
7
20
 
8
- interface IRegistryLinked {
21
+ function register(address objectAddress) external returns (NftId nftId);
9
22
 
10
- event LogDebug(uint256 idx, address module, string comment);
23
+ function registerObjectForInstance(
24
+ NftId parentNftid,
25
+ ObjectType objectType,
26
+ address initialOwner,
27
+ bytes memory data
28
+ ) external returns (NftId nftId);
11
29
 
12
- function getRegistry() external view returns(IRegistry registry);
13
- }
30
+ function getServiceAddress(string memory serviceName, VersionPart majorVersion) external view returns (address serviceAddress);
14
31
 
15
- interface IRegisterable is
16
- IOwnable,
17
- IRegistryLinked
18
- {
19
-
20
- function register() external returns(uint256 nftId);
21
-
22
- function getNftId() external view returns(uint256 nftId);
23
- function getParentNftId() external view returns(uint256 parentNftId);
24
- function getType() external view returns(uint256 objectType);
25
- function getData() external view returns(bytes memory data);
26
- function isRegisterable() external pure returns(bool);
27
- function getInitialOwner() external view returns(address initialOwner);
28
-
29
- function isRegistered() external view returns(bool);
30
- }
32
+ function getObjectCount() external view returns (uint256);
31
33
 
34
+ function getNftId() external view returns (NftId nftId);
32
35
 
33
- interface IRegistry {
36
+ function getNftId(
37
+ address objectAddress
38
+ ) external view returns (NftId nftId);
34
39
 
35
- struct RegistryInfo {
36
- uint256 nftId;
37
- uint256 parentNftId;
38
- uint256 objectType;
39
- address objectAddress;
40
- address initialOwner;
41
- }
40
+ function getObjectInfo(
41
+ NftId nftId
42
+ ) external view returns (ObjectInfo memory info);
42
43
 
43
- function TOKEN() external pure returns(uint256);
44
- function INSTANCE() external pure returns(uint256);
45
- function PRODUCT() external pure returns(uint256);
46
- function ORACLE() external pure returns(uint256);
47
- function POOL() external pure returns(uint256);
48
- function POLICY() external pure returns(uint256);
49
- function BUNDLE() external pure returns(uint256);
44
+ function getName(
45
+ NftId nftId
46
+ ) external view returns (string memory name);
50
47
 
51
- function register(address objectAddress) external returns(uint256 nftId);
52
- function registerObjectForInstance(
53
- uint256 parentNftid,
54
- uint256 objectType,
55
- address initialOwner
56
- )
57
- external returns(uint256 nftId);
48
+ function getProtocolOwner() external view returns (address);
58
49
 
59
- function getObjectCount() external view returns(uint256);
50
+ function getOwner(NftId nftId) external view returns (address ownerAddress);
60
51
 
61
- function getNftId(address objectAddress) external view returns(uint256 nftId);
62
- function getInfo(uint256 nftId) external view returns(RegistryInfo memory info);
63
- function getOwner(uint256 nftId) external view returns(address ownerAddress);
52
+ function isRegistered(NftId nftId) external view returns (bool);
64
53
 
65
- function isRegistered(address objectAddress) external view returns(bool);
54
+ function isRegistered(address objectAddress) external view returns (bool);
66
55
 
67
- function getNftAddress() external view returns(address nft);
56
+ function getChainNft() external view returns (IChainNft);
68
57
  }
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IRegistry} from "../registry/IRegistry.sol";
5
+
6
+ interface IRegistryLinked {
7
+ function getRegistry() external view returns (IRegistry registry);
8
+ }
@@ -1,144 +1,173 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IChainNft} from "./IChainNft.sol";
5
- import {IRegistry, IRegistryLinked, IRegisterable} from "./IRegistry.sol";
4
+ import {IRegisterable} from "../shared/IRegisterable.sol";
5
+ import {IService} from "../instance/service/IService.sol";
6
6
 
7
- contract RegistryLinked is IRegistryLinked {
7
+ import {IChainNft} from "./IChainNft.sol";
8
+ import {ChainNft} from "./ChainNft.sol";
9
+ import {IRegistry} from "./IRegistry.sol";
10
+ import {NftId, toNftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
11
+ import {VersionPart} from "../types/Version.sol";
12
+ import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, DISTRIBUTOR, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
13
+
14
+ // TODO make registry upgradable
15
+ contract Registry is
16
+ IRegisterable,
17
+ IRegistry
18
+ {
19
+ using NftIdLib for NftId;
8
20
 
9
- IRegistry internal _registry;
10
-
11
- constructor(address registry) {
12
- _registry = IRegistry(registry);
13
- }
21
+ string public constant EMPTY_URI = "";
14
22
 
15
- function getRegistry() external view override returns(IRegistry registry) {
16
- return _registry;
17
- }
23
+ mapping(NftId nftId => ObjectInfo info) private _info;
24
+ mapping(NftId nftId => address owner) private _owner;
25
+ mapping(address object => NftId nftId) private _nftIdByAddress;
26
+ mapping(ObjectType objectType => bool) private _isValidType;
27
+ mapping(ObjectType objectType => mapping(ObjectType objectParentType => bool)) private _isValidParentType;
18
28
 
19
- }
29
+ mapping(NftId nftId => string stringValue) private _string;
30
+ mapping(bytes32 serviceNameHash => mapping(VersionPart majorVersion => address service)) _service;
20
31
 
32
+ NftId private _nftId;
33
+ IChainNft private _chainNft;
34
+ ChainNft private _chainNftInternal;
35
+ address private _initialOwner;
21
36
 
22
- abstract contract Registerable is
23
- RegistryLinked,
24
- IRegisterable
25
- {
37
+ // @dev will own protocol nft and registry nft(s) minted during initialize
38
+ address private _protocolOwner;
26
39
 
27
- address private _initialOwner;
28
-
29
- constructor(address registry)
30
- RegistryLinked(registry)
40
+ // TODO refactor once registry becomes upgradable
41
+ // @Dev the protocol owner will get ownership of the
42
+ // protocol nft and the global registry nft minted in this
43
+ // initializer function
44
+ function initialize(
45
+ address chainNft,
46
+ address protocolOwner
47
+ )
48
+ public
31
49
  {
32
- _initialOwner = msg.sender;
33
- }
50
+ require(
51
+ address(_chainNft) == address(0),
52
+ "ERROR:REG-001:ALREADY_INITIALIZED"
53
+ );
34
54
 
35
- // getType, getData and register need to be implemented by concrete contract
55
+ _initialOwner = msg.sender;
56
+ _protocolOwner = protocolOwner;
36
57
 
37
- function isRegisterable() external pure override returns(bool) {
38
- return true;
39
- }
58
+ _chainNft = IChainNft(chainNft);
59
+ _chainNftInternal = ChainNft(chainNft);
40
60
 
41
- function getInitialOwner() public view override returns(address deployer) {
42
- return _initialOwner;
43
- }
61
+ // initial registry setup
62
+ _registerProtocol();
63
+ _nftId = _registerRegistry();
44
64
 
45
- function isRegistered() public view override returns(bool) {
46
- return _registry.getNftId(address(this)) > 0;
65
+ // setup rules for further registrations
66
+ _setupValidTypes();
67
+ _setupValidParentTypes();
47
68
  }
48
69
 
49
- function getNftId() public view override returns(uint256 id) {
50
- return _registry.getNftId(address(this));
51
- }
52
70
 
53
- function getOwner() public view override returns(address owner) {
54
- uint256 id = _registry.getNftId(address(this));
55
- owner = _registry.getOwner(id);
56
- return owner != address(0) ? owner : _initialOwner;
57
- }
71
+ function register(
72
+ address objectAddress
73
+ )
74
+ // TODO add authz (only services may register components etc)
75
+ // we have to check how we do authz for registring services (just restrict to protocol owner/registry owner)
76
+ external override returns (NftId nftId) {
77
+ require(
78
+ _nftIdByAddress[objectAddress].eqz(),
79
+ "ERROR:REG-002:ALREADY_REGISTERED"
80
+ );
58
81
 
59
- }
82
+ IRegisterable registerable = IRegisterable(objectAddress);
83
+ require(
84
+ registerable.supportsInterface(type(IRegisterable).interfaceId),
85
+ "ERROR:REG-003:NOT_REGISTERABLE"
86
+ );
60
87
 
61
- contract Registry is IRegistry {
88
+ ObjectType objectType = registerable.getType();
89
+ require(
90
+ _isValidType[objectType],
91
+ "ERROR:REG-004:TYPE_INVALID"
92
+ );
62
93
 
63
- string public constant EMPTY_URI = "";
94
+ NftId parentNftId = registerable.getParentNftId();
95
+ require(
96
+ isRegistered(parentNftId),
97
+ "ERROR:REG-005:PARENT_NOT_REGISTERED"
98
+ );
64
99
 
65
- mapping(uint256 id => RegistryInfo info) private _info;
66
- mapping(uint256 id => address owner) private _owner;
67
- mapping(address object => uint256 id) private _idByAddress;
100
+ require(
101
+ _isValidParentType[objectType][_info[parentNftId].objectType],
102
+ "ERROR:REG-006:PARENT_TYPE_INVALID"
103
+ );
68
104
 
69
- IChainNft private _chainNft;
105
+ // also check that nftId and parentNFtId are on the same chain if applicable
70
106
 
71
- function initialize(address chainNft) external {
72
- require(address(_chainNft) == address(0), "ERROR:REG-001:ALREADY_INITIALIZED");
73
- _chainNft = IChainNft(chainNft);
74
- }
107
+ // nft minting
108
+ uint256 mintedTokenId = _chainNft.mint(
109
+ registerable.getOwner(),
110
+ EMPTY_URI
111
+ );
75
112
 
76
- function TOKEN() public pure override returns(uint256) { return 30; }
77
- function INSTANCE() public pure override returns(uint256) { return 40; }
78
- function PRODUCT() public pure override returns(uint256) { return 50; }
79
- function ORACLE() public pure override returns(uint256) { return 60; }
80
- function POOL() public pure override returns(uint256) { return 70; }
81
- function POLICY() public pure override returns(uint256) { return 80; }
82
- function BUNDLE() public pure override returns(uint256) { return 90; }
113
+ nftId = toNftId(mintedTokenId);
83
114
 
84
- function register(address objectAddress) external override returns(uint256 nftId) {
85
- require(_idByAddress[objectAddress] == 0, "ERROR:REG-001:ALREADY_REGISTERED");
115
+ // special case services
116
+ if(registerable.getType() == SERVICE()) {
117
+ IService service = IService(objectAddress);
118
+ require(
119
+ service.supportsInterface(type(IService).interfaceId),
120
+ "ERROR:REG-007:NOT_SERVICE"
121
+ );
86
122
 
87
- IRegisterable registerable = IRegisterable(objectAddress);
88
- require(registerable.isRegisterable(), "ERROR:REG-002:NOT_REGISTERABLE");
89
-
90
- // check parent exists (for objects not instances)
91
- if(registerable.getType() != INSTANCE()) {
92
- RegistryInfo memory parentInfo = _info[registerable.getParentNftId()];
93
- require(parentInfo.nftId > 0, "ERROR:REG-003:PARENT_NOT_FOUND");
94
- // check validity of parent relation, valid relations are
95
- // policy -> product, bundle -> pool, product -> instance, pool -> instance
96
- }
123
+ string memory serviceName = service.getName();
124
+ VersionPart majorVersion = service.getMajorVersion();
125
+ bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
97
126
 
98
- nftId = _chainNft.mint(
99
- registerable.getInitialOwner(),
100
- EMPTY_URI);
101
-
102
- RegistryInfo memory info = RegistryInfo(
103
- nftId,
104
- registerable.getParentNftId(),
105
- registerable.getType(),
106
- objectAddress,
107
- registerable.getInitialOwner()
108
- );
127
+ // service specific state
128
+ _string[nftId] = serviceName;
109
129
 
110
- _info[nftId] = info;
111
- _idByAddress[objectAddress] = nftId;
130
+ require(
131
+ _service[serviceNameHash][majorVersion] == address(0),
132
+ "ERROR:REG-008:ALREADY_REGISTERED"
133
+ );
134
+ _service[serviceNameHash][majorVersion] = objectAddress;
135
+ }
112
136
 
113
- // add logging
137
+ // create object info and link nft id with it
138
+ _registerObjectInfo(registerable, nftId);
114
139
  }
115
140
 
116
141
 
117
142
  function registerObjectForInstance(
118
- uint256 parentNftId,
119
- uint256 objectType,
120
- address initialOwner
143
+ NftId parentNftId,
144
+ ObjectType objectType,
145
+ address initialOwner,
146
+ bytes memory data
121
147
  )
122
- external
148
+ external
123
149
  override
124
- // TODO add onlyRegisteredInstance
125
- returns(uint256 nftId)
150
+ returns (
151
+ // TODO add onlyRegisteredInstance
152
+ NftId nftId
153
+ )
126
154
  {
127
155
  // TODO add more validation
128
156
  require(
129
157
  objectType == POLICY() || objectType == BUNDLE(),
130
- "ERROR:REG-005:TYPE_INVALID");
158
+ "ERROR:REG-010:TYPE_INVALID"
159
+ );
131
160
 
132
- nftId = _chainNft.mint(
133
- initialOwner,
134
- EMPTY_URI);
161
+ uint256 mintedTokenId = _chainNft.mint(initialOwner, EMPTY_URI);
162
+ nftId = toNftId(mintedTokenId);
135
163
 
136
- RegistryInfo memory info = RegistryInfo(
164
+ ObjectInfo memory info = ObjectInfo(
137
165
  nftId,
138
166
  parentNftId,
139
167
  objectType,
140
168
  address(0),
141
- initialOwner
169
+ initialOwner,
170
+ data
142
171
  );
143
172
 
144
173
  _info[nftId] = info;
@@ -146,31 +175,207 @@ contract Registry is IRegistry {
146
175
  // add logging
147
176
  }
148
177
 
149
-
150
- function getObjectCount() external view override returns(uint256) {
178
+ function getObjectCount() external view override returns (uint256) {
151
179
  return _chainNft.totalSupply();
152
180
  }
153
181
 
182
+ function getNftId(
183
+ address object
184
+ ) external view override returns (NftId id) {
185
+ return _nftIdByAddress[object];
186
+ }
187
+
188
+ function isRegistered(
189
+ NftId nftId
190
+ ) public view override returns (bool) {
191
+ return _info[nftId].objectType.gtz();
192
+ }
154
193
 
155
- function getNftId(address object) external view override returns(uint256 id) {
156
- return _idByAddress[object];
194
+ function isRegistered(
195
+ address object
196
+ ) external view override returns (bool) {
197
+ return _nftIdByAddress[object].gtz();
157
198
  }
158
199
 
200
+ function getObjectInfo(
201
+ NftId nftId
202
+ ) external view override returns (ObjectInfo memory info) {
203
+ return _info[nftId];
204
+ }
159
205
 
160
- function isRegistered(address object) external view override returns(bool) {
161
- return _idByAddress[object] > 0;
206
+ function getName(
207
+ NftId nftId
208
+ ) external view returns (string memory name) {
209
+ return _string[nftId];
162
210
  }
163
211
 
212
+ function getOwner(NftId nftId) external view override returns (address) {
213
+ return _chainNft.ownerOf(nftId.toInt());
214
+ }
164
215
 
165
- function getInfo(uint256 nftId) external view override returns(RegistryInfo memory info) {
166
- return _info[nftId];
216
+ function getChainNft() external view override returns (IChainNft) {
217
+ return _chainNft;
218
+ }
219
+
220
+ // special case to retrive a gif service
221
+ function getServiceAddress(string memory serviceName, VersionPart majorVersion) external view override returns (address serviceAddress) {
222
+ bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
223
+ return _service[serviceNameHash][majorVersion];
224
+ }
225
+
226
+ // from IERC165
227
+ function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
228
+ return interfaceId == type(IRegistry).interfaceId;
229
+ }
230
+
231
+ // from IRegistryLinked
232
+ function getRegistry() external view override returns (IRegistry registry) {
233
+ return this;
234
+ }
235
+
236
+ // from IRegisterable
237
+ function register() external pure override returns (NftId nftId) {
238
+ return zeroNftId();
239
+ }
240
+
241
+ function getType() external pure override returns (ObjectType objectType) {
242
+ return REGISTRY();
243
+ }
244
+
245
+
246
+ function getOwner() public view override returns (address owner) {
247
+ return _nftId.gtz() ? this.getOwner(_nftId) : _initialOwner;
248
+ }
249
+
250
+ function getNftId() external view override (IRegisterable, IRegistry) returns (NftId nftId) {
251
+ return _nftId;
252
+ }
253
+
254
+ function getParentNftId() external view returns (NftId nftId) {
255
+ // we're the global registry
256
+ if(block.chainid == 1) {
257
+ return toNftId(_chainNftInternal.PROTOCOL_NFT_ID());
258
+ }
259
+ else {
260
+ return toNftId(_chainNftInternal.GLOBAL_REGISTRY_ID());
261
+ }
262
+ }
263
+
264
+ function getData() external pure returns (bytes memory data) {
265
+ return "";
266
+ }
267
+
268
+ // registry specific functions
269
+ function getProtocolOwner() external view override returns (address) {
270
+ return _protocolOwner;
167
271
  }
168
272
 
169
- function getOwner(uint256 nftId) external view override returns(address) {
170
- return _chainNft.ownerOf(nftId);
273
+ /// @dev defines which types are allowed to register
274
+ function _setupValidTypes() internal {
275
+ _isValidType[REGISTRY()] = true; // only for global registry
276
+ _isValidType[TOKEN()] = true;
277
+ _isValidType[SERVICE()] = true;
278
+ _isValidType[INSTANCE()] = true;
279
+ _isValidType[STAKE()] = true;
280
+ _isValidType[PRODUCT()] = true;
281
+ _isValidType[ORACLE()] = true;
282
+ _isValidType[POOL()] = true;
283
+ _isValidType[POLICY()] = true;
284
+ _isValidType[BUNDLE()] = true;
171
285
  }
172
286
 
173
- function getNftAddress() external view override returns(address nft) {
174
- return address(_chainNft);
287
+ /// @dev defines which types - parent type relations are allowed to register
288
+ function _setupValidParentTypes() internal {
289
+ // registry as parent
290
+ _isValidParentType[TOKEN()][REGISTRY()] = true;
291
+ _isValidParentType[SERVICE()][REGISTRY()] = true;
292
+ _isValidParentType[INSTANCE()][REGISTRY()] = true;
293
+
294
+ // instance as parent
295
+ _isValidParentType[PRODUCT()][INSTANCE()] = true;
296
+ _isValidParentType[DISTRIBUTOR()][INSTANCE()] = true;
297
+ _isValidParentType[ORACLE()][INSTANCE()] = true;
298
+ _isValidParentType[POOL()][INSTANCE()] = true;
299
+
300
+ // product as parent
301
+ _isValidParentType[POLICY()][PRODUCT()] = true;
302
+
303
+ // pool as parent
304
+ _isValidParentType[BUNDLE()][POOL()] = true;
305
+ _isValidParentType[STAKE()][POOL()] = true;
175
306
  }
307
+
308
+ /// @dev protocol registration used to anchor the dip ecosystem relations
309
+ function _registerProtocol() virtual internal {
310
+ uint256 protocolId = _chainNftInternal.PROTOCOL_NFT_ID();
311
+ _chainNftInternal.mint(_protocolOwner, protocolId);
312
+
313
+ NftId protocolNftid = toNftId(protocolId);
314
+ ObjectInfo memory protocolInfo = ObjectInfo(
315
+ protocolNftid,
316
+ zeroNftId(), // parent nft id
317
+ PROTOCOL(),
318
+ address(0), // contract address
319
+ _protocolOwner,
320
+ "" // data
321
+ );
322
+
323
+ _info[protocolNftid] = protocolInfo;
324
+ }
325
+
326
+ /// @dev registry registration
327
+ /// might also register the global registry when not on mainnet
328
+ function _registerRegistry() virtual internal returns (NftId registryNftId) {
329
+ uint256 registryId = _chainNftInternal.calculateTokenId(2);
330
+ registryNftId = toNftId(registryId);
331
+
332
+ // we're not the global registry
333
+ if(registryId != _chainNftInternal.GLOBAL_REGISTRY_ID()) {
334
+ _registerGlobalRegistry();
335
+ }
336
+
337
+ _chainNftInternal.mint(_protocolOwner, registryId);
338
+ _registerObjectInfo(this, registryNftId);
339
+ }
340
+
341
+
342
+ /// @dev global registry registration for non mainnet registries
343
+ function _registerGlobalRegistry() virtual internal {
344
+ uint256 globalRegistryId = _chainNftInternal.GLOBAL_REGISTRY_ID();
345
+ _chainNftInternal.mint(_protocolOwner, globalRegistryId);
346
+
347
+ NftId globalRegistryNftId = toNftId(globalRegistryId);
348
+ ObjectInfo memory globalRegistryInfo = ObjectInfo(
349
+ globalRegistryNftId,
350
+ toNftId(_chainNftInternal.PROTOCOL_NFT_ID()),
351
+ REGISTRY(),
352
+ address(0), // contract address
353
+ _protocolOwner,
354
+ "" // data
355
+ );
356
+
357
+ _info[globalRegistryNftId] = globalRegistryInfo;
358
+ }
359
+
360
+
361
+ function _registerObjectInfo(
362
+ IRegisterable registerable,
363
+ NftId nftId
364
+ ) internal virtual {
365
+ address objectAddress = address(registerable);
366
+ ObjectInfo memory info = ObjectInfo(
367
+ nftId,
368
+ registerable.getParentNftId(),
369
+ registerable.getType(),
370
+ objectAddress,
371
+ registerable.getOwner(),
372
+ registerable.getData()
373
+ );
374
+
375
+ _info[nftId] = info;
376
+ _nftIdByAddress[objectAddress] = nftId;
377
+
378
+ // add logging
379
+ }
380
+
176
381
  }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IERC165} from "@openzeppelin/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,24 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IERC165} from "@openzeppelin/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 register() external returns (NftId nftId);
16
+
17
+ function getType() external pure returns (ObjectType objectType);
18
+
19
+ function getNftId() external view returns (NftId nftId);
20
+
21
+ function getParentNftId() external view returns (NftId nftId);
22
+
23
+ function getData() external view returns (bytes memory data);
24
+ }