@etherisc/gif-next 0.0.2-8872ac5 → 0.0.2-8d47fa1-080

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/README.md +170 -7
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
  3. package/artifacts/contracts/components/{IProduct.sol/IProductComponent.json → BaseComponent.sol/BaseComponent.json} +88 -67
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +445 -0
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/{IPool.sol/IPoolComponent.json → IBaseComponent.sol/IBaseComponent.json} +69 -71
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +343 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +474 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +373 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +445 -56
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +324 -53
  18. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  22. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  24. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  26. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  33. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  34. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  35. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  36. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  37. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  38. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  39. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  40. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  41. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  42. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  43. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  44. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  45. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  46. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  47. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1575 -295
  48. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +4 -0
  49. package/artifacts/contracts/instance/{component/IComponent.sol → IInstanceLinked.sol}/IInstanceLinked.json +1 -1
  50. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  51. package/artifacts/contracts/instance/Instance.sol/Instance.json +1888 -376
  52. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  53. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +393 -0
  54. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  55. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  56. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  57. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +560 -0
  58. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  59. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
  60. package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +4 -0
  61. package/artifacts/contracts/instance/{component/ComponentModule.sol/ComponentModule.json → base/IService.sol/IService.json} +171 -154
  62. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  63. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +456 -0
  64. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  65. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +710 -0
  66. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  67. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  68. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +4 -0
  69. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.json +10 -0
  70. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +4 -0
  71. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +380 -0
  72. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +4 -0
  73. package/artifacts/contracts/instance/{access → module/access}/Access.sol/AccessModule.json +85 -152
  74. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +4 -0
  75. package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccess.json +1 -1
  76. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +4 -0
  77. package/artifacts/contracts/instance/{access → module/access}/IAccess.sol/IAccessModule.json +96 -99
  78. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +4 -0
  79. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +297 -0
  80. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +4 -0
  81. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.json +10 -0
  82. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +297 -0
  84. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +4 -0
  85. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +117 -0
  86. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +4 -0
  87. package/artifacts/contracts/instance/{component → module/component}/IComponent.sol/IComponent.json +1 -1
  88. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +4 -0
  89. package/artifacts/contracts/instance/{product/IProductService.sol/IProductService.json → module/component/IComponent.sol/IComponentModule.json} +56 -53
  90. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  92. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.json +10 -0
  94. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.json +10 -0
  96. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +4 -0
  97. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicy.json +1 -1
  98. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +4 -0
  99. package/artifacts/contracts/instance/{policy → module/policy}/IPolicy.sol/IPolicyModule.json +159 -106
  100. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +4 -0
  101. package/artifacts/contracts/instance/{policy → module/policy}/PolicyModule.sol/PolicyModule.json +159 -106
  102. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +4 -0
  103. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPool.json +1 -1
  104. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +4 -0
  105. package/artifacts/contracts/instance/{pool → module/pool}/IPoolModule.sol/IPoolModule.json +74 -59
  106. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +4 -0
  107. package/artifacts/contracts/instance/{pool → module/pool}/PoolModule.sol/PoolModule.json +64 -62
  108. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +4 -0
  109. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.json +10 -0
  110. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +4 -0
  111. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +113 -0
  112. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +4 -0
  113. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +131 -0
  114. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +4 -0
  115. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.json +10 -0
  116. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +4 -0
  117. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +638 -0
  118. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  119. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +76 -0
  120. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +4 -0
  121. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +638 -0
  122. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +690 -0
  124. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  125. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +526 -0
  126. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
  127. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +389 -0
  128. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  129. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +369 -0
  130. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  131. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +484 -0
  132. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  133. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +674 -0
  134. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  135. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +649 -0
  136. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  137. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +964 -0
  138. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  139. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +194 -2
  140. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  141. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +5 -0
  142. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  143. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +364 -72
  144. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  145. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.json +24 -0
  146. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  147. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +668 -0
  148. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  149. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  150. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  151. package/artifacts/contracts/registry/Registry.sol/Registry.json +570 -82
  152. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.dbg.json +4 -0
  153. package/artifacts/contracts/registry/RegistryInstaller.sol/RegistryInstaller.json +344 -0
  154. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  155. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +861 -0
  156. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  157. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
  158. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +4 -0
  159. package/artifacts/contracts/{registry/IRegistry.sol → shared/IOwnable.sol}/IOwnable.json +1 -1
  160. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  161. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +124 -0
  162. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  163. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
  164. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  165. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +310 -0
  166. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  167. package/artifacts/contracts/{registry/Registry.sol → shared/Registerable.sol}/Registerable.json +71 -77
  168. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  169. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  170. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  171. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
  172. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  173. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +445 -0
  174. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  175. package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
  176. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +4 -0
  177. package/artifacts/contracts/test/TestPool.sol/TestPool.json +602 -0
  178. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +4 -0
  179. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +632 -0
  180. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  181. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +191 -0
  182. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  183. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
  184. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  185. package/artifacts/contracts/test/TestService.sol/TestService.json +472 -0
  186. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  187. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +338 -0
  188. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  189. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
  190. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  191. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +270 -0
  192. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  193. package/artifacts/contracts/test/Usdc.sol/USDC.json +338 -0
  194. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  195. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  196. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  198. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  200. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  201. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  202. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  203. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +111 -0
  204. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  205. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  206. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  207. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
  208. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  209. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  210. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  211. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  212. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  213. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  214. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  215. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +30 -0
  216. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  217. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  218. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  219. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +64 -2
  220. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  221. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +88 -62
  222. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  223. package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
  224. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  225. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +30 -0
  226. package/contracts/components/BaseComponent.sol +79 -0
  227. package/contracts/components/Distribution.sol +155 -0
  228. package/contracts/components/IBaseComponent.sol +19 -0
  229. package/contracts/components/IDistributionComponent.sol +47 -0
  230. package/contracts/components/IPoolComponent.sol +65 -0
  231. package/contracts/components/IProductComponent.sol +39 -0
  232. package/contracts/components/Pool.sol +236 -12
  233. package/contracts/components/Product.sol +268 -24
  234. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  235. package/contracts/experiment/statemachine/ISM.sol +25 -0
  236. package/contracts/experiment/statemachine/SM.sol +57 -0
  237. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  238. package/contracts/instance/IInstance.sol +44 -8
  239. package/contracts/instance/IInstanceLinked.sol +8 -0
  240. package/contracts/instance/Instance.sol +60 -39
  241. package/contracts/instance/base/ComponentServiceBase.sol +49 -0
  242. package/contracts/instance/base/IInstanceBase.sol +23 -0
  243. package/contracts/instance/base/IKeyValueStore.sol +50 -0
  244. package/contracts/instance/base/ILifecycle.sol +30 -0
  245. package/contracts/instance/base/IService.sol +15 -0
  246. package/contracts/instance/base/InstanceBase.sol +89 -0
  247. package/contracts/instance/base/KeyValueStore.sol +161 -0
  248. package/contracts/instance/base/Lifecycle.sol +100 -0
  249. package/contracts/instance/base/ModuleBase.sol +57 -0
  250. package/contracts/instance/base/ServiceBase.sol +43 -0
  251. package/contracts/instance/module/access/Access.sol +149 -0
  252. package/contracts/instance/module/access/IAccess.sol +53 -0
  253. package/contracts/instance/module/bundle/BundleModule.sol +134 -0
  254. package/contracts/instance/module/bundle/IBundle.sol +53 -0
  255. package/contracts/instance/module/component/ComponentModule.sol +71 -0
  256. package/contracts/instance/module/component/IComponent.sol +28 -0
  257. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  258. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  259. package/contracts/instance/module/policy/IPolicy.sol +63 -0
  260. package/contracts/instance/module/policy/PolicyModule.sol +91 -0
  261. package/contracts/instance/module/pool/IPoolModule.sol +41 -0
  262. package/contracts/instance/module/pool/PoolModule.sol +95 -0
  263. package/contracts/instance/module/risk/IRisk.sol +26 -0
  264. package/contracts/instance/module/risk/RiskModule.sol +62 -0
  265. package/contracts/instance/module/treasury/ITreasury.sol +84 -0
  266. package/contracts/instance/module/treasury/TokenHandler.sol +48 -0
  267. package/contracts/instance/module/treasury/TreasuryModule.sol +131 -0
  268. package/contracts/instance/service/ComponentOwnerService.sol +272 -0
  269. package/contracts/instance/service/DistributionService.sol +54 -0
  270. package/contracts/instance/service/IComponentOwnerService.sol +20 -0
  271. package/contracts/instance/service/IDistributionService.sol +12 -0
  272. package/contracts/instance/service/IPoolService.sol +37 -0
  273. package/contracts/instance/service/IProductService.sol +107 -0
  274. package/contracts/instance/service/PoolService.sol +149 -0
  275. package/contracts/instance/service/ProductService.sol +509 -0
  276. package/contracts/registry/ChainNft.sol +94 -42
  277. package/contracts/registry/IChainNft.sol +3 -2
  278. package/contracts/registry/IRegistry.sol +51 -56
  279. package/contracts/registry/IRegistryLinked.sol +8 -0
  280. package/contracts/registry/IRegistryService.sol +29 -0
  281. package/contracts/registry/ITransferInterceptor.sol +6 -0
  282. package/contracts/registry/Registry.sol +436 -140
  283. package/contracts/registry/RegistryInstaller.sol +100 -0
  284. package/contracts/registry/RegistryService.sol +383 -0
  285. package/contracts/shared/ERC165.sol +21 -0
  286. package/contracts/shared/IOwnable.sol +6 -0
  287. package/contracts/shared/IRegisterable.sol +22 -0
  288. package/contracts/shared/IVersionable.sol +96 -0
  289. package/contracts/shared/ProxyManager.sol +115 -0
  290. package/contracts/shared/Registerable.sol +117 -0
  291. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  292. package/contracts/shared/Versionable.sol +147 -0
  293. package/contracts/test/TestDistribution.sol +22 -0
  294. package/contracts/test/TestFee.sol +25 -0
  295. package/contracts/test/TestPool.sol +27 -0
  296. package/contracts/test/TestProduct.sol +74 -0
  297. package/contracts/test/TestRegisterable.sol +18 -0
  298. package/contracts/test/TestRoleId.sol +14 -0
  299. package/contracts/test/TestService.sol +26 -0
  300. package/contracts/test/TestToken.sol +26 -0
  301. package/contracts/test/TestVersion.sol +44 -0
  302. package/contracts/test/TestVersionable.sol +17 -0
  303. package/contracts/test/Usdc.sol +26 -0
  304. package/contracts/types/AddressSet.sol +58 -0
  305. package/contracts/types/Fee.sol +56 -0
  306. package/contracts/types/Key32.sol +45 -0
  307. package/contracts/types/NftId.sol +22 -1
  308. package/contracts/types/NftIdSet.sol +60 -0
  309. package/contracts/types/ObjectType.sol +131 -0
  310. package/contracts/types/ReferralId.sol +48 -0
  311. package/contracts/types/RiskId.sol +43 -0
  312. package/contracts/types/RoleId.sol +38 -0
  313. package/contracts/types/StateId.sol +101 -0
  314. package/contracts/types/Timestamp.sol +22 -1
  315. package/contracts/types/UFixed.sol +26 -22
  316. package/contracts/types/Version.sol +104 -0
  317. package/package.json +15 -5
  318. package/artifacts/contracts/components/Component.sol/Component.dbg.json +0 -4
  319. package/artifacts/contracts/components/Component.sol/Component.json +0 -179
  320. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
  321. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
  322. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
  323. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
  324. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
  325. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
  326. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
  327. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
  328. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
  329. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +0 -50
  330. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  331. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  332. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
  333. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -147
  334. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
  335. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
  336. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +0 -179
  337. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  338. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +0 -245
  339. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
  340. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -94
  341. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
  342. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  343. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  344. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  345. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  346. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  347. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  348. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
  349. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
  350. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
  351. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
  352. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.json +0 -75
  353. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
  354. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -167
  355. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
  356. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
  357. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +0 -166
  358. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
  359. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +0 -49
  360. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
  361. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
  362. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
  363. package/contracts/components/Component.sol +0 -60
  364. package/contracts/components/IPool.sol +0 -9
  365. package/contracts/components/IProduct.sol +0 -9
  366. package/contracts/instance/access/Access.sol +0 -165
  367. package/contracts/instance/access/IAccess.sol +0 -63
  368. package/contracts/instance/component/ComponentModule.sol +0 -213
  369. package/contracts/instance/component/IComponent.sol +0 -73
  370. package/contracts/instance/policy/IPolicy.sol +0 -51
  371. package/contracts/instance/policy/PolicyModule.sol +0 -91
  372. package/contracts/instance/pool/IPoolModule.sol +0 -29
  373. package/contracts/instance/pool/PoolModule.sol +0 -73
  374. package/contracts/instance/product/IProductService.sol +0 -36
  375. package/contracts/instance/product/ProductService.sol +0 -112
@@ -1,55 +1,299 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IProductService} from "../instance/product/IProductService.sol";
5
- import {Component} from "./Component.sol";
6
- import {IProductComponent} from "./IProduct.sol";
7
- import {NftId} from "../types/NftId.sol";
4
+ import {IERC20Metadata} from "@openzeppelin5/contracts/token/ERC20/extensions/IERC20Metadata.sol";
8
5
 
9
- contract Product is Component, IProductComponent {
10
- IProductService private _productService;
11
- address private _pool;
6
+ import {IRisk} from "../instance/module/risk/IRisk.sol";
7
+ import {ITreasury} from "../instance/module/treasury/ITreasury.sol";
8
+ import {IProductService} from "../instance/service/IProductService.sol";
9
+ import {IProductComponent} from "./IProductComponent.sol";
10
+ import {NftId, zeroNftId} from "../types/NftId.sol";
11
+ import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
12
+ import {ReferralId} from "../types/ReferralId.sol";
13
+ import {RiskId, RiskIdLib} from "../types/RiskId.sol";
14
+ import {StateId} from "../types/StateId.sol";
15
+ import {Timestamp} from "../types/Timestamp.sol";
16
+ import {Fee, FeeLib} from "../types/Fee.sol";
17
+ import {BaseComponent} from "./BaseComponent.sol";
18
+
19
+ import {IRegistry} from "../registry/IRegistry.sol";
20
+ import {IRegisterable} from "../shared/IRegisterable.sol";
21
+ import {Registerable} from "../shared/Registerable.sol";
22
+
23
+ import {IPool} from "../instance/module/pool/IPoolModule.sol";
24
+ import {IPoolComponent} from "../components/IPoolComponent.sol";
25
+
26
+ contract Product is BaseComponent, IProductComponent {
27
+ IProductService internal _productService;
28
+ IPoolComponent internal _pool;
29
+ address internal _distribution;
30
+ Fee internal _initialProductFee;
31
+ Fee internal _initialProcessingFee;
32
+
33
+ NftId internal _poolNftId;
34
+ NftId internal _distributionNftId;
12
35
 
13
36
  constructor(
14
37
  address registry,
15
- address instance,
16
- address pool
17
- ) Component(registry, instance) {
38
+ NftId instanceNftid,
39
+ address token,
40
+ bool isInterceptor,
41
+ address pool,
42
+ address distribution,
43
+ Fee memory productFee,
44
+ Fee memory processingFee,
45
+ address initialOwner
46
+ ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
47
+ // TODO add validation
18
48
  _productService = _instance.getProductService();
19
- _pool = pool;
49
+ _pool = IPoolComponent(pool);
50
+ _distribution = distribution;
51
+ _initialProductFee = productFee;
52
+ _initialProcessingFee = processingFee;
53
+
54
+ _poolNftId = getRegistry().getNftId(address(_pool));
55
+ _distributionNftId = getRegistry().getNftId(_distribution);
56
+
57
+ _registerInterface(type(IProductComponent).interfaceId);
58
+ }
59
+
60
+
61
+ function calculatePremium(
62
+ uint256 sumInsuredAmount,
63
+ RiskId riskId,
64
+ uint256 lifetime,
65
+ bytes memory applicationData,
66
+ ReferralId referralId,
67
+ NftId bundleNftId
68
+ )
69
+ external
70
+ view
71
+ override
72
+ returns (uint256 premiumAmount)
73
+ {
74
+ (premiumAmount,,,,) = _productService.calculatePremium(
75
+ riskId,
76
+ sumInsuredAmount,
77
+ lifetime,
78
+ applicationData,
79
+ bundleNftId,
80
+ referralId
81
+ );
82
+ }
83
+
84
+
85
+ function calculateNetPremium(
86
+ uint256 sumInsuredAmount,
87
+ RiskId riskId,
88
+ uint256 lifetime,
89
+ bytes memory applicationData
90
+ )
91
+ external
92
+ view
93
+ virtual override
94
+ returns (uint256 netPremiumAmount)
95
+ {
96
+ // default 10% of sum insured
97
+ return sumInsuredAmount / 10;
98
+ }
99
+
100
+ function _toRiskId(string memory riskName) internal pure returns (RiskId riskId) {
101
+ return RiskIdLib.toRiskId(riskName);
102
+ }
103
+
104
+ function _createRisk(
105
+ RiskId id,
106
+ bytes memory data
107
+ ) internal {
108
+ _productService.createRisk(
109
+ id,
110
+ data
111
+ );
112
+ }
113
+
114
+ function _setRiskInfo(
115
+ RiskId id,
116
+ IRisk.RiskInfo memory info
117
+ ) internal {
118
+ _productService.setRiskInfo(
119
+ id,
120
+ info
121
+ );
122
+ }
123
+
124
+ function _updateRiskState(
125
+ RiskId id,
126
+ StateId state
127
+ ) internal {
128
+ _productService.updateRiskState(
129
+ id,
130
+ state
131
+ );
132
+ }
133
+
134
+ function _getRiskInfo(RiskId id) internal view returns (IRisk.RiskInfo memory info) {
135
+ return _instance.getRiskInfo(id);
20
136
  }
21
137
 
22
138
  function _createApplication(
23
139
  address applicationOwner,
140
+ RiskId riskId,
24
141
  uint256 sumInsuredAmount,
25
- uint256 premiumAmount,
26
142
  uint256 lifetime,
27
- NftId bundleNftId
143
+ bytes memory applicationData,
144
+ NftId bundleNftId,
145
+ ReferralId referralId
28
146
  ) internal returns (NftId nftId) {
29
147
  nftId = _productService.createApplication(
30
148
  applicationOwner,
149
+ riskId,
31
150
  sumInsuredAmount,
32
- premiumAmount,
33
151
  lifetime,
34
- bundleNftId
152
+ applicationData,
153
+ bundleNftId,
154
+ referralId
35
155
  );
36
156
  }
37
157
 
38
- function _underwrite(NftId nftId) internal {
39
- _productService.underwrite(nftId);
158
+ function _underwrite(
159
+ NftId policyNftId,
160
+ bool requirePremiumPayment,
161
+ Timestamp activateAt
162
+ )
163
+ internal
164
+ {
165
+ _productService.underwrite(
166
+ policyNftId,
167
+ requirePremiumPayment,
168
+ activateAt);
169
+ }
170
+
171
+ function _collectPremium(
172
+ NftId policyNftId,
173
+ Timestamp activateAt
174
+ )
175
+ internal
176
+ {
177
+ _productService.collectPremium(
178
+ policyNftId,
179
+ activateAt);
180
+ }
181
+
182
+ function _activate(
183
+ NftId policyNftId,
184
+ Timestamp activateAt
185
+ )
186
+ internal
187
+ {
188
+ _productService.activate(
189
+ policyNftId,
190
+ activateAt);
40
191
  }
41
192
 
42
193
  function getPoolNftId() external view override returns (NftId poolNftId) {
43
- return _registry.getNftId(_pool);
194
+ return getRegistry().getNftId(address(_pool));
195
+ }
196
+
197
+ function getDistributionNftId() external view override returns (NftId distributionNftId) {
198
+ return getRegistry().getNftId(_distribution);
199
+ }
200
+
201
+ // from product component
202
+ function setFees(
203
+ Fee memory productFee,
204
+ Fee memory processingFee
205
+ )
206
+ external
207
+ onlyOwner
208
+ override
209
+ {
210
+ _productService.setFees(productFee, processingFee);
211
+ }
212
+
213
+ // TODO delete, call instance intead
214
+ function getProductFee()
215
+ external
216
+ view
217
+ override
218
+ returns (Fee memory productFee)
219
+ {
220
+ NftId productNftId = getNftId();
221
+ if (_instance.hasTreasuryInfo(productNftId)) {
222
+ return _instance.getTreasuryInfo(productNftId).productFee;
223
+ } else {
224
+ return _initialProductFee;
225
+ }
44
226
  }
45
227
 
46
- // from registerable
47
- function getType() public view override returns (uint256) {
48
- return _registry.PRODUCT();
228
+ function getProcessingFee()
229
+ external
230
+ view
231
+ override
232
+ returns (Fee memory processingFee)
233
+ {
234
+ NftId productNftId = getNftId();
235
+ if (_instance.hasTreasuryInfo(productNftId)) {
236
+ return _instance.getTreasuryInfo(productNftId).processingFee;
237
+ } else {
238
+ return _initialProcessingFee;
239
+ }
49
240
  }
50
241
 
51
- // from registerable
52
- function getData() external view override returns (bytes memory data) {
53
- return bytes(abi.encode(getInstance().getNftId()));
242
+ // from IRegisterable
243
+
244
+ // TODO used only once, occupies space
245
+ function getInitialInfo()
246
+ public
247
+ view
248
+ override (IRegisterable, Registerable)
249
+ returns (IRegistry.ObjectInfo memory, bytes memory)
250
+ {
251
+ // from Registerable
252
+ (
253
+ IRegistry.ObjectInfo memory productInfo,
254
+ bytes memory data
255
+ ) = super.getInitialInfo();
256
+
257
+ // TODO read pool & distribution fees
258
+ // 1) from pool -> the only option -> pool must be registered first?
259
+ // 2) from instance -> all fees are set into instance at product registration which is ongoing here
260
+ // checks are done in registryProduct() where THIS function is called
261
+ //require(getRegistry().getObjectInfo(_poolNftId).objectType == POOL(), "POOL_NOT_REGISTERED");
262
+ //require(getRegistry().getObjectInfo(_distributionNftId).objectType == DISTRIBUTION(), "DISTRIBUTION_NOT_REGISTERED");
263
+
264
+ // from PoolComponent
265
+ (
266
+ IRegistry.ObjectInfo memory poolInfo,
267
+ bytes memory poolData
268
+ ) = _pool.getInitialInfo();
269
+
270
+ (
271
+ /*IPool.PoolInfo memory info*/,
272
+ /*address wallet*/,
273
+ /*IERC20Metadata token*/,
274
+ Fee memory initialPoolFee,
275
+ Fee memory initialStakingFee,
276
+ Fee memory initialPerformanceFee
277
+ ) = abi.decode(poolData, (IPool.PoolInfo, address, IERC20Metadata, Fee, Fee, Fee));
278
+
279
+ // TODO from DistributionComponent
280
+
281
+ return (
282
+ productInfo,
283
+ abi.encode(
284
+ ITreasury.TreasuryInfo(
285
+ _poolNftId,
286
+ _distributionNftId,
287
+ _token,
288
+ _initialProductFee,
289
+ _initialProcessingFee,
290
+ initialPoolFee,
291
+ initialStakingFee,
292
+ initialPerformanceFee,
293
+ FeeLib.zeroFee()//_instance.getDistributionFee(_distributionNftId)
294
+ ),
295
+ _wallet
296
+ )
297
+ );
54
298
  }
55
299
  }
@@ -0,0 +1,27 @@
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
+
7
+ contract LifeCycleModule {
8
+ mapping(ObjectType objectType => StateId initialState)
9
+ private _initialState;
10
+
11
+ mapping(ObjectType objectType => mapping(StateId stateFrom => mapping(StateId stateTo => bool isValid)))
12
+ private _isValidTransition;
13
+
14
+ function getInitialState(
15
+ ObjectType objectType
16
+ ) external view returns (StateId) {
17
+ return _initialState[objectType];
18
+ }
19
+
20
+ function isValidTransition(
21
+ ObjectType objectType,
22
+ StateId fromId,
23
+ StateId toId
24
+ ) external view returns (bool) {
25
+ return _isValidTransition[objectType][fromId][toId];
26
+ }
27
+ }
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {StateId} from "../../types/StateId.sol";
5
+
6
+ interface ISMEE {
7
+ error ErrorInitialStateUndefined();
8
+ error ErrorStartStateUndefined();
9
+ error ErrorNextStateUndefined();
10
+ error ErrorStateChangeInvalid(StateId currentStateId, StateId newStateId);
11
+
12
+ event LogInitialStateSet(StateId initialStateId);
13
+ event LogStateChanged(StateId oldStateId, StateId newStateId);
14
+ }
15
+
16
+ interface ISM is ISMEE {
17
+ function changeToState(StateId newStateId) external;
18
+
19
+ function isValidTransition(
20
+ StateId currentStateId,
21
+ StateId newStateId
22
+ ) external view returns (bool isValid);
23
+
24
+ function getState() external view returns (StateId currentStateId);
25
+ }
@@ -0,0 +1,57 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {StateId, toStateId, zeroStateId} from "../../types/StateId.sol";
5
+ import {ISM} from "./ISM.sol";
6
+
7
+ contract SM is ISM {
8
+ mapping(StateId currentState => mapping(StateId newState => bool isValid))
9
+ private _isValidTransition;
10
+
11
+ StateId internal _state;
12
+
13
+ function setInitialState(StateId initialStateId) internal {
14
+ if (initialStateId == zeroStateId()) {
15
+ revert ErrorInitialStateUndefined();
16
+ }
17
+
18
+ _state = initialStateId;
19
+ }
20
+
21
+ function addTransition(
22
+ StateId currentStateId,
23
+ StateId nextStateId
24
+ ) internal {
25
+ if (currentStateId == zeroStateId()) {
26
+ revert ErrorStartStateUndefined();
27
+ }
28
+
29
+ if (nextStateId == zeroStateId()) {
30
+ revert ErrorNextStateUndefined();
31
+ }
32
+
33
+ _isValidTransition[currentStateId][nextStateId] = true;
34
+ }
35
+
36
+ function changeToState(StateId newStateId) external override {
37
+ if (!_isValidTransition[_state][newStateId]) {
38
+ revert ErrorStateChangeInvalid(_state, newStateId);
39
+ }
40
+
41
+ StateId stateOld = _state;
42
+ _state = newStateId;
43
+
44
+ emit LogStateChanged(stateOld, _state);
45
+ }
46
+
47
+ function isValidTransition(
48
+ StateId currentStateId,
49
+ StateId newStateId
50
+ ) external view override returns (bool isValid) {
51
+ return _isValidTransition[currentStateId][newStateId];
52
+ }
53
+
54
+ function getState() external view override returns (StateId state) {
55
+ return _state;
56
+ }
57
+ }
@@ -0,0 +1,31 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {StateId, toStateId} from "../../types/StateId.sol";
5
+ import {SM} from "./SM.sol";
6
+
7
+ contract SimpleStateMachine is SM {
8
+ uint8 public constant STATE_ACTIVE = 10;
9
+ uint8 public constant STATE_PAUSED = 20;
10
+ uint8 public constant STATE_ARCHIVED = 30;
11
+
12
+ constructor() {
13
+ addTransition(ACTIVE(), PAUSED());
14
+ addTransition(PAUSED(), ACTIVE());
15
+ addTransition(PAUSED(), ARCHIVED());
16
+
17
+ setInitialState(ACTIVE());
18
+ }
19
+
20
+ function ACTIVE() public pure returns (StateId stateId) {
21
+ return toStateId(STATE_ACTIVE);
22
+ }
23
+
24
+ function PAUSED() public pure returns (StateId stateId) {
25
+ return toStateId(STATE_PAUSED);
26
+ }
27
+
28
+ function ARCHIVED() public pure returns (StateId stateId) {
29
+ return toStateId(STATE_ARCHIVED);
30
+ }
31
+ }
@@ -1,18 +1,54 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {IRegisterable} from "../registry/IRegistry.sol";
5
- import {IAccessModule} from "./access/IAccess.sol";
6
- import {IComponentModule} from "./component/IComponent.sol";
7
- import {IProductModule} from "./product/IProductService.sol";
8
- import {IPolicyModule} from "./policy/IPolicy.sol";
9
- import {IPoolModule} from "./pool/IPoolModule.sol";
4
+ import {IERC165} from "@openzeppelin5/contracts/utils/introspection/IERC165.sol";
10
5
 
6
+ import {IVersionable} from "../shared/IVersionable.sol";
7
+ import {IRegisterable} from "../shared/IRegisterable.sol";
8
+ import {IOwnable} from "../shared/IOwnable.sol";
9
+ import {RoleId} from "../types/RoleId.sol";
10
+
11
+ import {IAccessModule} from "./module/access/IAccess.sol";
12
+ import {IBundleModule} from "./module/bundle/IBundle.sol";
13
+ import {IDistributionModule} from "./module/distribution/IDistribution.sol";
14
+ import {IComponentModule} from "./module/component/IComponent.sol";
15
+ import {IPolicyModule} from "./module/policy/IPolicy.sol";
16
+ import {IPoolModule} from "./module/pool/IPoolModule.sol";
17
+ import {IRiskModule} from "./module/risk/IRisk.sol";
18
+ import {ITreasuryModule} from "./module/treasury/ITreasury.sol";
19
+
20
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
21
+ import {IRegistry} from "../registry/IRegistryLinked.sol";
22
+
23
+ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
24
+ import {IDistributionService} from "./service/IDistributionService.sol";
25
+ import {IProductService} from "./service/IProductService.sol";
26
+ import {IPoolService} from "./service/IPoolService.sol";
27
+ import {IInstanceBase} from "./base/IInstanceBase.sol";
28
+
29
+ // solhint-disable-next-line no-empty-blocks
11
30
  interface IInstance is
31
+ IERC165,
32
+ IVersionable,
12
33
  IRegisterable,
13
34
  IAccessModule,
14
35
  IPolicyModule,
15
36
  IPoolModule,
37
+ IRiskModule,
38
+ IBundleModule,
16
39
  IComponentModule,
17
- IProductModule
18
- {}
40
+ ITreasuryModule,
41
+ IDistributionModule,
42
+ IInstanceBase
43
+ {
44
+ function getRegistry() external view override (IPolicyModule, IRegisterable) returns (IRegistry registry);
45
+ function getOwner() external view override (IOwnable, IAccessModule) returns(address owner);
46
+
47
+ function getKeyValueStore() external view override (IInstanceBase) returns (IKeyValueStore keyValueStore);
48
+
49
+ function getComponentOwnerService() external view override (IInstanceBase, IComponentModule, IPoolModule, ITreasuryModule) returns(IComponentOwnerService);
50
+ function getDistributionService() external view override returns(IDistributionService);
51
+ function getProductService() external view override (IInstanceBase, IBundleModule, IPolicyModule) returns(IProductService);
52
+ function getPoolService() external view override (IInstanceBase, IBundleModule, IPoolModule) returns(IPoolService);
53
+
54
+ }
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IInstance} from "./IInstance.sol";
5
+
6
+ interface IInstanceLinked {
7
+ function getInstance() external view returns (IInstance instance);
8
+ }
@@ -1,64 +1,85 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {Registerable} from "../registry/Registry.sol";
4
+ import {NftId} from "../types/NftId.sol";
5
+ import {RoleId} from "../types/RoleId.sol";
6
+
7
+ import {InstanceBase} from "./base/InstanceBase.sol";
8
+ import {AccessModule} from "./module/access/Access.sol";
9
+ import {ComponentModule} from "./module/component/ComponentModule.sol";
10
+ import {DistributionModule} from "./module/distribution/DistributionModule.sol";
11
+ import {PolicyModule} from "./module/policy/PolicyModule.sol";
12
+ import {PoolModule} from "./module/pool/PoolModule.sol";
13
+ import {RiskModule} from "./module/risk/RiskModule.sol";
14
+ import {BundleModule} from "./module/bundle/BundleModule.sol";
15
+ import {TreasuryModule} from "./module/treasury/TreasuryModule.sol";
16
+
5
17
  import {IRegistry} from "../registry/IRegistry.sol";
18
+ import {Registerable} from "../shared/Registerable.sol";
19
+ import {IAccessModule} from "./module/access/IAccess.sol";
20
+ import {IBundleModule} from "./module/bundle/IBundle.sol";
21
+ import {IComponentModule} from "./module/component/IComponent.sol";
22
+ import {IPoolModule} from "./module/pool/IPoolModule.sol";
23
+ import {IPolicyModule} from "./module/policy/IPolicy.sol";
24
+ import {IInstanceBase} from "./base/IInstanceBase.sol";
25
+ import {ITreasuryModule} from "./module/treasury/ITreasury.sol";
6
26
 
7
- import {IAccessModule, AccessModule} from "./access/Access.sol";
8
- import {ComponentModule} from "./component/ComponentModule.sol";
9
- import {ProductModule} from "./product/ProductService.sol";
10
- import {PolicyModule} from "./policy/PolicyModule.sol";
11
- import {PoolModule} from "./pool/PoolModule.sol";
27
+ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
28
+ import {IDistributionService} from "./service/IDistributionService.sol";
29
+ import {IProductService} from "./service/IProductService.sol";
30
+ import {IPoolService} from "./service/IPoolService.sol";
12
31
 
13
- import {IInstance} from "./IInstance.sol";
14
- import {NftId, toNftId} from "../types/NftId.sol";
32
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
15
33
 
16
34
  contract Instance is
17
- Registerable,
35
+ InstanceBase,
18
36
  AccessModule,
37
+ BundleModule,
19
38
  ComponentModule,
39
+ DistributionModule,
20
40
  PolicyModule,
21
41
  PoolModule,
22
- ProductModule,
23
- IInstance
42
+ RiskModule,
43
+ TreasuryModule
24
44
  {
25
45
  constructor(
26
46
  address registry,
27
- address componentOwnerService,
28
- address productService
47
+ NftId registryNftId,
48
+ address initialOwner
29
49
  )
30
- Registerable(registry)
50
+ InstanceBase(registry, registryNftId, initialOwner)
31
51
  AccessModule()
32
- ComponentModule(componentOwnerService)
33
- PolicyModule(productService)
34
- ProductModule(productService)
35
- PoolModule(productService)
36
- {}
52
+ BundleModule()
53
+ DistributionModule()
54
+ ComponentModule()
55
+ PolicyModule()
56
+ PoolModule()
57
+ TreasuryModule()
58
+ {
59
+ initializeBundleModule(_keyValueStore);
60
+ initializeComponentModule(_keyValueStore);
61
+ initializeDistributionModule(_keyValueStore);
62
+ initializePolicyModule(_keyValueStore);
63
+ initializePoolModule(_keyValueStore);
64
+ initializeRiskModule(_keyValueStore);
65
+ }
37
66
 
38
- // from registerable
39
- function register() external override returns (NftId nftId) {
67
+ modifier onlyComponentOwnerService() override (ComponentModule, PoolModule, TreasuryModule) {
40
68
  require(
41
- address(_registry) != address(0),
42
- "ERROR:PRD-001:REGISTRY_ZERO"
69
+ msg.sender == address(this.getComponentOwnerService()),
70
+ "ERROR:CMP-001:NOT_REGISTRY_SERVICE"
43
71
  );
44
- return _registry.register(address(this));
72
+ _;
45
73
  }
46
74
 
47
- // from registerable
48
- function getParentNftId() public view override returns (NftId) {
49
- // TODO add self registry and exchange 0 for_registry.getNftId();
50
- // define parent tree for all registerables
51
- // eg 0 <- chain(mainnet) <- global registry <- chain registry <- instance <- component <- policy/bundle
52
- return toNftId(0);
53
- }
75
+ function getRegistry() public view override (Registerable, IPolicyModule) returns (IRegistry registry) { return super.getRegistry(); }
54
76
 
55
- // from registerable
56
- function getType() external view override returns (uint256 objectType) {
57
- return _registry.INSTANCE();
58
- }
77
+ function getKeyValueStore() public view override (InstanceBase) returns (IKeyValueStore keyValueStore) { return super.getKeyValueStore(); }
59
78
 
60
- // from registerable
61
- function getData() external view override returns (bytes memory data) {
62
- return bytes(abi.encode(0));
63
- }
79
+ function getComponentOwnerService() external view override (IInstanceBase, IComponentModule, ITreasuryModule, IPoolModule) returns(IComponentOwnerService service) { return _componentOwnerService; }
80
+ function getDistributionService() external view override (IInstanceBase) returns(IDistributionService service) { return _distributionService; }
81
+ function getProductService() external view override (IBundleModule, IPolicyModule, IInstanceBase) returns(IProductService service) { return _productService; }
82
+ function getPoolService() external view override (IBundleModule, IPoolModule, IInstanceBase) returns(IPoolService service) { return _poolService; }
83
+
84
+ function getOwner() public view override (IAccessModule, Registerable) returns(address owner) { return super.getOwner(); }
64
85
  }