@etherisc/gif-next 0.0.2-8daf0fe-431 → 0.0.2-8e283ec-993

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 (451) hide show
  1. package/README.md +32 -3
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  3. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +38 -52
  4. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  5. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +2 -2
  6. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  7. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +8 -8
  8. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  10. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +0 -19
  11. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  12. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +1 -1
  13. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  14. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +19 -0
  15. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +1 -1
  16. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +8 -8
  17. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  18. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +23 -4
  19. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  20. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +85 -248
  21. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  22. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +18 -18
  23. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  24. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +43 -222
  25. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  26. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +228 -217
  27. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  28. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +93 -101
  29. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  30. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +43 -37
  31. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  32. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +120 -31
  33. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +4 -0
  34. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +1411 -0
  35. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +4 -0
  36. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +1171 -0
  37. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +4 -0
  38. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +1545 -0
  39. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +4 -0
  40. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +1980 -0
  41. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +4 -0
  42. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +703 -0
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  44. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +6 -6
  45. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  46. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +5 -5
  47. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  48. package/artifacts/contracts/instance/Instance.sol/Instance.json +17 -106
  49. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  50. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +102 -100
  51. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  52. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +31 -31
  53. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  54. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +467 -127
  55. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  56. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +44 -151
  57. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  58. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +61 -81
  59. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  60. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +255 -240
  61. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  62. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
  63. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  66. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +4 -0
  67. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +182 -0
  68. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +4 -0
  69. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +181 -0
  70. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  76. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  77. package/artifacts/contracts/mock/Dip.sol/Dip.json +2 -2
  78. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  79. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +59 -235
  80. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  81. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +21 -21
  82. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  83. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  84. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +30 -37
  85. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  86. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  87. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +27 -219
  88. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  89. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +37 -144
  90. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +60 -80
  92. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  93. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +79 -280
  94. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  95. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +19 -19
  96. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  97. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +407 -174
  98. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +137 -89
  100. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  101. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +205 -1
  102. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  103. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +72 -94
  104. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  105. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +293 -104
  106. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  107. package/artifacts/contracts/pool/Pool.sol/Pool.json +69 -276
  108. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  109. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +396 -253
  110. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  111. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +90 -82
  112. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  113. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +36 -162
  114. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  115. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +57 -89
  116. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  117. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +47 -248
  118. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  119. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +19 -19
  120. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  121. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +212 -181
  122. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  123. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +92 -100
  124. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  125. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +5 -0
  126. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  127. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +120 -6
  128. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  129. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +266 -119
  130. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  131. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +43 -43
  132. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  133. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +47 -63
  134. package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +4 -0
  135. package/artifacts/contracts/product/{IProductService.sol/IProductService.json → IRiskService.sol/IRiskService.json} +2 -2
  136. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  137. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +358 -318
  138. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  139. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +97 -101
  140. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  141. package/artifacts/contracts/product/PricingService.sol/PricingService.json +118 -265
  142. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  143. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +80 -120
  144. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  145. package/artifacts/contracts/product/Product.sol/Product.json +47 -248
  146. package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +4 -0
  147. package/artifacts/contracts/product/RiskService.sol/RiskService.json +588 -0
  148. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +4 -0
  149. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +682 -0
  150. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  151. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +59 -16
  152. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  153. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +276 -9
  154. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  155. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -183
  156. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  157. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  158. package/artifacts/contracts/registry/Registry.sol/Registry.json +495 -67
  159. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  160. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +251 -134
  161. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  162. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +23 -313
  163. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  164. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +52 -72
  165. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +4 -0
  166. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +164 -0
  167. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +4 -0
  168. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +1169 -0
  169. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  170. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +26 -7
  171. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  172. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +4 -4
  173. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  174. package/artifacts/contracts/shared/Component.sol/Component.json +0 -211
  175. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  176. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +247 -161
  177. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  178. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +105 -95
  179. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  180. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +5 -112
  181. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +4 -0
  182. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +92 -0
  183. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  184. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +0 -26
  185. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  186. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +153 -0
  187. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  188. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +19 -37
  189. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  190. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.json +11 -5
  191. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  192. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.json +0 -5
  193. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  194. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  195. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +15 -47
  196. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  197. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  198. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  199. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  200. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +4 -0
  201. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +53 -0
  202. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  203. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +19 -222
  204. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  205. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +15 -89
  206. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  207. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +4 -65
  208. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +4 -0
  209. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +306 -0
  210. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  211. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +6 -57
  212. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  213. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +19 -141
  214. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  215. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +8 -97
  216. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  217. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
  218. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  219. package/artifacts/contracts/shared/Service.sol/Service.json +5 -112
  220. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  221. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +330 -11
  222. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +4 -0
  223. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +108 -0
  224. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  225. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +27 -27
  226. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  227. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  228. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +85 -105
  229. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  230. package/artifacts/contracts/staking/Staking.sol/Staking.json +85 -262
  231. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +4 -0
  232. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +164 -0
  233. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  234. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +77 -88
  235. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  236. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +6 -6
  237. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  238. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +31 -138
  239. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  240. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +56 -76
  241. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  242. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +146 -165
  243. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  244. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +58 -22
  245. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  246. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.json +2 -2
  247. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  248. package/artifacts/contracts/type/Amount.sol/AmountLib.json +37 -8
  249. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  250. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +2 -2
  251. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  252. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +4 -4
  253. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  254. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +4 -4
  255. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  256. package/artifacts/contracts/type/Fee.sol/FeeLib.json +17 -12
  257. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  258. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  259. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  260. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +4 -4
  261. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  262. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  263. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  264. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +2 -2
  265. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  266. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +19 -19
  267. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  268. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +4 -4
  269. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  270. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +4 -4
  271. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  272. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +4 -4
  273. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  274. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +14 -14
  275. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  276. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +50 -2
  277. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  278. package/artifacts/contracts/type/Selector.sol/SelectorLib.json +2 -2
  279. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  280. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
  281. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  282. package/artifacts/contracts/type/StateId.sol/StateIdLib.json +2 -2
  283. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  284. package/artifacts/contracts/type/String.sol/StrLib.json +2 -2
  285. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  286. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +23 -4
  287. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  288. package/artifacts/contracts/type/UFixed.sol/MathLib.json +9 -3
  289. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  290. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +52 -2
  291. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  292. package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -2
  293. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  294. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +21 -2
  295. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +4 -0
  296. package/artifacts/contracts/{shared → upgradeability}/IVersionable.sol/IVersionable.json +1 -1
  297. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  298. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +586 -0
  299. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  300. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  301. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +4 -0
  302. package/artifacts/contracts/{shared → upgradeability}/Versionable.sol/Versionable.json +1 -1
  303. package/contracts/authorization/AccessAdmin.sol +28 -24
  304. package/contracts/authorization/Authorization.sol +5 -2
  305. package/contracts/authorization/IAccessAdmin.sol +0 -1
  306. package/contracts/authorization/IServiceAuthorization.sol +3 -0
  307. package/contracts/authorization/ServiceAuthorization.sol +4 -0
  308. package/contracts/distribution/BasicDistribution.sol +4 -15
  309. package/contracts/distribution/BasicDistributionAuthorization.sol +5 -1
  310. package/contracts/distribution/Distribution.sol +23 -11
  311. package/contracts/distribution/DistributionService.sol +76 -42
  312. package/contracts/distribution/DistributionServiceManager.sol +8 -11
  313. package/contracts/distribution/IDistributionComponent.sol +8 -4
  314. package/contracts/distribution/IDistributionService.sol +18 -2
  315. package/contracts/examples/unpermissioned/SimpleDistribution.sol +50 -0
  316. package/contracts/examples/unpermissioned/SimpleOracle.sol +137 -0
  317. package/contracts/examples/unpermissioned/SimplePool.sol +76 -0
  318. package/contracts/examples/unpermissioned/SimpleProduct.sol +351 -0
  319. package/contracts/instance/{BundleManager.sol → BundleSet.sol} +23 -23
  320. package/contracts/instance/IInstance.sol +11 -34
  321. package/contracts/instance/IInstanceService.sol +5 -5
  322. package/contracts/instance/Instance.sol +13 -38
  323. package/contracts/instance/InstanceAdmin.sol +31 -9
  324. package/contracts/instance/InstanceAuthorizationV3.sol +16 -14
  325. package/contracts/instance/InstanceReader.sol +125 -11
  326. package/contracts/instance/InstanceService.sol +71 -49
  327. package/contracts/instance/InstanceServiceManager.sol +8 -13
  328. package/contracts/instance/InstanceStore.sol +18 -4
  329. package/contracts/instance/base/ObjectLifecycle.sol +111 -0
  330. package/contracts/instance/base/{ObjectManager.sol → ObjectSet.sol} +5 -5
  331. package/contracts/instance/module/IBundle.sol +1 -1
  332. package/contracts/instance/module/IComponents.sol +4 -8
  333. package/contracts/instance/module/IDistribution.sol +0 -1
  334. package/contracts/instance/module/IPolicy.sol +24 -24
  335. package/contracts/mock/Dip.sol +1 -1
  336. package/contracts/oracle/IOracleComponent.sol +2 -1
  337. package/contracts/oracle/Oracle.sol +17 -7
  338. package/contracts/oracle/OracleService.sol +11 -8
  339. package/contracts/oracle/OracleServiceManager.sol +8 -11
  340. package/contracts/pool/BasicPool.sol +7 -5
  341. package/contracts/pool/BasicPoolAuthorization.sol +11 -2
  342. package/contracts/pool/BundleService.sol +197 -55
  343. package/contracts/pool/BundleServiceManager.sol +8 -11
  344. package/contracts/pool/IBundleService.sol +33 -5
  345. package/contracts/pool/IPoolComponent.sol +24 -8
  346. package/contracts/pool/IPoolService.sol +55 -34
  347. package/contracts/pool/Pool.sol +72 -30
  348. package/contracts/pool/PoolService.sol +223 -127
  349. package/contracts/pool/PoolServiceManager.sol +6 -9
  350. package/contracts/product/ApplicationService.sol +62 -65
  351. package/contracts/product/ApplicationServiceManager.sol +6 -6
  352. package/contracts/product/BasicProduct.sol +3 -32
  353. package/contracts/product/BasicProductAuthorization.sol +3 -0
  354. package/contracts/product/ClaimService.sol +243 -112
  355. package/contracts/product/ClaimServiceManager.sol +6 -6
  356. package/contracts/product/IApplicationService.sol +1 -0
  357. package/contracts/product/IClaimService.sol +29 -6
  358. package/contracts/product/IPolicyService.sol +31 -32
  359. package/contracts/product/IPricingService.sol +7 -7
  360. package/contracts/product/IProductComponent.sol +18 -4
  361. package/contracts/product/{IProductService.sol → IRiskService.sol} +1 -1
  362. package/contracts/product/PolicyService.sol +361 -190
  363. package/contracts/product/PolicyServiceManager.sol +6 -9
  364. package/contracts/product/PricingService.sol +46 -46
  365. package/contracts/product/PricingServiceManager.sol +5 -8
  366. package/contracts/product/Product.sol +90 -50
  367. package/contracts/product/{ProductService.sol → RiskService.sol} +13 -41
  368. package/contracts/product/RiskServiceManager.sol +39 -0
  369. package/contracts/registry/ChainNft.sol +65 -32
  370. package/contracts/registry/IRegistry.sol +65 -16
  371. package/contracts/registry/IRegistryService.sol +0 -9
  372. package/contracts/registry/Registry.sol +340 -211
  373. package/contracts/registry/RegistryAdmin.sol +172 -71
  374. package/contracts/registry/RegistryService.sol +59 -66
  375. package/contracts/registry/RegistryServiceManager.sol +4 -4
  376. package/contracts/registry/ReleaseLifecycle.sol +27 -0
  377. package/contracts/registry/{ReleaseManager.sol → ReleaseRegistry.sol} +155 -182
  378. package/contracts/registry/ServiceAuthorizationV3.sol +7 -8
  379. package/contracts/registry/TokenRegistry.sol +2 -2
  380. package/contracts/shared/Component.sol +30 -43
  381. package/contracts/shared/ComponentService.sol +90 -28
  382. package/contracts/shared/ComponentServiceManager.sol +10 -7
  383. package/contracts/shared/ComponentVerifyingService.sol +2 -3
  384. package/contracts/shared/ContractLib.sol +38 -0
  385. package/contracts/shared/IComponent.sol +4 -4
  386. package/contracts/shared/IComponentService.sol +15 -9
  387. package/contracts/shared/IInstanceLinkedComponent.sol +9 -10
  388. package/contracts/shared/IKeyValueStore.sol +1 -0
  389. package/contracts/shared/ILifecycle.sol +1 -2
  390. package/contracts/shared/IPolicyHolder.sol +12 -22
  391. package/contracts/shared/IService.sol +1 -1
  392. package/contracts/shared/{ERC165.sol → InitializableERC165.sol} +3 -3
  393. package/contracts/shared/InstanceLinkedComponent.sol +26 -6
  394. package/contracts/shared/KeyValueStore.sol +6 -2
  395. package/contracts/shared/Lifecycle.sol +16 -69
  396. package/contracts/shared/{NftIdSetManager.sol → NftIdSet.sol} +1 -1
  397. package/contracts/shared/NftOwnable.sol +7 -7
  398. package/contracts/shared/PolicyHolder.sol +17 -57
  399. package/contracts/shared/Registerable.sol +4 -4
  400. package/contracts/shared/RegistryLinked.sol +3 -2
  401. package/contracts/shared/Service.sol +19 -15
  402. package/contracts/shared/TokenHandler.sol +100 -19
  403. package/contracts/shared/TokenHandlerDeployerLib.sol +12 -0
  404. package/contracts/staking/IStaking.sol +3 -3
  405. package/contracts/staking/IStakingService.sol +12 -5
  406. package/contracts/staking/StakeManagerLib.sol +18 -25
  407. package/contracts/staking/Staking.sol +27 -42
  408. package/contracts/staking/StakingLifecycle.sol +23 -0
  409. package/contracts/staking/StakingManager.sol +10 -12
  410. package/contracts/staking/StakingReader.sol +12 -16
  411. package/contracts/staking/StakingService.sol +10 -14
  412. package/contracts/staking/StakingServiceManager.sol +4 -4
  413. package/contracts/staking/StakingStore.sol +15 -23
  414. package/contracts/staking/TargetManagerLib.sol +7 -3
  415. package/contracts/type/Amount.sol +12 -5
  416. package/contracts/type/Blocknumber.sol +7 -1
  417. package/contracts/type/ObjectType.sol +18 -18
  418. package/contracts/type/PayoutId.sol +10 -10
  419. package/contracts/type/Referral.sol +1 -0
  420. package/contracts/type/Seconds.sol +21 -1
  421. package/contracts/type/StateId.sol +1 -0
  422. package/contracts/type/Timestamp.sol +11 -1
  423. package/contracts/type/UFixed.sol +33 -10
  424. package/contracts/type/Version.sol +3 -1
  425. package/contracts/{shared → upgradeability}/ProxyManager.sol +70 -38
  426. package/contracts/{shared → upgradeability}/UpgradableProxyWithAdmin.sol +1 -3
  427. package/contracts/{shared → upgradeability}/Versionable.sol +2 -2
  428. package/package.json +3 -3
  429. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +0 -4
  430. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +0 -703
  431. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +0 -4
  432. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +0 -181
  433. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +0 -4
  434. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +0 -4
  435. package/artifacts/contracts/product/ProductService.sol/ProductService.json +0 -708
  436. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +0 -4
  437. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +0 -702
  438. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +0 -4
  439. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +0 -1140
  440. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +0 -4
  441. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +0 -73
  442. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +0 -4
  443. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.dbg.json +0 -4
  444. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.json +0 -306
  445. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +0 -4
  446. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +0 -617
  447. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +0 -4
  448. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +0 -129
  449. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +0 -4
  450. package/contracts/product/ProductServiceManager.sol +0 -42
  451. /package/contracts/{shared → upgradeability}/IVersionable.sol +0 -0
@@ -0,0 +1,129 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "UpgradableProxyWithAdmin",
4
+ "sourceName": "contracts/upgradeability/UpgradableProxyWithAdmin.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "internalType": "address",
10
+ "name": "implementation",
11
+ "type": "address"
12
+ },
13
+ {
14
+ "internalType": "address",
15
+ "name": "initialProxyAdminOwner",
16
+ "type": "address"
17
+ },
18
+ {
19
+ "internalType": "bytes",
20
+ "name": "data",
21
+ "type": "bytes"
22
+ }
23
+ ],
24
+ "stateMutability": "nonpayable",
25
+ "type": "constructor"
26
+ },
27
+ {
28
+ "inputs": [
29
+ {
30
+ "internalType": "address",
31
+ "name": "target",
32
+ "type": "address"
33
+ }
34
+ ],
35
+ "name": "AddressEmptyCode",
36
+ "type": "error"
37
+ },
38
+ {
39
+ "inputs": [
40
+ {
41
+ "internalType": "address",
42
+ "name": "admin",
43
+ "type": "address"
44
+ }
45
+ ],
46
+ "name": "ERC1967InvalidAdmin",
47
+ "type": "error"
48
+ },
49
+ {
50
+ "inputs": [
51
+ {
52
+ "internalType": "address",
53
+ "name": "implementation",
54
+ "type": "address"
55
+ }
56
+ ],
57
+ "name": "ERC1967InvalidImplementation",
58
+ "type": "error"
59
+ },
60
+ {
61
+ "inputs": [],
62
+ "name": "ERC1967NonPayable",
63
+ "type": "error"
64
+ },
65
+ {
66
+ "inputs": [],
67
+ "name": "FailedInnerCall",
68
+ "type": "error"
69
+ },
70
+ {
71
+ "inputs": [],
72
+ "name": "ProxyDeniedAdminAccess",
73
+ "type": "error"
74
+ },
75
+ {
76
+ "anonymous": false,
77
+ "inputs": [
78
+ {
79
+ "indexed": false,
80
+ "internalType": "address",
81
+ "name": "previousAdmin",
82
+ "type": "address"
83
+ },
84
+ {
85
+ "indexed": false,
86
+ "internalType": "address",
87
+ "name": "newAdmin",
88
+ "type": "address"
89
+ }
90
+ ],
91
+ "name": "AdminChanged",
92
+ "type": "event"
93
+ },
94
+ {
95
+ "anonymous": false,
96
+ "inputs": [
97
+ {
98
+ "indexed": true,
99
+ "internalType": "address",
100
+ "name": "implementation",
101
+ "type": "address"
102
+ }
103
+ ],
104
+ "name": "Upgraded",
105
+ "type": "event"
106
+ },
107
+ {
108
+ "stateMutability": "payable",
109
+ "type": "fallback"
110
+ },
111
+ {
112
+ "inputs": [],
113
+ "name": "getProxyAdmin",
114
+ "outputs": [
115
+ {
116
+ "internalType": "contract ProxyAdmin",
117
+ "name": "",
118
+ "type": "address"
119
+ }
120
+ ],
121
+ "stateMutability": "nonpayable",
122
+ "type": "function"
123
+ }
124
+ ],
125
+ "bytecode": "0x60a060405234801561000f575f80fd5b50604051610e4c380380610e4c83398101604081905261002e9161037c565b828282828161003d828261009e565b50508160405161004c90610340565b6001600160a01b039091168152602001604051809103905ff080158015610075573d5f803e3d5ffd5b506001600160a01b031660805261009361008e60805190565b6100fc565b505050505050610463565b6100a782610169565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156100f0576100eb82826101e7565b505050565b6100f861025a565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61013b5f80516020610e2c833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a16101668161027b565b50565b806001600160a01b03163b5f036101a357604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b60605f80846001600160a01b031684604051610203919061044d565b5f60405180830381855af49150503d805f811461023b576040519150601f19603f3d011682016040523d82523d5f602084013e610240565b606091505b5090925090506102518583836102b8565b95945050505050565b34156102795760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b0381166102a457604051633173bdd160e11b81525f600482015260240161019a565b805f80516020610e2c8339815191526101c6565b6060826102cd576102c882610317565b610310565b81511580156102e457506001600160a01b0384163b155b1561030d57604051639996b31560e01b81526001600160a01b038516600482015260240161019a565b50805b9392505050565b8051156103275780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6104ef8061093d83390190565b80516001600160a01b0381168114610363575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f6060848603121561038e575f80fd5b6103978461034d565b92506103a56020850161034d565b60408501519092506001600160401b038111156103c0575f80fd5b8401601f810186136103d0575f80fd5b80516001600160401b038111156103e9576103e9610368565b604051601f8201601f19908116603f011681016001600160401b038111828210171561041757610417610368565b60405281815282820160200188101561042e575f80fd5b8160208401602083015e5f602083830101528093505050509250925092565b5f82518060208501845e5f920191825250919050565b6080516104bd6104805f395f818160350152607201526104bd5ff3fe60806040526004361061001d575f3560e01c80638b3240a014610027575b610025610070565b005b348015610032575f80fd5b507f00000000000000000000000000000000000000000000000000000000000000006040516001600160a01b03909116815260200160405180910390f35b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100dc575f356001600160e01b03191663278f794360e11b146100d2576040516334ad5dbb60e21b815260040160405180910390fd5b6100da6100e9565b565b6100da610117565b905090565b5f806100f83660048184610365565b81019061010591906103a0565b915091506101138282610127565b5050565b6100da610122610181565b6101b3565b610130826101d1565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561017957610174828261024c565b505050565b6101136102be565b5f6100e47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b365f80375f80365f845af43d5f803e8080156101cd573d5ff35b3d5ffd5b806001600160a01b03163b5f0361020b57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516102689190610471565b5f60405180830381855af49150503d805f81146102a0576040519150601f19603f3d011682016040523d82523d5f602084013e6102a5565b606091505b50915091506102b58583836102dd565b95945050505050565b34156100da5760405163b398979f60e01b815260040160405180910390fd5b6060826102f2576102ed8261033c565b610335565b815115801561030957506001600160a01b0384163b155b1561033257604051639996b31560e01b81526001600160a01b0385166004820152602401610202565b50805b9392505050565b80511561034c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f8085851115610373575f80fd5b8386111561037f575f80fd5b5050820193919092039150565b634e487b7160e01b5f52604160045260245ffd5b5f80604083850312156103b1575f80fd5b82356001600160a01b03811681146103c7575f80fd5b9150602083013567ffffffffffffffff8111156103e2575f80fd5b8301601f810185136103f2575f80fd5b803567ffffffffffffffff81111561040c5761040c61038c565b604051601f8201601f19908116603f0116810167ffffffffffffffff8111828210171561043b5761043b61038c565b604052818152828201602001871015610452575f80fd5b816020840160208301375f602083830101528093505050509250929050565b5f82518060208501845e5f92019182525091905056fea26469706673582212205f12e4d638be8d591db7c67d942f3e9eeb14e9e44f78ba8cddaca37631bdc49764736f6c634300081a0033608060405234801561000f575f80fd5b506040516104ef3803806104ef83398101604081905261002e916100bb565b806001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100658161006c565b50506100e8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f602082840312156100cb575f80fd5b81516001600160a01b03811681146100e1575f80fd5b9392505050565b6103fa806100f55f395ff3fe608060405260043610610049575f3560e01c8063715018a61461004d5780638da5cb5b146100635780639623609d1461008e578063ad3cb1cc146100a1578063f2fde38b146100de575b5f80fd5b348015610058575f80fd5b506100616100fd565b005b34801561006e575f80fd5b505f546040516001600160a01b0390911681526020015b60405180910390f35b61006161009c366004610260565b610110565b3480156100ac575f80fd5b506100d1604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516100859190610365565b3480156100e9575f80fd5b506100616100f836600461037e565b61017b565b6101056101bd565b61010e5f6101e9565b565b6101186101bd565b60405163278f794360e11b81526001600160a01b03841690634f1ef2869034906101489086908690600401610399565b5f604051808303818588803b15801561015f575f80fd5b505af1158015610171573d5f803e3d5ffd5b5050505050505050565b6101836101bd565b6001600160a01b0381166101b157604051631e4fbdf760e01b81525f60048201526024015b60405180910390fd5b6101ba816101e9565b50565b5f546001600160a01b0316331461010e5760405163118cdaa760e01b81523360048201526024016101a8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146101ba575f80fd5b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215610272575f80fd5b833561027d81610238565b9250602084013561028d81610238565b9150604084013567ffffffffffffffff8111156102a8575f80fd5b8401601f810186136102b8575f80fd5b803567ffffffffffffffff8111156102d2576102d261024c565b604051601f8201601f19908116603f0116810167ffffffffffffffff811182821017156103015761030161024c565b604052818152828201602001881015610318575f80fd5b816020840160208301375f602083830101528093505050509250925092565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6103776020830184610337565b9392505050565b5f6020828403121561038e575f80fd5b813561037781610238565b6001600160a01b03831681526040602082018190525f906103bc90830184610337565b94935050505056fea264697066735822122063012ab3c3421087c307802be7295f03bec95db9eea702a4c2db9595befa162464736f6c634300081a0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
126
+ "deployedBytecode": "0x60806040526004361061001d575f3560e01c80638b3240a014610027575b610025610070565b005b348015610032575f80fd5b507f00000000000000000000000000000000000000000000000000000000000000006040516001600160a01b03909116815260200160405180910390f35b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036100dc575f356001600160e01b03191663278f794360e11b146100d2576040516334ad5dbb60e21b815260040160405180910390fd5b6100da6100e9565b565b6100da610117565b905090565b5f806100f83660048184610365565b81019061010591906103a0565b915091506101138282610127565b5050565b6100da610122610181565b6101b3565b610130826101d1565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561017957610174828261024c565b505050565b6101136102be565b5f6100e47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b365f80375f80365f845af43d5f803e8080156101cd573d5ff35b3d5ffd5b806001600160a01b03163b5f0361020b57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516102689190610471565b5f60405180830381855af49150503d805f81146102a0576040519150601f19603f3d011682016040523d82523d5f602084013e6102a5565b606091505b50915091506102b58583836102dd565b95945050505050565b34156100da5760405163b398979f60e01b815260040160405180910390fd5b6060826102f2576102ed8261033c565b610335565b815115801561030957506001600160a01b0384163b155b1561033257604051639996b31560e01b81526001600160a01b0385166004820152602401610202565b50805b9392505050565b80511561034c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f8085851115610373575f80fd5b8386111561037f575f80fd5b5050820193919092039150565b634e487b7160e01b5f52604160045260245ffd5b5f80604083850312156103b1575f80fd5b82356001600160a01b03811681146103c7575f80fd5b9150602083013567ffffffffffffffff8111156103e2575f80fd5b8301601f810185136103f2575f80fd5b803567ffffffffffffffff81111561040c5761040c61038c565b604051601f8201601f19908116603f0116810167ffffffffffffffff8111828210171561043b5761043b61038c565b604052818152828201602001871015610452575f80fd5b816020840160208301375f602083830101528093505050509250929050565b5f82518060208501845e5f92019182525091905056fea26469706673582212205f12e4d638be8d591db7c67d942f3e9eeb14e9e44f78ba8cddaca37631bdc49764736f6c634300081a0033",
127
+ "linkReferences": {},
128
+ "deployedLinkReferences": {}
129
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_format": "hh-sol-dbg-1",
3
+ "buildInfo": "../../../build-info/611214afb9dd0633def7529ada90c109.json"
4
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "_format": "hh-sol-artifact-1",
3
3
  "contractName": "Versionable",
4
- "sourceName": "contracts/shared/Versionable.sol",
4
+ "sourceName": "contracts/upgradeability/Versionable.sol",
5
5
  "abi": [
6
6
  {
7
7
  "inputs": [],
@@ -3,13 +3,15 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
5
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
6
+ import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
6
7
 
7
8
  import {AccessManagerCloneable} from "./AccessManagerCloneable.sol";
9
+ import {ContractLib} from "../shared/ContractLib.sol";
8
10
  import {IAccessAdmin} from "./IAccessAdmin.sol";
9
11
  import {RoleId, RoleIdLib, ADMIN_ROLE, PUBLIC_ROLE} from "../type/RoleId.sol";
10
12
  import {Selector, SelectorLib, SelectorSetLib} from "../type/Selector.sol";
11
13
  import {Str, StrLib} from "../type/String.sol";
12
- import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
14
+ import {TimestampLib} from "../type/Timestamp.sol";
13
15
 
14
16
 
15
17
  /**
@@ -19,6 +21,7 @@ import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
19
21
  */
20
22
  contract AccessAdmin is
21
23
  AccessManagedUpgradeable,
24
+ ReentrancyGuardUpgradeable,
22
25
  IAccessAdmin
23
26
  {
24
27
  using EnumerableSet for EnumerableSet.AddressSet;
@@ -111,7 +114,6 @@ contract AccessAdmin is
111
114
 
112
115
  _setAuthority(address(_authority)); // set authority for oz access managed
113
116
  _createAdminAndPublicRoles();
114
- _disableInitializers();
115
117
  }
116
118
 
117
119
  //--- view functions for roles ------------------------------------------//
@@ -217,17 +219,18 @@ contract AccessAdmin is
217
219
  selector.toBytes4()));
218
220
  }
219
221
 
220
- function isAccessManaged(address target) public view returns (bool) {
221
- if (!_isContract(target)) {
222
- return false;
223
- }
222
+ // TODO cleanup
223
+ // function isAccessManaged(address target) public view returns (bool) {
224
+ // if (!_isContract(target)) {
225
+ // return false;
226
+ // }
224
227
 
225
- (bool success, ) = target.staticcall(
226
- abi.encodeWithSelector(
227
- AccessManagedUpgradeable.authority.selector));
228
+ // (bool success, ) = target.staticcall(
229
+ // abi.encodeWithSelector(
230
+ // AccessManagedUpgradeable.authority.selector));
228
231
 
229
- return success;
230
- }
232
+ // return success;
233
+ // }
231
234
 
232
235
  function canCall(address caller, address target, Selector selector) external virtual view returns (bool can) {
233
236
  (can, ) = _authority.canCall(caller, target, selector.toBytes4());
@@ -347,7 +350,6 @@ contract AccessAdmin is
347
350
  internal
348
351
  {
349
352
  RoleId adminRoleId = RoleIdLib.toRoleId(_authority.ADMIN_ROLE());
350
- FunctionInfo[] memory functions;
351
353
 
352
354
  // setup admin role
353
355
  _createRoleUnchecked(
@@ -522,6 +524,7 @@ contract AccessAdmin is
522
524
  bool custom
523
525
  )
524
526
  internal
527
+ nonReentrant()
525
528
  {
526
529
  // check target does not yet exist
527
530
  if(targetExists(target)) {
@@ -545,7 +548,7 @@ contract AccessAdmin is
545
548
  }
546
549
 
547
550
  // check target is an access managed contract
548
- if (!isAccessManaged(target)) {
551
+ if (!ContractLib.isAccessManaged(target)) {
549
552
  revert ErrorTargetNotAccessManaged(target);
550
553
  }
551
554
 
@@ -573,16 +576,17 @@ contract AccessAdmin is
573
576
  emit LogTargetCreated(target, targetName);
574
577
  }
575
578
 
576
- function _isContract(address target)
577
- internal
578
- view
579
- returns (bool)
580
- {
581
- uint256 size;
582
- assembly {
583
- size := extcodesize(target)
584
- }
585
- return size > 0;
586
- }
579
+ // TODO cleanup
580
+ // function _isContract(address target)
581
+ // internal
582
+ // view
583
+ // returns (bool)
584
+ // {
585
+ // uint256 size;
586
+ // assembly {
587
+ // size := extcodesize(target)
588
+ // }
589
+ // return size > 0;
590
+ // }
587
591
 
588
592
  }
@@ -129,12 +129,15 @@ contract Authorization
129
129
  }
130
130
 
131
131
  function _addComponentTargetWithRole(ObjectType componentType) internal {
132
+ _addComponentTargetWithRole(componentType, 0);
133
+ }
134
+
135
+ function _addComponentTargetWithRole(ObjectType componentType, uint64 index) internal {
132
136
  _addTargetWithRole(
133
137
  getTargetName(),
134
- RoleIdLib.toComponentRoleId(componentType, 0),
138
+ RoleIdLib.toComponentRoleId(componentType, index),
135
139
  _toTargetRoleName(
136
140
  getTargetName()));
137
-
138
141
  }
139
142
 
140
143
  /// @dev Add a contract role for the provided role id and name.
@@ -131,6 +131,5 @@ interface IAccessAdmin is
131
131
 
132
132
  function toRole(RoleId adminRoleId, RoleType roleType, uint32 maxMemberCount, string memory name) external view returns (RoleInfo memory);
133
133
  function toFunction(bytes4 selector, string memory name) external view returns (FunctionInfo memory);
134
- function isAccessManaged(address target) external view returns (bool);
135
134
  function deployer() external view returns (address);
136
135
  }
@@ -19,6 +19,9 @@ interface IServiceAuthorization {
19
19
  view
20
20
  returns(VersionPart release);
21
21
 
22
+ /// @dev Returns the service domain for the provided index.
23
+ function getServiceDomain(uint idx) external view returns(ObjectType serviceDomain);
24
+
22
25
  /// @dev Returns the full list of service domains for this release.
23
26
  /// Services need to be registered for the release in revers order of this list.
24
27
  function getServiceDomains() external view returns(ObjectType[] memory serviceDomains);
@@ -40,6 +40,10 @@ contract ServiceAuthorization
40
40
  return _serviceDomains;
41
41
  }
42
42
 
43
+ function getServiceDomain(uint idx) external view returns(ObjectType serviceDomain) {
44
+ return _serviceDomains[idx];
45
+ }
46
+
43
47
  function getServiceAddress(ObjectType serviceDomain) external view returns(address service) {
44
48
  return _serviceAddress[serviceDomain];
45
49
  }
@@ -1,25 +1,14 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {COMPONENT, DISTRIBUTION} from "../type/ObjectType.sol";
5
4
  import {Distribution} from "./Distribution.sol";
6
5
  import {IAuthorization} from "../authorization/IAuthorization.sol";
7
- import {IDistributionService} from "./IDistributionService.sol";
8
- import {IProductService} from "../product/IProductService.sol";
9
- import {NftId, NftIdLib} from "../type/NftId.sol";
10
- import {ReferralId, ReferralStatus, ReferralLib} from "../type/Referral.sol";
11
- import {Fee, FeeLib} from "../type/Fee.sol";
12
- import {InstanceLinkedComponent} from "../shared/InstanceLinkedComponent.sol";
13
- import {IComponentService} from "../shared/IComponentService.sol";
14
- import {IDistribution} from "../instance/module/IDistribution.sol";
15
- import {IDistributionComponent} from "./IDistributionComponent.sol";
16
- import {IRegistry} from "../registry/IRegistry.sol";
17
- import {TokenHandler} from "../shared/TokenHandler.sol";
18
- import {InstanceReader} from "../instance/InstanceReader.sol";
6
+ import {NftId} from "../type/NftId.sol";
7
+ import {ReferralId} from "../type/Referral.sol";
8
+ import {Fee} from "../type/Fee.sol";
19
9
  import {UFixed} from "../type/UFixed.sol";
20
10
  import {DistributorType} from "../type/DistributorType.sol";
21
- import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
22
- import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
11
+ import {Timestamp} from "../type/Timestamp.sol";
23
12
 
24
13
 
25
14
  contract BasicDistribution is
@@ -3,10 +3,11 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {Authorization} from "../authorization/Authorization.sol";
5
5
  import {BasicDistribution} from "./BasicDistribution.sol";
6
+ import {Distribution} from "./Distribution.sol";
6
7
  import {DISTRIBUTION} from "../type/ObjectType.sol";
7
8
  import {IAccess} from "../authorization/IAccess.sol";
9
+ import {IInstanceLinkedComponent} from "../shared/IInstanceLinkedComponent.sol";
8
10
  import {PUBLIC_ROLE} from "../../contracts/type/RoleId.sol";
9
- import {RoleId} from "../type/RoleId.sol";
10
11
 
11
12
 
12
13
  contract BasicDistributionAuthorization
@@ -38,6 +39,9 @@ contract BasicDistributionAuthorization
38
39
  _authorize(functions, BasicDistribution.createDistributor.selector, "createDistributor");
39
40
  _authorize(functions, BasicDistribution.updateDistributorType.selector, "updateDistributorType");
40
41
  _authorize(functions, BasicDistribution.createReferral.selector, "createReferral");
42
+
43
+ _authorize(functions, IInstanceLinkedComponent.withdrawFees.selector, "withdrawFees");
44
+ _authorize(functions, Distribution.withdrawCommission.selector, "withdrawCommission");
41
45
  }
42
46
  }
43
47
 
@@ -1,24 +1,19 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {Amount} from "../type/Amount.sol";
4
5
  import {COMPONENT, DISTRIBUTION} from "../type/ObjectType.sol";
5
6
  import {IAuthorization} from "../authorization/IAuthorization.sol";
6
7
  import {IDistributionService} from "./IDistributionService.sol";
7
- import {IProductService} from "../product/IProductService.sol";
8
8
  import {NftId, NftIdLib} from "../type/NftId.sol";
9
9
  import {ReferralId, ReferralStatus, ReferralLib} from "../type/Referral.sol";
10
- import {Fee, FeeLib} from "../type/Fee.sol";
10
+ import {Fee} from "../type/Fee.sol";
11
11
  import {InstanceLinkedComponent} from "../shared/InstanceLinkedComponent.sol";
12
12
  import {IComponentService} from "../shared/IComponentService.sol";
13
- import {IDistribution} from "../instance/module/IDistribution.sol";
14
13
  import {IDistributionComponent} from "./IDistributionComponent.sol";
15
- import {IRegistry} from "../registry/IRegistry.sol";
16
- import {TokenHandler} from "../shared/TokenHandler.sol";
17
- import {InstanceReader} from "../instance/InstanceReader.sol";
18
14
  import {UFixed} from "../type/UFixed.sol";
19
15
  import {DistributorType} from "../type/DistributorType.sol";
20
- import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
21
- import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
16
+ import {Timestamp} from "../type/Timestamp.sol";
22
17
 
23
18
 
24
19
  abstract contract Distribution is
@@ -41,13 +36,13 @@ abstract contract Distribution is
41
36
  _;
42
37
  }
43
38
 
44
-
45
39
  function register()
46
40
  external
47
41
  virtual
48
42
  onlyOwner()
49
43
  {
50
44
  _getDistributionStorage()._componentService.registerDistribution();
45
+ _approveTokenHandler(type(uint256).max);
51
46
  }
52
47
 
53
48
 
@@ -127,7 +122,18 @@ abstract contract Distribution is
127
122
  return true;
128
123
  }
129
124
 
130
-
125
+ /// @inheritdoc IDistributionComponent
126
+ function withdrawCommission(NftId distributorNftId, Amount amount)
127
+ external
128
+ virtual
129
+ restricted()
130
+ onlyDistributor()
131
+ onlyNftOwner(distributorNftId)
132
+ returns (Amount withdrawnAmount)
133
+ {
134
+ return _withdrawCommission(distributorNftId, amount);
135
+ }
136
+
131
137
  function _initializeDistribution(
132
138
  address registry,
133
139
  NftId instanceNftId,
@@ -158,7 +164,7 @@ abstract contract Distribution is
158
164
  $._distributionService = IDistributionService(_getServiceAddress(DISTRIBUTION()));
159
165
  $._componentService = IComponentService(_getServiceAddress(COMPONENT()));
160
166
 
161
- registerInterface(type(IDistributionComponent).interfaceId);
167
+ _registerInterface(type(IDistributionComponent).interfaceId);
162
168
  }
163
169
 
164
170
  /// @dev Sets the distribution fees to the provided values.
@@ -266,6 +272,12 @@ abstract contract Distribution is
266
272
  data);
267
273
  }
268
274
 
275
+ function _withdrawCommission(NftId distributorNftId, Amount amount)
276
+ internal
277
+ returns (Amount withdrawnAmount)
278
+ {
279
+ return _getDistributionStorage()._distributionService.withdrawCommission(distributorNftId, amount);
280
+ }
269
281
 
270
282
  function _nftTransferFrom(address from, address to, uint256 tokenId) internal virtual override {
271
283
  // keep track of distributor nft owner
@@ -12,29 +12,14 @@ import {IPolicy} from "../instance/module/IPolicy.sol";
12
12
 
13
13
  import {Amount, AmountLib} from "../type/Amount.sol";
14
14
  import {NftId, NftIdLib} from "../type/NftId.sol";
15
- import {Fee, FeeLib} from "../type/Fee.sol";
16
15
  import {KEEP_STATE} from "../type/StateId.sol";
17
16
  import {ObjectType, COMPONENT, DISTRIBUTION, INSTANCE, DISTRIBUTION, DISTRIBUTOR, REGISTRY} from "../type/ObjectType.sol";
18
- import {Version, VersionLib} from "../type/Version.sol";
19
- import {RoleId} from "../type/RoleId.sol";
20
-
21
- import {IVersionable} from "../shared/IVersionable.sol";
22
- import {Versionable} from "../shared/Versionable.sol";
23
-
24
- import {IService} from "../shared/IService.sol";
25
- import {Service} from "../shared/Service.sol";
26
17
  import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
27
- import {InstanceService} from "../instance/InstanceService.sol";
28
- import {IComponent} from "../shared/IComponent.sol";
29
- import {IDistributionComponent} from "../distribution/IDistributionComponent.sol";
30
18
  import {IDistributionService} from "./IDistributionService.sol";
31
- import {IPricingService} from "../product/IPricingService.sol";
32
-
33
- import {UFixed, UFixedLib} from "../type/UFixed.sol";
19
+ import {UFixed} from "../type/UFixed.sol";
34
20
  import {DistributorType, DistributorTypeLib} from "../type/DistributorType.sol";
35
- import {ReferralId, ReferralStatus, ReferralLib} from "../type/Referral.sol";
36
- import {Timestamp, TimestampLib, zeroTimestamp} from "../type/Timestamp.sol";
37
- import {Key32} from "../type/Key32.sol";
21
+ import {ReferralId, ReferralLib} from "../type/Referral.sol";
22
+ import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
38
23
  import {IDistribution} from "../instance/module/IDistribution.sol";
39
24
  import {InstanceStore} from "../instance/InstanceStore.sol";
40
25
 
@@ -43,12 +28,6 @@ contract DistributionService is
43
28
  ComponentVerifyingService,
44
29
  IDistributionService
45
30
  {
46
- using NftIdLib for NftId;
47
- using TimestampLib for Timestamp;
48
- using UFixedLib for UFixed;
49
- using FeeLib for Fee;
50
- using ReferralLib for ReferralId;
51
-
52
31
  IComponentService private _componentService;
53
32
  IInstanceService private _instanceService;
54
33
  IRegistryService private _registryService;
@@ -58,21 +37,21 @@ contract DistributionService is
58
37
  bytes memory data
59
38
  )
60
39
  internal
61
- initializer
62
40
  virtual override
41
+ initializer()
63
42
  {
64
- address initialOwner;
65
- address registryAddress;
66
- (registryAddress, initialOwner) = abi.decode(data, (address, address));
67
- // TODO while DistributionService is not deployed in DistributionServiceManager constructor
68
- // owner is DistributionServiceManager deployer
69
- initializeService(registryAddress, address(0), owner);
43
+ (
44
+ address registryAddress,
45
+ address authority
46
+ ) = abi.decode(data, (address, address));
47
+
48
+ _initializeService(registryAddress, authority, owner);
70
49
 
71
50
  _componentService = IComponentService(_getServiceAddress(COMPONENT()));
72
51
  _instanceService = IInstanceService(_getServiceAddress(INSTANCE()));
73
52
  _registryService = IRegistryService(_getServiceAddress(REGISTRY()));
74
53
 
75
- registerInterface(type(IDistributionService).interfaceId);
54
+ _registerInterface(type(IDistributionService).interfaceId);
76
55
  }
77
56
 
78
57
 
@@ -152,7 +131,6 @@ contract DistributionService is
152
131
  distributorType,
153
132
  true, // active
154
133
  data,
155
- AmountLib.zero(),
156
134
  0);
157
135
 
158
136
  instance.getInstanceStore().createDistributor(distributorNftId, info);
@@ -228,11 +206,28 @@ contract DistributionService is
228
206
  return referralId;
229
207
  }
230
208
 
209
+ /// @inheritdoc IDistributionService
210
+ function processReferral(
211
+ NftId distributionNftId,
212
+ ReferralId referralId
213
+ )
214
+ external
215
+ virtual
216
+ restricted
217
+ {
218
+ if (referralIsValid(distributionNftId, referralId)) {
219
+ IInstance instance = _getInstanceForDistribution(distributionNftId);
220
+ // update book keeping for referral info
221
+ IDistribution.ReferralInfo memory referralInfo = instance.getInstanceReader().getReferralInfo(referralId);
222
+ referralInfo.usedReferrals += 1;
223
+ instance.getInstanceStore().updateReferral(referralId, referralInfo, KEEP_STATE());
224
+ }
225
+ }
231
226
 
232
227
  function processSale(
233
228
  NftId distributionNftId, // assume always of distribution type
234
229
  ReferralId referralId,
235
- IPolicy.Premium memory premium
230
+ IPolicy.PremiumInfo memory premium
236
231
  )
237
232
  external
238
233
  virtual
@@ -243,33 +238,72 @@ contract DistributionService is
243
238
  InstanceStore store = instance.getInstanceStore();
244
239
 
245
240
  // get distribution owner fee amount
246
- Amount distributionOwnerFee = AmountLib.toAmount(premium.distributionOwnerFeeFixAmount + premium.distributionOwnerFeeVarAmount);
241
+ Amount distributionOwnerFee = premium.distributionOwnerFeeFixAmount + premium.distributionOwnerFeeVarAmount;
247
242
 
248
243
  // update referral/distributor info if applicable
249
244
  if (referralIsValid(distributionNftId, referralId)) {
250
245
 
251
246
  // increase distribution balance by commission amount and distribution owner fee
252
- Amount commissionAmount = AmountLib.toAmount(premium.commissionAmount);
247
+ Amount commissionAmount = premium.commissionAmount;
253
248
  _componentService.increaseDistributionBalance(store, distributionNftId, commissionAmount, distributionOwnerFee);
254
249
 
255
250
  // update book keeping for referral info
256
251
  IDistribution.ReferralInfo memory referralInfo = reader.getReferralInfo(referralId);
257
- referralInfo.usedReferrals += 1;
258
- store.updateReferral(referralId, referralInfo, KEEP_STATE());
252
+
253
+ _componentService.increaseDistributorBalance(store, referralInfo.distributorNftId, AmountLib.zero(), commissionAmount);
259
254
 
260
255
  // update book keeping for distributor info
261
256
  IDistribution.DistributorInfo memory distributorInfo = reader.getDistributorInfo(referralInfo.distributorNftId);
262
- // TODO refactor sum of commission amount into a fee balance for distributors
263
- distributorInfo.commissionAmount = distributorInfo.commissionAmount + commissionAmount;
264
257
  distributorInfo.numPoliciesSold += 1;
265
258
  store.updateDistributor(referralInfo.distributorNftId, distributorInfo, KEEP_STATE());
266
259
  } else {
267
-
268
260
  // increase distribution balance by distribution owner fee
269
261
  _componentService.increaseDistributionBalance(store, distributionNftId, AmountLib.zero(), distributionOwnerFee);
270
262
  }
271
263
  }
272
264
 
265
+ /// @inheritdoc IDistributionService
266
+ function withdrawCommission(NftId distributorNftId, Amount amount)
267
+ public
268
+ virtual
269
+ // TODO: restricted() (once #462 is done)
270
+ returns (Amount withdrawnAmount)
271
+ {
272
+ (NftId distributionNftId,, IInstance instance) = _getAndVerifyActiveComponent(DISTRIBUTION());
273
+ InstanceReader reader = instance.getInstanceReader();
274
+
275
+ IComponents.ComponentInfo memory distributionInfo = reader.getComponentInfo(distributionNftId);
276
+ address distributionWallet = distributionInfo.wallet;
277
+
278
+ Amount commissionAmount = reader.getFeeAmount(distributorNftId);
279
+
280
+ // determine withdrawn amount
281
+ withdrawnAmount = amount;
282
+ if (withdrawnAmount.gte(AmountLib.max())) {
283
+ withdrawnAmount = commissionAmount;
284
+ } else {
285
+ if (withdrawnAmount.gt(commissionAmount)) {
286
+ revert ErrorDistributionServiceCommissionWithdrawAmountExceedsLimit(withdrawnAmount, commissionAmount);
287
+ }
288
+ }
289
+
290
+ // decrease fee counters by withdrawnAmount and update distributor info
291
+ {
292
+ InstanceStore store = instance.getInstanceStore();
293
+ // decrease fee counter for distribution balance
294
+ _componentService.decreaseDistributionBalance(store, distributionNftId, withdrawnAmount, AmountLib.zero());
295
+ // decrease fee counter for distributor fee
296
+ _componentService.decreaseDistributorBalance(store, distributorNftId, AmountLib.zero(), withdrawnAmount);
297
+ }
298
+
299
+ // transfer amount to distributor
300
+ {
301
+ address distributor = getRegistry().ownerOf(distributorNftId);
302
+ emit LogDistributionServiceCommissionWithdrawn(distributorNftId, distributor, address(distributionInfo.token), withdrawnAmount);
303
+ distributionInfo.tokenHandler.distributeTokens(distributionWallet, distributor, withdrawnAmount);
304
+ }
305
+ }
306
+
273
307
  function referralIsValid(NftId distributionNftId, ReferralId referralId) public view returns (bool isValid) {
274
308
  if (distributionNftId.eqz() || referralId.eqz()) {
275
309
  return false;
@@ -292,7 +326,7 @@ contract DistributionService is
292
326
  returns(IInstance instance)
293
327
  {
294
328
  NftId instanceNftId = getRegistry().getObjectInfo(distributionNftId).parentNftId;
295
- address instanceAddress = getRegistry().getObjectInfo(instanceNftId).objectAddress;
329
+ address instanceAddress = getRegistry().getObjectAddress(instanceNftId);
296
330
  return IInstance(instanceAddress);
297
331
  }
298
332