@etherisc/gif-next 0.0.2-efdb520-159 → 0.0.2-efef0ea-320

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. package/README.md +58 -11
  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/SM.sol/SM.json +2 -2
  32. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +2 -2
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  37. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +697 -671
  38. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  39. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  40. package/artifacts/contracts/instance/Instance.sol/Instance.json +928 -744
  41. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  42. package/artifacts/contracts/instance/{InstanceBase.sol/InstanceBase.json → base/ComponentServiceBase.sol/ComponentServiceBase.json} +107 -33
  43. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  44. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  45. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  46. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +560 -0
  47. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  48. package/artifacts/contracts/instance/{module/lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
  49. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
  50. package/artifacts/contracts/instance/{service → base}/IService.sol/IService.json +63 -22
  51. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  52. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +463 -0
  53. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  54. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +710 -0
  55. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  56. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  57. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
  58. package/artifacts/contracts/instance/{module/product/ProductModule.sol/ProductModule.json → base/ModuleBase.sol/ModuleBase.json} +2 -2
  59. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  60. package/artifacts/contracts/instance/{service → base}/ServiceBase.sol/ServiceBase.json +93 -6
  61. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  64. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +71 -50
  66. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +71 -50
  69. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +22 -93
  71. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +22 -93
  74. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  75. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  76. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  77. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.json +10 -0
  78. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +10 -0
  80. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  82. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +61 -38
  83. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +61 -38
  85. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  87. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -5
  88. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  89. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -5
  90. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/{product/IProductModule.sol/IProductModule.json → risk/IRisk.sol/IRisk.json} +2 -2
  92. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +113 -0
  94. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +131 -0
  96. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  97. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  98. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +209 -236
  99. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  100. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  101. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  102. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +209 -236
  103. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  104. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +141 -42
  105. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  106. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +507 -0
  107. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  108. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +62 -21
  109. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  110. package/artifacts/contracts/instance/service/{ComponentServiceBase.sol/ComponentServiceBase.json → IDistributionService.sol/IDistributionService.json} +96 -30
  111. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  112. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +127 -22
  113. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  114. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +215 -21
  115. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  116. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +177 -46
  117. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  118. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +322 -62
  119. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  120. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  121. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  122. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  123. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  124. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  125. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.dbg.json +4 -0
  126. package/artifacts/contracts/registry/RegistryUpgradeable.sol/RegistryUpgradeable.json +724 -0
  127. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +58 -17
  132. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.dbg.json +4 -0
  133. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.json +248 -0
  134. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +4 -0
  135. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.json +129 -0
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +92 -5
  139. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.dbg.json +4 -0
  140. package/artifacts/contracts/shared/VersionableUpgradeable.sol/VersionableUpgradeable.json +228 -0
  141. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  142. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +405 -0
  143. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestFee.sol/TestFee.json +28 -4
  145. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestPool.sol/TestPool.json +194 -3
  147. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +209 -27
  149. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  151. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +38 -4
  153. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestService.sol/TestService.json +102 -43
  155. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +14 -18
  158. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +102 -39
  160. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  161. package/artifacts/contracts/test/Usdc.sol/USDC.json +338 -0
  162. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  165. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  166. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  167. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  168. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
  169. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  171. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  172. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  173. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  175. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  176. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  177. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  178. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  179. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  180. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
  181. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  183. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +34 -8
  186. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/Version.sol/VersionLib.json +101 -2
  188. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  190. package/contracts/components/BaseComponent.sol +7 -2
  191. package/contracts/components/Distribution.sol +132 -0
  192. package/contracts/components/IDistributionComponent.sol +47 -0
  193. package/contracts/components/IPoolComponent.sol +14 -0
  194. package/contracts/components/IProductComponent.sol +24 -5
  195. package/contracts/components/Pool.sol +64 -3
  196. package/contracts/components/Product.sol +123 -13
  197. package/contracts/instance/IInstance.sol +16 -13
  198. package/contracts/instance/Instance.sol +22 -10
  199. package/contracts/instance/{service → base}/ComponentServiceBase.sol +1 -0
  200. package/contracts/instance/base/IInstanceBase.sol +22 -0
  201. package/contracts/instance/base/IKeyValueStore.sol +50 -0
  202. package/contracts/instance/base/ILifecycle.sol +30 -0
  203. package/contracts/instance/{InstanceBase.sol → base/InstanceBase.sol} +34 -17
  204. package/contracts/instance/base/KeyValueStore.sol +161 -0
  205. package/contracts/instance/{module/lifecycle/LifecycleModule.sol → base/Lifecycle.sol} +50 -39
  206. package/contracts/instance/base/ModuleBase.sol +57 -0
  207. package/contracts/instance/{service → base}/ServiceBase.sol +1 -3
  208. package/contracts/instance/module/access/Access.sol +6 -6
  209. package/contracts/instance/module/bundle/BundleModule.sol +24 -118
  210. package/contracts/instance/module/bundle/IBundle.sol +9 -9
  211. package/contracts/instance/module/component/ComponentModule.sol +27 -61
  212. package/contracts/instance/module/component/IComponent.sol +5 -30
  213. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  214. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  215. package/contracts/instance/module/policy/IPolicy.sol +12 -9
  216. package/contracts/instance/module/policy/PolicyModule.sol +33 -26
  217. package/contracts/instance/module/pool/IPoolModule.sol +0 -1
  218. package/contracts/instance/module/pool/PoolModule.sol +12 -9
  219. package/contracts/instance/module/risk/IRisk.sol +26 -0
  220. package/contracts/instance/module/risk/RiskModule.sol +62 -0
  221. package/contracts/instance/module/treasury/ITreasury.sol +30 -52
  222. package/contracts/instance/module/treasury/TreasuryModule.sol +74 -84
  223. package/contracts/instance/service/ComponentOwnerService.sol +33 -50
  224. package/contracts/instance/service/DistributionService.sol +59 -0
  225. package/contracts/instance/service/IComponentOwnerService.sol +1 -1
  226. package/contracts/instance/service/IDistributionService.sol +12 -0
  227. package/contracts/instance/service/IPoolService.sol +8 -1
  228. package/contracts/instance/service/IProductService.sol +56 -7
  229. package/contracts/instance/service/PoolService.sol +64 -13
  230. package/contracts/instance/service/ProductService.sol +234 -83
  231. package/contracts/registry/Registry.sol +4 -4
  232. package/contracts/registry/RegistryUpgradeable.sol +488 -0
  233. package/contracts/shared/IVersionable.sol +19 -6
  234. package/contracts/shared/Proxy.sol +94 -0
  235. package/contracts/shared/Versionable.sol +16 -9
  236. package/contracts/shared/VersionableUpgradeable.sol +136 -0
  237. package/contracts/test/TestDistribution.sol +21 -0
  238. package/contracts/test/TestFee.sol +3 -3
  239. package/contracts/test/TestPool.sol +6 -3
  240. package/contracts/test/TestProduct.sol +36 -8
  241. package/contracts/test/TestRoleId.sol +2 -2
  242. package/contracts/test/TestService.sol +3 -6
  243. package/contracts/test/TestVersion.sol +4 -7
  244. package/contracts/test/TestVersionable.sol +2 -5
  245. package/contracts/test/Usdc.sol +26 -0
  246. package/contracts/types/Fee.sol +44 -20
  247. package/contracts/types/Key32.sol +45 -0
  248. package/contracts/types/NftId.sol +16 -1
  249. package/contracts/types/ObjectType.sol +24 -8
  250. package/contracts/types/ReferralId.sol +48 -0
  251. package/contracts/types/RiskId.sol +43 -0
  252. package/contracts/types/RoleId.sol +12 -10
  253. package/contracts/types/StateId.sol +7 -1
  254. package/contracts/types/UFixed.sol +19 -16
  255. package/contracts/types/Version.sol +37 -25
  256. package/package.json +1 -1
  257. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +0 -4
  258. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.json +0 -50
  259. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  260. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
  261. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
  262. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
  263. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
  264. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
  265. package/artifacts/contracts/instance/module/product/IProductModule.sol/IProductModule.dbg.json +0 -4
  266. package/artifacts/contracts/instance/module/product/ProductModule.sol/ProductModule.dbg.json +0 -4
  267. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  268. package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +0 -4
  269. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  270. package/contracts/instance/IServiceLinked.sol +0 -12
  271. package/contracts/instance/module/lifecycle/ILifecycle.sol +0 -47
  272. package/contracts/instance/module/product/IProductModule.sol +0 -6
  273. package/contracts/instance/module/product/ProductModule.sol +0 -8
  274. /package/contracts/instance/{service → base}/IService.sol +0 -0
@@ -3,32 +3,33 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IRegistry} from "../../../registry/IRegistry.sol";
5
5
 
6
- import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
7
6
  import {IProductService} from "../../service/IProductService.sol";
8
7
  import {IPoolService} from "../../service/IPoolService.sol";
9
8
 
9
+ import {Fee} from "../../../types/Fee.sol";
10
10
  import {NftId} from "../../../types/NftId.sol";
11
+ import {Key32, KeyId} from "../../../types/Key32.sol";
11
12
  import {LibNftIdSet} from "../../../types/NftIdSet.sol";
12
13
  import {ObjectType, PRODUCT, ORACLE, POOL, BUNDLE, POLICY} from "../../../types/ObjectType.sol";
13
14
  import {StateId, ACTIVE, PAUSED, ARCHIVED, CLOSED, APPLIED, REVOKED, DECLINED} from "../../../types/StateId.sol";
14
15
  import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
15
16
  import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
16
17
 
17
- import {ILifecycleModule} from "../lifecycle/ILifecycle.sol";
18
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
19
+ import {ModuleBase} from "../../base/ModuleBase.sol";
20
+
18
21
  import {IBundleModule} from "./IBundle.sol";
19
22
 
20
- abstract contract BundleModule is
23
+ abstract contract BundleModule is
24
+ ModuleBase,
21
25
  IBundleModule
22
26
  {
23
27
 
24
28
  using LibNftIdSet for LibNftIdSet.Set;
25
29
 
26
- mapping(NftId bundleNftId => BundleInfo info) private _bundleInfo;
27
30
  mapping(NftId bundleNftId => LibNftIdSet.Set policies) private _collateralizedPolicies;
28
31
  mapping(NftId bundleNftId => mapping(NftId policyNftId => uint256 amount)) private _collateralizationAmount;
29
32
 
30
- LifecycleModule private _lifecycleModule;
31
-
32
33
  modifier onlyBundlePoolService() {
33
34
  require(
34
35
  msg.sender == address(this.getPoolService()),
@@ -54,13 +55,14 @@ abstract contract BundleModule is
54
55
  _;
55
56
  }
56
57
 
57
- constructor() {
58
- _lifecycleModule = LifecycleModule(address(this));
58
+ function initializeBundleModule(IKeyValueStore keyValueStore) internal {
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,101 +71,35 @@ abstract contract BundleModule is
69
71
  onlyBundlePoolService
70
72
  override
71
73
  {
72
-
73
- _bundleInfo[bundleNftId] = BundleInfo(
74
- bundleNftId,
74
+ BundleInfo memory info = BundleInfo(
75
75
  poolNftId,
76
- _lifecycleModule.getInitialState(BUNDLE()),
76
+ fee,
77
77
  filter,
78
78
  amount, // capital
79
79
  0, // locked capital
80
80
  amount, // balance
81
- blockTimestamp(), // createdAt
82
81
  blockTimestamp().addSeconds(lifetime), // expiredAt
83
- zeroTimestamp(), // closedAt
84
- blockNumber() // updatedIn
82
+ zeroTimestamp() // closedAt
85
83
  );
86
84
 
87
- // TODO add logging
85
+ _create(BUNDLE(), bundleNftId, abi.encode(info));
88
86
  }
89
87
 
90
- function setBundleInfo(BundleInfo memory bundleInfo)
88
+ function setBundleInfo(NftId bundleNftId, BundleInfo memory info)
91
89
  external
92
90
  override
93
91
  onlyPoolOrProductService
94
92
  {
95
- _bundleInfo[bundleInfo.nftId] = bundleInfo;
93
+ _updateData(BUNDLE(), bundleNftId, abi.encode(info));
96
94
  }
97
95
 
98
- // function updateBundleState(
99
- // NftId bundleNftId,
100
- // StateId newState
101
- // )
102
- // external
103
- // // add authz (both product and pool service)
104
- // override
105
- // {
106
- // BundleInfo storage info = _bundleInfo[bundleNftId];
107
- // info.state = newState;
108
- // info.updatedIn = blockNumber();
109
- // }
110
-
111
- // function extendBundle(
112
- // NftId bundleNftId,
113
- // uint256 lifetimeExtension
114
- // )
115
- // external
116
- // onlyBundlePoolService
117
- // override
118
- // {
119
- // BundleInfo storage info = _bundleInfo[bundleNftId];
120
- // info.expiredAt = info.expiredAt.addSeconds(lifetimeExtension);
121
- // info.updatedIn = blockNumber();
122
- // }
123
-
124
- // function closeBundle(
125
- // NftId bundleNftId
126
- // )
127
- // external
128
- // onlyBundlePoolService
129
- // override
130
- // {
131
- // BundleInfo storage info = _bundleInfo[bundleNftId];
132
- // info.state = CLOSED();
133
- // info.closedAt = blockTimestamp();
134
- // info.updatedIn = blockNumber();
135
- // }
136
-
137
- // function processStake(
138
- // NftId nftId,
139
- // uint256 amount
140
- // )
141
- // external
142
- // onlyBundlePoolService
143
- // override
144
- // {
145
- // BundleInfo storage info = _bundleInfo[nftId];
146
- // info.capitalAmount += amount;
147
- // info.balanceAmount += amount;
148
- // info.updatedIn = blockNumber();
149
- // }
150
-
151
- // function processUnstake(
152
- // NftId nftId,
153
- // uint256 amount
154
- // )
155
- // external
156
- // onlyBundlePoolService
157
- // override
158
- // {
159
- // BundleInfo storage info = _bundleInfo[nftId];
160
- // // TODO fix book keeping in a way that provides
161
- // // continuous infor regarding profitability
162
- // // this is needed to properly apply performance fees
163
- // info.capitalAmount -= amount;
164
- // info.balanceAmount -= amount;
165
- // info.updatedIn = blockNumber();
166
- // }
96
+ function updateBundleState(NftId bundleNftId, StateId state)
97
+ external
98
+ override
99
+ onlyBundlePoolService
100
+ {
101
+ _updateState(BUNDLE(), bundleNftId, state);
102
+ }
167
103
 
168
104
  function collateralizePolicy(
169
105
  NftId bundleNftId,
@@ -187,42 +123,12 @@ abstract contract BundleModule is
187
123
  override
188
124
  returns(uint256 collateralAmount)
189
125
  {
190
- // BundleInfo storage info = _bundleInfo[bundleNftId];
191
- // info.lockedAmount -= collateralAmount;
192
- // info.updatedIn = blockNumber();
193
-
194
126
  collateralAmount = _collateralizationAmount[bundleNftId][policyNftId];
195
127
  delete _collateralizationAmount[bundleNftId][policyNftId];
196
128
  _collateralizedPolicies[bundleNftId].remove(policyNftId);
197
129
  }
198
130
 
199
- // function addPremium(NftId bundleNftId, uint256 amount)
200
- // external
201
- // onlyBundleProductService
202
- // override
203
- // {
204
- // BundleInfo storage info = _bundleInfo[bundleNftId];
205
- // info.capitalAmount += amount;
206
- // info.balanceAmount += amount;
207
- // info.updatedIn = blockNumber();
208
- // }
209
-
210
- // function subtractPayout(NftId bundleNftId, NftId policyNftId, uint256 amount)
211
- // external
212
- // onlyBundleProductService
213
- // override
214
- // {
215
- // BundleInfo storage info = _bundleInfo[bundleNftId];
216
- // info.capitalAmount -= amount;
217
- // info.lockedAmount -= amount;
218
- // info.balanceAmount -= amount;
219
- // info.updatedIn = blockNumber();
220
-
221
- // // deduct amount from sum insured for this policy
222
- // _collateralizationAmount[bundleNftId][policyNftId] -= amount;
223
- // }
224
-
225
131
  function getBundleInfo(NftId bundleNftId) external view override returns(BundleInfo memory bundleInfo) {
226
- return _bundleInfo[bundleNftId];
132
+ return abi.decode(_getData(BUNDLE(), bundleNftId), (BundleInfo));
227
133
  }
228
134
  }
@@ -3,28 +3,28 @@ 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";
7
+ import {Key32} from "../../../types/Key32.sol";
6
8
  import {NftId} from "../../../types/NftId.sol";
7
9
  import {StateId} from "../../../types/StateId.sol";
8
10
  import {Timestamp} from "../../../types/Timestamp.sol";
9
11
  import {Blocknumber} from "../../../types/Blocknumber.sol";
10
12
 
13
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
11
14
  import {IProductService} from "../../service/IProductService.sol";
12
15
  import {IPoolService} from "../../service/IPoolService.sol";
13
16
 
14
17
  interface IBundle {
15
18
 
16
19
  struct BundleInfo {
17
- NftId nftId;
18
20
  NftId poolNftId;
19
- StateId state; // active, paused, closed (expriy only implicit)
21
+ Fee fee; // bundle fee on net premium amounts
20
22
  bytes filter; // required conditions for applications to be considered for collateralization by this bundle
21
23
  uint256 capitalAmount; // net investment capital amount (<= balance)
22
24
  uint256 lockedAmount; // capital amount linked to collateralizaion of non-closed policies (<= balance)
23
25
  uint256 balanceAmount; // total amount of funds: net investment capital + net premiums - payouts
24
- Timestamp createdAt;
25
26
  Timestamp expiredAt; // no new policies
26
27
  Timestamp closedAt;
27
- Blocknumber updatedIn;
28
28
  }
29
29
  }
30
30
 
@@ -33,19 +33,19 @@ interface IBundleModule is IBundle {
33
33
  function createBundleInfo(
34
34
  NftId bundleNftId,
35
35
  NftId poolNftId,
36
+ Fee memory fee,
36
37
  uint256 amount,
37
38
  uint256 lifetime,
38
39
  bytes calldata filter
39
40
  ) external;
40
41
 
41
- function setBundleInfo(BundleInfo memory bundleInfo) external;
42
+ function setBundleInfo(NftId nftId, BundleInfo memory bundleInfo) external;
43
+ function updateBundleState(NftId nftId, StateId state) external;
44
+
42
45
  function collateralizePolicy(NftId bundleNftId, NftId policyNftId, uint256 amount) external;
43
46
  function releasePolicy(NftId bundleNftId, NftId policyNftId) external returns(uint256 collateralAmount);
44
47
 
45
- function getBundleInfo(NftId bundleNftId) external view returns(BundleInfo memory bundleInfo);
46
-
47
- // repeat registry linked signature
48
- function getRegistry() external view returns (IRegistry registry);
48
+ function getBundleInfo(NftId nftId) external view returns(BundleInfo memory bundleInfo);
49
49
 
50
50
  // repeat service linked signatures to avoid linearization issues
51
51
  function getProductService() external returns(IProductService);
@@ -2,32 +2,21 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
6
+ import {IComponentModule} from "./IComponent.sol";
5
7
 
6
- import {IRegistry} from "../../../registry/IRegistry.sol";
7
- import {IInstance} from "../../IInstance.sol";
8
+ import {NftId} from "../../../types/NftId.sol";
9
+ import {ObjectType, COMPONENT} from "../../../types/ObjectType.sol";
10
+ import {StateId} from "../../../types/StateId.sol";
11
+ import {ModuleBase} from "../../base/ModuleBase.sol";
8
12
 
9
- import {LifecycleModule} from "../lifecycle/LifecycleModule.sol";
10
- import {IComponent, IComponentModule} from "./IComponent.sol";
11
- import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
12
- import {ObjectType, PRODUCT, ORACLE, POOL} from "../../../types/ObjectType.sol";
13
- import {StateId, ACTIVE, PAUSED} from "../../../types/StateId.sol";
14
- import {NftId, NftIdLib, zeroNftId} from "../../../types/NftId.sol";
15
- import {Fee, zeroFee} from "../../../types/Fee.sol";
16
- // import {IBaseComponent} from "../../../components/IBaseComponent.sol";
17
-
18
- abstract contract ComponentModule is
13
+ abstract contract ComponentModule is
14
+ ModuleBase,
19
15
  IComponentModule
20
16
  {
21
- using NftIdLib for NftId;
22
17
 
23
- mapping(NftId nftId => ComponentInfo info) private _componentInfo;
24
18
  NftId[] private _nftIds;
25
19
 
26
- mapping(ObjectType cType => bytes32 role) private _componentOwnerRole;
27
-
28
- // TODO maybe move this to Instance contract as internal variable?
29
- LifecycleModule private _lifecycleModule;
30
-
31
20
  modifier onlyComponentOwnerService() {
32
21
  require(
33
22
  msg.sender == address(this.getComponentOwnerService()),
@@ -36,49 +25,32 @@ abstract contract ComponentModule is
36
25
  _;
37
26
  }
38
27
 
39
- constructor() {
40
- address componentAddress = address(this);
41
- _lifecycleModule = LifecycleModule(componentAddress);
28
+ function initializeComponentModule(IKeyValueStore keyValueStore) internal {
29
+ _initialize(keyValueStore);
42
30
  }
43
31
 
44
32
  function registerComponent(
45
33
  NftId nftId,
46
- ObjectType objectType,
47
- IERC20Metadata token
48
- ) external override onlyComponentOwnerService {
49
-
50
- // create component info
51
- _componentInfo[nftId] = ComponentInfo(
52
- nftId,
53
- _lifecycleModule.getInitialState(objectType),
54
- token
55
- );
56
-
34
+ IERC20Metadata token,
35
+ address wallet
36
+ )
37
+ external
38
+ onlyComponentOwnerService
39
+ override
40
+ {
41
+ ComponentInfo memory info = ComponentInfo(token, wallet);
57
42
  _nftIds.push(nftId);
58
-
59
- // TODO add logging
43
+ _create(COMPONENT(), nftId, abi.encode(info));
60
44
  }
61
45
 
62
- function setComponentInfo(
63
- ComponentInfo memory info
64
- ) external onlyComponentOwnerService returns (NftId nftId) {
65
- nftId = info.nftId;
66
- require(
67
- nftId.gtz() && _componentInfo[nftId].nftId.eq(nftId),
68
- "ERROR:CMP-006:COMPONENT_UNKNOWN"
69
- );
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
+ }
70
50
 
71
- // TODO decide if state changes should have explicit functions and not
72
- // just a generic setXYZInfo and implicit state transitions
73
- // when in doubt go for the explicit approach ...
74
- ObjectType objectType = this.getRegistry().getObjectInfo(nftId).objectType;
75
- _lifecycleModule.checkAndLogTransition(
76
- nftId,
77
- objectType,
78
- _componentInfo[nftId].state,
79
- info.state
80
- );
81
- _componentInfo[nftId] = info;
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;
82
54
  }
83
55
 
84
56
  function getComponentCount()
@@ -95,10 +67,4 @@ abstract contract ComponentModule is
95
67
  ) external view override returns (NftId componentNftId) {
96
68
  return _nftIds[idx];
97
69
  }
98
-
99
- function getComponentInfo(
100
- NftId nftId
101
- ) external view override returns (ComponentInfo memory) {
102
- return _componentInfo[nftId];
103
- }
104
- }
70
+ }
@@ -2,52 +2,27 @@
2
2
  pragma solidity ^0.8.19;
3
3
 
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+ import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
5
6
 
6
-
7
- import {IRegistry} from "../../../registry/IRegistry.sol";
8
- import {IInstance} from "../../IInstance.sol";
9
7
  import {StateId} from "../../../types/StateId.sol";
10
8
  import {NftId} from "../../../types/NftId.sol";
11
- import {ObjectType} from "../../../types/ObjectType.sol";
12
- import {RoleId} from "../../../types/RoleId.sol";
13
- import {Fee} from "../../../types/Fee.sol";
14
- import {UFixed} from "../../../types/UFixed.sol";
15
-
16
- import {IComponentOwnerService} from "../../service/IComponentOwnerService.sol";
17
- // import {IComponentBase} from "../../../components/IComponentBase.sol";
18
9
 
19
10
  interface IComponent {
20
- // component dynamic info (static info kept in registry)
21
11
  struct ComponentInfo {
22
- NftId nftId;
23
- StateId state;
24
12
  IERC20Metadata token;
13
+ address wallet;
25
14
  }
26
15
  }
27
16
 
28
17
  interface IComponentModule is IComponent {
29
- function getRegistry() external view returns (IRegistry registry);
30
18
 
31
- function registerComponent(
32
- NftId nftId,
33
- ObjectType objectType,
34
- IERC20Metadata token
35
- ) external;
36
-
37
- function setComponentInfo(
38
- ComponentInfo memory info
39
- ) external returns (NftId componentNftId);
40
-
41
- function getComponentInfo(
42
- NftId nftId
43
- ) external view returns (ComponentInfo memory info);
19
+ function registerComponent(NftId nftId, IERC20Metadata token, address wallet) external;
20
+ function getComponentToken(NftId nftId) external view returns (IERC20Metadata token);
21
+ function getComponentWallet(NftId nftId) external view returns (address wallet);
44
22
 
45
23
  function getComponentCount() external view returns (uint256 numberOfCompnents);
46
-
47
24
  function getComponentId(uint256 idx) external view returns (NftId nftId);
48
25
 
49
26
  // repeat service linked signaturea to avoid linearization issues
50
27
  function getComponentOwnerService() external view returns(IComponentOwnerService);
51
-
52
- function hasRole(RoleId role, address member) external view returns (bool);
53
28
  }
@@ -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,42 +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
- bytes data;
25
- Timestamp createdAt;
25
+ bytes applicationData;
26
+ bytes policyData;
26
27
  Timestamp activatedAt; // time of underwriting
27
28
  Timestamp expiredAt; // no new claims (activatedAt + lifetime)
28
29
  Timestamp closedAt; // no locked capital
29
- Blocknumber updatedIn; // write log entries in a way to support backtracking of all state changes
30
30
  }
31
31
  }
32
32
 
33
33
  interface IPolicyModule is IPolicy {
34
- function createApplication(
35
- NftId productNftId,
34
+ function createPolicyInfo(
36
35
  NftId policyNftId,
36
+ NftId productNftId,
37
+ ReferralId referralId,
38
+ RiskId riskId,
37
39
  uint256 sumInsuredAmount,
38
40
  uint256 premiumAmount,
39
41
  uint256 lifetime,
40
42
  NftId bundleNftId
41
43
  ) external;
42
44
 
43
- function setPolicyInfo(PolicyInfo memory policyInfo) external;
45
+ function setPolicyInfo(NftId policyNftId, PolicyInfo memory info) external;
46
+ function updatePolicyState(NftId nftId, StateId state) external;
44
47
 
45
48
  // function underwrite(NftId nftId) external;
46
49
 
@@ -3,23 +3,22 @@ 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";
10
- import {APPLIED, ACTIVE, UNDERWRITTEN} from "../../../types/StateId.sol";
11
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";
12
13
  import {Timestamp, blockTimestamp, zeroTimestamp} from "../../../types/Timestamp.sol";
13
- import {Blocknumber, blockNumber} from "../../../types/Blocknumber.sol";
14
14
 
15
- import {LifecycleModule} from "../../module/lifecycle/LifecycleModule.sol";
15
+ import {IKeyValueStore} from "../../base/IKeyValueStore.sol";
16
+ import {ModuleBase} from "../../base/ModuleBase.sol";
16
17
 
17
- abstract contract PolicyModule is IPolicyModule {
18
- using NftIdLib for NftId;
19
-
20
- mapping(NftId nftId => PolicyInfo info) private _policyInfo;
21
-
22
- LifecycleModule private _lifecycleModule;
18
+ abstract contract PolicyModule is
19
+ ModuleBase,
20
+ IPolicyModule
21
+ {
23
22
 
24
23
  // TODO find a better place to avoid dupliation
25
24
  modifier onlyProductService2() {
@@ -30,13 +29,15 @@ abstract contract PolicyModule is IPolicyModule {
30
29
  _;
31
30
  }
32
31
 
33
- constructor() {
34
- _lifecycleModule = LifecycleModule(address(this));
32
+ function initializePolicyModule(IKeyValueStore keyValueStore) internal {
33
+ _initialize(keyValueStore);
35
34
  }
36
35
 
37
- function createApplication(
38
- NftId productNftId,
36
+ function createPolicyInfo(
39
37
  NftId policyNftId,
38
+ NftId productNftId,
39
+ ReferralId referralId,
40
+ RiskId riskId,
40
41
  uint256 sumInsuredAmount,
41
42
  uint256 premiumAmount,
42
43
  uint256 lifetime,
@@ -46,39 +47,45 @@ abstract contract PolicyModule is IPolicyModule {
46
47
  onlyProductService2
47
48
  override
48
49
  {
49
- _policyInfo[policyNftId] = PolicyInfo(
50
- policyNftId,
50
+ PolicyInfo memory info = PolicyInfo(
51
51
  productNftId,
52
52
  bundleNftId,
53
+ referralId,
53
54
  address(0), // beneficiary = policy nft holder
54
- _lifecycleModule.getInitialState(POLICY()),
55
+ riskId,
55
56
  sumInsuredAmount,
56
57
  premiumAmount,
57
58
  0, // premium paid amount
58
59
  lifetime,
59
- "", // data
60
- blockTimestamp(), // createdAt
60
+ "", // applicationData
61
+ "", // policyData
61
62
  zeroTimestamp(), // activatedAt
62
63
  zeroTimestamp(), // expiredAt
63
- zeroTimestamp(), // closedAt
64
- blockNumber() // updatedIn
64
+ zeroTimestamp() // closedAt
65
65
  );
66
66
 
67
- // TODO add logging
67
+ _create(POLICY(), policyNftId, abi.encode(info));
68
68
  }
69
69
 
70
- function setPolicyInfo(PolicyInfo memory policyInfo)
70
+ function setPolicyInfo(NftId policyNftId, PolicyInfo memory info)
71
71
  external
72
72
  override
73
73
  onlyProductService2
74
74
  {
75
- _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);
76
84
  }
77
85
 
78
86
  function getPolicyInfo(
79
87
  NftId nftId
80
88
  ) external view returns (PolicyInfo memory info) {
81
- return _policyInfo[nftId];
89
+ return abi.decode(_getData(POLICY(), nftId), (PolicyInfo));
82
90
  }
83
-
84
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
  }