@etherisc/gif-next 0.0.2-ed4dd55 → 0.0.2-f74fcad-685
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +33 -0
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +35 -9
- package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/InstanceLinked.json +2 -2
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +84 -8
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +34 -152
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +146 -13
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +148 -15
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +714 -127
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +845 -129
- package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +1 -1
- package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +31 -59
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +103 -6
- package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +34 -8
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +31 -59
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +50 -3
- package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycle.json +134 -0
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +4 -0
- package/artifacts/contracts/instance/lifecycle/ILifecycle.sol/ILifecycleModule.json +182 -0
- package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +4 -0
- package/artifacts/contracts/instance/lifecycle/LifecycleModule.sol/LifecycleModule.json +221 -0
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.json +44 -21
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +44 -21
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +1 -1
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.json +23 -43
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.json +28 -35
- package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +1 -1
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/product/IProductService.sol/IProductService.json +21 -8
- package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +1 -1
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +85 -14
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasury.json +10 -0
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
- package/artifacts/contracts/instance/treasury/ITreasury.sol/ITreasuryModule.json +490 -0
- package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
- package/artifacts/contracts/instance/treasury/TokenHandler.sol/TokenHandler.json +45 -0
- package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
- package/artifacts/contracts/instance/treasury/TreasuryModule.sol/TreasuryModule.json +490 -0
- package/artifacts/contracts/mock/Dip.sol/DIP.dbg.json +4 -0
- package/artifacts/contracts/mock/Dip.sol/DIP.json +338 -0
- package/artifacts/contracts/mock/TestPool.sol/TestPool.dbg.json +4 -0
- package/artifacts/contracts/mock/TestPool.sol/TestPool.json +294 -0
- package/artifacts/contracts/mock/TestProduct.sol/TestProduct.dbg.json +4 -0
- package/artifacts/contracts/mock/TestProduct.sol/TestProduct.json +384 -0
- package/artifacts/contracts/mock/Usdc.sol/USDC.dbg.json +4 -0
- package/artifacts/contracts/mock/Usdc.sol/USDC.json +338 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +8 -8
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +20 -111
- package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registerable.json +9 -9
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +66 -115
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +2 -2
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +85 -3
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +174 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +479 -0
- package/contracts/components/Component.sol +39 -24
- package/contracts/components/IPool.sol +9 -3
- package/contracts/components/IProduct.sol +11 -6
- package/contracts/components/Pool.sol +37 -14
- package/contracts/components/Product.sol +48 -24
- package/contracts/experiment/errors/Require.sol +38 -0
- package/contracts/experiment/errors/Revert.sol +44 -0
- package/contracts/experiment/inheritance/A.sol +8 -11
- package/contracts/experiment/inheritance/B.sol +10 -5
- package/contracts/experiment/inheritance/C.sol +11 -5
- package/contracts/experiment/inheritance/IA.sol +2 -7
- package/contracts/experiment/inheritance/IB.sol +3 -2
- package/contracts/experiment/inheritance/IC.sol +4 -3
- package/contracts/experiment/statemachine/Dummy.sol +27 -0
- package/contracts/experiment/statemachine/ISM.sol +25 -0
- package/contracts/experiment/statemachine/README.md +112 -0
- package/contracts/experiment/statemachine/SM.sol +57 -0
- package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
- package/contracts/experiment/types/TypeA.sol +14 -9
- package/contracts/experiment/types/TypeB.sol +14 -9
- package/contracts/instance/IInstance.sol +8 -3
- package/contracts/instance/Instance.sol +24 -15
- package/contracts/instance/access/Access.sol +63 -116
- package/contracts/instance/access/IAccess.sol +28 -48
- package/contracts/instance/component/ComponentModule.sol +162 -147
- package/contracts/instance/component/IComponent.sol +41 -61
- package/contracts/instance/lifecycle/ILifecycle.sol +47 -0
- package/contracts/instance/lifecycle/LifecycleModule.sol +88 -0
- package/contracts/instance/policy/IPolicy.sol +19 -35
- package/contracts/instance/policy/PolicyModule.sol +52 -44
- package/contracts/instance/pool/IPoolModule.sol +9 -26
- package/contracts/instance/pool/PoolModule.sol +43 -45
- package/contracts/instance/product/IProductService.sol +10 -19
- package/contracts/instance/product/ProductService.sol +86 -55
- package/contracts/instance/treasury/ITreasury.sol +91 -0
- package/contracts/instance/treasury/TokenHandler.sol +24 -0
- package/contracts/instance/treasury/TreasuryModule.sol +168 -0
- package/contracts/mock/Dip.sol +26 -0
- package/contracts/mock/TestPool.sol +16 -0
- package/contracts/mock/TestProduct.sol +39 -0
- package/contracts/mock/Usdc.sol +26 -0
- package/contracts/registry/ChainNft.sol +23 -61
- package/contracts/registry/IChainNft.sol +10 -7
- package/contracts/registry/IRegistry.sol +40 -41
- package/contracts/registry/Registry.sol +73 -67
- package/contracts/types/Blocknumber.sol +118 -0
- package/contracts/types/ChainId.sol +24 -10
- package/contracts/types/Fee.sol +32 -0
- package/contracts/types/NftId.sol +36 -10
- package/contracts/types/ObjectType.sol +107 -0
- package/contracts/types/StateId.sol +91 -0
- package/contracts/types/Timestamp.sol +102 -0
- package/contracts/types/UFixed.sol +210 -0
- 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
|
-
|
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(
|
40
|
-
|
41
|
-
|
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(
|
52
|
-
|
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(
|
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
|
-
|
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 {
|
4
|
+
import {NftId} from "../types/NftId.sol";
|
5
|
+
import {Fee} from "../types/Fee.sol";
|
5
6
|
|
6
|
-
interface IProductComponent
|
7
|
-
|
8
|
-
{
|
7
|
+
interface IProductComponent {
|
8
|
+
function getPoolNftId() external view returns (NftId poolNftId);
|
9
9
|
|
10
|
-
function
|
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
|
-
|
9
|
-
|
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
|
-
|
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
|
22
|
-
return
|
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
|
20
|
-
|
21
|
-
|
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
|
-
|
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(
|
47
|
-
internal
|
48
|
-
{
|
49
|
+
function _underwrite(NftId nftId) internal {
|
49
50
|
_productService.underwrite(nftId);
|
50
51
|
}
|
51
52
|
|
52
|
-
function
|
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
|
58
|
-
return
|
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) {
|
46
|
-
|
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) {
|
18
|
-
|
16
|
+
function getB() external view override returns (uint256) {
|
17
|
+
return _x;
|
18
|
+
}
|
19
19
|
|
20
|
-
|
21
|
-
|
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) {
|
18
|
-
|
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) {
|
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
|
7
|
-
|
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
|
+
}
|