@etherisc/gif-next 0.0.2-a6faeb6-912 → 0.0.2-a7954cc-097
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/contracts/components/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 +39 -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 +88 -14
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +92 -600
- 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 +129 -189
- 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 -32
- 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 +945 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +432 -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 +49 -72
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -37
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +669 -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 +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +664 -0
- 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 +17 -241
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +993 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +464 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +32 -354
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -57
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +40 -410
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -81
- 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 +1 -1
- package/contracts/components/IBaseComponent.sol +3 -0
- package/contracts/components/Pool.sol +10 -6
- package/contracts/components/Product.sol +9 -6
- package/contracts/instance/IInstance.sol +6 -0
- package/contracts/instance/IInstanceService.sol +9 -3
- package/contracts/instance/Instance.sol +24 -202
- package/contracts/instance/InstanceAccessManager.sol +92 -77
- package/contracts/instance/InstanceService.sol +154 -57
- package/contracts/instance/InstanceServiceManager.sol +5 -8
- package/contracts/instance/base/ComponentServiceBase.sol +32 -84
- package/contracts/instance/module/IAccess.sol +27 -17
- package/contracts/instance/service/BundleService.sol +260 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/ComponentOwnerService.sol +4 -6
- package/contracts/instance/service/DistributionService.sol +45 -20
- package/contracts/instance/service/DistributionServiceManager.sol +6 -9
- package/contracts/instance/service/IBundleService.sol +45 -0
- package/contracts/instance/service/IPolicyService.sol +87 -0
- package/contracts/instance/service/IPoolService.sol +2 -33
- package/contracts/instance/service/IProductService.sol +2 -72
- package/contracts/instance/service/PolicyService.sol +503 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +43 -206
- package/contracts/instance/service/PoolServiceManager.sol +5 -8
- package/contracts/instance/service/ProductService.sol +56 -456
- 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 +48 -83
- 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 -10
- 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
|
{
|
@@ -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) {
|
@@ -256,7 +260,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
256
260
|
internal
|
257
261
|
returns(NftId bundleNftId)
|
258
262
|
{
|
259
|
-
bundleNftId =
|
263
|
+
bundleNftId = _bundleService.createBundle(
|
260
264
|
bundleOwner,
|
261
265
|
fee,
|
262
266
|
amount,
|
@@ -6,6 +6,7 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
6
6
|
import {IRisk} from "../instance/module/IRisk.sol";
|
7
7
|
import {ITreasury} from "../instance/module/ITreasury.sol";
|
8
8
|
import {IProductService} from "../instance/service/IProductService.sol";
|
9
|
+
import {IPolicyService} from "../instance/service/IPolicyService.sol";
|
9
10
|
import {IProductComponent} from "./IProductComponent.sol";
|
10
11
|
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
11
12
|
import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
|
@@ -28,10 +29,11 @@ import {Distribution} from "../components/Distribution.sol";
|
|
28
29
|
|
29
30
|
import {zeroNftId} from "../types/NftId.sol";
|
30
31
|
|
31
|
-
contract Product is BaseComponent, IProductComponent {
|
32
|
+
abstract contract Product is BaseComponent, IProductComponent {
|
32
33
|
using NftIdLib for NftId;
|
33
34
|
|
34
35
|
IProductService internal _productService;
|
36
|
+
IPolicyService internal _policyService;
|
35
37
|
Pool internal _pool;
|
36
38
|
Distribution internal _distribution;
|
37
39
|
Fee internal _initialProductFee;
|
@@ -54,6 +56,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
54
56
|
) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
|
55
57
|
// TODO add validation
|
56
58
|
_productService = _instance.getProductService();
|
59
|
+
_policyService = _instance.getPolicyService();
|
57
60
|
_pool = Pool(pool);
|
58
61
|
_distribution = Distribution(distribution);
|
59
62
|
_initialProductFee = productFee;
|
@@ -81,7 +84,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
81
84
|
override
|
82
85
|
returns (uint256 premiumAmount)
|
83
86
|
{
|
84
|
-
(premiumAmount,,,,) =
|
87
|
+
(premiumAmount,,,,) = _policyService.calculatePremium(
|
85
88
|
riskId,
|
86
89
|
sumInsuredAmount,
|
87
90
|
lifetime,
|
@@ -154,7 +157,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
154
157
|
NftId bundleNftId,
|
155
158
|
ReferralId referralId
|
156
159
|
) internal returns (NftId nftId) {
|
157
|
-
nftId =
|
160
|
+
nftId = _policyService.createApplication(
|
158
161
|
applicationOwner,
|
159
162
|
riskId,
|
160
163
|
sumInsuredAmount,
|
@@ -172,7 +175,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
172
175
|
)
|
173
176
|
internal
|
174
177
|
{
|
175
|
-
|
178
|
+
_policyService.underwrite(
|
176
179
|
policyNftId,
|
177
180
|
requirePremiumPayment,
|
178
181
|
activateAt);
|
@@ -184,7 +187,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
184
187
|
)
|
185
188
|
internal
|
186
189
|
{
|
187
|
-
|
190
|
+
_policyService.collectPremium(
|
188
191
|
policyNftId,
|
189
192
|
activateAt);
|
190
193
|
}
|
@@ -195,7 +198,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
195
198
|
)
|
196
199
|
internal
|
197
200
|
{
|
198
|
-
|
201
|
+
_policyService.activate(
|
199
202
|
policyNftId,
|
200
203
|
activateAt);
|
201
204
|
}
|
@@ -6,10 +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";
|
14
|
+
import {IPolicyService} from "./service/IPolicyService.sol";
|
15
|
+
import {IBundleService} from "./service/IBundleService.sol";
|
13
16
|
import {IBundle} from "./module/IBundle.sol";
|
14
17
|
import {ISetup} from "./module/ISetup.sol";
|
15
18
|
import {NftId} from "../types/NftId.sol";
|
@@ -26,6 +29,8 @@ interface IInstance is IERC165, IKeyValueStore {
|
|
26
29
|
function getDistributionService() external view returns (IDistributionService);
|
27
30
|
function getProductService() external view returns (IProductService);
|
28
31
|
function getPoolService() external view returns (IPoolService);
|
32
|
+
function getPolicyService() external view returns (IPolicyService);
|
33
|
+
function getBundleService() external view returns (IBundleService);
|
29
34
|
|
30
35
|
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
|
31
36
|
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
|
@@ -51,6 +56,7 @@ interface IInstance is IERC165, IKeyValueStore {
|
|
51
56
|
function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
|
52
57
|
function updatePolicyState(NftId policyNftId, StateId newState) external;
|
53
58
|
|
59
|
+
function getInstanceAccessManager() external view returns (InstanceAccessManager);
|
54
60
|
function getInstanceReader() external view returns (InstanceReader);
|
55
61
|
function getBundleManager() external view returns (BundleManager);
|
56
62
|
}
|
@@ -10,7 +10,7 @@ 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";
|
@@ -18,17 +18,23 @@ import {BundleManager} from "./BundleManager.sol";
|
|
18
18
|
interface IInstanceService is IService {
|
19
19
|
|
20
20
|
error ErrorInstanceServiceRequestUnauhorized(address caller);
|
21
|
-
|
21
|
+
error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
|
22
|
+
error ErrorInstanceServiceComponentNotRegistered(address componentAddress);
|
23
|
+
|
22
24
|
event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
|
23
25
|
|
24
26
|
function createInstanceClone()
|
25
27
|
external
|
26
28
|
returns (
|
27
|
-
|
29
|
+
InstanceAccessManager clonedAccessManager,
|
28
30
|
Instance clonedInstance,
|
29
31
|
NftId instanceNftId,
|
30
32
|
InstanceReader clonedInstanceReader,
|
31
33
|
BundleManager clonedBundleManager
|
32
34
|
);
|
35
|
+
|
36
|
+
function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
|
37
|
+
function setTargetLocked(string memory targetName, bool locked) external;
|
38
|
+
|
33
39
|
}
|
34
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";
|
@@ -30,6 +31,8 @@ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
|
30
31
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
31
32
|
import {IPoolService} from "./service/IPoolService.sol";
|
32
33
|
import {IProductService} from "./service/IProductService.sol";
|
34
|
+
import {IPolicyService} from "./service/IPolicyService.sol";
|
35
|
+
import {IBundleService} from "./service/IBundleService.sol";
|
33
36
|
import {VersionPart} from "../types/Version.sol";
|
34
37
|
import {InstanceBase} from "./InstanceBase.sol";
|
35
38
|
|
@@ -48,13 +51,7 @@ contract Instance is
|
|
48
51
|
|
49
52
|
bool private _initialized;
|
50
53
|
|
51
|
-
|
52
|
-
mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
|
53
|
-
RoleId [] internal _roles;
|
54
|
-
|
55
|
-
mapping(ShortString name => address target) internal _target;
|
56
|
-
|
57
|
-
AccessManagerUpgradeable internal _accessManager;
|
54
|
+
InstanceAccessManager internal _accessManager;
|
58
55
|
InstanceReader internal _instanceReader;
|
59
56
|
BundleManager internal _bundleManager;
|
60
57
|
|
@@ -66,136 +63,14 @@ contract Instance is
|
|
66
63
|
|
67
64
|
__AccessManaged_init(accessManagerAddress);
|
68
65
|
|
69
|
-
_accessManager =
|
70
|
-
|
71
|
-
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
72
|
-
|
66
|
+
_accessManager = InstanceAccessManager(accessManagerAddress);
|
67
|
+
|
73
68
|
_initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
|
74
69
|
|
75
70
|
_registerInterface(type(IInstance).interfaceId);
|
76
71
|
_initialized = true;
|
77
72
|
}
|
78
73
|
|
79
|
-
//--- Role ------------------------------------------------------//
|
80
|
-
function createStandardRole(RoleId roleId, string memory name) external restricted() {
|
81
|
-
_createRole(roleId, name, false, true);
|
82
|
-
}
|
83
|
-
|
84
|
-
function createCustomRole(RoleId roleId, string memory name) external restricted() {
|
85
|
-
_createRole(roleId, name, true, true);
|
86
|
-
}
|
87
|
-
|
88
|
-
function updateRole(RoleId roleId, string memory name, StateId newState) external restricted() {
|
89
|
-
(bool isCustom,) = _validateRoleParameters(roleId, name, false);
|
90
|
-
IAccess.RoleInfo memory role = _toRole(roleId, name, isCustom);
|
91
|
-
update(toRoleKey32(roleId), abi.encode(role), newState);
|
92
|
-
}
|
93
|
-
|
94
|
-
function updateRoleState(RoleId roleId, StateId newState) external restricted() {
|
95
|
-
updateState(toRoleKey32(roleId), newState);
|
96
|
-
}
|
97
|
-
|
98
|
-
function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
|
99
|
-
Key32 roleKey = toRoleKey32(roleId);
|
100
|
-
|
101
|
-
if (!exists(roleKey)) {
|
102
|
-
revert IAccess.ErrorGrantNonexstentRole(roleId);
|
103
|
-
}
|
104
|
-
|
105
|
-
if (getState(roleKey) != ACTIVE()) {
|
106
|
-
revert IAccess.ErrorRoleIdNotActive(roleId);
|
107
|
-
}
|
108
|
-
|
109
|
-
if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
|
110
|
-
_accessManager.grantRole(roleId.toInt(), member, EXECUTION_DELAY);
|
111
|
-
EnumerableSet.add(_roleMembers[roleId], member);
|
112
|
-
return true;
|
113
|
-
}
|
114
|
-
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
|
118
|
-
function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
|
119
|
-
Key32 roleKey = toRoleKey32(roleId);
|
120
|
-
|
121
|
-
if (!exists(roleKey)) {
|
122
|
-
revert IAccess.ErrorRevokeNonexstentRole(roleId);
|
123
|
-
}
|
124
|
-
|
125
|
-
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
126
|
-
_accessManager.revokeRole(roleId.toInt(), member);
|
127
|
-
EnumerableSet.remove(_roleMembers[roleId], member);
|
128
|
-
return true;
|
129
|
-
}
|
130
|
-
|
131
|
-
return false;
|
132
|
-
}
|
133
|
-
|
134
|
-
/// @dev not restricted function by intention
|
135
|
-
/// the restriction to role members is already enforced by the call to the access manger
|
136
|
-
function renounceRole(RoleId roleId) external returns (bool revoked) {
|
137
|
-
address member = msg.sender;
|
138
|
-
Key32 roleKey = toRoleKey32(roleId);
|
139
|
-
|
140
|
-
if (!exists(roleKey)) {
|
141
|
-
revert IAccess.ErrorRenounceNonexstentRole(roleId);
|
142
|
-
}
|
143
|
-
|
144
|
-
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
145
|
-
_accessManager.renounceRole(roleId.toInt(), member);
|
146
|
-
EnumerableSet.remove(_roleMembers[roleId], member);
|
147
|
-
return true;
|
148
|
-
}
|
149
|
-
|
150
|
-
return false;
|
151
|
-
}
|
152
|
-
|
153
|
-
function roles() external view returns (uint256 numberOfRoles) {
|
154
|
-
return _roles.length;
|
155
|
-
}
|
156
|
-
|
157
|
-
function getRoleId(uint256 idx) external view returns (RoleId roleId) {
|
158
|
-
return _roles[idx];
|
159
|
-
}
|
160
|
-
|
161
|
-
function getRole(RoleId roleId) external view returns (IAccess.RoleInfo memory role) {
|
162
|
-
return abi.decode(getData(roleId.toKey32()), (IAccess.RoleInfo));
|
163
|
-
}
|
164
|
-
|
165
|
-
function roleMembers(RoleId roleId) external view returns (uint256 numberOfMembers) {
|
166
|
-
return EnumerableSet.length(_roleMembers[roleId]);
|
167
|
-
}
|
168
|
-
|
169
|
-
function getRoleMember(RoleId roleId, uint256 idx) external view returns (address roleMember) {
|
170
|
-
return EnumerableSet.at(_roleMembers[roleId], idx);
|
171
|
-
}
|
172
|
-
|
173
|
-
function _createRole(RoleId roleId, string memory name, bool isCustom, bool validateParameters) internal {
|
174
|
-
if (validateParameters) {
|
175
|
-
_validateRoleParameters(roleId, name, isCustom);
|
176
|
-
}
|
177
|
-
|
178
|
-
IAccess.RoleInfo memory role = _toRole(roleId, name, isCustom);
|
179
|
-
_role[role.name] = roleId;
|
180
|
-
_roles.push(roleId);
|
181
|
-
|
182
|
-
create(toRoleKey32(roleId), abi.encode(role));
|
183
|
-
}
|
184
|
-
|
185
|
-
//--- Target ------------------------------------------------------//
|
186
|
-
function createTarget(address target, IAccess.TargetInfo memory targetInfo) external restricted() {
|
187
|
-
_validateTargetParameters(target, targetInfo);
|
188
|
-
create(toTargetKey32(target), abi.encode(targetInfo));
|
189
|
-
}
|
190
|
-
|
191
|
-
function setTargetClosed(address target, bool closed) external restricted() {
|
192
|
-
if (!exists(toTargetKey32(target))) {
|
193
|
-
revert IAccess.ErrorTargetDoesNotExist(target);
|
194
|
-
}
|
195
|
-
|
196
|
-
_accessManager.setTargetClosed(target, closed);
|
197
|
-
}
|
198
|
-
|
199
74
|
//--- ProductSetup ------------------------------------------------------//
|
200
75
|
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external restricted() {
|
201
76
|
create(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup));
|
@@ -340,71 +215,6 @@ contract Instance is
|
|
340
215
|
}
|
341
216
|
|
342
217
|
//--- internal view/pure functions --------------------------------------//
|
343
|
-
function _toRole(RoleId roleId, string memory name, bool isCustom)
|
344
|
-
internal
|
345
|
-
pure
|
346
|
-
returns (IAccess.RoleInfo memory role)
|
347
|
-
{
|
348
|
-
return IAccess.RoleInfo(
|
349
|
-
ShortStrings.toShortString(name),
|
350
|
-
isCustom);
|
351
|
-
}
|
352
|
-
|
353
|
-
function _validateRoleParameters(
|
354
|
-
RoleId roleId,
|
355
|
-
string memory name,
|
356
|
-
bool isCustom
|
357
|
-
)
|
358
|
-
internal
|
359
|
-
view
|
360
|
-
returns (
|
361
|
-
bool roleExists,
|
362
|
-
bool roleIsCustom
|
363
|
-
)
|
364
|
-
{
|
365
|
-
Key32 roleKey = toRoleKey32(roleId);
|
366
|
-
roleExists = exists(roleKey);
|
367
|
-
if (roleExists) {
|
368
|
-
roleIsCustom = abi.decode(getData(roleKey), (IAccess.RoleInfo)).isCustom;
|
369
|
-
} else {
|
370
|
-
roleIsCustom = isCustom;
|
371
|
-
}
|
372
|
-
|
373
|
-
// check role id
|
374
|
-
uint64 roleIdInt = RoleId.unwrap(roleId);
|
375
|
-
if(roleIdInt == ADMIN_ROLE || roleIdInt == PUBLIC_ROLE) {
|
376
|
-
revert IAccess.ErrorRoleIdInvalid(roleId);
|
377
|
-
}
|
378
|
-
|
379
|
-
if (roleIsCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
|
380
|
-
revert IAccess.ErrorRoleIdTooSmall(roleId);
|
381
|
-
} else if (roleIsCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
|
382
|
-
revert IAccess.ErrorRoleIdTooBig(roleId);
|
383
|
-
}
|
384
|
-
|
385
|
-
// role name checks
|
386
|
-
ShortString nameShort = ShortStrings.toShortString(name);
|
387
|
-
if (ShortStrings.byteLength(nameShort) == 0) {
|
388
|
-
revert IAccess.ErrorRoleNameEmpty(roleId);
|
389
|
-
}
|
390
|
-
|
391
|
-
if (_role[nameShort] != RoleIdLib.zero() && _role[nameShort] != roleId) {
|
392
|
-
revert IAccess.ErrorRoleNameNotUnique(_role[nameShort], nameShort);
|
393
|
-
}
|
394
|
-
}
|
395
|
-
|
396
|
-
function _validateTargetParameters(address target, IAccess.TargetInfo memory targetInfo) internal view {
|
397
|
-
|
398
|
-
}
|
399
|
-
|
400
|
-
function toRoleKey32(RoleId roleId) public pure returns (Key32) {
|
401
|
-
return roleId.toKey32();
|
402
|
-
}
|
403
|
-
|
404
|
-
function toTargetKey32(address target) public pure returns (Key32) {
|
405
|
-
return Key32Lib.toKey32(TARGET(), KeyId.wrap(bytes20(target)));
|
406
|
-
}
|
407
|
-
|
408
218
|
function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
|
409
219
|
return nftId.toKey32(objectType);
|
410
220
|
}
|
@@ -418,19 +228,31 @@ contract Instance is
|
|
418
228
|
}
|
419
229
|
|
420
230
|
function getComponentOwnerService() external view returns (IComponentOwnerService) {
|
421
|
-
return ComponentOwnerService(_registry.getServiceAddress(
|
231
|
+
return ComponentOwnerService(_registry.getServiceAddress(COMPONENT(), VersionPart.wrap(3)));
|
422
232
|
}
|
423
233
|
|
424
234
|
function getDistributionService() external view returns (IDistributionService) {
|
425
|
-
return IDistributionService(_registry.getServiceAddress(
|
235
|
+
return IDistributionService(_registry.getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
|
426
236
|
}
|
427
237
|
|
428
238
|
function getProductService() external view returns (IProductService) {
|
429
|
-
return IProductService(_registry.getServiceAddress(
|
239
|
+
return IProductService(_registry.getServiceAddress(PRODUCT(), VersionPart.wrap(3)));
|
430
240
|
}
|
431
241
|
|
432
242
|
function getPoolService() external view returns (IPoolService) {
|
433
|
-
return IPoolService(_registry.getServiceAddress(
|
243
|
+
return IPoolService(_registry.getServiceAddress(POOL(), VersionPart.wrap(3)));
|
244
|
+
}
|
245
|
+
|
246
|
+
function getPolicyService() external view returns (IPolicyService) {
|
247
|
+
return IPolicyService(_registry.getServiceAddress(POLICY(), VersionPart.wrap(3)));
|
248
|
+
}
|
249
|
+
|
250
|
+
function getBundleService() external view returns (IBundleService) {
|
251
|
+
return IBundleService(_registry.getServiceAddress(BUNDLE(), VersionPart.wrap(3)));
|
252
|
+
}
|
253
|
+
|
254
|
+
function getInstanceAccessManager() external view returns (InstanceAccessManager) {
|
255
|
+
return _accessManager;
|
434
256
|
}
|
435
257
|
|
436
258
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|