@etherisc/gif-next 0.0.2-da77c50-824 → 0.0.2-de0a1d3-009

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. package/README.md +58 -11
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +405 -0
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +340 -0
  8. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +131 -0
  10. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +109 -18
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +194 -3
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +160 -21
  16. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  28. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  32. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  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 +697 -671
  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 +928 -744
  41. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  42. package/artifacts/contracts/instance/{InstanceBase.sol/InstanceBase.json → base/ComponentServiceBase.sol/ComponentServiceBase.json} +107 -33
  43. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  44. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  45. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  46. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +560 -0
  47. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  48. package/artifacts/contracts/instance/{module/lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
  49. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
  50. package/artifacts/contracts/instance/{service → base}/IService.sol/IService.json +63 -22
  51. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  52. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +463 -0
  53. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  54. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +710 -0
  55. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  56. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  57. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
  58. package/artifacts/contracts/instance/{module/product/ProductModule.sol/ProductModule.json → base/ModuleBase.sol/ModuleBase.json} +2 -2
  59. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  60. package/artifacts/contracts/instance/{service → base}/ServiceBase.sol/ServiceBase.json +93 -6
  61. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +71 -50
  66. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +71 -50
  69. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +22 -93
  71. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +22 -93
  74. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  75. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  76. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  77. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.json +10 -0
  78. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +10 -0
  80. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  82. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +61 -38
  83. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +61 -38
  85. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  87. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -5
  88. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  89. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -5
  90. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/{product/IProductModule.sol/IProductModule.json → risk/IRisk.sol/IRisk.json} +2 -2
  92. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +113 -0
  94. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +131 -0
  96. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  97. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  98. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +209 -236
  99. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  100. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  101. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  102. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +209 -236
  103. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +141 -42
  105. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  106. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +507 -0
  107. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  108. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +62 -21
  109. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  110. package/artifacts/contracts/instance/service/{ComponentServiceBase.sol/ComponentServiceBase.json → IDistributionService.sol/IDistributionService.json} +96 -30
  111. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  112. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +127 -22
  113. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  114. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +215 -21
  115. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  116. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +177 -46
  117. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  118. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +322 -62
  119. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  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/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  123. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  124. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  125. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +4 -0
  126. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +724 -0
  127. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +58 -17
  132. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.dbg.json +4 -0
  133. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.json +248 -0
  134. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +4 -0
  135. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.json +129 -0
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +92 -5
  139. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +4 -0
  140. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +228 -0
  141. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  142. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +405 -0
  143. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestFee.sol/TestFee.json +28 -4
  145. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestPool.sol/TestPool.json +194 -3
  147. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +209 -27
  149. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  151. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +38 -4
  153. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestService.sol/TestService.json +102 -43
  155. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +14 -18
  158. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +102 -39
  160. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  161. package/artifacts/contracts/test/Usdc.sol/USDC.json +338 -0
  162. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  166. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  167. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  168. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
  169. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  171. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  172. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  173. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  175. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  176. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  177. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  178. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  179. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  180. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
  181. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  183. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +34 -8
  186. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/Version.sol/VersionLib.json +101 -2
  188. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  190. package/contracts/components/BaseComponent.sol +7 -2
  191. package/contracts/components/Distribution.sol +132 -0
  192. package/contracts/components/IDistributionComponent.sol +47 -0
  193. package/contracts/components/IPoolComponent.sol +14 -0
  194. package/contracts/components/IProductComponent.sol +24 -5
  195. package/contracts/components/Pool.sol +64 -3
  196. package/contracts/components/Product.sol +123 -13
  197. package/contracts/instance/IInstance.sol +16 -13
  198. package/contracts/instance/Instance.sol +22 -10
  199. package/contracts/instance/{service → base}/ComponentServiceBase.sol +1 -0
  200. package/contracts/instance/base/IInstanceBase.sol +22 -0
  201. package/contracts/instance/base/IKeyValueStore.sol +50 -0
  202. package/contracts/instance/base/ILifecycle.sol +30 -0
  203. package/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol} +34 -17
  204. package/contracts/instance/base/KeyValueStore.sol +161 -0
  205. package/contracts/instance/{module/lifecycle/LifecycleModule.sol → base/Lifecycle.sol} +50 -39
  206. package/contracts/instance/base/ModuleBase.sol +57 -0
  207. package/contracts/instance/{service → base}/ServiceBase.sol +1 -3
  208. package/contracts/instance/module/access/Access.sol +6 -6
  209. package/contracts/instance/module/bundle/BundleModule.sol +24 -118
  210. package/contracts/instance/module/bundle/IBundle.sol +9 -9
  211. package/contracts/instance/module/component/ComponentModule.sol +27 -61
  212. package/contracts/instance/module/component/IComponent.sol +5 -30
  213. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  214. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  215. package/contracts/instance/module/policy/IPolicy.sol +12 -9
  216. package/contracts/instance/module/policy/PolicyModule.sol +33 -26
  217. package/contracts/instance/module/pool/IPoolModule.sol +0 -1
  218. package/contracts/instance/module/pool/PoolModule.sol +12 -9
  219. package/contracts/instance/module/risk/IRisk.sol +26 -0
  220. package/contracts/instance/module/risk/RiskModule.sol +62 -0
  221. package/contracts/instance/module/treasury/ITreasury.sol +30 -52
  222. package/contracts/instance/module/treasury/TreasuryModule.sol +74 -84
  223. package/contracts/instance/service/ComponentOwnerService.sol +33 -50
  224. package/contracts/instance/service/DistributionService.sol +59 -0
  225. package/contracts/instance/service/IComponentOwnerService.sol +1 -1
  226. package/contracts/instance/service/IDistributionService.sol +12 -0
  227. package/contracts/instance/service/IPoolService.sol +8 -1
  228. package/contracts/instance/service/IProductService.sol +56 -7
  229. package/contracts/instance/service/PoolService.sol +64 -13
  230. package/contracts/instance/service/ProductService.sol +234 -83
  231. package/contracts/registry/Registry.sol +4 -4
  232. package/contracts/registry/RegistryUpgradeable.sol +473 -0
  233. package/contracts/shared/IVersionable.sol +19 -6
  234. package/contracts/shared/Proxy.sol +94 -0
  235. package/contracts/shared/Versionable.sol +16 -9
  236. package/contracts/shared/VersionableUpgradeable.sol +133 -0
  237. package/contracts/test/TestDistribution.sol +21 -0
  238. package/contracts/test/TestFee.sol +3 -3
  239. package/contracts/test/TestPool.sol +6 -3
  240. package/contracts/test/TestProduct.sol +36 -8
  241. package/contracts/test/TestRoleId.sol +2 -2
  242. package/contracts/test/TestService.sol +3 -6
  243. package/contracts/test/TestVersion.sol +4 -7
  244. package/contracts/test/TestVersionable.sol +2 -5
  245. package/contracts/test/Usdc.sol +26 -0
  246. package/contracts/types/Fee.sol +44 -20
  247. package/contracts/types/Key32.sol +45 -0
  248. package/contracts/types/NftId.sol +16 -1
  249. package/contracts/types/ObjectType.sol +24 -8
  250. package/contracts/types/ReferralId.sol +48 -0
  251. package/contracts/types/RiskId.sol +43 -0
  252. package/contracts/types/RoleId.sol +12 -10
  253. package/contracts/types/StateId.sol +7 -1
  254. package/contracts/types/UFixed.sol +19 -16
  255. package/contracts/types/Version.sol +37 -25
  256. package/package.json +1 -1
  257. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +0 -4
  258. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.json +0 -50
  259. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  260. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
  261. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
  262. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
  263. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
  264. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
  265. package/artifacts/contracts/instance/module/product/IProductModule.sol/IProductModule.dbg.json +0 -4
  266. package/artifacts/contracts/instance/module/product/ProductModule.sol/ProductModule.dbg.json +0 -4
  267. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  268. package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +0 -4
  269. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  270. package/contracts/instance/IServiceLinked.sol +0 -12
  271. package/contracts/instance/module/lifecycle/ILifecycle.sol +0 -47
  272. package/contracts/instance/module/product/IProductModule.sol +0 -6
  273. package/contracts/instance/module/product/ProductModule.sol +0 -8
  274. /package/contracts/instance/{service → base}/IService.sol +0 -0
@@ -0,0 +1,473 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Initializable} from "@openzeppelin5/contracts/proxy/utils/Initializable.sol";
5
+
6
+ import {IRegisterable} from "../shared/IRegisterable.sol";
7
+ import {IService} from "../instance/base/IService.sol";
8
+
9
+ import {IChainNft} from "./IChainNft.sol";
10
+ import {ChainNft} from "./ChainNft.sol";
11
+ import {IRegistry} from "./IRegistry.sol";
12
+ import {NftId, toNftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
13
+ import {Version, VersionPart, VersionLib} from "../types/Version.sol";
14
+ import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, DISTRIBUTION, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
15
+
16
+ import {VersionableUpgradeable} from "../shared/VersionableUpgradeable.sol";
17
+
18
+
19
+ /// IMPORTANT
20
+ // Upgradeable contract MUST:
21
+ // 1) inherit from Versionable
22
+ // 2) implement version() function
23
+ // 3) implement internal _initialize() function with onlyInitializing modifier
24
+ // 4) implement internal _upgrade() function with onlyInitializing modifier (1st version MUST revert)
25
+ // 5) have onlyInitialising modifier for each function callable during deployment and/or upgrade
26
+ // 6) use default empty constructor -> _disableInitializer() called from Versionable contructor
27
+ // 7) use namespace storage
28
+ //
29
+ // IMPORTANT
30
+ // Each version MUST:
31
+ // 1) define its own namespace storage struct ONLY if changes were introduced to storage (MUST NOT use struct type inside)
32
+ // 2) ALWAYS define private getter even if no changes were introduced to storage struct (MUST use default implementation, change ONLY return type)
33
+ // 3) use the same "locationV1" var in each getter
34
+ // Optional:
35
+ // 4) implement public initialize() with intializer modifier
36
+ // 5) implement public upgrade() with reinitializer(VersionLib.toUint64(getVersion())) (1st version MUST revert)
37
+
38
+
39
+ contract RegistryUpgradeable is
40
+ VersionableUpgradeable,
41
+ IRegisterable,
42
+ IRegistry
43
+ {
44
+ using NftIdLib for NftId;
45
+
46
+ string public constant EMPTY_URI = "";
47
+
48
+ // IMPORTANT Every new version with storage changes must implement its own struct
49
+ // copy paste previous version and add changes
50
+ // @custom:storage-location erc7201:gif-next.contracts.registry.Registry.sol
51
+ struct StorageV1 {
52
+
53
+ mapping(NftId nftId => ObjectInfo info) _info;
54
+ mapping(address object => NftId nftId) _nftIdByAddress;
55
+ mapping(ObjectType objectType => bool) _isValidType;
56
+ mapping(ObjectType objectType => mapping(ObjectType objectParentType => bool)) _isValidParentType;
57
+
58
+ mapping(NftId nftId => string stringValue) _string;
59
+ mapping(bytes32 serviceNameHash => mapping(VersionPart majorVersion => address service)) _service;
60
+
61
+ NftId _nftId;
62
+ IChainNft _chainNft;
63
+ ChainNft _chainNftInternal;
64
+ address _initialOwner;
65
+
66
+ /// @dev will own protocol nft and registry nft(s) minted during initialize
67
+ address _protocolOwner;
68
+ }
69
+
70
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.registry.Registry.sol")) - 1)) & ~bytes32(uint256(0xff));
71
+ bytes32 public constant locationV1 = 0x6548007c3f4340f82f348c576c0ff69f4f529cadd5ad41f96aae61abceeaa300;
72
+
73
+ // IMPORTANT Every new version must implement this function
74
+ // keep it private -> if unreachable from the next version then not included in its byte code
75
+ // each version MUST use the same locationV1, just change return type
76
+ function _getStorage() private pure returns (StorageV1 storage $) {
77
+ assembly {
78
+ $.slot := locationV1
79
+ }
80
+ }
81
+
82
+ /// @dev the protocol owner will get ownership of the
83
+ // protocol nft and the global registry nft minted in this
84
+ // initializer function
85
+ function _initialize(bytes memory data)
86
+ internal
87
+ virtual override
88
+ onlyInitializing
89
+ {
90
+ address protocolOwner = abi.decode(data, (address));
91
+ StorageV1 storage $ = _getStorage();
92
+
93
+ $._initialOwner = msg.sender; // TODO here delegate call from proxy constructor, msg.sender is proxy deployer -> Proxy.sol
94
+ $._protocolOwner = protocolOwner;
95
+
96
+ // deploy NFT
97
+ $._chainNftInternal = new ChainNft(address(this));// adds 10kb to deployment size
98
+ $._chainNft = IChainNft($._chainNftInternal);
99
+
100
+ // initial registry setup
101
+ _registerProtocol();
102
+ $._nftId = _registerRegistry();
103
+
104
+ // setup rules for further registrations
105
+ _setupValidTypes();
106
+ _setupValidParentTypes();
107
+ }
108
+
109
+ function register(
110
+ address objectAddress
111
+ )
112
+ // TODO add authz (only services may register components etc)
113
+ // we have to check how we do authz for registring services (just restrict to protocol owner/registry owner)
114
+ external override returns (NftId nftId) {
115
+ StorageV1 storage $ = _getStorage();
116
+
117
+ require(
118
+ $._nftIdByAddress[objectAddress].eqz(),
119
+ "ERROR:REG-002:ALREADY_REGISTERED"
120
+ );
121
+
122
+ IRegisterable registerable = IRegisterable(objectAddress);
123
+ require(
124
+ registerable.supportsInterface(type(IRegisterable).interfaceId),
125
+ "ERROR:REG-003:NOT_REGISTERABLE"
126
+ );
127
+
128
+ ObjectType objectType = registerable.getType();
129
+ require(
130
+ $._isValidType[objectType],
131
+ "ERROR:REG-004:TYPE_INVALID"
132
+ );
133
+
134
+ NftId parentNftId = registerable.getParentNftId();
135
+ require(
136
+ isRegistered(parentNftId),
137
+ "ERROR:REG-005:PARENT_NOT_REGISTERED"
138
+ );
139
+
140
+ require(
141
+ $._isValidParentType[objectType][$._info[parentNftId].objectType],
142
+ "ERROR:REG-006:PARENT_TYPE_INVALID"
143
+ );
144
+
145
+ // also check that nftId and parentNFtId are on the same chain if applicable
146
+
147
+ // nft minting
148
+ uint256 mintedTokenId = $._chainNft.mint(
149
+ registerable.getOwner(),
150
+ EMPTY_URI
151
+ );
152
+
153
+ nftId = toNftId(mintedTokenId);
154
+
155
+ // special case services
156
+ if(registerable.getType() == SERVICE()) {
157
+ IService service = IService(objectAddress);
158
+ require(
159
+ service.supportsInterface(type(IService).interfaceId),
160
+ "ERROR:REG-007:NOT_SERVICE"
161
+ );
162
+
163
+ string memory serviceName = service.getName();
164
+ VersionPart majorVersion = service.getMajorVersion();
165
+ bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
166
+
167
+ // service specific state
168
+ $._string[nftId] = serviceName;
169
+
170
+ require(
171
+ $._service[serviceNameHash][majorVersion] == address(0),
172
+ "ERROR:REG-008:ALREADY_REGISTERED"
173
+ );
174
+ $._service[serviceNameHash][majorVersion] = objectAddress;
175
+ }
176
+
177
+ // create object info and link nft id with it
178
+ _registerObjectInfo(registerable, nftId);
179
+ }
180
+
181
+
182
+ function registerObjectForInstance(
183
+ NftId parentNftId,
184
+ ObjectType objectType,
185
+ address initialOwner,
186
+ bytes memory data
187
+ )
188
+ external
189
+ override
190
+ returns (
191
+ // TODO add onlyRegisteredInstance
192
+ NftId nftId
193
+ )
194
+ {
195
+ StorageV1 storage $ = _getStorage();
196
+
197
+ // TODO add more validation
198
+ require(
199
+ objectType == POLICY() || objectType == BUNDLE(),
200
+ "ERROR:REG-010:TYPE_INVALID"
201
+ );
202
+
203
+ uint256 mintedTokenId = $._chainNft.mint(initialOwner, EMPTY_URI);
204
+ nftId = toNftId(mintedTokenId);
205
+
206
+ ObjectInfo memory info = ObjectInfo(
207
+ nftId,
208
+ parentNftId,
209
+ objectType,
210
+ address(0),
211
+ initialOwner,
212
+ data
213
+ );
214
+
215
+ $._info[nftId] = info;
216
+
217
+ // add logging
218
+ }
219
+
220
+ function getObjectCount() external view override returns (uint256) {
221
+ return _getStorage()._chainNft.totalSupply();
222
+ }
223
+
224
+ function getNftId(
225
+ address object
226
+ ) external view override returns (NftId id) {
227
+ return _getStorage()._nftIdByAddress[object];
228
+ }
229
+
230
+ function isRegistered(
231
+ NftId nftId
232
+ ) public view override returns (bool) {
233
+ return _getStorage()._info[nftId].objectType.gtz();
234
+ }
235
+
236
+ function isRegistered(
237
+ address object
238
+ ) external view override returns (bool) {
239
+ return _getStorage()._nftIdByAddress[object].gtz();
240
+ }
241
+
242
+ function getObjectInfo(
243
+ NftId nftId
244
+ ) external view override returns (ObjectInfo memory info) {
245
+ return _getStorage()._info[nftId];
246
+ }
247
+
248
+ function getName(
249
+ NftId nftId
250
+ ) external view returns (string memory name) {
251
+ return _getStorage()._string[nftId];
252
+ }
253
+
254
+ function getOwner(NftId nftId) external view override returns (address) {
255
+ return _getStorage()._chainNft.ownerOf(nftId.toInt());
256
+ }
257
+
258
+ function getChainNft() external view override returns (IChainNft) {
259
+ return _getStorage()._chainNft;
260
+ }
261
+
262
+ // special case to retrive a gif service
263
+ function getServiceAddress(string memory serviceName, VersionPart majorVersion) external view override returns (address serviceAddress) {
264
+ bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
265
+ return _getStorage()._service[serviceNameHash][majorVersion];
266
+ }
267
+
268
+ // from IERC165
269
+ function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
270
+ return interfaceId == type(IRegistry).interfaceId;
271
+ }
272
+
273
+ // from IRegistryLinked
274
+ function getRegistry() external view override returns (IRegistry registry) {
275
+ return this;
276
+ }
277
+
278
+ // from IVersionable
279
+ function getVersion() public pure virtual override returns (Version) {
280
+ return VersionLib.toVersion(1, 0, 0);
281
+ }
282
+
283
+ // from IRegisterable
284
+ // TODO
285
+ // 1) Registerable can not register itself -> otherwise register have to trust owner address provided by registerable
286
+ // registerable owner MUST call register and provide registerable address
287
+ // 2) Who is msg.sender here???
288
+ function register() external pure override returns (NftId nftId) {
289
+ return zeroNftId();
290
+ }
291
+
292
+ function getType() external pure override returns (ObjectType objectType) {
293
+ return REGISTRY();
294
+ }
295
+
296
+ function getOwner() public view override returns (address owner) {
297
+ StorageV1 storage $ = _getStorage();
298
+ return $._nftId.gtz() ? this.getOwner($._nftId) : $._initialOwner;
299
+ }
300
+
301
+ function getNftId() public view override (IRegisterable, IRegistry) returns (NftId nftId) {
302
+ return _getStorage()._nftId;
303
+ }
304
+
305
+ function getParentNftId() public view returns (NftId nftId) {
306
+ StorageV1 storage $ = _getStorage();
307
+ nftId = $._info[$._nftId].parentNftId;
308
+ }
309
+
310
+ function getData() public pure returns (bytes memory data) {
311
+ return "";
312
+ }
313
+
314
+ // registry specific functions
315
+ function getProtocolOwner() external view override returns (address) {
316
+ return _getStorage()._protocolOwner;
317
+ }
318
+
319
+ /// @dev defines which types are allowed to register
320
+ function _setupValidTypes() internal onlyInitializing {
321
+ StorageV1 storage $ = _getStorage();
322
+ $._isValidType[REGISTRY()] = true; // only for global registry
323
+ $._isValidType[TOKEN()] = true;
324
+ $._isValidType[SERVICE()] = true;
325
+ $._isValidType[INSTANCE()] = true;
326
+ $._isValidType[STAKE()] = true;
327
+ $._isValidType[PRODUCT()] = true;
328
+ $._isValidType[ORACLE()] = true;
329
+ $._isValidType[POOL()] = true;
330
+ $._isValidType[DISTRIBUTION()] = true;
331
+ $._isValidType[POLICY()] = true;
332
+ $._isValidType[BUNDLE()] = true;
333
+ }
334
+
335
+ /// @dev defines which types - parent type relations are allowed to register
336
+ function _setupValidParentTypes() internal onlyInitializing {
337
+ StorageV1 storage $ = _getStorage();
338
+ // registry as parent
339
+ $._isValidParentType[TOKEN()][REGISTRY()] = true;
340
+ $._isValidParentType[SERVICE()][REGISTRY()] = true;
341
+ $._isValidParentType[INSTANCE()][REGISTRY()] = true;
342
+
343
+ // instance as parent
344
+ $._isValidParentType[PRODUCT()][INSTANCE()] = true;
345
+ $._isValidParentType[DISTRIBUTION()][INSTANCE()] = true;
346
+ $._isValidParentType[ORACLE()][INSTANCE()] = true;
347
+ $._isValidParentType[POOL()][INSTANCE()] = true;
348
+
349
+ // product as parent
350
+ $._isValidParentType[POLICY()][PRODUCT()] = true;
351
+
352
+ // pool as parent
353
+ $._isValidParentType[BUNDLE()][POOL()] = true;
354
+ $._isValidParentType[STAKE()][POOL()] = true;
355
+ }
356
+
357
+ /// @dev protocol registration used to anchor the dip ecosystem relations
358
+ function _registerProtocol()
359
+ virtual
360
+ internal
361
+ onlyInitializing
362
+ {
363
+ StorageV1 storage $ = _getStorage();
364
+
365
+ uint256 protocolId = $._chainNftInternal.PROTOCOL_NFT_ID();
366
+ $._chainNftInternal.mint($._protocolOwner, protocolId);
367
+
368
+ NftId protocolNftid = toNftId(protocolId);
369
+ ObjectInfo memory protocolInfo = ObjectInfo(
370
+ protocolNftid,
371
+ zeroNftId(), // parent nft id
372
+ PROTOCOL(),
373
+ address(0), // contract address
374
+ $._protocolOwner,
375
+ "" // data
376
+ );
377
+
378
+ $._info[protocolNftid] = protocolInfo;
379
+ }
380
+
381
+ /// @dev registry registration
382
+ /// might also register the global registry when not on mainnet
383
+ function _registerRegistry()
384
+ virtual
385
+ internal
386
+ onlyInitializing
387
+ returns (NftId registryNftId)
388
+ {
389
+ StorageV1 storage $ = _getStorage();
390
+
391
+ uint256 registryId = $._chainNftInternal.calculateTokenId(2);
392
+ registryNftId = toNftId(registryId);
393
+
394
+ // we're not the global registry
395
+ if(registryId != $._chainNftInternal.GLOBAL_REGISTRY_ID()) {
396
+ _registerGlobalRegistry();
397
+ }
398
+
399
+ $._chainNftInternal.mint($._protocolOwner, registryId);
400
+
401
+ NftId parentNftId;
402
+ // we're the global registry
403
+ if(block.chainid == 1) {
404
+ parentNftId = toNftId($._chainNftInternal.PROTOCOL_NFT_ID());
405
+ }
406
+ else {
407
+ parentNftId = toNftId($._chainNftInternal.GLOBAL_REGISTRY_ID());
408
+ }
409
+ ObjectInfo memory registryInfo = ObjectInfo(
410
+ registryNftId,
411
+ parentNftId,
412
+ REGISTRY(),
413
+ address(this), // proxy address
414
+ $._protocolOwner, // registry owner is different from proxy owner
415
+ ""
416
+ );
417
+
418
+ $._info[registryNftId] = registryInfo;
419
+ $._nftIdByAddress[address(this)] = registryNftId;
420
+
421
+ // add logging
422
+ }
423
+
424
+
425
+ /// @dev global registry registration for non mainnet registries
426
+ function _registerGlobalRegistry()
427
+ virtual
428
+ internal
429
+ onlyInitializing
430
+ {
431
+ StorageV1 storage $ = _getStorage();
432
+
433
+ uint256 globalRegistryId = $._chainNftInternal.GLOBAL_REGISTRY_ID();
434
+ $._chainNftInternal.mint($._protocolOwner, globalRegistryId);
435
+
436
+ NftId globalRegistryNftId = toNftId(globalRegistryId);
437
+ ObjectInfo memory globalRegistryInfo = ObjectInfo(
438
+ globalRegistryNftId,
439
+ toNftId($._chainNftInternal.PROTOCOL_NFT_ID()),
440
+ REGISTRY(),
441
+ address(0), // contract address
442
+ $._protocolOwner,
443
+ "" // data
444
+ );
445
+
446
+ $._info[globalRegistryNftId] = globalRegistryInfo;
447
+ }
448
+
449
+ function _registerObjectInfo(
450
+ IRegisterable registerable,
451
+ NftId nftId
452
+ )
453
+ internal
454
+ virtual
455
+ {
456
+ address objectAddress = address(registerable);
457
+ ObjectInfo memory info = ObjectInfo(
458
+ nftId,
459
+ registerable.getParentNftId(),
460
+ registerable.getType(),
461
+ objectAddress,
462
+ registerable.getOwner(),
463
+ registerable.getData()
464
+ );
465
+
466
+ StorageV1 storage $ = _getStorage();
467
+ $._info[nftId] = info;
468
+ $._nftIdByAddress[objectAddress] = nftId;
469
+
470
+ // add logging
471
+ }
472
+
473
+ }
@@ -3,7 +3,7 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {Blocknumber, blockNumber} from "../types/Blocknumber.sol";
5
5
  import {Timestamp, blockTimestamp} from "../types/Timestamp.sol";
6
- import {Version, VersionPart, zeroVersion} from "../types/Version.sol";
6
+ import {Version, VersionPart} from "../types/Version.sol";
7
7
 
8
8
  interface IVersionable {
9
9
 
@@ -11,18 +11,29 @@ interface IVersionable {
11
11
  Version version;
12
12
  address implementation;
13
13
  address activatedBy;
14
- Blocknumber activatedIn;
15
14
  Timestamp activatedAt;
15
+ Blocknumber activatedIn;
16
16
  }
17
17
 
18
18
  event LogVersionableActivated(Version version, address implementation, address activatedBy);
19
19
 
20
+ // TODO uncomment when all implementations are ready
21
+ /**
22
+ * @dev IMPORTANT
23
+ * implementation MUST be guarded by initializer modifier
24
+ * implementation MUST call internal function _activate()
25
+ * new version MUST inherit from previous version
26
+ */
27
+ function initialize(address implementation, address activatedBy, bytes memory activationData) external;
28
+
20
29
  /**
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
30
+ * @dev
31
+ * implementation MUST be guarded by reinitializer(version().toUint64()) modifier
32
+ * implementation MUST call internal function _activate()
33
+ * new version MUST inherit from previous version
34
+ * the first verion MUST revert
24
35
  */
25
- function activate(address implementation, address activatedBy) external;
36
+ function upgrade(address implementation, address activatedBy, bytes memory upgradeData) external;
26
37
 
27
38
  /**
28
39
  * @dev returns true if the specified version has been activated for the current contract
@@ -49,4 +60,6 @@ interface IVersionable {
49
60
  */
50
61
  function getVersionInfo(Version version) external view returns(VersionInfo memory versionInfo);
51
62
 
63
+ function getInitializedVersion() external view returns(uint64);
64
+
52
65
  }
@@ -0,0 +1,94 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Ownable} from "@openzeppelin5/contracts/access/Ownable.sol";
5
+ import {ProxyAdmin} from "@openzeppelin5/contracts/proxy/transparent/ProxyAdmin.sol";
6
+ import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "@openzeppelin5/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
7
+
8
+ import {IVersionable} from "./IVersionable.sol";
9
+
10
+ contract ProxyWithProxyAdminGetter is TransparentUpgradeableProxy {
11
+
12
+ constructor(address implementation, address initialProxyAdminOwner, bytes memory data)
13
+ TransparentUpgradeableProxy(implementation, initialProxyAdminOwner, data)
14
+ {}
15
+
16
+ function getProxyAdmin() external returns (ProxyAdmin) { return ProxyAdmin(_proxyAdmin()); }
17
+ }
18
+
19
+ // renamed because of name collision with OZ Proxy -> local proxy type was missing in typechain-types
20
+ contract ProxyDeployer is Ownable {
21
+
22
+ event ProxyDeployed(address indexed proxy);
23
+
24
+ // TODO use contract functions selectors ???
25
+ string public constant INITIALIZE_SIGNATURE = "initialize(address,address,bytes)";
26
+ string public constant UPGRADE_SIGNATURE = "upgrade(address,address,bytes)";
27
+
28
+ ProxyWithProxyAdminGetter private _proxy;
29
+ bool private _isDeployed;
30
+
31
+ /// @dev only used to capture proxy owner
32
+ constructor()
33
+ Ownable(msg.sender)
34
+ {
35
+ }
36
+
37
+ function getDeployData(address implementation, address proxyOwner, bytes memory deployData) public pure returns (bytes memory data) {
38
+ return abi.encodeWithSignature(INITIALIZE_SIGNATURE, implementation, proxyOwner, deployData);
39
+ }
40
+
41
+ function getUpgradeData(address implementation, address proxyOwner, bytes memory upgradeData) public pure returns (bytes memory data) {
42
+ return abi.encodeWithSignature(UPGRADE_SIGNATURE, implementation, proxyOwner, upgradeData);
43
+ }
44
+
45
+ /// @dev deploy initial contract
46
+ function deploy(address initialImplementation, bytes memory deployData)
47
+ external
48
+ onlyOwner()
49
+ returns (IVersionable versionable)
50
+ {
51
+ require(!_isDeployed, "ERROR:PRX-010:ALREADY_DEPLOYED");
52
+
53
+ address currentProxyOwner = owner();
54
+ address initialProxyAdminOwner = address(this);
55
+ bytes memory data = getDeployData(initialImplementation, currentProxyOwner, deployData);
56
+
57
+ _proxy = new ProxyWithProxyAdminGetter(
58
+ initialImplementation,
59
+ initialProxyAdminOwner,
60
+ data
61
+ );
62
+
63
+ _isDeployed = true;
64
+ versionable = IVersionable(address(_proxy));
65
+
66
+ emit ProxyDeployed(address(_proxy));
67
+ }
68
+
69
+ /// @dev upgrade existing contract
70
+ function upgrade(address newImplementation, bytes memory upgradeData)
71
+ external
72
+ onlyOwner
73
+ returns (IVersionable versionable)
74
+ {
75
+ require(_isDeployed, "ERROR:PRX-020:NOT_YET_DEPLOYED");
76
+
77
+ address currentProxyOwner = owner();
78
+ // ProxyAdmin proxyAdmin = _proxy.getProxyAdmin();
79
+ ProxyAdmin proxyAdmin = getProxyAdmin();
80
+ ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(_proxy));
81
+ bytes memory data = getUpgradeData(newImplementation, currentProxyOwner, upgradeData);
82
+
83
+ proxyAdmin.upgradeAndCall(
84
+ proxy,
85
+ newImplementation,
86
+ data);
87
+
88
+ versionable = IVersionable(address(_proxy));
89
+ }
90
+
91
+ function getProxyAdmin() public returns (ProxyAdmin) {
92
+ return _proxy.getProxyAdmin();
93
+ }
94
+ }
@@ -1,14 +1,15 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {Initializable} from "@openzeppelin5/contracts/proxy/utils/Initializable.sol";
5
+
4
6
  import {Blocknumber, blockNumber} from "../types/Blocknumber.sol";
5
7
  import {Timestamp, blockTimestamp} from "../types/Timestamp.sol";
6
- import {Version, VersionPart, zeroVersion} from "../types/Version.sol";
8
+ import {Version, VersionPart} from "../types/Version.sol";
7
9
 
8
10
  import {IVersionable} from "./IVersionable.sol";
9
11
 
10
- abstract contract Versionable is IVersionable {
11
-
12
+ abstract contract Versionable is Initializable, IVersionable {
12
13
 
13
14
  mapping(Version version => VersionInfo info) private _versionHistory;
14
15
  Version [] private _versions;
@@ -21,12 +22,15 @@ abstract contract Versionable is IVersionable {
21
22
 
22
23
  // IMPORTANT this function needs to be implemented by each new version
23
24
  // and needs to call internal function call _activate()
24
- function activate(address implementation, address activatedBy)
25
+ function initialize(address implementation, address activatedBy, bytes memory initializationData)
25
26
  external
26
- override
27
+ virtual
27
28
  {
28
29
  _activate(implementation, activatedBy);
29
30
  }
31
+ // TODO mock, delete when implementations are ready
32
+ function activate(address implementation, address activatedBy, bytes memory activatinData) public {}
33
+ function upgrade(address implementation, address activatedBy, bytes memory upgradeData) external {}
30
34
 
31
35
 
32
36
  // can only be called once per contract
@@ -58,8 +62,8 @@ abstract contract Versionable is IVersionable {
58
62
  thisVersion,
59
63
  implementation,
60
64
  activatedBy,
61
- blockNumber(),
62
- blockTimestamp()
65
+ blockTimestamp(),
66
+ blockNumber()
63
67
  );
64
68
 
65
69
  emit LogVersionableActivated(thisVersion, implementation, activatedBy);
@@ -80,13 +84,16 @@ abstract contract Versionable is IVersionable {
80
84
 
81
85
 
82
86
  function getVersion(uint256 idx) external view override returns(Version) {
83
- require(idx < _versions.length, "ERROR:VRN-010:INDEX_TOO_LARGE");
84
87
  return _versions[idx];
85
88
  }
86
89
 
87
90
 
88
91
  function getVersionInfo(Version _version) external override view returns(VersionInfo memory) {
89
- require(isActivated(_version), "ERROR:VRN-020:VERSION_UNKNOWN");
90
92
  return _versionHistory[_version];
91
93
  }
94
+
95
+ function getInitializedVersion() external view returns(uint64)
96
+ {
97
+ return _getInitializedVersion();
98
+ }
92
99
  }