@etherisc/gif-next 0.0.2-cff6256-424 → 0.0.2-d02cb80-460

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) 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 +142 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +164 -62
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +104 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -52
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +28 -2
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  14. package/artifacts/contracts/components/Pool.sol/Pool.json +193 -16
  15. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  16. package/artifacts/contracts/components/Product.sol/Product.json +166 -58
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  37. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  38. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  40. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  41. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  42. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
  43. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
  44. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1373 -93
  46. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  47. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  48. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  49. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +108 -1
  50. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  51. package/artifacts/contracts/instance/Instance.sol/Instance.json +160 -641
  52. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +291 -143
  54. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  55. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  56. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  57. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +177 -38
  58. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  59. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +333 -67
  60. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  61. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +91 -23
  62. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  63. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  64. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +40 -0
  66. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  70. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +54 -22
  73. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  80. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +923 -0
  81. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  82. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +440 -0
  83. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
  85. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +69 -26
  87. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  88. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +18 -18
  89. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  90. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +669 -0
  91. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  94. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +664 -0
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +9 -71
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -232
  99. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +984 -0
  101. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  102. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +464 -0
  103. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  104. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +718 -0
  105. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  106. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +428 -0
  107. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  108. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +768 -0
  109. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  110. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
  111. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  112. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +2 -110
  114. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  115. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
  116. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  117. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  118. package/artifacts/contracts/registry/Registry.sol/Registry.json +35 -146
  119. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  120. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
  121. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  122. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +26 -34
  123. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  124. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
  125. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  126. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  127. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  133. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  135. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  137. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  139. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  140. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  143. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  145. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  147. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestService.sol/TestService.json +9 -9
  149. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  152. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  153. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  154. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  158. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  161. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  162. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  168. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  174. package/contracts/components/BaseComponent.sol +62 -8
  175. package/contracts/components/Distribution.sol +12 -15
  176. package/contracts/components/IBaseComponent.sol +7 -0
  177. package/contracts/components/IDistributionComponent.sol +0 -2
  178. package/contracts/components/IPoolComponent.sol +5 -1
  179. package/contracts/components/Pool.sol +42 -29
  180. package/contracts/components/Product.sol +41 -46
  181. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  182. package/contracts/instance/BundleManager.sol +129 -0
  183. package/contracts/instance/Cloneable.sol +46 -0
  184. package/contracts/instance/IInstance.sol +34 -7
  185. package/contracts/instance/IInstanceBase.sol +26 -0
  186. package/contracts/instance/IInstanceService.sol +15 -3
  187. package/contracts/instance/Instance.sol +57 -224
  188. package/contracts/instance/InstanceAccessManager.sol +95 -78
  189. package/contracts/instance/InstanceBase.sol +41 -0
  190. package/contracts/instance/InstanceReader.sol +26 -1
  191. package/contracts/instance/InstanceService.sol +222 -69
  192. package/contracts/instance/InstanceServiceManager.sol +6 -5
  193. package/contracts/instance/ObjectManager.sol +101 -0
  194. package/contracts/instance/base/ComponentServiceBase.sol +45 -12
  195. package/contracts/instance/module/IAccess.sol +27 -17
  196. package/contracts/instance/module/IBundle.sol +1 -0
  197. package/contracts/instance/module/ISetup.sol +3 -0
  198. package/contracts/instance/service/BundleService.sol +260 -0
  199. package/contracts/instance/service/BundleServiceManager.sol +54 -0
  200. package/contracts/instance/service/DistributionService.sol +43 -21
  201. package/contracts/instance/service/DistributionServiceManager.sol +6 -5
  202. package/contracts/instance/service/IBundleService.sol +45 -0
  203. package/contracts/instance/service/IPolicyService.sol +87 -0
  204. package/contracts/instance/service/IPoolService.sol +6 -23
  205. package/contracts/instance/service/IProductService.sol +6 -73
  206. package/contracts/instance/service/PolicyService.sol +508 -0
  207. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  208. package/contracts/instance/service/PoolService.sol +124 -0
  209. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  210. package/contracts/instance/service/ProductService.sol +173 -0
  211. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  212. package/contracts/registry/IRegistry.sol +5 -18
  213. package/contracts/registry/IRegistryService.sol +28 -11
  214. package/contracts/registry/Registry.sol +4 -45
  215. package/contracts/registry/RegistryService.sol +30 -71
  216. package/contracts/shared/NftOwnable.sol +2 -4
  217. package/contracts/shared/Service.sol +1 -0
  218. package/contracts/types/NftIdSet.sol +26 -24
  219. package/contracts/types/RoleId.sol +7 -2
  220. package/package.json +1 -1
  221. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  222. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  223. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  224. package/contracts/instance/AccessManagedSimple.sol +0 -115
  225. package/contracts/instance/AccessManagerSimple.sol +0 -692
@@ -3,93 +3,69 @@ 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, INSTANCE_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, POLICY_SERVICE_ROLE, BUNDLE_SERVICE_ROLE, INSTANCE_SERVICE_ROLE } 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);
49
+
50
+ createDefaultGifRoles();
88
51
  }
89
52
 
90
- //--- Role ------------------------------------------------------//
53
+ function createDefaultGifRoles() public restricted() {
54
+ _createRole(INSTANCE_OWNER_ROLE(), "InstanceOwnerRole", false, true);
55
+ _createRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole", false, true);
56
+ _createRole(POOL_OWNER_ROLE(), "PoolOwnerRole", false, true);
57
+ _createRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole", false, true);
58
+
59
+ _createRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole", false, true);
60
+ _createRole(POOL_SERVICE_ROLE(), "PoolServiceRole", false, true);
61
+ _createRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole", false, true);
62
+ _createRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole", false, true);
63
+ _createRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole", false, true);
64
+ _createRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole", false, true);
65
+ }
91
66
 
92
- function createDefaultRole(RoleId roleId, string memory name) external restricted() {
67
+ //--- Role ------------------------------------------------------//
68
+ function createGifRole(RoleId roleId, string memory name) external restricted() {
93
69
  _createRole(roleId, name, false, true);
94
70
  }
95
71
 
@@ -99,7 +75,7 @@ contract InstanceAccessManager is
99
75
 
100
76
  function setRoleLocked(RoleId roleId, bool locked) external restricted() {
101
77
  if (!roleExists(roleId)) {
102
- revert ErrorSetLockedForNonexstentRole(roleId);
78
+ revert IAccess.ErrorIAccessSetLockedForNonexstentRole(roleId);
103
79
  }
104
80
 
105
81
  _role[roleId].isLocked = locked;
@@ -112,11 +88,11 @@ contract InstanceAccessManager is
112
88
 
113
89
  function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
114
90
  if (!roleExists(roleId)) {
115
- revert ErrorGrantNonexstentRole(roleId);
91
+ revert IAccess.ErrorIAccessGrantNonexstentRole(roleId);
116
92
  }
117
93
 
118
94
  if (_role[roleId].isLocked) {
119
- revert ErrorRoleIdNotActive(roleId);
95
+ revert IAccess.ErrorIAccessRoleIdNotActive(roleId);
120
96
  }
121
97
 
122
98
  if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
@@ -130,7 +106,7 @@ contract InstanceAccessManager is
130
106
 
131
107
  function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
132
108
  if (!roleExists(roleId)) {
133
- revert ErrorRevokeNonexstentRole(roleId);
109
+ revert IAccess.ErrorIAccessRevokeNonexstentRole(roleId);
134
110
  }
135
111
 
136
112
  if (EnumerableSet.contains(_roleMembers[roleId], member)) {
@@ -148,7 +124,7 @@ contract InstanceAccessManager is
148
124
  address member = msg.sender;
149
125
 
150
126
  if (!roleExists(roleId)) {
151
- revert ErrorRenounceNonexstentRole(roleId);
127
+ revert IAccess.ErrorIAccessRenounceNonexstentRole(roleId);
152
128
  }
153
129
 
154
130
  if (EnumerableSet.contains(_roleMembers[roleId], member)) {
@@ -173,7 +149,7 @@ contract InstanceAccessManager is
173
149
  return _roleForName[ShortStrings.toShortString(name)];
174
150
  }
175
151
 
176
- function getRole(RoleId roleId) external view returns (RoleInfo memory role) {
152
+ function getRole(RoleId roleId) external view returns (IAccess.RoleInfo memory role) {
177
153
  return _role[roleId];
178
154
  }
179
155
 
@@ -190,13 +166,19 @@ contract InstanceAccessManager is
190
166
  }
191
167
 
192
168
  //--- Target ------------------------------------------------------//
169
+ function createGifTarget(address target, string memory name) external restricted() {
170
+ _createTarget(target, name, false, true);
171
+ }
172
+
193
173
  function createTarget(address target, string memory name) external restricted() {
194
174
  _createTarget(target, name, true, true);
195
175
  }
196
176
 
197
- function setTargetLocked(address target, bool locked) external restricted() {
198
- if (!targetExists(target)) {
199
- revert ErrorSetLockedForNonexstentTarget(target);
177
+ function setTargetLocked(string memory targetName, bool locked) external restricted() {
178
+ address target = _targetForName[ShortStrings.toShortString(targetName)];
179
+
180
+ if (target == address(0)) {
181
+ revert IAccess.ErrorIAccessSetLockedForNonexstentTarget(target);
200
182
  }
201
183
 
202
184
  _target[target].isLocked = locked;
@@ -214,7 +196,7 @@ contract InstanceAccessManager is
214
196
  _validateRoleParameters(roleId, name, isCustom);
215
197
  }
216
198
 
217
- RoleInfo memory role = RoleInfo(
199
+ IAccess.RoleInfo memory role = IAccess.RoleInfo(
218
200
  ShortStrings.toShortString(name),
219
201
  isCustom,
220
202
  false, // role un-locked,
@@ -233,35 +215,35 @@ contract InstanceAccessManager is
233
215
  )
234
216
  internal
235
217
  view
236
- returns (RoleInfo memory existingRole)
218
+ returns (IAccess.RoleInfo memory existingRole)
237
219
  {
238
220
  // check role id
239
221
  uint64 roleIdInt = RoleId.unwrap(roleId);
240
222
  if(roleIdInt == _accessManager.ADMIN_ROLE() || roleIdInt == _accessManager.PUBLIC_ROLE()) {
241
- revert ErrorRoleIdInvalid(roleId);
223
+ revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
242
224
  }
243
225
 
244
226
  // prevent changing isCustom for existing roles
245
227
  existingRole = _role[roleId];
246
228
 
247
229
  if (existingRole.createdAt.gtz() && isCustom != existingRole.isCustom) {
248
- revert ErrorRoleIsCustomIsImmutable(roleId, isCustom, existingRole.isCustom);
230
+ revert IAccess.ErrorIAccessRoleIsCustomIsImmutable(roleId, isCustom, existingRole.isCustom);
249
231
  }
250
232
 
251
233
  if (isCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
252
- revert ErrorRoleIdTooSmall(roleId);
234
+ revert IAccess.ErrorIAccessRoleIdTooSmall(roleId);
253
235
  } else if (!isCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
254
- revert ErrorRoleIdTooBig(roleId);
236
+ revert IAccess.ErrorIAccessRoleIdTooBig(roleId);
255
237
  }
256
238
 
257
239
  // role name checks
258
240
  ShortString nameShort = ShortStrings.toShortString(name);
259
241
  if (ShortStrings.byteLength(nameShort) == 0) {
260
- revert ErrorRoleNameEmpty(roleId);
242
+ revert IAccess.ErrorIAccessRoleNameEmpty(roleId);
261
243
  }
262
244
 
263
245
  if (_roleForName[nameShort] != RoleIdLib.zero() && _roleForName[nameShort] != roleId) {
264
- revert ErrorRoleNameNotUnique(_roleForName[nameShort], nameShort);
246
+ revert IAccess.ErrorIAccessRoleNameNotUnique(_roleForName[nameShort], nameShort);
265
247
  }
266
248
  }
267
249
 
@@ -270,7 +252,7 @@ contract InstanceAccessManager is
270
252
  _validateTargetParameters(target, name, isCustom);
271
253
  }
272
254
 
273
- TargetInfo memory info = TargetInfo(
255
+ IAccess.TargetInfo memory info = IAccess.TargetInfo(
274
256
  ShortStrings.toShortString(name),
275
257
  isCustom,
276
258
  _accessManager.isTargetClosed(target), // sync with state in access manager
@@ -283,6 +265,41 @@ contract InstanceAccessManager is
283
265
  }
284
266
 
285
267
  function _validateTargetParameters(address target, string memory name, bool isCustom) internal view {
268
+ // TODO: implement
269
+ }
270
+
271
+ function setTargetFunctionRole(
272
+ address target,
273
+ bytes4[] calldata selectors,
274
+ uint64 roleId
275
+ ) public virtual restricted() {
276
+ _accessManager.setTargetFunctionRole(target, selectors, roleId);
277
+ }
278
+
279
+ function setTargetFunctionRole(
280
+ string memory targetName,
281
+ bytes4[] calldata selectors,
282
+ RoleId roleId
283
+ ) public virtual restricted() {
284
+ address target = _targetForName[ShortStrings.toShortString(targetName)];
285
+ uint64 roleIdInt = RoleId.unwrap(roleId);
286
+ _accessManager.setTargetFunctionRole(target, selectors, roleIdInt);
287
+ }
288
+
289
+ function getAccessManager() public restricted() returns (AccessManagerUpgradeableInitializeable) {
290
+ return _accessManager;
291
+ }
292
+
293
+ function setTargetClosed(string memory targetName, bool closed) public restricted() {
294
+ address target = _targetForName[ShortStrings.toShortString(targetName)];
295
+ _accessManager.setTargetClosed(target, closed);
296
+ }
286
297
 
298
+ function canCall(
299
+ address caller,
300
+ address target,
301
+ bytes4 selector
302
+ ) public view virtual returns (bool immediate, uint32 delay) {
303
+ return _accessManager.canCall(caller, target, selector);
287
304
  }
288
305
  }
@@ -0,0 +1,41 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
5
+ import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
+
7
+ import {IAccess} from "./module/IAccess.sol";
8
+ import {IBundle} from "./module/IBundle.sol";
9
+ import {IPolicy} from "./module/IPolicy.sol";
10
+ import {IRisk} from "./module/IRisk.sol";
11
+ import {ISetup} from "./module/ISetup.sol";
12
+ import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
13
+ import {KeyValueStore} from "./base/KeyValueStore.sol";
14
+ import {IInstance} from "./IInstance.sol";
15
+ import {InstanceReader} from "./InstanceReader.sol";
16
+ import {BundleManager} from "./BundleManager.sol";
17
+ import {NftId} from "../types/NftId.sol";
18
+ import {NumberId} from "../types/NumberId.sol";
19
+ import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
20
+ import {RiskId, RiskIdLib} from "../types/RiskId.sol";
21
+ import {RoleId, RoleIdLib} from "../types/RoleId.sol";
22
+ import {StateId, ACTIVE} from "../types/StateId.sol";
23
+ import {ERC165} from "../shared/ERC165.sol";
24
+ import {Registerable} from "../shared/Registerable.sol";
25
+ import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
26
+ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
27
+ import {IDistributionService} from "./service/IDistributionService.sol";
28
+ import {IPoolService} from "./service/IPoolService.sol";
29
+ import {IProductService} from "./service/IProductService.sol";
30
+ import {VersionPart} from "../types/Version.sol";
31
+ import {IInstanceBase} from "./IInstanceBase.sol";
32
+
33
+ contract InstanceBase is
34
+ IInstanceBase,
35
+ KeyValueStore,
36
+ ERC165,
37
+ Registerable
38
+ {
39
+
40
+
41
+ }
@@ -7,14 +7,16 @@ import {DistributorType} from "../types/DistributorType.sol";
7
7
  import {Fee, FeeLib} from "../types/Fee.sol";
8
8
  import {Key32} from "../types/Key32.sol";
9
9
  import {NftId} from "../types/NftId.sol";
10
- import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY} from "../types/ObjectType.sol";
10
+ import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY, BUNDLE} from "../types/ObjectType.sol";
11
11
  import {ReferralId, ReferralStatus, ReferralLib, REFERRAL_OK, REFERRAL_ERROR_UNKNOWN, REFERRAL_ERROR_EXPIRED, REFERRAL_ERROR_EXHAUSTED} from "../types/Referral.sol";
12
12
  import {Registerable} from "../shared/Registerable.sol";
13
13
  import {RiskId} from "../types/RiskId.sol";
14
14
  import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
15
15
  import {Version} from "../types/Version.sol";
16
+ import {StateId} from "../types/StateId.sol";
16
17
 
17
18
  import {IRegistry} from "../registry/IRegistry.sol";
19
+ import {IBundle} from "../instance/module/IBundle.sol";
18
20
  import {IDistribution} from "../instance/module/IDistribution.sol";
19
21
  import {IInstance} from "./IInstance.sol";
20
22
  import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
@@ -80,6 +82,14 @@ contract InstanceReader {
80
82
  }
81
83
  }
82
84
 
85
+ function getPolicyState(NftId policyNftId)
86
+ public
87
+ view
88
+ returns (StateId state)
89
+ {
90
+ return _instance.getState(toPolicyKey(policyNftId));
91
+ }
92
+
83
93
  function getRiskInfo(RiskId riskId)
84
94
  public
85
95
  view
@@ -114,6 +124,17 @@ contract InstanceReader {
114
124
  return abi.decode(data, (ITreasury.TreasuryInfo));
115
125
  }
116
126
  }
127
+
128
+ function getBundleInfo(NftId bundleNftId)
129
+ public
130
+ view
131
+ returns (IBundle.BundleInfo memory info)
132
+ {
133
+ bytes memory data = _store.getData(toBundleKey(bundleNftId));
134
+ if (data.length > 0) {
135
+ return abi.decode(data, (IBundle.BundleInfo));
136
+ }
137
+ }
117
138
 
118
139
  function getDistributorTypeInfo(DistributorType distributorType)
119
140
  public
@@ -259,6 +280,10 @@ contract InstanceReader {
259
280
  return distributionNftId.toKey32(DISTRIBUTION());
260
281
  }
261
282
 
283
+ function toBundleKey(NftId poolNftId) public pure returns (Key32) {
284
+ return poolNftId.toKey32(BUNDLE());
285
+ }
286
+
262
287
  function toPoolKey(NftId poolNftId) public pure returns (Key32) {
263
288
  return poolNftId.toKey32(POOL());
264
289
  }