@etherisc/gif-next 0.0.2-ed4dd55 → 0.0.2-f619be3-760

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. package/README.md +49 -0
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +35 -9
  4. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +1 -1
  5. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +2 -2
  6. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +84 -8
  8. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +34 -152
  10. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.json +146 -13
  12. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  13. package/artifacts/contracts/components/Product.sol/Product.json +148 -15
  14. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
  15. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
  16. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  20. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  22. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  32. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  33. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  34. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  35. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  36. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  37. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  38. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  39. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  40. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  41. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +714 -127
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +845 -129
  46. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +1 -1
  47. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +1 -1
  48. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +1 -1
  49. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +1 -1
  50. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  51. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  52. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +31 -59
  53. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +1 -1
  54. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +103 -6
  55. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +1 -1
  56. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +1 -1
  57. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +34 -8
  58. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  59. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +31 -59
  60. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +1 -1
  61. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +50 -3
  62. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +1 -1
  63. package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  64. package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.json +134 -0
  65. package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +4 -0
  66. package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycleModule.json +182 -0
  67. package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +4 -0
  68. package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.json +221 -0
  69. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  70. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  71. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.json +44 -21
  72. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +44 -21
  74. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  75. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  76. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.json +23 -43
  77. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  78. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.json +28 -35
  79. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +1 -1
  80. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.json +21 -8
  82. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +1 -1
  83. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +85 -14
  85. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
  86. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasury.json +10 -0
  87. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
  88. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.json +490 -0
  89. package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  90. package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.json +45 -0
  91. package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
  92. package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.json +490 -0
  93. package/artifacts/contracts/mock/Dip.sol/DIP.dbg.json +4 -0
  94. package/artifacts/contracts/mock/Dip.sol/DIP.json +338 -0
  95. package/artifacts/contracts/mock/TestPool.sol/TestPool.dbg.json +4 -0
  96. package/artifacts/contracts/mock/TestPool.sol/TestPool.json +294 -0
  97. package/artifacts/contracts/mock/TestProduct.sol/TestProduct.dbg.json +4 -0
  98. package/artifacts/contracts/mock/TestProduct.sol/TestProduct.json +384 -0
  99. package/artifacts/contracts/mock/Usdc.sol/USDC.dbg.json +4 -0
  100. package/artifacts/contracts/mock/Usdc.sol/USDC.json +338 -0
  101. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  102. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  103. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  104. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +1 -1
  106. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +8 -8
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +20 -111
  109. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +1 -1
  110. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +1 -1
  111. package/artifacts/contracts/registry/Registry.sol/Registerable.json +9 -9
  112. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/Registry.sol/Registry.json +66 -115
  114. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +1 -1
  115. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +2 -2
  116. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  117. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
  118. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  119. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  120. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  121. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +85 -3
  122. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  123. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  124. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  125. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  126. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
  127. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +174 -0
  128. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +4 -0
  129. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +479 -0
  130. package/contracts/components/Component.sol +39 -24
  131. package/contracts/components/IPool.sol +9 -3
  132. package/contracts/components/IProduct.sol +11 -6
  133. package/contracts/components/Pool.sol +37 -14
  134. package/contracts/components/Product.sol +48 -24
  135. package/contracts/experiment/errors/Require.sol +38 -0
  136. package/contracts/experiment/errors/Revert.sol +44 -0
  137. package/contracts/experiment/inheritance/A.sol +8 -11
  138. package/contracts/experiment/inheritance/B.sol +10 -5
  139. package/contracts/experiment/inheritance/C.sol +11 -5
  140. package/contracts/experiment/inheritance/IA.sol +2 -7
  141. package/contracts/experiment/inheritance/IB.sol +3 -2
  142. package/contracts/experiment/inheritance/IC.sol +4 -3
  143. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  144. package/contracts/experiment/statemachine/ISM.sol +25 -0
  145. package/contracts/experiment/statemachine/README.md +112 -0
  146. package/contracts/experiment/statemachine/SM.sol +57 -0
  147. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  148. package/contracts/experiment/types/TypeA.sol +14 -9
  149. package/contracts/experiment/types/TypeB.sol +14 -9
  150. package/contracts/instance/IInstance.sol +8 -3
  151. package/contracts/instance/Instance.sol +24 -15
  152. package/contracts/instance/access/Access.sol +63 -116
  153. package/contracts/instance/access/IAccess.sol +28 -48
  154. package/contracts/instance/component/ComponentModule.sol +162 -147
  155. package/contracts/instance/component/IComponent.sol +41 -61
  156. package/contracts/instance/lifecycle/ILifecycle.sol +47 -0
  157. package/contracts/instance/lifecycle/LifecycleModule.sol +88 -0
  158. package/contracts/instance/policy/IPolicy.sol +19 -35
  159. package/contracts/instance/policy/PolicyModule.sol +52 -44
  160. package/contracts/instance/pool/IPoolModule.sol +9 -26
  161. package/contracts/instance/pool/PoolModule.sol +43 -45
  162. package/contracts/instance/product/IProductService.sol +10 -19
  163. package/contracts/instance/product/ProductService.sol +86 -55
  164. package/contracts/instance/treasury/ITreasury.sol +91 -0
  165. package/contracts/instance/treasury/TokenHandler.sol +24 -0
  166. package/contracts/instance/treasury/TreasuryModule.sol +168 -0
  167. package/contracts/mock/Dip.sol +26 -0
  168. package/contracts/mock/TestPool.sol +16 -0
  169. package/contracts/mock/TestProduct.sol +39 -0
  170. package/contracts/mock/Usdc.sol +26 -0
  171. package/contracts/registry/ChainNft.sol +23 -61
  172. package/contracts/registry/IChainNft.sol +10 -7
  173. package/contracts/registry/IRegistry.sol +40 -41
  174. package/contracts/registry/Registry.sol +73 -67
  175. package/contracts/types/Blocknumber.sol +118 -0
  176. package/contracts/types/ChainId.sol +24 -10
  177. package/contracts/types/Fee.sol +32 -0
  178. package/contracts/types/NftId.sol +36 -10
  179. package/contracts/types/ObjectType.sol +107 -0
  180. package/contracts/types/StateId.sol +91 -0
  181. package/contracts/types/Timestamp.sol +102 -0
  182. package/contracts/types/UFixed.sol +210 -0
  183. package/package.json +14 -5
@@ -1,62 +1,77 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
4
6
  import {IRegistry, IRegisterable, IRegistryLinked} from "../registry/IRegistry.sol";
5
7
  import {Registerable} from "../registry/Registry.sol";
6
8
  import {IInstance} from "../instance/IInstance.sol";
7
9
 
8
10
  import {IInstanceLinked, IComponent, IComponentContract, IComponentModule, IComponentOwnerService} from "../instance/component/IComponent.sol";
11
+ import {NftId} from "../types/NftId.sol";
9
12
 
10
-
11
- contract InstanceLinked is
12
- IInstanceLinked
13
- {
13
+ contract InstanceLinked is IInstanceLinked {
14
14
  IInstance internal _instance;
15
15
 
16
16
  constructor(address instance) {
17
17
  _instance = IInstance(instance);
18
18
  }
19
19
 
20
- // function setInstance(address instance) public override {
21
- // require(address(_instance) == address(0), "ERROR:RGL-001:INSTANCE_ALREADY_SET");
22
- // _instance = IInstance(instance);
23
- // }
24
-
25
- function getInstance() public view override returns(IInstance instance) {
20
+ function getInstance() public view override returns (IInstance instance) {
26
21
  return _instance;
27
22
  }
28
23
  }
29
24
 
30
-
31
25
  abstract contract Component is
32
26
  Registerable,
33
27
  InstanceLinked,
34
28
  IComponentContract
35
29
  {
36
-
37
30
  address private _deployer;
31
+ address private _wallet;
32
+ IERC20Metadata private _token;
38
33
 
39
- constructor(address registry, address instance)
40
- Registerable(registry)
41
- InstanceLinked(instance)
42
- { }
34
+ constructor(
35
+ address registry,
36
+ address instance,
37
+ address token
38
+ ) Registerable(registry) InstanceLinked(instance) {
39
+ _wallet = address(this);
40
+ _token = IERC20Metadata(token);
41
+ }
43
42
 
44
43
  // from registerable
45
- function register()
46
- public
47
- override
48
- returns(uint256 componentId)
49
- {
44
+ function register() public override returns (NftId componentId) {
50
45
  require(msg.sender == getInitialOwner(), "");
51
- require(address(_registry) != address(0), "ERROR:PRD-001:REGISTRY_ZERO");
52
- require(_registry.isRegistered(address(_instance)), "ERROR:PRD-002:INSTANCE_NOT_REGISTERED");
46
+ require(
47
+ address(_registry) != address(0),
48
+ "ERROR:PRD-001:REGISTRY_ZERO"
49
+ );
50
+ require(
51
+ _registry.isRegistered(address(_instance)),
52
+ "ERROR:PRD-002:INSTANCE_NOT_REGISTERED"
53
+ );
53
54
 
54
55
  IComponentOwnerService cos = _instance.getComponentOwnerService();
55
56
  componentId = cos.register(this);
56
57
  }
57
58
 
58
59
  // from registerable
59
- function getParentNftId() public view override returns(uint256) {
60
+ function getParentNftId() public view override returns (NftId) {
60
61
  return getInstance().getNftId();
61
62
  }
63
+
64
+ // from component contract
65
+ function getWallet()
66
+ external
67
+ view
68
+ override
69
+ returns (address walletAddress)
70
+ {
71
+ return _wallet;
72
+ }
73
+
74
+ function getToken() external view override returns (IERC20Metadata token) {
75
+ return _token;
76
+ }
62
77
  }
@@ -1,9 +1,15 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {Fee} from "../types/Fee.sol";
4
5
  import {IComponentContract} from "../instance/component/IComponent.sol";
5
6
 
6
7
  // just marker interface for now
7
- interface IPoolComponent is
8
- IComponentContract
9
- { }
8
+ interface IPoolComponent is IComponentContract {
9
+ function getStakingFee() external view returns (Fee memory stakingFee);
10
+
11
+ function getPerformanceFee()
12
+ external
13
+ view
14
+ returns (Fee memory performanceFee);
15
+ }
@@ -1,11 +1,16 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IComponentContract} from "../instance/component/IComponent.sol";
4
+ import {NftId} from "../types/NftId.sol";
5
+ import {Fee} from "../types/Fee.sol";
5
6
 
6
- interface IProductComponent is
7
- IComponentContract
8
- {
7
+ interface IProductComponent {
8
+ function getPoolNftId() external view returns (NftId poolNftId);
9
9
 
10
- function getPoolNftId() external view returns(uint256 poolNftId);
11
- }
10
+ function getPolicyFee() external view returns (Fee memory policyFee);
11
+
12
+ function getProcessingFee()
13
+ external
14
+ view
15
+ returns (Fee memory processingFee);
16
+ }
@@ -1,29 +1,52 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {ObjectType, POOL} from "../types/ObjectType.sol";
5
+ import {Fee} from "../types/Fee.sol";
4
6
  import {IPoolComponent} from "./IPool.sol";
5
7
  import {Component} from "./Component.sol";
6
8
 
7
-
8
- contract Pool is
9
- Component,
10
- IPoolComponent
11
- {
9
+ contract Pool is Component, IPoolComponent {
10
+ Fee private _stakingFee;
11
+ Fee private _performanceFee;
12
12
 
13
13
  constructor(
14
- address registry,
15
- address instance
16
- )
17
- Component(registry, instance)
18
- { }
14
+ address registry,
15
+ address instance,
16
+ address token,
17
+ Fee memory stakingFee,
18
+ Fee memory performanceFee
19
+ ) Component(registry, instance, token) {
20
+ _stakingFee = stakingFee;
21
+ _performanceFee = performanceFee;
22
+ }
23
+
24
+ // from pool component
25
+ function getStakingFee()
26
+ external
27
+ view
28
+ override
29
+ returns (Fee memory stakingFee)
30
+ {
31
+ return _stakingFee;
32
+ }
33
+
34
+ function getPerformanceFee()
35
+ external
36
+ view
37
+ override
38
+ returns (Fee memory performanceFee)
39
+ {
40
+ return _performanceFee;
41
+ }
19
42
 
20
43
  // from registerable
21
- function getType() public view override returns(uint256) {
22
- return _registry.POOL();
44
+ function getType() public pure override returns (ObjectType) {
45
+ return POOL();
23
46
  }
24
47
 
25
48
  // from registerable
26
- function getData() external view override returns(bytes memory data) {
49
+ function getData() external view override returns (bytes memory data) {
27
50
  return bytes(abi.encode(getInstance().getNftId()));
28
51
  }
29
- }
52
+ }
@@ -4,24 +4,30 @@ pragma solidity ^0.8.19;
4
4
  import {IProductService} from "../instance/product/IProductService.sol";
5
5
  import {Component} from "./Component.sol";
6
6
  import {IProductComponent} from "./IProduct.sol";
7
+ import {NftId} from "../types/NftId.sol";
8
+ import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
9
+ import {Fee} from "../types/Fee.sol";
10
+ import {Component} from "./Component.sol";
7
11
 
8
-
9
- contract Product is
10
- Component,
11
- IProductComponent
12
- {
12
+ contract Product is Component, IProductComponent {
13
13
  IProductService private _productService;
14
14
  address private _pool;
15
+ Fee private _policyFee;
16
+ Fee private _processingFee;
15
17
 
16
18
  constructor(
17
- address registry,
18
- address instance,
19
- address pool
20
- )
21
- Component(registry, instance)
22
- {
19
+ address registry,
20
+ address instance,
21
+ address token,
22
+ address pool,
23
+ Fee memory policyFee,
24
+ Fee memory processingFee
25
+ ) Component(registry, instance, token) {
26
+ // TODO add validation
23
27
  _productService = _instance.getProductService();
24
28
  _pool = pool;
29
+ _policyFee = policyFee;
30
+ _processingFee = processingFee;
25
31
  }
26
32
 
27
33
  function _createApplication(
@@ -29,11 +35,8 @@ contract Product is
29
35
  uint256 sumInsuredAmount,
30
36
  uint256 premiumAmount,
31
37
  uint256 lifetime,
32
- uint256 bundleNftId
33
- )
34
- internal
35
- returns(uint256 nftId)
36
- {
38
+ NftId bundleNftId
39
+ ) internal returns (NftId nftId) {
37
40
  nftId = _productService.createApplication(
38
41
  applicationOwner,
39
42
  sumInsuredAmount,
@@ -43,23 +46,44 @@ contract Product is
43
46
  );
44
47
  }
45
48
 
46
- function _underwrite(uint256 nftId)
47
- internal
48
- {
49
+ function _underwrite(NftId nftId) internal {
49
50
  _productService.underwrite(nftId);
50
51
  }
51
52
 
52
- function getPoolNftId() external view override returns(uint256 poolNftId) {
53
+ function _collectPremium(NftId nftId) internal {
54
+ _productService.collectPremium(nftId);
55
+ }
56
+
57
+ function getPoolNftId() external view override returns (NftId poolNftId) {
53
58
  return _registry.getNftId(_pool);
54
59
  }
55
60
 
61
+ // from product component
62
+ function getPolicyFee()
63
+ external
64
+ view
65
+ override
66
+ returns (Fee memory policyFee)
67
+ {
68
+ return _policyFee;
69
+ }
70
+
71
+ function getProcessingFee()
72
+ external
73
+ view
74
+ override
75
+ returns (Fee memory processingFee)
76
+ {
77
+ return _processingFee;
78
+ }
79
+
56
80
  // from registerable
57
- function getType() public view override returns(uint256) {
58
- return _registry.PRODUCT();
81
+ function getType() public pure override returns (ObjectType) {
82
+ return PRODUCT();
59
83
  }
60
84
 
61
85
  // from registerable
62
- function getData() external view override returns(bytes memory data) {
86
+ function getData() external view override returns (bytes memory data) {
63
87
  return bytes(abi.encode(getInstance().getNftId()));
64
88
  }
65
- }
89
+ }
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ contract Require {
5
+ error AsmallerThanB_S();
6
+ error AsmallerThanB_M(uint a);
7
+ error AsmallerThanB_L(uint a, uint b);
8
+
9
+ uint256 private _b;
10
+
11
+ constructor() {
12
+ _b = 42;
13
+ }
14
+
15
+ function isAlargerThanBRequire_S(
16
+ uint a
17
+ ) external view returns (bool isLarger) {
18
+ require(a > _b, "ERROR:ABC-001");
19
+
20
+ return true;
21
+ }
22
+
23
+ function isAlargerThanBRequire_M(
24
+ uint a
25
+ ) external view returns (bool isLarger) {
26
+ require(a > _b, "ERROR:ABC-002:A_IS_SMALLER");
27
+
28
+ return true;
29
+ }
30
+
31
+ function isAlargerThanBRequire_L(
32
+ uint a
33
+ ) external view returns (bool isLarger) {
34
+ require(a > _b, "ERROR:ABC-003:A_IS_SMALLER_THAN_B");
35
+
36
+ return true;
37
+ }
38
+ }
@@ -0,0 +1,44 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ contract Revert {
5
+ error AsmallerThanB_S();
6
+ error AsmallerThanB_M(uint a);
7
+ error AsmallerThanB_L(uint a, uint b);
8
+
9
+ uint256 private _b;
10
+
11
+ constructor() {
12
+ _b = 42;
13
+ }
14
+
15
+ function isAlargerThanBRevert_S(
16
+ uint a
17
+ ) external view returns (bool isLarger) {
18
+ if (a <= _b) {
19
+ revert AsmallerThanB_S();
20
+ }
21
+
22
+ return true;
23
+ }
24
+
25
+ function isAlargerThanBRevert_M(
26
+ uint a
27
+ ) external view returns (bool isLarger) {
28
+ if (a <= _b) {
29
+ revert AsmallerThanB_M(a);
30
+ }
31
+
32
+ return true;
33
+ }
34
+
35
+ function isAlargerThanBRevert_L(
36
+ uint a
37
+ ) external view returns (bool isLarger) {
38
+ if (a <= _b) {
39
+ revert AsmallerThanB_L(a, _b);
40
+ }
41
+
42
+ return true;
43
+ }
44
+ }
@@ -35,22 +35,19 @@ a.setC(20);
35
35
  */
36
36
 
37
37
  contract AShared is ISharedA {
38
-
39
38
  uint256 private _x;
40
39
 
41
40
  constructor() {
42
41
  _x = 42;
43
42
  }
44
43
 
45
- function getA() external view override returns(uint256) { return _x; }
46
- function setA(uint256 newA) external override { _x = newA; }
47
- }
48
-
49
- contract A is
50
- AShared,
51
- B,
52
- C,
53
- IA
54
- {
44
+ function getA() external view override returns (uint256) {
45
+ return _x;
46
+ }
55
47
 
48
+ function setA(uint256 newA) external override {
49
+ _x = newA;
50
+ }
56
51
  }
52
+
53
+ contract A is AShared, B, C, IA {}
@@ -5,7 +5,6 @@ import {ISharedA} from "./IA.sol";
5
5
  import {IB} from "./IB.sol";
6
6
 
7
7
  abstract contract B is ISharedA, IB {
8
-
9
8
  // names of private variables can be re-used in inheritance
10
9
  uint256 private _x;
11
10
 
@@ -14,10 +13,16 @@ abstract contract B is ISharedA, IB {
14
13
  }
15
14
 
16
15
  // access own state
17
- function getB() external view override returns(uint256) { return _x; }
18
- function setB(uint256 newB) external override { _x = newB; }
16
+ function getB() external view override returns (uint256) {
17
+ return _x;
18
+ }
19
19
 
20
- // access state from parent contract A
21
- function getAfromB() external view override returns(uint256) { return this.getA(); }
20
+ function setB(uint256 newB) external override {
21
+ _x = newB;
22
+ }
22
23
 
24
+ // access state from parent contract A
25
+ function getAfromB() external view override returns (uint256) {
26
+ return this.getA();
27
+ }
23
28
  }
@@ -6,7 +6,6 @@ import {IB} from "./IB.sol";
6
6
  import {IC} from "./IC.sol";
7
7
 
8
8
  abstract contract C is ISharedA, IC {
9
-
10
9
  uint256 private _x;
11
10
 
12
11
  constructor() {
@@ -14,14 +13,21 @@ abstract contract C is ISharedA, IC {
14
13
  }
15
14
 
16
15
  // access own state
17
- function getC() external view override returns(uint256) { return _x; }
18
- function setC(uint256 newC) external override { _x = newC; }
16
+ function getC() external view override returns (uint256) {
17
+ return _x;
18
+ }
19
+
20
+ function setC(uint256 newC) external override {
21
+ _x = newC;
22
+ }
19
23
 
20
24
  // access state from parent contract A
21
- function getAfromC() external view override returns(uint256) { return this.getA(); }
25
+ function getAfromC() external view override returns (uint256) {
26
+ return this.getA();
27
+ }
22
28
 
23
29
  // access state from other module B
24
- function getBfromC() external view override returns(uint256) {
30
+ function getBfromC() external view override returns (uint256) {
25
31
  IB b = IB(address(this));
26
32
  return b.getB();
27
33
  }
@@ -5,14 +5,9 @@ import {IB} from "./IB.sol";
5
5
  import {IC} from "./IC.sol";
6
6
 
7
7
  interface ISharedA {
8
+ function getA() external view returns (uint256);
8
9
 
9
- function getA() external view returns(uint256);
10
10
  function setA(uint256 newA) external;
11
11
  }
12
12
 
13
- interface IA is
14
- ISharedA,
15
- IB,
16
- IC
17
- {
18
- }
13
+ interface IA is ISharedA, IB, IC {}
@@ -2,8 +2,9 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  interface IB {
5
+ function getAfromB() external view returns (uint256);
6
+
7
+ function getB() external view returns (uint256);
5
8
 
6
- function getAfromB() external view returns(uint256);
7
- function getB() external view returns(uint256);
8
9
  function setB(uint256 newA) external;
9
10
  }
@@ -2,10 +2,11 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  interface IC {
5
+ function getAfromC() external view returns (uint256);
5
6
 
6
- function getAfromC() external view returns(uint256);
7
- function getBfromC() external view returns(uint256);
7
+ function getBfromC() external view returns (uint256);
8
+
9
+ function getC() external view returns (uint256);
8
10
 
9
- function getC() external view returns(uint256);
10
11
  function setC(uint256 newA) external;
11
12
  }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {ObjectType} from "../../types/ObjectType.sol";
5
+ import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
6
+
7
+ contract LifeCycleModule {
8
+ mapping(ObjectType objectType => StateId initialState)
9
+ private _initialState;
10
+
11
+ mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
12
+ private _isValidTransition;
13
+
14
+ function getInitialState(
15
+ ObjectType objectType
16
+ ) external view returns (StateId) {
17
+ return _initialState[objectType];
18
+ }
19
+
20
+ function isValidTransition(
21
+ ObjectType objectType,
22
+ StateId fromId,
23
+ StateId toId
24
+ ) external view returns (bool) {
25
+ return _isValidTransition[objectType][fromId][toId];
26
+ }
27
+ }
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {StateId} from "../../types/StateId.sol";
5
+
6
+ interface ISMEE {
7
+ error ErrorInitialStateUndefined();
8
+ error ErrorStartStateUndefined();
9
+ error ErrorNextStateUndefined();
10
+ error ErrorStateChangeInvalid(StateId currentStateId, StateId newStateId);
11
+
12
+ event LogInitialStateSet(StateId initialStateId);
13
+ event LogStateChanged(StateId oldStateId, StateId newStateId);
14
+ }
15
+
16
+ interface ISM is ISMEE {
17
+ function changeToState(StateId newStateId) external;
18
+
19
+ function isValidTransition(
20
+ StateId currentStateId,
21
+ StateId newStateId
22
+ ) external view returns (bool isValid);
23
+
24
+ function getState() external view returns (StateId currentStateId);
25
+ }