@etherisc/gif-next 0.0.2-cff6256-424 → 0.0.2-d224a95-375
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 +1347 -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 +169 -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 +207 -51
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +70 -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 +59 -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/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 +100 -25
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +30 -14
- 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/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +167 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +1049 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +464 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -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 +35 -26
- package/contracts/components/Product.sol +33 -41
- 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 +30 -7
- package/contracts/instance/IInstanceBase.sol +26 -0
- package/contracts/instance/IInstanceService.sol +5 -3
- package/contracts/instance/Instance.sol +41 -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 +105 -24
- package/contracts/instance/InstanceServiceManager.sol +6 -5
- package/contracts/instance/ObjectManager.sol +101 -0
- package/contracts/instance/base/ComponentServiceBase.sol +96 -1
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/ISetup.sol +3 -0
- package/contracts/instance/service/DistributionService.sol +12 -20
- package/contracts/instance/service/DistributionServiceManager.sol +6 -5
- package/contracts/instance/service/IPoolService.sol +16 -2
- package/contracts/instance/service/IProductService.sol +6 -3
- package/contracts/instance/service/PoolService.sol +287 -0
- package/contracts/instance/service/PoolServiceManager.sol +54 -0
- package/contracts/instance/service/ProductService.sol +570 -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 +2 -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
@@ -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,16 @@ 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";
|
29
33
|
import {VersionPart} from "../types/Version.sol";
|
34
|
+
import {InstanceBase} from "./InstanceBase.sol";
|
30
35
|
|
31
36
|
contract Instance is
|
32
|
-
|
33
|
-
KeyValueStore,
|
37
|
+
AccessManagedUpgradeable,
|
34
38
|
IInstance,
|
35
|
-
|
36
|
-
|
39
|
+
// Initializable,
|
40
|
+
InstanceBase
|
37
41
|
{
|
38
42
|
|
39
43
|
uint64 public constant ADMIN_ROLE = type(uint64).min;
|
@@ -50,20 +54,19 @@ contract Instance is
|
|
50
54
|
|
51
55
|
mapping(ShortString name => address target) internal _target;
|
52
56
|
|
53
|
-
|
57
|
+
AccessManagerUpgradeable internal _accessManager;
|
54
58
|
InstanceReader internal _instanceReader;
|
59
|
+
BundleManager internal _bundleManager;
|
55
60
|
|
56
|
-
|
61
|
+
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner)
|
62
|
+
public
|
63
|
+
initializer
|
57
64
|
{
|
58
|
-
initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
|
59
|
-
}
|
60
|
-
|
61
|
-
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
|
62
65
|
require(!_initialized, "Contract instance has already been initialized");
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
_accessManager =
|
67
|
+
__AccessManaged_init(accessManagerAddress);
|
68
|
+
|
69
|
+
_accessManager = AccessManagerUpgradeable(accessManagerAddress);
|
67
70
|
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
68
71
|
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
69
72
|
|
@@ -220,16 +223,16 @@ contract Instance is
|
|
220
223
|
}
|
221
224
|
|
222
225
|
//--- PoolSetup ------------------------------------------------------//
|
223
|
-
function createPoolSetup(NftId
|
224
|
-
create(_toNftKey32(
|
226
|
+
function createPoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
|
227
|
+
create(_toNftKey32(poolNftId, POOL()), abi.encode(setup));
|
225
228
|
}
|
226
229
|
|
227
|
-
function updatePoolSetup(NftId
|
228
|
-
update(_toNftKey32(
|
230
|
+
function updatePoolSetup(NftId poolNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
|
231
|
+
update(_toNftKey32(poolNftId, POOL()), abi.encode(setup), newState);
|
229
232
|
}
|
230
233
|
|
231
|
-
function updatePoolSetupState(NftId
|
232
|
-
updateState(_toNftKey32(
|
234
|
+
function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
|
235
|
+
updateState(_toNftKey32(poolNftId, POOL()), newState);
|
233
236
|
}
|
234
237
|
|
235
238
|
//--- DistributorType ---------------------------------------------------//
|
@@ -422,22 +425,31 @@ contract Instance is
|
|
422
425
|
return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
|
423
426
|
}
|
424
427
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
// }
|
428
|
+
function getProductService() external view returns (IProductService) {
|
429
|
+
return IProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
|
430
|
+
}
|
429
431
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
// }
|
432
|
+
function getPoolService() external view returns (IPoolService) {
|
433
|
+
return IPoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
|
434
|
+
}
|
434
435
|
|
435
436
|
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
436
437
|
require(address(_instanceReader) == address(0), "InstanceReader is set");
|
438
|
+
require(instanceReader.getInstanceNftId() == getNftId(), "NFT ID of InstanceReader does not match");
|
437
439
|
_instanceReader = instanceReader;
|
438
440
|
}
|
439
441
|
|
440
442
|
function getInstanceReader() external view returns (InstanceReader) {
|
441
443
|
return _instanceReader;
|
442
444
|
}
|
445
|
+
|
446
|
+
function setBundleManager(BundleManager bundleManager) external restricted() {
|
447
|
+
require(address(_bundleManager) == address(0), "BundleManager is set");
|
448
|
+
require(bundleManager.getInstanceNftId() == getNftId(), "NFT ID of BundleManager does not match");
|
449
|
+
_bundleManager = bundleManager;
|
450
|
+
}
|
451
|
+
|
452
|
+
function getBundleManager() external view returns (BundleManager) {
|
453
|
+
return _bundleManager;
|
454
|
+
}
|
443
455
|
}
|
@@ -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} 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;
|
@@ -44,32 +49,40 @@ contract InstanceService is Service, IInstanceService {
|
|
44
49
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
45
50
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
46
51
|
|
47
|
-
|
48
|
-
//
|
49
|
-
|
52
|
+
// initially set the authority of the access managar to this (being the instance service).
|
53
|
+
// This will allow the instance service to bootstrap the authorizations of the instance
|
54
|
+
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
55
|
+
clonedAccessManager = AccessManagerUpgradeableInitializeable(Clones.clone(_accessManagerMaster));
|
56
|
+
clonedAccessManager.__AccessManagerUpgradeableInitializeable_init(address(this));
|
50
57
|
|
51
58
|
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
52
59
|
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
53
60
|
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
54
|
-
|
61
|
+
clonedInstanceNftId = info.nftId;
|
55
62
|
|
56
63
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
57
|
-
clonedInstanceReader.initialize(_registryAddress,
|
64
|
+
clonedInstanceReader.initialize(_registryAddress, clonedInstanceNftId);
|
65
|
+
clonedInstance.setInstanceReader(clonedInstanceReader);
|
58
66
|
|
59
|
-
|
67
|
+
clonedBundleManager = BundleManager(Clones.clone(_instanceBundleManagerMaster));
|
68
|
+
clonedBundleManager.initialize(address(clonedAccessManager), _registryAddress, clonedInstanceNftId);
|
69
|
+
clonedInstance.setBundleManager(clonedBundleManager);
|
60
70
|
|
61
|
-
|
71
|
+
// TODO amend setters with instance specific , policy manager ...
|
72
|
+
|
73
|
+
_grantInitialAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
|
62
74
|
|
63
|
-
// switch instance ownership to instance owner
|
75
|
+
// to complete setup switch instance ownership to the instance owner
|
76
|
+
// TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
|
64
77
|
clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
|
65
78
|
clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
|
66
79
|
|
67
|
-
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader),
|
80
|
+
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
|
68
81
|
}
|
69
82
|
|
70
|
-
function _grantInitialAuthorizations(
|
83
|
+
function _grantInitialAuthorizations(AccessManagerUpgradeable clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
84
|
+
// configure authorization for distribution service on instance
|
71
85
|
address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
72
|
-
|
73
86
|
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
|
74
87
|
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
|
75
88
|
instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
|
@@ -78,6 +91,48 @@ contract InstanceService is Service, IInstanceService {
|
|
78
91
|
address(clonedInstance),
|
79
92
|
instanceDistributionServiceSelectors,
|
80
93
|
DISTRIBUTION_SERVICE_ROLE().toInt());
|
94
|
+
|
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
|
+
instancePoolServiceSelectors[2] = clonedInstance.createBundle.selector;
|
102
|
+
instancePoolServiceSelectors[3] = clonedInstance.updateBundle.selector;
|
103
|
+
clonedAccessManager.setTargetFunctionRole(
|
104
|
+
address(clonedInstance),
|
105
|
+
instancePoolServiceSelectors,
|
106
|
+
POOL_SERVICE_ROLE().toInt());
|
107
|
+
|
108
|
+
// configure authorization for pool service on bundle manager
|
109
|
+
bytes4[] memory bundleManagerPoolServiceSelectors = new bytes4[](5);
|
110
|
+
bundleManagerPoolServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
|
111
|
+
bundleManagerPoolServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
|
112
|
+
bundleManagerPoolServiceSelectors[2] = clonedBundleManager.add.selector;
|
113
|
+
bundleManagerPoolServiceSelectors[3] = clonedBundleManager.lock.selector;
|
114
|
+
bundleManagerPoolServiceSelectors[4] = clonedBundleManager.unlock.selector;
|
115
|
+
clonedAccessManager.setTargetFunctionRole(
|
116
|
+
address(clonedBundleManager),
|
117
|
+
bundleManagerPoolServiceSelectors,
|
118
|
+
POOL_SERVICE_ROLE().toInt());
|
119
|
+
|
120
|
+
// configure authorization for product service on instance
|
121
|
+
address productServiceAddress = _registry.getServiceAddress("ProductService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
122
|
+
clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE().toInt(), address(productServiceAddress), 0);
|
123
|
+
bytes4[] memory instanceProductServiceSelectors = new bytes4[](9);
|
124
|
+
instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
|
125
|
+
instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
|
126
|
+
instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
|
127
|
+
instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
|
128
|
+
instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
|
129
|
+
instanceProductServiceSelectors[5] = clonedInstance.createPolicy.selector;
|
130
|
+
instanceProductServiceSelectors[6] = clonedInstance.updatePolicy.selector;
|
131
|
+
instanceProductServiceSelectors[7] = clonedInstance.updatePolicyState.selector;
|
132
|
+
clonedAccessManager.setTargetFunctionRole(
|
133
|
+
address(clonedInstance),
|
134
|
+
instanceProductServiceSelectors,
|
135
|
+
PRODUCT_SERVICE_ROLE().toInt());
|
81
136
|
}
|
82
137
|
|
83
138
|
function setAccessManagerMaster(address accessManagerMaster) external {
|
@@ -88,19 +143,32 @@ contract InstanceService is Service, IInstanceService {
|
|
88
143
|
}
|
89
144
|
|
90
145
|
function setInstanceMaster(address instanceMaster) external {
|
146
|
+
// TODO: ensure instance has correct access manager
|
91
147
|
require(
|
92
148
|
_instanceMaster == address(0),
|
93
149
|
"ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
94
150
|
_instanceMaster = instanceMaster;
|
95
151
|
}
|
96
152
|
|
97
|
-
function setInstanceReaderMaster(address instanceReaderMaster) external {
|
98
|
-
|
99
|
-
|
100
|
-
"ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
|
153
|
+
function setInstanceReaderMaster(address instanceReaderMaster) external onlyOwner {
|
154
|
+
// TODO: ensure instance reader points to master instance
|
155
|
+
// TODO: add a test for this
|
101
156
|
_instanceReaderMaster = instanceReaderMaster;
|
102
157
|
}
|
103
158
|
|
159
|
+
function upgradeInstanceReader(NftId instanceNftId) external {
|
160
|
+
// TODO: ensure this is done by instance owner
|
161
|
+
// TODO: upgrade instance reader of this instance to latest (set above here)
|
162
|
+
}
|
163
|
+
|
164
|
+
function setBundleManagerMaster(address bundleManagerMaster) external {
|
165
|
+
// TODO: ensure bundle manager points to master instance
|
166
|
+
require(
|
167
|
+
_instanceBundleManagerMaster == address(0),
|
168
|
+
"ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
|
169
|
+
_instanceBundleManagerMaster = bundleManagerMaster;
|
170
|
+
}
|
171
|
+
|
104
172
|
function getInstanceReaderMaster() external view returns (address) {
|
105
173
|
return _instanceReaderMaster;
|
106
174
|
}
|
@@ -113,6 +181,10 @@ contract InstanceService is Service, IInstanceService {
|
|
113
181
|
return _accessManagerMaster;
|
114
182
|
}
|
115
183
|
|
184
|
+
function getBundleManagerMaster() external view returns (address) {
|
185
|
+
return _instanceBundleManagerMaster;
|
186
|
+
}
|
187
|
+
|
116
188
|
// From IService
|
117
189
|
function getName() public pure override(IService, Service) returns(string memory) {
|
118
190
|
return NAME;
|
@@ -144,15 +216,24 @@ contract InstanceService is Service, IInstanceService {
|
|
144
216
|
|
145
217
|
address initialOwner = address(0);
|
146
218
|
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
147
|
-
|
148
|
-
|
219
|
+
// TODO while InstanceService is not deployed in InstanceServiceManager constructor
|
220
|
+
// owner is InstanceServiceManager deployer
|
221
|
+
_initializeService(_registryAddress, owner);
|
149
222
|
|
150
223
|
_registerInterface(type(IService).interfaceId);
|
151
224
|
_registerInterface(type(IInstanceService).interfaceId);
|
152
225
|
}
|
153
226
|
|
154
|
-
function
|
155
|
-
|
227
|
+
function hasRole(address account, RoleId role, NftId instanceNftId) external view returns (bool) {
|
228
|
+
IRegistry.ObjectInfo memory instanceObjectInfo = getRegistry().getObjectInfo(instanceNftId);
|
229
|
+
address instanceAddress = instanceObjectInfo.objectAddress;
|
230
|
+
Instance instance = Instance(instanceAddress);
|
231
|
+
AccessManagerUpgradeable accessManager = AccessManagerUpgradeable(instance.authority());
|
232
|
+
(bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
|
233
|
+
if (executionDelay > 0) {
|
234
|
+
return false;
|
235
|
+
}
|
236
|
+
return isMember;
|
156
237
|
}
|
157
238
|
}
|
158
239
|
|
@@ -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;
|
@@ -0,0 +1,101 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Cloneable} from "./Cloneable.sol";
|
5
|
+
|
6
|
+
import {IInstance} from "./IInstance.sol";
|
7
|
+
import {INSTANCE} from "../types/ObjectType.sol";
|
8
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
9
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
10
|
+
import {LibNftIdSet} from "../types/NftIdSet.sol";
|
11
|
+
import {NftId} from "../types/NftId.sol";
|
12
|
+
|
13
|
+
contract ObjectManager is
|
14
|
+
Cloneable
|
15
|
+
{
|
16
|
+
|
17
|
+
event LogObjectManagerInitialized(NftId instanceNftId, address instanceReader);
|
18
|
+
|
19
|
+
error ErrorObjectManagerNftIdInvalid(NftId instanceNftId);
|
20
|
+
error ErrorObjectManagerAlreadyAdded(NftId componentNftId, NftId objectNftId);
|
21
|
+
|
22
|
+
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _activeObjects;
|
23
|
+
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _allObjects;
|
24
|
+
NftId internal _instanceNftId;
|
25
|
+
InstanceReader internal _instanceReader;
|
26
|
+
|
27
|
+
constructor() Cloneable() {
|
28
|
+
_instanceReader = InstanceReader(address(0));
|
29
|
+
}
|
30
|
+
|
31
|
+
/// @dev call to initialize MUST be made in the same transaction as cloning of the contract
|
32
|
+
function initialize(
|
33
|
+
address authority,
|
34
|
+
address registry,
|
35
|
+
NftId instanceNftId
|
36
|
+
)
|
37
|
+
external
|
38
|
+
{
|
39
|
+
initialize(authority, registry);
|
40
|
+
|
41
|
+
// check/handle instance nft id/instance reader
|
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;
|
50
|
+
|
51
|
+
emit LogObjectManagerInitialized(instanceNftId, address(_instanceReader));
|
52
|
+
}
|
53
|
+
|
54
|
+
function getInstanceReader() external view returns (InstanceReader) {
|
55
|
+
return _instanceReader;
|
56
|
+
}
|
57
|
+
|
58
|
+
function getInstanceNftId() external view returns (NftId) {
|
59
|
+
return _instanceNftId;
|
60
|
+
}
|
61
|
+
|
62
|
+
function _add(NftId componentNftId, NftId objectNftId) internal {
|
63
|
+
LibNftIdSet.Set storage allSet = _allObjects[componentNftId];
|
64
|
+
LibNftIdSet.Set storage activeSet = _activeObjects[componentNftId];
|
65
|
+
|
66
|
+
LibNftIdSet.add(allSet, objectNftId);
|
67
|
+
LibNftIdSet.add(activeSet, objectNftId);
|
68
|
+
}
|
69
|
+
|
70
|
+
function _activate(NftId componentNftId, NftId objectNftId) internal {
|
71
|
+
LibNftIdSet.add(_activeObjects[componentNftId], objectNftId);
|
72
|
+
}
|
73
|
+
|
74
|
+
function _deactivate(NftId componentNftId, NftId objectNftId) internal {
|
75
|
+
LibNftIdSet.remove(_activeObjects[componentNftId], objectNftId);
|
76
|
+
}
|
77
|
+
|
78
|
+
function _objects(NftId componentNftId) internal view returns (uint256) {
|
79
|
+
return LibNftIdSet.size(_allObjects[componentNftId]);
|
80
|
+
}
|
81
|
+
|
82
|
+
function _contains(NftId componentNftId, NftId objectNftId) internal view returns (bool) {
|
83
|
+
return LibNftIdSet.contains(_allObjects[componentNftId], objectNftId);
|
84
|
+
}
|
85
|
+
|
86
|
+
function _getObject(NftId componentNftId, uint256 idx) internal view returns (NftId) {
|
87
|
+
return LibNftIdSet.getElementAt(_allObjects[componentNftId], idx);
|
88
|
+
}
|
89
|
+
|
90
|
+
function _activeObjs(NftId componentNftId) internal view returns (uint256) {
|
91
|
+
return LibNftIdSet.size(_activeObjects[componentNftId]);
|
92
|
+
}
|
93
|
+
|
94
|
+
function _isActive(NftId componentNftId, NftId objectNftId) internal view returns (bool) {
|
95
|
+
return LibNftIdSet.contains(_activeObjects[componentNftId], objectNftId);
|
96
|
+
}
|
97
|
+
|
98
|
+
function _getActiveObject(NftId componentNftId, uint256 idx) internal view returns (NftId) {
|
99
|
+
return LibNftIdSet.getElementAt(_activeObjects[componentNftId], idx);
|
100
|
+
}
|
101
|
+
}
|