@etherisc/gif-next 0.0.2-bca36d7-613 → 0.0.2-be8b468-276
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +13 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +75 -15
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +13 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +52 -0
- 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/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +29 -13
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +39 -18
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- 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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +0 -13
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- 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 +93 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +98 -98
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -47
- 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 +46 -14
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +27 -11
- 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/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/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 +18 -18
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +641 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +428 -0
- 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/IProductService.sol/IProductService.dbg.json +1 -1
- 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 +309 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -19
- 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 +258 -24
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +20 -44
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +49 -28
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
- 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 +4 -4
- 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/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- 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 +11 -11
- 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/TestVersion.sol/TestVersion.json +2 -2
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
- 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/StateId.sol/StateIdLib.json +2 -2
- 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/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/BaseComponent.sol +8 -3
- package/contracts/components/Distribution.sol +13 -13
- package/contracts/components/IBaseComponent.sol +1 -0
- package/contracts/components/IDistributionComponent.sol +3 -0
- package/contracts/components/Pool.sol +1 -2
- package/contracts/components/Product.sol +1 -1
- package/contracts/instance/AccessManagedSimple.sol +1 -8
- package/contracts/instance/IInstance.sol +6 -1
- package/contracts/instance/Instance.sol +6 -5
- package/contracts/instance/InstanceAccessManager.sol +1 -1
- package/contracts/instance/InstanceService.sol +25 -1
- package/contracts/instance/base/ComponentServiceBase.sol +1 -11
- package/contracts/instance/service/DistributionService.sol +96 -0
- package/contracts/instance/service/DistributionServiceManager.sol +53 -0
- package/contracts/registry/IRegistry.sol +38 -2
- package/contracts/registry/IRegistryService.sol +0 -2
- package/contracts/registry/Registry.sol +94 -28
- package/contracts/registry/RegistryService.sol +2 -47
- package/contracts/registry/RegistryServiceManager.sol +21 -5
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ERC165.sol +6 -2
- package/contracts/shared/Registerable.sol +1 -0
- package/contracts/types/RoleId.sol +6 -0
- package/contracts/types/StateId.sol +4 -0
- package/contracts/types/Version.sol +4 -1
- package/package.json +1 -1
@@ -11,13 +11,15 @@ import {IInstance} from "../instance/IInstance.sol";
|
|
11
11
|
import {IInstance} from "../instance/IInstance.sol";
|
12
12
|
import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
|
13
13
|
import {IBaseComponent} from "./IBaseComponent.sol";
|
14
|
-
import {NftId} from "../types/NftId.sol";
|
14
|
+
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
15
15
|
import {ObjectType} from "../types/ObjectType.sol";
|
16
16
|
|
17
17
|
abstract contract BaseComponent is
|
18
18
|
Registerable,
|
19
19
|
IBaseComponent
|
20
20
|
{
|
21
|
+
using NftIdLib for NftId;
|
22
|
+
|
21
23
|
IComponentOwnerService internal _componentOwnerService;
|
22
24
|
|
23
25
|
address internal _deployer;
|
@@ -29,7 +31,6 @@ abstract contract BaseComponent is
|
|
29
31
|
constructor(
|
30
32
|
address registry,
|
31
33
|
NftId instanceNftId,
|
32
|
-
NftId productNftId,
|
33
34
|
address token,
|
34
35
|
ObjectType componentType,
|
35
36
|
bool isInterceptor,
|
@@ -49,7 +50,6 @@ abstract contract BaseComponent is
|
|
49
50
|
_componentOwnerService = _instance.getComponentOwnerService();
|
50
51
|
_wallet = address(this);
|
51
52
|
_token = IERC20Metadata(token);
|
52
|
-
_productNftId = productNftId;
|
53
53
|
|
54
54
|
_registerInterface(type(IBaseComponent).interfaceId);
|
55
55
|
}
|
@@ -80,6 +80,11 @@ abstract contract BaseComponent is
|
|
80
80
|
return _instance;
|
81
81
|
}
|
82
82
|
|
83
|
+
function setProductNftId(NftId productNftId) public override onlyOwner {
|
84
|
+
require(_productNftId.eq(zeroNftId()), "product nft id already set");
|
85
|
+
_productNftId = productNftId;
|
86
|
+
}
|
87
|
+
|
83
88
|
function getProductNftId() public view override returns (NftId productNftId) {
|
84
89
|
return _productNftId;
|
85
90
|
}
|
@@ -38,20 +38,19 @@ contract Distribution is
|
|
38
38
|
constructor(
|
39
39
|
address registry,
|
40
40
|
NftId instanceNftId,
|
41
|
-
NftId productNftId,
|
42
41
|
// TODO refactor into tokenNftId
|
43
42
|
address token,
|
44
43
|
bool verifying,
|
45
44
|
Fee memory distributionFee,
|
46
45
|
address initialOwner
|
47
46
|
)
|
48
|
-
BaseComponent(registry, instanceNftId,
|
47
|
+
BaseComponent(registry, instanceNftId, token, DISTRIBUTION(), true, initialOwner)
|
49
48
|
{
|
50
49
|
_isVerifying = verifying;
|
51
50
|
_initialDistributionFee = distributionFee;
|
52
51
|
|
52
|
+
_distributionService = _instance.getDistributionService();
|
53
53
|
// TODO: reactivate when services are available again
|
54
|
-
// _distributionService = _instance.getDistributionService();
|
55
54
|
// _productService = _instance.getProductService();
|
56
55
|
|
57
56
|
_registerInterface(type(IDistributionComponent).interfaceId);
|
@@ -122,20 +121,21 @@ contract Distribution is
|
|
122
121
|
return false;
|
123
122
|
}
|
124
123
|
|
125
|
-
function
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
}
|
124
|
+
function getInitialSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
125
|
+
return ISetup.DistributionSetupInfo(
|
126
|
+
_productNftId,
|
127
|
+
TokenHandler(address(_token)),
|
128
|
+
_initialDistributionFee,
|
129
|
+
_isVerifying,
|
130
|
+
address(0) // TODO: use correct wallet
|
131
|
+
);
|
132
|
+
}
|
135
133
|
|
134
|
+
function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
136
135
|
InstanceReader reader = _instance.getInstanceReader();
|
137
136
|
return reader.getDistributionSetupInfo(getNftId());
|
138
137
|
}
|
138
|
+
|
139
139
|
|
140
140
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
141
141
|
function isVerifying() external view returns (bool verifying) {
|
@@ -4,9 +4,12 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {Fee} from "../types/Fee.sol";
|
5
5
|
import {ReferralId} from "../types/Referral.sol";
|
6
6
|
import {NftId} from "../types/NftId.sol";
|
7
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
7
8
|
|
8
9
|
interface IDistributionComponent {
|
9
10
|
|
11
|
+
function getInitialSetupInfo() external view returns (ISetup.DistributionSetupInfo memory setupInfo);
|
12
|
+
|
10
13
|
function setFees(
|
11
14
|
Fee memory distributionFee
|
12
15
|
) external;
|
@@ -55,7 +55,6 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
55
55
|
constructor(
|
56
56
|
address registry,
|
57
57
|
NftId instanceNftId,
|
58
|
-
NftId productNftId,
|
59
58
|
// TODO refactor into tokenNftId
|
60
59
|
address token,
|
61
60
|
bool isInterceptor,
|
@@ -66,7 +65,7 @@ contract Pool is BaseComponent, IPoolComponent {
|
|
66
65
|
Fee memory performanceFee,
|
67
66
|
address initialOwner
|
68
67
|
)
|
69
|
-
BaseComponent(registry, instanceNftId,
|
68
|
+
BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
|
70
69
|
{
|
71
70
|
_isVerifying = verifying;
|
72
71
|
// TODO add validation
|
@@ -49,7 +49,7 @@ contract Product is BaseComponent, IProductComponent {
|
|
49
49
|
Fee memory productFee,
|
50
50
|
Fee memory processingFee,
|
51
51
|
address initialOwner
|
52
|
-
) BaseComponent(registry, instanceNftid,
|
52
|
+
) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
|
53
53
|
// TODO add validation
|
54
54
|
// TODO: reactivate when services are available again
|
55
55
|
// _productService = _instance.getProductService();
|
@@ -24,14 +24,7 @@ abstract contract AccessManagedSimple is Context, IAccessManaged {
|
|
24
24
|
|
25
25
|
bool private _consumingSchedule;
|
26
26
|
|
27
|
-
|
28
|
-
* @dev Initializes the contract connected to an initial authority.
|
29
|
-
*/
|
30
|
-
constructor(address initialAuthority) {
|
31
|
-
initialize(initialAuthority);
|
32
|
-
}
|
33
|
-
|
34
|
-
function initialize(address initialAuthority) public {
|
27
|
+
function initializeAccessManagedSimple(address initialAuthority) internal {
|
35
28
|
require(!_initialized, "AccessManaged: already initialized");
|
36
29
|
_setAuthority(initialAuthority);
|
37
30
|
_initialized = true;
|
@@ -11,17 +11,22 @@ import {IPoolService} from "./service/IPoolService.sol";
|
|
11
11
|
import {IProductService} from "./service/IProductService.sol";
|
12
12
|
import {ISetup} from "./module/ISetup.sol";
|
13
13
|
import {NftId} from "../types/NftId.sol";
|
14
|
+
import {StateId} from "../types/StateId.sol";
|
14
15
|
|
15
16
|
interface IInstance is IERC165 {
|
16
17
|
|
17
18
|
function getComponentOwnerService() external view returns (IComponentOwnerService);
|
18
19
|
// TODO: renable these when we have the services
|
19
|
-
|
20
|
+
function getDistributionService() external view returns (IDistributionService);
|
20
21
|
// function getProductService() external view returns (IProductService);
|
21
22
|
// function getPoolService() external view returns (IPoolService);
|
22
23
|
|
23
24
|
function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
|
25
|
+
|
24
26
|
function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
|
27
|
+
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
|
28
|
+
function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;
|
29
|
+
|
25
30
|
function createPoolSetup(NftId distributionNftId, ISetup.PoolSetupInfo memory setup) external;
|
26
31
|
|
27
32
|
function getInstanceReader() external view returns (InstanceReader);
|
@@ -25,6 +25,7 @@ import {ERC165} from "../shared/ERC165.sol";
|
|
25
25
|
import {Registerable} from "../shared/Registerable.sol";
|
26
26
|
import {ComponentOwnerService} from "./service/ComponentOwnerService.sol";
|
27
27
|
import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
|
28
|
+
import {IDistributionService} from "./service/IDistributionService.sol";
|
28
29
|
import {VersionPart} from "../types/Version.sol";
|
29
30
|
|
30
31
|
contract Instance is
|
@@ -53,7 +54,6 @@ contract Instance is
|
|
53
54
|
InstanceReader internal _instanceReader;
|
54
55
|
|
55
56
|
constructor(address accessManagerAddress, address registryAddress, NftId registryNftId)
|
56
|
-
AccessManagedSimple(accessManagerAddress)
|
57
57
|
{
|
58
58
|
initialize(accessManagerAddress, registryAddress, registryNftId, msg.sender);
|
59
59
|
}
|
@@ -61,6 +61,8 @@ contract Instance is
|
|
61
61
|
function initialize(address accessManagerAddress, address registryAddress, NftId registryNftId, address initialOwner) public {
|
62
62
|
require(!_initialized, "Contract instance has already been initialized");
|
63
63
|
|
64
|
+
initializeAccessManagedSimple(accessManagerAddress);
|
65
|
+
|
64
66
|
_accessManager = AccessManagerSimple(accessManagerAddress);
|
65
67
|
_createRole(RoleIdLib.toRoleId(ADMIN_ROLE), "AdminRole", false, false);
|
66
68
|
_createRole(RoleIdLib.toRoleId(PUBLIC_ROLE), "PublicRole", false, false);
|
@@ -416,10 +418,9 @@ contract Instance is
|
|
416
418
|
return ComponentOwnerService(_registry.getServiceAddress("ComponentOwnerService", VersionPart.wrap(3)));
|
417
419
|
}
|
418
420
|
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
// }
|
421
|
+
function getDistributionService() external view returns (IDistributionService) {
|
422
|
+
return IDistributionService(_registry.getServiceAddress("DistributionService", VersionPart.wrap(3)));
|
423
|
+
}
|
423
424
|
|
424
425
|
// TODO reactivate when services are available
|
425
426
|
// function getProductService() external view returns (IProductService) {
|
@@ -79,9 +79,9 @@ contract InstanceAccessManager is
|
|
79
79
|
AccessManagerSimple internal _accessManager;
|
80
80
|
|
81
81
|
constructor(address accessManager)
|
82
|
-
AccessManagedSimple(accessManager)
|
83
82
|
{
|
84
83
|
_accessManager = AccessManagerSimple(accessManager);
|
84
|
+
initializeAccessManagedSimple(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);
|
@@ -16,6 +16,7 @@ import {IService} from "../shared/IService.sol";
|
|
16
16
|
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
17
17
|
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
18
18
|
import {VersionLib} from "../types/Version.sol";
|
19
|
+
import {ADMIN_ROLE, INSTANCE_SERVICE_ROLE} from "../types/RoleId.sol";
|
19
20
|
|
20
21
|
contract InstanceService is Service, IInstanceService {
|
21
22
|
|
@@ -37,13 +38,15 @@ contract InstanceService is Service, IInstanceService {
|
|
37
38
|
InstanceReader clonedInstanceReader
|
38
39
|
)
|
39
40
|
{
|
41
|
+
address instanceOwner = msg.sender;
|
40
42
|
Registry registry = Registry(_registryAddress);
|
41
43
|
NftId registryNftId = registry.getNftId(_registryAddress);
|
42
44
|
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
43
45
|
RegistryService registryService = RegistryService(registryServiceAddress);
|
44
46
|
|
45
47
|
clonedAccessManager = AccessManagerSimple(Clones.clone(_accessManagerMaster));
|
46
|
-
|
48
|
+
// initial as this
|
49
|
+
clonedAccessManager.initialize(address(this));
|
47
50
|
|
48
51
|
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
49
52
|
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
@@ -53,9 +56,30 @@ contract InstanceService is Service, IInstanceService {
|
|
53
56
|
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
54
57
|
clonedInstanceReader.initialize(_registryAddress, instanceNftId);
|
55
58
|
|
59
|
+
_grantAuthorizations(clonedAccessManager, clonedInstance);
|
60
|
+
|
61
|
+
clonedInstance.setInstanceReader(clonedInstanceReader);
|
62
|
+
|
63
|
+
// switch instance ownership to instance owner
|
64
|
+
clonedAccessManager.grantRole(ADMIN_ROLE().toInt(), instanceOwner, 0);
|
65
|
+
clonedAccessManager.revokeRole(ADMIN_ROLE().toInt(), address(this));
|
66
|
+
|
56
67
|
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), instanceNftId);
|
57
68
|
}
|
58
69
|
|
70
|
+
function _grantAuthorizations(AccessManagerSimple clonedAccessManager, Instance clonedInstance) internal {
|
71
|
+
// grant initial permissions (if any)
|
72
|
+
|
73
|
+
// example
|
74
|
+
// clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE().toInt(), address(this), 0);
|
75
|
+
// bytes4[] memory instanceSetInstanceReaderSelectors = new bytes4[](1);
|
76
|
+
// instanceSetInstanceReaderSelectors[0] = clonedInstance.setInstanceReader.selector;
|
77
|
+
// clonedAccessManager.setTargetFunctionRole(
|
78
|
+
// address(clonedInstance),
|
79
|
+
// instanceSetInstanceReaderSelectors,
|
80
|
+
// INSTANCE_SERVICE_ROLE().toInt());
|
81
|
+
}
|
82
|
+
|
59
83
|
function setAccessManagerMaster(address accessManagerMaster) external {
|
60
84
|
require(
|
61
85
|
_accessManagerMaster == address(0),
|
@@ -12,16 +12,6 @@ import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
|
|
12
12
|
|
13
13
|
abstract contract ComponentServiceBase is Service {
|
14
14
|
|
15
|
-
constructor(
|
16
|
-
address registry,
|
17
|
-
NftId registryNftId,
|
18
|
-
address initialOwner
|
19
|
-
)
|
20
|
-
{
|
21
|
-
_initializeService(registry, initialOwner);
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
15
|
function _getAndVerifyComponentInfoAndInstance(
|
26
16
|
ObjectType objectType
|
27
17
|
)
|
@@ -32,7 +22,7 @@ abstract contract ComponentServiceBase is Service {
|
|
32
22
|
IInstance instance
|
33
23
|
)
|
34
24
|
{
|
35
|
-
NftId componentNftId =
|
25
|
+
NftId componentNftId = _registry.getNftId(msg.sender);
|
36
26
|
require(componentNftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
37
27
|
|
38
28
|
info = getRegistry().getObjectInfo(componentNftId);
|
@@ -0,0 +1,96 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../../registry/IRegistry.sol";
|
5
|
+
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
6
|
+
import {IInstance} from "../../instance/IInstance.sol";
|
7
|
+
import {InstanceReader} from "../../instance/InstanceReader.sol";
|
8
|
+
import {ISetup} from "../../instance/module/ISetup.sol";
|
9
|
+
import {ITreasury} from "../../instance/module/ITreasury.sol";
|
10
|
+
|
11
|
+
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
12
|
+
import {Fee} from "../../types/Fee.sol";
|
13
|
+
import {KEEP_STATE} from "../../types/StateId.sol";
|
14
|
+
import {DISTRIBUTION} from "../../types/ObjectType.sol";
|
15
|
+
import {Version, VersionLib} from "../../types/Version.sol";
|
16
|
+
|
17
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
18
|
+
import {Versionable} from "../../shared/Versionable.sol";
|
19
|
+
|
20
|
+
import {IService} from "../../shared/IService.sol";
|
21
|
+
import {Service} from "../../shared/Service.sol";
|
22
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
23
|
+
import {IDistributionService} from "./IDistributionService.sol";
|
24
|
+
import {Distribution} from "../../components/Distribution.sol";
|
25
|
+
|
26
|
+
string constant DISTRIBUTION_SERVICE_NAME = "DistributionService";
|
27
|
+
|
28
|
+
contract DistributionService is
|
29
|
+
ComponentServiceBase,
|
30
|
+
IDistributionService
|
31
|
+
{
|
32
|
+
using NftIdLib for NftId;
|
33
|
+
|
34
|
+
string public constant NAME = "DistributionService";
|
35
|
+
|
36
|
+
address internal _registryAddress;
|
37
|
+
|
38
|
+
function _initialize(
|
39
|
+
address owner,
|
40
|
+
bytes memory data
|
41
|
+
)
|
42
|
+
internal
|
43
|
+
initializer
|
44
|
+
virtual override
|
45
|
+
{
|
46
|
+
address initialOwner = address(0);
|
47
|
+
(_registryAddress, initialOwner) = abi.decode(data, (address, address));
|
48
|
+
|
49
|
+
// IRegistry registry = IRegistry(_registryAddress);
|
50
|
+
|
51
|
+
_initializeService(_registryAddress, initialOwner);
|
52
|
+
|
53
|
+
_registerInterface(type(IService).interfaceId);
|
54
|
+
_registerInterface(type(IDistributionService).interfaceId);
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
function getName() public pure override(IService, Service) returns(string memory name) {
|
59
|
+
return NAME;
|
60
|
+
}
|
61
|
+
|
62
|
+
function register(address distributionComponentAddress, address componentOwner)
|
63
|
+
external
|
64
|
+
// TODO restricted
|
65
|
+
returns (NftId distributionNftId)
|
66
|
+
{
|
67
|
+
// TODO validate permission of componentOwner
|
68
|
+
Distribution distribution = Distribution(distributionComponentAddress);
|
69
|
+
IRegistryService registryService = getRegistryService();
|
70
|
+
(IRegistry.ObjectInfo memory distributionObjInfo, ) = registryService.registerDistribution(
|
71
|
+
distribution,
|
72
|
+
componentOwner
|
73
|
+
);
|
74
|
+
distributionNftId = distributionObjInfo.nftId;
|
75
|
+
|
76
|
+
ISetup.DistributionSetupInfo memory initialSetup = distribution.getInitialSetupInfo();
|
77
|
+
IInstance instance = distribution.getInstance();
|
78
|
+
instance.createDistributionSetup(distributionNftId, initialSetup);
|
79
|
+
}
|
80
|
+
|
81
|
+
function setFees(
|
82
|
+
Fee memory distributionFee
|
83
|
+
)
|
84
|
+
external
|
85
|
+
override
|
86
|
+
{
|
87
|
+
(IRegistry.ObjectInfo memory info , IInstance instance) = _getAndVerifyComponentInfoAndInstance(DISTRIBUTION());
|
88
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
89
|
+
NftId distributionNftId = info.nftId;
|
90
|
+
|
91
|
+
ISetup.DistributionSetupInfo memory distSetupInfo = instanceReader.getDistributionSetupInfo(distributionNftId);
|
92
|
+
distSetupInfo.distributionFee = distributionFee;
|
93
|
+
|
94
|
+
instance.updateDistributionSetup(distributionNftId, distSetupInfo, KEEP_STATE());
|
95
|
+
}
|
96
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {IVersionable} from "../../shared/IVersionable.sol";
|
5
|
+
import {ProxyManager} from "../../shared/ProxyManager.sol";
|
6
|
+
import {DistributionService} from "./DistributionService.sol";
|
7
|
+
import {Registry} from "../../registry/Registry.sol";
|
8
|
+
import {RegistryService} from "../../registry/RegistryService.sol";
|
9
|
+
import {VersionLib} from "../../types/Version.sol";
|
10
|
+
|
11
|
+
contract DistributionServiceManager is ProxyManager {
|
12
|
+
|
13
|
+
DistributionService private _distributionService;
|
14
|
+
|
15
|
+
/// @dev initializes proxy manager with distribution service implementation and deploys instance
|
16
|
+
constructor(
|
17
|
+
address registryAddress
|
18
|
+
)
|
19
|
+
ProxyManager()
|
20
|
+
{
|
21
|
+
DistributionService distSrv = new DistributionService();
|
22
|
+
bytes memory data = abi.encode(registryAddress, address(this));
|
23
|
+
IVersionable versionable = deploy(
|
24
|
+
address(distSrv),
|
25
|
+
data);
|
26
|
+
|
27
|
+
_distributionService = DistributionService(address(versionable));
|
28
|
+
|
29
|
+
Registry registry = Registry(registryAddress);
|
30
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
31
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
32
|
+
|
33
|
+
registryService.registerService(_distributionService);
|
34
|
+
|
35
|
+
// link ownership of instance service manager ot nft owner of instance service
|
36
|
+
_linkToNftOwnable(
|
37
|
+
address(registryAddress),
|
38
|
+
address(_distributionService));
|
39
|
+
|
40
|
+
// implies that after this constructor call only upgrade functionality is available
|
41
|
+
_isDeployed = true;
|
42
|
+
}
|
43
|
+
|
44
|
+
//--- view functions ----------------------------------------------------//
|
45
|
+
function getDistributionService()
|
46
|
+
external
|
47
|
+
view
|
48
|
+
returns (DistributionService distributionService)
|
49
|
+
{
|
50
|
+
return _distributionService;
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
@@ -10,10 +10,33 @@ import {VersionPart} from "../types/Version.sol";
|
|
10
10
|
|
11
11
|
interface IRegistry is IERC165 {
|
12
12
|
|
13
|
+
event LogInitialMajorVersionSet(VersionPart majorVersion);
|
14
|
+
event LogMajorVersionSet(VersionPart majorVersionMax);
|
13
15
|
event LogRegistration(ObjectInfo info);
|
14
|
-
|
16
|
+
event LogTokenStateSet(address token, VersionPart majorVersion, bool active);
|
15
17
|
event LogServiceNameRegistration(string serviceName, VersionPart majorVersion);
|
16
18
|
|
19
|
+
// supported versions
|
20
|
+
error MajorVersionMaxIncreaseInvalid(VersionPart newMajorVersionMax, VersionPart existingMaxMajorVersion);
|
21
|
+
|
22
|
+
// token whitelisting
|
23
|
+
error TokenNotRegistered(address token);
|
24
|
+
error NotToken(address token);
|
25
|
+
error TokenMajorVersionInvalid(VersionPart majorVersion);
|
26
|
+
|
27
|
+
// register
|
28
|
+
error NotRegistryService();
|
29
|
+
error ZeroParentAddress();
|
30
|
+
error ContractAlreadyRegistered(address objectAddress);
|
31
|
+
error InvalidServiceVersion(VersionPart majorVersion);
|
32
|
+
error ServiceNameAlreadyRegistered(string name, VersionPart majorVersion);
|
33
|
+
|
34
|
+
// approve
|
35
|
+
error NotOwner(address account);
|
36
|
+
error NotRegisteredContract(NftId registrarNftId);
|
37
|
+
error NotService(NftId registrarNftId);
|
38
|
+
error InvalidTypesCombination(ObjectType objectType, ObjectType parentType);
|
39
|
+
|
17
40
|
|
18
41
|
struct ObjectInfo {
|
19
42
|
NftId nftId;
|
@@ -26,11 +49,22 @@ interface IRegistry is IERC165 {
|
|
26
49
|
}// TODO delete nftId and initialOwner(if not used) from struct
|
27
50
|
// TODO strong disagree, keep nftId there (lets keep get object info return object consistent)
|
28
51
|
|
52
|
+
function setMajorVersion(VersionPart newMajorVersionMax) external;
|
53
|
+
|
29
54
|
function register(ObjectInfo memory info) external returns (NftId nftId);
|
30
|
-
|
55
|
+
|
56
|
+
function setTokenActive(address token, VersionPart majorVersion, bool active) external;
|
57
|
+
|
58
|
+
function getMajorVersionMin() external view returns (VersionPart);
|
59
|
+
|
60
|
+
function getMajorVersionMax() external view returns (VersionPart);
|
61
|
+
|
62
|
+
function getMajorVersion() external view returns (VersionPart);
|
31
63
|
|
32
64
|
function getObjectCount() external view returns (uint256);
|
33
65
|
|
66
|
+
function getNftId() external view returns (NftId nftId);
|
67
|
+
|
34
68
|
function getNftId(address objectAddress) external view returns (NftId nftId);
|
35
69
|
|
36
70
|
function ownerOf(NftId nftId) external view returns (address);
|
@@ -45,6 +79,8 @@ interface IRegistry is IERC165 {
|
|
45
79
|
|
46
80
|
function isRegistered(address contractAddress) external view returns (bool);
|
47
81
|
|
82
|
+
function isTokenActive(address token, VersionPart majorVersion) external view returns (bool);
|
83
|
+
|
48
84
|
function getServiceName(NftId nftId) external view returns (string memory name);
|
49
85
|
|
50
86
|
function getServiceAddress(
|
@@ -12,8 +12,6 @@ import {IBaseComponent} from "../components/IBaseComponent.sol";
|
|
12
12
|
|
13
13
|
interface IRegistryService is IService {
|
14
14
|
|
15
|
-
function registerToken(address tokenAddress) external returns(NftId nftId);
|
16
|
-
|
17
15
|
function registerService(IService service) external returns(IRegistry.ObjectInfo memory info, bytes memory data);
|
18
16
|
|
19
17
|
function registerInstance(IRegisterable instance)
|