@etherisc/gif-next 0.0.2-b9e43cf-870 → 0.0.2-bad4d33-850
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → Component.sol/Component.json} +273 -14
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +184 -10
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +61 -88
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +496 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +512 -74
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +596 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +165 -93
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +189 -15
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +179 -13
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +21 -5
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +111 -74
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +47 -60
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +41 -82
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +168 -92
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +37 -24
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +102 -31
- 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/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +131 -60
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +31 -18
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +126 -47
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +31 -14
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +0 -5
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +0 -5
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +0 -5
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +0 -5
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +0 -5
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +152 -81
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +44 -31
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +126 -47
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +31 -14
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +126 -47
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +31 -14
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +83 -3
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +33 -28
- 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 +96 -24
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +18 -18
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +61 -56
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +28 -15
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +70 -53
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +23 -26
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -5
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +0 -5
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +19 -6
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +13 -5
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +19 -11
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +29 -21
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +216 -0
- package/contracts/components/Distribution.sol +40 -51
- package/contracts/components/IComponent.sol +43 -0
- package/contracts/components/IDistributionComponent.sol +5 -2
- package/contracts/components/IPoolComponent.sol +6 -21
- package/contracts/components/IProductComponent.sol +7 -3
- package/contracts/components/Pool.sol +44 -108
- package/contracts/components/Product.sol +51 -86
- package/contracts/instance/BundleManager.sol +7 -11
- package/contracts/instance/IInstance.sol +20 -10
- package/contracts/instance/IInstanceService.sol +2 -1
- package/contracts/instance/Instance.sol +28 -31
- package/contracts/instance/InstanceAccessManager.sol +6 -11
- package/contracts/instance/InstanceReader.sol +3 -25
- package/contracts/instance/InstanceService.sol +112 -22
- package/contracts/instance/ObjectManager.sol +7 -24
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/service/BundleService.sol +2 -3
- package/contracts/instance/service/DistributionService.sol +23 -37
- package/contracts/instance/service/PolicyService.sol +2 -3
- package/contracts/instance/service/PoolService.sol +20 -55
- package/contracts/instance/service/ProductService.sol +50 -30
- package/contracts/registry/IRegistry.sol +13 -6
- package/contracts/registry/IRegistryService.sol +16 -9
- package/contracts/registry/Registry.sol +100 -44
- package/contracts/registry/RegistryAccessManager.sol +31 -25
- package/contracts/registry/RegistryService.sol +27 -85
- package/contracts/registry/ReleaseManager.sol +72 -82
- package/contracts/registry/TokenRegistry.sol +5 -3
- package/contracts/shared/IRegisterable.sol +1 -3
- package/contracts/shared/NftOwnable.sol +5 -0
- package/contracts/shared/Registerable.sol +10 -14
- package/contracts/shared/Service.sol +4 -2
- package/contracts/types/RoleId.sol +2 -2
- package/package.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
- package/contracts/components/BaseComponent.sol +0 -159
- package/contracts/components/IBaseComponent.sol +0 -34
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
- package/contracts/instance/IInstanceBase.sol +0 -26
- package/contracts/instance/InstanceBase.sol +0 -41
- package/contracts/instance/base/ComponentServiceBase.sol +0 -76
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -315
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -1,22 +1,9 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
|
-
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
-
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
7
4
|
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
8
5
|
|
9
|
-
import {IAccess} from "./module/IAccess.sol";
|
10
|
-
import {IBundle} from "./module/IBundle.sol";
|
11
|
-
import {IPolicy} from "./module/IPolicy.sol";
|
12
|
-
import {IRisk} from "./module/IRisk.sol";
|
13
|
-
import {ISetup} from "./module/ISetup.sol";
|
14
6
|
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
15
|
-
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
16
|
-
import {IInstance} from "./IInstance.sol";
|
17
|
-
import {InstanceReader} from "./InstanceReader.sol";
|
18
|
-
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
19
|
-
import {BundleManager} from "./BundleManager.sol";
|
20
7
|
import {NftId} from "../types/NftId.sol";
|
21
8
|
import {NumberId} from "../types/NumberId.sol";
|
22
9
|
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT} from "../types/ObjectType.sol";
|
@@ -24,25 +11,40 @@ import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
|
24
11
|
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
25
12
|
import {StateId, ACTIVE} from "../types/StateId.sol";
|
26
13
|
import {TimestampLib} from "../types/Timestamp.sol";
|
14
|
+
import {VersionPart} from "../types/Version.sol";
|
15
|
+
|
27
16
|
import {ERC165} from "../shared/ERC165.sol";
|
28
17
|
import {Registerable} from "../shared/Registerable.sol";
|
29
|
-
|
30
|
-
import {
|
18
|
+
|
19
|
+
import {IInstance} from "./IInstance.sol";
|
20
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
21
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
22
|
+
import {BundleManager} from "./BundleManager.sol";
|
23
|
+
|
24
|
+
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
25
|
+
|
26
|
+
import {IAccess} from "./module/IAccess.sol";
|
27
|
+
import {IBundle} from "./module/IBundle.sol";
|
28
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
29
|
+
import {IRisk} from "./module/IRisk.sol";
|
30
|
+
import {ISetup} from "./module/ISetup.sol";
|
31
|
+
|
31
32
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
32
33
|
import {IPoolService} from "./service/IPoolService.sol";
|
33
34
|
import {IProductService} from "./service/IProductService.sol";
|
34
35
|
import {IPolicyService} from "./service/IPolicyService.sol";
|
35
36
|
import {IBundleService} from "./service/IBundleService.sol";
|
36
|
-
import {VersionPart} from "../types/Version.sol";
|
37
|
-
import {InstanceBase} from "./InstanceBase.sol";
|
37
|
+
import {VersionPart, VersionPartLib} from "../types/Version.sol";
|
38
38
|
|
39
39
|
contract Instance is
|
40
|
-
AccessManagedUpgradeable,
|
41
40
|
IInstance,
|
42
|
-
|
43
|
-
|
41
|
+
AccessManagedUpgradeable,
|
42
|
+
Registerable,
|
43
|
+
KeyValueStore
|
44
44
|
{
|
45
45
|
|
46
|
+
uint256 public constant GIF_MAJOR_VERSION = 3;
|
47
|
+
|
46
48
|
uint64 public constant ADMIN_ROLE = type(uint64).min;
|
47
49
|
uint64 public constant PUBLIC_ROLE = type(uint64).max;
|
48
50
|
uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
|
@@ -59,16 +61,11 @@ contract Instance is
|
|
59
61
|
public
|
60
62
|
initializer
|
61
63
|
{
|
62
|
-
require(!_initialized, "Contract instance has already been initialized");
|
63
|
-
|
64
64
|
__AccessManaged_init(accessManagerAddress);
|
65
|
-
|
66
|
-
_accessManager = InstanceAccessManager(accessManagerAddress);
|
67
65
|
|
68
66
|
_initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
|
69
67
|
|
70
68
|
_registerInterface(type(IInstance).interfaceId);
|
71
|
-
_initialized = true;
|
72
69
|
}
|
73
70
|
|
74
71
|
//--- ProductSetup ------------------------------------------------------//
|
@@ -227,10 +224,6 @@ contract Instance is
|
|
227
224
|
return policyNftId.toKey32(POLICY());
|
228
225
|
}
|
229
226
|
|
230
|
-
function getComponentOwnerService() external view returns (IComponentOwnerService) {
|
231
|
-
return ComponentOwnerService(_registry.getServiceAddress(COMPONENT(), VersionPart.wrap(3)));
|
232
|
-
}
|
233
|
-
|
234
227
|
function getDistributionService() external view returns (IDistributionService) {
|
235
228
|
return IDistributionService(_registry.getServiceAddress(DISTRIBUTION(), VersionPart.wrap(3)));
|
236
229
|
}
|
@@ -252,17 +245,21 @@ contract Instance is
|
|
252
245
|
}
|
253
246
|
|
254
247
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
255
|
-
require(instanceReader.
|
248
|
+
require(instanceReader.getInstance() == Instance(this), "InstanceReader instance mismatch");
|
256
249
|
_instanceReader = instanceReader;
|
257
250
|
}
|
258
251
|
|
252
|
+
function getMajorVersion() external pure returns (VersionPart majorVersion) {
|
253
|
+
return VersionPartLib.toVersionPart(GIF_MAJOR_VERSION);
|
254
|
+
}
|
255
|
+
|
259
256
|
function getInstanceReader() external view returns (InstanceReader) {
|
260
257
|
return _instanceReader;
|
261
258
|
}
|
262
259
|
|
263
260
|
function setBundleManager(BundleManager bundleManager) external restricted() {
|
264
261
|
require(address(_bundleManager) == address(0), "BundleManager is set");
|
265
|
-
require(bundleManager.
|
262
|
+
require(bundleManager.getInstance() == Instance(this), "BundleManager instance mismatch");
|
266
263
|
_bundleManager = bundleManager;
|
267
264
|
}
|
268
265
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
|
5
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
4
6
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
7
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
-
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
7
8
|
|
8
|
-
import {AccessManagerUpgradeableInitializeable} from "../../contracts/instance/AccessManagerUpgradeableInitializeable.sol";
|
9
9
|
import {RoleId, RoleIdLib } from "../types/RoleId.sol";
|
10
10
|
import {TimestampLib} from "../types/Timestamp.sol";
|
11
11
|
import {IAccess} from "./module/IAccess.sol";
|
@@ -32,14 +32,13 @@ contract InstanceAccessManager is
|
|
32
32
|
mapping(ShortString name => address target) internal _targetForName;
|
33
33
|
address [] internal _targets;
|
34
34
|
|
35
|
-
|
35
|
+
AccessManager internal _accessManager;
|
36
36
|
|
37
|
-
function
|
37
|
+
function initialize(address initialAdmin) external initializer
|
38
38
|
{
|
39
39
|
// if size of the contract gets too large, this can be externalized which will reduce the contract size considerably
|
40
|
-
_accessManager = new
|
41
|
-
// this service required
|
42
|
-
_accessManager.__AccessManagerUpgradeableInitializeable_init(address(this));
|
40
|
+
_accessManager = new AccessManager(address(this));
|
41
|
+
// this service required admin rights to access manager to be able to grant/revoke roles
|
43
42
|
_accessManager.grantRole(_accessManager.ADMIN_ROLE(), initialAdmin, 0);
|
44
43
|
|
45
44
|
__AccessManaged_init(address(_accessManager));
|
@@ -277,10 +276,6 @@ contract InstanceAccessManager is
|
|
277
276
|
_accessManager.setTargetFunctionRole(target, selectors, roleIdInt);
|
278
277
|
}
|
279
278
|
|
280
|
-
function getAccessManager() public restricted() returns (AccessManagerUpgradeableInitializeable) {
|
281
|
-
return _accessManager;
|
282
|
-
}
|
283
|
-
|
284
279
|
function setTargetClosed(string memory targetName, bool closed) public restricted() {
|
285
280
|
address target = _targetForName[ShortStrings.toShortString(targetName)];
|
286
281
|
if (target == address(0)) {
|
@@ -31,39 +31,21 @@ contract InstanceReader {
|
|
31
31
|
bool private _initialized;
|
32
32
|
|
33
33
|
IRegistry internal _registry;
|
34
|
-
NftId internal _instanceNftId;
|
35
34
|
IInstance internal _instance;
|
36
35
|
IKeyValueStore internal _store;
|
37
36
|
|
38
|
-
|
39
|
-
address registry,
|
40
|
-
NftId instanceNftId
|
41
|
-
)
|
42
|
-
{
|
43
|
-
initialize(registry, instanceNftId);
|
44
|
-
}
|
45
|
-
|
46
|
-
function initialize(address registry, NftId instanceNftId) public {
|
37
|
+
function initialize(address registry, address instance) public {
|
47
38
|
require(!_initialized, "ERROR:CRD-000:ALREADY_INITIALIZED");
|
48
39
|
|
49
40
|
require(
|
50
41
|
address(registry) != address(0),
|
51
42
|
"ERROR:CRD-001:REGISTRY_ZERO");
|
52
43
|
|
53
|
-
require(
|
54
|
-
instanceNftId.gtz(),
|
55
|
-
"ERROR:CRD-002:NFT_ID_ZERO");
|
56
44
|
|
57
45
|
_registry = IRegistry(registry);
|
58
|
-
_instanceNftId = instanceNftId;
|
59
|
-
IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(_instanceNftId);
|
60
46
|
|
61
|
-
|
62
|
-
|
63
|
-
"ERROR:CRD-003:PARENT_NOT_INSTANCE");
|
64
|
-
|
65
|
-
_instance = IInstance(instanceInfo.objectAddress);
|
66
|
-
_store = IKeyValueStore(instanceInfo.objectAddress);
|
47
|
+
_instance = IInstance(instance);
|
48
|
+
_store = IKeyValueStore(instance);
|
67
49
|
|
68
50
|
_initialized = true;
|
69
51
|
}
|
@@ -301,10 +283,6 @@ contract InstanceReader {
|
|
301
283
|
return _store;
|
302
284
|
}
|
303
285
|
|
304
|
-
function getInstanceNftId() external view returns (NftId nftId) {
|
305
|
-
return _instanceNftId;
|
306
|
-
}
|
307
|
-
|
308
286
|
function toUFixed(uint256 value, int8 exp) public pure returns (UFixed) {
|
309
287
|
return UFixedLib.toUFixed(value, exp);
|
310
288
|
}
|
@@ -10,7 +10,7 @@ import {IInstanceService} from "./IInstanceService.sol";
|
|
10
10
|
import {InstanceReader} from "./InstanceReader.sol";
|
11
11
|
import {BundleManager} from "./BundleManager.sol";
|
12
12
|
import {IRegistry} from "../registry/IRegistry.sol";
|
13
|
-
import {
|
13
|
+
import {IRegistryService} from "../registry/IRegistryService.sol";
|
14
14
|
import {ChainNft} from "../registry/ChainNft.sol";
|
15
15
|
import {Service} from "../../contracts/shared/Service.sol";
|
16
16
|
import {IService} from "../shared/IService.sol";
|
@@ -18,6 +18,9 @@ import {NftId} from "../../contracts/types/NftId.sol";
|
|
18
18
|
import {RoleId} from "../types/RoleId.sol";
|
19
19
|
import {ADMIN_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, POLICY_SERVICE_ROLE, BUNDLE_SERVICE_ROLE} from "../types/RoleId.sol";
|
20
20
|
import {ObjectType, INSTANCE, BUNDLE, POLICY, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
|
21
|
+
import {IDistributionComponent} from "../components/IDistributionComponent.sol";
|
22
|
+
import {IPoolComponent} from "../components/IPoolComponent.sol";
|
23
|
+
import {IProductComponent} from "../components/IProductComponent.sol";
|
21
24
|
|
22
25
|
contract InstanceService is Service, IInstanceService {
|
23
26
|
|
@@ -28,7 +31,6 @@ contract InstanceService is Service, IInstanceService {
|
|
28
31
|
|
29
32
|
// TODO update to real hash when instance is stable
|
30
33
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
31
|
-
string public constant NAME = "InstanceService";
|
32
34
|
|
33
35
|
modifier onlyInstanceOwner(NftId instanceNftId) {
|
34
36
|
IRegistry registry = getRegistry();
|
@@ -63,25 +65,23 @@ contract InstanceService is Service, IInstanceService {
|
|
63
65
|
address registryAddress = address(registry);
|
64
66
|
NftId registryNftId = registry.getNftId(registryAddress);
|
65
67
|
address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getMajorVersion());
|
66
|
-
|
68
|
+
IRegistryService registryService = IRegistryService(registryServiceAddress);
|
67
69
|
|
68
70
|
// initially set the authority of the access managar to this (being the instance service).
|
69
71
|
// This will allow the instance service to bootstrap the authorizations of the instance
|
70
72
|
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
71
73
|
clonedAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
|
72
|
-
clonedAccessManager.
|
74
|
+
clonedAccessManager.initialize(address(this));
|
73
75
|
|
74
76
|
clonedInstance = Instance(Clones.clone(_masterInstance));
|
75
77
|
clonedInstance.initialize(address(clonedAccessManager), registryAddress, registryNftId, msg.sender);
|
76
|
-
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
77
|
-
clonedInstanceNftId = info.nftId;
|
78
78
|
|
79
79
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
|
80
|
-
clonedInstanceReader.initialize(registryAddress,
|
80
|
+
clonedInstanceReader.initialize(registryAddress, address(clonedInstance));
|
81
81
|
clonedInstance.setInstanceReader(clonedInstanceReader);
|
82
82
|
|
83
83
|
clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
|
84
|
-
clonedBundleManager.initialize(address(clonedAccessManager), registryAddress,
|
84
|
+
clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, address(clonedInstance));
|
85
85
|
clonedInstance.setBundleManager(clonedBundleManager);
|
86
86
|
|
87
87
|
// TODO amend setters with instance specific , policy manager ...
|
@@ -93,6 +93,10 @@ contract InstanceService is Service, IInstanceService {
|
|
93
93
|
clonedAccessManager.grantRole(ADMIN_ROLE(), instanceOwner);
|
94
94
|
clonedAccessManager.revokeRole(ADMIN_ROLE(), address(this));
|
95
95
|
|
96
|
+
IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
|
97
|
+
clonedInstanceNftId = info.nftId;
|
98
|
+
// clonedInstance.linkToRegisteredNftId();
|
99
|
+
|
96
100
|
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
|
97
101
|
}
|
98
102
|
|
@@ -121,6 +125,7 @@ contract InstanceService is Service, IInstanceService {
|
|
121
125
|
}
|
122
126
|
|
123
127
|
function _createGifTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
128
|
+
clonedAccessManager.createGifTarget(address(clonedAccessManager), "InstanceAccessManager");
|
124
129
|
clonedAccessManager.createGifTarget(address(clonedInstance), "Instance");
|
125
130
|
clonedAccessManager.createGifTarget(address(clonedBundleManager), "BundleManager");
|
126
131
|
}
|
@@ -136,7 +141,7 @@ contract InstanceService is Service, IInstanceService {
|
|
136
141
|
clonedAccessManager.setTargetFunctionRole(
|
137
142
|
"Instance",
|
138
143
|
instanceDistributionServiceSelectors,
|
139
|
-
DISTRIBUTION_SERVICE_ROLE());
|
144
|
+
DISTRIBUTION_SERVICE_ROLE());
|
140
145
|
}
|
141
146
|
|
142
147
|
function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
@@ -217,30 +222,54 @@ contract InstanceService is Service, IInstanceService {
|
|
217
222
|
"Instance",
|
218
223
|
instanceInstanceServiceSelectors,
|
219
224
|
INSTANCE_SERVICE_ROLE());
|
225
|
+
|
226
|
+
bytes4[] memory instanceAccessManagerInstanceServiceSelectors = new bytes4[](1);
|
227
|
+
instanceAccessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
|
228
|
+
clonedAccessManager.setTargetFunctionRole(
|
229
|
+
"InstanceAccessManager",
|
230
|
+
instanceAccessManagerInstanceServiceSelectors,
|
231
|
+
INSTANCE_SERVICE_ROLE());
|
220
232
|
}
|
221
233
|
|
222
|
-
function
|
223
|
-
|
234
|
+
function setAndRegisterMasterInstance(address instanceAddress)
|
235
|
+
external
|
236
|
+
onlyOwner
|
237
|
+
returns(NftId masterInstanceNftId)
|
238
|
+
{
|
224
239
|
require(_masterInstance == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
240
|
+
require(_masterInstanceAccessManager == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
225
241
|
require(_masterInstanceBundleManager == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
|
226
242
|
|
227
|
-
require (accessManagerAddress != address(0), "ERROR:CRD-005:ACCESS_MANAGER_ZERO");
|
228
243
|
require (instanceAddress != address(0), "ERROR:CRD-006:INSTANCE_ZERO");
|
244
|
+
|
245
|
+
IInstance instance = IInstance(instanceAddress);
|
246
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
247
|
+
address accessManagerAddress = address(accessManager);
|
248
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
249
|
+
address instanceReaderAddress = address(instanceReader);
|
250
|
+
BundleManager bundleManager = instance.getBundleManager();
|
251
|
+
address bundleManagerAddress = address(bundleManager);
|
252
|
+
|
253
|
+
require (accessManagerAddress != address(0), "ERROR:CRD-005:ACCESS_MANAGER_ZERO");
|
229
254
|
require (instanceReaderAddress != address(0), "ERROR:CRD-007:INSTANCE_READER_ZERO");
|
230
255
|
require (bundleManagerAddress != address(0), "ERROR:CRD-008:BUNDLE_MANAGER_ZERO");
|
231
256
|
|
232
|
-
|
233
|
-
InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
|
234
|
-
BundleManager bundleManager = BundleManager(bundleManagerAddress);
|
235
|
-
|
257
|
+
|
236
258
|
require(instance.authority() == accessManagerAddress, "ERROR:CRD-009:INSTANCE_AUTHORITY_MISMATCH");
|
237
|
-
require(instanceReader.
|
238
|
-
require(bundleManager.
|
259
|
+
require(instanceReader.getInstance() == instance, "ERROR:CRD-010:INSTANCE_READER_INSTANCE_MISMATCH");
|
260
|
+
require(bundleManager.getInstance() == instance, "ERROR:CRD-011:BUNDLE_MANAGER_INSTANCE_MISMATCH");
|
239
261
|
|
240
262
|
_masterInstanceAccessManager = accessManagerAddress;
|
241
263
|
_masterInstance = instanceAddress;
|
242
264
|
_masterInstanceReader = instanceReaderAddress;
|
243
265
|
_masterInstanceBundleManager = bundleManagerAddress;
|
266
|
+
|
267
|
+
IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(), getMajorVersion()));
|
268
|
+
IInstance masterInstance = IInstance(_masterInstance);
|
269
|
+
IRegistry.ObjectInfo memory info = registryService.registerInstance(masterInstance, getOwner());
|
270
|
+
masterInstanceNftId = info.nftId;
|
271
|
+
|
272
|
+
// masterInstance.linkToRegisteredNftId();
|
244
273
|
}
|
245
274
|
|
246
275
|
function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
|
@@ -249,11 +278,12 @@ contract InstanceService is Service, IInstanceService {
|
|
249
278
|
require(instanceReaderAddress != _masterInstanceReader, "ERROR:CRD-014:INSTANCE_READER_MASTER_SAME_AS_NEW");
|
250
279
|
|
251
280
|
InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
|
252
|
-
require(instanceReader.
|
281
|
+
require(instanceReader.getInstance() == IInstance(_masterInstance), "ERROR:CRD-015:INSTANCE_READER_INSTANCE_MISMATCH");
|
253
282
|
|
254
283
|
_masterInstanceReader = instanceReaderAddress;
|
255
284
|
}
|
256
285
|
|
286
|
+
// TODO access restriction
|
257
287
|
function upgradeInstanceReader(NftId instanceNftId) external {
|
258
288
|
IRegistry registry = getRegistry();
|
259
289
|
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
@@ -265,7 +295,7 @@ contract InstanceService is Service, IInstanceService {
|
|
265
295
|
}
|
266
296
|
|
267
297
|
InstanceReader upgradedInstanceReaderClone = InstanceReader(Clones.clone(address(_masterInstanceReader)));
|
268
|
-
upgradedInstanceReaderClone.initialize(address(registry),
|
298
|
+
upgradedInstanceReaderClone.initialize(address(registry), address(instance));
|
269
299
|
instance.setInstanceReader(upgradedInstanceReaderClone);
|
270
300
|
}
|
271
301
|
|
@@ -315,12 +345,72 @@ contract InstanceService is Service, IInstanceService {
|
|
315
345
|
return accessManager.hasRole(role, account);
|
316
346
|
}
|
317
347
|
|
318
|
-
function
|
348
|
+
function createGifTarget(NftId instanceNftId, address targetAddress, string memory targetName) external onlyRegisteredService {
|
319
349
|
IRegistry registry = getRegistry();
|
320
350
|
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
321
351
|
Instance instance = Instance(instanceInfo.objectAddress);
|
322
352
|
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
323
|
-
accessManager.
|
353
|
+
accessManager.createGifTarget(targetAddress, targetName);
|
354
|
+
}
|
355
|
+
|
356
|
+
function grantDistributionDefaultPermissions(NftId instanceNftId, address distributionAddress, string memory distributionName) external onlyRegisteredService {
|
357
|
+
IRegistry registry = getRegistry();
|
358
|
+
IRegistry.ObjectInfo memory distributionInfo = registry.getObjectInfo(distributionAddress);
|
359
|
+
|
360
|
+
if (distributionInfo.objectType != DISTRIBUTION()) {
|
361
|
+
revert ErrorInstanceServiceInvalidComponentType(distributionAddress, DISTRIBUTION(), distributionInfo.objectType);
|
362
|
+
}
|
363
|
+
|
364
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
365
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
366
|
+
InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
|
367
|
+
|
368
|
+
bytes4[] memory fctSelectors = new bytes4[](1);
|
369
|
+
fctSelectors[0] = IDistributionComponent.setFees.selector;
|
370
|
+
instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors, DISTRIBUTION_OWNER_ROLE());
|
371
|
+
|
372
|
+
bytes4[] memory fctSelectors2 = new bytes4[](2);
|
373
|
+
fctSelectors2[0] = IDistributionComponent.processSale.selector;
|
374
|
+
fctSelectors2[1] = IDistributionComponent.processRenewal.selector;
|
375
|
+
instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors2, PRODUCT_SERVICE_ROLE());
|
376
|
+
}
|
377
|
+
|
378
|
+
function grantPoolDefaultPermissions(NftId instanceNftId, address poolAddress, string memory poolName) external onlyRegisteredService {
|
379
|
+
IRegistry registry = getRegistry();
|
380
|
+
IRegistry.ObjectInfo memory poolInfo = registry.getObjectInfo(poolAddress);
|
381
|
+
|
382
|
+
if (poolInfo.objectType != POOL()) {
|
383
|
+
revert ErrorInstanceServiceInvalidComponentType(poolAddress, POOL(), poolInfo.objectType);
|
384
|
+
}
|
385
|
+
|
386
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
387
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
388
|
+
InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
|
389
|
+
|
390
|
+
bytes4[] memory fctSelectors = new bytes4[](1);
|
391
|
+
fctSelectors[0] = IPoolComponent.setFees.selector;
|
392
|
+
instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors, POOL_OWNER_ROLE());
|
393
|
+
|
394
|
+
bytes4[] memory fctSelectors2 = new bytes4[](1);
|
395
|
+
fctSelectors2[0] = IPoolComponent.underwrite.selector;
|
396
|
+
instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors2, POLICY_SERVICE_ROLE());
|
397
|
+
}
|
398
|
+
|
399
|
+
function grantProductDefaultPermissions(NftId instanceNftId, address productAddress, string memory productName) external onlyRegisteredService {
|
400
|
+
IRegistry registry = getRegistry();
|
401
|
+
IRegistry.ObjectInfo memory productInfo = registry.getObjectInfo(productAddress);
|
402
|
+
|
403
|
+
if (productInfo.objectType != PRODUCT()) {
|
404
|
+
revert ErrorInstanceServiceInvalidComponentType(productAddress, PRODUCT(), productInfo.objectType);
|
405
|
+
}
|
406
|
+
|
407
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
408
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
409
|
+
InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
|
410
|
+
|
411
|
+
bytes4[] memory fctSelectors = new bytes4[](1);
|
412
|
+
fctSelectors[0] = IProductComponent.setFees.selector;
|
413
|
+
instanceAccessManager.setTargetFunctionRole(productName, fctSelectors, PRODUCT_OWNER_ROLE());
|
324
414
|
}
|
325
415
|
|
326
416
|
function setTargetLocked(string memory targetName, bool locked) external {
|
@@ -14,49 +14,32 @@ contract ObjectManager is
|
|
14
14
|
Cloneable
|
15
15
|
{
|
16
16
|
|
17
|
-
event LogObjectManagerInitialized(
|
17
|
+
event LogObjectManagerInitialized(address instance);
|
18
18
|
|
19
19
|
error ErrorObjectManagerNftIdInvalid(NftId instanceNftId);
|
20
20
|
error ErrorObjectManagerAlreadyAdded(NftId componentNftId, NftId objectNftId);
|
21
21
|
|
22
22
|
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _activeObjects;
|
23
23
|
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _allObjects;
|
24
|
-
|
25
|
-
InstanceReader internal _instanceReader;
|
26
|
-
|
27
|
-
constructor() Cloneable() {
|
28
|
-
_instanceReader = InstanceReader(address(0));
|
29
|
-
}
|
24
|
+
IInstance internal _instance; // store instance address -> more flexible, instance may not be registered during ObjectManager initialization
|
30
25
|
|
31
26
|
/// @dev call to initialize MUST be made in the same transaction as cloning of the contract
|
32
27
|
function initialize(
|
33
28
|
address authority,
|
34
29
|
address registry,
|
35
|
-
|
30
|
+
address instance
|
36
31
|
)
|
37
32
|
external
|
38
33
|
{
|
39
34
|
initialize(authority, registry);
|
40
35
|
|
41
|
-
|
42
|
-
IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(instanceNftId);
|
43
|
-
if (instanceInfo.objectType != INSTANCE()) {
|
44
|
-
revert ErrorObjectManagerNftIdInvalid(instanceNftId);
|
45
|
-
}
|
46
|
-
|
47
|
-
IInstance instance = IInstance(instanceInfo.objectAddress);
|
48
|
-
_instanceReader = instance.getInstanceReader();
|
49
|
-
_instanceNftId = instanceNftId;
|
36
|
+
_instance = IInstance(instance);
|
50
37
|
|
51
|
-
emit LogObjectManagerInitialized(
|
52
|
-
}
|
53
|
-
|
54
|
-
function getInstanceReader() external view returns (InstanceReader) {
|
55
|
-
return _instanceReader;
|
38
|
+
emit LogObjectManagerInitialized(instance);
|
56
39
|
}
|
57
40
|
|
58
|
-
function
|
59
|
-
return
|
41
|
+
function getInstance() external view returns (IInstance) {
|
42
|
+
return _instance;
|
60
43
|
}
|
61
44
|
|
62
45
|
function _add(NftId componentNftId, NftId objectNftId) internal {
|
@@ -0,0 +1,134 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IComponent} from "../../components/IComponent.sol";
|
5
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
6
|
+
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
7
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
8
|
+
import {IAccess} from "../module/IAccess.sol";
|
9
|
+
import {ObjectType, INSTANCE, REGISTRY} from "../../types/ObjectType.sol";
|
10
|
+
import {NftId} from "../../types/NftId.sol";
|
11
|
+
import {RoleId} from "../../types/RoleId.sol";
|
12
|
+
|
13
|
+
import {Service} from "../../shared/Service.sol";
|
14
|
+
import {InstanceService} from "../InstanceService.sol";
|
15
|
+
import {InstanceAccessManager} from "../InstanceAccessManager.sol";
|
16
|
+
|
17
|
+
abstract contract ComponentService is Service {
|
18
|
+
|
19
|
+
error ErrorComponentServiceAlreadyRegistered(address component, NftId nftId);
|
20
|
+
error ErrorComponentServiceNotComponent(address component);
|
21
|
+
error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
|
22
|
+
error ErrorComponentServiceSenderNotOwner(address component, address initialOwner, address sender);
|
23
|
+
error ErrorComponentServiceExpectedRoleMissing(NftId instanceNftId, RoleId requiredRole, address sender);
|
24
|
+
error ErrorComponentServiceComponentLocked(address component);
|
25
|
+
|
26
|
+
/// @dev modifier to check if caller is a registered service
|
27
|
+
modifier onlyService() {
|
28
|
+
address caller = msg.sender;
|
29
|
+
require(getRegistry().isRegisteredService(caller), "ERROR_NOT_SERVICE");
|
30
|
+
_;
|
31
|
+
}
|
32
|
+
|
33
|
+
// view functions
|
34
|
+
|
35
|
+
function getRegistryService() public view virtual returns (IRegistryService) {
|
36
|
+
address service = getRegistry().getServiceAddress(REGISTRY(), getMajorVersion());
|
37
|
+
return IRegistryService(service);
|
38
|
+
}
|
39
|
+
|
40
|
+
function getInstanceService() public view returns (InstanceService) {
|
41
|
+
address service = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
|
42
|
+
return InstanceService(service);
|
43
|
+
}
|
44
|
+
|
45
|
+
// internal functions
|
46
|
+
function _checkComponentForRegistration(
|
47
|
+
address componentAddress,
|
48
|
+
ObjectType requiredType,
|
49
|
+
RoleId requiredRole
|
50
|
+
)
|
51
|
+
internal
|
52
|
+
view
|
53
|
+
returns (
|
54
|
+
IComponent component,
|
55
|
+
address owner,
|
56
|
+
IInstance instance,
|
57
|
+
NftId instanceNftId
|
58
|
+
)
|
59
|
+
{
|
60
|
+
// component may only be registerd by initial owner of component
|
61
|
+
owner = msg.sender;
|
62
|
+
|
63
|
+
// check component has not already been registerd
|
64
|
+
NftId compoentNftId = _registry.getNftId(componentAddress);
|
65
|
+
if(compoentNftId.gtz()) {
|
66
|
+
revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
|
67
|
+
}
|
68
|
+
|
69
|
+
// check this is a component
|
70
|
+
component = IComponent(componentAddress);
|
71
|
+
if(!component.supportsInterface(type(IComponent).interfaceId)) {
|
72
|
+
revert ErrorComponentServiceNotComponent(componentAddress);
|
73
|
+
}
|
74
|
+
|
75
|
+
// check component is of required type
|
76
|
+
IRegistry.ObjectInfo memory componentInfo = component.getInitialInfo();
|
77
|
+
if(componentInfo.objectType != requiredType) {
|
78
|
+
revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
|
79
|
+
}
|
80
|
+
|
81
|
+
// check msg.sender is component owner
|
82
|
+
address initialOwner = componentInfo.initialOwner;
|
83
|
+
if(owner != initialOwner) {
|
84
|
+
revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
|
85
|
+
}
|
86
|
+
|
87
|
+
// check instance has assigned required role to owner
|
88
|
+
instanceNftId = componentInfo.parentNftId;
|
89
|
+
instance = _getInstance(instanceNftId);
|
90
|
+
bool hasRole = getInstanceService().hasRole(
|
91
|
+
owner,
|
92
|
+
requiredRole,
|
93
|
+
address(instance));
|
94
|
+
|
95
|
+
if(!hasRole) {
|
96
|
+
revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
// internal view functions
|
101
|
+
|
102
|
+
function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
|
103
|
+
IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
|
104
|
+
return IInstance(instanceInfo.objectAddress);
|
105
|
+
}
|
106
|
+
|
107
|
+
function _getAndVerifyComponentInfoAndInstance(
|
108
|
+
//address component,
|
109
|
+
ObjectType expectedType
|
110
|
+
)
|
111
|
+
internal
|
112
|
+
view
|
113
|
+
returns(
|
114
|
+
IRegistry.ObjectInfo memory info,
|
115
|
+
IInstance instance
|
116
|
+
)
|
117
|
+
{
|
118
|
+
IRegistry registry = getRegistry();
|
119
|
+
//TODO redundant check -> just check type
|
120
|
+
//NftId componentNftId = registry.getNftId(component);
|
121
|
+
//require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
122
|
+
|
123
|
+
info = registry.getObjectInfo(msg.sender);
|
124
|
+
require(info.objectType == expectedType, "OBJECT_TYPE_INVALID");
|
125
|
+
|
126
|
+
address instanceAddress = registry.getObjectInfo(info.parentNftId).objectAddress;
|
127
|
+
instance = IInstance(instanceAddress);
|
128
|
+
|
129
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
130
|
+
if (accessManager.isTargetLocked(info.objectAddress)) {
|
131
|
+
revert IAccess.ErrorIAccessTargetLocked(info.objectAddress);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|