@etherisc/gif-next 0.0.2-ead1eb0-841 → 0.0.2-eadf4ad-932
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +80 -80
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +97 -58
- package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +2 -2
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +2 -2
- package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +2 -2
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +24 -24
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +69 -30
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2 -2
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.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/IComponents.sol/IComponents.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/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +44 -44
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +79 -40
- package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolService.sol/PoolService.json +48 -48
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +81 -42
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +4 -4
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +68 -29
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +10 -10
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +90 -51
- package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
- package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +8 -8
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +90 -51
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +30 -30
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +77 -38
- package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/product/ProductService.sol/ProductService.json +6 -6
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +66 -27
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +73 -13
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +153 -51
- 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 +93 -25
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +48 -95
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +170 -68
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +72 -28
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +363 -76
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
- package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +1 -1
- package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +43 -14
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +4 -4
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +4 -0
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +667 -0
- package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
- package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/distribution/DistributionService.sol +8 -6
- package/contracts/distribution/DistributionServiceManager.sol +9 -6
- package/contracts/instance/InstanceService.sol +9 -16
- package/contracts/instance/InstanceServiceManager.sol +10 -20
- package/contracts/pool/BundleService.sol +13 -11
- package/contracts/pool/BundleServiceManager.sol +9 -18
- package/contracts/pool/PoolService.sol +12 -11
- package/contracts/pool/PoolServiceManager.sol +9 -18
- package/contracts/product/ApplicationService.sol +6 -5
- package/contracts/product/ApplicationServiceManager.sol +9 -6
- package/contracts/product/ClaimService.sol +6 -5
- package/contracts/product/ClaimServiceManager.sol +9 -6
- package/contracts/product/PolicyService.sol +6 -4
- package/contracts/product/PolicyServiceManager.sol +9 -21
- package/contracts/product/PricingService.sol +6 -5
- package/contracts/product/PricingServiceManager.sol +9 -18
- package/contracts/product/ProductService.sol +6 -4
- package/contracts/product/ProductServiceManager.sol +9 -21
- package/contracts/registry/IRegistry.sol +19 -12
- package/contracts/registry/IRegistryService.sol +22 -30
- package/contracts/registry/Registry.sol +40 -36
- package/contracts/registry/RegistryAccessManager.sol +39 -123
- package/contracts/registry/RegistryService.sol +22 -76
- package/contracts/registry/RegistryServiceManager.sol +21 -9
- package/contracts/registry/ReleaseManager.sol +243 -189
- package/contracts/shared/ComponentService.sol +0 -9
- package/contracts/shared/ProxyManager.sol +26 -0
- package/contracts/staking/StakingService.sol +7 -4
- package/contracts/staking/{StakeingServiceManager.sol → StakingServiceManager.sol} +8 -5
- package/contracts/type/RoleId.sol +10 -3
- package/package.json +1 -1
- package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.dbg.json +0 -4
- package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.json +0 -628
@@ -1,224 +1,243 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
5
|
+
import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
|
4
6
|
import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
|
5
7
|
|
6
8
|
import {NftId} from "../type/NftId.sol";
|
7
|
-
import {RoleId} from "../type/RoleId.sol";
|
9
|
+
import {RoleId, ADMIN_ROLE, PUBLIC_ROLE} from "../type/RoleId.sol";
|
8
10
|
import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../type/ObjectType.sol";
|
9
11
|
import {Version, VersionLib, VersionPart, VersionPartLib} from "../type/Version.sol";
|
10
12
|
import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
|
11
13
|
|
12
14
|
import {IService} from "../shared/IService.sol";
|
15
|
+
import {AccessManagerUpgradeableInitializeable} from "../shared/AccessManagerUpgradeableInitializeable.sol";
|
13
16
|
|
14
17
|
import {IRegistry} from "./IRegistry.sol";
|
15
18
|
import {Registry} from "./Registry.sol";
|
16
19
|
import {IRegistryService} from "./IRegistryService.sol";
|
17
20
|
import {RegistryAccessManager} from "./RegistryAccessManager.sol";
|
18
21
|
|
22
|
+
// gif admin is not technical, should sent simple txs
|
23
|
+
// foundation creates
|
24
|
+
// other guy deployes
|
25
|
+
// other guy checks (can precompute addresses and compare with what deployed)
|
26
|
+
// foundation activates
|
27
|
+
// TODO add function to deactivate releases
|
28
|
+
// TODO in next pr add getVersion() to releaseAccessManager only, set in initialize()
|
29
|
+
// TODO in next pr make single base for registry access manager, release access manager and instance access manager
|
19
30
|
|
20
31
|
contract ReleaseManager is AccessManaged
|
21
32
|
{
|
22
33
|
using ObjectTypeLib for ObjectType;
|
23
34
|
|
24
|
-
event LogReleaseCreation(VersionPart version);
|
35
|
+
event LogReleaseCreation(VersionPart version, bytes32 salt, AccessManagerUpgradeableInitializeable accessManager);
|
25
36
|
event LogReleaseActivation(VersionPart version);
|
26
37
|
|
27
|
-
// createNextRelease
|
28
|
-
error NotRegistryService();
|
29
|
-
error UnexpectedServiceAuthority(address expected, address found);
|
30
38
|
|
39
|
+
// prepareRelease
|
40
|
+
error ErrorReleaseManagerReleaseEmpty();
|
41
|
+
error ErrorReleaseManagerReleaseAlreadyCreated(VersionPart version);
|
42
|
+
|
31
43
|
// registerService
|
32
|
-
error
|
44
|
+
error ErrorReleaseManagerNotService(IService service);
|
45
|
+
error ErrorReleaseManagerServiceAddressInvalid(IService given, address expected);
|
33
46
|
|
34
47
|
// activateNextRelease
|
35
|
-
error
|
36
|
-
error
|
37
|
-
|
38
|
-
// _getAndVerifyContractInfo
|
39
|
-
error UnexpectedRegisterableType(ObjectType expected, ObjectType found);
|
40
|
-
error NotRegisterableOwner(address notOwner);
|
41
|
-
error SelfRegistration();
|
42
|
-
error RegisterableOwnerIsRegistered();
|
48
|
+
error ErrorReleaseManagerReleaseNotCreated(VersionPart releaseVersion);
|
49
|
+
error ErrorReleaseManagerReleaseRegistrationNotFinished(VersionPart releaseVersion, uint awaitingRegistration);
|
50
|
+
error ErrorReleaseManagerReleaseAlreadyActivated(VersionPart releaseVersion);
|
43
51
|
|
44
52
|
// _verifyService
|
45
|
-
error
|
46
|
-
error
|
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
|
-
|
53
|
+
error ErrorReleaseManagerServiceReleaseAuthorityMismatch(IService service, address serviceAuthority, address releaseAuthority);
|
54
|
+
error ErrorReleaseManagerServiceReleaseVersionMismatch(IService service, VersionPart serviceVersion, VersionPart releaseVersion);
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
// _verifyServiceInfo
|
57
|
+
error ErrorReleaseManagerServiceInfoAddressInvalid(IService service, address expected);
|
58
|
+
error ErrorReleaseManagerServiceInfoInterceptorInvalid(IService service, bool isInterceptor);
|
59
|
+
error ErrorReleaseManagerServiceInfoTypeInvalid(IService service, ObjectType expected, ObjectType found);
|
60
|
+
error ErrorReleaseManagerServiceInfoOwnerInvalid(IService service, address expected, address found);
|
61
|
+
error ErrorReleaseManagerServiceSelfRegistration(IService service);
|
62
|
+
error ErrorReleaseManagerServiceOwnerRegistered(IService service, address owner);
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
VersionPart _next;// major version to create and activate
|
64
|
+
// _verifyServiceAuthorizations
|
65
|
+
error ErrorReleaseManagerServiceRoleInvalid(address service, RoleId role);
|
61
66
|
|
62
|
-
|
67
|
+
RegistryAccessManager public immutable _accessManager;
|
68
|
+
IRegistry public immutable _registry;
|
63
69
|
|
64
|
-
|
65
|
-
mapping(VersionPart
|
70
|
+
mapping(VersionPart version => AccessManagerUpgradeableInitializeable accessManager) internal _releaseAccessManager;
|
71
|
+
mapping(VersionPart version => IRegistry.ReleaseInfo info) internal _releaseInfo;
|
72
|
+
mapping(address registryService => bool isActive) internal _active;// have access to registry
|
66
73
|
|
67
|
-
|
74
|
+
VersionPart immutable internal _initial;// first active version
|
75
|
+
VersionPart internal _latest;// latest active version
|
76
|
+
VersionPart internal _next;// version to create and activate
|
68
77
|
|
69
|
-
|
70
|
-
|
71
|
-
mapping(VersionPart majorVersion => bool isValid) _valid; // TODO refactor to use _active only
|
78
|
+
uint internal _awaitingRegistration; // "services left to register" counter
|
72
79
|
|
73
80
|
constructor(
|
74
81
|
RegistryAccessManager accessManager,
|
75
82
|
VersionPart initialVersion)
|
76
83
|
AccessManaged(accessManager.authority())
|
77
84
|
{
|
78
|
-
require(initialVersion.toInt() > 0, "ReleaseManager: initial version is 0");
|
79
|
-
|
80
85
|
_accessManager = accessManager;
|
81
|
-
|
82
86
|
_initial = initialVersion;
|
83
|
-
_next = initialVersion;
|
84
|
-
|
87
|
+
_next = VersionPartLib.toVersionPart(initialVersion.toInt() - 1);
|
85
88
|
_registry = new Registry();
|
86
89
|
}
|
87
90
|
|
88
|
-
/// @dev skips previous release if was not activated
|
89
|
-
function createNextRelease()
|
91
|
+
/// @dev skips previous release if it was not activated
|
92
|
+
function createNextRelease()
|
90
93
|
external
|
91
94
|
restricted // GIF_ADMIN_ROLE
|
95
|
+
returns(VersionPart version)
|
92
96
|
{
|
93
|
-
|
94
|
-
// TODO check/test: assignment to _next likely missing ...
|
95
|
-
VersionPartLib.toVersionPart(_next.toInt() + 1);
|
96
|
-
|
97
|
-
// disallow registration of regular services for next version while registry service is not registered
|
97
|
+
_next = VersionPartLib.toVersionPart(_next.toInt() + 1);
|
98
98
|
_awaitingRegistration = 0;
|
99
|
-
|
100
|
-
emit LogReleaseCreation(_next);
|
101
99
|
}
|
102
100
|
|
103
|
-
function
|
104
|
-
|
105
|
-
|
101
|
+
function prepareNextRelease(
|
102
|
+
address[] memory addresses,
|
103
|
+
RoleId[][] memory serviceRoles,
|
104
|
+
RoleId[][] memory functionRoles,
|
105
|
+
bytes4[][][] memory selectors,
|
106
|
+
bytes32 salt
|
107
|
+
)
|
108
|
+
external
|
109
|
+
restricted // GIF_MANAGER_ROLE
|
110
|
+
returns(address releaseAccessManagerAddress, VersionPart version, bytes32 releaseSalt)
|
106
111
|
{
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
// release was created
|
111
|
-
if(service == address(0)) {
|
112
|
-
revert ReleaseNotCreated();
|
112
|
+
if(addresses.length == 0) {
|
113
|
+
revert ErrorReleaseManagerReleaseEmpty();
|
113
114
|
}
|
114
115
|
|
115
|
-
// release fully deployed
|
116
116
|
if(_awaitingRegistration > 0) {
|
117
|
-
revert
|
117
|
+
revert ErrorReleaseManagerReleaseAlreadyCreated(version);
|
118
118
|
}
|
119
119
|
|
120
|
-
|
120
|
+
_verifyReleaseAuthorizations(addresses, serviceRoles, functionRoles, selectors);
|
121
121
|
|
122
|
-
|
122
|
+
version = getNextVersion();
|
123
123
|
|
124
|
-
|
125
|
-
|
124
|
+
_releaseInfo[version].version = version;
|
125
|
+
_releaseInfo[version].addresses = addresses;
|
126
|
+
_releaseInfo[version].serviceRoles = serviceRoles;
|
127
|
+
_releaseInfo[version].functionRoles = functionRoles;
|
128
|
+
_releaseInfo[version].selectors = selectors;
|
129
|
+
_awaitingRegistration = addresses.length;
|
126
130
|
|
127
|
-
|
131
|
+
version = getNextVersion();
|
132
|
+
// ensures unique salt
|
133
|
+
releaseSalt = keccak256(
|
134
|
+
bytes.concat(
|
135
|
+
bytes32(version.toInt()),
|
136
|
+
salt));
|
137
|
+
|
138
|
+
releaseAccessManagerAddress = Clones.cloneDeterministic(_accessManager.authority(), releaseSalt);
|
139
|
+
AccessManagerUpgradeableInitializeable releaseAccessManager = AccessManagerUpgradeableInitializeable(releaseAccessManagerAddress);
|
140
|
+
|
141
|
+
_releaseAccessManager[version] = releaseAccessManager;
|
142
|
+
|
143
|
+
releaseAccessManager.initialize(address(this));
|
144
|
+
|
145
|
+
emit LogReleaseCreation(version, releaseSalt, releaseAccessManager);
|
128
146
|
}
|
129
147
|
|
130
|
-
|
131
|
-
// IMPORTANT: MUST never be possible to create with access/release manager, token registry
|
132
|
-
// callable once per release after release creation
|
133
|
-
// can not register regular services
|
134
|
-
function registerRegistryService(IRegistryService service)
|
148
|
+
function registerService(IService service)
|
135
149
|
external
|
136
150
|
restricted // GIF_MANAGER_ROLE
|
137
151
|
returns(NftId nftId)
|
138
152
|
{
|
139
|
-
|
140
|
-
|
141
|
-
|
153
|
+
(
|
154
|
+
IRegistry.ObjectInfo memory info,
|
155
|
+
ObjectType domain,
|
156
|
+
VersionPart version
|
157
|
+
) = _verifyService(service);
|
158
|
+
|
159
|
+
uint serviceIdx = _awaitingRegistration - 1;
|
160
|
+
address serviceAddress = _releaseInfo[version].addresses[serviceIdx];
|
161
|
+
// TODO temp, while typescript addresses computation is not implemented
|
162
|
+
/*if(address(service) != serviceAddress) {
|
163
|
+
revert ErrorReleaseManagerServiceAddressInvalid(service, serviceAddress);
|
164
|
+
}*/
|
165
|
+
|
166
|
+
_setServiceAuthorizations(
|
167
|
+
_releaseAccessManager[version],
|
168
|
+
// TODO temp, while typescript addresses computation is not implemented
|
169
|
+
address(service),//serviceAddress,
|
170
|
+
_releaseInfo[version].serviceRoles[serviceIdx],
|
171
|
+
_releaseInfo[version].functionRoles[serviceIdx],
|
172
|
+
_releaseInfo[version].selectors[serviceIdx]);
|
173
|
+
|
174
|
+
_awaitingRegistration = serviceIdx;
|
175
|
+
// checked in registry
|
176
|
+
_releaseInfo[version].domains.push(domain);
|
177
|
+
|
178
|
+
nftId = _registry.registerService(info, version, domain);
|
142
179
|
|
143
|
-
// TODO unreliable! MUST guarantee the same authority -> how?
|
144
|
-
address serviceAuthority = service.authority();
|
145
|
-
if(serviceAuthority != authority()) {
|
146
|
-
revert UnexpectedServiceAuthority(
|
147
|
-
authority(),
|
148
|
-
serviceAuthority);
|
149
|
-
}
|
150
|
-
|
151
|
-
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
152
|
-
|
153
|
-
VersionPart majorVersion = _next;
|
154
|
-
ObjectType domain = REGISTRY();
|
155
|
-
_verifyService(service, majorVersion, domain);
|
156
|
-
_createRelease(service.getFunctionConfigs());
|
157
|
-
|
158
|
-
nftId = _registry.registerService(info, majorVersion, domain);
|
159
|
-
|
160
|
-
// external call
|
161
180
|
service.linkToRegisteredNftId();
|
162
181
|
}
|
163
182
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
external
|
168
|
-
restricted // GIF_MANAGER_ROLE
|
169
|
-
returns(NftId nftId)
|
183
|
+
function activateNextRelease()
|
184
|
+
external
|
185
|
+
restricted // GIF_ADMIN_ROLE
|
170
186
|
{
|
171
|
-
|
172
|
-
|
187
|
+
VersionPart version = _next;
|
188
|
+
address service = _registry.getServiceAddress(REGISTRY(), version);
|
189
|
+
|
190
|
+
// release exists, registry service is a MUST
|
191
|
+
//if(_releaseAccessManager[version] == address(0)) {
|
192
|
+
if(service == address(0)) {
|
193
|
+
revert ErrorReleaseManagerReleaseNotCreated(version);
|
194
|
+
}
|
195
|
+
|
196
|
+
// release fully deployed
|
197
|
+
if(_awaitingRegistration > 0) {
|
198
|
+
revert ErrorReleaseManagerReleaseRegistrationNotFinished(version, _awaitingRegistration);
|
173
199
|
}
|
174
200
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
_verifyService(service, majorVersion, domain);
|
179
|
-
|
180
|
-
// setup and grant unique role if service does registrations
|
181
|
-
bytes4[] memory selectors = _selectors[majorVersion][domain];
|
182
|
-
address registryService = _registry.getServiceAddress(REGISTRY(), majorVersion);
|
183
|
-
if(selectors.length > 0) {
|
184
|
-
_accessManager.setAndGrantUniqueRole(
|
185
|
-
address(service),
|
186
|
-
registryService,
|
187
|
-
selectors);
|
201
|
+
// release is not activated
|
202
|
+
if(_releaseInfo[version].activatedAt.gtz()) {
|
203
|
+
revert ErrorReleaseManagerReleaseAlreadyActivated(version);
|
188
204
|
}
|
189
|
-
|
190
|
-
_awaitingRegistration--;
|
191
205
|
|
192
|
-
|
206
|
+
_latest = version;
|
193
207
|
|
194
|
-
|
195
|
-
|
208
|
+
_active[service] = true;
|
209
|
+
_releaseInfo[version].activatedAt = TimestampLib.blockTimestamp();
|
210
|
+
|
211
|
+
emit LogReleaseActivation(version);
|
196
212
|
}
|
197
213
|
|
198
214
|
//--- view functions ----------------------------------------------------//
|
199
215
|
|
200
|
-
function
|
201
|
-
|
216
|
+
function predictDeterministicAddress(
|
217
|
+
address implementation,
|
218
|
+
bytes32 salt,
|
219
|
+
address deployer
|
220
|
+
) external pure returns (address predicted) {
|
221
|
+
return Clones.predictDeterministicAddress(implementation, salt, deployer);
|
222
|
+
}
|
223
|
+
|
224
|
+
function isActiveRegistryService(address service) external view returns(bool) {
|
202
225
|
return _active[service];
|
203
226
|
}
|
204
227
|
|
205
|
-
function isValidRelease(VersionPart version) external view returns(bool)
|
206
|
-
|
207
|
-
return _valid[version];
|
228
|
+
function isValidRelease(VersionPart version) external view returns(bool) {
|
229
|
+
return _releaseInfo[version].activatedAt.gtz();
|
208
230
|
}
|
209
231
|
|
210
|
-
function getRegistry() external view returns(address)
|
211
|
-
{
|
232
|
+
function getRegistry() external view returns(address) {
|
212
233
|
return (address(_registry));
|
213
234
|
}
|
214
235
|
|
215
|
-
function getReleaseInfo(VersionPart version) external view returns(IRegistry.ReleaseInfo memory)
|
216
|
-
|
217
|
-
return _release[version];
|
236
|
+
function getReleaseInfo(VersionPart version) external view returns(IRegistry.ReleaseInfo memory) {
|
237
|
+
return _releaseInfo[version];
|
218
238
|
}
|
219
239
|
|
220
|
-
function getNextVersion() public view returns(VersionPart)
|
221
|
-
{
|
240
|
+
function getNextVersion() public view returns(VersionPart) {
|
222
241
|
return _next;
|
223
242
|
}
|
224
243
|
|
@@ -230,99 +249,134 @@ contract ReleaseManager is AccessManaged
|
|
230
249
|
return _initial;
|
231
250
|
}
|
232
251
|
|
252
|
+
function getReleaseAccessManager(VersionPart version) external view returns(AccessManagerUpgradeableInitializeable) {
|
253
|
+
return _releaseAccessManager[version];
|
254
|
+
}
|
255
|
+
|
233
256
|
//--- private functions ----------------------------------------------------//
|
234
257
|
|
235
|
-
function
|
258
|
+
function _verifyService(IService service)
|
259
|
+
internal
|
260
|
+
returns(
|
261
|
+
IRegistry.ObjectInfo memory serviceInfo,
|
262
|
+
ObjectType serviceDomain,
|
263
|
+
VersionPart serviceVersion
|
264
|
+
)
|
265
|
+
{
|
266
|
+
if(!service.supportsInterface(type(IService).interfaceId)) {
|
267
|
+
revert ErrorReleaseManagerNotService(service);
|
268
|
+
}
|
269
|
+
|
270
|
+
address owner = msg.sender;
|
271
|
+
address serviceAuthority = service.authority();
|
272
|
+
serviceVersion = service.getVersion().toMajorPart();
|
273
|
+
serviceDomain = service.getDomain();// checked in registry
|
274
|
+
serviceInfo = service.getInitialInfo();
|
275
|
+
|
276
|
+
_verifyServiceInfo(service, serviceInfo, owner);
|
277
|
+
|
278
|
+
VersionPart releaseVersion = getNextVersion(); // never 0
|
279
|
+
address releaseAuthority = address(_releaseAccessManager[releaseVersion]); // can be zero if registering service when release is not created
|
280
|
+
|
281
|
+
// IMPORTANT: can not guarantee service access is actually controlled by authority
|
282
|
+
if(serviceAuthority != releaseAuthority) {
|
283
|
+
revert ErrorReleaseManagerServiceReleaseAuthorityMismatch(
|
284
|
+
service,
|
285
|
+
serviceAuthority,
|
286
|
+
releaseAuthority);
|
287
|
+
}
|
288
|
+
|
289
|
+
if(serviceVersion != releaseVersion) {
|
290
|
+
revert ErrorReleaseManagerServiceReleaseVersionMismatch(
|
291
|
+
service,
|
292
|
+
serviceVersion,
|
293
|
+
releaseVersion);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
function _verifyServiceInfo(
|
236
298
|
IService service,
|
237
|
-
|
299
|
+
IRegistry.ObjectInfo memory info,
|
238
300
|
address expectedOwner // assume always valid, can not be 0
|
239
301
|
)
|
240
302
|
internal
|
241
|
-
|
242
|
-
returns(
|
243
|
-
IRegistry.ObjectInfo memory info
|
244
|
-
)
|
303
|
+
view
|
245
304
|
{
|
246
|
-
info
|
247
|
-
|
248
|
-
|
305
|
+
if(info.objectAddress != address(service)) {
|
306
|
+
revert ErrorReleaseManagerServiceInfoAddressInvalid(service, address(service));
|
307
|
+
}
|
308
|
+
|
309
|
+
if(info.isInterceptor != false) { // service is never interceptor
|
310
|
+
revert ErrorReleaseManagerServiceInfoInterceptorInvalid(service, info.isInterceptor);
|
311
|
+
}
|
249
312
|
|
250
|
-
if(info.objectType !=
|
251
|
-
revert
|
313
|
+
if(info.objectType != SERVICE()) {// type is checked in registry anyway...but service logic may depend on expected value
|
314
|
+
revert ErrorReleaseManagerServiceInfoTypeInvalid(service, SERVICE(), info.objectType);
|
252
315
|
}
|
253
316
|
|
254
317
|
address owner = info.initialOwner;
|
255
318
|
|
256
319
|
if(owner != expectedOwner) { // registerable owner protection
|
257
|
-
revert
|
320
|
+
revert ErrorReleaseManagerServiceInfoOwnerInvalid(service, expectedOwner, owner);
|
258
321
|
}
|
259
322
|
|
260
323
|
if(owner == address(service)) {
|
261
|
-
revert
|
324
|
+
revert ErrorReleaseManagerServiceSelfRegistration(service);
|
262
325
|
}
|
263
326
|
|
264
327
|
if(_registry.isRegistered(owner)) {
|
265
|
-
revert
|
328
|
+
revert ErrorReleaseManagerServiceOwnerRegistered(service, owner);
|
266
329
|
}
|
267
330
|
}
|
268
331
|
|
269
|
-
function
|
270
|
-
|
271
|
-
|
272
|
-
|
332
|
+
function _verifyReleaseAuthorizations(
|
333
|
+
address[] memory serviceAddress,
|
334
|
+
RoleId[][] memory serviceRoles,
|
335
|
+
RoleId[][] memory functionRoles,
|
336
|
+
bytes4[][][] memory selectors
|
273
337
|
)
|
274
338
|
internal
|
275
339
|
view
|
276
|
-
returns(ObjectType)
|
277
340
|
{
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
341
|
+
for(uint serviceIdx = 0; serviceIdx < serviceAddress.length; serviceIdx++)
|
342
|
+
{
|
343
|
+
for(uint roleIdx = 0; roleIdx < serviceRoles[serviceIdx].length; roleIdx++)
|
344
|
+
{
|
345
|
+
RoleId role = serviceRoles[serviceIdx][roleIdx];
|
346
|
+
if(role == ADMIN_ROLE()) {
|
347
|
+
revert ErrorReleaseManagerServiceRoleInvalid(serviceAddress[serviceIdx], role);
|
348
|
+
}
|
349
|
+
}
|
286
350
|
}
|
287
|
-
|
288
|
-
|
351
|
+
// TODO no duplicate service "domain" role per release
|
352
|
+
// TODO no duplicate service roles per service
|
353
|
+
// TODO no duplicate service function roles per service
|
354
|
+
// TODO no duplicate service function selectors per service
|
289
355
|
}
|
290
356
|
|
291
|
-
|
292
|
-
|
357
|
+
function _setServiceAuthorizations(
|
358
|
+
IAccessManager accessManager,
|
359
|
+
address serviceAddress,
|
360
|
+
RoleId[] memory serviceRoles,
|
361
|
+
RoleId[] memory functionRoles,
|
362
|
+
bytes4[][] memory selectors
|
363
|
+
)
|
293
364
|
internal
|
294
365
|
{
|
295
|
-
|
296
|
-
|
297
|
-
if(config.length == 0) {
|
298
|
-
revert ConfigMissing();
|
299
|
-
}
|
300
|
-
// always in release
|
301
|
-
_release[version].domains.push(REGISTRY());
|
302
|
-
for(uint idx = 0; idx < config.length; idx++)
|
366
|
+
for(uint idx = 0; idx < functionRoles.length; idx++)
|
303
367
|
{
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
domain.eqz()
|
309
|
-
) { revert ConfigServiceDomainInvalid(idx, domain); }
|
310
|
-
|
311
|
-
bytes4[] memory selectors = config[idx].selectors;
|
312
|
-
|
313
|
-
// 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
|
314
|
-
// no overwrite
|
315
|
-
if(_selectors[version][domain].length > 0) {
|
316
|
-
revert SelectorAlreadyExists(version, domain);
|
317
|
-
}
|
318
|
-
|
319
|
-
_selectors[version][domain] = selectors;
|
320
|
-
_release[version].domains.push(domain);
|
368
|
+
accessManager.setTargetFunctionRole(
|
369
|
+
serviceAddress,
|
370
|
+
selectors[idx],
|
371
|
+
functionRoles[idx].toInt());
|
321
372
|
}
|
322
|
-
// TODO set when activated?
|
323
|
-
_release[version].createdAt = TimestampLib.blockTimestamp();
|
324
|
-
//_release[version].updatedAt = TimestampLib.blockTimestamp();
|
325
373
|
|
326
|
-
|
374
|
+
for(uint idx = 0; idx < serviceRoles.length; idx++)
|
375
|
+
{
|
376
|
+
accessManager.grantRole(
|
377
|
+
serviceRoles[idx].toInt(),
|
378
|
+
serviceAddress,
|
379
|
+
0);
|
380
|
+
}
|
327
381
|
}
|
328
382
|
}
|
@@ -26,15 +26,6 @@ abstract contract ComponentService is
|
|
26
26
|
error ErrorComponentServiceSenderNotService(address sender);
|
27
27
|
error ErrorComponentServiceComponentTypeInvalid(address component, ObjectType expectedType, ObjectType foundType);
|
28
28
|
|
29
|
-
/// @dev modifier to check if caller is a registered service
|
30
|
-
modifier onlyService() {
|
31
|
-
address caller = msg.sender;
|
32
|
-
if(!getRegistry().isRegisteredService(caller)) {
|
33
|
-
revert ErrorComponentServiceSenderNotService(caller);
|
34
|
-
}
|
35
|
-
_;
|
36
|
-
}
|
37
|
-
|
38
29
|
// view functions
|
39
30
|
|
40
31
|
function getRegistryService() public view virtual returns (IRegistryService) {
|
@@ -2,6 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
|
5
|
+
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
5
6
|
|
6
7
|
import {Blocknumber, blockNumber} from "../type/Blocknumber.sol";
|
7
8
|
import {IVersionable} from "./IVersionable.sol";
|
@@ -79,6 +80,31 @@ contract ProxyManager is
|
|
79
80
|
emit LogProxyManagerVersionableDeployed(address(_proxy), initialImplementation);
|
80
81
|
}
|
81
82
|
|
83
|
+
function deployDetermenistic(address initialImplementation, bytes memory initializationData, bytes32 salt)
|
84
|
+
public
|
85
|
+
virtual
|
86
|
+
onlyOwner()
|
87
|
+
returns (IVersionable versionable)
|
88
|
+
{
|
89
|
+
if (_versions.length > 0) {
|
90
|
+
revert ErrorProxyManagerAlreadyDeployed();
|
91
|
+
}
|
92
|
+
|
93
|
+
address currentProxyOwner = getOwner();
|
94
|
+
address initialProxyAdminOwner = address(this);
|
95
|
+
|
96
|
+
_proxy = new UpgradableProxyWithAdmin{salt: salt}(
|
97
|
+
initialImplementation,
|
98
|
+
initialProxyAdminOwner,
|
99
|
+
getDeployData(currentProxyOwner, initializationData)
|
100
|
+
);
|
101
|
+
|
102
|
+
versionable = IVersionable(address(_proxy));
|
103
|
+
_updateVersionHistory(versionable.getVersion(), initialImplementation, currentProxyOwner);
|
104
|
+
|
105
|
+
emit LogProxyManagerVersionableDeployed(address(_proxy), initialImplementation);
|
106
|
+
}
|
107
|
+
|
82
108
|
/// @dev upgrade existing contract
|
83
109
|
function upgrade(address newImplementation, bytes memory upgradeData)
|
84
110
|
public
|
@@ -143,14 +143,17 @@ contract StakingService is
|
|
143
143
|
virtual override
|
144
144
|
initializer()
|
145
145
|
{
|
146
|
-
|
147
|
-
|
148
|
-
|
146
|
+
(
|
147
|
+
address registryAddress,,
|
148
|
+
//address managerAddress
|
149
|
+
address authority
|
150
|
+
) = abi.decode(data, (address, address, address));
|
151
|
+
|
152
|
+
initializeService(registryAddress, authority, owner);
|
149
153
|
|
150
154
|
StakingServiceStorage storage $ = _getStakingServiceStorage();
|
151
155
|
$._poolService = IPoolService(_getServiceAddress(POOL()));
|
152
156
|
|
153
|
-
initializeService(registryAddress, address(0), owner);
|
154
157
|
registerInterface(type(IStakingService).interfaceId);
|
155
158
|
}
|
156
159
|
|
@@ -13,15 +13,18 @@ contract StakingServiceManager is
|
|
13
13
|
|
14
14
|
/// @dev initializes proxy manager with service implementation
|
15
15
|
constructor(
|
16
|
-
address
|
16
|
+
address authority,
|
17
|
+
address registryAddress,
|
18
|
+
bytes32 salt
|
17
19
|
)
|
18
20
|
ProxyManager(registryAddress)
|
19
21
|
{
|
20
|
-
StakingService svc = new StakingService();
|
21
|
-
bytes memory data = abi.encode(registryAddress, address(this));
|
22
|
-
IVersionable versionable =
|
22
|
+
StakingService svc = new StakingService{salt: salt}();
|
23
|
+
bytes memory data = abi.encode(registryAddress, address(this), authority);
|
24
|
+
IVersionable versionable = deployDetermenistic(
|
23
25
|
address(svc),
|
24
|
-
data
|
26
|
+
data,
|
27
|
+
salt);
|
25
28
|
|
26
29
|
_stakingService = StakingService(address(versionable));
|
27
30
|
}
|