@etherisc/gif-next 0.0.2-78bf628-134 → 0.0.2-7b53731-256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +38 -7
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +405 -0
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +340 -0
  8. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +131 -0
  10. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +109 -18
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +194 -3
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +160 -21
  16. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  28. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  34. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  35. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +545 -393
  36. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  37. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  38. package/artifacts/contracts/instance/Instance.sol/Instance.json +672 -456
  39. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  40. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +32 -0
  42. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +32 -0
  47. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  48. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +14 -14
  49. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
  51. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +55 -54
  58. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +56 -55
  61. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +12 -7
  63. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +12 -7
  66. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  67. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  68. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  69. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensation.json → distribution/IDistribution.sol/IDistribution.json} +2 -2
  70. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  71. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensationModule.json → distribution/IDistribution.sol/IDistributionModule.json} +2 -2
  72. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +53 -40
  75. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +53 -40
  77. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  78. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -5
  80. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -5
  82. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  83. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +104 -1
  85. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +126 -5
  87. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  88. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  89. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +209 -231
  90. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  91. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  92. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  93. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +209 -231
  94. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +28 -20
  96. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  97. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +420 -0
  98. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +325 -0
  101. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +64 -0
  103. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +160 -7
  105. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  106. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +84 -12
  107. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  108. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +216 -31
  109. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  110. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  111. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  112. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  113. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  115. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +4 -0
  116. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +495 -0
  117. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  118. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  119. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/Proxy.sol/Proxy.dbg.json +4 -0
  122. package/artifacts/contracts/shared/Proxy.sol/Proxy.json +178 -0
  123. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +4 -0
  124. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.json +129 -0
  125. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  126. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +4 -0
  128. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +187 -0
  129. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  130. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +405 -0
  131. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  132. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  133. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  134. package/artifacts/contracts/test/TestPool.sol/TestPool.json +194 -3
  135. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +209 -27
  137. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  139. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  141. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestService.sol/TestService.json +2 -2
  143. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  145. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  147. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  148. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  149. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  150. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  151. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  152. package/artifacts/contracts/types/Fee.sol/FeeLib.json +50 -11
  153. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  154. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  155. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  156. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  157. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  158. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  159. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  160. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  161. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  162. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  163. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  164. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  165. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  167. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  172. package/contracts/components/BaseComponent.sol +7 -1
  173. package/contracts/components/Distribution.sol +132 -0
  174. package/contracts/components/IDistributionComponent.sol +47 -0
  175. package/contracts/components/IPoolComponent.sol +14 -0
  176. package/contracts/components/IProductComponent.sol +24 -5
  177. package/contracts/components/Pool.sol +64 -3
  178. package/contracts/components/Product.sol +123 -13
  179. package/contracts/instance/IInstance.sol +7 -4
  180. package/contracts/instance/Instance.sol +11 -4
  181. package/contracts/instance/base/IInstanceBase.sol +3 -0
  182. package/contracts/instance/base/InstanceBase.sol +7 -0
  183. package/contracts/instance/base/Lifecycle.sol +10 -2
  184. package/contracts/instance/base/ModuleBase.sol +22 -17
  185. package/contracts/instance/module/access/Access.sol +3 -3
  186. package/contracts/instance/module/bundle/BundleModule.sol +10 -12
  187. package/contracts/instance/module/bundle/IBundle.sol +6 -11
  188. package/contracts/instance/module/component/ComponentModule.sol +15 -20
  189. package/contracts/instance/module/component/IComponent.sol +3 -2
  190. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  191. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  192. package/contracts/instance/module/policy/IPolicy.sol +10 -8
  193. package/contracts/instance/module/policy/PolicyModule.sol +33 -19
  194. package/contracts/instance/module/pool/IPoolModule.sol +0 -1
  195. package/contracts/instance/module/pool/PoolModule.sol +12 -9
  196. package/contracts/instance/module/risk/IRisk.sol +18 -2
  197. package/contracts/instance/module/risk/RiskModule.sol +56 -2
  198. package/contracts/instance/module/treasury/ITreasury.sol +29 -50
  199. package/contracts/instance/module/treasury/TreasuryModule.sol +71 -85
  200. package/contracts/instance/service/ComponentOwnerService.sol +19 -24
  201. package/contracts/instance/service/DistributionService.sol +59 -0
  202. package/contracts/instance/service/IDistributionService.sol +12 -0
  203. package/contracts/instance/service/IPoolService.sol +7 -0
  204. package/contracts/instance/service/IProductService.sol +56 -7
  205. package/contracts/instance/service/PoolService.sol +30 -4
  206. package/contracts/instance/service/ProductService.sol +229 -74
  207. package/contracts/registry/Registry.sol +3 -3
  208. package/contracts/registry/RegistryUpgradeable.sol +416 -0
  209. package/contracts/shared/Proxy.sol +83 -0
  210. package/contracts/shared/Versionable.sol +1 -1
  211. package/contracts/shared/VersionableUpgradeable.sol +108 -0
  212. package/contracts/test/TestDistribution.sol +21 -0
  213. package/contracts/test/TestPool.sol +5 -2
  214. package/contracts/test/TestProduct.sol +35 -7
  215. package/contracts/types/Fee.sol +8 -3
  216. package/contracts/types/ObjectType.sol +17 -5
  217. package/contracts/types/ReferralId.sol +48 -0
  218. package/contracts/types/RiskId.sol +43 -0
  219. package/contracts/types/RoleId.sol +2 -2
  220. package/package.json +1 -1
  221. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
  222. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
  223. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
  224. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
  225. package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
  226. package/contracts/instance/module/compensation/ICompensation.sol +0 -10
@@ -6,8 +6,8 @@ import {RoleId} from "../types/RoleId.sol";
6
6
 
7
7
  import {InstanceBase} from "./base/InstanceBase.sol";
8
8
  import {AccessModule} from "./module/access/Access.sol";
9
- import {CompensationModule} from "./module/compensation/CompensationModule.sol";
10
9
  import {ComponentModule} from "./module/component/ComponentModule.sol";
10
+ import {DistributionModule} from "./module/distribution/DistributionModule.sol";
11
11
  import {PolicyModule} from "./module/policy/PolicyModule.sol";
12
12
  import {PoolModule} from "./module/pool/PoolModule.sol";
13
13
  import {RiskModule} from "./module/risk/RiskModule.sol";
@@ -24,6 +24,7 @@ import {IPolicyModule} from "./module/policy/IPolicy.sol";
24
24
  import {IInstanceBase} from "./base/IInstanceBase.sol";
25
25
 
26
26
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
27
+ import {IDistributionService} from "./service/IDistributionService.sol";
27
28
  import {IProductService} from "./service/IProductService.sol";
28
29
  import {IPoolService} from "./service/IPoolService.sol";
29
30
 
@@ -34,7 +35,7 @@ contract Instance is
34
35
  AccessModule,
35
36
  BundleModule,
36
37
  ComponentModule,
37
- CompensationModule,
38
+ DistributionModule,
38
39
  PolicyModule,
39
40
  PoolModule,
40
41
  RiskModule,
@@ -47,6 +48,7 @@ contract Instance is
47
48
  InstanceBase(registry, registryNftId)
48
49
  AccessModule()
49
50
  BundleModule()
51
+ DistributionModule()
50
52
  ComponentModule()
51
53
  PolicyModule()
52
54
  PoolModule()
@@ -54,12 +56,17 @@ contract Instance is
54
56
  {
55
57
  initializeBundleModule(_keyValueStore);
56
58
  initializeComponentModule(_keyValueStore);
59
+ initializeDistributionModule(_keyValueStore);
60
+ initializePolicyModule(_keyValueStore);
61
+ initializePoolModule(_keyValueStore);
62
+ initializeRiskModule(_keyValueStore);
57
63
  }
58
64
 
59
- function getRegistry() public view override (Registerable, IBundleModule, IPolicyModule) returns (IRegistry registry) { return super.getRegistry(); }
60
- function getKeyValueStore() public view override (InstanceBase, IBundleModule) returns (IKeyValueStore keyValueStore) { return super.getKeyValueStore(); }
65
+ function getRegistry() public view override (Registerable, IPolicyModule) returns (IRegistry registry) { return super.getRegistry(); }
66
+ function getKeyValueStore() public view override (InstanceBase) returns (IKeyValueStore keyValueStore) { return super.getKeyValueStore(); }
61
67
 
62
68
  function getComponentOwnerService() external view override (IComponentModule, IInstanceBase) returns(IComponentOwnerService service) { return _componentOwnerService; }
69
+ function getDistributionService() external view override (IInstanceBase) returns(IDistributionService service) { return _distributionService; }
63
70
  function getProductService() external view override (IBundleModule, IPolicyModule, IInstanceBase) returns(IProductService service) { return _productService; }
64
71
  function getPoolService() external view override (IBundleModule, IPoolModule, IInstanceBase) returns(IPoolService service) { return _poolService; }
65
72
 
@@ -6,14 +6,17 @@ import {StateId} from "../../types/StateId.sol";
6
6
 
7
7
  import {IKeyValueStore} from "./IKeyValueStore.sol";
8
8
  import {IComponentOwnerService} from "../service/IComponentOwnerService.sol";
9
+ import {IDistributionService} from "../service/IDistributionService.sol";
9
10
  import {IProductService} from "../service/IProductService.sol";
10
11
  import {IPoolService} from "../service/IPoolService.sol";
11
12
 
12
13
  interface IInstanceBase {
13
14
  function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
14
15
  function updateState(Key32 key, StateId state) external;
16
+ function getState(Key32 key) external view returns (StateId state);
15
17
 
16
18
  function getComponentOwnerService() external view returns(IComponentOwnerService service);
19
+ function getDistributionService() external view returns(IDistributionService);
17
20
  function getProductService() external view returns(IProductService service);
18
21
  function getPoolService() external view returns(IPoolService service);
19
22
  }
@@ -11,6 +11,7 @@ import {StateId} from "../../types/StateId.sol";
11
11
  import {Version, VersionPart, VersionLib} from "../../types/Version.sol";
12
12
 
13
13
  import {IComponentOwnerService} from "../service/IComponentOwnerService.sol";
14
+ import {IDistributionService} from "../service/IDistributionService.sol";
14
15
  import {IProductService} from "../service/IProductService.sol";
15
16
  import {IPoolService} from "../service/IPoolService.sol";
16
17
 
@@ -28,6 +29,7 @@ abstract contract InstanceBase is
28
29
  IKeyValueStore internal _keyValueStore;
29
30
 
30
31
  IComponentOwnerService internal _componentOwnerService;
32
+ IDistributionService internal _distributionService;
31
33
  IProductService internal _productService;
32
34
  IPoolService internal _poolService;
33
35
 
@@ -50,6 +52,10 @@ abstract contract InstanceBase is
50
52
  _keyValueStore.updateState(key, state);
51
53
  }
52
54
 
55
+ function getState(Key32 key) external view override returns (StateId state) {
56
+ return _keyValueStore.getState(key);
57
+ }
58
+
53
59
  // from versionable
54
60
  function getVersion()
55
61
  public
@@ -70,6 +76,7 @@ abstract contract InstanceBase is
70
76
  function _linkToServicesInRegistry() internal {
71
77
  VersionPart majorVersion = getVersion().toMajorPart();
72
78
  _componentOwnerService = IComponentOwnerService(_getAndCheck("ComponentOwnerService", majorVersion));
79
+ _distributionService = IDistributionService(_getAndCheck("DistributionService", majorVersion));
73
80
  _productService = IProductService(_getAndCheck("ProductService", majorVersion));
74
81
  _poolService = IPoolService(_getAndCheck("PoolService", majorVersion));
75
82
  }
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {NftId} from "../../types/NftId.sol";
5
- import {ObjectType, COMPONENT, BUNDLE, POLICY} from "../../types/ObjectType.sol";
5
+ import {ObjectType, COMPONENT, BUNDLE, POLICY, RISK} from "../../types/ObjectType.sol";
6
6
  import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, UNDERWRITTEN, REVOKED, DECLINED} from "../../types/StateId.sol";
7
7
  import {ILifecycle} from "./ILifecycle.sol";
8
8
 
@@ -14,9 +14,10 @@ contract Lifecycle is ILifecycle {
14
14
  private _isValidTransition;
15
15
 
16
16
  constructor() {
17
- _setupComponentLifecycle();
18
17
  _setupBundleLifecycle();
18
+ _setupComponentLifecycle();
19
19
  _setupPolicyLifecycle();
20
+ _setupRiskLifecycle();
20
21
  }
21
22
 
22
23
  function hasLifecycle(
@@ -89,4 +90,11 @@ contract Lifecycle is ILifecycle {
89
90
  _isValidTransition[POLICY()][UNDERWRITTEN()][ACTIVE()] = true;
90
91
  _isValidTransition[POLICY()][ACTIVE()][CLOSED()] = true;
91
92
  }
93
+
94
+ function _setupRiskLifecycle() internal {
95
+ _initialState[RISK()] = ACTIVE();
96
+ _isValidTransition[RISK()][ACTIVE()][PAUSED()] = true;
97
+ _isValidTransition[RISK()][PAUSED()][ACTIVE()] = true;
98
+ _isValidTransition[RISK()][PAUSED()][ARCHIVED()] = true;
99
+ }
92
100
  }
@@ -16,37 +16,42 @@ import {IKeyValueStore} from "./IKeyValueStore.sol";
16
16
  abstract contract ModuleBase {
17
17
 
18
18
  IKeyValueStore private _store;
19
- ObjectType private _type;
20
19
 
21
- function _initialize(IKeyValueStore keyValueStore, ObjectType objectType) internal {
20
+ function _initialize(IKeyValueStore keyValueStore) internal {
22
21
  _store = keyValueStore;
23
- _type = objectType;
24
22
  }
25
23
 
26
- function _create(NftId nftId, bytes memory data) internal {
24
+ function _create(ObjectType objectType, Key32 key, bytes memory data) internal {
27
25
  _store.create(
28
- _toKey32(nftId),
29
- _type,
26
+ key,
27
+ objectType,
30
28
  data);
31
29
  }
32
30
 
33
- function _updateData(NftId nftId, bytes memory data) internal {
34
- _store.updateData(_toKey32(nftId), data);
31
+ function _create(ObjectType objectType, NftId nftId, bytes memory data) internal {
32
+ _store.create(
33
+ nftId.toKey32(objectType),
34
+ objectType,
35
+ data);
35
36
  }
36
37
 
37
- function _updateState(NftId nftId, StateId state) internal {
38
- _store.updateState(_toKey32(nftId), state);
38
+ function _updateData(ObjectType objectType, NftId nftId, bytes memory data) internal {
39
+ _store.updateData(nftId.toKey32(objectType), data);
39
40
  }
40
41
 
41
- function _getData(NftId nftId) internal view returns(bytes memory data) {
42
- return _store.getData(_toKey32(nftId));
42
+ function _updateState(ObjectType objectType, NftId nftId, StateId state) internal {
43
+ _store.updateState(nftId.toKey32(objectType), state);
43
44
  }
44
45
 
45
- function _getState(NftId nftId) internal view returns(StateId) {
46
- return _store.getState(_toKey32(nftId));
46
+ function _exists(ObjectType objectType, NftId nftId) internal view returns (bool hasData) {
47
+ return _store.exists(nftId.toKey32(objectType));
47
48
  }
48
49
 
49
- function _toKey32(NftId nftId) internal view returns (Key32 key32) {
50
- return nftId.toKey32(_type);
51
- }
50
+ function _getData(ObjectType objectType, NftId nftId) internal view returns(bytes memory data) {
51
+ return _store.getData(nftId.toKey32(objectType));
52
+ }
53
+
54
+ function _getState(ObjectType objectType, NftId nftId) internal view returns(StateId) {
55
+ return _store.getState(nftId.toKey32(objectType));
56
+ }
52
57
  }
@@ -6,8 +6,8 @@ pragma solidity ^0.8.19;
6
6
  import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
7
7
 
8
8
  import {RoleId, RoleIdLib} from "../../../types/RoleId.sol";
9
- import {DISTRIBUTOR_OWNER_ROLE, ORACLE_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE} from "../../../types/RoleId.sol";
10
- import {DISTRIBUTOR_OWNER_ROLE_NAME, ORACLE_OWNER_ROLE_NAME, POOL_OWNER_ROLE_NAME, PRODUCT_OWNER_ROLE_NAME} from "../../../types/RoleId.sol";
9
+ import {DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE} from "../../../types/RoleId.sol";
10
+ import {DISTRIBUTION_OWNER_ROLE_NAME, ORACLE_OWNER_ROLE_NAME, POOL_OWNER_ROLE_NAME, PRODUCT_OWNER_ROLE_NAME} from "../../../types/RoleId.sol";
11
11
  import {IAccessModule} from "./IAccess.sol";
12
12
 
13
13
  abstract contract AccessModule is IAccessModule {
@@ -36,7 +36,7 @@ abstract contract AccessModule is IAccessModule {
36
36
  }
37
37
 
38
38
  constructor() {
39
- _createRole(DISTRIBUTOR_OWNER_ROLE(), DISTRIBUTOR_OWNER_ROLE_NAME());
39
+ _createRole(DISTRIBUTION_OWNER_ROLE(), DISTRIBUTION_OWNER_ROLE_NAME());
40
40
  _createRole(ORACLE_OWNER_ROLE(), ORACLE_OWNER_ROLE_NAME());
41
41
  _createRole(POOL_OWNER_ROLE(), POOL_OWNER_ROLE_NAME());
42
42
  _createRole(PRODUCT_OWNER_ROLE(), PRODUCT_OWNER_ROLE_NAME());
@@ -6,6 +6,7 @@ import {IRegistry} from "../../../registry/IRegistry.sol";
6
6
  import {IProductService} from "../../service/IProductService.sol";
7
7
  import {IPoolService} from "../../service/IPoolService.sol";
8
8
 
9
+ import {Fee} from "../../../types/Fee.sol";
9
10
  import {NftId} from "../../../types/NftId.sol";
10
11
  import {Key32, KeyId} from "../../../types/Key32.sol";
11
12
  import {LibNftIdSet} from "../../../types/NftIdSet.sol";
@@ -55,12 +56,13 @@ abstract contract BundleModule is
55
56
  }
56
57
 
57
58
  function initializeBundleModule(IKeyValueStore keyValueStore) internal {
58
- _initialize(keyValueStore, BUNDLE());
59
+ _initialize(keyValueStore);
59
60
  }
60
61
 
61
62
  function createBundleInfo(
62
63
  NftId bundleNftId,
63
64
  NftId poolNftId,
65
+ Fee memory fee,
64
66
  uint256 amount,
65
67
  uint256 lifetime,
66
68
  bytes calldata filter
@@ -69,9 +71,9 @@ abstract contract BundleModule is
69
71
  onlyBundlePoolService
70
72
  override
71
73
  {
72
- BundleInfo memory bundleInfo = BundleInfo(
73
- bundleNftId,
74
+ BundleInfo memory info = BundleInfo(
74
75
  poolNftId,
76
+ fee,
75
77
  filter,
76
78
  amount, // capital
77
79
  0, // locked capital
@@ -80,15 +82,15 @@ abstract contract BundleModule is
80
82
  zeroTimestamp() // closedAt
81
83
  );
82
84
 
83
- _create(bundleNftId, abi.encode(bundleInfo));
85
+ _create(BUNDLE(), bundleNftId, abi.encode(info));
84
86
  }
85
87
 
86
- function setBundleInfo(BundleInfo memory bundleInfo)
88
+ function setBundleInfo(NftId bundleNftId, BundleInfo memory info)
87
89
  external
88
90
  override
89
91
  onlyPoolOrProductService
90
92
  {
91
- _updateData(bundleInfo.nftId, abi.encode(bundleInfo));
93
+ _updateData(BUNDLE(), bundleNftId, abi.encode(info));
92
94
  }
93
95
 
94
96
  function updateBundleState(NftId bundleNftId, StateId state)
@@ -96,7 +98,7 @@ abstract contract BundleModule is
96
98
  override
97
99
  onlyBundlePoolService
98
100
  {
99
- _updateState(bundleNftId, state);
101
+ _updateState(BUNDLE(), bundleNftId, state);
100
102
  }
101
103
 
102
104
  function collateralizePolicy(
@@ -127,10 +129,6 @@ abstract contract BundleModule is
127
129
  }
128
130
 
129
131
  function getBundleInfo(NftId bundleNftId) external view override returns(BundleInfo memory bundleInfo) {
130
- return abi.decode(_getData(bundleNftId), (BundleInfo));
132
+ return abi.decode(_getData(BUNDLE(), bundleNftId), (BundleInfo));
131
133
  }
132
-
133
- function toBundleKey32(NftId bundleNftId) external view override returns (Key32 key32) {
134
- return _toKey32(bundleNftId);
135
- }
136
134
  }
@@ -3,6 +3,7 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../../registry/IRegistry.sol";
5
5
  import {IInstance} from "../../IInstance.sol";
6
+ import {Fee} from "../../../types/Fee.sol";
6
7
  import {Key32} from "../../../types/Key32.sol";
7
8
  import {NftId} from "../../../types/NftId.sol";
8
9
  import {StateId} from "../../../types/StateId.sol";
@@ -16,8 +17,8 @@ import {IPoolService} from "../../service/IPoolService.sol";
16
17
  interface IBundle {
17
18
 
18
19
  struct BundleInfo {
19
- NftId nftId;
20
20
  NftId poolNftId;
21
+ Fee fee; // bundle fee on net premium amounts
21
22
  bytes filter; // required conditions for applications to be considered for collateralization by this bundle
22
23
  uint256 capitalAmount; // net investment capital amount (<= balance)
23
24
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
@@ -32,25 +33,19 @@ interface IBundleModule is IBundle {
32
33
  function createBundleInfo(
33
34
  NftId bundleNftId,
34
35
  NftId poolNftId,
36
+ Fee memory fee,
35
37
  uint256 amount,
36
38
  uint256 lifetime,
37
39
  bytes calldata filter
38
40
  ) external;
39
41
 
40
- function setBundleInfo(BundleInfo memory bundleInfo) external;
41
- function updateBundleState(NftId bundleNftId, StateId state) external;
42
+ function setBundleInfo(NftId nftId, BundleInfo memory bundleInfo) external;
43
+ function updateBundleState(NftId nftId, StateId state) external;
42
44
 
43
45
  function collateralizePolicy(NftId bundleNftId, NftId policyNftId, uint256 amount) external;
44
46
  function releasePolicy(NftId bundleNftId, NftId policyNftId) external returns(uint256 collateralAmount);
45
47
 
46
- function getBundleInfo(NftId bundleNftId) external view returns(BundleInfo memory bundleInfo);
47
- function toBundleKey32(NftId bundleNftId) external view returns (Key32 key32);
48
-
49
- // repeat registry linked signature
50
- function getRegistry() external view returns (IRegistry registry);
51
-
52
- // repeat instance base signature
53
- function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
48
+ function getBundleInfo(NftId nftId) external view returns(BundleInfo memory bundleInfo);
54
49
 
55
50
  // repeat service linked signatures to avoid linearization issues
56
51
  function getProductService() external returns(IProductService);
@@ -26,20 +26,31 @@ abstract contract ComponentModule is
26
26
  }
27
27
 
28
28
  function initializeComponentModule(IKeyValueStore keyValueStore) internal {
29
- _initialize(keyValueStore, COMPONENT());
29
+ _initialize(keyValueStore);
30
30
  }
31
31
 
32
32
  function registerComponent(
33
33
  NftId nftId,
34
- IERC20Metadata token
34
+ IERC20Metadata token,
35
+ address wallet
35
36
  )
36
37
  external
37
38
  onlyComponentOwnerService
38
39
  override
39
40
  {
40
- ComponentInfo memory info = ComponentInfo(token);
41
+ ComponentInfo memory info = ComponentInfo(token, wallet);
41
42
  _nftIds.push(nftId);
42
- _create(nftId, abi.encode(info));
43
+ _create(COMPONENT(), nftId, abi.encode(info));
44
+ }
45
+
46
+ function getComponentToken(NftId nftId) external view override returns(IERC20Metadata token) {
47
+ ComponentInfo memory info = abi.decode(_getData(COMPONENT(), nftId), (ComponentInfo));
48
+ return info.token;
49
+ }
50
+
51
+ function getComponentWallet(NftId nftId) external view override returns (address wallet) {
52
+ ComponentInfo memory info = abi.decode(_getData(COMPONENT(), nftId), (ComponentInfo));
53
+ return info.wallet;
43
54
  }
44
55
 
45
56
  function getComponentCount()
@@ -56,20 +67,4 @@ abstract contract ComponentModule is
56
67
  ) external view override returns (NftId componentNftId) {
57
68
  return _nftIds[idx];
58
69
  }
59
-
60
- function getComponentState(
61
- NftId nftId
62
- )
63
- external
64
- view
65
- override
66
- returns (StateId state)
67
- {
68
- return _getState(nftId);
69
- }
70
-
71
- function getComponentToken(NftId nftId) external view override returns(IERC20Metadata token) {
72
- ComponentInfo memory info = abi.decode(_getData(nftId), (ComponentInfo));
73
- return info.token;
74
- }
75
70
  }
@@ -10,14 +10,15 @@ import {NftId} from "../../../types/NftId.sol";
10
10
  interface IComponent {
11
11
  struct ComponentInfo {
12
12
  IERC20Metadata token;
13
+ address wallet;
13
14
  }
14
15
  }
15
16
 
16
17
  interface IComponentModule is IComponent {
17
18
 
18
- function registerComponent(NftId nftId, IERC20Metadata token) external;
19
- function getComponentState(NftId nftId) external view returns (StateId state);
19
+ function registerComponent(NftId nftId, IERC20Metadata token, address wallet) external;
20
20
  function getComponentToken(NftId nftId) external view returns (IERC20Metadata token);
21
+ function getComponentWallet(NftId nftId) external view returns (address wallet);
21
22
 
22
23
  function getComponentCount() external view returns (uint256 numberOfCompnents);
23
24
  function getComponentId(uint256 idx) external view returns (NftId nftId);
@@ -0,0 +1,17 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IDistributionModule} from "./IDistribution.sol";
5
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
6
+ import {ModuleBase} from "../../base/ModuleBase.sol";
7
+
8
+ contract DistributionModule is
9
+ ModuleBase,
10
+ IDistributionModule
11
+ {
12
+
13
+ function initializeDistributionModule(IKeyValueStore keyValueStore) internal {
14
+ _initialize(keyValueStore);
15
+ }
16
+
17
+ }
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ interface IDistribution {
5
+
6
+ }
7
+
8
+ interface IDistributionModule is IDistribution {
9
+
10
+ }
@@ -5,43 +5,45 @@ import {IRegistry} from "../../../registry/IRegistry.sol";
5
5
  import {IInstance} from "../../IInstance.sol";
6
6
  import {IProductService} from "../../service/IProductService.sol";
7
7
  import {NftId} from "../../../types/NftId.sol";
8
+ import {ReferralId} from "../../../types/ReferralId.sol";
9
+ import {RiskId} from "../../../types/RiskId.sol";
8
10
  import {StateId} from "../../../types/StateId.sol";
9
11
  import {Timestamp} from "../../../types/Timestamp.sol";
10
- import {Blocknumber} from "../../../types/Blocknumber.sol";
11
12
 
12
13
  // TODO check if there is value to introuce IContract and let IPolicy derive from IContract
13
14
  interface IPolicy {
14
15
  struct PolicyInfo {
15
- NftId nftId;
16
16
  NftId productNftId;
17
17
  NftId bundleNftId;
18
+ ReferralId referralId;
18
19
  address beneficiary;
19
- StateId state; // applied, withdrawn, rejected, active, closed
20
+ RiskId riskId;
20
21
  uint256 sumInsuredAmount;
21
22
  uint256 premiumAmount;
22
23
  uint256 premiumPaidAmount;
23
24
  uint256 lifetime;
24
25
  bytes applicationData;
25
26
  bytes policyData;
26
- Timestamp createdAt;
27
27
  Timestamp activatedAt; // time of underwriting
28
28
  Timestamp expiredAt; // no new claims (activatedAt + lifetime)
29
29
  Timestamp closedAt; // no locked capital
30
- Blocknumber updatedIn; // write log entries in a way to support backtracking of all state changes
31
30
  }
32
31
  }
33
32
 
34
33
  interface IPolicyModule is IPolicy {
35
- function createApplication(
36
- NftId productNftId,
34
+ function createPolicyInfo(
37
35
  NftId policyNftId,
36
+ NftId productNftId,
37
+ ReferralId referralId,
38
+ RiskId riskId,
38
39
  uint256 sumInsuredAmount,
39
40
  uint256 premiumAmount,
40
41
  uint256 lifetime,
41
42
  NftId bundleNftId
42
43
  ) external;
43
44
 
44
- function setPolicyInfo(PolicyInfo memory policyInfo) external;
45
+ function setPolicyInfo(NftId policyNftId, PolicyInfo memory info) external;
46
+ function updatePolicyState(NftId nftId, StateId state) external;
45
47
 
46
48
  // function underwrite(NftId nftId) external;
47
49
 
@@ -6,15 +6,19 @@ import {IRegistry} from "../../../registry/IRegistry.sol";
6
6
  import {IProductService} from "../../service/IProductService.sol";
7
7
  import {IPolicy, IPolicyModule} from "./IPolicy.sol";
8
8
  import {ObjectType, POLICY} from "../../../types/ObjectType.sol";
9
- import {APPLIED, ACTIVE, UNDERWRITTEN} from "../../../types/StateId.sol";
10
9
  import {NftId, NftIdLib} from "../../../types/NftId.sol";
10
+ import {ReferralId} from "../../../types/ReferralId.sol";
11
+ import {RiskId} from "../../../types/RiskId.sol";
12
+ import {StateId} from "../../../types/StateId.sol";
11
13
  import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
12
- import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
13
14
 
14
- abstract contract PolicyModule is IPolicyModule {
15
- using NftIdLib for NftId;
15
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
16
+ import {ModuleBase} from "../../base/ModuleBase.sol";
16
17
 
17
- mapping(NftId nftId => PolicyInfo info) private _policyInfo;
18
+ abstract contract PolicyModule is
19
+ ModuleBase,
20
+ IPolicyModule
21
+ {
18
22
 
19
23
  // TODO find a better place to avoid dupliation
20
24
  modifier onlyProductService2() {
@@ -25,9 +29,15 @@ abstract contract PolicyModule is IPolicyModule {
25
29
  _;
26
30
  }
27
31
 
28
- function createApplication(
29
- NftId productNftId,
32
+ function initializePolicyModule(IKeyValueStore keyValueStore) internal {
33
+ _initialize(keyValueStore);
34
+ }
35
+
36
+ function createPolicyInfo(
30
37
  NftId policyNftId,
38
+ NftId productNftId,
39
+ ReferralId referralId,
40
+ RiskId riskId,
31
41
  uint256 sumInsuredAmount,
32
42
  uint256 premiumAmount,
33
43
  uint256 lifetime,
@@ -37,41 +47,45 @@ abstract contract PolicyModule is IPolicyModule {
37
47
  onlyProductService2
38
48
  override
39
49
  {
40
- _policyInfo[policyNftId] = PolicyInfo(
41
- policyNftId,
50
+ PolicyInfo memory info = PolicyInfo(
42
51
  productNftId,
43
52
  bundleNftId,
53
+ referralId,
44
54
  address(0), // beneficiary = policy nft holder
45
- // _lifecycleModule.getInitialState(POLICY()),
46
- APPLIED(),
55
+ riskId,
47
56
  sumInsuredAmount,
48
57
  premiumAmount,
49
58
  0, // premium paid amount
50
59
  lifetime,
51
60
  "", // applicationData
52
61
  "", // policyData
53
- blockTimestamp(), // createdAt
54
62
  zeroTimestamp(), // activatedAt
55
63
  zeroTimestamp(), // expiredAt
56
- zeroTimestamp(), // closedAt
57
- blockNumber() // updatedIn
64
+ zeroTimestamp() // closedAt
58
65
  );
59
66
 
60
- // TODO add logging
67
+ _create(POLICY(), policyNftId, abi.encode(info));
61
68
  }
62
69
 
63
- function setPolicyInfo(PolicyInfo memory policyInfo)
70
+ function setPolicyInfo(NftId policyNftId, PolicyInfo memory info)
64
71
  external
65
72
  override
66
73
  onlyProductService2
67
74
  {
68
- _policyInfo[policyInfo.nftId] = policyInfo;
75
+ _updateData(POLICY(), policyNftId, abi.encode(info));
76
+ }
77
+
78
+ function updatePolicyState(NftId bundleNftId, StateId state)
79
+ external
80
+ override
81
+ onlyProductService2
82
+ {
83
+ _updateState(POLICY(), bundleNftId, state);
69
84
  }
70
85
 
71
86
  function getPolicyInfo(
72
87
  NftId nftId
73
88
  ) external view returns (PolicyInfo memory info) {
74
- return _policyInfo[nftId];
89
+ return abi.decode(_getData(POLICY(), nftId), (PolicyInfo));
75
90
  }
76
-
77
91
  }
@@ -9,7 +9,6 @@ import {IPoolService} from "../../service/IPoolService.sol";
9
9
 
10
10
  interface IPool {
11
11
  struct PoolInfo {
12
- NftId nftId;
13
12
  bool isVerifying;
14
13
  UFixed collateralizationLevel;
15
14
  }