@etherisc/gif-next 0.0.2-f034782-101 → 0.0.2-f080b71-868
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -83
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +10 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +10 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +100 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +100 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +110 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +100 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +20 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +10 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +214 -1988
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +101 -14
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +379 -2729
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +95 -58
- package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +124 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +45 -25
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +157 -126
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +30 -58
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2677 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +108 -21
- 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/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +6 -6
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IComponents.sol/IComponents.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/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +119 -227
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +11 -35
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +330 -147
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +70 -14
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +127 -32
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +193 -386
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +38 -74
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +68 -149
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +163 -113
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +89 -231
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +132 -24
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +430 -14
- package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.json +518 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +210 -65
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +493 -48
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +18 -14
- package/artifacts/contracts/instance/service/PricingService.sol/PricingService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PricingService.sol/PricingService.json +988 -0
- package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.json +689 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +139 -44
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
- 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/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -24
- 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 +2 -2
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -36
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- 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/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +80 -14
- 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/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.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/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +86 -15
- 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/TestFee.sol/TestFee.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
- 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/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
- 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/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- 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/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- 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/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +4 -2
- package/contracts/components/IComponent.sol +3 -1
- package/contracts/components/Pool.sol +8 -4
- package/contracts/components/Product.sol +8 -5
- package/contracts/instance/IInstance.sol +16 -54
- package/contracts/instance/IInstanceService.sol +14 -2
- package/contracts/instance/Instance.sol +88 -188
- package/contracts/instance/InstanceAccessManager.sol +41 -23
- package/contracts/instance/InstanceAuthorizationsLib.sol +299 -0
- package/contracts/instance/InstanceReader.sol +15 -6
- package/contracts/instance/InstanceService.sol +59 -234
- package/contracts/instance/InstanceStore.sol +219 -0
- package/contracts/instance/base/ComponentService.sol +51 -38
- package/contracts/instance/base/KeyValueStore.sol +8 -3
- package/contracts/instance/module/IAccess.sol +2 -2
- package/contracts/instance/module/IBundle.sol +6 -4
- package/contracts/instance/module/IComponents.sol +6 -0
- package/contracts/instance/service/ApplicationService.sol +35 -202
- package/contracts/instance/service/BundleService.sol +165 -70
- package/contracts/instance/service/ClaimService.sol +2 -8
- package/contracts/instance/service/DistributionService.sol +30 -151
- package/contracts/instance/service/IApplicationService.sol +0 -18
- package/contracts/instance/service/IBundleService.sol +54 -22
- package/contracts/instance/service/IDistributionService.sol +1 -14
- package/contracts/instance/service/IPolicyService.sol +2 -0
- package/contracts/instance/service/IPoolService.sol +65 -1
- package/contracts/instance/service/IPricingService.sol +36 -0
- package/contracts/instance/service/PolicyService.sol +88 -115
- package/contracts/instance/service/PoolService.sol +136 -53
- package/contracts/instance/service/PricingService.sol +275 -0
- package/contracts/instance/service/PricingServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +25 -56
- package/contracts/registry/IRegistryService.sol +4 -3
- package/contracts/registry/RegistryService.sol +25 -22
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/Service.sol +21 -7
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/Amount.sol +60 -0
- package/contracts/types/Fee.sol +12 -5
- package/contracts/types/ObjectType.sol +4 -0
- package/package.json +1 -1
@@ -4,26 +4,32 @@ pragma solidity ^0.8.20;
|
|
4
4
|
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
5
5
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
6
|
|
7
|
-
import {Instance} from "./Instance.sol";
|
8
|
-
import {IInstance} from "./IInstance.sol";
|
9
|
-
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
10
|
-
import {IInstanceService} from "./IInstanceService.sol";
|
11
|
-
import {InstanceReader} from "./InstanceReader.sol";
|
12
|
-
import {BundleManager} from "./BundleManager.sol";
|
13
|
-
import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
|
14
|
-
import {IRegistry} from "../registry/IRegistry.sol";
|
15
|
-
import {IRegistryService} from "../registry/IRegistryService.sol";
|
16
|
-
import {ChainNft} from "../registry/ChainNft.sol";
|
17
|
-
import {Service} from "../../contracts/shared/Service.sol";
|
18
|
-
import {IService} from "../shared/IService.sol";
|
19
7
|
import {NftId} from "../../contracts/types/NftId.sol";
|
20
8
|
import {RoleId} from "../types/RoleId.sol";
|
21
9
|
import {ADMIN_ROLE, INSTANCE_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, APPLICATION_SERVICE_ROLE, POLICY_SERVICE_ROLE, CLAIM_SERVICE_ROLE, BUNDLE_SERVICE_ROLE, INSTANCE_ROLE} from "../types/RoleId.sol";
|
22
10
|
import {ObjectType, INSTANCE, BUNDLE, APPLICATION, POLICY, CLAIM, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
|
11
|
+
|
12
|
+
import {Service} from "../shared/Service.sol";
|
13
|
+
import {IService} from "../shared/IService.sol";
|
14
|
+
|
23
15
|
import {IDistributionComponent} from "../components/IDistributionComponent.sol";
|
24
16
|
import {IPoolComponent} from "../components/IPoolComponent.sol";
|
25
17
|
import {IProductComponent} from "../components/IProductComponent.sol";
|
26
18
|
|
19
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
20
|
+
import {IRegistryService} from "../registry/IRegistryService.sol";
|
21
|
+
import {ChainNft} from "../registry/ChainNft.sol";
|
22
|
+
|
23
|
+
import {Instance} from "./Instance.sol";
|
24
|
+
import {IInstance} from "./IInstance.sol";
|
25
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
26
|
+
import {IInstanceService} from "./IInstanceService.sol";
|
27
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
28
|
+
import {BundleManager} from "./BundleManager.sol";
|
29
|
+
import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
|
30
|
+
import {InstanceStore} from "./InstanceStore.sol";
|
31
|
+
import {InstanceAuthorizationsLib} from "./InstanceAuthorizationsLib.sol";
|
32
|
+
|
27
33
|
contract InstanceService is
|
28
34
|
Service,
|
29
35
|
IInstanceService
|
@@ -33,6 +39,7 @@ contract InstanceService is
|
|
33
39
|
address internal _masterInstance;
|
34
40
|
address internal _masterInstanceReader;
|
35
41
|
address internal _masterInstanceBundleManager;
|
42
|
+
address internal _masterInstanceStore;
|
36
43
|
|
37
44
|
// TODO update to real hash when instance is stable
|
38
45
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
@@ -67,18 +74,18 @@ contract InstanceService is
|
|
67
74
|
Instance clonedInstance,
|
68
75
|
NftId clonedInstanceNftId,
|
69
76
|
InstanceReader clonedInstanceReader,
|
70
|
-
BundleManager clonedBundleManager
|
77
|
+
BundleManager clonedBundleManager,
|
78
|
+
InstanceStore clonedInstanceStore
|
71
79
|
)
|
72
80
|
{
|
73
81
|
address instanceOwner = msg.sender;
|
74
82
|
IRegistry registry = getRegistry();
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
83
|
+
NftId registryNftId = registry.getNftId(address(registry));
|
84
|
+
IRegistryService registryService = IRegistryService(
|
85
|
+
registry.getServiceAddress(REGISTRY(), getVersion().toMajorPart())
|
86
|
+
);
|
79
87
|
|
80
|
-
clonedOzAccessManager = AccessManagerUpgradeableInitializeable(
|
81
|
-
Clones.clone(_masterOzAccessManager));
|
88
|
+
clonedOzAccessManager = AccessManagerUpgradeableInitializeable(Clones.clone(_masterOzAccessManager));
|
82
89
|
|
83
90
|
// initially grants ADMIN_ROLE to this (being the instance service).
|
84
91
|
// This will allow the instance service to bootstrap the authorizations of the instance.
|
@@ -89,8 +96,12 @@ contract InstanceService is
|
|
89
96
|
clonedInstance = Instance(Clones.clone(_masterInstance));
|
90
97
|
clonedInstance.initialize(
|
91
98
|
address(clonedOzAccessManager),
|
92
|
-
|
99
|
+
address(registry),
|
93
100
|
instanceOwner);
|
101
|
+
// initialize and set before instance reader
|
102
|
+
clonedInstanceStore = InstanceStore(Clones.clone(address(_masterInstanceStore)));
|
103
|
+
clonedInstanceStore.initialize(address(clonedInstance));
|
104
|
+
clonedInstance.setInstanceStore(clonedInstanceStore);
|
94
105
|
|
95
106
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
|
96
107
|
clonedInstanceReader.initialize(address(clonedInstance));
|
@@ -107,221 +118,32 @@ contract InstanceService is
|
|
107
118
|
|
108
119
|
// TODO amend setters with instance specific , policy manager ...
|
109
120
|
|
110
|
-
|
121
|
+
// TODO library does external calls -> but it is registry and access manager -> find out is it best practice
|
122
|
+
InstanceAuthorizationsLib.grantInitialAuthorizations(
|
123
|
+
clonedInstanceAccessManager,
|
124
|
+
clonedInstance,
|
125
|
+
clonedBundleManager,
|
126
|
+
clonedInstanceStore,
|
127
|
+
instanceOwner,
|
128
|
+
getRegistry(),
|
129
|
+
getVersion().toMajorPart());
|
111
130
|
|
112
131
|
clonedOzAccessManager.renounceRole(ADMIN_ROLE().toInt(), address(this));
|
113
132
|
|
114
133
|
IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
|
115
134
|
clonedInstanceNftId = info.nftId;
|
116
|
-
// clonedInstance.linkToRegisteredNftId();
|
117
135
|
|
118
136
|
emit LogInstanceCloned(
|
119
137
|
address(clonedOzAccessManager),
|
120
138
|
address(clonedInstanceAccessManager),
|
121
|
-
address(clonedInstance),
|
139
|
+
address(clonedInstance),
|
140
|
+
address(clonedInstanceStore),
|
122
141
|
address(clonedBundleManager),
|
123
142
|
address(clonedInstanceReader),
|
124
143
|
clonedInstanceNftId);
|
125
144
|
}
|
126
145
|
|
127
|
-
function
|
128
|
-
InstanceAccessManager clonedAccessManager,
|
129
|
-
Instance clonedInstance,
|
130
|
-
BundleManager clonedBundleManager,
|
131
|
-
address instanceOwner)
|
132
|
-
internal
|
133
|
-
{
|
134
|
-
_createCoreAndGifRoles(clonedAccessManager);
|
135
|
-
_createCoreTargets(clonedAccessManager, clonedInstance, clonedBundleManager);
|
136
|
-
_grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstance);
|
137
|
-
_grantPoolServiceAuthorizations(clonedAccessManager, clonedInstance);
|
138
|
-
_grantProductServiceAuthorizations(clonedAccessManager, clonedInstance);
|
139
|
-
_grantApplicationServiceAuthorizations(clonedAccessManager, clonedInstance);
|
140
|
-
_grantPolicyServiceAuthorizations(clonedAccessManager, clonedInstance);
|
141
|
-
_grantClaimServiceAuthorizations(clonedAccessManager, clonedInstance);
|
142
|
-
_grantBundleServiceAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
|
143
|
-
_grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance);
|
144
|
-
_grantInstanceOwnerAuthorizations(clonedAccessManager, instanceOwner);
|
145
|
-
}
|
146
|
-
|
147
|
-
function _createCoreAndGifRoles(InstanceAccessManager clonedAccessManager) internal {
|
148
|
-
// default roles controlled by ADMIN_ROLE -> core roles
|
149
|
-
// all set/granted only once during cloning (the only exception is INSTANCE_OWNER_ROLE, hooked to instance nft)
|
150
|
-
clonedAccessManager.createCoreRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole");
|
151
|
-
clonedAccessManager.createCoreRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole");
|
152
|
-
clonedAccessManager.createCoreRole(POOL_SERVICE_ROLE(), "PoolServiceRole");
|
153
|
-
clonedAccessManager.createCoreRole(APPLICATION_SERVICE_ROLE(), "ApplicationServiceRole");
|
154
|
-
clonedAccessManager.createCoreRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole");
|
155
|
-
clonedAccessManager.createCoreRole(CLAIM_SERVICE_ROLE(), "ClaimServiceRole");
|
156
|
-
clonedAccessManager.createCoreRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole");
|
157
|
-
clonedAccessManager.createCoreRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole");
|
158
|
-
// default roles controlled by INSTANCE_OWNER_ROLE -> gif roles
|
159
|
-
clonedAccessManager.createGifRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole", INSTANCE_OWNER_ROLE());
|
160
|
-
clonedAccessManager.createGifRole(POOL_OWNER_ROLE(), "PoolOwnerRole", INSTANCE_OWNER_ROLE());
|
161
|
-
clonedAccessManager.createGifRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole", INSTANCE_OWNER_ROLE());
|
162
|
-
}
|
163
|
-
|
164
|
-
function _createCoreTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
165
|
-
clonedAccessManager.createCoreTarget(address(clonedAccessManager), "InstanceAccessManager");
|
166
|
-
clonedAccessManager.createCoreTarget(address(clonedInstance), "Instance");
|
167
|
-
clonedAccessManager.createCoreTarget(address(clonedBundleManager), "BundleManager");
|
168
|
-
}
|
169
|
-
|
170
|
-
function _grantDistributionServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
171
|
-
// configure authorization for distribution service on instance
|
172
|
-
address distributionServiceAddress = getRegistry().getServiceAddress(DISTRIBUTION(), getMajorVersion());
|
173
|
-
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), distributionServiceAddress);
|
174
|
-
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](11);
|
175
|
-
instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
|
176
|
-
instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
|
177
|
-
instanceDistributionServiceSelectors[2] = clonedInstance.createDistributorType.selector;
|
178
|
-
instanceDistributionServiceSelectors[3] = clonedInstance.updateDistributorType.selector;
|
179
|
-
instanceDistributionServiceSelectors[4] = clonedInstance.updateDistributorTypeState.selector;
|
180
|
-
instanceDistributionServiceSelectors[5] = clonedInstance.createDistributor.selector;
|
181
|
-
instanceDistributionServiceSelectors[6] = clonedInstance.updateDistributor.selector;
|
182
|
-
instanceDistributionServiceSelectors[7] = clonedInstance.updateDistributorState.selector;
|
183
|
-
instanceDistributionServiceSelectors[8] = clonedInstance.createReferral.selector;
|
184
|
-
instanceDistributionServiceSelectors[9] = clonedInstance.updateReferral.selector;
|
185
|
-
instanceDistributionServiceSelectors[10] = clonedInstance.updateReferralState.selector;
|
186
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
187
|
-
"Instance",
|
188
|
-
instanceDistributionServiceSelectors,
|
189
|
-
DISTRIBUTION_SERVICE_ROLE());
|
190
|
-
}
|
191
|
-
|
192
|
-
function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
193
|
-
// configure authorization for pool service on instance
|
194
|
-
address poolServiceAddress = getRegistry().getServiceAddress(POOL(), getMajorVersion());
|
195
|
-
clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
|
196
|
-
bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
|
197
|
-
instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
|
198
|
-
instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
|
199
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
200
|
-
"Instance",
|
201
|
-
instancePoolServiceSelectors,
|
202
|
-
POOL_SERVICE_ROLE());
|
203
|
-
}
|
204
|
-
|
205
|
-
function _grantProductServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
206
|
-
// configure authorization for product service on instance
|
207
|
-
address productServiceAddress = getRegistry().getServiceAddress(PRODUCT(), getMajorVersion());
|
208
|
-
clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
|
209
|
-
bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
|
210
|
-
instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
|
211
|
-
instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
|
212
|
-
instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
|
213
|
-
instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
|
214
|
-
instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
|
215
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
216
|
-
"Instance",
|
217
|
-
instanceProductServiceSelectors,
|
218
|
-
PRODUCT_SERVICE_ROLE());
|
219
|
-
}
|
220
|
-
|
221
|
-
function _grantApplicationServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
222
|
-
// configure authorization for application services on instance
|
223
|
-
address applicationServiceAddress = getRegistry().getServiceAddress(APPLICATION(), getMajorVersion());
|
224
|
-
clonedAccessManager.grantRole(APPLICATION_SERVICE_ROLE(), applicationServiceAddress);
|
225
|
-
bytes4[] memory instanceApplicationServiceSelectors = new bytes4[](3);
|
226
|
-
instanceApplicationServiceSelectors[0] = clonedInstance.createApplication.selector;
|
227
|
-
instanceApplicationServiceSelectors[1] = clonedInstance.updateApplication.selector;
|
228
|
-
instanceApplicationServiceSelectors[2] = clonedInstance.updateApplicationState.selector;
|
229
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
230
|
-
"Instance",
|
231
|
-
instanceApplicationServiceSelectors,
|
232
|
-
APPLICATION_SERVICE_ROLE());
|
233
|
-
}
|
234
|
-
|
235
|
-
function _grantPolicyServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
236
|
-
// configure authorization for policy services on instance
|
237
|
-
address policyServiceAddress = getRegistry().getServiceAddress(POLICY(), getMajorVersion());
|
238
|
-
clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), policyServiceAddress);
|
239
|
-
bytes4[] memory instancePolicyServiceSelectors = new bytes4[](2);
|
240
|
-
instancePolicyServiceSelectors[0] = clonedInstance.updatePolicy.selector;
|
241
|
-
instancePolicyServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
|
242
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
243
|
-
"Instance",
|
244
|
-
instancePolicyServiceSelectors,
|
245
|
-
POLICY_SERVICE_ROLE());
|
246
|
-
}
|
247
|
-
|
248
|
-
function _grantClaimServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
249
|
-
// configure authorization for claim/payout services on instance
|
250
|
-
address claimServiceAddress = getRegistry().getServiceAddress(CLAIM(), getMajorVersion());
|
251
|
-
clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), claimServiceAddress);
|
252
|
-
// TODO add claims function authz
|
253
|
-
bytes4[] memory instanceClaimServiceSelectors = new bytes4[](0);
|
254
|
-
// instanceClaimServiceSelectors[0] = clonedInstance.updatePolicy.selector;
|
255
|
-
// instanceClaimServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
|
256
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
257
|
-
"Instance",
|
258
|
-
instanceClaimServiceSelectors,
|
259
|
-
CLAIM_SERVICE_ROLE());
|
260
|
-
}
|
261
|
-
|
262
|
-
function _grantBundleServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
263
|
-
// configure authorization for bundle service on instance
|
264
|
-
address bundleServiceAddress = getRegistry().getServiceAddress(BUNDLE(), getMajorVersion());
|
265
|
-
clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
|
266
|
-
bytes4[] memory instanceBundleServiceSelectors = new bytes4[](3);
|
267
|
-
instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
|
268
|
-
instanceBundleServiceSelectors[1] = clonedInstance.updateBundle.selector;
|
269
|
-
instanceBundleServiceSelectors[2] = clonedInstance.updateBundleState.selector;
|
270
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
271
|
-
"Instance",
|
272
|
-
instanceBundleServiceSelectors,
|
273
|
-
BUNDLE_SERVICE_ROLE());
|
274
|
-
|
275
|
-
// configure authorization for bundle service on bundle manager
|
276
|
-
bytes4[] memory bundleManagerBundleServiceSelectors = new bytes4[](5);
|
277
|
-
bundleManagerBundleServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
|
278
|
-
bundleManagerBundleServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
|
279
|
-
bundleManagerBundleServiceSelectors[2] = clonedBundleManager.add.selector;
|
280
|
-
bundleManagerBundleServiceSelectors[3] = clonedBundleManager.lock.selector;
|
281
|
-
bundleManagerBundleServiceSelectors[4] = clonedBundleManager.unlock.selector;
|
282
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
283
|
-
"BundleManager",
|
284
|
-
bundleManagerBundleServiceSelectors,
|
285
|
-
BUNDLE_SERVICE_ROLE());
|
286
|
-
}
|
287
|
-
|
288
|
-
function _grantInstanceServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
289
|
-
// configure authorization for instance service on instance
|
290
|
-
address instanceServiceAddress = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
|
291
|
-
clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
|
292
|
-
bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
|
293
|
-
instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
|
294
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
295
|
-
"Instance",
|
296
|
-
instanceInstanceServiceSelectors,
|
297
|
-
INSTANCE_SERVICE_ROLE());
|
298
|
-
|
299
|
-
// configure authorizations for instance service on instance access manager
|
300
|
-
bytes4[] memory accessManagerInstanceServiceSelectors = new bytes4[](3);
|
301
|
-
accessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
|
302
|
-
accessManagerInstanceServiceSelectors[1] = clonedAccessManager.setTargetLocked.selector;
|
303
|
-
accessManagerInstanceServiceSelectors[2] = clonedAccessManager.setCoreTargetFunctionRole.selector;
|
304
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
305
|
-
"InstanceAccessManager",
|
306
|
-
accessManagerInstanceServiceSelectors,
|
307
|
-
INSTANCE_SERVICE_ROLE());
|
308
|
-
}
|
309
|
-
|
310
|
-
function _grantInstanceOwnerAuthorizations(InstanceAccessManager clonedAccessManager, address instanceOwner) internal {
|
311
|
-
// configure authorization for instance owner on instance access manager
|
312
|
-
// instance owner role is granted/revoked ONLY by INSTANCE_ROLE
|
313
|
-
bytes4[] memory accessManagerInstanceOwnerSelectors = new bytes4[](3);
|
314
|
-
accessManagerInstanceOwnerSelectors[0] = clonedAccessManager.createRole.selector;
|
315
|
-
accessManagerInstanceOwnerSelectors[1] = clonedAccessManager.createTarget.selector;
|
316
|
-
accessManagerInstanceOwnerSelectors[2] = clonedAccessManager.setTargetFunctionRole.selector;
|
317
|
-
clonedAccessManager.setCoreTargetFunctionRole(
|
318
|
-
"InstanceAccessManager",
|
319
|
-
accessManagerInstanceOwnerSelectors,
|
320
|
-
INSTANCE_OWNER_ROLE());
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
function setAndRegisterMasterInstance(address instanceAddress)
|
146
|
+
function setAndRegisterMasterInstance(address instanceAddress)
|
325
147
|
external
|
326
148
|
onlyOwner
|
327
149
|
returns(NftId masterInstanceNftId)
|
@@ -342,14 +164,18 @@ contract InstanceService is
|
|
342
164
|
address instanceReaderAddress = address(instanceReader);
|
343
165
|
BundleManager bundleManager = instance.getBundleManager();
|
344
166
|
address bundleManagerAddress = address(bundleManager);
|
167
|
+
InstanceStore instanceStore = instance.getInstanceStore();
|
168
|
+
address instanceStoreAddress = address(instanceStore);
|
345
169
|
|
346
170
|
if(ozAccessManagerAddress == address(0)) { revert ErrorInstanceServiceOzAccessManagerZero();}
|
347
171
|
if(instanceAccessManagerAddress == address(0)) { revert ErrorInstanceServiceInstanceAccessManagerZero(); }
|
348
172
|
if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderZero(); }
|
349
173
|
if(bundleManagerAddress == address(0)) { revert ErrorInstanceServiceBundleManagerZero(); }
|
174
|
+
if(instanceStoreAddress == address(0)) { revert ErrorInstanceServiceInstanceStoreZero(); }
|
350
175
|
|
351
176
|
if(instance.authority() != instanceAccessManager.authority()) { revert ErrorInstanceServiceInstanceAuthorityMismatch(); }
|
352
177
|
if(bundleManager.authority() != instanceAccessManager.authority()) { revert ErrorInstanceServiceBundleManagerAuthorityMismatch(); }
|
178
|
+
if(instanceStore.authority() != instanceAccessManager.authority()) { revert ErrorInstanceServiceInstanceStoreAuthorityMismatch(); }
|
353
179
|
if(instanceReader.getInstance() != instance) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch2(); }
|
354
180
|
if(bundleManager.getInstance() != instance) { revert ErrorInstanceServiceBundleMangerInstanceMismatch(); }
|
355
181
|
|
@@ -358,13 +184,12 @@ contract InstanceService is
|
|
358
184
|
_masterInstance = instanceAddress;
|
359
185
|
_masterInstanceReader = instanceReaderAddress;
|
360
186
|
_masterInstanceBundleManager = bundleManagerAddress;
|
187
|
+
_masterInstanceStore = instanceStoreAddress;
|
361
188
|
|
362
|
-
IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(),
|
189
|
+
IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(), getVersion().toMajorPart()));
|
363
190
|
IInstance masterInstance = IInstance(_masterInstance);
|
364
191
|
IRegistry.ObjectInfo memory info = registryService.registerInstance(masterInstance, getOwner());
|
365
192
|
masterInstanceNftId = info.nftId;
|
366
|
-
|
367
|
-
// masterInstance.linkToRegisteredNftId();
|
368
193
|
}
|
369
194
|
|
370
195
|
function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
|
@@ -408,7 +233,7 @@ contract InstanceService is
|
|
408
233
|
}
|
409
234
|
|
410
235
|
// From IService
|
411
|
-
function getDomain() public pure override
|
236
|
+
function getDomain() public pure override returns(ObjectType) {
|
412
237
|
return INSTANCE();
|
413
238
|
}
|
414
239
|
|
@@ -426,7 +251,7 @@ contract InstanceService is
|
|
426
251
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
427
252
|
// TODO while InstanceService is not deployed in InstanceServiceManager constructor
|
428
253
|
// owner is InstanceServiceManager deployer
|
429
|
-
initializeService(registryAddress, owner);
|
254
|
+
initializeService(registryAddress, address(0), owner);
|
430
255
|
registerInterface(type(IInstanceService).interfaceId);
|
431
256
|
}
|
432
257
|
|
@@ -449,7 +274,7 @@ contract InstanceService is
|
|
449
274
|
InstanceAccessManager accessManager = instance.getInstanceAccessManager();
|
450
275
|
accessManager.createGifTarget(targetAddress, targetName);
|
451
276
|
// set proposed target config
|
452
|
-
// TODO restriction:
|
277
|
+
// TODO restriction: gif targets are set only once and only here?
|
453
278
|
// assume config is a mix of gif and custom roles and no further configuration by INSTANCE_OWNER_ROLE is ever needed?
|
454
279
|
for(uint roleIdx = 0; roleIdx < roles.length; roleIdx++)
|
455
280
|
{
|
@@ -459,18 +284,18 @@ contract InstanceService is
|
|
459
284
|
|
460
285
|
// TODO called by component, but target can be component helper...so needs target name
|
461
286
|
// TODO check that targetName associated with component...how???
|
462
|
-
//function setTargetLocked(string memory targetName, bool locked) onlyComponent external {
|
463
287
|
function setComponentLocked(bool locked) onlyComponent external {
|
464
288
|
address componentAddress = msg.sender;
|
465
289
|
IRegistry registry = getRegistry();
|
466
290
|
NftId instanceNftId = registry.getObjectInfo(componentAddress).parentNftId;
|
467
|
-
address instanceAddress = registry.getObjectInfo(instanceNftId).objectAddress;
|
468
|
-
IInstance instance = IInstance(instanceAddress);
|
469
291
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
292
|
+
IInstance instance = IInstance(
|
293
|
+
registry.getObjectInfo(
|
294
|
+
instanceNftId).objectAddress);
|
295
|
+
|
296
|
+
instance.getInstanceAccessManager().setTargetLockedByService(
|
297
|
+
componentAddress,
|
298
|
+
locked);
|
474
299
|
}
|
475
300
|
|
476
301
|
function _validateInstanceAndComponent(NftId instanceNftId, address componentAddress)
|
@@ -0,0 +1,219 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
5
|
+
|
6
|
+
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
7
|
+
import {NftId} from "../types/NftId.sol";
|
8
|
+
import {ClaimId} from "../types/ClaimId.sol";
|
9
|
+
import {NumberId} from "../types/NumberId.sol";
|
10
|
+
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET, COMPONENT, DISTRIBUTOR, DISTRIBUTOR_TYPE} from "../types/ObjectType.sol";
|
11
|
+
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
12
|
+
import {RoleId, RoleIdLib, INSTANCE_ROLE, INSTANCE_OWNER_ROLE} from "../types/RoleId.sol";
|
13
|
+
import {StateId, ACTIVE} from "../types/StateId.sol";
|
14
|
+
import {TimestampLib} from "../types/Timestamp.sol";
|
15
|
+
import {VersionPart, VersionPartLib} from "../types/Version.sol";
|
16
|
+
|
17
|
+
//import {IRegistry} from "../registry/IRegistry.sol";
|
18
|
+
|
19
|
+
import {IInstance} from "./IInstance.sol";
|
20
|
+
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
21
|
+
import {IKeyValueStore} from "./base/KeyValueStore.sol";
|
22
|
+
|
23
|
+
import {IBundle} from "./module/IBundle.sol";
|
24
|
+
import {IComponents} from "./module/IComponents.sol";
|
25
|
+
import {IDistribution} from "./module/IDistribution.sol";
|
26
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
27
|
+
import {IRisk} from "./module/IRisk.sol";
|
28
|
+
import {ISetup} from "./module/ISetup.sol";
|
29
|
+
|
30
|
+
|
31
|
+
// TODO combine with instance reader?
|
32
|
+
contract InstanceStore is AccessManagedUpgradeable, KeyValueStore
|
33
|
+
{
|
34
|
+
function initialize(address instance)
|
35
|
+
public
|
36
|
+
initializer()
|
37
|
+
{
|
38
|
+
address authority = IInstance(instance).authority();
|
39
|
+
__AccessManaged_init(authority);
|
40
|
+
initializeLifecycle();
|
41
|
+
}
|
42
|
+
|
43
|
+
//--- ProductSetup ------------------------------------------------------//
|
44
|
+
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external restricted() {
|
45
|
+
create(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup));
|
46
|
+
}
|
47
|
+
|
48
|
+
function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external restricted() {
|
49
|
+
update(_toNftKey32(productNftId, PRODUCT()), abi.encode(setup), newState);
|
50
|
+
}
|
51
|
+
|
52
|
+
function updateProductSetupState(NftId productNftId, StateId newState) external restricted() {
|
53
|
+
updateState(_toNftKey32(productNftId, PRODUCT()), newState);
|
54
|
+
}
|
55
|
+
|
56
|
+
//--- DistributionSetup ------------------------------------------------------//
|
57
|
+
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external restricted() {
|
58
|
+
create(_toNftKey32(distributionNftId, DISTRIBUTION()), abi.encode(setup));
|
59
|
+
}
|
60
|
+
|
61
|
+
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external restricted() {
|
62
|
+
update(_toNftKey32(distributionNftId, DISTRIBUTION()), abi.encode(setup), newState);
|
63
|
+
}
|
64
|
+
|
65
|
+
function updateDistributionSetupState(NftId distributionNftId, StateId newState) external restricted() {
|
66
|
+
updateState(_toNftKey32(distributionNftId, DISTRIBUTION()), newState);
|
67
|
+
}
|
68
|
+
|
69
|
+
//--- PoolSetup ------------------------------------------------------//
|
70
|
+
function createPoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info) external restricted() {
|
71
|
+
create(_toNftKey32(poolNftId, POOL()), abi.encode(info));
|
72
|
+
}
|
73
|
+
|
74
|
+
function updatePoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info, StateId newState) external restricted() {
|
75
|
+
update(_toNftKey32(poolNftId, POOL()), abi.encode(info), newState);
|
76
|
+
}
|
77
|
+
|
78
|
+
function updatePoolSetupState(NftId poolNftId, StateId newState) external restricted() {
|
79
|
+
updateState(_toNftKey32(poolNftId, POOL()), newState);
|
80
|
+
}
|
81
|
+
|
82
|
+
//--- DistributorType -------------------------------------------------------//
|
83
|
+
function createDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info) external restricted() {
|
84
|
+
create(distributorKey, abi.encode(info));
|
85
|
+
}
|
86
|
+
|
87
|
+
function updateDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info, StateId newState) external restricted() {
|
88
|
+
update(distributorKey, abi.encode(info), newState);
|
89
|
+
}
|
90
|
+
|
91
|
+
function updateDistributorTypeState(Key32 distributorKey, StateId newState) external restricted() {
|
92
|
+
updateState(distributorKey, newState);
|
93
|
+
}
|
94
|
+
|
95
|
+
//--- Distributor -------------------------------------------------------//
|
96
|
+
function createDistributor(NftId nftId, IDistribution.DistributorInfo memory info) external restricted() {
|
97
|
+
create(toDistributorKey32(nftId), abi.encode(info));
|
98
|
+
}
|
99
|
+
|
100
|
+
function updateDistributor(NftId nftId, IDistribution.DistributorInfo memory info, StateId newState) external restricted() {
|
101
|
+
update(toDistributorKey32(nftId), abi.encode(info), newState);
|
102
|
+
}
|
103
|
+
|
104
|
+
function updateDistributorState(NftId nftId, StateId newState) external restricted() {
|
105
|
+
updateState(toDistributorKey32(nftId), newState);
|
106
|
+
}
|
107
|
+
|
108
|
+
//--- Referral ----------------------------------------------------------//
|
109
|
+
function createReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo) external restricted() {
|
110
|
+
create(referralKey, abi.encode(referralInfo));
|
111
|
+
}
|
112
|
+
|
113
|
+
function updateReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo, StateId newState) external restricted() {
|
114
|
+
update(referralKey, abi.encode(referralInfo), newState);
|
115
|
+
}
|
116
|
+
|
117
|
+
function updateReferralState(Key32 referralKey, StateId newState) external restricted() {
|
118
|
+
updateState(referralKey, newState);
|
119
|
+
}
|
120
|
+
|
121
|
+
//--- Bundle ------------------------------------------------------------//
|
122
|
+
function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external restricted() {
|
123
|
+
create(toBundleKey32(bundleNftId), abi.encode(bundle));
|
124
|
+
}
|
125
|
+
|
126
|
+
function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external restricted() {
|
127
|
+
update(toBundleKey32(bundleNftId), abi.encode(bundle), newState);
|
128
|
+
}
|
129
|
+
|
130
|
+
function updateBundleState(NftId bundleNftId, StateId newState) external restricted() {
|
131
|
+
updateState(toBundleKey32(bundleNftId), newState);
|
132
|
+
}
|
133
|
+
|
134
|
+
//--- Risk --------------------------------------------------------------//
|
135
|
+
function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external restricted() {
|
136
|
+
create(riskId.toKey32(), abi.encode(risk));
|
137
|
+
}
|
138
|
+
|
139
|
+
function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external restricted() {
|
140
|
+
update(riskId.toKey32(), abi.encode(risk), newState);
|
141
|
+
}
|
142
|
+
|
143
|
+
function updateRiskState(RiskId riskId, StateId newState) external restricted() {
|
144
|
+
updateState(riskId.toKey32(), newState);
|
145
|
+
}
|
146
|
+
|
147
|
+
//--- Application (Policy) ----------------------------------------------//
|
148
|
+
function createApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy) external restricted() {
|
149
|
+
create(toPolicyKey32(applicationNftId), abi.encode(policy));
|
150
|
+
}
|
151
|
+
|
152
|
+
function updateApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy, StateId newState) external restricted() {
|
153
|
+
update(toPolicyKey32(applicationNftId), abi.encode(policy), newState);
|
154
|
+
}
|
155
|
+
|
156
|
+
function updateApplicationState(NftId applicationNftId, StateId newState) external restricted() {
|
157
|
+
updateState(toPolicyKey32(applicationNftId), newState);
|
158
|
+
}
|
159
|
+
|
160
|
+
//--- Policy ------------------------------------------------------------//
|
161
|
+
function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external restricted() {
|
162
|
+
update(toPolicyKey32(policyNftId), abi.encode(policy), newState);
|
163
|
+
}
|
164
|
+
|
165
|
+
function updatePolicyState(NftId policyNftId, StateId newState) external restricted() {
|
166
|
+
updateState(toPolicyKey32(policyNftId), newState);
|
167
|
+
}
|
168
|
+
|
169
|
+
//--- Claim -------------------------------------------------------------//
|
170
|
+
function createClaim(NftId policyNftId, ClaimId claimId, IPolicy.ClaimInfo memory claim) external restricted() {
|
171
|
+
create(toPolicyKey32(policyNftId), abi.encode(claim));
|
172
|
+
}
|
173
|
+
|
174
|
+
function updateClaim(NftId policyNftId, ClaimId claimId, IPolicy.ClaimInfo memory claim, StateId newState) external restricted() {
|
175
|
+
update(toPolicyKey32(policyNftId), abi.encode(claim), newState);
|
176
|
+
}
|
177
|
+
|
178
|
+
function updateClaimState(NftId policyNftId, ClaimId claimId, StateId newState) external restricted() {
|
179
|
+
updateState(toPolicyKey32(policyNftId), newState);
|
180
|
+
}
|
181
|
+
|
182
|
+
//--- Payout ------------------------------------------------------------//
|
183
|
+
function createPayout(NftId policyNftId, NumberId payoutId, IPolicy.PayoutInfo memory payout) external restricted() {
|
184
|
+
create(toPolicyKey32(policyNftId), abi.encode(payout));
|
185
|
+
}
|
186
|
+
|
187
|
+
function updatePayout(NftId policyNftId, NumberId payoutId, IPolicy.PayoutInfo memory payout, StateId newState) external restricted() {
|
188
|
+
update(toPolicyKey32(policyNftId), abi.encode(payout), newState);
|
189
|
+
}
|
190
|
+
|
191
|
+
function updatePayoutState(NftId policyNftId, StateId newState) external restricted() {
|
192
|
+
updateState(toPolicyKey32(policyNftId), newState);
|
193
|
+
}
|
194
|
+
|
195
|
+
//--- internal view/pure functions --------------------------------------//
|
196
|
+
function _toNftKey32(NftId nftId, ObjectType objectType) internal pure returns (Key32) {
|
197
|
+
return nftId.toKey32(objectType);
|
198
|
+
}
|
199
|
+
|
200
|
+
function toBundleKey32(NftId bundleNftId) public pure returns (Key32) {
|
201
|
+
return bundleNftId.toKey32(BUNDLE());
|
202
|
+
}
|
203
|
+
|
204
|
+
function toPolicyKey32(NftId policyNftId) public pure returns (Key32) {
|
205
|
+
return policyNftId.toKey32(POLICY());
|
206
|
+
}
|
207
|
+
|
208
|
+
function toDistributionKey32(NftId distNftId) public pure returns (Key32) {
|
209
|
+
return distNftId.toKey32(DISTRIBUTION());
|
210
|
+
}
|
211
|
+
|
212
|
+
function toDistributorTypeKey32(NftId distNftId) public pure returns (Key32) {
|
213
|
+
return distNftId.toKey32(DISTRIBUTOR_TYPE());
|
214
|
+
}
|
215
|
+
|
216
|
+
function toDistributorKey32(NftId distNftId) public pure returns (Key32) {
|
217
|
+
return distNftId.toKey32(DISTRIBUTOR());
|
218
|
+
}
|
219
|
+
}
|