@etherisc/gif-next 0.0.2-d551b5e-892 → 0.0.2-d5522f6-712
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +29 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +33 -102
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +29 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +33 -130
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +33 -113
- 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/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- 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 +26 -0
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +99 -14
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +82 -603
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +221 -114
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +2 -2
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +156 -192
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -98
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +24 -13
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- 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 +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/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1031 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +436 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +39 -52
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +47 -38
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -21
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +720 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +13 -13
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +121 -14
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +12 -241
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +32 -34
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +237 -65
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +51 -23
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +30 -320
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -41
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +43 -55
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +12 -12
- 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 +132 -133
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -65
- 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 +145 -227
- 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 +30 -128
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +546 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
- 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/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
- 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 +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
- 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 +2 -2
- 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 +31 -31
- 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/BaseComponent.sol +35 -8
- package/contracts/components/Distribution.sol +2 -1
- package/contracts/components/IBaseComponent.sol +3 -0
- package/contracts/components/Pool.sol +11 -6
- package/contracts/components/Product.sol +10 -1
- package/contracts/instance/IInstance.sol +4 -0
- package/contracts/instance/IInstanceService.sol +10 -2
- package/contracts/instance/Instance.sol +20 -204
- package/contracts/instance/InstanceAccessManager.sol +92 -77
- package/contracts/instance/InstanceService.sol +208 -115
- package/contracts/instance/InstanceServiceManager.sol +5 -8
- package/contracts/instance/base/ComponentServiceBase.sol +16 -12
- package/contracts/instance/module/IAccess.sol +27 -17
- package/contracts/instance/service/BundleService.sol +294 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/ComponentOwnerService.sol +4 -6
- package/contracts/instance/service/DistributionService.sol +21 -19
- package/contracts/instance/service/DistributionServiceManager.sol +6 -9
- package/contracts/instance/service/IBundleService.sol +44 -0
- package/contracts/instance/service/IPolicyService.sol +9 -2
- package/contracts/instance/service/IPoolService.sol +2 -33
- package/contracts/instance/service/IProductService.sol +2 -2
- package/contracts/instance/service/PolicyService.sol +70 -44
- package/contracts/instance/service/PoolService.sol +33 -205
- package/contracts/instance/service/PoolServiceManager.sol +5 -8
- package/contracts/instance/service/ProductService.sol +55 -15
- package/contracts/registry/ChainNft.sol +1 -1
- package/contracts/registry/IRegistry.sol +26 -16
- package/contracts/registry/IRegistryService.sol +13 -5
- package/contracts/registry/Registry.sol +149 -201
- package/contracts/registry/RegistryAccessManager.sol +210 -0
- package/contracts/registry/RegistryService.sol +49 -88
- package/contracts/registry/RegistryServiceManager.sol +18 -36
- package/contracts/registry/ReleaseManager.sol +348 -0
- package/contracts/registry/TokenRegistry.sol +5 -6
- package/contracts/shared/IService.sol +2 -1
- package/contracts/shared/ProxyManager.sol +1 -1
- package/contracts/shared/Service.sol +10 -7
- package/contracts/test/TestService.sol +3 -2
- package/contracts/types/RoleId.sol +10 -11
- package/package.json +1 -1
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
@@ -1,15 +1,21 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
5
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
6
|
+
|
4
7
|
import {IBaseComponent} from "./IBaseComponent.sol";
|
5
8
|
import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
|
6
|
-
import {
|
9
|
+
import {IInstanceService} from "../instance/IInstanceService.sol";
|
7
10
|
import {IInstance} from "../instance/IInstance.sol";
|
11
|
+
import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
|
8
12
|
import {IRegistry} from "../registry/IRegistry.sol";
|
9
13
|
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
10
|
-
import {ObjectType} from "../types/ObjectType.sol";
|
14
|
+
import {ObjectType, INSTANCE} from "../types/ObjectType.sol";
|
15
|
+
import {VersionLib} from "../types/Version.sol";
|
11
16
|
import {Registerable} from "../shared/Registerable.sol";
|
12
|
-
import {
|
17
|
+
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
18
|
+
import {IAccess} from "../instance/module/IAccess.sol";
|
13
19
|
|
14
20
|
abstract contract BaseComponent is
|
15
21
|
Registerable,
|
@@ -18,13 +24,30 @@ abstract contract BaseComponent is
|
|
18
24
|
using NftIdLib for NftId;
|
19
25
|
|
20
26
|
IComponentOwnerService internal _componentOwnerService;
|
27
|
+
IInstanceService internal _instanceService;
|
21
28
|
|
22
29
|
address internal _deployer;
|
23
30
|
address internal _wallet;
|
24
31
|
IERC20Metadata internal _token;
|
25
32
|
IInstance internal _instance;
|
33
|
+
InstanceAccessManager internal _instanceAccessManager;
|
26
34
|
NftId internal _productNftId;
|
27
35
|
|
36
|
+
modifier onlyInstanceRole(uint64 roleIdNum) {
|
37
|
+
RoleId roleId = RoleIdLib.toRoleId(roleIdNum);
|
38
|
+
if( !_instanceAccessManager.hasRole(roleId, msg.sender)) {
|
39
|
+
revert ErrorBaseComponentUnauthorized(msg.sender, roleIdNum);
|
40
|
+
}
|
41
|
+
_;
|
42
|
+
}
|
43
|
+
|
44
|
+
modifier isNotLocked() {
|
45
|
+
if (_instanceAccessManager.isTargetLocked(address(this))) {
|
46
|
+
revert IAccess.ErrorIAccessTargetLocked(address(this));
|
47
|
+
}
|
48
|
+
_;
|
49
|
+
}
|
50
|
+
|
28
51
|
constructor(
|
29
52
|
address registry,
|
30
53
|
NftId instanceNftId,
|
@@ -39,27 +62,31 @@ abstract contract BaseComponent is
|
|
39
62
|
|
40
63
|
IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
|
41
64
|
_instance = IInstance(instanceInfo.objectAddress);
|
65
|
+
_instanceAccessManager = _instance.getInstanceAccessManager();
|
42
66
|
require(
|
43
67
|
_instance.supportsInterface(type(IInstance).interfaceId),
|
44
68
|
""
|
45
69
|
);
|
46
70
|
|
47
71
|
_componentOwnerService = _instance.getComponentOwnerService();
|
72
|
+
_instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), VersionLib.toVersion(3, 0, 0).toMajorPart()));
|
48
73
|
_wallet = address(this);
|
49
74
|
_token = IERC20Metadata(token);
|
50
75
|
|
51
76
|
_registerInterface(type(IBaseComponent).interfaceId);
|
52
77
|
}
|
53
78
|
|
79
|
+
function getName() public pure virtual returns (string memory name);
|
80
|
+
|
54
81
|
// from component contract
|
55
|
-
// TODO
|
82
|
+
// TODO only owner and instance owner
|
56
83
|
function lock() external onlyOwner override {
|
57
|
-
|
84
|
+
_instanceService.setTargetLocked(getName(), true);
|
58
85
|
}
|
59
|
-
|
60
|
-
// TODO
|
86
|
+
|
87
|
+
// TODO only owner and instance owner
|
61
88
|
function unlock() external onlyOwner override {
|
62
|
-
|
89
|
+
_instanceService.setTargetLocked(getName(), false);
|
63
90
|
}
|
64
91
|
|
65
92
|
function getWallet()
|
@@ -16,7 +16,7 @@ import {Registerable} from "../shared/Registerable.sol";
|
|
16
16
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
17
17
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
18
18
|
|
19
|
-
contract Distribution is
|
19
|
+
abstract contract Distribution is
|
20
20
|
BaseComponent,
|
21
21
|
IDistributionComponent
|
22
22
|
{
|
@@ -150,6 +150,7 @@ contract Distribution is
|
|
150
150
|
return (
|
151
151
|
info,
|
152
152
|
abi.encode(
|
153
|
+
getName(),
|
153
154
|
ISetup.DistributionSetupInfo(
|
154
155
|
_productNftId,
|
155
156
|
_tokenHandler,
|
@@ -10,10 +10,13 @@ import {NftId} from "../types/NftId.sol";
|
|
10
10
|
interface IBaseComponent is IRegisterable {
|
11
11
|
error ErrorBaseComponentWalletAddressIsSameAsCurrent(address newWallet);
|
12
12
|
error ErrorBaseComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
|
13
|
+
error ErrorBaseComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
|
13
14
|
|
14
15
|
event LogBaseComponentWalletAddressChanged(address newWallet);
|
15
16
|
event LogBaseComponentWalletTokensTransferred(address from, address to, uint256 amount);
|
16
17
|
|
18
|
+
function getName() external pure virtual returns (string memory name);
|
19
|
+
|
17
20
|
function lock() external;
|
18
21
|
|
19
22
|
function unlock() external;
|
@@ -4,6 +4,7 @@ pragma solidity ^0.8.20;
|
|
4
4
|
import {ObjectType, POOL} from "../types/ObjectType.sol";
|
5
5
|
import {IProductService} from "../instance/service/IProductService.sol";
|
6
6
|
import {IPoolService} from "../instance/service/IPoolService.sol";
|
7
|
+
import {IBundleService} from "../instance/service/IBundleService.sol";
|
7
8
|
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
8
9
|
import {Fee} from "../types/Fee.sol";
|
9
10
|
import {UFixed} from "../types/UFixed.sol";
|
@@ -22,7 +23,7 @@ import {InstanceReader} from "../instance/InstanceReader.sol";
|
|
22
23
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
23
24
|
import {Registerable} from "../shared/Registerable.sol";
|
24
25
|
|
25
|
-
contract Pool is BaseComponent, IPoolComponent {
|
26
|
+
abstract contract Pool is BaseComponent, IPoolComponent {
|
26
27
|
using NftIdLib for NftId;
|
27
28
|
|
28
29
|
bool internal _isConfirmingApplication;
|
@@ -40,6 +41,8 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
40
41
|
// only relevant to protect callback functions for "active" pools
|
41
42
|
IProductService private _productService;
|
42
43
|
|
44
|
+
IBundleService private _bundleService;
|
45
|
+
|
43
46
|
modifier onlyPoolService() {
|
44
47
|
require(
|
45
48
|
msg.sender == address(_poolService),
|
@@ -80,6 +83,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
80
83
|
|
81
84
|
_poolService = _instance.getPoolService();
|
82
85
|
_productService = _instance.getProductService();
|
86
|
+
_bundleService = _instance.getBundleService();
|
83
87
|
|
84
88
|
_registerInterface(type(IPoolComponent).interfaceId);
|
85
89
|
}
|
@@ -95,7 +99,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
95
99
|
returns(NftId bundleNftId)
|
96
100
|
{
|
97
101
|
address owner = msg.sender;
|
98
|
-
bundleNftId =
|
102
|
+
bundleNftId = _bundleService.createBundle(
|
99
103
|
owner,
|
100
104
|
fee,
|
101
105
|
initialAmount,
|
@@ -168,7 +172,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
168
172
|
override
|
169
173
|
// TODO add onlyBundleOwner
|
170
174
|
{
|
171
|
-
|
175
|
+
_bundleService.setBundleFee(bundleNftId, fee);
|
172
176
|
}
|
173
177
|
|
174
178
|
function lockBundle(
|
@@ -178,7 +182,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
178
182
|
override
|
179
183
|
// TODO add onlyBundleOwner
|
180
184
|
{
|
181
|
-
|
185
|
+
_bundleService.lockBundle(bundleNftId);
|
182
186
|
}
|
183
187
|
|
184
188
|
function unlockBundle(
|
@@ -188,7 +192,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
188
192
|
override
|
189
193
|
// TODO add onlyBundleOwner
|
190
194
|
{
|
191
|
-
|
195
|
+
_bundleService.unlockBundle(bundleNftId);
|
192
196
|
}
|
193
197
|
|
194
198
|
function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
|
@@ -213,6 +217,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
213
217
|
return (
|
214
218
|
info,
|
215
219
|
abi.encode(
|
220
|
+
getName(),
|
216
221
|
ISetup.PoolSetupInfo(
|
217
222
|
_productNftId,
|
218
223
|
_tokenHandler,
|
@@ -256,7 +261,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
256
261
|
internal
|
257
262
|
returns(NftId bundleNftId)
|
258
263
|
{
|
259
|
-
bundleNftId =
|
264
|
+
bundleNftId = _bundleService.createBundle(
|
260
265
|
bundleOwner,
|
261
266
|
fee,
|
262
267
|
amount,
|
@@ -29,7 +29,7 @@ import {Distribution} from "../components/Distribution.sol";
|
|
29
29
|
|
30
30
|
import {zeroNftId} from "../types/NftId.sol";
|
31
31
|
|
32
|
-
contract Product is BaseComponent, IProductComponent {
|
32
|
+
abstract contract Product is BaseComponent, IProductComponent {
|
33
33
|
using NftIdLib for NftId;
|
34
34
|
|
35
35
|
IProductService internal _productService;
|
@@ -203,6 +203,14 @@ contract Product is BaseComponent, IProductComponent {
|
|
203
203
|
activateAt);
|
204
204
|
}
|
205
205
|
|
206
|
+
function _close(
|
207
|
+
NftId policyNftId
|
208
|
+
)
|
209
|
+
internal
|
210
|
+
{
|
211
|
+
_policyService.close(policyNftId);
|
212
|
+
}
|
213
|
+
|
206
214
|
function getPoolNftId() external view override returns (NftId poolNftId) {
|
207
215
|
return getRegistry().getNftId(address(_pool));
|
208
216
|
}
|
@@ -272,6 +280,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
272
280
|
return (
|
273
281
|
productInfo,
|
274
282
|
abi.encode(
|
283
|
+
getName(),
|
275
284
|
ISetup.ProductSetupInfo(
|
276
285
|
_token,
|
277
286
|
_tokenHandler,
|
@@ -6,11 +6,13 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
6
|
import {BundleManager} from "./BundleManager.sol";
|
7
7
|
import {InstanceReader} from "./InstanceReader.sol";
|
8
8
|
|
9
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
9
10
|
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
10
11
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
11
12
|
import {IPoolService} from "./service/IPoolService.sol";
|
12
13
|
import {IProductService} from "./service/IProductService.sol";
|
13
14
|
import {IPolicyService} from "./service/IPolicyService.sol";
|
15
|
+
import {IBundleService} from "./service/IBundleService.sol";
|
14
16
|
import {IBundle} from "./module/IBundle.sol";
|
15
17
|
import {ISetup} from "./module/ISetup.sol";
|
16
18
|
import {NftId} from "../types/NftId.sol";
|
@@ -28,6 +30,7 @@ interface IInstance is IERC165, IKeyValueStore {
|
|
28
30
|
function getProductService() external view returns (IProductService);
|
29
31
|
function getPoolService() external view returns (IPoolService);
|
30
32
|
function getPolicyService() external view returns (IPolicyService);
|
33
|
+
function getBundleService() external view returns (IBundleService);
|
31
34
|
|
32
35
|
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
|
33
36
|
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
|
@@ -53,6 +56,7 @@ interface IInstance is IERC165, IKeyValueStore {
|
|
53
56
|
function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
|
54
57
|
function updatePolicyState(NftId policyNftId, StateId newState) external;
|
55
58
|
|
59
|
+
function getInstanceAccessManager() external view returns (InstanceAccessManager);
|
56
60
|
function getInstanceReader() external view returns (InstanceReader);
|
57
61
|
function getBundleManager() external view returns (BundleManager);
|
58
62
|
}
|
@@ -10,23 +10,31 @@ import {IRegistry} from "../registry/IRegistry.sol";
|
|
10
10
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
11
11
|
import {IBaseComponent} from "../components/IBaseComponent.sol";
|
12
12
|
|
13
|
-
import {
|
13
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
14
14
|
import {Instance} from "./Instance.sol";
|
15
15
|
import {InstanceReader} from "./InstanceReader.sol";
|
16
16
|
import {BundleManager} from "./BundleManager.sol";
|
17
17
|
|
18
18
|
interface IInstanceService is IService {
|
19
19
|
|
20
|
+
error ErrorInstanceServiceRequestUnauhorized(address caller);
|
21
|
+
error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
|
22
|
+
error ErrorInstanceServiceComponentNotRegistered(address componentAddress);
|
23
|
+
|
20
24
|
event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
|
21
25
|
|
22
26
|
function createInstanceClone()
|
23
27
|
external
|
24
28
|
returns (
|
25
|
-
|
29
|
+
InstanceAccessManager clonedAccessManager,
|
26
30
|
Instance clonedInstance,
|
27
31
|
NftId instanceNftId,
|
28
32
|
InstanceReader clonedInstanceReader,
|
29
33
|
BundleManager clonedBundleManager
|
30
34
|
);
|
35
|
+
|
36
|
+
function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
|
37
|
+
function setTargetLocked(string memory targetName, bool locked) external;
|
38
|
+
|
31
39
|
}
|
32
40
|
|
@@ -5,7 +5,6 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
|
|
5
5
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
6
|
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
7
7
|
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
8
|
-
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
9
8
|
|
10
9
|
import {IAccess} from "./module/IAccess.sol";
|
11
10
|
import {IBundle} from "./module/IBundle.sol";
|
@@ -16,13 +15,15 @@ import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
|
16
15
|
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
17
16
|
import {IInstance} from "./IInstance.sol";
|
18
17
|
import {InstanceReader} from "./InstanceReader.sol";
|
18
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
19
19
|
import {BundleManager} from "./BundleManager.sol";
|
20
20
|
import {NftId} from "../types/NftId.sol";
|
21
21
|
import {NumberId} from "../types/NumberId.sol";
|
22
|
-
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
22
|
+
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT} from "../types/ObjectType.sol";
|
23
23
|
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
24
24
|
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
25
25
|
import {StateId, ACTIVE} from "../types/StateId.sol";
|
26
|
+
import {TimestampLib} from "../types/Timestamp.sol";
|
26
27
|
import {ERC165} from "../shared/ERC165.sol";
|
27
28
|
import {Registerable} from "../shared/Registerable.sol";
|
28
29
|
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
@@ -31,6 +32,7 @@ import {IDistributionService} from "./service/IDistributionService.sol";
|
|
31
32
|
import {IPoolService} from "./service/IPoolService.sol";
|
32
33
|
import {IProductService} from "./service/IProductService.sol";
|
33
34
|
import {IPolicyService} from "./service/IPolicyService.sol";
|
35
|
+
import {IBundleService} from "./service/IBundleService.sol";
|
34
36
|
import {VersionPart} from "../types/Version.sol";
|
35
37
|
import {InstanceBase} from "./InstanceBase.sol";
|
36
38
|
|
@@ -49,13 +51,7 @@ contract Instance is
|
|
49
51
|
|
50
52
|
bool private _initialized;
|
51
53
|
|
52
|
-
|
53
|
-
mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
|
54
|
-
RoleId [] internal _roles;
|
55
|
-
|
56
|
-
mapping(ShortString name => address target) internal _target;
|
57
|
-
|
58
|
-
AccessManagerUpgradeable internal _accessManager;
|
54
|
+
InstanceAccessManager internal _accessManager;
|
59
55
|
InstanceReader internal _instanceReader;
|
60
56
|
BundleManager internal _bundleManager;
|
61
57
|
|
@@ -67,136 +63,14 @@ contract Instance is
|
|
67
63
|
|
68
64
|
__AccessManaged_init(accessManagerAddress);
|
69
65
|
|
70
|
-
_accessManager =
|
71
|
-
|
72
|
-
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
73
|
-
|
66
|
+
_accessManager = InstanceAccessManager(accessManagerAddress);
|
67
|
+
|
74
68
|
_initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
|
75
69
|
|
76
70
|
_registerInterface(type(IInstance).interfaceId);
|
77
71
|
_initialized = true;
|
78
72
|
}
|
79
73
|
|
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.toInt(), member, EXECUTION_DELAY);
|
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.toInt(), 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.renounceRole(roleId.toInt(), 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, IAccess.TargetInfo memory targetInfo) external restricted() {
|
188
|
-
_validateTargetParameters(target, targetInfo);
|
189
|
-
create(toTargetKey32(target), abi.encode(targetInfo));
|
190
|
-
}
|
191
|
-
|
192
|
-
function setTargetClosed(address target, bool closed) external restricted() {
|
193
|
-
if (!exists(toTargetKey32(target))) {
|
194
|
-
revert IAccess.ErrorTargetDoesNotExist(target);
|
195
|
-
}
|
196
|
-
|
197
|
-
_accessManager.setTargetClosed(target, closed);
|
198
|
-
}
|
199
|
-
|
200
74
|
//--- ProductSetup ------------------------------------------------------//
|
201
75
|
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external restricted() {
|
202
76
|
create(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup));
|
@@ -341,71 +215,6 @@ contract Instance is
|
|
341
215
|
}
|
342
216
|
|
343
217
|
//--- internal view/pure functions --------------------------------------//
|
344
|
-
function _toRole(RoleId roleId, string memory name, bool isCustom)
|
345
|
-
internal
|
346
|
-
pure
|
347
|
-
returns (IAccess.RoleInfo memory role)
|
348
|
-
{
|
349
|
-
return IAccess.RoleInfo(
|
350
|
-
ShortStrings.toShortString(name),
|
351
|
-
isCustom);
|
352
|
-
}
|
353
|
-
|
354
|
-
function _validateRoleParameters(
|
355
|
-
RoleId roleId,
|
356
|
-
string memory name,
|
357
|
-
bool isCustom
|
358
|
-
)
|
359
|
-
internal
|
360
|
-
view
|
361
|
-
returns (
|
362
|
-
bool roleExists,
|
363
|
-
bool roleIsCustom
|
364
|
-
)
|
365
|
-
{
|
366
|
-
Key32 roleKey = toRoleKey32(roleId);
|
367
|
-
roleExists = exists(roleKey);
|
368
|
-
if (roleExists) {
|
369
|
-
roleIsCustom = abi.decode(getData(roleKey), (IAccess.RoleInfo)).isCustom;
|
370
|
-
} else {
|
371
|
-
roleIsCustom = isCustom;
|
372
|
-
}
|
373
|
-
|
374
|
-
// check role id
|
375
|
-
uint64 roleIdInt = RoleId.unwrap(roleId);
|
376
|
-
if(roleIdInt == ADMIN_ROLE || roleIdInt == PUBLIC_ROLE) {
|
377
|
-
revert IAccess.ErrorRoleIdInvalid(roleId);
|
378
|
-
}
|
379
|
-
|
380
|
-
if (roleIsCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
|
381
|
-
revert IAccess.ErrorRoleIdTooSmall(roleId);
|
382
|
-
} else if (roleIsCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
|
383
|
-
revert IAccess.ErrorRoleIdTooBig(roleId);
|
384
|
-
}
|
385
|
-
|
386
|
-
// role name checks
|
387
|
-
ShortString nameShort = ShortStrings.toShortString(name);
|
388
|
-
if (ShortStrings.byteLength(nameShort) == 0) {
|
389
|
-
revert IAccess.ErrorRoleNameEmpty(roleId);
|
390
|
-
}
|
391
|
-
|
392
|
-
if (_role[nameShort] != RoleIdLib.zero() && _role[nameShort] != roleId) {
|
393
|
-
revert IAccess.ErrorRoleNameNotUnique(_role[nameShort], nameShort);
|
394
|
-
}
|
395
|
-
}
|
396
|
-
|
397
|
-
function _validateTargetParameters(address target, IAccess.TargetInfo memory targetInfo) internal view {
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
function toRoleKey32(RoleId roleId) public pure returns (Key32) {
|
402
|
-
return roleId.toKey32();
|
403
|
-
}
|
404
|
-
|
405
|
-
function toTargetKey32(address target) public pure returns (Key32) {
|
406
|
-
return Key32Lib.toKey32(TARGET(), KeyId.wrap(bytes20(target)));
|
407
|
-
}
|
408
|
-
|
409
218
|
function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
|
410
219
|
return nftId.toKey32(objectType);
|
411
220
|
}
|
@@ -419,27 +228,34 @@ contract Instance is
|
|
419
228
|
}
|
420
229
|
|
421
230
|
function getComponentOwnerService() external view returns (IComponentOwnerService) {
|
422
|
-
return ComponentOwnerService(_registry.getServiceAddress(
|
231
|
+
return ComponentOwnerService(_registry.getServiceAddress(COMPONENT(), VersionPart.wrap(3)));
|
423
232
|
}
|
424
233
|
|
425
234
|
function getDistributionService() external view returns (IDistributionService) {
|
426
|
-
return IDistributionService(_registry.getServiceAddress(
|
235
|
+
return IDistributionService(_registry.getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
|
427
236
|
}
|
428
237
|
|
429
238
|
function getProductService() external view returns (IProductService) {
|
430
|
-
return IProductService(_registry.getServiceAddress(
|
239
|
+
return IProductService(_registry.getServiceAddress(PRODUCT(), VersionPart.wrap(3)));
|
431
240
|
}
|
432
241
|
|
433
242
|
function getPoolService() external view returns (IPoolService) {
|
434
|
-
return IPoolService(_registry.getServiceAddress(
|
243
|
+
return IPoolService(_registry.getServiceAddress(POOL(), VersionPart.wrap(3)));
|
435
244
|
}
|
436
245
|
|
437
246
|
function getPolicyService() external view returns (IPolicyService) {
|
438
|
-
return IPolicyService(_registry.getServiceAddress(
|
247
|
+
return IPolicyService(_registry.getServiceAddress(POLICY(), VersionPart.wrap(3)));
|
248
|
+
}
|
249
|
+
|
250
|
+
function getBundleService() external view returns (IBundleService) {
|
251
|
+
return IBundleService(_registry.getServiceAddress(BUNDLE(), VersionPart.wrap(3)));
|
252
|
+
}
|
253
|
+
|
254
|
+
function getInstanceAccessManager() external view returns (InstanceAccessManager) {
|
255
|
+
return _accessManager;
|
439
256
|
}
|
440
257
|
|
441
258
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
442
|
-
require(address(_instanceReader) == address(0), "InstanceReader is set");
|
443
259
|
require(instanceReader.getInstanceNftId() == getNftId(), "NFT ID of InstanceReader does not match");
|
444
260
|
_instanceReader = instanceReader;
|
445
261
|
}
|