@etherisc/gif-next 0.0.2-f752d2a-551 → 0.0.2-f7b8c9f-436

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. package/README.md +71 -0
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +166 -39
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +557 -0
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +119 -39
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +177 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +108 -156
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +67 -139
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +417 -88
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +360 -51
  18. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  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 +1 -1
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  37. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +913 -530
  38. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/Instance.sol/Instance.json +1043 -556
  41. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +224 -43
  43. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +51 -1
  45. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +49 -0
  47. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  48. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/IService.sol/IService.json +174 -53
  50. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +263 -45
  52. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  53. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +41 -23
  54. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  55. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
  56. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  58. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +220 -52
  59. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +55 -54
  64. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +56 -55
  67. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +22 -93
  69. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +22 -93
  72. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  73. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  74. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  75. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensation.json → distribution/IDistribution.sol/IDistribution.json} +2 -2
  76. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  77. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensationModule.json → distribution/IDistribution.sol/IDistributionModule.json} +2 -2
  78. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  80. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +61 -51
  81. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  82. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +61 -51
  83. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  85. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +29 -14
  86. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  87. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +28 -13
  88. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  89. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  90. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +104 -1
  91. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  92. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +126 -5
  93. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  94. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  95. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +326 -221
  96. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  97. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  98. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  99. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +326 -221
  100. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +350 -79
  102. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +630 -0
  104. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  105. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +176 -74
  106. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  107. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
  108. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  109. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +235 -50
  110. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  111. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +325 -51
  112. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  113. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +335 -53
  114. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  115. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +466 -71
  116. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  117. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +141 -12
  118. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  119. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +5 -0
  120. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  121. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +298 -39
  122. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  123. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +745 -0
  124. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  125. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  126. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  127. package/artifacts/contracts/registry/Registry.sol/Registry.json +489 -120
  128. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  129. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +997 -0
  130. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  131. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +468 -0
  132. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  133. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  134. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  135. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  136. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  137. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
  138. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  139. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +117 -37
  140. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  141. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -14
  142. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  143. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
  144. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  145. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
  146. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  147. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +190 -37
  148. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  149. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  150. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  151. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -14
  152. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  153. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +557 -0
  154. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  156. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestPool.sol/TestPool.json +417 -88
  158. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +407 -56
  160. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  161. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +204 -36
  162. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  163. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  164. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  165. package/artifacts/contracts/test/TestService.sol/TestService.json +267 -62
  166. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  167. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  168. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  169. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  170. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +89 -25
  171. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  172. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  173. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/Fee.sol/FeeLib.json +50 -11
  177. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  178. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  179. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  181. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  182. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  183. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  185. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  186. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  187. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  188. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  189. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  191. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  192. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  194. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -2
  196. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  198. package/contracts/components/BaseComponent.sol +12 -21
  199. package/contracts/components/Distribution.sol +155 -0
  200. package/contracts/components/IBaseComponent.sol +2 -2
  201. package/contracts/components/IDistributionComponent.sol +46 -0
  202. package/contracts/components/IPoolComponent.sol +15 -8
  203. package/contracts/components/IProductComponent.sol +26 -8
  204. package/contracts/components/Pool.sol +99 -27
  205. package/contracts/components/Product.sol +204 -22
  206. package/contracts/instance/IInstance.sol +12 -10
  207. package/contracts/instance/Instance.sol +28 -9
  208. package/contracts/instance/base/ComponentServiceBase.sol +13 -6
  209. package/contracts/instance/base/IInstanceBase.sol +11 -2
  210. package/contracts/instance/base/IKeyValueStore.sol +4 -3
  211. package/contracts/instance/base/InstanceBase.sol +19 -10
  212. package/contracts/instance/base/KeyValueStore.sol +12 -7
  213. package/contracts/instance/base/Lifecycle.sol +15 -10
  214. package/contracts/instance/base/ModuleBase.sol +22 -17
  215. package/contracts/instance/base/ServiceBase.sol +20 -13
  216. package/contracts/instance/module/access/Access.sol +3 -3
  217. package/contracts/instance/module/bundle/BundleModule.sol +10 -12
  218. package/contracts/instance/module/bundle/IBundle.sol +6 -11
  219. package/contracts/instance/module/component/ComponentModule.sol +34 -58
  220. package/contracts/instance/module/component/IComponent.sol +7 -32
  221. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  222. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  223. package/contracts/instance/module/policy/IPolicy.sol +13 -10
  224. package/contracts/instance/module/policy/PolicyModule.sol +35 -20
  225. package/contracts/instance/module/pool/IPoolModule.sol +4 -4
  226. package/contracts/instance/module/pool/PoolModule.sol +23 -15
  227. package/contracts/instance/module/risk/IRisk.sol +18 -2
  228. package/contracts/instance/module/risk/RiskModule.sol +56 -2
  229. package/contracts/instance/module/treasury/ITreasury.sol +32 -51
  230. package/contracts/instance/module/treasury/TokenHandler.sol +2 -2
  231. package/contracts/instance/module/treasury/TreasuryModule.sol +68 -89
  232. package/contracts/instance/service/ComponentOwnerService.sol +200 -95
  233. package/contracts/instance/service/DistributionService.sol +54 -0
  234. package/contracts/instance/service/IComponentOwnerService.sol +0 -2
  235. package/contracts/instance/service/IDistributionService.sol +12 -0
  236. package/contracts/instance/service/IPoolService.sol +7 -0
  237. package/contracts/instance/service/IProductService.sol +56 -7
  238. package/contracts/instance/service/PoolService.sol +49 -23
  239. package/contracts/instance/service/ProductService.sol +248 -92
  240. package/contracts/registry/ChainNft.sol +43 -15
  241. package/contracts/registry/IChainNft.sol +3 -2
  242. package/contracts/registry/IRegistry.sol +42 -26
  243. package/contracts/registry/IRegistryService.sol +29 -0
  244. package/contracts/registry/ITransferInterceptor.sol +6 -0
  245. package/contracts/registry/Registry.sol +384 -274
  246. package/contracts/registry/RegistryService.sol +368 -0
  247. package/contracts/registry/RegistryServiceManager.sol +43 -0
  248. package/contracts/shared/ContractDeployerLib.sol +72 -0
  249. package/contracts/shared/ERC165.sol +1 -1
  250. package/contracts/shared/INftOwnable.sol +22 -0
  251. package/contracts/shared/IRegisterable.sol +9 -16
  252. package/contracts/shared/IVersionable.sol +55 -11
  253. package/contracts/shared/NftOwnable.sol +136 -0
  254. package/contracts/shared/ProxyManager.sol +94 -0
  255. package/contracts/shared/Registerable.sol +62 -59
  256. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  257. package/contracts/shared/Versionable.sol +112 -54
  258. package/contracts/test/TestDistribution.sol +22 -0
  259. package/contracts/test/TestPool.sol +7 -2
  260. package/contracts/test/TestProduct.sol +37 -7
  261. package/contracts/test/TestRegisterable.sol +5 -6
  262. package/contracts/test/TestService.sol +5 -11
  263. package/contracts/types/Fee.sol +8 -3
  264. package/contracts/types/ObjectType.sol +24 -8
  265. package/contracts/types/ReferralId.sol +48 -0
  266. package/contracts/types/RiskId.sol +43 -0
  267. package/contracts/types/RoleId.sol +2 -2
  268. package/contracts/types/Version.sol +9 -0
  269. package/package.json +1 -1
  270. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
  271. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
  272. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
  273. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
  274. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
  275. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
  276. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  277. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  278. package/contracts/experiment/statemachine/README.md +0 -112
  279. package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
  280. package/contracts/instance/module/compensation/ICompensation.sol +0 -10
  281. package/contracts/registry/IRegistryLinked.sol +0 -8
  282. package/contracts/shared/IOwnable.sol +0 -6
@@ -0,0 +1,368 @@
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 {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
10
+ import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
11
+ import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
12
+ import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
13
+ import {IPoolComponent} from "../../contracts/components/IPoolComponent.sol";
14
+ import {IProductComponent} from "../../contracts/components/IProductComponent.sol";
15
+ import {IDistributionComponent} from "../../contracts/components/IDistributionComponent.sol";
16
+
17
+ import {IVersionable} from "../../contracts/shared/IVersionable.sol";
18
+ import {Versionable} from "../../contracts/shared/Versionable.sol";
19
+ import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
20
+
21
+ import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
22
+ import {ObjectType, REGISTRY, TOKEN, SERVICE, PRODUCT, ORACLE, POOL, TOKEN, INSTANCE, DISTRIBUTION, POLICY, BUNDLE} from "../../contracts/types/ObjectType.sol";
23
+ import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
24
+ import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
25
+ import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
26
+ import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
27
+
28
+ import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
29
+ import {IService} from "../../contracts/instance/base/IService.sol";
30
+ import {IRegistryService} from "./IRegistryService.sol";
31
+ import {Registry} from "../registry/Registry.sol";
32
+
33
+ contract RegistryService is
34
+ ServiceBase,
35
+ IRegistryService
36
+ {
37
+ using NftIdLib for NftId;
38
+
39
+ error NotRegistryOwner();
40
+ error MissingAllowance();
41
+
42
+ error NotToken();
43
+ error NotService();
44
+ error NotComponent();
45
+ error NotInstance();
46
+
47
+ error InvalidAddress(address registerableAddress);
48
+ error InvalidInitialOwner(address initialOwner);
49
+ error SelfRegistration();
50
+ error InvalidType(ObjectType objectType);
51
+
52
+ string public constant NAME = "RegistryService";
53
+
54
+ // TODO update to real hash when registry is stable
55
+ bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
56
+
57
+ address constant public NFT_LOCK_ADDRESS = address(0x1);
58
+
59
+ /// @dev
60
+ // msg.sender - ONLY registry owner
61
+ // CAN register ANY non IRegisterable address
62
+ // CAN register ONLY valid object-parent types combinations for TOKEN
63
+ // CAN NOT register itself
64
+ // IMPORTANT: MUST NOT call untrusted contract inbetween calls to registry/instance (trusted contracts)
65
+ // motivation: registry/instance state may change during external call
66
+ // TODO it may be usefull to have transferable token nft in order to delist token, make it invalid for new beginings
67
+ // TODO: MUST prohibit registration of precompiles addresses
68
+ function registerToken(address tokenAddress)
69
+ external
70
+ returns(NftId nftId)
71
+ {
72
+ IRegisterable registerable = IRegisterable(tokenAddress);
73
+ bool isRegisterable;
74
+
75
+ // registryOwner can not register IRegisterable as TOKEN
76
+ try registerable.supportsInterface(type(IRegisterable).interfaceId) returns(bool result) {
77
+ isRegisterable = result;
78
+ } catch {
79
+ isRegisterable = false;
80
+ }
81
+
82
+ if(isRegisterable) {
83
+ revert NotToken();
84
+ }
85
+
86
+ NftId registryNftId = _registry.getNftId(address(_registry));
87
+ if(msg.sender != _registry.ownerOf(registryNftId)) {
88
+ revert NotRegistryOwner();
89
+ }
90
+
91
+ IRegistry.ObjectInfo memory info = IRegistry.ObjectInfo(
92
+ zeroNftId(), // any value
93
+ registryNftId, // parent nft id
94
+ TOKEN(),
95
+ false, // isInterceptor
96
+ tokenAddress,
97
+ NFT_LOCK_ADDRESS,
98
+ "" // any value
99
+ );
100
+
101
+ nftId = _registry.register(info);
102
+ }
103
+
104
+ /// @dev
105
+ // msg.sender - ONLY registry owner
106
+ // CAN register ONLY valid object-parent types combinations for SERVICE
107
+ // CAN register ONLY IRegisterable address he owns
108
+ // CAN NOT register itself
109
+ // IMPORTANT: MUST NOT check owner before calling external contract
110
+ function registerService(IService service)
111
+ external
112
+ returns(
113
+ IRegistry.ObjectInfo memory info,
114
+ bytes memory data
115
+ )
116
+ {
117
+ if(service.supportsInterface(type(IService).interfaceId) == false) {
118
+ revert NotService();
119
+ }
120
+
121
+ (
122
+ info,
123
+ data
124
+ ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
125
+
126
+ NftId registryNftId = _registry.getNftId(address(_registry));
127
+ if(msg.sender != _registry.ownerOf(registryNftId)) {
128
+ revert NotRegistryOwner();
129
+ }
130
+
131
+ info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
132
+ info.nftId = _registry.register(info);
133
+ service.linkToRegisteredNftId();
134
+
135
+ return (
136
+ info,
137
+ data
138
+ );
139
+ }
140
+
141
+ // anybody can register component if instance gives a corresponding role
142
+ //function registerComponent(IBaseComponent component, ObjectType componentType)
143
+ function registerComponent(IBaseComponent component, ObjectType componentType, address owner)
144
+ external
145
+ returns(
146
+ IRegistry.ObjectInfo memory info,
147
+ bytes memory data
148
+ )
149
+ {
150
+ if(!component.supportsInterface(type(IBaseComponent).interfaceId)) {
151
+ revert NotComponent();
152
+ }
153
+
154
+ (
155
+ info,
156
+ data
157
+ ) = _getAndVerifyContractInfo(component, componentType, owner);
158
+
159
+ NftId serviceNftId = _registry.getNftId(msg.sender);
160
+
161
+ if(!_registry.allowance(serviceNftId, componentType)) {
162
+ revert MissingAllowance();
163
+ }
164
+
165
+ info.nftId = _registry.register(info);
166
+ component.linkToRegisteredNftId();
167
+
168
+ return (
169
+ info,
170
+ data
171
+ );
172
+ }
173
+
174
+ // TODO: when called by approved service: add owner arg (service must pass it's msg.sender as owner) & check service allowance
175
+ //function registerInstance(IRegisterable instance, address owner)
176
+ function registerInstance(IRegisterable instance)
177
+ external
178
+ returns(
179
+ IRegistry.ObjectInfo memory info,
180
+ bytes memory data
181
+ )
182
+ {
183
+ if(instance.supportsInterface(type(IInstance).interfaceId) == false) {
184
+ revert NotInstance();
185
+ }
186
+
187
+ (
188
+ info,
189
+ data
190
+ ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);// owner);
191
+
192
+ info.nftId = _registry.register(info);
193
+ instance.linkToRegisteredNftId();
194
+
195
+ return (
196
+ info,
197
+ data
198
+ );
199
+ }
200
+
201
+ function registerPolicy(IRegistry.ObjectInfo memory info)
202
+ external
203
+ returns(NftId nftId)
204
+ {
205
+ NftId senderNftId = _registry.getNftId(msg.sender);
206
+
207
+ if(_registry.allowance(senderNftId, POLICY()) == false) {
208
+ revert MissingAllowance();
209
+ }
210
+
211
+ _verifyObjectInfo(info, POLICY());
212
+
213
+ nftId = _registry.register(info);
214
+ }
215
+
216
+ function registerBundle(IRegistry.ObjectInfo memory info)
217
+ external
218
+ returns(NftId nftId)
219
+ {
220
+ NftId senderNftId = _registry.getNftId(msg.sender);
221
+
222
+ if(_registry.allowance(senderNftId, BUNDLE()) == false) {
223
+ revert MissingAllowance();
224
+ }
225
+
226
+ _verifyObjectInfo(info, BUNDLE());
227
+
228
+ nftId = _registry.register(info);
229
+ }
230
+
231
+
232
+ // From IService
233
+ function getName() public pure override(IService, ServiceBase) returns(string memory) {
234
+ return NAME;
235
+ }
236
+
237
+
238
+ // from Versionable
239
+
240
+ /// @dev top level initializer
241
+ // 1) registry is non upgradeable -> don't need a proxy and uses constructor !
242
+ // 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
243
+ // 3) deploy registry -> pass registry service address as constructor argument
244
+ // registry is getting instantiated and locked to registry service address forever
245
+ function _initialize(
246
+ address owner,
247
+ bytes memory registryByteCodeWithInitCode
248
+ )
249
+ internal
250
+ initializer
251
+ virtual override
252
+ {
253
+ bytes memory encodedConstructorArguments = abi.encode(
254
+ owner,
255
+ getMajorVersion());
256
+
257
+ bytes memory registryCreationCode = ContractDeployerLib.getCreationCode(
258
+ registryByteCodeWithInitCode,
259
+ encodedConstructorArguments);
260
+
261
+ address registryAddress = ContractDeployerLib.deploy(
262
+ registryCreationCode,
263
+ REGISTRY_CREATION_CODE_HASH);
264
+
265
+ IRegistry registry = IRegistry(registryAddress);
266
+ NftId registryNftId = registry.getNftId(registryAddress);
267
+
268
+ _initializeServiceBase(registryAddress, registryNftId, owner);
269
+ linkToRegisteredNftId();
270
+
271
+ _registerInterface(type(IRegistryService).interfaceId);
272
+ }
273
+
274
+ // parent check done in registry because of approve()
275
+ function _getAndVerifyContractInfo(
276
+ IRegisterable registerable,
277
+ ObjectType objectType,
278
+ address owner
279
+ )
280
+ internal
281
+ returns(
282
+ IRegistry.ObjectInfo memory info,
283
+ bytes memory data
284
+ )
285
+ {
286
+ (
287
+ info,
288
+ data
289
+ ) = registerable.getInitialInfo();
290
+
291
+ if(info.objectAddress != address(registerable)) {
292
+ revert InvalidAddress(info.objectAddress);
293
+ }
294
+
295
+ if(
296
+ getRegistry().isRegistered(owner) ||
297
+ info.initialOwner != owner) { // contract owner protection
298
+ revert InvalidInitialOwner(info.initialOwner);
299
+ }
300
+
301
+ if(msg.sender == address(registerable)) {
302
+ revert SelfRegistration();
303
+ }
304
+
305
+ if(info.objectType != objectType) {
306
+ revert InvalidType(info.objectType);
307
+ }
308
+
309
+ /*NftId parentNftId = info.parentNftId;
310
+ IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
311
+
312
+ if(parentInfo.objectType != parentType) { // parent registration + type
313
+ revert InvalidParent(parentNftId);
314
+ }*/
315
+
316
+ return(
317
+ info,
318
+ data
319
+ );
320
+ }
321
+
322
+ // parent checks done in registry because of approve()
323
+ function _verifyObjectInfo(
324
+ IRegistry.ObjectInfo memory info,
325
+ ObjectType objectType
326
+ )
327
+ internal
328
+ view
329
+ {
330
+ if(info.objectAddress > address(0)) {
331
+ revert InvalidAddress(info.objectAddress);
332
+ }
333
+
334
+ if(
335
+ getRegistry().isRegistered(info.initialOwner) ||
336
+ info.initialOwner == address(0)) {
337
+ // TODO non registered address can register object(e.g. POLICY()) and then transfer associated nft to registered contract
338
+ // what are motivations to do so?
339
+ // at least registered contract can not register objects by itself, SERVICE,
340
+ revert InvalidInitialOwner(info.initialOwner);
341
+ }
342
+
343
+ // can catch all 3 if check that initialOwner is not registered
344
+ /*if(info.initialOwner == msg.sender) {
345
+ revert InitialOwnerIsParent();
346
+ }
347
+
348
+ if(info.initialOwner == address(this)) {
349
+ revert InitialOwnerIsService();
350
+ }
351
+
352
+ if(info.initialOwner == address(getRegistry())) {
353
+ revert InitialOwnerIsRegistry();
354
+ }*/
355
+
356
+
357
+ if(info.objectType != objectType) {
358
+ revert InvalidType(info.objectType);
359
+ }
360
+
361
+ /*NftId parentNftId = info.parentNftId;
362
+ IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
363
+
364
+ if(parentInfo.objectType != parentType) { // parent registration + type
365
+ revert InvalidParent(parentNftId);
366
+ }*/
367
+ }
368
+ }
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Registry} from "./Registry.sol";
5
+ import {IVersionable} from "../shared/IVersionable.sol";
6
+ import {ProxyManager} from "../shared/ProxyManager.sol";
7
+ import {RegistryService} from "./RegistryService.sol";
8
+
9
+
10
+ contract RegistryServiceManager is
11
+ ProxyManager
12
+ {
13
+ RegistryService private _registryService;
14
+
15
+ /// @dev initializes proxy manager with registry service implementation and deploys registry
16
+ constructor(
17
+ )
18
+ ProxyManager()
19
+ {
20
+ IVersionable versionable = deploy(
21
+ address(new RegistryService()),
22
+ type(Registry).creationCode);
23
+
24
+ _registryService = RegistryService(address(versionable));
25
+
26
+ // link ownership of registry service manager ot nft owner of registry service
27
+ _linkToNftOwnable(
28
+ address(_registryService.getRegistry()),
29
+ address(_registryService));
30
+
31
+ // implies that after this constructor call only upgrade functionality is available
32
+ _isDeployed = true;
33
+ }
34
+
35
+ //--- view functions ----------------------------------------------------//
36
+ function getRegistryService()
37
+ external
38
+ view
39
+ returns (RegistryService registryService)
40
+ {
41
+ return _registryService;
42
+ }
43
+ }
@@ -0,0 +1,72 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ library ContractDeployerLib {
5
+
6
+ event LogContractDeployed(address contractAddress);
7
+
8
+ error ErrorCreationCodeHashMismatch(bytes32 expectedHash, bytes32 actualHash);
9
+
10
+ /// @dev deploys a new contract using the provided creation code
11
+ function deploy(
12
+ bytes memory creationCode,
13
+ bytes32 expectedCreationCodeHash
14
+ )
15
+ public
16
+ returns (address contractAdress)
17
+ {
18
+ // check against expected hash, if provided
19
+ if (expectedCreationCodeHash != bytes32(0)) {
20
+ bytes32 creationCodeHash = getHash(creationCode);
21
+ if (creationCodeHash != expectedCreationCodeHash) {
22
+ revert ErrorCreationCodeHashMismatch(expectedCreationCodeHash, creationCodeHash);
23
+ }
24
+ }
25
+
26
+ // solhint-disable no-inline-assembly
27
+ assembly {
28
+ contractAdress := create(0, add(creationCode, 0x20), mload(creationCode))
29
+
30
+ if iszero(extcodesize(contractAdress)) {
31
+ revert(0, 0)
32
+ }
33
+ }
34
+ // solhint enable
35
+
36
+ emit LogContractDeployed(contractAdress);
37
+ }
38
+
39
+ /// @dev gets the creation code for the new contract
40
+ // for terminology see eg https://www.rareskills.io/post/ethereum-contract-creation-code
41
+ function getCreationCode(
42
+ bytes memory byteCodeWithInitCode, // what you get with type(<Contract>).creationCode
43
+ bytes memory encodedConstructorArguments // what you get with
44
+ )
45
+ public
46
+ pure
47
+ returns (bytes memory creationCode)
48
+ {
49
+ return abi.encodePacked(byteCodeWithInitCode, encodedConstructorArguments);
50
+ }
51
+
52
+
53
+ function matchesWithHash(
54
+ bytes memory creationCode,
55
+ bytes32 expectedHash
56
+ )
57
+ public
58
+ pure
59
+ returns (bool isMatching)
60
+ {
61
+ return getHash(creationCode) == expectedHash;
62
+ }
63
+
64
+
65
+ function getHash(bytes memory creationCode)
66
+ public
67
+ pure
68
+ returns (bytes32 hash)
69
+ {
70
+ return keccak256(creationCode);
71
+ }
72
+ }
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
4
+ import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
5
5
 
6
6
  contract ERC165 is IERC165 {
7
7
  mapping(bytes4 => bool) private _isSupported;
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IRegistry} from "../registry/IRegistry.sol";
5
+ import {NftId} from "../types/NftId.sol";
6
+
7
+ interface INftOwnable {
8
+ error ErrorNotOwner(address account);
9
+
10
+ error ErrorAlreadyLinked(address registry, NftId nftId);
11
+ error ErrorRegistryAlreadyInitialized(address registry);
12
+ error ErrorRegistryNotInitialized();
13
+ error ErrorRegistryAddressZero();
14
+ error ErrorNotRegistry(address registryAddress);
15
+ error ErrorContractNotRegistered(address contractAddress);
16
+
17
+ function linkToRegisteredNftId() external;
18
+
19
+ function getRegistry() external view returns (IRegistry);
20
+ function getNftId() external view returns (NftId);
21
+ function getOwner() external view returns (address);
22
+ }
@@ -1,24 +1,17 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
4
+ import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
5
5
 
6
+ import {INftOwnable} from "./INftOwnable.sol";
6
7
  import {IRegistry} from "../registry/IRegistry.sol";
7
8
  import {NftId} from "../types/NftId.sol";
8
9
  import {ObjectType} from "../types/ObjectType.sol";
9
10
 
10
- import {IOwnable} from "./IOwnable.sol";
11
+ interface IRegisterable is IERC165, INftOwnable {
11
12
 
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
- }
13
+ function getInitialInfo()
14
+ external
15
+ view
16
+ returns (IRegistry.ObjectInfo memory, bytes memory data);
17
+ }
@@ -1,9 +1,34 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
- import {Blocknumber, blockNumber} from "../types/Blocknumber.sol";
5
- import {Timestamp, blockTimestamp} from "../types/Timestamp.sol";
6
- import {Version, VersionPart} from "../types/Version.sol";
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"
7
32
 
8
33
  interface IVersionable {
9
34
 
@@ -15,22 +40,35 @@ interface IVersionable {
15
40
  Blocknumber activatedIn;
16
41
  }
17
42
 
18
- event LogVersionableActivated(Version version, address implementation, address activatedBy);
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;
19
53
 
20
54
  /**
21
- * @dev IMPORTANT this function needs to be implemented by each new version
22
- * any such activate implementation needs to call internal function call _activate()
23
- * any new version needs to inherit from previous version
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
24
60
  */
25
- function activate(address implementation, address activatedBy) external;
61
+ function upgrade(address implementation, address activatedBy, bytes memory upgradeData) external;
26
62
 
27
63
  /**
28
64
  * @dev returns true if the specified version has been activated for the current contract
29
65
  */
30
- function isActivated(Version version) external view returns(bool);
66
+ function isInitialized(Version version) external view returns(bool);
31
67
 
32
68
  /**
33
- * @dev returns currently active version of this contract
69
+ * @dev returns version of this contract
70
+ * each new implementation MUST implement this function
71
+ * version number MUST increase
34
72
  */
35
73
  function getVersion() external pure returns(Version);
36
74
 
@@ -49,4 +87,10 @@ interface IVersionable {
49
87
  */
50
88
  function getVersionInfo(Version version) external view returns(VersionInfo memory versionInfo);
51
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
+
52
96
  }