@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
@@ -8,6 +8,7 @@ import {StateId} from "../types/StateId.sol";
8
8
  import {RiskId} from "../types/RiskId.sol";
9
9
  import {VersionPart} from "../types/Version.sol";
10
10
  import {Key32} from "../types/Key32.sol";
11
+ import {RoleId} from "../types/RoleId.sol";
11
12
 
12
13
  import {IRegisterable} from "../shared/IRegisterable.sol";
13
14
 
@@ -16,83 +17,44 @@ import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
16
17
  import {InstanceAccessManager} from "./InstanceAccessManager.sol";
17
18
  import {BundleManager} from "./BundleManager.sol";
18
19
  import {InstanceReader} from "./InstanceReader.sol";
20
+ import {InstanceStore} from "./InstanceStore.sol";
21
+
22
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
23
+
24
+ import {IAccess} from "./module/IAccess.sol";
19
25
 
20
- import {IBundle} from "./module/IBundle.sol";
21
26
  import {IBundleService} from "./service/IBundleService.sol";
22
- import {IComponents} from "./module/IComponents.sol";
23
27
  import {IDistributionService} from "./service/IDistributionService.sol";
24
- import {InstanceAccessManager} from "./InstanceAccessManager.sol";
25
- import {IKeyValueStore} from "./base/IKeyValueStore.sol";
26
- import {IPolicy} from "./module/IPolicy.sol";
27
- import {IDistribution} from "./module/IDistribution.sol";
28
28
  import {IPolicyService} from "./service/IPolicyService.sol";
29
29
  import {IPoolService} from "./service/IPoolService.sol";
30
30
  import {IProductService} from "./service/IProductService.sol";
31
31
  import {IPolicyService} from "./service/IPolicyService.sol";
32
32
  import {IBundleService} from "./service/IBundleService.sol";
33
- import {IRisk} from "./module/IRisk.sol";
34
- import {ISetup} from "./module/ISetup.sol";
35
33
 
36
34
 
37
35
 
38
36
  interface IInstance is
39
37
  IRegisterable,
40
38
  ITransferInterceptor,
41
- IAccessManaged,
42
- IKeyValueStore
39
+ IAccessManaged
43
40
  {
41
+ function createRole(string memory roleName, string memory adminName) external returns (RoleId roleId, RoleId admin);
42
+ function grantRole(RoleId roleId, address account) external;
43
+ function revokeRole(RoleId roleId, address account) external;
44
+
45
+ function createTarget(address target, string memory name) external;
46
+ function setTargetFunctionRole(string memory targetName, bytes4[] calldata selectors, RoleId roleId) external;
47
+ function setTargetLocked(address target, bool locked) external;
48
+
44
49
  function getDistributionService() external view returns (IDistributionService);
45
50
  function getProductService() external view returns (IProductService);
46
51
  function getPoolService() external view returns (IPoolService);
47
52
  function getPolicyService() external view returns (IPolicyService);
48
53
  function getBundleService() external view returns (IBundleService);
49
54
 
50
- function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
51
- function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
52
- function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
53
-
54
- function createPoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info) external;
55
- function updatePoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info, StateId newState) external;
56
- function updatePoolSetupState(NftId poolNftId, StateId newState) external;
57
-
58
- function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external;
59
- function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external;
60
- function updateBundleState(NftId bundleNftId, StateId newState) external;
61
-
62
- function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
63
- function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external;
64
- function updateProductSetupState(NftId productNftId, StateId newState) external;
65
-
66
- function createDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info) external;
67
- function updateDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info, StateId newState) external;
68
- function updateDistributorTypeState(Key32 distributorKey, StateId newState) external;
69
-
70
- function createDistributor(NftId nftId, IDistribution.DistributorInfo memory info) external;
71
- function updateDistributor(NftId nftId, IDistribution.DistributorInfo memory info, StateId newState) external;
72
- function updateDistributorState(NftId nftId, StateId newState) external;
73
-
74
- function createReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo) external;
75
- function updateReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo, StateId newState) external;
76
- function updateReferralState(Key32 referralKey, StateId newState) external;
77
-
78
- function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external;
79
- function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external;
80
- function updateRiskState(RiskId riskId, StateId newState) external;
81
-
82
- function createApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy) external;
83
- function updateApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
84
- function updateApplicationState(NftId applicationNftId, StateId newState) external;
85
-
86
- function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
87
- function updatePolicyState(NftId policyNftId, StateId newState) external;
88
-
89
- // TODO add claims/payouts function to instance
90
- // function updateClaims(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
91
-
92
55
  function getMajorVersion() external pure returns (VersionPart majorVersion);
93
56
  function getInstanceReader() external view returns (InstanceReader);
94
57
  function getBundleManager() external view returns (BundleManager);
95
-
96
- function setInstanceAccessManager(InstanceAccessManager accessManager) external;
97
58
  function getInstanceAccessManager() external view returns (InstanceAccessManager);
59
+ function getInstanceStore() external view returns (InstanceStore);
98
60
  }
@@ -15,6 +15,7 @@ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
15
15
  import {Instance} from "./Instance.sol";
16
16
  import {InstanceReader} from "./InstanceReader.sol";
17
17
  import {BundleManager} from "./BundleManager.sol";
18
+ import {InstanceStore} from "./InstanceStore.sol";
18
19
 
19
20
  interface IInstanceService is IService {
20
21
 
@@ -33,11 +34,13 @@ interface IInstanceService is IService {
33
34
  error ErrorInstanceServiceInstanceAccessManagerZero();
34
35
  error ErrorInstanceServiceInstanceReaderZero();
35
36
  error ErrorInstanceServiceBundleManagerZero();
37
+ error ErrorInstanceServiceInstanceStoreZero();
36
38
 
37
39
  error ErrorInstanceServiceInstanceAuthorityMismatch();
38
40
  error ErrorInstanceServiceBundleManagerAuthorityMismatch();
39
41
  error ErrorInstanceServiceInstanceReaderInstanceMismatch2();
40
42
  error ErrorInstanceServiceBundleMangerInstanceMismatch();
43
+ error ErrorInstanceServiceInstanceStoreAuthorityMismatch();
41
44
 
42
45
  error ErrorInstanceServiceRequestUnauhorized(address caller);
43
46
  error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
@@ -46,7 +49,15 @@ interface IInstanceService is IService {
46
49
  error ErrorInstanceServiceInstanceComponentMismatch(NftId instanceNftId, NftId componentNftId);
47
50
  error ErrorInstanceServiceInvalidComponentType(address componentAddress, ObjectType expectedType, ObjectType componentType);
48
51
 
49
- event LogInstanceCloned(address clonedOzAccessManager, address clonedInstanceAccessManager, address clonedInstance, address clonedBundleManager, address clonedInstanceReader, NftId clonedInstanceNftId);
52
+ event LogInstanceCloned(
53
+ address clonedOzAccessManager,
54
+ address clonedInstanceAccessManager,
55
+ address clonedInstance,
56
+ address clonedInstanceStore,
57
+ address clonedBundleManager,
58
+ address clonedInstanceReader,
59
+ NftId clonedInstanceNftId
60
+ );
50
61
 
51
62
  function createInstanceClone()
52
63
  external
@@ -56,7 +67,8 @@ interface IInstanceService is IService {
56
67
  Instance clonedInstance,
57
68
  NftId instanceNftId,
58
69
  InstanceReader clonedInstanceReader,
59
- BundleManager clonedBundleManager
70
+ BundleManager clonedBundleManager,
71
+ InstanceStore clonedInstanceStore
60
72
  );
61
73
 
62
74
  function createGifTarget(
@@ -3,19 +3,14 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
5
 
6
- import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
7
6
  import {NftId} from "../types/NftId.sol";
8
- import {ClaimId} from "../types/ClaimId.sol";
9
- import {NumberId} from "../types/NumberId.sol";
10
7
  import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT, DISTRIBUTOR, DISTRIBUTOR_TYPE} from "../types/ObjectType.sol";
11
- import {RiskId, RiskIdLib} from "../types/RiskId.sol";
12
- import {RoleId, RoleIdLib, INSTANCE_ROLE, INSTANCE_OWNER_ROLE} from "../types/RoleId.sol";
13
- import {StateId, ACTIVE} from "../types/StateId.sol";
14
- import {TimestampLib} from "../types/Timestamp.sol";
8
+ import {RoleId, RoleIdLib, eqRoleId, ADMIN_ROLE, INSTANCE_ROLE, INSTANCE_OWNER_ROLE} from "../types/RoleId.sol";
15
9
  import {VersionPart, VersionPartLib} from "../types/Version.sol";
16
10
 
17
11
  import {ERC165} from "../shared/ERC165.sol";
18
12
  import {Registerable} from "../shared/Registerable.sol";
13
+ import {TokenHandler} from "../shared/TokenHandler.sol";
19
14
 
20
15
  import {IRegistry} from "../registry/IRegistry.sol";
21
16
 
@@ -23,6 +18,7 @@ import {IInstance} from "./IInstance.sol";
23
18
  import {InstanceReader} from "./InstanceReader.sol";
24
19
  import {InstanceAccessManager} from "./InstanceAccessManager.sol";
25
20
  import {BundleManager} from "./BundleManager.sol";
21
+ import {InstanceStore} from "./InstanceStore.sol";
26
22
 
27
23
  import {KeyValueStore} from "./base/KeyValueStore.sol";
28
24
 
@@ -39,29 +35,32 @@ import {IPoolService} from "./service/IPoolService.sol";
39
35
  import {IProductService} from "./service/IProductService.sol";
40
36
  import {IPolicyService} from "./service/IPolicyService.sol";
41
37
  import {IBundleService} from "./service/IBundleService.sol";
42
- import {TokenHandler} from "../shared/TokenHandler.sol";
43
- import {VersionPart, VersionPartLib} from "../types/Version.sol";
44
38
 
45
39
  contract Instance is
46
40
  IInstance,
47
41
  AccessManagedUpgradeable,
48
- Registerable,
49
- KeyValueStore
42
+ Registerable
50
43
  {
44
+ error InstanceErrorReaderInstanceMismatch(address expectedInstance, address foundInstance);
51
45
 
52
- uint256 public constant GIF_MAJOR_VERSION = 3;
46
+ error InstanceErrorBundleManagerAlreadySet();
47
+ error InstanceErrorBundleManagerAuthorityMismatch();
48
+ error InstanceErrorBundleManagerInstanceMismatch(address expectedInstance, address foundInstance);
49
+
50
+ error InstanceErrorAccessManagerAlreadySet();
51
+ error InstanceErrorAccessManagerAuthorityMismatch();
53
52
 
54
- uint64 public constant ADMIN_ROLE = type(uint64).min;
55
- uint64 public constant PUBLIC_ROLE = type(uint64).max;
56
- uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
53
+ error InstanceErrorInstanceStoreAlreadySet();
54
+ error InstanceErrorInstanceStoreAuthorityMismatch();
57
55
 
58
- uint32 public constant EXECUTION_DELAY = 0;
56
+ uint256 public constant GIF_MAJOR_VERSION = 3;
59
57
 
60
58
  bool private _initialized;
61
59
 
62
60
  InstanceAccessManager internal _accessManager;
63
61
  InstanceReader internal _instanceReader;
64
62
  BundleManager internal _bundleManager;
63
+ InstanceStore internal _instanceStore;
65
64
 
66
65
  modifier onlyChainNft() {
67
66
  if(msg.sender != getRegistry().getChainNftAddress()) {
@@ -71,168 +70,66 @@ contract Instance is
71
70
  }
72
71
 
73
72
  function initialize(address authority, address registryAddress, address initialOwner)
74
- public
73
+ external
75
74
  initializer()
76
75
  {
77
76
  __AccessManaged_init(authority);
78
77
 
79
78
  IRegistry registry = IRegistry(registryAddress);
80
79
  initializeRegisterable(registryAddress, registry.getNftId(), INSTANCE(), true, initialOwner, "");
81
- initializeLifecycle();
82
80
 
83
81
  registerInterface(type(IInstance).interfaceId);
84
82
  }
85
83
 
86
- //--- ProductSetup ------------------------------------------------------//
87
- function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external restricted() {
88
- create(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup));
89
- }
90
-
91
- function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external restricted() {
92
- update(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup), newState);
93
- }
94
-
95
- function updateProductSetupState(NftId productNftId, StateId newState) external restricted() {
96
- updateState(_toNftKey32(productNftId, PRODUCT()), newState);
97
- }
98
-
99
- //--- DistributionSetup ------------------------------------------------------//
100
- function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external restricted() {
101
- create(_toNftKey32(distributionNftId, DISTRIBUTION()), abi.encode(setup));
102
- }
103
-
104
- function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external restricted() {
105
- update(_toNftKey32(distributionNftId, DISTRIBUTION()), abi.encode(setup), newState);
106
- }
107
-
108
- function updateDistributionSetupState(NftId distributionNftId, StateId newState) external restricted() {
109
- updateState(_toNftKey32(distributionNftId, DISTRIBUTION()), newState);
110
- }
111
-
112
- //--- PoolSetup ------------------------------------------------------//
113
- function createPoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info) external restricted() {
114
- create(_toNftKey32(poolNftId, POOL()), abi.encode(info));
115
- }
116
-
117
- function updatePoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info, StateId newState) external restricted() {
118
- update(_toNftKey32(poolNftId, POOL()), abi.encode(info), newState);
119
- }
120
-
121
- function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
122
- updateState(_toNftKey32(poolNftId, POOL()), newState);
123
- }
124
-
125
- //--- DistributorType -------------------------------------------------------//
126
- function createDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info) external restricted() {
127
- create(distributorKey, abi.encode(info));
128
- }
129
-
130
- function updateDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info, StateId newState) external restricted() {
131
- update(distributorKey, abi.encode(info), newState);
132
- }
133
-
134
- function updateDistributorTypeState(Key32 distributorKey, StateId newState) external restricted() {
135
- updateState(distributorKey, newState);
136
- }
137
-
138
- //--- Distributor -------------------------------------------------------//
139
- function createDistributor(NftId nftId, IDistribution.DistributorInfo memory info) external restricted() {
140
- create(toDistributorKey32(nftId), abi.encode(info));
141
- }
142
-
143
- function updateDistributor(NftId nftId, IDistribution.DistributorInfo memory info, StateId newState) external restricted() {
144
- update(toDistributorKey32(nftId), abi.encode(info), newState);
145
- }
146
-
147
- function updateDistributorState(NftId nftId, StateId newState) external restricted() {
148
- updateState(toDistributorKey32(nftId), newState);
149
- }
150
-
151
- //--- Referral ----------------------------------------------------------//
152
- function createReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo) external restricted() {
153
- create(referralKey, abi.encode(referralInfo));
154
- }
155
-
156
- function updateReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo, StateId newState) external restricted() {
157
- update(referralKey, abi.encode(referralInfo), newState);
158
- }
159
-
160
- function updateReferralState(Key32 referralKey, StateId newState) external restricted() {
161
- updateState(referralKey, newState);
162
- }
163
-
164
- //--- Bundle ------------------------------------------------------------//
165
- function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external restricted() {
166
- create(toBundleKey32(bundleNftId), abi.encode(bundle));
167
- }
168
-
169
- function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external restricted() {
170
- update(toBundleKey32(bundleNftId), abi.encode(bundle), newState);
171
- }
84
+ //--- Roles ------------------------------------------------------------//
172
85
 
173
- function updateBundleState(NftId bundleNftId, StateId newState) external restricted() {
174
- updateState(toBundleKey32(bundleNftId), newState);
175
- }
176
-
177
- //--- Risk --------------------------------------------------------------//
178
- function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external restricted() {
179
- create(riskId.toKey32(), abi.encode(risk));
180
- }
181
-
182
- function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external restricted() {
183
- update(riskId.toKey32(), abi.encode(risk), newState);
184
- }
185
-
186
- function updateRiskState(RiskId riskId, StateId newState) external restricted() {
187
- updateState(riskId.toKey32(), newState);
188
- }
189
-
190
- //--- Application (Policy) ----------------------------------------------//
191
- function createApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy) external restricted() {
192
- create(toPolicyKey32(applicationNftId), abi.encode(policy));
193
- }
194
-
195
- function updateApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy, StateId newState) external restricted() {
196
- update(toPolicyKey32(applicationNftId), abi.encode(policy), newState);
197
- }
198
-
199
- function updateApplicationState(NftId applicationNftId, StateId newState) external restricted() {
200
- updateState(toPolicyKey32(applicationNftId), newState);
201
- }
202
-
203
- //--- Policy ------------------------------------------------------------//
204
- function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external restricted() {
205
- update(toPolicyKey32(policyNftId), abi.encode(policy), newState);
206
- }
207
-
208
- function updatePolicyState(NftId policyNftId, StateId newState) external restricted() {
209
- updateState(toPolicyKey32(policyNftId), newState);
86
+ function createRole(string memory roleName, string memory adminName)
87
+ external
88
+ restricted // INSTANCE_OWNER_ROLE
89
+ returns (RoleId roleId, RoleId admin)
90
+ {
91
+ (roleId, admin) = _accessManager.createRole(roleName, adminName);
210
92
  }
211
93
 
212
- //--- Claim -------------------------------------------------------------//
213
- function createClaim(NftId policyNftId, ClaimId claimId, IPolicy.ClaimInfo memory claim) external restricted() {
214
- create(toPolicyKey32(policyNftId), abi.encode(claim));
94
+ function grantRole(RoleId roleId, address account)
95
+ external
96
+ restricted // INSTANCE_OWNER_ROLE
97
+ {
98
+ _accessManager.grantRole(roleId, account);
215
99
  }
216
100
 
217
- function updateClaim(NftId policyNftId, ClaimId claimId, IPolicy.ClaimInfo memory claim, StateId newState) external restricted() {
218
- update(toPolicyKey32(policyNftId), abi.encode(claim), newState);
101
+ function revokeRole(RoleId roleId, address account)
102
+ external
103
+ restricted // INSTANCE_OWNER_ROLE
104
+ {
105
+ _accessManager.revokeRole(roleId, account);
219
106
  }
220
107
 
221
- function updateClaimState(NftId policyNftId, ClaimId claimId, StateId newState) external restricted() {
222
- updateState(toPolicyKey32(policyNftId), newState);
223
- }
108
+ //--- Targets ------------------------------------------------------------//
224
109
 
225
- //--- Payout ------------------------------------------------------------//
226
- function createPayout(NftId policyNftId, NumberId payoutId, IPolicy.PayoutInfo memory payout) external restricted() {
227
- create(toPolicyKey32(policyNftId), abi.encode(payout));
110
+ function createTarget(address target, string memory name)
111
+ external
112
+ restricted // INSTANCE_OWNER_ROLE
113
+ {
114
+ _accessManager.createTarget(target, name);
228
115
  }
229
116
 
230
- function updatePayout(NftId policyNftId, NumberId payoutId, IPolicy.PayoutInfo memory payout, StateId newState) external restricted() {
231
- update(toPolicyKey32(policyNftId), abi.encode(payout), newState);
117
+ function setTargetFunctionRole(
118
+ string memory targetName,
119
+ bytes4[] calldata selectors,
120
+ RoleId roleId
121
+ )
122
+ external
123
+ restricted // INSTANCE_OWNER_ROLE
124
+ {
125
+ _accessManager.setTargetFunctionRole(targetName, selectors, roleId);
232
126
  }
233
127
 
234
- function updatePayoutState(NftId policyNftId, StateId newState) external restricted() {
235
- updateState(toPolicyKey32(policyNftId), newState);
128
+ function setTargetLocked(address target, bool locked)
129
+ external
130
+ restricted // INSTANCE_OWNER_ROLE
131
+ {
132
+ _accessManager.setTargetLockedByInstance(target, locked);
236
133
  }
237
134
 
238
135
  //--- ITransferInterceptor ------------------------------------------------------------//
@@ -246,31 +143,6 @@ contract Instance is
246
143
  assert(_accessManager.grantRole(INSTANCE_OWNER_ROLE(), to) == true);
247
144
  }
248
145
 
249
- //--- internal view/pure functions --------------------------------------//
250
- function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
251
- return nftId.toKey32(objectType);
252
- }
253
-
254
- function toBundleKey32(NftId bundleNftId) public pure returns (Key32) {
255
- return bundleNftId.toKey32(BUNDLE());
256
- }
257
-
258
- function toPolicyKey32(NftId policyNftId) public pure returns (Key32) {
259
- return policyNftId.toKey32(POLICY());
260
- }
261
-
262
- function toDistributionKey32(NftId distNftId) public pure returns (Key32) {
263
- return distNftId.toKey32(DISTRIBUTION());
264
- }
265
-
266
- function toDistributorTypeKey32(NftId distNftId) public pure returns (Key32) {
267
- return distNftId.toKey32(DISTRIBUTOR_TYPE());
268
- }
269
-
270
- function toDistributorKey32(NftId distNftId) public pure returns (Key32) {
271
- return distNftId.toKey32(DISTRIBUTOR());
272
- }
273
-
274
146
  function getDistributionService() external view returns (IDistributionService) {
275
147
  return IDistributionService(getRegistry().getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
276
148
  }
@@ -292,7 +164,9 @@ contract Instance is
292
164
  }
293
165
 
294
166
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
295
- require(instanceReader.getInstance() == Instance(this), "InstanceReader instance mismatch");
167
+ if(instanceReader.getInstance() != Instance(this)) {
168
+ revert InstanceErrorReaderInstanceMismatch(address(this), address(instanceReader.getInstance()));
169
+ }
296
170
  _instanceReader = instanceReader;
297
171
  }
298
172
 
@@ -305,9 +179,15 @@ contract Instance is
305
179
  }
306
180
 
307
181
  function setBundleManager(BundleManager bundleManager) external restricted() {
308
- require(address(_bundleManager) == address(0), "BundleManager is set");
309
- require(bundleManager.getInstance() == Instance(this), "BundleManager instance mismatch");
310
- require(bundleManager.authority() == authority(), "BundleManager authority mismatch");
182
+ if(address(_bundleManager) != address(0)) {
183
+ revert InstanceErrorBundleManagerAlreadySet();
184
+ }
185
+ if(bundleManager.getInstance() != Instance(this)) {
186
+ revert InstanceErrorBundleManagerInstanceMismatch(address(this), address(bundleManager.getInstance()));
187
+ }
188
+ if(bundleManager.authority() != authority()) {
189
+ revert InstanceErrorBundleManagerAuthorityMismatch();
190
+ }
311
191
  _bundleManager = bundleManager;
312
192
  }
313
193
 
@@ -316,12 +196,32 @@ contract Instance is
316
196
  }
317
197
 
318
198
  function setInstanceAccessManager(InstanceAccessManager accessManager) external restricted {
319
- require(address(_accessManager) == address(0), "InstanceAccessManager is set");
320
- require(accessManager.authority() == authority(), "InstanceAccessManager authority mismatch");
199
+ if(address(_accessManager) != address(0)) {
200
+ revert InstanceErrorAccessManagerAlreadySet();
201
+ }
202
+ if(accessManager.authority() != authority()) {
203
+ revert InstanceErrorAccessManagerAuthorityMismatch();
204
+ }
321
205
  _accessManager = accessManager;
322
206
  }
323
207
 
324
208
  function getInstanceAccessManager() external view returns (InstanceAccessManager) {
325
209
  return _accessManager;
326
210
  }
327
- }
211
+
212
+ function setInstanceStore(InstanceStore instanceStore) external restricted {
213
+ if(address(_instanceStore) != address(0)) {
214
+ revert InstanceErrorInstanceStoreAlreadySet();
215
+ }
216
+ if(instanceStore.authority() != authority()) {
217
+ revert InstanceErrorInstanceStoreAuthorityMismatch();
218
+ }
219
+ _instanceStore = instanceStore;
220
+ }
221
+
222
+ function getInstanceStore() external view returns (InstanceStore) {
223
+ return _instanceStore;
224
+ }
225
+
226
+ //--- internal view/pure functions --------------------------------------//
227
+ }
@@ -73,7 +73,7 @@ contract InstanceAccessManager is
73
73
  _createRole(ADMIN_ROLE(), ADMIN_ROLE_NAME, IAccess.Type.Core);
74
74
  _createRole(PUBLIC_ROLE(), PUBLIC_ROLE_NAME, IAccess.Type.Core);
75
75
  _createRole(INSTANCE_ROLE(), INSTANCE_ROLE_NAME, IAccess.Type.Core);
76
- _createRole(INSTANCE_OWNER_ROLE(), INSTANCE_OWNER_ROLE_NAME, IAccess.Type.Gif);
76
+ _createRole(INSTANCE_OWNER_ROLE(), INSTANCE_OWNER_ROLE_NAME, IAccess.Type.Gif);// TODO should be of core type
77
77
 
78
78
  // assume `this` is already a member of ADMIN_ROLE
79
79
  EnumerableSet.add(_roleMembers[ADMIN_ROLE()], address(this));
@@ -142,6 +142,7 @@ contract InstanceAccessManager is
142
142
  _roleInfo[roleId].admin = admin;
143
143
  }
144
144
 
145
+ // TODO core role can be granted only to 1 member
145
146
  function grantRole(RoleId roleId, address member)
146
147
  public
147
148
  restrictedToRoleAdmin(roleId)
@@ -226,7 +227,7 @@ contract InstanceAccessManager is
226
227
  return _roleIds[idx];
227
228
  }
228
229
 
229
- // TODO now: for non existent name returns ADMIN_ROLE id
230
+ // TODO returns ADMIN_ROLE id for non existent name
230
231
  function getRoleIdForName(string memory name) external view returns (RoleId roleId) {
231
232
  return _roleIdForName[ShortStrings.toShortString(name)];
232
233
  }
@@ -250,7 +251,7 @@ contract InstanceAccessManager is
250
251
  _createTarget(target, name, IAccess.Type.Core);
251
252
  }
252
253
  // INSTANCE_SERVICE_ROLE
253
- // assume gif target is registered and belongs to the same instance as instance access manager
254
+ // TODO check for instance mismatch?
254
255
  function createGifTarget(address target, string memory name) external restricted()
255
256
  {
256
257
  if(!_registry.isRegistered(target)) {
@@ -268,27 +269,23 @@ contract InstanceAccessManager is
268
269
  {
269
270
  _createTarget(target, name, IAccess.Type.Custom);
270
271
  }
271
- // INSTANCE_SERVICE_ROLE
272
- // IMPORTANT: instance access manager MUST be of Core type -> otherwise will be locked forever
273
- function setTargetLocked(string memory targetName, bool locked)
272
+
273
+ // TODO instance owner locks component instead of revoking it access to the instance...
274
+ function setTargetLockedByService(address target, bool locked)
274
275
  external
275
- restricted()
276
+ restricted // INSTANCE_SERVICE_ROLE
276
277
  {
277
- ShortString nameShort = ShortStrings.toShortString(targetName);
278
- address target = _targetAddressForName[nameShort];
279
-
280
- if (target == address(0)) {
281
- revert IAccess.ErrorIAccessTargetDoesNotExist(nameShort);
282
- }
278
+ _setTargetLocked(target, locked);
279
+ }
283
280
 
284
- if(_targetInfo[target].ttype == IAccess.Type.Core) {
285
- revert IAccess.ErrorIAccessTargetTypeInvalid(nameShort, _targetInfo[target].ttype);
286
- }
287
- // TODO isLocked is redundant but makes getTargetInfo() faster
288
- _targetInfo[target].isLocked = locked;
289
- _accessManager.setTargetClosed(target, locked);
281
+ function setTargetLockedByInstance(address target, bool locked)
282
+ external
283
+ restricted // INSTANCE_ROLE
284
+ {
285
+ _setTargetLocked(target, locked);
290
286
  }
291
287
 
288
+
292
289
  // allowed combinations of roles and targets:
293
290
  //1) set core role for core target
294
291
  //2) set gif role for gif target
@@ -314,7 +311,7 @@ contract InstanceAccessManager is
314
311
 
315
312
  // not custom target
316
313
  if(_targetInfo[target].ttype == IAccess.Type.Custom) {
317
- revert IAccess.ErrorIAccessTargetTypeInvalid(nameShort, IAccess.Type.Custom);
314
+ revert IAccess.ErrorIAccessTargetTypeInvalid(target, IAccess.Type.Custom);
318
315
  }
319
316
 
320
317
  // not custom role
@@ -345,7 +342,7 @@ contract InstanceAccessManager is
345
342
 
346
343
  // not core target
347
344
  if(_targetInfo[target].ttype == IAccess.Type.Core) {
348
- revert IAccess.ErrorIAccessTargetTypeInvalid(nameShort, IAccess.Type.Core);
345
+ revert IAccess.ErrorIAccessTargetTypeInvalid(target, IAccess.Type.Core);
349
346
  }
350
347
 
351
348
  // not core role
@@ -356,8 +353,13 @@ contract InstanceAccessManager is
356
353
  _setTargetFunctionRole(target, nameShort, selectors, roleId);
357
354
  }
358
355
 
356
+ function getTargetAddress(string memory targetName) public view returns(address targetAddress) {
357
+ ShortString nameShort = ShortStrings.toShortString(targetName);
358
+ return _targetAddressForName[nameShort];
359
+ }
360
+
359
361
  function isTargetLocked(address target) public view returns (bool locked) {
360
- return _accessManager.isTargetClosed(target);
362
+ return _targetInfo[target].isLocked;
361
363
  }
362
364
 
363
365
  function targetExists(address target) public view returns (bool exists) {
@@ -492,6 +494,22 @@ contract InstanceAccessManager is
492
494
  }
493
495
  }
494
496
 
497
+ // IMPORTANT: instance access manager MUST be of Core type -> otherwise can be locked forever
498
+ function _setTargetLocked(address target, bool locked) internal
499
+ {
500
+ IAccess.Type targetType = _targetInfo[target].ttype;
501
+ if(target == address(0) || targetType == IAccess.Type.NotInitialized) {
502
+ revert IAccess.ErrorIAccessTargetDoesNotExist(target);
503
+ }
504
+
505
+ if(targetType == IAccess.Type.Core) {
506
+ revert IAccess.ErrorIAccessTargetTypeInvalid(target, targetType);
507
+ }
508
+
509
+ _targetInfo[target].isLocked = locked;
510
+ _accessManager.setTargetClosed(target, locked);
511
+ }
512
+
495
513
  function _setTargetFunctionRole(
496
514
  address target,
497
515
  ShortString name,
@@ -501,7 +519,7 @@ contract InstanceAccessManager is
501
519
  internal
502
520
  {
503
521
  if (target == address(0)) {
504
- revert IAccess.ErrorIAccessTargetDoesNotExist(name);
522
+ revert IAccess.ErrorIAccessTargetDoesNotExist(target);
505
523
  }
506
524
 
507
525
  if (!roleExists(roleId)) {