@etherisc/gif-next 0.0.2-b9e9dc3-713 → 0.0.2-bca36d7-613
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +2 -2
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- 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/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +2 -2
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +2 -2
- 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/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +13 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +1 -1
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +15 -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/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +59 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +138 -81
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +45 -32
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +63 -37
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +80 -28
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +17 -9
- 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 +18 -18
- 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/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- 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 +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +8 -8
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +5 -5
- 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 +4 -0
- package/artifacts/contracts/{instance/base → shared}/IService.sol/IService.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 +4 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → shared/Service.sol/Service.json} +2 -2
- 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/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/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/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/instance/AccessManagedSimple.sol +8 -0
- package/contracts/instance/AccessManagerSimple.sol +10 -0
- package/contracts/instance/IInstanceService.sol +21 -8
- package/contracts/instance/Instance.sol +12 -6
- package/contracts/instance/InstanceReader.sol +10 -0
- package/contracts/instance/InstanceService.sol +57 -21
- package/contracts/instance/base/ComponentServiceBase.sol +3 -3
- package/contracts/instance/service/ComponentOwnerService.sol +5 -5
- package/contracts/instance/service/IComponentOwnerService.sol +1 -1
- package/contracts/instance/service/IDistributionService.sol +1 -1
- package/contracts/instance/service/IPoolService.sol +1 -1
- package/contracts/instance/service/IProductService.sol +1 -1
- package/contracts/registry/IRegistry.sol +1 -0
- package/contracts/registry/IRegistryService.sol +8 -8
- package/contracts/registry/Registry.sol +1 -1
- package/contracts/registry/RegistryService.sol +12 -8
- package/contracts/{instance/base → shared}/IService.sol +3 -3
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +54 -0
- package/contracts/test/TestService.sol +3 -5
- package/package.json +1 -1
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/contracts/instance/base/ServiceBase.sol +0 -44
@@ -7,18 +7,22 @@ import {AccessManagerSimple} from "./AccessManagerSimple.sol";
|
|
7
7
|
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
|
8
8
|
import {Instance} from "./Instance.sol";
|
9
9
|
import {IInstanceService} from "./IInstanceService.sol";
|
10
|
-
import {
|
10
|
+
import {InstanceReader} from "./InstanceReader.sol";
|
11
11
|
import {IRegistry} from "../registry/IRegistry.sol";
|
12
|
-
import {
|
12
|
+
import {Registry} from "../registry/Registry.sol";
|
13
|
+
import {RegistryService} from "../registry/RegistryService.sol";
|
14
|
+
import {Service} from "../../contracts/shared/Service.sol";
|
15
|
+
import {IService} from "../shared/IService.sol";
|
13
16
|
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
14
17
|
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
18
|
+
import {VersionLib} from "../types/Version.sol";
|
15
19
|
|
16
|
-
contract InstanceService is
|
20
|
+
contract InstanceService is Service, IInstanceService {
|
17
21
|
|
18
22
|
address internal _registryAddress;
|
19
23
|
address internal _accessManagerMaster;
|
20
|
-
address internal _instanceAccessManagerMaster;
|
21
24
|
address internal _instanceMaster;
|
25
|
+
address internal _instanceReaderMaster;
|
22
26
|
|
23
27
|
// TODO update to real hash when instance is stable
|
24
28
|
bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
|
@@ -27,34 +31,66 @@ contract InstanceService is ServiceBase, IInstanceService {
|
|
27
31
|
function createInstanceClone()
|
28
32
|
external
|
29
33
|
returns (
|
30
|
-
AccessManagerSimple
|
31
|
-
|
32
|
-
|
34
|
+
AccessManagerSimple clonedAccessManager,
|
35
|
+
Instance clonedInstance,
|
36
|
+
NftId instanceNftId,
|
37
|
+
InstanceReader clonedInstanceReader
|
33
38
|
)
|
34
39
|
{
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
Registry registry = Registry(_registryAddress);
|
41
|
+
NftId registryNftId = registry.getNftId(_registryAddress);
|
42
|
+
address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
|
43
|
+
RegistryService registryService = RegistryService(registryServiceAddress);
|
44
|
+
|
45
|
+
clonedAccessManager = AccessManagerSimple(Clones.clone(_accessManagerMaster));
|
46
|
+
clonedAccessManager.initialize(msg.sender);
|
47
|
+
|
48
|
+
clonedInstance = Instance(Clones.clone(_instanceMaster));
|
49
|
+
clonedInstance.initialize(address(clonedAccessManager), _registryAddress, registryNftId, msg.sender);
|
50
|
+
( IRegistry.ObjectInfo memory info, ) = registryService.registerInstance(clonedInstance);
|
51
|
+
instanceNftId = info.nftId;
|
52
|
+
|
53
|
+
clonedInstanceReader = InstanceReader(Clones.clone(address(_instanceReaderMaster)));
|
54
|
+
clonedInstanceReader.initialize(_registryAddress, instanceNftId);
|
55
|
+
|
56
|
+
emit LogInstanceCloned(address(clonedAccessManager), address(clonedInstance), address(clonedInstanceReader), instanceNftId);
|
38
57
|
}
|
39
58
|
|
40
|
-
function setAccessManagerMaster(address
|
41
|
-
|
59
|
+
function setAccessManagerMaster(address accessManagerMaster) external {
|
60
|
+
require(
|
61
|
+
_accessManagerMaster == address(0),
|
62
|
+
"ERROR:CRD-001:ACCESS_MANAGER_MASTER_ALREADY_SET");
|
63
|
+
_accessManagerMaster = accessManagerMaster;
|
42
64
|
}
|
43
65
|
|
44
|
-
function
|
45
|
-
|
66
|
+
function setInstanceMaster(address instanceMaster) external {
|
67
|
+
require(
|
68
|
+
_instanceMaster == address(0),
|
69
|
+
"ERROR:CRD-002:INSTANCE_MASTER_ALREADY_SET");
|
70
|
+
_instanceMaster = instanceMaster;
|
46
71
|
}
|
47
72
|
|
48
|
-
function
|
49
|
-
|
73
|
+
function setInstanceReaderMaster(address instanceReaderMaster) external {
|
74
|
+
require(
|
75
|
+
_instanceReaderMaster == address(0),
|
76
|
+
"ERROR:CRD-003:INSTANCE_READER_MASTER_ALREADY_SET");
|
77
|
+
_instanceReaderMaster = instanceReaderMaster;
|
50
78
|
}
|
51
79
|
|
52
|
-
function
|
53
|
-
|
54
|
-
|
80
|
+
function getInstanceReaderMaster() external view returns (address) {
|
81
|
+
return _instanceReaderMaster;
|
82
|
+
}
|
83
|
+
|
84
|
+
function getInstanceMaster() external view returns (address) {
|
85
|
+
return _instanceMaster;
|
86
|
+
}
|
87
|
+
|
88
|
+
function getAccessManagerMaster() external view returns (address) {
|
89
|
+
return _accessManagerMaster;
|
90
|
+
}
|
55
91
|
|
56
92
|
// From IService
|
57
|
-
function getName() public pure override(IService,
|
93
|
+
function getName() public pure override(IService, Service) returns(string memory) {
|
58
94
|
return NAME;
|
59
95
|
}
|
60
96
|
|
@@ -89,7 +125,7 @@ contract InstanceService is ServiceBase, IInstanceService {
|
|
89
125
|
IRegistry registry = IRegistry(_registryAddress);
|
90
126
|
NftId registryNftId = registry.getNftId(_registryAddress);
|
91
127
|
|
92
|
-
|
128
|
+
_initializeService(_registryAddress, initialOwner);
|
93
129
|
|
94
130
|
_registerInterface(type(IService).interfaceId);
|
95
131
|
_registerInterface(type(IInstanceService).interfaceId);
|
@@ -7,10 +7,10 @@ import {IInstance} from "../../instance/IInstance.sol";
|
|
7
7
|
import {ObjectType, INSTANCE, PRODUCT, POOL} from "../../types/ObjectType.sol";
|
8
8
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
9
9
|
|
10
|
-
import {
|
10
|
+
import {Service} from "../../shared/Service.sol";
|
11
11
|
import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
|
12
12
|
|
13
|
-
abstract contract ComponentServiceBase is
|
13
|
+
abstract contract ComponentServiceBase is Service {
|
14
14
|
|
15
15
|
constructor(
|
16
16
|
address registry,
|
@@ -18,7 +18,7 @@ abstract contract ComponentServiceBase is ServiceBase {
|
|
18
18
|
address initialOwner
|
19
19
|
)
|
20
20
|
{
|
21
|
-
|
21
|
+
_initializeService(registry, initialOwner);
|
22
22
|
}
|
23
23
|
|
24
24
|
|
@@ -27,15 +27,15 @@ import {UFixed, UFixedLib} from "../../types/UFixed.sol";
|
|
27
27
|
import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
|
28
28
|
import {IPoolComponent} from "../../components/IPoolComponent.sol";
|
29
29
|
import {IProductComponent} from "../../components/IProductComponent.sol";
|
30
|
-
import {IService} from "
|
30
|
+
import {IService} from "../../shared/IService.sol";
|
31
31
|
import {IComponentOwnerService} from "./IComponentOwnerService.sol";
|
32
|
-
import {
|
32
|
+
import {Service} from "../../shared/Service.sol";
|
33
33
|
// import {IPool, IPoolModule} from "../module/IPoolModule.sol";
|
34
34
|
|
35
35
|
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
36
36
|
|
37
37
|
contract ComponentOwnerService is
|
38
|
-
|
38
|
+
Service,
|
39
39
|
IComponentOwnerService
|
40
40
|
{
|
41
41
|
using NftIdLib for NftId;
|
@@ -64,11 +64,11 @@ contract ComponentOwnerService is
|
|
64
64
|
address initialOwner
|
65
65
|
)
|
66
66
|
{
|
67
|
-
|
67
|
+
_initializeService(registry, initialOwner);
|
68
68
|
_registerInterface(type(IComponentOwnerService).interfaceId);
|
69
69
|
}
|
70
70
|
|
71
|
-
function getName() public pure override(IService,
|
71
|
+
function getName() public pure override(IService, Service) returns(string memory name) {
|
72
72
|
return NAME;
|
73
73
|
}
|
74
74
|
|
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
|
|
5
5
|
import {ObjectType} from "../../types/ObjectType.sol";
|
6
6
|
import {RoleId} from "../../types/RoleId.sol";
|
7
7
|
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
8
|
-
import {IService} from "
|
8
|
+
import {IService} from "../../shared/IService.sol";
|
9
9
|
|
10
10
|
// TODO rename to registry service
|
11
11
|
interface IComponentOwnerService is IService {
|
@@ -3,7 +3,7 @@ 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 {IService} from "
|
6
|
+
import {IService} from "../../shared/IService.sol";
|
7
7
|
|
8
8
|
interface IDistributionService is IService {
|
9
9
|
function setFees(
|
@@ -3,7 +3,7 @@ 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 {IService} from "
|
6
|
+
import {IService} from "../../shared/IService.sol";
|
7
7
|
|
8
8
|
interface IPoolService is IService {
|
9
9
|
function setFees(
|
@@ -2,7 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IRisk} from "../module/IRisk.sol";
|
5
|
-
import {IService} from "
|
5
|
+
import {IService} from "../../shared/IService.sol";
|
6
6
|
|
7
7
|
import {NftId} from "../../types/NftId.sol";
|
8
8
|
import {ReferralId} from "../../types/Referral.sol";
|
@@ -24,6 +24,7 @@ interface IRegistry is IERC165 {
|
|
24
24
|
address initialOwner;
|
25
25
|
bytes data;
|
26
26
|
}// TODO delete nftId and initialOwner(if not used) from struct
|
27
|
+
// TODO strong disagree, keep nftId there (lets keep get object info return object consistent)
|
27
28
|
|
28
29
|
function register(ObjectInfo memory info) external returns (NftId nftId);
|
29
30
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {NftId} from "
|
5
|
-
import {ObjectType} from "
|
6
|
-
import {RoleId} from "
|
7
|
-
import {IService} from "
|
8
|
-
import {IRegistry} from "
|
9
|
-
|
10
|
-
import {IRegisterable} from "
|
11
|
-
import {IBaseComponent} from "
|
4
|
+
import {NftId} from "../types/NftId.sol";
|
5
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
6
|
+
import {RoleId} from "../types/RoleId.sol";
|
7
|
+
import {IService} from "../shared/IService.sol";
|
8
|
+
import {IRegistry} from "./IRegistry.sol";
|
9
|
+
|
10
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
11
|
+
import {IBaseComponent} from "../components/IBaseComponent.sol";
|
12
12
|
|
13
13
|
interface IRegistryService is IService {
|
14
14
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
5
|
-
import {IService} from "../
|
5
|
+
import {IService} from "../shared/IService.sol";
|
6
6
|
|
7
7
|
import {ChainNft} from "./ChainNft.sol";
|
8
8
|
import {IRegistry} from "./IRegistry.sol";
|
@@ -28,15 +28,15 @@ import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
|
28
28
|
import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
|
29
29
|
import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
|
30
30
|
|
31
|
-
import {
|
32
|
-
import {IService} from "
|
31
|
+
import {Service} from "../shared/Service.sol";
|
32
|
+
import {IService} from "../shared/IService.sol";
|
33
33
|
import {IRegistryService} from "./IRegistryService.sol";
|
34
34
|
import {Registry} from "./Registry.sol";
|
35
35
|
import {ChainNft} from "./ChainNft.sol";
|
36
36
|
|
37
37
|
contract RegistryService is
|
38
38
|
AccessManagedUpgradeable,
|
39
|
-
|
39
|
+
Service,
|
40
40
|
IRegistryService
|
41
41
|
{
|
42
42
|
using NftIdLib for NftId;
|
@@ -158,7 +158,6 @@ contract RegistryService is
|
|
158
158
|
bytes memory data
|
159
159
|
)
|
160
160
|
{
|
161
|
-
|
162
161
|
if(!instance.supportsInterface(type(IInstance).interfaceId)) {
|
163
162
|
revert NotInstance();
|
164
163
|
}
|
@@ -290,7 +289,7 @@ contract RegistryService is
|
|
290
289
|
|
291
290
|
|
292
291
|
// From IService
|
293
|
-
function getName() public pure override(IService,
|
292
|
+
function getName() public pure override(IService, Service) returns(string memory) {
|
294
293
|
return NAME;
|
295
294
|
}
|
296
295
|
//function getType() public pure override(IService, ServiceBase) returns(ObjectType serviceType) {
|
@@ -334,7 +333,7 @@ contract RegistryService is
|
|
334
333
|
|
335
334
|
NftId registryNftId = registry.getNftId(address(registry));
|
336
335
|
|
337
|
-
|
336
|
+
_initializeService(address(registry), owner);
|
338
337
|
|
339
338
|
// TODO why do registry service proxy need to keep its nftId??? -> no registryServiceNftId checks in implementation
|
340
339
|
// if they are -> use registry address to obtain owner of registry service nft (works the same with any registerable and(or) implementation)
|
@@ -367,8 +366,13 @@ contract RegistryService is
|
|
367
366
|
|
368
367
|
address owner = info.initialOwner;
|
369
368
|
|
370
|
-
|
371
|
-
|
369
|
+
// solhint-disable-next-line
|
370
|
+
if(expectedType == INSTANCE()) {
|
371
|
+
// any address may create a new instance via instance service
|
372
|
+
} else {
|
373
|
+
if(owner != expectedOwner) { // registerable owner protection
|
374
|
+
revert NotRegisterableOwner(expectedOwner);
|
375
|
+
}
|
372
376
|
}
|
373
377
|
|
374
378
|
if(owner == address(registerable)) {
|
@@ -1,10 +1,10 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {VersionPart} from "
|
4
|
+
import {VersionPart} from "../types/Version.sol";
|
5
5
|
|
6
|
-
import {IRegisterable} from "
|
7
|
-
import {IVersionable} from "
|
6
|
+
import {IRegisterable} from "./IRegisterable.sol";
|
7
|
+
import {IVersionable} from "./IVersionable.sol";
|
8
8
|
|
9
9
|
interface IService is
|
10
10
|
IRegisterable,
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {Registerable} from "./Registerable.sol";
|
5
|
+
import {Versionable} from "./Versionable.sol";
|
6
|
+
|
7
|
+
/// @dev base contract for upgradable objects like services and upgradable components
|
8
|
+
/// deriving contracs need to call _initializeRegisterable
|
9
|
+
/// TODO internalizes versionable here, a non-registerable versionalbe might itself have some value but is outside the scope of the gif
|
10
|
+
/// after this merge versionable will no longer exist on its own in gif
|
11
|
+
/// only registerable and upgradable (which is a registerable too) will remain
|
12
|
+
abstract contract RegisterableUpgradable is
|
13
|
+
Registerable,
|
14
|
+
Versionable
|
15
|
+
{
|
16
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
5
|
+
import {IService} from "./IService.sol";
|
6
|
+
import {IVersionable} from "./IVersionable.sol";
|
7
|
+
import {NftId, zeroNftId} from "../types/NftId.sol";
|
8
|
+
import {RegisterableUpgradable} from "./RegisterableUpgradable.sol";
|
9
|
+
import {SERVICE} from "../types/ObjectType.sol";
|
10
|
+
import {Version, VersionPart, VersionLib} from "../types/Version.sol";
|
11
|
+
import {Versionable} from "./Versionable.sol";
|
12
|
+
|
13
|
+
/// @dev service base contract
|
14
|
+
abstract contract Service is
|
15
|
+
RegisterableUpgradable,
|
16
|
+
IService
|
17
|
+
{
|
18
|
+
function getName() public pure virtual override returns(string memory name);
|
19
|
+
|
20
|
+
function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
|
21
|
+
return getVersion().toMajorPart();
|
22
|
+
}
|
23
|
+
|
24
|
+
// from Versionable
|
25
|
+
function getVersion()
|
26
|
+
public
|
27
|
+
pure
|
28
|
+
virtual override (IVersionable, Versionable)
|
29
|
+
returns(Version)
|
30
|
+
{
|
31
|
+
return VersionLib.toVersion(3,0,0);
|
32
|
+
}
|
33
|
+
|
34
|
+
function _initializeService(
|
35
|
+
address registry,
|
36
|
+
address initialOwner
|
37
|
+
)
|
38
|
+
internal
|
39
|
+
//onlyInitializing //TODO uncomment when "fully" upgradeable
|
40
|
+
{
|
41
|
+
// service must provide its name and version upon registration
|
42
|
+
bytes memory data = abi.encode(getName(), getMajorVersion());
|
43
|
+
NftId registryNftId = _getRegistryNftId(registry);
|
44
|
+
bool isInterceptor = false;
|
45
|
+
|
46
|
+
_initializeRegisterable(registry, registryNftId, SERVICE(), isInterceptor, initialOwner, data);
|
47
|
+
_registerInterface(type(IService).interfaceId);
|
48
|
+
}
|
49
|
+
|
50
|
+
// this is just a conveniene function, actual validation will be done upon registration
|
51
|
+
function _getRegistryNftId(address registryAddress) internal view returns (NftId) {
|
52
|
+
return IRegistry(registryAddress).getNftId(registryAddress);
|
53
|
+
}
|
54
|
+
}
|
@@ -3,21 +3,19 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../contracts/types/NftId.sol";
|
5
5
|
import {Version, VersionLib} from "../../contracts/types/Version.sol";
|
6
|
-
import {
|
6
|
+
import {Service} from "../../contracts/shared/Service.sol";
|
7
7
|
|
8
8
|
import {IVersionable} from "../../contracts/shared/IVersionable.sol";
|
9
9
|
import {Versionable} from "../../contracts/shared/Versionable.sol";
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
contract TestService is ServiceBase {
|
11
|
+
contract TestService is Service {
|
14
12
|
|
15
13
|
string public constant NAME = "TestService";
|
16
14
|
|
17
15
|
constructor(address registry, NftId registryNftId, address initialOwner)
|
18
16
|
// solhint-disable-next-line no-empty-blocks
|
19
17
|
{
|
20
|
-
|
18
|
+
_initializeService(registry, initialOwner);
|
21
19
|
}
|
22
20
|
|
23
21
|
function getName() public pure override returns(string memory name) {
|
package/package.json
CHANGED
@@ -1,44 +0,0 @@
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.19;
|
3
|
-
|
4
|
-
import {NftId, zeroNftId} from "../../types/NftId.sol";
|
5
|
-
import {ObjectType, SERVICE} from "../../types/ObjectType.sol";
|
6
|
-
import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
|
7
|
-
|
8
|
-
import {Registerable} from "../../shared/Registerable.sol";
|
9
|
-
import {IRegistry} from "../../registry/IRegistry.sol";
|
10
|
-
import {IVersionable} from "../../shared/IVersionable.sol";
|
11
|
-
import {Versionable} from "../../shared/Versionable.sol";
|
12
|
-
|
13
|
-
import {IService} from "./IService.sol";
|
14
|
-
|
15
|
-
abstract contract ServiceBase is
|
16
|
-
Registerable,
|
17
|
-
Versionable,
|
18
|
-
IService
|
19
|
-
{
|
20
|
-
function getName() public pure virtual override returns(string memory name);
|
21
|
-
|
22
|
-
function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
|
23
|
-
return getVersion().toMajorPart();
|
24
|
-
}
|
25
|
-
|
26
|
-
// from Versionable
|
27
|
-
function getVersion()
|
28
|
-
public
|
29
|
-
pure
|
30
|
-
virtual override (IVersionable, Versionable)
|
31
|
-
returns(Version)
|
32
|
-
{
|
33
|
-
return VersionLib.toVersion(3,0,0);
|
34
|
-
}
|
35
|
-
|
36
|
-
function _initializeServiceBase(address registry, NftId registryNftId, address initialOwner)
|
37
|
-
internal
|
38
|
-
//onlyInitializing //TODO uncomment when "fully" upgradeable
|
39
|
-
{// service must provide its name and version upon registration
|
40
|
-
bytes memory data = abi.encode(getName(), getMajorVersion());
|
41
|
-
_initializeRegisterable(registry, registryNftId, SERVICE(), false, initialOwner, data);
|
42
|
-
_registerInterface(type(IService).interfaceId);
|
43
|
-
}
|
44
|
-
}
|