@etherisc/gif-next 0.0.2-dc7e4cb-141 → 0.0.2-de220d6-949
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -14
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +2 -2
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +2 -2
- package/artifacts/contracts/experiment/errors/IncrementRevert.sol/IIncrementRevert.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/IncrementRevert.sol/IIncrementRevert.json +27 -0
- package/artifacts/contracts/experiment/errors/IncrementRevert.sol/IncrementRevert.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/IncrementRevert.sol/IncrementRevert.json +83 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/IRevert.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/IRevert.json +75 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +34 -2
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
- 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 +1 -1
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +2 -2
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +54 -195
- package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +202 -269
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{service → base}/ComponentServiceBase.sol/ComponentServiceBase.json +1 -1
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{IServiceLinked.sol/IServiceLinked.json → base/IInstanceBase.sol/IInstanceBase.json} +15 -2
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +511 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/{module/lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/instance/{service → base}/IService.sol/IService.json +1 -1
- package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol}/InstanceBase.json +14 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +692 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.json +10 -0
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/{service → base}/ServiceBase.sol/ServiceBase.json +1 -1
- package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +50 -30
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +50 -30
- package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +1 -1
- package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +12 -2
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +12 -2
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
- package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +34 -2
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +2 -2
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +4 -4
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
- package/artifacts/contracts/test/TestPool.sol/TestPool.json +2 -2
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
- package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +2 -2
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +38 -4
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/BaseComponent.sol +0 -1
- package/contracts/experiment/errors/IncrementRevert.sol +43 -0
- package/contracts/experiment/errors/Revert.sol +13 -4
- package/contracts/instance/IInstance.sol +9 -10
- package/contracts/instance/Instance.sol +9 -7
- package/contracts/instance/{service → base}/ComponentServiceBase.sol +1 -0
- package/contracts/instance/base/IInstanceBase.sol +14 -0
- package/contracts/instance/base/IKeyValueStore.sol +49 -0
- package/contracts/instance/base/ILifecycle.sol +30 -0
- package/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol} +20 -11
- package/contracts/instance/base/KeyValueStore.sol +156 -0
- package/contracts/instance/{module/lifecycle/LifecycleModule.sol → base/Lifecycle.sol} +36 -30
- package/contracts/instance/base/ModuleBase.sol +52 -0
- package/contracts/instance/{service → base}/ServiceBase.sol +0 -2
- package/contracts/instance/module/access/Access.sol +3 -3
- package/contracts/instance/module/bundle/BundleModule.sol +24 -116
- package/contracts/instance/module/bundle/IBundle.sol +8 -3
- package/contracts/instance/module/component/ComponentModule.sol +10 -18
- package/contracts/instance/module/policy/IPolicy.sol +2 -1
- package/contracts/instance/module/policy/PolicyModule.sol +4 -11
- package/contracts/instance/service/ComponentOwnerService.sol +1 -2
- package/contracts/instance/service/IComponentOwnerService.sol +1 -1
- package/contracts/instance/service/IPoolService.sol +1 -1
- package/contracts/instance/service/IProductService.sol +1 -1
- package/contracts/instance/service/PoolService.sol +1 -1
- package/contracts/instance/service/ProductService.sol +2 -3
- package/contracts/registry/Registry.sol +1 -1
- package/contracts/test/TestRoleId.sol +2 -2
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/Key32.sol +45 -0
- package/contracts/types/NftId.sol +16 -1
- package/contracts/types/RoleId.sol +11 -9
- package/contracts/types/StateId.sol +7 -1
- package/package.json +1 -1
- package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +0 -4
- package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
- package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
- package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
- package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
- package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/contracts/instance/IServiceLinked.sol +0 -12
- package/contracts/instance/module/lifecycle/ILifecycle.sol +0 -47
- /package/contracts/instance/{service → base}/IService.sol +0 -0
@@ -3,7 +3,6 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {IRegistry} from "../../../registry/IRegistry.sol";
|
5
5
|
|
6
|
-
import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
|
7
6
|
import {IProductService} from "../../service/IProductService.sol";
|
8
7
|
import {IPolicy, IPolicyModule} from "./IPolicy.sol";
|
9
8
|
import {ObjectType, POLICY} from "../../../types/ObjectType.sol";
|
@@ -12,15 +11,11 @@ import {NftId, NftIdLib} from "../../../types/NftId.sol";
|
|
12
11
|
import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
|
13
12
|
import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
|
14
13
|
|
15
|
-
import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
|
16
|
-
|
17
14
|
abstract contract PolicyModule is IPolicyModule {
|
18
15
|
using NftIdLib for NftId;
|
19
16
|
|
20
17
|
mapping(NftId nftId => PolicyInfo info) private _policyInfo;
|
21
18
|
|
22
|
-
LifecycleModule private _lifecycleModule;
|
23
|
-
|
24
19
|
// TODO find a better place to avoid dupliation
|
25
20
|
modifier onlyProductService2() {
|
26
21
|
require(
|
@@ -30,10 +25,6 @@ abstract contract PolicyModule is IPolicyModule {
|
|
30
25
|
_;
|
31
26
|
}
|
32
27
|
|
33
|
-
constructor() {
|
34
|
-
_lifecycleModule = LifecycleModule(address(this));
|
35
|
-
}
|
36
|
-
|
37
28
|
function createApplication(
|
38
29
|
NftId productNftId,
|
39
30
|
NftId policyNftId,
|
@@ -51,12 +42,14 @@ abstract contract PolicyModule is IPolicyModule {
|
|
51
42
|
productNftId,
|
52
43
|
bundleNftId,
|
53
44
|
address(0), // beneficiary = policy nft holder
|
54
|
-
_lifecycleModule.getInitialState(POLICY()),
|
45
|
+
// _lifecycleModule.getInitialState(POLICY()),
|
46
|
+
APPLIED(),
|
55
47
|
sumInsuredAmount,
|
56
48
|
premiumAmount,
|
57
49
|
0, // premium paid amount
|
58
50
|
lifetime,
|
59
|
-
"", //
|
51
|
+
"", // applicationData
|
52
|
+
"", // policyData
|
60
53
|
blockTimestamp(), // createdAt
|
61
54
|
zeroTimestamp(), // activatedAt
|
62
55
|
zeroTimestamp(), // expiredAt
|
@@ -6,7 +6,6 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
|
|
6
6
|
import {IRegistry} from "../../registry/IRegistry.sol";
|
7
7
|
import {IInstance} from "../IInstance.sol";
|
8
8
|
|
9
|
-
import {LifecycleModule} from "../module/lifecycle/LifecycleModule.sol";
|
10
9
|
import {ITreasuryModule} from "../module/treasury/ITreasury.sol";
|
11
10
|
import {TreasuryModule} from "../module/treasury/TreasuryModule.sol";
|
12
11
|
import {IComponent, IComponentModule} from "../module/component/IComponent.sol";
|
@@ -24,7 +23,7 @@ import {Fee} from "../../types/Fee.sol";
|
|
24
23
|
import {Version, VersionLib} from "../../types/Version.sol";
|
25
24
|
|
26
25
|
import {IProductComponent} from "../../components/IProductComponent.sol";
|
27
|
-
import {ServiceBase} from "
|
26
|
+
import {ServiceBase} from "../base/ServiceBase.sol";
|
28
27
|
import {IComponentOwnerService} from "./IComponentOwnerService.sol";
|
29
28
|
|
30
29
|
contract ComponentOwnerService is
|
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
|
|
5
5
|
import {ObjectType} from "../../types/ObjectType.sol";
|
6
6
|
import {RoleId} from "../../types/RoleId.sol";
|
7
7
|
import {IBaseComponent} from "../../components/IBaseComponent.sol";
|
8
|
-
import {IService} from "
|
8
|
+
import {IService} from "../base/IService.sol";
|
9
9
|
|
10
10
|
// TODO rename to registry service
|
11
11
|
interface IComponentOwnerService is IService {
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../types/NftId.sol";
|
5
5
|
import {Fee} from "../../types/Fee.sol";
|
6
|
-
import {IService} from "
|
6
|
+
import {IService} from "../base/IService.sol";
|
7
7
|
|
8
8
|
interface IPoolService is IService {
|
9
9
|
function setFees(
|
@@ -5,7 +5,7 @@ import {NftId} from "../../types/NftId.sol";
|
|
5
5
|
import {Timestamp} from "../../types/Timestamp.sol";
|
6
6
|
import {UFixed} from "../../types/UFixed.sol";
|
7
7
|
import {Fee} from "../../types/Fee.sol";
|
8
|
-
import {IService} from "
|
8
|
+
import {IService} from "../base/IService.sol";
|
9
9
|
|
10
10
|
interface IProductService is IService {
|
11
11
|
function setFees(
|
@@ -13,7 +13,7 @@ import {POOL, BUNDLE} from "../../types/ObjectType.sol";
|
|
13
13
|
import {Fee} from "../../types/Fee.sol";
|
14
14
|
import {Version, VersionLib} from "../../types/Version.sol";
|
15
15
|
|
16
|
-
import {ComponentServiceBase} from "
|
16
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
17
17
|
import {IPoolService} from "./IPoolService.sol";
|
18
18
|
|
19
19
|
|
@@ -22,7 +22,7 @@ import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
|
|
22
22
|
import {Fee, FeeLib} from "../../types/Fee.sol";
|
23
23
|
import {Version, VersionLib} from "../../types/Version.sol";
|
24
24
|
|
25
|
-
import {ComponentServiceBase} from "
|
25
|
+
import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
|
26
26
|
import {IProductService} from "./IProductService.sol";
|
27
27
|
|
28
28
|
// TODO or name this ProtectionService to have Product be something more generic (loan, savings account, ...)
|
@@ -134,7 +134,6 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
134
134
|
returns (IBundle.BundleInfo memory)
|
135
135
|
{
|
136
136
|
bundleInfo.lockedAmount += collateralAmount;
|
137
|
-
bundleInfo.updatedIn = blockNumber();
|
138
137
|
instance.collateralizePolicy(bundleInfo.nftId, policyNftId, collateralAmount);
|
139
138
|
return bundleInfo;
|
140
139
|
}
|
@@ -151,7 +150,7 @@ contract ProductService is ComponentServiceBase, IProductService {
|
|
151
150
|
IPoolComponent pool = IPoolComponent(poolAddress);
|
152
151
|
pool.underwrite(
|
153
152
|
policyInfo.nftId,
|
154
|
-
policyInfo.
|
153
|
+
policyInfo.applicationData,
|
155
154
|
bundleFilter,
|
156
155
|
collateralAmount);
|
157
156
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
5
|
-
import {IService} from "../instance/
|
5
|
+
import {IService} from "../instance/base/IService.sol";
|
6
6
|
|
7
7
|
import {IChainNft} from "./IChainNft.sol";
|
8
8
|
import {ChainNft} from "./ChainNft.sol";
|
@@ -1,10 +1,10 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
-
import {RoleId,
|
4
|
+
import {RoleId, RoleIdLib, PRODUCT_OWNER_ROLE_NAME, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE_NAME, POOL_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
|
5
5
|
|
6
6
|
contract TestRoleId {
|
7
|
-
function getRole(string memory roleName) external pure returns (RoleId) { return toRoleId(roleName); }
|
7
|
+
function getRole(string memory roleName) external pure returns (RoleId) { return RoleIdLib.toRoleId(roleName); }
|
8
8
|
|
9
9
|
function getProductOwnerRoleName() external pure returns (string memory) { return PRODUCT_OWNER_ROLE_NAME(); }
|
10
10
|
function getProductOwnerRole() external pure returns (RoleId) { return PRODUCT_OWNER_ROLE(); }
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.19;
|
|
3
3
|
|
4
4
|
import {NftId} from "../../contracts/types/NftId.sol";
|
5
5
|
import {Version, VersionLib} from "../../contracts/types/Version.sol";
|
6
|
-
import {ServiceBase} from "../../contracts/instance/
|
6
|
+
import {ServiceBase} from "../../contracts/instance/base/ServiceBase.sol";
|
7
7
|
|
8
8
|
import {IVersionable} from "../../contracts/shared/IVersionable.sol";
|
9
9
|
import {Versionable} from "../../contracts/shared/Versionable.sol";
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {ObjectType} from "./ObjectType.sol";
|
5
|
+
|
6
|
+
type Key32 is bytes32;
|
7
|
+
type KeyId is bytes31;
|
8
|
+
|
9
|
+
// type bindings
|
10
|
+
using {
|
11
|
+
eqKey32 as ==,
|
12
|
+
neKey32 as !=,
|
13
|
+
Key32Lib.toKey
|
14
|
+
} for Key32 global;
|
15
|
+
|
16
|
+
// @dev Returns true iff keys are identical
|
17
|
+
function eqKey32(Key32 a, Key32 b) pure returns (bool isSame) {
|
18
|
+
return Key32.unwrap(a) == Key32.unwrap(b);
|
19
|
+
}
|
20
|
+
|
21
|
+
// @dev Returns true iff keys are different
|
22
|
+
function neKey32(Key32 a, Key32 b) pure returns (bool isDifferent) {
|
23
|
+
return Key32.unwrap(a) != Key32.unwrap(b);
|
24
|
+
}
|
25
|
+
|
26
|
+
library Key32Lib {
|
27
|
+
|
28
|
+
uint8 public constant TYPE_SHIFT = 31 * 8;
|
29
|
+
uint8 public constant ID_SHIFT = uint8(32 * 8 - TYPE_SHIFT);
|
30
|
+
bytes32 public constant TYPE_MASK = bytes32(bytes1(type(uint8).max)); // first byte in bytes32
|
31
|
+
bytes32 public constant ID_MASK = bytes32(~TYPE_MASK); // remaining bytes in bytes32
|
32
|
+
|
33
|
+
function toKey32(ObjectType objectType, KeyId id) public pure returns (Key32) {
|
34
|
+
uint256 uintObjectType = ObjectType.unwrap(objectType);
|
35
|
+
uint256 uintId = uint248(KeyId.unwrap(id));
|
36
|
+
uint256 uintKey = (uintObjectType << TYPE_SHIFT) + uintId;
|
37
|
+
return Key32.wrap(bytes32(uintKey));
|
38
|
+
}
|
39
|
+
|
40
|
+
function toKey(Key32 key) public pure returns (ObjectType objectType, KeyId id) {
|
41
|
+
bytes32 key32 = Key32.unwrap(key);
|
42
|
+
objectType = ObjectType.wrap(uint8(uint256(key32 & TYPE_MASK) >> TYPE_SHIFT));
|
43
|
+
id = KeyId.wrap(bytes31((key32 & ID_MASK) << ID_SHIFT));
|
44
|
+
}
|
45
|
+
}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.19;
|
3
3
|
|
4
|
+
import {Key32, KeyId, Key32Lib} from "./Key32.sol";
|
5
|
+
import {ObjectType} from "./ObjectType.sol";
|
6
|
+
|
4
7
|
// uint96 allows for chain ids up to 13 digits
|
5
8
|
type NftId is uint96;
|
6
9
|
|
@@ -10,7 +13,9 @@ using {
|
|
10
13
|
neNftId as !=,
|
11
14
|
NftIdLib.toInt,
|
12
15
|
NftIdLib.gtz,
|
13
|
-
NftIdLib.eqz
|
16
|
+
NftIdLib.eqz,
|
17
|
+
NftIdLib.toKeyId,
|
18
|
+
NftIdLib.toKey32
|
14
19
|
} for NftId global;
|
15
20
|
|
16
21
|
// general pure free functions
|
@@ -54,4 +59,14 @@ library NftIdLib {
|
|
54
59
|
function eq(NftId a, NftId b) public pure returns (bool isSame) {
|
55
60
|
return eqNftId(a, b);
|
56
61
|
}
|
62
|
+
|
63
|
+
/// @dev Returns the key32 value for the specified nft id and object type.
|
64
|
+
function toKey32(NftId id, ObjectType objectType) public pure returns (Key32 key) {
|
65
|
+
return Key32Lib.toKey32(objectType, toKeyId(id));
|
66
|
+
}
|
67
|
+
|
68
|
+
/// @dev Returns the key id value for the specified nft id
|
69
|
+
function toKeyId(NftId id) public pure returns (KeyId keyId) {
|
70
|
+
return KeyId.wrap(bytes31(uint248(NftId.unwrap(id))));
|
71
|
+
}
|
57
72
|
}
|
@@ -15,15 +15,10 @@ function ORACLE_OWNER_ROLE_NAME() pure returns (string memory) { return "OracleO
|
|
15
15
|
function POOL_OWNER_ROLE_NAME() pure returns (string memory) { return "PoolOwnerRole"; }
|
16
16
|
function PRODUCT_OWNER_ROLE_NAME() pure returns (string memory) { return "ProductOwnerRole"; }
|
17
17
|
|
18
|
-
function DISTRIBUTOR_OWNER_ROLE() pure returns (RoleId) { return toRoleId("DistributorOwnerRole"); }
|
19
|
-
function ORACLE_OWNER_ROLE() pure returns (RoleId) { return toRoleId("OracleOwnerRole"); }
|
20
|
-
function POOL_OWNER_ROLE() pure returns (RoleId) { return toRoleId("PoolOwnerRole"); }
|
21
|
-
function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return toRoleId("ProductOwnerRole"); }
|
22
|
-
|
23
|
-
// @dev Converts a role string into a role id.
|
24
|
-
function toRoleId(string memory role) pure returns (RoleId) {
|
25
|
-
return RoleId.wrap(bytes8(keccak256(abi.encode(role))));
|
26
|
-
}
|
18
|
+
function DISTRIBUTOR_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("DistributorOwnerRole"); }
|
19
|
+
function ORACLE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("OracleOwnerRole"); }
|
20
|
+
function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("PoolOwnerRole"); }
|
21
|
+
function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("ProductOwnerRole"); }
|
27
22
|
|
28
23
|
// @dev Returns true iff role ids a and b are identical
|
29
24
|
function eqRoleId(RoleId a, RoleId b) pure returns (bool isSame) {
|
@@ -34,3 +29,10 @@ function eqRoleId(RoleId a, RoleId b) pure returns (bool isSame) {
|
|
34
29
|
function neRoleId(RoleId a, RoleId b) pure returns (bool isDifferent) {
|
35
30
|
return RoleId.unwrap(a) != RoleId.unwrap(b);
|
36
31
|
}
|
32
|
+
|
33
|
+
library RoleIdLib {
|
34
|
+
// @dev Converts a role string into a role id.
|
35
|
+
function toRoleId(string memory role) public pure returns (RoleId) {
|
36
|
+
return RoleId.wrap(bytes8(keccak256(abi.encode(role))));
|
37
|
+
}
|
38
|
+
}
|
@@ -5,7 +5,13 @@ pragma solidity ^0.8.19;
|
|
5
5
|
type StateId is uint8;
|
6
6
|
|
7
7
|
// type bindings
|
8
|
-
using {
|
8
|
+
using {
|
9
|
+
eqStateId as ==,
|
10
|
+
neStateId as !=,
|
11
|
+
StateIdLib.eqz,
|
12
|
+
StateIdLib.gtz,
|
13
|
+
StateIdLib.toInt
|
14
|
+
} for StateId global;
|
9
15
|
|
10
16
|
// general pure free functions
|
11
17
|
function APPLIED() pure returns (StateId) {
|
package/package.json
CHANGED
@@ -1,134 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"_format": "hh-sol-artifact-1",
|
3
|
-
"contractName": "ILifecycle",
|
4
|
-
"sourceName": "contracts/instance/module/lifecycle/ILifecycle.sol",
|
5
|
-
"abi": [
|
6
|
-
{
|
7
|
-
"inputs": [
|
8
|
-
{
|
9
|
-
"internalType": "NftId",
|
10
|
-
"name": "nftId",
|
11
|
-
"type": "uint96"
|
12
|
-
},
|
13
|
-
{
|
14
|
-
"internalType": "ObjectType",
|
15
|
-
"name": "objectType",
|
16
|
-
"type": "uint8"
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"internalType": "StateId",
|
20
|
-
"name": "fromStateId",
|
21
|
-
"type": "uint8"
|
22
|
-
},
|
23
|
-
{
|
24
|
-
"internalType": "StateId",
|
25
|
-
"name": "toStateId",
|
26
|
-
"type": "uint8"
|
27
|
-
}
|
28
|
-
],
|
29
|
-
"name": "ErrorInvalidStateTransition",
|
30
|
-
"type": "error"
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"inputs": [
|
34
|
-
{
|
35
|
-
"internalType": "NftId",
|
36
|
-
"name": "nftId",
|
37
|
-
"type": "uint96"
|
38
|
-
},
|
39
|
-
{
|
40
|
-
"internalType": "ObjectType",
|
41
|
-
"name": "objectType",
|
42
|
-
"type": "uint8"
|
43
|
-
}
|
44
|
-
],
|
45
|
-
"name": "ErrorNoLifecycle",
|
46
|
-
"type": "error"
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"anonymous": false,
|
50
|
-
"inputs": [
|
51
|
-
{
|
52
|
-
"indexed": false,
|
53
|
-
"internalType": "NftId",
|
54
|
-
"name": "nftId",
|
55
|
-
"type": "uint96"
|
56
|
-
},
|
57
|
-
{
|
58
|
-
"indexed": false,
|
59
|
-
"internalType": "StateId",
|
60
|
-
"name": "fromStateId",
|
61
|
-
"type": "uint8"
|
62
|
-
},
|
63
|
-
{
|
64
|
-
"indexed": false,
|
65
|
-
"internalType": "StateId",
|
66
|
-
"name": "toStateId",
|
67
|
-
"type": "uint8"
|
68
|
-
}
|
69
|
-
],
|
70
|
-
"name": "LogBundleStateChanged",
|
71
|
-
"type": "event"
|
72
|
-
},
|
73
|
-
{
|
74
|
-
"anonymous": false,
|
75
|
-
"inputs": [
|
76
|
-
{
|
77
|
-
"indexed": false,
|
78
|
-
"internalType": "NftId",
|
79
|
-
"name": "nftId",
|
80
|
-
"type": "uint96"
|
81
|
-
},
|
82
|
-
{
|
83
|
-
"indexed": false,
|
84
|
-
"internalType": "ObjectType",
|
85
|
-
"name": "objectType",
|
86
|
-
"type": "uint8"
|
87
|
-
},
|
88
|
-
{
|
89
|
-
"indexed": false,
|
90
|
-
"internalType": "StateId",
|
91
|
-
"name": "fromStateId",
|
92
|
-
"type": "uint8"
|
93
|
-
},
|
94
|
-
{
|
95
|
-
"indexed": false,
|
96
|
-
"internalType": "StateId",
|
97
|
-
"name": "toStateId",
|
98
|
-
"type": "uint8"
|
99
|
-
}
|
100
|
-
],
|
101
|
-
"name": "LogComponentStateChanged",
|
102
|
-
"type": "event"
|
103
|
-
},
|
104
|
-
{
|
105
|
-
"anonymous": false,
|
106
|
-
"inputs": [
|
107
|
-
{
|
108
|
-
"indexed": false,
|
109
|
-
"internalType": "NftId",
|
110
|
-
"name": "nftId",
|
111
|
-
"type": "uint96"
|
112
|
-
},
|
113
|
-
{
|
114
|
-
"indexed": false,
|
115
|
-
"internalType": "StateId",
|
116
|
-
"name": "fromStateId",
|
117
|
-
"type": "uint8"
|
118
|
-
},
|
119
|
-
{
|
120
|
-
"indexed": false,
|
121
|
-
"internalType": "StateId",
|
122
|
-
"name": "toStateId",
|
123
|
-
"type": "uint8"
|
124
|
-
}
|
125
|
-
],
|
126
|
-
"name": "LogPolicyStateChanged",
|
127
|
-
"type": "event"
|
128
|
-
}
|
129
|
-
],
|
130
|
-
"bytecode": "0x",
|
131
|
-
"deployedBytecode": "0x",
|
132
|
-
"linkReferences": {},
|
133
|
-
"deployedLinkReferences": {}
|
134
|
-
}
|