@etherisc/gif-next 0.0.2-e2d8c7d-942 → 0.0.2-e38b7e6-931
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +40 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +42 -100
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +40 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +5 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +42 -128
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +47 -116
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +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 +90 -13
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +88 -14
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +56 -616
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +221 -114
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +2 -2
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +126 -242
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -126
- 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/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +114 -13
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -13
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +235 -37
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +20 -24
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +145 -38
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +17 -21
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +64 -13
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +120 -13
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +13 -13
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +13 -13
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +326 -64
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +51 -23
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +145 -38
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +17 -21
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +151 -44
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +17 -13
- 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 +132 -133
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -65
- 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 +145 -227
- 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 +30 -128
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +530 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +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 +31 -31
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/BaseComponent.sol +48 -12
- package/contracts/components/Distribution.sol +2 -11
- package/contracts/components/IBaseComponent.sol +5 -1
- package/contracts/components/IProductComponent.sol +2 -2
- package/contracts/components/Pool.sol +5 -18
- package/contracts/components/Product.sol +19 -16
- package/contracts/instance/IInstance.sol +3 -3
- package/contracts/instance/IInstanceBase.sol +0 -1
- package/contracts/instance/IInstanceService.sol +9 -3
- package/contracts/instance/Instance.sol +12 -214
- package/contracts/instance/InstanceAccessManager.sol +92 -77
- package/contracts/instance/InstanceBase.sol +0 -2
- package/contracts/instance/InstanceService.sol +118 -72
- package/contracts/instance/InstanceServiceManager.sol +5 -8
- package/contracts/instance/base/ComponentServiceBase.sol +78 -12
- package/contracts/instance/base/IInstanceBase.sol +0 -2
- package/contracts/instance/module/IAccess.sol +27 -17
- package/contracts/instance/service/BundleService.sol +39 -5
- package/contracts/instance/service/BundleServiceManager.sol +5 -8
- package/contracts/instance/service/DistributionService.sol +33 -36
- package/contracts/instance/service/DistributionServiceManager.sol +6 -9
- package/contracts/instance/service/IBundleService.sol +5 -6
- package/contracts/instance/service/IPolicyService.sol +7 -0
- package/contracts/instance/service/PolicyService.sol +65 -34
- package/contracts/instance/service/PoolService.sol +46 -28
- package/contracts/instance/service/PoolServiceManager.sol +5 -8
- package/contracts/instance/service/ProductService.sol +66 -30
- package/contracts/registry/ChainNft.sol +1 -1
- package/contracts/registry/IRegistry.sol +26 -16
- package/contracts/registry/IRegistryService.sol +13 -5
- package/contracts/registry/Registry.sol +149 -201
- package/contracts/registry/RegistryAccessManager.sol +210 -0
- package/contracts/registry/RegistryService.sol +50 -88
- package/contracts/registry/RegistryServiceManager.sol +18 -36
- package/contracts/registry/ReleaseManager.sol +342 -0
- package/contracts/registry/TokenRegistry.sol +5 -6
- package/contracts/shared/IRegisterable.sol +0 -2
- package/contracts/shared/IService.sol +2 -1
- package/contracts/shared/ProxyManager.sol +1 -1
- package/contracts/shared/Service.sol +10 -7
- package/contracts/test/TestService.sol +3 -2
- package/contracts/types/RoleId.sol +10 -12
- package/package.json +1 -1
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- 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/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/service/ComponentOwnerService.sol +0 -317
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
@@ -1,23 +1,31 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
|
4
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
6
5
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
6
|
+
|
7
|
+
import {IBaseComponent} from "./IBaseComponent.sol";
|
8
|
+
import {IProductService} from "../instance/service/IProductService.sol";
|
9
|
+
import {IInstanceService} from "../instance/IInstanceService.sol";
|
7
10
|
import {IInstance} from "../instance/IInstance.sol";
|
11
|
+
import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
|
8
12
|
import {IRegistry} from "../registry/IRegistry.sol";
|
9
13
|
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
10
|
-
import {ObjectType} from "../types/ObjectType.sol";
|
14
|
+
import {ObjectType, INSTANCE, PRODUCT} from "../types/ObjectType.sol";
|
15
|
+
import {VersionLib} from "../types/Version.sol";
|
11
16
|
import {Registerable} from "../shared/Registerable.sol";
|
12
|
-
import {
|
17
|
+
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
18
|
+
import {IAccess} from "../instance/module/IAccess.sol";
|
13
19
|
|
20
|
+
// TODO also inherit oz accessmanaged
|
14
21
|
abstract contract BaseComponent is
|
15
22
|
Registerable,
|
16
23
|
IBaseComponent
|
17
24
|
{
|
18
25
|
using NftIdLib for NftId;
|
19
26
|
|
20
|
-
|
27
|
+
IInstanceService internal _instanceService;
|
28
|
+
IProductService internal _productService;
|
21
29
|
|
22
30
|
address internal _deployer;
|
23
31
|
address internal _wallet;
|
@@ -25,6 +33,31 @@ abstract contract BaseComponent is
|
|
25
33
|
IInstance internal _instance;
|
26
34
|
NftId internal _productNftId;
|
27
35
|
|
36
|
+
modifier onlyProductService() {
|
37
|
+
if(msg.sender != address(_productService)) {
|
38
|
+
revert ErrorBaseComponentNotProductService(msg.sender);
|
39
|
+
}
|
40
|
+
_;
|
41
|
+
}
|
42
|
+
|
43
|
+
modifier onlyInstanceRole(uint64 roleIdNum) {
|
44
|
+
RoleId roleId = RoleIdLib.toRoleId(roleIdNum);
|
45
|
+
InstanceAccessManager accessManager = InstanceAccessManager(_instance.authority());
|
46
|
+
if( !accessManager.hasRole(roleId, msg.sender)) {
|
47
|
+
revert ErrorBaseComponentUnauthorized(msg.sender, roleIdNum);
|
48
|
+
}
|
49
|
+
_;
|
50
|
+
}
|
51
|
+
|
52
|
+
// TODO move to oz accessmanaged locked (which is included in restricted modifier)
|
53
|
+
modifier isNotLocked() {
|
54
|
+
InstanceAccessManager accessManager = InstanceAccessManager(_instance.authority());
|
55
|
+
if (accessManager.isTargetLocked(address(this))) {
|
56
|
+
revert IAccess.ErrorIAccessTargetLocked(address(this));
|
57
|
+
}
|
58
|
+
_;
|
59
|
+
}
|
60
|
+
|
28
61
|
constructor(
|
29
62
|
address registry,
|
30
63
|
NftId instanceNftId,
|
@@ -37,29 +70,32 @@ abstract contract BaseComponent is
|
|
37
70
|
bytes memory data = "";
|
38
71
|
_initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, data);
|
39
72
|
|
40
|
-
IRegistry.ObjectInfo memory instanceInfo =
|
73
|
+
IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(instanceNftId);
|
41
74
|
_instance = IInstance(instanceInfo.objectAddress);
|
42
75
|
require(
|
43
76
|
_instance.supportsInterface(type(IInstance).interfaceId),
|
44
77
|
""
|
45
78
|
);
|
46
79
|
|
47
|
-
|
80
|
+
_instanceService = IInstanceService(_registry.getServiceAddress(INSTANCE(), VersionLib.toVersion(3, 0, 0).toMajorPart()));
|
81
|
+
_productService = IProductService(_registry.getServiceAddress(PRODUCT(), VersionLib.toVersion(3, 0, 0).toMajorPart()));
|
48
82
|
_wallet = address(this);
|
49
83
|
_token = IERC20Metadata(token);
|
50
84
|
|
51
85
|
_registerInterface(type(IBaseComponent).interfaceId);
|
52
86
|
}
|
53
87
|
|
88
|
+
function getName() public pure virtual returns (string memory name);
|
89
|
+
|
54
90
|
// from component contract
|
55
|
-
// TODO
|
91
|
+
// TODO only owner and instance owner
|
56
92
|
function lock() external onlyOwner override {
|
57
|
-
|
93
|
+
_instanceService.setTargetLocked(getName(), true);
|
58
94
|
}
|
59
|
-
|
60
|
-
// TODO
|
95
|
+
|
96
|
+
// TODO only owner and instance owner
|
61
97
|
function unlock() external onlyOwner override {
|
62
|
-
|
98
|
+
_instanceService.setTargetLocked(getName(), false);
|
63
99
|
}
|
64
100
|
|
65
101
|
function getWallet()
|
@@ -16,7 +16,7 @@ import {Registerable} from "../shared/Registerable.sol";
|
|
16
16
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
17
17
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
18
18
|
|
19
|
-
contract Distribution is
|
19
|
+
abstract contract Distribution is
|
20
20
|
BaseComponent,
|
21
21
|
IDistributionComponent
|
22
22
|
{
|
@@ -28,14 +28,6 @@ contract Distribution is
|
|
28
28
|
TokenHandler internal _tokenHandler;
|
29
29
|
|
30
30
|
IDistributionService private _distributionService;
|
31
|
-
IProductService private _productService;
|
32
|
-
|
33
|
-
modifier onlyProductService() {
|
34
|
-
require(
|
35
|
-
msg.sender == address(_productService),
|
36
|
-
"ERROR:POL-002:NOT_PRODUCT_SERVICE");
|
37
|
-
_;
|
38
|
-
}
|
39
31
|
|
40
32
|
constructor(
|
41
33
|
address registry,
|
@@ -52,9 +44,7 @@ contract Distribution is
|
|
52
44
|
_initialDistributionFee = distributionFee;
|
53
45
|
|
54
46
|
_tokenHandler = TokenHandler(token);
|
55
|
-
|
56
47
|
_distributionService = _instance.getDistributionService();
|
57
|
-
_productService = _instance.getProductService();
|
58
48
|
|
59
49
|
_registerInterface(type(IDistributionComponent).interfaceId);
|
60
50
|
}
|
@@ -150,6 +140,7 @@ contract Distribution is
|
|
150
140
|
return (
|
151
141
|
info,
|
152
142
|
abi.encode(
|
143
|
+
getName(),
|
153
144
|
ISetup.DistributionSetupInfo(
|
154
145
|
_productNftId,
|
155
146
|
_tokenHandler,
|
@@ -10,12 +10,16 @@ import {NftId} from "../types/NftId.sol";
|
|
10
10
|
interface IBaseComponent is IRegisterable {
|
11
11
|
error ErrorBaseComponentWalletAddressIsSameAsCurrent(address newWallet);
|
12
12
|
error ErrorBaseComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
|
13
|
+
error ErrorBaseComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
|
14
|
+
error ErrorBaseComponentNotProductService(address caller);
|
13
15
|
|
14
16
|
event LogBaseComponentWalletAddressChanged(address newWallet);
|
15
17
|
event LogBaseComponentWalletTokensTransferred(address from, address to, uint256 amount);
|
16
18
|
|
17
|
-
function
|
19
|
+
function getName() external pure returns (string memory name);
|
18
20
|
|
21
|
+
// TODO remove and replace with accessmanaged target locking mechanism
|
22
|
+
function lock() external;
|
19
23
|
function unlock() external;
|
20
24
|
|
21
25
|
function getToken() external view returns (IERC20Metadata token);
|
@@ -18,8 +18,8 @@ interface IProductComponent {
|
|
18
18
|
RiskId riskId,
|
19
19
|
uint256 lifetime,
|
20
20
|
bytes memory applicationData,
|
21
|
-
|
22
|
-
|
21
|
+
NftId bundleNftId,
|
22
|
+
ReferralId referralId
|
23
23
|
) external view returns (uint256 premiumAmount);
|
24
24
|
|
25
25
|
function calculateNetPremium(
|
@@ -1,11 +1,10 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {IProductService} from "../instance/service/IProductService.sol";
|
4
|
+
import {POOL} from "../types/ObjectType.sol";
|
6
5
|
import {IPoolService} from "../instance/service/IPoolService.sol";
|
7
6
|
import {IBundleService} from "../instance/service/IBundleService.sol";
|
8
|
-
import {NftId,
|
7
|
+
import {NftId, NftIdLib} from "../types/NftId.sol";
|
9
8
|
import {Fee} from "../types/Fee.sol";
|
10
9
|
import {UFixed} from "../types/UFixed.sol";
|
11
10
|
import {IPoolComponent} from "./IPoolComponent.sol";
|
@@ -15,15 +14,13 @@ import {ISetup} from "../instance/module/ISetup.sol";
|
|
15
14
|
|
16
15
|
import {IRegistry} from "../registry/IRegistry.sol";
|
17
16
|
|
18
|
-
// import {IPool} from "../instance/module/pool/IPoolModule.sol";
|
19
|
-
import {ITreasury} from "../instance/module/ITreasury.sol";
|
20
17
|
import {ISetup} from "../instance/module/ISetup.sol";
|
21
18
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
22
19
|
|
23
20
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
24
21
|
import {Registerable} from "../shared/Registerable.sol";
|
25
22
|
|
26
|
-
contract Pool is BaseComponent, IPoolComponent {
|
23
|
+
abstract contract Pool is BaseComponent, IPoolComponent {
|
27
24
|
using NftIdLib for NftId;
|
28
25
|
|
29
26
|
bool internal _isConfirmingApplication;
|
@@ -37,10 +34,6 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
37
34
|
|
38
35
|
// may be used to interact with instance by derived contracts
|
39
36
|
IPoolService internal _poolService;
|
40
|
-
|
41
|
-
// only relevant to protect callback functions for "active" pools
|
42
|
-
IProductService private _productService;
|
43
|
-
|
44
37
|
IBundleService private _bundleService;
|
45
38
|
|
46
39
|
modifier onlyPoolService() {
|
@@ -50,13 +43,6 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
50
43
|
_;
|
51
44
|
}
|
52
45
|
|
53
|
-
modifier onlyProductService() {
|
54
|
-
require(
|
55
|
-
msg.sender == address(_productService),
|
56
|
-
"ERROR:POL-002:NOT_PRODUCT_SERVICE");
|
57
|
-
_;
|
58
|
-
}
|
59
|
-
|
60
46
|
constructor(
|
61
47
|
address registry,
|
62
48
|
NftId instanceNftId,
|
@@ -82,7 +68,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
82
68
|
_tokenHandler = new TokenHandler(token);
|
83
69
|
|
84
70
|
_poolService = _instance.getPoolService();
|
85
|
-
_productService = _instance.getProductService();
|
71
|
+
// _productService = _instance.getProductService();
|
86
72
|
_bundleService = _instance.getBundleService();
|
87
73
|
|
88
74
|
_registerInterface(type(IPoolComponent).interfaceId);
|
@@ -217,6 +203,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
217
203
|
return (
|
218
204
|
info,
|
219
205
|
abi.encode(
|
206
|
+
getName(),
|
220
207
|
ISetup.PoolSetupInfo(
|
221
208
|
_productNftId,
|
222
209
|
_tokenHandler,
|
@@ -4,17 +4,15 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
6
|
import {IRisk} from "../instance/module/IRisk.sol";
|
7
|
-
import {ITreasury} from "../instance/module/ITreasury.sol";
|
8
|
-
import {IProductService} from "../instance/service/IProductService.sol";
|
9
7
|
import {IPolicyService} from "../instance/service/IPolicyService.sol";
|
10
8
|
import {IProductComponent} from "./IProductComponent.sol";
|
11
|
-
import {NftId,
|
12
|
-
import {
|
9
|
+
import {NftId, NftIdLib} from "../types/NftId.sol";
|
10
|
+
import {PRODUCT} from "../types/ObjectType.sol";
|
13
11
|
import {ReferralId} from "../types/Referral.sol";
|
14
12
|
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
15
13
|
import {StateId} from "../types/StateId.sol";
|
16
14
|
import {Timestamp} from "../types/Timestamp.sol";
|
17
|
-
import {Fee
|
15
|
+
import {Fee} from "../types/Fee.sol";
|
18
16
|
import {BaseComponent} from "./BaseComponent.sol";
|
19
17
|
|
20
18
|
import {IRegistry} from "../registry/IRegistry.sol";
|
@@ -27,12 +25,9 @@ import {ISetup} from "../instance/module/ISetup.sol";
|
|
27
25
|
import {Pool} from "../components/Pool.sol";
|
28
26
|
import {Distribution} from "../components/Distribution.sol";
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
contract Product is BaseComponent, IProductComponent {
|
28
|
+
abstract contract Product is BaseComponent, IProductComponent {
|
33
29
|
using NftIdLib for NftId;
|
34
30
|
|
35
|
-
IProductService internal _productService;
|
36
31
|
IPolicyService internal _policyService;
|
37
32
|
Pool internal _pool;
|
38
33
|
Distribution internal _distribution;
|
@@ -55,7 +50,6 @@ contract Product is BaseComponent, IProductComponent {
|
|
55
50
|
address initialOwner
|
56
51
|
) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
|
57
52
|
// TODO add validation
|
58
|
-
_productService = _instance.getProductService();
|
59
53
|
_policyService = _instance.getPolicyService();
|
60
54
|
_pool = Pool(pool);
|
61
55
|
_distribution = Distribution(distribution);
|
@@ -76,8 +70,8 @@ contract Product is BaseComponent, IProductComponent {
|
|
76
70
|
RiskId riskId,
|
77
71
|
uint256 lifetime,
|
78
72
|
bytes memory applicationData,
|
79
|
-
|
80
|
-
|
73
|
+
NftId bundleNftId,
|
74
|
+
ReferralId referralId
|
81
75
|
)
|
82
76
|
external
|
83
77
|
view
|
@@ -203,6 +197,14 @@ contract Product is BaseComponent, IProductComponent {
|
|
203
197
|
activateAt);
|
204
198
|
}
|
205
199
|
|
200
|
+
function _close(
|
201
|
+
NftId policyNftId
|
202
|
+
)
|
203
|
+
internal
|
204
|
+
{
|
205
|
+
_policyService.close(policyNftId);
|
206
|
+
}
|
207
|
+
|
206
208
|
function getPoolNftId() external view override returns (NftId poolNftId) {
|
207
209
|
return getRegistry().getNftId(address(_pool));
|
208
210
|
}
|
@@ -256,8 +258,8 @@ contract Product is BaseComponent, IProductComponent {
|
|
256
258
|
) = _pool.getInitialInfo();
|
257
259
|
|
258
260
|
(
|
259
|
-
ISetup.PoolSetupInfo memory poolSetupInfo
|
260
|
-
) = abi.decode(poolData, (ISetup.PoolSetupInfo));
|
261
|
+
, ISetup.PoolSetupInfo memory poolSetupInfo
|
262
|
+
) = abi.decode(poolData, (string, ISetup.PoolSetupInfo));
|
261
263
|
|
262
264
|
// from DistributionComponent
|
263
265
|
(
|
@@ -266,12 +268,13 @@ contract Product is BaseComponent, IProductComponent {
|
|
266
268
|
) = _distribution.getInitialInfo();
|
267
269
|
|
268
270
|
(
|
269
|
-
ISetup.DistributionSetupInfo memory distributionSetupInfo
|
270
|
-
) = abi.decode(distributionData, (ISetup.DistributionSetupInfo));
|
271
|
+
, ISetup.DistributionSetupInfo memory distributionSetupInfo
|
272
|
+
) = abi.decode(distributionData, (string, ISetup.DistributionSetupInfo));
|
271
273
|
|
272
274
|
return (
|
273
275
|
productInfo,
|
274
276
|
abi.encode(
|
277
|
+
getName(),
|
275
278
|
ISetup.ProductSetupInfo(
|
276
279
|
_token,
|
277
280
|
_tokenHandler,
|
@@ -2,11 +2,12 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
5
|
+
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
5
6
|
|
6
7
|
import {BundleManager} from "./BundleManager.sol";
|
7
8
|
import {InstanceReader} from "./InstanceReader.sol";
|
8
9
|
|
9
|
-
import {
|
10
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
10
11
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
11
12
|
import {IPoolService} from "./service/IPoolService.sol";
|
12
13
|
import {IProductService} from "./service/IProductService.sol";
|
@@ -22,9 +23,8 @@ import {IPolicy} from "./module/IPolicy.sol";
|
|
22
23
|
import {IKeyValueStore} from "./base/IKeyValueStore.sol";
|
23
24
|
|
24
25
|
|
25
|
-
interface IInstance is IERC165, IKeyValueStore {
|
26
|
+
interface IInstance is IERC165, IKeyValueStore, IAccessManaged {
|
26
27
|
|
27
|
-
function getComponentOwnerService() external view returns (IComponentOwnerService);
|
28
28
|
function getDistributionService() external view returns (IDistributionService);
|
29
29
|
function getProductService() external view returns (IProductService);
|
30
30
|
function getPoolService() external view returns (IPoolService);
|
@@ -6,7 +6,6 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
6
|
import {BundleManager} from "./BundleManager.sol";
|
7
7
|
import {InstanceReader} from "./InstanceReader.sol";
|
8
8
|
|
9
|
-
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
10
9
|
import {IDistributionService} from "./service/IDistributionService.sol";
|
11
10
|
import {IPoolService} from "./service/IPoolService.sol";
|
12
11
|
import {IProductService} from "./service/IProductService.sol";
|
@@ -10,7 +10,7 @@ import {IRegistry} from "../registry/IRegistry.sol";
|
|
10
10
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
11
11
|
import {IBaseComponent} from "../components/IBaseComponent.sol";
|
12
12
|
|
13
|
-
import {
|
13
|
+
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
14
14
|
import {Instance} from "./Instance.sol";
|
15
15
|
import {InstanceReader} from "./InstanceReader.sol";
|
16
16
|
import {BundleManager} from "./BundleManager.sol";
|
@@ -18,17 +18,23 @@ import {BundleManager} from "./BundleManager.sol";
|
|
18
18
|
interface IInstanceService is IService {
|
19
19
|
|
20
20
|
error ErrorInstanceServiceRequestUnauhorized(address caller);
|
21
|
-
|
21
|
+
error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
|
22
|
+
error ErrorInstanceServiceComponentNotRegistered(address componentAddress);
|
23
|
+
|
22
24
|
event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
|
23
25
|
|
24
26
|
function createInstanceClone()
|
25
27
|
external
|
26
28
|
returns (
|
27
|
-
|
29
|
+
InstanceAccessManager clonedAccessManager,
|
28
30
|
Instance clonedInstance,
|
29
31
|
NftId instanceNftId,
|
30
32
|
InstanceReader clonedInstanceReader,
|
31
33
|
BundleManager clonedBundleManager
|
32
34
|
);
|
35
|
+
|
36
|
+
function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
|
37
|
+
function setTargetLocked(string memory targetName, bool locked) external;
|
38
|
+
|
33
39
|
}
|
34
40
|
|