@etherisc/gif-next 0.0.2-9d3eab3-323 → 0.0.2-9dd1984-554
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/{BaseComponent.sol/BaseComponent.json → Component.sol/Component.json} +51 -6
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +51 -104
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/components/{IBaseComponent.sol/IBaseComponent.json → IComponent.sol/IComponent.json} +51 -6
- 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 +51 -132
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +56 -120
- 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 +75 -1
- 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 -229
- 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/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +98 -24
- 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 +219 -48
- 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 +131 -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 +51 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +107 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +308 -60
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +48 -20
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +131 -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 +131 -38
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -9
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +72 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +3 -3
- 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 +85 -59
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +33 -23
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -17
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +13 -13
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +84 -101
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +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 +2 -2
- 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/Component.sol +177 -0
- package/contracts/components/Distribution.sol +5 -14
- package/contracts/components/{IBaseComponent.sol → IComponent.sol} +12 -6
- package/contracts/components/IProductComponent.sol +2 -2
- package/contracts/components/Pool.sol +7 -20
- package/contracts/components/Product.sol +21 -18
- package/contracts/instance/IInstance.sol +3 -3
- package/contracts/instance/IInstanceBase.sol +0 -1
- package/contracts/instance/IInstanceService.sol +10 -4
- package/contracts/instance/Instance.sol +6 -208
- package/contracts/instance/InstanceAccessManager.sol +92 -77
- package/contracts/instance/InstanceBase.sol +0 -2
- package/contracts/instance/InstanceService.sol +117 -71
- package/contracts/instance/InstanceServiceManager.sol +5 -9
- package/contracts/instance/base/ComponentService.sol +133 -0
- package/contracts/instance/base/IInstanceBase.sol +0 -2
- package/contracts/instance/module/IAccess.sol +27 -17
- package/contracts/instance/service/BundleService.sol +38 -5
- package/contracts/instance/service/BundleServiceManager.sol +5 -9
- package/contracts/instance/service/DistributionService.sol +33 -32
- package/contracts/instance/service/DistributionServiceManager.sol +6 -10
- package/contracts/instance/service/IBundleService.sol +5 -6
- package/contracts/instance/service/IPolicyService.sol +7 -0
- package/contracts/instance/service/PolicyService.sol +62 -27
- package/contracts/instance/service/PoolService.sol +46 -26
- package/contracts/instance/service/PoolServiceManager.sol +5 -9
- package/contracts/instance/service/ProductService.sol +104 -31
- package/contracts/registry/IRegistry.sol +17 -3
- package/contracts/registry/IRegistryService.sol +5 -5
- package/contracts/registry/Registry.sol +30 -19
- package/contracts/registry/RegistryAccessManager.sol +27 -27
- package/contracts/registry/RegistryService.sol +22 -32
- package/contracts/registry/RegistryServiceManager.sol +4 -2
- package/contracts/registry/ReleaseManager.sol +87 -123
- package/contracts/registry/TokenRegistry.sol +4 -4
- package/contracts/shared/IRegisterable.sol +0 -2
- package/contracts/shared/NftOwnable.sol +2 -0
- package/contracts/shared/Service.sol +4 -2
- package/contracts/types/RoleId.sol +6 -7
- package/package.json +1 -1
- 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/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -814
- 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/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +0 -442
- package/contracts/components/BaseComponent.sol +0 -132
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/base/ComponentServiceBase.sol +0 -72
- package/contracts/instance/service/ComponentOwnerService.sol +0 -315
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -7,8 +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 {
|
11
|
-
import {SERVICE} from "../types/ObjectType.sol";
|
10
|
+
import {REGISTRY} from "../types/ObjectType.sol";
|
12
11
|
|
13
12
|
contract InstanceServiceManager is ProxyManager {
|
14
13
|
|
@@ -29,10 +28,10 @@ contract InstanceServiceManager is ProxyManager {
|
|
29
28
|
|
30
29
|
_instanceService = InstanceService(address(versionable));
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
//
|
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);
|
36
35
|
//registryService.registerService(_instanceService);
|
37
36
|
// RegistryService registryService = _instanceService.getRegistryService();
|
38
37
|
|
@@ -41,9 +40,6 @@ contract InstanceServiceManager is ProxyManager {
|
|
41
40
|
//_linkToNftOwnable(
|
42
41
|
// address(registryAddress),
|
43
42
|
// address(_instanceService));
|
44
|
-
|
45
|
-
// implies that after this constructor call only upgrade functionality is available
|
46
|
-
_isDeployed = true;
|
47
43
|
}
|
48
44
|
|
49
45
|
//--- view functions ----------------------------------------------------//
|
@@ -0,0 +1,133 @@
|
|
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
|
+
returns (
|
53
|
+
IComponent component,
|
54
|
+
address owner,
|
55
|
+
IInstance instance,
|
56
|
+
NftId instanceNftId
|
57
|
+
)
|
58
|
+
{
|
59
|
+
// component may only be registerd by initial owner of component
|
60
|
+
owner = msg.sender;
|
61
|
+
|
62
|
+
// check component has not already been registerd
|
63
|
+
NftId compoentNftId = _registry.getNftId(componentAddress);
|
64
|
+
if(compoentNftId.gtz()) {
|
65
|
+
revert ErrorComponentServiceAlreadyRegistered(componentAddress, compoentNftId);
|
66
|
+
}
|
67
|
+
|
68
|
+
// check this is a component
|
69
|
+
component = IComponent(componentAddress);
|
70
|
+
if(!component.supportsInterface(type(IComponent).interfaceId)) {
|
71
|
+
revert ErrorComponentServiceNotComponent(componentAddress);
|
72
|
+
}
|
73
|
+
|
74
|
+
// check component is of required type
|
75
|
+
(IRegistry.ObjectInfo memory componentInfo, ) = component.getInitialInfo();
|
76
|
+
if(componentInfo.objectType != requiredType) {
|
77
|
+
revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
|
78
|
+
}
|
79
|
+
|
80
|
+
// check msg.sender is component owner
|
81
|
+
address initialOwner = componentInfo.initialOwner;
|
82
|
+
if(owner != initialOwner) {
|
83
|
+
revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
|
84
|
+
}
|
85
|
+
|
86
|
+
// check instance has assigned required role to owner
|
87
|
+
instanceNftId = componentInfo.parentNftId;
|
88
|
+
instance = _getInstance(instanceNftId);
|
89
|
+
bool hasRole = getInstanceService().hasRole(
|
90
|
+
owner,
|
91
|
+
requiredRole,
|
92
|
+
address(instance));
|
93
|
+
|
94
|
+
if(!hasRole) {
|
95
|
+
revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
// internal view functions
|
100
|
+
|
101
|
+
function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
|
102
|
+
IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
|
103
|
+
return IInstance(instanceInfo.objectAddress);
|
104
|
+
}
|
105
|
+
|
106
|
+
function _getAndVerifyComponentInfoAndInstance(
|
107
|
+
//address component,
|
108
|
+
ObjectType expectedType
|
109
|
+
)
|
110
|
+
internal
|
111
|
+
view
|
112
|
+
returns(
|
113
|
+
IRegistry.ObjectInfo memory info,
|
114
|
+
IInstance instance
|
115
|
+
)
|
116
|
+
{
|
117
|
+
IRegistry registry = getRegistry();
|
118
|
+
//TODO redundant check -> just check type
|
119
|
+
//NftId componentNftId = registry.getNftId(component);
|
120
|
+
//require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
121
|
+
|
122
|
+
info = registry.getObjectInfo(msg.sender);
|
123
|
+
require(info.objectType == expectedType, "OBJECT_TYPE_INVALID");
|
124
|
+
|
125
|
+
address instanceAddress = registry.getObjectInfo(info.parentNftId).objectAddress;
|
126
|
+
instance = IInstance(instanceAddress);
|
127
|
+
|
128
|
+
InstanceAccessManager accessManager = InstanceAccessManager(instance.authority());
|
129
|
+
if (accessManager.isTargetLocked(info.objectAddress)) {
|
130
|
+
revert IAccess.ErrorIAccessTargetLocked(info.objectAddress);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
@@ -6,7 +6,6 @@ import {StateId} from "../../types/StateId.sol";
|
|
6
6
|
|
7
7
|
import {IKeyValueStore} from "./IKeyValueStore.sol";
|
8
8
|
|
9
|
-
import {IComponentOwnerService} from "../service/IComponentOwnerService.sol";
|
10
9
|
import {IDistributionService} from "../service/IDistributionService.sol";
|
11
10
|
import {IProductService} from "../service/IProductService.sol";
|
12
11
|
import {IPoolService} from "../service/IPoolService.sol";
|
@@ -16,7 +15,6 @@ interface IInstanceBase {
|
|
16
15
|
function updateState(Key32 key, StateId state) external;
|
17
16
|
function getState(Key32 key) external view returns (StateId state);
|
18
17
|
|
19
|
-
function getComponentOwnerService() external view returns(IComponentOwnerService);
|
20
18
|
function getDistributionService() external view returns(IDistributionService);
|
21
19
|
function getProductService() external view returns(IProductService service);
|
22
20
|
function getPoolService() external view returns(IPoolService service);
|
@@ -5,34 +5,44 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
|
|
5
5
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
6
|
|
7
7
|
import {RoleId} from "../../types/RoleId.sol";
|
8
|
+
import {Timestamp} from "../../types/Timestamp.sol";
|
8
9
|
|
9
10
|
interface IAccess {
|
11
|
+
|
10
12
|
struct RoleInfo {
|
11
13
|
ShortString name;
|
12
14
|
bool isCustom;
|
15
|
+
bool isLocked;
|
16
|
+
Timestamp createdAt;
|
17
|
+
Timestamp updatedAt;
|
13
18
|
}
|
14
19
|
|
15
20
|
struct TargetInfo {
|
16
21
|
ShortString name;
|
17
22
|
bool isCustom;
|
23
|
+
bool isLocked;
|
24
|
+
Timestamp createdAt;
|
25
|
+
Timestamp updatedAt;
|
18
26
|
}
|
19
27
|
|
20
|
-
error
|
21
|
-
error
|
22
|
-
error
|
23
|
-
error
|
24
|
-
error
|
25
|
-
|
26
|
-
error
|
27
|
-
error
|
28
|
-
error
|
29
|
-
error
|
30
|
-
error
|
31
|
-
error
|
32
|
-
error
|
33
|
-
error ErrorRoleInvalidUpdate(RoleId roleId, bool isCustom);
|
34
|
-
error ErrorGrantNonexstentRole(RoleId roleId);
|
35
|
-
error ErrorRevokeNonexstentRole(RoleId roleId);
|
36
|
-
error ErrorRenounceNonexstentRole(RoleId roleId);
|
28
|
+
error ErrorIAccessRoleIdInvalid(RoleId roleId);
|
29
|
+
error ErrorIAccessRoleIdTooBig(RoleId roleId);
|
30
|
+
error ErrorIAccessRoleIdTooSmall(RoleId roleId);
|
31
|
+
error ErrorIAccessRoleIdAlreadyExists(RoleId roleId, ShortString name);
|
32
|
+
error ErrorIAccessRoleIdNotActive(RoleId roleId);
|
33
|
+
error ErrorIAccessRoleNameEmpty(RoleId roleId);
|
34
|
+
error ErrorIAccessRoleNameNotUnique(RoleId roleId, ShortString name);
|
35
|
+
error ErrorIAccessRoleInvalidUpdate(RoleId roleId, bool isCustom);
|
36
|
+
error ErrorIAccessRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
|
37
|
+
error ErrorIAccessSetLockedForNonexstentRole(RoleId roleId);
|
38
|
+
error ErrorIAccessGrantNonexstentRole(RoleId roleId);
|
39
|
+
error ErrorIAccessRevokeNonexstentRole(RoleId roleId);
|
40
|
+
error ErrorIAccessRenounceNonexstentRole(RoleId roleId);
|
37
41
|
|
42
|
+
error ErrorIAccessTargetAddressZero();
|
43
|
+
error ErrorIAccessTargetAlreadyExists(address target, ShortString name);
|
44
|
+
error ErrorIAccessTargetNameEmpty(address target);
|
45
|
+
error ErrorIAccessTargetNameExists(address target, address existingTarget, ShortString name);
|
46
|
+
error ErrorIAccessSetLockedForNonexstentTarget(address target);
|
47
|
+
error ErrorIAccessTargetLocked(address target);
|
38
48
|
}
|
@@ -24,17 +24,16 @@ import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
|
24
24
|
import {IService} from "../../shared/IService.sol";
|
25
25
|
import {Service} from "../../shared/Service.sol";
|
26
26
|
import {BundleManager} from "../BundleManager.sol";
|
27
|
-
import {
|
27
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
28
28
|
import {IBundleService} from "./IBundleService.sol";
|
29
29
|
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
30
30
|
import {InstanceService} from "../InstanceService.sol";
|
31
31
|
import {InstanceReader} from "../InstanceReader.sol";
|
32
|
-
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
33
32
|
|
34
33
|
string constant BUNDLE_SERVICE_NAME = "BundleService";
|
35
34
|
|
36
35
|
contract BundleService is
|
37
|
-
|
36
|
+
ComponentService,
|
38
37
|
IBundleService
|
39
38
|
{
|
40
39
|
using NftIdLib for NftId;
|
@@ -186,6 +185,40 @@ contract BundleService is
|
|
186
185
|
linkPolicy(instance, policyNftId);
|
187
186
|
}
|
188
187
|
|
188
|
+
function increaseBalance(IInstance instance,
|
189
|
+
NftId bundleNftId,
|
190
|
+
uint256 amount
|
191
|
+
)
|
192
|
+
external
|
193
|
+
onlyService
|
194
|
+
{
|
195
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
196
|
+
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
197
|
+
|
198
|
+
bundleInfo.balanceAmount += amount;
|
199
|
+
|
200
|
+
instance.updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
|
201
|
+
}
|
202
|
+
|
203
|
+
function closePolicy(IInstance instance,
|
204
|
+
NftId policyNftId,
|
205
|
+
NftId bundleNftId,
|
206
|
+
uint256 collateralAmount
|
207
|
+
)
|
208
|
+
external
|
209
|
+
onlyService
|
210
|
+
{
|
211
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
212
|
+
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
213
|
+
|
214
|
+
// lock collateral
|
215
|
+
bundleInfo.lockedAmount -= collateralAmount;
|
216
|
+
|
217
|
+
instance.updateBundle(bundleNftId, bundleInfo, KEEP_STATE());
|
218
|
+
|
219
|
+
unlinkPolicy(instance, policyNftId);
|
220
|
+
}
|
221
|
+
|
189
222
|
/// @dev links policy to bundle
|
190
223
|
function linkPolicy(IInstance instance, NftId policyNftId)
|
191
224
|
internal
|
@@ -219,8 +252,8 @@ contract BundleService is
|
|
219
252
|
}
|
220
253
|
|
221
254
|
// ensure policy is closeable
|
222
|
-
if (
|
223
|
-
|
255
|
+
if ( TimestampLib.blockTimestamp() < policyInfo.expiredAt
|
256
|
+
&& policyInfo.payoutAmount < policyInfo.sumInsuredAmount)
|
224
257
|
{
|
225
258
|
revert BundleManager.ErrorBundleManagerPolicyNotCloseable(policyNftId);
|
226
259
|
}
|
@@ -6,8 +6,7 @@ import {ProxyManager} from "../../shared/ProxyManager.sol";
|
|
6
6
|
import {BundleService} from "./BundleService.sol";
|
7
7
|
import {Registry} from "../../registry/Registry.sol";
|
8
8
|
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
-
import {
|
10
|
-
import {ObjectType, SERVICE} from "../../types/ObjectType.sol";
|
9
|
+
import {ObjectType, REGISTRY} from "../../types/ObjectType.sol";
|
11
10
|
|
12
11
|
contract BundleServiceManager is ProxyManager {
|
13
12
|
|
@@ -27,10 +26,10 @@ contract BundleServiceManager is ProxyManager {
|
|
27
26
|
|
28
27
|
_bundleService = BundleService(address(versionable));
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
//
|
29
|
+
// TODO `this` must have a role or own nft to register service
|
30
|
+
//Registry registry = Registry(registryAddress);
|
31
|
+
//address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _bundleService.getMajorVersion());
|
32
|
+
//RegistryService registryService = RegistryService(registryServiceAddress);
|
34
33
|
//registryService.registerService(_poolService);
|
35
34
|
|
36
35
|
// TODO no nft to link yet
|
@@ -38,9 +37,6 @@ contract BundleServiceManager is ProxyManager {
|
|
38
37
|
//_linkToNftOwnable(
|
39
38
|
// address(registryAddress),
|
40
39
|
// address(_poolService));
|
41
|
-
|
42
|
-
// implies that after this constructor call only upgrade functionality is available
|
43
|
-
_isDeployed = true;
|
44
40
|
}
|
45
41
|
|
46
42
|
//--- view functions ----------------------------------------------------//
|
@@ -2,11 +2,10 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
-
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
6
5
|
import {IInstance} from "../../instance/IInstance.sol";
|
6
|
+
import {InstanceAccessManager} from "../InstanceAccessManager.sol";
|
7
7
|
import {InstanceReader} from "../../instance/InstanceReader.sol";
|
8
8
|
import {ISetup} from "../../instance/module/ISetup.sol";
|
9
|
-
import {ITreasury} from "../../instance/module/ITreasury.sol";
|
10
9
|
|
11
10
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
12
11
|
import {Fee} from "../../types/Fee.sol";
|
@@ -20,17 +19,14 @@ import {Versionable} from "../../shared/Versionable.sol";
|
|
20
19
|
|
21
20
|
import {IService} from "../../shared/IService.sol";
|
22
21
|
import {Service} from "../../shared/Service.sol";
|
23
|
-
import {
|
24
|
-
import {IDistributionService} from "./IDistributionService.sol";
|
25
|
-
import {Distribution} from "../../components/Distribution.sol";
|
22
|
+
import {ComponentService} from "../base/ComponentService.sol";
|
26
23
|
import {InstanceService} from "../InstanceService.sol";
|
27
|
-
import {
|
28
|
-
import {
|
29
|
-
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
24
|
+
import {IDistributionService} from "./IDistributionService.sol";
|
25
|
+
import {IComponent} from "../../components/IComponent.sol";
|
30
26
|
|
31
27
|
|
32
28
|
contract DistributionService is
|
33
|
-
|
29
|
+
ComponentService,
|
34
30
|
IDistributionService
|
35
31
|
{
|
36
32
|
using NftIdLib for NftId;
|
@@ -63,34 +59,39 @@ contract DistributionService is
|
|
63
59
|
external
|
64
60
|
returns(NftId distributionNftId)
|
65
61
|
{
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
62
|
+
(
|
63
|
+
IComponent distribution,
|
64
|
+
address owner,
|
65
|
+
IInstance instance,
|
66
|
+
NftId instanceNftId
|
67
|
+
) = _checkComponentForRegistration(
|
68
|
+
distributionAddress,
|
69
|
+
DISTRIBUTION(),
|
70
|
+
DISTRIBUTION_OWNER_ROLE());
|
71
|
+
|
72
|
+
(
|
73
|
+
IRegistry.ObjectInfo memory distributionInfo,
|
74
|
+
bytes memory data
|
75
|
+
) = getRegistryService().registerDistribution(distribution, owner);
|
76
|
+
distribution.linkToRegisteredNftId();
|
77
|
+
distributionNftId = distributionInfo.nftId;
|
78
|
+
|
79
|
+
(
|
80
|
+
string memory name,
|
81
|
+
ISetup.DistributionSetupInfo memory initialSetup
|
82
|
+
) = _decodeAndVerifyDistributionData(data);
|
86
83
|
instance.createDistributionSetup(distributionNftId, initialSetup);
|
84
|
+
|
85
|
+
getInstanceService().createTarget(instanceNftId, distributionAddress, name);
|
87
86
|
}
|
88
87
|
|
89
|
-
function
|
88
|
+
function _decodeAndVerifyDistributionData(bytes memory data)
|
89
|
+
internal
|
90
|
+
returns(string memory name, ISetup.DistributionSetupInfo memory setup)
|
90
91
|
{
|
91
|
-
setup = abi.decode(
|
92
|
+
(name, setup) = abi.decode(
|
92
93
|
data,
|
93
|
-
(ISetup.DistributionSetupInfo)
|
94
|
+
(string, ISetup.DistributionSetupInfo)
|
94
95
|
);
|
95
96
|
|
96
97
|
// TODO add checks if applicable
|
@@ -6,8 +6,7 @@ import {ProxyManager} from "../../shared/ProxyManager.sol";
|
|
6
6
|
import {DistributionService} from "./DistributionService.sol";
|
7
7
|
import {Registry} from "../../registry/Registry.sol";
|
8
8
|
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
-
import {
|
10
|
-
import {SERVICE} from "../../types/ObjectType.sol";
|
9
|
+
import {REGISTRY} from "../../types/ObjectType.sol";
|
11
10
|
|
12
11
|
contract DistributionServiceManager is ProxyManager {
|
13
12
|
|
@@ -26,11 +25,11 @@ contract DistributionServiceManager is ProxyManager {
|
|
26
25
|
data);
|
27
26
|
|
28
27
|
_distributionService = DistributionService(address(versionable));
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
//
|
28
|
+
|
29
|
+
// TODO `thi` must have a role or own nft to register service
|
30
|
+
//Registry registry = Registry(registryAddress);
|
31
|
+
//address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _distributionService.getMajorVersion());
|
32
|
+
//RegistryService registryService = RegistryService(registryServiceAddress);
|
34
33
|
//registryService.registerService(_distributionService);
|
35
34
|
|
36
35
|
// TODO no nft to link yet
|
@@ -38,9 +37,6 @@ contract DistributionServiceManager is ProxyManager {
|
|
38
37
|
//_linkToNftOwnable(
|
39
38
|
// address(registryAddress),
|
40
39
|
// address(_distributionService));
|
41
|
-
|
42
|
-
// implies that after this constructor call only upgrade functionality is available
|
43
|
-
_isDeployed = true;
|
44
40
|
}
|
45
41
|
|
46
42
|
//--- view functions ----------------------------------------------------//
|
@@ -26,12 +26,11 @@ interface IBundleService is IService {
|
|
26
26
|
|
27
27
|
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
28
28
|
|
29
|
-
function underwritePolicy(IInstance instanceNftId,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
) external;
|
29
|
+
function underwritePolicy(IInstance instanceNftId, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount, uint256 netPremium) external;
|
30
|
+
|
31
|
+
function increaseBalance(IInstance instance, NftId bundleNftId, uint256 amount) external;
|
32
|
+
|
33
|
+
function closePolicy(IInstance instance, NftId policyNftId, NftId bundleNftId, uint256 collateralAmount) external;
|
35
34
|
|
36
35
|
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
37
36
|
|
@@ -15,6 +15,13 @@ import {Fee} from "../../types/Fee.sol";
|
|
15
15
|
interface IPolicyService is IService {
|
16
16
|
|
17
17
|
error ErrorIPolicyServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
18
|
+
error ErrorIPolicyServicePremiumAlreadyPaid(NftId policyNftId, uint256 premiumPaidAmount);
|
19
|
+
error ErrorIPolicyServicePolicyNotActivated(NftId policyNftId);
|
20
|
+
error ErrorIPolicyServicePolicyAlreadyClosed(NftId policyNftId);
|
21
|
+
error ErrorIPolicyServicePolicyNotActive(NftId policyNftId, StateId state);
|
22
|
+
error ErrorIPolicyServicePremiumNotFullyPaid(NftId policyNftId, uint256 premiumAmount, uint256 premiumPaidAmount);
|
23
|
+
error ErrorIPolicyServiceOpenClaims(NftId policyNftId, uint16 openClaimsCount);
|
24
|
+
error ErrorIPolicyServicePolicyHasNotExpired(NftId policyNftId, Timestamp expiredAt);
|
18
25
|
|
19
26
|
function calculatePremium(
|
20
27
|
RiskId riskId,
|