@etherisc/gif-next 0.0.2-c8acbd3-764 → 0.0.2-ce2fc91-485

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/README.md +25 -0
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  4. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  5. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  7. package/artifacts/contracts/components/Pool.sol/Pool.json +2 -2
  8. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  9. package/artifacts/contracts/components/Product.sol/Product.json +2 -2
  10. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  11. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  12. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  13. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  14. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  15. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  16. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  22. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  28. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  29. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +69 -19
  30. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  31. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  32. package/artifacts/contracts/instance/Instance.sol/Instance.json +121 -87
  33. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  34. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  35. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  36. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  37. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  38. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  39. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  40. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
  41. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
  43. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  45. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  46. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  47. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  48. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +1 -1
  52. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +65 -12
  56. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +64 -11
  59. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  61. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +12 -2
  62. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +12 -2
  64. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  74. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +14 -30
  77. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  78. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  80. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +2 -2
  82. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +2 -2
  84. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  85. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  86. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  87. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  88. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  89. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  90. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  91. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  92. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  93. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  94. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  95. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  96. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  97. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  98. package/artifacts/contracts/test/TestPool.sol/TestPool.json +2 -2
  99. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  100. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +2 -2
  101. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  102. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  103. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  104. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  105. package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
  106. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  107. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  108. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  109. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  110. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  111. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  112. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  113. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  114. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  115. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  116. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  117. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  118. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  119. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  120. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  121. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  122. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  123. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  124. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  125. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  126. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  127. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  128. package/contracts/instance/IInstance.sol +1 -1
  129. package/contracts/instance/Instance.sol +1 -1
  130. package/contracts/instance/module/component/ComponentModule.sol +53 -44
  131. package/contracts/instance/module/component/IComponent.sol +17 -7
  132. package/contracts/instance/module/policy/IPolicy.sol +2 -1
  133. package/contracts/instance/module/policy/PolicyModule.sol +2 -1
  134. package/contracts/instance/service/ComponentOwnerService.sol +22 -16
  135. package/contracts/instance/service/ProductService.sol +1 -1
  136. package/contracts/registry/Registry.sol +2 -2
  137. package/contracts/types/ObjectType.sol +8 -4
  138. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/ac8b1a0ba35c3a8a508882d70043ad3f.json"
3
+ "buildInfo": "../../../build-info/3e18b257c0aaa6e0f6affdec1f5c116c.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/ac8b1a0ba35c3a8a508882d70043ad3f.json"
3
+ "buildInfo": "../../../build-info/3e18b257c0aaa6e0f6affdec1f5c116c.json"
4
4
  }
@@ -44,7 +44,7 @@ interface IInstance is
44
44
 
45
45
  function hasRole(RoleId role, address member) external view override (IAccessModule, IComponentModule) returns (bool hasRole);
46
46
 
47
- function getKeyValueStore() external view override (IBundleModule, IInstanceBase) returns (IKeyValueStore keyValueStore);
47
+ function getKeyValueStore() external view override (IBundleModule, IComponentModule, IInstanceBase) returns (IKeyValueStore keyValueStore);
48
48
  function getComponentOwnerService() external view override (IInstanceBase, IComponentModule) returns(IComponentOwnerService);
49
49
  function getProductService() external view override (IInstanceBase, IBundleModule, IPolicyModule) returns(IProductService);
50
50
  function getPoolService() external view override (IInstanceBase, IBundleModule, IPoolModule) returns(IPoolService);
@@ -56,7 +56,7 @@ contract Instance is
56
56
  }
57
57
 
58
58
  function getRegistry() public view override (Registerable, IBundleModule, IComponentModule, IPolicyModule) returns (IRegistry registry) { return super.getRegistry(); }
59
- function getKeyValueStore() public view override (InstanceBase, IBundleModule) returns (IKeyValueStore keyValueStore) { return super.getKeyValueStore(); }
59
+ function getKeyValueStore() public view override (InstanceBase, IComponentModule, IBundleModule) returns (IKeyValueStore keyValueStore) { return super.getKeyValueStore(); }
60
60
 
61
61
  function hasRole(RoleId role, address member) public view override (AccessModule, IComponentModule) returns (bool) { return super.hasRole(role, member); }
62
62
 
@@ -4,25 +4,30 @@ pragma solidity ^0.8.19;
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
 
6
6
  import {IRegistry} from "../../../registry/IRegistry.sol";
7
- import {IInstance} from "../../IInstance.sol";
8
7
 
9
- import {IComponent, IComponentModule} from "./IComponent.sol";
10
- import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
11
- import {ObjectType, PRODUCT, ORACLE, POOL} from "../../../types/ObjectType.sol";
12
- import {StateId, ACTIVE, PAUSED} from "../../../types/StateId.sol";
13
- import {NftId, NftIdLib, zeroNftId} from "../../../types/NftId.sol";
14
- import {Fee} from "../../../types/Fee.sol";
8
+ import {IProductService} from "../../service/IProductService.sol";
9
+ import {IPoolService} from "../../service/IPoolService.sol";
15
10
 
16
- abstract contract ComponentModule is
11
+ import {NftId} from "../../../types/NftId.sol";
12
+ import {Key32, KeyId} from "../../../types/Key32.sol";
13
+ import {LibNftIdSet} from "../../../types/NftIdSet.sol";
14
+ import {ObjectType, COMPONENT, PRODUCT, ORACLE, POOL, BUNDLE, POLICY} from "../../../types/ObjectType.sol";
15
+ import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, REVOKED, DECLINED} from "../../../types/StateId.sol";
16
+ import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
17
+ import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
18
+
19
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
20
+ import {ModuleBase} from "../../base/ModuleBase.sol";
21
+
22
+ import {IComponentModule} from "./IComponent.sol";
23
+
24
+ abstract contract ComponentModule is
25
+ ModuleBase,
17
26
  IComponentModule
18
27
  {
19
- using NftIdLib for NftId;
20
28
 
21
- mapping(NftId nftId => ComponentInfo info) private _componentInfo;
22
29
  NftId[] private _nftIds;
23
30
 
24
- mapping(ObjectType cType => bytes32 role) private _componentOwnerRole;
25
-
26
31
  modifier onlyComponentOwnerService() {
27
32
  require(
28
33
  msg.sender == address(this.getComponentOwnerService()),
@@ -31,45 +36,43 @@ abstract contract ComponentModule is
31
36
  _;
32
37
  }
33
38
 
39
+ function initializeComponentModule(IKeyValueStore keyValueStore) internal {
40
+ _initialize(keyValueStore, COMPONENT());
41
+ }
42
+
34
43
  function registerComponent(
35
44
  NftId nftId,
36
- ObjectType objectType,
45
+ ObjectType, // objectType,
37
46
  IERC20Metadata token
38
- ) external override onlyComponentOwnerService {
39
-
40
- // create component info
41
- _componentInfo[nftId] = ComponentInfo(
47
+ )
48
+ external
49
+ onlyComponentOwnerService
50
+ override
51
+ {
52
+ ComponentInfo memory info = ComponentInfo(
42
53
  nftId,
43
- // _lifecycleModule.getInitialState(objectType),
44
- ACTIVE(),
45
54
  token
46
55
  );
47
56
 
48
57
  _nftIds.push(nftId);
49
58
 
50
- // TODO add logging
59
+ _create(nftId, abi.encode(info));
51
60
  }
52
61
 
53
- function setComponentInfo(
54
- ComponentInfo memory info
55
- ) external onlyComponentOwnerService returns (NftId nftId) {
56
- nftId = info.nftId;
57
- require(
58
- nftId.gtz() && _componentInfo[nftId].nftId.eq(nftId),
59
- "ERROR:CMP-006:COMPONENT_UNKNOWN"
60
- );
62
+ function setComponentInfo(ComponentInfo memory info)
63
+ external
64
+ override
65
+ onlyComponentOwnerService
66
+ {
67
+ _updateData(info.nftId, abi.encode(info));
68
+ }
61
69
 
62
- // TODO decide if state changes should have explicit functions and not
63
- // just a generic setXYZInfo and implicit state transitions
64
- // when in doubt go for the explicit approach ...
65
- // ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
66
- // _lifecycleModule.checkAndLogTransition(
67
- // nftId,
68
- // objectType,
69
- // _componentInfo[nftId].state,
70
- // info.state
71
- // );
72
- _componentInfo[nftId] = info;
70
+ function updateComponentState(NftId nftId, StateId state)
71
+ external
72
+ override
73
+ onlyComponentOwnerService
74
+ {
75
+ _updateState(nftId, state);
73
76
  }
74
77
 
75
78
  function getComponentCount()
@@ -87,9 +90,15 @@ abstract contract ComponentModule is
87
90
  return _nftIds[idx];
88
91
  }
89
92
 
90
- function getComponentInfo(
91
- NftId nftId
92
- ) external view override returns (ComponentInfo memory) {
93
- return _componentInfo[nftId];
93
+ function getComponentInfo(NftId nftId) external view override returns(ComponentInfo memory info) {
94
+ return abi.decode(_getData(nftId), (ComponentInfo));
94
95
  }
95
- }
96
+
97
+ function getComponentState(NftId nftId) external view returns (StateId state) {
98
+ return _getState(nftId);
99
+ }
100
+
101
+ function toComponentKey32(NftId nftId) external view override returns (Key32 key32) {
102
+ return _toKey32(nftId);
103
+ }
104
+ }
@@ -7,26 +7,24 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
7
7
  import {IRegistry} from "../../../registry/IRegistry.sol";
8
8
  import {IInstance} from "../../IInstance.sol";
9
9
  import {StateId} from "../../../types/StateId.sol";
10
+ import {Key32} from "../../../types/Key32.sol";
10
11
  import {NftId} from "../../../types/NftId.sol";
11
12
  import {ObjectType} from "../../../types/ObjectType.sol";
12
13
  import {RoleId} from "../../../types/RoleId.sol";
13
14
  import {Fee} from "../../../types/Fee.sol";
14
15
  import {UFixed} from "../../../types/UFixed.sol";
15
16
 
17
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
16
18
  import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
17
- // import {IComponentBase} from "../../../components/IComponentBase.sol";
18
19
 
19
20
  interface IComponent {
20
- // component dynamic info (static info kept in registry)
21
21
  struct ComponentInfo {
22
22
  NftId nftId;
23
- StateId state;
24
23
  IERC20Metadata token;
25
24
  }
26
25
  }
27
26
 
28
27
  interface IComponentModule is IComponent {
29
- function getRegistry() external view returns (IRegistry registry);
30
28
 
31
29
  function registerComponent(
32
30
  NftId nftId,
@@ -36,18 +34,30 @@ interface IComponentModule is IComponent {
36
34
 
37
35
  function setComponentInfo(
38
36
  ComponentInfo memory info
39
- ) external returns (NftId componentNftId);
37
+ ) external;
38
+
39
+ function updateComponentState(NftId nftId, StateId state) external;
40
40
 
41
41
  function getComponentInfo(
42
42
  NftId nftId
43
43
  ) external view returns (ComponentInfo memory info);
44
44
 
45
+ function getComponentState(NftId nftId) external view returns (StateId state);
46
+
45
47
  function getComponentCount() external view returns (uint256 numberOfCompnents);
46
48
 
47
49
  function getComponentId(uint256 idx) external view returns (NftId nftId);
48
50
 
51
+ function hasRole(RoleId role, address member) external view returns (bool);
52
+
53
+ function toComponentKey32(NftId nftId) external view returns (Key32 key32);
54
+
55
+ // repeat registry linked signature
56
+ function getRegistry() external view returns (IRegistry registry);
57
+
58
+ // repeat instance base signature
59
+ function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
60
+
49
61
  // repeat service linked signaturea to avoid linearization issues
50
62
  function getComponentOwnerService() external view returns(IComponentOwnerService);
51
-
52
- function hasRole(RoleId role, address member) external view returns (bool);
53
63
  }
@@ -21,7 +21,8 @@ interface IPolicy {
21
21
  uint256 premiumAmount;
22
22
  uint256 premiumPaidAmount;
23
23
  uint256 lifetime;
24
- bytes data;
24
+ bytes applicationData;
25
+ bytes policyData;
25
26
  Timestamp createdAt;
26
27
  Timestamp activatedAt; // time of underwriting
27
28
  Timestamp expiredAt; // no new claims (activatedAt + lifetime)
@@ -48,7 +48,8 @@ abstract contract PolicyModule is IPolicyModule {
48
48
  premiumAmount,
49
49
  0, // premium paid amount
50
50
  lifetime,
51
- "", // data
51
+ "", // applicationData
52
+ "", // policyData
52
53
  blockTimestamp(), // createdAt
53
54
  zeroTimestamp(), // activatedAt
54
55
  zeroTimestamp(), // expiredAt
@@ -143,28 +143,34 @@ contract ComponentOwnerService is
143
143
  function lock(
144
144
  IBaseComponent component
145
145
  ) external override onlyRegisteredComponent(component) {
146
+ // TODO use msg.sender to get component and get instance via registered parent nft id
146
147
  IInstance instance = component.getInstance();
147
- IComponent.ComponentInfo memory info = instance.getComponentInfo(
148
- component.getNftId()
149
- );
150
- require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
151
-
152
- info.state = PAUSED();
153
- // setComponentInfo checks for valid state changes
154
- instance.setComponentInfo(info);
148
+ instance.updateComponentState(component.getNftId(), PAUSED());
149
+ // IInstance instance = component.getInstance();
150
+ // IComponent.ComponentInfo memory info = instance.getComponentInfo(
151
+ // component.getNftId()
152
+ // );
153
+ // require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
154
+
155
+ // info.state = PAUSED();
156
+ // // setComponentInfo checks for valid state changes
157
+ // instance.setComponentInfo(info);
155
158
  }
156
159
 
157
160
  function unlock(
158
161
  IBaseComponent component
159
162
  ) external override onlyRegisteredComponent(component) {
163
+ // TODO use msg.sender to get component and get instance via registered parent nft id
160
164
  IInstance instance = component.getInstance();
161
- IComponent.ComponentInfo memory info = instance.getComponentInfo(
162
- component.getNftId()
163
- );
164
- require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
165
-
166
- info.state = ACTIVE();
167
- // setComponentInfo checks for valid state changes
168
- instance.setComponentInfo(info);
165
+ instance.updateComponentState(component.getNftId(), ACTIVE());
166
+ // IInstance instance = component.getInstance();
167
+ // IComponent.ComponentInfo memory info = instance.getComponentInfo(
168
+ // component.getNftId()
169
+ // );
170
+ // require(info.nftId.gtz(), "ERROR_COMPONENT_UNKNOWN");
171
+
172
+ // info.state = ACTIVE();
173
+ // // setComponentInfo checks for valid state changes
174
+ // instance.setComponentInfo(info);
169
175
  }
170
176
  }
@@ -150,7 +150,7 @@ contract ProductService is ComponentServiceBase, IProductService {
150
150
  IPoolComponent pool = IPoolComponent(poolAddress);
151
151
  pool.underwrite(
152
152
  policyInfo.nftId,
153
- policyInfo.data,
153
+ policyInfo.applicationData,
154
154
  bundleFilter,
155
155
  collateralAmount);
156
156
  }
@@ -9,7 +9,7 @@ import {ChainNft} from "./ChainNft.sol";
9
9
  import {IRegistry} from "./IRegistry.sol";
10
10
  import {NftId, toNftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
11
11
  import {VersionPart} from "../types/Version.sol";
12
- import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, DISTRIBUTOR, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
12
+ import {ObjectType, PROTOCOL, REGISTRY, TOKEN, SERVICE, INSTANCE, STAKE, PRODUCT, COMPENSATION, ORACLE, POOL, POLICY, BUNDLE} from "../types/ObjectType.sol";
13
13
 
14
14
  // TODO make registry upgradable
15
15
  contract Registry is
@@ -293,7 +293,7 @@ contract Registry is
293
293
 
294
294
  // instance as parent
295
295
  _isValidParentType[PRODUCT()][INSTANCE()] = true;
296
- _isValidParentType[DISTRIBUTOR()][INSTANCE()] = true;
296
+ _isValidParentType[COMPENSATION()][INSTANCE()] = true;
297
297
  _isValidParentType[ORACLE()][INSTANCE()] = true;
298
298
  _isValidParentType[POOL()][INSTANCE()] = true;
299
299
 
@@ -37,22 +37,26 @@ function STAKE() pure returns (ObjectType) {
37
37
  return toObjectType(60);
38
38
  }
39
39
 
40
- function PRODUCT() pure returns (ObjectType) {
40
+ function COMPONENT() pure returns (ObjectType) {
41
41
  return toObjectType(100);
42
42
  }
43
43
 
44
- function DISTRIBUTOR() pure returns (ObjectType) {
44
+ function PRODUCT() pure returns (ObjectType) {
45
45
  return toObjectType(110);
46
46
  }
47
47
 
48
- function ORACLE() pure returns (ObjectType) {
48
+ function COMPENSATION() pure returns (ObjectType) {
49
49
  return toObjectType(120);
50
50
  }
51
51
 
52
- function POOL() pure returns (ObjectType) {
52
+ function ORACLE() pure returns (ObjectType) {
53
53
  return toObjectType(130);
54
54
  }
55
55
 
56
+ function POOL() pure returns (ObjectType) {
57
+ return toObjectType(140);
58
+ }
59
+
56
60
  function POLICY() pure returns (ObjectType) {
57
61
  return toObjectType(200);
58
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-c8acbd3-764",
3
+ "version": "0.0.2-ce2fc91-485",
4
4
  "description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
5
5
  "main": "index.js",
6
6
  "scripts": {