@etherisc/gif-next 0.0.2-edf4742-498 → 0.0.2-ee7cb16-393
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +63 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +126 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +136 -10
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +88 -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/IPoolComponent.sol/IPoolComponent.json +28 -2
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +168 -11
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +144 -64
- 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 +4 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +963 -18
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +6 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +143 -139
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +55 -32
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +74 -40
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +145 -64
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +52 -32
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
- 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/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +16 -16
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +2 -2
- 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/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +167 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +40 -31
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +238 -28
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +33 -21
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1147 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +488 -0
- 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 +19 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -0
- 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 +45 -18
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +76 -20
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +29 -25
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +12 -12
- 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/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
- 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 +4 -4
- 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 +9 -9
- 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/NftIdSet.sol/LibNftIdSet.json +26 -3
- 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 +49 -8
- package/contracts/components/Distribution.sol +6 -3
- package/contracts/components/IBaseComponent.sol +6 -0
- package/contracts/components/IPoolComponent.sol +5 -1
- package/contracts/components/Pool.sol +33 -9
- package/contracts/components/Product.sol +33 -41
- package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
- package/contracts/instance/BundleManager.sol +129 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +21 -4
- package/contracts/instance/IInstanceBase.sol +26 -0
- package/contracts/instance/IInstanceService.sol +5 -3
- package/contracts/instance/Instance.sol +30 -18
- package/contracts/instance/InstanceAccessManager.sol +6 -6
- package/contracts/instance/InstanceBase.sol +41 -0
- package/contracts/instance/InstanceReader.sol +9 -0
- package/contracts/instance/InstanceService.sol +95 -32
- package/contracts/instance/InstanceServiceManager.sol +6 -5
- package/contracts/instance/ObjectManager.sol +101 -0
- package/contracts/instance/base/ComponentServiceBase.sol +12 -2
- package/contracts/instance/module/ISetup.sol +3 -1
- package/contracts/instance/service/DistributionService.sol +3 -2
- package/contracts/instance/service/DistributionServiceManager.sol +6 -5
- package/contracts/instance/service/IPoolService.sol +16 -2
- package/contracts/instance/service/IProductService.sol +6 -3
- package/contracts/instance/service/PoolService.sol +111 -17
- package/contracts/instance/service/PoolServiceManager.sol +6 -5
- package/contracts/instance/service/ProductService.sol +570 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/IRegistry.sol +2 -0
- package/contracts/registry/IRegistryService.sol +28 -11
- package/contracts/registry/Registry.sol +4 -0
- package/contracts/registry/RegistryService.sol +30 -71
- package/contracts/shared/NftOwnable.sol +2 -4
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/RoleId.sol +1 -0
- package/package.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
- package/contracts/instance/AccessManagedSimple.sol +0 -115
- package/contracts/instance/AccessManagerSimple.sol +0 -692
@@ -3,9 +3,9 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
5
|
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
7
|
+
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
6
8
|
|
7
|
-
import {AccessManagedSimple} from "./AccessManagedSimple.sol";
|
8
|
-
import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
9
9
|
import {IBundle} from "./module/IBundle.sol";
|
10
10
|
import {IPolicy} from "./module/IPolicy.sol";
|
11
11
|
import {IRisk} from "./module/IRisk.sol";
|
@@ -21,7 +21,7 @@ import {StateId, ACTIVE} from "../types/StateId.sol";
|
|
21
21
|
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
22
22
|
|
23
23
|
contract InstanceAccessManager is
|
24
|
-
|
24
|
+
AccessManagedUpgradeable
|
25
25
|
{
|
26
26
|
string public constant ADMIN_ROLE_NAME = "AdminRole";
|
27
27
|
string public constant PUBLIC_ROLE_NAME = "PublicRole";
|
@@ -76,12 +76,12 @@ contract InstanceAccessManager is
|
|
76
76
|
mapping(ShortString name => address target) internal _targetForName;
|
77
77
|
address [] internal _targets;
|
78
78
|
|
79
|
-
|
79
|
+
AccessManagerUpgradeable internal _accessManager;
|
80
80
|
|
81
81
|
constructor(address accessManager)
|
82
82
|
{
|
83
|
-
_accessManager =
|
84
|
-
|
83
|
+
_accessManager = AccessManagerUpgradeable(accessManager);
|
84
|
+
__AccessManaged_init(accessManager);
|
85
85
|
|
86
86
|
_createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
|
87
87
|
_createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
5
|
+
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
6
|
+
|
7
|
+
import {IAccess} from "./module/IAccess.sol";
|
8
|
+
import {IBundle} from "./module/IBundle.sol";
|
9
|
+
import {IPolicy} from "./module/IPolicy.sol";
|
10
|
+
import {IRisk} from "./module/IRisk.sol";
|
11
|
+
import {ISetup} from "./module/ISetup.sol";
|
12
|
+
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
13
|
+
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
14
|
+
import {IInstance} from "./IInstance.sol";
|
15
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
16
|
+
import {BundleManager} from "./BundleManager.sol";
|
17
|
+
import {NftId} from "../types/NftId.sol";
|
18
|
+
import {NumberId} from "../types/NumberId.sol";
|
19
|
+
import {ObjectType, BUNDLE, DISTRIBUTION, INSTANCE, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
20
|
+
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
21
|
+
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
22
|
+
import {StateId, ACTIVE} from "../types/StateId.sol";
|
23
|
+
import {ERC165} from "../shared/ERC165.sol";
|
24
|
+
import {Registerable} from "../shared/Registerable.sol";
|
25
|
+
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
26
|
+
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
27
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
28
|
+
import {IPoolService} from "./service/IPoolService.sol";
|
29
|
+
import {IProductService} from "./service/IProductService.sol";
|
30
|
+
import {VersionPart} from "../types/Version.sol";
|
31
|
+
import {IInstanceBase} from "./IInstanceBase.sol";
|
32
|
+
|
33
|
+
contract InstanceBase is
|
34
|
+
IInstanceBase,
|
35
|
+
KeyValueStore,
|
36
|
+
ERC165,
|
37
|
+
Registerable
|
38
|
+
{
|
39
|
+
|
40
|
+
|
41
|
+
}
|
@@ -13,6 +13,7 @@ import {Registerable} from "../shared/Registerable.sol";
|
|
13
13
|
import {RiskId} from "../types/RiskId.sol";
|
14
14
|
import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
|
15
15
|
import {Version} from "../types/Version.sol";
|
16
|
+
import {StateId} from "../types/StateId.sol";
|
16
17
|
|
17
18
|
import {IRegistry} from "../registry/IRegistry.sol";
|
18
19
|
import {IBundle} from "../instance/module/IBundle.sol";
|
@@ -81,6 +82,14 @@ contract InstanceReader {
|
|
81
82
|
}
|
82
83
|
}
|
83
84
|
|
85
|
+
function getPolicyState(NftId policyNftId)
|
86
|
+
public
|
87
|
+
view
|
88
|
+
returns (StateId state)
|
89
|
+
{
|
90
|
+
return _instance.getState(toPolicyKey(policyNftId));
|
91
|
+
}
|
92
|
+
|
84
93
|
function getRiskInfo(RiskId riskId)
|
85
94
|
public
|
86
95
|
view
|
@@ -2,12 +2,14 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
5
|
+
import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
|
5
6
|
|
6
|
-
import {
|
7
|
+
import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
|
7
8
|
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
8
9
|
import {Instance} from "./Instance.sol";
|
9
10
|
import {IInstanceService} from "./IInstanceService.sol";
|
10
11
|
import {InstanceReader} from "./InstanceReader.sol";
|
12
|
+
import {BundleManager} from "./BundleManager.sol";
|
11
13
|
import {IRegistry} from "../registry/IRegistry.sol";
|
12
14
|
import {Registry} from "../registry/Registry.sol";
|
13
15
|
import {RegistryService} from "../registry/RegistryService.sol";
|
@@ -17,7 +19,7 @@ import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
|
17
19
|
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
18
20
|
import {RoleId} from "../types/RoleId.sol";
|
19
21
|
import {VersionLib} from "../types/Version.sol";
|
20
|
-
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE} from "../types/RoleId.sol";
|
22
|
+
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE} from "../types/RoleId.sol";
|
21
23
|
|
22
24
|
contract InstanceService is Service, IInstanceService {
|
23
25
|
|
@@ -25,6 +27,7 @@ contract InstanceService is Service, IInstanceService {
|
|
25
27
|
address internal _accessManagerMaster;
|
26
28
|
address internal _instanceMaster;
|
27
29
|
address internal _instanceReaderMaster;
|
30
|
+
address internal _instanceBundleManagerMaster;
|
28
31
|
|
29
32
|
// TODO update to real hash when instance is stable
|
30
33
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
@@ -33,10 +36,11 @@ contract InstanceService is Service, IInstanceService {
|
|
33
36
|
function createInstanceClone()
|
34
37
|
external
|
35
38
|
returns (
|
36
|
-
|
39
|
+
AccessManagerUpgradeableInitializeable clonedAccessManager,
|
37
40
|
Instance clonedInstance,
|
38
|
-
NftId
|
39
|
-
InstanceReader clonedInstanceReader
|
41
|
+
NftId clonedInstanceNftId,
|
42
|
+
InstanceReader clonedInstanceReader,
|
43
|
+
BundleManager clonedBundleManager
|
40
44
|
)
|
41
45
|
{
|
42
46
|
address instanceOwner = msg.sender;
|
@@ -48,30 +52,36 @@ contract InstanceService is Service, IInstanceService {
|
|
48
52
|
// initially set the authority of the access managar to this (being the instance service).
|
49
53
|
// This will allow the instance service to bootstrap the authorizations of the instance
|
50
54
|
// and then transfer the ownership of the access manager to the instance owner once everything is setup
|
51
|
-
clonedAccessManager =
|
52
|
-
clonedAccessManager.
|
55
|
+
clonedAccessManager = AccessManagerUpgradeableInitializeable(Clones.clone(_accessManagerMaster));
|
56
|
+
clonedAccessManager.__AccessManagerUpgradeableInitializeable_init(address(this));
|
53
57
|
|
54
58
|
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
55
59
|
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
56
60
|
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
57
|
-
|
61
|
+
clonedInstanceNftId = info.nftId;
|
58
62
|
|
59
63
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
60
|
-
clonedInstanceReader.initialize(_registryAddress,
|
64
|
+
clonedInstanceReader.initialize(_registryAddress, clonedInstanceNftId);
|
65
|
+
clonedInstance.setInstanceReader(clonedInstanceReader);
|
61
66
|
|
62
|
-
|
67
|
+
clonedBundleManager = BundleManager(Clones.clone(_instanceBundleManagerMaster));
|
68
|
+
clonedBundleManager.initialize(address(clonedAccessManager), _registryAddress, clonedInstanceNftId);
|
69
|
+
clonedInstance.setBundleManager(clonedBundleManager);
|
70
|
+
|
71
|
+
// TODO amend setters with instance specific , policy manager ...
|
72
|
+
|
73
|
+
_grantInitialAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
|
63
74
|
|
64
|
-
clonedInstance.setInstanceReader(clonedInstanceReader);
|
65
|
-
|
66
75
|
// to complete setup switch instance ownership to the instance owner
|
67
76
|
// TODO: use a role less powerful than admin, maybe INSTANCE_ADMIN (does not exist yet)
|
68
77
|
clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
|
69
78
|
clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
|
70
79
|
|
71
|
-
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader),
|
80
|
+
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), clonedInstanceNftId);
|
72
81
|
}
|
73
82
|
|
74
|
-
function _grantInitialAuthorizations(
|
83
|
+
function _grantInitialAuthorizations(AccessManagerUpgradeable clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
|
84
|
+
// configure authorization for distribution service on instance
|
75
85
|
address distributionServiceAddress = _registry.getServiceAddress("DistributionService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
76
86
|
clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE().toInt(), distributionServiceAddress, 0);
|
77
87
|
bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](2);
|
@@ -82,6 +92,7 @@ contract InstanceService is Service, IInstanceService {
|
|
82
92
|
instanceDistributionServiceSelectors,
|
83
93
|
DISTRIBUTION_SERVICE_ROLE().toInt());
|
84
94
|
|
95
|
+
// configure authorization for pool service on instance
|
85
96
|
address poolServiceAddress = _registry.getServiceAddress("PoolService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
86
97
|
clonedAccessManager.grantRole(POOL_SERVICE_ROLE().toInt(), address(poolServiceAddress), 0);
|
87
98
|
bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
|
@@ -93,28 +104,75 @@ contract InstanceService is Service, IInstanceService {
|
|
93
104
|
address(clonedInstance),
|
94
105
|
instancePoolServiceSelectors,
|
95
106
|
POOL_SERVICE_ROLE().toInt());
|
107
|
+
|
108
|
+
// configure authorization for pool service on bundle manager
|
109
|
+
bytes4[] memory bundleManagerPoolServiceSelectors = new bytes4[](5);
|
110
|
+
bundleManagerPoolServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
|
111
|
+
bundleManagerPoolServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
|
112
|
+
bundleManagerPoolServiceSelectors[2] = clonedBundleManager.add.selector;
|
113
|
+
bundleManagerPoolServiceSelectors[3] = clonedBundleManager.lock.selector;
|
114
|
+
bundleManagerPoolServiceSelectors[4] = clonedBundleManager.unlock.selector;
|
115
|
+
clonedAccessManager.setTargetFunctionRole(
|
116
|
+
address(clonedBundleManager),
|
117
|
+
bundleManagerPoolServiceSelectors,
|
118
|
+
POOL_SERVICE_ROLE().toInt());
|
96
119
|
|
120
|
+
// configure authorization for product service on instance
|
121
|
+
address productServiceAddress = _registry.getServiceAddress("ProductService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
122
|
+
clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE().toInt(), address(productServiceAddress), 0);
|
123
|
+
bytes4[] memory instanceProductServiceSelectors = new bytes4[](9);
|
124
|
+
instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
|
125
|
+
instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
|
126
|
+
instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
|
127
|
+
instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
|
128
|
+
instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
|
129
|
+
instanceProductServiceSelectors[5] = clonedInstance.createPolicy.selector;
|
130
|
+
instanceProductServiceSelectors[6] = clonedInstance.updatePolicy.selector;
|
131
|
+
instanceProductServiceSelectors[7] = clonedInstance.updatePolicyState.selector;
|
132
|
+
clonedAccessManager.setTargetFunctionRole(
|
133
|
+
address(clonedInstance),
|
134
|
+
instanceProductServiceSelectors,
|
135
|
+
PRODUCT_SERVICE_ROLE().toInt());
|
97
136
|
}
|
98
137
|
|
99
|
-
function
|
100
|
-
require(
|
101
|
-
|
102
|
-
|
103
|
-
|
138
|
+
function setMasterInstance(address accessManagerAddress, address instanceAddress, address instanceReaderAddress, address bundleManagerAddress) external onlyOwner {
|
139
|
+
require( _accessManagerMaster == address(0), "ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
140
|
+
require( _instanceMaster == address(0), "ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
141
|
+
require( _instanceBundleManagerMaster == address(0), "ERROR:CRD-004:BUNDLE_MANAGER_MASTER_ALREADY_SET");
|
142
|
+
|
143
|
+
require (accessManagerAddress != address(0), "ERROR:CRD-005:ACCESS_MANAGER_ZERO");
|
144
|
+
require (instanceAddress != address(0), "ERROR:CRD-006:INSTANCE_ZERO");
|
145
|
+
require (instanceReaderAddress != address(0), "ERROR:CRD-007:INSTANCE_READER_ZERO");
|
146
|
+
require (bundleManagerAddress != address(0), "ERROR:CRD-008:BUNDLE_MANAGER_ZERO");
|
147
|
+
|
148
|
+
Instance instance = Instance(instanceAddress);
|
149
|
+
InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
|
150
|
+
BundleManager bundleManager = BundleManager(bundleManagerAddress);
|
151
|
+
|
152
|
+
require(instance.authority() == accessManagerAddress, "ERROR:CRD-009:INSTANCE_AUTHORITY_MISMATCH");
|
153
|
+
require(instanceReader.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-010:INSTANCE_READER_INSTANCE_MISMATCH");
|
154
|
+
require(bundleManager.getInstanceNftId() == instance.getNftId(), "ERROR:CRD-011:BUNDLE_MANAGER_INSTANCE_MISMATCH");
|
155
|
+
|
156
|
+
_accessManagerMaster = accessManagerAddress;
|
157
|
+
_instanceMaster = instanceAddress;
|
158
|
+
_instanceReaderMaster = instanceReaderAddress;
|
159
|
+
_instanceBundleManagerMaster = bundleManagerAddress;
|
104
160
|
}
|
105
161
|
|
106
|
-
function
|
107
|
-
require(
|
108
|
-
|
109
|
-
|
110
|
-
|
162
|
+
function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
|
163
|
+
require(_instanceReaderMaster != address(0), "ERROR:CRD-003:INSTANCE_READER_MASTER_NOT_SET");
|
164
|
+
require (instanceReaderAddress != address(0), "ERROR:CRD-012:INSTANCE_READER_ZERO");
|
165
|
+
require(instanceReaderAddress != _instanceReaderMaster, "ERROR:CRD-014:INSTANCE_READER_MASTER_SAME_AS_NEW");
|
166
|
+
|
167
|
+
InstanceReader instanceReader = InstanceReader(instanceReaderAddress);
|
168
|
+
require(instanceReader.getInstanceNftId() == Instance(_instanceMaster).getNftId(), "ERROR:CRD-015:INSTANCE_READER_INSTANCE_MISMATCH");
|
169
|
+
|
170
|
+
_instanceReaderMaster = instanceReaderAddress;
|
111
171
|
}
|
112
172
|
|
113
|
-
function
|
114
|
-
|
115
|
-
|
116
|
-
"ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
|
117
|
-
_instanceReaderMaster = instanceReaderMaster;
|
173
|
+
function upgradeInstanceReader(NftId instanceNftId) external {
|
174
|
+
// TODO: ensure this is done by instance owner
|
175
|
+
// TODO: upgrade instance reader of this instance to latest (set above here)
|
118
176
|
}
|
119
177
|
|
120
178
|
function getInstanceReaderMaster() external view returns (address) {
|
@@ -129,6 +187,10 @@ contract InstanceService is Service, IInstanceService {
|
|
129
187
|
return _accessManagerMaster;
|
130
188
|
}
|
131
189
|
|
190
|
+
function getBundleManagerMaster() external view returns (address) {
|
191
|
+
return _instanceBundleManagerMaster;
|
192
|
+
}
|
193
|
+
|
132
194
|
// From IService
|
133
195
|
function getName() public pure override(IService, Service) returns(string memory) {
|
134
196
|
return NAME;
|
@@ -160,8 +222,9 @@ contract InstanceService is Service, IInstanceService {
|
|
160
222
|
|
161
223
|
address initialOwner = address(0);
|
162
224
|
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
163
|
-
|
164
|
-
|
225
|
+
// TODO while InstanceService is not deployed in InstanceServiceManager constructor
|
226
|
+
// owner is InstanceServiceManager deployer
|
227
|
+
_initializeService(_registryAddress, owner);
|
165
228
|
|
166
229
|
_registerInterface(type(IService).interfaceId);
|
167
230
|
_registerInterface(type(IInstanceService).interfaceId);
|
@@ -171,7 +234,7 @@ contract InstanceService is Service, IInstanceService {
|
|
171
234
|
IRegistry.ObjectInfo memory instanceObjectInfo = getRegistry().getObjectInfo(instanceNftId);
|
172
235
|
address instanceAddress = instanceObjectInfo.objectAddress;
|
173
236
|
Instance instance = Instance(instanceAddress);
|
174
|
-
|
237
|
+
AccessManagerUpgradeable accessManager = AccessManagerUpgradeable(instance.authority());
|
175
238
|
(bool isMember, uint32 executionDelay) = accessManager.hasRole(role.toInt(), account);
|
176
239
|
if (executionDelay > 0) {
|
177
240
|
return false;
|
@@ -31,14 +31,15 @@ contract InstanceServiceManager is ProxyManager {
|
|
31
31
|
Registry registry = Registry(registryAddress);
|
32
32
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
33
33
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
34
|
-
|
35
|
-
registryService.registerService(_instanceService);
|
34
|
+
// TODO this must have a role or own nft to register service
|
35
|
+
//registryService.registerService(_instanceService);
|
36
36
|
// RegistryService registryService = _instanceService.getRegistryService();
|
37
37
|
|
38
|
+
// TODO no nft to link yet
|
38
39
|
// link ownership of instance service manager ot nft owner of instance service
|
39
|
-
_linkToNftOwnable(
|
40
|
-
|
41
|
-
|
40
|
+
//_linkToNftOwnable(
|
41
|
+
// address(registryAddress),
|
42
|
+
// address(_instanceService));
|
42
43
|
|
43
44
|
// implies that after this constructor call only upgrade functionality is available
|
44
45
|
_isDeployed = true;
|
@@ -0,0 +1,101 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Cloneable} from "./Cloneable.sol";
|
5
|
+
|
6
|
+
import {IInstance} from "./IInstance.sol";
|
7
|
+
import {INSTANCE} from "../types/ObjectType.sol";
|
8
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
9
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
10
|
+
import {LibNftIdSet} from "../types/NftIdSet.sol";
|
11
|
+
import {NftId} from "../types/NftId.sol";
|
12
|
+
|
13
|
+
contract ObjectManager is
|
14
|
+
Cloneable
|
15
|
+
{
|
16
|
+
|
17
|
+
event LogObjectManagerInitialized(NftId instanceNftId, address instanceReader);
|
18
|
+
|
19
|
+
error ErrorObjectManagerNftIdInvalid(NftId instanceNftId);
|
20
|
+
error ErrorObjectManagerAlreadyAdded(NftId componentNftId, NftId objectNftId);
|
21
|
+
|
22
|
+
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _activeObjects;
|
23
|
+
mapping(NftId compnentNftId => LibNftIdSet.Set objects) internal _allObjects;
|
24
|
+
NftId internal _instanceNftId;
|
25
|
+
InstanceReader internal _instanceReader;
|
26
|
+
|
27
|
+
constructor() Cloneable() {
|
28
|
+
_instanceReader = InstanceReader(address(0));
|
29
|
+
}
|
30
|
+
|
31
|
+
/// @dev call to initialize MUST be made in the same transaction as cloning of the contract
|
32
|
+
function initialize(
|
33
|
+
address authority,
|
34
|
+
address registry,
|
35
|
+
NftId instanceNftId
|
36
|
+
)
|
37
|
+
external
|
38
|
+
{
|
39
|
+
initialize(authority, registry);
|
40
|
+
|
41
|
+
// check/handle instance nft id/instance reader
|
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;
|
50
|
+
|
51
|
+
emit LogObjectManagerInitialized(instanceNftId, address(_instanceReader));
|
52
|
+
}
|
53
|
+
|
54
|
+
function getInstanceReader() external view returns (InstanceReader) {
|
55
|
+
return _instanceReader;
|
56
|
+
}
|
57
|
+
|
58
|
+
function getInstanceNftId() external view returns (NftId) {
|
59
|
+
return _instanceNftId;
|
60
|
+
}
|
61
|
+
|
62
|
+
function _add(NftId componentNftId, NftId objectNftId) internal {
|
63
|
+
LibNftIdSet.Set storage allSet = _allObjects[componentNftId];
|
64
|
+
LibNftIdSet.Set storage activeSet = _activeObjects[componentNftId];
|
65
|
+
|
66
|
+
LibNftIdSet.add(allSet, objectNftId);
|
67
|
+
LibNftIdSet.add(activeSet, objectNftId);
|
68
|
+
}
|
69
|
+
|
70
|
+
function _activate(NftId componentNftId, NftId objectNftId) internal {
|
71
|
+
LibNftIdSet.add(_activeObjects[componentNftId], objectNftId);
|
72
|
+
}
|
73
|
+
|
74
|
+
function _deactivate(NftId componentNftId, NftId objectNftId) internal {
|
75
|
+
LibNftIdSet.remove(_activeObjects[componentNftId], objectNftId);
|
76
|
+
}
|
77
|
+
|
78
|
+
function _objects(NftId componentNftId) internal view returns (uint256) {
|
79
|
+
return LibNftIdSet.size(_allObjects[componentNftId]);
|
80
|
+
}
|
81
|
+
|
82
|
+
function _contains(NftId componentNftId, NftId objectNftId) internal view returns (bool) {
|
83
|
+
return LibNftIdSet.contains(_allObjects[componentNftId], objectNftId);
|
84
|
+
}
|
85
|
+
|
86
|
+
function _getObject(NftId componentNftId, uint256 idx) internal view returns (NftId) {
|
87
|
+
return LibNftIdSet.getElementAt(_allObjects[componentNftId], idx);
|
88
|
+
}
|
89
|
+
|
90
|
+
function _activeObjs(NftId componentNftId) internal view returns (uint256) {
|
91
|
+
return LibNftIdSet.size(_activeObjects[componentNftId]);
|
92
|
+
}
|
93
|
+
|
94
|
+
function _isActive(NftId componentNftId, NftId objectNftId) internal view returns (bool) {
|
95
|
+
return LibNftIdSet.contains(_activeObjects[componentNftId], objectNftId);
|
96
|
+
}
|
97
|
+
|
98
|
+
function _getActiveObject(NftId componentNftId, uint256 idx) internal view returns (NftId) {
|
99
|
+
return LibNftIdSet.getElementAt(_activeObjects[componentNftId], idx);
|
100
|
+
}
|
101
|
+
}
|
@@ -9,6 +9,7 @@ import {NftId, NftIdLib} from "../../types/NftId.sol";
|
|
9
9
|
import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../types/RoleId.sol";
|
10
10
|
|
11
11
|
import {BaseComponent} from "../../components/BaseComponent.sol";
|
12
|
+
import {Product} from "../../components/Product.sol";
|
12
13
|
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
13
14
|
import {Service} from "../../shared/Service.sol";
|
14
15
|
import {InstanceService} from "../InstanceService.sol";
|
@@ -35,6 +36,13 @@ abstract contract ComponentServiceBase is Service {
|
|
35
36
|
_;
|
36
37
|
}
|
37
38
|
|
39
|
+
/// @dev modifier to check if caller is a registered service
|
40
|
+
modifier onlyService() {
|
41
|
+
address caller = msg.sender;
|
42
|
+
require(getRegistry().isRegisteredService(caller), "ERROR_NOT_SERVICE");
|
43
|
+
_;
|
44
|
+
}
|
45
|
+
|
38
46
|
function _initializeService(
|
39
47
|
address registry,
|
40
48
|
address initialOwner
|
@@ -80,8 +88,10 @@ abstract contract ComponentServiceBase is Service {
|
|
80
88
|
}
|
81
89
|
|
82
90
|
componentNftId = objInfo.nftId;
|
83
|
-
|
84
|
-
|
91
|
+
{
|
92
|
+
IInstance instance = _getInstance(objInfo);
|
93
|
+
_finalizeComponentRegistration(componentNftId, initialObjData, instance);
|
94
|
+
}
|
85
95
|
}
|
86
96
|
|
87
97
|
function _finalizeComponentRegistration(NftId componentNftId, bytes memory initialObjData, IInstance instance) internal virtual;
|
@@ -5,7 +5,6 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
5
5
|
|
6
6
|
import {Fee} from "../../types/Fee.sol";
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
|
-
import {LibNftIdSet} from "../../types/NftIdSet.sol";
|
9
8
|
import {UFixed} from "../../types/UFixed.sol";
|
10
9
|
import {TokenHandler} from "../../shared/TokenHandler.sol";
|
11
10
|
|
@@ -21,6 +20,8 @@ interface ISetup {
|
|
21
20
|
Fee poolFee; // pool fee on net premium
|
22
21
|
Fee stakingFee; // pool fee on staked capital from investor
|
23
22
|
Fee performanceFee; // pool fee on profits from capital investors
|
23
|
+
bool isIntercepting; // intercepts nft transfers (for products)
|
24
|
+
address wallet;
|
24
25
|
}
|
25
26
|
|
26
27
|
struct DistributionSetupInfo {
|
@@ -39,6 +40,7 @@ interface ISetup {
|
|
39
40
|
Fee stakingFee; // pool fee on staked capital from investor
|
40
41
|
Fee performanceFee; // pool fee on profits from capital investors
|
41
42
|
bool isIntercepting; // intercepts nft transfers (for bundles)
|
43
|
+
bool isConfirmingApplication; // confirms applications before they are underwritten
|
42
44
|
address wallet;
|
43
45
|
}
|
44
46
|
}
|
@@ -49,8 +49,9 @@ contract DistributionService is
|
|
49
49
|
{
|
50
50
|
address initialOwner = address(0);
|
51
51
|
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
52
|
-
|
53
|
-
|
52
|
+
// TODO while DistributionService is not deployed in DistributionServiceManager constructor
|
53
|
+
// owner is DistributionServiceManager deployer
|
54
|
+
_initializeService(_registryAddress, owner);
|
54
55
|
|
55
56
|
_registerInterface(type(IService).interfaceId);
|
56
57
|
_registerInterface(type(IDistributionService).interfaceId);
|
@@ -29,13 +29,14 @@ contract DistributionServiceManager is ProxyManager {
|
|
29
29
|
Registry registry = Registry(registryAddress);
|
30
30
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
31
31
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
32
|
+
// TODO this must have a role or own nft to register service
|
33
|
+
//registryService.registerService(_distributionService);
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
// TODO no nft to link yet
|
35
36
|
// link ownership of instance service manager ot nft owner of instance service
|
36
|
-
_linkToNftOwnable(
|
37
|
-
|
38
|
-
|
37
|
+
//_linkToNftOwnable(
|
38
|
+
// address(registryAddress),
|
39
|
+
// address(_distributionService));
|
39
40
|
|
40
41
|
// implies that after this constructor call only upgrade functionality is available
|
41
42
|
_isDeployed = true;
|
@@ -3,9 +3,14 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
+
import {StateId} from "../../types/StateId.sol";
|
6
7
|
import {IService} from "../../shared/IService.sol";
|
8
|
+
import {IBundle} from "../module/IBundle.sol";
|
9
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
10
|
|
8
11
|
interface IPoolService is IService {
|
12
|
+
error ErrorIPoolServiceInsufficientAllowance(address bundleOwner, address tokenHandlerAddress, uint256 amount);
|
13
|
+
|
9
14
|
function setFees(
|
10
15
|
Fee memory poolFee,
|
11
16
|
Fee memory stakingFee,
|
@@ -25,13 +30,22 @@ interface IPoolService is IService {
|
|
25
30
|
Fee memory fee
|
26
31
|
) external;
|
27
32
|
|
33
|
+
function updateBundle(NftId instanceNftId, NftId bundleNftId, IBundle.BundleInfo memory bundleInfo, StateId state) external;
|
34
|
+
|
35
|
+
function underwritePolicy(IInstance instanceNftId,
|
36
|
+
NftId policyNftId,
|
37
|
+
NftId bundleNftId,
|
38
|
+
uint256 collateralAmount,
|
39
|
+
uint256 netPremium
|
40
|
+
) external;
|
41
|
+
|
28
42
|
// function fundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
29
43
|
|
30
44
|
// function defundBundle(NftId bundleNftId, uint256 amount) external returns(uint256 netAmount);
|
31
45
|
|
32
|
-
|
46
|
+
function lockBundle(NftId bundleNftId) external;
|
33
47
|
|
34
|
-
|
48
|
+
function unlockBundle(NftId bundleNftId) external;
|
35
49
|
|
36
50
|
// function closeBundle(NftId bundleNftId) external;
|
37
51
|
}
|
@@ -13,6 +13,9 @@ import {UFixed} from "../../types/UFixed.sol";
|
|
13
13
|
import {Fee} from "../../types/Fee.sol";
|
14
14
|
|
15
15
|
interface IProductService is IService {
|
16
|
+
|
17
|
+
error ErrorIProductServiceInsufficientAllowance(address customer, address tokenHandlerAddress, uint256 amount);
|
18
|
+
|
16
19
|
function setFees(
|
17
20
|
Fee memory productFee,
|
18
21
|
Fee memory processingFee
|
@@ -24,15 +27,15 @@ interface IProductService is IService {
|
|
24
27
|
) external;
|
25
28
|
|
26
29
|
|
27
|
-
function
|
30
|
+
function updateRisk(
|
28
31
|
RiskId riskId,
|
29
|
-
|
32
|
+
bytes memory data
|
30
33
|
) external;
|
31
34
|
|
32
35
|
|
33
36
|
function updateRiskState(
|
34
37
|
RiskId riskId,
|
35
|
-
StateId
|
38
|
+
StateId newState
|
36
39
|
) external;
|
37
40
|
|
38
41
|
|