@etherisc/gif-next 0.0.2-836a512-798 → 0.0.2-839b2a2-792

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.
Files changed (149) hide show
  1. package/README.md +8 -0
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +1 -1
  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 +1 -1
  8. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  10. package/artifacts/contracts/components/Pool.sol/Pool.json +5 -5
  11. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  12. package/artifacts/contracts/components/Product.sol/Product.json +5 -5
  13. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  14. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
  15. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  17. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  19. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  21. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  35. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  37. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +137 -21
  41. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  42. package/artifacts/contracts/instance/Instance.sol/Instance.json +175 -35
  43. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +1 -1
  44. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +1 -1
  45. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +1 -1
  46. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +1 -1
  47. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  48. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  49. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +2 -21
  50. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +65 -10
  52. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +1 -1
  53. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +1 -1
  54. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +1 -1
  55. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  56. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +2 -21
  57. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +1 -1
  58. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +47 -0
  59. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +1 -1
  60. package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  61. package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +1 -1
  63. package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.json +2 -2
  64. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  65. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  66. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  67. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  68. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  69. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +1 -1
  71. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +1 -1
  72. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +1 -1
  74. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +14 -14
  75. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  76. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  77. package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.json +135 -0
  78. package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  79. package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  80. package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  81. package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.json +135 -0
  82. package/artifacts/contracts/mock/Dip.sol/DIP.dbg.json +4 -0
  83. package/artifacts/contracts/mock/Dip.sol/DIP.json +338 -0
  84. package/artifacts/contracts/mock/TestPool.sol/TestPool.dbg.json +4 -0
  85. package/artifacts/contracts/mock/TestPool.sol/TestPool.json +294 -0
  86. package/artifacts/contracts/mock/TestProduct.sol/TestProduct.dbg.json +4 -0
  87. package/artifacts/contracts/mock/TestProduct.sol/TestProduct.json +384 -0
  88. package/artifacts/contracts/mock/Usdc.sol/USDC.dbg.json +4 -0
  89. package/artifacts/contracts/mock/Usdc.sol/USDC.json +338 -0
  90. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  91. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  92. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  93. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +1 -1
  94. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +1 -1
  95. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  96. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +1 -1
  97. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +1 -1
  98. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  99. package/artifacts/contracts/registry/Registry.sol/Registry.json +10 -10
  100. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +1 -1
  101. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +2 -2
  102. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  103. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  104. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  105. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  106. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  107. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  108. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  109. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  110. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  111. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  112. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  113. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +2 -2
  114. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  115. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +37 -11
  116. package/contracts/components/Component.sol +12 -12
  117. package/contracts/components/IPool.sol +6 -2
  118. package/contracts/components/IProduct.sol +7 -2
  119. package/contracts/components/Pool.sol +14 -7
  120. package/contracts/components/Product.sol +14 -6
  121. package/contracts/experiment/statemachine/Dummy.sol +12 -18
  122. package/contracts/experiment/statemachine/ISM.sol +7 -2
  123. package/contracts/experiment/statemachine/SM.sol +15 -12
  124. package/contracts/experiment/statemachine/SimpleStateMachine.sol +11 -4
  125. package/contracts/instance/IInstance.sol +4 -1
  126. package/contracts/instance/Instance.sol +8 -5
  127. package/contracts/instance/component/ComponentModule.sol +55 -35
  128. package/contracts/instance/component/IComponent.sol +12 -14
  129. package/contracts/instance/lifecycle/ILifecycle.sol +32 -17
  130. package/contracts/instance/lifecycle/LifecycleModule.sol +28 -31
  131. package/contracts/instance/policy/IPolicy.sol +0 -2
  132. package/contracts/instance/policy/PolicyModule.sol +14 -7
  133. package/contracts/instance/pool/IPoolModule.sol +3 -2
  134. package/contracts/instance/pool/PoolModule.sol +11 -12
  135. package/contracts/instance/product/ProductService.sol +30 -12
  136. package/contracts/instance/treasury/ITreasury.sol +43 -25
  137. package/contracts/instance/treasury/TokenHandler.sol +1 -4
  138. package/contracts/instance/treasury/TreasuryModule.sol +82 -45
  139. package/contracts/mock/Dip.sol +26 -0
  140. package/contracts/mock/TestPool.sol +16 -0
  141. package/contracts/mock/TestProduct.sol +39 -0
  142. package/contracts/mock/Usdc.sol +26 -0
  143. package/contracts/registry/IRegistry.sol +0 -2
  144. package/contracts/registry/Registry.sol +7 -2
  145. package/contracts/types/Fee.sol +6 -4
  146. package/contracts/types/ObjectType.sol +77 -20
  147. package/contracts/types/StateId.sol +68 -23
  148. package/contracts/types/UFixed.sol +18 -14
  149. package/package.json +4 -2
@@ -7,7 +7,6 @@ import {IPoolComponent} from "./IPool.sol";
7
7
  import {Component} from "./Component.sol";
8
8
 
9
9
  contract Pool is Component, IPoolComponent {
10
-
11
10
  Fee private _stakingFee;
12
11
  Fee private _performanceFee;
13
12
 
@@ -17,24 +16,32 @@ contract Pool is Component, IPoolComponent {
17
16
  address token,
18
17
  Fee memory stakingFee,
19
18
  Fee memory performanceFee
20
- )
21
- Component(registry, instance, token)
22
- {
19
+ ) Component(registry, instance, token) {
23
20
  _stakingFee = stakingFee;
24
21
  _performanceFee = performanceFee;
25
22
  }
26
23
 
27
24
  // from pool component
28
- function getStakingFee() external view override returns(Fee memory stakingFee) {
25
+ function getStakingFee()
26
+ external
27
+ view
28
+ override
29
+ returns (Fee memory stakingFee)
30
+ {
29
31
  return _stakingFee;
30
32
  }
31
33
 
32
- function getPerformanceFee() external view override returns(Fee memory performanceFee) {
34
+ function getPerformanceFee()
35
+ external
36
+ view
37
+ override
38
+ returns (Fee memory performanceFee)
39
+ {
33
40
  return _performanceFee;
34
41
  }
35
42
 
36
43
  // from registerable
37
- function getType() public pure override returns(ObjectType) {
44
+ function getType() public pure override returns (ObjectType) {
38
45
  return POOL();
39
46
  }
40
47
 
@@ -22,9 +22,7 @@ contract Product is Component, IProductComponent {
22
22
  address pool,
23
23
  Fee memory policyFee,
24
24
  Fee memory processingFee
25
- )
26
- Component(registry, instance, token)
27
- {
25
+ ) Component(registry, instance, token) {
28
26
  // TODO add validation
29
27
  _productService = _instance.getProductService();
30
28
  _pool = pool;
@@ -61,16 +59,26 @@ contract Product is Component, IProductComponent {
61
59
  }
62
60
 
63
61
  // from product component
64
- function getPolicyFee() external view override returns(Fee memory policyFee) {
62
+ function getPolicyFee()
63
+ external
64
+ view
65
+ override
66
+ returns (Fee memory policyFee)
67
+ {
65
68
  return _policyFee;
66
69
  }
67
70
 
68
- function getProcessingFee() external view override returns(Fee memory processingFee) {
71
+ function getProcessingFee()
72
+ external
73
+ view
74
+ override
75
+ returns (Fee memory processingFee)
76
+ {
69
77
  return _processingFee;
70
78
  }
71
79
 
72
80
  // from registerable
73
- function getType() public pure override returns(ObjectType) {
81
+ function getType() public pure override returns (ObjectType) {
74
82
  return PRODUCT();
75
83
  }
76
84
 
@@ -4,30 +4,24 @@ pragma solidity ^0.8.19;
4
4
  import {ObjectType} from "../../types/ObjectType.sol";
5
5
  import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
6
6
 
7
-
8
7
  contract LifeCycleModule {
8
+ mapping(ObjectType objectType => StateId initialState)
9
+ private _initialState;
9
10
 
10
- mapping(ObjectType objectType => StateId initialState) private _initialState;
11
-
12
- mapping(ObjectType objectType =>
13
- mapping(StateId stateFrom =>
14
- mapping(StateId stateTo => bool isValid))) private _isValidTransition;
11
+ mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
12
+ private _isValidTransition;
15
13
 
16
-
17
- function getInitialState(ObjectType objectType)
18
- external
19
- view
20
- returns(StateId)
21
- {
14
+ function getInitialState(
15
+ ObjectType objectType
16
+ ) external view returns (StateId) {
22
17
  return _initialState[objectType];
23
18
  }
24
19
 
25
-
26
- function isValidTransition(ObjectType objectType, StateId fromId, StateId toId)
27
- external
28
- view
29
- returns(bool)
30
- {
20
+ function isValidTransition(
21
+ ObjectType objectType,
22
+ StateId fromId,
23
+ StateId toId
24
+ ) external view returns (bool) {
31
25
  return _isValidTransition[objectType][fromId][toId];
32
26
  }
33
27
  }
@@ -15,6 +15,11 @@ interface ISMEE {
15
15
 
16
16
  interface ISM is ISMEE {
17
17
  function changeToState(StateId newStateId) external;
18
- function isValidTransition(StateId currentStateId, StateId newStateId) external view returns(bool isValid);
19
- function getState() external view returns(StateId currentStateId);
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);
20
25
  }
@@ -5,36 +5,36 @@ import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
5
5
  import {ISM} from "./ISM.sol";
6
6
 
7
7
  contract SM is ISM {
8
-
9
- mapping(StateId currentState => mapping(StateId newState => bool isValid)) private _isValidTransition;
8
+ mapping(StateId currentState => mapping(StateId newState => bool isValid))
9
+ private _isValidTransition;
10
10
 
11
11
  StateId internal _state;
12
12
 
13
-
14
13
  function setInitialState(StateId initialStateId) internal {
15
- if(initialStateId == zeroStateId()) {
14
+ if (initialStateId == zeroStateId()) {
16
15
  revert ErrorInitialStateUndefined();
17
16
  }
18
17
 
19
18
  _state = initialStateId;
20
19
  }
21
20
 
22
-
23
- function addTransition(StateId currentStateId, StateId nextStateId) internal {
24
- if(currentStateId == zeroStateId()) {
21
+ function addTransition(
22
+ StateId currentStateId,
23
+ StateId nextStateId
24
+ ) internal {
25
+ if (currentStateId == zeroStateId()) {
25
26
  revert ErrorStartStateUndefined();
26
27
  }
27
28
 
28
- if(nextStateId == zeroStateId()) {
29
+ if (nextStateId == zeroStateId()) {
29
30
  revert ErrorNextStateUndefined();
30
31
  }
31
32
 
32
33
  _isValidTransition[currentStateId][nextStateId] = true;
33
34
  }
34
35
 
35
-
36
36
  function changeToState(StateId newStateId) external override {
37
- if(!_isValidTransition[_state][newStateId]) {
37
+ if (!_isValidTransition[_state][newStateId]) {
38
38
  revert ErrorStateChangeInvalid(_state, newStateId);
39
39
  }
40
40
 
@@ -44,11 +44,14 @@ contract SM is ISM {
44
44
  emit LogStateChanged(stateOld, _state);
45
45
  }
46
46
 
47
- function isValidTransition(StateId currentStateId, StateId newStateId) external view override returns(bool isValid) {
47
+ function isValidTransition(
48
+ StateId currentStateId,
49
+ StateId newStateId
50
+ ) external view override returns (bool isValid) {
48
51
  return _isValidTransition[currentStateId][newStateId];
49
52
  }
50
53
 
51
- function getState() external view override returns(StateId state) {
54
+ function getState() external view override returns (StateId state) {
52
55
  return _state;
53
56
  }
54
57
  }
@@ -5,7 +5,6 @@ import {StateId, toStateId} from "../../types/StateId.sol";
5
5
  import {SM} from "./SM.sol";
6
6
 
7
7
  contract SimpleStateMachine is SM {
8
-
9
8
  uint8 public constant STATE_ACTIVE = 10;
10
9
  uint8 public constant STATE_PAUSED = 20;
11
10
  uint8 public constant STATE_ARCHIVED = 30;
@@ -18,7 +17,15 @@ contract SimpleStateMachine is SM {
18
17
  setInitialState(ACTIVE());
19
18
  }
20
19
 
21
- function ACTIVE() public pure returns(StateId stateId) { return toStateId(STATE_ACTIVE); }
22
- function PAUSED() public pure returns(StateId stateId) { return toStateId(STATE_PAUSED); }
23
- function ARCHIVED() public pure returns(StateId stateId) { return toStateId(STATE_ARCHIVED); }
20
+ function ACTIVE() public pure returns (StateId stateId) {
21
+ return toStateId(STATE_ACTIVE);
22
+ }
23
+
24
+ function PAUSED() public pure returns (StateId stateId) {
25
+ return toStateId(STATE_PAUSED);
26
+ }
27
+
28
+ function ARCHIVED() public pure returns (StateId stateId) {
29
+ return toStateId(STATE_ARCHIVED);
30
+ }
24
31
  }
@@ -10,6 +10,7 @@ import {IPolicyModule} from "./policy/IPolicy.sol";
10
10
  import {IPoolModule} from "./pool/IPoolModule.sol";
11
11
  import {ITreasuryModule} from "./treasury/ITreasury.sol";
12
12
 
13
+ // solhint-disable-next-line no-empty-blocks
13
14
  interface IInstance is
14
15
  IRegisterable,
15
16
  IAccessModule,
@@ -19,4 +20,6 @@ interface IInstance is
19
20
  IComponentModule,
20
21
  IProductModule,
21
22
  ITreasuryModule
22
- {}
23
+ {
24
+
25
+ }
@@ -19,9 +19,9 @@ import {NftId, toNftId} from "../types/NftId.sol";
19
19
  contract Instance is
20
20
  Registerable,
21
21
  AccessModule,
22
- LifecycleModule,
23
- ComponentModule,
24
- PolicyModule,
22
+ LifecycleModule,
23
+ ComponentModule,
24
+ PolicyModule,
25
25
  PoolModule,
26
26
  ProductModule,
27
27
  TreasuryModule,
@@ -38,7 +38,10 @@ contract Instance is
38
38
  PolicyModule(productService)
39
39
  ProductModule(productService)
40
40
  PoolModule(productService)
41
- {}
41
+ // solhint-disable-next-line no-empty-blocks
42
+ {
43
+
44
+ }
42
45
 
43
46
  // from registerable
44
47
  function register() external override returns (NftId nftId) {
@@ -58,7 +61,7 @@ contract Instance is
58
61
  }
59
62
 
60
63
  // from registerable
61
- function getType() external pure override returns(ObjectType objectType) {
64
+ function getType() external pure override returns (ObjectType objectType) {
62
65
  return INSTANCE();
63
66
  }
64
67
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
6
  import {RegistryLinked} from "../../registry/Registry.sol";
7
7
  import {IRegistry, IRegistryLinked} from "../../registry/IRegistry.sol";
@@ -9,6 +9,7 @@ import {IAccessComponentTypeRoles, IAccessCheckRole} from "../access/IAccess.sol
9
9
  import {IInstance} from "../IInstance.sol";
10
10
 
11
11
  import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
12
+ import {ITreasuryModule} from "../treasury/ITreasury.sol";
12
13
  import {TreasuryModule} from "../treasury/TreasuryModule.sol";
13
14
  import {IComponent, IComponentContract, IComponentModule, IComponentOwnerService} from "./IComponent.sol";
14
15
  import {IProductComponent} from "../../components/IProduct.sol";
@@ -55,12 +56,9 @@ abstract contract ComponentModule is
55
56
  _componentOwnerService = ComponentOwnerService(componentOwnerService);
56
57
  }
57
58
 
58
- function registerComponent(IComponentContract component)
59
- external
60
- override
61
- onlyComponentOwnerService
62
- returns(NftId nftId)
63
- {
59
+ function registerComponent(
60
+ IComponentContract component
61
+ ) external override onlyComponentOwnerService returns (NftId nftId) {
64
62
  ObjectType objectType = component.getType();
65
63
  bytes32 typeRole = getRoleForType(objectType);
66
64
  require(
@@ -69,17 +67,18 @@ abstract contract ComponentModule is
69
67
  );
70
68
 
71
69
  nftId = this.getRegistry().register(address(component));
72
- IERC20 token = component.getToken();
70
+ IERC20Metadata token = component.getToken();
73
71
  address wallet = component.getWallet();
74
72
 
75
73
  // create component info
76
74
  _componentInfo[nftId] = ComponentInfo(
77
75
  nftId,
78
76
  _lifecycleModule.getInitialState(objectType),
79
- token);
77
+ token
78
+ );
80
79
 
81
80
  // component type specific registration actions
82
- if(component.getType() == PRODUCT()) {
81
+ if (component.getType() == PRODUCT()) {
83
82
  IProductComponent product = IProductComponent(address(component));
84
83
  NftId poolNftId = product.getPoolNftId();
85
84
  require(poolNftId.gtz(), "ERROR:CMP-005:POOL_UNKNOWN");
@@ -89,15 +88,15 @@ abstract contract ComponentModule is
89
88
  // implement and add validation
90
89
  NftId distributorNftId = zeroNftId();
91
90
  _treasuryModule.registerProduct(
92
- nftId,
93
- distributorNftId,
94
- poolNftId,
95
- token,
96
- wallet,
91
+ nftId,
92
+ distributorNftId,
93
+ poolNftId,
94
+ token,
95
+ wallet,
97
96
  product.getPolicyFee(),
98
- product.getProcessingFee());
99
- }
100
- else if(component.getType() == POOL()) {
97
+ product.getProcessingFee()
98
+ );
99
+ } else if (component.getType() == POOL()) {
101
100
  IPoolComponent pool = IPoolComponent(address(component));
102
101
 
103
102
  // register with pool
@@ -105,10 +104,11 @@ abstract contract ComponentModule is
105
104
 
106
105
  // register with tresury
107
106
  _treasuryModule.registerPool(
108
- nftId,
109
- wallet,
107
+ nftId,
108
+ wallet,
110
109
  pool.getStakingFee(),
111
- pool.getPerformanceFee());
110
+ pool.getPerformanceFee()
111
+ );
112
112
  }
113
113
  // TODO add distribution
114
114
 
@@ -140,7 +140,12 @@ abstract contract ComponentModule is
140
140
  // just a generic setXYZInfo and implicit state transitions
141
141
  // when in doubt go for the explicit approach ...
142
142
  ObjectType objectType = this.getRegistry().getInfo(nftId).objectType;
143
- _lifecycleModule.checkAndLogTransition(nftId, objectType, _componentInfo[nftId].state, info.state);
143
+ _lifecycleModule.checkAndLogTransition(
144
+ nftId,
145
+ objectType,
146
+ _componentInfo[nftId].state,
147
+ info.state
148
+ );
144
149
  _componentInfo[nftId] = info;
145
150
  }
146
151
 
@@ -150,10 +155,6 @@ abstract contract ComponentModule is
150
155
  return _componentInfo[nftId];
151
156
  }
152
157
 
153
- function getComponentOwner(
154
- NftId nftId
155
- ) external view returns (address owner) {}
156
-
157
158
  function getComponentId(
158
159
  address componentAddress
159
160
  ) external view returns (NftId componentNftId) {
@@ -175,18 +176,16 @@ abstract contract ComponentModule is
175
176
  return _nftIds.length;
176
177
  }
177
178
 
178
- function getRoleForType(ObjectType cType)
179
- public
180
- view
181
- returns(bytes32 role)
182
- {
183
- if(cType == PRODUCT()) {
179
+ function getRoleForType(
180
+ ObjectType cType
181
+ ) public view returns (bytes32 role) {
182
+ if (cType == PRODUCT()) {
184
183
  return this.PRODUCT_OWNER_ROLE();
185
184
  }
186
- if(cType == POOL()) {
185
+ if (cType == POOL()) {
187
186
  return this.POOL_OWNER_ROLE();
188
187
  }
189
- if(cType == ORACLE()) {
188
+ if (cType == ORACLE()) {
190
189
  return this.ORACLE_OWNER_ROLE();
191
190
  }
192
191
  }
@@ -210,7 +209,12 @@ contract ComponentOwnerService is
210
209
  _;
211
210
  }
212
211
 
213
- constructor(address registry) RegistryLinked(registry) {}
212
+ constructor(
213
+ address registry
214
+ ) RegistryLinked(registry) // solhint-disable-next-line no-empty-blocks
215
+ {
216
+
217
+ }
214
218
 
215
219
  function register(
216
220
  IComponentContract component
@@ -251,4 +255,20 @@ contract ComponentOwnerService is
251
255
  // setComponentInfo checks for valid state changes
252
256
  instance.setComponentInfo(info);
253
257
  }
258
+
259
+ function setProductFees(
260
+ IComponentContract product,
261
+ Fee memory policyFee,
262
+ Fee memory processingFee
263
+ ) external override onlyComponentOwner(product) {
264
+ require(product.getType() == PRODUCT(), "ERROR_NOT_PRODUCT");
265
+
266
+ address instanceAddress = address(product.getInstance());
267
+ ITreasuryModule treasuryModule = ITreasuryModule(instanceAddress);
268
+ treasuryModule.setProductFees(
269
+ product.getNftId(),
270
+ policyFee,
271
+ processingFee
272
+ );
273
+ }
254
274
  }
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
6
  import {IOwnable, IRegistryLinked, IRegisterable} from "../../registry/IRegistry.sol";
7
7
  import {IInstance} from "../IInstance.sol";
@@ -11,12 +11,11 @@ import {Fee} from "../../types/Fee.sol";
11
11
  import {UFixed} from "../../types/UFixed.sol";
12
12
 
13
13
  interface IComponent {
14
-
15
14
  // component dynamic info (static info kept in registry)
16
15
  struct ComponentInfo {
17
16
  NftId nftId;
18
17
  StateId state;
19
- IERC20 token;
18
+ IERC20Metadata token;
20
19
  }
21
20
  }
22
21
 
@@ -25,13 +24,10 @@ interface IInstanceLinked {
25
24
  function getInstance() external view returns (IInstance instance);
26
25
  }
27
26
 
28
- interface IComponentContract is
29
- IRegisterable,
30
- IInstanceLinked,
31
- IComponent
32
- {
33
- function getToken() external view returns(IERC20 token);
34
- function getWallet() external view returns(address walletAddress);
27
+ interface IComponentContract is IRegisterable, IInstanceLinked, IComponent {
28
+ function getToken() external view returns (IERC20Metadata token);
29
+
30
+ function getWallet() external view returns (address walletAddress);
35
31
  }
36
32
 
37
33
  interface IComponentOwnerService is IRegistryLinked {
@@ -42,6 +38,12 @@ interface IComponentOwnerService is IRegistryLinked {
42
38
  function lock(IComponentContract component) external;
43
39
 
44
40
  function unlock(IComponentContract component) external;
41
+
42
+ function setProductFees(
43
+ IComponentContract product,
44
+ Fee memory policyFee,
45
+ Fee memory processingFee
46
+ ) external;
45
47
  }
46
48
 
47
49
  interface IComponentModule is IOwnable, IRegistryLinked, IComponent {
@@ -57,10 +59,6 @@ interface IComponentModule is IOwnable, IRegistryLinked, IComponent {
57
59
  NftId nftId
58
60
  ) external view returns (ComponentInfo memory info);
59
61
 
60
- function getComponentOwner(
61
- NftId nftId
62
- ) external view returns (address owner);
63
-
64
62
  function getComponentId(
65
63
  address componentAddress
66
64
  ) external view returns (NftId nftId);
@@ -6,27 +6,42 @@ import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
6
6
  import {NftId} from "../../types/NftId.sol";
7
7
 
8
8
  interface ILifecycle {
9
-
10
- event LogComponentStateChanged(NftId nftId, ObjectType objectType, StateId fromStateId, StateId toStateId);
11
- event LogBundleStateChanged(NftId nftId, StateId fromStateId, StateId toStateId);
12
- event LogPolicyStateChanged(NftId nftId, StateId fromStateId, StateId toStateId);
9
+ event LogComponentStateChanged(
10
+ NftId nftId,
11
+ ObjectType objectType,
12
+ StateId fromStateId,
13
+ StateId toStateId
14
+ );
15
+ event LogBundleStateChanged(
16
+ NftId nftId,
17
+ StateId fromStateId,
18
+ StateId toStateId
19
+ );
20
+ event LogPolicyStateChanged(
21
+ NftId nftId,
22
+ StateId fromStateId,
23
+ StateId toStateId
24
+ );
13
25
  // event LogClaimStateChanged(NftId nftId, ClaimId claimId, StateId fromStateId, StateId toStateId);
14
26
  // event LogPayoutStateChanged(NftId nftId, ClaimId claimId, PayoutId payoutId, StateId fromStateId, StateId toStateId);
15
27
 
16
28
  error ErrorNoLifecycle(NftId nftId, ObjectType objectType);
17
- error ErrorInvalidStateTransition(NftId nftId, ObjectType objectType, StateId fromStateId, StateId toStateId);
29
+ error ErrorInvalidStateTransition(
30
+ NftId nftId,
31
+ ObjectType objectType,
32
+ StateId fromStateId,
33
+ StateId toStateId
34
+ );
18
35
  }
19
36
 
20
37
  interface ILifecycleModule is ILifecycle {
21
-
22
- function getInitialState(ObjectType objectType)
23
- external
24
- view
25
- returns(StateId);
26
-
27
-
28
- function isValidTransition(ObjectType objectType, StateId fromId, StateId toId)
29
- external
30
- view
31
- returns(bool);
32
- }
38
+ function getInitialState(
39
+ ObjectType objectType
40
+ ) external view returns (StateId);
41
+
42
+ function isValidTransition(
43
+ ObjectType objectType,
44
+ StateId fromId,
45
+ StateId toId
46
+ ) external view returns (bool);
47
+ }