@etherisc/gif-next 0.0.2-743affe-003 → 0.0.2-7878646-744

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +11 -0
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +90 -2
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +118 -6
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +80 -3
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -166
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +0 -166
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -166
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +120 -6
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +118 -6
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
  21. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
  22. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
  23. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
  24. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  40. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +54 -286
  43. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +154 -399
  46. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +90 -2
  48. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  51. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/IService.sol/IService.json +80 -3
  53. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +90 -2
  55. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  56. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  58. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +90 -2
  60. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +2 -2
  68. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -13
  73. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -13
  75. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  80. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +2 -2
  82. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  83. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  85. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  86. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +177 -40
  89. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +120 -16
  91. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +80 -3
  93. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +80 -3
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +80 -3
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -3
  99. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  100. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +122 -18
  101. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +146 -42
  103. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  104. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  105. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  106. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +40 -167
  108. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  109. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +214 -10
  110. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  111. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  112. package/artifacts/contracts/registry/Registry.sol/Registry.json +66 -188
  113. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  114. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +415 -31
  115. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  116. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +496 -0
  117. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  118. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  119. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  120. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  121. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  122. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
  123. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  124. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +80 -3
  125. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  127. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
  128. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  129. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +121 -82
  130. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +120 -6
  132. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  133. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  134. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  135. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +118 -6
  137. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  139. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestPool.sol/TestPool.json +120 -6
  141. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +120 -8
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +120 -6
  145. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  147. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.json +126 -14
  149. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  151. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  154. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  155. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  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/Fee.sol/FeeLib.json +4 -4
  161. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  162. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  164. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  169. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  172. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  173. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  174. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  175. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  177. package/contracts/components/BaseComponent.sol +1 -1
  178. package/contracts/components/IBaseComponent.sol +1 -1
  179. package/contracts/components/IDistributionComponent.sol +1 -2
  180. package/contracts/components/IPoolComponent.sol +1 -2
  181. package/contracts/components/IProductComponent.sol +1 -3
  182. package/contracts/components/Product.sol +4 -4
  183. package/contracts/experiment/cloning/Cloner.sol +47 -0
  184. package/contracts/instance/IInstance.sol +5 -7
  185. package/contracts/instance/Instance.sol +4 -6
  186. package/contracts/instance/base/ServiceBase.sol +1 -0
  187. package/contracts/instance/module/component/ComponentModule.sol +1 -1
  188. package/contracts/instance/module/component/IComponent.sol +1 -1
  189. package/contracts/instance/module/policy/IPolicy.sol +1 -1
  190. package/contracts/instance/module/treasury/ITreasury.sol +1 -1
  191. package/contracts/instance/module/treasury/TokenHandler.sol +1 -1
  192. package/contracts/instance/module/treasury/TreasuryModule.sol +4 -4
  193. package/contracts/instance/service/ComponentOwnerService.sol +73 -30
  194. package/contracts/instance/service/ProductService.sol +7 -6
  195. package/contracts/registry/ChainNft.sol +2 -2
  196. package/contracts/registry/IChainNft.sol +1 -1
  197. package/contracts/registry/IRegistry.sol +7 -25
  198. package/contracts/registry/IRegistryService.sol +9 -3
  199. package/contracts/registry/Registry.sol +78 -157
  200. package/contracts/registry/RegistryService.sol +179 -121
  201. package/contracts/registry/RegistryServiceManager.sol +64 -0
  202. package/contracts/shared/ContractDeployerLib.sol +72 -0
  203. package/contracts/shared/ERC165.sol +1 -1
  204. package/contracts/shared/INftOwnable.sol +22 -0
  205. package/contracts/shared/IRegisterable.sol +3 -8
  206. package/contracts/shared/NftOwnable.sol +136 -0
  207. package/contracts/shared/ProxyManager.sol +16 -37
  208. package/contracts/shared/Registerable.sol +14 -42
  209. package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
  210. package/contracts/shared/Versionable.sol +1 -1
  211. package/contracts/test/TestFee.sol +2 -2
  212. package/contracts/types/Fee.sol +3 -3
  213. package/contracts/types/RoleId.sol +7 -0
  214. package/contracts/types/UFixed.sol +128 -12
  215. package/package.json +4 -3
  216. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  217. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  218. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  219. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.json +0 -10
  220. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  221. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  222. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
  223. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +0 -24
  224. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.dbg.json +0 -4
  225. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.json +0 -344
  226. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  227. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  228. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  229. package/contracts/instance/module/access/Access.sol +0 -149
  230. package/contracts/instance/module/access/IAccess.sol +0 -53
  231. package/contracts/registry/IRegistryLinked.sol +0 -8
  232. package/contracts/registry/RegistryInstaller.sol +0 -100
  233. package/contracts/shared/IOwnable.sol +0 -6
@@ -1,13 +1,15 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+ import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
6
+ import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
7
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
8
 
6
- import {IRegistry} from "../registry/IRegistry.sol";
9
+ import {IRegistry} from "./IRegistry.sol";
7
10
  import {IInstance} from "../instance/IInstance.sol";
8
11
 
9
- //import {ITreasury, ITreasuryModule} from "../../contracts/instance/module/treasury/ITreasury.sol";
10
- //import {TreasuryModule} from "../../contracts/instance/module/treasury/TreasuryModule.sol";
12
+ import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
11
13
  import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
12
14
  import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
13
15
  import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
@@ -25,44 +27,53 @@ import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
25
27
  import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
26
28
  import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
27
29
  import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
28
- //import {UFixed, UFixedMathLib} from "../../contracts/types/UFixed.sol";
29
-
30
30
 
31
31
  import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
32
32
  import {IService} from "../../contracts/instance/base/IService.sol";
33
33
  import {IRegistryService} from "./IRegistryService.sol";
34
- import {Registry} from "../registry/Registry.sol";
34
+ import {Registry} from "./Registry.sol";
35
+ import {ChainNft} from "./ChainNft.sol";
35
36
 
36
37
  contract RegistryService is
38
+ AccessManagedUpgradeable,
37
39
  ServiceBase,
38
40
  IRegistryService
39
41
  {
40
42
  using NftIdLib for NftId;
41
43
 
44
+ error SelfRegistration();
42
45
  error NotRegistryOwner();
43
- error MissingAllowance();
44
46
 
45
47
  error NotToken();
46
48
  error NotService();
47
- error NotComponent();
48
49
  error NotInstance();
49
-
50
- error InvalidAddress(address registerableAddress);
50
+ error NotProduct();
51
+ error NotPool();
52
+ error NotDistribution();
53
+
54
+ error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
55
+ error NotRegisterableOwner(address expectedOwner);
56
+ error RegisterableOwnerIsZero();
57
+ error RegisterableOwnerIsRegistered();
51
58
  error InvalidInitialOwner(address initialOwner);
52
- error SelfRegistration();
53
- error InvalidType(ObjectType objectType);
59
+ error InvalidAddress(address registerableAddress);
54
60
 
61
+
62
+ // Initial value for constant variable has to be compile-time constant
63
+ // TODO define types as constants?
64
+ //ObjectType public constant SERVICE_TYPE = REGISTRY();
55
65
  string public constant NAME = "RegistryService";
56
66
 
57
- bytes32 public constant REGISTRY_CREATIONCODE_HASH = 0x7e569c7200a12c63728b648d78f84be7e32ef6804f9ee723e15363ce34d01251;
67
+ // TODO update to real hash when registry is stable
68
+ bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
58
69
 
59
- address constant public NFT_LOCK_ADDRESS = address(0x1);
70
+ address public constant NFT_LOCK_ADDRESS = address(0x1);
60
71
 
61
72
  /// @dev
62
73
  // msg.sender - ONLY registry owner
63
- // CAN register ANY non IRegisterable address
64
- // CAN register ONLY valid object-parent types combinations for TOKEN
65
74
  // CAN NOT register itself
75
+ // CAN NOT register IRegisterable address
76
+ // CAN register ONLY valid object-parent types combinations for TOKEN
66
77
  // IMPORTANT: MUST NOT call untrusted contract inbetween calls to registry/instance (trusted contracts)
67
78
  // motivation: registry/instance state may change during external call
68
79
  // TODO it may be usefull to have transferable token nft in order to delist token, make it invalid for new beginings
@@ -71,29 +82,25 @@ contract RegistryService is
71
82
  external
72
83
  returns(NftId nftId)
73
84
  {
74
- IRegisterable registerable = IRegisterable(tokenAddress);
75
- bool isRegisterable;
76
-
77
- // registryOwner can not register IRegisterable as TOKEN
78
- try registerable.supportsInterface(type(IRegisterable).interfaceId) returns(bool result) {
79
- isRegisterable = result;
80
- } catch {
81
- isRegisterable = false;
82
- }
85
+ if(msg.sender == tokenAddress) {
86
+ revert SelfRegistration();
87
+ }
83
88
 
84
- if(isRegisterable) {
89
+ // MUST not revert if no ERC165 support
90
+ if(tokenAddress.code.length == 0 ||
91
+ ERC165Checker.supportsInterface(tokenAddress, type(IRegisterable).interfaceId)) {
85
92
  revert NotToken();
86
- }
93
+ }
87
94
 
88
- IRegistry registry = getRegistry();
95
+ NftId registryNftId = _registry.getNftId(address(_registry));
89
96
 
90
- if(msg.sender != registry.ownerOf(address(registry))) {
97
+ if(msg.sender != _registry.ownerOf(registryNftId)) {
91
98
  revert NotRegistryOwner();
92
99
  }
93
100
 
94
101
  IRegistry.ObjectInfo memory info = IRegistry.ObjectInfo(
95
102
  zeroNftId(), // any value
96
- registry.getNftId(address(registry)),
103
+ registryNftId, // parent nft id
97
104
  TOKEN(),
98
105
  false, // isInterceptor
99
106
  tokenAddress,
@@ -101,14 +108,14 @@ contract RegistryService is
101
108
  "" // any value
102
109
  );
103
110
 
104
- nftId = registry.register(info);
111
+ nftId = _registry.register(info);
105
112
  }
106
113
 
107
114
  /// @dev
108
115
  // msg.sender - ONLY registry owner
116
+ // CAN NOT register itself
109
117
  // CAN register ONLY valid object-parent types combinations for SERVICE
110
118
  // CAN register ONLY IRegisterable address he owns
111
- // CAN NOT register itself
112
119
  // IMPORTANT: MUST NOT check owner before calling external contract
113
120
  function registerService(IService service)
114
121
  external
@@ -117,56 +124,83 @@ contract RegistryService is
117
124
  bytes memory data
118
125
  )
119
126
  {
120
- if(service.supportsInterface(type(IService).interfaceId) == false) {
127
+
128
+ // CAN revert if no ERC165 support -> will revert with empty message
129
+ if(!service.supportsInterface(type(IService).interfaceId)) {
121
130
  revert NotService();
122
- }
131
+ }
123
132
 
124
133
  (
125
134
  info,
126
135
  data
127
136
  ) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
128
137
 
129
- IRegistry registry = getRegistry();
130
-
131
- if(msg.sender != registry.ownerOf(address(registry))) {
138
+ if(msg.sender != _registry.getOwner()) {
132
139
  revert NotRegistryOwner();
133
140
  }
134
141
 
135
- info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
136
- info.nftId = registry.register(info);
137
-
142
+ info.nftId = _registry.register(info);
143
+ service.linkToRegisteredNftId();
138
144
  return (
139
145
  info,
140
146
  data
141
147
  );
142
148
  }
143
149
 
144
- // anybody can register component if instance gives a corresponding role
145
- //function registerComponent(IBaseComponent component, ObjectType componentType)
146
- function registerComponent(IBaseComponent component, ObjectType componentType, address owner)
150
+ // If msg.sender is approved service:
151
+ // 1) add owner arg (service MUST pass it's msg.sender as owner)
152
+ // 2) check service allowance
153
+ // 3) comment self registrstion check
154
+ //function registerInstance(IRegisterable instance, address owner)
155
+ function registerInstance(IRegisterable instance)
147
156
  external
148
157
  returns(
149
158
  IRegistry.ObjectInfo memory info,
150
159
  bytes memory data
151
160
  )
152
161
  {
153
- if(component.supportsInterface(type(IBaseComponent).interfaceId) == false) {
154
- revert NotComponent();
162
+
163
+ if(!instance.supportsInterface(type(IInstance).interfaceId)) {
164
+ revert NotInstance();
155
165
  }
156
166
 
157
167
  (
158
168
  info,
159
169
  data
160
- ) = _getAndVerifyContractInfo(component, componentType, owner);
170
+ ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);
171
+
172
+ info.nftId = _registry.register(info);
173
+ instance.linkToRegisteredNftId(); // asume safe
174
+
175
+ return (
176
+ info,
177
+ data
178
+ );
179
+ }
161
180
 
162
- IRegistry registry = getRegistry();
163
- NftId serviceNftId = registry.getNftId(msg.sender);
181
+ function registerProduct(IBaseComponent product, address owner)
182
+ external
183
+ restricted
184
+ returns(
185
+ IRegistry.ObjectInfo memory info,
186
+ bytes memory data
187
+ )
188
+ {
189
+ // CAN revert if no ERC165 support -> will revert with empty message
190
+ if(!product.supportsInterface(type(IProductComponent).interfaceId)) {
191
+ revert NotProduct();
192
+ }
193
+
194
+ (
195
+ info,
196
+ data
197
+ ) = _getAndVerifyContractInfo(product, PRODUCT(), owner);
164
198
 
165
- if(registry.allowance(serviceNftId, componentType) == false) {
166
- revert MissingAllowance();
167
- }
199
+ NftId serviceNftId = _registry.getNftId(msg.sender);
168
200
 
169
- info.nftId = registry.register(info);
201
+ info.nftId = _registry.register(info);
202
+ // TODO unsafe, let component or its owner derive nftId latter, when state assumptions and modifications of GIF contracts are finished
203
+ product.linkToRegisteredNftId();
170
204
 
171
205
  return (
172
206
  info,
@@ -174,68 +208,85 @@ contract RegistryService is
174
208
  );
175
209
  }
176
210
 
177
- // TODO: when called by approved service: add owner arg (service must pass it's msg.sender as owner) & check service allowance
178
- //function registerInstance(IRegisterable instance, address owner)
179
- function registerInstance(IRegisterable instance)
180
- external
211
+ function registerPool(IBaseComponent pool, address owner)
212
+ external
213
+ restricted
181
214
  returns(
182
215
  IRegistry.ObjectInfo memory info,
183
216
  bytes memory data
184
217
  )
185
218
  {
186
- if(instance.supportsInterface(type(IInstance).interfaceId) == false) {
187
- revert NotInstance();
219
+ if(!pool.supportsInterface(type(IPoolComponent).interfaceId)) {
220
+ revert NotPool();
188
221
  }
189
222
 
190
223
  (
191
224
  info,
192
225
  data
193
- ) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);// owner);
226
+ ) = _getAndVerifyContractInfo(pool, POOL(), owner);
194
227
 
195
- IRegistry registry = getRegistry();
228
+ NftId serviceNftId = _registry.getNftId(msg.sender);
196
229
 
197
- //if(registry.allowance(registry.getNftId(msg.sender), INSTANCE()) == false) {
198
- // revert MissingAllowance();
199
- //}
230
+ info.nftId = _registry.register(info);
231
+ pool.linkToRegisteredNftId();
200
232
 
201
- info.nftId = registry.register(info);
202
-
203
233
  return (
204
234
  info,
205
- data
206
- );
235
+ data
236
+ );
237
+ }
238
+
239
+ function registerDistribution(IBaseComponent distribution, address owner)
240
+ external
241
+ restricted
242
+ returns(
243
+ IRegistry.ObjectInfo memory info,
244
+ bytes memory data
245
+ )
246
+ {
247
+ if(!distribution.supportsInterface(type(IDistributionComponent).interfaceId)) {
248
+ revert NotDistribution();
249
+ }
250
+
251
+ (
252
+ info,
253
+ data
254
+ ) = _getAndVerifyContractInfo(distribution, DISTRIBUTION(), owner);
255
+
256
+ NftId serviceNftId = _registry.getNftId(msg.sender);
257
+
258
+ info.nftId = _registry.register(info);
259
+ distribution.linkToRegisteredNftId();
260
+
261
+ return (
262
+ info,
263
+ data
264
+ );
207
265
  }
208
266
 
209
267
  function registerPolicy(IRegistry.ObjectInfo memory info)
210
- external
268
+ external
269
+ restricted
211
270
  returns(NftId nftId)
212
271
  {
213
- IRegistry registry = getRegistry();
214
- NftId senderNftId = registry.getNftId(msg.sender);
215
-
216
- if(registry.allowance(senderNftId, POLICY()) == false) {
217
- revert MissingAllowance();
218
- }
272
+ NftId senderNftId = _registry.getNftId(msg.sender);
219
273
 
220
274
  _verifyObjectInfo(info, POLICY());
221
275
 
222
- nftId = registry.register(info);
276
+ nftId = _registry.register(info);
223
277
  }
224
278
 
225
279
  function registerBundle(IRegistry.ObjectInfo memory info)
226
- external
280
+ external
281
+ restricted
227
282
  returns(NftId nftId)
228
283
  {
229
- IRegistry registry = getRegistry();
230
- NftId senderNftId = registry.getNftId(msg.sender);
231
284
 
232
- if(registry.allowance(senderNftId, BUNDLE()) == false) {
233
- revert MissingAllowance();
234
- }
285
+ NftId senderNftId = _registry.getNftId(msg.sender);
235
286
 
236
287
  _verifyObjectInfo(info, BUNDLE());
237
288
 
238
- nftId = registry.register(info);
289
+ nftId = _registry.register(info);
239
290
  }
240
291
 
241
292
 
@@ -243,6 +294,9 @@ contract RegistryService is
243
294
  function getName() public pure override(IService, ServiceBase) returns(string memory) {
244
295
  return NAME;
245
296
  }
297
+ //function getType() public pure override(IService, ServiceBase) returns(ObjectType serviceType) {
298
+ // return SERVICE_TYPE;
299
+ //}
246
300
 
247
301
 
248
302
  // from Versionable
@@ -252,47 +306,51 @@ contract RegistryService is
252
306
  // 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
253
307
  // 3) deploy registry -> pass registry service address as constructor argument
254
308
  // registry is getting instantiated and locked to registry service address forever
255
- function _initialize(address protocolOwner, bytes memory registryCreationCode)
309
+ function _initialize(
310
+ address owner,
311
+ bytes memory data
312
+ )
256
313
  internal
257
314
  initializer
258
315
  virtual override
259
316
  {
260
- // TODO check when stable
261
- //require(keccak256(registryCreationCode) == REGISTRY_CREATIONCODE_HASH, "INVALID_REGISTRY_CREATIONCODE");
262
-
263
- bytes memory bytecode = abi.encodePacked(
264
- registryCreationCode,
265
- abi.encode(
266
- protocolOwner,
267
- getMajorVersion()
268
- )
269
- );
317
+ (
318
+ address initialAuthority,
319
+ bytes memory registryByteCodeWithInitCode
320
+ ) = abi.decode(data, (address, bytes));
270
321
 
271
- address registryAddress;
322
+ __AccessManaged_init(initialAuthority);
272
323
 
273
- assembly {
274
- registryAddress := create(0, add(bytecode, 0x20), mload(bytecode))
324
+ bytes memory encodedConstructorArguments = abi.encode(
325
+ owner,
326
+ getMajorVersion());
275
327
 
276
- if iszero(extcodesize(registryAddress)) {
277
- revert(0, 0)
278
- }
279
- }
328
+ bytes memory registryCreationCode = ContractDeployerLib.getCreationCode(
329
+ registryByteCodeWithInitCode,
330
+ encodedConstructorArguments);
331
+
332
+ IRegistry registry = IRegistry(ContractDeployerLib.deploy(
333
+ registryCreationCode,
334
+ REGISTRY_CREATION_CODE_HASH));
280
335
 
281
- IRegistry registry = IRegistry(registryAddress);
282
- NftId registryNftId = registry.getNftId(registryAddress);
336
+ NftId registryNftId = registry.getNftId(address(registry));
283
337
 
284
- _initializeServiceBase(registryAddress, registryNftId, protocolOwner);
338
+ _initializeServiceBase(address(registry), registryNftId, owner);
285
339
 
340
+ // TODO why do registry service proxy need to keep its nftId??? -> no registryServiceNftId checks in implementation
341
+ // if they are -> use registry address to obtain owner of registry service nft (works the same with any registerable and(or) implementation)
342
+ linkToRegisteredNftId();
286
343
  _registerInterface(type(IRegistryService).interfaceId);
287
344
  }
288
345
 
289
346
  // parent check done in registry because of approve()
290
347
  function _getAndVerifyContractInfo(
291
348
  IRegisterable registerable,
292
- ObjectType objectType,
293
- address owner
349
+ ObjectType expectedType, // assume can be valid only
350
+ address expectedOwner // assume can be 0
294
351
  )
295
352
  internal
353
+ view
296
354
  returns(
297
355
  IRegistry.ObjectInfo memory info,
298
356
  bytes memory data
@@ -302,23 +360,28 @@ contract RegistryService is
302
360
  info,
303
361
  data
304
362
  ) = registerable.getInitialInfo();
363
+ info.objectAddress = address(registerable);
305
364
 
306
- if(info.objectAddress != address(registerable)) {
307
- revert InvalidAddress(info.objectAddress);
365
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
366
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
308
367
  }
309
368
 
310
- if(
311
- getRegistry().isRegistered(owner) ||
312
- info.initialOwner != owner) { // contract owner protection
313
- revert InvalidInitialOwner(info.initialOwner);
369
+ address owner = info.initialOwner;
370
+
371
+ if(owner != expectedOwner) { // registerable owner protection
372
+ revert NotRegisterableOwner(expectedOwner);
314
373
  }
315
374
 
316
- if(msg.sender == address(registerable)) {
375
+ if(owner == address(registerable)) {
317
376
  revert SelfRegistration();
318
377
  }
378
+
379
+ if(owner == address(0)) {
380
+ revert RegisterableOwnerIsZero();
381
+ }
319
382
 
320
- if(info.objectType != objectType) {
321
- revert InvalidType(info.objectType);
383
+ if(getRegistry().isRegistered(owner)) {
384
+ revert RegisterableOwnerIsRegistered();
322
385
  }
323
386
 
324
387
  /*NftId parentNftId = info.parentNftId;
@@ -368,11 +431,6 @@ contract RegistryService is
368
431
  revert InitialOwnerIsRegistry();
369
432
  }*/
370
433
 
371
-
372
- if(info.objectType != objectType) {
373
- revert InvalidType(info.objectType);
374
- }
375
-
376
434
  /*NftId parentNftId = info.parentNftId;
377
435
  IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
378
436
 
@@ -380,4 +438,4 @@ contract RegistryService is
380
438
  revert InvalidParent(parentNftId);
381
439
  }*/
382
440
  }
383
- }
441
+ }
@@ -0,0 +1,64 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
5
+
6
+ import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
7
+
8
+ import {Registry} from "./Registry.sol";
9
+ import {IVersionable} from "../shared/IVersionable.sol";
10
+ import {ProxyManager} from "../shared/ProxyManager.sol";
11
+ import {RegistryService} from "./RegistryService.sol";
12
+
13
+
14
+ contract RegistryServiceManager is
15
+ ProxyManager
16
+ {
17
+ bytes32 constant public ACCESS_MANAGER_CREATION_CODE_HASH = 0x0;
18
+
19
+ RegistryService private _registryService;
20
+
21
+ AccessManager private _accessManager;
22
+
23
+ /// @dev initializes proxy manager with registry service implementation and deploys registry
24
+ constructor(
25
+ address accessManager
26
+ )
27
+ ProxyManager()
28
+ {
29
+ _accessManager = AccessManager(accessManager);
30
+
31
+ bytes memory initializationData = abi.encode(accessManager, type(Registry).creationCode);
32
+
33
+ IVersionable versionable = deploy(
34
+ address(new RegistryService()),
35
+ initializationData);
36
+
37
+ _registryService = RegistryService(address(versionable));
38
+
39
+ // link ownership of registry service manager ot nft owner of registry service
40
+ _linkToNftOwnable(
41
+ address(_registryService.getRegistry()),
42
+ address(_registryService));
43
+
44
+ // implies that after this constructor call only upgrade functionality is available
45
+ _isDeployed = true;
46
+ }
47
+
48
+ //--- view functions ----------------------------------------------------//
49
+ function getRegistryService()
50
+ external
51
+ view
52
+ returns (RegistryService registryService)
53
+ {
54
+ return _registryService;
55
+ }
56
+
57
+ function getAccessManager()
58
+ external
59
+ view
60
+ returns (AccessManager)
61
+ {
62
+ return _accessManager;
63
+ }
64
+ }
@@ -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 "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
4
+ import {IERC165} from "@openzeppelin/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
+ }