@etherisc/gif-next 0.0.2-bc11089-132 → 0.0.2-bca28f1-161
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +73 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +897 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +896 -235
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → IComponent.sol/IComponent.json} +137 -86
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +798 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +662 -43
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +661 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +603 -204
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +529 -122
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +38 -62
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +706 -56
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +152 -19
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +560 -272
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +103 -176
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +61 -97
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +460 -191
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +187 -85
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -32
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/{shared/RegisterableUpgradable.sol/RegisterableUpgradable.json → instance/base/ComponentService.sol/ComponentService.json} +321 -9
- 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 +24 -13
- 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/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +495 -100
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +172 -26
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +554 -62
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +197 -23
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/{base/ComponentServiceBase.sol/ComponentServiceBase.json → service/IApplicationService.sol/IApplicationService.json} +221 -104
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +181 -52
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +229 -19
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +152 -32
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +32 -19
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +32 -19
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +481 -87
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +203 -25
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +301 -62
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +169 -23
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +301 -62
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +169 -15
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +225 -133
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +185 -77
- 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 +238 -235
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +243 -129
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +181 -97
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +150 -29
- 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 +41 -3
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +37 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +18 -5
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +69 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +32 -19
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -2
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +156 -11
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +156 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +152 -11
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +178 -19
- 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/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -2
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +152 -11
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +196 -37
- 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/TestVersionable.sol/TestVersionable.json +8 -8
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/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/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/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 +236 -0
- package/contracts/components/Distribution.sol +209 -64
- package/contracts/components/IComponent.sol +50 -0
- package/contracts/components/IDistributionComponent.sol +59 -3
- package/contracts/components/IPoolComponent.sol +50 -29
- package/contracts/components/IProductComponent.sol +7 -3
- package/contracts/components/Pool.sol +135 -152
- package/contracts/components/Product.sol +103 -117
- package/contracts/instance/BundleManager.sol +7 -11
- package/contracts/instance/IInstance.sol +35 -11
- package/contracts/instance/IInstanceService.sol +23 -2
- package/contracts/instance/Instance.sol +67 -62
- package/contracts/instance/InstanceAccessManager.sol +31 -38
- package/contracts/instance/InstanceReader.sol +3 -25
- package/contracts/instance/InstanceService.sol +198 -56
- package/contracts/instance/InstanceServiceManager.sol +5 -8
- package/contracts/instance/ObjectManager.sol +7 -24
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/module/IAccess.sol +4 -5
- package/contracts/instance/module/ISetup.sol +5 -4
- package/contracts/instance/service/ApplicationService.sol +268 -0
- package/contracts/instance/service/BundleService.sol +52 -14
- package/contracts/instance/service/BundleServiceManager.sol +5 -8
- package/contracts/instance/service/DistributionService.sol +208 -49
- package/contracts/instance/service/DistributionServiceManager.sol +6 -9
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +12 -3
- package/contracts/instance/service/IDistributionService.sol +53 -0
- package/contracts/instance/service/IPolicyService.sol +17 -16
- package/contracts/instance/service/PolicyService.sol +148 -132
- package/contracts/instance/service/PoolService.sol +27 -42
- package/contracts/instance/service/PoolServiceManager.sol +5 -8
- package/contracts/instance/service/ProductService.sol +100 -40
- package/contracts/registry/ChainNft.sol +1 -1
- package/contracts/registry/IRegistry.sol +37 -19
- package/contracts/registry/IRegistryService.sol +30 -13
- package/contracts/registry/Registry.sol +233 -217
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +81 -162
- package/contracts/registry/RegistryServiceManager.sol +18 -36
- package/contracts/registry/ReleaseManager.sol +331 -0
- package/contracts/registry/TokenRegistry.sol +11 -9
- package/contracts/shared/ERC165.sol +12 -11
- package/contracts/shared/INftOwnable.sol +12 -6
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -6
- package/contracts/shared/IRegistryLinked.sol +15 -0
- package/contracts/shared/IService.sol +2 -1
- package/contracts/shared/IVersionable.sol +2 -2
- package/contracts/shared/NftOwnable.sol +113 -57
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +6 -5
- package/contracts/shared/Registerable.sol +15 -24
- package/contracts/shared/RegistryLinked.sol +64 -0
- package/contracts/shared/Service.sol +18 -13
- package/contracts/shared/Versionable.sol +3 -2
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +4 -3
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/ObjectType.sol +6 -2
- package/contracts/types/RoleId.sol +4 -5
- package/package.json +3 -3
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -384
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +0 -448
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +0 -763
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -466
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/contracts/components/BaseComponent.sol +0 -148
- package/contracts/components/IBaseComponent.sol +0 -32
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +0 -23
- package/contracts/instance/IInstanceBase.sol +0 -26
- package/contracts/instance/InstanceBase.sol +0 -41
- package/contracts/instance/base/ComponentServiceBase.sol +0 -72
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -317
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -4,19 +4,23 @@ pragma solidity ^0.8.20;
|
|
4
4
|
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
5
5
|
|
6
6
|
import {Instance} from "./Instance.sol";
|
7
|
+
import {IInstance} from "./IInstance.sol";
|
7
8
|
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
8
9
|
import {IInstanceService} from "./IInstanceService.sol";
|
9
10
|
import {InstanceReader} from "./InstanceReader.sol";
|
10
11
|
import {BundleManager} from "./BundleManager.sol";
|
11
12
|
import {IRegistry} from "../registry/IRegistry.sol";
|
12
|
-
import {
|
13
|
+
import {IRegistryService} from "../registry/IRegistryService.sol";
|
13
14
|
import {ChainNft} from "../registry/ChainNft.sol";
|
14
15
|
import {Service} from "../../contracts/shared/Service.sol";
|
15
16
|
import {IService} from "../shared/IService.sol";
|
16
17
|
import {NftId} from "../../contracts/types/NftId.sol";
|
17
18
|
import {RoleId} from "../types/RoleId.sol";
|
18
|
-
import {
|
19
|
-
import {
|
19
|
+
import {ADMIN_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, POLICY_SERVICE_ROLE, BUNDLE_SERVICE_ROLE} from "../types/RoleId.sol";
|
20
|
+
import {ObjectType, INSTANCE, BUNDLE, POLICY, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
|
21
|
+
import {IDistributionComponent} from "../components/IDistributionComponent.sol";
|
22
|
+
import {IPoolComponent} from "../components/IPoolComponent.sol";
|
23
|
+
import {IProductComponent} from "../components/IProductComponent.sol";
|
20
24
|
|
21
25
|
contract InstanceService is Service, IInstanceService {
|
22
26
|
|
@@ -27,11 +31,10 @@ contract InstanceService is Service, IInstanceService {
|
|
27
31
|
|
28
32
|
// TODO update to real hash when instance is stable
|
29
33
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
30
|
-
string public constant NAME = "InstanceService";
|
31
34
|
|
32
35
|
modifier onlyInstanceOwner(NftId instanceNftId) {
|
33
36
|
IRegistry registry = getRegistry();
|
34
|
-
ChainNft chainNft = registry.
|
37
|
+
ChainNft chainNft = ChainNft(registry.getChainNftAddress());
|
35
38
|
|
36
39
|
if( msg.sender != chainNft.ownerOf(instanceNftId.toInt())) {
|
37
40
|
revert ErrorInstanceServiceNotInstanceOwner(msg.sender, instanceNftId);
|
@@ -39,6 +42,14 @@ contract InstanceService is Service, IInstanceService {
|
|
39
42
|
_;
|
40
43
|
}
|
41
44
|
|
45
|
+
modifier onlyRegisteredService() {
|
46
|
+
address caller = msg.sender;
|
47
|
+
if (! getRegistry().isRegisteredService(caller)) {
|
48
|
+
revert ErrorInstanceServiceRequestUnauhorized(caller);
|
49
|
+
}
|
50
|
+
_;
|
51
|
+
}
|
52
|
+
|
42
53
|
function createInstanceClone()
|
43
54
|
external
|
44
55
|
returns (
|
@@ -53,26 +64,24 @@ contract InstanceService is Service, IInstanceService {
|
|
53
64
|
IRegistry registry = getRegistry();
|
54
65
|
address registryAddress = address(registry);
|
55
66
|
NftId registryNftId = registry.getNftId(registryAddress);
|
56
|
-
address registryServiceAddress = registry.getServiceAddress(
|
57
|
-
|
67
|
+
address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getMajorVersion());
|
68
|
+
IRegistryService registryService = IRegistryService(registryServiceAddress);
|
58
69
|
|
59
70
|
// initially set the authority of the access managar to this (being the instance service).
|
60
71
|
// This will allow the instance service to bootstrap the authorizations of the instance
|
61
72
|
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
62
73
|
clonedAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
|
63
|
-
clonedAccessManager.
|
74
|
+
clonedAccessManager.initialize(address(this));
|
64
75
|
|
65
76
|
clonedInstance = Instance(Clones.clone(_masterInstance));
|
66
77
|
clonedInstance.initialize(address(clonedAccessManager), registryAddress, registryNftId, msg.sender);
|
67
|
-
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
68
|
-
clonedInstanceNftId = info.nftId;
|
69
78
|
|
70
79
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
|
71
|
-
clonedInstanceReader.initialize(registryAddress,
|
80
|
+
clonedInstanceReader.initialize(registryAddress, address(clonedInstance));
|
72
81
|
clonedInstance.setInstanceReader(clonedInstanceReader);
|
73
82
|
|
74
83
|
clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
|
75
|
-
clonedBundleManager.initialize(address(clonedAccessManager), registryAddress,
|
84
|
+
clonedBundleManager.initialize(address(clonedAccessManager), registryAddress, address(clonedInstance));
|
76
85
|
clonedInstance.setBundleManager(clonedBundleManager);
|
77
86
|
|
78
87
|
// TODO amend setters with instance specific , policy manager ...
|
@@ -84,10 +93,15 @@ contract InstanceService is Service, IInstanceService {
|
|
84
93
|
clonedAccessManager.grantRole(ADMIN_ROLE(), instanceOwner);
|
85
94
|
clonedAccessManager.revokeRole(ADMIN_ROLE(), address(this));
|
86
95
|
|
96
|
+
IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
|
97
|
+
clonedInstanceNftId = info.nftId;
|
98
|
+
// clonedInstance.linkToRegisteredNftId();
|
99
|
+
|
87
100
|
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
|
88
101
|
}
|
89
102
|
|
90
103
|
function _grantInitialAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
104
|
+
_createGifRoles(clonedAccessManager);
|
91
105
|
_createGifTargets(clonedAccessManager, clonedInstance, clonedBundleManager);
|
92
106
|
_grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstance);
|
93
107
|
_grantPoolServiceAuthorizations(clonedAccessManager, clonedInstance);
|
@@ -97,7 +111,21 @@ contract InstanceService is Service, IInstanceService {
|
|
97
111
|
_grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance);
|
98
112
|
}
|
99
113
|
|
114
|
+
function _createGifRoles(InstanceAccessManager clonedAccessManager) internal {
|
115
|
+
clonedAccessManager.createGifRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole");
|
116
|
+
clonedAccessManager.createGifRole(POOL_OWNER_ROLE(), "PoolOwnerRole");
|
117
|
+
clonedAccessManager.createGifRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole");
|
118
|
+
|
119
|
+
clonedAccessManager.createGifRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole");
|
120
|
+
clonedAccessManager.createGifRole(POOL_SERVICE_ROLE(), "PoolServiceRole");
|
121
|
+
clonedAccessManager.createGifRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole");
|
122
|
+
clonedAccessManager.createGifRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole");
|
123
|
+
clonedAccessManager.createGifRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole");
|
124
|
+
clonedAccessManager.createGifRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole");
|
125
|
+
}
|
126
|
+
|
100
127
|
function _createGifTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
128
|
+
clonedAccessManager.createGifTarget(address(clonedAccessManager), "InstanceAccessManager");
|
101
129
|
clonedAccessManager.createGifTarget(address(clonedInstance), "Instance");
|
102
130
|
clonedAccessManager.createGifTarget(address(clonedBundleManager), "BundleManager");
|
103
131
|
}
|
@@ -105,20 +133,29 @@ contract InstanceService is Service, IInstanceService {
|
|
105
133
|
function _grantDistributionServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
106
134
|
// configure authorization for distribution service on instance
|
107
135
|
IRegistry registry = getRegistry();
|
108
|
-
address distributionServiceAddress =
|
109
|
-
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(),
|
110
|
-
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](
|
136
|
+
address distributionServiceAddress = registry.getServiceAddress(DISTRIBUTION(), getMajorVersion());
|
137
|
+
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), distributionServiceAddress);
|
138
|
+
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](11);
|
111
139
|
instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
|
112
140
|
instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
|
141
|
+
instanceDistributionServiceSelectors[2] = clonedInstance.createDistributorType.selector;
|
142
|
+
instanceDistributionServiceSelectors[3] = clonedInstance.updateDistributorType.selector;
|
143
|
+
instanceDistributionServiceSelectors[4] = clonedInstance.updateDistributorTypeState.selector;
|
144
|
+
instanceDistributionServiceSelectors[5] = clonedInstance.createDistributor.selector;
|
145
|
+
instanceDistributionServiceSelectors[6] = clonedInstance.updateDistributor.selector;
|
146
|
+
instanceDistributionServiceSelectors[7] = clonedInstance.updateDistributorState.selector;
|
147
|
+
instanceDistributionServiceSelectors[8] = clonedInstance.createReferral.selector;
|
148
|
+
instanceDistributionServiceSelectors[9] = clonedInstance.updateReferral.selector;
|
149
|
+
instanceDistributionServiceSelectors[10] = clonedInstance.updateReferralState.selector;
|
113
150
|
clonedAccessManager.setTargetFunctionRole(
|
114
151
|
"Instance",
|
115
152
|
instanceDistributionServiceSelectors,
|
116
|
-
DISTRIBUTION_SERVICE_ROLE());
|
153
|
+
DISTRIBUTION_SERVICE_ROLE());
|
117
154
|
}
|
118
155
|
|
119
156
|
function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
120
157
|
// configure authorization for pool service on instance
|
121
|
-
address poolServiceAddress =
|
158
|
+
address poolServiceAddress = getRegistry().getServiceAddress(POOL(), getMajorVersion());
|
122
159
|
clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
|
123
160
|
bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
|
124
161
|
instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
|
@@ -131,7 +168,7 @@ contract InstanceService is Service, IInstanceService {
|
|
131
168
|
|
132
169
|
function _grantProductServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
133
170
|
// configure authorization for product service on instance
|
134
|
-
address productServiceAddress =
|
171
|
+
address productServiceAddress = getRegistry().getServiceAddress(PRODUCT(), getMajorVersion());
|
135
172
|
clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
|
136
173
|
bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
|
137
174
|
instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
|
@@ -147,7 +184,7 @@ contract InstanceService is Service, IInstanceService {
|
|
147
184
|
|
148
185
|
function _grantPolicyServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
149
186
|
// configure authorization for policy service on instance
|
150
|
-
address policyServiceAddress =
|
187
|
+
address policyServiceAddress = getRegistry().getServiceAddress(POLICY(), getMajorVersion());
|
151
188
|
clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), address(policyServiceAddress));
|
152
189
|
bytes4[] memory instancePolicyServiceSelectors = new bytes4[](3);
|
153
190
|
instancePolicyServiceSelectors[0] = clonedInstance.createPolicy.selector;
|
@@ -161,7 +198,7 @@ contract InstanceService is Service, IInstanceService {
|
|
161
198
|
|
162
199
|
function _grantBundleServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
163
200
|
// configure authorization for bundle service on instance
|
164
|
-
address bundleServiceAddress =
|
201
|
+
address bundleServiceAddress = getRegistry().getServiceAddress(BUNDLE(), getMajorVersion());
|
165
202
|
clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
|
166
203
|
bytes4[] memory instanceBundleServiceSelectors = new bytes4[](2);
|
167
204
|
instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
|
@@ -186,7 +223,7 @@ contract InstanceService is Service, IInstanceService {
|
|
186
223
|
|
187
224
|
function _grantInstanceServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
|
188
225
|
// configure authorization for instance service on instance
|
189
|
-
address instanceServiceAddress =
|
226
|
+
address instanceServiceAddress = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
|
190
227
|
clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
|
191
228
|
bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
|
192
229
|
instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
|
@@ -194,43 +231,67 @@ contract InstanceService is Service, IInstanceService {
|
|
194
231
|
"Instance",
|
195
232
|
instanceInstanceServiceSelectors,
|
196
233
|
INSTANCE_SERVICE_ROLE());
|
197
|
-
}
|
198
|
-
|
199
|
-
function setMasterInstance(address accessManagerAddress, address instanceAddress, address instanceReaderAddress, address bundleManagerAddress) external onlyOwner {
|
200
|
-
require(_masterInstanceAccessManager == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
201
|
-
require(_masterInstance == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
202
|
-
require(_masterInstanceBundleManager == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
|
203
234
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
BundleManager bundleManager = BundleManager(bundleManagerAddress);
|
235
|
+
bytes4[] memory instanceAccessManagerInstanceServiceSelectors = new bytes4[](1);
|
236
|
+
instanceAccessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
|
237
|
+
clonedAccessManager.setTargetFunctionRole(
|
238
|
+
"InstanceAccessManager",
|
239
|
+
instanceAccessManagerInstanceServiceSelectors,
|
240
|
+
INSTANCE_SERVICE_ROLE());
|
241
|
+
}
|
212
242
|
|
213
|
-
|
214
|
-
|
215
|
-
|
243
|
+
function setAndRegisterMasterInstance(address instanceAddress)
|
244
|
+
external
|
245
|
+
onlyOwner
|
246
|
+
returns(NftId masterInstanceNftId)
|
247
|
+
{
|
248
|
+
if(_masterInstance != address(0)) { revert ErrorInstanceServiceMasterInstanceAlreadySet(); }
|
249
|
+
if(_masterInstanceAccessManager != address(0)) { revert ErrorInstanceServiceMasterInstanceAccessManagerAlreadySet(); }
|
250
|
+
if(_masterInstanceBundleManager != address(0)) { revert ErrorInstanceServiceMasterBundleManagerAlreadySet(); }
|
251
|
+
|
252
|
+
if(instanceAddress == address(0)) { revert ErrorInstanceServiceInstanceAddressZero(); }
|
253
|
+
|
254
|
+
IInstance instance = IInstance(instanceAddress);
|
255
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
256
|
+
address accessManagerAddress = address(accessManager);
|
257
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
258
|
+
address instanceReaderAddress = address(instanceReader);
|
259
|
+
BundleManager bundleManager = instance.getBundleManager();
|
260
|
+
address bundleManagerAddress = address(bundleManager);
|
261
|
+
|
262
|
+
if(accessManagerAddress == address(0)) { revert ErrorInstanceServiceAccessManagerZero(); }
|
263
|
+
if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderZero(); }
|
264
|
+
if(bundleManagerAddress == address(0)) { revert ErrorInstanceServiceBundleManagerZero(); }
|
265
|
+
|
266
|
+
if(instance.authority() != accessManagerAddress) { revert ErrorInstanceServiceInstanceAuthorityMismatch(); }
|
267
|
+
if(instanceReader.getInstance() != instance) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch2(); }
|
268
|
+
if(bundleManager.getInstance() != instance) { revert ErrorInstanceServiceBundleMangerInstanceMismatch(); }
|
216
269
|
|
217
270
|
_masterInstanceAccessManager = accessManagerAddress;
|
218
271
|
_masterInstance = instanceAddress;
|
219
272
|
_masterInstanceReader = instanceReaderAddress;
|
220
273
|
_masterInstanceBundleManager = bundleManagerAddress;
|
274
|
+
|
275
|
+
IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(), getMajorVersion()));
|
276
|
+
IInstance masterInstance = IInstance(_masterInstance);
|
277
|
+
IRegistry.ObjectInfo memory info = registryService.registerInstance(masterInstance, getOwner());
|
278
|
+
masterInstanceNftId = info.nftId;
|
279
|
+
|
280
|
+
// masterInstance.linkToRegisteredNftId();
|
221
281
|
}
|
222
282
|
|
223
283
|
function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
|
224
|
-
|
225
|
-
|
226
|
-
|
284
|
+
if(_masterInstanceReader == address(0)) { revert ErrorInstanceServiceMasterInstanceReaderNotSet(); }
|
285
|
+
if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderAddressZero(); }
|
286
|
+
if(instanceReaderAddress == _masterInstanceReader) { revert ErrorInstanceServiceInstanceReaderSameAsMasterInstanceReader(); }
|
227
287
|
|
228
288
|
InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
|
229
|
-
|
289
|
+
if(instanceReader.getInstance() != IInstance(_masterInstance)) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch(); }
|
230
290
|
|
231
291
|
_masterInstanceReader = instanceReaderAddress;
|
232
292
|
}
|
233
293
|
|
294
|
+
// TODO access restriction
|
234
295
|
function upgradeInstanceReader(NftId instanceNftId) external {
|
235
296
|
IRegistry registry = getRegistry();
|
236
297
|
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
@@ -242,7 +303,7 @@ contract InstanceService is Service, IInstanceService {
|
|
242
303
|
}
|
243
304
|
|
244
305
|
InstanceReader upgradedInstanceReaderClone = InstanceReader(Clones.clone(address(_masterInstanceReader)));
|
245
|
-
upgradedInstanceReaderClone.initialize(address(registry),
|
306
|
+
upgradedInstanceReaderClone.initialize(address(registry), address(instance));
|
246
307
|
instance.setInstanceReader(upgradedInstanceReaderClone);
|
247
308
|
}
|
248
309
|
|
@@ -263,15 +324,11 @@ contract InstanceService is Service, IInstanceService {
|
|
263
324
|
}
|
264
325
|
|
265
326
|
// From IService
|
266
|
-
function
|
267
|
-
return
|
327
|
+
function getDomain() public pure override(Service, IService) returns(ObjectType) {
|
328
|
+
return INSTANCE();
|
268
329
|
}
|
269
330
|
|
270
331
|
/// @dev top level initializer
|
271
|
-
// 1) registry is non upgradeable -> don't need a proxy and uses constructor !
|
272
|
-
// 2) deploy registry service first -> from its initialization func it is easier to deploy registry then vice versa
|
273
|
-
// 3) deploy registry -> pass registry service address as constructor argument
|
274
|
-
// registry is getting instantiated and locked to registry service address forever
|
275
332
|
function _initialize(
|
276
333
|
address owner,
|
277
334
|
bytes memory data
|
@@ -280,21 +337,106 @@ contract InstanceService is Service, IInstanceService {
|
|
280
337
|
initializer
|
281
338
|
virtual override
|
282
339
|
{
|
283
|
-
address initialOwner
|
284
|
-
address registryAddress
|
340
|
+
address initialOwner;
|
341
|
+
address registryAddress;
|
285
342
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
286
343
|
// TODO while InstanceService is not deployed in InstanceServiceManager constructor
|
287
344
|
// owner is InstanceServiceManager deployer
|
288
|
-
|
289
|
-
|
290
|
-
_registerInterface(type(IService).interfaceId);
|
291
|
-
_registerInterface(type(IInstanceService).interfaceId);
|
345
|
+
initializeService(registryAddress, owner);
|
346
|
+
registerInterface(type(IInstanceService).interfaceId);
|
292
347
|
}
|
293
348
|
|
294
349
|
function hasRole(address account, RoleId role, address instanceAddress) public view returns (bool) {
|
295
350
|
Instance instance = Instance(instanceAddress);
|
296
|
-
InstanceAccessManager accessManager = instance.
|
351
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
297
352
|
return accessManager.hasRole(role, account);
|
298
353
|
}
|
354
|
+
|
355
|
+
function createGifTarget(NftId instanceNftId, address targetAddress, string memory targetName) external onlyRegisteredService {
|
356
|
+
IRegistry registry = getRegistry();
|
357
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
358
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
359
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
360
|
+
accessManager.createGifTarget(targetAddress, targetName);
|
361
|
+
}
|
362
|
+
|
363
|
+
function grantDistributionDefaultPermissions(NftId instanceNftId, address distributionAddress, string memory distributionName) external onlyRegisteredService {
|
364
|
+
IRegistry registry = getRegistry();
|
365
|
+
IRegistry.ObjectInfo memory distributionInfo = registry.getObjectInfo(distributionAddress);
|
366
|
+
|
367
|
+
if (distributionInfo.objectType != DISTRIBUTION()) {
|
368
|
+
revert ErrorInstanceServiceInvalidComponentType(distributionAddress, DISTRIBUTION(), distributionInfo.objectType);
|
369
|
+
}
|
370
|
+
|
371
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
372
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
373
|
+
InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
|
374
|
+
|
375
|
+
bytes4[] memory fctSelectors = new bytes4[](1);
|
376
|
+
fctSelectors[0] = IDistributionComponent.setFees.selector;
|
377
|
+
instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors, DISTRIBUTION_OWNER_ROLE());
|
378
|
+
|
379
|
+
bytes4[] memory fctSelectors2 = new bytes4[](2);
|
380
|
+
fctSelectors2[0] = IDistributionComponent.processSale.selector;
|
381
|
+
fctSelectors2[1] = IDistributionComponent.processRenewal.selector;
|
382
|
+
instanceAccessManager.setTargetFunctionRole(distributionName, fctSelectors2, PRODUCT_SERVICE_ROLE());
|
383
|
+
}
|
384
|
+
|
385
|
+
function grantPoolDefaultPermissions(NftId instanceNftId, address poolAddress, string memory poolName) external onlyRegisteredService {
|
386
|
+
IRegistry registry = getRegistry();
|
387
|
+
IRegistry.ObjectInfo memory poolInfo = registry.getObjectInfo(poolAddress);
|
388
|
+
|
389
|
+
if (poolInfo.objectType != POOL()) {
|
390
|
+
revert ErrorInstanceServiceInvalidComponentType(poolAddress, POOL(), poolInfo.objectType);
|
391
|
+
}
|
392
|
+
|
393
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
394
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
395
|
+
InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
|
396
|
+
|
397
|
+
bytes4[] memory fctSelectors = new bytes4[](1);
|
398
|
+
fctSelectors[0] = IPoolComponent.setFees.selector;
|
399
|
+
instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors, POOL_OWNER_ROLE());
|
400
|
+
|
401
|
+
bytes4[] memory fctSelectors2 = new bytes4[](1);
|
402
|
+
fctSelectors2[0] = IPoolComponent.verifyApplication.selector;
|
403
|
+
instanceAccessManager.setTargetFunctionRole(poolName, fctSelectors2, POLICY_SERVICE_ROLE());
|
404
|
+
}
|
405
|
+
|
406
|
+
function grantProductDefaultPermissions(NftId instanceNftId, address productAddress, string memory productName) external onlyRegisteredService {
|
407
|
+
IRegistry registry = getRegistry();
|
408
|
+
IRegistry.ObjectInfo memory productInfo = registry.getObjectInfo(productAddress);
|
409
|
+
|
410
|
+
if (productInfo.objectType != PRODUCT()) {
|
411
|
+
revert ErrorInstanceServiceInvalidComponentType(productAddress, PRODUCT(), productInfo.objectType);
|
412
|
+
}
|
413
|
+
|
414
|
+
IRegistry.ObjectInfo memory instanceInfo = registry.getObjectInfo(instanceNftId);
|
415
|
+
Instance instance = Instance(instanceInfo.objectAddress);
|
416
|
+
InstanceAccessManager instanceAccessManager = InstanceAccessManager(instance.authority());
|
417
|
+
|
418
|
+
bytes4[] memory fctSelectors = new bytes4[](1);
|
419
|
+
fctSelectors[0] = IProductComponent.setFees.selector;
|
420
|
+
instanceAccessManager.setTargetFunctionRole(productName, fctSelectors, PRODUCT_OWNER_ROLE());
|
421
|
+
}
|
422
|
+
|
423
|
+
function setTargetLocked(string memory targetName, bool locked) external {
|
424
|
+
address componentAddress = msg.sender;
|
425
|
+
IRegistry registry = getRegistry();
|
426
|
+
IRegistry.ObjectInfo memory componentInfo = registry.getObjectInfo(componentAddress);
|
427
|
+
if (componentInfo.nftId.eqz()) {
|
428
|
+
revert ErrorInstanceServiceComponentNotRegistered(componentAddress);
|
429
|
+
}
|
430
|
+
|
431
|
+
// TODO validate component type
|
432
|
+
|
433
|
+
|
434
|
+
address instanceAddress = registry.getObjectInfo(componentInfo.parentNftId).objectAddress;
|
435
|
+
IInstance instance = IInstance(instanceAddress);
|
436
|
+
|
437
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
438
|
+
accessManager.setTargetClosed(targetName, locked);
|
439
|
+
}
|
440
|
+
|
299
441
|
}
|
300
442
|
|
@@ -7,7 +7,7 @@ import {ProxyManager} from "../shared/ProxyManager.sol";
|
|
7
7
|
import {InstanceService} from "./InstanceService.sol";
|
8
8
|
import {Registry} from "../registry/Registry.sol";
|
9
9
|
import {RegistryService} from "../registry/RegistryService.sol";
|
10
|
-
import {
|
10
|
+
import {REGISTRY} from "../types/ObjectType.sol";
|
11
11
|
|
12
12
|
contract InstanceServiceManager is ProxyManager {
|
13
13
|
|
@@ -28,10 +28,10 @@ contract InstanceServiceManager is ProxyManager {
|
|
28
28
|
|
29
29
|
_instanceService = InstanceService(address(versionable));
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
//
|
31
|
+
// TODO `this` must have a role or own nft to register service
|
32
|
+
//Registry registry = Registry(registryAddress);
|
33
|
+
//address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _instanceService.getMajorVersion());
|
34
|
+
//RegistryService registryService = RegistryService(registryServiceAddress);
|
35
35
|
//registryService.registerService(_instanceService);
|
36
36
|
// RegistryService registryService = _instanceService.getRegistryService();
|
37
37
|
|
@@ -40,9 +40,6 @@ contract InstanceServiceManager is ProxyManager {
|
|
40
40
|
//_linkToNftOwnable(
|
41
41
|
// address(registryAddress),
|
42
42
|
// address(_instanceService));
|
43
|
-
|
44
|
-
// implies that after this constructor call only upgrade functionality is available
|
45
|
-
_isDeployed = true;
|
46
43
|
}
|
47
44
|
|
48
45
|
//--- view functions ----------------------------------------------------//
|
@@ -14,49 +14,32 @@ contract ObjectManager is
|
|
14
14
|
Cloneable
|
15
15
|
{
|
16
16
|
|
17
|
-
event LogObjectManagerInitialized(
|
17
|
+
event LogObjectManagerInitialized(address instance);
|
18
18
|
|
19
19
|
error ErrorObjectManagerNftIdInvalid(NftId instanceNftId);
|
20
20
|
error ErrorObjectManagerAlreadyAdded(NftId componentNftId, NftId objectNftId);
|
21
21
|
|
22
22
|
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _activeObjects;
|
23
23
|
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _allObjects;
|
24
|
-
|
25
|
-
InstanceReader internal _instanceReader;
|
26
|
-
|
27
|
-
constructor() Cloneable() {
|
28
|
-
_instanceReader = InstanceReader(address(0));
|
29
|
-
}
|
24
|
+
IInstance internal _instance; // store instance address -> more flexible, instance may not be registered during ObjectManager initialization
|
30
25
|
|
31
26
|
/// @dev call to initialize MUST be made in the same transaction as cloning of the contract
|
32
27
|
function initialize(
|
33
28
|
address authority,
|
34
29
|
address registry,
|
35
|
-
|
30
|
+
address instance
|
36
31
|
)
|
37
32
|
external
|
38
33
|
{
|
39
34
|
initialize(authority, registry);
|
40
35
|
|
41
|
-
|
42
|
-
IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(instanceNftId);
|
43
|
-
if (instanceInfo.objectType != INSTANCE()) {
|
44
|
-
revert ErrorObjectManagerNftIdInvalid(instanceNftId);
|
45
|
-
}
|
46
|
-
|
47
|
-
IInstance instance = IInstance(instanceInfo.objectAddress);
|
48
|
-
_instanceReader = instance.getInstanceReader();
|
49
|
-
_instanceNftId = instanceNftId;
|
36
|
+
_instance = IInstance(instance);
|
50
37
|
|
51
|
-
emit LogObjectManagerInitialized(
|
52
|
-
}
|
53
|
-
|
54
|
-
function getInstanceReader() external view returns (InstanceReader) {
|
55
|
-
return _instanceReader;
|
38
|
+
emit LogObjectManagerInitialized(instance);
|
56
39
|
}
|
57
40
|
|
58
|
-
function
|
59
|
-
return
|
41
|
+
function getInstance() external view returns (IInstance) {
|
42
|
+
return _instance;
|
60
43
|
}
|
61
44
|
|
62
45
|
function _add(NftId componentNftId, NftId objectNftId) internal {
|
@@ -0,0 +1,134 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IComponent} from "../../components/IComponent.sol";
|
5
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
6
|
+
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
7
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
8
|
+
import {IAccess} from "../module/IAccess.sol";
|
9
|
+
import {ObjectType, INSTANCE, REGISTRY} from "../../types/ObjectType.sol";
|
10
|
+
import {NftId} from "../../types/NftId.sol";
|
11
|
+
import {RoleId} from "../../types/RoleId.sol";
|
12
|
+
|
13
|
+
import {Service} from "../../shared/Service.sol";
|
14
|
+
import {InstanceService} from "../InstanceService.sol";
|
15
|
+
import {InstanceAccessManager} from "../InstanceAccessManager.sol";
|
16
|
+
|
17
|
+
abstract contract ComponentService is Service {
|
18
|
+
|
19
|
+
error ErrorComponentServiceAlreadyRegistered(address component, NftId nftId);
|
20
|
+
error ErrorComponentServiceNotComponent(address component);
|
21
|
+
error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
|
22
|
+
error ErrorComponentServiceSenderNotOwner(address component, address initialOwner, address sender);
|
23
|
+
error ErrorComponentServiceExpectedRoleMissing(NftId instanceNftId, RoleId requiredRole, address sender);
|
24
|
+
error ErrorComponentServiceComponentLocked(address component);
|
25
|
+
|
26
|
+
/// @dev modifier to check if caller is a registered service
|
27
|
+
modifier onlyService() {
|
28
|
+
address caller = msg.sender;
|
29
|
+
require(getRegistry().isRegisteredService(caller), "ERROR_NOT_SERVICE");
|
30
|
+
_;
|
31
|
+
}
|
32
|
+
|
33
|
+
// view functions
|
34
|
+
|
35
|
+
function getRegistryService() public view virtual returns (IRegistryService) {
|
36
|
+
address service = getRegistry().getServiceAddress(REGISTRY(), getMajorVersion());
|
37
|
+
return IRegistryService(service);
|
38
|
+
}
|
39
|
+
|
40
|
+
function getInstanceService() public view returns (InstanceService) {
|
41
|
+
address service = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
|
42
|
+
return InstanceService(service);
|
43
|
+
}
|
44
|
+
|
45
|
+
// internal functions
|
46
|
+
function _checkComponentForRegistration(
|
47
|
+
address componentAddress,
|
48
|
+
ObjectType requiredType,
|
49
|
+
RoleId requiredRole
|
50
|
+
)
|
51
|
+
internal
|
52
|
+
view
|
53
|
+
returns (
|
54
|
+
IComponent component,
|
55
|
+
address owner,
|
56
|
+
IInstance instance,
|
57
|
+
NftId instanceNftId
|
58
|
+
)
|
59
|
+
{
|
60
|
+
// component may only be registerd by initial owner of component
|
61
|
+
owner = msg.sender;
|
62
|
+
|
63
|
+
// check component has not already been registerd
|
64
|
+
NftId compoentNftId = getRegistry().getNftId(componentAddress);
|
65
|
+
if(compoentNftId.gtz()) {
|
66
|
+
revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
|
67
|
+
}
|
68
|
+
|
69
|
+
// check this is a component
|
70
|
+
component = IComponent(componentAddress);
|
71
|
+
if(!component.supportsInterface(type(IComponent).interfaceId)) {
|
72
|
+
revert ErrorComponentServiceNotComponent(componentAddress);
|
73
|
+
}
|
74
|
+
|
75
|
+
// check component is of required type
|
76
|
+
IRegistry.ObjectInfo memory componentInfo = component.getInitialInfo();
|
77
|
+
if(componentInfo.objectType != requiredType) {
|
78
|
+
revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
|
79
|
+
}
|
80
|
+
|
81
|
+
// check msg.sender is component owner
|
82
|
+
address initialOwner = componentInfo.initialOwner;
|
83
|
+
if(owner != initialOwner) {
|
84
|
+
revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
|
85
|
+
}
|
86
|
+
|
87
|
+
// check instance has assigned required role to owner
|
88
|
+
instanceNftId = componentInfo.parentNftId;
|
89
|
+
instance = _getInstance(instanceNftId);
|
90
|
+
bool hasRole = getInstanceService().hasRole(
|
91
|
+
owner,
|
92
|
+
requiredRole,
|
93
|
+
address(instance));
|
94
|
+
|
95
|
+
if(!hasRole) {
|
96
|
+
revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
// internal view functions
|
101
|
+
|
102
|
+
function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
|
103
|
+
IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
|
104
|
+
return IInstance(instanceInfo.objectAddress);
|
105
|
+
}
|
106
|
+
|
107
|
+
function _getAndVerifyComponentInfoAndInstance(
|
108
|
+
//address component,
|
109
|
+
ObjectType expectedType
|
110
|
+
)
|
111
|
+
internal
|
112
|
+
view
|
113
|
+
returns(
|
114
|
+
IRegistry.ObjectInfo memory info,
|
115
|
+
IInstance instance
|
116
|
+
)
|
117
|
+
{
|
118
|
+
IRegistry registry = getRegistry();
|
119
|
+
//TODO redundant check -> just check type
|
120
|
+
//NftId componentNftId = registry.getNftId(component);
|
121
|
+
//require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
122
|
+
|
123
|
+
info = registry.getObjectInfo(msg.sender);
|
124
|
+
require(info.objectType == expectedType, "OBJECT_TYPE_INVALID");
|
125
|
+
|
126
|
+
address instanceAddress = registry.getObjectInfo(info.parentNftId).objectAddress;
|
127
|
+
instance = IInstance(instanceAddress);
|
128
|
+
|
129
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
130
|
+
if (accessManager.isTargetLocked(info.objectAddress)) {
|
131
|
+
revert IAccess.ErrorIAccessTargetLocked(info.objectAddress);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|