@etherisc/gif-next 0.0.2-851536d → 0.0.2-86f4673-518

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 (421) hide show
  1. package/README.md +436 -8
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +735 -30
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +1140 -0
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
  7. package/artifacts/contracts/{registry/IChainNft.sol/IChainNft.json → components/IComponent.sol/IComponent.json} +292 -224
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +708 -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 +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +1216 -76
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +1148 -102
  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 +1 -1
  25. package/artifacts/contracts/experiment/errors/Require.sol/Require.json +2 -2
  26. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +2 -2
  28. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/inheritance/A.sol/A.json +2 -2
  30. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +2 -2
  32. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  36. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  37. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  38. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
  39. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
  40. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
  41. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
  42. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
  43. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
  44. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
  45. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
  46. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
  47. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
  48. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  49. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +2 -2
  50. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  51. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +2 -2
  52. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  53. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
  54. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  55. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +185 -0
  56. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  57. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1592 -476
  58. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
  59. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +674 -0
  60. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  61. package/artifacts/contracts/instance/Instance.sol/Instance.json +2653 -518
  62. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
  63. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +984 -0
  64. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
  65. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1386 -0
  66. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
  67. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +1260 -0
  68. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
  69. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +610 -0
  70. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  71. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
  72. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
  73. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +754 -0
  74. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
  75. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +429 -0
  76. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
  77. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
  78. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
  79. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +502 -0
  80. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
  81. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
  82. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
  83. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +254 -0
  84. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
  85. package/artifacts/contracts/instance/{access/IAccess.sol/IAccess.json → module/IBundle.sol/IBundle.json} +2 -2
  86. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
  87. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
  88. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
  89. package/artifacts/contracts/instance/{policy → module}/IPolicy.sol/IPolicy.json +1 -1
  90. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
  91. package/artifacts/contracts/instance/{pool/IPoolModule.sol/IPool.json → module/IRisk.sol/IRisk.json} +2 -2
  92. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
  93. package/artifacts/contracts/instance/{component/IComponent.sol/IComponent.json → module/ISetup.sol/ISetup.json} +2 -2
  94. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
  95. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +10 -0
  96. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
  97. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +1117 -0
  98. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  99. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1318 -0
  100. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  101. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +586 -0
  102. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  103. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +923 -0
  104. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
  105. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +574 -0
  106. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
  107. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +638 -0
  108. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  109. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +798 -0
  110. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  111. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +459 -0
  112. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  113. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +784 -0
  114. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
  115. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +512 -0
  116. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
  117. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +549 -0
  118. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  119. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1378 -0
  120. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  121. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +642 -0
  122. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  123. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +957 -0
  124. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  125. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +574 -0
  126. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  127. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +1007 -0
  128. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  129. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +574 -0
  130. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  131. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +239 -2
  132. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  133. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +519 -61
  134. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
  135. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +999 -0
  136. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
  137. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
  138. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  139. package/artifacts/contracts/registry/Registry.sol/Registry.json +567 -75
  140. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  141. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  142. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
  143. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1351 -0
  144. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
  145. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +601 -0
  146. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  147. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
  148. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  149. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +531 -0
  150. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
  151. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
  152. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
  153. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +73 -0
  154. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
  155. package/artifacts/contracts/{registry/Registry.sol/Registerable.json → shared/INftOwnable.sol/INftOwnable.json} +68 -70
  156. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
  157. package/artifacts/contracts/{instance/product/IProductService.sol/IProductService.json → shared/IPolicyHolder.sol/IPolicyHolder.json} +68 -53
  158. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
  159. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +214 -0
  160. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
  161. package/artifacts/contracts/{instance/product/ProductService.sol/ProductModule.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +23 -29
  162. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
  163. package/artifacts/contracts/shared/IService.sol/IService.json +434 -0
  164. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
  165. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
  166. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
  167. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +303 -0
  168. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
  169. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +269 -0
  170. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
  171. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +499 -0
  172. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
  173. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +415 -0
  174. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
  175. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +105 -0
  176. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
  177. package/artifacts/contracts/shared/Service.sol/Service.json +627 -0
  178. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
  179. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
  180. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
  181. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
  182. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
  183. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
  184. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
  185. package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
  186. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
  187. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +446 -0
  188. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
  189. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
  190. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
  191. package/artifacts/contracts/test/TestService.sol/TestService.json +759 -0
  192. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
  193. package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
  194. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
  195. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
  196. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
  197. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +286 -0
  198. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
  199. package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
  200. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
  201. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
  202. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  203. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  204. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  205. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +2 -2
  206. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
  207. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
  208. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
  209. package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
  210. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
  211. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
  212. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  213. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +65 -4
  214. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
  215. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +33 -0
  216. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
  217. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
  218. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
  219. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
  220. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
  221. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
  222. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  223. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  224. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
  225. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
  226. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
  227. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
  228. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  229. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +77 -2
  230. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
  231. package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
  232. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
  233. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
  234. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
  235. package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
  236. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
  237. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +49 -0
  238. package/contracts/components/Component.sol +205 -37
  239. package/contracts/components/Distribution.sol +156 -0
  240. package/contracts/components/IComponent.sol +50 -0
  241. package/contracts/components/IDistributionComponent.sol +47 -0
  242. package/contracts/components/IPoolComponent.sol +87 -0
  243. package/contracts/components/IProductComponent.sol +39 -0
  244. package/contracts/components/Pool.sol +242 -17
  245. package/contracts/components/Product.sol +244 -32
  246. package/contracts/experiment/cloning/Cloner.sol +47 -0
  247. package/contracts/experiment/errors/Require.sol +10 -5
  248. package/contracts/experiment/errors/Revert.sol +13 -8
  249. package/contracts/experiment/inheritance/A.sol +8 -11
  250. package/contracts/experiment/inheritance/B.sol +10 -5
  251. package/contracts/experiment/inheritance/C.sol +11 -5
  252. package/contracts/experiment/inheritance/IA.sol +2 -7
  253. package/contracts/experiment/inheritance/IB.sol +3 -2
  254. package/contracts/experiment/inheritance/IC.sol +4 -3
  255. package/contracts/experiment/statemachine/Dummy.sol +27 -0
  256. package/contracts/experiment/statemachine/ISM.sol +25 -0
  257. package/contracts/experiment/statemachine/SM.sol +57 -0
  258. package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
  259. package/contracts/experiment/types/TypeA.sol +14 -9
  260. package/contracts/experiment/types/TypeB.sol +14 -9
  261. package/contracts/instance/BundleManager.sol +125 -0
  262. package/contracts/instance/Cloneable.sol +46 -0
  263. package/contracts/instance/IInstance.sol +67 -15
  264. package/contracts/instance/IInstanceService.sol +59 -0
  265. package/contracts/instance/Instance.sol +247 -43
  266. package/contracts/instance/InstanceAccessManager.sol +297 -0
  267. package/contracts/instance/InstanceReader.sol +293 -0
  268. package/contracts/instance/InstanceService.sol +433 -0
  269. package/contracts/instance/InstanceServiceManager.sol +54 -0
  270. package/contracts/instance/ObjectManager.sol +84 -0
  271. package/contracts/instance/base/ComponentService.sol +134 -0
  272. package/contracts/instance/base/IKeyValueStore.sol +49 -0
  273. package/contracts/instance/base/ILifecycle.sol +30 -0
  274. package/contracts/instance/base/KeyValueStore.sol +172 -0
  275. package/contracts/instance/base/Lifecycle.sol +100 -0
  276. package/contracts/instance/module/IAccess.sol +47 -0
  277. package/contracts/instance/module/IBundle.sol +20 -0
  278. package/contracts/instance/module/IDistribution.sol +39 -0
  279. package/contracts/instance/module/IPolicy.sol +45 -0
  280. package/contracts/instance/module/IRisk.sol +11 -0
  281. package/contracts/instance/module/ISetup.sol +47 -0
  282. package/contracts/instance/module/ITreasury.sol +23 -0
  283. package/contracts/instance/service/ApplicationService.sol +268 -0
  284. package/contracts/instance/service/BundleService.sol +298 -0
  285. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  286. package/contracts/instance/service/DistributionService.sol +105 -0
  287. package/contracts/instance/service/DistributionServiceManager.sol +51 -0
  288. package/contracts/instance/service/IApplicationService.sol +82 -0
  289. package/contracts/instance/service/IBundleService.sol +54 -0
  290. package/contracts/instance/service/IDistributionService.sol +12 -0
  291. package/contracts/instance/service/IPolicyService.sol +88 -0
  292. package/contracts/instance/service/IPoolService.sol +20 -0
  293. package/contracts/instance/service/IProductService.sol +40 -0
  294. package/contracts/instance/service/PolicyService.sol +524 -0
  295. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  296. package/contracts/instance/service/PoolService.sol +109 -0
  297. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  298. package/contracts/instance/service/ProductService.sol +233 -0
  299. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  300. package/contracts/registry/ChainNft.sol +138 -109
  301. package/contracts/registry/IRegistry.sol +78 -49
  302. package/contracts/registry/IRegistryService.sol +65 -0
  303. package/contracts/registry/ITransferInterceptor.sol +6 -0
  304. package/contracts/registry/Registry.sol +396 -116
  305. package/contracts/registry/RegistryAccessManager.sol +216 -0
  306. package/contracts/registry/RegistryService.sol +261 -0
  307. package/contracts/registry/RegistryServiceManager.sol +62 -0
  308. package/contracts/registry/ReleaseManager.sol +332 -0
  309. package/contracts/registry/TokenRegistry.sol +113 -0
  310. package/contracts/shared/ContractDeployerLib.sol +72 -0
  311. package/contracts/shared/ERC165.sol +26 -0
  312. package/contracts/shared/INftOwnable.sol +28 -0
  313. package/contracts/shared/IPolicyHolder.sol +26 -0
  314. package/contracts/shared/IRegisterable.sol +15 -0
  315. package/contracts/shared/IRegistryLinked.sol +15 -0
  316. package/contracts/shared/IService.sol +16 -0
  317. package/contracts/shared/IVersionable.sol +96 -0
  318. package/contracts/shared/NftOwnable.sol +190 -0
  319. package/contracts/shared/PolicyHolder.sol +81 -0
  320. package/contracts/shared/ProxyManager.sol +95 -0
  321. package/contracts/shared/Registerable.sol +81 -0
  322. package/contracts/shared/RegistryLinked.sol +64 -0
  323. package/contracts/shared/Service.sol +60 -0
  324. package/contracts/shared/TokenHandler.sol +27 -0
  325. package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
  326. package/contracts/shared/Versionable.sol +148 -0
  327. package/contracts/test/TestFee.sol +25 -0
  328. package/contracts/test/TestRegisterable.sol +18 -0
  329. package/contracts/test/TestRoleId.sol +14 -0
  330. package/contracts/test/TestService.sol +25 -0
  331. package/contracts/test/TestToken.sol +26 -0
  332. package/contracts/test/TestVersion.sol +44 -0
  333. package/contracts/test/TestVersionable.sol +17 -0
  334. package/contracts/test/Usdc.sol +26 -0
  335. package/contracts/types/AddressSet.sol +58 -0
  336. package/contracts/types/Blocknumber.sol +76 -18
  337. package/contracts/types/ChainId.sol +18 -10
  338. package/contracts/types/DistributorType.sol +55 -0
  339. package/contracts/types/Fee.sol +56 -0
  340. package/contracts/types/Key32.sol +50 -0
  341. package/contracts/types/NftId.sol +48 -11
  342. package/contracts/types/NftIdSet.sol +62 -0
  343. package/contracts/types/NumberId.sol +52 -0
  344. package/contracts/types/ObjectType.sol +156 -0
  345. package/contracts/types/Referral.sol +85 -0
  346. package/contracts/types/RiskId.sol +43 -0
  347. package/contracts/types/RoleId.sol +90 -0
  348. package/contracts/types/StateId.sol +105 -0
  349. package/contracts/types/Timestamp.sol +89 -17
  350. package/contracts/types/UFixed.sol +193 -75
  351. package/contracts/types/Version.sol +107 -0
  352. package/package.json +21 -6
  353. package/artifacts/contracts/components/Component.sol/InstanceLinked.dbg.json +0 -4
  354. package/artifacts/contracts/components/Component.sol/InstanceLinked.json +0 -35
  355. package/artifacts/contracts/components/IPool.sol/IPoolComponent.dbg.json +0 -4
  356. package/artifacts/contracts/components/IPool.sol/IPoolComponent.json +0 -179
  357. package/artifacts/contracts/components/IProduct.sol/IProductComponent.dbg.json +0 -4
  358. package/artifacts/contracts/components/IProduct.sol/IProductComponent.json +0 -192
  359. package/artifacts/contracts/instance/access/Access.sol/AccessModule.dbg.json +0 -4
  360. package/artifacts/contracts/instance/access/Access.sol/AccessModule.json +0 -400
  361. package/artifacts/contracts/instance/access/IAccess.sol/IAccess.dbg.json +0 -4
  362. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.dbg.json +0 -4
  363. package/artifacts/contracts/instance/access/IAccess.sol/IAccessCheckRole.json +0 -35
  364. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.dbg.json +0 -4
  365. package/artifacts/contracts/instance/access/IAccess.sol/IAccessComponentTypeRoles.json +0 -50
  366. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.dbg.json +0 -4
  367. package/artifacts/contracts/instance/access/IAccess.sol/IAccessModule.json +0 -336
  368. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.dbg.json +0 -4
  369. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentModule.json +0 -327
  370. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.dbg.json +0 -4
  371. package/artifacts/contracts/instance/component/ComponentModule.sol/ComponentOwnerService.json +0 -147
  372. package/artifacts/contracts/instance/component/IComponent.sol/IComponent.dbg.json +0 -4
  373. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.dbg.json +0 -4
  374. package/artifacts/contracts/instance/component/IComponent.sol/IComponentContract.json +0 -179
  375. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.dbg.json +0 -4
  376. package/artifacts/contracts/instance/component/IComponent.sol/IComponentModule.json +0 -245
  377. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.dbg.json +0 -4
  378. package/artifacts/contracts/instance/component/IComponent.sol/IComponentOwnerService.json +0 -94
  379. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.dbg.json +0 -4
  380. package/artifacts/contracts/instance/component/IComponent.sol/IInstanceLinked.json +0 -24
  381. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicy.dbg.json +0 -4
  382. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.dbg.json +0 -4
  383. package/artifacts/contracts/instance/policy/IPolicy.sol/IPolicyModule.json +0 -231
  384. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.dbg.json +0 -4
  385. package/artifacts/contracts/instance/policy/PolicyModule.sol/PolicyModule.json +0 -231
  386. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPool.dbg.json +0 -4
  387. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.dbg.json +0 -4
  388. package/artifacts/contracts/instance/pool/IPoolModule.sol/IPoolModule.json +0 -149
  389. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.dbg.json +0 -4
  390. package/artifacts/contracts/instance/pool/PoolModule.sol/PoolModule.json +0 -162
  391. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.dbg.json +0 -4
  392. package/artifacts/contracts/instance/product/IProductService.sol/IProductModule.json +0 -75
  393. package/artifacts/contracts/instance/product/IProductService.sol/IProductService.dbg.json +0 -4
  394. package/artifacts/contracts/instance/product/ProductService.sol/ProductModule.dbg.json +0 -4
  395. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.dbg.json +0 -4
  396. package/artifacts/contracts/instance/product/ProductService.sol/ProductService.json +0 -167
  397. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
  398. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.dbg.json +0 -4
  399. package/artifacts/contracts/registry/IRegistry.sol/IOwnable.json +0 -24
  400. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.dbg.json +0 -4
  401. package/artifacts/contracts/registry/IRegistry.sol/IRegisterable.json +0 -166
  402. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.dbg.json +0 -4
  403. package/artifacts/contracts/registry/IRegistry.sol/IRegistryLinked.json +0 -49
  404. package/artifacts/contracts/registry/Registry.sol/Registerable.dbg.json +0 -4
  405. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.dbg.json +0 -4
  406. package/artifacts/contracts/registry/Registry.sol/RegistryLinked.json +0 -60
  407. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
  408. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.json +0 -440
  409. package/contracts/components/IPool.sol +0 -9
  410. package/contracts/components/IProduct.sol +0 -12
  411. package/contracts/instance/access/Access.sol +0 -218
  412. package/contracts/instance/access/IAccess.sol +0 -83
  413. package/contracts/instance/component/ComponentModule.sol +0 -248
  414. package/contracts/instance/component/IComponent.sol +0 -95
  415. package/contracts/instance/policy/IPolicy.sol +0 -66
  416. package/contracts/instance/policy/PolicyModule.sol +0 -107
  417. package/contracts/instance/pool/IPoolModule.sol +0 -41
  418. package/contracts/instance/pool/PoolModule.sol +0 -86
  419. package/contracts/instance/product/IProductService.sol +0 -46
  420. package/contracts/instance/product/ProductService.sol +0 -108
  421. package/contracts/registry/IChainNft.sol +0 -18
@@ -0,0 +1,96 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Blocknumber} from "../types/Blocknumber.sol";
5
+ import {Timestamp} from "../types/Timestamp.sol";
6
+ import {Version} from "../types/Version.sol";
7
+
8
+
9
+ /// IMPORTANT
10
+ // Upgradeable contract MUST:
11
+ // 1) inherit from Versionable
12
+ // 2) implement version() function
13
+ // 3) implement internal _initialize() function with onlyInitializing modifier
14
+ // 4) implement internal _upgrade() function with onlyInitializing modifier (1st version MUST revert)
15
+ // 5) have onlyInitialising modifier for each function callable inside _initialize()/_upgrade() (MUST use different functions for initialization/upgrade and normal operations)
16
+ // 6) use default empty constructor -> _disableInitializer() is called from Versionable contructor
17
+ // 7) use namespace storage
18
+ // 8) since now inheritance is used for upgradability, contract MUST BE inherited ONLY by the next version
19
+ // Upgradeable contract SHOULD:
20
+ // 9) define all non private methods as virtual (in order to be able to upgrade them latter)
21
+ // otherwise, it is still possible to upgrade contract, but everyone who is using it will have to switch to a new fucntions
22
+ // in some cases this ok but not in the others...
23
+ //
24
+ // IMPORTANT
25
+ // Each version MUST:
26
+ // 1) define namespace storage struct if accessing storage
27
+ // - DO NOT use structs inside, except
28
+ // - CAN use structs ONLY inside mappings
29
+ // 2) ALWAYS define private getter if accessing storage
30
+ // - MUST use default implementation, CAN change ONLY return type
31
+ // - MUST use the same "LOCATION_V1"
32
+
33
+ interface IVersionable {
34
+
35
+ struct VersionInfo {
36
+ Version version;
37
+ address implementation;
38
+ address activatedBy;
39
+ Timestamp activatedAt;
40
+ Blocknumber activatedIn;
41
+ }
42
+
43
+ event LogVersionableInitialized(Version version, address implementation, address activatedBy);
44
+
45
+ // TODO uncomment when all implementations are ready
46
+ /**
47
+ * @dev IMPORTANT
48
+ * implementation MUST be guarded by initializer modifier
49
+ * implementation MUST call internal function Versionable._updateVersionHistory
50
+ * new version MUST inherit from previous version
51
+ */
52
+ function initializeVersionable(address implementation, address activatedBy, bytes memory activationData) external;
53
+
54
+ /**
55
+ * @dev
56
+ * implementation MUST be guarded by reinitializer(version().toUint64()) modifier
57
+ * implementation MUST call internal function Versionable._updateVersionHistory
58
+ * new version MUST inherit from previous version
59
+ * the first verion MUST revert
60
+ */
61
+ function upgradeVersionable(address implementation, address activatedBy, bytes memory upgradeData) external;
62
+
63
+ /**
64
+ * @dev returns true if the specified version has been activated for the current contract
65
+ */
66
+ function isInitialized(Version version) external view returns(bool);
67
+
68
+ /**
69
+ * @dev returns version of this contract
70
+ * each new implementation MUST implement this function
71
+ * version number MUST increase
72
+ */
73
+ function getVersion() external pure returns(Version);
74
+
75
+ /**
76
+ * @dev returns the number of all deployed versions of this contract
77
+ */
78
+ function getVersionCount() external view returns(uint256 numberOfVersions);
79
+
80
+ /**
81
+ * @dev returns the i-th (index) version of this contract
82
+ */
83
+ function getVersion(uint256 index) external view returns(Version version);
84
+
85
+ /**
86
+ * @dev returns the i-th (index) version info of this contract
87
+ */
88
+ function getVersionInfo(Version version) external view returns(VersionInfo memory versionInfo);
89
+
90
+ // TODO make sure it is needed here
91
+ /**
92
+ * @dev returns currently active version
93
+ */
94
+ function getInitializedVersion() external view returns(uint64);
95
+
96
+ }
@@ -0,0 +1,190 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ // import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
+
6
+ import {ERC165} from "./ERC165.sol";
7
+ import {INftOwnable} from "./INftOwnable.sol";
8
+ import {IRegistry} from "../registry/IRegistry.sol";
9
+ import {NftId, zeroNftId} from "../types/NftId.sol";
10
+ import {RegistryLinked} from "./RegistryLinked.sol";
11
+
12
+ contract NftOwnable is
13
+ ERC165,
14
+ RegistryLinked,
15
+ INftOwnable
16
+ {
17
+ // keccak256(abi.encode(uint256(keccak256("etherisc.storage.NftOwnable")) - 1)) & ~bytes32(uint256(0xff));
18
+ bytes32 public constant NFT_OWNABLE_STORAGE_LOCATION_V1 = 0x07ebcf49758b6ed3af50fa146bec0abe157c0218fe65dc0874c286e9d5da4f00;
19
+
20
+ struct NftOwnableStorage {
21
+ // IRegistry _registry;
22
+ NftId _nftId;
23
+ address _initialOwner;
24
+ }
25
+
26
+ /// @dev enforces msg.sender is owner of nft (or initial owner of nft ownable)
27
+ modifier onlyOwner() {
28
+ if (msg.sender != getOwner()) {
29
+ revert ErrorNotOwner(msg.sender);
30
+ }
31
+ _;
32
+ }
33
+
34
+
35
+ /// @dev initialization for upgradable contracts
36
+ // used in _initializeRegisterable
37
+ function initializeNftOwnable(
38
+ address initialOwner,
39
+ address registryAddress
40
+ )
41
+ public
42
+ virtual
43
+ onlyInitializing()
44
+ {
45
+ _setInitialOwner(initialOwner);
46
+
47
+ initializeRegistryLinked(registryAddress);
48
+ initializeERC165();
49
+ registerInterface(type(INftOwnable).interfaceId);
50
+ }
51
+
52
+
53
+ function initializeOwner(address initialOwner)
54
+ public
55
+ initializer()
56
+ {
57
+ _setInitialOwner(initialOwner);
58
+ initializeERC165();
59
+ registerInterface(type(INftOwnable).interfaceId);
60
+ }
61
+
62
+
63
+ /// @dev links this contract to nft after registration
64
+ // needs to be done once per registered contract and
65
+ // reduces registry calls to check ownership
66
+ // does not need any protection as function can only do the "right thing"
67
+ function linkToRegisteredNftId()
68
+ public
69
+ virtual
70
+ {
71
+ NftOwnableStorage storage $ = _getNftOwnableStorage();
72
+
73
+ if ($._nftId.gtz()) {
74
+ revert ErrorAlreadyLinked(address(getRegistry()), $._nftId);
75
+ }
76
+
77
+ if (address(getRegistry()) == address(0)) {
78
+ revert ErrorRegistryNotInitialized();
79
+ }
80
+
81
+ address contractAddress = address(this);
82
+
83
+ if (!getRegistry().isRegistered(contractAddress)) {
84
+ revert ErrorContractNotRegistered(contractAddress);
85
+ }
86
+
87
+ $._nftId = getRegistry().getNftId(contractAddress);
88
+ }
89
+
90
+
91
+ // function getRegistry() public view virtual override returns (IRegistry) {
92
+ // return _getNftOwnableStorage()._registry;
93
+ // }
94
+
95
+ function getNftId() public view virtual override returns (NftId) {
96
+ return _getNftOwnableStorage()._nftId;
97
+ }
98
+
99
+ function getInitialOwner() public view returns (address) {
100
+ return _getNftOwnableStorage()._initialOwner;
101
+ }
102
+
103
+ function getOwner() public view virtual override returns (address) {
104
+ NftOwnableStorage storage $ = _getNftOwnableStorage();
105
+
106
+ if ($._nftId.gtz()) {
107
+ return getRegistry().ownerOf($._nftId);
108
+ }
109
+
110
+ return $._initialOwner;
111
+ }
112
+
113
+ /// @dev set initialOwner
114
+ /// initial owner may only be set during initialization
115
+ function _setInitialOwner(address initialOwner)
116
+ internal
117
+ virtual
118
+ onlyInitializing()
119
+ {
120
+ if(initialOwner == address(0)) {
121
+ revert ErrorInitialOwnerZero();
122
+ }
123
+
124
+ _getNftOwnableStorage()._initialOwner = initialOwner;
125
+ }
126
+
127
+ // TODO check if function can be refactored to work with a registry address set in an initializer
128
+ /// @dev used in constructor of registry service manager
129
+ // links ownership of registry service manager ot nft owner of registry service
130
+ function _linkToNftOwnable(
131
+ address registryAddress,
132
+ address nftOwnableAddress
133
+ )
134
+ internal
135
+ onlyOwner()
136
+ returns (NftId)
137
+ {
138
+ NftOwnableStorage storage $ = _getNftOwnableStorage();
139
+
140
+ if ($._nftId.gtz()) {
141
+ revert ErrorAlreadyLinked(address(getRegistry()), $._nftId);
142
+ }
143
+
144
+ _setRegistry(registryAddress);
145
+
146
+ if (!getRegistry().isRegistered(nftOwnableAddress)) {
147
+ revert ErrorContractNotRegistered(nftOwnableAddress);
148
+ }
149
+
150
+ $._nftId = getRegistry().getNftId(nftOwnableAddress);
151
+
152
+ return $._nftId;
153
+ }
154
+
155
+
156
+ // function _setRegistry(address registryAddress)
157
+ // private
158
+ // {
159
+ // NftOwnableStorage storage $ = _getNftOwnableStorage();
160
+
161
+ // if (address($._registry) != address(0)) {
162
+ // revert ErrorRegistryAlreadyInitialized(address($._registry));
163
+ // }
164
+
165
+ // if (registryAddress == address(0)) {
166
+ // revert ErrorRegistryAddressZero();
167
+ // }
168
+
169
+ // if (registryAddress.code.length == 0) {
170
+ // revert ErrorNotRegistry(registryAddress);
171
+ // }
172
+
173
+ // $._registry = IRegistry(registryAddress);
174
+
175
+ // try $._registry.supportsInterface(type(IRegistry).interfaceId) returns (bool isRegistry) {
176
+ // if (!isRegistry) {
177
+ // revert ErrorNotRegistry(registryAddress);
178
+ // }
179
+ // } catch {
180
+ // revert ErrorNotRegistry(registryAddress);
181
+ // }
182
+ // }
183
+
184
+
185
+ function _getNftOwnableStorage() private pure returns (NftOwnableStorage storage $) {
186
+ assembly {
187
+ $.slot := NFT_OWNABLE_STORAGE_LOCATION_V1
188
+ }
189
+ }
190
+ }
@@ -0,0 +1,81 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
+ import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
6
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
+
8
+ import {ERC165} from "./ERC165.sol";
9
+ import {IPolicyHolder} from "./IPolicyHolder.sol";
10
+ import {IRegistry} from "../registry/IRegistry.sol";
11
+ import {NftId} from "../types/NftId.sol";
12
+ import {NumberId} from "../types/NumberId.sol";
13
+ import {RegistryLinked} from "./RegistryLinked.sol";
14
+
15
+ /// @dev template implementation for IPolicyHolder
16
+ contract PolicyHolder is
17
+ ERC165,
18
+ RegistryLinked,
19
+ IPolicyHolder
20
+ {
21
+ // keccak256(abi.encode(uint256(keccak256("etherisc.storage.PolicyHolder")) - 1)) & ~bytes32(uint256(0xff));
22
+ // TODO fix address
23
+ bytes32 public constant POLICY_HOLDER_STORAGE_LOCATION_V1 = 0x07ebcf49758b6ed3af50fa146bec0abe157c0218fe65dc0874c286e9d5da4f00;
24
+
25
+ // TODO uncomment/fix/refactor
26
+ struct PolicyHolderStorage {
27
+ // mapping(NftId policyId => mapping(NumberId claimId => address beneficiary)) private _claimBeneficiary;
28
+ // mapping(NftId policyId => address beneficiary) private _beneficiary;
29
+ bool dummy;
30
+ }
31
+
32
+ function initializePolicyHolder(
33
+ address registryAddress
34
+ )
35
+ public
36
+ virtual
37
+ onlyInitializing()
38
+ {
39
+ initializeRegistryLinked(registryAddress);
40
+ }
41
+
42
+ /// @dev empty default implementation
43
+ function policyCreatedCallback(NftId policyNftId) external virtual { }
44
+
45
+ /// @dev empty default implementation
46
+ function payoutExecutedCallback(NftId policyNftId, NumberId payoutId, address beneficiary, uint256 amount) external virtual { }
47
+
48
+ /// @dev determines beneficiary address that will be used in payouts targeting this contract
49
+ /// returned address will override GIF default where the policy nft holder is treated as beneficiary
50
+ function getBeneficiary(NftId policyId, NumberId claimId) external virtual view returns (address beneficiary) {
51
+ // TODO add implementation
52
+ }
53
+
54
+ //--- IERC165 functions ---------------//
55
+ function onERC721Received(
56
+ address, // operator
57
+ address, // from
58
+ uint256, // tokenId
59
+ bytes calldata // data
60
+ )
61
+ external
62
+ virtual
63
+ returns (bytes4)
64
+ {
65
+ return IERC721Receiver.onERC721Received.selector;
66
+ }
67
+
68
+ function _setBeneficiary(address beneficiary) internal {
69
+
70
+ }
71
+
72
+ function _setBeneficiary(NftId policyId, address beneficiary) internal {
73
+
74
+ }
75
+
76
+ function _getPolicyHolderStorage() private pure returns (PolicyHolderStorage storage $) {
77
+ assembly {
78
+ $.slot := POLICY_HOLDER_STORAGE_LOCATION_V1
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,95 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
5
+ import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
6
+ import {ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
7
+
8
+ import {IVersionable} from "./IVersionable.sol";
9
+ import {NftOwnable} from "./NftOwnable.sol";
10
+ import {UpgradableProxyWithAdmin} from "./UpgradableProxyWithAdmin.sol";
11
+
12
+ /// @dev manages proxy deployments for upgradable contracs of type IVersionable
13
+ contract ProxyManager is
14
+ NftOwnable
15
+ {
16
+
17
+ event LogProxyDeployed(address indexed proxy, address initialImplementation);
18
+ event LogProxyDeployedWithSalt(address indexed proxy, address initialImplementation);
19
+ event LogProxyUpgraded(address indexed proxy, address upgradedImplementation);
20
+
21
+ error ErrorAlreadyDeployed();
22
+ error ErrorAlreadyDeployedWithSalt();
23
+ error ErrorNotYetDeployed();
24
+
25
+ UpgradableProxyWithAdmin internal _proxy;
26
+ bool internal _isDeployed;
27
+
28
+ /// @dev only used to capture proxy owner
29
+ constructor()
30
+ {
31
+ initializeOwner(msg.sender);
32
+ }
33
+
34
+ /// @dev deploy initial contract
35
+ function deploy(address initialImplementation, bytes memory initializationData)
36
+ public
37
+ virtual
38
+ onlyOwner()
39
+ returns (IVersionable versionable)
40
+ {
41
+ if (_isDeployed) { revert ErrorAlreadyDeployed(); }
42
+ _isDeployed = true;
43
+
44
+ address currentProxyOwner = getOwner(); // used by implementation
45
+ address initialProxyAdminOwner = address(this); // used by proxy
46
+ bytes memory data = getDeployData(initialImplementation, currentProxyOwner, initializationData);
47
+
48
+ _proxy = new UpgradableProxyWithAdmin(
49
+ initialImplementation,
50
+ initialProxyAdminOwner,
51
+ data
52
+ );
53
+
54
+ versionable = IVersionable(address(_proxy));
55
+
56
+ emit LogProxyDeployed(address(_proxy), initialImplementation);
57
+ }
58
+
59
+ /// @dev upgrade existing contract
60
+ function upgrade(address newImplementation, bytes memory upgradeData)
61
+ public
62
+ virtual
63
+ onlyOwner()
64
+ returns (IVersionable versionable)
65
+ {
66
+ if (!_isDeployed) { revert ErrorNotYetDeployed(); }
67
+
68
+ address currentProxyOwner = getOwner();
69
+ ProxyAdmin proxyAdmin = getProxy().getProxyAdmin();
70
+ ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(_proxy));
71
+ bytes memory data = getUpgradeData(newImplementation, currentProxyOwner, upgradeData);
72
+
73
+ proxyAdmin.upgradeAndCall(
74
+ proxy,
75
+ newImplementation,
76
+ data);
77
+
78
+ versionable = IVersionable(address(_proxy));
79
+
80
+ emit LogProxyUpgraded(address(_proxy), newImplementation);
81
+
82
+ }
83
+
84
+ function getDeployData(address implementation, address proxyOwner, bytes memory deployData) public pure returns (bytes memory data) {
85
+ return abi.encodeWithSelector(IVersionable.initializeVersionable.selector, implementation, proxyOwner, deployData);
86
+ }
87
+
88
+ function getUpgradeData(address implementation, address proxyOwner, bytes memory upgradeData) public pure returns (bytes memory data) {
89
+ return abi.encodeWithSelector(IVersionable.upgradeVersionable.selector, implementation, proxyOwner, upgradeData);
90
+ }
91
+
92
+ function getProxy() public returns (UpgradableProxyWithAdmin) {
93
+ return _proxy;
94
+ }
95
+ }
@@ -0,0 +1,81 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
+
6
+ import {NftId, zeroNftId} from "../types/NftId.sol";
7
+ import {NftOwnable} from "../shared/NftOwnable.sol";
8
+ import {ObjectType} from "../types/ObjectType.sol";
9
+
10
+ import {IRegistry} from "../registry/IRegistry.sol";
11
+ import {IRegisterable} from "./IRegisterable.sol";
12
+ import {Versionable} from "./Versionable.sol";
13
+
14
+ contract Registerable is
15
+ NftOwnable,
16
+ IRegisterable
17
+ {
18
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Registerable.sol")) - 1)) & ~bytes32(uint256(0xff));
19
+ bytes32 public constant REGISTERABLE_LOCATION_V1 = 0x6548007c3f4340f82f348c576c0ff69f4f529cadd5ad41f96aae61abceeaa300;
20
+
21
+ error ErrorRegisterableNotRegistry(address registryAddress);
22
+
23
+ struct RegisterableStorage {
24
+ NftId _parentNftId;
25
+ ObjectType _objectType;
26
+ bool _isInterceptor;
27
+ bytes _data;
28
+ }
29
+
30
+ function _getRegisterableStorage() private pure returns (RegisterableStorage storage $) {
31
+ assembly {
32
+ $.slot := REGISTERABLE_LOCATION_V1
33
+ }
34
+ }
35
+
36
+ function initializeRegisterable(
37
+ address registryAddress,
38
+ NftId parentNftId,
39
+ ObjectType objectType,
40
+ bool isInterceptor,
41
+ address initialOwner,
42
+ bytes memory data
43
+ )
44
+ public
45
+ virtual
46
+ onlyInitializing
47
+ {
48
+ initializeNftOwnable(
49
+ initialOwner,
50
+ registryAddress);
51
+
52
+ // TODO check parentNftId -> registry.isRegistered(parentNftId)
53
+ // TODO check object-parent type pair -> registry.isValidTypeCombo() or something...verify with registry that setup will be able to register...
54
+
55
+ RegisterableStorage storage $ = _getRegisterableStorage();
56
+ $._parentNftId = parentNftId;
57
+ $._objectType = objectType;
58
+ $._isInterceptor = isInterceptor;
59
+ $._data = data;
60
+
61
+ registerInterface(type(IRegisterable).interfaceId);
62
+ }
63
+
64
+
65
+ function getInitialInfo()
66
+ public
67
+ view
68
+ virtual
69
+ returns (IRegistry.ObjectInfo memory info)
70
+ {
71
+ RegisterableStorage memory $ = _getRegisterableStorage();
72
+ info = IRegistry.ObjectInfo(
73
+ zeroNftId(),
74
+ $._parentNftId,
75
+ $._objectType,
76
+ $._isInterceptor,
77
+ address(this),
78
+ getInitialOwner(),
79
+ $._data);
80
+ }
81
+ }
@@ -0,0 +1,64 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
+ import {IRegistry} from "../registry/IRegistry.sol";
6
+ import {IRegistryLinked} from "./IRegistryLinked.sol";
7
+
8
+ contract RegistryLinked is
9
+ Initializable,
10
+ IRegistryLinked
11
+ {
12
+
13
+ IRegistry private _registry;
14
+
15
+ /// @dev initialization for upgradable contracts
16
+ // used in _initializeRegisterable
17
+ function initializeRegistryLinked(
18
+ address registryAddress
19
+ )
20
+ public
21
+ virtual
22
+ onlyInitializing()
23
+ {
24
+ _setRegistry(registryAddress);
25
+ }
26
+
27
+
28
+ function getRegistry() public view returns (IRegistry) {
29
+ return _registry;
30
+ }
31
+
32
+
33
+ function getRegistryAddress() public view returns (address) {
34
+ return address(_registry);
35
+ }
36
+
37
+
38
+ function _setRegistry(address registryAddress)
39
+ internal
40
+ {
41
+
42
+ if (address(_registry) != address(0)) {
43
+ revert ErrorRegistryAlreadyInitialized(address(_registry));
44
+ }
45
+
46
+ if (registryAddress == address(0)) {
47
+ revert ErrorRegistryAddressZero();
48
+ }
49
+
50
+ if (registryAddress.code.length == 0) {
51
+ revert ErrorNotRegistry(registryAddress);
52
+ }
53
+
54
+ _registry = IRegistry(registryAddress);
55
+
56
+ try _registry.supportsInterface(type(IRegistry).interfaceId) returns (bool isRegistry) {
57
+ if (!isRegistry) {
58
+ revert ErrorNotRegistry(registryAddress);
59
+ }
60
+ } catch {
61
+ revert ErrorNotRegistry(registryAddress);
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {ObjectType, SERVICE} from "../types/ObjectType.sol";
5
+ import {NftId, zeroNftId} from "../types/NftId.sol";
6
+ import {Version, VersionPart, VersionLib} from "../types/Version.sol";
7
+
8
+ import {Versionable} from "./Versionable.sol";
9
+ import {IService} from "./IService.sol";
10
+ import {IVersionable} from "./IVersionable.sol";
11
+ import {Versionable} from "./Versionable.sol";
12
+ import {Registerable} from "./Registerable.sol";
13
+
14
+ import {IRegistry} from "../registry/IRegistry.sol";
15
+
16
+
17
+ /// @dev service base contract
18
+ abstract contract Service is
19
+ Registerable,
20
+ Versionable,
21
+ IService
22
+ {
23
+ function getDomain() public pure virtual override returns(ObjectType);
24
+
25
+ function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
26
+ return getVersion().toMajorPart();
27
+ }
28
+
29
+ // from Versionable
30
+ function getVersion()
31
+ public
32
+ pure
33
+ virtual override (IVersionable, Versionable)
34
+ returns(Version)
35
+ {
36
+ return VersionLib.toVersion(3,0,0);
37
+ }
38
+
39
+ function initializeService(
40
+ address registry,
41
+ address initialOwner
42
+ )
43
+ public
44
+ virtual
45
+ onlyInitializing()
46
+ {
47
+ // service must provide its name and version upon registration
48
+ bytes memory data = abi.encode(getDomain(), getMajorVersion());
49
+ NftId registryNftId = _getRegistryNftId(registry);
50
+ bool isInterceptor = false;
51
+
52
+ initializeRegisterable(registry, registryNftId, SERVICE(), isInterceptor, initialOwner, data);
53
+ registerInterface(type(IService).interfaceId);
54
+ }
55
+
56
+ // this is just a conveniene function, actual validation will be done upon registration
57
+ function _getRegistryNftId(address registryAddress) internal view returns (NftId) {
58
+ return IRegistry(registryAddress).getNftId(registryAddress);
59
+ }
60
+ }
@@ -0,0 +1,27 @@
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
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6
+
7
+ contract TokenHandler {
8
+ IERC20Metadata private _token;
9
+
10
+ constructor(address token) {
11
+ _token = IERC20Metadata(token);
12
+ }
13
+
14
+ // TODO add logging
15
+ function transfer(
16
+ address from,
17
+ address to,
18
+ uint256 amount // TODO add authz (only treasury/instance/product/pool/ service)
19
+ ) external {
20
+ SafeERC20.safeTransferFrom(_token, from, to, amount);
21
+ // _token.transferFrom(from, to, amount);
22
+ }
23
+
24
+ function getToken() external view returns (IERC20Metadata) {
25
+ return _token;
26
+ }
27
+ }