@etherisc/gif-next 0.0.2-ce8407f-016 → 0.0.2-d243ae6-520
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +314 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +610 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +26 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +152 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +774 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +754 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
- 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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +13 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +15 -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 +342 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +489 -493
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +45 -32
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +438 -33
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +654 -16
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +432 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +481 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +0 -77
- 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/KeyValueStore.sol/KeyValueStore.json +10 -244
- 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 +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +41 -161
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +134 -7
- 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 +62 -190
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +287 -39
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +61 -33
- 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/ERC165.sol/ERC165.json +2 -2
- 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 +4 -0
- package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.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 +6 -6
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +2 -2
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- 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/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -6
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +111 -5
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +17 -17
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- 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/TestVersionable.sol/TestVersionable.json +2 -2
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
- 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/Fee.sol/FeeLib.json +4 -4
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- 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 +86 -0
- package/contracts/components/Distribution.sol +166 -0
- package/contracts/components/IBaseComponent.sol +7 -2
- package/contracts/components/IDistributionComponent.sol +43 -0
- package/contracts/components/IPoolComponent.sol +62 -0
- package/contracts/components/IProductComponent.sol +35 -0
- package/contracts/components/Pool.sol +259 -0
- package/contracts/components/Product.sol +297 -0
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/AccessManagedSimple.sol +12 -4
- package/contracts/instance/AccessManagerSimple.sol +12 -2
- package/contracts/instance/IAccessManagerSimple.sol +1 -1
- package/contracts/instance/IInstance.sol +23 -1
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +59 -9
- package/contracts/instance/InstanceAccessManager.sol +2 -2
- package/contracts/instance/InstanceReader.sol +63 -8
- package/contracts/instance/InstanceService.sol +111 -18
- package/contracts/instance/InstanceServiceManager.sol +56 -0
- package/contracts/instance/base/ComponentServiceBase.sol +49 -0
- package/contracts/instance/base/IInstanceBase.sol +23 -0
- package/contracts/instance/base/IKeyValueStore.sol +5 -4
- package/contracts/instance/base/KeyValueStore.sol +4 -20
- package/contracts/instance/module/IAccess.sol +2 -2
- package/contracts/instance/module/ISetup.sol +3 -1
- package/contracts/instance/module/ITreasury.sol +1 -1
- package/contracts/instance/service/ComponentOwnerService.sol +317 -0
- package/contracts/instance/service/IComponentOwnerService.sol +20 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +37 -0
- package/contracts/instance/service/IProductService.sol +107 -0
- package/contracts/registry/ChainNft.sol +40 -25
- package/contracts/registry/IRegistry.sol +5 -20
- package/contracts/registry/IRegistryService.sol +16 -10
- package/contracts/registry/Registry.sol +87 -155
- package/contracts/registry/RegistryService.sol +182 -107
- package/contracts/registry/RegistryServiceManager.sol +23 -2
- package/contracts/shared/ERC165.sol +1 -1
- package/contracts/shared/IRegisterable.sol +1 -1
- package/contracts/{instance/base → shared}/IService.sol +3 -3
- package/contracts/shared/ProxyManager.sol +3 -3
- package/contracts/shared/Registerable.sol +2 -2
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +54 -0
- package/contracts/shared/TokenHandler.sol +2 -2
- package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
- package/contracts/shared/Versionable.sol +1 -1
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRoleId.sol +6 -6
- package/contracts/test/TestService.sol +3 -5
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/RoleId.sol +11 -4
- package/contracts/types/UFixed.sol +128 -12
- package/package.json +4 -3
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/instance/base/ServiceBase.sol +0 -44
- package/contracts/registry/IChainNft.sol +0 -22
@@ -1,6 +1,28 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
5
5
|
|
6
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
7
|
+
|
8
|
+
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
9
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
10
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
11
|
+
import {IProductService} from "./service/IProductService.sol";
|
12
|
+
import {ISetup} from "./module/ISetup.sol";
|
13
|
+
import {NftId} from "../types/NftId.sol";
|
14
|
+
|
15
|
+
interface IInstance is IERC165 {
|
16
|
+
|
17
|
+
function getComponentOwnerService() external view returns (IComponentOwnerService);
|
18
|
+
// TODO: renable these when we have the services
|
19
|
+
// function getDistributionService() external view returns (IDistributionService);
|
20
|
+
// function getProductService() external view returns (IProductService);
|
21
|
+
// function getPoolService() external view returns (IPoolService);
|
22
|
+
|
23
|
+
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
|
24
|
+
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
|
25
|
+
function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external;
|
26
|
+
|
27
|
+
function getInstanceReader() external view returns (InstanceReader);
|
6
28
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {NftId} from "../types/NftId.sol";
|
5
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
6
|
+
import {RoleId} from "../types/RoleId.sol";
|
7
|
+
import {IService} from "../shared/IService.sol";
|
8
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
9
|
+
|
10
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
11
|
+
import {IBaseComponent} from "../components/IBaseComponent.sol";
|
12
|
+
|
13
|
+
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
14
|
+
import {Instance} from "./Instance.sol";
|
15
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
16
|
+
|
17
|
+
interface IInstanceService is IService {
|
18
|
+
|
19
|
+
event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
|
20
|
+
|
21
|
+
function createInstanceClone()
|
22
|
+
external
|
23
|
+
returns (
|
24
|
+
AccessManagerSimple clonedAccessManager,
|
25
|
+
Instance clonedInstance,
|
26
|
+
NftId instanceNftId,
|
27
|
+
InstanceReader clonedInstanceReader
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
@@ -1,8 +1,8 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {EnumerableSet} from "@
|
5
|
-
import {ShortString, ShortStrings} from "@
|
4
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
|
+
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
6
|
|
7
7
|
import {AccessManagedSimple} from "./AccessManagedSimple.sol";
|
8
8
|
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
@@ -14,17 +14,25 @@ import {ISetup} from "./module/ISetup.sol";
|
|
14
14
|
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
15
15
|
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
16
16
|
import {IInstance} from "./IInstance.sol";
|
17
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
17
18
|
import {NftId} from "../types/NftId.sol";
|
18
19
|
import {NumberId} from "../types/NumberId.sol";
|
19
|
-
import {ObjectType, BUNDLE, DISTRIBUTION, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
20
|
+
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
20
21
|
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
21
22
|
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
22
23
|
import {StateId, ACTIVE} from "../types/StateId.sol";
|
24
|
+
import {ERC165} from "../shared/ERC165.sol";
|
25
|
+
import {Registerable} from "../shared/Registerable.sol";
|
26
|
+
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
27
|
+
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
28
|
+
import {VersionPart} from "../types/Version.sol";
|
23
29
|
|
24
30
|
contract Instance is
|
25
31
|
AccessManagedSimple,
|
26
32
|
KeyValueStore,
|
27
|
-
IInstance
|
33
|
+
IInstance,
|
34
|
+
ERC165,
|
35
|
+
Registerable
|
28
36
|
{
|
29
37
|
|
30
38
|
uint64 public constant ADMIN_ROLE = type(uint64).min;
|
@@ -33,6 +41,8 @@ contract Instance is
|
|
33
41
|
|
34
42
|
uint32 public constant EXECUTION_DELAY = 0;
|
35
43
|
|
44
|
+
bool private _initialized;
|
45
|
+
|
36
46
|
mapping(ShortString name => RoleId roleId) internal _role;
|
37
47
|
mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
|
38
48
|
RoleId [] internal _roles;
|
@@ -40,13 +50,25 @@ contract Instance is
|
|
40
50
|
mapping(ShortString name => address target) internal _target;
|
41
51
|
|
42
52
|
AccessManagerSimple internal _accessManager;
|
53
|
+
InstanceReader internal _instanceReader;
|
43
54
|
|
44
|
-
constructor(address accessManagerAddress)
|
55
|
+
constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
|
45
56
|
AccessManagedSimple(accessManagerAddress)
|
46
57
|
{
|
58
|
+
initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
|
59
|
+
}
|
60
|
+
|
61
|
+
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
|
62
|
+
require(!_initialized, "Contract instance has already been initialized");
|
63
|
+
|
47
64
|
_accessManager = AccessManagerSimple(accessManagerAddress);
|
48
65
|
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
49
66
|
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
67
|
+
|
68
|
+
_initializeRegisterable(registryAddress, registryNftId, INSTANCE(), false, initialOwner, "");
|
69
|
+
|
70
|
+
_registerInterface(type(IInstance).interfaceId);
|
71
|
+
_initialized = true;
|
50
72
|
}
|
51
73
|
|
52
74
|
//--- Role ------------------------------------------------------//
|
@@ -183,11 +205,11 @@ contract Instance is
|
|
183
205
|
}
|
184
206
|
|
185
207
|
//--- DistributionSetup ------------------------------------------------------//
|
186
|
-
function createDistributionSetup(NftId distributionNftId, ISetup.
|
208
|
+
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external restricted() {
|
187
209
|
create(_toNftKey32(distributionNftId, DISTRIBUTION()), abi.encode(setup));
|
188
210
|
}
|
189
211
|
|
190
|
-
function updateDistributionSetup(NftId distributionNftId, ISetup.
|
212
|
+
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external restricted() {
|
191
213
|
update(_toNftKey32(distributionNftId, DISTRIBUTION()), abi.encode(setup), newState);
|
192
214
|
}
|
193
215
|
|
@@ -196,11 +218,11 @@ contract Instance is
|
|
196
218
|
}
|
197
219
|
|
198
220
|
//--- PoolSetup ------------------------------------------------------//
|
199
|
-
function createPoolSetup(NftId distributionNftId, ISetup.
|
221
|
+
function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external restricted() {
|
200
222
|
create(_toNftKey32(distributionNftId, POOL()), abi.encode(setup));
|
201
223
|
}
|
202
224
|
|
203
|
-
function updatePoolSetup(NftId distributionNftId, ISetup.
|
225
|
+
function updatePoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup, StateId newState) external restricted() {
|
204
226
|
update(_toNftKey32(distributionNftId, POOL()), abi.encode(setup), newState);
|
205
227
|
}
|
206
228
|
|
@@ -389,4 +411,32 @@ contract Instance is
|
|
389
411
|
function toPolicyKey32(NftId policyNftId) public pure returns (Key32) {
|
390
412
|
return policyNftId.toKey32(POLICY());
|
391
413
|
}
|
414
|
+
|
415
|
+
function getComponentOwnerService() external view returns (IComponentOwnerService) {
|
416
|
+
return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
|
417
|
+
}
|
418
|
+
|
419
|
+
// TODO reactivate when services are available
|
420
|
+
// function getDistributionService() external view returns (IDistributionService) {
|
421
|
+
// return DistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
|
422
|
+
// }
|
423
|
+
|
424
|
+
// TODO reactivate when services are available
|
425
|
+
// function getProductService() external view returns (IProductService) {
|
426
|
+
// return ProductService(_registry.getServiceAddress("ProductService", VersionPart.wrap(3)));
|
427
|
+
// }
|
428
|
+
|
429
|
+
// TODO reactivate when services are available
|
430
|
+
// function getPoolService() external view returns (IPoolService) {
|
431
|
+
// return PoolService(_registry.getServiceAddress("PoolService", VersionPart.wrap(3)));
|
432
|
+
// }
|
433
|
+
|
434
|
+
function setInstanceReader(InstanceReader instanceReader) external restricted() {
|
435
|
+
require(address(_instanceReader) == address(0), "InstanceReader is set");
|
436
|
+
_instanceReader = instanceReader;
|
437
|
+
}
|
438
|
+
|
439
|
+
function getInstanceReader() external view returns (InstanceReader) {
|
440
|
+
return _instanceReader;
|
441
|
+
}
|
392
442
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {EnumerableSet} from "@
|
5
|
-
import {ShortString, ShortStrings} from "@
|
4
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
|
+
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
6
|
|
7
7
|
import {AccessManagedSimple} from "./AccessManagedSimple.sol";
|
8
8
|
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
@@ -1,17 +1,17 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IERC20Metadata} from "@
|
4
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
6
|
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, INSTANCE, PRODUCT, POLICY, TREASURY} from "../types/ObjectType.sol";
|
10
|
+
import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY} 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
|
-
import {UFixed,
|
14
|
+
import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
|
15
15
|
import {Version} from "../types/Version.sol";
|
16
16
|
|
17
17
|
import {IRegistry} from "../registry/IRegistry.sol";
|
@@ -20,11 +20,13 @@ import {IInstance} from "./IInstance.sol";
|
|
20
20
|
import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
|
21
21
|
import {IPolicy} from "../instance/module/IPolicy.sol";
|
22
22
|
import {IRisk} from "../instance/module/IRisk.sol";
|
23
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
23
24
|
import {ITreasury} from "../instance/module/ITreasury.sol";
|
24
25
|
import {TimestampLib} from "../types/Timestamp.sol";
|
25
26
|
|
26
27
|
|
27
28
|
contract InstanceReader {
|
29
|
+
bool private _initialized;
|
28
30
|
|
29
31
|
IRegistry internal _registry;
|
30
32
|
NftId internal _instanceNftId;
|
@@ -36,6 +38,12 @@ contract InstanceReader {
|
|
36
38
|
NftId instanceNftId
|
37
39
|
)
|
38
40
|
{
|
41
|
+
initialize(registry, instanceNftId);
|
42
|
+
}
|
43
|
+
|
44
|
+
function initialize(address registry, NftId instanceNftId) public {
|
45
|
+
require(!_initialized, "ERROR:CRD-000:ALREADY_INITIALIZED");
|
46
|
+
|
39
47
|
require(
|
40
48
|
address(registry) != address(0),
|
41
49
|
"ERROR:CRD-001:REGISTRY_ZERO");
|
@@ -54,8 +62,11 @@ contract InstanceReader {
|
|
54
62
|
|
55
63
|
_instance = IInstance(instanceInfo.objectAddress);
|
56
64
|
_store = IKeyValueStore(instanceInfo.objectAddress);
|
65
|
+
|
66
|
+
_initialized = true;
|
57
67
|
}
|
58
68
|
|
69
|
+
|
59
70
|
// module specific functions
|
60
71
|
|
61
72
|
function getPolicyInfo(NftId policyNftId)
|
@@ -126,6 +137,38 @@ contract InstanceReader {
|
|
126
137
|
}
|
127
138
|
}
|
128
139
|
|
140
|
+
function getDistributionSetupInfo(NftId distributionNftId)
|
141
|
+
public
|
142
|
+
view
|
143
|
+
returns (ISetup.DistributionSetupInfo memory info)
|
144
|
+
{
|
145
|
+
bytes memory data = _store.getData(toDistributionKey(distributionNftId));
|
146
|
+
if (data.length > 0) {
|
147
|
+
return abi.decode(data, (ISetup.DistributionSetupInfo));
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
function getPoolSetupInfo(NftId poolNftId)
|
152
|
+
public
|
153
|
+
view
|
154
|
+
returns (ISetup.PoolSetupInfo memory info)
|
155
|
+
{
|
156
|
+
bytes memory data = _store.getData(toPoolKey(poolNftId));
|
157
|
+
if (data.length > 0) {
|
158
|
+
return abi.decode(data, (ISetup.PoolSetupInfo));
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
function getProductSetupInfo(NftId productNftId)
|
163
|
+
public
|
164
|
+
view
|
165
|
+
returns (ISetup.ProductSetupInfo memory info)
|
166
|
+
{
|
167
|
+
bytes memory data = _store.getData(toProductKey(productNftId));
|
168
|
+
if (data.length > 0) {
|
169
|
+
return abi.decode(data, (ISetup.ProductSetupInfo));
|
170
|
+
}
|
171
|
+
}
|
129
172
|
|
130
173
|
function getReferralInfo(ReferralId referralId)
|
131
174
|
public
|
@@ -175,19 +218,19 @@ contract InstanceReader {
|
|
175
218
|
|
176
219
|
if (info.expiryAt.eqz()) {
|
177
220
|
return (
|
178
|
-
|
221
|
+
UFixedLib.zero(),
|
179
222
|
REFERRAL_ERROR_UNKNOWN());
|
180
223
|
}
|
181
224
|
|
182
225
|
if (info.expiryAt < TimestampLib.blockTimestamp()) {
|
183
226
|
return (
|
184
|
-
|
227
|
+
UFixedLib.zero(),
|
185
228
|
REFERRAL_ERROR_EXPIRED());
|
186
229
|
}
|
187
230
|
|
188
231
|
if (info.usedReferrals >= info.maxReferrals) {
|
189
232
|
return (
|
190
|
-
|
233
|
+
UFixedLib.zero(),
|
191
234
|
REFERRAL_ERROR_EXHAUSTED());
|
192
235
|
}
|
193
236
|
|
@@ -212,6 +255,18 @@ contract InstanceReader {
|
|
212
255
|
return distributorNftId.toKey32(DISTRIBUTOR());
|
213
256
|
}
|
214
257
|
|
258
|
+
function toDistributionKey(NftId distributionNftId) public pure returns (Key32) {
|
259
|
+
return distributionNftId.toKey32(DISTRIBUTION());
|
260
|
+
}
|
261
|
+
|
262
|
+
function toPoolKey(NftId poolNftId) public pure returns (Key32) {
|
263
|
+
return poolNftId.toKey32(POOL());
|
264
|
+
}
|
265
|
+
|
266
|
+
function toProductKey(NftId productNftId) public pure returns (Key32) {
|
267
|
+
return productNftId.toKey32(PRODUCT());
|
268
|
+
}
|
269
|
+
|
215
270
|
// low level function
|
216
271
|
function getInstance() external view returns (IInstance instance) {
|
217
272
|
return _instance;
|
@@ -226,10 +281,10 @@ contract InstanceReader {
|
|
226
281
|
}
|
227
282
|
|
228
283
|
function toUFixed(uint256 value, int8 exp) public pure returns (UFixed) {
|
229
|
-
return
|
284
|
+
return UFixedLib.toUFixed(value, exp);
|
230
285
|
}
|
231
286
|
|
232
287
|
function toInt(UFixed value) public pure returns (uint256) {
|
233
|
-
return
|
288
|
+
return UFixedLib.toInt(value);
|
234
289
|
}
|
235
290
|
}
|
@@ -1,45 +1,138 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {Clones} from "@
|
4
|
+
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
5
5
|
|
6
6
|
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
7
7
|
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
8
8
|
import {Instance} from "./Instance.sol";
|
9
|
+
import {IInstanceService} from "./IInstanceService.sol";
|
10
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
11
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
12
|
+
import {Registry} from "../registry/Registry.sol";
|
13
|
+
import {RegistryService} from "../registry/RegistryService.sol";
|
14
|
+
import {Service} from "../../contracts/shared/Service.sol";
|
15
|
+
import {IService} from "../shared/IService.sol";
|
16
|
+
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
17
|
+
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
18
|
+
import {VersionLib} from "../types/Version.sol";
|
9
19
|
|
10
|
-
contract InstanceService {
|
20
|
+
contract InstanceService is Service, IInstanceService {
|
11
21
|
|
22
|
+
address internal _registryAddress;
|
12
23
|
address internal _accessManagerMaster;
|
13
|
-
address internal _instanceAccessManagerMaster;
|
14
24
|
address internal _instanceMaster;
|
25
|
+
address internal _instanceReaderMaster;
|
26
|
+
|
27
|
+
// TODO update to real hash when instance is stable
|
28
|
+
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
29
|
+
string public constant NAME = "InstanceService";
|
15
30
|
|
16
31
|
function createInstanceClone()
|
17
32
|
external
|
18
33
|
returns (
|
19
|
-
AccessManagerSimple
|
20
|
-
|
21
|
-
|
34
|
+
AccessManagerSimple clonedAccessManager,
|
35
|
+
Instance clonedInstance,
|
36
|
+
NftId instanceNftId,
|
37
|
+
InstanceReader clonedInstanceReader
|
22
38
|
)
|
23
39
|
{
|
24
|
-
|
25
|
-
|
26
|
-
|
40
|
+
Registry registry = Registry(_registryAddress);
|
41
|
+
NftId registryNftId = registry.getNftId(_registryAddress);
|
42
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
43
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
44
|
+
|
45
|
+
clonedAccessManager = AccessManagerSimple(Clones.clone(_accessManagerMaster));
|
46
|
+
clonedAccessManager.initialize(msg.sender);
|
47
|
+
|
48
|
+
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
49
|
+
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
50
|
+
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
51
|
+
instanceNftId = info.nftId;
|
52
|
+
|
53
|
+
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
54
|
+
clonedInstanceReader.initialize(_registryAddress, instanceNftId);
|
55
|
+
|
56
|
+
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), instanceNftId);
|
57
|
+
}
|
58
|
+
|
59
|
+
function setAccessManagerMaster(address accessManagerMaster) external {
|
60
|
+
require(
|
61
|
+
_accessManagerMaster == address(0),
|
62
|
+
"ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
63
|
+
_accessManagerMaster = accessManagerMaster;
|
64
|
+
}
|
65
|
+
|
66
|
+
function setInstanceMaster(address instanceMaster) external {
|
67
|
+
require(
|
68
|
+
_instanceMaster == address(0),
|
69
|
+
"ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
70
|
+
_instanceMaster = instanceMaster;
|
71
|
+
}
|
72
|
+
|
73
|
+
function setInstanceReaderMaster(address instanceReaderMaster) external {
|
74
|
+
require(
|
75
|
+
_instanceReaderMaster == address(0),
|
76
|
+
"ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
|
77
|
+
_instanceReaderMaster = instanceReaderMaster;
|
27
78
|
}
|
28
79
|
|
29
|
-
function
|
30
|
-
|
80
|
+
function getInstanceReaderMaster() external view returns (address) {
|
81
|
+
return _instanceReaderMaster;
|
31
82
|
}
|
32
83
|
|
33
|
-
function
|
34
|
-
|
84
|
+
function getInstanceMaster() external view returns (address) {
|
85
|
+
return _instanceMaster;
|
35
86
|
}
|
36
87
|
|
37
|
-
function
|
38
|
-
|
88
|
+
function getAccessManagerMaster() external view returns (address) {
|
89
|
+
return _accessManagerMaster;
|
39
90
|
}
|
40
91
|
|
41
|
-
|
42
|
-
function
|
43
|
-
|
92
|
+
// From IService
|
93
|
+
function getName() public pure override(IService, Service) returns(string memory) {
|
94
|
+
return NAME;
|
95
|
+
}
|
96
|
+
|
97
|
+
/// @dev top level initializer
|
98
|
+
// 1) registry is non upgradeable -> don't need a proxy and uses constructor !
|
99
|
+
// 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
|
100
|
+
// 3) deploy registry -> pass registry service address as constructor argument
|
101
|
+
// registry is getting instantiated and locked to registry service address forever
|
102
|
+
function _initialize(
|
103
|
+
address owner,
|
104
|
+
bytes memory data
|
105
|
+
)
|
106
|
+
internal
|
107
|
+
initializer
|
108
|
+
virtual override
|
109
|
+
{
|
110
|
+
// bytes memory encodedConstructorArguments = abi.encode(
|
111
|
+
// _registryAddress);
|
112
|
+
|
113
|
+
// bytes memory instanceCreationCode = ContractDeployerLib.getCreationCode(
|
114
|
+
// instanceByteCodeWithInitCode,
|
115
|
+
// encodedConstructorArguments);
|
116
|
+
|
117
|
+
// address instanceAddress = ContractDeployerLib.deploy(
|
118
|
+
// instanceCreationCode,
|
119
|
+
// INSTANCE_CREATION_CODE_HASH);
|
120
|
+
|
121
|
+
address initialOwner = address(0);
|
122
|
+
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
123
|
+
|
124
|
+
// // TODO register instance in registry
|
125
|
+
IRegistry registry = IRegistry(_registryAddress);
|
126
|
+
NftId registryNftId = registry.getNftId(_registryAddress);
|
127
|
+
|
128
|
+
_initializeService(_registryAddress, initialOwner);
|
129
|
+
|
130
|
+
_registerInterface(type(IService).interfaceId);
|
131
|
+
_registerInterface(type(IInstanceService).interfaceId);
|
132
|
+
}
|
133
|
+
|
134
|
+
function getInstance() external view returns (Instance) {
|
135
|
+
return Instance(address(this));
|
136
|
+
}
|
44
137
|
}
|
45
138
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Instance} from "./Instance.sol";
|
5
|
+
import {IVersionable} from "../shared/IVersionable.sol";
|
6
|
+
import {ProxyManager} from "../shared/ProxyManager.sol";
|
7
|
+
import {InstanceService} from "./InstanceService.sol";
|
8
|
+
import {Registry} from "../registry/Registry.sol";
|
9
|
+
import {RegistryService} from "../registry/RegistryService.sol";
|
10
|
+
import {VersionLib} from "../types/Version.sol";
|
11
|
+
|
12
|
+
contract InstanceServiceManager is ProxyManager {
|
13
|
+
|
14
|
+
InstanceService private _instanceService;
|
15
|
+
|
16
|
+
/// @dev initializes proxy manager with instance service implementation and deploys instance
|
17
|
+
constructor(
|
18
|
+
address registryAddress
|
19
|
+
)
|
20
|
+
ProxyManager()
|
21
|
+
{
|
22
|
+
InstanceService instSrv = new InstanceService();
|
23
|
+
// bytes memory initCode = type(InstanceService).creationCode;
|
24
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
25
|
+
IVersionable versionable = deploy(
|
26
|
+
address(instSrv),
|
27
|
+
data);
|
28
|
+
|
29
|
+
_instanceService = InstanceService(address(versionable));
|
30
|
+
|
31
|
+
Registry registry = Registry(registryAddress);
|
32
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
33
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
34
|
+
|
35
|
+
registryService.registerService(_instanceService);
|
36
|
+
// RegistryService registryService = _instanceService.getRegistryService();
|
37
|
+
|
38
|
+
// link ownership of instance service manager ot nft owner of instance service
|
39
|
+
_linkToNftOwnable(
|
40
|
+
address(registryAddress),
|
41
|
+
address(_instanceService));
|
42
|
+
|
43
|
+
// implies that after this constructor call only upgrade functionality is available
|
44
|
+
_isDeployed = true;
|
45
|
+
}
|
46
|
+
|
47
|
+
//--- view functions ----------------------------------------------------//
|
48
|
+
function getInstanceService()
|
49
|
+
external
|
50
|
+
view
|
51
|
+
returns (InstanceService instanceService)
|
52
|
+
{
|
53
|
+
return _instanceService;
|
54
|
+
}
|
55
|
+
|
56
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
6
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
|
+
import {ObjectType, INSTANCE, PRODUCT, POOL} from "../../types/ObjectType.sol";
|
8
|
+
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
9
|
+
|
10
|
+
import {Service} from "../../shared/Service.sol";
|
11
|
+
import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
|
12
|
+
|
13
|
+
abstract contract ComponentServiceBase is Service {
|
14
|
+
|
15
|
+
constructor(
|
16
|
+
address registry,
|
17
|
+
NftId registryNftId,
|
18
|
+
address initialOwner
|
19
|
+
)
|
20
|
+
{
|
21
|
+
_initializeService(registry, initialOwner);
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
function _getAndVerifyComponentInfoAndInstance(
|
26
|
+
ObjectType objectType
|
27
|
+
)
|
28
|
+
internal
|
29
|
+
view
|
30
|
+
returns(
|
31
|
+
IRegistry.ObjectInfo memory info,
|
32
|
+
IInstance instance
|
33
|
+
)
|
34
|
+
{
|
35
|
+
NftId componentNftId = getRegistry().getNftId(msg.sender);
|
36
|
+
require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
37
|
+
|
38
|
+
info = getRegistry().getObjectInfo(componentNftId);
|
39
|
+
require(info.objectType == objectType, "OBJECT_TYPE_INVALID");
|
40
|
+
|
41
|
+
address instanceAddress = getRegistry().getObjectInfo(info.parentNftId).objectAddress;
|
42
|
+
instance = IInstance(instanceAddress);
|
43
|
+
}
|
44
|
+
|
45
|
+
function getRegistryService() public view virtual returns (IRegistryService) {
|
46
|
+
address service = getRegistry().getServiceAddress("RegistryService", getMajorVersion());
|
47
|
+
return IRegistryService(service);
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Key32} from "../../types/Key32.sol";
|
5
|
+
import {StateId} from "../../types/StateId.sol";
|
6
|
+
|
7
|
+
import {IKeyValueStore} from "./IKeyValueStore.sol";
|
8
|
+
|
9
|
+
import {IComponentOwnerService} from "../service/IComponentOwnerService.sol";
|
10
|
+
import {IDistributionService} from "../service/IDistributionService.sol";
|
11
|
+
import {IProductService} from "../service/IProductService.sol";
|
12
|
+
import {IPoolService} from "../service/IPoolService.sol";
|
13
|
+
|
14
|
+
interface IInstanceBase {
|
15
|
+
function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
|
16
|
+
function updateState(Key32 key, StateId state) external;
|
17
|
+
function getState(Key32 key) external view returns (StateId state);
|
18
|
+
|
19
|
+
function getComponentOwnerService() external view returns(IComponentOwnerService);
|
20
|
+
function getDistributionService() external view returns(IDistributionService);
|
21
|
+
function getProductService() external view returns(IProductService service);
|
22
|
+
function getPoolService() external view returns(IPoolService service);
|
23
|
+
}
|
@@ -9,6 +9,7 @@ import {StateId} from "../../types/StateId.sol";
|
|
9
9
|
|
10
10
|
import {ILifecycle} from "./ILifecycle.sol";
|
11
11
|
|
12
|
+
// TODO remove - internal only?
|
12
13
|
interface IKeyValueStore is ILifecycle {
|
13
14
|
|
14
15
|
struct Value {
|
@@ -33,10 +34,10 @@ interface IKeyValueStore is ILifecycle {
|
|
33
34
|
event LogStateUpdated(ObjectType objectType, KeyId keyId, StateId stateOld, StateId stateNew, address updatedBy, address txOrigin, Blocknumber lastUpdatedIn);
|
34
35
|
|
35
36
|
// generic state changing functions
|
36
|
-
function create(Key32 key, bytes memory data) external;
|
37
|
-
function update(Key32 key, bytes memory data, StateId state) external;
|
38
|
-
function updateData(Key32 key, bytes memory data) external;
|
39
|
-
function updateState(Key32 key, StateId state) external;
|
37
|
+
// function create(Key32 key, bytes memory data) external;
|
38
|
+
// function update(Key32 key, bytes memory data, StateId state) external;
|
39
|
+
// function updateData(Key32 key, bytes memory data) external;
|
40
|
+
// function updateState(Key32 key, StateId state) external;
|
40
41
|
|
41
42
|
function exists(Key32 key) external view returns (bool);
|
42
43
|
function get(Key32 key) external view returns (Value memory value);
|