@etherisc/gif-next 0.0.2-ce8407f-016 → 0.0.2-cf68d0c-530
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +108 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +327 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +670 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +39 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +204 -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 +790 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +775 -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/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/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 +435 -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 +491 -495
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +34 -34
- 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 +726 -16
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +468 -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/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 +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
- 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 +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 +292 -103
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +123 -15
- 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 +249 -143
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +272 -48
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +79 -30
- 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 +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/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/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/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 +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/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 +91 -0
- package/contracts/components/Distribution.sol +166 -0
- package/contracts/components/IBaseComponent.sol +8 -2
- package/contracts/components/IDistributionComponent.sol +46 -0
- package/contracts/components/IPoolComponent.sol +62 -0
- package/contracts/components/IProductComponent.sol +35 -0
- package/contracts/components/Pool.sol +258 -0
- package/contracts/components/Product.sol +297 -0
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/instance/AccessManagedSimple.sol +9 -8
- package/contracts/instance/AccessManagerSimple.sol +12 -2
- package/contracts/instance/IAccessManagerSimple.sol +1 -1
- package/contracts/instance/IInstance.sol +28 -1
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +61 -10
- package/contracts/instance/InstanceAccessManager.sol +3 -3
- package/contracts/instance/InstanceReader.sol +63 -8
- package/contracts/instance/InstanceService.sol +131 -18
- package/contracts/instance/InstanceServiceManager.sol +56 -0
- package/contracts/instance/base/ComponentServiceBase.sol +39 -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/DistributionService.sol +96 -0
- package/contracts/instance/service/DistributionServiceManager.sol +53 -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 +43 -22
- package/contracts/registry/IRegistryService.sol +16 -12
- package/contracts/registry/Registry.sol +163 -165
- package/contracts/registry/RegistryService.sol +168 -138
- package/contracts/registry/RegistryServiceManager.sol +39 -2
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ERC165.sol +7 -3
- 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 +3 -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 +17 -4
- package/contracts/types/StateId.sol +4 -0
- package/contracts/types/UFixed.sol +128 -12
- package/contracts/types/Version.sol +4 -1
- 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
@@ -2,13 +2,12 @@
|
|
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
|
-
import {IChainNft} from "./IChainNft.sol";
|
8
7
|
import {ChainNft} from "./ChainNft.sol";
|
9
8
|
import {IRegistry} from "./IRegistry.sol";
|
10
9
|
import {NftId, toNftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
11
|
-
import {Version, VersionPart, VersionLib} from "../types/Version.sol";
|
10
|
+
import {Version, VersionPart, VersionLib, VersionPartLib} from "../types/Version.sol";
|
12
11
|
import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, DISTRIBUTION, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
|
13
12
|
import {ITransferInterceptor} from "./ITransferInterceptor.sol";
|
14
13
|
|
@@ -29,57 +28,40 @@ contract Registry is
|
|
29
28
|
ERC165,
|
30
29
|
IRegistry
|
31
30
|
{
|
32
|
-
|
33
|
-
error NotRegistryService();
|
34
|
-
error ZeroParentAddress();
|
35
|
-
error ContractAlreadyRegistered(address objectAddress);
|
36
|
-
error InvalidServiceVersion(VersionPart majorVersion);
|
37
|
-
error ServiceNameAlreadyRegistered(string name, VersionPart majorVersion);
|
38
|
-
|
39
|
-
// approve
|
40
|
-
error NotOwner();
|
41
|
-
error NotRegisteredContract(NftId registrarNftId);
|
42
|
-
error NotService(NftId registrarNftId);
|
43
|
-
error InvalidTypesCombination(ObjectType objectType, ObjectType parentType);
|
44
|
-
|
45
|
-
uint256 public constant MAJOR_VERSION_MIN = 3;
|
31
|
+
uint256 public constant GIF_MAJOR_VERSION_AT_DEPLOYMENT = 3;
|
46
32
|
address public constant NFT_LOCK_ADDRESS = address(0x1);
|
47
33
|
uint256 public constant REGISTRY_SERVICE_TOKEN_SEQUENCE_ID = 3;
|
48
34
|
string public constant EMPTY_URI = "";
|
49
35
|
|
50
|
-
|
51
|
-
|
36
|
+
VersionPart internal _majorVersion;
|
37
|
+
|
38
|
+
mapping(NftId nftId => ObjectInfo info) internal _info;
|
39
|
+
mapping(address object => NftId nftId) internal _nftIdByAddress;
|
52
40
|
|
53
41
|
mapping(NftId registrator => mapping(
|
54
|
-
ObjectType objectType => bool)) _isApproved;
|
42
|
+
ObjectType objectType => bool)) internal _isApproved;
|
55
43
|
|
56
44
|
mapping(ObjectType objectType => mapping(
|
57
|
-
ObjectType parentType => bool)) _isValidContractCombination;
|
45
|
+
ObjectType parentType => bool)) internal _isValidContractCombination;
|
58
46
|
|
59
47
|
mapping(ObjectType objectType => mapping(
|
60
|
-
ObjectType parentType => bool)) _isValidObjectCombination;
|
48
|
+
ObjectType parentType => bool)) internal _isValidObjectCombination;
|
49
|
+
|
50
|
+
mapping(address token => mapping(
|
51
|
+
VersionPart majorVersion => bool isActive)) internal _tokenIsActive;
|
61
52
|
|
62
|
-
mapping(NftId nftId => string name) _string;
|
53
|
+
mapping(NftId nftId => string name) internal _string;
|
63
54
|
mapping(bytes32 serviceNameHash => mapping(
|
64
|
-
VersionPart majorVersion => address service)) _service;
|
65
|
-
|
66
|
-
NftId _registryNftId;
|
67
|
-
NftId _serviceNftId; // set in stone upon registry creation
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
/*
|
72
|
-
modifier onlyInitialOwner() {
|
73
|
-
if(
|
74
|
-
msg.sender != getOwner() ||
|
75
|
-
msg.sender != _info[_registryNftId].initialOwner) {
|
76
|
-
revert NotInitialOwner();
|
77
|
-
}
|
78
|
-
}*/
|
55
|
+
VersionPart majorVersion => address service)) internal _service;
|
56
|
+
|
57
|
+
NftId internal _registryNftId;
|
58
|
+
NftId internal _serviceNftId; // set in stone upon registry creation
|
59
|
+
ChainNft internal _chainNft;
|
60
|
+
|
79
61
|
|
80
62
|
modifier onlyOwner() {
|
81
63
|
if(msg.sender != getOwner()) {
|
82
|
-
revert NotOwner();
|
64
|
+
revert NotOwner(msg.sender);
|
83
65
|
}
|
84
66
|
_;
|
85
67
|
}
|
@@ -95,11 +77,13 @@ contract Registry is
|
|
95
77
|
constructor(address registryOwner, VersionPart majorVersion)
|
96
78
|
{
|
97
79
|
require(registryOwner > address(0), "Registry: registry owner is 0");
|
98
|
-
|
80
|
+
|
81
|
+
// major version at constructor time
|
82
|
+
_majorVersion = VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT);
|
83
|
+
emit LogInitialMajorVersionSet(_majorVersion);
|
99
84
|
|
100
85
|
// deploy NFT
|
101
|
-
|
102
|
-
_chainNft = IChainNft(_chainNftInternal);
|
86
|
+
_chainNft = new ChainNft(address(this));// adds 10kb to deployment size
|
103
87
|
|
104
88
|
// initial registry setup
|
105
89
|
_registerProtocol();
|
@@ -112,9 +96,25 @@ contract Registry is
|
|
112
96
|
_registerInterface(type(IRegistry).interfaceId);
|
113
97
|
}
|
114
98
|
|
99
|
+
// from IRegistry
|
100
|
+
|
101
|
+
/// @dev latest GIF release version
|
102
|
+
function setMajorVersion(VersionPart newMajorVersion)
|
103
|
+
external
|
104
|
+
onlyOwner
|
105
|
+
{
|
106
|
+
// ensure major version increments is one
|
107
|
+
uint256 oldMax = _majorVersion.toInt();
|
108
|
+
uint256 newMax = newMajorVersion.toInt();
|
109
|
+
if (newMax <= oldMax || newMax - oldMax != 1) {
|
110
|
+
revert MajorVersionMaxIncreaseInvalid(newMajorVersion, _majorVersion);
|
111
|
+
}
|
112
|
+
|
113
|
+
_majorVersion = newMajorVersion;
|
114
|
+
emit LogMajorVersionSet(_majorVersion);
|
115
|
+
}
|
116
|
+
|
115
117
|
/// @dev registry protects only against tampering existing records, registering with invalid types pairs and 0 parent address
|
116
|
-
// IMPORTANT: rare case when parentNftId is not registered and == next nftId -> technincally this is ZeroParentAddress error
|
117
|
-
// to catch this check parent address before minting !!!!
|
118
118
|
// TODO service registration means its approval for some type?
|
119
119
|
// TODO registration of precompile addresses
|
120
120
|
function register(ObjectInfo memory info)
|
@@ -139,8 +139,6 @@ contract Registry is
|
|
139
139
|
address interceptor = _getInterceptor(info.isInterceptor, info.objectAddress, parentInfo.isInterceptor, parentAddress);
|
140
140
|
|
141
141
|
// TODO does external call
|
142
|
-
// check for receiver in registry service?
|
143
|
-
// use unsafe transfer?
|
144
142
|
uint256 mintedTokenId = _chainNft.mint(
|
145
143
|
info.initialOwner,
|
146
144
|
interceptor,
|
@@ -170,33 +168,8 @@ contract Registry is
|
|
170
168
|
_nftIdByAddress[contractAddress] = nftId;
|
171
169
|
|
172
170
|
// special case
|
173
|
-
if(objectType == SERVICE())
|
174
|
-
|
175
|
-
(
|
176
|
-
string memory serviceName,
|
177
|
-
VersionPart majorVersion
|
178
|
-
) = abi.decode(info.data, (string, VersionPart));
|
179
|
-
bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
|
180
|
-
|
181
|
-
// TODO MUST guarantee consistency of service.getVersion() and majorVersion here
|
182
|
-
// TODO update _serviceNftId when registryService with new major version is registered? -> it is fixed in current setup
|
183
|
-
// TODO do not use names -> each object type is registered by corresponding service -> conflicting with approve()
|
184
|
-
if(
|
185
|
-
majorVersion.toInt() < MAJOR_VERSION_MIN ||
|
186
|
-
(majorVersion.toInt() > MAJOR_VERSION_MIN &&
|
187
|
-
_service[serviceNameHash][VersionLib.toVersionPart(majorVersion.toInt() - 1)] == address(0) )
|
188
|
-
) {
|
189
|
-
revert InvalidServiceVersion(majorVersion);
|
190
|
-
}
|
191
|
-
|
192
|
-
if(_service[serviceNameHash][majorVersion] != address(0)) {
|
193
|
-
revert ServiceNameAlreadyRegistered(serviceName, majorVersion);
|
194
|
-
}
|
195
|
-
|
196
|
-
_string[nftId] = serviceName;
|
197
|
-
_service[serviceNameHash][majorVersion] = contractAddress;
|
198
|
-
|
199
|
-
emit LogServiceNameRegistration(serviceName, majorVersion);
|
171
|
+
if(objectType == SERVICE()) {
|
172
|
+
_registerService(info);
|
200
173
|
}
|
201
174
|
}
|
202
175
|
else
|
@@ -206,75 +179,70 @@ contract Registry is
|
|
206
179
|
}
|
207
180
|
}
|
208
181
|
|
209
|
-
emit LogRegistration(
|
210
|
-
}
|
211
|
-
|
212
|
-
function registerFrom(
|
213
|
-
address from,
|
214
|
-
ObjectInfo memory info
|
215
|
-
) external returns (NftId nftId)
|
216
|
-
{
|
217
|
-
revert();
|
182
|
+
emit LogRegistration(info);
|
218
183
|
}
|
219
|
-
|
220
184
|
|
221
|
-
/// @dev
|
222
|
-
//
|
223
|
-
//
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
// - registration and approve is a single operation, no need for separate approve() function
|
228
|
-
// - then approve can be used to adding new valid object-parent combinations???
|
229
|
-
function approve(
|
230
|
-
NftId serviceNftId,
|
231
|
-
ObjectType objectType,
|
232
|
-
ObjectType parentType
|
233
|
-
)
|
234
|
-
public
|
235
|
-
onlyOwner()
|
185
|
+
/// @dev token state is informative, registry have no clue about used tokens
|
186
|
+
// component owner is responsible for token selection and operations
|
187
|
+
// service MUST deny registration of component with inactive token
|
188
|
+
function setTokenActive(address token, VersionPart majorVersion, bool active)
|
189
|
+
external
|
190
|
+
onlyOwner
|
236
191
|
{
|
237
|
-
|
238
|
-
|
239
|
-
if(
|
240
|
-
revert
|
192
|
+
// verify that token is registered
|
193
|
+
ObjectInfo memory info = _info[_nftIdByAddress[token]];
|
194
|
+
if (info.nftId.eqz()) {
|
195
|
+
revert TokenNotRegistered(token);
|
241
196
|
}
|
242
197
|
|
243
|
-
|
244
|
-
|
198
|
+
// verify provided address is a registered token
|
199
|
+
if (info.objectType != TOKEN()) {
|
200
|
+
revert NotToken(token);
|
245
201
|
}
|
246
202
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
203
|
+
// verify valid major version
|
204
|
+
// ensure major version increments is one
|
205
|
+
uint256 version = majorVersion.toInt();
|
206
|
+
uint256 versionNow = _majorVersion.toInt();
|
207
|
+
if (version < GIF_MAJOR_VERSION_AT_DEPLOYMENT || version > versionNow) {
|
208
|
+
revert TokenMajorVersionInvalid(majorVersion);
|
251
209
|
}
|
252
210
|
|
253
|
-
|
211
|
+
_tokenIsActive[token][majorVersion] = active;
|
254
212
|
|
255
|
-
emit
|
213
|
+
emit LogTokenStateSet(token, majorVersion, active);
|
256
214
|
}
|
257
215
|
|
258
|
-
/// @dev
|
259
|
-
|
260
|
-
|
261
|
-
function allowance(
|
262
|
-
NftId nftId,
|
263
|
-
ObjectType object
|
264
|
-
)
|
265
|
-
public
|
266
|
-
view
|
267
|
-
returns (bool)
|
268
|
-
{
|
269
|
-
return _isApproved[nftId][object];
|
216
|
+
/// @dev earliest GIF major version
|
217
|
+
function getMajorVersionMin() external view returns (VersionPart) {
|
218
|
+
return VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT);
|
270
219
|
}
|
271
220
|
|
272
|
-
//
|
221
|
+
// TODO make distinction between active an not yet active version
|
222
|
+
// need to be thought trough, not yet clear if necessary
|
223
|
+
// need to answer question: what is the latest version during the upgrade process?
|
224
|
+
// likely setting up a new gif version does not fit into a single tx
|
225
|
+
// in this case we might want to have a period where the latest version is
|
226
|
+
// in the process of being set up while the latest active version is 1 major release smaller
|
227
|
+
/// @dev latest GIF major version (might not yet be active)
|
228
|
+
function getMajorVersionMax() external view returns (VersionPart) {
|
229
|
+
return _majorVersion;
|
230
|
+
}
|
231
|
+
|
232
|
+
/// @dev latest active GIF release version
|
233
|
+
function getMajorVersion() external view returns (VersionPart) {
|
234
|
+
return _majorVersion;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
273
238
|
function getObjectCount() external view override returns (uint256) {
|
274
|
-
|
275
239
|
return _chainNft.totalSupply();
|
276
240
|
}
|
277
241
|
|
242
|
+
function getNftId() external view returns (NftId nftId) {
|
243
|
+
return _registryNftId;
|
244
|
+
}
|
245
|
+
|
278
246
|
function getNftId(address object) external view override returns (NftId id) {
|
279
247
|
return _nftIdByAddress[object];
|
280
248
|
}
|
@@ -305,6 +273,10 @@ contract Registry is
|
|
305
273
|
return _nftIdByAddress[object].gtz();
|
306
274
|
}
|
307
275
|
|
276
|
+
function isTokenActive(address token, VersionPart majorVersion) external view returns (bool) {
|
277
|
+
return _tokenIsActive[token][majorVersion];
|
278
|
+
}
|
279
|
+
|
308
280
|
function getServiceName(NftId nftId) external view returns (string memory) {
|
309
281
|
return _string[nftId];
|
310
282
|
}
|
@@ -319,7 +291,7 @@ contract Registry is
|
|
319
291
|
return _service[serviceNameHash][majorVersion];
|
320
292
|
}
|
321
293
|
|
322
|
-
function getChainNft() external view override returns (
|
294
|
+
function getChainNft() external view override returns (ChainNft) {
|
323
295
|
return _chainNft;
|
324
296
|
}
|
325
297
|
|
@@ -327,16 +299,68 @@ contract Registry is
|
|
327
299
|
return ownerOf(address(this));
|
328
300
|
}
|
329
301
|
|
330
|
-
// Internals
|
302
|
+
// Internals
|
303
|
+
|
304
|
+
function _registerService(ObjectInfo memory info)
|
305
|
+
internal
|
306
|
+
{
|
307
|
+
(
|
308
|
+
string memory serviceName,
|
309
|
+
VersionPart majorVersion
|
310
|
+
) = abi.decode(info.data, (string, VersionPart));
|
311
|
+
bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
|
312
|
+
|
313
|
+
// ensures consistency of service.getVersion() and majorVersion here
|
314
|
+
if(majorVersion != _majorVersion) {
|
315
|
+
revert InvalidServiceVersion(majorVersion);
|
316
|
+
}
|
317
|
+
|
318
|
+
if(_service[serviceNameHash][majorVersion] != address(0)) {
|
319
|
+
revert ServiceNameAlreadyRegistered(serviceName, majorVersion);
|
320
|
+
}
|
321
|
+
|
322
|
+
_string[info.nftId] = serviceName;
|
323
|
+
_service[serviceNameHash][majorVersion] = info.objectAddress;
|
324
|
+
|
325
|
+
emit LogServiceNameRegistration(serviceName, majorVersion);
|
326
|
+
}
|
327
|
+
|
328
|
+
/// @dev obtain interceptor address for this nft if applicable, address(0) otherwise
|
329
|
+
function _getInterceptor(
|
330
|
+
bool isInterceptor,
|
331
|
+
address objectAddress,
|
332
|
+
bool parentIsInterceptor,
|
333
|
+
address parentObjectAddress
|
334
|
+
)
|
335
|
+
internal
|
336
|
+
view
|
337
|
+
returns (address interceptor)
|
338
|
+
{
|
339
|
+
if (objectAddress == address(0)) {
|
340
|
+
if (parentIsInterceptor) {
|
341
|
+
return parentObjectAddress;
|
342
|
+
} else {
|
343
|
+
return address(0);
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
if (isInterceptor) {
|
348
|
+
return objectAddress;
|
349
|
+
}
|
350
|
+
|
351
|
+
return address(0);
|
352
|
+
}
|
353
|
+
|
354
|
+
// Internals called only in constructor
|
331
355
|
|
332
356
|
/// @dev protocol registration used to anchor the dip ecosystem relations
|
333
357
|
function _registerProtocol()
|
334
358
|
internal
|
335
359
|
{
|
336
|
-
uint256 protocolId =
|
360
|
+
uint256 protocolId = _chainNft.PROTOCOL_NFT_ID();
|
337
361
|
NftId protocolNftId = toNftId(protocolId);
|
338
362
|
|
339
|
-
|
363
|
+
_chainNft.mint(NFT_LOCK_ADDRESS, protocolId);
|
340
364
|
|
341
365
|
_info[protocolNftId] = ObjectInfo(
|
342
366
|
protocolNftId,
|
@@ -354,22 +378,22 @@ contract Registry is
|
|
354
378
|
function _registerRegistry(address registryOwner)
|
355
379
|
internal
|
356
380
|
{
|
357
|
-
uint256 registryId =
|
381
|
+
uint256 registryId = _chainNft.calculateTokenId(2);
|
358
382
|
NftId registryNftId = toNftId(registryId);
|
359
383
|
|
360
384
|
NftId parentNftId;
|
361
385
|
|
362
|
-
if(registryId !=
|
386
|
+
if(registryId != _chainNft.GLOBAL_REGISTRY_ID())
|
363
387
|
{// we're not the global registry
|
364
388
|
_registerGlobalRegistry();
|
365
|
-
parentNftId = toNftId(
|
389
|
+
parentNftId = toNftId(_chainNft.GLOBAL_REGISTRY_ID());
|
366
390
|
}
|
367
391
|
else
|
368
392
|
{// we are global registry
|
369
|
-
parentNftId = toNftId(
|
393
|
+
parentNftId = toNftId(_chainNft.PROTOCOL_NFT_ID());
|
370
394
|
}
|
371
395
|
|
372
|
-
|
396
|
+
_chainNft.mint(registryOwner, registryId);
|
373
397
|
|
374
398
|
_info[registryNftId] = ObjectInfo(
|
375
399
|
registryNftId,
|
@@ -389,15 +413,15 @@ contract Registry is
|
|
389
413
|
function _registerGlobalRegistry()
|
390
414
|
internal
|
391
415
|
{
|
392
|
-
uint256 globalRegistryId =
|
416
|
+
uint256 globalRegistryId = _chainNft.GLOBAL_REGISTRY_ID();
|
393
417
|
|
394
|
-
|
418
|
+
_chainNft.mint(NFT_LOCK_ADDRESS, globalRegistryId);
|
395
419
|
|
396
420
|
NftId globalRegistryNftId = toNftId(globalRegistryId);
|
397
421
|
|
398
422
|
_info[globalRegistryNftId] = ObjectInfo(
|
399
423
|
globalRegistryNftId,
|
400
|
-
toNftId(
|
424
|
+
toNftId(_chainNft.PROTOCOL_NFT_ID()), // parent
|
401
425
|
REGISTRY(),
|
402
426
|
false, // isInterceptor
|
403
427
|
address(0), // objectAddress
|
@@ -409,10 +433,10 @@ contract Registry is
|
|
409
433
|
function _registerRegistryService(address registryOwner)
|
410
434
|
internal
|
411
435
|
{
|
412
|
-
uint256 serviceId =
|
436
|
+
uint256 serviceId = _chainNft.calculateTokenId(REGISTRY_SERVICE_TOKEN_SEQUENCE_ID);
|
413
437
|
NftId serviceNftId = toNftId(serviceId);
|
414
438
|
|
415
|
-
|
439
|
+
_chainNft.mint(registryOwner, serviceId);
|
416
440
|
|
417
441
|
_info[serviceNftId] = ObjectInfo(
|
418
442
|
serviceNftId,
|
@@ -428,37 +452,11 @@ contract Registry is
|
|
428
452
|
|
429
453
|
string memory serviceName = "RegistryService";
|
430
454
|
bytes32 serviceNameHash = keccak256(abi.encode(serviceName));
|
431
|
-
_service[serviceNameHash][VersionLib.toVersionPart(
|
455
|
+
_service[serviceNameHash][VersionLib.toVersionPart(GIF_MAJOR_VERSION_AT_DEPLOYMENT)] = msg.sender;
|
432
456
|
_string[serviceNftId] = serviceName;
|
433
457
|
_serviceNftId = serviceNftId;
|
434
458
|
}
|
435
459
|
|
436
|
-
/// @dev obtain interceptor address for this nft if applicable, address(0) otherwise
|
437
|
-
function _getInterceptor(
|
438
|
-
bool isInterceptor,
|
439
|
-
address objectAddress,
|
440
|
-
bool parentIsInterceptor,
|
441
|
-
address parentObjectAddress
|
442
|
-
)
|
443
|
-
internal
|
444
|
-
view
|
445
|
-
returns (address interceptor)
|
446
|
-
{
|
447
|
-
if (objectAddress == address(0)) {
|
448
|
-
if (parentIsInterceptor) {
|
449
|
-
return parentObjectAddress;
|
450
|
-
} else {
|
451
|
-
return address(0);
|
452
|
-
}
|
453
|
-
}
|
454
|
-
|
455
|
-
if (isInterceptor) {
|
456
|
-
return objectAddress;
|
457
|
-
}
|
458
|
-
|
459
|
-
return address(0);
|
460
|
-
}
|
461
|
-
|
462
460
|
/// @dev defines which object - parent types relations are allowed to register
|
463
461
|
// IMPORTANT:
|
464
462
|
// 1) EACH object type MUST have only one parent type across ALL mappings
|