@etherisc/gif-next 0.0.2-cf68d0c-530 → 0.0.2-d10d6b3-916

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. package/README.md +43 -0
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +10 -62
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -52
  8. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +28 -2
  10. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.json +42 -19
  13. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  14. package/artifacts/contracts/components/Product.sol/Product.json +18 -64
  15. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +775 -0
  39. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  40. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  41. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1347 -93
  44. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  45. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +5 -0
  46. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  47. package/artifacts/contracts/instance/Instance.sol/Instance.json +176 -84
  48. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
  50. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +177 -38
  52. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +193 -50
  54. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +70 -26
  56. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  57. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +272 -0
  58. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +59 -0
  60. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  62. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
  74. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +100 -25
  76. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +30 -14
  78. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +167 -0
  82. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
  84. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +1049 -0
  86. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  87. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +464 -0
  88. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  89. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
  90. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  91. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -0
  92. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  93. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  94. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +2 -110
  95. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  96. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
  97. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  98. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  99. package/artifacts/contracts/registry/Registry.sol/Registry.json +35 -146
  100. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  101. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
  102. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  103. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +26 -34
  104. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  105. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
  106. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  107. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  108. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  109. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  110. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  111. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  112. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  113. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  114. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  115. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  116. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  117. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  118. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  119. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  120. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  121. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  122. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  123. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  124. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  125. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  126. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  127. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  128. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  129. package/artifacts/contracts/test/TestService.sol/TestService.json +9 -9
  130. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  131. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  132. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  133. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  134. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  135. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  136. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  137. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  138. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  139. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  140. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  141. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  142. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  143. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  144. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  145. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  146. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  147. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  148. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  149. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  155. package/contracts/components/Distribution.sol +12 -15
  156. package/contracts/components/IDistributionComponent.sol +0 -2
  157. package/contracts/components/IPoolComponent.sol +5 -1
  158. package/contracts/components/Pool.sol +35 -26
  159. package/contracts/components/Product.sol +33 -41
  160. package/contracts/instance/BundleManager.sol +129 -0
  161. package/contracts/instance/Cloneable.sol +46 -0
  162. package/contracts/instance/IInstance.sol +30 -7
  163. package/contracts/instance/IInstanceService.sol +3 -1
  164. package/contracts/instance/Instance.sol +26 -15
  165. package/contracts/instance/InstanceReader.sol +26 -1
  166. package/contracts/instance/InstanceService.sol +90 -16
  167. package/contracts/instance/InstanceServiceManager.sol +6 -5
  168. package/contracts/instance/ObjectManager.sol +95 -0
  169. package/contracts/instance/base/ComponentServiceBase.sol +96 -1
  170. package/contracts/instance/module/IBundle.sol +1 -0
  171. package/contracts/instance/module/ISetup.sol +3 -0
  172. package/contracts/instance/service/DistributionService.sol +12 -20
  173. package/contracts/instance/service/DistributionServiceManager.sol +6 -5
  174. package/contracts/instance/service/IPoolService.sol +16 -2
  175. package/contracts/instance/service/IProductService.sol +6 -3
  176. package/contracts/instance/service/PoolService.sol +287 -0
  177. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  178. package/contracts/instance/service/ProductService.sol +570 -0
  179. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  180. package/contracts/registry/IRegistry.sol +5 -18
  181. package/contracts/registry/IRegistryService.sol +28 -11
  182. package/contracts/registry/Registry.sol +4 -45
  183. package/contracts/registry/RegistryService.sol +30 -71
  184. package/contracts/shared/NftOwnable.sol +2 -4
  185. package/contracts/shared/Service.sol +1 -0
  186. package/contracts/types/NftIdSet.sol +26 -24
  187. package/contracts/types/RoleId.sol +2 -0
  188. package/package.json +1 -1
@@ -12,22 +12,39 @@ import {IBaseComponent} from "../components/IBaseComponent.sol";
12
12
 
13
13
  interface IRegistryService is IService {
14
14
 
15
- function registerService(IService service) external returns(IRegistry.ObjectInfo memory info, bytes memory data);
15
+ error SelfRegistration();
16
+ error NotRegistryOwner();
16
17
 
17
- function registerInstance(IRegisterable instance)
18
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
18
+ error NotService();
19
+ error NotInstance();
20
+ error NotProduct();
21
+ error NotPool();
22
+ error NotDistribution();
19
23
 
20
- function registerProduct(IBaseComponent product, address owner)
21
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
24
+ error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
25
+ error NotRegisterableOwner(address expectedOwner);
26
+ error RegisterableOwnerIsZero();
27
+ error RegisterableOwnerIsRegistered();
28
+ error InvalidInitialOwner(address initialOwner);
29
+ error InvalidAddress(address registerableAddress);
22
30
 
23
- function registerPool(IBaseComponent pool, address owner)
24
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
25
31
 
26
- function registerDistribution(IBaseComponent distribution, address owner)
27
- external returns(IRegistry.ObjectInfo memory info, bytes memory data);
32
+ function registerService(IService service) external returns(IRegistry.ObjectInfo memory info, bytes memory data);
28
33
 
29
- function registerPolicy(IRegistry.ObjectInfo memory info) external returns(NftId nftId); // -> easy to upgrade
34
+ function registerInstance(IRegisterable instance)
35
+ external returns(IRegistry.ObjectInfo memory info, bytes memory data);
30
36
 
31
- function registerBundle(IRegistry.ObjectInfo memory info) external returns(NftId nftId);
37
+ function registerProduct(IBaseComponent product, address owner)
38
+ external returns(IRegistry.ObjectInfo memory info, bytes memory data);
39
+
40
+ function registerPool(IBaseComponent pool, address owner)
41
+ external returns(IRegistry.ObjectInfo memory info, bytes memory data);
42
+
43
+ function registerDistribution(IBaseComponent distribution, address owner)
44
+ external returns(IRegistry.ObjectInfo memory info, bytes memory data);
45
+
46
+ function registerPolicy(IRegistry.ObjectInfo memory info) external returns(NftId nftId); // -> easy to upgrade
47
+
48
+ function registerBundle(IRegistry.ObjectInfo memory info) external returns(NftId nftId);
32
49
  }
33
50
 
@@ -30,6 +30,7 @@ contract Registry is
30
30
  {
31
31
  uint256 public constant GIF_MAJOR_VERSION_AT_DEPLOYMENT = 3;
32
32
  address public constant NFT_LOCK_ADDRESS = address(0x1);
33
+ uint256 public constant REGISTRY_TOKEN_SEQUENCE_ID = 2;
33
34
  uint256 public constant REGISTRY_SERVICE_TOKEN_SEQUENCE_ID = 3;
34
35
  string public constant EMPTY_URI = "";
35
36
 
@@ -38,18 +39,12 @@ contract Registry is
38
39
  mapping(NftId nftId => ObjectInfo info) internal _info;
39
40
  mapping(address object => NftId nftId) internal _nftIdByAddress;
40
41
 
41
- mapping(NftId registrator => mapping(
42
- ObjectType objectType => bool)) internal _isApproved;
43
-
44
42
  mapping(ObjectType objectType => mapping(
45
43
  ObjectType parentType => bool)) internal _isValidContractCombination;
46
44
 
47
45
  mapping(ObjectType objectType => mapping(
48
46
  ObjectType parentType => bool)) internal _isValidObjectCombination;
49
47
 
50
- mapping(address token => mapping(
51
- VersionPart majorVersion => bool isActive)) internal _tokenIsActive;
52
-
53
48
  mapping(NftId nftId => string name) internal _string;
54
49
  mapping(bytes32 serviceNameHash => mapping(
55
50
  VersionPart majorVersion => address service)) internal _service;
@@ -67,7 +62,6 @@ contract Registry is
67
62
  }
68
63
 
69
64
  modifier onlyRegistryService() {
70
-
71
65
  if(msg.sender != _info[_serviceNftId].objectAddress) {
72
66
  revert NotRegistryService();
73
67
  }
@@ -181,38 +175,6 @@ contract Registry is
181
175
 
182
176
  emit LogRegistration(info);
183
177
  }
184
-
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
191
- {
192
- // verify that token is registered
193
- ObjectInfo memory info = _info[_nftIdByAddress[token]];
194
- if (info.nftId.eqz()) {
195
- revert TokenNotRegistered(token);
196
- }
197
-
198
- // verify provided address is a registered token
199
- if (info.objectType != TOKEN()) {
200
- revert NotToken(token);
201
- }
202
-
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);
209
- }
210
-
211
- _tokenIsActive[token][majorVersion] = active;
212
-
213
- emit LogTokenStateSet(token, majorVersion, active);
214
- }
215
-
216
178
  /// @dev earliest GIF major version
217
179
  function getMajorVersionMin() external view returns (VersionPart) {
218
180
  return VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT);
@@ -233,7 +195,6 @@ contract Registry is
233
195
  function getMajorVersion() external view returns (VersionPart) {
234
196
  return _majorVersion;
235
197
  }
236
-
237
198
 
238
199
  function getObjectCount() external view override returns (uint256) {
239
200
  return _chainNft.totalSupply();
@@ -252,7 +213,6 @@ contract Registry is
252
213
  }
253
214
 
254
215
  function ownerOf(address contractAddress) public view returns (address) {
255
-
256
216
  return _chainNft.ownerOf(_nftIdByAddress[contractAddress].toInt());
257
217
  }
258
218
 
@@ -261,7 +221,6 @@ contract Registry is
261
221
  }
262
222
 
263
223
  function getObjectInfo(address object) external view override returns (ObjectInfo memory) {
264
-
265
224
  return _info[_nftIdByAddress[object]];
266
225
  }
267
226
 
@@ -273,8 +232,8 @@ contract Registry is
273
232
  return _nftIdByAddress[object].gtz();
274
233
  }
275
234
 
276
- function isTokenActive(address token, VersionPart majorVersion) external view returns (bool) {
277
- return _tokenIsActive[token][majorVersion];
235
+ function isRegisteredService(address object) external view override returns (bool) {
236
+ return _nftIdByAddress[object].gtz() && _info[_nftIdByAddress[object]].objectType == SERVICE();
278
237
  }
279
238
 
280
239
  function getServiceName(NftId nftId) external view returns (string memory) {
@@ -378,7 +337,7 @@ contract Registry is
378
337
  function _registerRegistry(address registryOwner)
379
338
  internal
380
339
  {
381
- uint256 registryId = _chainNft.calculateTokenId(2);
340
+ uint256 registryId = _chainNft.calculateTokenId(REGISTRY_TOKEN_SEQUENCE_ID);
382
341
  NftId registryNftId = toNftId(registryId);
383
342
 
384
343
  NftId parentNftId;
@@ -8,8 +8,6 @@ import {IRegistry} from "./IRegistry.sol";
8
8
  import {IInstance} from "../instance/IInstance.sol";
9
9
 
10
10
  import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
11
- // import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
12
- // import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
13
11
  import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
14
12
  import {IPoolComponent} from "../../contracts/components/IPoolComponent.sol";
15
13
  import {IProductComponent} from "../../contracts/components/IProductComponent.sol";
@@ -20,7 +18,7 @@ import {Versionable} from "../../contracts/shared/Versionable.sol";
20
18
  import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
21
19
 
22
20
  import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
23
- import {ObjectType, REGISTRY, SERVICE, PRODUCT, ORACLE, POOL, INSTANCE, DISTRIBUTION, POLICY, BUNDLE} from "../../contracts/types/ObjectType.sol";
21
+ import {ObjectType, REGISTRY, SERVICE, PRODUCT, ORACLE, POOL, INSTANCE, DISTRIBUTION, POLICY, BUNDLE, STAKE} from "../../contracts/types/ObjectType.sol";
24
22
  import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
25
23
  import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
26
24
  import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
@@ -30,7 +28,6 @@ import {Service} from "../shared/Service.sol";
30
28
  import {IService} from "../shared/IService.sol";
31
29
  import {IRegistryService} from "./IRegistryService.sol";
32
30
  import {Registry} from "./Registry.sol";
33
- import {ChainNft} from "./ChainNft.sol";
34
31
 
35
32
  contract RegistryService is
36
33
  AccessManagedUpgradeable,
@@ -39,22 +36,6 @@ contract RegistryService is
39
36
  {
40
37
  using NftIdLib for NftId;
41
38
 
42
- // TODO move errors to interface contract
43
- error SelfRegistration();
44
- error NotRegistryOwner();
45
-
46
- error NotService();
47
- error NotInstance();
48
- error NotProduct();
49
- error NotPool();
50
- error NotDistribution();
51
-
52
- error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
53
- error NotRegisterableOwner(address expectedOwner);
54
- error RegisterableOwnerIsZero();
55
- error RegisterableOwnerIsRegistered();
56
- error InvalidInitialOwner(address initialOwner);
57
- error InvalidAddress(address registerableAddress);
58
39
 
59
40
  // Initial value for constant variable has to be compile-time constant
60
41
  // TODO define types as constants?
@@ -74,9 +55,7 @@ contract RegistryService is
74
55
  // IMPORTANT: MUST NOT check owner before calling external contract
75
56
  function registerService(IService service)
76
57
  external
77
- // TODO restrict access - registryService.registerService must use accessmanager for checking permissions as
78
- // services are not always owned by registry owner - actually only registry service is owned by registry owner
79
-
58
+ restricted
80
59
  returns(
81
60
  IRegistry.ObjectInfo memory info,
82
61
  bytes memory data
@@ -95,17 +74,9 @@ contract RegistryService is
95
74
 
96
75
  info.nftId = _registry.register(info);
97
76
  service.linkToRegisteredNftId();
98
- return (
99
- info,
100
- data
101
- );
77
+ return (info, data);
102
78
  }
103
79
 
104
- // If msg.sender is approved service:
105
- // 1) add owner arg (service MUST pass it's msg.sender as owner)
106
- // 2) check service allowance
107
- // 3) comment self registrstion check
108
- //function registerInstance(IRegisterable instance, address owner)
109
80
  function registerInstance(IRegisterable instance)
110
81
  external
111
82
  returns(
@@ -125,10 +96,7 @@ contract RegistryService is
125
96
  info.nftId = _registry.register(info);
126
97
  instance.linkToRegisteredNftId(); // asume safe
127
98
 
128
- return (
129
- info,
130
- data
131
- );
99
+ return (info, data);
132
100
  }
133
101
 
134
102
  function registerProduct(IBaseComponent product, address owner)
@@ -149,16 +117,11 @@ contract RegistryService is
149
117
  data
150
118
  ) = _getAndVerifyContractInfo(product, PRODUCT(), owner);
151
119
 
152
- NftId serviceNftId = _registry.getNftId(msg.sender);
153
-
154
120
  info.nftId = _registry.register(info);
155
121
  // TODO unsafe, let component or its owner derive nftId latter, when state assumptions and modifications of GIF contracts are finished
156
122
  product.linkToRegisteredNftId();
157
123
 
158
- return (
159
- info,
160
- data
161
- );
124
+ return (info, data);
162
125
  }
163
126
 
164
127
  function registerPool(IBaseComponent pool, address owner)
@@ -178,15 +141,10 @@ contract RegistryService is
178
141
  data
179
142
  ) = _getAndVerifyContractInfo(pool, POOL(), owner);
180
143
 
181
- NftId serviceNftId = _registry.getNftId(msg.sender);
182
-
183
144
  info.nftId = _registry.register(info);
184
145
  pool.linkToRegisteredNftId();
185
146
 
186
- return (
187
- info,
188
- data
189
- );
147
+ return (info, data);
190
148
  }
191
149
 
192
150
  function registerDistribution(IBaseComponent distribution, address owner)
@@ -206,15 +164,10 @@ contract RegistryService is
206
164
  data
207
165
  ) = _getAndVerifyContractInfo(distribution, DISTRIBUTION(), owner);
208
166
 
209
- NftId serviceNftId = _registry.getNftId(msg.sender);
210
-
211
167
  info.nftId = _registry.register(info);
212
168
  distribution.linkToRegisteredNftId();
213
169
 
214
- return (
215
- info,
216
- data
217
- );
170
+ return (info, data);
218
171
  }
219
172
 
220
173
  function registerPolicy(IRegistry.ObjectInfo memory info)
@@ -222,8 +175,6 @@ contract RegistryService is
222
175
  restricted
223
176
  returns(NftId nftId)
224
177
  {
225
- NftId senderNftId = _registry.getNftId(msg.sender);
226
-
227
178
  _verifyObjectInfo(info, POLICY());
228
179
 
229
180
  nftId = _registry.register(info);
@@ -234,14 +185,20 @@ contract RegistryService is
234
185
  restricted
235
186
  returns(NftId nftId)
236
187
  {
237
-
238
- NftId senderNftId = _registry.getNftId(msg.sender);
239
-
240
188
  _verifyObjectInfo(info, BUNDLE());
241
189
 
242
190
  nftId = _registry.register(info);
243
191
  }
244
192
 
193
+ function registerStake(IRegistry.ObjectInfo memory info)
194
+ external
195
+ restricted
196
+ returns(NftId nftId)
197
+ {
198
+ _verifyObjectInfo(info, STAKE());
199
+
200
+ nftId = _registry.register(info);
201
+ }
245
202
 
246
203
  // From IService
247
204
  function getName() public pure override(IService, Service) returns(string memory) {
@@ -296,7 +253,6 @@ contract RegistryService is
296
253
  _registerInterface(type(IRegistryService).interfaceId);
297
254
  }
298
255
 
299
- // parent check done in registry because of approve()
300
256
  function _getAndVerifyContractInfo(
301
257
  IRegisterable registerable,
302
258
  ObjectType expectedType, // assume can be valid only
@@ -355,25 +311,28 @@ contract RegistryService is
355
311
  );
356
312
  }
357
313
 
358
- // parent checks done in registry because of approve()
359
314
  function _verifyObjectInfo(
360
315
  IRegistry.ObjectInfo memory info,
361
- ObjectType objectType
316
+ ObjectType expectedType
362
317
  )
363
318
  internal
364
319
  view
365
320
  {
366
- if(info.objectAddress > address(0)) {
367
- revert InvalidAddress(info.objectAddress);
321
+ // enforce instead of check
322
+ info.objectAddress = address(0);
323
+
324
+ if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
325
+ revert UnexpectedRegisterableType(expectedType, info.objectType);
368
326
  }
369
327
 
370
- if(
371
- getRegistry().isRegistered(info.initialOwner) ||
372
- info.initialOwner == address(0)) {
373
- // TODO non registered address can register object(e.g. POLICY()) and then transfer associated nft to registered contract
374
- // what are motivations to do so?
375
- // at least registered contract can not register objects by itself, SERVICE,
376
- revert InvalidInitialOwner(info.initialOwner);
328
+ address owner = info.initialOwner;
329
+
330
+ if(owner == address(0)) {
331
+ revert RegisterableOwnerIsZero();
332
+ }
333
+
334
+ if(getRegistry().isRegistered(owner)) {
335
+ revert RegisterableOwnerIsRegistered();
377
336
  }
378
337
 
379
338
  // can catch all 3 if check that initialOwner is not registered
@@ -13,10 +13,7 @@ contract NftOwnable is INftOwnable {
13
13
 
14
14
  /// @dev enforces msg.sender is owner of nft (or initial owner of nft ownable)
15
15
  modifier onlyOwner() {
16
- address owner = getOwner();
17
-
18
- // owner == address(0) is eg uninitialized upgradable contract
19
- if (owner != address(0) && msg.sender != owner) {
16
+ if (msg.sender != getOwner()) {
20
17
  revert ErrorNotOwner(msg.sender);
21
18
  }
22
19
  _;
@@ -77,6 +74,7 @@ contract NftOwnable is INftOwnable {
77
74
  internal
78
75
  virtual
79
76
  {
77
+ require(initialOwner > address(0), "NftOwnable: initial owner is 0");
80
78
  _initialOwner = initialOwner;
81
79
  _setRegistry(registryAddress);
82
80
  }
@@ -36,6 +36,7 @@ abstract contract Service is
36
36
  address initialOwner
37
37
  )
38
38
  internal
39
+ virtual
39
40
  //onlyInitializing //TODO uncomment when "fully" upgradeable
40
41
  {
41
42
  // service must provide its name and version upon registration
@@ -11,35 +11,37 @@ library LibNftIdSet {
11
11
  mapping(NftId nftid => uint256 index) at;
12
12
  }
13
13
 
14
- function add(Set storage set, NftId nftId) external returns(bool added) {
15
- if (set.at[nftId] == 0) {
16
- set.ids.push(nftId);
17
- set.at[nftId] = set.ids.length;
18
- return true;
19
- } else {
20
- return false;
14
+ error ErrorNftIdSetAlreadyAdded(NftId nftId);
15
+ error ErrorNftIdSetNotInSet(NftId nftId);
16
+
17
+
18
+ function add(Set storage set, NftId nftId) external {
19
+ if (set.at[nftId] > 0) {
20
+ revert ErrorNftIdSetAlreadyAdded(nftId);
21
21
  }
22
+
23
+ set.ids.push(nftId);
24
+ set.at[nftId] = set.ids.length;
22
25
  }
23
26
 
24
- function remove(Set storage set, NftId nftId) external returns(bool removed) {
27
+ function remove(Set storage set, NftId nftId) external {
25
28
  uint256 nftIdIndex = set.at[nftId];
26
29
 
27
- if (nftIdIndex > 0) {
28
- uint256 toDeleteIndex = nftIdIndex - 1;
29
- uint256 lastIndex = set.ids.length - 1;
30
-
31
- if (lastIndex != toDeleteIndex) {
32
- NftId lastId = set.ids[lastIndex];
33
- set.ids[toDeleteIndex] = lastId;
34
- set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
35
- }
36
-
37
- set.ids.pop();
38
- delete set.at[nftId];
39
- return true;
40
- } else {
41
- return false;
30
+ if (nftIdIndex == 0) {
31
+ revert ErrorNftIdSetNotInSet(nftId);
42
32
  }
33
+
34
+ uint256 toDeleteIndex = nftIdIndex - 1;
35
+ uint256 lastIndex = set.ids.length - 1;
36
+
37
+ if (lastIndex != toDeleteIndex) {
38
+ NftId lastId = set.ids[lastIndex];
39
+ set.ids[toDeleteIndex] = lastId;
40
+ set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
41
+ }
42
+
43
+ set.ids.pop();
44
+ delete set.at[nftId];
43
45
  }
44
46
 
45
47
  function isEmpty(Set storage set) external view returns(bool empty) {
@@ -50,7 +52,7 @@ library LibNftIdSet {
50
52
  return set.at[nftId] > 0;
51
53
  }
52
54
 
53
- function getLength(Set storage set) external view returns(uint256 length) {
55
+ function size(Set storage set) external view returns(uint256 length) {
54
56
  return set.ids.length;
55
57
  }
56
58
 
@@ -37,6 +37,8 @@ function POOL_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId
37
37
  function PRODUCT_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1400); }
38
38
 
39
39
  function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10000); }
40
+ function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10100); }
41
+ function PRODUCT_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10200); }
40
42
 
41
43
  function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(11000); }
42
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-cf68d0c-530",
3
+ "version": "0.0.2-d10d6b3-916",
4
4
  "description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
5
5
  "main": "index.js",
6
6
  "scripts": {