@etherisc/gif-next 0.0.2-34d25ca → 0.0.2-35bac6a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -18
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/InstanceLinked.json +2 -2
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +2 -2
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +2 -2
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.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/access/Access.sol/AccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +2 -2
- package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +1 -1
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +1 -1
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +1 -1
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +2 -2
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registerable.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/Registry.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +2 -2
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +2 -2
- package/contracts/components/Component.sol +18 -16
- package/contracts/components/IPool.sol +3 -3
- package/contracts/components/IProduct.sol +6 -3
- package/contracts/components/Pool.sol +13 -6
- package/contracts/components/Product.sol +21 -10
- package/contracts/experiment/errors/Require.sol +5 -10
- package/contracts/experiment/errors/Revert.sol +8 -13
- package/contracts/experiment/inheritance/A.sol +11 -8
- package/contracts/experiment/inheritance/B.sol +5 -10
- package/contracts/experiment/inheritance/C.sol +5 -11
- package/contracts/experiment/inheritance/IA.sol +7 -2
- package/contracts/experiment/inheritance/IB.sol +2 -3
- package/contracts/experiment/inheritance/IC.sol +3 -4
- package/contracts/experiment/types/TypeA.sol +9 -14
- package/contracts/experiment/types/TypeB.sol +9 -14
- package/contracts/instance/IInstance.sol +3 -1
- package/contracts/instance/Instance.sol +13 -13
- package/contracts/instance/access/Access.sol +116 -63
- package/contracts/instance/access/IAccess.sol +48 -28
- package/contracts/instance/component/ComponentModule.sol +98 -63
- package/contracts/instance/component/IComponent.sol +52 -30
- package/contracts/instance/policy/IPolicy.sol +24 -9
- package/contracts/instance/policy/PolicyModule.sol +35 -19
- package/contracts/instance/pool/IPoolModule.sol +19 -7
- package/contracts/instance/pool/PoolModule.sol +35 -22
- package/contracts/instance/product/IProductService.sol +15 -5
- package/contracts/instance/product/ProductService.sol +39 -43
- package/contracts/registry/ChainNft.sol +61 -23
- package/contracts/registry/IChainNft.sol +7 -10
- package/contracts/registry/IRegistry.sol +36 -46
- package/contracts/registry/Registry.sol +53 -80
- package/contracts/types/Blocknumber.sol +18 -76
- package/contracts/types/ChainId.sol +10 -18
- package/contracts/types/NftId.sol +13 -29
- package/contracts/types/Timestamp.sol +16 -63
- package/contracts/types/UFixed.sol +64 -58
- package/package.json +3 -7
|
@@ -11,7 +11,7 @@ import {IProductComponent} from "../../components/IProduct.sol";
|
|
|
11
11
|
import {IPoolModule} from "../pool/IPoolModule.sol";
|
|
12
12
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
|
13
13
|
|
|
14
|
-
abstract contract ComponentModule is
|
|
14
|
+
abstract contract ComponentModule is
|
|
15
15
|
IRegistryLinked,
|
|
16
16
|
IAccessComponentTypeRoles,
|
|
17
17
|
IAccessCheckRole,
|
|
@@ -29,10 +29,7 @@ abstract contract ComponentModule is
|
|
|
29
29
|
IComponentOwnerService private _componentOwnerService;
|
|
30
30
|
|
|
31
31
|
modifier onlyComponentOwnerService() {
|
|
32
|
-
require(
|
|
33
|
-
address(_componentOwnerService) == msg.sender,
|
|
34
|
-
"ERROR:CMP-001:NOT_OWNER_SERVICE"
|
|
35
|
-
);
|
|
32
|
+
require(address(_componentOwnerService) == msg.sender, "ERROR:CMP-001:NOT_OWNER_SERVICE");
|
|
36
33
|
_;
|
|
37
34
|
}
|
|
38
35
|
|
|
@@ -40,21 +37,25 @@ abstract contract ComponentModule is
|
|
|
40
37
|
_componentOwnerService = ComponentOwnerService(componentOwnerService);
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
function registerComponent(
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
function registerComponent(IComponentContract component)
|
|
41
|
+
external
|
|
42
|
+
override
|
|
43
|
+
onlyComponentOwnerService
|
|
44
|
+
returns(NftId nftId)
|
|
45
|
+
{
|
|
46
46
|
bytes32 typeRole = getRoleForType(component.getType());
|
|
47
47
|
require(
|
|
48
48
|
this.hasRole(typeRole, component.getInitialOwner()),
|
|
49
|
-
"ERROR:CMP-004:TYPE_ROLE_MISSING"
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
"ERROR:CMP-004:TYPE_ROLE_MISSING");
|
|
50
|
+
|
|
52
51
|
nftId = this.getRegistry().register(address(component));
|
|
53
52
|
|
|
54
|
-
_componentInfo[nftId] = ComponentInfo(
|
|
53
|
+
_componentInfo[nftId] = ComponentInfo(
|
|
54
|
+
nftId,
|
|
55
|
+
CState.Active);
|
|
55
56
|
|
|
56
57
|
// special case product -> persist product - pool assignment
|
|
57
|
-
if
|
|
58
|
+
if(component.getType() == this.getRegistry().PRODUCT()) {
|
|
58
59
|
IProductComponent product = IProductComponent(address(component));
|
|
59
60
|
NftId poolNftId = product.getPoolNftId();
|
|
60
61
|
require(poolNftId.gtz(), "ERROR:CMP-005:POOL_UNKNOWN");
|
|
@@ -63,7 +64,8 @@ abstract contract ComponentModule is
|
|
|
63
64
|
_poolNftIdForProduct[nftId] = poolNftId;
|
|
64
65
|
|
|
65
66
|
// add creation of productInfo
|
|
66
|
-
}
|
|
67
|
+
}
|
|
68
|
+
else if(component.getType() == this.getRegistry().POOL()) {
|
|
67
69
|
IPoolModule poolModule = IPoolModule(address(this));
|
|
68
70
|
poolModule.createPoolInfo(
|
|
69
71
|
nftId,
|
|
@@ -78,79 +80,104 @@ abstract contract ComponentModule is
|
|
|
78
80
|
// add logging
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
function getPoolNftId(
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
function getPoolNftId(NftId productNftId)
|
|
84
|
+
external
|
|
85
|
+
view
|
|
86
|
+
override
|
|
87
|
+
returns(NftId poolNftId)
|
|
88
|
+
{
|
|
84
89
|
poolNftId = _poolNftIdForProduct[productNftId];
|
|
85
90
|
}
|
|
86
91
|
|
|
92
|
+
|
|
87
93
|
function getComponentOwnerService()
|
|
88
94
|
external
|
|
89
|
-
view
|
|
90
95
|
override
|
|
91
|
-
|
|
96
|
+
view
|
|
97
|
+
returns(IComponentOwnerService)
|
|
92
98
|
{
|
|
93
99
|
return _componentOwnerService;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
|
-
function setComponentInfo(
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
function setComponentInfo(ComponentInfo memory info)
|
|
103
|
+
external
|
|
104
|
+
onlyComponentOwnerService
|
|
105
|
+
returns(NftId nftId)
|
|
106
|
+
{
|
|
99
107
|
nftId = info.nftId;
|
|
100
108
|
require(
|
|
101
109
|
nftId.gtz() && _componentInfo[nftId].nftId.eq(nftId),
|
|
102
|
-
"ERROR:CMP-006:COMPONENT_UNKNOWN"
|
|
103
|
-
);
|
|
110
|
+
"ERROR:CMP-006:COMPONENT_UNKNOWN");
|
|
104
111
|
|
|
105
112
|
_componentInfo[nftId] = info;
|
|
106
113
|
|
|
107
114
|
// add logging
|
|
108
115
|
}
|
|
109
116
|
|
|
110
|
-
function getComponentInfo(
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
function getComponentInfo(NftId nftId)
|
|
118
|
+
external
|
|
119
|
+
override
|
|
120
|
+
view
|
|
121
|
+
returns(ComponentInfo memory)
|
|
122
|
+
{
|
|
113
123
|
return _componentInfo[nftId];
|
|
114
124
|
}
|
|
115
125
|
|
|
116
|
-
function getComponentOwner(
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
function getComponentOwner(NftId nftId)
|
|
127
|
+
external
|
|
128
|
+
view
|
|
129
|
+
returns(address owner)
|
|
130
|
+
{
|
|
131
|
+
|
|
132
|
+
}
|
|
119
133
|
|
|
120
|
-
function getComponentId(
|
|
121
|
-
|
|
122
|
-
|
|
134
|
+
function getComponentId(address componentAddress)
|
|
135
|
+
external
|
|
136
|
+
view
|
|
137
|
+
returns(NftId componentNftId)
|
|
138
|
+
{
|
|
123
139
|
return _nftIdByAddress[componentAddress];
|
|
124
140
|
}
|
|
125
141
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
142
|
+
|
|
143
|
+
function getComponentId(uint256 idx)
|
|
144
|
+
external
|
|
145
|
+
override
|
|
146
|
+
view
|
|
147
|
+
returns(NftId componentNftId)
|
|
148
|
+
{
|
|
129
149
|
return _nftIds[idx];
|
|
130
150
|
}
|
|
131
151
|
|
|
152
|
+
|
|
132
153
|
function components()
|
|
133
154
|
external
|
|
134
|
-
view
|
|
135
155
|
override
|
|
136
|
-
|
|
156
|
+
view
|
|
157
|
+
returns(uint256 numberOfCompnents)
|
|
137
158
|
{
|
|
138
159
|
return _nftIds.length;
|
|
139
160
|
}
|
|
140
161
|
|
|
141
|
-
function getRoleForType(uint256 cType)
|
|
142
|
-
|
|
162
|
+
function getRoleForType(uint256 cType)
|
|
163
|
+
public
|
|
164
|
+
view
|
|
165
|
+
returns(bytes32 role)
|
|
166
|
+
{
|
|
167
|
+
if(cType == this.getRegistry().PRODUCT()) {
|
|
143
168
|
return this.PRODUCT_OWNER_ROLE();
|
|
144
169
|
}
|
|
145
|
-
if
|
|
170
|
+
if(cType == this.getRegistry().POOL()) {
|
|
146
171
|
return this.POOL_OWNER_ROLE();
|
|
147
172
|
}
|
|
148
|
-
if
|
|
173
|
+
if(cType == this.getRegistry().ORACLE()) {
|
|
149
174
|
return this.ORACLE_OWNER_ROLE();
|
|
150
175
|
}
|
|
176
|
+
|
|
151
177
|
}
|
|
152
178
|
}
|
|
153
179
|
|
|
180
|
+
|
|
154
181
|
// this is actually the component owner service
|
|
155
182
|
contract ComponentOwnerService is
|
|
156
183
|
RegistryLinked,
|
|
@@ -161,7 +188,9 @@ contract ComponentOwnerService is
|
|
|
161
188
|
|
|
162
189
|
modifier onlyComponentOwner(IComponentContract component) {
|
|
163
190
|
NftId nftId = _registry.getNftId(address(component));
|
|
164
|
-
require(
|
|
191
|
+
require(
|
|
192
|
+
nftId.gtz(),
|
|
193
|
+
"ERROR:COS-001:COMPONENT_UNKNOWN");
|
|
165
194
|
require(
|
|
166
195
|
msg.sender == _registry.getOwner(nftId),
|
|
167
196
|
"ERROR:COS-002:NOT_OWNER"
|
|
@@ -169,27 +198,31 @@ contract ComponentOwnerService is
|
|
|
169
198
|
_;
|
|
170
199
|
}
|
|
171
200
|
|
|
172
|
-
constructor(address registry)
|
|
201
|
+
constructor(address registry)
|
|
202
|
+
RegistryLinked(registry)
|
|
203
|
+
{ }
|
|
173
204
|
|
|
174
|
-
function register(
|
|
175
|
-
|
|
176
|
-
|
|
205
|
+
function register(IComponentContract component)
|
|
206
|
+
external
|
|
207
|
+
override
|
|
208
|
+
returns(NftId nftId)
|
|
209
|
+
{
|
|
177
210
|
require(
|
|
178
|
-
msg.sender == component.getInitialOwner(),
|
|
179
|
-
"ERROR:COS-003:NOT_OWNER"
|
|
180
|
-
);
|
|
211
|
+
msg.sender == component.getInitialOwner(),
|
|
212
|
+
"ERROR:COS-003:NOT_OWNER");
|
|
181
213
|
|
|
182
214
|
IInstance instance = component.getInstance();
|
|
183
215
|
nftId = instance.registerComponent(component);
|
|
184
216
|
}
|
|
185
217
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
218
|
+
|
|
219
|
+
function lock(IComponentContract component)
|
|
220
|
+
external
|
|
221
|
+
override
|
|
222
|
+
onlyComponentOwner(component)
|
|
223
|
+
{
|
|
189
224
|
IInstance instance = component.getInstance();
|
|
190
|
-
ComponentInfo memory info = instance.getComponentInfo(
|
|
191
|
-
component.getNftId()
|
|
192
|
-
);
|
|
225
|
+
ComponentInfo memory info = instance.getComponentInfo(component.getNftId());
|
|
193
226
|
require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
|
194
227
|
// TODO add state change validation
|
|
195
228
|
|
|
@@ -197,17 +230,19 @@ contract ComponentOwnerService is
|
|
|
197
230
|
instance.setComponentInfo(info);
|
|
198
231
|
}
|
|
199
232
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
233
|
+
|
|
234
|
+
function unlock(IComponentContract component)
|
|
235
|
+
external
|
|
236
|
+
override
|
|
237
|
+
onlyComponentOwner(component)
|
|
238
|
+
{
|
|
203
239
|
IInstance instance = component.getInstance();
|
|
204
|
-
ComponentInfo memory info = instance.getComponentInfo(
|
|
205
|
-
component.getNftId()
|
|
206
|
-
);
|
|
240
|
+
ComponentInfo memory info = instance.getComponentInfo(component.getNftId());
|
|
207
241
|
require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
|
|
208
242
|
// TODO state change validation
|
|
209
243
|
|
|
210
244
|
info.state = CState.Active;
|
|
211
245
|
instance.setComponentInfo(info);
|
|
212
246
|
}
|
|
213
|
-
|
|
247
|
+
|
|
248
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.19;
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
import {IOwnable, IRegistryLinked, IRegisterable} from "../../registry/IRegistry.sol";
|
|
5
6
|
import {IInstance} from "../IInstance.sol";
|
|
6
7
|
import {NftId} from "../../types/NftId.sol";
|
|
7
8
|
|
|
8
9
|
interface IComponent {
|
|
10
|
+
|
|
9
11
|
// TODO decide if enum or uints with constants (as in IRegistry.PRODUCT())
|
|
10
12
|
enum CState {
|
|
11
13
|
Undefined,
|
|
@@ -20,54 +22,74 @@ interface IComponent {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
|
|
23
26
|
interface IInstanceLinked {
|
|
24
27
|
// function setInstance(address instance) external;
|
|
25
|
-
function getInstance() external view returns
|
|
28
|
+
function getInstance() external view returns(IInstance instance);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
interface IComponentContract is IRegisterable, IInstanceLinked, IComponent {}
|
|
29
31
|
|
|
30
|
-
interface
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
interface IComponentContract is
|
|
33
|
+
IRegisterable,
|
|
34
|
+
IInstanceLinked,
|
|
35
|
+
IComponent
|
|
36
|
+
{ }
|
|
34
37
|
|
|
35
|
-
function lock(IComponentContract component) external;
|
|
36
38
|
|
|
39
|
+
interface IComponentOwnerService is IRegistryLinked{
|
|
40
|
+
|
|
41
|
+
function register(IComponentContract component) external returns(NftId nftId);
|
|
42
|
+
function lock(IComponentContract component) external;
|
|
37
43
|
function unlock(IComponentContract component) external;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
interface IComponentModule is IOwnable, IRegistryLinked, IComponent {
|
|
41
|
-
function registerComponent(
|
|
42
|
-
IComponentContract component
|
|
43
|
-
) external returns (NftId nftId);
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
interface IComponentModule is
|
|
48
|
+
IOwnable,
|
|
49
|
+
IRegistryLinked,
|
|
50
|
+
IComponent
|
|
51
|
+
{
|
|
48
52
|
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
function registerComponent(IComponentContract component)
|
|
54
|
+
external
|
|
55
|
+
returns(NftId nftId);
|
|
52
56
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
function setComponentInfo(ComponentInfo memory info)
|
|
58
|
+
external
|
|
59
|
+
returns(NftId componentNftId);
|
|
56
60
|
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
function getComponentInfo(NftId nftId)
|
|
62
|
+
external
|
|
63
|
+
view
|
|
64
|
+
returns(ComponentInfo memory info);
|
|
60
65
|
|
|
61
|
-
function
|
|
66
|
+
function getComponentOwner(NftId nftId)
|
|
67
|
+
external
|
|
68
|
+
view
|
|
69
|
+
returns(address owner);
|
|
62
70
|
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
function getComponentId(address componentAddress)
|
|
72
|
+
external
|
|
73
|
+
view
|
|
74
|
+
returns(NftId nftId);
|
|
66
75
|
|
|
67
|
-
function
|
|
76
|
+
function getComponentId(uint256 idx)
|
|
77
|
+
external
|
|
78
|
+
view
|
|
79
|
+
returns(NftId nftId);
|
|
80
|
+
|
|
81
|
+
function getPoolNftId(NftId productNftId)
|
|
82
|
+
external
|
|
83
|
+
view
|
|
84
|
+
returns(NftId poolNftId);
|
|
85
|
+
|
|
86
|
+
function components()
|
|
87
|
+
external
|
|
88
|
+
view
|
|
89
|
+
returns(uint256 numberOfCompnents);
|
|
68
90
|
|
|
69
91
|
function getComponentOwnerService()
|
|
70
92
|
external
|
|
71
93
|
view
|
|
72
|
-
returns
|
|
73
|
-
}
|
|
94
|
+
returns(IComponentOwnerService);
|
|
95
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.19;
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
import {IOwnable, IRegistryLinked, IRegisterable, IRegistry} from "../../registry/IRegistry.sol";
|
|
5
6
|
import {IInstance} from "../IInstance.sol";
|
|
6
7
|
import {IProductService} from "../product/IProductService.sol";
|
|
@@ -8,6 +9,7 @@ import {NftId} from "../../types/NftId.sol";
|
|
|
8
9
|
|
|
9
10
|
// TODO check if there is value to introuce IContract and let IPolicy derive from IContract
|
|
10
11
|
interface IPolicy {
|
|
12
|
+
|
|
11
13
|
enum PolicyState {
|
|
12
14
|
Undefined,
|
|
13
15
|
Applied,
|
|
@@ -19,9 +21,11 @@ interface IPolicy {
|
|
|
19
21
|
struct PolicyInfo {
|
|
20
22
|
NftId nftId;
|
|
21
23
|
PolicyState state; // applied, withdrawn, rejected, active, closed
|
|
24
|
+
|
|
22
25
|
uint256 sumInsuredAmount;
|
|
23
26
|
uint256 premiumAmount;
|
|
24
27
|
uint256 lifetime; // activatedAt + lifetime >= expiredAt
|
|
28
|
+
|
|
25
29
|
uint256 createdAt;
|
|
26
30
|
uint256 activatedAt; // time of underwriting
|
|
27
31
|
uint256 expiredAt; // no new claims
|
|
@@ -29,7 +33,12 @@ interface IPolicy {
|
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
interface IPolicyModule is
|
|
36
|
+
interface IPolicyModule is
|
|
37
|
+
IOwnable,
|
|
38
|
+
IRegistryLinked,
|
|
39
|
+
IPolicy
|
|
40
|
+
{
|
|
41
|
+
|
|
33
42
|
function createApplication(
|
|
34
43
|
IRegistry.RegistryInfo memory productInfo,
|
|
35
44
|
address applicationOwner,
|
|
@@ -37,15 +46,21 @@ interface IPolicyModule is IOwnable, IRegistryLinked, IPolicy {
|
|
|
37
46
|
uint256 premiumAmount,
|
|
38
47
|
uint256 lifetime,
|
|
39
48
|
NftId bundleNftId
|
|
40
|
-
)
|
|
49
|
+
)
|
|
50
|
+
external
|
|
51
|
+
returns(NftId nftId);
|
|
52
|
+
|
|
53
|
+
function activate(NftId nftId)
|
|
54
|
+
external;
|
|
41
55
|
|
|
42
|
-
function
|
|
56
|
+
function getBundleNftForPolicy(NftId nftId)
|
|
57
|
+
external
|
|
58
|
+
view
|
|
59
|
+
returns(NftId bundleNft);
|
|
43
60
|
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
function getPolicyInfo(NftId nftId)
|
|
62
|
+
external
|
|
63
|
+
view
|
|
64
|
+
returns(PolicyInfo memory info);
|
|
47
65
|
|
|
48
|
-
function getPolicyInfo(
|
|
49
|
-
NftId nftId
|
|
50
|
-
) external view returns (PolicyInfo memory info);
|
|
51
66
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.19;
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
// import {IOwnable, IRegistryLinked, IRegisterable} from "../../registry/IRegistry.sol";
|
|
5
6
|
import {IRegistry, IRegistryLinked} from "../../registry/IRegistry.sol";
|
|
6
7
|
|
|
@@ -8,7 +9,10 @@ import {IProductService} from "../product/IProductService.sol";
|
|
|
8
9
|
import {IPolicy, IPolicyModule} from "./IPolicy.sol";
|
|
9
10
|
import {NftId, NftIdLib} from "../../types/NftId.sol";
|
|
10
11
|
|
|
11
|
-
abstract contract PolicyModule is
|
|
12
|
+
abstract contract PolicyModule is
|
|
13
|
+
IRegistryLinked,
|
|
14
|
+
IPolicyModule
|
|
15
|
+
{
|
|
12
16
|
using NftIdLib for NftId;
|
|
13
17
|
|
|
14
18
|
mapping(NftId nftId => PolicyInfo info) private _policyInfo;
|
|
@@ -18,10 +22,7 @@ abstract contract PolicyModule is IRegistryLinked, IPolicyModule {
|
|
|
18
22
|
|
|
19
23
|
// TODO find a better place to avoid dupliation
|
|
20
24
|
modifier onlyProductService2() {
|
|
21
|
-
require(
|
|
22
|
-
address(_productService) == msg.sender,
|
|
23
|
-
"ERROR:POL-001:NOT_PRODUCT_SERVICE"
|
|
24
|
-
);
|
|
25
|
+
require(address(_productService) == msg.sender, "ERROR:POL-001:NOT_PRODUCT_SERVICE");
|
|
25
26
|
_;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -29,6 +30,7 @@ abstract contract PolicyModule is IRegistryLinked, IPolicyModule {
|
|
|
29
30
|
_productService = IProductService(productService);
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
|
|
32
34
|
function createApplication(
|
|
33
35
|
IRegistry.RegistryInfo memory productInfo,
|
|
34
36
|
address applicationOwner,
|
|
@@ -36,20 +38,22 @@ abstract contract PolicyModule is IRegistryLinked, IPolicyModule {
|
|
|
36
38
|
uint256 premiumAmount,
|
|
37
39
|
uint256 lifetime,
|
|
38
40
|
NftId bundleNftId
|
|
39
|
-
)
|
|
41
|
+
)
|
|
42
|
+
external
|
|
43
|
+
override
|
|
44
|
+
onlyProductService2
|
|
45
|
+
returns(NftId nftId)
|
|
46
|
+
{
|
|
40
47
|
// TODO add parameter validation
|
|
41
|
-
if
|
|
42
|
-
IRegistry.RegistryInfo memory bundleInfo = this
|
|
43
|
-
.getRegistry()
|
|
44
|
-
.getInfo(bundleNftId);
|
|
48
|
+
if(bundleNftId.gtz()) {
|
|
49
|
+
IRegistry.RegistryInfo memory bundleInfo = this.getRegistry().getInfo(bundleNftId);
|
|
45
50
|
// IRegistry.RegistryInfo memory poolInfo = this.getRegistry().getInfo(bundleInfo.parentNftId);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
nftId = this.getRegistry().registerObjectForInstance(
|
|
49
54
|
productInfo.nftId,
|
|
50
55
|
this.getRegistry().POLICY(),
|
|
51
|
-
applicationOwner
|
|
52
|
-
);
|
|
56
|
+
applicationOwner);
|
|
53
57
|
|
|
54
58
|
_policyInfo[nftId] = PolicyInfo(
|
|
55
59
|
nftId,
|
|
@@ -68,7 +72,12 @@ abstract contract PolicyModule is IRegistryLinked, IPolicyModule {
|
|
|
68
72
|
// add logging
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
|
|
75
|
+
|
|
76
|
+
function activate(NftId nftId)
|
|
77
|
+
external
|
|
78
|
+
override
|
|
79
|
+
onlyProductService2
|
|
80
|
+
{
|
|
72
81
|
PolicyInfo storage info = _policyInfo[nftId];
|
|
73
82
|
info.activatedAt = block.timestamp;
|
|
74
83
|
info.expiredAt = block.timestamp + info.lifetime;
|
|
@@ -77,15 +86,22 @@ abstract contract PolicyModule is IRegistryLinked, IPolicyModule {
|
|
|
77
86
|
// add logging
|
|
78
87
|
}
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
function getBundleNftForPolicy(NftId nftId)
|
|
92
|
+
external
|
|
93
|
+
view
|
|
94
|
+
returns(NftId bundleNft)
|
|
95
|
+
{
|
|
83
96
|
return _bundleForPolicy[nftId];
|
|
84
97
|
}
|
|
85
98
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
|
|
100
|
+
function getPolicyInfo(NftId nftId)
|
|
101
|
+
external
|
|
102
|
+
view
|
|
103
|
+
returns(PolicyInfo memory info)
|
|
104
|
+
{
|
|
89
105
|
return _policyInfo[nftId];
|
|
90
106
|
}
|
|
91
107
|
}
|
|
@@ -5,6 +5,7 @@ import {IOwnable, IRegistry, IRegistryLinked} from "../../registry/IRegistry.sol
|
|
|
5
5
|
import {NftId} from "../../types/NftId.sol";
|
|
6
6
|
|
|
7
7
|
interface IPool {
|
|
8
|
+
|
|
8
9
|
struct PoolInfo {
|
|
9
10
|
NftId nftId;
|
|
10
11
|
address wallet;
|
|
@@ -14,16 +15,27 @@ interface IPool {
|
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
interface IPoolModule is
|
|
18
|
-
|
|
18
|
+
interface IPoolModule is
|
|
19
|
+
IOwnable,
|
|
20
|
+
IRegistryLinked,
|
|
21
|
+
IPool
|
|
22
|
+
{
|
|
23
|
+
|
|
24
|
+
function underwrite(
|
|
25
|
+
NftId poolNftId,
|
|
26
|
+
NftId policyNftId
|
|
27
|
+
)
|
|
28
|
+
external;
|
|
19
29
|
|
|
20
30
|
function createPoolInfo(
|
|
21
31
|
NftId nftId,
|
|
22
32
|
address wallet,
|
|
23
33
|
address token
|
|
24
|
-
)
|
|
34
|
+
)
|
|
35
|
+
external;
|
|
25
36
|
|
|
26
|
-
function getPoolInfo(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
function getPoolInfo(NftId nftId)
|
|
38
|
+
external
|
|
39
|
+
view
|
|
40
|
+
returns(PoolInfo memory info);
|
|
41
|
+
}
|