@etherisc/gif-next 0.0.2-f034782-101 → 0.0.2-f080b71-868

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. package/README.md +6 -83
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +10 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +10 -0
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IComponent.sol/IComponent.json +100 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +100 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +110 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +100 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +20 -0
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +10 -0
  18. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
  19. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  20. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  21. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  22. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  23. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +214 -1988
  24. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  25. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +101 -14
  26. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  27. package/artifacts/contracts/instance/Instance.sol/Instance.json +379 -2729
  28. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  29. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +95 -58
  30. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +4 -0
  31. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +124 -0
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  33. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +45 -25
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +157 -126
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +30 -58
  38. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
  39. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2677 -0
  40. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  41. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  42. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +108 -21
  44. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
  48. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  50. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +6 -6
  52. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  59. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  60. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +119 -227
  61. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  62. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +11 -35
  63. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  64. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +330 -147
  65. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  66. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +70 -14
  67. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  68. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +127 -32
  69. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  70. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
  71. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +193 -386
  73. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  74. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +38 -74
  75. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +68 -149
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +163 -113
  79. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
  81. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +89 -231
  83. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +132 -24
  85. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +430 -14
  87. package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.dbg.json +4 -0
  88. package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.json +518 -0
  89. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
  91. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +210 -65
  93. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
  95. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +493 -48
  97. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +18 -14
  99. package/artifacts/contracts/instance/service/PricingService.sol/PricingService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/PricingService.sol/PricingService.json +988 -0
  101. package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.dbg.json +4 -0
  102. package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.json +689 -0
  103. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +139 -44
  105. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  106. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
  107. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  109. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  110. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -24
  111. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  112. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  114. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  115. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  116. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  117. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -36
  118. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  119. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
  120. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  121. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
  122. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  123. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  124. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  125. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  126. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  131. package/artifacts/contracts/shared/IService.sol/IService.json +80 -14
  132. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  133. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  134. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  135. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  136. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  137. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  138. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  139. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  140. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  141. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  142. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  143. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  144. package/artifacts/contracts/shared/Service.sol/Service.json +86 -15
  145. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  146. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  147. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  150. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  152. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  154. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
  156. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  158. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  159. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  160. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  161. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
  162. package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
  163. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  168. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
  170. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  172. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  174. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  175. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  176. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  179. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  182. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  184. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  186. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  192. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  193. package/contracts/components/Component.sol +4 -2
  194. package/contracts/components/IComponent.sol +3 -1
  195. package/contracts/components/Pool.sol +8 -4
  196. package/contracts/components/Product.sol +8 -5
  197. package/contracts/instance/IInstance.sol +16 -54
  198. package/contracts/instance/IInstanceService.sol +14 -2
  199. package/contracts/instance/Instance.sol +88 -188
  200. package/contracts/instance/InstanceAccessManager.sol +41 -23
  201. package/contracts/instance/InstanceAuthorizationsLib.sol +299 -0
  202. package/contracts/instance/InstanceReader.sol +15 -6
  203. package/contracts/instance/InstanceService.sol +59 -234
  204. package/contracts/instance/InstanceStore.sol +219 -0
  205. package/contracts/instance/base/ComponentService.sol +51 -38
  206. package/contracts/instance/base/KeyValueStore.sol +8 -3
  207. package/contracts/instance/module/IAccess.sol +2 -2
  208. package/contracts/instance/module/IBundle.sol +6 -4
  209. package/contracts/instance/module/IComponents.sol +6 -0
  210. package/contracts/instance/service/ApplicationService.sol +35 -202
  211. package/contracts/instance/service/BundleService.sol +165 -70
  212. package/contracts/instance/service/ClaimService.sol +2 -8
  213. package/contracts/instance/service/DistributionService.sol +30 -151
  214. package/contracts/instance/service/IApplicationService.sol +0 -18
  215. package/contracts/instance/service/IBundleService.sol +54 -22
  216. package/contracts/instance/service/IDistributionService.sol +1 -14
  217. package/contracts/instance/service/IPolicyService.sol +2 -0
  218. package/contracts/instance/service/IPoolService.sol +65 -1
  219. package/contracts/instance/service/IPricingService.sol +36 -0
  220. package/contracts/instance/service/PolicyService.sol +88 -115
  221. package/contracts/instance/service/PoolService.sol +136 -53
  222. package/contracts/instance/service/PricingService.sol +275 -0
  223. package/contracts/instance/service/PricingServiceManager.sol +51 -0
  224. package/contracts/instance/service/ProductService.sol +25 -56
  225. package/contracts/registry/IRegistryService.sol +4 -3
  226. package/contracts/registry/RegistryService.sol +25 -22
  227. package/contracts/registry/ReleaseManager.sol +20 -18
  228. package/contracts/shared/IService.sol +4 -6
  229. package/contracts/shared/Service.sol +21 -7
  230. package/contracts/test/TestService.sol +1 -1
  231. package/contracts/types/Amount.sol +60 -0
  232. package/contracts/types/Fee.sol +12 -5
  233. package/contracts/types/ObjectType.sol +4 -0
  234. package/package.json +1 -1
@@ -0,0 +1,299 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {ADMIN_ROLE, INSTANCE_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, APPLICATION_SERVICE_ROLE, POLICY_SERVICE_ROLE, CLAIM_SERVICE_ROLE, BUNDLE_SERVICE_ROLE, INSTANCE_ROLE} from "../types/RoleId.sol";
5
+ import {INSTANCE, BUNDLE, APPLICATION, POLICY, CLAIM, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
6
+ import {VersionPart} from "../types/Version.sol";
7
+
8
+ import {IRegistry} from "../registry/IRegistry.sol";
9
+
10
+ import {Instance} from "./Instance.sol";
11
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
12
+ import {InstanceReader} from "./InstanceReader.sol";
13
+ import {BundleManager} from "./BundleManager.sol";
14
+ import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
15
+ import {InstanceStore} from "./InstanceStore.sol";
16
+
17
+
18
+ library InstanceAuthorizationsLib
19
+ {
20
+ function grantInitialAuthorizations(
21
+ InstanceAccessManager clonedAccessManager,
22
+ Instance clonedInstance,
23
+ BundleManager clonedBundleManager,
24
+ InstanceStore clonedInstanceStore,
25
+ address instanceOwner,
26
+ IRegistry registry,
27
+ VersionPart majorVersion)
28
+ external
29
+ {
30
+ _createCoreAndGifRoles(clonedAccessManager);
31
+ _createCoreTargets(clonedAccessManager, clonedInstance, clonedBundleManager, clonedInstanceStore);
32
+ _grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstanceStore, registry, majorVersion);
33
+ _grantPoolServiceAuthorizations(clonedAccessManager, clonedInstanceStore, registry, majorVersion);
34
+ _grantProductServiceAuthorizations(clonedAccessManager, clonedInstanceStore, registry, majorVersion);
35
+ _grantApplicationServiceAuthorizations(clonedAccessManager, clonedInstanceStore, registry, majorVersion);
36
+ _grantPolicyServiceAuthorizations(clonedAccessManager, clonedInstanceStore, registry, majorVersion);
37
+ _grantClaimServiceAuthorizations(clonedAccessManager, clonedInstanceStore, registry, majorVersion);
38
+ _grantBundleServiceAuthorizations(clonedAccessManager, clonedInstanceStore, clonedBundleManager, registry, majorVersion);
39
+ _grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance, registry, majorVersion);
40
+ _grantInstanceAuthorizations(clonedAccessManager, registry, majorVersion);
41
+ _grantInstanceOwnerAuthorizations(clonedAccessManager, clonedInstance, registry, majorVersion);
42
+ }
43
+
44
+ function _createCoreAndGifRoles(InstanceAccessManager clonedAccessManager) private {
45
+ // default roles controlled by ADMIN_ROLE -> core roles
46
+ // all set/granted only once during cloning (the only exception is INSTANCE_OWNER_ROLE, hooked to instance nft)
47
+ clonedAccessManager.createCoreRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole");
48
+ clonedAccessManager.createCoreRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole");
49
+ clonedAccessManager.createCoreRole(POOL_SERVICE_ROLE(), "PoolServiceRole");
50
+ clonedAccessManager.createCoreRole(APPLICATION_SERVICE_ROLE(), "ApplicationServiceRole");
51
+ clonedAccessManager.createCoreRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole");
52
+ clonedAccessManager.createCoreRole(CLAIM_SERVICE_ROLE(), "ClaimServiceRole");
53
+ clonedAccessManager.createCoreRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole");
54
+ clonedAccessManager.createCoreRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole");
55
+ // default roles controlled by INSTANCE_OWNER_ROLE -> gif roles
56
+ clonedAccessManager.createGifRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole", INSTANCE_OWNER_ROLE());
57
+ clonedAccessManager.createGifRole(POOL_OWNER_ROLE(), "PoolOwnerRole", INSTANCE_OWNER_ROLE());
58
+ clonedAccessManager.createGifRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole", INSTANCE_OWNER_ROLE());
59
+ }
60
+
61
+ function _createCoreTargets(
62
+ InstanceAccessManager clonedAccessManager,
63
+ Instance clonedInstance,
64
+ BundleManager clonedBundleManager,
65
+ InstanceStore clonedInstanceStore)
66
+ private
67
+ {
68
+ clonedAccessManager.createCoreTarget(address(clonedAccessManager), "InstanceAccessManager");// TODO create in instance access manager initializer?
69
+ clonedAccessManager.createCoreTarget(address(clonedInstance), "Instance");// TODO create in instance access manager initializer?
70
+ clonedAccessManager.createCoreTarget(address(clonedBundleManager), "BundleManager");
71
+ clonedAccessManager.createCoreTarget(address(clonedInstanceStore), "InstanceStore");
72
+ }
73
+
74
+ function _grantDistributionServiceAuthorizations(
75
+ InstanceAccessManager clonedAccessManager,
76
+ InstanceStore clonedInstanceStore,
77
+ IRegistry registry,
78
+ VersionPart majorVersion)
79
+ private
80
+ {
81
+ // configure authorization for distribution service on instance
82
+ address distributionServiceAddress = registry.getServiceAddress(DISTRIBUTION(), majorVersion);
83
+ clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), distributionServiceAddress);
84
+ bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](11);
85
+ instanceDistributionServiceSelectors[0] = clonedInstanceStore.createDistributionSetup.selector;
86
+ instanceDistributionServiceSelectors[1] = clonedInstanceStore.updateDistributionSetup.selector;
87
+ instanceDistributionServiceSelectors[2] = clonedInstanceStore.createDistributorType.selector;
88
+ instanceDistributionServiceSelectors[3] = clonedInstanceStore.updateDistributorType.selector;
89
+ instanceDistributionServiceSelectors[4] = clonedInstanceStore.updateDistributorTypeState.selector;
90
+ instanceDistributionServiceSelectors[5] = clonedInstanceStore.createDistributor.selector;
91
+ instanceDistributionServiceSelectors[6] = clonedInstanceStore.updateDistributor.selector;
92
+ instanceDistributionServiceSelectors[7] = clonedInstanceStore.updateDistributorState.selector;
93
+ instanceDistributionServiceSelectors[8] = clonedInstanceStore.createReferral.selector;
94
+ instanceDistributionServiceSelectors[9] = clonedInstanceStore.updateReferral.selector;
95
+ instanceDistributionServiceSelectors[10] = clonedInstanceStore.updateReferralState.selector;
96
+ clonedAccessManager.setCoreTargetFunctionRole(
97
+ "InstanceStore",
98
+ instanceDistributionServiceSelectors,
99
+ DISTRIBUTION_SERVICE_ROLE());
100
+ }
101
+
102
+ function _grantPoolServiceAuthorizations(
103
+ InstanceAccessManager clonedAccessManager,
104
+ InstanceStore clonedInstanceStore,
105
+ IRegistry registry,
106
+ VersionPart majorVersion)
107
+ private
108
+ {
109
+ // configure authorization for pool service on instance
110
+ address poolServiceAddress = registry.getServiceAddress(POOL(), majorVersion);
111
+ clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
112
+ bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
113
+ instancePoolServiceSelectors[0] = clonedInstanceStore.createPoolSetup.selector;
114
+ instancePoolServiceSelectors[1] = clonedInstanceStore.updatePoolSetup.selector;
115
+ clonedAccessManager.setCoreTargetFunctionRole(
116
+ "InstanceStore",
117
+ instancePoolServiceSelectors,
118
+ POOL_SERVICE_ROLE());
119
+ }
120
+
121
+ function _grantProductServiceAuthorizations(
122
+ InstanceAccessManager clonedAccessManager,
123
+ InstanceStore clonedInstanceStore,
124
+ IRegistry registry,
125
+ VersionPart majorVersion)
126
+ private
127
+ {
128
+ // configure authorization for product service on instance
129
+ address productServiceAddress = registry.getServiceAddress(PRODUCT(), majorVersion);
130
+ clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
131
+ bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
132
+ instanceProductServiceSelectors[0] = clonedInstanceStore.createProductSetup.selector;
133
+ instanceProductServiceSelectors[1] = clonedInstanceStore.updateProductSetup.selector;
134
+ instanceProductServiceSelectors[2] = clonedInstanceStore.createRisk.selector;
135
+ instanceProductServiceSelectors[3] = clonedInstanceStore.updateRisk.selector;
136
+ instanceProductServiceSelectors[4] = clonedInstanceStore.updateRiskState.selector;
137
+ clonedAccessManager.setCoreTargetFunctionRole(
138
+ "InstanceStore",
139
+ instanceProductServiceSelectors,
140
+ PRODUCT_SERVICE_ROLE());
141
+ }
142
+
143
+ function _grantApplicationServiceAuthorizations(
144
+ InstanceAccessManager clonedAccessManager,
145
+ InstanceStore clonedInstanceStore,
146
+ IRegistry registry,
147
+ VersionPart majorVersion)
148
+ private
149
+ {
150
+ // configure authorization for application services on instance
151
+ address applicationServiceAddress = registry.getServiceAddress(APPLICATION(), majorVersion);
152
+ clonedAccessManager.grantRole(APPLICATION_SERVICE_ROLE(), applicationServiceAddress);
153
+ bytes4[] memory instanceApplicationServiceSelectors = new bytes4[](3);
154
+ instanceApplicationServiceSelectors[0] = clonedInstanceStore.createApplication.selector;
155
+ instanceApplicationServiceSelectors[1] = clonedInstanceStore.updateApplication.selector;
156
+ instanceApplicationServiceSelectors[2] = clonedInstanceStore.updateApplicationState.selector;
157
+ clonedAccessManager.setCoreTargetFunctionRole(
158
+ "InstanceStore",
159
+ instanceApplicationServiceSelectors,
160
+ APPLICATION_SERVICE_ROLE());
161
+ }
162
+
163
+ function _grantPolicyServiceAuthorizations(
164
+ InstanceAccessManager clonedAccessManager,
165
+ InstanceStore clonedInstanceStore,
166
+ IRegistry registry,
167
+ VersionPart majorVersion)
168
+ private
169
+ {
170
+ // configure authorization for policy services on instance
171
+ address policyServiceAddress = registry.getServiceAddress(POLICY(), majorVersion);
172
+ clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), policyServiceAddress);
173
+ bytes4[] memory instancePolicyServiceSelectors = new bytes4[](2);
174
+ instancePolicyServiceSelectors[0] = clonedInstanceStore.updatePolicy.selector;
175
+ instancePolicyServiceSelectors[1] = clonedInstanceStore.updatePolicyState.selector;
176
+ clonedAccessManager.setCoreTargetFunctionRole(
177
+ "InstanceStore",
178
+ instancePolicyServiceSelectors,
179
+ POLICY_SERVICE_ROLE());
180
+ }
181
+
182
+ function _grantClaimServiceAuthorizations(
183
+ InstanceAccessManager clonedAccessManager,
184
+ InstanceStore clonedInstanceStore,
185
+ IRegistry registry,
186
+ VersionPart majorVersion)
187
+ private
188
+ {
189
+ // configure authorization for claim/payout services on instance
190
+ address claimServiceAddress = registry.getServiceAddress(CLAIM(), majorVersion);
191
+ clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), claimServiceAddress);
192
+ // TODO add claims function authz
193
+ bytes4[] memory instanceClaimServiceSelectors = new bytes4[](0);
194
+ // instanceClaimServiceSelectors[0] = clonedInstanceStore.updatePolicy.selector;
195
+ // instanceClaimServiceSelectors[1] = clonedInstanceStore.updatePolicyState.selector;
196
+ clonedAccessManager.setCoreTargetFunctionRole(
197
+ "InstanceStore",
198
+ instanceClaimServiceSelectors,
199
+ CLAIM_SERVICE_ROLE());
200
+ }
201
+
202
+ function _grantBundleServiceAuthorizations(
203
+ InstanceAccessManager clonedAccessManager,
204
+ InstanceStore clonedInstanceStore,
205
+ BundleManager clonedBundleManager,
206
+ IRegistry registry,
207
+ VersionPart majorVersion)
208
+ private
209
+ {
210
+ // configure authorization for bundle service on instance
211
+ address bundleServiceAddress = registry.getServiceAddress(BUNDLE(), majorVersion);
212
+ clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
213
+ bytes4[] memory instanceBundleServiceSelectors = new bytes4[](3);
214
+ instanceBundleServiceSelectors[0] = clonedInstanceStore.createBundle.selector;
215
+ instanceBundleServiceSelectors[1] = clonedInstanceStore.updateBundle.selector;
216
+ instanceBundleServiceSelectors[2] = clonedInstanceStore.updateBundleState.selector;
217
+ clonedAccessManager.setCoreTargetFunctionRole(
218
+ "InstanceStore",
219
+ instanceBundleServiceSelectors,
220
+ BUNDLE_SERVICE_ROLE());
221
+
222
+ // configure authorization for bundle service on bundle manager
223
+ bytes4[] memory bundleManagerBundleServiceSelectors = new bytes4[](5);
224
+ bundleManagerBundleServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
225
+ bundleManagerBundleServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
226
+ bundleManagerBundleServiceSelectors[2] = clonedBundleManager.add.selector;
227
+ bundleManagerBundleServiceSelectors[3] = clonedBundleManager.lock.selector;
228
+ bundleManagerBundleServiceSelectors[4] = clonedBundleManager.unlock.selector;
229
+ clonedAccessManager.setCoreTargetFunctionRole(
230
+ "BundleManager",
231
+ bundleManagerBundleServiceSelectors,
232
+ BUNDLE_SERVICE_ROLE());
233
+ }
234
+
235
+ function _grantInstanceServiceAuthorizations(
236
+ InstanceAccessManager clonedAccessManager,
237
+ Instance clonedInstance,
238
+ IRegistry registry,
239
+ VersionPart majorVersion)
240
+ private
241
+ {
242
+ // configure authorization for instance service on instance
243
+ address instanceServiceAddress = registry.getServiceAddress(INSTANCE(), majorVersion);
244
+ clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
245
+ bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
246
+ instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
247
+ clonedAccessManager.setCoreTargetFunctionRole(
248
+ "Instance",
249
+ instanceInstanceServiceSelectors,
250
+ INSTANCE_SERVICE_ROLE());
251
+
252
+ // configure authorizations for instance service on instance access manager
253
+ bytes4[] memory accessManagerInstanceServiceSelectors = new bytes4[](3);
254
+ accessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
255
+ accessManagerInstanceServiceSelectors[1] = clonedAccessManager.setTargetLockedByService.selector;
256
+ accessManagerInstanceServiceSelectors[2] = clonedAccessManager.setCoreTargetFunctionRole.selector;
257
+ clonedAccessManager.setCoreTargetFunctionRole(
258
+ "InstanceAccessManager",
259
+ accessManagerInstanceServiceSelectors,
260
+ INSTANCE_SERVICE_ROLE());
261
+ }
262
+
263
+ function _grantInstanceAuthorizations(
264
+ InstanceAccessManager clonedAccessManager,
265
+ IRegistry registry,
266
+ VersionPart majorVersion)
267
+ private
268
+ {
269
+ bytes4[] memory accessManagerInstanceSelectors = new bytes4[](4);
270
+ accessManagerInstanceSelectors[0] = clonedAccessManager.createRole.selector;
271
+ accessManagerInstanceSelectors[1] = clonedAccessManager.createTarget.selector;
272
+ accessManagerInstanceSelectors[2] = clonedAccessManager.setTargetFunctionRole.selector;
273
+ accessManagerInstanceSelectors[3] = clonedAccessManager.setTargetLockedByInstance.selector;
274
+ clonedAccessManager.setCoreTargetFunctionRole(
275
+ "InstanceAccessManager",
276
+ accessManagerInstanceSelectors,
277
+ INSTANCE_ROLE());
278
+ }
279
+
280
+ function _grantInstanceOwnerAuthorizations(
281
+ InstanceAccessManager clonedAccessManager,
282
+ Instance clonedInstance,
283
+ IRegistry registry,
284
+ VersionPart majorVersion)
285
+ private
286
+ {
287
+ // configure authorization for instance owner on instance access manager
288
+ // instance owner role is granted/revoked ONLY by INSTANCE_ROLE
289
+ bytes4[] memory instanceInstanceOwnerSelectors = new bytes4[](4);
290
+ instanceInstanceOwnerSelectors[0] = clonedInstance.createRole.selector;
291
+ instanceInstanceOwnerSelectors[1] = clonedInstance.createTarget.selector;
292
+ instanceInstanceOwnerSelectors[2] = clonedInstance.setTargetFunctionRole.selector;
293
+ instanceInstanceOwnerSelectors[3] = clonedInstance.setTargetLocked.selector;
294
+ clonedAccessManager.setCoreTargetFunctionRole(
295
+ "Instance",
296
+ instanceInstanceOwnerSelectors,
297
+ INSTANCE_OWNER_ROLE());
298
+ }
299
+ }
@@ -27,22 +27,30 @@ import {ISetup} from "../instance/module/ISetup.sol";
27
27
  import {ITreasury} from "../instance/module/ITreasury.sol";
28
28
  import {TimestampLib} from "../types/Timestamp.sol";
29
29
 
30
+ import {InstanceStore} from "./InstanceStore.sol";
31
+
30
32
 
31
33
  contract InstanceReader {
34
+
35
+ error ErrorInstanceReaderAlreadyInitialized();
36
+ error ErrorInstanceReaderInstanceZero();
37
+
32
38
  bool private _initialized;
33
39
 
34
40
  IInstance internal _instance;
35
41
  IKeyValueStore internal _store;
36
42
 
37
43
  function initialize(address instance) public {
38
- require(!_initialized, "ERROR:CRD-000:ALREADY_INITIALIZED");
44
+ if(_initialized) {
45
+ revert ErrorInstanceReaderAlreadyInitialized();
46
+ }
39
47
 
40
- require(
41
- address(instance) != address(0),
42
- "ERROR:CRD-001:INSTANCE_ZERO");
48
+ if(instance == address(0)) {
49
+ revert ErrorInstanceReaderInstanceZero();
50
+ }
43
51
 
44
52
  _instance = IInstance(instance);
45
- _store = IKeyValueStore(instance);
53
+ _store = _instance.getInstanceStore();
46
54
 
47
55
  _initialized = true;
48
56
  }
@@ -66,7 +74,7 @@ contract InstanceReader {
66
74
  view
67
75
  returns (StateId state)
68
76
  {
69
- return _instance.getState(toPolicyKey(policyNftId));
77
+ return _store.getState(toPolicyKey(policyNftId));
70
78
  }
71
79
 
72
80
  function getRiskInfo(RiskId riskId)
@@ -148,6 +156,7 @@ contract InstanceReader {
148
156
  }
149
157
  }
150
158
 
159
+ // TODO consider to replace by component type specific getXyzInfo
151
160
  function getComponentInfo(NftId poolNftId)
152
161
  public
153
162
  view