@etherisc/gif-next 0.0.2-9105e58-225 → 0.0.2-917cede-703

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 (332) hide show
  1. package/README.md +6 -83
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +78 -100
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +139 -194
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IComponent.sol/IComponent.json +156 -64
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +169 -143
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +353 -176
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +162 -138
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +291 -248
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +83 -173
  18. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  19. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  20. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  21. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
  22. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  23. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
  24. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  25. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +527 -400
  26. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  27. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +166 -181
  28. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  29. package/artifacts/contracts/instance/Instance.sol/Instance.json +500 -623
  30. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  31. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +472 -126
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  33. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +253 -236
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +300 -384
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +246 -84
  38. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  39. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
  40. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +71 -166
  42. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +40 -10
  46. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
  48. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  49. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +56 -73
  50. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  52. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
  53. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  59. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +266 -253
  60. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +214 -76
  62. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +409 -386
  64. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +249 -71
  66. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +338 -230
  68. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +225 -63
  70. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +883 -233
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +308 -78
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +196 -181
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +233 -296
  78. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +231 -177
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +594 -134
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +405 -190
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +583 -109
  86. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +68 -141
  88. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +525 -296
  90. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +228 -86
  92. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +734 -206
  94. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +234 -68
  96. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +107 -222
  98. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +191 -73
  100. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  101. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  102. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  103. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  104. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -163
  106. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  107. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
  108. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  109. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
  110. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  111. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  112. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  113. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +24 -221
  114. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  115. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +184 -70
  116. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  117. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
  118. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  119. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  120. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  121. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  122. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  124. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IService.sol/IService.json +68 -141
  128. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +0 -150
  130. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  132. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  133. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  134. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  135. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +169 -53
  136. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +5 -16
  138. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  139. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  140. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Service.sol/Service.json +82 -161
  142. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  143. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  144. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  145. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  146. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  147. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +0 -150
  148. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  150. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -17
  152. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
  154. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestService.sol/TestService.json +100 -211
  156. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  158. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  159. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  160. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +6 -188
  161. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  162. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
  164. package/artifacts/contracts/types/Amount.sol/AmountLib.json +209 -0
  165. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  167. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +83 -4
  170. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  172. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
  174. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  175. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  176. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  178. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  179. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  180. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  183. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +116 -7
  185. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +23 -4
  187. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  189. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  191. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
  192. package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
  193. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  194. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  195. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +38 -7
  197. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  198. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  199. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  200. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  201. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  202. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  203. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  204. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  205. package/contracts/components/Component.sol +99 -88
  206. package/contracts/components/Distribution.sol +22 -46
  207. package/contracts/components/IComponent.sol +40 -19
  208. package/contracts/components/IDistributionComponent.sol +1 -30
  209. package/contracts/components/IPoolComponent.sol +73 -47
  210. package/contracts/components/IProductComponent.sol +3 -2
  211. package/contracts/components/Pool.sol +178 -130
  212. package/contracts/components/Product.sol +157 -71
  213. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  214. package/contracts/instance/BundleManager.sol +10 -9
  215. package/contracts/instance/Cloneable.sol +7 -2
  216. package/contracts/instance/IInstance.sol +37 -27
  217. package/contracts/instance/IInstanceService.sol +18 -9
  218. package/contracts/instance/Instance.sol +117 -98
  219. package/contracts/instance/InstanceAccessManager.sol +388 -158
  220. package/contracts/instance/InstanceReader.sol +36 -12
  221. package/contracts/instance/InstanceService.sol +193 -191
  222. package/contracts/instance/ObjectManager.sol +6 -8
  223. package/contracts/instance/base/ComponentService.sol +17 -30
  224. package/contracts/instance/base/KeyValueStore.sol +13 -5
  225. package/contracts/instance/base/Lifecycle.sol +23 -6
  226. package/contracts/instance/module/IAccess.sol +21 -14
  227. package/contracts/instance/module/IBundle.sol +8 -5
  228. package/contracts/instance/module/IComponents.sol +41 -0
  229. package/contracts/instance/module/IDistribution.sol +2 -0
  230. package/contracts/instance/module/IPolicy.sol +37 -7
  231. package/contracts/instance/module/ISetup.sol +7 -21
  232. package/contracts/instance/service/ApplicationService.sol +137 -50
  233. package/contracts/instance/service/BundleService.sol +228 -83
  234. package/contracts/instance/service/ClaimService.sol +114 -26
  235. package/contracts/instance/service/DistributionService.sol +225 -71
  236. package/contracts/instance/service/IApplicationService.sol +9 -13
  237. package/contracts/instance/service/IBundleService.sol +74 -26
  238. package/contracts/instance/service/IClaimService.sol +46 -15
  239. package/contracts/instance/service/IDistributionService.sol +37 -3
  240. package/contracts/instance/service/IPolicyService.sol +69 -21
  241. package/contracts/instance/service/IPoolService.sol +85 -3
  242. package/contracts/instance/service/PolicyService.sol +301 -230
  243. package/contracts/instance/service/PolicyServiceManager.sol +1 -1
  244. package/contracts/instance/service/PoolService.sol +245 -18
  245. package/contracts/instance/service/ProductService.sol +31 -54
  246. package/contracts/instance/service/ProductServiceManager.sol +1 -1
  247. package/contracts/registry/ChainNft.sol +8 -0
  248. package/contracts/registry/IRegistry.sol +2 -0
  249. package/contracts/registry/IRegistryService.sol +4 -3
  250. package/contracts/registry/ITransferInterceptor.sol +1 -0
  251. package/contracts/registry/Registry.sol +23 -20
  252. package/contracts/registry/RegistryService.sol +15 -16
  253. package/contracts/registry/ReleaseManager.sol +26 -33
  254. package/contracts/registry/TokenRegistry.sol +1 -6
  255. package/contracts/shared/IService.sol +4 -4
  256. package/contracts/shared/IVersionable.sol +4 -47
  257. package/contracts/shared/ProxyManager.sol +89 -22
  258. package/contracts/shared/Registerable.sol +2 -6
  259. package/contracts/shared/Service.sol +29 -17
  260. package/contracts/shared/TokenHandler.sol +11 -5
  261. package/contracts/shared/Versionable.sol +1 -90
  262. package/contracts/test/TestService.sol +1 -1
  263. package/contracts/types/Amount.sol +70 -0
  264. package/contracts/types/Blocknumber.sol +1 -0
  265. package/contracts/types/ClaimId.sol +25 -2
  266. package/contracts/types/Fee.sol +13 -5
  267. package/contracts/types/NftId.sol +8 -0
  268. package/contracts/types/ObjectType.sol +6 -5
  269. package/contracts/types/PayoutId.sol +33 -5
  270. package/contracts/types/Referral.sol +4 -0
  271. package/contracts/types/RoleId.sol +13 -6
  272. package/contracts/types/Seconds.sol +54 -0
  273. package/contracts/types/StateId.sol +7 -2
  274. package/contracts/types/Timestamp.sol +18 -13
  275. package/contracts/types/UFixed.sol +1 -0
  276. package/contracts/types/Version.sol +1 -0
  277. package/package.json +1 -1
  278. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
  279. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
  280. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
  281. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
  282. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
  283. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
  284. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
  285. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
  286. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
  287. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
  288. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
  289. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
  290. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
  291. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
  292. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
  293. package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
  294. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
  295. package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
  296. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
  297. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
  298. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
  299. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
  300. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
  301. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +0 -50
  302. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
  303. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
  304. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
  305. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
  306. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
  307. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
  308. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
  309. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
  310. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
  311. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
  312. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
  313. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
  314. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
  315. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
  316. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
  317. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
  318. package/contracts/experiment/cloning/Cloner.sol +0 -47
  319. package/contracts/experiment/errors/Require.sol +0 -38
  320. package/contracts/experiment/errors/Revert.sol +0 -44
  321. package/contracts/experiment/inheritance/A.sol +0 -53
  322. package/contracts/experiment/inheritance/B.sol +0 -28
  323. package/contracts/experiment/inheritance/C.sol +0 -34
  324. package/contracts/experiment/inheritance/IA.sol +0 -13
  325. package/contracts/experiment/inheritance/IB.sol +0 -10
  326. package/contracts/experiment/inheritance/IC.sol +0 -12
  327. package/contracts/experiment/statemachine/Dummy.sol +0 -27
  328. package/contracts/experiment/statemachine/ISM.sol +0 -25
  329. package/contracts/experiment/statemachine/SM.sol +0 -57
  330. package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
  331. package/contracts/experiment/types/TypeA.sol +0 -47
  332. package/contracts/experiment/types/TypeB.sol +0 -29
@@ -1,11 +1,13 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5
- import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
6
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
7
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
7
8
 
8
9
  import {IComponent} from "./IComponent.sol";
10
+ import {IComponents} from "../instance/module/IComponents.sol";
9
11
  import {IProductService} from "../instance/service/IProductService.sol";
10
12
  import {IInstanceService} from "../instance/IInstanceService.sol";
11
13
  import {IInstance} from "../instance/IInstance.sol";
@@ -29,21 +31,23 @@ abstract contract Component is
29
31
  AccessManagedUpgradeable
30
32
  {
31
33
  // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Component.sol")) - 1)) & ~bytes32(uint256(0xff));
32
- bytes32 public constant CONTRACT_LOCATION_V1 = 0xffe8d4462baed26a47154f4b8f6db497d2f772496965791d25bd456e342b7f00;
34
+ bytes32 public constant COMPONENT_LOCATION_V1 = 0xffe8d4462baed26a47154f4b8f6db497d2f772496965791d25bd456e342b7f00;
33
35
 
34
36
  struct ComponentStorage {
35
- IInstance _instance; // instance for this component
36
- InstanceReader _instanceReader; // instance reader for this component
37
37
  string _name; // unique (per instance) component name
38
38
  IERC20Metadata _token; // token for this component
39
+ IInstance _instance; // instance for this component
39
40
  address _wallet; // wallet for this component (default = component contract itself)
41
+ InstanceReader _instanceReader; // instance reader for this component
40
42
  bool _isNftInterceptor; // declares if component is involved in nft transfers
41
- IInstanceService _instanceService; // instance service for this component
42
-
43
43
  NftId _productNftId; // only relevant for components that are linked to a aproduct
44
- IProductService _productService; // product service for component, might not be relevant for some component types (eg oracles)
45
44
  }
46
45
 
46
+ function _getComponentStorage() private pure returns (ComponentStorage storage $) {
47
+ assembly {
48
+ $.slot := COMPONENT_LOCATION_V1
49
+ }
50
+ }
47
51
 
48
52
  modifier onlyChainNft() {
49
53
  if(msg.sender != getRegistry().getChainNftAddress()) {
@@ -52,20 +56,6 @@ abstract contract Component is
52
56
  _;
53
57
  }
54
58
 
55
-
56
- modifier onlyProductService() {
57
- if(msg.sender != address(_getComponentStorage()._productService)) {
58
- revert ErrorComponentNotProductService(msg.sender);
59
- }
60
- _;
61
- }
62
-
63
- function _getComponentStorage() private pure returns (ComponentStorage storage $) {
64
- assembly {
65
- $.slot := CONTRACT_LOCATION_V1
66
- }
67
- }
68
-
69
59
  function initializeComponent(
70
60
  address registry,
71
61
  NftId instanceNftId,
@@ -74,78 +64,45 @@ abstract contract Component is
74
64
  ObjectType componentType,
75
65
  bool isInterceptor,
76
66
  address initialOwner,
77
- bytes memory data
67
+ bytes memory registryData // writeonly data that will saved in the object info record of the registry
78
68
  )
79
69
  public
80
70
  virtual
81
71
  onlyInitializing()
82
72
  {
83
- ComponentStorage storage $ = _getComponentStorage();
84
- initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, data);
85
-
86
- // set unique name of component
87
- $._name = name;
88
- $._isNftInterceptor = isInterceptor;
73
+ initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, registryData);
89
74
 
90
75
  // set and check linked instance
91
- IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
92
- $._instance = IInstance(instanceInfo.objectAddress);
76
+ ComponentStorage storage $ = _getComponentStorage();
77
+ $._instance = IInstance(
78
+ getRegistry().getObjectInfo(instanceNftId).objectAddress);
79
+
93
80
  if(!$._instance.supportsInterface(type(IInstance).interfaceId)) {
94
- revert ErrorComponentNotInstance(instanceNftId, instanceInfo.objectAddress);
81
+ revert ErrorComponentNotInstance(instanceNftId);
95
82
  }
96
83
 
97
84
  // initialize AccessManagedUpgradeable
98
85
  __AccessManaged_init($._instance.authority());
99
86
 
100
- // set linked services
101
- VersionPart gifVersion = $._instance.getMajorVersion();
102
- $._instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), gifVersion));
87
+ // set component state
88
+ $._name = name;
89
+ $._isNftInterceptor = isInterceptor;
103
90
  $._instanceReader = $._instance.getInstanceReader();
104
- $._productService = IProductService(getRegistry().getServiceAddress(PRODUCT(), gifVersion));
105
-
106
- // set wallet and token
107
91
  $._wallet = address(this);
108
92
  $._token = IERC20Metadata(token);
109
93
 
94
+ registerInterface(type(IAccessManaged).interfaceId);
110
95
  registerInterface(type(IComponent).interfaceId);
111
96
  }
112
97
 
113
- /// @dev callback function for nft transfers. may only be called by chain nft contract.
114
- /// default implementation is empty. overriding functions MUST add onlyChainNft modifier
115
- function nftTransferFrom(address from, address to, uint256 tokenId)
116
- external
117
- virtual override
118
- onlyChainNft()
119
- { }
120
-
121
- // TODO discuss replacement with modifier restricted from accessmanaged
122
98
  function lock() external onlyOwner override {
123
- _getComponentStorage()._instanceService.setTargetLocked(getName(), true);
99
+ IInstanceService(_getServiceAddress(INSTANCE())).setComponentLocked(true);
124
100
  }
125
101
 
126
102
  function unlock() external onlyOwner override {
127
- _getComponentStorage()._instanceService.setTargetLocked(getName(), false);
103
+ IInstanceService(_getServiceAddress(INSTANCE())).setComponentLocked(false);
128
104
  }
129
105
 
130
- // only product service may set product nft id during registration of product setup
131
- function setProductNftId(NftId productNftId)
132
- external
133
- override
134
- onlyProductService()
135
- {
136
- ComponentStorage storage $ = _getComponentStorage();
137
-
138
- if($._productNftId.gtz()) {
139
- revert ErrorComponentProductNftAlreadySet();
140
- }
141
-
142
- $._productNftId = productNftId;
143
- }
144
-
145
- /// @dev Sets the wallet address for the component.
146
- /// if the current wallet has tokens, these will be transferred.
147
- /// if the new wallet address is externally owned, an approval from the
148
- /// owner of the external wallet for the component to move all tokens must exist.
149
106
  function setWallet(address newWallet)
150
107
  external
151
108
  override
@@ -160,8 +117,9 @@ abstract contract Component is
160
117
  if (newWallet == address(0)) {
161
118
  revert ErrorComponentWalletAddressZero();
162
119
  }
120
+
163
121
  if (newWallet == currentWallet) {
164
- revert ErrorComponentWalletAddressIsSameAsCurrent(newWallet);
122
+ revert ErrorComponentWalletAddressIsSameAsCurrent();
165
123
  }
166
124
 
167
125
  if (currentBalance > 0) {
@@ -178,7 +136,7 @@ abstract contract Component is
178
136
 
179
137
  // effects
180
138
  $._wallet = newWallet;
181
- emit LogComponentWalletAddressChanged(newWallet);
139
+ emit LogComponentWalletAddressChanged(currentWallet, newWallet);
182
140
 
183
141
  // interactions
184
142
  if (currentBalance > 0) {
@@ -193,11 +151,44 @@ abstract contract Component is
193
151
  }
194
152
  }
195
153
 
196
- function getWallet()
197
- public
198
- view
154
+ function setProductNftId(NftId productNftId)
155
+ external
199
156
  override
200
- returns (address walletAddress)
157
+ {
158
+ ComponentStorage storage $ = _getComponentStorage();
159
+
160
+ // verify caller is product service
161
+ if(msg.sender != _getServiceAddress(PRODUCT())) {
162
+ revert ErrorComponentNotProductService(msg.sender);
163
+ }
164
+
165
+ // verify component is not yet linked to a product
166
+ if($._productNftId.gtz()) {
167
+ revert ErrorComponentProductNftAlreadySet();
168
+ }
169
+
170
+ $._productNftId = productNftId;
171
+ }
172
+
173
+ function nftMint(address to, uint256 tokenId)
174
+ external
175
+ virtual
176
+ onlyChainNft
177
+ {}
178
+
179
+ /// @dev callback function for nft transfers
180
+ /// may only be called by chain nft contract.
181
+ /// do not override this function to implement business logic for handling transfers
182
+ /// override internal function _nftTransferFrom instead
183
+ function nftTransferFrom(address from, address to, uint256 tokenId)
184
+ external
185
+ virtual
186
+ onlyChainNft
187
+ {
188
+ _nftTransferFrom(from, to, tokenId);
189
+ }
190
+
191
+ function getWallet() public view override returns (address walletAddress)
201
192
  {
202
193
  return _getComponentStorage()._wallet;
203
194
  }
@@ -214,15 +205,6 @@ abstract contract Component is
214
205
  return _getComponentStorage()._instance;
215
206
  }
216
207
 
217
- function getInstanceReader() public view returns (InstanceReader reader) {
218
- return _getComponentStorage()._instanceReader;
219
- }
220
-
221
- function getServiceAddress(ObjectType domain) public view returns (address service) {
222
- VersionPart majorVersion = getInstance().getMajorVersion();
223
- return getRegistry().getServiceAddress(domain, majorVersion);
224
- }
225
-
226
208
  function getName() public view override returns(string memory name) {
227
209
  return _getComponentStorage()._name;
228
210
  }
@@ -231,12 +213,41 @@ abstract contract Component is
231
213
  return _getComponentStorage()._productNftId;
232
214
  }
233
215
 
234
- function getInstanceService() public view returns (IInstanceService) {
235
- return _getComponentStorage()._instanceService;
216
+ function getComponentInfo() public view returns (IComponents.ComponentInfo memory info) {
217
+ info = _getInstanceReader().getComponentInfo(getNftId());
218
+
219
+ // fallback to initial info (wallet is always != address(0))
220
+ if(info.wallet == address(0)) {
221
+ info = _getInitialInfo();
222
+ }
236
223
  }
237
224
 
238
- function getProductService() public view returns (IProductService) {
239
- return _getComponentStorage()._productService;
225
+ /// @dev defines initial component specification
226
+ /// overwrite this function according to your use case
227
+ function _getInitialInfo()
228
+ internal
229
+ view
230
+ virtual
231
+ returns (IComponents.ComponentInfo memory info)
232
+ { }
233
+
234
+
235
+ /// @dev internal function for nft transfers.
236
+ /// handling logic that deals with nft transfers need to overwrite this function
237
+ function _nftTransferFrom(address from, address to, uint256 tokenId)
238
+ internal
239
+ virtual
240
+ { }
241
+
242
+ /// @dev returns reader for linked instance
243
+ function _getInstanceReader() internal view returns (InstanceReader reader) {
244
+ return _getComponentStorage()._instanceReader;
240
245
  }
241
246
 
242
- }
247
+ /// @dev returns the service address for the specified domain
248
+ /// gets address via lookup from registry using the major version form the linked instance
249
+ function _getServiceAddress(ObjectType domain) internal view returns (address service) {
250
+ VersionPart majorVersion = _getComponentStorage()._instance.getMajorVersion();
251
+ return getRegistry().getServiceAddress(domain, majorVersion);
252
+ }
253
+ }
@@ -8,6 +8,7 @@ import {NftId, zeroNftId, NftIdLib, toNftId} from "../types/NftId.sol";
8
8
  import {ReferralId, ReferralStatus, ReferralLib} from "../types/Referral.sol";
9
9
  import {Fee, FeeLib} from "../types/Fee.sol";
10
10
  import {Component} from "./Component.sol";
11
+ import {IDistribution} from "../instance/module/IDistribution.sol";
11
12
  import {IDistributionComponent} from "./IDistributionComponent.sol";
12
13
  import {IRegistry} from "../registry/IRegistry.sol";
13
14
  import {IRegisterable} from "../shared/IRegisterable.sol";
@@ -17,7 +18,7 @@ import {TokenHandler} from "../shared/TokenHandler.sol";
17
18
  import {InstanceReader} from "../instance/InstanceReader.sol";
18
19
  import {UFixed} from "../types/UFixed.sol";
19
20
  import {DistributorType} from "../types/DistributorType.sol";
20
- import {Timestamp} from "../types/Timestamp.sol";
21
+ import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
21
22
  import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
22
23
 
23
24
 
@@ -29,37 +30,43 @@ abstract contract Distribution is
29
30
  bytes32 public constant DISTRIBUTION_STORAGE_LOCATION_V1 = 0xaab7c5ea03d290056d6c060e0833d3ebcbe647f7694616a2ec52738a64b2f900;
30
31
 
31
32
  struct DistributionStorage {
33
+ Fee _minDistributionOwnerFee;
32
34
  Fee _distributionFee;
33
35
  TokenHandler _tokenHandler;
34
36
  IDistributionService _distributionService;
35
37
  mapping(address distributor => NftId distributorNftId) _distributorNftId;
36
38
  }
37
39
 
40
+ error ErrorDistributionAlreadyDistributor(address distributor, NftId distributorNftId);
41
+
38
42
  function initializeDistribution(
39
43
  address registry,
40
44
  NftId instanceNftId,
41
45
  string memory name,
42
46
  address token,
47
+ Fee memory minDistributionOwnerFee,
43
48
  Fee memory distributionFee,
44
49
  address initialOwner,
45
- bytes memory data
50
+ bytes memory registryData // writeonly data that will saved in the object info record of the registry
46
51
  )
47
52
  public
48
53
  virtual
49
54
  onlyInitializing()
50
55
  {
51
- initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, data);
56
+ initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, registryData);
52
57
 
53
58
  DistributionStorage storage $ = _getDistributionStorage();
54
59
  // TODO add validation
60
+ $._minDistributionOwnerFee = minDistributionOwnerFee;
55
61
  $._distributionFee = distributionFee;
56
62
  $._tokenHandler = new TokenHandler(token);
57
- $._distributionService = getInstance().getDistributionService();
63
+ $._distributionService = IDistributionService(_getServiceAddress(DISTRIBUTION()));
58
64
 
59
65
  registerInterface(type(IDistributionComponent).interfaceId);
60
66
  }
61
67
 
62
68
  function setFees(
69
+ Fee memory minDistributionOwnerFee,
63
70
  Fee memory distributionFee
64
71
  )
65
72
  external
@@ -67,7 +74,7 @@ abstract contract Distribution is
67
74
  onlyOwner
68
75
  restricted()
69
76
  {
70
- _getDistributionStorage()._distributionService.setFees(distributionFee);
77
+ _getDistributionStorage()._distributionService.setFees(minDistributionOwnerFee, distributionFee);
71
78
  }
72
79
 
73
80
  function getDistributionFee() external view returns (Fee memory distributionFee) {
@@ -111,7 +118,9 @@ abstract contract Distribution is
111
118
  returns(NftId distributorNftId)
112
119
  {
113
120
  DistributionStorage storage $ = _getDistributionStorage();
114
- require($._distributorNftId[distributor].eqz(), "ERROR:DST-030:ALREADY_DISTRIBUTOR");
121
+ if($._distributorNftId[distributor].gtz()) {
122
+ revert ErrorDistributionAlreadyDistributor(distributor, $._distributorNftId[distributor]);
123
+ }
115
124
 
116
125
  distributorNftId = $._distributionService.createDistributor(
117
126
  distributor,
@@ -141,7 +150,7 @@ abstract contract Distribution is
141
150
  * @dev lets distributors create referral codes.
142
151
  * referral codes need to be unique
143
152
  */
144
- function createReferral(
153
+ function _createReferral(
145
154
  NftId distributorNftId,
146
155
  string memory code,
147
156
  UFixed discountPercentage,
@@ -149,8 +158,7 @@ abstract contract Distribution is
149
158
  Timestamp expiryAt,
150
159
  bytes memory data
151
160
  )
152
- public
153
- // TODO add authz (only active distributor)
161
+ internal
154
162
  returns (ReferralId referralId)
155
163
  {
156
164
  DistributionStorage storage $ = _getDistributionStorage();
@@ -163,22 +171,6 @@ abstract contract Distribution is
163
171
  data);
164
172
  }
165
173
 
166
- function calculateFeeAmount(
167
- ReferralId referralId,
168
- uint256 netPremiumAmount
169
- )
170
- external
171
- view
172
- virtual override
173
- returns (uint256 feeAmount)
174
- {
175
- ISetup.DistributionSetupInfo memory setupInfo = getSetupInfo();
176
- Fee memory fee = setupInfo.distributionFee;
177
- (feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
178
- // TODO: use this?
179
- // return _distributionService.calculateFeeAmount(referralId, premiumAmount);
180
- }
181
-
182
174
  function isDistributor(address candidate)
183
175
  public
184
176
  view
@@ -206,7 +198,7 @@ abstract contract Distribution is
206
198
  )
207
199
  {
208
200
  ReferralId referralId = getReferralId(referralCode);
209
- return getInstanceReader().getDiscountPercentage(referralId);
201
+ return _getInstanceReader().getDiscountPercentage(referralId);
210
202
  }
211
203
 
212
204
 
@@ -235,19 +227,6 @@ abstract contract Distribution is
235
227
  return 0 * netPremiumAmount;
236
228
  }
237
229
 
238
- function processSale(
239
- ReferralId referralId,
240
- uint256 premiumAmount
241
- )
242
- external
243
- onlyOwner
244
- restricted()
245
- virtual override
246
- {
247
- DistributionStorage storage $ = _getDistributionStorage();
248
- $._distributionService.processSale(referralId, premiumAmount);
249
- }
250
-
251
230
  function processRenewal(
252
231
  ReferralId referralId,
253
232
  uint256 feeAmount
@@ -260,11 +239,6 @@ abstract contract Distribution is
260
239
  // default is no action
261
240
  }
262
241
 
263
- function referralIsValid(ReferralId referralId) external view returns (bool isValid) {
264
- // default is invalid
265
- return false;
266
- }
267
-
268
242
  function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
269
243
  InstanceReader reader = getInstance().getInstanceReader();
270
244
  setupInfo = reader.getDistributionSetupInfo(getNftId());
@@ -280,13 +254,15 @@ abstract contract Distribution is
280
254
  return ISetup.DistributionSetupInfo(
281
255
  zeroNftId(),
282
256
  $._tokenHandler,
257
+ $._minDistributionOwnerFee,
283
258
  $._distributionFee,
284
- address(this)
259
+ address(this),
260
+ 0
285
261
  );
286
262
  }
287
263
 
288
264
 
289
- function nftTransferFrom(address from, address to, uint256 tokenId) external virtual override (Component, ITransferInterceptor) {
265
+ function _nftTransferFrom(address from, address to, uint256 tokenId) internal virtual override {
290
266
  // keep track of distributor nft owner
291
267
  emit LogDistributorUpdated(to, msg.sender);
292
268
  DistributionStorage storage $ = _getDistributionStorage();
@@ -1,8 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
4
5
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
6
 
7
+ import {IComponents} from "../instance/module/IComponents.sol";
6
8
  import {IInstance} from "../instance/IInstance.sol";
7
9
  import {IInstanceService} from "../instance/IInstanceService.sol";
8
10
  import {IProductService} from "../instance/service/IProductService.sol";
@@ -11,45 +13,64 @@ import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
11
13
  import {NftId} from "../types/NftId.sol";
12
14
  import {ObjectType} from "../types/ObjectType.sol";
13
15
 
16
+ /// @dev component base class
17
+ /// component examples are product, distribution, pool and oracle
14
18
  interface IComponent is
15
19
  IRegisterable,
16
- ITransferInterceptor
20
+ ITransferInterceptor,
21
+ IAccessManaged
17
22
  {
18
-
19
23
  error ErrorComponentNotChainNft(address caller);
20
24
  error ErrorComponentNotProductService(address caller);
21
- error ErrorComponentNotInstance(NftId instanceNftId, address instance);
25
+ error ErrorComponentNotInstance(NftId instanceNftId);
22
26
  error ErrorComponentProductNftAlreadySet();
27
+
23
28
  error ErrorComponentWalletAddressZero();
24
- error ErrorComponentWalletAddressIsSameAsCurrent(address newWallet);
29
+ error ErrorComponentWalletAddressIsSameAsCurrent();
25
30
  error ErrorComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
26
- error ErrorComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
27
31
 
28
- event LogComponentWalletAddressChanged(address newWallet);
32
+ event LogComponentWalletAddressChanged(address oldWallet, address newWallet);
29
33
  event LogComponentWalletTokensTransferred(address from, address to, uint256 amount);
30
34
 
31
- function getName() external view returns (string memory name);
32
-
33
- // TODO remove and replace with accessmanaged target locking mechanism
35
+ /// @dev locks component to disable functions that may change state related to this component, the only exception is function "unlock"
36
+ /// only component owner (nft holder) is authorizes to call this function
34
37
  function lock() external;
35
- function unlock() external;
36
38
 
37
- function getToken() external view returns (IERC20Metadata token);
39
+ /// @dev unlocks component to (re-)enable functions that may change state related to this component
40
+ /// only component owner (nft holder) is authorizes to call this function
41
+ function unlock() external;
38
42
 
43
+ /// @dev sets the wallet address for the component
44
+ /// if the current wallet has tokens, these will be transferred
45
+ /// if the new wallet address is externally owned, an approval from the
46
+ /// owner of the external wallet for the component to move all tokens must exist
39
47
  function setWallet(address walletAddress) external;
40
- function getWallet() external view returns (address walletAddress);
41
48
 
42
- function isNftInterceptor() external view returns(bool isInterceptor);
49
+ /// @dev only product service may set product nft id during registration of product setup
50
+ function setProductNftId(NftId productNftId) external;
51
+
52
+ /// @dev returns the name of this component
53
+ /// to successfully register the component with an instance the name MUST be unique in the linked instance
54
+ function getName() external view returns (string memory name);
55
+
56
+ /// @dev defines which ERC20 token is used by this component
57
+ function getToken() external view returns (IERC20Metadata token);
43
58
 
59
+ /// @dev defines the instance to which this component is linked to
44
60
  function getInstance() external view returns (IInstance instance);
45
61
 
46
- /// @dev returns the service address for the specified domain
47
- /// gets address via lookup from registry using the major version form the linked instance
48
- function getServiceAddress(ObjectType domain) external view returns (address service);
62
+ /// @dev defines the wallet address used to hold the ERC20 tokens related to this component
63
+ /// the default address is the component token address
64
+ function getWallet() external view returns (address walletAddress);
49
65
 
50
- function setProductNftId(NftId productNftId) external;
66
+ /// @dev defines the product to which this component is linked to
67
+ /// this is only relevant for pool and distribution components
51
68
  function getProductNftId() external view returns (NftId productNftId);
52
69
 
53
- function getInstanceService() external view returns (IInstanceService);
54
- function getProductService() external view returns (IProductService);
70
+ function isNftInterceptor() external view returns(bool isInterceptor);
71
+
72
+ /// @dev returns component infos for this pool
73
+ /// when registered with an instance the info is obtained from the data stored in the instance
74
+ /// when not registered the function returns the info from the component contract
75
+ function getComponentInfo() external view returns (IComponents.ComponentInfo memory info);
55
76
  }
@@ -17,6 +17,7 @@ interface IDistributionComponent is IComponent {
17
17
  function getSetupInfo() external view returns (ISetup.DistributionSetupInfo memory setupInfo);
18
18
 
19
19
  function setFees(
20
+ Fee memory minDistributionOwnerFee,
20
21
  Fee memory distributionFee
21
22
  ) external;
22
23
 
@@ -44,38 +45,11 @@ interface IDistributionComponent is IComponent {
44
45
  bytes memory data
45
46
  ) external;
46
47
 
47
- /**
48
- * @dev lets distributors create referral codes.
49
- * referral codes need to be unique
50
- * distributor is identified via msg.sender.
51
- */
52
- function createReferral(
53
- NftId distributorNftId,
54
- string memory code,
55
- UFixed discountPercentage,
56
- uint32 maxReferrals,
57
- Timestamp expiryAt,
58
- bytes memory data
59
- ) external returns (ReferralId referralId);
60
-
61
- function calculateFeeAmount(
62
- ReferralId referralId,
63
- uint256 netPremiumAmount
64
- ) external view returns (uint256 feeAmount);
65
-
66
48
  function calculateRenewalFeeAmount(
67
49
  ReferralId referralId,
68
50
  uint256 netPremiumAmount
69
51
  ) external view returns (uint256 feeAmount);
70
52
 
71
- /// @dev callback from product service when selling a policy for a specific referralId
72
- /// the used referral id and the collected fee are provided as parameters
73
- /// the component implementation can then process this information accordingly
74
- function processSale(
75
- ReferralId referralId,
76
- uint256 feeAmount
77
- ) external;
78
-
79
53
  /// @dev callback from product service when a policy is renews for a specific referralId
80
54
  function processRenewal(
81
55
  ReferralId referralId,
@@ -92,9 +66,6 @@ interface IDistributionComponent is IComponent {
92
66
  string memory referralCode
93
67
  ) external returns (ReferralId referralId);
94
68
 
95
- /// @dev returns true iff the referral id is valid
96
- function referralIsValid(ReferralId referralId) external view returns (bool isValid);
97
-
98
69
  /// @dev returns true iff the component needs to be called when selling/renewing policis
99
70
  function isVerifying() external view returns (bool verifying);
100
71
  }