@etherisc/gif-next 0.0.2-f30e0eb-805 → 0.0.2-f398177-971

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. package/README.md +6 -83
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +47 -6
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +70 -13
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IComponent.sol/IComponent.json +137 -6
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +144 -13
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +161 -20
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +151 -20
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +71 -20
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +62 -21
  18. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  19. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
  20. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  21. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  22. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +310 -2004
  23. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  24. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +101 -52
  25. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  26. package/artifacts/contracts/instance/Instance.sol/Instance.json +425 -2757
  27. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  28. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +95 -58
  29. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +4 -0
  30. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +124 -0
  31. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +348 -58
  33. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +153 -207
  35. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +38 -83
  37. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
  38. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2788 -0
  39. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  40. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
  41. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +113 -34
  43. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  44. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +8 -8
  47. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  48. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +6 -6
  49. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  50. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +6 -6
  51. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  52. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  54. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  55. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  58. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  59. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +186 -236
  60. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +38 -55
  62. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +377 -182
  64. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +74 -39
  66. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +713 -83
  68. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +147 -32
  70. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +266 -442
  72. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +82 -107
  74. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +111 -174
  76. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +233 -128
  78. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +385 -51
  80. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +109 -282
  82. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +210 -99
  84. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +682 -33
  86. package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.dbg.json +4 -0
  87. package/artifacts/contracts/instance/service/IPricingService.sol/IPricingService.json +510 -0
  88. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +85 -27
  90. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +420 -160
  92. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +104 -53
  94. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +880 -82
  96. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +90 -39
  98. package/artifacts/contracts/instance/service/PricingService.sol/PricingService.dbg.json +4 -0
  99. package/artifacts/contracts/instance/service/PricingService.sol/PricingService.json +1004 -0
  100. package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.dbg.json +4 -0
  101. package/artifacts/contracts/instance/service/PricingServiceManager.sol/PricingServiceManager.json +688 -0
  102. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +144 -57
  104. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  105. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +28 -37
  106. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  107. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  108. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  109. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +5 -37
  110. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  111. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  112. package/artifacts/contracts/registry/Registry.sol/Registry.json +2 -2
  113. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  114. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  115. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  116. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +22 -49
  117. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  118. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +21 -34
  119. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  120. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
  121. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  122. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +10 -23
  123. package/artifacts/contracts/shared/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  124. package/artifacts/contracts/{instance → shared}/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +3 -3
  125. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  126. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  127. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  128. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +0 -13
  129. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  130. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +69 -9
  131. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +0 -13
  133. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  134. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.json +0 -13
  135. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  136. package/artifacts/contracts/shared/IService.sol/IService.json +85 -27
  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 +6 -19
  140. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  141. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +80 -26
  142. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  143. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +14 -27
  144. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  145. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +6 -19
  146. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  147. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -15
  148. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  149. package/artifacts/contracts/shared/Service.sol/Service.json +91 -28
  150. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  151. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +24 -6
  152. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  153. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  156. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +6 -19
  158. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  159. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  160. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  161. package/artifacts/contracts/test/TestService.sol/TestService.json +106 -39
  162. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  163. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  164. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  165. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  166. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  167. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
  168. package/artifacts/contracts/types/Amount.sol/AmountLib.json +281 -0
  169. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +83 -4
  173. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  175. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/Fee.sol/FeeLib.json +74 -19
  177. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  178. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  179. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  181. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  182. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  183. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  185. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  186. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  187. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +116 -7
  188. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  189. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  190. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  192. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  194. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  196. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  197. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  198. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +17 -4
  199. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  200. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  201. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  202. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  203. package/contracts/components/Component.sol +25 -4
  204. package/contracts/components/Distribution.sol +11 -6
  205. package/contracts/components/IComponent.sol +19 -3
  206. package/contracts/components/IPoolComponent.sol +8 -7
  207. package/contracts/components/IProductComponent.sol +5 -4
  208. package/contracts/components/Pool.sol +17 -14
  209. package/contracts/components/Product.sol +144 -62
  210. package/contracts/instance/BundleManager.sol +3 -4
  211. package/contracts/instance/IInstance.sol +32 -53
  212. package/contracts/instance/IInstanceService.sol +15 -14
  213. package/contracts/instance/Instance.sol +107 -205
  214. package/contracts/instance/InstanceAccessManager.sol +44 -25
  215. package/contracts/instance/InstanceAuthorizationsLib.sol +308 -0
  216. package/contracts/instance/InstanceReader.sol +85 -7
  217. package/contracts/instance/InstanceService.sol +102 -289
  218. package/contracts/instance/InstanceStore.sol +212 -0
  219. package/contracts/instance/ObjectManager.sol +1 -1
  220. package/contracts/instance/base/ComponentService.sol +53 -39
  221. package/contracts/instance/base/KeyValueStore.sol +8 -34
  222. package/contracts/instance/base/Lifecycle.sol +15 -4
  223. package/contracts/instance/module/IAccess.sol +2 -2
  224. package/contracts/instance/module/IBundle.sol +6 -4
  225. package/contracts/instance/module/IComponents.sol +7 -1
  226. package/contracts/instance/module/IDistribution.sol +3 -2
  227. package/contracts/instance/module/IPolicy.sol +13 -8
  228. package/contracts/instance/service/ApplicationService.sol +62 -226
  229. package/contracts/instance/service/BundleService.sol +172 -126
  230. package/contracts/instance/service/ClaimService.sol +318 -32
  231. package/contracts/instance/service/DistributionService.sol +71 -190
  232. package/contracts/instance/service/IApplicationService.sol +8 -28
  233. package/contracts/instance/service/IBundleService.sol +82 -26
  234. package/contracts/instance/service/IClaimService.sol +52 -23
  235. package/contracts/instance/service/IDistributionService.sol +11 -22
  236. package/contracts/instance/service/IPolicyService.sol +24 -16
  237. package/contracts/instance/service/IPoolService.sol +82 -3
  238. package/contracts/instance/service/IPricingService.sol +37 -0
  239. package/contracts/instance/service/PolicyService.sol +152 -179
  240. package/contracts/instance/service/PoolService.sol +239 -56
  241. package/contracts/instance/service/PricingService.sol +275 -0
  242. package/contracts/instance/service/PricingServiceManager.sol +51 -0
  243. package/contracts/instance/service/ProductService.sol +27 -58
  244. package/contracts/registry/IRegistryService.sol +2 -3
  245. package/contracts/registry/RegistryService.sol +24 -21
  246. package/contracts/registry/ReleaseManager.sol +20 -18
  247. package/contracts/shared/IPolicyHolder.sol +23 -9
  248. package/contracts/shared/IRegistryLinked.sol +0 -1
  249. package/contracts/shared/IService.sol +6 -6
  250. package/contracts/shared/NftOwnable.sol +0 -2
  251. package/contracts/shared/PolicyHolder.sol +30 -17
  252. package/contracts/shared/Registerable.sol +10 -9
  253. package/contracts/shared/RegistryLinked.sol +0 -5
  254. package/contracts/shared/Service.sol +21 -7
  255. package/contracts/shared/TokenHandler.sol +4 -2
  256. package/contracts/test/TestService.sol +1 -1
  257. package/contracts/types/Amount.sol +109 -0
  258. package/contracts/types/ClaimId.sol +25 -2
  259. package/contracts/types/Fee.sol +16 -8
  260. package/contracts/types/ObjectType.sol +9 -5
  261. package/contracts/types/PayoutId.sol +33 -5
  262. package/contracts/types/StateId.sol +6 -2
  263. package/contracts/types/Timestamp.sol +5 -0
  264. package/package.json +1 -1
  265. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +0 -4
  266. /package/contracts/{instance → shared}/AccessManagerUpgradeableInitializeable.sol +0 -0
@@ -0,0 +1,51 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IVersionable} from "../../shared/IVersionable.sol";
5
+ import {ProxyManager} from "../../shared/ProxyManager.sol";
6
+ import {PricingService} from "./PricingService.sol";
7
+ import {Registry} from "../../registry/Registry.sol";
8
+ import {RegistryService} from "../../registry/RegistryService.sol";
9
+ import {REGISTRY} from "../../types/ObjectType.sol";
10
+
11
+ contract PricingServiceManager is ProxyManager {
12
+
13
+ PricingService private _pricingService;
14
+
15
+ /// @dev initializes proxy manager with distribution service implementation and deploys instance
16
+ constructor(
17
+ address registryAddress
18
+ )
19
+ ProxyManager(registryAddress)
20
+ {
21
+ PricingService pricingSrv = new PricingService();
22
+ bytes memory data = abi.encode(registryAddress, address(this));
23
+ IVersionable versionable = deploy(
24
+ address(pricingSrv),
25
+ data);
26
+
27
+ _pricingService = PricingService(address(versionable));
28
+
29
+ // TODO `thi` must have a role or own nft to register service
30
+ //Registry registry = Registry(registryAddress);
31
+ //address registryServiceAddress = registry.getServiceAddress(REGISTRY(), _distributionService.getMajorVersion());
32
+ //RegistryService registryService = RegistryService(registryServiceAddress);
33
+ //registryService.registerService(_distributionService);
34
+
35
+ // TODO no nft to link yet
36
+ // link ownership of instance service manager ot nft owner of instance service
37
+ //_linkToNftOwnable(
38
+ // address(registryAddress),
39
+ // address(_distributionService));
40
+ }
41
+
42
+ //--- view functions ----------------------------------------------------//
43
+ function getPricingService()
44
+ external
45
+ view
46
+ returns (PricingService)
47
+ {
48
+ return _pricingService;
49
+ }
50
+
51
+ }
@@ -24,7 +24,7 @@ import {Timestamp, zeroTimestamp} from "../../types/Timestamp.sol";
24
24
  import {UFixed, UFixedLib} from "../../types/UFixed.sol";
25
25
  import {Blocknumber, blockNumber} from "../../types/Blocknumber.sol";
26
26
  import {ObjectType, PRODUCT, POOL, POLICY} from "../../types/ObjectType.sol";
27
- import {APPLIED, UNDERWRITTEN, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
27
+ import {APPLIED, ACTIVE, KEEP_STATE} from "../../types/StateId.sol";
28
28
  import {NftId, NftIdLib, zeroNftId} from "../../types/NftId.sol";
29
29
  import {Fee, FeeLib} from "../../types/Fee.sol";
30
30
  import {ReferralId} from "../../types/Referral.sol";
@@ -60,9 +60,9 @@ contract ProductService is ComponentService, IProductService {
60
60
  address initialOwner;
61
61
  (registryAddress, initialOwner) = abi.decode(data, (address, address));
62
62
 
63
- initializeService(registryAddress, owner);
63
+ initializeService(registryAddress, address(0), owner);
64
64
 
65
- _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
65
+ _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getVersion().toMajorPart()));
66
66
 
67
67
  registerInterface(type(IProductService).interfaceId);
68
68
  }
@@ -111,7 +111,7 @@ contract ProductService is ComponentService, IProductService {
111
111
  product.linkToRegisteredNftId();
112
112
 
113
113
  // create product setup in instance
114
- instance.createProductSetup(productNftId, product.getSetupInfo());
114
+ instance.getInstanceStore().createProductSetup(productNftId, product.getSetupInfo());
115
115
 
116
116
  bytes4[][] memory selectors = new bytes4[][](1);
117
117
  selectors[0] = new bytes4[](1);
@@ -129,7 +129,7 @@ contract ProductService is ComponentService, IProductService {
129
129
  roles);
130
130
  }
131
131
 
132
- function getDomain() public pure override(IService, Service) returns(ObjectType) {
132
+ function getDomain() public pure override returns(ObjectType) {
133
133
  return PRODUCT();
134
134
  }
135
135
 
@@ -147,38 +147,6 @@ contract ProductService is ComponentService, IProductService {
147
147
  // if(wallet == address(0)) {
148
148
  // revert WalletIsZero();
149
149
  // }
150
-
151
- // IRegistry.ObjectInfo memory tokenInfo = getRegistry().getObjectInfo(address(info.token));
152
-
153
- // if(tokenInfo.objectType != TOKEN()) {
154
- // revert InvalidToken();
155
- // }
156
-
157
- // IRegistry.ObjectInfo memory poolInfo = getRegistry().getObjectInfo(info.poolNftId);
158
-
159
- // if(poolInfo.objectType != POOL()) {
160
- // revert InvalidPool();
161
- // }
162
-
163
- // if(poolInfo.parentNftId != instanceNftId) {
164
- // revert InvalidPoolsInstance();
165
- // }
166
- // // TODO pool have the same token
167
- // //ITreasury.PoolSetup memory poolSetup = instance.getPoolSetup(info.poolNftId);
168
- // //require(tokenInfo.objectAddress == address(poolSetup.token), "ERROR:COS-018:PRODUCT_POOL_TOKEN_MISMATCH");
169
- // // TODO pool is not linked
170
-
171
- // IRegistry.ObjectInfo memory distributionInfo = getRegistry().getObjectInfo(info.distributionNftId);
172
-
173
- // if(distributionInfo.objectType != DISTRIBUTION()) {
174
- // revert InvalidDistribution();
175
- // }
176
-
177
- // if(distributionInfo.parentNftId != instanceNftId) {
178
- // revert InvalidDistributionsInstance();
179
- // }
180
- // // TODO distribution have the same token
181
- // // TODO distribution is not linked
182
150
  }
183
151
 
184
152
  function setFees(
@@ -189,32 +157,28 @@ contract ProductService is ComponentService, IProductService {
189
157
  {
190
158
  // TODO check args
191
159
 
192
- (
193
- IRegistry.ObjectInfo memory productInfo,
194
- IInstance instance
195
- ) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
196
-
160
+ (NftId productNftId,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
197
161
  InstanceReader instanceReader = instance.getInstanceReader();
198
- NftId productNftId = productInfo.nftId;
162
+
199
163
  ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
200
164
 
201
165
  productSetupInfo.productFee = productFee;
202
166
  productSetupInfo.processingFee = processingFee;
203
167
 
204
- instance.updateProductSetup(productNftId, productSetupInfo, KEEP_STATE());
168
+ instance.getInstanceStore().updateProductSetup(productNftId, productSetupInfo, KEEP_STATE());
205
169
  }
206
170
 
207
171
  function createRisk(
208
172
  RiskId riskId,
209
173
  bytes memory data
210
- ) external override {
211
- (
212
- IRegistry.ObjectInfo memory productInfo,
213
- IInstance instance
214
- ) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
215
- NftId productNftId = productInfo.nftId;
174
+ )
175
+ external
176
+ override
177
+ {
178
+ (NftId productNftId,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
216
179
  IRisk.RiskInfo memory riskInfo = IRisk.RiskInfo(productNftId, data);
217
- instance.createRisk(
180
+
181
+ instance.getInstanceStore().createRisk(
218
182
  riskId,
219
183
  riskInfo
220
184
  );
@@ -223,19 +187,24 @@ contract ProductService is ComponentService, IProductService {
223
187
  function updateRisk(
224
188
  RiskId riskId,
225
189
  bytes memory data
226
- ) external {
227
- (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
190
+ )
191
+ external
192
+ {
193
+ (,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
228
194
  InstanceReader instanceReader = instance.getInstanceReader();
195
+
229
196
  IRisk.RiskInfo memory riskInfo = instanceReader.getRiskInfo(riskId);
230
197
  riskInfo.data = data;
231
- instance.updateRisk(riskId, riskInfo, KEEP_STATE());
198
+ instance.getInstanceStore().updateRisk(riskId, riskInfo, KEEP_STATE());
232
199
  }
233
200
 
234
201
  function updateRiskState(
235
202
  RiskId riskId,
236
203
  StateId state
237
- ) external {
238
- (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
239
- instance.updateRiskState(riskId, state);
204
+ )
205
+ external
206
+ {
207
+ (,, IInstance instance) = _getAndVerifyCallingComponentAndInstance(PRODUCT());
208
+ instance.getInstanceStore().updateRiskState(riskId, state);
240
209
  }
241
- }
210
+ }
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
4
+ // import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
5
5
 
6
6
  import {NftId} from "../types/NftId.sol";
7
7
  import {ObjectType} from "../types/ObjectType.sol";
@@ -13,8 +13,7 @@ import {IRegisterable} from "../shared/IRegisterable.sol";
13
13
  import {IComponent} from "../components/IComponent.sol";
14
14
 
15
15
  interface IRegistryService is
16
- IService,
17
- IAccessManaged
16
+ IService
18
17
  {
19
18
  error SelfRegistration();
20
19
  error NotRegistryOwner();
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
5
- import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
+ // import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
6
6
 
7
7
  import {IRegistry} from "./IRegistry.sol";
8
8
  import {IInstance} from "../instance/IInstance.sol";
@@ -19,7 +19,7 @@ import {IRegisterable} from "../../contracts/shared/IRegisterable.sol";
19
19
  import {Registerable} from "../../contracts/shared/Registerable.sol";
20
20
 
21
21
  import {RoleId, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE, ORACLE_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
22
- import {ObjectType, REGISTRY, SERVICE, PRODUCT, ORACLE, POOL, INSTANCE, DISTRIBUTION, DISTRIBUTOR, APPLICATION, POLICY, CLAIM, BUNDLE, STAKE} from "../../contracts/types/ObjectType.sol";
22
+ import {ObjectType, REGISTRY, SERVICE, PRODUCT, ORACLE, POOL, INSTANCE, DISTRIBUTION, DISTRIBUTOR, APPLICATION, POLICY, CLAIM, BUNDLE, STAKE, PRICE} from "../../contracts/types/ObjectType.sol";
23
23
  import {StateId, ACTIVE, PAUSED} from "../../contracts/types/StateId.sol";
24
24
  import {NftId, NftIdLib, zeroNftId} from "../../contracts/types/NftId.sol";
25
25
  import {Fee, FeeLib} from "../../contracts/types/Fee.sol";
@@ -31,7 +31,6 @@ import {IRegistryService} from "./IRegistryService.sol";
31
31
  import {Registry} from "./Registry.sol";
32
32
 
33
33
  contract RegistryService is
34
- AccessManagedUpgradeable,
35
34
  Service,
36
35
  IRegistryService
37
36
  {
@@ -41,7 +40,7 @@ contract RegistryService is
41
40
  bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
42
41
 
43
42
  // From IService
44
- function getDomain() public pure override(IService, Service) returns(ObjectType serviceDomain) {
43
+ function getDomain() public pure override returns(ObjectType serviceDomain) {
45
44
  return REGISTRY();
46
45
  }
47
46
 
@@ -61,9 +60,8 @@ contract RegistryService is
61
60
  address initialAuthority
62
61
  ) = abi.decode(data, (address, address));
63
62
 
64
- __AccessManaged_init(initialAuthority);
63
+ initializeService(registryAddress, initialAuthority, owner);
65
64
 
66
- initializeService(registryAddress, owner);
67
65
  registerInterface(type(IRegistryService).interfaceId);
68
66
  }
69
67
 
@@ -178,7 +176,7 @@ contract RegistryService is
178
176
  FunctionConfig[] memory config
179
177
  )
180
178
  {
181
- config = new FunctionConfig[](8);
179
+ config = new FunctionConfig[](9);
182
180
 
183
181
  // order of service registrations MUST be reverse to this array
184
182
  /*config[-1].serviceDomain = STAKE();
@@ -194,27 +192,32 @@ contract RegistryService is
194
192
  config[2].serviceDomain = CLAIM();
195
193
  config[2].selectors = new bytes4[](0);
196
194
 
197
- config[3].serviceDomain = BUNDLE();
195
+ config[3].serviceDomain = PRODUCT();
198
196
  config[3].selectors = new bytes4[](1);
199
- config[3].selectors[0] = RegistryService.registerBundle.selector;
197
+ config[3].selectors[0] = RegistryService.registerProduct.selector;
200
198
 
201
- config[4].serviceDomain = PRODUCT();
199
+ config[4].serviceDomain = POOL();
202
200
  config[4].selectors = new bytes4[](1);
203
- config[4].selectors[0] = RegistryService.registerProduct.selector;
201
+ config[4].selectors[0] = RegistryService.registerPool.selector;
204
202
 
205
- config[5].serviceDomain = POOL();
203
+ // registration of bundle service must preceed registration of pool service
204
+ config[5].serviceDomain = BUNDLE();
206
205
  config[5].selectors = new bytes4[](1);
207
- config[5].selectors[0] = RegistryService.registerPool.selector;
206
+ config[5].selectors[0] = RegistryService.registerBundle.selector;
208
207
 
209
- config[6].serviceDomain = DISTRIBUTION();
210
- config[6].selectors = new bytes4[](2);
211
- config[6].selectors[0] = RegistryService.registerDistribution.selector;
212
- config[6].selectors[1] = RegistryService.registerDistributor.selector;
208
+ // registration of pricing service must preceed registration of application service
209
+ config[6].serviceDomain = PRICE();
210
+ config[6].selectors = new bytes4[](0);
213
211
 
214
- // registerInstance() have no restriction
215
- config[7].serviceDomain = INSTANCE();
216
- config[7].selectors = new bytes4[](1);
217
- config[7].selectors[0] = RegistryService.registerInstance.selector;
212
+ // registration of distribution service must preceed registration of pricing service
213
+ config[7].serviceDomain = DISTRIBUTION();
214
+ config[7].selectors = new bytes4[](2);
215
+ config[7].selectors[0] = RegistryService.registerDistribution.selector;
216
+ config[7].selectors[1] = RegistryService.registerDistributor.selector;
217
+
218
+ config[8].serviceDomain = INSTANCE();
219
+ config[8].selectors = new bytes4[](1);
220
+ config[8].selectors[0] = RegistryService.registerInstance.selector;
218
221
  }
219
222
 
220
223
  // Internal
@@ -6,7 +6,7 @@ import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManage
6
6
  import {NftId} from "../types/NftId.sol";
7
7
  import {RoleId} from "../types/RoleId.sol";
8
8
  import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
9
- import {VersionPart, VersionPartLib} from "../types/Version.sol";
9
+ import {Version, VersionLib, VersionPart, VersionPartLib} from "../types/Version.sol";
10
10
  import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
11
11
 
12
12
  import {IService} from "../shared/IService.sol";
@@ -55,19 +55,19 @@ contract ReleaseManager is AccessManaged
55
55
  RegistryAccessManager private immutable _accessManager;
56
56
  IRegistry private immutable _registry;
57
57
 
58
- VersionPart immutable _initial;// first active version
59
- VersionPart _latest;// latest active version
60
- VersionPart _next;// version to create and activate
58
+ VersionPart immutable _initial;// first active major version
59
+ VersionPart _latest;// latest active major version
60
+ VersionPart _next;// major version to create and activate
61
61
 
62
- mapping(VersionPart version => IRegistry.ReleaseInfo info) _release;
62
+ mapping(VersionPart majorVersion => IRegistry.ReleaseInfo info) _release;
63
63
 
64
- mapping(VersionPart version => mapping(ObjectType serviceDomain => bytes4[])) _selectors; // registry service function selector assigned to domain
64
+ mapping(VersionPart majorVersion => mapping(ObjectType serviceDomain => bytes4[])) _selectors; // registry service function selector assigned to domain
65
65
 
66
66
  uint _awaitingRegistration; // "services left to register" counter
67
67
 
68
68
  mapping(address registryService => bool isActive) _active;
69
69
 
70
- mapping(VersionPart version => bool isValid) _valid; // TODO refactor to use _active only
70
+ mapping(VersionPart majorVersion => bool isValid) _valid; // TODO refactor to use _active only
71
71
 
72
72
  constructor(
73
73
  RegistryAccessManager accessManager,
@@ -146,12 +146,12 @@ contract ReleaseManager is AccessManaged
146
146
 
147
147
  IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
148
148
 
149
- VersionPart version = _next;
149
+ VersionPart majorVersion = _next;
150
150
  ObjectType domain = REGISTRY();
151
- _verifyService(service, version, domain);
151
+ _verifyService(service, majorVersion, domain);
152
152
  _createRelease(service.getFunctionConfigs());
153
153
 
154
- nftId = _registry.registerService(info, version, domain);
154
+ nftId = _registry.registerService(info, majorVersion, domain);
155
155
 
156
156
  // external call
157
157
  service.linkToRegisteredNftId();
@@ -169,13 +169,13 @@ contract ReleaseManager is AccessManaged
169
169
  }
170
170
 
171
171
  IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
172
- VersionPart version = getNextVersion();
173
- ObjectType domain = _release[version].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
174
- _verifyService(service, version, domain);
172
+ VersionPart majorVersion = getNextVersion();
173
+ ObjectType domain = _release[majorVersion].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
174
+ _verifyService(service, majorVersion, domain);
175
175
 
176
176
  // setup and grant unique role if service does registrations
177
- bytes4[] memory selectors = _selectors[version][domain];
178
- address registryService = _registry.getServiceAddress(REGISTRY(), version);
177
+ bytes4[] memory selectors = _selectors[majorVersion][domain];
178
+ address registryService = _registry.getServiceAddress(REGISTRY(), majorVersion);
179
179
  if(selectors.length > 0) {
180
180
  _accessManager.setAndGrantUniqueRole(
181
181
  address(service),
@@ -185,7 +185,7 @@ contract ReleaseManager is AccessManaged
185
185
 
186
186
  _awaitingRegistration--;
187
187
 
188
- nftId = _registry.registerService(info, version, domain);
188
+ nftId = _registry.registerService(info, majorVersion, domain);
189
189
 
190
190
  // external call
191
191
  service.linkToRegisteredNftId();
@@ -271,8 +271,10 @@ contract ReleaseManager is AccessManaged
271
271
  view
272
272
  returns(ObjectType)
273
273
  {
274
- if(service.getMajorVersion() != expectedVersion) {
275
- revert UnexpectedServiceVersion(expectedVersion, service.getMajorVersion());
274
+ Version version = service.getVersion();
275
+ VersionPart majorVersion = version.toMajorPart();
276
+ if(majorVersion != expectedVersion) {
277
+ revert UnexpectedServiceVersion(expectedVersion, majorVersion);
276
278
  }
277
279
 
278
280
  if(service.getDomain() != expectedDomain) {
@@ -4,23 +4,37 @@ pragma solidity ^0.8.20;
4
4
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
  import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
6
6
 
7
- import {IRegistry} from "../registry/IRegistry.sol";
7
+ import {Amount} from "../types/Amount.sol";
8
+ import {ClaimId} from "../types/ClaimId.sol";
9
+ import {IRegistryLinked} from "../shared/IRegistryLinked.sol";
8
10
  import {NftId} from "../types/NftId.sol";
9
- import {NumberId} from "../types/NumberId.sol";
11
+ import {PayoutId} from "../types/PayoutId.sol";
10
12
 
11
13
  /// @dev generic interface for contracts that need to hold policies and receive payouts
12
14
  /// GIF will notify policy holder contracts for policy creation and payout execution
13
- ///
15
+ interface IPolicyHolder is
16
+ IERC165,
17
+ IERC721Receiver,
18
+ IRegistryLinked
19
+ {
14
20
 
15
- interface IPolicyHolder is IERC165, IERC721Receiver {
21
+ /// @dev callback function that will be called after successful policy activation
22
+ /// active policies may open claims under the activated policy
23
+ function policyActivated(NftId policyNftId) external;
16
24
 
17
- /// @dev callback function that will be called after successful policy creation
18
- function policyCreatedCallback(NftId policyNftId) external;
25
+ /// @dev callback function to indicate the specified policy has expired
26
+ /// expired policies may no longer open claims
27
+ /// it is optional for products to notifiy policy holder of expired claims
28
+ function policyExpired(NftId policyNftId) external;
29
+
30
+ /// @dev callback function to notify the confirmation of the specified claim
31
+ /// active policies may open claims under the activated policy
32
+ function claimConfirmed(NftId policyNftId, ClaimId claimId, Amount amount) external;
19
33
 
20
34
  /// @dev callback function that will be called after a successful payout
21
- function payoutExecutedCallback(NftId policyNftId, NumberId payoutId, address beneficiary, uint256 amount) external;
35
+ function payoutExecuted(NftId policyNftId, PayoutId payoutId, address beneficiary, Amount amount) external;
22
36
 
23
- /// @dev determines beneficiary address that will be used in payouts targeting this contract
37
+ /// @dev determines policy and claim specific beneficiary address
24
38
  /// returned address will override GIF default where the policy nft holder is treated as beneficiary
25
- function getBeneficiary(NftId policyId, NumberId claimId) external view returns (address beneficiary);
39
+ function getBeneficiary(NftId policyNftId, ClaimId claimId) external view returns (address beneficiary);
26
40
  }
@@ -8,5 +8,4 @@ interface IRegistryLinked {
8
8
  error ErrorNotRegistry(address registryAddress);
9
9
 
10
10
  function getRegistry() external view returns (IRegistry);
11
- function getRegistryAddress() external view returns (address);
12
11
  }
@@ -1,18 +1,18 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {VersionPart} from "../types/Version.sol";
5
- import {ObjectType} from "../types/ObjectType.sol";
4
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
6
5
 
7
6
  import {IRegisterable} from "./IRegisterable.sol";
8
7
  import {IVersionable} from "./IVersionable.sol";
8
+ import {ObjectType} from "../types/ObjectType.sol";
9
9
 
10
10
  interface IService is
11
11
  IRegisterable,
12
- IVersionable
12
+ IVersionable,
13
+ IAccessManaged
13
14
  {
14
- error ErrorIServiceCallerUnknown(address caller);
15
-
15
+ error ErrorServiceNotImplemented();
16
+
16
17
  function getDomain() external pure returns(ObjectType serviceDomain);
17
- function getMajorVersion() external view returns(VersionPart majorVersion);
18
18
  }
@@ -1,8 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- // import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
-
6
4
  import {ERC165} from "./ERC165.sol";
7
5
  import {INftOwnable} from "./INftOwnable.sol";
8
6
  import {NftId} from "../types/NftId.sol";
@@ -5,11 +5,12 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
5
  import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
6
6
  import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
7
 
8
+ import {Amount} from "../types/Amount.sol";
9
+ import {ClaimId, ClaimIdLib} from "../types/ClaimId.sol";
8
10
  import {ERC165} from "./ERC165.sol";
9
11
  import {IPolicyHolder} from "./IPolicyHolder.sol";
10
- import {IRegistry} from "../registry/IRegistry.sol";
11
12
  import {NftId} from "../types/NftId.sol";
12
- import {NumberId} from "../types/NumberId.sol";
13
+ import {PayoutId} from "../types/PayoutId.sol";
13
14
  import {RegistryLinked} from "./RegistryLinked.sol";
14
15
 
15
16
  /// @dev template implementation for IPolicyHolder
@@ -22,33 +23,43 @@ contract PolicyHolder is
22
23
  // TODO fix address
23
24
  bytes32 public constant POLICY_HOLDER_STORAGE_LOCATION_V1 = 0x07ebcf49758b6ed3af50fa146bec0abe157c0218fe65dc0874c286e9d5da4f00;
24
25
 
25
- // TODO uncomment/fix/refactor
26
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;
27
+ mapping(NftId policyId => mapping(ClaimId claimId => address beneficiary)) _beneficiary;
30
28
  }
31
29
 
32
30
  function initializePolicyHolder(
33
- address registryAddress
31
+ address registryAddress,
32
+ address beneficiaryDefault
34
33
  )
35
34
  public
36
35
  virtual
37
36
  onlyInitializing()
38
37
  {
39
38
  initializeRegistryLinked(registryAddress);
39
+ registerInterface(type(IPolicyHolder).interfaceId);
40
40
  }
41
41
 
42
42
  /// @dev empty default implementation
43
- function policyCreatedCallback(NftId policyNftId) external virtual { }
43
+ function policyActivated(NftId policyNftId) external {}
44
44
 
45
45
  /// @dev empty default implementation
46
- function payoutExecutedCallback(NftId policyNftId, NumberId payoutId, address beneficiary, uint256 amount) external virtual { }
46
+ function policyExpired(NftId policyNftId) external {}
47
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
48
+ /// @dev empty default implementation
49
+ function claimConfirmed(NftId policyNftId, ClaimId claimId, Amount amount) external {}
50
+
51
+ /// @dev empty default implementation
52
+ function payoutExecuted(NftId policyNftId, PayoutId payoutId, address beneficiary, Amount amount) external {}
53
+
54
+ /// @dev returns claim specific beneficiary
55
+ /// when no such beneficiary is defined the policy specific beneficiary is returned
56
+ function getBeneficiary(NftId policyNftId, ClaimId claimId) external virtual view returns (address beneficiary) {
57
+ beneficiary = _getPolicyHolderStorage()._beneficiary[policyNftId][claimId];
58
+
59
+ // fallback to claim independent beneficiary
60
+ if(beneficiary == address(0) && claimId.gtz()) {
61
+ beneficiary = _getPolicyHolderStorage()._beneficiary[policyNftId][ClaimIdLib.zero()];
62
+ }
52
63
  }
53
64
 
54
65
  //--- IERC165 functions ---------------//
@@ -65,12 +76,14 @@ contract PolicyHolder is
65
76
  return IERC721Receiver.onERC721Received.selector;
66
77
  }
67
78
 
68
- function _setBeneficiary(address beneficiary) internal {
69
-
79
+ /// @dev sets policy specific beneficiary (used when no claim specific beneficiary is defined)
80
+ function _setBeneficiary(NftId policyNftId, address beneficiary) internal {
81
+ _setBeneficiary(policyNftId, ClaimIdLib.zero(), beneficiary);
70
82
  }
71
83
 
72
- function _setBeneficiary(NftId policyId, address beneficiary) internal {
73
-
84
+ /// @dev sets policy and claim specific beneficiary
85
+ function _setBeneficiary(NftId policyNftId, ClaimId claimId, address beneficiary) internal {
86
+ _getPolicyHolderStorage()._beneficiary[policyNftId][claimId] = beneficiary;
74
87
  }
75
88
 
76
89
  function _getPolicyHolderStorage() private pure returns (PolicyHolderStorage storage $) {
@@ -9,7 +9,6 @@ import {ObjectType} from "../types/ObjectType.sol";
9
9
 
10
10
  import {IRegistry} from "../registry/IRegistry.sol";
11
11
  import {IRegisterable} from "./IRegisterable.sol";
12
- import {Versionable} from "./Versionable.sol";
13
12
 
14
13
  contract Registerable is
15
14
  NftOwnable,
@@ -25,12 +24,6 @@ contract Registerable is
25
24
  bytes _data;
26
25
  }
27
26
 
28
- function _getRegisterableStorage() private pure returns (RegisterableStorage storage $) {
29
- assembly {
30
- $.slot := REGISTERABLE_LOCATION_V1
31
- }
32
- }
33
-
34
27
  function initializeRegisterable(
35
28
  address registryAddress,
36
29
  NftId parentNftId,
@@ -47,7 +40,11 @@ contract Registerable is
47
40
  initialOwner,
48
41
  registryAddress);
49
42
 
50
- RegisterableStorage storage $ = _getRegisterableStorage();
43
+ RegisterableStorage storage $;
44
+ assembly {
45
+ $.slot := REGISTERABLE_LOCATION_V1
46
+ }
47
+
51
48
  $._parentNftId = parentNftId;
52
49
  $._objectType = objectType;
53
50
  $._isInterceptor = isInterceptor;
@@ -61,7 +58,11 @@ contract Registerable is
61
58
  virtual
62
59
  returns (IRegistry.ObjectInfo memory info)
63
60
  {
64
- RegisterableStorage memory $ = _getRegisterableStorage();
61
+ RegisterableStorage storage $;
62
+ assembly {
63
+ $.slot := REGISTERABLE_LOCATION_V1
64
+ }
65
+
65
66
  info = IRegistry.ObjectInfo(
66
67
  zeroNftId(),
67
68
  $._parentNftId,
@@ -40,9 +40,4 @@ contract RegistryLinked is
40
40
  function getRegistry() public view returns (IRegistry) {
41
41
  return _registry;
42
42
  }
43
-
44
-
45
- function getRegistryAddress() public view returns (address) {
46
- return address(_registry);
47
- }
48
43
  }