@etherisc/gif-next 0.0.2-f30e0eb-805 → 0.0.2-f4f2d93-430
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -83
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +10 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +10 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +100 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +100 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +110 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +100 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +20 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +10 -0
- package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.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/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +34 -14
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +80 -14
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +90 -70
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +76 -57
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +21 -11
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +208 -62
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +62 -22
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +85 -30
- 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/KeyValueStore.sol/KeyValueStore.json +2 -2
- 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 +6 -6
- 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/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +124 -53
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +21 -13
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +298 -160
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +74 -14
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +104 -41
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +189 -123
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +48 -48
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +80 -14
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +142 -113
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +101 -24
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +90 -24
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +430 -14
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +136 -65
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +468 -55
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +18 -14
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +114 -51
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
- 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/IRegistryService.sol/IRegistryService.json +0 -24
- 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/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -36
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- 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/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/IService.sol/IService.json +80 -14
- 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/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/Service.sol/Service.json +86 -15
- 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/TestFee.sol/TestFee.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
- 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/Amount.sol/AmountLib.dbg.json +4 -0
- package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
- 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/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.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/Seconds.sol/SecondsLib.dbg.json +1 -1
- 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 +4 -2
- package/contracts/components/IComponent.sol +3 -1
- package/contracts/components/Pool.sol +8 -4
- package/contracts/instance/Instance.sol +1 -0
- package/contracts/instance/InstanceAccessManager.sol +16 -11
- package/contracts/instance/InstanceReader.sol +1 -0
- package/contracts/instance/InstanceService.sol +19 -19
- package/contracts/instance/base/ComponentService.sol +17 -30
- package/contracts/instance/base/KeyValueStore.sol +8 -3
- package/contracts/instance/module/IAccess.sol +2 -2
- package/contracts/instance/module/IBundle.sol +6 -4
- package/contracts/instance/module/IComponents.sol +6 -0
- package/contracts/instance/service/ApplicationService.sol +9 -9
- package/contracts/instance/service/BundleService.sol +155 -60
- package/contracts/instance/service/ClaimService.sol +3 -3
- package/contracts/instance/service/DistributionService.sol +24 -56
- package/contracts/instance/service/IBundleService.sol +53 -22
- package/contracts/instance/service/IDistributionService.sol +1 -0
- package/contracts/instance/service/IPoolService.sol +65 -1
- package/contracts/instance/service/PolicyService.sol +60 -101
- package/contracts/instance/service/PoolService.sol +132 -49
- package/contracts/instance/service/ProductService.sol +20 -51
- package/contracts/registry/IRegistryService.sol +4 -3
- package/contracts/registry/RegistryService.sol +10 -11
- package/contracts/registry/ReleaseManager.sol +20 -18
- package/contracts/shared/IService.sol +4 -6
- package/contracts/shared/Service.sol +21 -7
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/Amount.sol +60 -0
- package/contracts/types/Fee.sol +12 -5
- package/package.json +1 -1
@@ -13,6 +13,7 @@ import {IVersionable} from "../../shared/IVersionable.sol";
|
|
13
13
|
import {Versionable} from "../../shared/Versionable.sol";
|
14
14
|
import {INftOwnable} from "../../shared/INftOwnable.sol";
|
15
15
|
|
16
|
+
import {Amount} from "../../types/Amount.sol";
|
16
17
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
17
18
|
import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
|
18
19
|
import {ObjectType, POOL, BUNDLE} from "../../types/ObjectType.sol";
|
@@ -20,6 +21,7 @@ import {PUBLIC_ROLE, POOL_OWNER_ROLE, POLICY_SERVICE_ROLE, RoleId} from "../../t
|
|
20
21
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
21
22
|
import {Version, VersionLib} from "../../types/Version.sol";
|
22
23
|
import {KEEP_STATE, StateId} from "../../types/StateId.sol";
|
24
|
+
import {Seconds} from "../../types/Seconds.sol";
|
23
25
|
import {TimestampLib, zeroTimestamp} from "../../types/Timestamp.sol";
|
24
26
|
import {Version, VersionLib} from "../../types/Version.sol";
|
25
27
|
|
@@ -27,6 +29,7 @@ import {IService} from "../../shared/IService.sol";
|
|
27
29
|
import {Service} from "../../shared/Service.sol";
|
28
30
|
import {BundleManager} from "../BundleManager.sol";
|
29
31
|
import {ComponentService} from "../base/ComponentService.sol";
|
32
|
+
import {IBundleService} from "./IBundleService.sol";
|
30
33
|
import {IPoolService} from "./IPoolService.sol";
|
31
34
|
import {IRegistryService} from "../../registry/IRegistryService.sol";
|
32
35
|
import {InstanceService} from "../InstanceService.sol";
|
@@ -42,7 +45,7 @@ contract PoolService is
|
|
42
45
|
{
|
43
46
|
using NftIdLib for NftId;
|
44
47
|
|
45
|
-
|
48
|
+
IBundleService internal _bundleService;
|
46
49
|
|
47
50
|
function _initialize(
|
48
51
|
address owner,
|
@@ -57,54 +60,17 @@ contract PoolService is
|
|
57
60
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
58
61
|
// TODO while PoolService is not deployed in PoolServiceManager constructor
|
59
62
|
// owner is PoolServiceManager deployer
|
60
|
-
initializeService(registryAddress, owner);
|
63
|
+
initializeService(registryAddress, address(0), owner);
|
64
|
+
|
65
|
+
_bundleService = IBundleService(getRegistry().getServiceAddress(BUNDLE(), getVersion().toMajorPart()));
|
66
|
+
|
61
67
|
registerInterface(type(IPoolService).interfaceId);
|
62
68
|
}
|
63
69
|
|
64
|
-
function getDomain() public pure override
|
70
|
+
function getDomain() public pure override returns(ObjectType) {
|
65
71
|
return POOL();
|
66
72
|
}
|
67
73
|
|
68
|
-
/*function register(address poolAddress)
|
69
|
-
external
|
70
|
-
returns(NftId poolNftId)
|
71
|
-
{
|
72
|
-
(
|
73
|
-
IComponent component,
|
74
|
-
address owner,
|
75
|
-
IInstance instance,
|
76
|
-
NftId instanceNftId
|
77
|
-
) = _checkComponentForRegistration(
|
78
|
-
poolAddress,
|
79
|
-
POOL(),
|
80
|
-
POOL_OWNER_ROLE());
|
81
|
-
|
82
|
-
IPoolComponent pool = IPoolComponent(poolAddress);
|
83
|
-
IRegistry.ObjectInfo memory registryInfo = getRegistryService().registerPool(pool, owner);
|
84
|
-
pool.linkToRegisteredNftId();
|
85
|
-
poolNftId = registryInfo.nftId;
|
86
|
-
|
87
|
-
instance.createPoolSetup(poolNftId, pool.getSetupInfo());
|
88
|
-
|
89
|
-
bytes4[][] memory selectors = new bytes4[][](2);
|
90
|
-
selectors[0] = new bytes4[](1);
|
91
|
-
selectors[1] = new bytes4[](1);
|
92
|
-
|
93
|
-
selectors[0][0] = IPoolComponent.setFees.selector;
|
94
|
-
selectors[1][0] = IPoolComponent.verifyApplication.selector;
|
95
|
-
|
96
|
-
RoleId[] memory roles = new RoleId[](2);
|
97
|
-
roles[0] = POOL_OWNER_ROLE();
|
98
|
-
roles[1] = POLICY_SERVICE_ROLE();
|
99
|
-
|
100
|
-
getInstanceService().createGifTarget(
|
101
|
-
instanceNftId,
|
102
|
-
poolAddress,
|
103
|
-
pool.getName(),
|
104
|
-
selectors,
|
105
|
-
roles);
|
106
|
-
}*/
|
107
|
-
|
108
74
|
function register(address poolAddress)
|
109
75
|
external
|
110
76
|
returns(NftId poolNftId)
|
@@ -155,9 +121,8 @@ contract PoolService is
|
|
155
121
|
external
|
156
122
|
virtual
|
157
123
|
{
|
158
|
-
(IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
124
|
+
(NftId poolNftId, IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
159
125
|
InstanceReader instanceReader = instance.getInstanceReader();
|
160
|
-
NftId poolNftId = registryInfo.nftId;
|
161
126
|
|
162
127
|
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
163
128
|
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
@@ -174,9 +139,8 @@ contract PoolService is
|
|
174
139
|
external
|
175
140
|
virtual
|
176
141
|
{
|
177
|
-
(IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
142
|
+
(NftId poolNftId, IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
178
143
|
InstanceReader instanceReader = instance.getInstanceReader();
|
179
|
-
NftId poolNftId = registryInfo.nftId;
|
180
144
|
|
181
145
|
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
182
146
|
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
@@ -202,9 +166,8 @@ contract PoolService is
|
|
202
166
|
external
|
203
167
|
virtual
|
204
168
|
{
|
205
|
-
(IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
169
|
+
(NftId poolNftId, IRegistry.ObjectInfo memory registryInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
206
170
|
InstanceReader instanceReader = instance.getInstanceReader();
|
207
|
-
NftId poolNftId = registryInfo.nftId;
|
208
171
|
|
209
172
|
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
210
173
|
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
@@ -217,4 +180,124 @@ contract PoolService is
|
|
217
180
|
|
218
181
|
// TODO add logging
|
219
182
|
}
|
183
|
+
|
184
|
+
|
185
|
+
function createBundle(
|
186
|
+
address owner, // initial bundle owner
|
187
|
+
Fee memory fee, // fees deducted from premium that go to bundle owner
|
188
|
+
Amount stakingAmount, // staking amount - staking fees result in initial bundle capital
|
189
|
+
Seconds lifetime, // initial duration for which new policies are covered
|
190
|
+
bytes calldata filter // optional use case specific criteria that define if a policy may be covered by this bundle
|
191
|
+
)
|
192
|
+
external
|
193
|
+
virtual
|
194
|
+
returns(NftId bundleNftId)
|
195
|
+
{
|
196
|
+
(NftId poolNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
197
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
198
|
+
|
199
|
+
// TODO add implementation that takes care of staking fees
|
200
|
+
Amount stakingAfterFeesAmount = stakingAmount;
|
201
|
+
|
202
|
+
bundleNftId = _bundleService.create(
|
203
|
+
instance,
|
204
|
+
poolNftId,
|
205
|
+
owner,
|
206
|
+
fee,
|
207
|
+
stakingAfterFeesAmount,
|
208
|
+
lifetime,
|
209
|
+
filter);
|
210
|
+
|
211
|
+
emit LogPoolServiceBundleCreated(instance.getNftId(), poolNftId, bundleNftId);
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
function closeBundle(NftId bundleNftId)
|
216
|
+
external
|
217
|
+
virtual
|
218
|
+
{
|
219
|
+
(NftId poolNftId,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(POOL());
|
220
|
+
|
221
|
+
// TODO book keeping for pool collateral released outside of retention level
|
222
|
+
|
223
|
+
// releasing collateral in bundle
|
224
|
+
_bundleService.close(instance, bundleNftId);
|
225
|
+
|
226
|
+
// TODO get performance fee for pool, transfer of remaining funds + bundle fees to bundle owner
|
227
|
+
|
228
|
+
emit LogPoolServiceBundleClosed(instance.getNftId(), poolNftId, bundleNftId);
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
function lockCollateral(
|
233
|
+
IInstance instance,
|
234
|
+
NftId productNftId,
|
235
|
+
NftId applicationNftId,
|
236
|
+
IPolicy.PolicyInfo memory applicationInfo,
|
237
|
+
uint256 premiumAmount // premium amount after product and distribution fees
|
238
|
+
)
|
239
|
+
external
|
240
|
+
virtual
|
241
|
+
// TODO add restricted and granting for policy service
|
242
|
+
{
|
243
|
+
InstanceReader instanceReader = instance.getInstanceReader();
|
244
|
+
NftId poolNftId = instanceReader.getProductSetupInfo(productNftId).poolNftId;
|
245
|
+
NftId bundleNftId = applicationInfo.bundleNftId;
|
246
|
+
|
247
|
+
// TODO move this check to application creation and don't repeat this here
|
248
|
+
// ensure that pool for bundle from application matches with pool for product of application
|
249
|
+
IBundle.BundleInfo memory bundleInfo = instanceReader.getBundleInfo(bundleNftId);
|
250
|
+
if(bundleInfo.poolNftId != poolNftId) {
|
251
|
+
revert ErrorPoolServiceBundlePoolMismatch(bundleInfo.poolNftId, poolNftId);
|
252
|
+
}
|
253
|
+
|
254
|
+
IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(poolNftId);
|
255
|
+
IComponents.PoolInfo memory poolInfo = abi.decode(componentInfo.data, (IComponents.PoolInfo));
|
256
|
+
|
257
|
+
// TODO add correct required collateral calculation (collateralization level mibht be != 1, retention level might be < 1)
|
258
|
+
uint256 collateralAmount = applicationInfo.sumInsuredAmount;
|
259
|
+
|
260
|
+
// TODO add correct net premium calculation (pool fee might be > 0)
|
261
|
+
uint256 premiumAfterPoolFeeAmount = premiumAmount;
|
262
|
+
|
263
|
+
// lock collateral amount from involvedd bundle
|
264
|
+
_bundleService.lockCollateral(
|
265
|
+
instance,
|
266
|
+
applicationNftId,
|
267
|
+
bundleNftId,
|
268
|
+
collateralAmount,
|
269
|
+
premiumAfterPoolFeeAmount);
|
270
|
+
|
271
|
+
// also verify/confirm application by pool if necessary
|
272
|
+
if(poolInfo.isVerifyingApplications) {
|
273
|
+
address poolAddress = getRegistry().getObjectInfo(poolNftId).objectAddress;
|
274
|
+
IPoolComponent(poolAddress).verifyApplication(
|
275
|
+
applicationNftId,
|
276
|
+
applicationInfo.applicationData,
|
277
|
+
bundleNftId,
|
278
|
+
bundleInfo.filter,
|
279
|
+
collateralAmount);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
|
284
|
+
/// @dev releases the remaining collateral linked to the specified policy
|
285
|
+
/// may only be called by the policy service for unlocked pool components
|
286
|
+
function releaseCollateral(
|
287
|
+
IInstance instance,
|
288
|
+
NftId policyNftId,
|
289
|
+
IPolicy.PolicyInfo memory policyInfo
|
290
|
+
)
|
291
|
+
external
|
292
|
+
virtual
|
293
|
+
// TODO add restricted and granting for policy service
|
294
|
+
{
|
295
|
+
// release collateral from involved bundle
|
296
|
+
_bundleService.releaseCollateral(
|
297
|
+
instance,
|
298
|
+
policyNftId,
|
299
|
+
policyInfo.bundleNftId,
|
300
|
+
policyInfo.sumInsuredAmount);
|
301
|
+
}
|
302
|
+
|
220
303
|
}
|
@@ -60,9 +60,9 @@ contract ProductService is ComponentService, IProductService {
|
|
60
60
|
address initialOwner;
|
61
61
|
(registryAddress, initialOwner) = abi.decode(data, (address, address));
|
62
62
|
|
63
|
-
initializeService(registryAddress, owner);
|
63
|
+
initializeService(registryAddress, address(0), owner);
|
64
64
|
|
65
|
-
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(),
|
65
|
+
_poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getVersion().toMajorPart()));
|
66
66
|
|
67
67
|
registerInterface(type(IProductService).interfaceId);
|
68
68
|
}
|
@@ -129,7 +129,7 @@ contract ProductService is ComponentService, IProductService {
|
|
129
129
|
roles);
|
130
130
|
}
|
131
131
|
|
132
|
-
function getDomain() public pure override
|
132
|
+
function getDomain() public pure override returns(ObjectType) {
|
133
133
|
return PRODUCT();
|
134
134
|
}
|
135
135
|
|
@@ -147,38 +147,6 @@ contract ProductService is ComponentService, IProductService {
|
|
147
147
|
// if(wallet == address(0)) {
|
148
148
|
// revert WalletIsZero();
|
149
149
|
// }
|
150
|
-
|
151
|
-
// IRegistry.ObjectInfo memory tokenInfo = getRegistry().getObjectInfo(address(info.token));
|
152
|
-
|
153
|
-
// if(tokenInfo.objectType != TOKEN()) {
|
154
|
-
// revert InvalidToken();
|
155
|
-
// }
|
156
|
-
|
157
|
-
// IRegistry.ObjectInfo memory poolInfo = getRegistry().getObjectInfo(info.poolNftId);
|
158
|
-
|
159
|
-
// if(poolInfo.objectType != POOL()) {
|
160
|
-
// revert InvalidPool();
|
161
|
-
// }
|
162
|
-
|
163
|
-
// if(poolInfo.parentNftId != instanceNftId) {
|
164
|
-
// revert InvalidPoolsInstance();
|
165
|
-
// }
|
166
|
-
// // TODO pool have the same token
|
167
|
-
// //ITreasury.PoolSetup memory poolSetup = instance.getPoolSetup(info.poolNftId);
|
168
|
-
// //require(tokenInfo.objectAddress == address(poolSetup.token), "ERROR:COS-018:PRODUCT_POOL_TOKEN_MISMATCH");
|
169
|
-
// // TODO pool is not linked
|
170
|
-
|
171
|
-
// IRegistry.ObjectInfo memory distributionInfo = getRegistry().getObjectInfo(info.distributionNftId);
|
172
|
-
|
173
|
-
// if(distributionInfo.objectType != DISTRIBUTION()) {
|
174
|
-
// revert InvalidDistribution();
|
175
|
-
// }
|
176
|
-
|
177
|
-
// if(distributionInfo.parentNftId != instanceNftId) {
|
178
|
-
// revert InvalidDistributionsInstance();
|
179
|
-
// }
|
180
|
-
// // TODO distribution have the same token
|
181
|
-
// // TODO distribution is not linked
|
182
150
|
}
|
183
151
|
|
184
152
|
function setFees(
|
@@ -189,13 +157,9 @@ contract ProductService is ComponentService, IProductService {
|
|
189
157
|
{
|
190
158
|
// TODO check args
|
191
159
|
|
192
|
-
(
|
193
|
-
IRegistry.ObjectInfo memory productInfo,
|
194
|
-
IInstance instance
|
195
|
-
) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
196
|
-
|
160
|
+
(NftId productNftId, IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
197
161
|
InstanceReader instanceReader = instance.getInstanceReader();
|
198
|
-
|
162
|
+
|
199
163
|
ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
|
200
164
|
|
201
165
|
productSetupInfo.productFee = productFee;
|
@@ -207,13 +171,13 @@ contract ProductService is ComponentService, IProductService {
|
|
207
171
|
function createRisk(
|
208
172
|
RiskId riskId,
|
209
173
|
bytes memory data
|
210
|
-
)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
215
|
-
NftId productNftId = productInfo.nftId;
|
174
|
+
)
|
175
|
+
external
|
176
|
+
override
|
177
|
+
{
|
178
|
+
(NftId productNftId, IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
216
179
|
IRisk.RiskInfo memory riskInfo = IRisk.RiskInfo(productNftId, data);
|
180
|
+
|
217
181
|
instance.createRisk(
|
218
182
|
riskId,
|
219
183
|
riskInfo
|
@@ -223,9 +187,12 @@ contract ProductService is ComponentService, IProductService {
|
|
223
187
|
function updateRisk(
|
224
188
|
RiskId riskId,
|
225
189
|
bytes memory data
|
226
|
-
)
|
227
|
-
|
190
|
+
)
|
191
|
+
external
|
192
|
+
{
|
193
|
+
(,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
228
194
|
InstanceReader instanceReader = instance.getInstanceReader();
|
195
|
+
|
229
196
|
IRisk.RiskInfo memory riskInfo = instanceReader.getRiskInfo(riskId);
|
230
197
|
riskInfo.data = data;
|
231
198
|
instance.updateRisk(riskId, riskInfo, KEEP_STATE());
|
@@ -234,8 +201,10 @@ contract ProductService is ComponentService, IProductService {
|
|
234
201
|
function updateRiskState(
|
235
202
|
RiskId riskId,
|
236
203
|
StateId state
|
237
|
-
)
|
238
|
-
|
204
|
+
)
|
205
|
+
external
|
206
|
+
{
|
207
|
+
(,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
|
239
208
|
instance.updateRiskState(riskId, state);
|
240
209
|
}
|
241
210
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
4
|
+
// import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
5
5
|
|
6
6
|
import {NftId} from "../types/NftId.sol";
|
7
7
|
import {ObjectType} from "../types/ObjectType.sol";
|
@@ -13,8 +13,9 @@ import {IRegisterable} from "../shared/IRegisterable.sol";
|
|
13
13
|
import {IComponent} from "../components/IComponent.sol";
|
14
14
|
|
15
15
|
interface IRegistryService is
|
16
|
-
IService
|
17
|
-
|
16
|
+
IService
|
17
|
+
// TODO cleanup
|
18
|
+
// IAccessManaged
|
18
19
|
{
|
19
20
|
error SelfRegistration();
|
20
21
|
error NotRegistryOwner();
|
@@ -2,7 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
4
|
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
5
|
-
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
5
|
+
// import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
6
6
|
|
7
7
|
import {IRegistry} from "./IRegistry.sol";
|
8
8
|
import {IInstance} from "../instance/IInstance.sol";
|
@@ -31,7 +31,6 @@ import {IRegistryService} from "./IRegistryService.sol";
|
|
31
31
|
import {Registry} from "./Registry.sol";
|
32
32
|
|
33
33
|
contract RegistryService is
|
34
|
-
AccessManagedUpgradeable,
|
35
34
|
Service,
|
36
35
|
IRegistryService
|
37
36
|
{
|
@@ -41,7 +40,7 @@ contract RegistryService is
|
|
41
40
|
bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
|
42
41
|
|
43
42
|
// From IService
|
44
|
-
function getDomain() public pure override
|
43
|
+
function getDomain() public pure override returns(ObjectType serviceDomain) {
|
45
44
|
return REGISTRY();
|
46
45
|
}
|
47
46
|
|
@@ -61,9 +60,8 @@ contract RegistryService is
|
|
61
60
|
address initialAuthority
|
62
61
|
) = abi.decode(data, (address, address));
|
63
62
|
|
64
|
-
|
63
|
+
initializeService(registryAddress, initialAuthority, owner);
|
65
64
|
|
66
|
-
initializeService(registryAddress, owner);
|
67
65
|
registerInterface(type(IRegistryService).interfaceId);
|
68
66
|
}
|
69
67
|
|
@@ -194,17 +192,18 @@ contract RegistryService is
|
|
194
192
|
config[2].serviceDomain = CLAIM();
|
195
193
|
config[2].selectors = new bytes4[](0);
|
196
194
|
|
197
|
-
config[3].serviceDomain =
|
195
|
+
config[3].serviceDomain = PRODUCT();
|
198
196
|
config[3].selectors = new bytes4[](1);
|
199
|
-
config[3].selectors[0] = RegistryService.
|
197
|
+
config[3].selectors[0] = RegistryService.registerProduct.selector;
|
200
198
|
|
201
|
-
config[4].serviceDomain =
|
199
|
+
config[4].serviceDomain = POOL();
|
202
200
|
config[4].selectors = new bytes4[](1);
|
203
|
-
config[4].selectors[0] = RegistryService.
|
201
|
+
config[4].selectors[0] = RegistryService.registerPool.selector;
|
204
202
|
|
205
|
-
|
203
|
+
// registration of bundle service must preceed registration of pool service
|
204
|
+
config[5].serviceDomain = BUNDLE();
|
206
205
|
config[5].selectors = new bytes4[](1);
|
207
|
-
config[5].selectors[0] = RegistryService.
|
206
|
+
config[5].selectors[0] = RegistryService.registerBundle.selector;
|
208
207
|
|
209
208
|
config[6].serviceDomain = DISTRIBUTION();
|
210
209
|
config[6].selectors = new bytes4[](2);
|
@@ -6,7 +6,7 @@ import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManage
|
|
6
6
|
import {NftId} from "../types/NftId.sol";
|
7
7
|
import {RoleId} from "../types/RoleId.sol";
|
8
8
|
import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
|
9
|
-
import {VersionPart, VersionPartLib} from "../types/Version.sol";
|
9
|
+
import {Version, VersionLib, VersionPart, VersionPartLib} from "../types/Version.sol";
|
10
10
|
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
11
11
|
|
12
12
|
import {IService} from "../shared/IService.sol";
|
@@ -55,19 +55,19 @@ contract ReleaseManager is AccessManaged
|
|
55
55
|
RegistryAccessManager private immutable _accessManager;
|
56
56
|
IRegistry private immutable _registry;
|
57
57
|
|
58
|
-
VersionPart immutable _initial;// first active version
|
59
|
-
VersionPart _latest;// latest active version
|
60
|
-
VersionPart _next;// version to create and activate
|
58
|
+
VersionPart immutable _initial;// first active major version
|
59
|
+
VersionPart _latest;// latest active major version
|
60
|
+
VersionPart _next;// major version to create and activate
|
61
61
|
|
62
|
-
mapping(VersionPart
|
62
|
+
mapping(VersionPart majorVersion => IRegistry.ReleaseInfo info) _release;
|
63
63
|
|
64
|
-
mapping(VersionPart
|
64
|
+
mapping(VersionPart majorVersion => mapping(ObjectType serviceDomain => bytes4[])) _selectors; // registry service function selector assigned to domain
|
65
65
|
|
66
66
|
uint _awaitingRegistration; // "services left to register" counter
|
67
67
|
|
68
68
|
mapping(address registryService => bool isActive) _active;
|
69
69
|
|
70
|
-
mapping(VersionPart
|
70
|
+
mapping(VersionPart majorVersion => bool isValid) _valid; // TODO refactor to use _active only
|
71
71
|
|
72
72
|
constructor(
|
73
73
|
RegistryAccessManager accessManager,
|
@@ -146,12 +146,12 @@ contract ReleaseManager is AccessManaged
|
|
146
146
|
|
147
147
|
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
148
148
|
|
149
|
-
VersionPart
|
149
|
+
VersionPart majorVersion = _next;
|
150
150
|
ObjectType domain = REGISTRY();
|
151
|
-
_verifyService(service,
|
151
|
+
_verifyService(service, majorVersion, domain);
|
152
152
|
_createRelease(service.getFunctionConfigs());
|
153
153
|
|
154
|
-
nftId = _registry.registerService(info,
|
154
|
+
nftId = _registry.registerService(info, majorVersion, domain);
|
155
155
|
|
156
156
|
// external call
|
157
157
|
service.linkToRegisteredNftId();
|
@@ -169,13 +169,13 @@ contract ReleaseManager is AccessManaged
|
|
169
169
|
}
|
170
170
|
|
171
171
|
IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
|
172
|
-
VersionPart
|
173
|
-
ObjectType domain = _release[
|
174
|
-
_verifyService(service,
|
172
|
+
VersionPart majorVersion = getNextVersion();
|
173
|
+
ObjectType domain = _release[majorVersion].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
|
174
|
+
_verifyService(service, majorVersion, domain);
|
175
175
|
|
176
176
|
// setup and grant unique role if service does registrations
|
177
|
-
bytes4[] memory selectors = _selectors[
|
178
|
-
address registryService = _registry.getServiceAddress(REGISTRY(),
|
177
|
+
bytes4[] memory selectors = _selectors[majorVersion][domain];
|
178
|
+
address registryService = _registry.getServiceAddress(REGISTRY(), majorVersion);
|
179
179
|
if(selectors.length > 0) {
|
180
180
|
_accessManager.setAndGrantUniqueRole(
|
181
181
|
address(service),
|
@@ -185,7 +185,7 @@ contract ReleaseManager is AccessManaged
|
|
185
185
|
|
186
186
|
_awaitingRegistration--;
|
187
187
|
|
188
|
-
nftId = _registry.registerService(info,
|
188
|
+
nftId = _registry.registerService(info, majorVersion, domain);
|
189
189
|
|
190
190
|
// external call
|
191
191
|
service.linkToRegisteredNftId();
|
@@ -271,8 +271,10 @@ contract ReleaseManager is AccessManaged
|
|
271
271
|
view
|
272
272
|
returns(ObjectType)
|
273
273
|
{
|
274
|
-
|
275
|
-
|
274
|
+
Version version = service.getVersion();
|
275
|
+
VersionPart majorVersion = version.toMajorPart();
|
276
|
+
if(majorVersion != expectedVersion) {
|
277
|
+
revert UnexpectedServiceVersion(expectedVersion, majorVersion);
|
276
278
|
}
|
277
279
|
|
278
280
|
if(service.getDomain() != expectedDomain) {
|
@@ -1,18 +1,16 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {ObjectType} from "../types/ObjectType.sol";
|
4
|
+
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
6
5
|
|
7
6
|
import {IRegisterable} from "./IRegisterable.sol";
|
8
7
|
import {IVersionable} from "./IVersionable.sol";
|
8
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
9
9
|
|
10
10
|
interface IService is
|
11
11
|
IRegisterable,
|
12
|
-
IVersionable
|
12
|
+
IVersionable,
|
13
|
+
IAccessManaged
|
13
14
|
{
|
14
|
-
error ErrorIServiceCallerUnknown(address caller);
|
15
|
-
|
16
15
|
function getDomain() external pure returns(ObjectType serviceDomain);
|
17
|
-
function getMajorVersion() external view returns(VersionPart majorVersion);
|
18
16
|
}
|
@@ -1,7 +1,10 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
5
|
+
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
6
|
+
|
7
|
+
import {ObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
|
5
8
|
import {NftId, zeroNftId} from "../types/NftId.sol";
|
6
9
|
import {Version, VersionPart, VersionLib, VersionPartLib} from "../types/Version.sol";
|
7
10
|
|
@@ -18,14 +21,11 @@ import {IRegistry} from "../registry/IRegistry.sol";
|
|
18
21
|
abstract contract Service is
|
19
22
|
Registerable,
|
20
23
|
Versionable,
|
24
|
+
AccessManagedUpgradeable,
|
21
25
|
IService
|
22
26
|
{
|
23
|
-
function getDomain() public pure virtual override returns(ObjectType);
|
24
27
|
|
25
|
-
|
26
|
-
function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
|
27
|
-
return VersionPartLib.toVersionPart(3);
|
28
|
-
}
|
28
|
+
uint8 private constant GIF_MAJOR_VERSION = 3;
|
29
29
|
|
30
30
|
// from Versionable
|
31
31
|
function getVersion()
|
@@ -34,11 +34,12 @@ abstract contract Service is
|
|
34
34
|
virtual override (IVersionable, Versionable)
|
35
35
|
returns(Version)
|
36
36
|
{
|
37
|
-
return VersionLib.toVersion(
|
37
|
+
return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
|
38
38
|
}
|
39
39
|
|
40
40
|
function initializeService(
|
41
41
|
address registry,
|
42
|
+
address authority, // real authority for registry service adress(0) for other services
|
42
43
|
address initialOwner
|
43
44
|
)
|
44
45
|
public
|
@@ -53,6 +54,19 @@ abstract contract Service is
|
|
53
54
|
initialOwner,
|
54
55
|
""); // data
|
55
56
|
|
57
|
+
// externally provided authority
|
58
|
+
if(authority != address(0)) {
|
59
|
+
__AccessManaged_init(authority);
|
60
|
+
} else {
|
61
|
+
address registryServiceAddress = getRegistry().getServiceAddress(
|
62
|
+
REGISTRY(),
|
63
|
+
VersionPartLib.toVersionPart(GIF_MAJOR_VERSION));
|
64
|
+
|
65
|
+
// copy authority from already registered registry services
|
66
|
+
__AccessManaged_init(IAccessManaged(registryServiceAddress).authority());
|
67
|
+
}
|
68
|
+
|
69
|
+
registerInterface(type(IAccessManaged).interfaceId);
|
56
70
|
registerInterface(type(IService).interfaceId);
|
57
71
|
}
|
58
72
|
}
|
@@ -16,7 +16,7 @@ contract TestService is Service {
|
|
16
16
|
constructor(address registry, NftId registryNftId, address initialOwner)
|
17
17
|
// solhint-disable-next-line no-empty-blocks
|
18
18
|
{
|
19
|
-
initializeService(registry, initialOwner);
|
19
|
+
initializeService(registry, address(0), initialOwner);
|
20
20
|
}
|
21
21
|
|
22
22
|
function getDomain() public pure override returns(ObjectType) {
|