@etherisc/gif-next 0.0.2-96b5b72-170 → 0.0.2-97aac30-275

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 (401) hide show
  1. package/README.md +2 -1
  2. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  3. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +193 -164
  4. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  5. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +114 -321
  6. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  7. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +120 -82
  8. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +72 -108
  10. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  11. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +22 -48
  12. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  13. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  14. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  15. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +25 -6
  16. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  17. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +56 -22
  18. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  19. package/artifacts/contracts/instance/Instance.sol/Instance.json +53 -18
  20. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +4 -0
  21. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +708 -0
  22. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +1 -1
  23. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +132 -28
  24. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  25. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +458 -331
  26. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  27. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +133 -59
  28. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  29. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +110 -32
  30. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  31. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +1103 -308
  32. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +4 -0
  33. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +318 -0
  34. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  35. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +4 -0
  36. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +10 -0
  37. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  38. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +2 -2
  39. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  40. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +8 -116
  41. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  42. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  43. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  44. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  45. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  46. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +4 -0
  47. package/artifacts/contracts/mock/Dip.sol/Dip.json +376 -0
  48. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +4 -0
  49. package/artifacts/contracts/{instance/module/ISetup.sol/ISetup.json → oracle/IOracle.sol/IOracle.json} +2 -2
  50. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +4 -0
  51. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +759 -0
  52. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +4 -0
  53. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +662 -0
  54. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +4 -0
  55. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +1146 -0
  56. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +4 -0
  57. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +997 -0
  58. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +4 -0
  59. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +718 -0
  60. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  61. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +69 -252
  62. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  63. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +105 -55
  64. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  65. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +8 -53
  66. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  67. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +134 -86
  68. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  69. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +121 -133
  70. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  71. package/artifacts/contracts/pool/Pool.sol/Pool.json +239 -92
  72. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  73. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +170 -368
  74. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  75. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +98 -72
  76. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  77. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +69 -153
  78. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  79. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +105 -31
  80. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  81. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +95 -203
  82. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  83. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +118 -56
  84. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  85. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +7 -1
  86. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  87. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +7 -1
  88. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  89. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +81 -25
  90. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  91. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +27 -1
  92. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  93. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +230 -107
  94. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  95. package/artifacts/contracts/product/IProductService.sol/IProductService.json +0 -55
  96. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  97. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +164 -299
  98. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +106 -92
  100. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  101. package/artifacts/contracts/product/PricingService.sol/PricingService.json +139 -160
  102. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  103. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +130 -40
  104. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  105. package/artifacts/contracts/product/Product.sol/Product.json +334 -146
  106. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  107. package/artifacts/contracts/product/ProductService.sol/ProductService.json +29 -214
  108. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  109. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +88 -34
  110. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  111. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  112. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +163 -61
  114. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  115. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +256 -65
  116. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  117. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  118. package/artifacts/contracts/registry/Registry.sol/Registry.json +378 -67
  119. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +4 -0
  120. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +407 -0
  121. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  122. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +272 -68
  123. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  124. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +87 -35
  125. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  126. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +799 -127
  127. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.dbg.json +4 -0
  128. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.json +137 -0
  129. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  130. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +314 -138
  131. package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.dbg.json +4 -0
  132. package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.json +1193 -0
  133. package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.dbg.json +4 -0
  134. package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.json +1715 -0
  135. package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.dbg.json +4 -0
  136. package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.json +1728 -0
  137. package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.dbg.json +4 -0
  138. package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.json +1806 -0
  139. package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.dbg.json +4 -0
  140. package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.json +1824 -0
  141. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  142. package/artifacts/contracts/shared/Component.sol/Component.json +184 -11
  143. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  144. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +908 -49
  145. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +4 -0
  146. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +792 -0
  147. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +4 -0
  148. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +526 -0
  149. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  150. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  151. package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.dbg.json +4 -0
  152. package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.json +1562 -0
  153. package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.dbg.json +4 -0
  154. package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.json +1600 -0
  155. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  156. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +172 -4
  157. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +4 -0
  158. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +867 -0
  159. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  160. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +80 -22
  161. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  162. package/artifacts/contracts/{instance/base → shared}/IKeyValueStore.sol/IKeyValueStore.json +1 -11
  163. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  164. package/artifacts/contracts/{instance/base → shared}/ILifecycle.sol/ILifecycle.json +1 -1
  165. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  166. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +7 -1
  167. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  168. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +21 -3
  169. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  170. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +7 -1
  171. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  172. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  173. package/artifacts/contracts/shared/IService.sol/IService.json +7 -1
  174. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  175. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +4 -0
  176. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.json +39 -0
  177. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  178. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +176 -24
  179. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  180. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +571 -0
  181. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  182. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +194 -0
  183. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.dbg.json +4 -0
  184. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.json +306 -0
  185. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  186. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +13 -7
  187. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  188. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +31 -13
  189. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  190. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +64 -16
  191. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  192. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +21 -7
  193. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  194. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  195. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  196. package/artifacts/contracts/shared/Service.sol/Service.json +7 -1
  197. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  198. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  199. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  200. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  201. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  202. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  203. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1103 -172
  204. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  205. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +497 -49
  206. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +4 -0
  207. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +444 -0
  208. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  209. package/artifacts/contracts/staking/Staking.sol/Staking.json +1247 -56
  210. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  211. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +167 -30
  212. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +4 -0
  213. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +592 -0
  214. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  215. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +605 -78
  216. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  217. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +122 -28
  218. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +4 -0
  219. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +2189 -0
  220. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +4 -0
  221. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +571 -0
  222. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  223. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.json +2 -2
  224. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  225. package/artifacts/contracts/type/Amount.sol/AmountLib.json +68 -4
  226. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  227. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +53 -2
  228. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  229. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
  230. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  231. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
  232. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  233. package/artifacts/contracts/type/Fee.sol/FeeLib.json +34 -34
  234. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  235. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  236. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  237. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +47 -4
  238. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  239. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  240. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  241. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +15 -2
  242. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  243. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
  244. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  245. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +2 -2
  246. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +4 -0
  247. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +204 -0
  248. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  249. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +2 -2
  250. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  251. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +2 -2
  252. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  253. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +76 -2
  254. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  255. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +2 -2
  256. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  257. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +17 -4
  258. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  259. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  260. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  261. package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -2
  262. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  263. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +2 -2
  264. package/contracts/distribution/Distribution.sol +27 -51
  265. package/contracts/distribution/DistributionService.sol +55 -106
  266. package/contracts/distribution/DistributionServiceManager.sol +9 -18
  267. package/contracts/distribution/IDistributionComponent.sol +3 -8
  268. package/contracts/distribution/IDistributionService.sol +2 -8
  269. package/contracts/instance/IInstance.sol +12 -7
  270. package/contracts/instance/IInstanceService.sol +13 -5
  271. package/contracts/instance/Instance.sol +30 -23
  272. package/contracts/instance/InstanceAdmin.sol +331 -0
  273. package/contracts/instance/InstanceAuthorizationsLib.sol +210 -141
  274. package/contracts/instance/InstanceReader.sol +64 -42
  275. package/contracts/instance/InstanceService.sol +141 -87
  276. package/contracts/instance/InstanceServiceManager.sol +10 -20
  277. package/contracts/instance/InstanceStore.sol +125 -55
  278. package/contracts/instance/base/BalanceStore.sol +118 -0
  279. package/contracts/instance/base/ObjectCounter.sol +21 -0
  280. package/contracts/instance/module/IAccess.sol +2 -10
  281. package/contracts/instance/module/IBundle.sol +1 -4
  282. package/contracts/instance/module/IComponents.sol +15 -4
  283. package/contracts/instance/module/IPolicy.sol +8 -2
  284. package/contracts/mock/Dip.sol +26 -0
  285. package/contracts/oracle/IOracle.sol +20 -0
  286. package/contracts/oracle/IOracleComponent.sol +32 -0
  287. package/contracts/oracle/IOracleService.sol +65 -0
  288. package/contracts/oracle/Oracle.sol +145 -0
  289. package/contracts/oracle/OracleService.sol +277 -0
  290. package/contracts/oracle/OracleServiceManager.sol +42 -0
  291. package/contracts/pool/BundleService.sol +63 -149
  292. package/contracts/pool/BundleServiceManager.sol +9 -18
  293. package/contracts/pool/IBundleService.sol +4 -16
  294. package/contracts/pool/IPoolComponent.sol +2 -4
  295. package/contracts/pool/IPoolService.sol +45 -9
  296. package/contracts/pool/Pool.sol +37 -40
  297. package/contracts/pool/PoolService.sol +195 -145
  298. package/contracts/pool/PoolServiceManager.sol +9 -18
  299. package/contracts/product/ApplicationService.sol +111 -43
  300. package/contracts/product/ApplicationServiceManager.sol +9 -6
  301. package/contracts/product/ClaimService.sol +21 -21
  302. package/contracts/product/ClaimServiceManager.sol +9 -6
  303. package/contracts/product/IApplicationService.sol +1 -1
  304. package/contracts/product/IClaimService.sol +7 -1
  305. package/contracts/product/IPolicyService.sol +6 -8
  306. package/contracts/product/IPricingService.sol +3 -1
  307. package/contracts/product/IProductComponent.sol +5 -4
  308. package/contracts/product/IProductService.sol +1 -8
  309. package/contracts/product/PolicyService.sol +226 -127
  310. package/contracts/product/PolicyServiceManager.sol +9 -21
  311. package/contracts/product/PricingService.sol +74 -48
  312. package/contracts/product/PricingServiceManager.sol +9 -18
  313. package/contracts/product/Product.sol +45 -47
  314. package/contracts/product/ProductService.sol +26 -112
  315. package/contracts/product/ProductServiceManager.sol +9 -21
  316. package/contracts/registry/ChainNft.sol +1 -0
  317. package/contracts/registry/IRegistry.sol +38 -24
  318. package/contracts/registry/IRegistryService.sol +31 -31
  319. package/contracts/registry/Registry.sol +176 -105
  320. package/contracts/registry/RegistryAdmin.sol +237 -0
  321. package/contracts/registry/RegistryService.sol +44 -82
  322. package/contracts/registry/RegistryServiceManager.sol +21 -23
  323. package/contracts/registry/ReleaseManager.sol +450 -210
  324. package/contracts/registry/ServiceAuthorizationsLib.sol +173 -0
  325. package/contracts/registry/TokenRegistry.sol +261 -62
  326. package/contracts/shared/AccessManagerCustom.sol +736 -0
  327. package/contracts/shared/AccessManagerExtended.sol +470 -0
  328. package/contracts/shared/AccessManagerExtendedInitializeable.sol +13 -0
  329. package/contracts/shared/AccessManagerExtendedWithDisable.sol +137 -0
  330. package/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol +14 -0
  331. package/contracts/shared/Component.sol +153 -49
  332. package/contracts/shared/ComponentService.sol +561 -93
  333. package/contracts/shared/ComponentServiceManager.sol +35 -0
  334. package/contracts/shared/ComponentVerifyingService.sol +117 -0
  335. package/contracts/shared/ERC165.sol +1 -1
  336. package/contracts/shared/IAccessManagerExtended.sol +74 -0
  337. package/contracts/shared/IAccessManagerExtendedWithDisable.sol +18 -0
  338. package/contracts/shared/IComponent.sol +20 -8
  339. package/contracts/shared/IComponentService.sol +102 -0
  340. package/contracts/shared/IInstanceLinkedComponent.sol +5 -11
  341. package/contracts/{instance/base → shared}/IKeyValueStore.sol +6 -6
  342. package/contracts/{instance/base → shared}/ILifecycle.sol +3 -3
  343. package/contracts/shared/INftOwnable.sol +1 -1
  344. package/contracts/shared/IPolicyHolder.sol +6 -1
  345. package/contracts/shared/IService.sol +1 -1
  346. package/contracts/shared/InitializableCustom.sol +177 -0
  347. package/contracts/shared/InstanceLinkedComponent.sol +51 -178
  348. package/contracts/{instance/base → shared}/KeyValueStore.sol +30 -72
  349. package/contracts/{instance/base → shared}/Lifecycle.sol +12 -3
  350. package/contracts/shared/NftIdSetManager.sol +65 -0
  351. package/contracts/shared/NftOwnable.sol +2 -13
  352. package/contracts/shared/PolicyHolder.sol +21 -13
  353. package/contracts/shared/ProxyManager.sol +31 -1
  354. package/contracts/shared/Registerable.sol +2 -2
  355. package/contracts/shared/Service.sol +7 -2
  356. package/contracts/staking/IStaking.sol +146 -8
  357. package/contracts/staking/IStakingService.sol +83 -39
  358. package/contracts/staking/StakeManagerLib.sol +179 -0
  359. package/contracts/staking/Staking.sol +503 -17
  360. package/contracts/staking/StakingManager.sol +22 -14
  361. package/contracts/staking/StakingReader.sol +187 -0
  362. package/contracts/staking/StakingService.sol +246 -44
  363. package/contracts/staking/StakingServiceManager.sol +8 -4
  364. package/contracts/staking/StakingStore.sol +572 -0
  365. package/contracts/staking/TargetManagerLib.sol +207 -0
  366. package/contracts/type/AddressSet.sol +1 -1
  367. package/contracts/type/Amount.sol +20 -1
  368. package/contracts/type/Blocknumber.sol +20 -3
  369. package/contracts/type/Fee.sol +17 -16
  370. package/contracts/type/NftId.sol +14 -16
  371. package/contracts/type/NftIdSet.sol +1 -1
  372. package/contracts/type/ObjectType.sol +12 -10
  373. package/contracts/type/Referral.sol +1 -1
  374. package/contracts/type/RequestId.sol +75 -0
  375. package/contracts/type/RiskId.sol +1 -1
  376. package/contracts/type/RoleId.sol +18 -4
  377. package/contracts/type/Seconds.sol +27 -0
  378. package/contracts/type/StateId.sol +27 -2
  379. package/contracts/type/Timestamp.sol +6 -2
  380. package/contracts/type/Version.sol +1 -1
  381. package/package.json +4 -3
  382. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +0 -4
  383. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +0 -1348
  384. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +0 -4
  385. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +0 -4
  386. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +0 -4
  387. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +0 -581
  388. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +0 -4
  389. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +0 -194
  390. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +0 -4
  391. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +0 -4
  392. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +0 -10
  393. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +0 -4
  394. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +0 -285
  395. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  396. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +0 -1206
  397. package/contracts/instance/InstanceAccessManager.sol +0 -543
  398. package/contracts/instance/module/ISetup.sol +0 -33
  399. package/contracts/instance/module/ITreasury.sol +0 -23
  400. package/contracts/registry/RegistryAccessManager.sol +0 -207
  401. package/contracts/shared/AccessManagerUpgradeableInitializeable.sol +0 -13
@@ -1,23 +1,34 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
+ import {Amount, AmountLib} from "../type/Amount.sol";
5
+ import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
6
+ import {Fee, FeeLib} from "../type/Fee.sol";
4
7
  import {IInstanceLinkedComponent} from "./IInstanceLinkedComponent.sol";
5
8
  import {IRegistry} from "../registry/IRegistry.sol";
6
9
  import {IRegistryService} from "../registry/IRegistryService.sol";
7
10
  import {IInstance} from "../instance/IInstance.sol";
8
11
  import {IAccess} from "../instance/module/IAccess.sol";
9
- import {ObjectType, INSTANCE, REGISTRY} from "../type/ObjectType.sol";
10
12
  import {NftId} from "../type/NftId.sol";
11
- import {RoleId} from "../type/RoleId.sol";
13
+ import {ObjectType, REGISTRY, COMPONENT, DISTRIBUTION, INSTANCE, ORACLE, POOL, PRODUCT} from "../type/ObjectType.sol";
14
+ import {RoleId, DISTRIBUTION_OWNER_ROLE, ORACLE_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, POLICY_SERVICE_ROLE, PRODUCT_SERVICE_ROLE} from "../type/RoleId.sol";
15
+ import {KEEP_STATE} from "../type/StateId.sol";
16
+ import {IComponents} from "../instance/module/IComponents.sol";
17
+ import {IComponentService} from "./IComponentService.sol";
18
+ import {IDistributionComponent} from "../distribution/IDistributionComponent.sol";
19
+ import {IInstanceService} from "../instance/IInstanceService.sol";
20
+ import {IPoolComponent} from "../pool/IPoolComponent.sol";
21
+ import {IProductComponent} from "../product/IProductComponent.sol";
22
+ import {InstanceReader} from "../instance/InstanceReader.sol";
23
+ import {InstanceStore} from "../instance/InstanceStore.sol";
24
+ import {TokenHandler} from "./TokenHandler.sol";
12
25
 
13
- import {Service} from "../shared/Service.sol";
14
- import {InstanceService} from "../instance/InstanceService.sol";
15
- import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
16
-
17
- abstract contract ComponentService is
18
- Service
26
+ contract ComponentService is
27
+ ComponentVerifyingService,
28
+ IComponentService
19
29
  {
20
30
 
31
+ error ErrorComponentServiceAlreadyRegistered(address component);
21
32
  error ErrorComponentServiceNotComponent(address component);
22
33
  error ErrorComponentServiceInvalidType(address component, ObjectType requiredType, ObjectType componentType);
23
34
  error ErrorComponentServiceSenderNotOwner(address component, address initialOwner, address sender);
@@ -26,125 +37,582 @@ abstract contract ComponentService is
26
37
  error ErrorComponentServiceSenderNotService(address sender);
27
38
  error ErrorComponentServiceComponentTypeInvalid(address component, ObjectType expectedType, ObjectType foundType);
28
39
 
29
- /// @dev modifier to check if caller is a registered service
30
- modifier onlyService() {
31
- address caller = msg.sender;
32
- if(!getRegistry().isRegisteredService(caller)) {
33
- revert ErrorComponentServiceSenderNotService(caller);
40
+ bool private constant INCREASE = true;
41
+ bool private constant DECREASE = false;
42
+
43
+ IRegistryService private _registryService;
44
+ IInstanceService private _instanceService;
45
+
46
+ function _initialize(
47
+ address owner,
48
+ bytes memory data
49
+ )
50
+ internal
51
+ virtual override
52
+ initializer()
53
+ {
54
+ // TODO check this, might no longer be the way, refactor if necessary
55
+ address registryAddress;
56
+ address initialOwner;
57
+ (registryAddress, initialOwner) = abi.decode(data, (address, address));
58
+
59
+ initializeService(registryAddress, address(0), owner);
60
+
61
+ _registryService = IRegistryService(_getServiceAddress(REGISTRY()));
62
+ _instanceService = IInstanceService(_getServiceAddress(INSTANCE()));
63
+
64
+ registerInterface(type(IComponentService).interfaceId);
65
+ }
66
+
67
+
68
+ function getDomain() public pure virtual override returns(ObjectType) {
69
+ return COMPONENT();
70
+ }
71
+
72
+ //-------- component ----------------------------------------------------//
73
+
74
+ function setWallet(address newWallet) external virtual {
75
+ (NftId componentNftId,, IInstance instance) = _getAndVerifyActiveComponent(COMPONENT());
76
+ IComponents.ComponentInfo memory info = instance.getInstanceReader().getComponentInfo(componentNftId);
77
+ address currentWallet = info.wallet;
78
+
79
+ if (newWallet == address(0)) {
80
+ revert ErrorComponentServiceNewWalletAddressZero();
34
81
  }
35
- _;
82
+
83
+ if (currentWallet == address(0)) {
84
+ revert ErrorComponentServiceWalletAddressZero();
85
+ }
86
+
87
+ if (newWallet == currentWallet) {
88
+ revert ErrorComponentServiceWalletAddressIsSameAsCurrent();
89
+ }
90
+
91
+ info.wallet = newWallet;
92
+ instance.getInstanceStore().updateComponent(componentNftId, info, KEEP_STATE());
93
+ emit LogComponentServiceWalletAddressChanged(componentNftId, currentWallet, newWallet);
94
+ }
95
+
96
+ // TODO implement
97
+ function lock() external virtual {}
98
+
99
+ // TODO implement
100
+ function unlock() external virtual {}
101
+
102
+
103
+ //-------- product ------------------------------------------------------//
104
+
105
+ function registerProduct()
106
+ external
107
+ virtual
108
+ {
109
+ address contractAddress = msg.sender;
110
+ RoleId[] memory roles = new RoleId[](1);
111
+ bytes4[][] memory selectors = new bytes4[][](1);
112
+
113
+ // authorizaion for distribution owner
114
+ roles[0] = PRODUCT_OWNER_ROLE();
115
+ selectors[0] = _createSelectors(IProductComponent.setFees.selector);
116
+
117
+ // register/create component setup
118
+ (
119
+ InstanceReader instanceReader,
120
+ InstanceStore instanceStore,
121
+ NftId productNftId
122
+ ) = _register(
123
+ contractAddress,
124
+ PRODUCT(),
125
+ PRODUCT_OWNER_ROLE(),
126
+ roles,
127
+ selectors);
128
+
129
+ // create product info
130
+ IComponents.ProductInfo memory productInfo = IProductComponent(contractAddress).getInitialProductInfo();
131
+ instanceStore.createProduct(productNftId, productInfo);
132
+
133
+ // link distribution and pool to product
134
+ _linkToProduct(instanceReader, instanceStore, productInfo.distributionNftId, productNftId);
135
+ _linkToProduct(instanceReader, instanceStore, productInfo.poolNftId, productNftId);
36
136
  }
37
137
 
38
- // view functions
39
138
 
40
- function getRegistryService() public view virtual returns (IRegistryService) {
41
- return IRegistryService(_getServiceAddress(REGISTRY()));
139
+ function setProductFees(
140
+ Fee memory productFee, // product fee on net premium
141
+ Fee memory processingFee // product fee on payout amounts
142
+ )
143
+ external
144
+ virtual
145
+ {
146
+ (NftId productNftId,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
147
+ IComponents.ProductInfo memory productInfo = instance.getInstanceReader().getProductInfo(productNftId);
148
+ bool feesChanged = false;
149
+
150
+ // update product fee if required
151
+ if(!FeeLib.eq(productInfo.productFee, productFee)) {
152
+ _logUpdateFee(productNftId, "ProductFee", productInfo.productFee, productFee);
153
+ productInfo.productFee = productFee;
154
+ feesChanged = true;
155
+ }
156
+
157
+ // update processing fee if required
158
+ if(!FeeLib.eq(productInfo.processingFee, processingFee)) {
159
+ _logUpdateFee(productNftId, "ProcessingFee", productInfo.processingFee, processingFee);
160
+ productInfo.processingFee = processingFee;
161
+ feesChanged = true;
162
+ }
163
+
164
+ if(feesChanged) {
165
+ instance.getInstanceStore().updateProduct(productNftId, productInfo, KEEP_STATE());
166
+ emit LogComponentServiceProductFeesUpdated(productNftId);
167
+ }
42
168
  }
43
169
 
44
- function getInstanceService() public view returns (InstanceService) {
45
- return InstanceService(_getServiceAddress(INSTANCE()));
170
+ function increaseProductFees(
171
+ InstanceStore instanceStore,
172
+ NftId productNftId,
173
+ Amount feeAmount
174
+ )
175
+ external
176
+ virtual
177
+ // TODO re-enable once role granting is stable and fixed
178
+ // restricted()
179
+ {
180
+ _changeTargetBalance(INCREASE, instanceStore, productNftId, AmountLib.zero(), feeAmount);
46
181
  }
47
182
 
48
- // internal functions
49
- function _checkComponentForRegistration(
50
- address componentAddress,
51
- ObjectType requiredType,
52
- RoleId requiredRole
183
+
184
+ function decreaseProductFees(InstanceStore instanceStore, NftId productNftId, Amount feeAmount)
185
+ external
186
+ virtual
187
+ // TODO re-enable once role granting is stable and fixed
188
+ // restricted()
189
+ {
190
+ _changeTargetBalance(DECREASE, instanceStore, productNftId, AmountLib.zero(), feeAmount);
191
+ }
192
+
193
+ //-------- distribution -------------------------------------------------//
194
+
195
+ /// @dev registers the sending component as a distribution component
196
+ function registerDistribution()
197
+ external
198
+ virtual
199
+ {
200
+ address contractAddress = msg.sender;
201
+ RoleId[] memory roles = new RoleId[](2);
202
+ bytes4[][] memory selectors = new bytes4[][](2);
203
+
204
+ // authorizaion for distribution owner
205
+ roles[0] = DISTRIBUTION_OWNER_ROLE();
206
+ selectors[0] = _createSelectors(IDistributionComponent.setFees.selector);
207
+
208
+ // authorizaion for product service
209
+ roles[1] = PRODUCT_SERVICE_ROLE();
210
+ selectors[1] = _createSelectors(IDistributionComponent.processRenewal.selector);
211
+
212
+ // register/create component info
213
+ _register(
214
+ contractAddress,
215
+ DISTRIBUTION(),
216
+ DISTRIBUTION_OWNER_ROLE(),
217
+ roles,
218
+ selectors);
219
+ }
220
+
221
+
222
+ function setDistributionFees(
223
+ Fee memory distributionFee, // distribution fee for sales that do not include commissions
224
+ Fee memory minDistributionOwnerFee // min fee required by distribution owner (not including commissions for distributors)
53
225
  )
54
- internal
55
- view
56
- returns (
57
- IInstanceLinkedComponent component,
58
- address owner,
59
- IInstance instance,
60
- NftId instanceNftId
61
- )
226
+ external
227
+ virtual
62
228
  {
63
- // component may only be registerd by initial owner of component
64
- owner = msg.sender;
229
+ (NftId distributionNftId,, IInstance instance) = _getAndVerifyActiveComponent(DISTRIBUTION());
230
+ (NftId productNftId, IComponents.ProductInfo memory productInfo) = _getLinkedProductInfo(
231
+ instance.getInstanceReader(), distributionNftId);
232
+ bool feesChanged = false;
65
233
 
66
- // check this is a component
67
- component = IInstanceLinkedComponent(componentAddress);
68
- if(!component.supportsInterface(type(IInstanceLinkedComponent).interfaceId)) {
69
- revert ErrorComponentServiceNotComponent(componentAddress);
234
+ // update distributino fee if required
235
+ if(!FeeLib.eq(productInfo.distributionFee, distributionFee)) {
236
+ _logUpdateFee(productNftId, "DistributionFee", productInfo.distributionFee, distributionFee);
237
+ productInfo.distributionFee = distributionFee;
238
+ feesChanged = true;
70
239
  }
71
240
 
72
- // check component is of required type
73
- IRegistry.ObjectInfo memory componentInfo = component.getInitialInfo();
74
- if(componentInfo.objectType != requiredType) {
75
- revert ErrorComponentServiceInvalidType(componentAddress, requiredType, componentInfo.objectType);
241
+ // update min distribution owner fee if required
242
+ if(!FeeLib.eq(productInfo.minDistributionOwnerFee, minDistributionOwnerFee)) {
243
+ _logUpdateFee(productNftId, "MinDistributionOwnerFee", productInfo.minDistributionOwnerFee, minDistributionOwnerFee);
244
+ productInfo.minDistributionOwnerFee = minDistributionOwnerFee;
245
+ feesChanged = true;
246
+ }
247
+
248
+ if(feesChanged) {
249
+ instance.getInstanceStore().updateProduct(productNftId, productInfo, KEEP_STATE());
250
+ emit LogComponentServiceDistributionFeesUpdated(distributionNftId);
251
+ }
252
+ }
253
+
254
+ function increaseDistributionBalance(
255
+ InstanceStore instanceStore,
256
+ NftId distributionNftId,
257
+ Amount amount,
258
+ Amount feeAmount
259
+ )
260
+ external
261
+ virtual
262
+ // TODO re-enable once role granting is stable and fixed
263
+ // restricted()
264
+ {
265
+ _changeTargetBalance(INCREASE, instanceStore, distributionNftId, amount, feeAmount);
266
+ }
267
+
268
+
269
+ function decreaseDistributionBalance(
270
+ InstanceStore instanceStore,
271
+ NftId distributionNftId,
272
+ Amount amount,
273
+ Amount feeAmount
274
+ )
275
+ external
276
+ virtual
277
+ // TODO re-enable once role granting is stable and fixed
278
+ // restricted()
279
+ {
280
+ _changeTargetBalance(DECREASE, instanceStore, distributionNftId, amount, feeAmount);
281
+ }
282
+
283
+ //-------- oracle -------------------------------------------------------//
284
+
285
+ function registerOracle()
286
+ external
287
+ virtual
288
+ {
289
+ address contractAddress = msg.sender;
290
+ RoleId[] memory roles = new RoleId[](0);
291
+ bytes4[][] memory selectors = new bytes4[][](0);
292
+
293
+ // register/create component setup
294
+ (
295
+ , // instance reader
296
+ InstanceStore instanceStore,
297
+ NftId componentNftId
298
+ ) = _register(
299
+ contractAddress,
300
+ ORACLE(),
301
+ ORACLE_OWNER_ROLE(),
302
+ roles,
303
+ selectors);
304
+ }
305
+
306
+ //-------- pool ---------------------------------------------------------//
307
+
308
+ function registerPool()
309
+ external
310
+ virtual
311
+ {
312
+ address contractAddress = msg.sender;
313
+ RoleId[] memory roles = new RoleId[](2);
314
+ bytes4[][] memory selectors = new bytes4[][](2);
315
+
316
+ // authorizaion for pool owner
317
+ roles[0] = POOL_OWNER_ROLE();
318
+ selectors[0] = _createSelectors(IPoolComponent.setFees.selector);
319
+
320
+ // authorizaion for product service
321
+ roles[1] = POLICY_SERVICE_ROLE();
322
+ selectors[1] = _createSelectors(IPoolComponent.verifyApplication.selector);
323
+
324
+ // register/create component setup
325
+ (
326
+ , // instance reader
327
+ InstanceStore instanceStore,
328
+ NftId componentNftId
329
+ ) = _register(
330
+ contractAddress,
331
+ POOL(),
332
+ POOL_OWNER_ROLE(),
333
+ roles,
334
+ selectors);
335
+
336
+ // create info
337
+ instanceStore.createPool(
338
+ componentNftId,
339
+ IPoolComponent(contractAddress).getInitialPoolInfo());
340
+ }
341
+
342
+
343
+ function setPoolFees(
344
+ Fee memory poolFee, // pool fee on net premium
345
+ Fee memory stakingFee, // pool fee on staked capital from investor
346
+ Fee memory performanceFee // pool fee on profits from capital investors
347
+ )
348
+ external
349
+ virtual
350
+ {
351
+ (NftId poolNftId,, IInstance instance) = _getAndVerifyActiveComponent(POOL());
352
+ (NftId productNftId, IComponents.ProductInfo memory productInfo) = _getLinkedProductInfo(
353
+ instance.getInstanceReader(), poolNftId);
354
+ bool feesChanged = false;
355
+
356
+ // update pool fee if required
357
+ if(!FeeLib.eq(productInfo.poolFee, poolFee)) {
358
+ _logUpdateFee(productNftId, "PoolFee", productInfo.poolFee, poolFee);
359
+ productInfo.poolFee = poolFee;
360
+ feesChanged = true;
76
361
  }
77
362
 
78
- // check msg.sender is component owner
79
- address initialOwner = componentInfo.initialOwner;
80
- if(owner != initialOwner) {
81
- revert ErrorComponentServiceSenderNotOwner(componentAddress, componentInfo.initialOwner, owner);
363
+ // update staking fee if required
364
+ if(!FeeLib.eq(productInfo.stakingFee, stakingFee)) {
365
+ _logUpdateFee(productNftId, "StakingFee", productInfo.stakingFee, stakingFee);
366
+ productInfo.stakingFee = stakingFee;
367
+ feesChanged = true;
82
368
  }
83
369
 
84
- // check instance has assigned required role to owner
85
- instanceNftId = componentInfo.parentNftId;
86
- instance = _getInstance(instanceNftId);
87
- if(!instance.getInstanceAccessManager().hasRole(requiredRole, owner)) {
88
- revert ErrorComponentServiceExpectedRoleMissing(instanceNftId, requiredRole, owner);
370
+ // update performance fee if required
371
+ if(!FeeLib.eq(productInfo.performanceFee, performanceFee)) {
372
+ _logUpdateFee(productNftId, "PerformanceFee", productInfo.performanceFee, performanceFee);
373
+ productInfo.performanceFee = performanceFee;
374
+ feesChanged = true;
375
+ }
376
+
377
+ if(feesChanged) {
378
+ instance.getInstanceStore().updateProduct(productNftId, productInfo, KEEP_STATE());
379
+ emit LogComponentServicePoolFeesUpdated(poolNftId);
89
380
  }
90
381
  }
91
382
 
92
- // internal view functions
93
- function _getAndVerifyCallingComponentAndInstance(
94
- ObjectType expectedType // assume always of `component` type
383
+ function increasePoolBalance(
384
+ InstanceStore instanceStore,
385
+ NftId poolNftId,
386
+ Amount amount,
387
+ Amount feeAmount
388
+ )
389
+ public
390
+ virtual
391
+ // TODO re-enable once role granting is stable and fixed
392
+ // restricted()
393
+ {
394
+ _changeTargetBalance(INCREASE, instanceStore, poolNftId, amount, feeAmount);
395
+ }
396
+
397
+ function decreasePoolBalance(
398
+ InstanceStore instanceStore,
399
+ NftId poolNftId,
400
+ Amount amount,
401
+ Amount feeAmount
402
+ )
403
+ public
404
+ virtual
405
+ // TODO re-enable once role granting is stable and fixed
406
+ // restricted()
407
+ {
408
+ _changeTargetBalance(DECREASE, instanceStore, poolNftId, amount, feeAmount);
409
+ }
410
+
411
+ //-------- bundle -------------------------------------------------------//
412
+
413
+ function increaseBundleBalance(
414
+ InstanceStore instanceStore,
415
+ NftId bundleNftId,
416
+ Amount amount,
417
+ Amount feeAmount
418
+ )
419
+ external
420
+ virtual
421
+ // TODO re-enable once role granting is stable and fixed
422
+ // restricted()
423
+ {
424
+ _changeTargetBalance(INCREASE, instanceStore, bundleNftId, amount, feeAmount);
425
+ }
426
+
427
+ function decreaseBundleBalance(
428
+ InstanceStore instanceStore,
429
+ NftId bundleNftId,
430
+ Amount amount,
431
+ Amount feeAmount
432
+ )
433
+ external
434
+ virtual
435
+ // TODO re-enable once role granting is stable and fixed
436
+ // restricted()
437
+ {
438
+ _changeTargetBalance(DECREASE, instanceStore, bundleNftId, amount, feeAmount);
439
+ }
440
+
441
+
442
+ //-------- internal functions ------------------------------------------//
443
+
444
+ function _changeTargetBalance(
445
+ bool increase,
446
+ InstanceStore instanceStore,
447
+ NftId targetNftId,
448
+ Amount amount,
449
+ Amount feeAmount
95
450
  )
96
451
  internal
97
- view
98
- returns(
99
- NftId componentNftId,
100
- IRegistry.ObjectInfo memory componentInfo,
101
- IInstance instance
102
- )
452
+ virtual
103
453
  {
104
- componentNftId = getRegistry().getNftId(msg.sender);
105
- (componentInfo, instance) = _getAndVerifyComponentInfoAndInstance(componentNftId, expectedType);
454
+ Amount totalAmount = amount + feeAmount;
106
455
 
107
- // locked component can not call services
108
- if (instance.getInstanceAccessManager().isTargetLocked(componentInfo.objectAddress)) {
109
- revert IAccess.ErrorIAccessTargetLocked(componentInfo.objectAddress);
456
+ if(increase) {
457
+ if(totalAmount.gtz()) { instanceStore.increaseBalance(targetNftId, totalAmount); }
458
+ if(feeAmount.gtz()) { instanceStore.increaseFees(targetNftId, feeAmount); }
459
+ } else {
460
+ if(totalAmount.gtz()) { instanceStore.decreaseBalance(targetNftId, totalAmount); }
461
+ if(feeAmount.gtz()) { instanceStore.decreaseFees(targetNftId, feeAmount); }
110
462
  }
111
463
  }
112
464
 
113
- function _getAndVerifyComponentInfoAndInstance(
114
- NftId componentNftId,
115
- ObjectType expectedType // assume always of `component` type
465
+ /// @dev registers the component represented by the provided address
466
+ function _register(
467
+ address componentAddress, // address of component to register
468
+ ObjectType requiredType, // required type for component for registration
469
+ RoleId requiredRole, // role required for comonent owner for registration
470
+ RoleId[] memory roles, // roles with write access to component
471
+ bytes4[][] memory selectors // authorized functions per role with write access
116
472
  )
117
473
  internal
118
- view
119
- returns(
120
- IRegistry.ObjectInfo memory componentInfo,
121
- IInstance instance
474
+ virtual
475
+ returns (
476
+ InstanceReader instanceReader,
477
+ InstanceStore instanceStore,
478
+ NftId componentNftId
122
479
  )
123
480
  {
124
- componentInfo = getRegistry().getObjectInfo(componentNftId);
125
- if(componentInfo.objectType != expectedType) {
126
- revert ErrorComponentServiceComponentTypeInvalid(
127
- componentInfo.objectAddress,
128
- expectedType,
129
- componentInfo.objectType);
481
+ (
482
+ IInstance instance,
483
+ IInstanceLinkedComponent component,
484
+ address owner
485
+ ) = _getAndVerifyRegisterableComponent(
486
+ componentAddress,
487
+ requiredType,
488
+ requiredRole);
489
+
490
+ // register component with registry
491
+ componentNftId = _registryService.registerComponent(
492
+ component,
493
+ requiredType,
494
+ owner).nftId;
495
+
496
+ component.linkToRegisteredNftId();
497
+
498
+ // save amended component info with instance
499
+ instanceReader = instance.getInstanceReader();
500
+ instanceStore = instance.getInstanceStore();
501
+
502
+ IComponents.ComponentInfo memory componentInfo = component.getComponentInfo();
503
+ componentInfo.tokenHandler = new TokenHandler(address(componentInfo.token));
504
+ instanceStore.createComponent(component.getNftId(), componentInfo);
505
+
506
+ // configure instance authorization
507
+ _instanceService.createComponentTarget(
508
+ instance.getNftId(),
509
+ componentAddress,
510
+ component.getName(),
511
+ selectors,
512
+ roles);
513
+ }
514
+
515
+
516
+ /// @dev link the component info corresponding to the componentNftId to the provided productNftId
517
+ function _linkToProduct(
518
+ InstanceReader instanceReader,
519
+ InstanceStore instanceStore,
520
+ NftId componentNftId,
521
+ NftId productNftId
522
+ )
523
+ internal
524
+ {
525
+ // only link components that are registered
526
+ if(componentNftId.eqz()) {
527
+ return;
130
528
  }
529
+
530
+ IComponents.ComponentInfo memory componentInfo = instanceReader.getComponentInfo(componentNftId);
531
+ componentInfo.productNftId = productNftId;
532
+ instanceStore.updateComponent(componentNftId, componentInfo, KEEP_STATE());
533
+ }
534
+
535
+
536
+ function _logUpdateFee(NftId productNftId, string memory name, Fee memory feeBefore, Fee memory feeAfter)
537
+ internal
538
+ virtual
539
+ {
540
+ emit LogComponentServiceUpdateFee(
541
+ productNftId,
542
+ name,
543
+ feeBefore.fractionalFee,
544
+ feeBefore.fixedFee,
545
+ feeAfter.fractionalFee,
546
+ feeAfter.fixedFee
547
+ );
548
+ }
131
549
 
132
- instance = _getInstance(componentInfo.parentNftId);
550
+
551
+ function _createSelectors(bytes4 selector) internal pure returns (bytes4[] memory selectors) {
552
+ selectors = new bytes4[](1);
553
+ selectors[0] = selector;
133
554
  }
134
- // assume componentNftId is always of `instance` type
135
- function _getInstance(NftId instanceNftId) internal view returns (IInstance) {
136
- return IInstance(
137
- getRegistry().getObjectInfo(
138
- instanceNftId).objectAddress);
555
+
556
+
557
+ function _getLinkedProductInfo(
558
+ InstanceReader instanceReader,
559
+ NftId componentNftId
560
+ )
561
+ internal
562
+ view
563
+ returns(
564
+ NftId productNftId,
565
+ IComponents.ProductInfo memory info
566
+ )
567
+ {
568
+ productNftId = instanceReader.getComponentInfo(componentNftId).productNftId;
569
+ info = instanceReader.getProductInfo(productNftId);
139
570
  }
140
- // assume componentNftId is always of `component` type
141
- /*function _getInstanceForComponent(NftId componentNftId) internal view returns (IInstance) {
142
- NftId instanceNftId = getRegistry().getObjectInfo(componentNftId).parentNftId;
143
- address instanceAddress = getRegistry().getObjectInfo(instanceNftId).objectAddress;
144
- return IInstance(instanceAddress);
145
- }*/
146
571
 
147
- function _getServiceAddress(ObjectType domain) internal view returns (address) {
148
- return getRegistry().getServiceAddress(domain, getVersion().toMajorPart());
572
+
573
+ /// @dev based on the provided component address required type and role returns the component and related instance contract
574
+ /// the function reverts iff:
575
+ /// - the component has already been registered
576
+ /// - the component contract does not support IInstanceLinkedComponent
577
+ /// - the component type does not match with the required type
578
+ /// - the initial component owner misses the required role (with the instance access manager)
579
+ function _getAndVerifyRegisterableComponent(
580
+ address componentAddress,
581
+ ObjectType requiredType,
582
+ RoleId requiredRole
583
+ )
584
+ internal
585
+ view
586
+ returns (
587
+ IInstance instance,
588
+ IInstanceLinkedComponent component,
589
+ address owner
590
+ )
591
+ {
592
+ // check this is a component
593
+ component = IInstanceLinkedComponent(componentAddress);
594
+ if(!component.supportsInterface(type(IInstanceLinkedComponent).interfaceId)) {
595
+ revert ErrorComponentServiceNotComponent(componentAddress);
596
+ }
597
+
598
+ // check component is of required type
599
+ IRegistry.ObjectInfo memory info = component.getInitialInfo();
600
+ if(info.objectType != requiredType) {
601
+ revert ErrorComponentServiceInvalidType(componentAddress, requiredType, info.objectType);
602
+ }
603
+
604
+ // check component has not already been registered
605
+ if (getRegistry().getNftId(componentAddress).gtz()) {
606
+ revert ErrorComponentServiceAlreadyRegistered(componentAddress);
607
+ }
608
+
609
+ // check instance has assigned required role to inital owner
610
+ instance = _getInstance(info.parentNftId);
611
+ owner = info.initialOwner;
612
+
613
+ (bool hasRole,) = instance.getInstanceAccessManager().hasRole(requiredRole.toInt(), owner);
614
+ if(!hasRole) {
615
+ revert ErrorComponentServiceExpectedRoleMissing(info.parentNftId, requiredRole, owner);
616
+ }
149
617
  }
150
618
  }