@etherisc/gif-next 0.0.2-bd7444a → 0.0.2-c4efd5e

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