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