@etherisc/gif-next 0.0.2-ebbe63d → 0.0.2-ecbd488-936

Sign up to get free protection for your applications and to get access to all the features.
Files changed (333) hide show
  1. package/README.md +390 -2
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +327 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +618 -0
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +280 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +152 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +782 -0
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
  17. package/artifacts/contracts/components/Product.sol/Product.json +719 -0
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
  21. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
  22. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
  23. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
  24. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
  25. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
  26. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
  27. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
  28. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +4 -0
  29. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +128 -0
  30. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +4 -0
  31. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +42 -0
  32. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +4 -0
  33. package/artifacts/contracts/experiment/inheritance/B.sol/B.json +76 -0
  34. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +4 -0
  35. package/artifacts/contracts/experiment/inheritance/C.sol/C.json +89 -0
  36. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +4 -0
  37. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +128 -0
  38. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +4 -0
  39. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +37 -0
  40. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +4 -0
  41. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +50 -0
  42. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +4 -0
  43. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +63 -0
  44. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  45. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  46. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  47. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  48. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  49. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  50. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  51. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  52. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  53. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  54. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +4 -0
  55. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +10 -0
  56. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +4 -0
  57. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +10 -0
  58. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +4 -0
  59. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +101 -0
  60. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +4 -0
  61. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +1132 -0
  62. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +4 -0
  63. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +1082 -0
  64. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +4 -0
  65. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1014 -0
  66. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  67. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
  68. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +4 -0
  69. package/artifacts/contracts/instance/Instance.sol/Instance.json +3552 -0
  70. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  71. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +917 -0
  72. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  73. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1388 -0
  74. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  75. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +931 -0
  76. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  77. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +508 -0
  78. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
  79. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +540 -0
  80. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  81. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
  82. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  83. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +429 -0
  84. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  85. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
  86. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  87. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +502 -0
  88. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  89. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  90. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +211 -0
  92. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.json +10 -0
  94. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
  96. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  97. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.json +10 -0
  98. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  99. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.json +10 -0
  100. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  101. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.json +10 -0
  102. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  103. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +10 -0
  104. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
  106. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  107. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +716 -0
  108. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  109. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +444 -0
  110. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
  111. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
  112. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  113. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
  114. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  115. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
  116. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  117. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +739 -0
  118. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  119. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +839 -0
  120. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  121. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +448 -0
  122. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1046 -0
  124. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  125. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +448 -0
  126. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +4 -0
  127. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +771 -0
  128. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +4 -0
  129. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +626 -0
  130. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  131. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +947 -0
  132. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  133. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  134. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +4 -0
  135. package/artifacts/contracts/registry/Registry.sol/Registry.json +809 -0
  136. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  137. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1293 -0
  138. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  139. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +513 -0
  140. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  141. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
  142. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  143. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  144. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  145. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
  146. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  147. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
  148. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  149. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +201 -0
  150. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  151. package/artifacts/contracts/shared/IService.sol/IService.json +421 -0
  152. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  153. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
  154. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  155. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
  156. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  157. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
  158. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  159. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +274 -0
  160. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
  161. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
  162. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  163. package/artifacts/contracts/shared/Service.sol/Service.json +468 -0
  164. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  165. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  166. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  167. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  168. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  169. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
  170. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  171. package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
  172. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  173. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +305 -0
  174. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  175. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
  176. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  177. package/artifacts/contracts/test/TestService.sol/TestService.json +600 -0
  178. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  179. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
  180. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  181. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
  182. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  183. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +286 -0
  184. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  185. package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
  186. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  187. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  188. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  189. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
  190. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +4 -0
  191. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +10 -0
  192. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  193. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  194. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  195. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  196. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  197. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
  198. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +4 -0
  199. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +153 -0
  200. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  201. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
  202. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  203. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  204. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  205. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  206. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  207. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  208. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  209. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  210. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  211. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
  212. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  213. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  214. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
  215. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +249 -0
  216. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  217. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  218. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  219. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
  220. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  221. package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
  222. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  223. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +49 -0
  224. package/contracts/components/BaseComponent.sol +91 -0
  225. package/contracts/components/Distribution.sol +159 -0
  226. package/contracts/components/IBaseComponent.sol +25 -0
  227. package/contracts/components/IDistributionComponent.sol +44 -0
  228. package/contracts/components/IPoolComponent.sol +62 -0
  229. package/contracts/components/IProductComponent.sol +35 -0
  230. package/contracts/components/Pool.sol +242 -0
  231. package/contracts/components/Product.sol +284 -0
  232. package/contracts/experiment/cloning/Cloner.sol +47 -0
  233. package/contracts/experiment/errors/Require.sol +38 -0
  234. package/contracts/experiment/errors/Revert.sol +44 -0
  235. package/contracts/experiment/inheritance/A.sol +53 -0
  236. package/contracts/experiment/inheritance/B.sol +28 -0
  237. package/contracts/experiment/inheritance/C.sol +34 -0
  238. package/contracts/experiment/inheritance/IA.sol +13 -0
  239. package/contracts/experiment/inheritance/IB.sol +10 -0
  240. package/contracts/experiment/inheritance/IC.sol +12 -0
  241. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  242. package/contracts/experiment/statemachine/ISM.sol +25 -0
  243. package/contracts/experiment/statemachine/SM.sol +57 -0
  244. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  245. package/contracts/experiment/types/TypeA.sol +47 -0
  246. package/contracts/experiment/types/TypeB.sol +29 -0
  247. package/contracts/instance/AccessManagedSimple.sol +115 -0
  248. package/contracts/instance/AccessManagerSimple.sol +692 -0
  249. package/contracts/instance/IAccessManagerSimple.sol +391 -0
  250. package/contracts/instance/IInstance.sol +48 -0
  251. package/contracts/instance/IInstanceService.sol +30 -0
  252. package/contracts/instance/Instance.sol +443 -0
  253. package/contracts/instance/InstanceAccessManager.sol +288 -0
  254. package/contracts/instance/InstanceReader.sol +306 -0
  255. package/contracts/instance/InstanceService.sol +195 -0
  256. package/contracts/instance/InstanceServiceManager.sol +57 -0
  257. package/contracts/instance/base/ComponentServiceBase.sol +124 -0
  258. package/contracts/instance/base/IInstanceBase.sol +23 -0
  259. package/contracts/instance/base/IKeyValueStore.sol +49 -0
  260. package/contracts/instance/base/ILifecycle.sol +30 -0
  261. package/contracts/instance/base/KeyValueStore.sol +172 -0
  262. package/contracts/instance/base/Lifecycle.sol +100 -0
  263. package/contracts/instance/module/IAccess.sol +38 -0
  264. package/contracts/instance/module/IBundle.sol +20 -0
  265. package/contracts/instance/module/IDistribution.sol +39 -0
  266. package/contracts/instance/module/IPolicy.sol +45 -0
  267. package/contracts/instance/module/IRisk.sol +11 -0
  268. package/contracts/instance/module/ISetup.sol +44 -0
  269. package/contracts/instance/module/ITreasury.sol +23 -0
  270. package/contracts/instance/service/ComponentOwnerService.sol +317 -0
  271. package/contracts/instance/service/DistributionService.sol +88 -0
  272. package/contracts/instance/service/DistributionServiceManager.sol +54 -0
  273. package/contracts/instance/service/IComponentOwnerService.sol +20 -0
  274. package/contracts/instance/service/IDistributionService.sol +12 -0
  275. package/contracts/instance/service/IPoolService.sol +37 -0
  276. package/contracts/instance/service/IProductService.sol +107 -0
  277. package/contracts/instance/service/PoolService.sol +194 -0
  278. package/contracts/instance/service/PoolServiceManager.sol +54 -0
  279. package/contracts/instance/service/ProductService.sol +543 -0
  280. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  281. package/contracts/registry/ChainNft.sol +202 -0
  282. package/contracts/registry/IRegistry.sol +79 -0
  283. package/contracts/registry/IRegistryService.sol +50 -0
  284. package/contracts/registry/ITransferInterceptor.sol +6 -0
  285. package/contracts/registry/Registry.sol +444 -0
  286. package/contracts/registry/RegistryService.sol +358 -0
  287. package/contracts/registry/RegistryServiceManager.sol +80 -0
  288. package/contracts/registry/TokenRegistry.sol +111 -0
  289. package/contracts/shared/ContractDeployerLib.sol +72 -0
  290. package/contracts/shared/ERC165.sol +25 -0
  291. package/contracts/shared/INftOwnable.sol +22 -0
  292. package/contracts/shared/IRegisterable.sol +17 -0
  293. package/contracts/shared/IService.sol +15 -0
  294. package/contracts/shared/IVersionable.sol +96 -0
  295. package/contracts/shared/NftOwnable.sol +134 -0
  296. package/contracts/shared/ProxyManager.sol +94 -0
  297. package/contracts/shared/Registerable.sol +90 -0
  298. package/contracts/shared/RegisterableUpgradable.sol +16 -0
  299. package/contracts/shared/Service.sol +55 -0
  300. package/contracts/shared/TokenHandler.sol +27 -0
  301. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  302. package/contracts/shared/Versionable.sol +147 -0
  303. package/contracts/test/TestFee.sol +25 -0
  304. package/contracts/test/TestRegisterable.sol +18 -0
  305. package/contracts/test/TestRoleId.sol +14 -0
  306. package/contracts/test/TestService.sol +24 -0
  307. package/contracts/{Dip.sol → test/TestToken.sol} +5 -5
  308. package/contracts/test/TestVersion.sol +44 -0
  309. package/contracts/test/TestVersionable.sol +17 -0
  310. package/contracts/test/Usdc.sol +26 -0
  311. package/contracts/types/AddressSet.sol +58 -0
  312. package/contracts/types/Blocknumber.sol +118 -0
  313. package/contracts/types/ChainId.sol +38 -0
  314. package/contracts/types/DistributorType.sol +55 -0
  315. package/contracts/types/Fee.sol +56 -0
  316. package/contracts/types/Key32.sol +50 -0
  317. package/contracts/types/NftId.sol +72 -0
  318. package/contracts/types/NftIdSet.sol +60 -0
  319. package/contracts/types/NumberId.sol +52 -0
  320. package/contracts/types/ObjectType.sol +152 -0
  321. package/contracts/types/Referral.sol +85 -0
  322. package/contracts/types/RiskId.sol +43 -0
  323. package/contracts/types/RoleId.sol +90 -0
  324. package/contracts/types/StateId.sol +105 -0
  325. package/contracts/types/Timestamp.sol +127 -0
  326. package/contracts/types/UFixed.sol +325 -0
  327. package/contracts/types/Version.sol +107 -0
  328. package/package.json +26 -10
  329. package/artifacts/contracts/Dip.sol/DIP.dbg.json +0 -4
  330. package/artifacts/contracts/Dip.sol/DIP.json +0 -338
  331. package/artifacts/contracts/Lock.sol/Lock.dbg.json +0 -4
  332. package/artifacts/contracts/Lock.sol/Lock.json +0 -74
  333. package/contracts/Lock.sol +0 -34
@@ -0,0 +1,543 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {IRegistry} from "../../registry/IRegistry.sol";
5
+ import {IProductComponent} from "../../components/IProductComponent.sol";
6
+ import {Product} from "../../components/Product.sol";
7
+ import {IPoolComponent} from "../../components/IPoolComponent.sol";
8
+ import {IDistributionComponent} from "../../components/IDistributionComponent.sol";
9
+ import {IInstance} from "../IInstance.sol";
10
+ import {IPolicy} from "../module/IPolicy.sol";
11
+ import {IRisk} from "../module/IRisk.sol";
12
+ import {IBundle} from "../module/IBundle.sol";
13
+ import {IProductService} from "./IProductService.sol";
14
+ import {ITreasury} from "../module/ITreasury.sol";
15
+ import {ISetup} from "../module/ISetup.sol";
16
+
17
+ import {TokenHandler} from "../../shared/TokenHandler.sol";
18
+
19
+ import {IVersionable} from "../../shared/IVersionable.sol";
20
+ import {Versionable} from "../../shared/Versionable.sol";
21
+
22
+ import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
23
+ import {UFixed, UFixedLib} from "../../types/UFixed.sol";
24
+ import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
25
+ import {ObjectType, INSTANCE, PRODUCT, POLICY} from "../../types/ObjectType.sol";
26
+ import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
27
+ import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
28
+ import {Fee, FeeLib} from "../../types/Fee.sol";
29
+ import {ReferralId} from "../../types/Referral.sol";
30
+ import {RiskId} from "../../types/RiskId.sol";
31
+ import {StateId} from "../../types/StateId.sol";
32
+ import {Version, VersionLib} from "../../types/Version.sol";
33
+
34
+ import {IService} from "../../shared/IService.sol";
35
+ import {Service} from "../../shared/Service.sol";
36
+ import {ComponentServiceBase} from "../base/ComponentServiceBase.sol";
37
+ import {IProductService} from "./IProductService.sol";
38
+ import {InstanceReader} from "../InstanceReader.sol";
39
+
40
+ string constant PRODUCT_SERVICE_NAME = "ProductService";
41
+
42
+ // TODO or name this ProtectionService to have Product be something more generic (loan, savings account, ...)
43
+ contract ProductService is ComponentServiceBase, IProductService {
44
+ using NftIdLib for NftId;
45
+
46
+ string public constant NAME = "ProductService";
47
+
48
+ address internal _registryAddress;
49
+
50
+ event LogProductServiceSender(address sender);
51
+
52
+ function _initialize(
53
+ address owner,
54
+ bytes memory data
55
+ )
56
+ internal
57
+ initializer
58
+ virtual override
59
+ {
60
+ address initialOwner = address(0);
61
+ (_registryAddress, initialOwner) = abi.decode(data, (address, address));
62
+
63
+ _initializeService(_registryAddress, owner);
64
+
65
+ _registerInterface(type(IService).interfaceId);
66
+ _registerInterface(type(IProductService).interfaceId);
67
+ }
68
+
69
+
70
+ function getName() public pure override(IService, Service) returns(string memory name) {
71
+ return NAME;
72
+ }
73
+
74
+ function _finalizeComponentRegistration(NftId componentNftId, bytes memory initialObjData, IInstance instance) internal override {
75
+ ISetup.ProductSetupInfo memory initialSetup = abi.decode(
76
+ initialObjData,
77
+ (ISetup.ProductSetupInfo)
78
+ );
79
+ instance.createProductSetup(componentNftId, initialSetup);
80
+ }
81
+
82
+ function setFees(
83
+ Fee memory productFee,
84
+ Fee memory processingFee
85
+ )
86
+ external
87
+ override
88
+ {
89
+ (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
90
+ InstanceReader instanceReader = instance.getInstanceReader();
91
+ NftId productNftId = productInfo.nftId;
92
+
93
+ ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
94
+ productSetupInfo.productFee = productFee;
95
+ productSetupInfo.processingFee = processingFee;
96
+
97
+ instance.updateProductSetup(productNftId, productSetupInfo, KEEP_STATE());
98
+ }
99
+
100
+ // FIXME: this
101
+ function createRisk(
102
+ RiskId riskId,
103
+ bytes memory data
104
+ ) external override {
105
+ (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
106
+ NftId productNftId = productInfo.nftId;
107
+ IRisk.RiskInfo memory riskInfo = IRisk.RiskInfo(productNftId, data);
108
+ instance.createRisk(
109
+ riskId,
110
+ riskInfo
111
+ );
112
+ }
113
+
114
+ function updateRisk(
115
+ RiskId riskId,
116
+ bytes memory data
117
+ ) external {
118
+ (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
119
+ InstanceReader instanceReader = instance.getInstanceReader();
120
+ IRisk.RiskInfo memory riskInfo = instanceReader.getRiskInfo(riskId);
121
+ riskInfo.data = data;
122
+ instance.updateRisk(riskId, riskInfo, KEEP_STATE());
123
+ }
124
+
125
+ function updateRiskState(
126
+ RiskId riskId,
127
+ StateId state
128
+ ) external {
129
+ (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
130
+ instance.updateRiskState(riskId, state);
131
+ }
132
+
133
+ function _getAndVerifyInstanceAndProduct() internal view returns (Product product) {
134
+ IRegistry.ObjectInfo memory productInfo;
135
+ (productInfo,) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
136
+ product = Product(productInfo.objectAddress);
137
+ }
138
+
139
+ function calculatePremium(
140
+ RiskId riskId,
141
+ uint256 sumInsuredAmount,
142
+ uint256 lifetime,
143
+ bytes memory applicationData,
144
+ NftId bundleNftId,
145
+ ReferralId referralId
146
+ )
147
+ public
148
+ view
149
+ override
150
+ returns (
151
+ uint256 premiumAmount,
152
+ uint256 productFeeAmount,
153
+ uint256 poolFeeAmount,
154
+ uint256 bundleFeeAmount,
155
+ uint256 distributionFeeAmount
156
+ )
157
+ {
158
+ Product product = _getAndVerifyInstanceAndProduct();
159
+ uint256 netPremiumAmount = product.calculateNetPremium(
160
+ sumInsuredAmount,
161
+ riskId,
162
+ lifetime,
163
+ applicationData
164
+ );
165
+
166
+ (
167
+ productFeeAmount,
168
+ poolFeeAmount,
169
+ bundleFeeAmount,
170
+ distributionFeeAmount
171
+ ) = _calculateFeeAmounts(
172
+ netPremiumAmount,
173
+ product,
174
+ bundleNftId,
175
+ referralId
176
+ );
177
+
178
+ premiumAmount = netPremiumAmount + productFeeAmount;
179
+ premiumAmount += poolFeeAmount + bundleFeeAmount;
180
+ premiumAmount += distributionFeeAmount;
181
+ }
182
+
183
+ function _calculateFeeAmounts(
184
+ uint256 netPremiumAmount,
185
+ Product product,
186
+ NftId bundleNftId,
187
+ ReferralId referralId
188
+ )
189
+ internal
190
+ view
191
+ returns (
192
+ uint256 productFeeAmount,
193
+ uint256 poolFeeAmount,
194
+ uint256 bundleFeeAmount,
195
+ uint256 distributionFeeAmount
196
+ )
197
+ {
198
+ IInstance instance = product.getInstance();
199
+ // FIXME: this
200
+ // ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(product.getNftId());
201
+ // IBundle.BundleInfo memory bundleInfo = instance.getBundleInfo(bundleNftId);
202
+ // require(bundleInfo.poolNftId == treasuryInfo.poolNftId,"ERROR:PRS-035:BUNDLE_POOL_MISMATCH");
203
+
204
+ // (productFeeAmount,) = FeeLib.calculateFee(treasuryInfo.productFee, netPremiumAmount);
205
+ // (poolFeeAmount,) = FeeLib.calculateFee(treasuryInfo.poolFee, netPremiumAmount);
206
+ // (bundleFeeAmount,) = FeeLib.calculateFee(bundleInfo.fee, netPremiumAmount);
207
+
208
+ // IRegistry.ObjectInfo memory distributionInfo = getRegistry().getObjectInfo(treasuryInfo.distributionNftId);
209
+ // IDistributionComponent distribution = IDistributionComponent(distributionInfo.objectAddress);
210
+ // distributionFeeAmount = distribution.calculateFeeAmount(referralId, netPremiumAmount);
211
+ }
212
+
213
+
214
+ function createApplication(
215
+ address applicationOwner,
216
+ RiskId riskId,
217
+ uint256 sumInsuredAmount,
218
+ uint256 lifetime,
219
+ bytes memory applicationData,
220
+ NftId bundleNftId,
221
+ ReferralId referralId
222
+ ) external override returns (NftId policyNftId) {
223
+ (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
224
+ // TODO add validations (see create bundle in pool service)
225
+
226
+ policyNftId = getRegistryService().registerPolicy(
227
+ IRegistry.ObjectInfo(
228
+ zeroNftId(),
229
+ productInfo.nftId,
230
+ POLICY(),
231
+ false, // intercepting property for policies is defined on product
232
+ address(0),
233
+ applicationOwner,
234
+ ""
235
+ )
236
+ );
237
+
238
+ (uint256 premiumAmount,,,,) = calculatePremium(
239
+ riskId,
240
+ sumInsuredAmount,
241
+ lifetime,
242
+ applicationData,
243
+ bundleNftId,
244
+ referralId
245
+ );
246
+
247
+ // FIXME: this
248
+ // instance.createPolicyInfo(
249
+ // policyNftId,
250
+ // productInfo.nftId,
251
+ // referralId,
252
+ // riskId,
253
+ // sumInsuredAmount,
254
+ // premiumAmount,
255
+ // lifetime,
256
+ // bundleNftId
257
+ // );
258
+
259
+ // TODO add logging
260
+ }
261
+
262
+ function _getAndVerifyUnderwritingSetup(
263
+ IInstance instance,
264
+ IPolicy.PolicyInfo memory policyInfo
265
+ )
266
+ internal
267
+ view
268
+ returns (
269
+ ITreasury.TreasuryInfo memory treasuryInfo,
270
+ NftId bundleNftId,
271
+ IBundle.BundleInfo memory bundleInfo,
272
+ uint256 collateralAmount
273
+ )
274
+ {
275
+ // FIXME: this
276
+ // check match between policy and bundle (via pool)
277
+ // treasuryInfo = instance.getTreasuryInfo(policyInfo.productNftId);
278
+ // bundleNftId = policyInfo.bundleNftId;
279
+ // bundleInfo = instance.getBundleInfo(bundleNftId);
280
+ // require(bundleInfo.poolNftId == treasuryInfo.poolNftId, "POLICY_BUNDLE_MISMATCH");
281
+
282
+ // // calculate required collateral
283
+ // NftId poolNftId = treasuryInfo.poolNftId;
284
+ // ISetup.PoolSetupInfo memory poolInfo = instance.getPoolInfo(poolNftId);
285
+
286
+ // // obtain remaining return values
287
+ // collateralAmount = calculateRequiredCollateral(poolInfo.collateralizationLevel, policyInfo.sumInsuredAmount);
288
+ }
289
+
290
+ function _lockCollateralInBundle(
291
+ IInstance instance,
292
+ NftId bundleNftId,
293
+ IBundle.BundleInfo memory bundleInfo,
294
+ NftId policyNftId,
295
+ uint256 collateralAmount
296
+ )
297
+ internal
298
+ returns (IBundle.BundleInfo memory)
299
+ {
300
+ bundleInfo.lockedAmount += collateralAmount;
301
+ // FIXME: this
302
+ // instance.collateralizePolicy(bundleNftId, policyNftId, collateralAmount);
303
+ return bundleInfo;
304
+ }
305
+
306
+ function _underwriteByPool(
307
+ ITreasury.TreasuryInfo memory treasuryInfo,
308
+ NftId policyNftId,
309
+ IPolicy.PolicyInfo memory policyInfo,
310
+ bytes memory bundleFilter,
311
+ uint256 collateralAmount
312
+ )
313
+ internal
314
+ {
315
+ address poolAddress = getRegistry().getObjectInfo(treasuryInfo.poolNftId).objectAddress;
316
+ IPoolComponent pool = IPoolComponent(poolAddress);
317
+ pool.underwrite(
318
+ policyNftId,
319
+ policyInfo.applicationData,
320
+ bundleFilter,
321
+ collateralAmount);
322
+ }
323
+
324
+
325
+ function revoke(
326
+ NftId policyNftId
327
+ )
328
+ external
329
+ override
330
+ {
331
+ require(false, "ERROR:PRS-234:NOT_YET_IMPLEMENTED");
332
+ }
333
+
334
+
335
+ function underwrite(
336
+ NftId policyNftId,
337
+ bool requirePremiumPayment,
338
+ Timestamp activateAt
339
+ )
340
+ external
341
+ override
342
+ {
343
+ // check caller is registered product
344
+ (
345
+ IRegistry.ObjectInfo memory productInfo,
346
+ IInstance instance
347
+ ) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
348
+
349
+ // check match between policy and calling product
350
+ NftId productNftId = productInfo.nftId;
351
+ // FIXME: this
352
+ // IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
353
+ // require(policyInfo.productNftId == productNftId, "POLICY_PRODUCT_MISMATCH");
354
+ // require(instance.getState(policyNftId.toKey32(POLICY())) == APPLIED(), "ERROR:PRS-021:STATE_NOT_APPLIED");
355
+
356
+ // ITreasury.TreasuryInfo memory treasuryInfo;
357
+ // NftId bundleNftId;
358
+ // IBundle.BundleInfo memory bundleInfo;
359
+ // uint256 collateralAmount;
360
+
361
+ // (
362
+ // treasuryInfo,
363
+ // bundleNftId,
364
+ // bundleInfo,
365
+ // collateralAmount
366
+ // ) = _getAndVerifyUnderwritingSetup(
367
+ // instance,
368
+ // policyInfo
369
+ // );
370
+
371
+ // // lock bundle collateral
372
+ // bundleInfo = _lockCollateralInBundle(
373
+ // instance,
374
+ // bundleNftId,
375
+ // bundleInfo,
376
+ // policyNftId,
377
+ // collateralAmount);
378
+
379
+ // // set policy state to underwritten
380
+ // instance.updatePolicyState(policyNftId, UNDERWRITTEN());
381
+
382
+ // // optional activation of policy
383
+ // if(activateAt > zeroTimestamp()) {
384
+ // policyInfo.activatedAt = activateAt;
385
+ // policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
386
+
387
+ // instance.updatePolicyState(policyNftId, ACTIVE());
388
+ // }
389
+
390
+ // // optional collection of premium
391
+ // if(requirePremiumPayment) {
392
+ // uint256 netPremiumAmount = _processPremiumByTreasury(
393
+ // instance,
394
+ // productInfo.nftId,
395
+ // treasuryInfo,
396
+ // policyNftId,
397
+ // policyInfo.premiumAmount);
398
+
399
+ // policyInfo.premiumPaidAmount += policyInfo.premiumAmount;
400
+ // bundleInfo.balanceAmount += netPremiumAmount;
401
+ // }
402
+
403
+ // instance.setPolicyInfo(policyNftId, policyInfo);
404
+ // instance.setBundleInfo(bundleNftId, bundleInfo);
405
+
406
+ // // involve pool if necessary
407
+ // {
408
+ // NftId poolNftId = treasuryInfo.poolNftId;
409
+ // ISetup.PoolSetupInfo memory poolInfo = instance.getPoolInfo(poolNftId);
410
+
411
+ // if(poolInfo.isVerifying) {
412
+ // _underwriteByPool(
413
+ // treasuryInfo,
414
+ // policyNftId,
415
+ // policyInfo,
416
+ // bundleInfo.filter,
417
+ // collateralAmount
418
+ // );
419
+ // }
420
+ // }
421
+
422
+ // TODO add logging
423
+ }
424
+
425
+ function calculateRequiredCollateral(UFixed collateralizationLevel, uint256 sumInsuredAmount) public pure override returns(uint256 collateralAmount) {
426
+ UFixed sumInsuredUFixed = UFixedLib.toUFixed(sumInsuredAmount);
427
+ UFixed collateralUFixed = collateralizationLevel * sumInsuredUFixed;
428
+ return collateralUFixed.toInt();
429
+ }
430
+
431
+ function collectPremium(NftId policyNftId, Timestamp activateAt) external override {
432
+ // check caller is registered product
433
+ (IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
434
+
435
+ // perform actual token transfers
436
+ // FIXME: this
437
+ // IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
438
+ // ITreasury.TreasuryInfo memory treasuryInfo = instance.getTreasuryInfo(productInfo.nftId);
439
+
440
+ // uint256 premiumAmount = policyInfo.premiumAmount;
441
+ // _processPremiumByTreasury(instance, productInfo.nftId, treasuryInfo, policyNftId, premiumAmount);
442
+
443
+ // // policy level book keeping for premium paid
444
+ // policyInfo.premiumPaidAmount += premiumAmount;
445
+
446
+ // // optional activation of policy
447
+ // if(activateAt > zeroTimestamp()) {
448
+ // require(
449
+ // policyInfo.activatedAt.eqz(),
450
+ // "ERROR:PRS-030:ALREADY_ACTIVATED");
451
+
452
+ // policyInfo.activatedAt = activateAt;
453
+ // policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
454
+
455
+ // instance.updatePolicyState(policyNftId, ACTIVE());
456
+ // }
457
+
458
+ // instance.setPolicyInfo(policyNftId, policyInfo);
459
+
460
+ // TODO add logging
461
+ }
462
+
463
+ // FIXME: this
464
+ function activate(NftId policyNftId, Timestamp activateAt) external override {
465
+ // check caller is registered product
466
+ (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
467
+
468
+ // IPolicy.PolicyInfo memory policyInfo = instance.getPolicyInfo(policyNftId);
469
+
470
+ // require(
471
+ // policyInfo.activatedAt.eqz(),
472
+ // "ERROR:PRS-020:ALREADY_ACTIVATED");
473
+
474
+ // policyInfo.activatedAt = activateAt;
475
+ // policyInfo.expiredAt = activateAt.addSeconds(policyInfo.lifetime);
476
+
477
+ // instance.setPolicyInfo(policyNftId, policyInfo);
478
+ // instance.updatePolicyState(policyNftId, ACTIVE());
479
+
480
+ // TODO add logging
481
+ }
482
+
483
+ function close(
484
+ NftId policyNftId
485
+ ) external override // solhint-disable-next-line no-empty-blocks
486
+ {
487
+
488
+ }
489
+
490
+ function _getPoolNftId(
491
+ IInstance instance,
492
+ NftId productNftId
493
+ )
494
+ internal
495
+ view
496
+ returns (NftId poolNftid)
497
+ {
498
+ // FIXME: this
499
+ // return instance.getTreasuryInfo(productNftId).poolNftId;
500
+ }
501
+
502
+
503
+ function _processPremiumByTreasury(
504
+ IInstance instance,
505
+ NftId productNftId,
506
+ ITreasury.TreasuryInfo memory treasuryInfo,
507
+ NftId policyNftId,
508
+ uint256 premiumAmount
509
+ )
510
+ internal
511
+ returns (uint256 netPremiumAmount)
512
+ {
513
+ // process token transfer(s)
514
+ if(premiumAmount > 0) {
515
+ // FIXME: this
516
+ // TokenHandler tokenHandler = instance.getTokenHandler(productNftId);
517
+ // address policyOwner = getRegistry().ownerOf(policyNftId);
518
+ // address poolWallet = instance.getComponentWallet(treasuryInfo.poolNftId);
519
+ // netPremiumAmount = premiumAmount;
520
+ // Fee memory productFee = treasuryInfo.productFee;
521
+
522
+ // if (FeeLib.feeIsZero(productFee)) {
523
+ // tokenHandler.transfer(
524
+ // policyOwner,
525
+ // poolWallet,
526
+ // premiumAmount
527
+ // );
528
+ // } else {
529
+ // (uint256 feeAmount, uint256 netAmount) = instance.calculateFeeAmount(
530
+ // premiumAmount,
531
+ // productFee
532
+ // );
533
+
534
+ // address productWallet = instance.getComponentWallet(productNftId);
535
+ // tokenHandler.transfer(policyOwner, productWallet, feeAmount);
536
+ // tokenHandler.transfer(policyOwner, poolWallet, netAmount);
537
+ // netPremiumAmount = netAmount;
538
+ // }
539
+ }
540
+
541
+ // TODO add logging
542
+ }
543
+ }
@@ -0,0 +1,54 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IVersionable} from "../../shared/IVersionable.sol";
5
+ import {ProxyManager} from "../../shared/ProxyManager.sol";
6
+ import {ProductService} from "./ProductService.sol";
7
+ import {Registry} from "../../registry/Registry.sol";
8
+ import {RegistryService} from "../../registry/RegistryService.sol";
9
+ import {VersionLib} from "../../types/Version.sol";
10
+
11
+ contract ProductServiceManager is ProxyManager {
12
+
13
+ ProductService private _productService;
14
+
15
+ /// @dev initializes proxy manager with product service implementation
16
+ constructor(
17
+ address registryAddress
18
+ )
19
+ ProxyManager()
20
+ {
21
+ ProductService svc = new ProductService();
22
+ bytes memory data = abi.encode(registryAddress, address(this));
23
+ IVersionable versionable = deploy(
24
+ address(svc),
25
+ data);
26
+
27
+ _productService = ProductService(address(versionable));
28
+
29
+ // Registry registry = Registry(registryAddress);
30
+ // address registryServiceAddress = registry.getServiceAddress("RegistryService", VersionLib.toVersion(3, 0, 0).toMajorPart());
31
+ // RegistryService registryService = RegistryService(registryServiceAddress);
32
+ // TODO this must have a role or own nft to register service
33
+ //registryService.registerService(_productService);
34
+
35
+ // TODO no nft to link yet
36
+ // link ownership of instance service manager ot nft owner of instance service
37
+ //_linkToNftOwnable(
38
+ // address(registryAddress),
39
+ // address(_productService));
40
+
41
+ // implies that after this constructor call only upgrade functionality is available
42
+ _isDeployed = true;
43
+ }
44
+
45
+ //--- view functions ----------------------------------------------------//
46
+ function getProductService()
47
+ external
48
+ view
49
+ returns (ProductService productService)
50
+ {
51
+ return _productService;
52
+ }
53
+
54
+ }