@etherisc/gif-next 0.0.2-af8c650-079 → 0.0.2-afc9e82-014

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 (551) hide show
  1. package/README.md +249 -23
  2. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +4 -0
  3. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +1376 -0
  4. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +4 -0
  5. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +1556 -0
  6. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  7. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +780 -0
  8. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +1000 -0
  10. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  11. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +840 -0
  12. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  13. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +778 -0
  14. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  15. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +320 -1684
  16. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  17. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +616 -0
  18. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  19. package/artifacts/contracts/instance/Instance.sol/Instance.json +420 -1756
  20. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  21. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +1348 -0
  22. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +4 -0
  23. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +124 -0
  24. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  25. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1574 -0
  26. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  27. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +979 -0
  28. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  29. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +656 -0
  30. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
  31. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2847 -0
  32. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +4 -0
  33. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.json +190 -0
  34. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  35. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +478 -0
  36. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  37. package/artifacts/contracts/instance/{module/lifecycle/ILifecycle.sol/ILifecycleModule.json → base/ILifecycle.sol/ILifecycle.json} +10 -77
  38. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  39. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +581 -0
  40. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  41. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +194 -0
  42. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  43. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +256 -0
  44. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  45. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +237 -0
  46. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  47. package/artifacts/contracts/instance/module/{bundle/IBundle.sol → IBundle.sol}/IBundle.json +1 -1
  48. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  49. package/artifacts/contracts/instance/module/{access/IAccess.sol/IAccess.json → IComponents.sol/IComponents.json} +2 -2
  50. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  51. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
  52. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  53. package/artifacts/contracts/instance/module/{policy/IPolicy.sol → IPolicy.sol}/IPolicy.json +1 -1
  54. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  55. package/artifacts/contracts/instance/module/{risk/IRisk.sol → IRisk.sol}/IRisk.json +1 -1
  56. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  57. package/artifacts/contracts/instance/module/{pool/IPoolModule.sol/IPool.json → ISetup.sol/ISetup.json} +2 -2
  58. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  59. package/artifacts/contracts/instance/module/{treasury/ITreasury.sol → ITreasury.sol}/ITreasury.json +1 -1
  60. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +4 -0
  61. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +1288 -0
  62. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  63. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +696 -0
  64. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +4 -0
  65. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +735 -0
  66. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
  67. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +1095 -0
  68. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +4 -0
  69. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +1077 -0
  70. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +4 -0
  71. package/artifacts/contracts/pool/Pool.sol/Pool.json +1407 -0
  72. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +4 -0
  73. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +1622 -0
  74. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  75. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +708 -0
  76. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +4 -0
  77. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +918 -0
  78. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
  79. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +648 -0
  80. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +4 -0
  81. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +1386 -0
  82. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
  83. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +748 -0
  84. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +4 -0
  85. package/artifacts/contracts/{instance/service/IProductService.sol/IProductService.json → product/IApplicationService.sol/IApplicationService.json} +250 -234
  86. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +4 -0
  87. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +753 -0
  88. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  89. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +651 -0
  90. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +4 -0
  91. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +510 -0
  92. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +4 -0
  93. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +861 -0
  94. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +4 -0
  95. package/artifacts/contracts/{instance/service/IPoolService.sol/IPoolService.json → product/IProductService.sol/IProductService.json} +222 -156
  96. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +4 -0
  97. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +1281 -0
  98. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  99. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +740 -0
  100. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +4 -0
  101. package/artifacts/contracts/product/PricingService.sol/PricingService.json +1004 -0
  102. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +4 -0
  103. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +688 -0
  104. package/artifacts/contracts/product/Product.sol/Product.dbg.json +4 -0
  105. package/artifacts/contracts/product/Product.sol/Product.json +1198 -0
  106. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +4 -0
  107. package/artifacts/contracts/product/ProductService.sol/ProductService.json +864 -0
  108. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  109. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +640 -0
  110. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  111. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +199 -12
  112. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +485 -34
  114. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  115. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +858 -0
  116. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  117. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +52 -0
  118. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  119. package/artifacts/contracts/registry/Registry.sol/Registry.json +491 -105
  120. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  121. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  122. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  123. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1150 -0
  124. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  125. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +657 -0
  126. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  127. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +559 -0
  128. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  129. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +485 -0
  130. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  131. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  132. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +4 -0
  133. package/artifacts/contracts/shared/Component.sol/Component.json +873 -0
  134. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +4 -0
  135. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +631 -0
  136. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  137. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
  138. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +4 -0
  139. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +636 -0
  140. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  141. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +125 -0
  142. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
  143. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +189 -0
  144. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  145. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +91 -37
  146. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  147. package/artifacts/contracts/{registry → shared}/IRegistryLinked.sol/IRegistryLinked.json +13 -2
  148. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  149. package/artifacts/contracts/{instance/InstanceBase.sol/InstanceBase.json → shared/IService.sol/IService.json} +160 -146
  150. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  151. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +16 -125
  152. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  153. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +238 -0
  154. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
  155. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +302 -0
  156. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  157. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +569 -0
  158. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  159. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +245 -27
  160. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
  161. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +71 -0
  162. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  163. package/artifacts/contracts/{registry/IChainNft.sol/IChainNft.json → shared/Service.sol/Service.json} +256 -220
  164. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  165. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +114 -0
  166. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  167. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  168. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  169. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +29 -115
  170. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +4 -0
  171. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +523 -0
  172. package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.dbg.json +4 -0
  173. package/artifacts/contracts/staking/StakeingServiceManager.sol/StakingServiceManager.json +628 -0
  174. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +4 -0
  175. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +767 -0
  176. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  177. package/artifacts/contracts/{types → type}/AddressSet.sol/LibAddressSet.json +3 -3
  178. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +4 -0
  179. package/artifacts/contracts/type/Amount.sol/AmountLib.json +281 -0
  180. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
  181. package/artifacts/contracts/{types → type}/Blocknumber.sol/BlocknumberLib.json +3 -3
  182. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
  183. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +179 -0
  184. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  185. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +104 -0
  186. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +4 -0
  187. package/artifacts/contracts/type/Fee.sol/FeeLib.json +312 -0
  188. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +4 -0
  189. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +125 -0
  190. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +4 -0
  191. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +166 -0
  192. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  193. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +33 -0
  194. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  195. package/artifacts/contracts/{types → type}/ObjectType.sol/ObjectTypeLib.json +3 -3
  196. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
  197. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +209 -0
  198. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +4 -0
  199. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +142 -0
  200. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +4 -0
  201. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +86 -0
  202. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +4 -0
  203. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +156 -0
  204. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +4 -0
  205. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +124 -0
  206. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +4 -0
  207. package/artifacts/contracts/{types → type}/StateId.sol/StateIdLib.json +3 -3
  208. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +4 -0
  209. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +280 -0
  210. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +4 -0
  211. package/artifacts/contracts/{types/ChainId.sol/ChainIdLib.json → type/UFixed.sol/MathLib.json} +4 -4
  212. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +4 -0
  213. package/artifacts/contracts/{types/UFixed.sol/UFixedMathLib.json → type/UFixed.sol/UFixedLib.json} +4 -4
  214. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +4 -0
  215. package/artifacts/contracts/type/Version.sol/VersionLib.json +177 -0
  216. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +4 -0
  217. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +49 -0
  218. package/contracts/distribution/Distribution.sol +285 -0
  219. package/contracts/distribution/DistributionService.sol +349 -0
  220. package/contracts/distribution/DistributionServiceManager.sol +51 -0
  221. package/contracts/distribution/IDistributionComponent.sol +71 -0
  222. package/contracts/distribution/IDistributionService.sol +87 -0
  223. package/contracts/instance/BundleManager.sol +126 -0
  224. package/contracts/instance/IInstance.sol +69 -45
  225. package/contracts/instance/IInstanceService.sol +73 -0
  226. package/contracts/instance/Instance.sol +216 -53
  227. package/contracts/instance/InstanceAccessManager.sol +543 -0
  228. package/contracts/instance/InstanceAuthorizationsLib.sol +308 -0
  229. package/contracts/instance/InstanceReader.sol +368 -0
  230. package/contracts/instance/InstanceService.sol +308 -0
  231. package/contracts/instance/InstanceServiceManager.sol +54 -0
  232. package/contracts/instance/InstanceStore.sol +211 -0
  233. package/contracts/instance/base/Cloneable.sol +51 -0
  234. package/contracts/instance/base/IKeyValueStore.sol +53 -0
  235. package/contracts/instance/base/ILifecycle.sol +30 -0
  236. package/contracts/instance/base/KeyValueStore.sol +169 -0
  237. package/contracts/instance/base/Lifecycle.sol +121 -0
  238. package/contracts/instance/base/ObjectManager.sol +82 -0
  239. package/contracts/instance/module/IAccess.sol +54 -0
  240. package/contracts/instance/module/IBundle.sol +23 -0
  241. package/contracts/instance/module/IComponents.sol +41 -0
  242. package/contracts/instance/module/IDistribution.sol +42 -0
  243. package/contracts/instance/module/IPolicy.sol +78 -0
  244. package/contracts/instance/module/IRisk.sol +11 -0
  245. package/contracts/instance/module/ISetup.sol +33 -0
  246. package/contracts/instance/module/ITreasury.sol +23 -0
  247. package/contracts/pool/BundleService.sol +382 -0
  248. package/contracts/pool/BundleServiceManager.sol +51 -0
  249. package/contracts/pool/IBundleService.sol +118 -0
  250. package/contracts/pool/IPoolComponent.sol +114 -0
  251. package/contracts/pool/IPoolService.sol +114 -0
  252. package/contracts/pool/Pool.sol +302 -0
  253. package/contracts/pool/PoolService.sol +403 -0
  254. package/contracts/pool/PoolServiceManager.sol +51 -0
  255. package/contracts/product/ApplicationService.sol +186 -0
  256. package/contracts/product/ApplicationServiceManager.sol +35 -0
  257. package/contracts/product/ClaimService.sol +442 -0
  258. package/contracts/product/ClaimServiceManager.sol +35 -0
  259. package/contracts/product/IApplicationService.sol +62 -0
  260. package/contracts/product/IClaimService.sol +93 -0
  261. package/contracts/product/IPolicyService.sol +80 -0
  262. package/contracts/product/IPricingService.sol +37 -0
  263. package/contracts/product/IProductComponent.sol +41 -0
  264. package/contracts/product/IProductService.sol +40 -0
  265. package/contracts/product/PolicyService.sol +376 -0
  266. package/contracts/product/PolicyServiceManager.sol +54 -0
  267. package/contracts/product/PricingService.sol +275 -0
  268. package/contracts/product/PricingServiceManager.sol +51 -0
  269. package/contracts/product/Product.sol +379 -0
  270. package/contracts/product/ProductService.sol +210 -0
  271. package/contracts/product/ProductServiceManager.sol +54 -0
  272. package/contracts/registry/ChainNft.sol +87 -36
  273. package/contracts/registry/IRegistry.sol +71 -27
  274. package/contracts/registry/IRegistryService.sol +66 -0
  275. package/contracts/registry/ITransferInterceptor.sol +7 -0
  276. package/contracts/registry/Registry.sol +372 -286
  277. package/contracts/registry/RegistryAccessManager.sol +216 -0
  278. package/contracts/registry/RegistryService.sol +285 -0
  279. package/contracts/registry/RegistryServiceManager.sol +60 -0
  280. package/contracts/registry/ReleaseManager.sol +328 -0
  281. package/contracts/registry/TokenRegistry.sol +116 -0
  282. package/contracts/shared/AccessManagerUpgradeableInitializeable.sol +13 -0
  283. package/contracts/shared/Component.sol +271 -0
  284. package/contracts/shared/ComponentService.sol +150 -0
  285. package/contracts/shared/ERC165.sol +14 -8
  286. package/contracts/shared/IComponent.sol +90 -0
  287. package/contracts/shared/INftOwnable.sol +23 -0
  288. package/contracts/shared/IPolicyHolder.sol +40 -0
  289. package/contracts/shared/IRegisterable.sol +10 -19
  290. package/contracts/shared/IRegistryLinked.sol +11 -0
  291. package/contracts/shared/IService.sol +18 -0
  292. package/contracts/shared/IVersionable.sol +38 -37
  293. package/contracts/shared/NftOwnable.sol +118 -0
  294. package/contracts/shared/PolicyHolder.sol +94 -0
  295. package/contracts/shared/ProxyManager.sol +169 -0
  296. package/contracts/shared/Registerable.sol +54 -65
  297. package/contracts/shared/RegistryLinked.sol +43 -0
  298. package/contracts/shared/Service.sol +72 -0
  299. package/contracts/shared/TokenHandler.sol +35 -0
  300. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  301. package/contracts/shared/Versionable.sol +38 -68
  302. package/contracts/staking/IStakingService.sol +102 -0
  303. package/contracts/staking/StakeingServiceManager.sol +37 -0
  304. package/contracts/staking/StakingService.sol +166 -0
  305. package/contracts/type/Amount.sol +109 -0
  306. package/contracts/{types → type}/Blocknumber.sol +1 -0
  307. package/contracts/type/ClaimId.sol +75 -0
  308. package/contracts/type/DistributorType.sol +55 -0
  309. package/contracts/type/Fee.sol +65 -0
  310. package/contracts/type/Key32.sol +50 -0
  311. package/contracts/{types → type}/NftId.sol +24 -1
  312. package/contracts/type/NftIdSet.sol +62 -0
  313. package/contracts/{types → type}/ObjectType.sol +62 -15
  314. package/contracts/type/PayoutId.sol +82 -0
  315. package/contracts/type/Referral.sol +89 -0
  316. package/contracts/type/RiskId.sol +43 -0
  317. package/contracts/type/RoleId.sol +132 -0
  318. package/contracts/type/Seconds.sol +54 -0
  319. package/contracts/{types → type}/StateId.sol +19 -4
  320. package/contracts/{types → type}/Timestamp.sol +22 -13
  321. package/contracts/{types → type}/UFixed.sol +129 -12
  322. package/contracts/{types → type}/Version.sol +14 -1
  323. package/package.json +6 -5
  324. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +0 -4
  325. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +0 -174
  326. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
  327. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +0 -174
  328. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +0 -4
  329. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +0 -356
  330. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +0 -4
  331. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +0 -279
  332. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +0 -4
  333. package/artifacts/contracts/components/Pool.sol/Pool.json +0 -387
  334. package/artifacts/contracts/components/Product.sol/Product.dbg.json +0 -4
  335. package/artifacts/contracts/components/Product.sol/Product.json +0 -305
  336. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
  337. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
  338. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
  339. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
  340. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
  341. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
  342. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
  343. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
  344. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
  345. package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
  346. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
  347. package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
  348. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
  349. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
  350. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
  351. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
  352. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
  353. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +0 -50
  354. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
  355. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
  356. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
  357. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
  358. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
  359. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
  360. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
  361. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
  362. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
  363. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
  364. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
  365. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
  366. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
  367. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
  368. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
  369. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
  370. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +0 -4
  371. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.json +0 -24
  372. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.dbg.json +0 -4
  373. package/artifacts/contracts/instance/IServiceLinked.sol/IServiceLinked.json +0 -50
  374. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +0 -4
  375. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +0 -4
  376. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.json +0 -333
  377. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +0 -4
  378. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  379. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.json +0 -333
  380. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +0 -4
  381. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +0 -276
  382. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +0 -4
  383. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +0 -4
  384. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +0 -276
  385. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
  386. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
  387. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
  388. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.json +0 -10
  389. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
  390. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.json +0 -10
  391. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  392. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +0 -188
  393. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +0 -4
  394. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.json +0 -10
  395. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  396. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +0 -188
  397. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.dbg.json +0 -4
  398. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycle.json +0 -134
  399. package/artifacts/contracts/instance/module/lifecycle/ILifecycle.sol/ILifecycleModule.dbg.json +0 -4
  400. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.dbg.json +0 -4
  401. package/artifacts/contracts/instance/module/lifecycle/LifecycleModule.sol/LifecycleModule.json +0 -221
  402. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  403. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  404. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +0 -261
  405. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  406. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +0 -261
  407. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  408. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  409. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -149
  410. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  411. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -149
  412. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +0 -4
  413. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +0 -4
  414. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +0 -10
  415. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +0 -4
  416. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +0 -10
  417. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +0 -4
  418. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +0 -4
  419. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +0 -533
  420. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +0 -4
  421. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +0 -76
  422. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +0 -4
  423. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +0 -533
  424. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +0 -4
  425. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +0 -491
  426. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +0 -4
  427. package/artifacts/contracts/instance/service/ComponentServiceBase.sol/ComponentServiceBase.json +0 -300
  428. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +0 -4
  429. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +0 -364
  430. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +0 -4
  431. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +0 -4
  432. package/artifacts/contracts/instance/service/IService.sol/IService.dbg.json +0 -4
  433. package/artifacts/contracts/instance/service/IService.sol/IService.json +0 -300
  434. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +0 -4
  435. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +0 -471
  436. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +0 -4
  437. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +0 -673
  438. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.dbg.json +0 -4
  439. package/artifacts/contracts/instance/service/ServiceBase.sol/ServiceBase.json +0 -300
  440. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  441. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +0 -4
  442. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +0 -4
  443. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.json +0 -24
  444. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +0 -4
  445. package/artifacts/contracts/test/TestFee.sol/TestFee.json +0 -119
  446. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +0 -4
  447. package/artifacts/contracts/test/TestPool.sol/TestPool.json +0 -387
  448. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +0 -4
  449. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +0 -393
  450. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +0 -4
  451. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +0 -137
  452. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +0 -4
  453. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +0 -82
  454. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +0 -4
  455. package/artifacts/contracts/test/TestService.sol/TestService.json +0 -379
  456. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +0 -4
  457. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +0 -338
  458. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +0 -4
  459. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +0 -218
  460. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +0 -4
  461. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +0 -206
  462. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +0 -4
  463. package/artifacts/contracts/test/Usdc.sol/USDC.json +0 -338
  464. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +0 -4
  465. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +0 -4
  466. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +0 -4
  467. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +0 -4
  468. package/artifacts/contracts/types/Fee.sol/FeeLib.json +0 -218
  469. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +0 -4
  470. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +0 -92
  471. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +0 -4
  472. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +0 -10
  473. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +0 -4
  474. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +0 -4
  475. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +0 -4
  476. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +0 -236
  477. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  478. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +0 -4
  479. package/artifacts/contracts/types/Version.sol/VersionLib.json +0 -139
  480. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +0 -4
  481. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +0 -30
  482. package/contracts/components/BaseComponent.sol +0 -89
  483. package/contracts/components/IBaseComponent.sol +0 -19
  484. package/contracts/components/IPoolComponent.sol +0 -57
  485. package/contracts/components/IProductComponent.sol +0 -19
  486. package/contracts/components/Pool.sol +0 -174
  487. package/contracts/components/Product.sol +0 -117
  488. package/contracts/experiment/errors/Require.sol +0 -38
  489. package/contracts/experiment/errors/Revert.sol +0 -44
  490. package/contracts/experiment/inheritance/A.sol +0 -53
  491. package/contracts/experiment/inheritance/B.sol +0 -28
  492. package/contracts/experiment/inheritance/C.sol +0 -34
  493. package/contracts/experiment/inheritance/IA.sol +0 -13
  494. package/contracts/experiment/inheritance/IB.sol +0 -10
  495. package/contracts/experiment/inheritance/IC.sol +0 -12
  496. package/contracts/experiment/statemachine/Dummy.sol +0 -27
  497. package/contracts/experiment/statemachine/ISM.sol +0 -25
  498. package/contracts/experiment/statemachine/README.md +0 -112
  499. package/contracts/experiment/statemachine/SM.sol +0 -57
  500. package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
  501. package/contracts/experiment/types/TypeA.sol +0 -47
  502. package/contracts/experiment/types/TypeB.sol +0 -29
  503. package/contracts/instance/IInstanceLinked.sol +0 -8
  504. package/contracts/instance/IServiceLinked.sol +0 -12
  505. package/contracts/instance/InstanceBase.sol +0 -71
  506. package/contracts/instance/module/access/Access.sol +0 -149
  507. package/contracts/instance/module/access/IAccess.sol +0 -53
  508. package/contracts/instance/module/bundle/BundleModule.sol +0 -228
  509. package/contracts/instance/module/bundle/IBundle.sol +0 -53
  510. package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
  511. package/contracts/instance/module/compensation/ICompensation.sol +0 -10
  512. package/contracts/instance/module/component/ComponentModule.sol +0 -103
  513. package/contracts/instance/module/component/IComponent.sol +0 -53
  514. package/contracts/instance/module/lifecycle/ILifecycle.sol +0 -47
  515. package/contracts/instance/module/lifecycle/LifecycleModule.sol +0 -89
  516. package/contracts/instance/module/policy/IPolicy.sol +0 -60
  517. package/contracts/instance/module/policy/PolicyModule.sol +0 -84
  518. package/contracts/instance/module/pool/IPoolModule.sol +0 -41
  519. package/contracts/instance/module/pool/PoolModule.sol +0 -87
  520. package/contracts/instance/module/risk/IRisk.sol +0 -10
  521. package/contracts/instance/module/risk/RiskModule.sol +0 -8
  522. package/contracts/instance/module/treasury/ITreasury.sol +0 -103
  523. package/contracts/instance/module/treasury/TokenHandler.sol +0 -48
  524. package/contracts/instance/module/treasury/TreasuryModule.sol +0 -152
  525. package/contracts/instance/service/ComponentOwnerService.sol +0 -171
  526. package/contracts/instance/service/ComponentServiceBase.sol +0 -41
  527. package/contracts/instance/service/IComponentOwnerService.sol +0 -22
  528. package/contracts/instance/service/IPoolService.sol +0 -30
  529. package/contracts/instance/service/IProductService.sol +0 -58
  530. package/contracts/instance/service/IService.sol +0 -15
  531. package/contracts/instance/service/PoolService.sol +0 -123
  532. package/contracts/instance/service/ProductService.sol +0 -355
  533. package/contracts/instance/service/ServiceBase.sol +0 -39
  534. package/contracts/registry/IChainNft.sol +0 -21
  535. package/contracts/registry/IRegistryLinked.sol +0 -8
  536. package/contracts/shared/IOwnable.sol +0 -6
  537. package/contracts/test/TestFee.sol +0 -25
  538. package/contracts/test/TestPool.sol +0 -22
  539. package/contracts/test/TestProduct.sol +0 -44
  540. package/contracts/test/TestRegisterable.sol +0 -19
  541. package/contracts/test/TestRoleId.sol +0 -14
  542. package/contracts/test/TestService.sol +0 -32
  543. package/contracts/test/TestToken.sol +0 -26
  544. package/contracts/test/TestVersion.sol +0 -44
  545. package/contracts/test/TestVersionable.sol +0 -17
  546. package/contracts/test/Usdc.sol +0 -26
  547. package/contracts/types/ChainId.sol +0 -38
  548. package/contracts/types/Fee.sol +0 -51
  549. package/contracts/types/NftIdSet.sol +0 -60
  550. package/contracts/types/RoleId.sol +0 -36
  551. /package/contracts/{types → type}/AddressSet.sol +0 -0
@@ -0,0 +1,75 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ // uint16 allows for 65'535 claims per policy
5
+ type ClaimId is uint16;
6
+
7
+ import {CLAIM} from "./ObjectType.sol";
8
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
9
+ import {NftId} from "./NftId.sol";
10
+
11
+ // type bindings
12
+ using {
13
+ eqClaimId as ==,
14
+ neClaimId as !=,
15
+ ClaimIdLib.eqz,
16
+ ClaimIdLib.gtz,
17
+ ClaimIdLib.toInt,
18
+ ClaimIdLib.toKey32
19
+ } for ClaimId global;
20
+
21
+
22
+ // pure free functions for operators
23
+ function eqClaimId(ClaimId a, ClaimId b) pure returns (bool isSame) {
24
+ return ClaimId.unwrap(a) == ClaimId.unwrap(b);
25
+ }
26
+
27
+ function neClaimId(ClaimId a, ClaimId b) pure returns (bool isDifferent) {
28
+ return ClaimId.unwrap(a) != ClaimId.unwrap(b);
29
+ }
30
+
31
+ // library functions that operate on user defined type
32
+ library ClaimIdLib {
33
+ /// @dev claim id min value (0), use only for non-initialized values
34
+ function zero() public pure returns (ClaimId) {
35
+ return ClaimId.wrap(0);
36
+ }
37
+ /// @dev claim id max value (2**16-1), use only for non-initialized values
38
+ function max() public pure returns (ClaimId) {
39
+ return ClaimId.wrap(type(uint16).max);
40
+ }
41
+
42
+ /// @dev Converts an uint into a ClaimId.
43
+ function toClaimId(uint256 a) public pure returns (ClaimId) {
44
+ return ClaimId.wrap(uint16(a));
45
+ }
46
+
47
+ /// @dev Converts the ClaimId to a uint.
48
+ function toInt(ClaimId a) public pure returns (uint16) {
49
+ return uint16(ClaimId.unwrap(a));
50
+ }
51
+
52
+ /// @dev Converts the ClaimId and NftId to a Key32.
53
+ function toKey32(ClaimId claimId, NftId policyNftId) public pure returns (Key32) {
54
+ return Key32Lib.toKey32(CLAIM(), toKeyId(claimId, policyNftId));
55
+ }
56
+
57
+ /// @dev Converts the ClaimId and NftId to a Key32.
58
+ function toKeyId(ClaimId claimId, NftId policyNftId) public pure returns (KeyId) {
59
+ return KeyId.wrap(
60
+ bytes31(
61
+ bytes14(
62
+ uint112(
63
+ NftId.unwrap(policyNftId) << 16 + ClaimId.unwrap(claimId)))));
64
+ }
65
+
66
+ /// @dev Returns true if the value is non-zero (> 0).
67
+ function gtz(ClaimId a) public pure returns (bool) {
68
+ return ClaimId.unwrap(a) > 0;
69
+ }
70
+
71
+ /// @dev Returns true if the value is zero (== 0).
72
+ function eqz(ClaimId a) public pure returns (bool) {
73
+ return ClaimId.unwrap(a) == 0;
74
+ }
75
+ }
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
5
+ import {NftId} from "./NftId.sol";
6
+ import {DISTRIBUTOR_TYPE} from "./ObjectType.sol";
7
+
8
+ type DistributorType is bytes8;
9
+
10
+ // type bindings
11
+ using {
12
+ eqDistributorType as ==,
13
+ neDistributorType as !=,
14
+ DistributorTypeLib.toKey32
15
+ } for DistributorType global;
16
+
17
+ // general pure free functions
18
+
19
+ // pure free functions for operators
20
+ function eqDistributorType(
21
+ DistributorType a,
22
+ DistributorType b
23
+ ) pure returns (bool isSame) {
24
+ return DistributorType.unwrap(a) == DistributorType.unwrap(b);
25
+ }
26
+
27
+ function neDistributorType(
28
+ DistributorType a,
29
+ DistributorType b
30
+ ) pure returns (bool isDifferent) {
31
+ return DistributorType.unwrap(a) != DistributorType.unwrap(b);
32
+ }
33
+
34
+ // library functions that operate on user defined type
35
+ library DistributorTypeLib {
36
+
37
+ function zero() public pure returns (DistributorType) {
38
+ return DistributorType.wrap(bytes8(0));
39
+ }
40
+
41
+ // @dev Converts a referral string into an id.
42
+ function toDistributorType(NftId distributionNftId, string memory name) public pure returns (DistributorType) {
43
+ return DistributorType.wrap(bytes8(keccak256(abi.encode(distributionNftId, name))));
44
+ }
45
+
46
+ /// @dev Returns the key32 value for the specified nft id and object type.
47
+ function toKey32(DistributorType id) public pure returns (Key32 key) {
48
+ return Key32Lib.toKey32(DISTRIBUTOR_TYPE(), toKeyId(id));
49
+ }
50
+
51
+ /// @dev Returns the key id value for the specified nft id
52
+ function toKeyId(DistributorType id) public pure returns (KeyId keyId) {
53
+ return KeyId.wrap(bytes31(DistributorType.unwrap(id)));
54
+ }
55
+ }
@@ -0,0 +1,65 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Amount, AmountLib} from "./Amount.sol";
5
+ import {UFixed, UFixedLib} from "./UFixed.sol";
6
+
7
+ struct Fee {
8
+ UFixed fractionalFee;
9
+ uint256 fixedFee;
10
+ }
11
+
12
+ library FeeLib {
13
+
14
+ function calculateFee(
15
+ Fee memory fee,
16
+ Amount amount
17
+ )
18
+ public
19
+ pure
20
+ returns (
21
+ Amount feeAmount,
22
+ Amount netAmount
23
+ )
24
+ {
25
+ netAmount = amount;
26
+ if(gtz(fee)) {
27
+ UFixed fractionalAmount =
28
+ amount.toUFixed() * fee.fractionalFee;
29
+ feeAmount = AmountLib.toAmount(fractionalAmount.toInt() + fee.fixedFee);
30
+ netAmount = netAmount - feeAmount;
31
+ }
32
+ }
33
+
34
+ /// @dev Converts the uint256 to a fee struct.
35
+ function toFee(
36
+ UFixed fractionalFee,
37
+ uint256 fixedFee
38
+ ) public pure returns (Fee memory fee) {
39
+ return Fee(fractionalFee, fixedFee);
40
+ }
41
+
42
+ /// @dev Return the percent fee struct (x%, 0)
43
+ function percentageFee(uint8 percent) public pure returns (Fee memory fee) {
44
+ return Fee(UFixedLib.toUFixed(percent, -2), 0);
45
+ }
46
+
47
+ // TODO rename to zero
48
+ /// @dev Return a zero fee struct (0, 0)
49
+ function zeroFee() public pure returns (Fee memory fee) {
50
+ return Fee(UFixed.wrap(0), 0);
51
+ }
52
+
53
+ // pure free functions for operators
54
+ function feeIsSame(Fee memory a, Fee memory b) public pure returns (bool isSame) {
55
+ return a.fixedFee == b.fixedFee && a.fractionalFee == b.fractionalFee;
56
+ }
57
+
58
+ function gtz(Fee memory fee) public pure returns (bool) {
59
+ return UFixed.unwrap(fee.fractionalFee) > 0 || fee.fixedFee > 0;
60
+ }
61
+
62
+ function eqz(Fee memory fee) public pure returns (bool) {
63
+ return fee.fixedFee == 0 && UFixed.unwrap(fee.fractionalFee) == 0;
64
+ }
65
+ }
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {ObjectType} from "./ObjectType.sol";
5
+
6
+ type Key32 is bytes32;
7
+ type KeyId is bytes31;
8
+
9
+ // type bindings
10
+ using {
11
+ eqKey32 as ==,
12
+ neKey32 as !=,
13
+ Key32Lib.toKeyId,
14
+ Key32Lib.toObjectType
15
+ } for Key32 global;
16
+
17
+ // @dev Returns true iff keys are identical
18
+ function eqKey32(Key32 a, Key32 b) pure returns (bool isSame) {
19
+ return Key32.unwrap(a) == Key32.unwrap(b);
20
+ }
21
+
22
+ // @dev Returns true iff keys are different
23
+ function neKey32(Key32 a, Key32 b) pure returns (bool isDifferent) {
24
+ return Key32.unwrap(a) != Key32.unwrap(b);
25
+ }
26
+
27
+ library Key32Lib {
28
+
29
+ uint8 public constant TYPE_SHIFT = 31 * 8;
30
+ uint8 public constant ID_SHIFT = uint8(32 * 8 - TYPE_SHIFT);
31
+ bytes32 public constant TYPE_MASK = bytes32(bytes1(type(uint8).max)); // first byte in bytes32
32
+ bytes32 public constant ID_MASK = bytes32(~TYPE_MASK); // remaining bytes in bytes32
33
+
34
+ function toKey32(ObjectType objectType, KeyId id) public pure returns (Key32) {
35
+ uint256 uintObjectType = ObjectType.unwrap(objectType);
36
+ uint256 uintId = uint248(KeyId.unwrap(id));
37
+ uint256 uintKey = (uintObjectType << TYPE_SHIFT) + uintId;
38
+ return Key32.wrap(bytes32(uintKey));
39
+ }
40
+
41
+ function toObjectType(Key32 key) public pure returns (ObjectType objectType) {
42
+ bytes32 key32 = Key32.unwrap(key);
43
+ objectType = ObjectType.wrap(uint8(uint256(key32 & TYPE_MASK) >> TYPE_SHIFT));
44
+ }
45
+
46
+ function toKeyId(Key32 key) public pure returns (KeyId id) {
47
+ bytes32 key32 = Key32.unwrap(key);
48
+ id = KeyId.wrap(bytes31((key32 & ID_MASK) << ID_SHIFT));
49
+ }
50
+ }
@@ -1,6 +1,9 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
5
+ import {ObjectType} from "./ObjectType.sol";
6
+
4
7
  // uint96 allows for chain ids up to 13 digits
5
8
  type NftId is uint96;
6
9
 
@@ -10,7 +13,9 @@ using {
10
13
  neNftId as !=,
11
14
  NftIdLib.toInt,
12
15
  NftIdLib.gtz,
13
- NftIdLib.eqz
16
+ NftIdLib.eqz,
17
+ NftIdLib.toKeyId,
18
+ NftIdLib.toKey32
14
19
  } for NftId global;
15
20
 
16
21
  // general pure free functions
@@ -19,6 +24,7 @@ function toNftId(uint256 id) pure returns (NftId) {
19
24
  return NftId.wrap(uint96(id));
20
25
  }
21
26
 
27
+ // TODO move to NftIdLib and rename to zero()
22
28
  /// @dev Return the NftId zero (0)
23
29
  function zeroNftId() pure returns (NftId) {
24
30
  return NftId.wrap(0);
@@ -35,6 +41,13 @@ function neNftId(NftId a, NftId b) pure returns (bool isDifferent) {
35
41
 
36
42
  // library functions that operate on user defined type
37
43
  library NftIdLib {
44
+
45
+ /// @dev the zero nft id
46
+ /// is never a valid nft id and implies a non-initialized value
47
+ function zero() public pure returns (NftId) {
48
+ return NftId.wrap(0);
49
+ }
50
+
38
51
  /// @dev Converts the NftId to a uint256.
39
52
  function toInt(NftId nftId) public pure returns (uint96) {
40
53
  return uint96(NftId.unwrap(nftId));
@@ -54,4 +67,14 @@ library NftIdLib {
54
67
  function eq(NftId a, NftId b) public pure returns (bool isSame) {
55
68
  return eqNftId(a, b);
56
69
  }
70
+
71
+ /// @dev Returns the key32 value for the specified nft id and object type.
72
+ function toKey32(NftId id, ObjectType objectType) public pure returns (Key32 key) {
73
+ return Key32Lib.toKey32(objectType, toKeyId(id));
74
+ }
75
+
76
+ /// @dev Returns the key id value for the specified nft id
77
+ function toKeyId(NftId id) public pure returns (KeyId keyId) {
78
+ return KeyId.wrap(bytes31(uint248(NftId.unwrap(id))));
79
+ }
57
80
  }
@@ -0,0 +1,62 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {NftId} from "../type/NftId.sol";
5
+
6
+ // based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/EnumerableSet.sol
7
+ library LibNftIdSet {
8
+
9
+ struct Set {
10
+ NftId[] ids;
11
+ mapping(NftId nftid => uint256 index) at;
12
+ }
13
+
14
+ error ErrorNftIdSetAlreadyAdded(NftId nftId);
15
+ error ErrorNftIdSetNotInSet(NftId nftId);
16
+
17
+
18
+ function add(Set storage set, NftId nftId) external {
19
+ if (set.at[nftId] > 0) {
20
+ revert ErrorNftIdSetAlreadyAdded(nftId);
21
+ }
22
+
23
+ set.ids.push(nftId);
24
+ set.at[nftId] = set.ids.length;
25
+ }
26
+
27
+ function remove(Set storage set, NftId nftId) external {
28
+ uint256 nftIdIndex = set.at[nftId];
29
+
30
+ if (nftIdIndex == 0) {
31
+ revert ErrorNftIdSetNotInSet(nftId);
32
+ }
33
+
34
+ uint256 toDeleteIndex = nftIdIndex - 1;
35
+ uint256 lastIndex = set.ids.length - 1;
36
+
37
+ if (lastIndex != toDeleteIndex) {
38
+ NftId lastId = set.ids[lastIndex];
39
+ set.ids[toDeleteIndex] = lastId;
40
+ set.at[lastId] = nftIdIndex; // Replace lastValue's index to valueIndex
41
+ }
42
+
43
+ set.ids.pop();
44
+ delete set.at[nftId];
45
+ }
46
+
47
+ function isEmpty(Set storage set) external view returns(bool empty) {
48
+ return set.ids.length == 0;
49
+ }
50
+
51
+ function contains(Set storage set, NftId nftId) external view returns(bool inSet) {
52
+ return set.at[nftId] > 0;
53
+ }
54
+
55
+ function size(Set storage set) external view returns(uint256 length) {
56
+ return set.ids.length;
57
+ }
58
+
59
+ function getElementAt(Set storage set, uint256 index) external view returns(NftId nftId) {
60
+ return set.ids[index];
61
+ }
62
+ }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
3
 
4
4
  type ObjectType is uint8;
5
5
 
@@ -8,6 +8,7 @@ using {
8
8
  eqObjectType as ==,
9
9
  neObjectType as !=,
10
10
  ObjectTypeLib.toInt,
11
+ ObjectTypeLib.eqz,
11
12
  ObjectTypeLib.gtz
12
13
  } for ObjectType global;
13
14
 
@@ -17,56 +18,101 @@ function PROTOCOL() pure returns (ObjectType) {
17
18
  return toObjectType(10);
18
19
  }
19
20
 
20
- function REGISTRY() pure returns (ObjectType) {
21
+ function ROLE() pure returns (ObjectType) {
21
22
  return toObjectType(20);
22
23
  }
23
24
 
24
- function TOKEN() pure returns (ObjectType) {
25
+ function TARGET() pure returns (ObjectType) {
25
26
  return toObjectType(30);
26
27
  }
27
28
 
28
- function SERVICE() pure returns (ObjectType) {
29
+ function REGISTRY() pure returns (ObjectType) {
29
30
  return toObjectType(40);
30
31
  }
31
32
 
32
- function INSTANCE() pure returns (ObjectType) {
33
+ function TOKEN() pure returns (ObjectType) {
33
34
  return toObjectType(50);
34
35
  }
35
36
 
36
- function STAKE() pure returns (ObjectType) {
37
+ function SERVICE() pure returns (ObjectType) {
37
38
  return toObjectType(60);
38
39
  }
39
40
 
40
- function PRODUCT() pure returns (ObjectType) {
41
+ function INSTANCE() pure returns (ObjectType) {
42
+ return toObjectType(70);
43
+ }
44
+
45
+ function STAKE() pure returns (ObjectType) {
46
+ return toObjectType(80);
47
+ }
48
+
49
+ function COMPONENT() pure returns (ObjectType) {
41
50
  return toObjectType(100);
42
51
  }
43
52
 
44
- function DISTRIBUTOR() pure returns (ObjectType) {
53
+ // TODO replace by PRODUCT_SETUP
54
+ function TREASURY() pure returns (ObjectType) {
55
+ return toObjectType(101);
56
+ }
57
+
58
+ function PRODUCT_SETUP() pure returns (ObjectType) {
59
+ return toObjectType(101);
60
+ }
61
+
62
+ function PRODUCT() pure returns (ObjectType) {
45
63
  return toObjectType(110);
46
64
  }
47
65
 
48
- function ORACLE() pure returns (ObjectType) {
66
+ function DISTRIBUTION() pure returns (ObjectType) {
49
67
  return toObjectType(120);
50
68
  }
51
69
 
52
- function POOL() pure returns (ObjectType) {
70
+ function DISTRIBUTOR_TYPE() pure returns (ObjectType) {
71
+ return toObjectType(121);
72
+ }
73
+
74
+ function DISTRIBUTOR() pure returns (ObjectType) {
75
+ return toObjectType(122);
76
+ }
77
+
78
+ function REFERRAL() pure returns (ObjectType) {
79
+ return toObjectType(123);
80
+ }
81
+
82
+ function ORACLE() pure returns (ObjectType) {
53
83
  return toObjectType(130);
54
84
  }
55
85
 
56
- function POLICY() pure returns (ObjectType) {
57
- return toObjectType(200);
86
+ function POOL() pure returns (ObjectType) {
87
+ return toObjectType(140);
58
88
  }
59
89
 
60
90
  function BUNDLE() pure returns (ObjectType) {
91
+ return toObjectType(220);
92
+ }
93
+
94
+ function RISK() pure returns (ObjectType) {
95
+ return toObjectType(200);
96
+ }
97
+
98
+ function APPLICATION() pure returns (ObjectType) {
61
99
  return toObjectType(210);
62
100
  }
63
101
 
102
+ function POLICY() pure returns (ObjectType) {
103
+ return toObjectType(211);
104
+ }
105
+
64
106
  function CLAIM() pure returns (ObjectType) {
65
- return toObjectType(201);
107
+ return toObjectType(212);
66
108
  }
67
109
 
68
110
  function PAYOUT() pure returns (ObjectType) {
69
- return toObjectType(202);
111
+ return toObjectType(213);
112
+ }
113
+
114
+ function PRICE() pure returns (ObjectType) {
115
+ return toObjectType(230);
70
116
  }
71
117
 
72
118
  /// @dev Converts the uint8 to a ObjectType.
@@ -74,6 +120,7 @@ function toObjectType(uint256 objectType) pure returns (ObjectType) {
74
120
  return ObjectType.wrap(uint8(objectType));
75
121
  }
76
122
 
123
+ // TODO move to ObjecTypeLib and rename to zero()
77
124
  /// @dev Return the ObjectType zero (0)
78
125
  function zeroObjectType() pure returns (ObjectType) {
79
126
  return ObjectType.wrap(0);
@@ -112,4 +159,4 @@ library ObjectTypeLib {
112
159
  function eq(ObjectType a, ObjectType b) public pure returns (bool isSame) {
113
160
  return eqObjectType(a, b);
114
161
  }
115
- }
162
+ }
@@ -0,0 +1,82 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ // uint24 allows for 65'535 claims with 255 payouts each per policy
5
+ type PayoutId is uint24;
6
+
7
+ import {ClaimId} from "./ClaimId.sol";
8
+ import {PAYOUT} from "./ObjectType.sol";
9
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
10
+ import {NftId} from "./NftId.sol";
11
+
12
+ // type bindings
13
+ using {
14
+ eqPayoutId as ==,
15
+ nePayoutId as !=,
16
+ PayoutIdLib.eqz,
17
+ PayoutIdLib.gtz,
18
+ PayoutIdLib.toInt,
19
+ PayoutIdLib.toClaimId,
20
+ PayoutIdLib.toPayoutNo,
21
+ PayoutIdLib.toKey32
22
+ } for PayoutId global;
23
+
24
+
25
+ // pure free functions for operators
26
+ function eqPayoutId(PayoutId a, PayoutId b) pure returns (bool isSame) {
27
+ return PayoutId.unwrap(a) == PayoutId.unwrap(b);
28
+ }
29
+
30
+ function nePayoutId(PayoutId a, PayoutId b) pure returns (bool isDifferent) {
31
+ return PayoutId.unwrap(a) != PayoutId.unwrap(b);
32
+ }
33
+
34
+ // library functions that operate on user defined type
35
+ library PayoutIdLib {
36
+ /// @dev Converts the PayoutId to a uint.
37
+ function zero() public pure returns (PayoutId) {
38
+ return PayoutId.wrap(0);
39
+ }
40
+
41
+ /// @dev Converts an uint into a PayoutId.
42
+ function toPayoutId(ClaimId claimId, uint8 payoutNo) public pure returns (PayoutId) {
43
+ return PayoutId.wrap((ClaimId.unwrap(claimId) << 8) + payoutNo);
44
+ }
45
+
46
+ function toClaimId(PayoutId payoutId) public pure returns (ClaimId) {
47
+ return ClaimId.wrap(uint16(PayoutId.unwrap(payoutId) >> 8));
48
+ }
49
+
50
+ function toPayoutNo(PayoutId payoutId) public pure returns (uint8) {
51
+ return uint8(PayoutId.unwrap(payoutId) & 255);
52
+ }
53
+
54
+ /// @dev Converts the PayoutId to a uint.
55
+ function toInt(PayoutId a) public pure returns (uint24) {
56
+ return uint24(PayoutId.unwrap(a));
57
+ }
58
+
59
+ /// @dev Returns true if the value is non-zero (> 0).
60
+ function gtz(PayoutId a) public pure returns (bool) {
61
+ return PayoutId.unwrap(a) > 0;
62
+ }
63
+
64
+ /// @dev Returns true if the value is zero (== 0).
65
+ function eqz(PayoutId a) public pure returns (bool) {
66
+ return PayoutId.unwrap(a) == 0;
67
+ }
68
+
69
+ /// @dev Converts the PayoutId and NftId to a Key32.
70
+ function toKey32(PayoutId payoutId, NftId policyNftId) public pure returns (Key32) {
71
+ return Key32Lib.toKey32(PAYOUT(), toKeyId(payoutId, policyNftId));
72
+ }
73
+
74
+ /// @dev Converts the PayoutId and NftId to a Key32.
75
+ function toKeyId(PayoutId payoutId, NftId policyNftId) public pure returns (KeyId) {
76
+ return KeyId.wrap(
77
+ bytes31(
78
+ bytes15(
79
+ uint120(
80
+ (NftId.unwrap(policyNftId) << 24) + PayoutId.unwrap(payoutId)))));
81
+ }
82
+ }
@@ -0,0 +1,89 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
5
+ import {NftId} from "./NftId.sol";
6
+ import {REFERRAL} from "./ObjectType.sol";
7
+
8
+ type ReferralId is bytes8;
9
+ type ReferralStatus is uint8;
10
+
11
+ // type bindings
12
+ using {
13
+ eqReferralId as ==,
14
+ neReferralId as !=,
15
+ ReferralLib.toKey32
16
+ } for ReferralId global;
17
+
18
+ using {
19
+ eqReferralStatus as ==,
20
+ neReferralStatus as !=
21
+ } for ReferralStatus global;
22
+
23
+ // general pure free functions
24
+
25
+ // @dev Returns true iff a and b are identical
26
+ function eqReferralId(ReferralId a, ReferralId b) pure returns (bool isSame) {
27
+ return ReferralId.unwrap(a) == ReferralId.unwrap(b);
28
+ }
29
+
30
+ // @dev Returns true iff a and b are different
31
+ function neReferralId(ReferralId a, ReferralId b) pure returns (bool isDifferent) {
32
+ return ReferralId.unwrap(a) != ReferralId.unwrap(b);
33
+ }
34
+
35
+ // @dev Returns true iff a and b are identical
36
+ function eqReferralStatus(ReferralStatus a, ReferralStatus b) pure returns (bool isSame) {
37
+ return ReferralStatus.unwrap(a) == ReferralStatus.unwrap(b);
38
+ }
39
+
40
+ // @dev Returns true iff a and b are different
41
+ function neReferralStatus(ReferralStatus a, ReferralStatus b) pure returns (bool isDifferent) {
42
+ return ReferralStatus.unwrap(a) != ReferralStatus.unwrap(b);
43
+ }
44
+
45
+ function REFERRAL_OK() pure returns (ReferralStatus) {
46
+ return ReferralStatus.wrap(10);
47
+ }
48
+
49
+ function REFERRAL_ERROR_UNKNOWN() pure returns (ReferralStatus) {
50
+ return ReferralStatus.wrap(100);
51
+ }
52
+
53
+ function REFERRAL_ERROR_EXPIRED() pure returns (ReferralStatus) {
54
+ return ReferralStatus.wrap(110);
55
+ }
56
+
57
+ function REFERRAL_ERROR_EXHAUSTED() pure returns (ReferralStatus) {
58
+ return ReferralStatus.wrap(120);
59
+ }
60
+
61
+ library ReferralLib {
62
+
63
+ function zero() public pure returns (ReferralId) {
64
+ return ReferralId.wrap(bytes8(0));
65
+ }
66
+
67
+ // @dev Converts a referral string into an id.
68
+ function toReferralId(NftId distributionNftId, string memory referral) public pure returns (ReferralId) {
69
+ return ReferralId.wrap(bytes8(keccak256(abi.encode(distributionNftId, referral))));
70
+ }
71
+
72
+ function toReferralStatus(uint8 status) public pure returns (ReferralStatus) {
73
+ return ReferralStatus.wrap(status);
74
+ }
75
+
76
+ /// @dev Returns the key32 value for the specified nft id and object type.
77
+ function toKey32(ReferralId id) public pure returns (Key32 key) {
78
+ return Key32Lib.toKey32(REFERRAL(), toKeyId(id));
79
+ }
80
+
81
+ /// @dev Returns the key id value for the specified nft id
82
+ function toKeyId(ReferralId id) public pure returns (KeyId keyId) {
83
+ return KeyId.wrap(bytes31(ReferralId.unwrap(id)));
84
+ }
85
+
86
+ function eqz(ReferralId id) public pure returns (bool) {
87
+ return eqReferralId(id, zero());
88
+ }
89
+ }