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