@etherisc/gif-next 0.0.2-edd8f00-238 → 0.0.2-ee0f913-209
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 +2 -2
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +2 -2
- 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/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.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 +2 -2
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +2 -2
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +84 -83
- package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.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/mock/Dip.sol/Dip.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
- package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +2 -2
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +2 -2
- package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleService.sol/BundleService.json +2 -2
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +2 -2
- 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 +2 -2
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +2 -2
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +2 -2
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +2 -2
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +2 -2
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +2 -2
- 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 +2 -2
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +2 -2
- package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
- package/artifacts/contracts/product/PricingService.sol/PricingService.json +2 -2
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +2 -2
- 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 +2 -2
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +2 -2
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/registry/IServiceAuthorization.sol/IServiceAuthorization.json +0 -19
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +2 -2
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +2 -2
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +154 -170
- package/artifacts/contracts/registry/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorization.sol/ServiceAuthorization.json +4 -23
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
- package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +4 -23
- 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/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.dbg.json +1 -1
- package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.dbg.json +1 -1
- package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.dbg.json +1 -1
- package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.dbg.json +1 -1
- package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.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/ComponentService.sol/ComponentService.json +26 -26
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +14 -14
- package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.dbg.json +1 -1
- package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
- package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +5 -11
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +5 -0
- 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/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
- package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +22 -21
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +42 -4
- package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
- 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/IStaking.sol/IStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +2 -2
- package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/staking/Staking.sol/Staking.json +2 -2
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +2 -2
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +2 -2
- package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingService.sol/StakingService.json +2 -2
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +2 -2
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
- package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +143 -142
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
- package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +2 -2
- 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/RequestId.sol/RequestIdLib.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/Seconds.sol/SecondsLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
- package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
- package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/type/String.sol/StrLib.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/instance/InstanceStore.sol +3 -6
- package/contracts/registry/IServiceAuthorization.sol +0 -3
- package/contracts/registry/ReleaseManager.sol +133 -129
- package/contracts/registry/ServiceAuthorization.sol +0 -4
- package/contracts/shared/ComponentService.sol +1 -4
- package/contracts/shared/IKeyValueStore.sol +0 -1
- package/contracts/shared/ILifecycle.sol +2 -1
- package/contracts/shared/KeyValueStore.sol +1 -5
- package/contracts/shared/Lifecycle.sol +66 -7
- package/contracts/staking/StakingStore.sol +1 -3
- package/package.json +1 -1
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +0 -182
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +0 -4
- package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +0 -187
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +0 -4
- package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +0 -187
- package/contracts/instance/base/ObjectLifecycle.sol +0 -96
- package/contracts/registry/ReleaseLifecycle.sol +0 -28
- package/contracts/staking/StakingLifecycle.sol +0 -24
@@ -14,7 +14,7 @@ import {ObjectType, ObjectTypeLib, POOL, RELEASE, REGISTRY, SERVICE, STAKING} fr
|
|
14
14
|
import {Version, VersionLib, VersionPart, VersionPartLib} from "../type/Version.sol";
|
15
15
|
import {Timestamp, TimestampLib, zeroTimestamp, ltTimestamp} from "../type/Timestamp.sol";
|
16
16
|
import {Seconds, SecondsLib} from "../type/Seconds.sol";
|
17
|
-
import {StateId, INITIAL, SCHEDULED, DEPLOYING, ACTIVE
|
17
|
+
import {StateId, INITIAL, SCHEDULED, DEPLOYING, ACTIVE} from "../type/StateId.sol";
|
18
18
|
import {Version, VersionLib, VersionPart, VersionPartLib} from "../type/Version.sol";
|
19
19
|
|
20
20
|
import {IService} from "../shared/IService.sol";
|
@@ -31,12 +31,11 @@ import {IAccessAdmin} from "../shared/IAccessAdmin.sol";
|
|
31
31
|
import {RegistryAdmin} from "./RegistryAdmin.sol";
|
32
32
|
import {Registry} from "./Registry.sol";
|
33
33
|
import {TokenRegistry} from "./TokenRegistry.sol";
|
34
|
-
import {ReleaseLifecycle} from "./ReleaseLifecycle.sol";
|
35
34
|
|
36
35
|
|
37
36
|
contract ReleaseManager is
|
38
|
-
AccessManaged,
|
39
|
-
|
37
|
+
AccessManaged,
|
38
|
+
ILifecycle,
|
40
39
|
IRegistryLinked
|
41
40
|
{
|
42
41
|
using ObjectTypeLib for ObjectType;
|
@@ -45,31 +44,31 @@ contract ReleaseManager is
|
|
45
44
|
|
46
45
|
event LogReleaseCreation(VersionPart version, bytes32 salt, address authority);
|
47
46
|
event LogReleaseActivation(VersionPart version);
|
48
|
-
event LogReleaseDisabled(VersionPart version);
|
49
|
-
event LogReleaseEnabled(VersionPart version);
|
50
|
-
event LogReleaseClosed(VersionPart version);
|
51
47
|
|
52
48
|
// constructor
|
53
49
|
error ErrorReleaseManagerNotRegistry(Registry registry);
|
54
50
|
|
55
51
|
// createNextRelease
|
56
|
-
error ErrorReleaseManagerReleaseCreationDisallowed(
|
52
|
+
error ErrorReleaseManagerReleaseCreationDisallowed(StateId currentStateId);
|
57
53
|
|
58
54
|
// prepareRelease
|
59
|
-
error ErrorReleaseManagerReleasePreparationDisallowed(
|
60
|
-
error ErrorReleaseManagerReleaseAlreadyPrepared(VersionPart version
|
61
|
-
error ErrorReleaseManagerVersionMismatch(VersionPart
|
55
|
+
error ErrorReleaseManagerReleasePreparationDisallowed(StateId currentStateId);
|
56
|
+
error ErrorReleaseManagerReleaseAlreadyPrepared(VersionPart version);
|
57
|
+
error ErrorReleaseManagerVersionMismatch(VersionPart expectedVersion, VersionPart providedVersion);
|
62
58
|
error ErrorReleaseManagerNoDomains(VersionPart version);
|
63
59
|
|
60
|
+
// register staking
|
61
|
+
//error ErrorReleaseManagerStakingAlreadySet(address stakingAddress);
|
62
|
+
|
64
63
|
// registerService
|
65
64
|
error ErrorReleaseManagerNoServiceRegistrationExpected();
|
66
65
|
error ErrorReleaseManagerServiceRegistrationDisallowed(StateId currentStateId);
|
67
66
|
error ErrorReleaseManagerServiceDomainMismatch(ObjectType expectedDomain, ObjectType actualDomain);
|
68
|
-
error ErrorReleaseManagerNotService(
|
69
|
-
error
|
67
|
+
error ErrorReleaseManagerNotService(IService service);
|
68
|
+
error ErrorReleaseManagerServiceAddressInvalid(IService given, address expected);
|
70
69
|
|
71
70
|
// activateNextRelease
|
72
|
-
error ErrorReleaseManagerReleaseActivationDisallowed(
|
71
|
+
error ErrorReleaseManagerReleaseActivationDisallowed(StateId currentStateId);
|
73
72
|
error ErrorReleaseManagerReleaseNotCreated(VersionPart releaseVersion);
|
74
73
|
error ErrorReleaseManagerReleaseRegistrationNotFinished(VersionPart releaseVersion, uint awaitingRegistration);
|
75
74
|
error ErrorReleaseManagerReleaseAlreadyActivated(VersionPart releaseVersion);
|
@@ -92,9 +91,11 @@ contract ReleaseManager is
|
|
92
91
|
|
93
92
|
Seconds public constant MIN_DISABLE_DELAY = Seconds.wrap(60 * 24 * 365); // 1 year
|
94
93
|
|
95
|
-
RegistryAdmin
|
96
|
-
address public _releaseAccessManagerCodeAddress;
|
97
|
-
Registry
|
94
|
+
RegistryAdmin public immutable _admin;
|
95
|
+
address public immutable _releaseAccessManagerCodeAddress;
|
96
|
+
Registry public immutable _registry;
|
97
|
+
IRegisterable private _staking;
|
98
|
+
address private _stakingOwner;
|
98
99
|
|
99
100
|
// TODO remove once it's clear that release authority will always be registry authority
|
100
101
|
mapping(VersionPart version => address authority) internal _releaseAccessManager;
|
@@ -103,14 +104,15 @@ contract ReleaseManager is
|
|
103
104
|
|
104
105
|
mapping(VersionPart version => IServiceAuthorization authz) internal _serviceAuthorization;
|
105
106
|
|
106
|
-
VersionPart
|
107
|
+
VersionPart immutable internal _initial;// first active version
|
107
108
|
VersionPart internal _latest; // latest active version
|
108
109
|
VersionPart internal _next; // version to create and activate
|
109
|
-
|
110
|
+
StateId internal _state; // current state of release manager
|
110
111
|
|
111
112
|
uint256 internal _registeredServices;
|
112
113
|
uint256 internal _servicesToRegister;
|
113
114
|
|
115
|
+
// deployer of this contract must be gif admin
|
114
116
|
constructor(Registry registry)
|
115
117
|
AccessManaged(msg.sender)
|
116
118
|
{
|
@@ -119,31 +121,35 @@ contract ReleaseManager is
|
|
119
121
|
revert ErrorReleaseManagerNotRegistry(registry);
|
120
122
|
}
|
121
123
|
|
122
|
-
setAuthority(registry.getAuthority());
|
123
|
-
|
124
124
|
_registry = registry;
|
125
|
+
setAuthority(_registry.getAuthority());
|
125
126
|
_admin = RegistryAdmin(_registry.getRegistryAdminAddress());
|
126
127
|
|
127
128
|
_initial = VersionPartLib.toVersionPart(INITIAL_GIF_VERSION);
|
128
129
|
_next = VersionPartLib.toVersionPart(INITIAL_GIF_VERSION - 1);
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
//
|
130
|
+
_state = getInitialState(RELEASE());
|
131
|
+
|
132
|
+
AccessManagerExtendedWithDisableInitializeable masterReleaseAccessManager = new AccessManagerExtendedWithDisableInitializeable();
|
133
|
+
masterReleaseAccessManager.initialize(_registry.NFT_LOCK_ADDRESS(), VersionLib.toVersionPart(0));
|
134
|
+
//masterReleaseAccessManager.disable();
|
135
|
+
_releaseAccessManagerCodeAddress = address(masterReleaseAccessManager);
|
134
136
|
}
|
135
137
|
|
136
138
|
/// @dev skips previous release if was not activated
|
137
|
-
/// sets
|
139
|
+
/// sets release manager into state SCHEDULED
|
138
140
|
function createNextRelease()
|
139
141
|
external
|
140
142
|
restricted() // GIF_ADMIN_ROLE
|
141
143
|
returns(VersionPart)
|
142
144
|
{
|
145
|
+
if (!isValidTransition(RELEASE(), _state, SCHEDULED())) {
|
146
|
+
revert ErrorReleaseManagerReleaseCreationDisallowed(_state);
|
147
|
+
}
|
148
|
+
|
143
149
|
_next = VersionPartLib.toVersionPart(_next.toInt() + 1);
|
144
150
|
_servicesToRegister = 0;
|
145
151
|
_registeredServices = 0;
|
146
|
-
_state
|
152
|
+
_state = SCHEDULED();
|
147
153
|
|
148
154
|
return _next;
|
149
155
|
}
|
@@ -160,6 +166,8 @@ contract ReleaseManager is
|
|
160
166
|
bytes32 releaseSalt
|
161
167
|
)
|
162
168
|
{
|
169
|
+
// TODO Any call to serviceAuthorization contract must be treated as a call to an external malicious contract
|
170
|
+
// How can wrong authorizations tamper the core, releases or instances?
|
163
171
|
(
|
164
172
|
VersionPart releaseVersion,
|
165
173
|
uint serviceDomainsCount
|
@@ -175,99 +183,87 @@ contract ReleaseManager is
|
|
175
183
|
revert ErrorReleaseManagerNoDomains(_next);
|
176
184
|
}
|
177
185
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
// verify release in state SCHEDULED
|
183
|
-
if (!isValidTransition(RELEASE(), state, newState)) {
|
184
|
-
revert ErrorReleaseManagerReleasePreparationDisallowed(version, state);
|
186
|
+
// verify release manager is in proper state to start deploying a next release
|
187
|
+
if (!isValidTransition(RELEASE(), _state, DEPLOYING())) {
|
188
|
+
revert ErrorReleaseManagerReleasePreparationDisallowed(_state);
|
185
189
|
}
|
186
190
|
|
187
191
|
// verify prepareNextRelease is only called once per release
|
188
192
|
if(_servicesToRegister > 0) {
|
189
|
-
revert ErrorReleaseManagerReleaseAlreadyPrepared(version
|
193
|
+
revert ErrorReleaseManagerReleaseAlreadyPrepared(version);
|
190
194
|
}
|
191
195
|
|
196
|
+
// store release specific service authorization
|
197
|
+
_serviceAuthorization[_next] = serviceAuthorization;
|
198
|
+
|
192
199
|
// ensures unique salt
|
193
|
-
// TODO CreateX have clones capability also
|
194
|
-
// what would releaseSalt look like if used with CreateX in pemissioned mode?
|
195
200
|
releaseSalt = keccak256(
|
196
201
|
bytes.concat(
|
197
202
|
bytes32(version.toInt()),
|
198
203
|
salt));
|
199
204
|
|
200
205
|
authority = _admin.authority();
|
201
|
-
|
206
|
+
|
202
207
|
_releaseAccessManager[_next] = authority;
|
203
208
|
_servicesToRegister = serviceDomainsCount;
|
204
|
-
|
209
|
+
|
210
|
+
_state = DEPLOYING();
|
205
211
|
|
206
212
|
emit LogReleaseCreation(version, releaseSalt, authority);
|
207
213
|
}
|
208
214
|
|
209
|
-
|
215
|
+
|
210
216
|
function registerService(IService service)
|
211
217
|
external
|
212
218
|
restricted // GIF_MANAGER_ROLE
|
213
219
|
returns(NftId nftId)
|
214
220
|
{
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
// verify release in state DEPLOYING
|
220
|
-
if (!isValidTransition(RELEASE(), state, newState)) {
|
221
|
-
// TOOD name must represent failed state transition
|
222
|
-
revert ErrorReleaseManagerServiceRegistrationDisallowed(state);
|
221
|
+
// TODO is it usefull to check transition from A to A?
|
222
|
+
if (!isValidTransition(RELEASE(), _state, DEPLOYING())) {
|
223
|
+
revert ErrorReleaseManagerServiceRegistrationDisallowed(_state);
|
223
224
|
}
|
224
225
|
|
225
|
-
// not all services are registered
|
226
226
|
if (_servicesToRegister == _registeredServices) {
|
227
227
|
revert ErrorReleaseManagerNoServiceRegistrationExpected();
|
228
228
|
}
|
229
229
|
|
230
|
-
// service can work with release manager
|
231
230
|
(
|
232
231
|
IRegistry.ObjectInfo memory info,
|
233
|
-
ObjectType
|
234
|
-
VersionPart
|
232
|
+
ObjectType domain,
|
233
|
+
VersionPart version
|
235
234
|
) = _verifyService(service);
|
236
235
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
revert ErrorReleaseManagerServiceDomainMismatch(expectedDomain, serviceDomain);
|
236
|
+
ObjectType expectedDomain = _serviceAuthorization[version].getServiceDomains()[_registeredServices];
|
237
|
+
if (service.getDomain() != expectedDomain) {
|
238
|
+
revert ErrorReleaseManagerServiceDomainMismatch(expectedDomain, service.getDomain());
|
241
239
|
}
|
242
240
|
|
243
|
-
// TODO uncomment when release addresses calculations are ready
|
244
|
-
// service address matches defined in release config
|
245
|
-
/*address expectedAddress = _serviceAuthorization[releaseVersion].getServiceAddress(expectedDomain);
|
246
|
-
if(address(service) != expectedAddress) {
|
247
|
-
//revert ErrorReleaseManagerServiceAddressMismatch(expectedAddress, address(service));
|
248
|
-
}*/
|
249
|
-
|
250
241
|
// checked in registry
|
251
|
-
_releaseInfo[
|
242
|
+
_releaseInfo[version].domains.push(domain);
|
252
243
|
|
253
|
-
|
244
|
+
// register service with registry
|
245
|
+
nftId = _registry.registerService(info, version, domain);
|
254
246
|
_registeredServices++;
|
255
247
|
|
248
|
+
service.linkToRegisteredNftId();
|
249
|
+
|
256
250
|
// setup service authorization
|
257
251
|
_admin.authorizeService(
|
258
|
-
_serviceAuthorization[
|
252
|
+
_serviceAuthorization[version],
|
259
253
|
service);
|
260
254
|
|
261
255
|
// TODO consider to extend this to REGISTRY
|
262
256
|
// special roles for registry/staking/pool service
|
263
|
-
if (
|
257
|
+
if (domain == STAKING() || domain == POOL()) {
|
264
258
|
// TODO rename to grantServiceDomainRole()
|
265
|
-
_admin.grantServiceRoleForAllVersions(service,
|
259
|
+
_admin.grantServiceRoleForAllVersions(service, domain);
|
266
260
|
}
|
267
261
|
|
268
|
-
|
269
|
-
|
270
|
-
|
262
|
+
if (_registeredServices < _servicesToRegister) {
|
263
|
+
_state = DEPLOYING();
|
264
|
+
} else {
|
265
|
+
// TODO end state depends on (_awaitingRegistration == 0)
|
266
|
+
}
|
271
267
|
}
|
272
268
|
|
273
269
|
|
@@ -275,16 +271,12 @@ contract ReleaseManager is
|
|
275
271
|
external
|
276
272
|
restricted // GIF_ADMIN_ROLE
|
277
273
|
{
|
278
|
-
|
279
|
-
|
280
|
-
StateId newState = ACTIVE();
|
281
|
-
|
282
|
-
// verify release in state DEPLOYING
|
283
|
-
if (!isValidTransition(RELEASE(), state, newState)) {
|
284
|
-
revert ErrorReleaseManagerReleaseActivationDisallowed(version, state);
|
274
|
+
if (!isValidTransition(RELEASE(), _state, ACTIVE())) {
|
275
|
+
revert ErrorReleaseManagerReleaseActivationDisallowed(_state);
|
285
276
|
}
|
286
277
|
|
287
278
|
// release fully deployed
|
279
|
+
VersionPart version = _next;
|
288
280
|
if(_registeredServices < _servicesToRegister) {
|
289
281
|
revert ErrorReleaseManagerReleaseRegistrationNotFinished(version, _servicesToRegister - _registeredServices);
|
290
282
|
}
|
@@ -295,8 +287,13 @@ contract ReleaseManager is
|
|
295
287
|
revert ErrorReleaseManagerReleaseNotCreated(version);
|
296
288
|
}
|
297
289
|
|
290
|
+
// release is not activated
|
291
|
+
if(_releaseInfo[version].activatedAt.gtz()) {
|
292
|
+
revert ErrorReleaseManagerReleaseAlreadyActivated(version);
|
293
|
+
}
|
294
|
+
|
298
295
|
_latest = version;
|
299
|
-
_state
|
296
|
+
_state = ACTIVE();
|
300
297
|
|
301
298
|
_releaseVersionByAddress[service] = version;
|
302
299
|
_releaseInfo[version].activatedAt = TimestampLib.blockTimestamp();
|
@@ -304,66 +301,43 @@ contract ReleaseManager is
|
|
304
301
|
emit LogReleaseActivation(version);
|
305
302
|
}
|
306
303
|
|
307
|
-
|
308
|
-
function
|
304
|
+
// release becomes disabled after delay expiration (can be reenabled before that)
|
305
|
+
function disableRelease(VersionPart version, Seconds disableDelay)
|
309
306
|
external
|
310
307
|
restricted // GIF_ADMIN_ROLE
|
311
308
|
{
|
312
|
-
|
313
|
-
|
309
|
+
// release was activated
|
310
|
+
if(_releaseInfo[version].activatedAt.eqz()) {
|
311
|
+
revert ErrorReleaseManagerReleaseNotActivated(version);
|
312
|
+
}
|
314
313
|
|
315
|
-
//
|
316
|
-
if
|
317
|
-
revert
|
314
|
+
// release not disabled already
|
315
|
+
if(_releaseInfo[version].disabledAt.gtz()) {
|
316
|
+
revert ErrorReleaseManagerReleaseAlreadyDisabled(version);
|
318
317
|
}
|
319
318
|
|
320
|
-
|
321
|
-
//_releaseAccessManager[version].disable();
|
319
|
+
disableDelay = SecondsLib.toSeconds(Math.max(disableDelay.toInt(), MIN_DISABLE_DELAY.toInt()));
|
322
320
|
|
323
|
-
|
324
|
-
|
321
|
+
// TODO come up with a substitute
|
322
|
+
// _releaseAccessManager[version].disable(disableDelay);
|
325
323
|
|
326
|
-
|
324
|
+
_releaseInfo[version].disabledAt = TimestampLib.blockTimestamp().addSeconds(disableDelay);
|
327
325
|
}
|
328
|
-
|
329
|
-
|
330
|
-
/// @dev resume operations with release services
|
331
|
-
function unpauseRelease(VersionPart version)
|
326
|
+
|
327
|
+
function enableRelease(VersionPart version)
|
332
328
|
external
|
333
329
|
restricted // GIF_ADMIN_ROLE
|
334
330
|
{
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
//
|
339
|
-
if (!isValidTransition(RELEASE(), state, newState)) {
|
340
|
-
revert ErrorReleaseManagerReleaseActivationDisallowed(version, state);
|
341
|
-
}
|
331
|
+
// release was disabled
|
332
|
+
//if(_releaseInfo[version].disabledAt.eqz()) {
|
333
|
+
// revert ErrorReleaseManagerReleaseAlreadyEnabled(version);
|
334
|
+
//}
|
342
335
|
|
336
|
+
// reverts if disable delay expired
|
343
337
|
// TODO come up with a substitute
|
344
338
|
// _releaseAccessManager[version].enable();
|
345
339
|
|
346
|
-
_state[version] = newState;
|
347
340
|
_releaseInfo[version].disabledAt = zeroTimestamp();
|
348
|
-
|
349
|
-
emit LogReleaseEnabled(version);
|
350
|
-
}
|
351
|
-
/// @dev permanently disable release
|
352
|
-
function closeRelease(VersionPart version)
|
353
|
-
external
|
354
|
-
restricted // GIF_ADMIN_ROLE
|
355
|
-
{
|
356
|
-
StateId state = _state[version];
|
357
|
-
StateId newState = CLOSED();
|
358
|
-
|
359
|
-
// verify release in state PAUSED
|
360
|
-
if (!isValidTransition(RELEASE(), state, newState)) {
|
361
|
-
revert ErrorReleaseManagerReleaseActivationDisallowed(version, state);
|
362
|
-
}
|
363
|
-
|
364
|
-
_state[version] = newState;
|
365
|
-
|
366
|
-
emit LogReleaseClosed(version);
|
367
341
|
}
|
368
342
|
|
369
343
|
//--- view functions ----------------------------------------------------//
|
@@ -401,8 +375,8 @@ contract ReleaseManager is
|
|
401
375
|
return _initial;
|
402
376
|
}
|
403
377
|
|
404
|
-
function getState(
|
405
|
-
return _state
|
378
|
+
function getState() external view returns (StateId stateId) {
|
379
|
+
return _state;
|
406
380
|
}
|
407
381
|
|
408
382
|
function getRemainingServicesToRegister() external view returns (uint256 services) {
|
@@ -425,6 +399,37 @@ contract ReleaseManager is
|
|
425
399
|
return _registry;
|
426
400
|
}
|
427
401
|
|
402
|
+
//--- ILifecycle -----------------------------------------------------------//
|
403
|
+
|
404
|
+
function hasLifecycle(ObjectType objectType) external pure returns (bool) { return objectType == RELEASE(); }
|
405
|
+
|
406
|
+
function getInitialState(ObjectType objectType) public pure returns (StateId stateId) {
|
407
|
+
if (objectType == RELEASE()) {
|
408
|
+
stateId = INITIAL();
|
409
|
+
}
|
410
|
+
}
|
411
|
+
|
412
|
+
function isValidTransition(
|
413
|
+
ObjectType objectType,
|
414
|
+
StateId fromId,
|
415
|
+
StateId toId
|
416
|
+
)
|
417
|
+
public
|
418
|
+
pure
|
419
|
+
returns (bool isValid)
|
420
|
+
{
|
421
|
+
if (objectType != RELEASE()) { return false; }
|
422
|
+
|
423
|
+
if (fromId == INITIAL() && toId == SCHEDULED()) { return true; }
|
424
|
+
if (fromId == SCHEDULED() && toId == DEPLOYING()) { return true; }
|
425
|
+
if (fromId == DEPLOYING() && toId == SCHEDULED()) { return true; }
|
426
|
+
if (fromId == DEPLOYING() && toId == DEPLOYING()) { return true; }
|
427
|
+
if (fromId == DEPLOYING() && toId == ACTIVE()) { return true; }
|
428
|
+
// TODO active -> scheduled missing, add tests to cover this and more scenarios (#358)
|
429
|
+
|
430
|
+
return false;
|
431
|
+
}
|
432
|
+
|
428
433
|
//--- private functions ----------------------------------------------------//
|
429
434
|
|
430
435
|
function _verifyService(IService service)
|
@@ -437,7 +442,7 @@ contract ReleaseManager is
|
|
437
442
|
)
|
438
443
|
{
|
439
444
|
if(!service.supportsInterface(type(IService).interfaceId)) {
|
440
|
-
revert ErrorReleaseManagerNotService(
|
445
|
+
revert ErrorReleaseManagerNotService(service);
|
441
446
|
}
|
442
447
|
|
443
448
|
address owner = msg.sender;
|
@@ -448,7 +453,7 @@ contract ReleaseManager is
|
|
448
453
|
|
449
454
|
_verifyServiceInfo(service, serviceInfo, owner);
|
450
455
|
|
451
|
-
VersionPart releaseVersion =
|
456
|
+
VersionPart releaseVersion = getNextVersion(); // never 0
|
452
457
|
address releaseAuthority = address(_releaseAccessManager[releaseVersion]); // can be zero if registering service when release is not created
|
453
458
|
|
454
459
|
// IMPORTANT: can not guarantee service access is actually controlled by authority
|
@@ -484,7 +489,7 @@ contract ReleaseManager is
|
|
484
489
|
revert ErrorReleaseManagerServiceInfoInterceptorInvalid(service, info.isInterceptor);
|
485
490
|
}
|
486
491
|
|
487
|
-
if(info.objectType != SERVICE()) {
|
492
|
+
if(info.objectType != SERVICE()) {// type is checked in registry anyway...but service logic may depend on expected value
|
488
493
|
revert ErrorReleaseManagerServiceInfoTypeInvalid(service, SERVICE(), info.objectType);
|
489
494
|
}
|
490
495
|
|
@@ -520,4 +525,3 @@ contract ReleaseManager is
|
|
520
525
|
return true;
|
521
526
|
}
|
522
527
|
}
|
523
|
-
|
@@ -42,10 +42,6 @@ contract ServiceAuthorization
|
|
42
42
|
return _serviceDomains;
|
43
43
|
}
|
44
44
|
|
45
|
-
function getServiceDomain(uint idx) external view returns(ObjectType serviceDomain) {
|
46
|
-
return _serviceDomains[idx];
|
47
|
-
}
|
48
|
-
|
49
45
|
function getServiceAddress(ObjectType serviceDomain) external view returns(address service) {
|
50
46
|
return _serviceAddress[serviceDomain];
|
51
47
|
}
|
@@ -490,16 +490,13 @@ contract ComponentService is
|
|
490
490
|
|
491
491
|
component.linkToRegisteredNftId();
|
492
492
|
|
493
|
-
|
494
|
-
// TODO second part, may be done in different tx....
|
495
|
-
|
496
493
|
// save amended component info with instance
|
497
494
|
instanceReader = instance.getInstanceReader();
|
498
495
|
instanceStore = instance.getInstanceStore();
|
499
496
|
|
500
497
|
IComponents.ComponentInfo memory componentInfo = component.getComponentInfo();
|
501
498
|
componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
|
502
|
-
instanceStore.createComponent(
|
499
|
+
instanceStore.createComponent(component.getNftId(), componentInfo);
|
503
500
|
|
504
501
|
// configure instance authorization
|
505
502
|
_instanceService.createComponentTarget(
|
@@ -13,7 +13,6 @@ interface IKeyValueStore is ILifecycle {
|
|
13
13
|
|
14
14
|
error ErrorKeyValueStoreTypeUndefined(ObjectType objectType);
|
15
15
|
error ErrorKeyValueStoreAlreadyCreated(Key32 key, ObjectType objectType);
|
16
|
-
error ErrorKeyValueStoreNoLifecycle(ObjectType objectType);
|
17
16
|
error ErrorKeyValueStoreStateZero(Key32 key);
|
18
17
|
error ErrorKeyValueStoreNotExisting(Key32 key);
|
19
18
|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
+
import {NftId} from "../type/NftId.sol";
|
4
5
|
import {ObjectType} from "../type/ObjectType.sol";
|
5
6
|
import {StateId} from "../type/StateId.sol";
|
6
7
|
|
7
8
|
interface ILifecycle {
|
8
9
|
|
9
|
-
error ErrorNoLifecycle(ObjectType objectType);
|
10
|
+
error ErrorNoLifecycle(NftId nftId, ObjectType objectType);
|
10
11
|
error ErrorInvalidStateTransition(
|
11
12
|
ObjectType objectType,
|
12
13
|
StateId fromStateId,
|
@@ -34,12 +34,8 @@ contract KeyValueStore is
|
|
34
34
|
revert ErrorKeyValueStoreAlreadyCreated(key32, objectType);
|
35
35
|
}
|
36
36
|
|
37
|
-
if(!hasLifecycle(objectType)) {
|
38
|
-
revert ErrorKeyValueStoreNoLifecycle(objectType);
|
39
|
-
}
|
40
|
-
|
41
37
|
Blocknumber blocknumber = blockBlocknumber();
|
42
|
-
StateId initialState = getInitialState(objectType);
|
38
|
+
StateId initialState = hasLifecycle(objectType) ? getInitialState(objectType) : ACTIVE();
|
43
39
|
|
44
40
|
// set metadata
|
45
41
|
metadata.objectType = objectType;
|
@@ -8,18 +8,27 @@ import {ObjectType, COMPONENT, BUNDLE, POLICY, REQUEST, RISK, CLAIM, PAYOUT} fro
|
|
8
8
|
import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, COLLATERALIZED, REVOKED, SUBMITTED, CONFIRMED, DECLINED, EXPECTED, PAID, FULFILLED, FAILED, CANCELLED} from "../type/StateId.sol";
|
9
9
|
import {ILifecycle} from "./ILifecycle.sol";
|
10
10
|
|
11
|
-
|
11
|
+
contract Lifecycle is
|
12
12
|
Initializable,
|
13
13
|
ILifecycle
|
14
14
|
{
|
15
|
-
// TODO make private
|
16
15
|
mapping(ObjectType objectType => StateId initialState)
|
17
|
-
|
16
|
+
private _initialState;
|
18
17
|
|
19
18
|
mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
|
20
|
-
|
19
|
+
private _isValidTransition;
|
21
20
|
|
22
|
-
|
21
|
+
function initializeLifecycle()
|
22
|
+
public
|
23
|
+
onlyInitializing
|
24
|
+
{
|
25
|
+
_setupBundleLifecycle();
|
26
|
+
_setupComponentLifecycle();
|
27
|
+
_setupPolicyLifecycle();
|
28
|
+
_setupClaimAndPayoutLifecycle();
|
29
|
+
_setupRiskLifecycle();
|
30
|
+
_setupRequestLifecycle();
|
31
|
+
}
|
23
32
|
|
24
33
|
function hasLifecycle(
|
25
34
|
ObjectType objectType
|
@@ -50,9 +59,9 @@ abstract contract Lifecycle is
|
|
50
59
|
public
|
51
60
|
view
|
52
61
|
{
|
53
|
-
//
|
62
|
+
// return if no life cycle support
|
54
63
|
if (_initialState[objectType].eqz()) {
|
55
|
-
|
64
|
+
return;
|
56
65
|
}
|
57
66
|
|
58
67
|
// enforce valid state transition
|
@@ -68,4 +77,54 @@ abstract contract Lifecycle is
|
|
68
77
|
) public view returns (bool) {
|
69
78
|
return _isValidTransition[objectType][fromId][toId];
|
70
79
|
}
|
80
|
+
|
81
|
+
function _setupComponentLifecycle() internal {
|
82
|
+
_initialState[COMPONENT()] = ACTIVE();
|
83
|
+
_isValidTransition[COMPONENT()][ACTIVE()][PAUSED()] = true;
|
84
|
+
_isValidTransition[COMPONENT()][PAUSED()][ACTIVE()] = true;
|
85
|
+
_isValidTransition[COMPONENT()][PAUSED()][ARCHIVED()] = true;
|
86
|
+
}
|
87
|
+
|
88
|
+
function _setupBundleLifecycle() internal {
|
89
|
+
_initialState[BUNDLE()] = ACTIVE();
|
90
|
+
_isValidTransition[BUNDLE()][ACTIVE()][PAUSED()] = true;
|
91
|
+
_isValidTransition[BUNDLE()][ACTIVE()][CLOSED()] = true;
|
92
|
+
_isValidTransition[BUNDLE()][PAUSED()][ACTIVE()] = true;
|
93
|
+
_isValidTransition[BUNDLE()][PAUSED()][CLOSED()] = true;
|
94
|
+
}
|
95
|
+
|
96
|
+
function _setupPolicyLifecycle() internal {
|
97
|
+
_initialState[POLICY()] = APPLIED();
|
98
|
+
_isValidTransition[POLICY()][APPLIED()][REVOKED()] = true;
|
99
|
+
_isValidTransition[POLICY()][APPLIED()][DECLINED()] = true;
|
100
|
+
_isValidTransition[POLICY()][APPLIED()][COLLATERALIZED()] = true;
|
101
|
+
_isValidTransition[POLICY()][APPLIED()][ACTIVE()] = true;
|
102
|
+
_isValidTransition[POLICY()][COLLATERALIZED()][ACTIVE()] = true;
|
103
|
+
_isValidTransition[POLICY()][ACTIVE()][CLOSED()] = true;
|
104
|
+
}
|
105
|
+
|
106
|
+
function _setupClaimAndPayoutLifecycle() internal {
|
107
|
+
_initialState[CLAIM()] = SUBMITTED();
|
108
|
+
_isValidTransition[CLAIM()][SUBMITTED()][CONFIRMED()] = true;
|
109
|
+
_isValidTransition[CLAIM()][SUBMITTED()][DECLINED()] = true;
|
110
|
+
_isValidTransition[CLAIM()][CONFIRMED()][CLOSED()] = true;
|
111
|
+
|
112
|
+
_initialState[PAYOUT()] = EXPECTED();
|
113
|
+
_isValidTransition[PAYOUT()][EXPECTED()][PAID()] = true;
|
114
|
+
}
|
115
|
+
|
116
|
+
function _setupRiskLifecycle() internal {
|
117
|
+
_initialState[RISK()] = ACTIVE();
|
118
|
+
_isValidTransition[RISK()][ACTIVE()][PAUSED()] = true;
|
119
|
+
_isValidTransition[RISK()][PAUSED()][ACTIVE()] = true;
|
120
|
+
_isValidTransition[RISK()][PAUSED()][ARCHIVED()] = true;
|
121
|
+
}
|
122
|
+
|
123
|
+
function _setupRequestLifecycle() internal {
|
124
|
+
_initialState[REQUEST()] = ACTIVE();
|
125
|
+
_isValidTransition[REQUEST()][ACTIVE()][FULFILLED()] = true;
|
126
|
+
_isValidTransition[REQUEST()][ACTIVE()][FAILED()] = true;
|
127
|
+
_isValidTransition[REQUEST()][FAILED()][FULFILLED()] = true;
|
128
|
+
_isValidTransition[REQUEST()][ACTIVE()][CANCELLED()] = true;
|
129
|
+
}
|
71
130
|
}
|
@@ -28,13 +28,11 @@ import {Version, VersionLib} from "../type/Version.sol";
|
|
28
28
|
import {Versionable} from "../shared/Versionable.sol";
|
29
29
|
|
30
30
|
import {RegistryAdmin} from "../registry/RegistryAdmin.sol";
|
31
|
-
import {StakingLifecycle} from "./StakingLifecycle.sol";
|
32
31
|
|
33
32
|
|
34
33
|
contract StakingStore is
|
35
34
|
AccessManaged,
|
36
|
-
KeyValueStore
|
37
|
-
StakingLifecycle
|
35
|
+
KeyValueStore
|
38
36
|
{
|
39
37
|
|
40
38
|
event LogStakingStoreReserveBalanceIncreased(NftId targetNftId, Amount dipAmount, Amount reserveBalance, Blocknumber lastUpdatedIn);
|