@etherisc/gif-next 0.0.2-fb8d07b-779 → 0.0.2-fbe8e04-715

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/README.md +63 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +126 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +136 -10
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +88 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +28 -2
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +168 -11
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +144 -64
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  37. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  40. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  41. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
  42. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  44. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +981 -10
  45. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  46. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  47. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  48. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +6 -1
  49. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  50. package/artifacts/contracts/instance/Instance.sol/Instance.json +169 -139
  51. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  52. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +55 -32
  53. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  54. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  55. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  56. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +74 -40
  57. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  58. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +223 -75
  59. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  60. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +92 -32
  61. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  62. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  63. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +0 -19
  65. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  69. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  78. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +923 -0
  79. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  80. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +440 -0
  81. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
  83. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +16 -48
  85. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -33
  87. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  88. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +669 -0
  89. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  92. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +664 -0
  93. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +9 -71
  95. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -232
  97. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  98. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +984 -0
  99. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +464 -0
  101. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +20 -157
  103. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -45
  105. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  106. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +768 -0
  107. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  108. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
  109. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  110. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  111. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +2 -110
  112. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  113. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
  114. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  115. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/Registry.sol/Registry.json +35 -146
  117. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  118. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
  119. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  120. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +26 -34
  121. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  122. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
  123. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  124. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  125. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  131. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  132. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  133. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  134. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  135. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  137. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  138. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  139. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  141. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  143. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  145. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestService.sol/TestService.json +9 -9
  147. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  150. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  151. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  152. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  157. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  160. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  166. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  172. package/contracts/components/BaseComponent.sol +49 -8
  173. package/contracts/components/Distribution.sol +6 -3
  174. package/contracts/components/IBaseComponent.sol +6 -0
  175. package/contracts/components/IPoolComponent.sol +5 -1
  176. package/contracts/components/Pool.sol +40 -12
  177. package/contracts/components/Product.sol +41 -46
  178. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  179. package/contracts/instance/BundleManager.sol +129 -0
  180. package/contracts/instance/Cloneable.sol +46 -0
  181. package/contracts/instance/IInstance.sol +25 -4
  182. package/contracts/instance/IInstanceBase.sol +26 -0
  183. package/contracts/instance/IInstanceService.sol +5 -3
  184. package/contracts/instance/Instance.sol +40 -18
  185. package/contracts/instance/InstanceAccessManager.sol +6 -6
  186. package/contracts/instance/InstanceBase.sol +41 -0
  187. package/contracts/instance/InstanceReader.sol +9 -0
  188. package/contracts/instance/InstanceService.sol +116 -37
  189. package/contracts/instance/InstanceServiceManager.sol +6 -5
  190. package/contracts/instance/ObjectManager.sol +101 -0
  191. package/contracts/instance/base/ComponentServiceBase.sol +22 -75
  192. package/contracts/instance/module/ISetup.sol +3 -1
  193. package/contracts/instance/service/BundleService.sol +260 -0
  194. package/contracts/instance/service/BundleServiceManager.sol +54 -0
  195. package/contracts/instance/service/DistributionService.sol +40 -9
  196. package/contracts/instance/service/DistributionServiceManager.sol +6 -5
  197. package/contracts/instance/service/IBundleService.sol +45 -0
  198. package/contracts/instance/service/IPolicyService.sol +87 -0
  199. package/contracts/instance/service/IPoolService.sol +6 -23
  200. package/contracts/instance/service/IProductService.sol +6 -73
  201. package/contracts/instance/service/PolicyService.sol +508 -0
  202. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  203. package/contracts/instance/service/PoolService.sol +44 -113
  204. package/contracts/instance/service/PoolServiceManager.sol +6 -5
  205. package/contracts/instance/service/ProductService.sol +173 -0
  206. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  207. package/contracts/registry/IRegistry.sol +5 -18
  208. package/contracts/registry/IRegistryService.sol +28 -11
  209. package/contracts/registry/Registry.sol +4 -45
  210. package/contracts/registry/RegistryService.sol +30 -71
  211. package/contracts/shared/NftOwnable.sol +2 -4
  212. package/contracts/types/NftIdSet.sol +26 -24
  213. package/contracts/types/RoleId.sol +3 -0
  214. package/package.json +1 -1
  215. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  216. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  217. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  218. package/contracts/instance/AccessManagedSimple.sol +0 -115
  219. package/contracts/instance/AccessManagerSimple.sol +0 -692
@@ -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
  }
@@ -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
 
@@ -38,6 +38,9 @@ function PRODUCT_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRol
38
38
 
39
39
  function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10000); }
40
40
  function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10100); }
41
+ function PRODUCT_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10200); }
42
+ function POLICY_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10300); }
43
+ function BUNDLE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(10400); }
41
44
 
42
45
  function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(11000); }
43
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-fb8d07b-779",
3
+ "version": "0.0.2-fbe8e04-715",
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": {
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5933227f1dcc121773cf6c64af3bdc36.json"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5933227f1dcc121773cf6c64af3bdc36.json"
4
- }