@etherisc/gif-next 0.0.2-b97394c-442 → 0.0.2-b9e43cf-870

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. package/README.md +63 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +155 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +143 -86
  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 +26 -0
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +168 -113
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +141 -95
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  37. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  40. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  41. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +129 -0
  44. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  45. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  46. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  47. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +104 -14
  48. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  49. package/artifacts/contracts/instance/Instance.sol/Instance.json +98 -658
  50. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +244 -114
  52. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  53. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  54. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  56. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  57. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +183 -151
  58. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  59. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -74
  60. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  61. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  62. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +24 -32
  64. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  71. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  78. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1031 -0
  79. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  80. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +436 -0
  81. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +39 -52
  83. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +49 -72
  85. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -37
  87. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  88. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +720 -0
  89. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +13 -13
  91. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  93. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  94. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +771 -0
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -185
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -241
  99. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1156 -0
  101. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  102. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +492 -0
  103. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +38 -282
  105. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  106. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -53
  107. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  108. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +40 -410
  109. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  110. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -81
  111. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  112. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  113. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +132 -133
  115. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  116. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -65
  117. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  118. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  119. package/artifacts/contracts/registry/Registry.sol/Registry.json +145 -227
  120. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  121. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  122. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  123. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +30 -128
  124. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  125. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
  126. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  127. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +530 -0
  128. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  129. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
  130. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  131. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  132. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  133. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  134. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  135. package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
  136. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  139. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  140. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  141. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  142. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  143. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  144. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  145. package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
  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/Versionable.sol/Versionable.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  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 +31 -31
  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/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  166. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  168. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  169. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  175. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  179. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  181. package/contracts/components/BaseComponent.sol +79 -11
  182. package/contracts/components/Distribution.sol +2 -1
  183. package/contracts/components/IBaseComponent.sol +9 -0
  184. package/contracts/components/IPoolComponent.sol +4 -0
  185. package/contracts/components/Pool.sol +29 -4
  186. package/contracts/components/Product.sol +22 -10
  187. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  188. package/contracts/instance/BundleManager.sol +129 -0
  189. package/contracts/instance/Cloneable.sol +46 -0
  190. package/contracts/instance/IInstance.sol +9 -1
  191. package/contracts/instance/IInstanceBase.sol +26 -0
  192. package/contracts/instance/IInstanceService.sol +13 -3
  193. package/contracts/instance/Instance.sol +43 -214
  194. package/contracts/instance/InstanceAccessManager.sol +93 -78
  195. package/contracts/instance/InstanceBase.sol +41 -0
  196. package/contracts/instance/InstanceService.sol +247 -100
  197. package/contracts/instance/InstanceServiceManager.sol +5 -8
  198. package/contracts/instance/ObjectManager.sol +101 -0
  199. package/contracts/instance/base/ComponentServiceBase.sol +29 -87
  200. package/contracts/instance/module/IAccess.sol +27 -17
  201. package/contracts/instance/module/ISetup.sol +0 -1
  202. package/contracts/instance/service/BundleService.sol +294 -0
  203. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  204. package/contracts/instance/service/ComponentOwnerService.sol +4 -6
  205. package/contracts/instance/service/DistributionService.sol +53 -21
  206. package/contracts/instance/service/DistributionServiceManager.sol +6 -9
  207. package/contracts/instance/service/IBundleService.sol +44 -0
  208. package/contracts/instance/service/IPolicyService.sol +94 -0
  209. package/contracts/instance/service/IPoolService.sol +3 -26
  210. package/contracts/instance/service/IProductService.sol +2 -72
  211. package/contracts/instance/service/PolicyService.sol +539 -0
  212. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  213. package/contracts/instance/service/PoolService.sol +68 -127
  214. package/contracts/instance/service/PoolServiceManager.sol +5 -8
  215. package/contracts/instance/service/ProductService.sol +100 -448
  216. package/contracts/registry/ChainNft.sol +1 -1
  217. package/contracts/registry/IRegistry.sol +26 -16
  218. package/contracts/registry/IRegistryService.sol +13 -5
  219. package/contracts/registry/Registry.sol +149 -201
  220. package/contracts/registry/RegistryAccessManager.sol +210 -0
  221. package/contracts/registry/RegistryService.sol +50 -88
  222. package/contracts/registry/RegistryServiceManager.sol +18 -36
  223. package/contracts/registry/ReleaseManager.sol +342 -0
  224. package/contracts/registry/TokenRegistry.sol +5 -6
  225. package/contracts/shared/IService.sol +2 -1
  226. package/contracts/shared/ProxyManager.sol +1 -1
  227. package/contracts/shared/Service.sol +10 -7
  228. package/contracts/test/TestService.sol +3 -2
  229. package/contracts/types/NftIdSet.sol +26 -24
  230. package/contracts/types/RoleId.sol +10 -10
  231. package/package.json +1 -1
  232. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  233. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  234. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  235. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  236. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  237. package/contracts/instance/AccessManagedSimple.sol +0 -115
  238. package/contracts/instance/AccessManagerSimple.sol +0 -692
  239. package/contracts/instance/IAccessManagerSimple.sol +0 -391
@@ -10,21 +10,31 @@ import {IRegistry} from "../registry/IRegistry.sol";
10
10
  import {IRegisterable} from "../shared/IRegisterable.sol";
11
11
  import {IBaseComponent} from "../components/IBaseComponent.sol";
12
12
 
13
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
13
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
14
14
  import {Instance} from "./Instance.sol";
15
15
  import {InstanceReader} from "./InstanceReader.sol";
16
+ import {BundleManager} from "./BundleManager.sol";
16
17
 
17
18
  interface IInstanceService is IService {
18
19
 
20
+ error ErrorInstanceServiceRequestUnauhorized(address caller);
21
+ error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
22
+ error ErrorInstanceServiceComponentNotRegistered(address componentAddress);
23
+
19
24
  event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
20
25
 
21
26
  function createInstanceClone()
22
27
  external
23
28
  returns (
24
- AccessManagerSimple clonedAccessManager,
29
+ InstanceAccessManager clonedAccessManager,
25
30
  Instance clonedInstance,
26
31
  NftId instanceNftId,
27
- InstanceReader clonedInstanceReader
32
+ InstanceReader clonedInstanceReader,
33
+ BundleManager clonedBundleManager
28
34
  );
35
+
36
+ function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
37
+ function setTargetLocked(string memory targetName, bool locked) external;
38
+
29
39
  }
30
40
 
@@ -3,9 +3,9 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
5
  import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
+ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
7
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
6
8
 
7
- import {AccessManagedSimple} from "./AccessManagedSimple.sol";
8
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
9
9
  import {IAccess} from "./module/IAccess.sol";
10
10
  import {IBundle} from "./module/IBundle.sol";
11
11
  import {IPolicy} from "./module/IPolicy.sol";
@@ -15,12 +15,15 @@ import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
15
15
  import {KeyValueStore} from "./base/KeyValueStore.sol";
16
16
  import {IInstance} from "./IInstance.sol";
17
17
  import {InstanceReader} from "./InstanceReader.sol";
18
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
19
+ import {BundleManager} from "./BundleManager.sol";
18
20
  import {NftId} from "../types/NftId.sol";
19
21
  import {NumberId} from "../types/NumberId.sol";
20
- import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
22
+ import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT} from "../types/ObjectType.sol";
21
23
  import {RiskId, RiskIdLib} from "../types/RiskId.sol";
22
24
  import {RoleId, RoleIdLib} from "../types/RoleId.sol";
23
25
  import {StateId, ACTIVE} from "../types/StateId.sol";
26
+ import {TimestampLib} from "../types/Timestamp.sol";
24
27
  import {ERC165} from "../shared/ERC165.sol";
25
28
  import {Registerable} from "../shared/Registerable.sol";
26
29
  import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
@@ -28,14 +31,16 @@ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
28
31
  import {IDistributionService} from "./service/IDistributionService.sol";
29
32
  import {IPoolService} from "./service/IPoolService.sol";
30
33
  import {IProductService} from "./service/IProductService.sol";
34
+ import {IPolicyService} from "./service/IPolicyService.sol";
35
+ import {IBundleService} from "./service/IBundleService.sol";
31
36
  import {VersionPart} from "../types/Version.sol";
37
+ import {InstanceBase} from "./InstanceBase.sol";
32
38
 
33
39
  contract Instance is
34
- AccessManagedSimple,
35
- KeyValueStore,
40
+ AccessManagedUpgradeable,
36
41
  IInstance,
37
- ERC165,
38
- Registerable
42
+ // Initializable,
43
+ InstanceBase
39
44
  {
40
45
 
41
46
  uint64 public constant ADMIN_ROLE = type(uint64).min;
@@ -46,155 +51,26 @@ contract Instance is
46
51
 
47
52
  bool private _initialized;
48
53
 
49
- mapping(ShortString name => RoleId roleId) internal _role;
50
- mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
51
- RoleId [] internal _roles;
52
-
53
- mapping(ShortString name => address target) internal _target;
54
-
55
- AccessManagerSimple internal _accessManager;
54
+ InstanceAccessManager internal _accessManager;
56
55
  InstanceReader internal _instanceReader;
56
+ BundleManager internal _bundleManager;
57
57
 
58
- constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
58
+ function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner)
59
+ public
60
+ initializer
59
61
  {
60
- initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
61
- }
62
-
63
- function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
64
62
  require(!_initialized, "Contract instance has already been initialized");
65
63
 
66
- initializeAccessManagedSimple(accessManagerAddress);
64
+ __AccessManaged_init(accessManagerAddress);
67
65
 
68
- _accessManager = AccessManagerSimple(accessManagerAddress);
69
- _createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
70
- _createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
71
-
66
+ _accessManager = InstanceAccessManager(accessManagerAddress);
67
+
72
68
  _initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
73
69
 
74
70
  _registerInterface(type(IInstance).interfaceId);
75
71
  _initialized = true;
76
72
  }
77
73
 
78
- //--- Role ------------------------------------------------------//
79
- function createStandardRole(RoleId roleId, string memory name) external restricted() {
80
- _createRole(roleId, name, false, true);
81
- }
82
-
83
- function createCustomRole(RoleId roleId, string memory name) external restricted() {
84
- _createRole(roleId, name, true, true);
85
- }
86
-
87
- function updateRole(RoleId roleId, string memory name, StateId newState) external restricted() {
88
- (bool isCustom,) = _validateRoleParameters(roleId, name, false);
89
- IAccess.RoleInfo memory role = _toRole(roleId, name, isCustom);
90
- update(toRoleKey32(roleId), abi.encode(role), newState);
91
- }
92
-
93
- function updateRoleState(RoleId roleId, StateId newState) external restricted() {
94
- updateState(toRoleKey32(roleId), newState);
95
- }
96
-
97
- function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
98
- Key32 roleKey = toRoleKey32(roleId);
99
-
100
- if (!exists(roleKey)) {
101
- revert IAccess.ErrorGrantNonexstentRole(roleId);
102
- }
103
-
104
- if (getState(roleKey) != ACTIVE()) {
105
- revert IAccess.ErrorRoleIdNotActive(roleId);
106
- }
107
-
108
- if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
109
- _accessManager.grantRole(roleId.toInt(), member, EXECUTION_DELAY);
110
- EnumerableSet.add(_roleMembers[roleId], member);
111
- return true;
112
- }
113
-
114
- return false;
115
- }
116
-
117
- function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
118
- Key32 roleKey = toRoleKey32(roleId);
119
-
120
- if (!exists(roleKey)) {
121
- revert IAccess.ErrorRevokeNonexstentRole(roleId);
122
- }
123
-
124
- if (EnumerableSet.contains(_roleMembers[roleId], member)) {
125
- _accessManager.revokeRole(roleId.toInt(), member);
126
- EnumerableSet.remove(_roleMembers[roleId], member);
127
- return true;
128
- }
129
-
130
- return false;
131
- }
132
-
133
- /// @dev not restricted function by intention
134
- /// the restriction to role members is already enforced by the call to the access manger
135
- function renounceRole(RoleId roleId) external returns (bool revoked) {
136
- address member = msg.sender;
137
- Key32 roleKey = toRoleKey32(roleId);
138
-
139
- if (!exists(roleKey)) {
140
- revert IAccess.ErrorRenounceNonexstentRole(roleId);
141
- }
142
-
143
- if (EnumerableSet.contains(_roleMembers[roleId], member)) {
144
- _accessManager.renounceRole(roleId.toInt(), member);
145
- EnumerableSet.remove(_roleMembers[roleId], member);
146
- return true;
147
- }
148
-
149
- return false;
150
- }
151
-
152
- function roles() external view returns (uint256 numberOfRoles) {
153
- return _roles.length;
154
- }
155
-
156
- function getRoleId(uint256 idx) external view returns (RoleId roleId) {
157
- return _roles[idx];
158
- }
159
-
160
- function getRole(RoleId roleId) external view returns (IAccess.RoleInfo memory role) {
161
- return abi.decode(getData(roleId.toKey32()), (IAccess.RoleInfo));
162
- }
163
-
164
- function roleMembers(RoleId roleId) external view returns (uint256 numberOfMembers) {
165
- return EnumerableSet.length(_roleMembers[roleId]);
166
- }
167
-
168
- function getRoleMember(RoleId roleId, uint256 idx) external view returns (address roleMember) {
169
- return EnumerableSet.at(_roleMembers[roleId], idx);
170
- }
171
-
172
- function _createRole(RoleId roleId, string memory name, bool isCustom, bool validateParameters) internal {
173
- if (validateParameters) {
174
- _validateRoleParameters(roleId, name, isCustom);
175
- }
176
-
177
- IAccess.RoleInfo memory role = _toRole(roleId, name, isCustom);
178
- _role[role.name] = roleId;
179
- _roles.push(roleId);
180
-
181
- create(toRoleKey32(roleId), abi.encode(role));
182
- }
183
-
184
- //--- Target ------------------------------------------------------//
185
- function createTarget(address target, IAccess.TargetInfo memory targetInfo) external restricted() {
186
- _validateTargetParameters(target, targetInfo);
187
- create(toTargetKey32(target), abi.encode(targetInfo));
188
- }
189
-
190
- function setTargetClosed(address target, bool closed) external restricted() {
191
- if (!exists(toTargetKey32(target))) {
192
- revert IAccess.ErrorTargetDoesNotExist(target);
193
- }
194
-
195
- _accessManager.setTargetClosed(target, closed);
196
- }
197
-
198
74
  //--- ProductSetup ------------------------------------------------------//
199
75
  function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external restricted() {
200
76
  create(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup));
@@ -339,71 +215,6 @@ contract Instance is
339
215
  }
340
216
 
341
217
  //--- internal view/pure functions --------------------------------------//
342
- function _toRole(RoleId roleId, string memory name, bool isCustom)
343
- internal
344
- pure
345
- returns (IAccess.RoleInfo memory role)
346
- {
347
- return IAccess.RoleInfo(
348
- ShortStrings.toShortString(name),
349
- isCustom);
350
- }
351
-
352
- function _validateRoleParameters(
353
- RoleId roleId,
354
- string memory name,
355
- bool isCustom
356
- )
357
- internal
358
- view
359
- returns (
360
- bool roleExists,
361
- bool roleIsCustom
362
- )
363
- {
364
- Key32 roleKey = toRoleKey32(roleId);
365
- roleExists = exists(roleKey);
366
- if (roleExists) {
367
- roleIsCustom = abi.decode(getData(roleKey), (IAccess.RoleInfo)).isCustom;
368
- } else {
369
- roleIsCustom = isCustom;
370
- }
371
-
372
- // check role id
373
- uint64 roleIdInt = RoleId.unwrap(roleId);
374
- if(roleIdInt == ADMIN_ROLE || roleIdInt == PUBLIC_ROLE) {
375
- revert IAccess.ErrorRoleIdInvalid(roleId);
376
- }
377
-
378
- if (roleIsCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
379
- revert IAccess.ErrorRoleIdTooSmall(roleId);
380
- } else if (roleIsCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
381
- revert IAccess.ErrorRoleIdTooBig(roleId);
382
- }
383
-
384
- // role name checks
385
- ShortString nameShort = ShortStrings.toShortString(name);
386
- if (ShortStrings.byteLength(nameShort) == 0) {
387
- revert IAccess.ErrorRoleNameEmpty(roleId);
388
- }
389
-
390
- if (_role[nameShort] != RoleIdLib.zero() && _role[nameShort] != roleId) {
391
- revert IAccess.ErrorRoleNameNotUnique(_role[nameShort], nameShort);
392
- }
393
- }
394
-
395
- function _validateTargetParameters(address target, IAccess.TargetInfo memory targetInfo) internal view {
396
-
397
- }
398
-
399
- function toRoleKey32(RoleId roleId) public pure returns (Key32) {
400
- return roleId.toKey32();
401
- }
402
-
403
- function toTargetKey32(address target) public pure returns (Key32) {
404
- return Key32Lib.toKey32(TARGET(), KeyId.wrap(bytes20(target)));
405
- }
406
-
407
218
  function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
408
219
  return nftId.toKey32(objectType);
409
220
  }
@@ -417,27 +228,45 @@ contract Instance is
417
228
  }
418
229
 
419
230
  function getComponentOwnerService() external view returns (IComponentOwnerService) {
420
- return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
231
+ return ComponentOwnerService(_registry.getServiceAddress(COMPONENT(), VersionPart.wrap(3)));
421
232
  }
422
233
 
423
234
  function getDistributionService() external view returns (IDistributionService) {
424
- return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
235
+ return IDistributionService(_registry.getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
425
236
  }
426
237
 
427
238
  function getProductService() external view returns (IProductService) {
428
- return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
239
+ return IProductService(_registry.getServiceAddress(PRODUCT(), VersionPart.wrap(3)));
429
240
  }
430
241
 
431
242
  function getPoolService() external view returns (IPoolService) {
432
- return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
243
+ return IPoolService(_registry.getServiceAddress(POOL(), VersionPart.wrap(3)));
244
+ }
245
+
246
+ function getPolicyService() external view returns (IPolicyService) {
247
+ return IPolicyService(_registry.getServiceAddress(POLICY(), VersionPart.wrap(3)));
248
+ }
249
+
250
+ function getBundleService() external view returns (IBundleService) {
251
+ return IBundleService(_registry.getServiceAddress(BUNDLE(), VersionPart.wrap(3)));
433
252
  }
434
253
 
435
254
  function setInstanceReader(InstanceReader instanceReader) external restricted() {
436
- require(address(_instanceReader) == address(0), "InstanceReader is set");
255
+ require(instanceReader.getInstanceNftId() == getNftId(), "NFT ID of InstanceReader does not match");
437
256
  _instanceReader = instanceReader;
438
257
  }
439
258
 
440
259
  function getInstanceReader() external view returns (InstanceReader) {
441
260
  return _instanceReader;
442
261
  }
262
+
263
+ function setBundleManager(BundleManager bundleManager) external restricted() {
264
+ require(address(_bundleManager) == address(0), "BundleManager is set");
265
+ require(bundleManager.getInstanceNftId() == getNftId(), "NFT ID of BundleManager does not match");
266
+ _bundleManager = bundleManager;
267
+ }
268
+
269
+ function getBundleManager() external view returns (BundleManager) {
270
+ return _bundleManager;
271
+ }
443
272
  }
@@ -3,93 +3,53 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
5
  import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
6
7
 
7
- import {AccessManagedSimple} from "./AccessManagedSimple.sol";
8
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
9
- import {IBundle} from "./module/IBundle.sol";
10
- import {IPolicy} from "./module/IPolicy.sol";
11
- import {IRisk} from "./module/IRisk.sol";
12
- import {ISetup} from "./module/ISetup.sol";
13
- import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
14
- import {KeyValueStore} from "./base/KeyValueStore.sol";
15
- import {NftId} from "../types/NftId.sol";
16
- import {NumberId} from "../types/NumberId.sol";
17
- import {ObjectType, BUNDLE, DISTRIBUTION, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
18
- import {RiskId, RiskIdLib} from "../types/RiskId.sol";
19
- import {RoleId, RoleIdLib} from "../types/RoleId.sol";
20
- import {StateId, ACTIVE} from "../types/StateId.sol";
21
- import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
8
+ import {AccessManagerUpgradeableInitializeable} from "../../contracts/instance/AccessManagerUpgradeableInitializeable.sol";
9
+ import {RoleId, RoleIdLib } from "../types/RoleId.sol";
10
+ import {TimestampLib} from "../types/Timestamp.sol";
11
+ import {IAccess} from "./module/IAccess.sol";
22
12
 
23
13
  contract InstanceAccessManager is
24
- AccessManagedSimple
14
+ AccessManagedUpgradeable
25
15
  {
16
+ using RoleIdLib for RoleId;
17
+
26
18
  string public constant ADMIN_ROLE_NAME = "AdminRole";
27
19
  string public constant PUBLIC_ROLE_NAME = "PublicRole";
28
20
 
29
21
  uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
30
22
  uint32 public constant EXECUTION_DELAY = 0;
31
23
 
32
- struct RoleInfo {
33
- ShortString name;
34
- bool isCustom;
35
- bool isLocked;
36
- Timestamp createdAt;
37
- Timestamp updatedAt;
38
- }
39
-
40
- struct TargetInfo {
41
- ShortString name;
42
- bool isCustom;
43
- bool isLocked;
44
- Timestamp createdAt;
45
- Timestamp updatedAt;
46
- }
47
-
48
- error ErrorRoleIdInvalid(RoleId roleId);
49
- error ErrorRoleIdTooBig(RoleId roleId);
50
- error ErrorRoleIdTooSmall(RoleId roleId);
51
- error ErrorRoleIdAlreadyExists(RoleId roleId, ShortString name);
52
- error ErrorRoleIdNotActive(RoleId roleId);
53
- error ErrorRoleNameEmpty(RoleId roleId);
54
- error ErrorRoleNameNotUnique(RoleId roleId, ShortString name);
55
- error ErrorRoleInvalidUpdate(RoleId roleId, bool isCustom);
56
- error ErrorRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
57
- error ErrorSetLockedForNonexstentRole(RoleId roleId);
58
- error ErrorGrantNonexstentRole(RoleId roleId);
59
- error ErrorRevokeNonexstentRole(RoleId roleId);
60
- error ErrorRenounceNonexstentRole(RoleId roleId);
61
-
62
- error ErrorTargetAddressZero();
63
- error ErrorTargetAlreadyExists(address target, ShortString name);
64
- error ErrorTargetNameEmpty(address target);
65
- error ErrorTargetNameExists(address target, address existingTarget, ShortString name);
66
- error ErrorSetLockedForNonexstentTarget(address target);
67
-
68
24
  // role specific state
69
- mapping(RoleId roleId => RoleInfo info) internal _role;
25
+ mapping(RoleId roleId => IAccess.RoleInfo info) internal _role;
70
26
  mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
71
27
  mapping(ShortString name => RoleId roleId) internal _roleForName;
72
28
  RoleId [] internal _roles;
73
29
 
74
30
  // target specific state
75
- mapping(address target => TargetInfo info) internal _target;
31
+ mapping(address target => IAccess.TargetInfo info) internal _target;
76
32
  mapping(ShortString name => address target) internal _targetForName;
77
33
  address [] internal _targets;
78
34
 
79
- AccessManagerSimple internal _accessManager;
35
+ AccessManagerUpgradeableInitializeable internal _accessManager;
80
36
 
81
- constructor(address accessManager)
37
+ function __InstanceAccessManager_initialize(address initialAdmin) external initializer
82
38
  {
83
- _accessManager = AccessManagerSimple(accessManager);
84
- initializeAccessManagedSimple(accessManager);
39
+ // if size of the contract gets too large, this can be externalized which will reduce the contract size considerably
40
+ _accessManager = new AccessManagerUpgradeableInitializeable();
41
+ // this service required adin rights to access manager to be able to grant/revoke roles
42
+ _accessManager.__AccessManagerUpgradeableInitializeable_init(address(this));
43
+ _accessManager.grantRole(_accessManager.ADMIN_ROLE(), initialAdmin, 0);
44
+
45
+ __AccessManaged_init(address(_accessManager));
85
46
 
86
47
  _createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
87
48
  _createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
88
49
  }
89
50
 
90
51
  //--- Role ------------------------------------------------------//
91
-
92
- function createDefaultRole(RoleId roleId, string memory name) external restricted() {
52
+ function createGifRole(RoleId roleId, string memory name) external restricted() {
93
53
  _createRole(roleId, name, false, true);
94
54
  }
95
55
 
@@ -99,7 +59,7 @@ contract InstanceAccessManager is
99
59
 
100
60
  function setRoleLocked(RoleId roleId, bool locked) external restricted() {
101
61
  if (!roleExists(roleId)) {
102
- revert ErrorSetLockedForNonexstentRole(roleId);
62
+ revert IAccess.ErrorIAccessSetLockedForNonexstentRole(roleId);
103
63
  }
104
64
 
105
65
  _role[roleId].isLocked = locked;
@@ -112,11 +72,11 @@ contract InstanceAccessManager is
112
72
 
113
73
  function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
114
74
  if (!roleExists(roleId)) {
115
- revert ErrorGrantNonexstentRole(roleId);
75
+ revert IAccess.ErrorIAccessGrantNonexstentRole(roleId);
116
76
  }
117
77
 
118
78
  if (_role[roleId].isLocked) {
119
- revert ErrorRoleIdNotActive(roleId);
79
+ revert IAccess.ErrorIAccessRoleIdNotActive(roleId);
120
80
  }
121
81
 
122
82
  if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
@@ -130,7 +90,7 @@ contract InstanceAccessManager is
130
90
 
131
91
  function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
132
92
  if (!roleExists(roleId)) {
133
- revert ErrorRevokeNonexstentRole(roleId);
93
+ revert IAccess.ErrorIAccessRevokeNonexstentRole(roleId);
134
94
  }
135
95
 
136
96
  if (EnumerableSet.contains(_roleMembers[roleId], member)) {
@@ -148,7 +108,7 @@ contract InstanceAccessManager is
148
108
  address member = msg.sender;
149
109
 
150
110
  if (!roleExists(roleId)) {
151
- revert ErrorRenounceNonexstentRole(roleId);
111
+ revert IAccess.ErrorIAccessRenounceNonexstentRole(roleId);
152
112
  }
153
113
 
154
114
  if (EnumerableSet.contains(_roleMembers[roleId], member)) {
@@ -173,7 +133,7 @@ contract InstanceAccessManager is
173
133
  return _roleForName[ShortStrings.toShortString(name)];
174
134
  }
175
135
 
176
- function getRole(RoleId roleId) external view returns (RoleInfo memory role) {
136
+ function getRole(RoleId roleId) external view returns (IAccess.RoleInfo memory role) {
177
137
  return _role[roleId];
178
138
  }
179
139
 
@@ -190,13 +150,19 @@ contract InstanceAccessManager is
190
150
  }
191
151
 
192
152
  //--- Target ------------------------------------------------------//
153
+ function createGifTarget(address target, string memory name) external restricted() {
154
+ _createTarget(target, name, false, true);
155
+ }
156
+
193
157
  function createTarget(address target, string memory name) external restricted() {
194
158
  _createTarget(target, name, true, true);
195
159
  }
196
160
 
197
- function setTargetLocked(address target, bool locked) external restricted() {
198
- if (!targetExists(target)) {
199
- revert ErrorSetLockedForNonexstentTarget(target);
161
+ function setTargetLocked(string memory targetName, bool locked) external restricted() {
162
+ address target = _targetForName[ShortStrings.toShortString(targetName)];
163
+
164
+ if (target == address(0)) {
165
+ revert IAccess.ErrorIAccessSetLockedForNonexstentTarget(target);
200
166
  }
201
167
 
202
168
  _target[target].isLocked = locked;
@@ -214,7 +180,7 @@ contract InstanceAccessManager is
214
180
  _validateRoleParameters(roleId, name, isCustom);
215
181
  }
216
182
 
217
- RoleInfo memory role = RoleInfo(
183
+ IAccess.RoleInfo memory role = IAccess.RoleInfo(
218
184
  ShortStrings.toShortString(name),
219
185
  isCustom,
220
186
  false, // role un-locked,
@@ -233,35 +199,35 @@ contract InstanceAccessManager is
233
199
  )
234
200
  internal
235
201
  view
236
- returns (RoleInfo memory existingRole)
202
+ returns (IAccess.RoleInfo memory existingRole)
237
203
  {
238
204
  // check role id
239
205
  uint64 roleIdInt = RoleId.unwrap(roleId);
240
206
  if(roleIdInt == _accessManager.ADMIN_ROLE() || roleIdInt == _accessManager.PUBLIC_ROLE()) {
241
- revert ErrorRoleIdInvalid(roleId);
207
+ revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
242
208
  }
243
209
 
244
210
  // prevent changing isCustom for existing roles
245
211
  existingRole = _role[roleId];
246
212
 
247
213
  if (existingRole.createdAt.gtz() && isCustom != existingRole.isCustom) {
248
- revert ErrorRoleIsCustomIsImmutable(roleId, isCustom, existingRole.isCustom);
214
+ revert IAccess.ErrorIAccessRoleIsCustomIsImmutable(roleId, isCustom, existingRole.isCustom);
249
215
  }
250
216
 
251
217
  if (isCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
252
- revert ErrorRoleIdTooSmall(roleId);
218
+ revert IAccess.ErrorIAccessRoleIdTooSmall(roleId);
253
219
  } else if (!isCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
254
- revert ErrorRoleIdTooBig(roleId);
220
+ revert IAccess.ErrorIAccessRoleIdTooBig(roleId);
255
221
  }
256
222
 
257
223
  // role name checks
258
224
  ShortString nameShort = ShortStrings.toShortString(name);
259
225
  if (ShortStrings.byteLength(nameShort) == 0) {
260
- revert ErrorRoleNameEmpty(roleId);
226
+ revert IAccess.ErrorIAccessRoleNameEmpty(roleId);
261
227
  }
262
228
 
263
229
  if (_roleForName[nameShort] != RoleIdLib.zero() && _roleForName[nameShort] != roleId) {
264
- revert ErrorRoleNameNotUnique(_roleForName[nameShort], nameShort);
230
+ revert IAccess.ErrorIAccessRoleNameNotUnique(_roleForName[nameShort], nameShort);
265
231
  }
266
232
  }
267
233
 
@@ -270,7 +236,14 @@ contract InstanceAccessManager is
270
236
  _validateTargetParameters(target, name, isCustom);
271
237
  }
272
238
 
273
- TargetInfo memory info = TargetInfo(
239
+ if (_target[target].createdAt.gtz()) {
240
+ revert IAccess.ErrorIAccessTargetAlreadyExists(target, _target[target].name);
241
+ }
242
+ if (_targetForName[ShortStrings.toShortString(name)] != address(0)) {
243
+ revert IAccess.ErrorIAccessTargetNameExists(target, _targetForName[ShortStrings.toShortString(name)], ShortStrings.toShortString(name));
244
+ }
245
+
246
+ IAccess.TargetInfo memory info = IAccess.TargetInfo(
274
247
  ShortStrings.toShortString(name),
275
248
  isCustom,
276
249
  _accessManager.isTargetClosed(target), // sync with state in access manager
@@ -283,6 +256,48 @@ contract InstanceAccessManager is
283
256
  }
284
257
 
285
258
  function _validateTargetParameters(address target, string memory name, bool isCustom) internal view {
259
+ // TODO: implement
260
+ }
261
+
262
+ function setTargetFunctionRole(
263
+ address target,
264
+ bytes4[] calldata selectors,
265
+ uint64 roleId
266
+ ) public virtual restricted() {
267
+ _accessManager.setTargetFunctionRole(target, selectors, roleId);
268
+ }
269
+
270
+ function setTargetFunctionRole(
271
+ string memory targetName,
272
+ bytes4[] calldata selectors,
273
+ RoleId roleId
274
+ ) public virtual restricted() {
275
+ address target = _targetForName[ShortStrings.toShortString(targetName)];
276
+ uint64 roleIdInt = RoleId.unwrap(roleId);
277
+ _accessManager.setTargetFunctionRole(target, selectors, roleIdInt);
278
+ }
279
+
280
+ function getAccessManager() public restricted() returns (AccessManagerUpgradeableInitializeable) {
281
+ return _accessManager;
282
+ }
283
+
284
+ function setTargetClosed(string memory targetName, bool closed) public restricted() {
285
+ address target = _targetForName[ShortStrings.toShortString(targetName)];
286
+ if (target == address(0)) {
287
+ revert IAccess.ErrorIAccessTargetAddressZero();
288
+ }
289
+ _accessManager.setTargetClosed(target, closed);
290
+ }
291
+
292
+ function isTargetLocked(address target) public view returns (bool locked) {
293
+ return _accessManager.isTargetClosed(target);
294
+ }
286
295
 
296
+ function canCall(
297
+ address caller,
298
+ address target,
299
+ bytes4 selector
300
+ ) public view virtual returns (bool immediate, uint32 delay) {
301
+ return _accessManager.canCall(caller, target, selector);
287
302
  }
288
303
  }