@etherisc/gif-next 0.0.2-ce8407f-016 → 0.0.2-d243ae6-520
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +104 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +314 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +610 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +26 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +152 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +774 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +754 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
- 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/IInstance.sol/IInstance.json +342 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +489 -493
- 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 +438 -33
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +654 -16
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +432 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +481 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +0 -77
- 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 +10 -244
- 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 +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +41 -161
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +134 -7
- 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 +62 -190
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +287 -39
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +61 -33
- 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 +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 +6 -6
- 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/TokenHandler.sol/TokenHandler.json +2 -2
- 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/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -6
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +111 -5
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +17 -17
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- 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/TestVersionable.sol/TestVersionable.json +2 -2
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.json +91 -53
- 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/Fee.sol/FeeLib.json +4 -4
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- 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 +86 -0
- package/contracts/components/Distribution.sol +166 -0
- package/contracts/components/IBaseComponent.sol +7 -2
- package/contracts/components/IDistributionComponent.sol +43 -0
- package/contracts/components/IPoolComponent.sol +62 -0
- package/contracts/components/IProductComponent.sol +35 -0
- package/contracts/components/Pool.sol +259 -0
- package/contracts/components/Product.sol +297 -0
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/AccessManagedSimple.sol +12 -4
- package/contracts/instance/AccessManagerSimple.sol +12 -2
- package/contracts/instance/IAccessManagerSimple.sol +1 -1
- package/contracts/instance/IInstance.sol +23 -1
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +59 -9
- package/contracts/instance/InstanceAccessManager.sol +2 -2
- package/contracts/instance/InstanceReader.sol +63 -8
- package/contracts/instance/InstanceService.sol +111 -18
- package/contracts/instance/InstanceServiceManager.sol +56 -0
- package/contracts/instance/base/ComponentServiceBase.sol +49 -0
- package/contracts/instance/base/IInstanceBase.sol +23 -0
- package/contracts/instance/base/IKeyValueStore.sol +5 -4
- package/contracts/instance/base/KeyValueStore.sol +4 -20
- package/contracts/instance/module/IAccess.sol +2 -2
- package/contracts/instance/module/ISetup.sol +3 -1
- package/contracts/instance/module/ITreasury.sol +1 -1
- package/contracts/instance/service/ComponentOwnerService.sol +317 -0
- package/contracts/instance/service/IComponentOwnerService.sol +20 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +37 -0
- package/contracts/instance/service/IProductService.sol +107 -0
- package/contracts/registry/ChainNft.sol +40 -25
- package/contracts/registry/IRegistry.sol +5 -20
- package/contracts/registry/IRegistryService.sol +16 -10
- package/contracts/registry/Registry.sol +87 -155
- package/contracts/registry/RegistryService.sol +182 -107
- package/contracts/registry/RegistryServiceManager.sol +23 -2
- package/contracts/shared/ERC165.sol +1 -1
- package/contracts/shared/IRegisterable.sol +1 -1
- package/contracts/{instance/base → shared}/IService.sol +3 -3
- package/contracts/shared/ProxyManager.sol +3 -3
- package/contracts/shared/Registerable.sol +2 -2
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +54 -0
- package/contracts/shared/TokenHandler.sol +2 -2
- package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
- package/contracts/shared/Versionable.sol +1 -1
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRoleId.sol +6 -6
- package/contracts/test/TestService.sol +3 -5
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/RoleId.sol +11 -4
- package/contracts/types/UFixed.sol +128 -12
- package/package.json +4 -3
- 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/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/instance/base/ServiceBase.sol +0 -44
- package/contracts/registry/IChainNft.sol +0 -22
@@ -1,66 +1,79 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IERC20Metadata} from "@
|
4
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
6
|
+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
|
7
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
5
8
|
|
6
|
-
import {IRegistry} from "
|
7
|
-
|
9
|
+
import {IRegistry} from "./IRegistry.sol";
|
10
|
+
import {IInstance} from "../instance/IInstance.sol";
|
8
11
|
|
9
12
|
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
10
13
|
// import {IComponent, IComponentModule} from "../../contracts/instance/module/component/IComponent.sol";
|
11
14
|
// import {IPool} from "../../contracts/instance/module/pool/IPoolModule.sol";
|
12
15
|
import {IBaseComponent} from "../../contracts/components/IBaseComponent.sol";
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
import {IPoolComponent} from "../../contracts/components/IPoolComponent.sol";
|
17
|
+
import {IProductComponent} from "../../contracts/components/IProductComponent.sol";
|
18
|
+
import {IDistributionComponent} from "../../contracts/components/IDistributionComponent.sol";
|
16
19
|
|
17
20
|
import {IVersionable} from "../../contracts/shared/IVersionable.sol";
|
18
21
|
import {Versionable} from "../../contracts/shared/Versionable.sol";
|
19
22
|
import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
|
20
23
|
|
21
|
-
import {RoleId} from "../../contracts/types/RoleId.sol";
|
24
|
+
import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
|
22
25
|
import {ObjectType, REGISTRY, TOKEN, SERVICE, PRODUCT, ORACLE, POOL, TOKEN, INSTANCE, DISTRIBUTION, POLICY, BUNDLE} from "../../contracts/types/ObjectType.sol";
|
23
26
|
import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
|
24
27
|
import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
|
25
28
|
import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
|
26
29
|
import {Version, VersionPart, VersionLib} from "../../contracts/types/Version.sol";
|
27
30
|
|
28
|
-
import {
|
29
|
-
import {IService} from "
|
31
|
+
import {Service} from "../shared/Service.sol";
|
32
|
+
import {IService} from "../shared/IService.sol";
|
30
33
|
import {IRegistryService} from "./IRegistryService.sol";
|
31
|
-
import {Registry} from "
|
34
|
+
import {Registry} from "./Registry.sol";
|
35
|
+
import {ChainNft} from "./ChainNft.sol";
|
32
36
|
|
33
37
|
contract RegistryService is
|
34
|
-
|
38
|
+
AccessManagedUpgradeable,
|
39
|
+
Service,
|
35
40
|
IRegistryService
|
36
41
|
{
|
37
42
|
using NftIdLib for NftId;
|
38
43
|
|
44
|
+
error SelfRegistration();
|
39
45
|
error NotRegistryOwner();
|
40
|
-
error MissingAllowance();
|
41
46
|
|
42
47
|
error NotToken();
|
43
48
|
error NotService();
|
44
|
-
error NotComponent();
|
45
49
|
error NotInstance();
|
46
|
-
|
47
|
-
error
|
50
|
+
error NotProduct();
|
51
|
+
error NotPool();
|
52
|
+
error NotDistribution();
|
53
|
+
|
54
|
+
error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
|
55
|
+
error NotRegisterableOwner(address expectedOwner);
|
56
|
+
error RegisterableOwnerIsZero();
|
57
|
+
error RegisterableOwnerIsRegistered();
|
48
58
|
error InvalidInitialOwner(address initialOwner);
|
49
|
-
error
|
50
|
-
|
59
|
+
error InvalidAddress(address registerableAddress);
|
60
|
+
|
51
61
|
|
62
|
+
// Initial value for constant variable has to be compile-time constant
|
63
|
+
// TODO define types as constants?
|
64
|
+
//ObjectType public constant SERVICE_TYPE = REGISTRY();
|
52
65
|
string public constant NAME = "RegistryService";
|
53
66
|
|
54
67
|
// TODO update to real hash when registry is stable
|
55
68
|
bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
|
56
69
|
|
57
|
-
address constant
|
70
|
+
address public constant NFT_LOCK_ADDRESS = address(0x1);
|
58
71
|
|
59
72
|
/// @dev
|
60
73
|
// msg.sender - ONLY registry owner
|
61
|
-
// CAN register ANY non IRegisterable address
|
62
|
-
// CAN register ONLY valid object-parent types combinations for TOKEN
|
63
74
|
// CAN NOT register itself
|
75
|
+
// CAN NOT register IRegisterable address
|
76
|
+
// CAN register ONLY valid object-parent types combinations for TOKEN
|
64
77
|
// IMPORTANT: MUST NOT call untrusted contract inbetween calls to registry/instance (trusted contracts)
|
65
78
|
// motivation: registry/instance state may change during external call
|
66
79
|
// TODO it may be usefull to have transferable token nft in order to delist token, make it invalid for new beginings
|
@@ -69,21 +82,18 @@ contract RegistryService is
|
|
69
82
|
external
|
70
83
|
returns(NftId nftId)
|
71
84
|
{
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
// registryOwner can not register IRegisterable as TOKEN
|
76
|
-
try registerable.supportsInterface(type(IRegisterable).interfaceId) returns(bool result) {
|
77
|
-
isRegisterable = result;
|
78
|
-
} catch {
|
79
|
-
isRegisterable = false;
|
80
|
-
}
|
85
|
+
if(msg.sender == tokenAddress) {
|
86
|
+
revert SelfRegistration();
|
87
|
+
}
|
81
88
|
|
82
|
-
if
|
89
|
+
// MUST not revert if no ERC165 support
|
90
|
+
if(tokenAddress.code.length == 0 ||
|
91
|
+
ERC165Checker.supportsInterface(tokenAddress, type(IRegisterable).interfaceId)) {
|
83
92
|
revert NotToken();
|
84
|
-
}
|
93
|
+
}
|
85
94
|
|
86
95
|
NftId registryNftId = _registry.getNftId(address(_registry));
|
96
|
+
|
87
97
|
if(msg.sender != _registry.ownerOf(registryNftId)) {
|
88
98
|
revert NotRegistryOwner();
|
89
99
|
}
|
@@ -103,67 +113,120 @@ contract RegistryService is
|
|
103
113
|
|
104
114
|
/// @dev
|
105
115
|
// msg.sender - ONLY registry owner
|
116
|
+
// CAN NOT register itself
|
106
117
|
// CAN register ONLY valid object-parent types combinations for SERVICE
|
107
118
|
// CAN register ONLY IRegisterable address he owns
|
108
|
-
// CAN NOT register itself
|
109
119
|
// IMPORTANT: MUST NOT check owner before calling external contract
|
110
120
|
function registerService(IService service)
|
111
121
|
external
|
122
|
+
// TODO restrict access - registryService.registerService must use accessmanager for checking permissions as
|
123
|
+
// services are not always owned by registry owner - actually only registry service is owned by registry owner
|
124
|
+
|
112
125
|
returns(
|
113
126
|
IRegistry.ObjectInfo memory info,
|
114
127
|
bytes memory data
|
115
128
|
)
|
116
129
|
{
|
117
|
-
|
130
|
+
|
131
|
+
// CAN revert if no ERC165 support -> will revert with empty message
|
132
|
+
if(!service.supportsInterface(type(IService).interfaceId)) {
|
118
133
|
revert NotService();
|
119
|
-
}
|
134
|
+
}
|
120
135
|
|
121
136
|
(
|
122
137
|
info,
|
123
138
|
data
|
124
139
|
) = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
125
140
|
|
126
|
-
NftId registryNftId = _registry.getNftId(address(_registry));
|
127
|
-
if(msg.sender != _registry.ownerOf(registryNftId)) {
|
128
|
-
revert NotRegistryOwner();
|
129
|
-
}
|
130
|
-
|
131
|
-
info.initialOwner = NFT_LOCK_ADDRESS;//registry.getLockAddress();
|
132
141
|
info.nftId = _registry.register(info);
|
133
142
|
service.linkToRegisteredNftId();
|
134
|
-
|
135
143
|
return (
|
136
144
|
info,
|
137
145
|
data
|
138
146
|
);
|
139
147
|
}
|
140
148
|
|
141
|
-
//
|
142
|
-
//
|
143
|
-
|
149
|
+
// If msg.sender is approved service:
|
150
|
+
// 1) add owner arg (service MUST pass it's msg.sender as owner)
|
151
|
+
// 2) check service allowance
|
152
|
+
// 3) comment self registrstion check
|
153
|
+
//function registerInstance(IRegisterable instance, address owner)
|
154
|
+
function registerInstance(IRegisterable instance)
|
155
|
+
external
|
156
|
+
returns(
|
157
|
+
IRegistry.ObjectInfo memory info,
|
158
|
+
bytes memory data
|
159
|
+
)
|
160
|
+
{
|
161
|
+
if(!instance.supportsInterface(type(IInstance).interfaceId)) {
|
162
|
+
revert NotInstance();
|
163
|
+
}
|
164
|
+
|
165
|
+
(
|
166
|
+
info,
|
167
|
+
data
|
168
|
+
) = _getAndVerifyContractInfo(instance, INSTANCE(), msg.sender);
|
169
|
+
|
170
|
+
info.nftId = _registry.register(info);
|
171
|
+
instance.linkToRegisteredNftId(); // asume safe
|
172
|
+
|
173
|
+
return (
|
174
|
+
info,
|
175
|
+
data
|
176
|
+
);
|
177
|
+
}
|
178
|
+
|
179
|
+
function registerProduct(IBaseComponent product, address owner)
|
144
180
|
external
|
181
|
+
restricted
|
145
182
|
returns(
|
146
183
|
IRegistry.ObjectInfo memory info,
|
147
184
|
bytes memory data
|
148
185
|
)
|
149
186
|
{
|
150
|
-
if
|
151
|
-
|
187
|
+
// CAN revert if no ERC165 support -> will revert with empty message
|
188
|
+
if(!product.supportsInterface(type(IProductComponent).interfaceId)) {
|
189
|
+
revert NotProduct();
|
152
190
|
}
|
153
191
|
|
154
192
|
(
|
155
193
|
info,
|
156
194
|
data
|
157
|
-
) = _getAndVerifyContractInfo(
|
195
|
+
) = _getAndVerifyContractInfo(product, PRODUCT(), owner);
|
158
196
|
|
159
197
|
NftId serviceNftId = _registry.getNftId(msg.sender);
|
160
198
|
|
161
|
-
|
162
|
-
|
163
|
-
|
199
|
+
info.nftId = _registry.register(info);
|
200
|
+
// TODO unsafe, let component or its owner derive nftId latter, when state assumptions and modifications of GIF contracts are finished
|
201
|
+
product.linkToRegisteredNftId();
|
202
|
+
|
203
|
+
return (
|
204
|
+
info,
|
205
|
+
data
|
206
|
+
);
|
207
|
+
}
|
208
|
+
|
209
|
+
function registerPool(IBaseComponent pool, address owner)
|
210
|
+
external
|
211
|
+
restricted
|
212
|
+
returns(
|
213
|
+
IRegistry.ObjectInfo memory info,
|
214
|
+
bytes memory data
|
215
|
+
)
|
216
|
+
{
|
217
|
+
if(!pool.supportsInterface(type(IPoolComponent).interfaceId)) {
|
218
|
+
revert NotPool();
|
219
|
+
}
|
220
|
+
|
221
|
+
(
|
222
|
+
info,
|
223
|
+
data
|
224
|
+
) = _getAndVerifyContractInfo(pool, POOL(), owner);
|
225
|
+
|
226
|
+
NftId serviceNftId = _registry.getNftId(msg.sender);
|
164
227
|
|
165
228
|
info.nftId = _registry.register(info);
|
166
|
-
|
229
|
+
pool.linkToRegisteredNftId();
|
167
230
|
|
168
231
|
return (
|
169
232
|
info,
|
@@ -171,58 +234,53 @@ contract RegistryService is
|
|
171
234
|
);
|
172
235
|
}
|
173
236
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
external
|
237
|
+
function registerDistribution(IBaseComponent distribution, address owner)
|
238
|
+
external
|
239
|
+
restricted
|
178
240
|
returns(
|
179
241
|
IRegistry.ObjectInfo memory info,
|
180
242
|
bytes memory data
|
181
243
|
)
|
182
244
|
{
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
245
|
+
if(!distribution.supportsInterface(type(IDistributionComponent).interfaceId)) {
|
246
|
+
revert NotDistribution();
|
247
|
+
}
|
248
|
+
|
249
|
+
(
|
250
|
+
info,
|
251
|
+
data
|
252
|
+
) = _getAndVerifyContractInfo(distribution, DISTRIBUTION(), owner);
|
253
|
+
|
254
|
+
NftId serviceNftId = _registry.getNftId(msg.sender);
|
255
|
+
|
256
|
+
info.nftId = _registry.register(info);
|
257
|
+
distribution.linkToRegisteredNftId();
|
258
|
+
|
259
|
+
return (
|
260
|
+
info,
|
261
|
+
data
|
262
|
+
);
|
200
263
|
}
|
201
264
|
|
202
265
|
function registerPolicy(IRegistry.ObjectInfo memory info)
|
203
|
-
external
|
266
|
+
external
|
267
|
+
restricted
|
204
268
|
returns(NftId nftId)
|
205
269
|
{
|
206
270
|
NftId senderNftId = _registry.getNftId(msg.sender);
|
207
271
|
|
208
|
-
if(_registry.allowance(senderNftId, POLICY()) == false) {
|
209
|
-
revert MissingAllowance();
|
210
|
-
}
|
211
|
-
|
212
272
|
_verifyObjectInfo(info, POLICY());
|
213
273
|
|
214
274
|
nftId = _registry.register(info);
|
215
275
|
}
|
216
276
|
|
217
277
|
function registerBundle(IRegistry.ObjectInfo memory info)
|
218
|
-
external
|
278
|
+
external
|
279
|
+
restricted
|
219
280
|
returns(NftId nftId)
|
220
281
|
{
|
221
|
-
NftId senderNftId = _registry.getNftId(msg.sender);
|
222
282
|
|
223
|
-
|
224
|
-
revert MissingAllowance();
|
225
|
-
}
|
283
|
+
NftId senderNftId = _registry.getNftId(msg.sender);
|
226
284
|
|
227
285
|
_verifyObjectInfo(info, BUNDLE());
|
228
286
|
|
@@ -231,9 +289,12 @@ contract RegistryService is
|
|
231
289
|
|
232
290
|
|
233
291
|
// From IService
|
234
|
-
function getName() public pure override(IService,
|
292
|
+
function getName() public pure override(IService, Service) returns(string memory) {
|
235
293
|
return NAME;
|
236
294
|
}
|
295
|
+
//function getType() public pure override(IService, ServiceBase) returns(ObjectType serviceType) {
|
296
|
+
// return SERVICE_TYPE;
|
297
|
+
//}
|
237
298
|
|
238
299
|
|
239
300
|
// from Versionable
|
@@ -245,12 +306,19 @@ contract RegistryService is
|
|
245
306
|
// registry is getting instantiated and locked to registry service address forever
|
246
307
|
function _initialize(
|
247
308
|
address owner,
|
248
|
-
bytes memory
|
309
|
+
bytes memory data
|
249
310
|
)
|
250
311
|
internal
|
251
312
|
initializer
|
252
313
|
virtual override
|
253
314
|
{
|
315
|
+
(
|
316
|
+
address initialAuthority,
|
317
|
+
bytes memory registryByteCodeWithInitCode
|
318
|
+
) = abi.decode(data, (address, bytes));
|
319
|
+
|
320
|
+
__AccessManaged_init(initialAuthority);
|
321
|
+
|
254
322
|
bytes memory encodedConstructorArguments = abi.encode(
|
255
323
|
owner,
|
256
324
|
getMajorVersion());
|
@@ -259,26 +327,28 @@ contract RegistryService is
|
|
259
327
|
registryByteCodeWithInitCode,
|
260
328
|
encodedConstructorArguments);
|
261
329
|
|
262
|
-
|
330
|
+
IRegistry registry = IRegistry(ContractDeployerLib.deploy(
|
263
331
|
registryCreationCode,
|
264
|
-
REGISTRY_CREATION_CODE_HASH);
|
332
|
+
REGISTRY_CREATION_CODE_HASH));
|
265
333
|
|
266
|
-
|
267
|
-
NftId registryNftId = registry.getNftId(registryAddress);
|
334
|
+
NftId registryNftId = registry.getNftId(address(registry));
|
268
335
|
|
269
|
-
|
270
|
-
linkToRegisteredNftId();
|
336
|
+
_initializeService(address(registry), owner);
|
271
337
|
|
338
|
+
// TODO why do registry service proxy need to keep its nftId??? -> no registryServiceNftId checks in implementation
|
339
|
+
// if they are -> use registry address to obtain owner of registry service nft (works the same with any registerable and(or) implementation)
|
340
|
+
linkToRegisteredNftId();
|
272
341
|
_registerInterface(type(IRegistryService).interfaceId);
|
273
342
|
}
|
274
343
|
|
275
344
|
// parent check done in registry because of approve()
|
276
345
|
function _getAndVerifyContractInfo(
|
277
346
|
IRegisterable registerable,
|
278
|
-
ObjectType
|
279
|
-
address
|
347
|
+
ObjectType expectedType, // assume can be valid only
|
348
|
+
address expectedOwner // assume can be 0
|
280
349
|
)
|
281
350
|
internal
|
351
|
+
view
|
282
352
|
returns(
|
283
353
|
IRegistry.ObjectInfo memory info,
|
284
354
|
bytes memory data
|
@@ -288,23 +358,33 @@ contract RegistryService is
|
|
288
358
|
info,
|
289
359
|
data
|
290
360
|
) = registerable.getInitialInfo();
|
361
|
+
info.objectAddress = address(registerable);
|
291
362
|
|
292
|
-
if(info.
|
293
|
-
revert
|
363
|
+
if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
|
364
|
+
revert UnexpectedRegisterableType(expectedType, info.objectType);
|
294
365
|
}
|
295
366
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
367
|
+
address owner = info.initialOwner;
|
368
|
+
|
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
|
+
}
|
300
376
|
}
|
301
377
|
|
302
|
-
if(
|
378
|
+
if(owner == address(registerable)) {
|
303
379
|
revert SelfRegistration();
|
304
380
|
}
|
381
|
+
|
382
|
+
if(owner == address(0)) {
|
383
|
+
revert RegisterableOwnerIsZero();
|
384
|
+
}
|
305
385
|
|
306
|
-
if(
|
307
|
-
revert
|
386
|
+
if(getRegistry().isRegistered(owner)) {
|
387
|
+
revert RegisterableOwnerIsRegistered();
|
308
388
|
}
|
309
389
|
|
310
390
|
/*NftId parentNftId = info.parentNftId;
|
@@ -354,11 +434,6 @@ contract RegistryService is
|
|
354
434
|
revert InitialOwnerIsRegistry();
|
355
435
|
}*/
|
356
436
|
|
357
|
-
|
358
|
-
if(info.objectType != objectType) {
|
359
|
-
revert InvalidType(info.objectType);
|
360
|
-
}
|
361
|
-
|
362
437
|
/*NftId parentNftId = info.parentNftId;
|
363
438
|
IRegistry.ObjectInfo memory parentInfo = getRegistry().getObjectInfo(parentNftId);
|
364
439
|
|
@@ -366,4 +441,4 @@ contract RegistryService is
|
|
366
441
|
revert InvalidParent(parentNftId);
|
367
442
|
}*/
|
368
443
|
}
|
369
|
-
}
|
444
|
+
}
|
@@ -1,6 +1,10 @@
|
|
1
1
|
// SPDX-License-Identifier: UNLICENSED
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
|
5
|
+
|
6
|
+
import {ContractDeployerLib} from "../shared/ContractDeployerLib.sol";
|
7
|
+
|
4
8
|
import {Registry} from "./Registry.sol";
|
5
9
|
import {IVersionable} from "../shared/IVersionable.sol";
|
6
10
|
import {ProxyManager} from "../shared/ProxyManager.sol";
|
@@ -10,16 +14,25 @@ import {RegistryService} from "./RegistryService.sol";
|
|
10
14
|
contract RegistryServiceManager is
|
11
15
|
ProxyManager
|
12
16
|
{
|
13
|
-
|
17
|
+
bytes32 constant public ACCESS_MANAGER_CREATION_CODE_HASH = 0x0;
|
18
|
+
|
19
|
+
RegistryService private _registryService;
|
20
|
+
|
21
|
+
AccessManager private _accessManager;
|
14
22
|
|
15
23
|
/// @dev initializes proxy manager with registry service implementation and deploys registry
|
16
24
|
constructor(
|
25
|
+
address accessManager
|
17
26
|
)
|
18
27
|
ProxyManager()
|
19
28
|
{
|
29
|
+
_accessManager = AccessManager(accessManager);
|
30
|
+
|
31
|
+
bytes memory initializationData = abi.encode(accessManager, type(Registry).creationCode);
|
32
|
+
|
20
33
|
IVersionable versionable = deploy(
|
21
34
|
address(new RegistryService()),
|
22
|
-
|
35
|
+
initializationData);
|
23
36
|
|
24
37
|
_registryService = RegistryService(address(versionable));
|
25
38
|
|
@@ -40,4 +53,12 @@ contract RegistryServiceManager is
|
|
40
53
|
{
|
41
54
|
return _registryService;
|
42
55
|
}
|
56
|
+
|
57
|
+
function getAccessManager()
|
58
|
+
external
|
59
|
+
view
|
60
|
+
returns (AccessManager)
|
61
|
+
{
|
62
|
+
return _accessManager;
|
63
|
+
}
|
43
64
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {IERC165} from "@
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
5
5
|
|
6
6
|
contract ERC165 is IERC165 {
|
7
7
|
mapping(bytes4 => bool) private _isSupported;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IERC165} from "@
|
4
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
5
5
|
|
6
6
|
import {INftOwnable} from "./INftOwnable.sol";
|
7
7
|
import {IRegistry} from "../registry/IRegistry.sol";
|
@@ -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,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {Ownable} from "@
|
5
|
-
import {ProxyAdmin} from "@
|
6
|
-
import {ITransparentUpgradeableProxy} from "@
|
4
|
+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
5
|
+
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
|
6
|
+
import {ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
|
7
7
|
|
8
8
|
import {IVersionable} from "./IVersionable.sol";
|
9
9
|
import {NftOwnable} from "./NftOwnable.sol";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {Initializable} from "@
|
4
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
5
5
|
|
6
6
|
import {NftId, zeroNftId} from "../types/NftId.sol";
|
7
7
|
import {NftOwnable} from "../shared/NftOwnable.sol";
|
@@ -75,7 +75,7 @@ contract Registerable is
|
|
75
75
|
RegisterableStorage storage $ = _getRegisterableStorage();
|
76
76
|
return (
|
77
77
|
IRegistry.ObjectInfo(
|
78
|
-
|
78
|
+
getNftId(),
|
79
79
|
$._parentNftId,
|
80
80
|
$._objectType,
|
81
81
|
$._isInterceptor,
|
@@ -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
|
+
}
|