@etherisc/gif-next 0.0.2-b9e9dc3-713 → 0.0.2-bc11089-288

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. package/README.md +67 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +155 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +177 -15
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +117 -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 +209 -16
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +179 -50
  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/Dummy.sol/LifeCycleModule.json +2 -2
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  35. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  37. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  39. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  40. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  41. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  42. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  43. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  44. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
  45. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  46. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1408 -22
  47. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  48. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  49. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  50. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +120 -0
  51. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  52. package/artifacts/contracts/instance/Instance.sol/Instance.json +200 -624
  53. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  54. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +283 -143
  55. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  56. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  57. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  58. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +202 -37
  59. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  60. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +344 -56
  61. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  62. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +97 -13
  63. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  64. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  65. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +40 -0
  67. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  69. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  70. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  71. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
  72. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  73. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  74. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +54 -22
  76. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  80. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  83. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +923 -0
  84. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  85. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +440 -0
  86. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +18 -18
  88. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  89. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +684 -0
  90. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  91. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +428 -0
  92. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  93. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +669 -0
  94. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  97. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +664 -0
  98. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +9 -71
  100. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -232
  102. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +984 -0
  104. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +464 -0
  106. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  107. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +718 -0
  108. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  109. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +428 -0
  110. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  111. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +768 -0
  112. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  113. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
  114. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  115. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +201 -0
  117. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  118. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -19
  119. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  120. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  121. package/artifacts/contracts/registry/Registry.sol/Registry.json +172 -49
  122. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  123. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -29
  124. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  125. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +47 -34
  126. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  127. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
  128. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  129. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  130. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  131. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  133. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  134. package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.json +1 -1
  135. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  138. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  139. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  140. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +4 -4
  142. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
  143. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
  144. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  145. package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +2 -2
  146. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  147. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  148. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  149. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  153. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  155. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestService.sol/TestService.json +11 -11
  157. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  158. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  160. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  161. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  162. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  163. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  164. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  169. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  171. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  172. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  178. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  180. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  185. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  187. package/contracts/components/BaseComponent.sol +73 -11
  188. package/contracts/components/Distribution.sol +15 -18
  189. package/contracts/components/IBaseComponent.sol +8 -0
  190. package/contracts/components/IDistributionComponent.sol +1 -0
  191. package/contracts/components/IPoolComponent.sol +5 -1
  192. package/contracts/components/Pool.sol +43 -31
  193. package/contracts/components/Product.sol +42 -47
  194. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  195. package/contracts/instance/BundleManager.sol +129 -0
  196. package/contracts/instance/Cloneable.sol +46 -0
  197. package/contracts/instance/IInstance.sol +41 -7
  198. package/contracts/instance/IInstanceBase.sol +26 -0
  199. package/contracts/instance/IInstanceService.sol +29 -8
  200. package/contracts/instance/Instance.sol +66 -226
  201. package/contracts/instance/InstanceAccessManager.sol +94 -78
  202. package/contracts/instance/InstanceBase.sol +41 -0
  203. package/contracts/instance/InstanceReader.sol +36 -1
  204. package/contracts/instance/InstanceService.sol +245 -47
  205. package/contracts/instance/InstanceServiceManager.sol +6 -5
  206. package/contracts/instance/ObjectManager.sol +101 -0
  207. package/contracts/instance/base/ComponentServiceBase.sol +44 -21
  208. package/contracts/instance/module/IAccess.sol +27 -17
  209. package/contracts/instance/module/IBundle.sol +1 -0
  210. package/contracts/instance/module/ISetup.sol +3 -0
  211. package/contracts/instance/service/BundleService.sol +260 -0
  212. package/contracts/instance/service/BundleServiceManager.sol +54 -0
  213. package/contracts/instance/service/ComponentOwnerService.sol +5 -5
  214. package/contracts/instance/service/DistributionService.sol +118 -0
  215. package/contracts/instance/service/DistributionServiceManager.sol +54 -0
  216. package/contracts/instance/service/IBundleService.sol +45 -0
  217. package/contracts/instance/service/IComponentOwnerService.sol +1 -1
  218. package/contracts/instance/service/IDistributionService.sol +1 -1
  219. package/contracts/instance/service/IPolicyService.sol +87 -0
  220. package/contracts/instance/service/IPoolService.sol +7 -24
  221. package/contracts/instance/service/IProductService.sol +7 -74
  222. package/contracts/instance/service/PolicyService.sol +508 -0
  223. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  224. package/contracts/instance/service/PoolService.sol +124 -0
  225. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  226. package/contracts/instance/service/ProductService.sol +173 -0
  227. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  228. package/contracts/registry/IRegistry.sol +26 -2
  229. package/contracts/registry/IRegistryService.sol +34 -19
  230. package/contracts/registry/Registry.sol +61 -36
  231. package/contracts/registry/RegistryService.sol +42 -124
  232. package/contracts/registry/RegistryServiceManager.sol +21 -5
  233. package/contracts/registry/TokenRegistry.sol +111 -0
  234. package/contracts/shared/ERC165.sol +6 -2
  235. package/contracts/{instance/base → shared}/IService.sol +3 -3
  236. package/contracts/shared/NftOwnable.sol +2 -4
  237. package/contracts/shared/Registerable.sol +1 -0
  238. package/contracts/shared/RegisterableUpgradable.sol +16 -0
  239. package/contracts/shared/Service.sol +55 -0
  240. package/contracts/test/TestService.sol +3 -5
  241. package/contracts/types/NftIdSet.sol +26 -24
  242. package/contracts/types/RoleId.sol +10 -1
  243. package/contracts/types/StateId.sol +4 -0
  244. package/contracts/types/Version.sol +4 -1
  245. package/package.json +1 -1
  246. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  247. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  248. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1119
  249. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  250. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  251. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
  252. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  253. package/contracts/instance/AccessManagedSimple.sol +0 -114
  254. package/contracts/instance/AccessManagerSimple.sol +0 -682
  255. package/contracts/instance/IAccessManagerSimple.sol +0 -391
  256. package/contracts/instance/base/ServiceBase.sol +0 -44
@@ -3,58 +3,267 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
5
5
 
6
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
7
- import {InstanceAccessManager} from "./InstanceAccessManager.sol";
8
6
  import {Instance} from "./Instance.sol";
7
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
9
8
  import {IInstanceService} from "./IInstanceService.sol";
10
- import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
9
+ import {InstanceReader} from "./InstanceReader.sol";
10
+ import {BundleManager} from "./BundleManager.sol";
11
11
  import {IRegistry} from "../registry/IRegistry.sol";
12
- import {IService} from "../../contracts/instance/base/IService.sol";
13
- import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
14
- import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
12
+ import {RegistryService} from "../registry/RegistryService.sol";
13
+ import {ChainNft} from "../registry/ChainNft.sol";
14
+ import {Service} from "../../contracts/shared/Service.sol";
15
+ import {IService} from "../shared/IService.sol";
16
+ import {NftId} from "../../contracts/types/NftId.sol";
17
+ import {RoleId} from "../types/RoleId.sol";
18
+ import {VersionLib} from "../types/Version.sol";
19
+ import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, POLICY_SERVICE_ROLE, BUNDLE_SERVICE_ROLE} from "../types/RoleId.sol";
15
20
 
16
- contract InstanceService is ServiceBase, IInstanceService {
21
+ contract InstanceService is Service, IInstanceService {
17
22
 
18
- address internal _registryAddress;
19
- address internal _accessManagerMaster;
20
- address internal _instanceAccessManagerMaster;
21
- address internal _instanceMaster;
23
+ address internal _masterInstanceAccessManager;
24
+ address internal _masterInstance;
25
+ address internal _masterInstanceReader;
26
+ address internal _masterInstanceBundleManager;
22
27
 
23
28
  // TODO update to real hash when instance is stable
24
29
  bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
25
30
  string public constant NAME = "InstanceService";
26
31
 
32
+ modifier onlyInstanceOwner(NftId instanceNftId) {
33
+ IRegistry registry = getRegistry();
34
+ ChainNft chainNft = registry.getChainNft();
35
+
36
+ if( msg.sender != chainNft.ownerOf(instanceNftId.toInt())) {
37
+ revert ErrorInstanceServiceNotInstanceOwner(msg.sender, instanceNftId);
38
+ }
39
+ _;
40
+ }
41
+
27
42
  function createInstanceClone()
28
43
  external
29
44
  returns (
30
- AccessManagerSimple am,
31
- InstanceAccessManager im,
32
- Instance i
45
+ InstanceAccessManager clonedAccessManager,
46
+ Instance clonedInstance,
47
+ NftId clonedInstanceNftId,
48
+ InstanceReader clonedInstanceReader,
49
+ BundleManager clonedBundleManager
33
50
  )
34
51
  {
35
- am = AccessManagerSimple(Clones.clone(_accessManagerMaster));
36
- im = InstanceAccessManager(Clones.clone(_instanceAccessManagerMaster));
37
- i = Instance(Clones.clone(_instanceMaster));
52
+ address instanceOwner = msg.sender;
53
+ IRegistry registry = getRegistry();
54
+ address registryAddress = address(registry);
55
+ NftId registryNftId = registry.getNftId(registryAddress);
56
+ address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
57
+ RegistryService registryService = RegistryService(registryServiceAddress);
58
+
59
+ // initially set the authority of the access managar to this (being the instance service).
60
+ // This will allow the instance service to bootstrap the authorizations of the instance
61
+ // and then transfer the ownership of the access manager to the instance owner once everything is setup
62
+ clonedAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
63
+ clonedAccessManager.__InstanceAccessManager_initialize(address(this));
64
+
65
+ clonedInstance = Instance(Clones.clone(_masterInstance));
66
+ clonedInstance.initialize(address(clonedAccessManager), registryAddress, registryNftId, msg.sender);
67
+ ( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
68
+ clonedInstanceNftId = info.nftId;
69
+
70
+ clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
71
+ clonedInstanceReader.initialize(registryAddress, clonedInstanceNftId);
72
+ clonedInstance.setInstanceReader(clonedInstanceReader);
73
+
74
+ clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
75
+ clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, clonedInstanceNftId);
76
+ clonedInstance.setBundleManager(clonedBundleManager);
77
+
78
+ // TODO amend setters with instance specific , policy manager ...
79
+
80
+ _grantInitialAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
81
+
82
+ // to complete setup switch instance ownership to the instance owner
83
+ // TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
84
+ clonedAccessManager.grantRole(ADMIN_ROLE(), instanceOwner);
85
+ clonedAccessManager.revokeRole(ADMIN_ROLE(), address(this));
86
+
87
+ emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
38
88
  }
39
89
 
40
- function setAccessManagerMaster(address accessManager) external {
41
- _accessManagerMaster = accessManager;
90
+ function _grantInitialAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
91
+ _createGifTargets(clonedAccessManager, clonedInstance, clonedBundleManager);
92
+ _grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstance);
93
+ _grantPoolServiceAuthorizations(clonedAccessManager, clonedInstance);
94
+ _grantProductServiceAuthorizations(clonedAccessManager, clonedInstance);
95
+ _grantPolicyServiceAuthorizations(clonedAccessManager, clonedInstance);
96
+ _grantBundleServiceAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
97
+ _grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance);
42
98
  }
43
99
 
44
- function setInstanceAccessManagerMaster(address instanceAccessManager) external {
45
- _instanceAccessManagerMaster = instanceAccessManager;
100
+ function _createGifTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
101
+ clonedAccessManager.createGifTarget(address(clonedInstance), "Instance");
102
+ clonedAccessManager.createGifTarget(address(clonedBundleManager), "BundleManager");
103
+ }
104
+
105
+ function _grantDistributionServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
106
+ // configure authorization for distribution service on instance
107
+ IRegistry registry = getRegistry();
108
+ address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
109
+ clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), address(distributionServiceAddress));
110
+ bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
111
+ instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
112
+ instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
113
+ clonedAccessManager.setTargetFunctionRole(
114
+ "Instance",
115
+ instanceDistributionServiceSelectors,
116
+ DISTRIBUTION_SERVICE_ROLE());
117
+ }
118
+
119
+ function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
120
+ // configure authorization for pool service on instance
121
+ address poolServiceAddress = _registry.getServiceAddress("PoolService", VersionLib.toVersion(3, 0, 0).toMajorPart());
122
+ clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
123
+ bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
124
+ instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
125
+ instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
126
+ clonedAccessManager.setTargetFunctionRole(
127
+ "Instance",
128
+ instancePoolServiceSelectors,
129
+ POOL_SERVICE_ROLE());
130
+ }
131
+
132
+ function _grantProductServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
133
+ // configure authorization for product service on instance
134
+ address productServiceAddress = _registry.getServiceAddress("ProductService", VersionLib.toVersion(3, 0, 0).toMajorPart());
135
+ clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
136
+ bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
137
+ instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
138
+ instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
139
+ instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
140
+ instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
141
+ instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
142
+ clonedAccessManager.setTargetFunctionRole(
143
+ "Instance",
144
+ instanceProductServiceSelectors,
145
+ PRODUCT_SERVICE_ROLE());
146
+ }
147
+
148
+ function _grantPolicyServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
149
+ // configure authorization for policy service on instance
150
+ address policyServiceAddress = _registry.getServiceAddress("PolicyService", VersionLib.toVersion(3, 0, 0).toMajorPart());
151
+ clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), address(policyServiceAddress));
152
+ bytes4[] memory instancePolicyServiceSelectors = new bytes4[](3);
153
+ instancePolicyServiceSelectors[0] = clonedInstance.createPolicy.selector;
154
+ instancePolicyServiceSelectors[1] = clonedInstance.updatePolicy.selector;
155
+ instancePolicyServiceSelectors[2] = clonedInstance.updatePolicyState.selector;
156
+ clonedAccessManager.setTargetFunctionRole(
157
+ "Instance",
158
+ instancePolicyServiceSelectors,
159
+ POLICY_SERVICE_ROLE());
160
+ }
161
+
162
+ function _grantBundleServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
163
+ // configure authorization for bundle service on instance
164
+ address bundleServiceAddress = _registry.getServiceAddress("BundleService", VersionLib.toVersion(3, 0, 0).toMajorPart());
165
+ clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
166
+ bytes4[] memory instanceBundleServiceSelectors = new bytes4[](2);
167
+ instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
168
+ instanceBundleServiceSelectors[1] = clonedInstance.updateBundle.selector;
169
+ clonedAccessManager.setTargetFunctionRole(
170
+ "Instance",
171
+ instanceBundleServiceSelectors,
172
+ BUNDLE_SERVICE_ROLE());
173
+
174
+ // configure authorization for bundle service on bundle manager
175
+ bytes4[] memory bundleManagerBundleServiceSelectors = new bytes4[](5);
176
+ bundleManagerBundleServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
177
+ bundleManagerBundleServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
178
+ bundleManagerBundleServiceSelectors[2] = clonedBundleManager.add.selector;
179
+ bundleManagerBundleServiceSelectors[3] = clonedBundleManager.lock.selector;
180
+ bundleManagerBundleServiceSelectors[4] = clonedBundleManager.unlock.selector;
181
+ clonedAccessManager.setTargetFunctionRole(
182
+ "BundleManager",
183
+ bundleManagerBundleServiceSelectors,
184
+ BUNDLE_SERVICE_ROLE());
46
185
  }
47
186
 
48
- function setInstanceMaster(address instance) external {
49
- _instanceMaster = instance;
187
+ function _grantInstanceServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
188
+ // configure authorization for instance service on instance
189
+ address instanceServiceAddress = _registry.getServiceAddress("InstanceService", VersionLib.toVersion(3, 0, 0).toMajorPart());
190
+ clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
191
+ bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
192
+ instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
193
+ clonedAccessManager.setTargetFunctionRole(
194
+ "Instance",
195
+ instanceInstanceServiceSelectors,
196
+ INSTANCE_SERVICE_ROLE());
50
197
  }
51
198
 
52
- function getAccessManagerMaster() external view returns (address) { return address(_accessManagerMaster); }
53
- function getInstanceAccessManagerMaster() external view returns (address) { return address(_instanceAccessManagerMaster); }
54
- function getInstanceMaster() external view returns (address) { return address(_instanceMaster); }
199
+ function setMasterInstance(address accessManagerAddress, address instanceAddress, address instanceReaderAddress, address bundleManagerAddress) external onlyOwner {
200
+ require(_masterInstanceAccessManager == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
201
+ require(_masterInstance == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
202
+ require(_masterInstanceBundleManager == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
203
+
204
+ require (accessManagerAddress != address(0), "ERROR:CRD-005:ACCESS_MANAGER_ZERO");
205
+ require (instanceAddress != address(0), "ERROR:CRD-006:INSTANCE_ZERO");
206
+ require (instanceReaderAddress != address(0), "ERROR:CRD-007:INSTANCE_READER_ZERO");
207
+ require (bundleManagerAddress != address(0), "ERROR:CRD-008:BUNDLE_MANAGER_ZERO");
208
+
209
+ Instance instance = Instance(instanceAddress);
210
+ InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
211
+ BundleManager bundleManager = BundleManager(bundleManagerAddress);
212
+
213
+ require(instance.authority() == accessManagerAddress, "ERROR:CRD-009:INSTANCE_AUTHORITY_MISMATCH");
214
+ require(instanceReader.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-010:INSTANCE_READER_INSTANCE_MISMATCH");
215
+ require(bundleManager.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-011:BUNDLE_MANAGER_INSTANCE_MISMATCH");
216
+
217
+ _masterInstanceAccessManager = accessManagerAddress;
218
+ _masterInstance = instanceAddress;
219
+ _masterInstanceReader = instanceReaderAddress;
220
+ _masterInstanceBundleManager = bundleManagerAddress;
221
+ }
222
+
223
+ function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
224
+ require(_masterInstanceReader != address(0), "ERROR:CRD-003:INSTANCE_READER_MASTER_NOT_SET");
225
+ require (instanceReaderAddress != address(0), "ERROR:CRD-012:INSTANCE_READER_ZERO");
226
+ require(instanceReaderAddress != _masterInstanceReader, "ERROR:CRD-014:INSTANCE_READER_MASTER_SAME_AS_NEW");
227
+
228
+ InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
229
+ require(instanceReader.getInstanceNftId() == Instance(_masterInstance).getNftId(), "ERROR:CRD-015:INSTANCE_READER_INSTANCE_MISMATCH");
230
+
231
+ _masterInstanceReader = instanceReaderAddress;
232
+ }
233
+
234
+ function upgradeInstanceReader(NftId instanceNftId) external {
235
+ IRegistry registry = getRegistry();
236
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
237
+ Instance instance = Instance(instanceInfo.objectAddress);
238
+ address owner = instance.getOwner();
239
+
240
+ if (msg.sender != owner) {
241
+ revert ErrorInstanceServiceRequestUnauhorized(msg.sender);
242
+ }
243
+
244
+ InstanceReader upgradedInstanceReaderClone = InstanceReader(Clones.clone(address(_masterInstanceReader)));
245
+ upgradedInstanceReaderClone.initialize(address(registry), instanceNftId);
246
+ instance.setInstanceReader(upgradedInstanceReaderClone);
247
+ }
248
+
249
+ function getMasterInstanceReader() external view returns (address) {
250
+ return _masterInstanceReader;
251
+ }
252
+
253
+ function getMasterInstance() external view returns (address) {
254
+ return _masterInstance;
255
+ }
256
+
257
+ function getMasterInstanceAccessManager() external view returns (address) {
258
+ return _masterInstanceAccessManager;
259
+ }
260
+
261
+ function getMasterInstanceBundleManager() external view returns (address) {
262
+ return _masterInstanceBundleManager;
263
+ }
55
264
 
56
265
  // From IService
57
- function getName() public pure override(IService, ServiceBase) returns(string memory) {
266
+ function getName() public pure override(IService, Service) returns(string memory) {
58
267
  return NAME;
59
268
  }
60
269
 
@@ -71,32 +280,21 @@ contract InstanceService is ServiceBase, IInstanceService {
71
280
  initializer
72
281
  virtual override
73
282
  {
74
- // bytes memory encodedConstructorArguments = abi.encode(
75
- // _registryAddress);
76
-
77
- // bytes memory instanceCreationCode = ContractDeployerLib.getCreationCode(
78
- // instanceByteCodeWithInitCode,
79
- // encodedConstructorArguments);
80
-
81
- // address instanceAddress = ContractDeployerLib.deploy(
82
- // instanceCreationCode,
83
- // INSTANCE_CREATION_CODE_HASH);
84
-
85
283
  address initialOwner = address(0);
86
- (_registryAddress, initialOwner) = abi.decode(data, (address, address));
87
-
88
- // // TODO register instance in registry
89
- IRegistry registry = IRegistry(_registryAddress);
90
- NftId registryNftId = registry.getNftId(_registryAddress);
91
-
92
- _initializeServiceBase(_registryAddress, registryNftId, initialOwner);
284
+ address registryAddress = address(0);
285
+ (registryAddress, initialOwner) = abi.decode(data, (address, address));
286
+ // TODO while InstanceService is not deployed in InstanceServiceManager constructor
287
+ // owner is InstanceServiceManager deployer
288
+ _initializeService(registryAddress, owner);
93
289
 
94
290
  _registerInterface(type(IService).interfaceId);
95
291
  _registerInterface(type(IInstanceService).interfaceId);
96
292
  }
97
293
 
98
- function getInstance() external view returns (Instance) {
99
- return Instance(address(this));
294
+ function hasRole(address account, RoleId role, address instanceAddress) public view returns (bool) {
295
+ Instance instance = Instance(instanceAddress);
296
+ InstanceAccessManager accessManager = instance.getInstanceAccessManager();
297
+ return accessManager.hasRole(role, account);
100
298
  }
101
299
  }
102
300
 
@@ -31,14 +31,15 @@ contract InstanceServiceManager is ProxyManager {
31
31
  Registry registry = Registry(registryAddress);
32
32
  address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
33
33
  RegistryService registryService = RegistryService(registryServiceAddress);
34
-
35
- registryService.registerService(_instanceService);
34
+ // TODO this must have a role or own nft to register service
35
+ //registryService.registerService(_instanceService);
36
36
  // RegistryService registryService = _instanceService.getRegistryService();
37
37
 
38
+ // TODO no nft to link yet
38
39
  // link ownership of instance service manager ot nft owner of instance service
39
- _linkToNftOwnable(
40
- address(registryAddress),
41
- address(_instanceService));
40
+ //_linkToNftOwnable(
41
+ // address(registryAddress),
42
+ // address(_instanceService));
42
43
 
43
44
  // implies that after this constructor call only upgrade functionality is available
44
45
  _isDeployed = true;
@@ -0,0 +1,101 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Cloneable} from "./Cloneable.sol";
5
+
6
+ import {IInstance} from "./IInstance.sol";
7
+ import {INSTANCE} from "../types/ObjectType.sol";
8
+ import {InstanceReader} from "./InstanceReader.sol";
9
+ import {IRegistry} from "../registry/IRegistry.sol";
10
+ import {LibNftIdSet} from "../types/NftIdSet.sol";
11
+ import {NftId} from "../types/NftId.sol";
12
+
13
+ contract ObjectManager is
14
+ Cloneable
15
+ {
16
+
17
+ event LogObjectManagerInitialized(NftId instanceNftId, address instanceReader);
18
+
19
+ error ErrorObjectManagerNftIdInvalid(NftId instanceNftId);
20
+ error ErrorObjectManagerAlreadyAdded(NftId componentNftId, NftId objectNftId);
21
+
22
+ mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _activeObjects;
23
+ mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _allObjects;
24
+ NftId internal _instanceNftId;
25
+ InstanceReader internal _instanceReader;
26
+
27
+ constructor() Cloneable() {
28
+ _instanceReader = InstanceReader(address(0));
29
+ }
30
+
31
+ /// @dev call to initialize MUST be made in the same transaction as cloning of the contract
32
+ function initialize(
33
+ address authority,
34
+ address registry,
35
+ NftId instanceNftId
36
+ )
37
+ external
38
+ {
39
+ initialize(authority, registry);
40
+
41
+ // check/handle instance nft id/instance reader
42
+ IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(instanceNftId);
43
+ if (instanceInfo.objectType != INSTANCE()) {
44
+ revert ErrorObjectManagerNftIdInvalid(instanceNftId);
45
+ }
46
+
47
+ IInstance instance = IInstance(instanceInfo.objectAddress);
48
+ _instanceReader = instance.getInstanceReader();
49
+ _instanceNftId = instanceNftId;
50
+
51
+ emit LogObjectManagerInitialized(instanceNftId, address(_instanceReader));
52
+ }
53
+
54
+ function getInstanceReader() external view returns (InstanceReader) {
55
+ return _instanceReader;
56
+ }
57
+
58
+ function getInstanceNftId() external view returns (NftId) {
59
+ return _instanceNftId;
60
+ }
61
+
62
+ function _add(NftId componentNftId, NftId objectNftId) internal {
63
+ LibNftIdSet.Set storage allSet = _allObjects[componentNftId];
64
+ LibNftIdSet.Set storage activeSet = _activeObjects[componentNftId];
65
+
66
+ LibNftIdSet.add(allSet, objectNftId);
67
+ LibNftIdSet.add(activeSet, objectNftId);
68
+ }
69
+
70
+ function _activate(NftId componentNftId, NftId objectNftId) internal {
71
+ LibNftIdSet.add(_activeObjects[componentNftId], objectNftId);
72
+ }
73
+
74
+ function _deactivate(NftId componentNftId, NftId objectNftId) internal {
75
+ LibNftIdSet.remove(_activeObjects[componentNftId], objectNftId);
76
+ }
77
+
78
+ function _objects(NftId componentNftId) internal view returns (uint256) {
79
+ return LibNftIdSet.size(_allObjects[componentNftId]);
80
+ }
81
+
82
+ function _contains(NftId componentNftId, NftId objectNftId) internal view returns (bool) {
83
+ return LibNftIdSet.contains(_allObjects[componentNftId], objectNftId);
84
+ }
85
+
86
+ function _getObject(NftId componentNftId, uint256 idx) internal view returns (NftId) {
87
+ return LibNftIdSet.getElementAt(_allObjects[componentNftId], idx);
88
+ }
89
+
90
+ function _activeObjs(NftId componentNftId) internal view returns (uint256) {
91
+ return LibNftIdSet.size(_activeObjects[componentNftId]);
92
+ }
93
+
94
+ function _isActive(NftId componentNftId, NftId objectNftId) internal view returns (bool) {
95
+ return LibNftIdSet.contains(_activeObjects[componentNftId], objectNftId);
96
+ }
97
+
98
+ function _getActiveObject(NftId componentNftId, uint256 idx) internal view returns (NftId) {
99
+ return LibNftIdSet.getElementAt(_activeObjects[componentNftId], idx);
100
+ }
101
+ }
@@ -4,26 +4,52 @@ pragma solidity ^0.8.19;
4
4
  import {IRegistry} from "../../registry/IRegistry.sol";
5
5
  import {IRegistryService} from "../../registry/IRegistryService.sol";
6
6
  import {IInstance} from "../../instance/IInstance.sol";
7
- import {ObjectType, INSTANCE, PRODUCT, POOL} from "../../types/ObjectType.sol";
7
+ import {ObjectType, INSTANCE, PRODUCT, POOL, DISTRIBUTION, ORACLE} from "../../types/ObjectType.sol";
8
8
  import {NftId, NftIdLib} from "../../types/NftId.sol";
9
+ import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../types/RoleId.sol";
9
10
 
10
- import {ServiceBase} from "./ServiceBase.sol";
11
+ import {BaseComponent} from "../../components/BaseComponent.sol";
12
+ import {Product} from "../../components/Product.sol";
13
+ import {INftOwnable} from "../../shared/INftOwnable.sol";
14
+ import {Service} from "../../shared/Service.sol";
15
+ import {InstanceService} from "../InstanceService.sol";
11
16
  import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
12
17
 
13
- abstract contract ComponentServiceBase is ServiceBase {
18
+ abstract contract ComponentServiceBase is Service {
14
19
 
15
- constructor(
16
- address registry,
17
- NftId registryNftId,
18
- address initialOwner
19
- )
20
- {
21
- _initializeServiceBase(registry, registryNftId, initialOwner);
20
+ error ExpectedRoleMissing(RoleId expected, address caller);
21
+ error ComponentTypeInvalid(ObjectType componentType);
22
+
23
+
24
+ /// @dev modifier to check if caller is a registered service
25
+ modifier onlyService() {
26
+ address caller = msg.sender;
27
+ require(getRegistry().isRegisteredService(caller), "ERROR_NOT_SERVICE");
28
+ _;
22
29
  }
23
30
 
31
+ // view functions
32
+
33
+ function getRegistryService() public view virtual returns (IRegistryService) {
34
+ address service = getRegistry().getServiceAddress("RegistryService", getMajorVersion());
35
+ return IRegistryService(service);
36
+ }
37
+
38
+ function getInstanceService() public view returns (InstanceService) {
39
+ return InstanceService(getRegistry().getServiceAddress("InstanceService", getMajorVersion()));
40
+ }
41
+
42
+ // internal view functions
43
+
44
+ function _getInstance(IRegistry.ObjectInfo memory compObjInfo) internal view returns (IInstance) {
45
+ IRegistry registry = getRegistry();
46
+ IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(compObjInfo.parentNftId);
47
+ return IInstance(instanceInfo.objectAddress);
48
+ }
24
49
 
25
50
  function _getAndVerifyComponentInfoAndInstance(
26
- ObjectType objectType
51
+ //address component,
52
+ ObjectType expectedType
27
53
  )
28
54
  internal
29
55
  view
@@ -32,18 +58,15 @@ abstract contract ComponentServiceBase is ServiceBase {
32
58
  IInstance instance
33
59
  )
34
60
  {
35
- NftId componentNftId = getRegistry().getNftId(msg.sender);
36
- require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
61
+ IRegistry registry = getRegistry();
62
+ //TODO redundant check -> just check type
63
+ //NftId componentNftId = registry.getNftId(component);
64
+ //require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
37
65
 
38
- info = getRegistry().getObjectInfo(componentNftId);
39
- require(info.objectType == objectType, "OBJECT_TYPE_INVALID");
66
+ info = registry.getObjectInfo(msg.sender);
67
+ require(info.objectType == expectedType, "OBJECT_TYPE_INVALID");
40
68
 
41
- address instanceAddress = getRegistry().getObjectInfo(info.parentNftId).objectAddress;
69
+ address instanceAddress = registry.getObjectInfo(info.parentNftId).objectAddress;
42
70
  instance = IInstance(instanceAddress);
43
71
  }
44
-
45
- function getRegistryService() public view virtual returns (IRegistryService) {
46
- address service = getRegistry().getServiceAddress("RegistryService", getMajorVersion());
47
- return IRegistryService(service);
48
- }
49
72
  }
@@ -5,34 +5,44 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
5
5
  import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
6
 
7
7
  import {RoleId} from "../../types/RoleId.sol";
8
+ import {Timestamp} from "../../types/Timestamp.sol";
8
9
 
9
10
  interface IAccess {
11
+
10
12
  struct RoleInfo {
11
13
  ShortString name;
12
14
  bool isCustom;
15
+ bool isLocked;
16
+ Timestamp createdAt;
17
+ Timestamp updatedAt;
13
18
  }
14
19
 
15
20
  struct TargetInfo {
16
21
  ShortString name;
17
22
  bool isCustom;
23
+ bool isLocked;
24
+ Timestamp createdAt;
25
+ Timestamp updatedAt;
18
26
  }
19
27
 
20
- error ErrorTargetAddressZero();
21
- error ErrorTargetAlreadyExists(address target, ShortString name);
22
- error ErrorTargetDoesNotExist(address target);
23
- error ErrorTargetNameEmpty(address target);
24
- error ErrorTargetNameExists(address target, address existingTarget, ShortString name);
25
-
26
- error ErrorRoleIdInvalid(RoleId roleId);
27
- error ErrorRoleIdTooBig(RoleId roleId);
28
- error ErrorRoleIdTooSmall(RoleId roleId);
29
- error ErrorRoleIdAlreadyExists(RoleId roleId, ShortString name);
30
- error ErrorRoleIdNotActive(RoleId roleId);
31
- error ErrorRoleNameEmpty(RoleId roleId);
32
- error ErrorRoleNameNotUnique(RoleId roleId, ShortString name);
33
- error ErrorRoleInvalidUpdate(RoleId roleId, bool isCustom);
34
- error ErrorGrantNonexstentRole(RoleId roleId);
35
- error ErrorRevokeNonexstentRole(RoleId roleId);
36
- error ErrorRenounceNonexstentRole(RoleId roleId);
28
+ error ErrorIAccessRoleIdInvalid(RoleId roleId);
29
+ error ErrorIAccessRoleIdTooBig(RoleId roleId);
30
+ error ErrorIAccessRoleIdTooSmall(RoleId roleId);
31
+ error ErrorIAccessRoleIdAlreadyExists(RoleId roleId, ShortString name);
32
+ error ErrorIAccessRoleIdNotActive(RoleId roleId);
33
+ error ErrorIAccessRoleNameEmpty(RoleId roleId);
34
+ error ErrorIAccessRoleNameNotUnique(RoleId roleId, ShortString name);
35
+ error ErrorIAccessRoleInvalidUpdate(RoleId roleId, bool isCustom);
36
+ error ErrorIAccessRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
37
+ error ErrorIAccessSetLockedForNonexstentRole(RoleId roleId);
38
+ error ErrorIAccessGrantNonexstentRole(RoleId roleId);
39
+ error ErrorIAccessRevokeNonexstentRole(RoleId roleId);
40
+ error ErrorIAccessRenounceNonexstentRole(RoleId roleId);
41
+
42
+ error ErrorIAccessTargetAddressZero();
43
+ error ErrorIAccessTargetAlreadyExists(address target, ShortString name);
44
+ error ErrorIAccessTargetNameEmpty(address target);
45
+ error ErrorIAccessTargetNameExists(address target, address existingTarget, ShortString name);
46
+ error ErrorIAccessSetLockedForNonexstentTarget(address target);
37
47
 
38
48
  }
@@ -13,6 +13,7 @@ interface IBundle {
13
13
  uint256 capitalAmount; // net investment capital + net premiums - payouts
14
14
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
15
15
  uint256 balanceAmount; // total amount of funds: capitalAmount + fees (balance >= captial)
16
+ uint256 lifetime;
16
17
  Timestamp expiredAt; // no new policies
17
18
  Timestamp closedAt; // no open policies, locked amount = 0
18
19
  }
@@ -20,6 +20,8 @@ interface ISetup {
20
20
  Fee poolFee; // pool fee on net premium
21
21
  Fee stakingFee; // pool fee on staked capital from investor
22
22
  Fee performanceFee; // pool fee on profits from capital investors
23
+ bool isIntercepting; // intercepts nft transfers (for products)
24
+ address wallet;
23
25
  }
24
26
 
25
27
  struct DistributionSetupInfo {
@@ -38,6 +40,7 @@ interface ISetup {
38
40
  Fee stakingFee; // pool fee on staked capital from investor
39
41
  Fee performanceFee; // pool fee on profits from capital investors
40
42
  bool isIntercepting; // intercepts nft transfers (for bundles)
43
+ bool isConfirmingApplication; // confirms applications before they are underwritten
41
44
  address wallet;
42
45
  }
43
46
  }