@etherisc/gif-next 0.0.2-7631288 → 0.0.2-770fd3b-604

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 (363) hide show
  1. package/README.md +524 -2
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
  3. package/artifacts/contracts/components/Component.sol/Component.json +897 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +1433 -0
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/IComponent.sol/IComponent.json +520 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +950 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +894 -0
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +813 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +1366 -0
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
  17. package/artifacts/contracts/components/Product.sol/Product.json +1290 -0
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
  19. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
  20. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
  21. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
  22. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
  23. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
  24. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
  25. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
  26. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
  27. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
  28. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +4 -0
  29. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +128 -0
  30. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +4 -0
  31. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +42 -0
  32. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +4 -0
  33. package/artifacts/contracts/experiment/inheritance/B.sol/B.json +76 -0
  34. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +4 -0
  35. package/artifacts/contracts/experiment/inheritance/C.sol/C.json +89 -0
  36. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +4 -0
  37. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +128 -0
  38. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +4 -0
  39. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +37 -0
  40. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +4 -0
  41. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +50 -0
  42. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +4 -0
  43. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +63 -0
  44. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  45. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  46. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  47. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  48. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  49. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  50. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  51. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  52. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  53. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  54. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +4 -0
  55. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +10 -0
  56. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +4 -0
  57. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +10 -0
  58. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  59. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
  60. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  61. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  62. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +4 -0
  63. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +2387 -0
  64. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  65. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +674 -0
  66. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +4 -0
  67. package/artifacts/contracts/instance/Instance.sol/Instance.json +3323 -0
  68. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  69. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +984 -0
  70. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  71. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1386 -0
  72. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  73. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +1260 -0
  74. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  75. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +610 -0
  76. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  77. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
  78. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  79. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +754 -0
  80. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  81. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +429 -0
  82. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  83. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
  84. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  85. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +502 -0
  86. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  87. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  88. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  89. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
  90. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  91. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.json +10 -0
  92. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  93. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
  94. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.json +10 -0
  96. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  97. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.json +10 -0
  98. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  99. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.json +10 -0
  100. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  101. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +10 -0
  102. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
  104. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1318 -0
  106. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  107. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +586 -0
  108. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  109. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1176 -0
  110. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  111. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +602 -0
  112. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
  113. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +638 -0
  114. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  115. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +798 -0
  116. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  117. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +656 -0
  118. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  119. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +784 -0
  120. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  121. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +512 -0
  122. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +549 -0
  124. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  125. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1378 -0
  126. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  127. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +642 -0
  128. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  129. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +957 -0
  130. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  131. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +574 -0
  132. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  133. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1007 -0
  134. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  135. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +574 -0
  136. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +4 -0
  137. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +771 -0
  138. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +4 -0
  139. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +737 -0
  140. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  141. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +999 -0
  142. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  143. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  144. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +4 -0
  145. package/artifacts/contracts/registry/Registry.sol/Registry.json +839 -0
  146. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  147. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  148. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  149. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1351 -0
  150. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  151. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +601 -0
  152. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  153. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
  154. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  155. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +531 -0
  156. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  157. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  158. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  159. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +73 -0
  160. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  161. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +164 -0
  162. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
  163. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
  164. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  165. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +214 -0
  166. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  167. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +69 -0
  168. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  169. package/artifacts/contracts/shared/IService.sol/IService.json +434 -0
  170. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  171. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
  172. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  173. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +303 -0
  174. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
  175. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
  176. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  177. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +499 -0
  178. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  179. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +415 -0
  180. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
  181. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
  182. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  183. package/artifacts/contracts/shared/Service.sol/Service.json +627 -0
  184. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  185. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  186. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  187. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  188. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  189. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
  190. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  191. package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
  192. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  193. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +446 -0
  194. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  195. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
  196. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  197. package/artifacts/contracts/test/TestService.sol/TestService.json +759 -0
  198. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  199. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
  200. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  201. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
  202. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  203. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +286 -0
  204. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  205. package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
  206. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  207. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  208. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  209. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
  210. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +4 -0
  211. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +10 -0
  212. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  213. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  214. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  215. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  216. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  217. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
  218. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +4 -0
  219. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +153 -0
  220. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  221. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +33 -0
  222. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  223. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  224. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  225. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  226. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  227. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  228. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  229. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  230. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  231. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
  232. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  233. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  234. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
  235. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +249 -0
  236. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  237. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  238. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  239. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
  240. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  241. package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
  242. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  243. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +49 -0
  244. package/contracts/components/Component.sol +236 -0
  245. package/contracts/components/Distribution.sol +298 -0
  246. package/contracts/components/IComponent.sol +50 -0
  247. package/contracts/components/IDistributionComponent.sol +100 -0
  248. package/contracts/components/IPoolComponent.sol +87 -0
  249. package/contracts/components/IProductComponent.sol +39 -0
  250. package/contracts/components/Pool.sol +254 -0
  251. package/contracts/components/Product.sol +278 -0
  252. package/contracts/experiment/cloning/Cloner.sol +47 -0
  253. package/contracts/experiment/errors/Require.sol +38 -0
  254. package/contracts/experiment/errors/Revert.sol +44 -0
  255. package/contracts/experiment/inheritance/A.sol +53 -0
  256. package/contracts/experiment/inheritance/B.sol +28 -0
  257. package/contracts/experiment/inheritance/C.sol +34 -0
  258. package/contracts/experiment/inheritance/IA.sol +13 -0
  259. package/contracts/experiment/inheritance/IB.sol +10 -0
  260. package/contracts/experiment/inheritance/IC.sol +12 -0
  261. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  262. package/contracts/experiment/statemachine/ISM.sol +25 -0
  263. package/contracts/experiment/statemachine/SM.sol +57 -0
  264. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  265. package/contracts/experiment/types/TypeA.sol +47 -0
  266. package/contracts/experiment/types/TypeB.sol +29 -0
  267. package/contracts/instance/BundleManager.sol +125 -0
  268. package/contracts/instance/Cloneable.sol +46 -0
  269. package/contracts/instance/IInstance.sol +86 -0
  270. package/contracts/instance/IInstanceService.sol +59 -0
  271. package/contracts/instance/Instance.sol +281 -0
  272. package/contracts/instance/InstanceAccessManager.sol +297 -0
  273. package/contracts/instance/InstanceReader.sol +293 -0
  274. package/contracts/instance/InstanceService.sol +433 -0
  275. package/contracts/instance/InstanceServiceManager.sol +54 -0
  276. package/contracts/instance/ObjectManager.sol +84 -0
  277. package/contracts/instance/base/ComponentService.sol +134 -0
  278. package/contracts/instance/base/IKeyValueStore.sol +49 -0
  279. package/contracts/instance/base/ILifecycle.sol +30 -0
  280. package/contracts/instance/base/KeyValueStore.sol +172 -0
  281. package/contracts/instance/base/Lifecycle.sol +100 -0
  282. package/contracts/instance/module/IAccess.sol +47 -0
  283. package/contracts/instance/module/IBundle.sol +20 -0
  284. package/contracts/instance/module/IDistribution.sol +39 -0
  285. package/contracts/instance/module/IPolicy.sol +45 -0
  286. package/contracts/instance/module/IRisk.sol +11 -0
  287. package/contracts/instance/module/ISetup.sol +47 -0
  288. package/contracts/instance/module/ITreasury.sol +23 -0
  289. package/contracts/instance/service/ApplicationService.sol +268 -0
  290. package/contracts/instance/service/BundleService.sol +298 -0
  291. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  292. package/contracts/instance/service/DistributionService.sol +274 -0
  293. package/contracts/instance/service/DistributionServiceManager.sol +51 -0
  294. package/contracts/instance/service/IApplicationService.sol +82 -0
  295. package/contracts/instance/service/IBundleService.sol +54 -0
  296. package/contracts/instance/service/IDistributionService.sol +65 -0
  297. package/contracts/instance/service/IPolicyService.sol +88 -0
  298. package/contracts/instance/service/IPoolService.sol +20 -0
  299. package/contracts/instance/service/IProductService.sol +40 -0
  300. package/contracts/instance/service/PolicyService.sol +524 -0
  301. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  302. package/contracts/instance/service/PoolService.sol +109 -0
  303. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  304. package/contracts/instance/service/ProductService.sol +233 -0
  305. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  306. package/contracts/registry/ChainNft.sol +202 -0
  307. package/contracts/registry/IRegistry.sol +99 -0
  308. package/contracts/registry/IRegistryService.sol +65 -0
  309. package/contracts/registry/ITransferInterceptor.sol +6 -0
  310. package/contracts/registry/Registry.sol +462 -0
  311. package/contracts/registry/RegistryAccessManager.sol +216 -0
  312. package/contracts/registry/RegistryService.sol +261 -0
  313. package/contracts/registry/RegistryServiceManager.sol +62 -0
  314. package/contracts/registry/ReleaseManager.sol +332 -0
  315. package/contracts/registry/TokenRegistry.sol +113 -0
  316. package/contracts/shared/ContractDeployerLib.sol +72 -0
  317. package/contracts/shared/ERC165.sol +26 -0
  318. package/contracts/shared/INftOwnable.sol +28 -0
  319. package/contracts/shared/IPolicyHolder.sol +26 -0
  320. package/contracts/shared/IRegisterable.sol +15 -0
  321. package/contracts/shared/IRegistryLinked.sol +15 -0
  322. package/contracts/shared/IService.sol +16 -0
  323. package/contracts/shared/IVersionable.sol +96 -0
  324. package/contracts/shared/NftOwnable.sol +190 -0
  325. package/contracts/shared/PolicyHolder.sol +81 -0
  326. package/contracts/shared/ProxyManager.sol +95 -0
  327. package/contracts/shared/Registerable.sol +81 -0
  328. package/contracts/shared/RegistryLinked.sol +64 -0
  329. package/contracts/shared/Service.sol +60 -0
  330. package/contracts/shared/TokenHandler.sol +27 -0
  331. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  332. package/contracts/shared/Versionable.sol +148 -0
  333. package/contracts/test/TestFee.sol +25 -0
  334. package/contracts/test/TestRegisterable.sol +18 -0
  335. package/contracts/test/TestRoleId.sol +14 -0
  336. package/contracts/test/TestService.sol +25 -0
  337. package/contracts/{Dip.sol → test/TestToken.sol} +5 -5
  338. package/contracts/test/TestVersion.sol +44 -0
  339. package/contracts/test/TestVersionable.sol +17 -0
  340. package/contracts/test/Usdc.sol +26 -0
  341. package/contracts/types/AddressSet.sol +58 -0
  342. package/contracts/types/Blocknumber.sol +118 -0
  343. package/contracts/types/ChainId.sol +38 -0
  344. package/contracts/types/DistributorType.sol +55 -0
  345. package/contracts/types/Fee.sol +56 -0
  346. package/contracts/types/Key32.sol +50 -0
  347. package/contracts/types/NftId.sol +72 -0
  348. package/contracts/types/NftIdSet.sol +62 -0
  349. package/contracts/types/NumberId.sol +52 -0
  350. package/contracts/types/ObjectType.sol +156 -0
  351. package/contracts/types/Referral.sol +85 -0
  352. package/contracts/types/RiskId.sol +43 -0
  353. package/contracts/types/RoleId.sol +90 -0
  354. package/contracts/types/StateId.sol +105 -0
  355. package/contracts/types/Timestamp.sol +127 -0
  356. package/contracts/types/UFixed.sol +325 -0
  357. package/contracts/types/Version.sol +107 -0
  358. package/package.json +26 -10
  359. package/artifacts/contracts/Dip.sol/DIP.dbg.json +0 -4
  360. package/artifacts/contracts/Dip.sol/DIP.json +0 -338
  361. package/artifacts/contracts/Lock.sol/Lock.dbg.json +0 -4
  362. package/artifacts/contracts/Lock.sol/Lock.json +0 -74
  363. package/contracts/Lock.sol +0 -34
@@ -0,0 +1,49 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "VersionPartLib",
4
+ "sourceName": "contracts/types/Version.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "internalType": "VersionPart",
10
+ "name": "a",
11
+ "type": "uint8"
12
+ }
13
+ ],
14
+ "name": "toInt",
15
+ "outputs": [
16
+ {
17
+ "internalType": "uint256",
18
+ "name": "",
19
+ "type": "uint256"
20
+ }
21
+ ],
22
+ "stateMutability": "pure",
23
+ "type": "function"
24
+ },
25
+ {
26
+ "inputs": [
27
+ {
28
+ "internalType": "uint256",
29
+ "name": "a",
30
+ "type": "uint256"
31
+ }
32
+ ],
33
+ "name": "toVersionPart",
34
+ "outputs": [
35
+ {
36
+ "internalType": "VersionPart",
37
+ "name": "",
38
+ "type": "uint8"
39
+ }
40
+ ],
41
+ "stateMutability": "pure",
42
+ "type": "function"
43
+ }
44
+ ],
45
+ "bytecode": "0x60fb610039600b82828239805160001a60731461002c57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80638e4ad86c146042578063ac43d834146067575b600080fd5b6050604d3660046085565b90565b60405160ff90911681526020015b60405180910390f35b60786072366004609d565b60ff1690565b604051908152602001605e565b600060208284031215609657600080fd5b5035919050565b60006020828403121560ae57600080fd5b813560ff8116811460be57600080fd5b939250505056fea264697066735822122074bb6f75f2cab9692d05e41844bf40283045a9440c662c37a97b2502d38207ed64736f6c63430008140033",
46
+ "deployedBytecode": "0x7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80638e4ad86c146042578063ac43d834146067575b600080fd5b6050604d3660046085565b90565b60405160ff90911681526020015b60405180910390f35b60786072366004609d565b60ff1690565b604051908152602001605e565b600060208284031215609657600080fd5b5035919050565b60006020828403121560ae57600080fd5b813560ff8116811460be57600080fd5b939250505056fea264697066735822122074bb6f75f2cab9692d05e41844bf40283045a9440c662c37a97b2502d38207ed64736f6c63430008140033",
47
+ "linkReferences": {},
48
+ "deployedLinkReferences": {}
49
+ }
@@ -0,0 +1,236 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
7
+
8
+ import {IComponent} from "./IComponent.sol";
9
+ import {IProductService} from "../instance/service/IProductService.sol";
10
+ import {IInstanceService} from "../instance/IInstanceService.sol";
11
+ import {IInstance} from "../instance/IInstance.sol";
12
+ import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
13
+ import {InstanceReader} from "../instance/InstanceReader.sol";
14
+ import {IRegistry} from "../registry/IRegistry.sol";
15
+ import {NftId} from "../types/NftId.sol";
16
+ import {ObjectType, INSTANCE, PRODUCT} from "../types/ObjectType.sol";
17
+ import {VersionPart} from "../types/Version.sol";
18
+ import {Registerable} from "../shared/Registerable.sol";
19
+ import {RoleId, RoleIdLib} from "../types/RoleId.sol";
20
+ import {IAccess} from "../instance/module/IAccess.sol";
21
+
22
+ // TODO discuss to inherit from oz accessmanaged
23
+ // then add (Distribution|Pool|Product)Upradeable that also intherit from Versionable
24
+ // same pattern as for Service which is also upgradeable
25
+ abstract contract Component is
26
+ Registerable,
27
+ IComponent,
28
+ AccessManagedUpgradeable
29
+ {
30
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Component.sol")) - 1)) & ~bytes32(uint256(0xff));
31
+ bytes32 public constant CONTRACT_LOCATION_V1 = 0xffe8d4462baed26a47154f4b8f6db497d2f772496965791d25bd456e342b7f00;
32
+
33
+ struct ComponentStorage {
34
+ IInstance _instance; // instance for this component
35
+ InstanceReader _instanceReader; // instance reader for this component
36
+ string _name; // unique (per instance) component name
37
+ IERC20Metadata _token; // token for this component
38
+ address _wallet; // wallet for this component (default = component contract itself)
39
+ bool _isNftInterceptor; // declares if component is involved in nft transfers
40
+ IInstanceService _instanceService; // instance service for this component
41
+
42
+ NftId _productNftId; // only relevant for components that are linked to a aproduct
43
+ IProductService _productService; // product service for component, might not be relevant for some component types (eg oracles)
44
+ }
45
+
46
+
47
+ modifier onlyChainNft() {
48
+ if(msg.sender != getRegistry().getChainNftAddress()) {
49
+ revert ErrorComponentNotChainNft(msg.sender);
50
+ }
51
+ _;
52
+ }
53
+
54
+
55
+ modifier onlyProductService() {
56
+ if(msg.sender != address(_getComponentStorage()._productService)) {
57
+ revert ErrorComponentNotProductService(msg.sender);
58
+ }
59
+ _;
60
+ }
61
+
62
+ function _getComponentStorage() private pure returns (ComponentStorage storage $) {
63
+ assembly {
64
+ $.slot := CONTRACT_LOCATION_V1
65
+ }
66
+ }
67
+
68
+ function initializeComponent(
69
+ address registry,
70
+ NftId instanceNftId,
71
+ string memory name,
72
+ address token,
73
+ ObjectType componentType,
74
+ bool isInterceptor,
75
+ address initialOwner,
76
+ bytes memory data
77
+ )
78
+ public
79
+ virtual
80
+ onlyInitializing()
81
+ {
82
+ ComponentStorage storage $ = _getComponentStorage();
83
+ initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, data);
84
+
85
+ // set unique name of component
86
+ $._name = name;
87
+ $._isNftInterceptor = isInterceptor;
88
+
89
+ // set and check linked instance
90
+ IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
91
+ $._instance = IInstance(instanceInfo.objectAddress);
92
+ if(!$._instance.supportsInterface(type(IInstance).interfaceId)) {
93
+ revert ErrorComponentNotInstance(instanceNftId, instanceInfo.objectAddress);
94
+ }
95
+
96
+ // initialize AccessManagedUpgradeable
97
+ __AccessManaged_init($._instance.authority());
98
+
99
+ // set linked services
100
+ VersionPart gifVersion = $._instance.getMajorVersion();
101
+ $._instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), gifVersion));
102
+ $._instanceReader = $._instance.getInstanceReader();
103
+ $._productService = IProductService(getRegistry().getServiceAddress(PRODUCT(), gifVersion));
104
+
105
+ // set wallet and token
106
+ $._wallet = address(this);
107
+ $._token = IERC20Metadata(token);
108
+
109
+ registerInterface(type(IComponent).interfaceId);
110
+ }
111
+
112
+ /// @dev callback function for nft transfers. may only be called by chain nft contract.
113
+ /// default implementation is empty. overriding functions MUST add onlyChainNft modifier
114
+ function nftTransferFrom(address from, address to, uint256 tokenId)
115
+ external
116
+ virtual override
117
+ onlyChainNft()
118
+ { }
119
+
120
+ // TODO discuss replacement with modifier restricted from accessmanaged
121
+ function lock() external onlyOwner override {
122
+ _getComponentStorage()._instanceService.setTargetLocked(getName(), true);
123
+ }
124
+
125
+ function unlock() external onlyOwner override {
126
+ _getComponentStorage()._instanceService.setTargetLocked(getName(), false);
127
+ }
128
+
129
+ // only product service may set product nft id during registration of product setup
130
+ function setProductNftId(NftId productNftId)
131
+ external
132
+ override
133
+ onlyProductService()
134
+ {
135
+ ComponentStorage storage $ = _getComponentStorage();
136
+
137
+ if($._productNftId.gtz()) {
138
+ revert ErrorComponentProductNftAlreadySet();
139
+ }
140
+
141
+ $._productNftId = productNftId;
142
+ }
143
+
144
+ /// @dev Sets the wallet address for the component.
145
+ /// if the current wallet has tokens, these will be transferred.
146
+ /// if the new wallet address is externally owned, an approval from the
147
+ /// owner of the external wallet for the component to move all tokens must exist.
148
+ function setWallet(address newWallet)
149
+ external
150
+ override
151
+ onlyOwner
152
+ {
153
+ ComponentStorage storage $ = _getComponentStorage();
154
+
155
+ address currentWallet = $._wallet;
156
+ uint256 currentBalance = $._token.balanceOf(currentWallet);
157
+
158
+ // checks
159
+ if (newWallet == address(0)) {
160
+ revert ErrorComponentWalletAddressZero();
161
+ }
162
+ if (newWallet == currentWallet) {
163
+ revert ErrorComponentWalletAddressIsSameAsCurrent(newWallet);
164
+ }
165
+
166
+ if (currentBalance > 0) {
167
+ if (currentWallet == address(this)) {
168
+ // move tokens from component smart contract to external wallet
169
+ } else {
170
+ // move tokens from external wallet to component smart contract or another external wallet
171
+ uint256 allowance = $._token.allowance(currentWallet, address(this));
172
+ if (allowance < currentBalance) {
173
+ revert ErrorComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
174
+ }
175
+ }
176
+ }
177
+
178
+ // effects
179
+ $._wallet = newWallet;
180
+ emit LogComponentWalletAddressChanged(newWallet);
181
+
182
+ // interactions
183
+ if (currentBalance > 0) {
184
+ // transfer tokens from current wallet to new wallet
185
+ if (currentWallet == address(this)) {
186
+ // transferFrom requires self allowance too
187
+ $._token.approve(address(this), currentBalance);
188
+ }
189
+
190
+ SafeERC20.safeTransferFrom($._token, currentWallet, newWallet, currentBalance);
191
+ emit LogComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
192
+ }
193
+ }
194
+
195
+ function getWallet()
196
+ public
197
+ view
198
+ override
199
+ returns (address walletAddress)
200
+ {
201
+ return _getComponentStorage()._wallet;
202
+ }
203
+
204
+ function getToken() public view override returns (IERC20Metadata token) {
205
+ return _getComponentStorage()._token;
206
+ }
207
+
208
+ function isNftInterceptor() public view override returns(bool isInterceptor) {
209
+ return _getComponentStorage()._isNftInterceptor;
210
+ }
211
+
212
+ function getInstance() public view override returns (IInstance instance) {
213
+ return _getComponentStorage()._instance;
214
+ }
215
+
216
+ function getInstanceReader() public view returns (InstanceReader reader) {
217
+ return _getComponentStorage()._instanceReader;
218
+ }
219
+
220
+ function getName() public view override returns(string memory name) {
221
+ return _getComponentStorage()._name;
222
+ }
223
+
224
+ function getProductNftId() public view override returns (NftId productNftId) {
225
+ return _getComponentStorage()._productNftId;
226
+ }
227
+
228
+ function getInstanceService() public view returns (IInstanceService) {
229
+ return _getComponentStorage()._instanceService;
230
+ }
231
+
232
+ function getProductService() public view returns (IProductService) {
233
+ return _getComponentStorage()._productService;
234
+ }
235
+
236
+ }
@@ -0,0 +1,298 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {DISTRIBUTION} from "../types/ObjectType.sol";
5
+ import {IDistributionService} from "../instance/service/IDistributionService.sol";
6
+ import {IProductService} from "../instance/service/IProductService.sol";
7
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
8
+ import {ReferralId, ReferralStatus, ReferralLib} from "../types/Referral.sol";
9
+ import {Fee, FeeLib} from "../types/Fee.sol";
10
+ import {Component} from "./Component.sol";
11
+ import {IDistributionComponent} from "./IDistributionComponent.sol";
12
+ import {IRegistry} from "../registry/IRegistry.sol";
13
+ import {IRegisterable} from "../shared/IRegisterable.sol";
14
+ import {ISetup} from "../instance/module/ISetup.sol";
15
+ import {Registerable} from "../shared/Registerable.sol";
16
+ import {TokenHandler} from "../shared/TokenHandler.sol";
17
+ import {InstanceReader} from "../instance/InstanceReader.sol";
18
+ import {UFixed} from "../types/UFixed.sol";
19
+ import {DistributorType} from "../types/DistributorType.sol";
20
+ import {Timestamp} from "../types/Timestamp.sol";
21
+
22
+
23
+ abstract contract Distribution is
24
+ Component,
25
+ IDistributionComponent
26
+ {
27
+ // keccak256(abi.encode(uint256(keccak256("etherisc.storage.Distribution")) - 1)) & ~bytes32(uint256(0xff));
28
+ bytes32 public constant DISTRIBUTION_STORAGE_LOCATION_V1 = 0xaab7c5ea03d290056d6c060e0833d3ebcbe647f7694616a2ec52738a64b2f900;
29
+
30
+ struct DistributionStorage {
31
+ Fee _distributionFee;
32
+ TokenHandler _tokenHandler;
33
+ IDistributionService _distributionService;
34
+ mapping(address distributor => NftId distributorNftId) _distributorNftId;
35
+ }
36
+
37
+ function initializeDistribution(
38
+ address registry,
39
+ NftId instanceNftId,
40
+ string memory name,
41
+ address token,
42
+ Fee memory distributionFee,
43
+ address initialOwner,
44
+ bytes memory data
45
+ )
46
+ public
47
+ virtual
48
+ onlyInitializing()
49
+ {
50
+ initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, data);
51
+
52
+ DistributionStorage storage $ = _getDistributionStorage();
53
+ // TODO add validation
54
+ $._distributionFee = distributionFee;
55
+ $._tokenHandler = new TokenHandler(token);
56
+ $._distributionService = getInstance().getDistributionService();
57
+
58
+ registerInterface(type(IDistributionComponent).interfaceId);
59
+ }
60
+
61
+ function setFees(
62
+ Fee memory distributionFee
63
+ )
64
+ external
65
+ override
66
+ onlyOwner
67
+ restricted()
68
+ {
69
+ _getDistributionStorage()._distributionService.setFees(distributionFee);
70
+ }
71
+
72
+ function getDistributionFee() external view returns (Fee memory distributionFee) {
73
+ DistributionStorage storage $ = _getDistributionStorage();
74
+ return $._distributionFee;
75
+ }
76
+
77
+ function createDistributorType(
78
+ string memory name,
79
+ UFixed minDiscountPercentage,
80
+ UFixed maxDiscountPercentage,
81
+ UFixed commissionPercentage,
82
+ uint32 maxReferralCount,
83
+ uint32 maxReferralLifetime,
84
+ bool allowSelfReferrals,
85
+ bool allowRenewals,
86
+ bytes memory data
87
+ )
88
+ public
89
+ returns (DistributorType distributorType)
90
+ {
91
+ DistributionStorage storage $ = _getDistributionStorage();
92
+ distributorType = $._distributionService.createDistributorType(
93
+ name,
94
+ minDiscountPercentage,
95
+ maxDiscountPercentage,
96
+ commissionPercentage,
97
+ maxReferralCount,
98
+ maxReferralLifetime,
99
+ allowSelfReferrals,
100
+ allowRenewals,
101
+ data);
102
+ }
103
+
104
+ function createDistributor(
105
+ address distributor,
106
+ DistributorType distributorType,
107
+ bytes memory data
108
+ )
109
+ public
110
+ returns(NftId distributorNftId)
111
+ {
112
+ DistributionStorage storage $ = _getDistributionStorage();
113
+ require($._distributorNftId[distributor].eqz(), "ERROR:DST-030:ALREADY_DISTRIBUTOR");
114
+
115
+ distributorNftId = $._distributionService.createDistributor(
116
+ distributor,
117
+ distributorType,
118
+ data);
119
+
120
+ $._distributorNftId[distributor] = distributorNftId;
121
+ }
122
+
123
+ function updateDistributorType(
124
+ NftId distributorNftId,
125
+ DistributorType distributorType,
126
+ bytes memory data
127
+ )
128
+ public
129
+ // TODO figure out what we need for authz
130
+ // and add it
131
+ {
132
+ DistributionStorage storage $ = _getDistributionStorage();
133
+ $._distributionService.updateDistributorType(
134
+ distributorNftId,
135
+ distributorType,
136
+ data);
137
+ }
138
+
139
+ /**
140
+ * @dev lets distributors create referral codes.
141
+ * referral codes need to be unique
142
+ */
143
+ function createReferral(
144
+ NftId distributorNftId,
145
+ string memory code,
146
+ UFixed discountPercentage,
147
+ uint32 maxReferrals,
148
+ Timestamp expiryAt,
149
+ bytes memory data
150
+ )
151
+ public
152
+ // TODO add authz (only active distributor)
153
+ returns (ReferralId referralId)
154
+ {
155
+ DistributionStorage storage $ = _getDistributionStorage();
156
+ referralId = $._distributionService.createReferral(
157
+ distributorNftId,
158
+ code,
159
+ discountPercentage,
160
+ maxReferrals,
161
+ expiryAt,
162
+ data);
163
+ }
164
+
165
+ function calculateFeeAmount(
166
+ ReferralId referralId,
167
+ uint256 netPremiumAmount
168
+ )
169
+ external
170
+ view
171
+ virtual override
172
+ returns (uint256 feeAmount)
173
+ {
174
+ ISetup.DistributionSetupInfo memory setupInfo = getSetupInfo();
175
+ Fee memory fee = setupInfo.distributionFee;
176
+ (feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
177
+ // TODO: use this?
178
+ // return _distributionService.calculateFeeAmount(referralId, premiumAmount);
179
+ }
180
+
181
+ function isDistributor(address candidate)
182
+ public
183
+ view
184
+ returns (bool)
185
+ {
186
+ DistributionStorage storage $ = _getDistributionStorage();
187
+ return $._distributorNftId[candidate].gtz();
188
+ }
189
+
190
+ function getDistributorNftId(address distributor)
191
+ public
192
+ view
193
+ returns (NftId distributorNftId)
194
+ {
195
+ DistributionStorage storage $ = _getDistributionStorage();
196
+ return $._distributorNftId[distributor];
197
+ }
198
+
199
+ function getDiscountPercentage(string memory referralCode)
200
+ external
201
+ view
202
+ returns (
203
+ UFixed discountPercentage,
204
+ ReferralStatus status
205
+ )
206
+ {
207
+ ReferralId referralId = getReferralId(referralCode);
208
+ return getInstanceReader().getDiscountPercentage(referralId);
209
+ }
210
+
211
+
212
+ function getReferralId(
213
+ string memory referralCode
214
+ )
215
+ public
216
+ view
217
+ returns (ReferralId referralId)
218
+ {
219
+ return ReferralLib.toReferralId(
220
+ getNftId(),
221
+ referralCode);
222
+ }
223
+
224
+ function calculateRenewalFeeAmount(
225
+ ReferralId referralId,
226
+ uint256 netPremiumAmount
227
+ )
228
+ external
229
+ view
230
+ virtual override
231
+ returns (uint256 feeAmount)
232
+ {
233
+ // default is no fees
234
+ return 0 * netPremiumAmount;
235
+ }
236
+
237
+ function processSale(
238
+ ReferralId referralId,
239
+ uint256 premiumAmount
240
+ )
241
+ external
242
+ onlyOwner
243
+ restricted()
244
+ virtual override
245
+ {
246
+ DistributionStorage storage $ = _getDistributionStorage();
247
+ $._distributionService.processSale(referralId, premiumAmount);
248
+ }
249
+
250
+ function processRenewal(
251
+ ReferralId referralId,
252
+ uint256 feeAmount
253
+ )
254
+ external
255
+ onlyOwner
256
+ restricted()
257
+ virtual override
258
+ {
259
+ // default is no action
260
+ }
261
+
262
+ function referralIsValid(ReferralId referralId) external view returns (bool isValid) {
263
+ // default is invalid
264
+ return false;
265
+ }
266
+
267
+ function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
268
+ InstanceReader reader = getInstance().getInstanceReader();
269
+ setupInfo = reader.getDistributionSetupInfo(getNftId());
270
+
271
+ // fallback to initial setup info (wallet is always != address(0))
272
+ if(setupInfo.wallet == address(0)) {
273
+ setupInfo = _getInitialSetupInfo();
274
+ }
275
+ }
276
+
277
+ function _getInitialSetupInfo() internal view returns (ISetup.DistributionSetupInfo memory setupInfo) {
278
+ DistributionStorage storage $ = _getDistributionStorage();
279
+ return ISetup.DistributionSetupInfo(
280
+ zeroNftId(),
281
+ $._tokenHandler,
282
+ $._distributionFee,
283
+ address(this)
284
+ );
285
+ }
286
+
287
+
288
+ /// @dev returns true iff the component needs to be called when selling/renewing policis
289
+ function isVerifying() external view returns (bool verifying) {
290
+ return true;
291
+ }
292
+
293
+ function _getDistributionStorage() private pure returns (DistributionStorage storage $) {
294
+ assembly {
295
+ $.slot := DISTRIBUTION_STORAGE_LOCATION_V1
296
+ }
297
+ }
298
+ }
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
+
6
+ import {IRegisterable} from "../shared/IRegisterable.sol";
7
+ import {IInstance} from "../instance/IInstance.sol";
8
+ import {IInstanceService} from "../instance/IInstanceService.sol";
9
+ import {IProductService} from "../instance/service/IProductService.sol";
10
+ import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
11
+ import {NftId} from "../types/NftId.sol";
12
+
13
+ interface IComponent is
14
+ IRegisterable,
15
+ ITransferInterceptor
16
+ {
17
+
18
+ error ErrorComponentNotChainNft(address caller);
19
+ error ErrorComponentNotProductService(address caller);
20
+ error ErrorComponentNotInstance(NftId instanceNftId, address instance);
21
+ error ErrorComponentProductNftAlreadySet();
22
+ error ErrorComponentWalletAddressZero();
23
+ error ErrorComponentWalletAddressIsSameAsCurrent(address newWallet);
24
+ error ErrorComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
25
+ error ErrorComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
26
+
27
+ event LogComponentWalletAddressChanged(address newWallet);
28
+ event LogComponentWalletTokensTransferred(address from, address to, uint256 amount);
29
+
30
+ function getName() external view returns (string memory name);
31
+
32
+ // TODO remove and replace with accessmanaged target locking mechanism
33
+ function lock() external;
34
+ function unlock() external;
35
+
36
+ function getToken() external view returns (IERC20Metadata token);
37
+
38
+ function setWallet(address walletAddress) external;
39
+ function getWallet() external view returns (address walletAddress);
40
+
41
+ function isNftInterceptor() external view returns(bool isInterceptor);
42
+
43
+ function getInstance() external view returns (IInstance instance);
44
+
45
+ function setProductNftId(NftId productNftId) external;
46
+ function getProductNftId() external view returns (NftId productNftId);
47
+
48
+ function getInstanceService() external view returns (IInstanceService);
49
+ function getProductService() external view returns (IProductService);
50
+ }