@etherisc/gif-next 0.0.2-cf606cd → 0.0.2-d3543ee-345

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. package/README.md +27 -0
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +28 -2
  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 +78 -2
  8. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +32 -150
  10. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  11. package/artifacts/contracts/components/Pool.sol/Pool.json +121 -6
  12. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  13. package/artifacts/contracts/components/Product.sol/Product.json +121 -6
  14. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
  16. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  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 +686 -99
  44. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  45. package/artifacts/contracts/instance/Instance.sol/Instance.json +757 -99
  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 +14 -42
  53. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +1 -1
  54. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +65 -10
  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 +28 -2
  58. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  59. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +12 -40
  60. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +1 -1
  61. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +47 -0
  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 +26 -3
  72. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +26 -3
  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 +15 -35
  77. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  78. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.json +22 -29
  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 +13 -0
  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 +41 -12
  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/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  94. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  95. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  96. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +1 -1
  97. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +1 -1
  98. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +2 -2
  99. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  100. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +4 -95
  101. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +1 -1
  102. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +1 -1
  103. package/artifacts/contracts/registry/Registry.sol/Registerable.json +2 -2
  104. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  105. package/artifacts/contracts/registry/Registry.sol/Registry.json +14 -105
  106. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +1 -1
  107. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +2 -2
  108. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  109. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  110. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  111. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  112. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  113. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  114. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  115. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  116. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  117. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  118. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  119. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +2 -2
  120. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  121. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +2 -2
  122. package/contracts/components/Component.sol +38 -23
  123. package/contracts/components/IPool.sol +9 -3
  124. package/contracts/components/IProduct.sol +10 -6
  125. package/contracts/components/Pool.sol +37 -14
  126. package/contracts/components/Product.sol +46 -23
  127. package/contracts/experiment/errors/Require.sol +10 -5
  128. package/contracts/experiment/errors/Revert.sol +13 -8
  129. package/contracts/experiment/inheritance/A.sol +8 -11
  130. package/contracts/experiment/inheritance/B.sol +10 -5
  131. package/contracts/experiment/inheritance/C.sol +11 -5
  132. package/contracts/experiment/inheritance/IA.sol +2 -7
  133. package/contracts/experiment/inheritance/IB.sol +3 -2
  134. package/contracts/experiment/inheritance/IC.sol +4 -3
  135. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  136. package/contracts/experiment/statemachine/ISM.sol +25 -0
  137. package/contracts/experiment/statemachine/README.md +112 -0
  138. package/contracts/experiment/statemachine/SM.sol +57 -0
  139. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  140. package/contracts/experiment/types/TypeA.sol +14 -9
  141. package/contracts/experiment/types/TypeB.sol +14 -9
  142. package/contracts/instance/IInstance.sol +8 -3
  143. package/contracts/instance/Instance.sol +22 -14
  144. package/contracts/instance/access/Access.sol +63 -116
  145. package/contracts/instance/access/IAccess.sol +28 -48
  146. package/contracts/instance/component/ComponentModule.sol +144 -118
  147. package/contracts/instance/component/IComponent.sol +39 -60
  148. package/contracts/instance/lifecycle/ILifecycle.sol +47 -0
  149. package/contracts/instance/lifecycle/LifecycleModule.sol +88 -0
  150. package/contracts/instance/policy/IPolicy.sol +16 -32
  151. package/contracts/instance/policy/PolicyModule.sol +47 -40
  152. package/contracts/instance/pool/IPoolModule.sol +7 -25
  153. package/contracts/instance/pool/PoolModule.sol +40 -45
  154. package/contracts/instance/product/IProductService.sol +6 -16
  155. package/contracts/instance/product/ProductService.sol +76 -48
  156. package/contracts/instance/treasury/ITreasury.sol +91 -0
  157. package/contracts/instance/treasury/TokenHandler.sol +24 -0
  158. package/contracts/instance/treasury/TreasuryModule.sol +168 -0
  159. package/contracts/registry/ChainNft.sol +23 -61
  160. package/contracts/registry/IChainNft.sol +10 -7
  161. package/contracts/registry/IRegistry.sol +35 -38
  162. package/contracts/registry/Registry.sol +57 -57
  163. package/contracts/types/Blocknumber.sol +76 -18
  164. package/contracts/types/ChainId.sol +18 -10
  165. package/contracts/types/Fee.sol +32 -0
  166. package/contracts/types/NftId.sol +29 -13
  167. package/contracts/types/ObjectType.sol +107 -0
  168. package/contracts/types/StateId.sol +91 -0
  169. package/contracts/types/Timestamp.sol +63 -16
  170. package/contracts/types/UFixed.sol +59 -64
  171. package/package.json +10 -4
@@ -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
+ }
@@ -0,0 +1,112 @@
1
+ # State Machines
2
+
3
+ Most GIF objects have a life cycle defined by a state machine.
4
+
5
+ For each object type the set of possible states is defined together with its initial state and the set of valid state transitions.
6
+
7
+ ## Object Types without States
8
+
9
+ * Protocol
10
+ * Chains
11
+ * Registries (both chain and main registry)
12
+
13
+ ## Object Types with States
14
+
15
+ * Tokens
16
+ * Instances
17
+ * Products
18
+ * Oracles
19
+ * Pools
20
+ * Bundles
21
+ * Policies
22
+ * Claim (non-NFT)
23
+ * Payout (non-NFT)
24
+
25
+ ### Simple State Machine
26
+
27
+ Valid states
28
+
29
+ * Active (initial state)
30
+ * Paused
31
+ * Archived (final state)
32
+
33
+ Valid state transitions:
34
+
35
+ * Active -> Paused
36
+ * Paused -> Active
37
+ * Paused -> Archived
38
+
39
+
40
+ Candidate object types for simple state machine
41
+
42
+ * Token
43
+ * Instance
44
+ * Product
45
+ * Oracle
46
+ * Pool
47
+
48
+ To discuss:
49
+
50
+ * Archived is final state
51
+ * What mechanism should exist to revert an unintended transition to 'Archived' state. Should there be such a mechanism?
52
+ * What mechanism should exist when the NFT of such an object is burned prematurely. Should there be such a mechanism
53
+
54
+ ### Bundle State Machine
55
+
56
+ Valid states
57
+
58
+ * Active (initial state)
59
+ * Paused
60
+ * Expired (implicit state)
61
+ * Closed (final state)
62
+
63
+ Expired is not an explicit state.
64
+ A bundle is expired for block.timestamp >= expiredAt
65
+
66
+ ### Policy State Machine
67
+
68
+ Valid states
69
+
70
+ * Applied (initial state)
71
+ * Revoked (final state)
72
+ * Declined (final state)
73
+ * Active
74
+ * Expired (implicit state)
75
+ * Closed (final state)
76
+
77
+ Expired is not an explicit state.
78
+ A policy is expired for block.timestamp >= expiredAt
79
+
80
+ To discuss:
81
+
82
+ * Should 'Closed' be less explicit using a closedAt state variable?
83
+ * Or even more lighweight? ie. block.timestamp >= expiredAt and no open claims
84
+
85
+ Valid state transitions:
86
+
87
+ * Applied -> Revoked
88
+ * Applied -> Declined
89
+ * Applied -> Active
90
+ * Active -> Closed (needs to be expired)
91
+
92
+ ### Claim State Machine
93
+
94
+ Valid states
95
+ * Applied (initial state)
96
+ * Confirmed
97
+ * Declined (final state)
98
+ * Closed (final state)
99
+
100
+ Valid state transitions:
101
+ * Applied -> Confirmed
102
+ * Applied -> Declined
103
+ * Confirmed -> Closed
104
+
105
+ ### Payout State Machine
106
+
107
+ Valid states
108
+ * Expected
109
+ * PaidOut
110
+
111
+ Valid state transitions:
112
+ * Expected -> PaidOut
@@ -0,0 +1,57 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
5
+ import {ISM} from "./ISM.sol";
6
+
7
+ contract SM is ISM {
8
+ mapping(StateId currentState => mapping(StateId newState => bool isValid))
9
+ private _isValidTransition;
10
+
11
+ StateId internal _state;
12
+
13
+ function setInitialState(StateId initialStateId) internal {
14
+ if (initialStateId == zeroStateId()) {
15
+ revert ErrorInitialStateUndefined();
16
+ }
17
+
18
+ _state = initialStateId;
19
+ }
20
+
21
+ function addTransition(
22
+ StateId currentStateId,
23
+ StateId nextStateId
24
+ ) internal {
25
+ if (currentStateId == zeroStateId()) {
26
+ revert ErrorStartStateUndefined();
27
+ }
28
+
29
+ if (nextStateId == zeroStateId()) {
30
+ revert ErrorNextStateUndefined();
31
+ }
32
+
33
+ _isValidTransition[currentStateId][nextStateId] = true;
34
+ }
35
+
36
+ function changeToState(StateId newStateId) external override {
37
+ if (!_isValidTransition[_state][newStateId]) {
38
+ revert ErrorStateChangeInvalid(_state, newStateId);
39
+ }
40
+
41
+ StateId stateOld = _state;
42
+ _state = newStateId;
43
+
44
+ emit LogStateChanged(stateOld, _state);
45
+ }
46
+
47
+ function isValidTransition(
48
+ StateId currentStateId,
49
+ StateId newStateId
50
+ ) external view override returns (bool isValid) {
51
+ return _isValidTransition[currentStateId][newStateId];
52
+ }
53
+
54
+ function getState() external view override returns (StateId state) {
55
+ return _state;
56
+ }
57
+ }
@@ -0,0 +1,31 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {StateId, toStateId} from "../../types/StateId.sol";
5
+ import {SM} from "./SM.sol";
6
+
7
+ contract SimpleStateMachine is SM {
8
+ uint8 public constant STATE_ACTIVE = 10;
9
+ uint8 public constant STATE_PAUSED = 20;
10
+ uint8 public constant STATE_ARCHIVED = 30;
11
+
12
+ constructor() {
13
+ addTransition(ACTIVE(), PAUSED());
14
+ addTransition(PAUSED(), ACTIVE());
15
+ addTransition(PAUSED(), ARCHIVED());
16
+
17
+ setInitialState(ACTIVE());
18
+ }
19
+
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
+ }
31
+ }
@@ -23,20 +23,25 @@ a.toInt() == x.toInt() // -> no error
23
23
  type TypeA is uint248;
24
24
 
25
25
  // type bindings
26
- using {
27
- eqTypeA as ==,
28
- neTypeA as !=,
29
- TypeALib.toInt
30
- } for TypeA global;
26
+ using {eqTypeA as ==, neTypeA as !=, TypeALib.toInt} for TypeA global;
31
27
 
32
28
  // general pure free functions
33
- function toTypeA(uint256 typeA) pure returns(TypeA) { return TypeA.wrap(uint248(typeA)); }
29
+ function toTypeA(uint256 typeA) pure returns (TypeA) {
30
+ return TypeA.wrap(uint248(typeA));
31
+ }
34
32
 
35
33
  // pure free functions for operators
36
- function eqTypeA(TypeA a, TypeA b) pure returns(bool isSame) { return TypeA.unwrap(a) == TypeA.unwrap(b); }
37
- function neTypeA(TypeA a, TypeA b) pure returns(bool isDifferent) { return TypeA.unwrap(a) != TypeA.unwrap(b); }
34
+ function eqTypeA(TypeA a, TypeA b) pure returns (bool isSame) {
35
+ return TypeA.unwrap(a) == TypeA.unwrap(b);
36
+ }
37
+
38
+ function neTypeA(TypeA a, TypeA b) pure returns (bool isDifferent) {
39
+ return TypeA.unwrap(a) != TypeA.unwrap(b);
40
+ }
38
41
 
39
42
  // library functions that operate on user defined type
40
43
  library TypeALib {
41
- function toInt(TypeA typeA) internal pure returns(uint256) { return uint256(TypeA.unwrap(typeA)); }
44
+ function toInt(TypeA typeA) internal pure returns (uint256) {
45
+ return uint256(TypeA.unwrap(typeA));
46
+ }
42
47
  }
@@ -5,20 +5,25 @@ pragma solidity ^0.8.19;
5
5
  type TypeB is uint248;
6
6
 
7
7
  // type bindings
8
- using {
9
- eqTypeB as ==,
10
- addTypeB as +,
11
- TypeBLib.toInt
12
- } for TypeB global;
8
+ using {eqTypeB as ==, addTypeB as +, TypeBLib.toInt} for TypeB global;
13
9
 
14
10
  // general pure free functions
15
- function toTypeB(uint256 x) pure returns(TypeB) { return TypeB.wrap(uint248(x)); }
11
+ function toTypeB(uint256 x) pure returns (TypeB) {
12
+ return TypeB.wrap(uint248(x));
13
+ }
16
14
 
17
15
  // pure free functions for operators
18
- function eqTypeB(TypeB a, TypeB b) pure returns(bool isSame) { return TypeB.unwrap(a) == TypeB.unwrap(b); }
19
- function addTypeB(TypeB a, TypeB b) pure returns(TypeB sum) { return TypeB.wrap(TypeB.unwrap(a) + TypeB.unwrap(b)); }
16
+ function eqTypeB(TypeB a, TypeB b) pure returns (bool isSame) {
17
+ return TypeB.unwrap(a) == TypeB.unwrap(b);
18
+ }
19
+
20
+ function addTypeB(TypeB a, TypeB b) pure returns (TypeB sum) {
21
+ return TypeB.wrap(TypeB.unwrap(a) + TypeB.unwrap(b));
22
+ }
20
23
 
21
24
  // library functions that operate on user defined type
22
25
  library TypeBLib {
23
- function toInt(TypeB b) internal pure returns(uint256) { return uint256(TypeB.unwrap(b)); }
26
+ function toInt(TypeB b) internal pure returns (uint256) {
27
+ return uint256(TypeB.unwrap(b));
28
+ }
24
29
  }
@@ -3,18 +3,23 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegisterable} from "../registry/IRegistry.sol";
5
5
  import {IAccessModule} from "./access/IAccess.sol";
6
+ import {ILifecycleModule} from "./lifecycle/ILifecycle.sol";
6
7
  import {IComponentModule} from "./component/IComponent.sol";
7
8
  import {IProductModule} from "./product/IProductService.sol";
8
9
  import {IPolicyModule} from "./policy/IPolicy.sol";
9
10
  import {IPoolModule} from "./pool/IPoolModule.sol";
11
+ import {ITreasuryModule} from "./treasury/ITreasury.sol";
10
12
 
11
-
13
+ // solhint-disable-next-line no-empty-blocks
12
14
  interface IInstance is
13
15
  IRegisterable,
14
16
  IAccessModule,
17
+ ILifecycleModule,
15
18
  IPolicyModule,
16
19
  IPoolModule,
17
20
  IComponentModule,
18
- IProductModule
19
- { }
21
+ IProductModule,
22
+ ITreasuryModule
23
+ {
20
24
 
25
+ }
@@ -5,24 +5,28 @@ import {Registerable} from "../registry/Registry.sol";
5
5
  import {IRegistry} from "../registry/IRegistry.sol";
6
6
 
7
7
  import {IAccessModule, AccessModule} from "./access/Access.sol";
8
+ import {LifecycleModule} from "./lifecycle/LifecycleModule.sol";
8
9
  import {ComponentModule} from "./component/ComponentModule.sol";
9
10
  import {ProductModule} from "./product/ProductService.sol";
10
11
  import {PolicyModule} from "./policy/PolicyModule.sol";
11
12
  import {PoolModule} from "./pool/PoolModule.sol";
13
+ import {TreasuryModule} from "./treasury/TreasuryModule.sol";
12
14
 
13
15
  import {IInstance} from "./IInstance.sol";
16
+ import {ObjectType, INSTANCE} from "../types/ObjectType.sol";
14
17
  import {NftId, toNftId} from "../types/NftId.sol";
15
18
 
16
19
  contract Instance is
17
20
  Registerable,
18
21
  AccessModule,
19
- ComponentModule,
20
- PolicyModule,
22
+ LifecycleModule,
23
+ ComponentModule,
24
+ PolicyModule,
21
25
  PoolModule,
22
- ProductModule,
26
+ ProductModule,
27
+ TreasuryModule,
23
28
  IInstance
24
29
  {
25
-
26
30
  constructor(
27
31
  address registry,
28
32
  address componentOwnerService,
@@ -34,31 +38,35 @@ contract Instance is
34
38
  PolicyModule(productService)
35
39
  ProductModule(productService)
36
40
  PoolModule(productService)
37
- { }
41
+ // solhint-disable-next-line no-empty-blocks
42
+ {
43
+
44
+ }
38
45
 
39
46
  // from registerable
40
- function register() external override returns(NftId nftId) {
41
- require(address(_registry) != address(0), "ERROR:PRD-001:REGISTRY_ZERO");
47
+ function register() external override returns (NftId nftId) {
48
+ require(
49
+ address(_registry) != address(0),
50
+ "ERROR:PRD-001:REGISTRY_ZERO"
51
+ );
42
52
  return _registry.register(address(this));
43
53
  }
44
54
 
45
55
  // from registerable
46
- function getParentNftId() public view override returns(NftId) {
56
+ function getParentNftId() public pure override returns (NftId) {
47
57
  // TODO add self registry and exchange 0 for_registry.getNftId();
48
58
  // define parent tree for all registerables
49
- // eg 0 <- chain(mainnet) <- global registry <- chain registry <- instance <- component <- policy/bundle
59
+ // eg 0 <- chain(mainnet) <- global registry <- chain registry <- instance <- component <- policy/bundle
50
60
  return toNftId(0);
51
61
  }
52
62
 
53
63
  // from registerable
54
- function getType() external view override returns(uint256 objectType) {
55
- return _registry.INSTANCE();
64
+ function getType() external pure override returns (ObjectType objectType) {
65
+ return INSTANCE();
56
66
  }
57
67
 
58
68
  // from registerable
59
- function getData() external view override returns(bytes memory data) {
69
+ function getData() external pure override returns (bytes memory data) {
60
70
  return bytes(abi.encode(0));
61
71
  }
62
-
63
-
64
72
  }