@etherisc/gif-next 0.0.2-e1f23dc-329 → 0.0.2-e2a57af-971
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +63 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +656 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +318 -87
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{shared/RegisterableUpgradable.sol/RegisterableUpgradable.json → components/IComponent.sol/IComponent.json} +171 -158
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +496 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +550 -30
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +596 -5
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +340 -152
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +329 -99
- 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/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +327 -2
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +125 -19
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +176 -669
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +231 -114
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +56 -82
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +260 -167
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +41 -76
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/{ComponentServiceBase.sol/ComponentServiceBase.json → ComponentService.sol/ComponentService.json} +124 -61
- 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/IAccess.sol/IAccess.json +59 -16
- 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/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1102 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +449 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +149 -93
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +29 -36
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/{IComponentOwnerService.sol/IComponentOwnerService.json → IBundleService.sol/IBundleService.json} +295 -46
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -18
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +766 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -169
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -225
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1227 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +505 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +148 -268
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +29 -40
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +150 -388
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +29 -64
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +212 -133
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +127 -93
- 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 +224 -234
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +68 -161
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +51 -104
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +13 -29
- 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/IRegisterable.sol/IRegisterable.json +0 -5
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +13 -18
- 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 +19 -6
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +19 -6
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +19 -11
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +26 -18
- 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 +19 -11
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +44 -36
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +216 -0
- package/contracts/components/Distribution.sol +41 -49
- package/contracts/components/IComponent.sol +43 -0
- package/contracts/components/IDistributionComponent.sol +5 -2
- package/contracts/components/IPoolComponent.sol +11 -13
- package/contracts/components/IProductComponent.sol +7 -3
- package/contracts/components/Pool.sol +74 -89
- package/contracts/components/Product.sol +68 -87
- package/contracts/instance/BundleManager.sol +125 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +27 -9
- package/contracts/instance/IInstanceService.sol +15 -4
- package/contracts/instance/Instance.sol +60 -234
- package/contracts/instance/InstanceAccessManager.sol +88 -78
- package/contracts/instance/InstanceReader.sol +3 -25
- package/contracts/instance/InstanceService.sol +347 -103
- package/contracts/instance/InstanceServiceManager.sol +5 -8
- package/contracts/instance/ObjectManager.sol +84 -0
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/module/IAccess.sol +27 -17
- package/contracts/instance/module/ISetup.sol +3 -1
- package/contracts/instance/service/BundleService.sol +293 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/DistributionService.sol +43 -25
- package/contracts/instance/service/DistributionServiceManager.sol +6 -9
- package/contracts/instance/service/IBundleService.sol +44 -0
- package/contracts/instance/service/IPolicyService.sol +94 -0
- package/contracts/instance/service/IPoolService.sol +4 -25
- package/contracts/instance/service/IProductService.sol +3 -70
- package/contracts/instance/service/PolicyService.sol +538 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +36 -127
- package/contracts/instance/service/PoolServiceManager.sol +5 -8
- package/contracts/instance/service/ProductService.sol +123 -453
- package/contracts/registry/ChainNft.sol +1 -1
- package/contracts/registry/IRegistry.sol +34 -17
- package/contracts/registry/IRegistryService.sol +28 -13
- package/contracts/registry/Registry.sol +214 -210
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +61 -157
- package/contracts/registry/RegistryServiceManager.sol +18 -36
- package/contracts/registry/ReleaseManager.sol +332 -0
- package/contracts/registry/TokenRegistry.sol +8 -7
- package/contracts/shared/IRegisterable.sol +1 -3
- package/contracts/shared/IService.sol +2 -1
- package/contracts/shared/NftOwnable.sol +5 -0
- package/contracts/shared/ProxyManager.sol +1 -1
- package/contracts/shared/Registerable.sol +10 -14
- package/contracts/shared/Service.sol +13 -8
- package/contracts/test/TestService.sol +3 -2
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/RoleId.sol +10 -10
- package/package.json +1 -1
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -327
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -280
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +0 -113
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -827
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +0 -4
- package/contracts/components/BaseComponent.sol +0 -91
- package/contracts/components/IBaseComponent.sol +0 -25
- package/contracts/instance/AccessManagedSimple.sol +0 -115
- package/contracts/instance/AccessManagerSimple.sol +0 -692
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/base/ComponentServiceBase.sol +0 -134
- package/contracts/instance/base/IInstanceBase.sol +0 -23
- package/contracts/instance/service/ComponentOwnerService.sol +0 -317
- package/contracts/instance/service/IComponentOwnerService.sol +0 -20
- package/contracts/shared/RegisterableUpgradable.sol +0 -16
@@ -0,0 +1,332 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
|
5
|
+
|
6
|
+
import {NftId} from "../types/NftId.sol";
|
7
|
+
import {RoleId} from "../types/RoleId.sol";
|
8
|
+
import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
|
9
|
+
import {VersionPart, VersionPartLib} from "../types/Version.sol";
|
10
|
+
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
11
|
+
|
12
|
+
import {IService} from "../shared/IService.sol";
|
13
|
+
|
14
|
+
import {IRegistry} from "./IRegistry.sol";
|
15
|
+
import {Registry} from "./Registry.sol";
|
16
|
+
import {IRegistryService} from "./IRegistryService.sol";
|
17
|
+
import {RegistryAccessManager} from "./RegistryAccessManager.sol";
|
18
|
+
|
19
|
+
|
20
|
+
contract ReleaseManager is AccessManaged
|
21
|
+
{
|
22
|
+
using ObjectTypeLib for ObjectType;
|
23
|
+
|
24
|
+
event LogReleaseCreation(VersionPart version);
|
25
|
+
event LogReleaseActivation(VersionPart version);
|
26
|
+
|
27
|
+
// createNextRelease
|
28
|
+
error NotRegistryService();
|
29
|
+
error UnexpectedServiceAuthority(address expected, address found);
|
30
|
+
|
31
|
+
// registerService
|
32
|
+
error NotService();
|
33
|
+
|
34
|
+
// activateNextRelease
|
35
|
+
error ReleaseNotCreated();
|
36
|
+
error ReleaseRegistrationNotFinished();
|
37
|
+
|
38
|
+
// _getAndVerifyContractInfo
|
39
|
+
error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
|
40
|
+
error NotRegisterableOwner(address notOwner);
|
41
|
+
error SelfRegistration();
|
42
|
+
error RegisterableOwnerIsRegistered();
|
43
|
+
|
44
|
+
// _verifyServiceInfo
|
45
|
+
error UnexpectedServiceVersion(VersionPart expected, VersionPart found);
|
46
|
+
error UnexpectedServiceDomain(ObjectType expected, ObjectType found);
|
47
|
+
|
48
|
+
// _verifyAndStoreConfig
|
49
|
+
error ConfigMissing();
|
50
|
+
error ConfigServiceDomainInvalid(uint configArrayIndex, ObjectType domain);
|
51
|
+
error ConfigSelectorZero(uint configArrayIndex);
|
52
|
+
error SelectorAlreadyExists(VersionPart releaseVersion, ObjectType serviceDomain);
|
53
|
+
|
54
|
+
|
55
|
+
RegistryAccessManager private immutable _accessManager;
|
56
|
+
IRegistry private immutable _registry;
|
57
|
+
|
58
|
+
VersionPart immutable _initial;// first active version
|
59
|
+
VersionPart _latest;// latest active version
|
60
|
+
VersionPart _next;// version to create and activate
|
61
|
+
|
62
|
+
mapping(VersionPart version => IRegistry.ReleaseInfo info) _release;
|
63
|
+
|
64
|
+
mapping(VersionPart version => mapping(ObjectType serviceDomain => bytes4)) _selector; // registry service function selector assigned to domain
|
65
|
+
|
66
|
+
uint _awaitingRegistration; // "services left to register" counter
|
67
|
+
|
68
|
+
mapping(address registryService => bool isActive) _active;
|
69
|
+
|
70
|
+
mapping(VersionPart version => bool isValid) _valid; // TODO refactor to use _active only
|
71
|
+
|
72
|
+
constructor(
|
73
|
+
RegistryAccessManager accessManager,
|
74
|
+
VersionPart initialVersion)
|
75
|
+
AccessManaged(accessManager.authority())
|
76
|
+
{
|
77
|
+
require(initialVersion.toInt() > 0, "ReleaseManager: initial version is 0");
|
78
|
+
|
79
|
+
_accessManager = accessManager;
|
80
|
+
|
81
|
+
_initial = initialVersion;
|
82
|
+
_next = initialVersion;
|
83
|
+
|
84
|
+
_registry = new Registry();
|
85
|
+
}
|
86
|
+
|
87
|
+
/// @dev skips previous release if was not activated
|
88
|
+
function createNextRelease()
|
89
|
+
external
|
90
|
+
restricted // GIF_ADMIN_ROLE
|
91
|
+
{
|
92
|
+
// allow to register new registry service for next version
|
93
|
+
VersionPartLib.toVersionPart(_next.toInt() + 1);
|
94
|
+
// disallow registration of regular services for next version while registry service is not registered
|
95
|
+
_awaitingRegistration = 0;
|
96
|
+
|
97
|
+
emit LogReleaseCreation(_next);
|
98
|
+
}
|
99
|
+
|
100
|
+
function activateNextRelease()
|
101
|
+
external
|
102
|
+
restricted // GIF_ADMIN_ROLE
|
103
|
+
{
|
104
|
+
VersionPart version = _next;
|
105
|
+
address service = _registry.getServiceAddress(REGISTRY(), version);
|
106
|
+
|
107
|
+
// release was created
|
108
|
+
if(service == address(0)) {
|
109
|
+
revert ReleaseNotCreated();
|
110
|
+
}
|
111
|
+
|
112
|
+
// release fully deployed
|
113
|
+
if(_awaitingRegistration > 0) {
|
114
|
+
revert ReleaseRegistrationNotFinished();
|
115
|
+
}
|
116
|
+
|
117
|
+
//setTargetClosed(service, false);
|
118
|
+
|
119
|
+
_latest = version;
|
120
|
+
|
121
|
+
_active[service] = true;
|
122
|
+
_valid[version] = true;
|
123
|
+
|
124
|
+
emit LogReleaseActivation(version);
|
125
|
+
}
|
126
|
+
|
127
|
+
// TODO deploy proxy and initialize with given implementation instead of using given proxy?
|
128
|
+
// IMPORTANT: MUST never be possible to create with access/release manager, token registry
|
129
|
+
// callable once per release after release creation, can not register regular services while registry service is not registered
|
130
|
+
function registerRegistryService(IRegistryService service)
|
131
|
+
external
|
132
|
+
restricted // GIF_MANAGER_ROLE
|
133
|
+
returns(NftId nftId)
|
134
|
+
{
|
135
|
+
if(!service.supportsInterface(type(IRegistryService).interfaceId)) {
|
136
|
+
revert NotRegistryService();
|
137
|
+
}
|
138
|
+
|
139
|
+
// TODO unreliable! MUST guarantee the same authority -> how?
|
140
|
+
address serviceAuthority = service.authority();
|
141
|
+
if(serviceAuthority != authority()) {
|
142
|
+
revert UnexpectedServiceAuthority(
|
143
|
+
authority(),
|
144
|
+
serviceAuthority);
|
145
|
+
}
|
146
|
+
|
147
|
+
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
148
|
+
|
149
|
+
VersionPart version = _next;
|
150
|
+
ObjectType domain = REGISTRY();
|
151
|
+
_verifyServiceInfo(info, version, domain);
|
152
|
+
|
153
|
+
// data: config bytes
|
154
|
+
_createRelease(service.getFunctionConfigs());
|
155
|
+
|
156
|
+
//setTargetClosed(service, true);
|
157
|
+
|
158
|
+
nftId = _registry.registerService(info, version, domain);
|
159
|
+
|
160
|
+
// external call
|
161
|
+
service.linkToRegisteredNftId();
|
162
|
+
}
|
163
|
+
|
164
|
+
// TODO adding service to release -> synchronized with proxy upgrades or simple addServiceToRelease(service, version, selector)?
|
165
|
+
// TODO removing service from release? -> set _active to false forever, but keep all other records?
|
166
|
+
function registerService(IService service)
|
167
|
+
external
|
168
|
+
restricted // GIF_MANAGER_ROLE
|
169
|
+
returns(NftId nftId)
|
170
|
+
{
|
171
|
+
if(!service.supportsInterface(type(IService).interfaceId)) {
|
172
|
+
revert NotService();
|
173
|
+
}
|
174
|
+
|
175
|
+
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
176
|
+
VersionPart version = getNextVersion();
|
177
|
+
ObjectType domain = _release[version].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
|
178
|
+
_verifyServiceInfo(info, version, domain);
|
179
|
+
|
180
|
+
// setup and grant unique role if service does registrations
|
181
|
+
bytes4[] memory selector = new bytes4[](1);
|
182
|
+
selector[0] = _selector[version][domain];
|
183
|
+
address registryService = _registry.getServiceAddress(REGISTRY(), version);
|
184
|
+
if(selector[0] != 0) {
|
185
|
+
_accessManager.setAndGrantUniqueRole(
|
186
|
+
address(service),
|
187
|
+
registryService,
|
188
|
+
selector);
|
189
|
+
}
|
190
|
+
|
191
|
+
_awaitingRegistration--;
|
192
|
+
|
193
|
+
nftId = _registry.registerService(info, version, domain);
|
194
|
+
|
195
|
+
// external call
|
196
|
+
service.linkToRegisteredNftId();
|
197
|
+
}
|
198
|
+
|
199
|
+
//--- view functions ----------------------------------------------------//
|
200
|
+
|
201
|
+
function isActiveRegistryService(address service) external view returns(bool)
|
202
|
+
{
|
203
|
+
return _active[service];
|
204
|
+
}
|
205
|
+
|
206
|
+
function isValidRelease(VersionPart version) external view returns(bool)
|
207
|
+
{
|
208
|
+
return _valid[version];
|
209
|
+
}
|
210
|
+
|
211
|
+
function getRegistry() external view returns(address)
|
212
|
+
{
|
213
|
+
return (address(_registry));
|
214
|
+
}
|
215
|
+
|
216
|
+
function getReleaseInfo(VersionPart version) external view returns(IRegistry.ReleaseInfo memory)
|
217
|
+
{
|
218
|
+
return _release[version];
|
219
|
+
}
|
220
|
+
|
221
|
+
function getNextVersion() public view returns(VersionPart)
|
222
|
+
{
|
223
|
+
return _next;
|
224
|
+
}
|
225
|
+
|
226
|
+
function getLatestVersion() external view returns(VersionPart) {
|
227
|
+
return _latest;
|
228
|
+
}
|
229
|
+
|
230
|
+
function getInitialVersion() external view returns(VersionPart) {
|
231
|
+
return _initial;
|
232
|
+
}
|
233
|
+
|
234
|
+
//--- private functions ----------------------------------------------------//
|
235
|
+
|
236
|
+
function _getAndVerifyContractInfo(
|
237
|
+
IService service,
|
238
|
+
ObjectType expectedType,
|
239
|
+
address expectedOwner // assume always valid, can not be 0
|
240
|
+
)
|
241
|
+
internal
|
242
|
+
// view
|
243
|
+
returns(
|
244
|
+
IRegistry.ObjectInfo memory info
|
245
|
+
)
|
246
|
+
{
|
247
|
+
info = service.getInitialInfo();
|
248
|
+
info.objectAddress = address(service);
|
249
|
+
info.isInterceptor = false; // service is never interceptor, at least now
|
250
|
+
|
251
|
+
if(info.objectType != expectedType) {// type is checked in registry anyway...but service logic may depend on expected value
|
252
|
+
revert UnexpectedRegisterableType(expectedType, info.objectType);
|
253
|
+
}
|
254
|
+
|
255
|
+
address owner = info.initialOwner;
|
256
|
+
|
257
|
+
if(owner != expectedOwner) { // registerable owner protection
|
258
|
+
revert NotRegisterableOwner(expectedOwner);
|
259
|
+
}
|
260
|
+
|
261
|
+
if(owner == address(service)) {
|
262
|
+
revert SelfRegistration();
|
263
|
+
}
|
264
|
+
|
265
|
+
if(_registry.isRegistered(owner)) {
|
266
|
+
revert RegisterableOwnerIsRegistered();
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
function _verifyServiceInfo(
|
271
|
+
IRegistry.ObjectInfo memory info,
|
272
|
+
VersionPart expectedVersion,
|
273
|
+
ObjectType expectedDomain
|
274
|
+
)
|
275
|
+
internal
|
276
|
+
view
|
277
|
+
returns(ObjectType)
|
278
|
+
{
|
279
|
+
(
|
280
|
+
ObjectType domain,
|
281
|
+
VersionPart version
|
282
|
+
) = abi.decode(info.data, (ObjectType, VersionPart));
|
283
|
+
|
284
|
+
if(version != expectedVersion) {
|
285
|
+
revert UnexpectedServiceVersion(expectedVersion, version);
|
286
|
+
}
|
287
|
+
|
288
|
+
if(domain != expectedDomain) {
|
289
|
+
revert UnexpectedServiceDomain(expectedDomain, domain);
|
290
|
+
}
|
291
|
+
|
292
|
+
return domain;
|
293
|
+
}
|
294
|
+
|
295
|
+
// TODO check if registry supports types specified in the config array
|
296
|
+
function _createRelease(IRegistryService.FunctionConfig[] memory config)
|
297
|
+
internal
|
298
|
+
{
|
299
|
+
VersionPart version = getNextVersion();
|
300
|
+
|
301
|
+
if(config.length == 0) {
|
302
|
+
revert ConfigMissing();
|
303
|
+
}
|
304
|
+
// always in release
|
305
|
+
_release[version].domains.push(REGISTRY());
|
306
|
+
for(uint idx = 0; idx < config.length; idx++)
|
307
|
+
{
|
308
|
+
ObjectType domain = config[idx].serviceDomain;
|
309
|
+
bytes4 selector = config[idx].selector;
|
310
|
+
|
311
|
+
// not "registry service" / zero domain
|
312
|
+
if(
|
313
|
+
domain == REGISTRY() ||
|
314
|
+
domain.eqz()
|
315
|
+
) { revert ConfigServiceDomainInvalid(idx, domain); }
|
316
|
+
|
317
|
+
// TODO can be zero -> e.g. duplicate domain, first with zero selector, second with non zero selector -> need to check _release[version].domains.contains(domain) instead
|
318
|
+
// no overwrite
|
319
|
+
if(_selector[version][domain] > 0) {
|
320
|
+
revert SelectorAlreadyExists(version, domain);
|
321
|
+
}
|
322
|
+
|
323
|
+
_selector[version][domain] = selector;
|
324
|
+
_release[version].domains.push(domain);
|
325
|
+
}
|
326
|
+
// TODO set when activated?
|
327
|
+
_release[version].createdAt = TimestampLib.blockTimestamp();
|
328
|
+
//_release[version].updatedAt = TimestampLib.blockTimestamp();
|
329
|
+
|
330
|
+
_awaitingRegistration = config.length;
|
331
|
+
}
|
332
|
+
}
|
@@ -6,16 +6,14 @@ import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165C
|
|
6
6
|
|
7
7
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
8
8
|
import {IRegistry} from "./IRegistry.sol";
|
9
|
-
import {
|
9
|
+
import {VersionPart} from "../types/Version.sol";
|
10
|
+
import {REGISTRY} from "../types/ObjectType.sol";
|
10
11
|
import {NftOwnable} from "../shared/NftOwnable.sol";
|
11
12
|
|
12
13
|
/// @title contract to register token per GIF major release.
|
13
14
|
contract TokenRegistry is
|
14
15
|
NftOwnable
|
15
16
|
{
|
16
|
-
|
17
|
-
string public constant REGISTRY_SERVICE_NAME = "RegistryService";
|
18
|
-
|
19
17
|
event LogRegistered(address token, string symbol, uint256 decimals);
|
20
18
|
event LogTokenStateSet(address token, VersionPart majorVersion, bool active);
|
21
19
|
|
@@ -34,12 +32,15 @@ contract TokenRegistry is
|
|
34
32
|
|
35
33
|
|
36
34
|
/// @dev link ownership of token registry to nft owner of registry service
|
35
|
+
// TODO latter registry service will get new release, new address, new nft, TokenRegistry will not catch that -> use AccessManaged only for services
|
37
36
|
function linkToNftOwnable(address registryAddress)
|
38
37
|
external
|
39
38
|
onlyOwner
|
40
39
|
{
|
41
40
|
IRegistry registry = IRegistry(registryAddress);
|
42
|
-
|
41
|
+
// TODO use _latest instead of _initial -> but _latest is 0 before first release activation
|
42
|
+
address registryServiceAddress = registry.getServiceAddress(REGISTRY(), registry.getNextVersion());
|
43
|
+
//address registryServiceAddress = registry.getServiceAddress(REGISTRY(), registry.getInitialVersion());
|
43
44
|
|
44
45
|
_linkToNftOwnable(registryAddress, registryServiceAddress);
|
45
46
|
}
|
@@ -59,7 +60,7 @@ contract TokenRegistry is
|
|
59
60
|
// verify valid major version
|
60
61
|
// ensure major version increments is one
|
61
62
|
uint256 version = majorVersion.toInt();
|
62
|
-
if (
|
63
|
+
if (!_registry.isValidRelease(majorVersion)) {
|
63
64
|
revert TokenMajorVersionInvalid(majorVersion);
|
64
65
|
}
|
65
66
|
|
@@ -80,7 +81,7 @@ contract TokenRegistry is
|
|
80
81
|
return _registered[token];
|
81
82
|
}
|
82
83
|
|
83
|
-
|
84
|
+
function isActive(address token, VersionPart majorVersion) external view returns (bool) {
|
84
85
|
return _active[token][majorVersion];
|
85
86
|
}
|
86
87
|
|
@@ -5,13 +5,11 @@ 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";
|
8
|
-
import {NftId} from "../types/NftId.sol";
|
9
|
-
import {ObjectType} from "../types/ObjectType.sol";
|
10
8
|
|
11
9
|
interface IRegisterable is IERC165, INftOwnable {
|
12
10
|
|
13
11
|
function getInitialInfo()
|
14
12
|
external
|
15
13
|
view
|
16
|
-
returns (IRegistry.ObjectInfo memory
|
14
|
+
returns (IRegistry.ObjectInfo memory);
|
17
15
|
}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {VersionPart} from "../types/Version.sol";
|
5
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
5
6
|
|
6
7
|
import {IRegisterable} from "./IRegisterable.sol";
|
7
8
|
import {IVersionable} from "./IVersionable.sol";
|
@@ -10,6 +11,6 @@ interface IService is
|
|
10
11
|
IRegisterable,
|
11
12
|
IVersionable
|
12
13
|
{
|
13
|
-
function
|
14
|
+
function getDomain() external pure returns(ObjectType serviceDomain);
|
14
15
|
function getMajorVersion() external view returns(VersionPart majorVersion);
|
15
16
|
}
|
@@ -5,8 +5,10 @@ import {INftOwnable} from "./INftOwnable.sol";
|
|
5
5
|
import {IRegistry} from "../registry/IRegistry.sol";
|
6
6
|
import {NftId, zeroNftId} from "../types/NftId.sol";
|
7
7
|
|
8
|
+
// TODO make contract upgradeable
|
8
9
|
contract NftOwnable is INftOwnable {
|
9
10
|
|
11
|
+
// TODO move vars to struct and add _getNftOwnableStorage
|
10
12
|
IRegistry internal _registry;
|
11
13
|
NftId private _nftId;
|
12
14
|
address private _initialOwner;
|
@@ -55,6 +57,9 @@ contract NftOwnable is INftOwnable {
|
|
55
57
|
return _nftId;
|
56
58
|
}
|
57
59
|
|
60
|
+
function getInitialOwner() public view returns (address) {
|
61
|
+
return _initialOwner;
|
62
|
+
}
|
58
63
|
|
59
64
|
function getOwner() public view virtual override returns (address) {
|
60
65
|
if (_nftId.gtz()) {
|
@@ -38,6 +38,7 @@ contract ProxyManager is
|
|
38
38
|
returns (IVersionable versionable)
|
39
39
|
{
|
40
40
|
if (_isDeployed) { revert ErrorAlreadyDeployed(); }
|
41
|
+
_isDeployed = true;
|
41
42
|
|
42
43
|
address currentProxyOwner = getOwner(); // used by implementation
|
43
44
|
address initialProxyAdminOwner = address(this); // used by proxy
|
@@ -49,7 +50,6 @@ contract ProxyManager is
|
|
49
50
|
data
|
50
51
|
);
|
51
52
|
|
52
|
-
_isDeployed = true;
|
53
53
|
versionable = IVersionable(address(_proxy));
|
54
54
|
|
55
55
|
emit LogProxyDeployed(address(_proxy), initialImplementation);
|
@@ -71,20 +71,16 @@ contract Registerable is
|
|
71
71
|
public
|
72
72
|
view
|
73
73
|
virtual
|
74
|
-
returns (IRegistry.ObjectInfo memory
|
74
|
+
returns (IRegistry.ObjectInfo memory info)
|
75
75
|
{
|
76
|
-
RegisterableStorage
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
$._data
|
86
|
-
),
|
87
|
-
bytes("")
|
88
|
-
);
|
76
|
+
RegisterableStorage memory $ = _getRegisterableStorage();
|
77
|
+
info = IRegistry.ObjectInfo(
|
78
|
+
zeroNftId(),
|
79
|
+
$._parentNftId,
|
80
|
+
$._objectType,
|
81
|
+
$._isInterceptor,
|
82
|
+
address(this),
|
83
|
+
getInitialOwner(),
|
84
|
+
$._data);
|
89
85
|
}
|
90
86
|
}
|
@@ -1,21 +1,26 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {IService} from "./IService.sol";
|
6
|
-
import {IVersionable} from "./IVersionable.sol";
|
4
|
+
import {ObjectType, SERVICE} from "../types/ObjectType.sol";
|
7
5
|
import {NftId, zeroNftId} from "../types/NftId.sol";
|
8
|
-
import {RegisterableUpgradable} from "./RegisterableUpgradable.sol";
|
9
|
-
import {SERVICE} from "../types/ObjectType.sol";
|
10
6
|
import {Version, VersionPart, VersionLib} from "../types/Version.sol";
|
7
|
+
|
8
|
+
import {Versionable} from "./Versionable.sol";
|
9
|
+
import {IService} from "./IService.sol";
|
10
|
+
import {IVersionable} from "./IVersionable.sol";
|
11
11
|
import {Versionable} from "./Versionable.sol";
|
12
|
+
import {Registerable} from "./Registerable.sol";
|
13
|
+
|
14
|
+
import {IRegistry} from "../registry/IRegistry.sol";
|
15
|
+
|
12
16
|
|
13
17
|
/// @dev service base contract
|
14
18
|
abstract contract Service is
|
15
|
-
|
19
|
+
Registerable,
|
20
|
+
Versionable,
|
16
21
|
IService
|
17
22
|
{
|
18
|
-
function
|
23
|
+
function getDomain() public pure virtual override returns(ObjectType);
|
19
24
|
|
20
25
|
function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
|
21
26
|
return getVersion().toMajorPart();
|
@@ -40,7 +45,7 @@ abstract contract Service is
|
|
40
45
|
//onlyInitializing //TODO uncomment when "fully" upgradeable
|
41
46
|
{
|
42
47
|
// service must provide its name and version upon registration
|
43
|
-
bytes memory data = abi.encode(
|
48
|
+
bytes memory data = abi.encode(getDomain(), getMajorVersion());
|
44
49
|
NftId registryNftId = _getRegistryNftId(registry);
|
45
50
|
bool isInterceptor = false;
|
46
51
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {ObjectType, PRODUCT} from "../../contracts/types/ObjectType.sol";
|
4
5
|
import {NftId} from "../../contracts/types/NftId.sol";
|
5
6
|
import {Version, VersionLib} from "../../contracts/types/Version.sol";
|
6
7
|
import {Service} from "../../contracts/shared/Service.sol";
|
@@ -18,7 +19,7 @@ contract TestService is Service {
|
|
18
19
|
_initializeService(registry, initialOwner);
|
19
20
|
}
|
20
21
|
|
21
|
-
function
|
22
|
-
return
|
22
|
+
function getDomain() public pure override returns(ObjectType) {
|
23
|
+
return PRODUCT();
|
23
24
|
}
|
24
25
|
}
|
@@ -11,35 +11,37 @@ library LibNftIdSet {
|
|
11
11
|
mapping(NftId nftid => uint256 index) at;
|
12
12
|
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
error ErrorNftIdSetAlreadyAdded(NftId nftId);
|
15
|
+
error ErrorNftIdSetNotInSet(NftId nftId);
|
16
|
+
|
17
|
+
|
18
|
+
function add(Set storage set, NftId nftId) external {
|
19
|
+
if (set.at[nftId] > 0) {
|
20
|
+
revert ErrorNftIdSetAlreadyAdded(nftId);
|
21
21
|
}
|
22
|
+
|
23
|
+
set.ids.push(nftId);
|
24
|
+
set.at[nftId] = set.ids.length;
|
22
25
|
}
|
23
26
|
|
24
|
-
function remove(Set storage set, NftId nftId) external
|
27
|
+
function remove(Set storage set, NftId nftId) external {
|
25
28
|
uint256 nftIdIndex = set.at[nftId];
|
26
29
|
|
27
|
-
if (nftIdIndex
|
28
|
-
|
29
|
-
uint256 lastIndex = set.ids.length - 1;
|
30
|
-
|
31
|
-
if (lastIndex != toDeleteIndex) {
|
32
|
-
NftId lastId = set.ids[lastIndex];
|
33
|
-
set.ids[toDeleteIndex] = lastId;
|
34
|
-
set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
|
35
|
-
}
|
36
|
-
|
37
|
-
set.ids.pop();
|
38
|
-
delete set.at[nftId];
|
39
|
-
return true;
|
40
|
-
} else {
|
41
|
-
return false;
|
30
|
+
if (nftIdIndex == 0) {
|
31
|
+
revert ErrorNftIdSetNotInSet(nftId);
|
42
32
|
}
|
33
|
+
|
34
|
+
uint256 toDeleteIndex = nftIdIndex - 1;
|
35
|
+
uint256 lastIndex = set.ids.length - 1;
|
36
|
+
|
37
|
+
if (lastIndex != toDeleteIndex) {
|
38
|
+
NftId lastId = set.ids[lastIndex];
|
39
|
+
set.ids[toDeleteIndex] = lastId;
|
40
|
+
set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
|
41
|
+
}
|
42
|
+
|
43
|
+
set.ids.pop();
|
44
|
+
delete set.at[nftId];
|
43
45
|
}
|
44
46
|
|
45
47
|
function isEmpty(Set storage set) external view returns(bool empty) {
|
@@ -50,7 +52,7 @@ library LibNftIdSet {
|
|
50
52
|
return set.at[nftId] > 0;
|
51
53
|
}
|
52
54
|
|
53
|
-
function
|
55
|
+
function size(Set storage set) external view returns(uint256 length) {
|
54
56
|
return set.ids.length;
|
55
57
|
}
|
56
58
|
|
@@ -24,23 +24,23 @@ function PRODUCT_OWNER_ROLE_NAME() pure returns (string memory) { return "Produc
|
|
24
24
|
|
25
25
|
function ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(0); }
|
26
26
|
|
27
|
-
// TODO correct numbers (maybe they are already defined in RegistryService)
|
28
27
|
function DISTRIBUTION_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(100); }
|
29
28
|
function ORACLE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(200); }
|
30
29
|
function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(300); }
|
31
30
|
function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(400); }
|
32
31
|
|
33
|
-
function DISTRIBUTION_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1000); }
|
34
|
-
function POLICY_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1100); }
|
35
|
-
function BUNDLE_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1200); }
|
36
|
-
function POOL_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1300); }
|
37
|
-
function PRODUCT_REGISTRAR_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1400); }
|
38
32
|
|
39
|
-
function
|
40
|
-
function
|
41
|
-
function
|
33
|
+
function INSTANCE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2000); }
|
34
|
+
function DISTRIBUTION_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2100); }
|
35
|
+
function POOL_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2200); }
|
36
|
+
function PRODUCT_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2300); }
|
37
|
+
function POLICY_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2400); }
|
38
|
+
function BUNDLE_SERVICE_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(2500); }
|
42
39
|
|
43
|
-
|
40
|
+
|
41
|
+
function GIF_ADMIN_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1500); }
|
42
|
+
function GIF_MANAGER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1600); }
|
43
|
+
function RELEASE_MANAGER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId(1700); }
|
44
44
|
|
45
45
|
// @dev Returns true iff role ids a and b are identical
|
46
46
|
function eqRoleId(RoleId a, RoleId b) pure returns (bool isSame) {
|
package/package.json
CHANGED