@etherisc/gif-next 0.0.2-4e4966e-474 → 0.0.2-4e6a781-730
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → Component.sol/Component.json} +300 -12
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +199 -94
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +86 -84
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +496 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +522 -28
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +596 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +190 -159
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +204 -110
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +269 -13
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +108 -18
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +95 -610
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +104 -194
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +41 -82
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +217 -200
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +41 -92
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +124 -42
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +62 -19
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +245 -66
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +35 -26
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +153 -65
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +32 -23
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +64 -18
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -18
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +120 -18
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +13 -18
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +13 -18
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +334 -91
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +66 -25
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +153 -65
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +32 -23
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +159 -71
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +32 -15
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +212 -133
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +127 -93
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +224 -234
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +68 -161
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +51 -104
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +13 -29
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +13 -18
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +26 -18
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +44 -36
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +216 -0
- package/contracts/components/Distribution.sol +38 -51
- package/contracts/components/IComponent.sol +43 -0
- package/contracts/components/IDistributionComponent.sol +5 -2
- package/contracts/components/IPoolComponent.sol +6 -12
- package/contracts/components/IProductComponent.sol +7 -3
- package/contracts/components/Pool.sol +45 -89
- package/contracts/components/Product.sol +58 -85
- package/contracts/instance/BundleManager.sol +7 -11
- package/contracts/instance/IInstance.sol +21 -9
- package/contracts/instance/IInstanceService.sol +9 -2
- package/contracts/instance/Instance.sol +35 -231
- package/contracts/instance/InstanceAccessManager.sol +38 -62
- package/contracts/instance/InstanceReader.sol +3 -25
- package/contracts/instance/InstanceService.sol +215 -57
- package/contracts/instance/InstanceServiceManager.sol +5 -8
- package/contracts/instance/ObjectManager.sol +7 -24
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/module/IAccess.sol +20 -18
- package/contracts/instance/service/BundleService.sol +41 -8
- package/contracts/instance/service/BundleServiceManager.sol +5 -8
- package/contracts/instance/service/DistributionService.sol +31 -43
- package/contracts/instance/service/DistributionServiceManager.sol +6 -9
- package/contracts/instance/service/IBundleService.sol +5 -6
- package/contracts/instance/service/IPolicyService.sol +7 -0
- package/contracts/instance/service/PolicyService.sol +67 -37
- package/contracts/instance/service/PoolService.sol +25 -39
- package/contracts/instance/service/PoolServiceManager.sol +5 -8
- package/contracts/instance/service/ProductService.sol +99 -38
- package/contracts/registry/ChainNft.sol +1 -1
- package/contracts/registry/IRegistry.sol +34 -17
- package/contracts/registry/IRegistryService.sol +28 -13
- package/contracts/registry/Registry.sol +214 -210
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +61 -157
- package/contracts/registry/RegistryServiceManager.sol +18 -36
- package/contracts/registry/ReleaseManager.sol +332 -0
- package/contracts/registry/TokenRegistry.sol +8 -7
- package/contracts/shared/IRegisterable.sol +1 -3
- package/contracts/shared/IService.sol +2 -1
- package/contracts/shared/NftOwnable.sol +5 -0
- package/contracts/shared/ProxyManager.sol +1 -1
- package/contracts/shared/Registerable.sol +10 -14
- package/contracts/shared/Service.sol +13 -8
- package/contracts/test/TestService.sol +3 -2
- package/contracts/types/RoleId.sol +4 -6
- package/package.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
- package/contracts/components/BaseComponent.sol +0 -132
- package/contracts/components/IBaseComponent.sol +0 -31
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/IInstanceBase.sol +0 -26
- package/contracts/instance/InstanceBase.sol +0 -41
- package/contracts/instance/base/ComponentServiceBase.sol +0 -72
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -317
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.20;
|
|
3
3
|
|
|
4
|
-
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
5
|
-
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
|
6
|
-
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
7
4
|
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
|
8
5
|
|
|
9
|
-
import {IAccess} from "./module/IAccess.sol";
|
|
10
|
-
import {IBundle} from "./module/IBundle.sol";
|
|
11
|
-
import {IPolicy} from "./module/IPolicy.sol";
|
|
12
|
-
import {IRisk} from "./module/IRisk.sol";
|
|
13
|
-
import {ISetup} from "./module/ISetup.sol";
|
|
14
6
|
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
|
15
|
-
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
|
16
|
-
import {IInstance} from "./IInstance.sol";
|
|
17
|
-
import {InstanceReader} from "./InstanceReader.sol";
|
|
18
|
-
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
|
19
|
-
import {BundleManager} from "./BundleManager.sol";
|
|
20
7
|
import {NftId} from "../types/NftId.sol";
|
|
21
8
|
import {NumberId} from "../types/NumberId.sol";
|
|
22
|
-
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
|
9
|
+
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT} from "../types/ObjectType.sol";
|
|
23
10
|
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
|
24
11
|
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
|
25
12
|
import {StateId, ACTIVE} from "../types/StateId.sol";
|
|
26
13
|
import {TimestampLib} from "../types/Timestamp.sol";
|
|
14
|
+
import {VersionPart} from "../types/Version.sol";
|
|
15
|
+
|
|
27
16
|
import {ERC165} from "../shared/ERC165.sol";
|
|
28
17
|
import {Registerable} from "../shared/Registerable.sol";
|
|
29
|
-
|
|
30
|
-
import {
|
|
18
|
+
|
|
19
|
+
import {IInstance} from "./IInstance.sol";
|
|
20
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
|
21
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
|
22
|
+
import {BundleManager} from "./BundleManager.sol";
|
|
23
|
+
|
|
24
|
+
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
|
25
|
+
|
|
26
|
+
import {IAccess} from "./module/IAccess.sol";
|
|
27
|
+
import {IBundle} from "./module/IBundle.sol";
|
|
28
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
|
29
|
+
import {IRisk} from "./module/IRisk.sol";
|
|
30
|
+
import {ISetup} from "./module/ISetup.sol";
|
|
31
|
+
|
|
31
32
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
|
32
33
|
import {IPoolService} from "./service/IPoolService.sol";
|
|
33
34
|
import {IProductService} from "./service/IProductService.sol";
|
|
34
35
|
import {IPolicyService} from "./service/IPolicyService.sol";
|
|
35
36
|
import {IBundleService} from "./service/IBundleService.sol";
|
|
36
|
-
import {VersionPart} from "../types/Version.sol";
|
|
37
|
-
import {InstanceBase} from "./InstanceBase.sol";
|
|
37
|
+
import {VersionPart, VersionPartLib} from "../types/Version.sol";
|
|
38
38
|
|
|
39
39
|
contract Instance is
|
|
40
|
-
AccessManagedUpgradeable,
|
|
41
40
|
IInstance,
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
AccessManagedUpgradeable,
|
|
42
|
+
Registerable,
|
|
43
|
+
KeyValueStore
|
|
44
44
|
{
|
|
45
45
|
|
|
46
|
+
uint256 public constant GIF_MAJOR_VERSION = 3;
|
|
47
|
+
|
|
46
48
|
uint64 public constant ADMIN_ROLE = type(uint64).min;
|
|
47
49
|
uint64 public constant PUBLIC_ROLE = type(uint64).max;
|
|
48
50
|
uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
|
|
@@ -51,10 +53,6 @@ contract Instance is
|
|
|
51
53
|
|
|
52
54
|
bool private _initialized;
|
|
53
55
|
|
|
54
|
-
mapping(ShortString name => RoleId roleId) internal _role;
|
|
55
|
-
mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
|
|
56
|
-
RoleId [] internal _roles;
|
|
57
|
-
|
|
58
56
|
InstanceAccessManager internal _accessManager;
|
|
59
57
|
InstanceReader internal _instanceReader;
|
|
60
58
|
BundleManager internal _bundleManager;
|
|
@@ -63,133 +61,11 @@ contract Instance is
|
|
|
63
61
|
public
|
|
64
62
|
initializer
|
|
65
63
|
{
|
|
66
|
-
require(!_initialized, "Contract instance has already been initialized");
|
|
67
|
-
|
|
68
64
|
__AccessManaged_init(accessManagerAddress);
|
|
69
|
-
|
|
70
|
-
_accessManager = InstanceAccessManager(accessManagerAddress);
|
|
71
|
-
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
|
72
|
-
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
|
73
|
-
|
|
65
|
+
|
|
74
66
|
_initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
|
|
75
67
|
|
|
76
68
|
_registerInterface(type(IInstance).interfaceId);
|
|
77
|
-
_initialized = true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
//--- Role ------------------------------------------------------//
|
|
81
|
-
function createStandardRole(RoleId roleId, string memory name) external restricted() {
|
|
82
|
-
_createRole(roleId, name, false, true);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function createCustomRole(RoleId roleId, string memory name) external restricted() {
|
|
86
|
-
_createRole(roleId, name, true, true);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function updateRole(RoleId roleId, string memory name, StateId newState) external restricted() {
|
|
90
|
-
(bool isCustom,) = _validateRoleParameters(roleId, name, false);
|
|
91
|
-
IAccess.RoleInfo memory role = _toRole(roleId, name, isCustom);
|
|
92
|
-
update(toRoleKey32(roleId), abi.encode(role), newState);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function updateRoleState(RoleId roleId, StateId newState) external restricted() {
|
|
96
|
-
updateState(toRoleKey32(roleId), newState);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
|
|
100
|
-
Key32 roleKey = toRoleKey32(roleId);
|
|
101
|
-
|
|
102
|
-
if (!exists(roleKey)) {
|
|
103
|
-
revert IAccess.ErrorGrantNonexstentRole(roleId);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (getState(roleKey) != ACTIVE()) {
|
|
107
|
-
revert IAccess.ErrorRoleIdNotActive(roleId);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
|
|
111
|
-
_accessManager.grantRole(roleId, member);
|
|
112
|
-
EnumerableSet.add(_roleMembers[roleId], member);
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
|
|
120
|
-
Key32 roleKey = toRoleKey32(roleId);
|
|
121
|
-
|
|
122
|
-
if (!exists(roleKey)) {
|
|
123
|
-
revert IAccess.ErrorRevokeNonexstentRole(roleId);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
|
127
|
-
_accessManager.revokeRole(roleId, member);
|
|
128
|
-
EnumerableSet.remove(_roleMembers[roleId], member);
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/// @dev not restricted function by intention
|
|
136
|
-
/// the restriction to role members is already enforced by the call to the access manger
|
|
137
|
-
function renounceRole(RoleId roleId) external returns (bool revoked) {
|
|
138
|
-
address member = msg.sender;
|
|
139
|
-
Key32 roleKey = toRoleKey32(roleId);
|
|
140
|
-
|
|
141
|
-
if (!exists(roleKey)) {
|
|
142
|
-
revert IAccess.ErrorRenounceNonexstentRole(roleId);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
|
146
|
-
_accessManager.revokeRole(roleId, member);
|
|
147
|
-
EnumerableSet.remove(_roleMembers[roleId], member);
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function roles() external view returns (uint256 numberOfRoles) {
|
|
155
|
-
return _roles.length;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getRoleId(uint256 idx) external view returns (RoleId roleId) {
|
|
159
|
-
return _roles[idx];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function getRole(RoleId roleId) external view returns (IAccess.RoleInfo memory role) {
|
|
163
|
-
return abi.decode(getData(roleId.toKey32()), (IAccess.RoleInfo));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function roleMembers(RoleId roleId) external view returns (uint256 numberOfMembers) {
|
|
167
|
-
return EnumerableSet.length(_roleMembers[roleId]);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function getRoleMember(RoleId roleId, uint256 idx) external view returns (address roleMember) {
|
|
171
|
-
return EnumerableSet.at(_roleMembers[roleId], idx);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function _createRole(RoleId roleId, string memory name, bool isCustom, bool validateParameters) internal {
|
|
175
|
-
if (validateParameters) {
|
|
176
|
-
_validateRoleParameters(roleId, name, isCustom);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
IAccess.RoleInfo memory role = _toRole(roleId, name, isCustom);
|
|
180
|
-
_role[role.name] = roleId;
|
|
181
|
-
_roles.push(roleId);
|
|
182
|
-
|
|
183
|
-
create(toRoleKey32(roleId), abi.encode(role));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
//--- Target ------------------------------------------------------//
|
|
187
|
-
function createTarget(address target, string memory targetName) external restricted() {
|
|
188
|
-
_accessManager.createTarget(target, targetName);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function setTargetLocked(string memory targetName, bool closed) external restricted() {
|
|
192
|
-
_accessManager.setTargetLocked(targetName, closed);
|
|
193
69
|
}
|
|
194
70
|
|
|
195
71
|
//--- ProductSetup ------------------------------------------------------//
|
|
@@ -336,74 +212,6 @@ contract Instance is
|
|
|
336
212
|
}
|
|
337
213
|
|
|
338
214
|
//--- internal view/pure functions --------------------------------------//
|
|
339
|
-
function _toRole(RoleId roleId, string memory name, bool isCustom)
|
|
340
|
-
internal
|
|
341
|
-
view
|
|
342
|
-
returns (IAccess.RoleInfo memory role)
|
|
343
|
-
{
|
|
344
|
-
return IAccess.RoleInfo(
|
|
345
|
-
ShortStrings.toShortString(name),
|
|
346
|
-
isCustom,
|
|
347
|
-
false,
|
|
348
|
-
TimestampLib.blockTimestamp(),
|
|
349
|
-
TimestampLib.blockTimestamp());
|
|
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
215
|
function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
|
|
408
216
|
return nftId.toKey32(objectType);
|
|
409
217
|
}
|
|
@@ -416,46 +224,42 @@ contract Instance is
|
|
|
416
224
|
return policyNftId.toKey32(POLICY());
|
|
417
225
|
}
|
|
418
226
|
|
|
419
|
-
function getComponentOwnerService() external view returns (IComponentOwnerService) {
|
|
420
|
-
return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
|
|
421
|
-
}
|
|
422
|
-
|
|
423
227
|
function getDistributionService() external view returns (IDistributionService) {
|
|
424
|
-
return IDistributionService(_registry.getServiceAddress(
|
|
228
|
+
return IDistributionService(_registry.getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
|
|
425
229
|
}
|
|
426
230
|
|
|
427
231
|
function getProductService() external view returns (IProductService) {
|
|
428
|
-
return IProductService(_registry.getServiceAddress(
|
|
232
|
+
return IProductService(_registry.getServiceAddress(PRODUCT(), VersionPart.wrap(3)));
|
|
429
233
|
}
|
|
430
234
|
|
|
431
235
|
function getPoolService() external view returns (IPoolService) {
|
|
432
|
-
return IPoolService(_registry.getServiceAddress(
|
|
236
|
+
return IPoolService(_registry.getServiceAddress(POOL(), VersionPart.wrap(3)));
|
|
433
237
|
}
|
|
434
238
|
|
|
435
239
|
function getPolicyService() external view returns (IPolicyService) {
|
|
436
|
-
return IPolicyService(_registry.getServiceAddress(
|
|
240
|
+
return IPolicyService(_registry.getServiceAddress(POLICY(), VersionPart.wrap(3)));
|
|
437
241
|
}
|
|
438
242
|
|
|
439
243
|
function getBundleService() external view returns (IBundleService) {
|
|
440
|
-
return IBundleService(_registry.getServiceAddress(
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function getInstanceAccessManager() external view returns (InstanceAccessManager) {
|
|
444
|
-
return _accessManager;
|
|
244
|
+
return IBundleService(_registry.getServiceAddress(BUNDLE(), VersionPart.wrap(3)));
|
|
445
245
|
}
|
|
446
246
|
|
|
447
247
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
|
448
|
-
require(instanceReader.
|
|
248
|
+
require(instanceReader.getInstance() == Instance(this), "InstanceReader instance mismatch");
|
|
449
249
|
_instanceReader = instanceReader;
|
|
450
250
|
}
|
|
451
251
|
|
|
252
|
+
function getMajorVersion() external pure returns (VersionPart majorVersion) {
|
|
253
|
+
return VersionPartLib.toVersionPart(GIF_MAJOR_VERSION);
|
|
254
|
+
}
|
|
255
|
+
|
|
452
256
|
function getInstanceReader() external view returns (InstanceReader) {
|
|
453
257
|
return _instanceReader;
|
|
454
258
|
}
|
|
455
259
|
|
|
456
260
|
function setBundleManager(BundleManager bundleManager) external restricted() {
|
|
457
261
|
require(address(_bundleManager) == address(0), "BundleManager is set");
|
|
458
|
-
require(bundleManager.
|
|
262
|
+
require(bundleManager.getInstance() == Instance(this), "BundleManager instance mismatch");
|
|
459
263
|
_bundleManager = bundleManager;
|
|
460
264
|
}
|
|
461
265
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.20;
|
|
3
3
|
|
|
4
|
+
import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
|
|
5
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
|
4
6
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
5
7
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
|
6
|
-
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
import {RoleId, RoleIdLib, 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";
|
|
9
|
+
import {RoleId, RoleIdLib } from "../types/RoleId.sol";
|
|
10
10
|
import {TimestampLib} from "../types/Timestamp.sol";
|
|
11
11
|
import {IAccess} from "./module/IAccess.sol";
|
|
12
12
|
|
|
@@ -21,26 +21,6 @@ contract InstanceAccessManager is
|
|
|
21
21
|
uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
|
|
22
22
|
uint32 public constant EXECUTION_DELAY = 0;
|
|
23
23
|
|
|
24
|
-
error ErrorRoleIdInvalid(RoleId roleId);
|
|
25
|
-
error ErrorRoleIdTooBig(RoleId roleId);
|
|
26
|
-
error ErrorRoleIdTooSmall(RoleId roleId);
|
|
27
|
-
error ErrorRoleIdAlreadyExists(RoleId roleId, ShortString name);
|
|
28
|
-
error ErrorRoleIdNotActive(RoleId roleId);
|
|
29
|
-
error ErrorRoleNameEmpty(RoleId roleId);
|
|
30
|
-
error ErrorRoleNameNotUnique(RoleId roleId, ShortString name);
|
|
31
|
-
error ErrorRoleInvalidUpdate(RoleId roleId, bool isCustom);
|
|
32
|
-
error ErrorRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
|
|
33
|
-
error ErrorSetLockedForNonexstentRole(RoleId roleId);
|
|
34
|
-
error ErrorGrantNonexstentRole(RoleId roleId);
|
|
35
|
-
error ErrorRevokeNonexstentRole(RoleId roleId);
|
|
36
|
-
error ErrorRenounceNonexstentRole(RoleId roleId);
|
|
37
|
-
|
|
38
|
-
error ErrorTargetAddressZero();
|
|
39
|
-
error ErrorTargetAlreadyExists(address target, ShortString name);
|
|
40
|
-
error ErrorTargetNameEmpty(address target);
|
|
41
|
-
error ErrorTargetNameExists(address target, address existingTarget, ShortString name);
|
|
42
|
-
error ErrorSetLockedForNonexstentTarget(address target);
|
|
43
|
-
|
|
44
24
|
// role specific state
|
|
45
25
|
mapping(RoleId roleId => IAccess.RoleInfo info) internal _role;
|
|
46
26
|
mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
|
|
@@ -52,41 +32,23 @@ contract InstanceAccessManager is
|
|
|
52
32
|
mapping(ShortString name => address target) internal _targetForName;
|
|
53
33
|
address [] internal _targets;
|
|
54
34
|
|
|
55
|
-
|
|
35
|
+
AccessManager internal _accessManager;
|
|
56
36
|
|
|
57
|
-
function
|
|
37
|
+
function initialize(address initialAdmin) external initializer
|
|
58
38
|
{
|
|
59
39
|
// if size of the contract gets too large, this can be externalized which will reduce the contract size considerably
|
|
60
|
-
_accessManager = new
|
|
61
|
-
// this service required
|
|
62
|
-
_accessManager.__AccessManagerUpgradeableInitializeable_init(address(this));
|
|
40
|
+
_accessManager = new AccessManager(address(this));
|
|
41
|
+
// this service required admin rights to access manager to be able to grant/revoke roles
|
|
63
42
|
_accessManager.grantRole(_accessManager.ADMIN_ROLE(), initialAdmin, 0);
|
|
64
43
|
|
|
65
44
|
__AccessManaged_init(address(_accessManager));
|
|
66
45
|
|
|
67
46
|
_createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
|
|
68
47
|
_createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
|
|
69
|
-
|
|
70
|
-
createDefaultGifRoles();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function createDefaultGifRoles() public restricted() {
|
|
74
|
-
// DISTRIBUTION_OWNER_ROLE
|
|
75
|
-
_createRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole", false, true);
|
|
76
|
-
_createRole(POOL_OWNER_ROLE(), "PoolOwnerRole", false, true);
|
|
77
|
-
_createRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole", false, true);
|
|
78
|
-
|
|
79
|
-
_createRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole", false, true);
|
|
80
|
-
_createRole(POOL_SERVICE_ROLE(), "PoolServiceRole", false, true);
|
|
81
|
-
_createRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole", false, true);
|
|
82
|
-
_createRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole", false, true);
|
|
83
|
-
_createRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole", false, true);
|
|
84
|
-
_createRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole", false, true);
|
|
85
48
|
}
|
|
86
49
|
|
|
87
50
|
//--- Role ------------------------------------------------------//
|
|
88
|
-
|
|
89
|
-
function createDefaultRole(RoleId roleId, string memory name) external restricted() {
|
|
51
|
+
function createGifRole(RoleId roleId, string memory name) external restricted() {
|
|
90
52
|
_createRole(roleId, name, false, true);
|
|
91
53
|
}
|
|
92
54
|
|
|
@@ -96,7 +58,7 @@ contract InstanceAccessManager is
|
|
|
96
58
|
|
|
97
59
|
function setRoleLocked(RoleId roleId, bool locked) external restricted() {
|
|
98
60
|
if (!roleExists(roleId)) {
|
|
99
|
-
revert
|
|
61
|
+
revert IAccess.ErrorIAccessSetLockedForNonexstentRole(roleId);
|
|
100
62
|
}
|
|
101
63
|
|
|
102
64
|
_role[roleId].isLocked = locked;
|
|
@@ -109,11 +71,11 @@ contract InstanceAccessManager is
|
|
|
109
71
|
|
|
110
72
|
function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
|
|
111
73
|
if (!roleExists(roleId)) {
|
|
112
|
-
revert
|
|
74
|
+
revert IAccess.ErrorIAccessGrantNonexstentRole(roleId);
|
|
113
75
|
}
|
|
114
76
|
|
|
115
77
|
if (_role[roleId].isLocked) {
|
|
116
|
-
revert
|
|
78
|
+
revert IAccess.ErrorIAccessRoleIdNotActive(roleId);
|
|
117
79
|
}
|
|
118
80
|
|
|
119
81
|
if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
|
|
@@ -127,7 +89,7 @@ contract InstanceAccessManager is
|
|
|
127
89
|
|
|
128
90
|
function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
|
|
129
91
|
if (!roleExists(roleId)) {
|
|
130
|
-
revert
|
|
92
|
+
revert IAccess.ErrorIAccessRevokeNonexstentRole(roleId);
|
|
131
93
|
}
|
|
132
94
|
|
|
133
95
|
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
|
@@ -145,7 +107,7 @@ contract InstanceAccessManager is
|
|
|
145
107
|
address member = msg.sender;
|
|
146
108
|
|
|
147
109
|
if (!roleExists(roleId)) {
|
|
148
|
-
revert
|
|
110
|
+
revert IAccess.ErrorIAccessRenounceNonexstentRole(roleId);
|
|
149
111
|
}
|
|
150
112
|
|
|
151
113
|
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
|
@@ -187,6 +149,10 @@ contract InstanceAccessManager is
|
|
|
187
149
|
}
|
|
188
150
|
|
|
189
151
|
//--- Target ------------------------------------------------------//
|
|
152
|
+
function createGifTarget(address target, string memory name) external restricted() {
|
|
153
|
+
_createTarget(target, name, false, true);
|
|
154
|
+
}
|
|
155
|
+
|
|
190
156
|
function createTarget(address target, string memory name) external restricted() {
|
|
191
157
|
_createTarget(target, name, true, true);
|
|
192
158
|
}
|
|
@@ -195,7 +161,7 @@ contract InstanceAccessManager is
|
|
|
195
161
|
address target = _targetForName[ShortStrings.toShortString(targetName)];
|
|
196
162
|
|
|
197
163
|
if (target == address(0)) {
|
|
198
|
-
revert
|
|
164
|
+
revert IAccess.ErrorIAccessSetLockedForNonexstentTarget(target);
|
|
199
165
|
}
|
|
200
166
|
|
|
201
167
|
_target[target].isLocked = locked;
|
|
@@ -237,30 +203,30 @@ contract InstanceAccessManager is
|
|
|
237
203
|
// check role id
|
|
238
204
|
uint64 roleIdInt = RoleId.unwrap(roleId);
|
|
239
205
|
if(roleIdInt == _accessManager.ADMIN_ROLE() || roleIdInt == _accessManager.PUBLIC_ROLE()) {
|
|
240
|
-
revert
|
|
206
|
+
revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
|
|
241
207
|
}
|
|
242
208
|
|
|
243
209
|
// prevent changing isCustom for existing roles
|
|
244
210
|
existingRole = _role[roleId];
|
|
245
211
|
|
|
246
212
|
if (existingRole.createdAt.gtz() && isCustom != existingRole.isCustom) {
|
|
247
|
-
revert
|
|
213
|
+
revert IAccess.ErrorIAccessRoleIsCustomIsImmutable(roleId, isCustom, existingRole.isCustom);
|
|
248
214
|
}
|
|
249
215
|
|
|
250
216
|
if (isCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
|
|
251
|
-
revert
|
|
217
|
+
revert IAccess.ErrorIAccessRoleIdTooSmall(roleId);
|
|
252
218
|
} else if (!isCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
|
|
253
|
-
revert
|
|
219
|
+
revert IAccess.ErrorIAccessRoleIdTooBig(roleId);
|
|
254
220
|
}
|
|
255
221
|
|
|
256
222
|
// role name checks
|
|
257
223
|
ShortString nameShort = ShortStrings.toShortString(name);
|
|
258
224
|
if (ShortStrings.byteLength(nameShort) == 0) {
|
|
259
|
-
revert
|
|
225
|
+
revert IAccess.ErrorIAccessRoleNameEmpty(roleId);
|
|
260
226
|
}
|
|
261
227
|
|
|
262
228
|
if (_roleForName[nameShort] != RoleIdLib.zero() && _roleForName[nameShort] != roleId) {
|
|
263
|
-
revert
|
|
229
|
+
revert IAccess.ErrorIAccessRoleNameNotUnique(_roleForName[nameShort], nameShort);
|
|
264
230
|
}
|
|
265
231
|
}
|
|
266
232
|
|
|
@@ -269,6 +235,13 @@ contract InstanceAccessManager is
|
|
|
269
235
|
_validateTargetParameters(target, name, isCustom);
|
|
270
236
|
}
|
|
271
237
|
|
|
238
|
+
if (_target[target].createdAt.gtz()) {
|
|
239
|
+
revert IAccess.ErrorIAccessTargetAlreadyExists(target, _target[target].name);
|
|
240
|
+
}
|
|
241
|
+
if (_targetForName[ShortStrings.toShortString(name)] != address(0)) {
|
|
242
|
+
revert IAccess.ErrorIAccessTargetNameExists(target, _targetForName[ShortStrings.toShortString(name)], ShortStrings.toShortString(name));
|
|
243
|
+
}
|
|
244
|
+
|
|
272
245
|
IAccess.TargetInfo memory info = IAccess.TargetInfo(
|
|
273
246
|
ShortStrings.toShortString(name),
|
|
274
247
|
isCustom,
|
|
@@ -303,15 +276,18 @@ contract InstanceAccessManager is
|
|
|
303
276
|
_accessManager.setTargetFunctionRole(target, selectors, roleIdInt);
|
|
304
277
|
}
|
|
305
278
|
|
|
306
|
-
function getAccessManager() public restricted() returns (AccessManagerUpgradeableInitializeable) {
|
|
307
|
-
return _accessManager;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
279
|
function setTargetClosed(string memory targetName, bool closed) public restricted() {
|
|
311
280
|
address target = _targetForName[ShortStrings.toShortString(targetName)];
|
|
281
|
+
if (target == address(0)) {
|
|
282
|
+
revert IAccess.ErrorIAccessTargetAddressZero();
|
|
283
|
+
}
|
|
312
284
|
_accessManager.setTargetClosed(target, closed);
|
|
313
285
|
}
|
|
314
286
|
|
|
287
|
+
function isTargetLocked(address target) public view returns (bool locked) {
|
|
288
|
+
return _accessManager.isTargetClosed(target);
|
|
289
|
+
}
|
|
290
|
+
|
|
315
291
|
function canCall(
|
|
316
292
|
address caller,
|
|
317
293
|
address target,
|
|
@@ -31,39 +31,21 @@ contract InstanceReader {
|
|
|
31
31
|
bool private _initialized;
|
|
32
32
|
|
|
33
33
|
IRegistry internal _registry;
|
|
34
|
-
NftId internal _instanceNftId;
|
|
35
34
|
IInstance internal _instance;
|
|
36
35
|
IKeyValueStore internal _store;
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
address registry,
|
|
40
|
-
NftId instanceNftId
|
|
41
|
-
)
|
|
42
|
-
{
|
|
43
|
-
initialize(registry, instanceNftId);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function initialize(address registry, NftId instanceNftId) public {
|
|
37
|
+
function initialize(address registry, address instance) public {
|
|
47
38
|
require(!_initialized, "ERROR:CRD-000:ALREADY_INITIALIZED");
|
|
48
39
|
|
|
49
40
|
require(
|
|
50
41
|
address(registry) != address(0),
|
|
51
42
|
"ERROR:CRD-001:REGISTRY_ZERO");
|
|
52
43
|
|
|
53
|
-
require(
|
|
54
|
-
instanceNftId.gtz(),
|
|
55
|
-
"ERROR:CRD-002:NFT_ID_ZERO");
|
|
56
44
|
|
|
57
45
|
_registry = IRegistry(registry);
|
|
58
|
-
_instanceNftId = instanceNftId;
|
|
59
|
-
IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(_instanceNftId);
|
|
60
46
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"ERROR:CRD-003:PARENT_NOT_INSTANCE");
|
|
64
|
-
|
|
65
|
-
_instance = IInstance(instanceInfo.objectAddress);
|
|
66
|
-
_store = IKeyValueStore(instanceInfo.objectAddress);
|
|
47
|
+
_instance = IInstance(instance);
|
|
48
|
+
_store = IKeyValueStore(instance);
|
|
67
49
|
|
|
68
50
|
_initialized = true;
|
|
69
51
|
}
|
|
@@ -301,10 +283,6 @@ contract InstanceReader {
|
|
|
301
283
|
return _store;
|
|
302
284
|
}
|
|
303
285
|
|
|
304
|
-
function getInstanceNftId() external view returns (NftId nftId) {
|
|
305
|
-
return _instanceNftId;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
286
|
function toUFixed(uint256 value, int8 exp) public pure returns (UFixed) {
|
|
309
287
|
return UFixedLib.toUFixed(value, exp);
|
|
310
288
|
}
|