@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
@@ -10,15 +10,27 @@ interface IPoolComponent is IBaseComponent {
10
10
 
11
11
  event LogUnderwrittenByPool(NftId policyNftId, uint256 collateralizationAmount, address pool);
12
12
 
13
+ function setFees(
14
+ Fee memory poolFee,
15
+ Fee memory stakingFee,
16
+ Fee memory performanceFee
17
+ ) external;
18
+
13
19
  /**
14
20
  * @dev creates a new bundle for this pool.
15
21
  */
16
22
  function createBundle(
23
+ Fee memory fee,
17
24
  uint256 initialAmount,
18
25
  uint256 lifetime,
19
26
  bytes memory filter
20
27
  ) external returns(NftId bundleNftId);
21
28
 
29
+ function setBundleFee(
30
+ NftId policyNftId,
31
+ Fee memory fee
32
+ ) external;
33
+
22
34
  /**
23
35
  * @dev this is a callback function that is called by the product service when underwriting a policy.
24
36
  * the pool has the option to check the details and object to underwriting by reverting.
@@ -48,6 +60,8 @@ interface IPoolComponent is IBaseComponent {
48
60
 
49
61
  function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
50
62
 
63
+ function getPoolFee() external view returns (Fee memory poolFee);
64
+
51
65
  function getStakingFee() external view returns (Fee memory stakingFee);
52
66
 
53
67
  function getPerformanceFee()
@@ -1,19 +1,38 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {NftId} from "../types/NftId.sol";
5
4
  import {Fee} from "../types/Fee.sol";
5
+ import {NftId} from "../types/NftId.sol";
6
+ import {ReferralId} from "../types/ReferralId.sol";
7
+ import {RiskId} from "../types/RiskId.sol";
8
+
6
9
  import {IBaseComponent} from "./IBaseComponent.sol";
7
10
 
8
11
  interface IProductComponent is IBaseComponent {
9
12
  function setFees(
10
- Fee memory policyFee,
13
+ Fee memory productFee,
11
14
  Fee memory processingFee
12
15
  ) external;
13
16
 
14
- function getPoolNftId() external view returns (NftId poolNftId);
15
-
16
- function getPolicyFee() external view returns (Fee memory policyFee);
17
+ function calculatePremium(
18
+ uint256 sumInsuredAmount,
19
+ RiskId riskId,
20
+ uint256 lifetime,
21
+ bytes memory applicationData,
22
+ ReferralId referralId,
23
+ NftId bundleNftId
24
+ ) external view returns (uint256 premiumAmount);
17
25
 
26
+ function calculateNetPremium(
27
+ uint256 sumInsuredAmount,
28
+ RiskId riskId,
29
+ uint256 lifetime,
30
+ bytes memory applicationData
31
+ ) external view returns (uint256 netPremiumAmount);
32
+
33
+ function getProductFee() external view returns (Fee memory productFee);
18
34
  function getProcessingFee() external view returns (Fee memory processingFee);
35
+
36
+ function getPoolNftId() external view returns (NftId poolNftId);
37
+ function getDistributionNftId() external view returns (NftId distributionNftId);
19
38
  }
@@ -15,6 +15,10 @@ contract Pool is BaseComponent, IPoolComponent {
15
15
  bool internal _isVerifying;
16
16
  UFixed internal _collateralizationLevel;
17
17
 
18
+ Fee internal _initialPoolFee;
19
+ Fee internal _initialStakingFee;
20
+ Fee internal _initialPerformanceFee;
21
+
18
22
  // may be used to interact with instance by derived contracts
19
23
  IPoolService internal _poolService;
20
24
 
@@ -41,19 +45,38 @@ contract Pool is BaseComponent, IPoolComponent {
41
45
  // TODO refactor into tokenNftId
42
46
  address token,
43
47
  bool verifying,
44
- UFixed collateralizationLevel
48
+ UFixed collateralizationLevel,
49
+ Fee memory poolFee,
50
+ Fee memory stakingFee,
51
+ Fee memory performanceFee
45
52
  )
46
53
  BaseComponent(registry, instanceNftId, token)
47
54
  {
48
55
  _isVerifying = verifying;
49
56
  // TODO add validation
50
57
  _collateralizationLevel = collateralizationLevel;
58
+ _initialPoolFee = poolFee;
59
+ _initialStakingFee = stakingFee;
60
+ _initialPerformanceFee = performanceFee;
51
61
 
52
62
  _poolService = _instance.getPoolService();
53
63
  _productService = _instance.getProductService();
54
64
  }
55
65
 
66
+ function setFees(
67
+ Fee memory poolFee,
68
+ Fee memory stakingFee,
69
+ Fee memory performanceFee
70
+ )
71
+ external
72
+ onlyOwner
73
+ override
74
+ {
75
+ _poolService.setFees(poolFee, stakingFee, performanceFee);
76
+ }
77
+
56
78
  function createBundle(
79
+ Fee memory fee,
57
80
  uint256 initialAmount,
58
81
  uint256 lifetime,
59
82
  bytes memory filter
@@ -65,6 +88,7 @@ contract Pool is BaseComponent, IPoolComponent {
65
88
  address owner = msg.sender;
66
89
  bundleNftId = _poolService.createBundle(
67
90
  owner,
91
+ fee,
68
92
  initialAmount,
69
93
  lifetime,
70
94
  filter
@@ -73,6 +97,17 @@ contract Pool is BaseComponent, IPoolComponent {
73
97
  // TODO add logging
74
98
  }
75
99
 
100
+ function setBundleFee(
101
+ NftId bundleNftId,
102
+ Fee memory fee
103
+ )
104
+ external
105
+ override
106
+ // TODO add onlyBundleOwner
107
+ {
108
+ _poolService.setBundleFee(bundleNftId, fee);
109
+ }
110
+
76
111
  /**
77
112
  * @dev see {IPool.underwrite}.
78
113
  * Default implementation that only writes a {LogUnderwrittenByPool} entry.
@@ -133,6 +168,7 @@ contract Pool is BaseComponent, IPoolComponent {
133
168
 
134
169
  function _createBundle(
135
170
  address bundleOwner,
171
+ Fee memory fee,
136
172
  uint256 amount,
137
173
  uint256 lifetime,
138
174
  bytes calldata filter
@@ -142,6 +178,7 @@ contract Pool is BaseComponent, IPoolComponent {
142
178
  {
143
179
  bundleNftId = _poolService.createBundle(
144
180
  bundleOwner,
181
+ fee,
145
182
  amount,
146
183
  lifetime,
147
184
  filter
@@ -149,13 +186,32 @@ contract Pool is BaseComponent, IPoolComponent {
149
186
  }
150
187
 
151
188
  // from pool component
189
+ function getPoolFee()
190
+ external
191
+ view
192
+ override
193
+ returns (Fee memory poolFee)
194
+ {
195
+ NftId productNftId = _instance.getProductNftId(getNftId());
196
+ if (_instance.hasTreasuryInfo(productNftId)) {
197
+ return _instance.getTreasuryInfo(productNftId).poolFee;
198
+ } else {
199
+ return _initialPoolFee;
200
+ }
201
+ }
202
+
152
203
  function getStakingFee()
153
204
  external
154
205
  view
155
206
  override
156
207
  returns (Fee memory stakingFee)
157
208
  {
158
- return _instance.getPoolSetup(getNftId()).stakingFee;
209
+ NftId productNftId = _instance.getProductNftId(getNftId());
210
+ if (_instance.hasTreasuryInfo(productNftId)) {
211
+ return _instance.getTreasuryInfo(productNftId).stakingFee;
212
+ } else {
213
+ return _initialStakingFee;
214
+ }
159
215
  }
160
216
 
161
217
  function getPerformanceFee()
@@ -164,7 +220,12 @@ contract Pool is BaseComponent, IPoolComponent {
164
220
  override
165
221
  returns (Fee memory performanceFee)
166
222
  {
167
- return _instance.getPoolSetup(getNftId()).performanceFee;
223
+ NftId productNftId = _instance.getProductNftId(getNftId());
224
+ if (_instance.hasTreasuryInfo(productNftId)) {
225
+ return _instance.getTreasuryInfo(productNftId).performanceFee;
226
+ } else {
227
+ return _initialPerformanceFee;
228
+ }
168
229
  }
169
230
 
170
231
  // from registerable
@@ -1,42 +1,138 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {IRisk} from "../instance/module/risk/IRisk.sol";
5
+ import {ITreasury} from "../instance/module/treasury/ITreasury.sol";
4
6
  import {IProductService} from "../instance/service/IProductService.sol";
5
7
  import {IProductComponent} from "./IProductComponent.sol";
6
8
  import {NftId} from "../types/NftId.sol";
7
9
  import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
10
+ import {ReferralId} from "../types/ReferralId.sol";
11
+ import {RiskId, RiskIdLib} from "../types/RiskId.sol";
12
+ import {StateId} from "../types/StateId.sol";
8
13
  import {Timestamp} from "../types/Timestamp.sol";
9
14
  import {Fee} from "../types/Fee.sol";
10
15
  import {BaseComponent} from "./BaseComponent.sol";
11
16
 
12
17
  contract Product is BaseComponent, IProductComponent {
13
- IProductService private _productService;
14
- address private _pool;
18
+ IProductService internal _productService;
19
+ address internal _pool;
20
+ address internal _distribution;
21
+ Fee internal _initialProductFee;
22
+ Fee internal _initialProcessingFee;
15
23
 
16
24
  constructor(
17
25
  address registry,
18
26
  NftId instanceNftid,
19
27
  address token,
20
- address pool
28
+ address pool,
29
+ address distribution,
30
+ Fee memory productFee,
31
+ Fee memory processingFee
21
32
  ) BaseComponent(registry, instanceNftid, token) {
22
33
  // TODO add validation
23
34
  _productService = _instance.getProductService();
24
35
  _pool = pool;
36
+ _distribution = distribution;
37
+ _initialProductFee = productFee;
38
+ _initialProcessingFee = processingFee;
39
+ }
40
+
41
+
42
+ function calculatePremium(
43
+ uint256 sumInsuredAmount,
44
+ RiskId riskId,
45
+ uint256 lifetime,
46
+ bytes memory applicationData,
47
+ ReferralId referralId,
48
+ NftId bundleNftId
49
+ )
50
+ external
51
+ view
52
+ override
53
+ returns (uint256 premiumAmount)
54
+ {
55
+ (premiumAmount,,,,) = _productService.calculatePremium(
56
+ riskId,
57
+ sumInsuredAmount,
58
+ lifetime,
59
+ applicationData,
60
+ bundleNftId,
61
+ referralId
62
+ );
63
+ }
64
+
65
+
66
+ function calculateNetPremium(
67
+ uint256 sumInsuredAmount,
68
+ RiskId riskId,
69
+ uint256 lifetime,
70
+ bytes memory applicationData
71
+ )
72
+ external
73
+ view
74
+ virtual override
75
+ returns (uint256 netPremiumAmount)
76
+ {
77
+ // default 10% of sum insured
78
+ return sumInsuredAmount / 10;
79
+ }
80
+
81
+ function _toRiskId(string memory riskName) internal pure returns (RiskId riskId) {
82
+ return RiskIdLib.toRiskId(riskName);
83
+ }
84
+
85
+ function _createRisk(
86
+ RiskId id,
87
+ bytes memory data
88
+ ) internal {
89
+ _productService.createRisk(
90
+ id,
91
+ data
92
+ );
93
+ }
94
+
95
+ function _setRiskInfo(
96
+ RiskId id,
97
+ IRisk.RiskInfo memory info
98
+ ) internal {
99
+ _productService.setRiskInfo(
100
+ id,
101
+ info
102
+ );
103
+ }
104
+
105
+ function _updateRiskState(
106
+ RiskId id,
107
+ StateId state
108
+ ) internal {
109
+ _productService.updateRiskState(
110
+ id,
111
+ state
112
+ );
113
+ }
114
+
115
+ function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
116
+ return _instance.getRiskInfo(id);
25
117
  }
26
118
 
27
119
  function _createApplication(
28
120
  address applicationOwner,
121
+ RiskId riskId,
29
122
  uint256 sumInsuredAmount,
30
- uint256 premiumAmount,
31
123
  uint256 lifetime,
32
- NftId bundleNftId
124
+ bytes memory applicationData,
125
+ NftId bundleNftId,
126
+ ReferralId referralId
33
127
  ) internal returns (NftId nftId) {
34
128
  nftId = _productService.createApplication(
35
129
  applicationOwner,
130
+ riskId,
36
131
  sumInsuredAmount,
37
- premiumAmount,
38
132
  lifetime,
39
- bundleNftId
133
+ applicationData,
134
+ bundleNftId,
135
+ referralId
40
136
  );
41
137
  }
42
138
 
@@ -79,26 +175,35 @@ contract Product is BaseComponent, IProductComponent {
79
175
  return _registry.getNftId(_pool);
80
176
  }
81
177
 
178
+ function getDistributionNftId() external view override returns (NftId distributionNftId) {
179
+ return _registry.getNftId(_distribution);
180
+ }
181
+
82
182
  // from product component
83
183
  function setFees(
84
- Fee memory policyFee,
184
+ Fee memory productFee,
85
185
  Fee memory processingFee
86
186
  )
87
187
  external
88
188
  onlyOwner
89
189
  override
90
190
  {
91
- _productService.setFees(policyFee, processingFee);
191
+ _productService.setFees(productFee, processingFee);
92
192
  }
93
193
 
94
194
 
95
- function getPolicyFee()
195
+ function getProductFee()
96
196
  external
97
197
  view
98
198
  override
99
- returns (Fee memory policyFee)
199
+ returns (Fee memory productFee)
100
200
  {
101
- return _instance.getProductSetup(getNftId()).policyFee;
201
+ NftId productNftId = getNftId();
202
+ if (_instance.hasTreasuryInfo(productNftId)) {
203
+ return _instance.getTreasuryInfo(productNftId).productFee;
204
+ } else {
205
+ return _initialProductFee;
206
+ }
102
207
  }
103
208
 
104
209
  function getProcessingFee()
@@ -107,7 +212,12 @@ contract Product is BaseComponent, IProductComponent {
107
212
  override
108
213
  returns (Fee memory processingFee)
109
214
  {
110
- return _instance.getProductSetup(getNftId()).processingFee;
215
+ NftId productNftId = getNftId();
216
+ if (_instance.hasTreasuryInfo(productNftId)) {
217
+ return _instance.getTreasuryInfo(productNftId).processingFee;
218
+ } else {
219
+ return _initialProcessingFee;
220
+ }
111
221
  }
112
222
 
113
223
  // from registerable
@@ -3,27 +3,28 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
 
6
-
7
6
  import {IVersionable} from "../shared/IVersionable.sol";
8
7
  import {IRegisterable} from "../shared/IRegisterable.sol";
9
8
  import {IOwnable} from "../shared/IOwnable.sol";
10
9
  import {RoleId} from "../types/RoleId.sol";
11
10
 
12
11
  import {IAccessModule} from "./module/access/IAccess.sol";
13
- import {ILifecycleModule} from "./module/lifecycle/ILifecycle.sol";
12
+ import {IBundleModule} from "./module/bundle/IBundle.sol";
13
+ import {IDistributionModule} from "./module/distribution/IDistribution.sol";
14
14
  import {IComponentModule} from "./module/component/IComponent.sol";
15
15
  import {IPolicyModule} from "./module/policy/IPolicy.sol";
16
16
  import {IPoolModule} from "./module/pool/IPoolModule.sol";
17
- import {IBundleModule} from "./module/bundle/IBundle.sol";
17
+ import {IRiskModule} from "./module/risk/IRisk.sol";
18
18
  import {ITreasuryModule} from "./module/treasury/ITreasury.sol";
19
19
 
20
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
20
21
  import {IRegistry, IRegistryLinked} from "../registry/IRegistryLinked.sol";
21
- import {IServiceLinked} from "./IServiceLinked.sol";
22
22
 
23
23
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
24
+ import {IDistributionService} from "./service/IDistributionService.sol";
24
25
  import {IProductService} from "./service/IProductService.sol";
25
26
  import {IPoolService} from "./service/IPoolService.sol";
26
-
27
+ import {IInstanceBase} from "./base/IInstanceBase.sol";
27
28
 
28
29
  // solhint-disable-next-line no-empty-blocks
29
30
  interface IInstance is
@@ -31,20 +32,22 @@ interface IInstance is
31
32
  IVersionable,
32
33
  IRegisterable,
33
34
  IAccessModule,
34
- ILifecycleModule,
35
35
  IPolicyModule,
36
36
  IPoolModule,
37
+ IRiskModule,
37
38
  IBundleModule,
38
39
  IComponentModule,
39
40
  ITreasuryModule,
40
- IServiceLinked
41
+ IDistributionModule,
42
+ IInstanceBase
41
43
  {
42
- function getRegistry() external view override (IBundleModule, IComponentModule, IPolicyModule, IRegisterable) returns (IRegistry registry);
43
- function hasRole(RoleId role, address member) external view override (IAccessModule, IComponentModule) returns (bool hasRole);
44
+ function getRegistry() external view override (IPolicyModule, IRegisterable) returns (IRegistry registry);
45
+ function getOwner() external view override (IOwnable, IAccessModule) returns(address owner);
44
46
 
45
- function getComponentOwnerService() external view override (IServiceLinked, IComponentModule) returns(IComponentOwnerService);
46
- function getProductService() external view override (IServiceLinked, IBundleModule, IPolicyModule) returns(IProductService);
47
- function getPoolService() external view override (IServiceLinked, IBundleModule, IPoolModule) returns(IPoolService);
47
+ function getKeyValueStore() external view override (IInstanceBase) returns (IKeyValueStore keyValueStore);
48
+ function getComponentOwnerService() external view override (IInstanceBase, IComponentModule) returns(IComponentOwnerService);
49
+ function getDistributionService() external view override returns(IDistributionService);
50
+ function getProductService() external view override (IInstanceBase, IBundleModule, IPolicyModule) returns(IProductService);
51
+ function getPoolService() external view override (IInstanceBase, IBundleModule, IPoolModule) returns(IPoolService);
48
52
 
49
- function getOwner() external view override (IOwnable, IAccessModule) returns(address owner);
50
53
  }
@@ -4,12 +4,13 @@ pragma solidity ^0.8.19;
4
4
  import {NftId} from "../types/NftId.sol";
5
5
  import {RoleId} from "../types/RoleId.sol";
6
6
 
7
- import {InstanceBase} from "./InstanceBase.sol";
7
+ import {InstanceBase} from "./base/InstanceBase.sol";
8
8
  import {AccessModule} from "./module/access/Access.sol";
9
- import {LifecycleModule} from "./module/lifecycle/LifecycleModule.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
+ import {RiskModule} from "./module/risk/RiskModule.sol";
13
14
  import {BundleModule} from "./module/bundle/BundleModule.sol";
14
15
  import {TreasuryModule} from "./module/treasury/TreasuryModule.sol";
15
16
 
@@ -20,20 +21,24 @@ import {IBundleModule} from "./module/bundle/IBundle.sol";
20
21
  import {IComponentModule} from "./module/component/IComponent.sol";
21
22
  import {IPoolModule} from "./module/pool/IPoolModule.sol";
22
23
  import {IPolicyModule} from "./module/policy/IPolicy.sol";
23
- import {IServiceLinked} from "./IServiceLinked.sol";
24
+ import {IInstanceBase} from "./base/IInstanceBase.sol";
24
25
 
25
26
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
27
+ import {IDistributionService} from "./service/IDistributionService.sol";
26
28
  import {IProductService} from "./service/IProductService.sol";
27
29
  import {IPoolService} from "./service/IPoolService.sol";
28
30
 
31
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
32
+
29
33
  contract Instance is
30
34
  InstanceBase,
31
35
  AccessModule,
32
36
  BundleModule,
33
37
  ComponentModule,
34
- LifecycleModule,
38
+ DistributionModule,
35
39
  PolicyModule,
36
40
  PoolModule,
41
+ RiskModule,
37
42
  TreasuryModule
38
43
  {
39
44
  constructor(
@@ -43,20 +48,27 @@ contract Instance is
43
48
  InstanceBase(registry, registryNftId)
44
49
  AccessModule()
45
50
  BundleModule()
51
+ DistributionModule()
46
52
  ComponentModule()
47
53
  PolicyModule()
48
54
  PoolModule()
49
55
  TreasuryModule()
50
56
  {
57
+ initializeBundleModule(_keyValueStore);
58
+ initializeComponentModule(_keyValueStore);
59
+ initializeDistributionModule(_keyValueStore);
60
+ initializePolicyModule(_keyValueStore);
61
+ initializePoolModule(_keyValueStore);
62
+ initializeRiskModule(_keyValueStore);
51
63
  }
52
64
 
53
- function getRegistry() public view override (Registerable, IBundleModule, IComponentModule, IPolicyModule) returns (IRegistry registry) { return super.getRegistry(); }
54
-
55
- function hasRole(RoleId role, address member) public view override (AccessModule, IComponentModule) returns (bool) { return super.hasRole(role, member); }
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(); }
56
67
 
57
- function getComponentOwnerService() external view override (IComponentModule, IServiceLinked) returns(IComponentOwnerService service) { return _componentOwnerService; }
58
- function getProductService() external view override (IBundleModule, IPolicyModule, IServiceLinked) returns(IProductService service) { return _productService; }
59
- function getPoolService() external view override (IBundleModule, IPoolModule, IServiceLinked) returns(IPoolService service) { return _poolService; }
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; }
70
+ function getProductService() external view override (IBundleModule, IPolicyModule, IInstanceBase) returns(IProductService service) { return _productService; }
71
+ function getPoolService() external view override (IBundleModule, IPoolModule, IInstanceBase) returns(IPoolService service) { return _poolService; }
60
72
 
61
73
  function getOwner() public view override (IAccessModule, Registerable) returns(address owner) { return super.getOwner(); }
62
74
  }
@@ -15,6 +15,7 @@ abstract contract ComponentServiceBase is ServiceBase {
15
15
  NftId registryNftId
16
16
  )
17
17
  ServiceBase(registry, registryNftId)
18
+ // solhint-disable-next-line no-empty-blocks
18
19
  {
19
20
  }
20
21
 
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Key32} from "../../types/Key32.sol";
5
+ import {StateId} from "../../types/StateId.sol";
6
+
7
+ import {IKeyValueStore} from "./IKeyValueStore.sol";
8
+ import {IComponentOwnerService} from "../service/IComponentOwnerService.sol";
9
+ import {IDistributionService} from "../service/IDistributionService.sol";
10
+ import {IProductService} from "../service/IProductService.sol";
11
+ import {IPoolService} from "../service/IPoolService.sol";
12
+
13
+ interface IInstanceBase {
14
+ function getKeyValueStore() external view returns (IKeyValueStore keyValueStore);
15
+ function updateState(Key32 key, StateId state) external;
16
+ function getState(Key32 key) external view returns (StateId state);
17
+
18
+ function getComponentOwnerService() external view returns(IComponentOwnerService service);
19
+ function getDistributionService() external view returns(IDistributionService);
20
+ function getProductService() external view returns(IProductService service);
21
+ function getPoolService() external view returns(IPoolService service);
22
+ }
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Blocknumber, blockBlocknumber, zeroBlocknumber} from "../../types/Blocknumber.sol";
5
+ import {Key32, KeyId} from "../../types/Key32.sol";
6
+ import {NftId} from "../../types/NftId.sol";
7
+ import {ObjectType} from "../../types/ObjectType.sol";
8
+ import {StateId} from "../../types/StateId.sol";
9
+
10
+ import {ILifecycle} from "./ILifecycle.sol";
11
+
12
+ interface IKeyValueStore is ILifecycle {
13
+
14
+ struct Key {
15
+ ObjectType objectType;
16
+ KeyId id;
17
+ }
18
+
19
+ struct Value {
20
+ Metadata metadata;
21
+ bytes data;
22
+ }
23
+
24
+ struct Metadata {
25
+ ObjectType objectType;
26
+ StateId state;
27
+ address updatedBy;
28
+ Blocknumber updatedIn;
29
+ Blocknumber createdIn;
30
+ }
31
+
32
+ event LogInfoCreated(Key key, StateId state, address createdBy, address txOrigin);
33
+ event LogInfoUpdated(Key key, StateId state, address updatedBy, address txOrigin, Blocknumber lastUpdatedIn);
34
+ event LogStateUpdated(Key key, StateId stateOld, StateId stateNew, address updatedBy, address txOrigin, Blocknumber lastUpdatedIn);
35
+
36
+ // generic state changing functions
37
+ function create(Key32 key, ObjectType objectType, bytes memory data) external;
38
+ function update(Key32 key, StateId state, bytes memory data) external;
39
+ function updateData(Key32 key, bytes memory data) external;
40
+ function updateState(Key32 key, StateId state) external;
41
+
42
+ function exists(Key32 key) external view returns (bool);
43
+ function get(Key32 key) external view returns (Value memory value);
44
+ function getData(Key32 key) external view returns (bytes memory data);
45
+ function getMetadata(Key32 key) external view returns (Metadata memory metadata);
46
+ function getState(Key32 key) external view returns (StateId state);
47
+
48
+ function toKey32(ObjectType objectType, KeyId id) external pure returns(Key32);
49
+ function toKey(Key32 key32) external pure returns(Key memory key);
50
+ }
@@ -0,0 +1,30 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {ObjectType} from "../../types/ObjectType.sol";
5
+ import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
6
+ import {NftId} from "../../types/NftId.sol";
7
+
8
+ interface ILifecycle {
9
+
10
+ error ErrorNoLifecycle(NftId nftId, ObjectType objectType);
11
+ error ErrorInvalidStateTransition(
12
+ ObjectType objectType,
13
+ StateId fromStateId,
14
+ StateId toStateId
15
+ );
16
+
17
+ function hasLifecycle(
18
+ ObjectType objectType
19
+ ) external view returns (bool);
20
+
21
+ function getInitialState(
22
+ ObjectType objectType
23
+ ) external view returns (StateId);
24
+
25
+ function isValidTransition(
26
+ ObjectType objectType,
27
+ StateId fromId,
28
+ StateId toId
29
+ ) external view returns (bool);
30
+ }