@etherisc/gif-next 0.0.2-c8cedfe-604 → 0.0.2-ca9d515-311
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +63 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +126 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +136 -62
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +88 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +0 -52
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +28 -2
- 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 +168 -19
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +144 -64
- 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 +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1373 -93
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +6 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +195 -142
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +55 -32
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +177 -38
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +285 -73
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +110 -26
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +40 -0
- 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/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 +923 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +440 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +69 -21
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +18 -18
- 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/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- 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 +9 -71
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -232
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +984 -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 +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +718 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +428 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +768 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
- 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 +2 -110
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
- 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 +35 -146
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +26 -34
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
- 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/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/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 +4 -4
- 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 +9 -9
- 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/NftIdSet.sol/LibNftIdSet.json +26 -3
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/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 +49 -8
- package/contracts/components/Distribution.sol +12 -15
- package/contracts/components/IBaseComponent.sol +6 -0
- package/contracts/components/IDistributionComponent.sol +0 -2
- package/contracts/components/IPoolComponent.sol +5 -1
- package/contracts/components/Pool.sol +42 -29
- package/contracts/components/Product.sol +41 -46
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
- package/contracts/instance/BundleManager.sol +129 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +34 -7
- package/contracts/instance/IInstanceBase.sol +26 -0
- package/contracts/instance/IInstanceService.sol +5 -3
- package/contracts/instance/Instance.sol +51 -29
- package/contracts/instance/InstanceAccessManager.sol +6 -6
- package/contracts/instance/InstanceBase.sol +41 -0
- package/contracts/instance/InstanceReader.sol +26 -1
- package/contracts/instance/InstanceService.sol +135 -35
- package/contracts/instance/InstanceServiceManager.sol +6 -5
- package/contracts/instance/ObjectManager.sol +101 -0
- package/contracts/instance/base/ComponentServiceBase.sol +45 -12
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/ISetup.sol +3 -0
- package/contracts/instance/service/BundleService.sol +260 -0
- package/contracts/instance/service/BundleServiceManager.sol +54 -0
- package/contracts/instance/service/DistributionService.sol +43 -21
- package/contracts/instance/service/DistributionServiceManager.sol +6 -5
- package/contracts/instance/service/IBundleService.sol +45 -0
- package/contracts/instance/service/IPolicyService.sol +87 -0
- package/contracts/instance/service/IPoolService.sol +6 -23
- package/contracts/instance/service/IProductService.sol +6 -73
- package/contracts/instance/service/PolicyService.sol +508 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +124 -0
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +173 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/IRegistry.sol +5 -18
- package/contracts/registry/IRegistryService.sol +28 -11
- package/contracts/registry/Registry.sol +4 -45
- package/contracts/registry/RegistryService.sol +30 -71
- package/contracts/shared/NftOwnable.sol +2 -4
- package/contracts/shared/Service.sol +1 -0
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/RoleId.sol +4 -0
- package/package.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
- package/contracts/instance/AccessManagedSimple.sol +0 -115
- package/contracts/instance/AccessManagerSimple.sol +0 -692
@@ -0,0 +1,26 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
5
|
+
|
6
|
+
import {BundleManager} from "./BundleManager.sol";
|
7
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
8
|
+
|
9
|
+
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
10
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
11
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
12
|
+
import {IProductService} from "./service/IProductService.sol";
|
13
|
+
import {IBundle} from "./module/IBundle.sol";
|
14
|
+
import {ISetup} from "./module/ISetup.sol";
|
15
|
+
import {NftId} from "../types/NftId.sol";
|
16
|
+
import {StateId} from "../types/StateId.sol";
|
17
|
+
import {RiskId} from "../types/RiskId.sol";
|
18
|
+
import {IRisk} from "./module/IRisk.sol";
|
19
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
20
|
+
import {IKeyValueStore} from "./base/IKeyValueStore.sol";
|
21
|
+
|
22
|
+
|
23
|
+
interface IInstanceBase is IERC165, IKeyValueStore {
|
24
|
+
|
25
|
+
|
26
|
+
}
|
@@ -10,9 +10,10 @@ 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 {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
|
14
14
|
import {Instance} from "./Instance.sol";
|
15
15
|
import {InstanceReader} from "./InstanceReader.sol";
|
16
|
+
import {BundleManager} from "./BundleManager.sol";
|
16
17
|
|
17
18
|
interface IInstanceService is IService {
|
18
19
|
|
@@ -21,10 +22,11 @@ interface IInstanceService is IService {
|
|
21
22
|
function createInstanceClone()
|
22
23
|
external
|
23
24
|
returns (
|
24
|
-
|
25
|
+
AccessManagerUpgradeableInitializeable clonedAccessManager,
|
25
26
|
Instance clonedInstance,
|
26
27
|
NftId instanceNftId,
|
27
|
-
InstanceReader clonedInstanceReader
|
28
|
+
InstanceReader clonedInstanceReader,
|
29
|
+
BundleManager clonedBundleManager
|
28
30
|
);
|
29
31
|
}
|
30
32
|
|
@@ -3,9 +3,10 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
5
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
+
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
7
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
8
|
+
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
6
9
|
|
7
|
-
import {AccessManagedSimple} from "./AccessManagedSimple.sol";
|
8
|
-
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
9
10
|
import {IAccess} from "./module/IAccess.sol";
|
10
11
|
import {IBundle} from "./module/IBundle.sol";
|
11
12
|
import {IPolicy} from "./module/IPolicy.sol";
|
@@ -15,6 +16,7 @@ import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
|
15
16
|
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
16
17
|
import {IInstance} from "./IInstance.sol";
|
17
18
|
import {InstanceReader} from "./InstanceReader.sol";
|
19
|
+
import {BundleManager} from "./BundleManager.sol";
|
18
20
|
import {NftId} from "../types/NftId.sol";
|
19
21
|
import {NumberId} from "../types/NumberId.sol";
|
20
22
|
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
@@ -26,14 +28,18 @@ import {Registerable} from "../shared/Registerable.sol";
|
|
26
28
|
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
27
29
|
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
28
30
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
31
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
32
|
+
import {IProductService} from "./service/IProductService.sol";
|
33
|
+
import {IPolicyService} from "./service/IPolicyService.sol";
|
34
|
+
import {IBundleService} from "./service/IBundleService.sol";
|
29
35
|
import {VersionPart} from "../types/Version.sol";
|
36
|
+
import {InstanceBase} from "./InstanceBase.sol";
|
30
37
|
|
31
38
|
contract Instance is
|
32
|
-
|
33
|
-
KeyValueStore,
|
39
|
+
AccessManagedUpgradeable,
|
34
40
|
IInstance,
|
35
|
-
|
36
|
-
|
41
|
+
// Initializable,
|
42
|
+
InstanceBase
|
37
43
|
{
|
38
44
|
|
39
45
|
uint64 public constant ADMIN_ROLE = type(uint64).min;
|
@@ -50,20 +56,19 @@ contract Instance is
|
|
50
56
|
|
51
57
|
mapping(ShortString name => address target) internal _target;
|
52
58
|
|
53
|
-
|
59
|
+
AccessManagerUpgradeable internal _accessManager;
|
54
60
|
InstanceReader internal _instanceReader;
|
61
|
+
BundleManager internal _bundleManager;
|
55
62
|
|
56
|
-
|
63
|
+
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner)
|
64
|
+
public
|
65
|
+
initializer
|
57
66
|
{
|
58
|
-
initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
|
59
|
-
}
|
60
|
-
|
61
|
-
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
|
62
67
|
require(!_initialized, "Contract instance has already been initialized");
|
63
68
|
|
64
|
-
|
65
|
-
|
66
|
-
_accessManager =
|
69
|
+
__AccessManaged_init(accessManagerAddress);
|
70
|
+
|
71
|
+
_accessManager = AccessManagerUpgradeable(accessManagerAddress);
|
67
72
|
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
68
73
|
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
69
74
|
|
@@ -220,16 +225,16 @@ contract Instance is
|
|
220
225
|
}
|
221
226
|
|
222
227
|
//--- PoolSetup ------------------------------------------------------//
|
223
|
-
function createPoolSetup(NftId
|
224
|
-
create(_toNftKey32(
|
228
|
+
function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
|
229
|
+
create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
|
225
230
|
}
|
226
231
|
|
227
|
-
function updatePoolSetup(NftId
|
228
|
-
update(_toNftKey32(
|
232
|
+
function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
|
233
|
+
update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
|
229
234
|
}
|
230
235
|
|
231
|
-
function updatePoolSetupState(NftId
|
232
|
-
updateState(_toNftKey32(
|
236
|
+
function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
|
237
|
+
updateState(_toNftKey32(poolNftId, POOL()), newState);
|
233
238
|
}
|
234
239
|
|
235
240
|
//--- DistributorType ---------------------------------------------------//
|
@@ -422,22 +427,39 @@ contract Instance is
|
|
422
427
|
return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
|
423
428
|
}
|
424
429
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
430
|
+
function getProductService() external view returns (IProductService) {
|
431
|
+
return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
|
432
|
+
}
|
433
|
+
|
434
|
+
function getPoolService() external view returns (IPoolService) {
|
435
|
+
return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
|
436
|
+
}
|
437
|
+
|
438
|
+
function getPolicyService() external view returns (IPolicyService) {
|
439
|
+
return IPolicyService(_registry.getServiceAddress("PolicyService", VersionPart.wrap(3)));
|
440
|
+
}
|
429
441
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
// }
|
442
|
+
function getBundleService() external view returns (IBundleService) {
|
443
|
+
return IBundleService(_registry.getServiceAddress("BundleService", VersionPart.wrap(3)));
|
444
|
+
}
|
434
445
|
|
435
446
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
436
447
|
require(address(_instanceReader) == address(0), "InstanceReader is set");
|
448
|
+
require(instanceReader.getInstanceNftId() == getNftId(), "NFT ID of InstanceReader does not match");
|
437
449
|
_instanceReader = instanceReader;
|
438
450
|
}
|
439
451
|
|
440
452
|
function getInstanceReader() external view returns (InstanceReader) {
|
441
453
|
return _instanceReader;
|
442
454
|
}
|
455
|
+
|
456
|
+
function setBundleManager(BundleManager bundleManager) external restricted() {
|
457
|
+
require(address(_bundleManager) == address(0), "BundleManager is set");
|
458
|
+
require(bundleManager.getInstanceNftId() == getNftId(), "NFT ID of BundleManager does not match");
|
459
|
+
_bundleManager = bundleManager;
|
460
|
+
}
|
461
|
+
|
462
|
+
function getBundleManager() external view returns (BundleManager) {
|
463
|
+
return _bundleManager;
|
464
|
+
}
|
443
465
|
}
|
@@ -3,9 +3,9 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
5
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
7
|
+
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
6
8
|
|
7
|
-
import {AccessManagedSimple} from "./AccessManagedSimple.sol";
|
8
|
-
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
9
9
|
import {IBundle} from "./module/IBundle.sol";
|
10
10
|
import {IPolicy} from "./module/IPolicy.sol";
|
11
11
|
import {IRisk} from "./module/IRisk.sol";
|
@@ -21,7 +21,7 @@ import {StateId, ACTIVE} from "../types/StateId.sol";
|
|
21
21
|
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
22
22
|
|
23
23
|
contract InstanceAccessManager is
|
24
|
-
|
24
|
+
AccessManagedUpgradeable
|
25
25
|
{
|
26
26
|
string public constant ADMIN_ROLE_NAME = "AdminRole";
|
27
27
|
string public constant PUBLIC_ROLE_NAME = "PublicRole";
|
@@ -76,12 +76,12 @@ contract InstanceAccessManager is
|
|
76
76
|
mapping(ShortString name => address target) internal _targetForName;
|
77
77
|
address [] internal _targets;
|
78
78
|
|
79
|
-
|
79
|
+
AccessManagerUpgradeable internal _accessManager;
|
80
80
|
|
81
81
|
constructor(address accessManager)
|
82
82
|
{
|
83
|
-
_accessManager =
|
84
|
-
|
83
|
+
_accessManager = AccessManagerUpgradeable(accessManager);
|
84
|
+
__AccessManaged_init(accessManager);
|
85
85
|
|
86
86
|
_createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
|
87
87
|
_createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
|
+
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
+
|
7
|
+
import {IAccess} from "./module/IAccess.sol";
|
8
|
+
import {IBundle} from "./module/IBundle.sol";
|
9
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
10
|
+
import {IRisk} from "./module/IRisk.sol";
|
11
|
+
import {ISetup} from "./module/ISetup.sol";
|
12
|
+
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
13
|
+
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
14
|
+
import {IInstance} from "./IInstance.sol";
|
15
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
16
|
+
import {BundleManager} from "./BundleManager.sol";
|
17
|
+
import {NftId} from "../types/NftId.sol";
|
18
|
+
import {NumberId} from "../types/NumberId.sol";
|
19
|
+
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
20
|
+
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
21
|
+
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
22
|
+
import {StateId, ACTIVE} from "../types/StateId.sol";
|
23
|
+
import {ERC165} from "../shared/ERC165.sol";
|
24
|
+
import {Registerable} from "../shared/Registerable.sol";
|
25
|
+
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
26
|
+
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
27
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
28
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
29
|
+
import {IProductService} from "./service/IProductService.sol";
|
30
|
+
import {VersionPart} from "../types/Version.sol";
|
31
|
+
import {IInstanceBase} from "./IInstanceBase.sol";
|
32
|
+
|
33
|
+
contract InstanceBase is
|
34
|
+
IInstanceBase,
|
35
|
+
KeyValueStore,
|
36
|
+
ERC165,
|
37
|
+
Registerable
|
38
|
+
{
|
39
|
+
|
40
|
+
|
41
|
+
}
|
@@ -7,14 +7,16 @@ import {DistributorType} from "../types/DistributorType.sol";
|
|
7
7
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
8
8
|
import {Key32} from "../types/Key32.sol";
|
9
9
|
import {NftId} from "../types/NftId.sol";
|
10
|
-
import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY} from "../types/ObjectType.sol";
|
10
|
+
import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY, BUNDLE} from "../types/ObjectType.sol";
|
11
11
|
import {ReferralId, ReferralStatus, ReferralLib, REFERRAL_OK, REFERRAL_ERROR_UNKNOWN, REFERRAL_ERROR_EXPIRED, REFERRAL_ERROR_EXHAUSTED} from "../types/Referral.sol";
|
12
12
|
import {Registerable} from "../shared/Registerable.sol";
|
13
13
|
import {RiskId} from "../types/RiskId.sol";
|
14
14
|
import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
|
15
15
|
import {Version} from "../types/Version.sol";
|
16
|
+
import {StateId} from "../types/StateId.sol";
|
16
17
|
|
17
18
|
import {IRegistry} from "../registry/IRegistry.sol";
|
19
|
+
import {IBundle} from "../instance/module/IBundle.sol";
|
18
20
|
import {IDistribution} from "../instance/module/IDistribution.sol";
|
19
21
|
import {IInstance} from "./IInstance.sol";
|
20
22
|
import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
|
@@ -80,6 +82,14 @@ contract InstanceReader {
|
|
80
82
|
}
|
81
83
|
}
|
82
84
|
|
85
|
+
function getPolicyState(NftId policyNftId)
|
86
|
+
public
|
87
|
+
view
|
88
|
+
returns (StateId state)
|
89
|
+
{
|
90
|
+
return _instance.getState(toPolicyKey(policyNftId));
|
91
|
+
}
|
92
|
+
|
83
93
|
function getRiskInfo(RiskId riskId)
|
84
94
|
public
|
85
95
|
view
|
@@ -114,6 +124,17 @@ contract InstanceReader {
|
|
114
124
|
return abi.decode(data, (ITreasury.TreasuryInfo));
|
115
125
|
}
|
116
126
|
}
|
127
|
+
|
128
|
+
function getBundleInfo(NftId bundleNftId)
|
129
|
+
public
|
130
|
+
view
|
131
|
+
returns (IBundle.BundleInfo memory info)
|
132
|
+
{
|
133
|
+
bytes memory data = _store.getData(toBundleKey(bundleNftId));
|
134
|
+
if (data.length > 0) {
|
135
|
+
return abi.decode(data, (IBundle.BundleInfo));
|
136
|
+
}
|
137
|
+
}
|
117
138
|
|
118
139
|
function getDistributorTypeInfo(DistributorType distributorType)
|
119
140
|
public
|
@@ -259,6 +280,10 @@ contract InstanceReader {
|
|
259
280
|
return distributionNftId.toKey32(DISTRIBUTION());
|
260
281
|
}
|
261
282
|
|
283
|
+
function toBundleKey(NftId poolNftId) public pure returns (Key32) {
|
284
|
+
return poolNftId.toKey32(BUNDLE());
|
285
|
+
}
|
286
|
+
|
262
287
|
function toPoolKey(NftId poolNftId) public pure returns (Key32) {
|
263
288
|
return poolNftId.toKey32(POOL());
|
264
289
|
}
|
@@ -2,12 +2,14 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
5
|
+
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
5
6
|
|
6
|
-
import {
|
7
|
+
import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
|
7
8
|
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
8
9
|
import {Instance} from "./Instance.sol";
|
9
10
|
import {IInstanceService} from "./IInstanceService.sol";
|
10
11
|
import {InstanceReader} from "./InstanceReader.sol";
|
12
|
+
import {BundleManager} from "./BundleManager.sol";
|
11
13
|
import {IRegistry} from "../registry/IRegistry.sol";
|
12
14
|
import {Registry} from "../registry/Registry.sol";
|
13
15
|
import {RegistryService} from "../registry/RegistryService.sol";
|
@@ -15,8 +17,9 @@ import {Service} from "../../contracts/shared/Service.sol";
|
|
15
17
|
import {IService} from "../shared/IService.sol";
|
16
18
|
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
17
19
|
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
20
|
+
import {RoleId} from "../types/RoleId.sol";
|
18
21
|
import {VersionLib} from "../types/Version.sol";
|
19
|
-
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE} from "../types/RoleId.sol";
|
22
|
+
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, POLICY_SERVICE_ROLE, BUNDLE_SERVICE_ROLE} from "../types/RoleId.sol";
|
20
23
|
|
21
24
|
contract InstanceService is Service, IInstanceService {
|
22
25
|
|
@@ -24,6 +27,7 @@ contract InstanceService is Service, IInstanceService {
|
|
24
27
|
address internal _accessManagerMaster;
|
25
28
|
address internal _instanceMaster;
|
26
29
|
address internal _instanceReaderMaster;
|
30
|
+
address internal _instanceBundleManagerMaster;
|
27
31
|
|
28
32
|
// TODO update to real hash when instance is stable
|
29
33
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
@@ -32,10 +36,11 @@ contract InstanceService is Service, IInstanceService {
|
|
32
36
|
function createInstanceClone()
|
33
37
|
external
|
34
38
|
returns (
|
35
|
-
|
39
|
+
AccessManagerUpgradeableInitializeable clonedAccessManager,
|
36
40
|
Instance clonedInstance,
|
37
|
-
NftId
|
38
|
-
InstanceReader clonedInstanceReader
|
41
|
+
NftId clonedInstanceNftId,
|
42
|
+
InstanceReader clonedInstanceReader,
|
43
|
+
BundleManager clonedBundleManager
|
39
44
|
)
|
40
45
|
{
|
41
46
|
address instanceOwner = msg.sender;
|
@@ -47,32 +52,37 @@ contract InstanceService is Service, IInstanceService {
|
|
47
52
|
// initially set the authority of the access managar to this (being the instance service).
|
48
53
|
// This will allow the instance service to bootstrap the authorizations of the instance
|
49
54
|
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
50
|
-
clonedAccessManager =
|
51
|
-
clonedAccessManager.
|
55
|
+
clonedAccessManager = AccessManagerUpgradeableInitializeable(Clones.clone(_accessManagerMaster));
|
56
|
+
clonedAccessManager.__AccessManagerUpgradeableInitializeable_init(address(this));
|
52
57
|
|
53
58
|
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
54
59
|
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
55
60
|
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
56
|
-
|
61
|
+
clonedInstanceNftId = info.nftId;
|
57
62
|
|
58
63
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
59
|
-
clonedInstanceReader.initialize(_registryAddress,
|
64
|
+
clonedInstanceReader.initialize(_registryAddress, clonedInstanceNftId);
|
65
|
+
clonedInstance.setInstanceReader(clonedInstanceReader);
|
60
66
|
|
61
|
-
|
67
|
+
clonedBundleManager = BundleManager(Clones.clone(_instanceBundleManagerMaster));
|
68
|
+
clonedBundleManager.initialize(address(clonedAccessManager), _registryAddress, clonedInstanceNftId);
|
69
|
+
clonedInstance.setBundleManager(clonedBundleManager);
|
62
70
|
|
63
|
-
|
71
|
+
// TODO amend setters with instance specific , policy manager ...
|
72
|
+
|
73
|
+
_grantInitialAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
|
64
74
|
|
65
75
|
// to complete setup switch instance ownership to the instance owner
|
66
76
|
// TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
|
67
77
|
clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
|
68
78
|
clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
|
69
79
|
|
70
|
-
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader),
|
80
|
+
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
|
71
81
|
}
|
72
82
|
|
73
|
-
function _grantInitialAuthorizations(
|
83
|
+
function _grantInitialAuthorizations(AccessManagerUpgradeable clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
84
|
+
// configure authorization for distribution service on instance
|
74
85
|
address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
75
|
-
|
76
86
|
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
|
77
87
|
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
|
78
88
|
instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
|
@@ -81,27 +91,95 @@ contract InstanceService is Service, IInstanceService {
|
|
81
91
|
address(clonedInstance),
|
82
92
|
instanceDistributionServiceSelectors,
|
83
93
|
DISTRIBUTION_SERVICE_ROLE().toInt());
|
84
|
-
}
|
85
94
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
95
|
+
// configure authorization for pool service on instance
|
96
|
+
address poolServiceAddress = _registry.getServiceAddress("PoolService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
97
|
+
clonedAccessManager.grantRole(POOL_SERVICE_ROLE().toInt(), address(poolServiceAddress), 0);
|
98
|
+
bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
|
99
|
+
instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
|
100
|
+
instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
|
101
|
+
clonedAccessManager.setTargetFunctionRole(
|
102
|
+
address(clonedInstance),
|
103
|
+
instancePoolServiceSelectors,
|
104
|
+
POOL_SERVICE_ROLE().toInt());
|
105
|
+
|
106
|
+
// configure authorization for product service on instance
|
107
|
+
address productServiceAddress = _registry.getServiceAddress("ProductService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
108
|
+
clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE().toInt(), address(productServiceAddress), 0);
|
109
|
+
bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
|
110
|
+
instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
|
111
|
+
instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
|
112
|
+
instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
|
113
|
+
instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
|
114
|
+
instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
|
115
|
+
clonedAccessManager.setTargetFunctionRole(
|
116
|
+
address(clonedInstance),
|
117
|
+
instanceProductServiceSelectors,
|
118
|
+
PRODUCT_SERVICE_ROLE().toInt());
|
119
|
+
|
120
|
+
// configure authorization for policy service on instance
|
121
|
+
address policyServiceAddress = _registry.getServiceAddress("PolicyService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
122
|
+
clonedAccessManager.grantRole(POLICY_SERVICE_ROLE().toInt(), address(policyServiceAddress), 0);
|
123
|
+
bytes4[] memory instancePolicyServiceSelectors = new bytes4[](3);
|
124
|
+
instancePolicyServiceSelectors[0] = clonedInstance.createPolicy.selector;
|
125
|
+
instancePolicyServiceSelectors[1] = clonedInstance.updatePolicy.selector;
|
126
|
+
instancePolicyServiceSelectors[2] = clonedInstance.updatePolicyState.selector;
|
127
|
+
clonedAccessManager.setTargetFunctionRole(
|
128
|
+
address(clonedInstance),
|
129
|
+
instancePolicyServiceSelectors,
|
130
|
+
POLICY_SERVICE_ROLE().toInt());
|
131
|
+
|
132
|
+
// configure authorization for bundle service on instance
|
133
|
+
address bundleServiceAddress = _registry.getServiceAddress("BundleService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
134
|
+
clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE().toInt(), address(bundleServiceAddress), 0);
|
135
|
+
bytes4[] memory instanceBundleServiceSelectors = new bytes4[](2);
|
136
|
+
instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
|
137
|
+
instanceBundleServiceSelectors[1] = clonedInstance.updateBundle.selector;
|
138
|
+
clonedAccessManager.setTargetFunctionRole(
|
139
|
+
address(clonedInstance),
|
140
|
+
instanceBundleServiceSelectors,
|
141
|
+
BUNDLE_SERVICE_ROLE().toInt());
|
142
|
+
|
143
|
+
// configure authorization for bundle service on bundle manager
|
144
|
+
bytes4[] memory bundleManagerBundleServiceSelectors = new bytes4[](5);
|
145
|
+
bundleManagerBundleServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
|
146
|
+
bundleManagerBundleServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
|
147
|
+
bundleManagerBundleServiceSelectors[2] = clonedBundleManager.add.selector;
|
148
|
+
bundleManagerBundleServiceSelectors[3] = clonedBundleManager.lock.selector;
|
149
|
+
bundleManagerBundleServiceSelectors[4] = clonedBundleManager.unlock.selector;
|
150
|
+
clonedAccessManager.setTargetFunctionRole(
|
151
|
+
address(clonedBundleManager),
|
152
|
+
bundleManagerBundleServiceSelectors,
|
153
|
+
BUNDLE_SERVICE_ROLE().toInt());
|
91
154
|
}
|
92
155
|
|
93
|
-
function
|
94
|
-
require(
|
95
|
-
|
96
|
-
|
97
|
-
|
156
|
+
function setMasterInstance(address accessManagerAddress, address instanceAddress, address instanceReaderAddress, address bundleManagerAddress) external onlyOwner {
|
157
|
+
require( _accessManagerMaster == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
158
|
+
require( _instanceMaster == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
159
|
+
require( _instanceBundleManagerMaster == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
|
160
|
+
|
161
|
+
require (accessManagerAddress != address(0), "ERROR:CRD-005:ACCESS_MANAGER_ZERO");
|
162
|
+
require (instanceAddress != address(0), "ERROR:CRD-006:INSTANCE_ZERO");
|
163
|
+
require (instanceReaderAddress != address(0), "ERROR:CRD-007:INSTANCE_READER_ZERO");
|
164
|
+
require (bundleManagerAddress != address(0), "ERROR:CRD-008:BUNDLE_MANAGER_ZERO");
|
165
|
+
|
166
|
+
Instance instance = Instance(instanceAddress);
|
167
|
+
InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
|
168
|
+
BundleManager bundleManager = BundleManager(bundleManagerAddress);
|
169
|
+
|
170
|
+
require(instance.authority() == accessManagerAddress, "ERROR:CRD-009:INSTANCE_AUTHORITY_MISMATCH");
|
171
|
+
require(instanceReader.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-010:INSTANCE_READER_INSTANCE_MISMATCH");
|
172
|
+
require(bundleManager.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-011:BUNDLE_MANAGER_INSTANCE_MISMATCH");
|
173
|
+
|
174
|
+
_accessManagerMaster = accessManagerAddress;
|
175
|
+
_instanceMaster = instanceAddress;
|
176
|
+
_instanceReaderMaster = instanceReaderAddress;
|
177
|
+
_instanceBundleManagerMaster = bundleManagerAddress;
|
98
178
|
}
|
99
179
|
|
100
|
-
function
|
101
|
-
|
102
|
-
|
103
|
-
"ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
|
104
|
-
_instanceReaderMaster = instanceReaderMaster;
|
180
|
+
function upgradeInstanceReader(NftId instanceNftId) external {
|
181
|
+
// TODO: ensure this is done by instance owner
|
182
|
+
// TODO: upgrade instance reader of this instance to latest (set above here)
|
105
183
|
}
|
106
184
|
|
107
185
|
function getInstanceReaderMaster() external view returns (address) {
|
@@ -116,6 +194,10 @@ contract InstanceService is Service, IInstanceService {
|
|
116
194
|
return _accessManagerMaster;
|
117
195
|
}
|
118
196
|
|
197
|
+
function getBundleManagerMaster() external view returns (address) {
|
198
|
+
return _instanceBundleManagerMaster;
|
199
|
+
}
|
200
|
+
|
119
201
|
// From IService
|
120
202
|
function getName() public pure override(IService, Service) returns(string memory) {
|
121
203
|
return NAME;
|
@@ -147,15 +229,33 @@ contract InstanceService is Service, IInstanceService {
|
|
147
229
|
|
148
230
|
address initialOwner = address(0);
|
149
231
|
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
150
|
-
|
151
|
-
|
232
|
+
// TODO while InstanceService is not deployed in InstanceServiceManager constructor
|
233
|
+
// owner is InstanceServiceManager deployer
|
234
|
+
_initializeService(_registryAddress, owner);
|
152
235
|
|
153
236
|
_registerInterface(type(IService).interfaceId);
|
154
237
|
_registerInterface(type(IInstanceService).interfaceId);
|
155
238
|
}
|
156
|
-
|
157
|
-
function
|
158
|
-
|
239
|
+
// TODO use instanceAddress instead of nft
|
240
|
+
/*function hasRole(address account, RoleId role, NftId instanceNftId) external view returns (bool) {
|
241
|
+
IRegistry.ObjectInfo memory instanceObjectInfo = getRegistry().getObjectInfo(instanceNftId);
|
242
|
+
address instanceAddress = instanceObjectInfo.objectAddress;
|
243
|
+
Instance instance = Instance(instanceAddress);
|
244
|
+
AccessManagerUpgradeable accessManager = AccessManagerUpgradeable(instance.authority());
|
245
|
+
(bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
|
246
|
+
if (executionDelay > 0) {
|
247
|
+
return false;
|
248
|
+
}
|
249
|
+
return isMember;
|
250
|
+
}*/
|
251
|
+
function hasRole(address account, RoleId role, address instanceAddress) external view returns (bool) {
|
252
|
+
Instance instance = Instance(instanceAddress);
|
253
|
+
AccessManagerUpgradeable accessManager = AccessManagerUpgradeable(instance.authority());
|
254
|
+
(bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
|
255
|
+
if (executionDelay > 0) {
|
256
|
+
return false;
|
257
|
+
}
|
258
|
+
return isMember;
|
159
259
|
}
|
160
260
|
}
|
161
261
|
|
@@ -31,14 +31,15 @@ contract InstanceServiceManager is ProxyManager {
|
|
31
31
|
Registry registry = Registry(registryAddress);
|
32
32
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
33
33
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
34
|
-
|
35
|
-
registryService.registerService(_instanceService);
|
34
|
+
// TODO this must have a role or own nft to register service
|
35
|
+
//registryService.registerService(_instanceService);
|
36
36
|
// RegistryService registryService = _instanceService.getRegistryService();
|
37
37
|
|
38
|
+
// TODO no nft to link yet
|
38
39
|
// link ownership of instance service manager ot nft owner of instance service
|
39
|
-
_linkToNftOwnable(
|
40
|
-
|
41
|
-
|
40
|
+
//_linkToNftOwnable(
|
41
|
+
// address(registryAddress),
|
42
|
+
// address(_instanceService));
|
42
43
|
|
43
44
|
// implies that after this constructor call only upgrade functionality is available
|
44
45
|
_isDeployed = true;
|