@etherisc/gif-next 0.0.2-ce8407f-016 → 0.0.2-cf68d0c-530

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. package/README.md +108 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +327 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +670 -0
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +39 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +204 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +790 -0
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
  17. package/artifacts/contracts/components/Product.sol/Product.json +775 -0
  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/Dummy.sol/LifeCycleModule.json +2 -2
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  40. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  41. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  42. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  43. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  44. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
  45. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
  46. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +15 -2
  47. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  48. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  49. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +435 -1
  50. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  51. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
  52. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  53. package/artifacts/contracts/instance/Instance.sol/Instance.json +491 -495
  54. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -34
  56. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  57. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +438 -33
  58. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  59. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +726 -16
  60. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  61. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +468 -0
  62. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  63. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +481 -0
  64. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  65. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  66. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +0 -77
  68. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  70. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +10 -244
  71. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  72. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  73. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
  81. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
  82. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  83. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +641 -0
  84. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +428 -0
  86. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
  87. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
  88. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  89. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
  90. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  91. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
  92. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  93. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
  94. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  95. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
  96. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  97. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +292 -103
  98. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  99. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +123 -15
  100. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  101. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  102. package/artifacts/contracts/registry/Registry.sol/Registry.json +249 -143
  103. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  104. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +272 -48
  105. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  106. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +79 -30
  107. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  108. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
  109. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  110. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  111. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  112. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  113. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  114. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  115. package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +1 -1
  116. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  117. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  118. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  119. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  120. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  121. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  122. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +6 -6
  123. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
  124. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
  125. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  126. package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +2 -2
  127. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  128. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  129. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  130. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  131. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  132. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  133. package/artifacts/contracts/test/TestFee.sol/TestFee.json +4 -4
  134. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  135. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -6
  136. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  137. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +111 -5
  138. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  139. package/artifacts/contracts/test/TestService.sol/TestService.json +17 -17
  140. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
  142. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  144. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  146. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  147. package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
  148. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  149. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/Fee.sol/FeeLib.json +4 -4
  154. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  155. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  157. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  163. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  165. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  167. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  168. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  169. package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
  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 +22 -3
  174. package/contracts/components/BaseComponent.sol +91 -0
  175. package/contracts/components/Distribution.sol +166 -0
  176. package/contracts/components/IBaseComponent.sol +8 -2
  177. package/contracts/components/IDistributionComponent.sol +46 -0
  178. package/contracts/components/IPoolComponent.sol +62 -0
  179. package/contracts/components/IProductComponent.sol +35 -0
  180. package/contracts/components/Pool.sol +258 -0
  181. package/contracts/components/Product.sol +297 -0
  182. package/contracts/experiment/cloning/Cloner.sol +47 -0
  183. package/contracts/instance/AccessManagedSimple.sol +9 -8
  184. package/contracts/instance/AccessManagerSimple.sol +12 -2
  185. package/contracts/instance/IAccessManagerSimple.sol +1 -1
  186. package/contracts/instance/IInstance.sol +28 -1
  187. package/contracts/instance/IInstanceService.sol +30 -0
  188. package/contracts/instance/Instance.sol +61 -10
  189. package/contracts/instance/InstanceAccessManager.sol +3 -3
  190. package/contracts/instance/InstanceReader.sol +63 -8
  191. package/contracts/instance/InstanceService.sol +131 -18
  192. package/contracts/instance/InstanceServiceManager.sol +56 -0
  193. package/contracts/instance/base/ComponentServiceBase.sol +39 -0
  194. package/contracts/instance/base/IInstanceBase.sol +23 -0
  195. package/contracts/instance/base/IKeyValueStore.sol +5 -4
  196. package/contracts/instance/base/KeyValueStore.sol +4 -20
  197. package/contracts/instance/module/IAccess.sol +2 -2
  198. package/contracts/instance/module/ISetup.sol +3 -1
  199. package/contracts/instance/module/ITreasury.sol +1 -1
  200. package/contracts/instance/service/ComponentOwnerService.sol +317 -0
  201. package/contracts/instance/service/DistributionService.sol +96 -0
  202. package/contracts/instance/service/DistributionServiceManager.sol +53 -0
  203. package/contracts/instance/service/IComponentOwnerService.sol +20 -0
  204. package/contracts/instance/service/IDistributionService.sol +12 -0
  205. package/contracts/instance/service/IPoolService.sol +37 -0
  206. package/contracts/instance/service/IProductService.sol +107 -0
  207. package/contracts/registry/ChainNft.sol +40 -25
  208. package/contracts/registry/IRegistry.sol +43 -22
  209. package/contracts/registry/IRegistryService.sol +16 -12
  210. package/contracts/registry/Registry.sol +163 -165
  211. package/contracts/registry/RegistryService.sol +168 -138
  212. package/contracts/registry/RegistryServiceManager.sol +39 -2
  213. package/contracts/registry/TokenRegistry.sol +111 -0
  214. package/contracts/shared/ERC165.sol +7 -3
  215. package/contracts/shared/IRegisterable.sol +1 -1
  216. package/contracts/{instance/base → shared}/IService.sol +3 -3
  217. package/contracts/shared/ProxyManager.sol +3 -3
  218. package/contracts/shared/Registerable.sol +3 -2
  219. package/contracts/shared/RegisterableUpgradable.sol +16 -0
  220. package/contracts/shared/Service.sol +54 -0
  221. package/contracts/shared/TokenHandler.sol +2 -2
  222. package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
  223. package/contracts/shared/Versionable.sol +1 -1
  224. package/contracts/test/TestFee.sol +2 -2
  225. package/contracts/test/TestRoleId.sol +6 -6
  226. package/contracts/test/TestService.sol +3 -5
  227. package/contracts/types/Fee.sol +3 -3
  228. package/contracts/types/RoleId.sol +17 -4
  229. package/contracts/types/StateId.sol +4 -0
  230. package/contracts/types/UFixed.sol +128 -12
  231. package/contracts/types/Version.sol +4 -1
  232. package/package.json +4 -3
  233. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  234. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  235. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  236. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
  237. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  238. package/contracts/instance/base/ServiceBase.sol +0 -44
  239. package/contracts/registry/IChainNft.sol +0 -22
@@ -2,13 +2,12 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {IRegisterable} from "../shared/IRegisterable.sol";
5
- import {IService} from "../instance/base/IService.sol";
5
+ import {IService} from "../shared/IService.sol";
6
6
 
7
- import {IChainNft} from "./IChainNft.sol";
8
7
  import {ChainNft} from "./ChainNft.sol";
9
8
  import {IRegistry} from "./IRegistry.sol";
10
9
  import {NftId, toNftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
11
- import {Version, VersionPart, VersionLib} from "../types/Version.sol";
10
+ import {Version, VersionPart, VersionLib, VersionPartLib} from "../types/Version.sol";
12
11
  import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, DISTRIBUTION, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
13
12
  import {ITransferInterceptor} from "./ITransferInterceptor.sol";
14
13
 
@@ -29,57 +28,40 @@ contract Registry is
29
28
  ERC165,
30
29
  IRegistry
31
30
  {
32
- // register
33
- error NotRegistryService();
34
- error ZeroParentAddress();
35
- error ContractAlreadyRegistered(address objectAddress);
36
- error InvalidServiceVersion(VersionPart majorVersion);
37
- error ServiceNameAlreadyRegistered(string name, VersionPart majorVersion);
38
-
39
- // approve
40
- error NotOwner();
41
- error NotRegisteredContract(NftId registrarNftId);
42
- error NotService(NftId registrarNftId);
43
- error InvalidTypesCombination(ObjectType objectType, ObjectType parentType);
44
-
45
- uint256 public constant MAJOR_VERSION_MIN = 3;
31
+ uint256 public constant GIF_MAJOR_VERSION_AT_DEPLOYMENT = 3;
46
32
  address public constant NFT_LOCK_ADDRESS = address(0x1);
47
33
  uint256 public constant REGISTRY_SERVICE_TOKEN_SEQUENCE_ID = 3;
48
34
  string public constant EMPTY_URI = "";
49
35
 
50
- mapping(NftId nftId => ObjectInfo info) _info;
51
- mapping(address object => NftId nftId) _nftIdByAddress;
36
+ VersionPart internal _majorVersion;
37
+
38
+ mapping(NftId nftId => ObjectInfo info) internal _info;
39
+ mapping(address object => NftId nftId) internal _nftIdByAddress;
52
40
 
53
41
  mapping(NftId registrator => mapping(
54
- ObjectType objectType => bool)) _isApproved;
42
+ ObjectType objectType => bool)) internal _isApproved;
55
43
 
56
44
  mapping(ObjectType objectType => mapping(
57
- ObjectType parentType => bool)) _isValidContractCombination;
45
+ ObjectType parentType => bool)) internal _isValidContractCombination;
58
46
 
59
47
  mapping(ObjectType objectType => mapping(
60
- ObjectType parentType => bool)) _isValidObjectCombination;
48
+ ObjectType parentType => bool)) internal _isValidObjectCombination;
49
+
50
+ mapping(address token => mapping(
51
+ VersionPart majorVersion => bool isActive)) internal _tokenIsActive;
61
52
 
62
- mapping(NftId nftId => string name) _string;
53
+ mapping(NftId nftId => string name) internal _string;
63
54
  mapping(bytes32 serviceNameHash => mapping(
64
- VersionPart majorVersion => address service)) _service;
65
-
66
- NftId _registryNftId;
67
- NftId _serviceNftId; // set in stone upon registry creation
68
- IChainNft _chainNft;
69
- ChainNft _chainNftInternal;
70
-
71
- /*
72
- modifier onlyInitialOwner() {
73
- if(
74
- msg.sender != getOwner() ||
75
- msg.sender != _info[_registryNftId].initialOwner) {
76
- revert NotInitialOwner();
77
- }
78
- }*/
55
+ VersionPart majorVersion => address service)) internal _service;
56
+
57
+ NftId internal _registryNftId;
58
+ NftId internal _serviceNftId; // set in stone upon registry creation
59
+ ChainNft internal _chainNft;
60
+
79
61
 
80
62
  modifier onlyOwner() {
81
63
  if(msg.sender != getOwner()) {
82
- revert NotOwner();
64
+ revert NotOwner(msg.sender);
83
65
  }
84
66
  _;
85
67
  }
@@ -95,11 +77,13 @@ contract Registry is
95
77
  constructor(address registryOwner, VersionPart majorVersion)
96
78
  {
97
79
  require(registryOwner > address(0), "Registry: registry owner is 0");
98
- require(majorVersion.toInt() == MAJOR_VERSION_MIN, "Registry: initial major version of registry service is not MAJOR_VERSION_MIN");
80
+
81
+ // major version at constructor time
82
+ _majorVersion = VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT);
83
+ emit LogInitialMajorVersionSet(_majorVersion);
99
84
 
100
85
  // deploy NFT
101
- _chainNftInternal = new ChainNft(address(this));// adds 10kb to deployment size
102
- _chainNft = IChainNft(_chainNftInternal);
86
+ _chainNft = new ChainNft(address(this));// adds 10kb to deployment size
103
87
 
104
88
  // initial registry setup
105
89
  _registerProtocol();
@@ -112,9 +96,25 @@ contract Registry is
112
96
  _registerInterface(type(IRegistry).interfaceId);
113
97
  }
114
98
 
99
+ // from IRegistry
100
+
101
+ /// @dev latest GIF release version
102
+ function setMajorVersion(VersionPart newMajorVersion)
103
+ external
104
+ onlyOwner
105
+ {
106
+ // ensure major version increments is one
107
+ uint256 oldMax = _majorVersion.toInt();
108
+ uint256 newMax = newMajorVersion.toInt();
109
+ if (newMax <= oldMax || newMax - oldMax != 1) {
110
+ revert MajorVersionMaxIncreaseInvalid(newMajorVersion, _majorVersion);
111
+ }
112
+
113
+ _majorVersion = newMajorVersion;
114
+ emit LogMajorVersionSet(_majorVersion);
115
+ }
116
+
115
117
  /// @dev registry protects only against tampering existing records, registering with invalid types pairs and 0 parent address
116
- // IMPORTANT: rare case when parentNftId is not registered and == next nftId -> technincally this is ZeroParentAddress error
117
- // to catch this check parent address before minting !!!!
118
118
  // TODO service registration means its approval for some type?
119
119
  // TODO registration of precompile addresses
120
120
  function register(ObjectInfo memory info)
@@ -139,8 +139,6 @@ contract Registry is
139
139
  address interceptor = _getInterceptor(info.isInterceptor, info.objectAddress, parentInfo.isInterceptor, parentAddress);
140
140
 
141
141
  // TODO does external call
142
- // check for receiver in registry service?
143
- // use unsafe transfer?
144
142
  uint256 mintedTokenId = _chainNft.mint(
145
143
  info.initialOwner,
146
144
  interceptor,
@@ -170,33 +168,8 @@ contract Registry is
170
168
  _nftIdByAddress[contractAddress] = nftId;
171
169
 
172
170
  // special case
173
- if(objectType == SERVICE())
174
- {
175
- (
176
- string memory serviceName,
177
- VersionPart majorVersion
178
- ) = abi.decode(info.data, (string, VersionPart));
179
- bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
180
-
181
- // TODO MUST guarantee consistency of service.getVersion() and majorVersion here
182
- // TODO update _serviceNftId when registryService with new major version is registered? -> it is fixed in current setup
183
- // TODO do not use names -> each object type is registered by corresponding service -> conflicting with approve()
184
- if(
185
- majorVersion.toInt() < MAJOR_VERSION_MIN ||
186
- (majorVersion.toInt() > MAJOR_VERSION_MIN &&
187
- _service[serviceNameHash][VersionLib.toVersionPart(majorVersion.toInt() - 1)] == address(0) )
188
- ) {
189
- revert InvalidServiceVersion(majorVersion);
190
- }
191
-
192
- if(_service[serviceNameHash][majorVersion] != address(0)) {
193
- revert ServiceNameAlreadyRegistered(serviceName, majorVersion);
194
- }
195
-
196
- _string[nftId] = serviceName;
197
- _service[serviceNameHash][majorVersion] = contractAddress;
198
-
199
- emit LogServiceNameRegistration(serviceName, majorVersion);
171
+ if(objectType == SERVICE()) {
172
+ _registerService(info);
200
173
  }
201
174
  }
202
175
  else
@@ -206,75 +179,70 @@ contract Registry is
206
179
  }
207
180
  }
208
181
 
209
- emit LogRegistration(nftId, info.parentNftId, info.objectType, info.isInterceptor, info.objectAddress, info.initialOwner);
210
- }
211
-
212
- function registerFrom(
213
- address from,
214
- ObjectInfo memory info
215
- ) external returns (NftId nftId)
216
- {
217
- revert();
182
+ emit LogRegistration(info);
218
183
  }
219
-
220
184
 
221
- /// @dev
222
- // msg.sender - registry owner
223
- // CAN approve only registered service contract
224
- // CAN approve any combination specified in _isValidCombination
225
- // CAN NOT approve itself
226
- // TODO in case where exists exactly one registered service per objectType (and major version):
227
- // - registration and approve is a single operation, no need for separate approve() function
228
- // - then approve can be used to adding new valid object-parent combinations???
229
- function approve(
230
- NftId serviceNftId,
231
- ObjectType objectType,
232
- ObjectType parentType
233
- )
234
- public
235
- onlyOwner()
185
+ /// @dev token state is informative, registry have no clue about used tokens
186
+ // component owner is responsible for token selection and operations
187
+ // service MUST deny registration of component with inactive token
188
+ function setTokenActive(address token, VersionPart majorVersion, bool active)
189
+ external
190
+ onlyOwner
236
191
  {
237
- address serviceAddress = _info[serviceNftId].objectAddress;
238
-
239
- if(_nftIdByAddress[serviceAddress].eqz()) {
240
- revert NotRegisteredContract(serviceNftId);
192
+ // verify that token is registered
193
+ ObjectInfo memory info = _info[_nftIdByAddress[token]];
194
+ if (info.nftId.eqz()) {
195
+ revert TokenNotRegistered(token);
241
196
  }
242
197
 
243
- if(_info[serviceNftId].objectType != SERVICE()) {
244
- revert NotService(serviceNftId);
198
+ // verify provided address is a registered token
199
+ if (info.objectType != TOKEN()) {
200
+ revert NotToken(token);
245
201
  }
246
202
 
247
- if(
248
- _isValidContractCombination[objectType][parentType] == false &&
249
- _isValidObjectCombination[objectType][parentType] == false) {
250
- revert InvalidTypesCombination(objectType, parentType);
203
+ // verify valid major version
204
+ // ensure major version increments is one
205
+ uint256 version = majorVersion.toInt();
206
+ uint256 versionNow = _majorVersion.toInt();
207
+ if (version < GIF_MAJOR_VERSION_AT_DEPLOYMENT || version > versionNow) {
208
+ revert TokenMajorVersionInvalid(majorVersion);
251
209
  }
252
210
 
253
- _isApproved[serviceNftId][objectType] = true;
211
+ _tokenIsActive[token][majorVersion] = active;
254
212
 
255
- emit LogApproval(serviceNftId, objectType);
213
+ emit LogTokenStateSet(token, majorVersion, active);
256
214
  }
257
215
 
258
- /// @dev returns false for registry owner nft
259
- // TODO allowance by address?
260
- // TODO checked by registry service -> but registry owner can upgrade registry service not to check allowance....
261
- function allowance(
262
- NftId nftId,
263
- ObjectType object
264
- )
265
- public
266
- view
267
- returns (bool)
268
- {
269
- return _isApproved[nftId][object];
216
+ /// @dev earliest GIF major version
217
+ function getMajorVersionMin() external view returns (VersionPart) {
218
+ return VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT);
270
219
  }
271
220
 
272
- // from IRegistry
221
+ // TODO make distinction between active an not yet active version
222
+ // need to be thought trough, not yet clear if necessary
223
+ // need to answer question: what is the latest version during the upgrade process?
224
+ // likely setting up a new gif version does not fit into a single tx
225
+ // in this case we might want to have a period where the latest version is
226
+ // in the process of being set up while the latest active version is 1 major release smaller
227
+ /// @dev latest GIF major version (might not yet be active)
228
+ function getMajorVersionMax() external view returns (VersionPart) {
229
+ return _majorVersion;
230
+ }
231
+
232
+ /// @dev latest active GIF release version
233
+ function getMajorVersion() external view returns (VersionPart) {
234
+ return _majorVersion;
235
+ }
236
+
237
+
273
238
  function getObjectCount() external view override returns (uint256) {
274
-
275
239
  return _chainNft.totalSupply();
276
240
  }
277
241
 
242
+ function getNftId() external view returns (NftId nftId) {
243
+ return _registryNftId;
244
+ }
245
+
278
246
  function getNftId(address object) external view override returns (NftId id) {
279
247
  return _nftIdByAddress[object];
280
248
  }
@@ -305,6 +273,10 @@ contract Registry is
305
273
  return _nftIdByAddress[object].gtz();
306
274
  }
307
275
 
276
+ function isTokenActive(address token, VersionPart majorVersion) external view returns (bool) {
277
+ return _tokenIsActive[token][majorVersion];
278
+ }
279
+
308
280
  function getServiceName(NftId nftId) external view returns (string memory) {
309
281
  return _string[nftId];
310
282
  }
@@ -319,7 +291,7 @@ contract Registry is
319
291
  return _service[serviceNameHash][majorVersion];
320
292
  }
321
293
 
322
- function getChainNft() external view override returns (IChainNft) {
294
+ function getChainNft() external view override returns (ChainNft) {
323
295
  return _chainNft;
324
296
  }
325
297
 
@@ -327,16 +299,68 @@ contract Registry is
327
299
  return ownerOf(address(this));
328
300
  }
329
301
 
330
- // Internals, called only in constructor
302
+ // Internals
303
+
304
+ function _registerService(ObjectInfo memory info)
305
+ internal
306
+ {
307
+ (
308
+ string memory serviceName,
309
+ VersionPart majorVersion
310
+ ) = abi.decode(info.data, (string, VersionPart));
311
+ bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
312
+
313
+ // ensures consistency of service.getVersion() and majorVersion here
314
+ if(majorVersion != _majorVersion) {
315
+ revert InvalidServiceVersion(majorVersion);
316
+ }
317
+
318
+ if(_service[serviceNameHash][majorVersion] != address(0)) {
319
+ revert ServiceNameAlreadyRegistered(serviceName, majorVersion);
320
+ }
321
+
322
+ _string[info.nftId] = serviceName;
323
+ _service[serviceNameHash][majorVersion] = info.objectAddress;
324
+
325
+ emit LogServiceNameRegistration(serviceName, majorVersion);
326
+ }
327
+
328
+ /// @dev obtain interceptor address for this nft if applicable, address(0) otherwise
329
+ function _getInterceptor(
330
+ bool isInterceptor,
331
+ address objectAddress,
332
+ bool parentIsInterceptor,
333
+ address parentObjectAddress
334
+ )
335
+ internal
336
+ view
337
+ returns (address interceptor)
338
+ {
339
+ if (objectAddress == address(0)) {
340
+ if (parentIsInterceptor) {
341
+ return parentObjectAddress;
342
+ } else {
343
+ return address(0);
344
+ }
345
+ }
346
+
347
+ if (isInterceptor) {
348
+ return objectAddress;
349
+ }
350
+
351
+ return address(0);
352
+ }
353
+
354
+ // Internals called only in constructor
331
355
 
332
356
  /// @dev protocol registration used to anchor the dip ecosystem relations
333
357
  function _registerProtocol()
334
358
  internal
335
359
  {
336
- uint256 protocolId = _chainNftInternal.PROTOCOL_NFT_ID();
360
+ uint256 protocolId = _chainNft.PROTOCOL_NFT_ID();
337
361
  NftId protocolNftId = toNftId(protocolId);
338
362
 
339
- _chainNftInternal.mint(NFT_LOCK_ADDRESS, protocolId);
363
+ _chainNft.mint(NFT_LOCK_ADDRESS, protocolId);
340
364
 
341
365
  _info[protocolNftId] = ObjectInfo(
342
366
  protocolNftId,
@@ -354,22 +378,22 @@ contract Registry is
354
378
  function _registerRegistry(address registryOwner)
355
379
  internal
356
380
  {
357
- uint256 registryId = _chainNftInternal.calculateTokenId(2);
381
+ uint256 registryId = _chainNft.calculateTokenId(2);
358
382
  NftId registryNftId = toNftId(registryId);
359
383
 
360
384
  NftId parentNftId;
361
385
 
362
- if(registryId != _chainNftInternal.GLOBAL_REGISTRY_ID())
386
+ if(registryId != _chainNft.GLOBAL_REGISTRY_ID())
363
387
  {// we're not the global registry
364
388
  _registerGlobalRegistry();
365
- parentNftId = toNftId(_chainNftInternal.GLOBAL_REGISTRY_ID());
389
+ parentNftId = toNftId(_chainNft.GLOBAL_REGISTRY_ID());
366
390
  }
367
391
  else
368
392
  {// we are global registry
369
- parentNftId = toNftId(_chainNftInternal.PROTOCOL_NFT_ID());
393
+ parentNftId = toNftId(_chainNft.PROTOCOL_NFT_ID());
370
394
  }
371
395
 
372
- _chainNftInternal.mint(registryOwner, registryId);
396
+ _chainNft.mint(registryOwner, registryId);
373
397
 
374
398
  _info[registryNftId] = ObjectInfo(
375
399
  registryNftId,
@@ -389,15 +413,15 @@ contract Registry is
389
413
  function _registerGlobalRegistry()
390
414
  internal
391
415
  {
392
- uint256 globalRegistryId = _chainNftInternal.GLOBAL_REGISTRY_ID();
416
+ uint256 globalRegistryId = _chainNft.GLOBAL_REGISTRY_ID();
393
417
 
394
- _chainNftInternal.mint(NFT_LOCK_ADDRESS, globalRegistryId);
418
+ _chainNft.mint(NFT_LOCK_ADDRESS, globalRegistryId);
395
419
 
396
420
  NftId globalRegistryNftId = toNftId(globalRegistryId);
397
421
 
398
422
  _info[globalRegistryNftId] = ObjectInfo(
399
423
  globalRegistryNftId,
400
- toNftId(_chainNftInternal.PROTOCOL_NFT_ID()), // parent
424
+ toNftId(_chainNft.PROTOCOL_NFT_ID()), // parent
401
425
  REGISTRY(),
402
426
  false, // isInterceptor
403
427
  address(0), // objectAddress
@@ -409,10 +433,10 @@ contract Registry is
409
433
  function _registerRegistryService(address registryOwner)
410
434
  internal
411
435
  {
412
- uint256 serviceId = _chainNftInternal.calculateTokenId(REGISTRY_SERVICE_TOKEN_SEQUENCE_ID);
436
+ uint256 serviceId = _chainNft.calculateTokenId(REGISTRY_SERVICE_TOKEN_SEQUENCE_ID);
413
437
  NftId serviceNftId = toNftId(serviceId);
414
438
 
415
- _chainNftInternal.mint(registryOwner, serviceId);
439
+ _chainNft.mint(registryOwner, serviceId);
416
440
 
417
441
  _info[serviceNftId] = ObjectInfo(
418
442
  serviceNftId,
@@ -428,37 +452,11 @@ contract Registry is
428
452
 
429
453
  string memory serviceName = "RegistryService";
430
454
  bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
431
- _service[serviceNameHash][VersionLib.toVersionPart(MAJOR_VERSION_MIN)] = msg.sender;
455
+ _service[serviceNameHash][VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT)] = msg.sender;
432
456
  _string[serviceNftId] = serviceName;
433
457
  _serviceNftId = serviceNftId;
434
458
  }
435
459
 
436
- /// @dev obtain interceptor address for this nft if applicable, address(0) otherwise
437
- function _getInterceptor(
438
- bool isInterceptor,
439
- address objectAddress,
440
- bool parentIsInterceptor,
441
- address parentObjectAddress
442
- )
443
- internal
444
- view
445
- returns (address interceptor)
446
- {
447
- if (objectAddress == address(0)) {
448
- if (parentIsInterceptor) {
449
- return parentObjectAddress;
450
- } else {
451
- return address(0);
452
- }
453
- }
454
-
455
- if (isInterceptor) {
456
- return objectAddress;
457
- }
458
-
459
- return address(0);
460
- }
461
-
462
460
  /// @dev defines which object - parent types relations are allowed to register
463
461
  // IMPORTANT:
464
462
  // 1) EACH object type MUST have only one parent type across ALL mappings