@etherisc/gif-next 0.0.2-e4b632c-016 → 0.0.2-e545d2c-624

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. package/README.md +67 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +168 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +156 -91
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +130 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +28 -2
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +188 -120
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +164 -143
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  37. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +788 -0
  40. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
  41. package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +74 -3
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +1463 -93
  44. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  45. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  46. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  47. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +104 -14
  48. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  49. package/artifacts/contracts/instance/Instance.sol/Instance.json +153 -660
  50. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +243 -126
  52. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  53. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  54. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +177 -38
  56. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  57. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +268 -60
  58. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  59. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +52 -24
  60. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
  61. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +285 -0
  62. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +60 -9
  64. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  68. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  70. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  71. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  78. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1031 -0
  79. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  80. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +436 -0
  81. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  82. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +39 -52
  83. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  84. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +118 -29
  85. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  86. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +18 -26
  87. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  88. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +720 -0
  89. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +13 -13
  91. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  92. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  93. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  94. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +771 -0
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  96. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -77
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +25 -240
  99. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1156 -0
  101. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  102. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +492 -0
  103. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
  104. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +727 -0
  105. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
  106. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +420 -0
  107. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
  108. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +777 -0
  109. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
  110. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +420 -0
  111. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  112. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  113. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  114. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +263 -63
  115. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  116. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +187 -83
  117. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  118. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  119. package/artifacts/contracts/registry/Registry.sol/Registry.json +233 -192
  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 +1 -1
  123. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +31 -97
  124. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  125. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -91
  126. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  127. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +530 -0
  128. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
  129. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +397 -0
  130. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  131. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  132. package/artifacts/contracts/shared/ERC165.sol/ERC165.json +2 -2
  133. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  134. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  135. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  136. package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
  137. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  139. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  140. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  141. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  142. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  143. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +4 -4
  144. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  145. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  146. package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
  147. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  148. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  149. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  150. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +4 -4
  154. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  156. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestService.sol/TestService.json +31 -31
  158. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  160. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  161. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  162. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  163. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  164. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  165. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  167. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  170. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  172. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +26 -3
  173. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  179. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  182. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  185. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
  187. package/contracts/components/BaseComponent.sol +87 -14
  188. package/contracts/components/Distribution.sol +17 -19
  189. package/contracts/components/IBaseComponent.sol +10 -0
  190. package/contracts/components/IDistributionComponent.sol +1 -0
  191. package/contracts/components/IPoolComponent.sol +5 -1
  192. package/contracts/components/Pool.sol +45 -32
  193. package/contracts/components/Product.sol +52 -48
  194. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  195. package/contracts/instance/BundleManager.sol +129 -0
  196. package/contracts/instance/Cloneable.sol +46 -0
  197. package/contracts/instance/IInstance.sol +36 -7
  198. package/contracts/instance/IInstanceBase.sol +26 -0
  199. package/contracts/instance/IInstanceService.sol +13 -3
  200. package/contracts/instance/Instance.sol +56 -226
  201. package/contracts/instance/InstanceAccessManager.sol +93 -78
  202. package/contracts/instance/InstanceBase.sol +41 -0
  203. package/contracts/instance/InstanceReader.sol +26 -1
  204. package/contracts/instance/InstanceService.sol +278 -71
  205. package/contracts/instance/InstanceServiceManager.sol +10 -12
  206. package/contracts/instance/ObjectManager.sol +101 -0
  207. package/contracts/instance/base/ComponentServiceBase.sol +50 -13
  208. package/contracts/instance/module/IAccess.sol +27 -17
  209. package/contracts/instance/module/IBundle.sol +1 -0
  210. package/contracts/instance/module/ISetup.sol +3 -0
  211. package/contracts/instance/service/BundleService.sol +294 -0
  212. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  213. package/contracts/instance/service/ComponentOwnerService.sol +4 -6
  214. package/contracts/instance/service/DistributionService.sol +64 -14
  215. package/contracts/instance/service/DistributionServiceManager.sol +11 -13
  216. package/contracts/instance/service/IBundleService.sol +44 -0
  217. package/contracts/instance/service/IPolicyService.sol +94 -0
  218. package/contracts/instance/service/IPoolService.sol +6 -23
  219. package/contracts/instance/service/IProductService.sol +6 -73
  220. package/contracts/instance/service/PolicyService.sol +539 -0
  221. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  222. package/contracts/instance/service/PoolService.sol +145 -0
  223. package/contracts/instance/service/PoolServiceManager.sol +51 -0
  224. package/contracts/instance/service/ProductService.sol +213 -0
  225. package/contracts/instance/service/ProductServiceManager.sol +54 -0
  226. package/contracts/registry/ChainNft.sol +1 -1
  227. package/contracts/registry/IRegistry.sol +39 -6
  228. package/contracts/registry/IRegistryService.sol +36 -13
  229. package/contracts/registry/Registry.sol +172 -199
  230. package/contracts/registry/RegistryAccessManager.sol +210 -0
  231. package/contracts/registry/RegistryService.sol +78 -202
  232. package/contracts/registry/RegistryServiceManager.sol +20 -22
  233. package/contracts/registry/ReleaseManager.sol +342 -0
  234. package/contracts/registry/TokenRegistry.sol +110 -0
  235. package/contracts/shared/ERC165.sol +6 -2
  236. package/contracts/shared/IService.sol +2 -1
  237. package/contracts/shared/NftOwnable.sol +2 -4
  238. package/contracts/shared/ProxyManager.sol +1 -1
  239. package/contracts/shared/Registerable.sol +1 -0
  240. package/contracts/shared/Service.sol +11 -7
  241. package/contracts/test/TestService.sol +3 -2
  242. package/contracts/types/NftIdSet.sol +26 -24
  243. package/contracts/types/RoleId.sol +14 -6
  244. package/contracts/types/Version.sol +4 -1
  245. package/package.json +1 -1
  246. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  247. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  248. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  249. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  250. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  251. package/contracts/instance/AccessManagedSimple.sol +0 -122
  252. package/contracts/instance/AccessManagerSimple.sol +0 -692
  253. package/contracts/instance/IAccessManagerSimple.sol +0 -391
@@ -170,8 +170,8 @@
170
170
  "type": "function"
171
171
  }
172
172
  ],
173
- "bytecode": "0x61039161003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100925760003560e01c80638e4ad86c116100655780638e4ad86c1461012157806394aa449c14610144578063a123b37c14610152578063c9e66e291461017957600080fd5b806304b8f6c5146100975780632efe0113146100b357806349a7111a146100c657806355601007146100fd575b600080fd5b60005b60405162ffffff90911681526020015b60405180910390f35b61009a6100c136600461026e565b610190565b6100d96100d436600461029a565b610231565b6040805160ff948516815292841660208401529216918101919091526060016100aa565b61011361010b36600461029a565b62ffffff1690565b6040519081526020016100aa565b61013261012f3660046102c6565b90565b60405160ff90911681526020016100aa565b61009a61012f3660046102df565b61016061010b36600461029a565b60405167ffffffffffffffff90911681526020016100aa565b61013261018736600461029a565b60101c60ff1690565b6000610100841080156101a4575061010083105b80156101b1575061010082105b61020c5760405162461bcd60e51b815260206004820152602260248201527f4552524f523a5652532d3031303a56455253494f4e5f504152545f544f4f5f42604482015261494760f01b606482015260840160405180910390fd5b8161021f600885901b601087901b61031f565b610229919061031f565b949350505050565b600080808360ff601082901c166102488383610338565b915061ffff600883901c16600061025f8185610338565b92989197509195509350505050565b60008060006060848603121561028357600080fd5b505081359360208301359350604090920135919050565b6000602082840312156102ac57600080fd5b813562ffffff811681146102bf57600080fd5b9392505050565b6000602082840312156102d857600080fd5b5035919050565b6000602082840312156102f157600080fd5b813567ffffffffffffffff811681146102bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561033257610332610309565b92915050565b62ffffff82811682821603908082111561035457610354610309565b509291505056fea2646970667358221220e42f77cfda39708b26a423d08fb99d9e3d65c337357ab7291eb4fdfec94256eb64736f6c63430008140033",
174
- "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100925760003560e01c80638e4ad86c116100655780638e4ad86c1461012157806394aa449c14610144578063a123b37c14610152578063c9e66e291461017957600080fd5b806304b8f6c5146100975780632efe0113146100b357806349a7111a146100c657806355601007146100fd575b600080fd5b60005b60405162ffffff90911681526020015b60405180910390f35b61009a6100c136600461026e565b610190565b6100d96100d436600461029a565b610231565b6040805160ff948516815292841660208401529216918101919091526060016100aa565b61011361010b36600461029a565b62ffffff1690565b6040519081526020016100aa565b61013261012f3660046102c6565b90565b60405160ff90911681526020016100aa565b61009a61012f3660046102df565b61016061010b36600461029a565b60405167ffffffffffffffff90911681526020016100aa565b61013261018736600461029a565b60101c60ff1690565b6000610100841080156101a4575061010083105b80156101b1575061010082105b61020c5760405162461bcd60e51b815260206004820152602260248201527f4552524f523a5652532d3031303a56455253494f4e5f504152545f544f4f5f42604482015261494760f01b606482015260840160405180910390fd5b8161021f600885901b601087901b61031f565b610229919061031f565b949350505050565b600080808360ff601082901c166102488383610338565b915061ffff600883901c16600061025f8185610338565b92989197509195509350505050565b60008060006060848603121561028357600080fd5b505081359360208301359350604090920135919050565b6000602082840312156102ac57600080fd5b813562ffffff811681146102bf57600080fd5b9392505050565b6000602082840312156102d857600080fd5b5035919050565b6000602082840312156102f157600080fd5b813567ffffffffffffffff811681146102bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561033257610332610309565b92915050565b62ffffff82811682821603908082111561035457610354610309565b509291505056fea2646970667358221220e42f77cfda39708b26a423d08fb99d9e3d65c337357ab7291eb4fdfec94256eb64736f6c63430008140033",
173
+ "bytecode": "0x61039161003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100925760003560e01c80638e4ad86c116100655780638e4ad86c1461012157806394aa449c14610144578063a123b37c14610152578063c9e66e291461017957600080fd5b806304b8f6c5146100975780632efe0113146100b357806349a7111a146100c657806355601007146100fd575b600080fd5b60005b60405162ffffff90911681526020015b60405180910390f35b61009a6100c136600461026e565b610190565b6100d96100d436600461029a565b610231565b6040805160ff948516815292841660208401529216918101919091526060016100aa565b61011361010b36600461029a565b62ffffff1690565b6040519081526020016100aa565b61013261012f3660046102c6565b90565b60405160ff90911681526020016100aa565b61009a61012f3660046102df565b61016061010b36600461029a565b60405167ffffffffffffffff90911681526020016100aa565b61013261018736600461029a565b60101c60ff1690565b6000610100841080156101a4575061010083105b80156101b1575061010082105b61020c5760405162461bcd60e51b815260206004820152602260248201527f4552524f523a5652532d3031303a56455253494f4e5f504152545f544f4f5f42604482015261494760f01b606482015260840160405180910390fd5b8161021f600885901b601087901b61031f565b610229919061031f565b949350505050565b600080808360ff601082901c166102488383610338565b915061ffff600883901c16600061025f8185610338565b92989197509195509350505050565b60008060006060848603121561028357600080fd5b505081359360208301359350604090920135919050565b6000602082840312156102ac57600080fd5b813562ffffff811681146102bf57600080fd5b9392505050565b6000602082840312156102d857600080fd5b5035919050565b6000602082840312156102f157600080fd5b813567ffffffffffffffff811681146102bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561033257610332610309565b92915050565b62ffffff82811682821603908082111561035457610354610309565b509291505056fea264697066735822122096e4b37266f82e0aaf6f30afa90c545c35f82576ca3b67d630233921e58f525b64736f6c63430008140033",
174
+ "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100925760003560e01c80638e4ad86c116100655780638e4ad86c1461012157806394aa449c14610144578063a123b37c14610152578063c9e66e291461017957600080fd5b806304b8f6c5146100975780632efe0113146100b357806349a7111a146100c657806355601007146100fd575b600080fd5b60005b60405162ffffff90911681526020015b60405180910390f35b61009a6100c136600461026e565b610190565b6100d96100d436600461029a565b610231565b6040805160ff948516815292841660208401529216918101919091526060016100aa565b61011361010b36600461029a565b62ffffff1690565b6040519081526020016100aa565b61013261012f3660046102c6565b90565b60405160ff90911681526020016100aa565b61009a61012f3660046102df565b61016061010b36600461029a565b60405167ffffffffffffffff90911681526020016100aa565b61013261018736600461029a565b60101c60ff1690565b6000610100841080156101a4575061010083105b80156101b1575061010082105b61020c5760405162461bcd60e51b815260206004820152602260248201527f4552524f523a5652532d3031303a56455253494f4e5f504152545f544f4f5f42604482015261494760f01b606482015260840160405180910390fd5b8161021f600885901b601087901b61031f565b610229919061031f565b949350505050565b600080808360ff601082901c166102488383610338565b915061ffff600883901c16600061025f8185610338565b92989197509195509350505050565b60008060006060848603121561028357600080fd5b505081359360208301359350604090920135919050565b6000602082840312156102ac57600080fd5b813562ffffff811681146102bf57600080fd5b9392505050565b6000602082840312156102d857600080fd5b5035919050565b6000602082840312156102f157600080fd5b813567ffffffffffffffff811681146102bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561033257610332610309565b92915050565b62ffffff82811682821603908082111561035457610354610309565b509291505056fea264697066735822122096e4b37266f82e0aaf6f30afa90c545c35f82576ca3b67d630233921e58f525b64736f6c63430008140033",
175
175
  "linkReferences": {},
176
176
  "deployedLinkReferences": {}
177
177
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/c520e33bf963a0266cb4c3e3da195de4.json"
3
+ "buildInfo": "../../../build-info/e5530b5c57be84d76caaa584abf46dd1.json"
4
4
  }
@@ -7,7 +7,7 @@
7
7
  "inputs": [
8
8
  {
9
9
  "internalType": "VersionPart",
10
- "name": "x",
10
+ "name": "a",
11
11
  "type": "uint8"
12
12
  }
13
13
  ],
@@ -21,10 +21,29 @@
21
21
  ],
22
22
  "stateMutability": "pure",
23
23
  "type": "function"
24
+ },
25
+ {
26
+ "inputs": [
27
+ {
28
+ "internalType": "uint256",
29
+ "name": "a",
30
+ "type": "uint256"
31
+ }
32
+ ],
33
+ "name": "toVersionPart",
34
+ "outputs": [
35
+ {
36
+ "internalType": "VersionPart",
37
+ "name": "",
38
+ "type": "uint8"
39
+ }
40
+ ],
41
+ "stateMutability": "pure",
42
+ "type": "function"
24
43
  }
25
44
  ],
26
- "bytecode": "0x60b9610039600b82828239805160001a60731461002c57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063ac43d834146038575b600080fd5b60496043366004605b565b60ff1690565b60405190815260200160405180910390f35b600060208284031215606c57600080fd5b813560ff81168114607c57600080fd5b939250505056fea264697066735822122028c6578af7cf354c26921be53c7bafd817914c3fa380a53d5f0e3935a1b47c8b64736f6c63430008140033",
27
- "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040526004361060335760003560e01c8063ac43d834146038575b600080fd5b60496043366004605b565b60ff1690565b60405190815260200160405180910390f35b600060208284031215606c57600080fd5b813560ff81168114607c57600080fd5b939250505056fea264697066735822122028c6578af7cf354c26921be53c7bafd817914c3fa380a53d5f0e3935a1b47c8b64736f6c63430008140033",
45
+ "bytecode": "0x60fb610039600b82828239805160001a60731461002c57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80638e4ad86c146042578063ac43d834146067575b600080fd5b6050604d3660046085565b90565b60405160ff90911681526020015b60405180910390f35b60786072366004609d565b60ff1690565b604051908152602001605e565b600060208284031215609657600080fd5b5035919050565b60006020828403121560ae57600080fd5b813560ff8116811460be57600080fd5b939250505056fea264697066735822122074bb6f75f2cab9692d05e41844bf40283045a9440c662c37a97b2502d38207ed64736f6c63430008140033",
46
+ "deployedBytecode": "0x7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80638e4ad86c146042578063ac43d834146067575b600080fd5b6050604d3660046085565b90565b60405160ff90911681526020015b60405180910390f35b60786072366004609d565b60ff1690565b604051908152602001605e565b600060208284031215609657600080fd5b5035919050565b60006020828403121560ae57600080fd5b813560ff8116811460be57600080fd5b939250505056fea264697066735822122074bb6f75f2cab9692d05e41844bf40283045a9440c662c37a97b2502d38207ed64736f6c63430008140033",
28
47
  "linkReferences": {},
29
48
  "deployedLinkReferences": {}
30
49
  }
@@ -1,24 +1,30 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
4
5
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
6
 
6
- import {Registerable} from "../shared/Registerable.sol";
7
-
8
- import {IRegistry} from "../registry/IRegistry.sol";
9
- import {IInstance} from "../instance/IInstance.sol";
10
-
11
- import {IInstance} from "../instance/IInstance.sol";
12
- import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
13
7
  import {IBaseComponent} from "./IBaseComponent.sol";
14
- import {NftId} from "../types/NftId.sol";
15
- import {ObjectType} from "../types/ObjectType.sol";
8
+ import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
9
+ import {IInstanceService} from "../instance/IInstanceService.sol";
10
+ import {IInstance} from "../instance/IInstance.sol";
11
+ import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
12
+ import {IRegistry} from "../registry/IRegistry.sol";
13
+ import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
14
+ import {ObjectType, INSTANCE} from "../types/ObjectType.sol";
15
+ import {VersionLib} from "../types/Version.sol";
16
+ import {Registerable} from "../shared/Registerable.sol";
17
+ import {RoleId, RoleIdLib} from "../types/RoleId.sol";
18
+ import {IAccess} from "../instance/module/IAccess.sol";
16
19
 
17
20
  abstract contract BaseComponent is
18
21
  Registerable,
19
22
  IBaseComponent
20
23
  {
24
+ using NftIdLib for NftId;
25
+
21
26
  IComponentOwnerService internal _componentOwnerService;
27
+ IInstanceService internal _instanceService;
22
28
 
23
29
  address internal _deployer;
24
30
  address internal _wallet;
@@ -26,10 +32,26 @@ abstract contract BaseComponent is
26
32
  IInstance internal _instance;
27
33
  NftId internal _productNftId;
28
34
 
35
+ modifier onlyInstanceRole(uint64 roleIdNum) {
36
+ RoleId roleId = RoleIdLib.toRoleId(roleIdNum);
37
+ InstanceAccessManager accessManager = InstanceAccessManager(_instance.authority());
38
+ if( !accessManager.hasRole(roleId, msg.sender)) {
39
+ revert ErrorBaseComponentUnauthorized(msg.sender, roleIdNum);
40
+ }
41
+ _;
42
+ }
43
+
44
+ modifier isNotLocked() {
45
+ InstanceAccessManager accessManager = InstanceAccessManager(_instance.authority());
46
+ if (accessManager.isTargetLocked(address(this))) {
47
+ revert IAccess.ErrorIAccessTargetLocked(address(this));
48
+ }
49
+ _;
50
+ }
51
+
29
52
  constructor(
30
53
  address registry,
31
54
  NftId instanceNftId,
32
- NftId productNftId,
33
55
  address token,
34
56
  ObjectType componentType,
35
57
  bool isInterceptor,
@@ -47,20 +69,24 @@ abstract contract BaseComponent is
47
69
  );
48
70
 
49
71
  _componentOwnerService = _instance.getComponentOwnerService();
72
+ _instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), VersionLib.toVersion(3, 0, 0).toMajorPart()));
50
73
  _wallet = address(this);
51
74
  _token = IERC20Metadata(token);
52
- _productNftId = productNftId;
53
75
 
54
76
  _registerInterface(type(IBaseComponent).interfaceId);
55
77
  }
56
78
 
79
+ function getName() public pure virtual returns (string memory name);
80
+
57
81
  // from component contract
82
+ // TODO only owner and instance owner
58
83
  function lock() external onlyOwner override {
59
- _componentOwnerService.lock(this);
84
+ _instanceService.setTargetLocked(getName(), true);
60
85
  }
61
-
86
+
87
+ // TODO only owner and instance owner
62
88
  function unlock() external onlyOwner override {
63
- _componentOwnerService.unlock(this);
89
+ _instanceService.setTargetLocked(getName(), false);
64
90
  }
65
91
 
66
92
  function getWallet()
@@ -72,6 +98,48 @@ abstract contract BaseComponent is
72
98
  return _wallet;
73
99
  }
74
100
 
101
+ /// @dev Sets the wallet address for the component.
102
+ /// if the current wallet has tokens, these will be transferred.
103
+ /// if the new wallet address is externally owned, an approval from the
104
+ /// owner of the external wallet for the component to move all tokens must exist.
105
+ function setWallet(address newWallet) external override onlyOwner {
106
+ address currentWallet = _wallet;
107
+ uint256 currentBalance = _token.balanceOf(currentWallet);
108
+
109
+ // checks
110
+ if (newWallet == currentWallet) {
111
+ revert ErrorBaseComponentWalletAddressIsSameAsCurrent(newWallet);
112
+ }
113
+
114
+ if (currentBalance > 0) {
115
+ if (currentWallet == address(this)) {
116
+ // move tokens from component smart contract to external wallet
117
+ } else {
118
+ // move tokens from external wallet to component smart contract or another external wallet
119
+ uint256 allowance = _token.allowance(currentWallet, address(this));
120
+ if (allowance < currentBalance) {
121
+ revert ErrorBaseComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
122
+ }
123
+ }
124
+ }
125
+
126
+ // effects
127
+ _wallet = newWallet;
128
+ emit LogBaseComponentWalletAddressChanged(newWallet);
129
+
130
+ // interactions
131
+ if (currentBalance > 0) {
132
+ // transfer tokens from current wallet to new wallet
133
+ if (currentWallet == address(this)) {
134
+ // transferFrom requires self allowance too
135
+ _token.approve(address(this), currentBalance);
136
+ }
137
+
138
+ SafeERC20.safeTransferFrom(_token, currentWallet, newWallet, currentBalance);
139
+ emit LogBaseComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
140
+ }
141
+ }
142
+
75
143
  function getToken() public view override returns (IERC20Metadata token) {
76
144
  return _token;
77
145
  }
@@ -80,6 +148,11 @@ abstract contract BaseComponent is
80
148
  return _instance;
81
149
  }
82
150
 
151
+ function setProductNftId(NftId productNftId) public override onlyOwner {
152
+ require(_productNftId.eq(zeroNftId()), "product nft id already set");
153
+ _productNftId = productNftId;
154
+ }
155
+
83
156
  function getProductNftId() public view override returns (NftId productNftId) {
84
157
  return _productNftId;
85
158
  }
@@ -16,7 +16,7 @@ import {Registerable} from "../shared/Registerable.sol";
16
16
  import {TokenHandler} from "../shared/TokenHandler.sol";
17
17
  import {InstanceReader} from "../instance/InstanceReader.sol";
18
18
 
19
- contract Distribution is
19
+ abstract contract Distribution is
20
20
  BaseComponent,
21
21
  IDistributionComponent
22
22
  {
@@ -25,6 +25,8 @@ contract Distribution is
25
25
  Fee internal _initialDistributionFee;
26
26
  bool internal _isVerifying;
27
27
 
28
+ TokenHandler internal _tokenHandler;
29
+
28
30
  IDistributionService private _distributionService;
29
31
  IProductService private _productService;
30
32
 
@@ -38,21 +40,21 @@ contract Distribution is
38
40
  constructor(
39
41
  address registry,
40
42
  NftId instanceNftId,
41
- NftId productNftId,
42
43
  // TODO refactor into tokenNftId
43
44
  address token,
44
45
  bool verifying,
45
46
  Fee memory distributionFee,
46
47
  address initialOwner
47
48
  )
48
- BaseComponent(registry, instanceNftId, productNftId, token, DISTRIBUTION(), true, initialOwner)
49
+ BaseComponent(registry, instanceNftId, token, DISTRIBUTION(), true, initialOwner)
49
50
  {
50
51
  _isVerifying = verifying;
51
52
  _initialDistributionFee = distributionFee;
52
53
 
53
- // TODO: reactivate when services are available again
54
- // _distributionService = _instance.getDistributionService();
55
- // _productService = _instance.getProductService();
54
+ _tokenHandler = TokenHandler(token);
55
+
56
+ _distributionService = _instance.getDistributionService();
57
+ _productService = _instance.getProductService();
56
58
 
57
59
  _registerInterface(type(IDistributionComponent).interfaceId);
58
60
  }
@@ -123,19 +125,10 @@ contract Distribution is
123
125
  }
124
126
 
125
127
  function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
126
- if (getNftId().eq(zeroNftId())) {
127
- return ISetup.DistributionSetupInfo(
128
- _productNftId,
129
- TokenHandler(address(0)),
130
- _initialDistributionFee,
131
- _isVerifying,
132
- address(0)
133
- );
134
- }
135
-
136
128
  InstanceReader reader = _instance.getInstanceReader();
137
129
  return reader.getDistributionSetupInfo(getNftId());
138
130
  }
131
+
139
132
 
140
133
  /// @dev returns true iff the component needs to be called when selling/renewing policis
141
134
  function isVerifying() external view returns (bool verifying) {
@@ -152,14 +145,19 @@ contract Distribution is
152
145
  {
153
146
  (
154
147
  IRegistry.ObjectInfo memory info,
155
- bytes memory data
156
148
  ) = super.getInitialInfo();
157
149
 
158
150
  return (
159
151
  info,
160
152
  abi.encode(
161
- _initialDistributionFee,
162
- _isVerifying
153
+ getName(),
154
+ ISetup.DistributionSetupInfo(
155
+ _productNftId,
156
+ _tokenHandler,
157
+ _initialDistributionFee,
158
+ _isVerifying,
159
+ address(this)
160
+ )
163
161
  )
164
162
  );
165
163
  }
@@ -8,6 +8,14 @@ import {IInstance} from "../instance/IInstance.sol";
8
8
  import {NftId} from "../types/NftId.sol";
9
9
 
10
10
  interface IBaseComponent is IRegisterable {
11
+ error ErrorBaseComponentWalletAddressIsSameAsCurrent(address newWallet);
12
+ error ErrorBaseComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
13
+ error ErrorBaseComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
14
+
15
+ event LogBaseComponentWalletAddressChanged(address newWallet);
16
+ event LogBaseComponentWalletTokensTransferred(address from, address to, uint256 amount);
17
+
18
+ function getName() external pure virtual returns (string memory name);
11
19
 
12
20
  function lock() external;
13
21
 
@@ -15,10 +23,12 @@ interface IBaseComponent is IRegisterable {
15
23
 
16
24
  function getToken() external view returns (IERC20Metadata token);
17
25
 
26
+ function setWallet(address walletAddress) external;
18
27
  function getWallet() external view returns (address walletAddress);
19
28
 
20
29
  function getInstance() external view returns (IInstance instance);
21
30
 
31
+ function setProductNftId(NftId productNftId) external;
22
32
  function getProductNftId() external view returns (NftId productNftId);
23
33
 
24
34
  }
@@ -4,6 +4,7 @@ pragma solidity ^0.8.19;
4
4
  import {Fee} from "../types/Fee.sol";
5
5
  import {ReferralId} from "../types/Referral.sol";
6
6
  import {NftId} from "../types/NftId.sol";
7
+ import {ISetup} from "../instance/module/ISetup.sol";
7
8
 
8
9
  interface IDistributionComponent {
9
10
 
@@ -43,6 +43,10 @@ interface IPoolComponent {
43
43
  uint256 collateralizationAmount
44
44
  ) external;
45
45
 
46
+ function lockBundle(NftId bundleNftId) external;
47
+
48
+ function unlockBundle(NftId bundleNftId) external;
49
+
46
50
  /**
47
51
  * @dev returns true iff the policy application data in policyData matches
48
52
  * with the bundle filter criteria encoded in bundleFilter.
@@ -55,7 +59,7 @@ interface IPoolComponent {
55
59
  view
56
60
  returns (bool isMatching);
57
61
 
58
- function isVerifying() external view returns (bool verifying);
62
+ function isConfirmingApplication() external view returns (bool isConfirmingApplication);
59
63
 
60
64
  function getCollateralizationLevel() external view returns (UFixed collateralizationLevel);
61
65
 
@@ -4,6 +4,7 @@ pragma solidity ^0.8.20;
4
4
  import {ObjectType, POOL} from "../types/ObjectType.sol";
5
5
  import {IProductService} from "../instance/service/IProductService.sol";
6
6
  import {IPoolService} from "../instance/service/IPoolService.sol";
7
+ import {IBundleService} from "../instance/service/IBundleService.sol";
7
8
  import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
8
9
  import {Fee} from "../types/Fee.sol";
9
10
  import {UFixed} from "../types/UFixed.sol";
@@ -22,22 +23,26 @@ import {InstanceReader} from "../instance/InstanceReader.sol";
22
23
  import {IRegisterable} from "../shared/IRegisterable.sol";
23
24
  import {Registerable} from "../shared/Registerable.sol";
24
25
 
25
- contract Pool is BaseComponent, IPoolComponent {
26
+ abstract contract Pool is BaseComponent, IPoolComponent {
26
27
  using NftIdLib for NftId;
27
28
 
28
- bool internal _isVerifying;
29
+ bool internal _isConfirmingApplication;
29
30
  UFixed internal _collateralizationLevel;
30
31
 
31
32
  Fee internal _initialPoolFee;
32
33
  Fee internal _initialStakingFee;
33
34
  Fee internal _initialPerformanceFee;
34
35
 
36
+ TokenHandler internal _tokenHandler;
37
+
35
38
  // may be used to interact with instance by derived contracts
36
39
  IPoolService internal _poolService;
37
40
 
38
41
  // only relevant to protect callback functions for "active" pools
39
42
  IProductService private _productService;
40
43
 
44
+ IBundleService private _bundleService;
45
+
41
46
  modifier onlyPoolService() {
42
47
  require(
43
48
  msg.sender == address(_poolService),
@@ -55,29 +60,30 @@ contract Pool is BaseComponent, IPoolComponent {
55
60
  constructor(
56
61
  address registry,
57
62
  NftId instanceNftId,
58
- NftId productNftId,
59
63
  // TODO refactor into tokenNftId
60
64
  address token,
61
65
  bool isInterceptor,
62
- bool verifying,
66
+ bool isConfirmingApplication,
63
67
  UFixed collateralizationLevel,
64
68
  Fee memory poolFee,
65
69
  Fee memory stakingFee,
66
70
  Fee memory performanceFee,
67
71
  address initialOwner
68
72
  )
69
- BaseComponent(registry, instanceNftId, productNftId, token, POOL(), isInterceptor, initialOwner)
73
+ BaseComponent(registry, instanceNftId, token, POOL(), isInterceptor, initialOwner)
70
74
  {
71
- _isVerifying = verifying;
75
+ _isConfirmingApplication = isConfirmingApplication;
72
76
  // TODO add validation
73
77
  _collateralizationLevel = collateralizationLevel;
74
78
  _initialPoolFee = poolFee;
75
79
  _initialStakingFee = stakingFee;
76
80
  _initialPerformanceFee = performanceFee;
77
81
 
78
- // TODO: reactivate when services are available again
79
- // _poolService = _instance.getPoolService();
80
- // _productService = _instance.getProductService();
82
+ _tokenHandler = new TokenHandler(token);
83
+
84
+ _poolService = _instance.getPoolService();
85
+ _productService = _instance.getProductService();
86
+ _bundleService = _instance.getBundleService();
81
87
 
82
88
  _registerInterface(type(IPoolComponent).interfaceId);
83
89
  }
@@ -93,7 +99,7 @@ contract Pool is BaseComponent, IPoolComponent {
93
99
  returns(NftId bundleNftId)
94
100
  {
95
101
  address owner = msg.sender;
96
- bundleNftId = _poolService.createBundle(
102
+ bundleNftId = _bundleService.createBundle(
97
103
  owner,
98
104
  fee,
99
105
  initialAmount,
@@ -138,8 +144,8 @@ contract Pool is BaseComponent, IPoolComponent {
138
144
  }
139
145
 
140
146
 
141
- function isVerifying() external view override returns (bool verifying) {
142
- return _isVerifying;
147
+ function isConfirmingApplication() external view override returns (bool isConfirmingApplication) {
148
+ return _isConfirmingApplication;
143
149
  }
144
150
 
145
151
  function getCollateralizationLevel() external view override returns (UFixed collateralizationLevel) {
@@ -166,24 +172,30 @@ contract Pool is BaseComponent, IPoolComponent {
166
172
  override
167
173
  // TODO add onlyBundleOwner
168
174
  {
169
- _poolService.setBundleFee(bundleNftId, fee);
175
+ _bundleService.setBundleFee(bundleNftId, fee);
170
176
  }
171
177
 
172
- function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
173
- // TODO fix this
174
- if (getNftId().eq(zeroNftId())) {
175
- return ISetup.PoolSetupInfo(
176
- _productNftId,
177
- TokenHandler(address(0)),
178
- _collateralizationLevel,
179
- _initialPoolFee,
180
- _initialStakingFee,
181
- _initialPerformanceFee,
182
- _isVerifying,
183
- _wallet
184
- );
185
- }
178
+ function lockBundle(
179
+ NftId bundleNftId
180
+ )
181
+ external
182
+ override
183
+ // TODO add onlyBundleOwner
184
+ {
185
+ _bundleService.lockBundle(bundleNftId);
186
+ }
186
187
 
188
+ function unlockBundle(
189
+ NftId bundleNftId
190
+ )
191
+ external
192
+ override
193
+ // TODO add onlyBundleOwner
194
+ {
195
+ _bundleService.unlockBundle(bundleNftId);
196
+ }
197
+
198
+ function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
187
199
  InstanceReader reader = _instance.getInstanceReader();
188
200
  return reader.getPoolSetupInfo(getNftId());
189
201
  }
@@ -200,20 +212,21 @@ contract Pool is BaseComponent, IPoolComponent {
200
212
  {
201
213
  (
202
214
  IRegistry.ObjectInfo memory info,
203
- bytes memory data
204
215
  ) = super.getInitialInfo();
205
216
 
206
217
  return (
207
218
  info,
208
219
  abi.encode(
220
+ getName(),
209
221
  ISetup.PoolSetupInfo(
210
- getProductNftId(),
211
- TokenHandler(address(0)),
222
+ _productNftId,
223
+ _tokenHandler,
212
224
  _collateralizationLevel,
213
225
  _initialPoolFee,
214
226
  _initialStakingFee,
215
227
  _initialPerformanceFee,
216
- _isVerifying,
228
+ false,
229
+ _isConfirmingApplication,
217
230
  _wallet
218
231
  )
219
232
  )
@@ -248,7 +261,7 @@ contract Pool is BaseComponent, IPoolComponent {
248
261
  internal
249
262
  returns(NftId bundleNftId)
250
263
  {
251
- bundleNftId = _poolService.createBundle(
264
+ bundleNftId = _bundleService.createBundle(
252
265
  bundleOwner,
253
266
  fee,
254
267
  amount,