@etherisc/gif-next 0.0.2-de0a1d3-009 → 0.0.2-e37834a-021

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. package/README.md +40 -25
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +80 -41
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +101 -61
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +43 -40
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -163
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +6 -185
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -163
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +150 -126
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +110 -52
  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/ISM.sol/ISM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  35. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  36. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +198 -74
  37. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  38. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.json +285 -178
  40. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +59 -53
  42. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +1 -1
  44. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/IService.sol/IService.json +45 -42
  48. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +62 -69
  50. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  53. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +55 -62
  55. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +2 -2
  66. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +29 -9
  74. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +28 -8
  76. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +2 -2
  80. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  82. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +138 -11
  83. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  85. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +138 -11
  87. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +165 -93
  89. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +87 -68
  91. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +45 -61
  93. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +45 -42
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +45 -42
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +45 -42
  99. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +89 -70
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +117 -98
  103. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  104. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +141 -12
  105. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  106. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +5 -0
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +293 -40
  109. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  110. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +668 -0
  111. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  112. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  113. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/Registry.sol/Registry.json +483 -120
  115. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  116. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +885 -0
  117. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  118. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +460 -0
  119. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  120. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  121. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  122. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  123. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  124. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +43 -40
  126. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -2
  128. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  129. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +132 -0
  130. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  131. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +344 -0
  132. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  133. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +76 -37
  134. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  135. package/artifacts/contracts/shared/{Proxy.sol/ProxyWithProxyAdminGetter.json → UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json} +4 -4
  136. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +4 -27
  138. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +1 -1
  139. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +101 -61
  140. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestPool.sol/TestPool.json +150 -126
  143. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +115 -58
  145. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +93 -39
  147. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestService.sol/TestService.json +81 -75
  150. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  153. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +15 -38
  155. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  156. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  157. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  161. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  172. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  174. package/contracts/components/BaseComponent.sol +12 -27
  175. package/contracts/components/Distribution.sol +29 -6
  176. package/contracts/components/IBaseComponent.sol +2 -2
  177. package/contracts/components/IDistributionComponent.sol +1 -2
  178. package/contracts/components/IPoolComponent.sol +3 -10
  179. package/contracts/components/IProductComponent.sol +2 -3
  180. package/contracts/components/Pool.sol +84 -73
  181. package/contracts/components/Product.sol +85 -13
  182. package/contracts/instance/IInstance.sol +4 -3
  183. package/contracts/instance/Instance.sol +14 -3
  184. package/contracts/instance/base/ComponentServiceBase.sol +13 -6
  185. package/contracts/instance/base/IInstanceBase.sol +3 -2
  186. package/contracts/instance/base/InstanceBase.sol +6 -8
  187. package/contracts/instance/base/ServiceBase.sol +19 -13
  188. package/contracts/instance/module/component/ComponentModule.sol +5 -4
  189. package/contracts/instance/module/component/IComponent.sol +2 -2
  190. package/contracts/instance/module/pool/IPoolModule.sol +4 -3
  191. package/contracts/instance/module/pool/PoolModule.sol +12 -7
  192. package/contracts/instance/module/treasury/ITreasury.sol +7 -5
  193. package/contracts/instance/module/treasury/TokenHandler.sol +2 -2
  194. package/contracts/instance/module/treasury/TreasuryModule.sol +21 -28
  195. package/contracts/instance/service/ComponentOwnerService.sol +181 -66
  196. package/contracts/instance/service/DistributionService.sol +6 -11
  197. package/contracts/instance/service/IComponentOwnerService.sol +0 -2
  198. package/contracts/instance/service/PoolService.sol +19 -19
  199. package/contracts/instance/service/ProductService.sol +25 -24
  200. package/contracts/registry/ChainNft.sol +43 -15
  201. package/contracts/registry/IChainNft.sol +3 -2
  202. package/contracts/registry/IRegistry.sol +44 -28
  203. package/contracts/registry/IRegistryService.sol +29 -0
  204. package/contracts/registry/ITransferInterceptor.sol +6 -0
  205. package/contracts/registry/Registry.sol +382 -273
  206. package/contracts/registry/RegistryService.sol +375 -0
  207. package/contracts/registry/RegistryServiceManager.sol +52 -0
  208. package/contracts/shared/ContractDeployerLib.sol +72 -0
  209. package/contracts/shared/ERC165.sol +1 -1
  210. package/contracts/shared/IRegisterable.sol +7 -9
  211. package/contracts/shared/IVersionable.sol +40 -9
  212. package/contracts/shared/NftOwnable.sol +87 -0
  213. package/contracts/shared/ProxyManager.sol +103 -0
  214. package/contracts/shared/Registerable.sol +74 -43
  215. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  216. package/contracts/shared/Versionable.sol +108 -60
  217. package/contracts/test/TestDistribution.sol +3 -2
  218. package/contracts/test/TestPool.sol +4 -2
  219. package/contracts/test/TestProduct.sol +4 -2
  220. package/contracts/test/TestRegisterable.sol +5 -6
  221. package/contracts/test/TestService.sol +5 -11
  222. package/contracts/types/Version.sol +1 -0
  223. package/package.json +1 -1
  224. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
  225. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
  226. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +0 -4
  227. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +0 -724
  228. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.dbg.json +0 -4
  229. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.json +0 -248
  230. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +0 -4
  231. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +0 -4
  232. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +0 -228
  233. package/contracts/experiment/statemachine/README.md +0 -112
  234. package/contracts/registry/IRegistryLinked.sol +0 -8
  235. package/contracts/registry/RegistryUpgradeable.sol +0 -473
  236. package/contracts/shared/Proxy.sol +0 -94
  237. package/contracts/shared/VersionableUpgradeable.sol +0 -133
@@ -1,473 +0,0 @@
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
- }
@@ -1,94 +0,0 @@
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,133 +0,0 @@
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 {Blocknumber, blockNumber} from "../types/Blocknumber.sol";
7
- import {Timestamp, blockTimestamp} from "../types/Timestamp.sol";
8
- import {Version, VersionPart, VersionLib} from "../types/Version.sol";
9
-
10
- import {IVersionable} from "./IVersionable.sol";
11
-
12
- abstract contract VersionableUpgradeable is
13
- Initializable,
14
- IVersionable
15
- {
16
- /// @custom:storage-location erc7201:gif-next.contracts.shared.Versionable.sol
17
- struct VersionableStorage {
18
- mapping(Version version => VersionInfo info) _versionHistory;
19
- Version [] _versions;
20
- Version _v1;
21
- }
22
-
23
- // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Versionable.sol")) - 1)) & ~bytes32(uint256(0xff))
24
- bytes32 private constant VersionableStorageLocation = 0x4f61291a8ac3d020d0a7d919a76b8592aa88385744dee3f8b4f3873b969ed900;
25
-
26
- function _getVersionableStorage() private pure returns (VersionableStorage storage $) {
27
- assembly {
28
- $.slot := VersionableStorageLocation
29
- }
30
- }
31
-
32
- constructor() {
33
- _disableInitializers();
34
- }
35
-
36
- function initialize(
37
- address implementation,
38
- address activatedBy, // TODO can it be a msg.sender ?
39
- bytes memory data
40
- )
41
- public
42
- virtual
43
- initializer
44
- {
45
- _activate(implementation, activatedBy);
46
- _initialize(data);
47
- }
48
- function upgrade(
49
- address implementation,
50
- address activatedBy,
51
- bytes memory data
52
- )
53
- external
54
- virtual
55
- reinitializer(VersionLib.toUint64(getVersion()))
56
- {
57
- _activate(implementation, activatedBy);
58
- _upgrade(data);
59
- }
60
- // IMPORTANT each version must implement this function
61
- // each implementation MUST use onlyInitialising modifier
62
- function _initialize(bytes memory data) virtual internal;
63
-
64
- // IMPORTANT each version except version "1" must implement this function
65
- // each implementation MUST use onlyInitialising modifier
66
- function _upgrade(bytes memory data) virtual internal {
67
- revert();
68
- }
69
-
70
- // can only be called once per contract
71
- // needs to be called inside the proxy upgrade tx
72
- // TODO run reinitializer(version().toUint64()) modifier after "version()" is checked,
73
- function _activate(
74
- address implementation,
75
- address activatedBy
76
- )
77
- private
78
- onlyInitializing
79
- {
80
- VersionableStorage storage $ = _getVersionableStorage();
81
-
82
- uint64 version = _getInitializedVersion();
83
-
84
- Version thisVersion = getVersion();
85
-
86
- if(version == 1) {
87
- // thisVersion is alias to version "1"
88
- $._v1 = thisVersion;
89
- }
90
- else {
91
- require(thisVersion > $._v1, "INVALID VERSION");
92
- }
93
-
94
- // update version history
95
- $._versions.push(thisVersion);
96
- $._versionHistory[thisVersion] = VersionInfo(
97
- thisVersion,
98
- implementation,
99
- activatedBy,
100
- blockTimestamp(),
101
- blockNumber()
102
- );
103
-
104
- emit LogVersionableActivated(thisVersion, implementation, activatedBy);
105
- }
106
-
107
- // TODO previous version(s) can not be active -> check that _version is the current one
108
- function isActivated(Version _version) public override view returns(bool) {
109
- return _getVersionableStorage()._versionHistory[_version].activatedIn.toInt() > 0;
110
- }
111
-
112
-
113
- function getVersion() public pure virtual returns(Version);
114
-
115
-
116
- function getVersionCount() external view override returns(uint256) {
117
- return _getVersionableStorage()._versions.length;
118
- }
119
-
120
- function getVersion(uint256 idx) external view override returns(Version) {
121
- return _getVersionableStorage()._versions[idx];
122
- }
123
-
124
-
125
- function getVersionInfo(Version _version) external override view returns(VersionInfo memory) {
126
- return _getVersionableStorage()._versionHistory[_version];
127
- }
128
-
129
- function getInitializedVersion() external view returns(uint64)
130
- {
131
- return _getInitializedVersion();
132
- }
133
- }