@etherisc/gif-next 0.0.2-78bf628-134 → 0.0.2-790d44b-698

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +38 -7
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.json +405 -0
  5. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  6. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
  7. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +340 -0
  8. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +131 -0
  10. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +109 -18
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +194 -3
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +160 -21
  16. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +2 -2
  28. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  34. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  35. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +609 -416
  36. package/artifacts/contracts/instance/IInstanceLinked.sol/IInstanceLinked.dbg.json +1 -1
  37. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  38. package/artifacts/contracts/instance/Instance.sol/Instance.json +751 -467
  39. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  40. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +82 -18
  41. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  42. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +32 -0
  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/IService.sol/IService.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/IService.sol/IService.json +59 -18
  47. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.dbg.json +1 -1
  48. package/artifacts/contracts/instance/base/InstanceBase.sol/InstanceBase.json +115 -19
  49. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  50. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +14 -14
  51. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  52. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +4 -4
  53. package/artifacts/contracts/instance/base/ModuleBase.sol/ModuleBase.dbg.json +1 -1
  54. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +1 -1
  55. package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.json +82 -18
  56. package/artifacts/contracts/instance/module/access/Access.sol/AccessModule.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccess.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/access/IAccess.sol/IAccessModule.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.dbg.json +1 -1
  60. package/artifacts/contracts/instance/module/bundle/BundleModule.sol/BundleModule.json +55 -54
  61. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundle.dbg.json +1 -1
  62. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.dbg.json +1 -1
  63. package/artifacts/contracts/instance/module/bundle/IBundle.sol/IBundleModule.json +56 -55
  64. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/component/ComponentModule.sol/ComponentModule.json +12 -7
  66. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponent.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/component/IComponent.sol/IComponentModule.json +12 -7
  69. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.dbg.json +4 -0
  70. package/artifacts/contracts/instance/module/distribution/DistributionModule.sol/DistributionModule.json +10 -0
  71. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistribution.dbg.json +4 -0
  72. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensation.json → distribution/IDistribution.sol/IDistribution.json} +2 -2
  73. package/artifacts/contracts/instance/module/distribution/IDistribution.sol/IDistributionModule.dbg.json +4 -0
  74. package/artifacts/contracts/instance/module/{compensation/ICompensation.sol/ICompensationModule.json → distribution/IDistribution.sol/IDistributionModule.json} +2 -2
  75. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicy.dbg.json +1 -1
  76. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.dbg.json +1 -1
  77. package/artifacts/contracts/instance/module/policy/IPolicy.sol/IPolicyModule.json +53 -40
  78. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.dbg.json +1 -1
  79. package/artifacts/contracts/instance/module/policy/PolicyModule.sol/PolicyModule.json +53 -40
  80. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPool.dbg.json +1 -1
  81. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.dbg.json +1 -1
  82. package/artifacts/contracts/instance/module/pool/IPoolModule.sol/IPoolModule.json +0 -5
  83. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.dbg.json +1 -1
  84. package/artifacts/contracts/instance/module/pool/PoolModule.sol/PoolModule.json +0 -5
  85. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRisk.dbg.json +1 -1
  86. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.dbg.json +1 -1
  87. package/artifacts/contracts/instance/module/risk/IRisk.sol/IRiskModule.json +104 -1
  88. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.dbg.json +1 -1
  89. package/artifacts/contracts/instance/module/risk/RiskModule.sol/RiskModule.json +126 -5
  90. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasury.dbg.json +1 -1
  91. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.dbg.json +1 -1
  92. package/artifacts/contracts/instance/module/treasury/ITreasury.sol/ITreasuryModule.json +209 -231
  93. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  94. package/artifacts/contracts/instance/module/treasury/TokenHandler.sol/TokenHandler.json +2 -2
  95. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.dbg.json +1 -1
  96. package/artifacts/contracts/instance/module/treasury/TreasuryModule.sol/TreasuryModule.json +209 -231
  97. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  98. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +119 -47
  99. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
  100. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +484 -0
  101. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  102. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +59 -18
  103. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
  104. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +366 -0
  105. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  106. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +124 -19
  107. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  108. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +212 -18
  109. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  110. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +170 -34
  111. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  112. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +296 -47
  113. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  114. package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +1 -1
  115. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  116. package/artifacts/contracts/registry/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  117. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  118. package/artifacts/contracts/registry/Registry.sol/Registry.json +266 -14
  119. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  120. package/artifacts/contracts/shared/IOwnable.sol/IOwnable.dbg.json +1 -1
  121. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  122. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  123. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +55 -14
  124. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.dbg.json +4 -0
  125. package/artifacts/contracts/shared/Proxy.sol/ProxyDeployer.json +248 -0
  126. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.dbg.json +4 -0
  127. package/artifacts/contracts/shared/Proxy.sol/ProxyWithProxyAdminGetter.json +129 -0
  128. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  129. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  130. package/artifacts/contracts/shared/Versionable.sol/Versionable.json +78 -14
  131. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.dbg.json +4 -0
  132. package/artifacts/contracts/test/TestDistribution.sol/TestDistribution.json +405 -0
  133. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  134. package/artifacts/contracts/test/TestFee.sol/TestFee.json +2 -2
  135. package/artifacts/contracts/test/TestPool.sol/TestPool.dbg.json +1 -1
  136. package/artifacts/contracts/test/TestPool.sol/TestPool.json +194 -3
  137. package/artifacts/contracts/test/TestProduct.sol/TestProduct.dbg.json +1 -1
  138. package/artifacts/contracts/test/TestProduct.sol/TestProduct.json +209 -27
  139. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  140. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  141. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  142. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  143. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  144. package/artifacts/contracts/test/TestService.sol/TestService.json +95 -31
  145. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  146. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  147. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  148. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +89 -25
  150. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  151. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  152. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  153. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  154. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  155. package/artifacts/contracts/types/Fee.sol/FeeLib.json +50 -11
  156. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  157. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  158. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  159. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
  160. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  161. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  162. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  164. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.dbg.json +4 -0
  165. package/artifacts/contracts/types/ReferralId.sol/ReferralIdLib.json +99 -0
  166. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
  167. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
  168. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  170. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +1 -1
  173. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Version.sol/VersionLib.json +40 -2
  175. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  177. package/contracts/components/BaseComponent.sol +7 -1
  178. package/contracts/components/Distribution.sol +132 -0
  179. package/contracts/components/IDistributionComponent.sol +47 -0
  180. package/contracts/components/IPoolComponent.sol +14 -0
  181. package/contracts/components/IProductComponent.sol +24 -5
  182. package/contracts/components/Pool.sol +64 -3
  183. package/contracts/components/Product.sol +123 -13
  184. package/contracts/instance/IInstance.sol +7 -4
  185. package/contracts/instance/Instance.sol +11 -4
  186. package/contracts/instance/base/IInstanceBase.sol +3 -0
  187. package/contracts/instance/base/InstanceBase.sol +7 -0
  188. package/contracts/instance/base/Lifecycle.sol +10 -2
  189. package/contracts/instance/base/ModuleBase.sol +22 -17
  190. package/contracts/instance/module/access/Access.sol +3 -3
  191. package/contracts/instance/module/bundle/BundleModule.sol +10 -12
  192. package/contracts/instance/module/bundle/IBundle.sol +6 -11
  193. package/contracts/instance/module/component/ComponentModule.sol +15 -20
  194. package/contracts/instance/module/component/IComponent.sol +3 -2
  195. package/contracts/instance/module/distribution/DistributionModule.sol +17 -0
  196. package/contracts/instance/module/distribution/IDistribution.sol +10 -0
  197. package/contracts/instance/module/policy/IPolicy.sol +10 -8
  198. package/contracts/instance/module/policy/PolicyModule.sol +33 -19
  199. package/contracts/instance/module/pool/IPoolModule.sol +0 -1
  200. package/contracts/instance/module/pool/PoolModule.sol +12 -9
  201. package/contracts/instance/module/risk/IRisk.sol +18 -2
  202. package/contracts/instance/module/risk/RiskModule.sol +56 -2
  203. package/contracts/instance/module/treasury/ITreasury.sol +29 -50
  204. package/contracts/instance/module/treasury/TreasuryModule.sol +71 -85
  205. package/contracts/instance/service/ComponentOwnerService.sol +19 -24
  206. package/contracts/instance/service/DistributionService.sol +59 -0
  207. package/contracts/instance/service/IDistributionService.sol +12 -0
  208. package/contracts/instance/service/IPoolService.sol +7 -0
  209. package/contracts/instance/service/IProductService.sol +56 -7
  210. package/contracts/instance/service/PoolService.sol +30 -4
  211. package/contracts/instance/service/ProductService.sol +229 -74
  212. package/contracts/registry/Registry.sol +190 -113
  213. package/contracts/shared/IVersionable.sol +51 -9
  214. package/contracts/shared/Proxy.sol +94 -0
  215. package/contracts/shared/Versionable.sol +90 -38
  216. package/contracts/test/TestDistribution.sol +21 -0
  217. package/contracts/test/TestPool.sol +5 -2
  218. package/contracts/test/TestProduct.sol +35 -7
  219. package/contracts/types/Fee.sol +8 -3
  220. package/contracts/types/ObjectType.sol +17 -5
  221. package/contracts/types/ReferralId.sol +48 -0
  222. package/contracts/types/RiskId.sol +43 -0
  223. package/contracts/types/RoleId.sol +2 -2
  224. package/contracts/types/Version.sol +8 -0
  225. package/package.json +1 -1
  226. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.dbg.json +0 -4
  227. package/artifacts/contracts/instance/module/compensation/CompensationModule.sol/CompensationModule.json +0 -10
  228. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensation.dbg.json +0 -4
  229. package/artifacts/contracts/instance/module/compensation/ICompensation.sol/ICompensationModule.dbg.json +0 -4
  230. package/contracts/instance/module/compensation/CompensationModule.sol +0 -8
  231. package/contracts/instance/module/compensation/ICompensation.sol +0 -10
@@ -0,0 +1,94 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Ownable} from "@openzeppelin5/contracts/access/Ownable.sol";
5
+ import {ProxyAdmin} from "@openzeppelin5/contracts/proxy/transparent/ProxyAdmin.sol";
6
+ import {TransparentUpgradeableProxy, ITransparentUpgradeableProxy} from "@openzeppelin5/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
7
+
8
+ import {IVersionable} from "./IVersionable.sol";
9
+
10
+ contract ProxyWithProxyAdminGetter is TransparentUpgradeableProxy {
11
+
12
+ constructor(address implementation, address initialProxyAdminOwner, bytes memory data)
13
+ TransparentUpgradeableProxy(implementation, initialProxyAdminOwner, data)
14
+ {}
15
+
16
+ function getProxyAdmin() external returns (ProxyAdmin) { return ProxyAdmin(_proxyAdmin()); }
17
+ }
18
+
19
+ // renamed because of name collision with OZ Proxy -> local proxy type was missing in typechain-types
20
+ contract ProxyDeployer is Ownable {
21
+
22
+ event ProxyDeployed(address indexed proxy);
23
+
24
+ // TODO use contract functions selectors ???
25
+ string public constant INITIALIZE_SIGNATURE = "initialize(address,address,bytes)";
26
+ string public constant UPGRADE_SIGNATURE = "upgrade(address,address,bytes)";
27
+
28
+ ProxyWithProxyAdminGetter private _proxy;
29
+ bool private _isDeployed;
30
+
31
+ /// @dev only used to capture proxy owner
32
+ constructor()
33
+ Ownable(msg.sender)
34
+ {
35
+ }
36
+
37
+ function getDeployData(address implementation, address proxyOwner, bytes memory deployData) public pure returns (bytes memory data) {
38
+ return abi.encodeWithSignature(INITIALIZE_SIGNATURE, implementation, proxyOwner, deployData);
39
+ }
40
+
41
+ function getUpgradeData(address implementation, address proxyOwner, bytes memory upgradeData) public pure returns (bytes memory data) {
42
+ return abi.encodeWithSignature(UPGRADE_SIGNATURE, implementation, proxyOwner, upgradeData);
43
+ }
44
+
45
+ /// @dev deploy initial contract
46
+ function deploy(address initialImplementation, bytes memory deployData)
47
+ external
48
+ onlyOwner()
49
+ returns (IVersionable versionable)
50
+ {
51
+ require(!_isDeployed, "ERROR:PRX-010:ALREADY_DEPLOYED");
52
+
53
+ address currentProxyOwner = owner();
54
+ address initialProxyAdminOwner = address(this);
55
+ bytes memory data = getDeployData(initialImplementation, currentProxyOwner, deployData);
56
+
57
+ _proxy = new ProxyWithProxyAdminGetter(
58
+ initialImplementation,
59
+ initialProxyAdminOwner,
60
+ data
61
+ );
62
+
63
+ _isDeployed = true;
64
+ versionable = IVersionable(address(_proxy));
65
+
66
+ emit ProxyDeployed(address(_proxy));
67
+ }
68
+
69
+ /// @dev upgrade existing contract
70
+ function upgrade(address newImplementation, bytes memory upgradeData)
71
+ external
72
+ onlyOwner
73
+ returns (IVersionable versionable)
74
+ {
75
+ require(_isDeployed, "ERROR:PRX-020:NOT_YET_DEPLOYED");
76
+
77
+ address currentProxyOwner = owner();
78
+ // ProxyAdmin proxyAdmin = _proxy.getProxyAdmin();
79
+ ProxyAdmin proxyAdmin = getProxyAdmin();
80
+ ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(_proxy));
81
+ bytes memory data = getUpgradeData(newImplementation, currentProxyOwner, upgradeData);
82
+
83
+ proxyAdmin.upgradeAndCall(
84
+ proxy,
85
+ newImplementation,
86
+ data);
87
+
88
+ versionable = IVersionable(address(_proxy));
89
+ }
90
+
91
+ function getProxyAdmin() public returns (ProxyAdmin) {
92
+ return _proxy.getProxyAdmin();
93
+ }
94
+ }
@@ -1,59 +1,107 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Initializable} from "@openzeppelin5/contracts/proxy/utils/Initializable.sol";
3
5
 
4
6
  import {Blocknumber, blockNumber} from "../types/Blocknumber.sol";
5
7
  import {Timestamp, blockTimestamp} from "../types/Timestamp.sol";
6
- import {Version, VersionPart} from "../types/Version.sol";
8
+ import {Version, VersionPart, VersionLib} from "../types/Version.sol";
7
9
 
8
10
  import {IVersionable} from "./IVersionable.sol";
9
11
 
10
- abstract contract Versionable is IVersionable {
11
12
 
12
- mapping(Version version => VersionInfo info) private _versionHistory;
13
- Version [] private _versions;
14
13
 
14
+ abstract contract Versionable is
15
+ Initializable,
16
+ IVersionable
17
+ {
18
+ /// @custom:storage-location erc7201:gif-next.contracts.shared.Versionable.sol
19
+ struct VersionableStorage {
20
+ mapping(Version version => VersionInfo info) _versionHistory;
21
+ Version [] _versions;
22
+ Version _v1;
23
+ }
24
+
25
+ // keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Versionable.sol")) - 1)) & ~bytes32(uint256(0xff))
26
+ bytes32 private constant VersionableStorageLocation = 0x4f61291a8ac3d020d0a7d919a76b8592aa88385744dee3f8b4f3873b969ed900;
27
+
28
+ function _getVersionableStorage() private pure returns (VersionableStorage storage $) {
29
+ assembly {
30
+ $.slot := VersionableStorageLocation
31
+ }
32
+ }
15
33
 
16
- // controlled activation for controller contract
17
34
  constructor() {
18
- _activate(address(0), msg.sender);
35
+ _disableInitializers();
19
36
  }
20
37
 
21
- // IMPORTANT this function needs to be implemented by each new version
22
- // and needs to call internal function call _activate()
23
- function activate(address implementation, address activatedBy)
38
+ function initialize(
39
+ address implementation,
40
+ address activatedBy, // TODO can it be a msg.sender ?
41
+ bytes memory data
42
+ )
43
+ public
44
+ initializer
45
+ {
46
+ _updateVersionHistory(implementation, activatedBy);
47
+ _initialize(data);
48
+ }
49
+ function upgrade(
50
+ address implementation,
51
+ address activatedBy,
52
+ bytes memory data
53
+ )
24
54
  external
25
- override
26
- {
27
- _activate(implementation, activatedBy);
55
+ reinitializer(VersionLib.toUint64(getVersion()))
56
+ {
57
+ _updateVersionHistory(implementation, activatedBy);
58
+ _upgrade(data);
28
59
  }
60
+ // IMPORTANT each version must implement this function
61
+ // each implementation MUST use onlyInitialising modifier
62
+ function _initialize(bytes memory data)
63
+ internal
64
+ onlyInitializing
65
+ virtual
66
+ {}
29
67
 
68
+ // IMPORTANT each version except version "1" must implement this function
69
+ // each implementation MUST use onlyInitialising modifier
70
+ function _upgrade(bytes memory data)
71
+ internal
72
+ onlyInitializing
73
+ virtual
74
+ {
75
+ revert();
76
+ }
30
77
 
31
78
  // can only be called once per contract
32
- // needs bo be called inside the proxy upgrade tx
33
- function _activate(
79
+ // needs to be called inside the proxy upgrade tx
80
+ // TODO run reinitializer(version().toUint64()) modifier after "version()" is checked,
81
+ function _updateVersionHistory(
34
82
  address implementation,
35
83
  address activatedBy
36
84
  )
37
- internal
85
+ private
86
+ onlyInitializing
38
87
  {
88
+ VersionableStorage storage $ = _getVersionableStorage();
89
+
90
+ uint64 version = _getInitializedVersion();
91
+
39
92
  Version thisVersion = getVersion();
40
- require(
41
- !isActivated(thisVersion),
42
- "ERROR:VRN-001:VERSION_ALREADY_ACTIVATED"
43
- );
44
-
45
- // require increasing version number
46
- if(_versions.length > 0) {
47
- Version lastVersion = _versions[_versions.length - 1];
48
- require(
49
- thisVersion > lastVersion,
50
- "ERROR:VRN-002:VERSION_NOT_INCREASING"
51
- );
93
+
94
+ if(version == 1) {
95
+ // thisVersion is alias to version "1"
96
+ $._v1 = thisVersion;
97
+ }
98
+ else {
99
+ require(thisVersion > $._v1, "INVALID VERSION");
52
100
  }
53
101
 
54
102
  // update version history
55
- _versions.push(thisVersion);
56
- _versionHistory[thisVersion] = VersionInfo(
103
+ $._versions.push(thisVersion);
104
+ $._versionHistory[thisVersion] = VersionInfo(
57
105
  thisVersion,
58
106
  implementation,
59
107
  activatedBy,
@@ -61,12 +109,12 @@ abstract contract Versionable is IVersionable {
61
109
  blockNumber()
62
110
  );
63
111
 
64
- emit LogVersionableActivated(thisVersion, implementation, activatedBy);
112
+ emit LogVersionableInitialized(thisVersion, implementation, activatedBy);
65
113
  }
66
114
 
67
-
68
- function isActivated(Version _version) public override view returns(bool) {
69
- return _versionHistory[_version].activatedIn.toInt() > 0;
115
+ // TODO previous version(s) can not be active -> check that _version is the latest one
116
+ function isInitialized(Version _version) public override view returns(bool) {
117
+ return _getVersionableStorage()._versionHistory[_version].activatedIn.toInt() > 0;
70
118
  }
71
119
 
72
120
 
@@ -74,16 +122,20 @@ abstract contract Versionable is IVersionable {
74
122
 
75
123
 
76
124
  function getVersionCount() external view override returns(uint256) {
77
- return _versions.length;
125
+ return _getVersionableStorage()._versions.length;
78
126
  }
79
127
 
80
-
81
128
  function getVersion(uint256 idx) external view override returns(Version) {
82
- return _versions[idx];
129
+ return _getVersionableStorage()._versions[idx];
83
130
  }
84
131
 
85
132
 
86
133
  function getVersionInfo(Version _version) external override view returns(VersionInfo memory) {
87
- return _versionHistory[_version];
134
+ return _getVersionableStorage()._versionHistory[_version];
135
+ }
136
+
137
+ function getInitializedVersion() external view returns(uint64)
138
+ {
139
+ return _getInitializedVersion();
88
140
  }
89
141
  }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Fee} from "../../contracts/types/Fee.sol";
5
+ import {NftId} from "../../contracts/types/NftId.sol";
6
+ import {Distribution} from "../../contracts/components/Distribution.sol";
7
+
8
+
9
+ contract TestDistribution is Distribution {
10
+
11
+ constructor(
12
+ address registry,
13
+ NftId instanceNftid,
14
+ address token,
15
+ bool isVerifying,
16
+ Fee memory distributionFee
17
+ )
18
+ Distribution(registry, instanceNftid, token, isVerifying, distributionFee)
19
+ // solhint-disable-next-line no-empty-blocks
20
+ {}
21
+ }
@@ -14,9 +14,12 @@ contract TestPool is Pool {
14
14
  NftId instanceNftid,
15
15
  address token,
16
16
  bool isVerifying,
17
- UFixed collateralizationLevel
17
+ UFixed collateralizationLevel,
18
+ Fee memory poolFee,
19
+ Fee memory stakingFee,
20
+ Fee memory performanceFee
18
21
  )
19
- Pool(registry, instanceNftid, token, isVerifying, collateralizationLevel)
22
+ Pool(registry, instanceNftid, token, isVerifying, collateralizationLevel, poolFee, stakingFee, performanceFee)
20
23
  // solhint-disable-next-line no-empty-blocks
21
24
  {}
22
25
  }
@@ -3,6 +3,8 @@ pragma solidity ^0.8.19;
3
3
 
4
4
  import {Product} from "../../contracts/components/Product.sol";
5
5
  import {NftId, toNftId} from "../../contracts/types/NftId.sol";
6
+ import {ReferralId} from "../types/ReferralId.sol";
7
+ import {RiskId} from "../../contracts/types/RiskId.sol";
6
8
  import {Timestamp, blockTimestamp} from "../../contracts/types/Timestamp.sol";
7
9
  import {Fee} from "../../contracts/types/Fee.sol";
8
10
 
@@ -10,26 +12,52 @@ contract TestProduct is Product {
10
12
 
11
13
  event LogTestProductSender(address sender);
12
14
 
13
- constructor(address registry, NftId instanceNftid, address token, address pool)
14
- Product(registry, instanceNftid, token, pool)
15
+ string public constant DEFAULT_RISK_NAME = "DEFAULT_RISK";
16
+ bool private defaultRiskCreated;
17
+
18
+ constructor(
19
+ address registry,
20
+ NftId instanceNftid,
21
+ address token,
22
+ address pool,
23
+ address distribution,
24
+ Fee memory productFee,
25
+ Fee memory processingFee
26
+ )
27
+ Product(registry, instanceNftid, token, pool, distribution, productFee, processingFee)
15
28
  // solhint-disable-next-line no-empty-blocks
16
- {}
29
+ {
30
+ }
31
+
32
+ function getDefaultRiskId() public pure returns (RiskId) {
33
+ return _toRiskId(DEFAULT_RISK_NAME);
34
+ }
17
35
 
18
36
  function applyForPolicy(
19
37
  uint256 sumInsuredAmount,
20
- uint256 premiumAmount,
21
38
  uint256 lifetime,
22
- NftId bundleNftId
39
+ NftId bundleNftId,
40
+ ReferralId referralId
23
41
  )
24
42
  external
25
43
  returns(NftId nftId)
26
44
  {
45
+ RiskId riskId = getDefaultRiskId();
46
+ bytes memory applicationData = "";
47
+
48
+ if (!defaultRiskCreated) {
49
+ _createRisk(riskId, "");
50
+ defaultRiskCreated = true;
51
+ }
52
+
27
53
  nftId = _createApplication(
28
54
  msg.sender, // policy holder
55
+ riskId,
29
56
  sumInsuredAmount,
30
- premiumAmount,
31
57
  lifetime,
32
- bundleNftId
58
+ applicationData,
59
+ bundleNftId,
60
+ referralId
33
61
  );
34
62
  }
35
63
 
@@ -11,8 +11,8 @@ struct Fee {
11
11
  library FeeLib {
12
12
 
13
13
  function calculateFee(
14
- uint256 amount,
15
- Fee memory fee
14
+ Fee memory fee,
15
+ uint256 amount
16
16
  )
17
17
  public
18
18
  pure
@@ -35,7 +35,12 @@ library FeeLib {
35
35
  return Fee(fractionalFee, fixedFee);
36
36
  }
37
37
 
38
- /// @dev Return the zero fee struct (0, 0)
38
+ /// @dev Return the percent fee struct (x%, 0)
39
+ function percentageFee(uint8 percent) public pure returns (Fee memory fee) {
40
+ return Fee(UFixedMathLib.toUFixed(percent, -2), 0);
41
+ }
42
+
43
+ /// @dev Return a zero fee struct (0, 0)
39
44
  function zeroFee() public pure returns (Fee memory fee) {
40
45
  return Fee(UFixed.wrap(0), 0);
41
46
  }
@@ -41,11 +41,15 @@ function COMPONENT() pure returns (ObjectType) {
41
41
  return toObjectType(100);
42
42
  }
43
43
 
44
+ function TREASURY() pure returns (ObjectType) {
45
+ return toObjectType(101);
46
+ }
47
+
44
48
  function PRODUCT() pure returns (ObjectType) {
45
49
  return toObjectType(110);
46
50
  }
47
51
 
48
- function COMPENSATION() pure returns (ObjectType) {
52
+ function DISTRIBUTION() pure returns (ObjectType) {
49
53
  return toObjectType(120);
50
54
  }
51
55
 
@@ -57,20 +61,28 @@ function POOL() pure returns (ObjectType) {
57
61
  return toObjectType(140);
58
62
  }
59
63
 
60
- function POLICY() pure returns (ObjectType) {
64
+ function RISK() pure returns (ObjectType) {
61
65
  return toObjectType(200);
62
66
  }
63
67
 
64
- function BUNDLE() pure returns (ObjectType) {
68
+ function POLICY() pure returns (ObjectType) {
65
69
  return toObjectType(210);
66
70
  }
67
71
 
72
+ function REFERRAL() pure returns (ObjectType) {
73
+ return toObjectType(212);
74
+ }
75
+
68
76
  function CLAIM() pure returns (ObjectType) {
69
- return toObjectType(201);
77
+ return toObjectType(214);
70
78
  }
71
79
 
72
80
  function PAYOUT() pure returns (ObjectType) {
73
- return toObjectType(202);
81
+ return toObjectType(216);
82
+ }
83
+
84
+ function BUNDLE() pure returns (ObjectType) {
85
+ return toObjectType(220);
74
86
  }
75
87
 
76
88
  /// @dev Converts the uint8 to a ObjectType.
@@ -0,0 +1,48 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
5
+ import {REFERRAL} from "./ObjectType.sol";
6
+
7
+ type ReferralId is bytes8;
8
+
9
+ // type bindings
10
+ using {
11
+ eqReferralId as ==,
12
+ neReferralId as !=,
13
+ ReferralIdLib.toKey32
14
+ } for ReferralId global;
15
+
16
+ // general pure free functions
17
+
18
+ // @dev Returns true iff risk ids a and b are identical
19
+ function eqReferralId(ReferralId a, ReferralId b) pure returns (bool isSame) {
20
+ return ReferralId.unwrap(a) == ReferralId.unwrap(b);
21
+ }
22
+
23
+ // @dev Returns true iff risk ids a and b are different
24
+ function neReferralId(ReferralId a, ReferralId b) pure returns (bool isDifferent) {
25
+ return ReferralId.unwrap(a) != ReferralId.unwrap(b);
26
+ }
27
+
28
+ library ReferralIdLib {
29
+
30
+ function zeroReferralId() public pure returns (ReferralId) {
31
+ return ReferralId.wrap(bytes8(0));
32
+ }
33
+
34
+ // @dev Converts a role string into a role id.
35
+ function toReferralId(string memory referral) public pure returns (ReferralId) {
36
+ return ReferralId.wrap(bytes8(keccak256(abi.encode(referral))));
37
+ }
38
+
39
+ /// @dev Returns the key32 value for the specified id
40
+ function toKey32(ReferralId id) public pure returns (Key32 key) {
41
+ return Key32Lib.toKey32(REFERRAL(), toKeyId(id));
42
+ }
43
+
44
+ /// @dev Returns the key id value for the specified id
45
+ function toKeyId(ReferralId id) public pure returns (KeyId keyId) {
46
+ return KeyId.wrap(bytes31(ReferralId.unwrap(id)));
47
+ }
48
+ }
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.19;
3
+
4
+ import {Key32, KeyId, Key32Lib} from "./Key32.sol";
5
+ import {RISK} from "./ObjectType.sol";
6
+
7
+ type RiskId is bytes8;
8
+
9
+ // type bindings
10
+ using {
11
+ eqRiskId as ==,
12
+ neRiskId as !=,
13
+ RiskIdLib.toKey32
14
+ } for RiskId global;
15
+
16
+ // general pure free functions
17
+
18
+ // @dev Returns true iff risk ids a and b are identical
19
+ function eqRiskId(RiskId a, RiskId b) pure returns (bool isSame) {
20
+ return RiskId.unwrap(a) == RiskId.unwrap(b);
21
+ }
22
+
23
+ // @dev Returns true iff risk ids a and b are different
24
+ function neRiskId(RiskId a, RiskId b) pure returns (bool isDifferent) {
25
+ return RiskId.unwrap(a) != RiskId.unwrap(b);
26
+ }
27
+
28
+ library RiskIdLib {
29
+ // @dev Converts a role string into a role id.
30
+ function toRiskId(string memory risk) public pure returns (RiskId) {
31
+ return RiskId.wrap(bytes8(keccak256(abi.encode(risk))));
32
+ }
33
+
34
+ /// @dev Returns the key32 value for the specified nft id and object type.
35
+ function toKey32(RiskId id) public pure returns (Key32 key) {
36
+ return Key32Lib.toKey32(RISK(), toKeyId(id));
37
+ }
38
+
39
+ /// @dev Returns the key id value for the specified nft id
40
+ function toKeyId(RiskId id) public pure returns (KeyId keyId) {
41
+ return KeyId.wrap(bytes31(RiskId.unwrap(id)));
42
+ }
43
+ }
@@ -10,12 +10,12 @@ using {
10
10
  } for RoleId global;
11
11
 
12
12
  // general pure free functions
13
- function DISTRIBUTOR_OWNER_ROLE_NAME() pure returns (string memory) { return "DistributorOwnerRole"; }
13
+ function DISTRIBUTION_OWNER_ROLE_NAME() pure returns (string memory) { return "DistributionOwnerRole"; }
14
14
  function ORACLE_OWNER_ROLE_NAME() pure returns (string memory) { return "OracleOwnerRole"; }
15
15
  function POOL_OWNER_ROLE_NAME() pure returns (string memory) { return "PoolOwnerRole"; }
16
16
  function PRODUCT_OWNER_ROLE_NAME() pure returns (string memory) { return "ProductOwnerRole"; }
17
17
 
18
- function DISTRIBUTOR_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("DistributorOwnerRole"); }
18
+ function DISTRIBUTION_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("DistributionOwnerRole"); }
19
19
  function ORACLE_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("OracleOwnerRole"); }
20
20
  function POOL_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("PoolOwnerRole"); }
21
21
  function PRODUCT_OWNER_ROLE() pure returns (RoleId) { return RoleIdLib.toRoleId("ProductOwnerRole"); }
@@ -23,6 +23,7 @@ using {
23
23
  versionGt as >,
24
24
  versionEq as ==,
25
25
  VersionLib.toInt,
26
+ VersionLib.toUint64,
26
27
  VersionLib.toMajorPart,
27
28
  VersionLib.toVersionParts
28
29
  }
@@ -34,6 +35,8 @@ function versionEq(Version a, Version b) pure returns(bool isSame) { return Vers
34
35
  library VersionLib {
35
36
  function toInt(Version version) external pure returns(uint) { return Version.unwrap(version); }
36
37
 
38
+ function toUint64(Version version) external pure returns(uint64) { return Version.unwrap(version); }
39
+
37
40
  function toMajorPart(Version version)
38
41
  external
39
42
  pure
@@ -89,6 +92,11 @@ library VersionLib {
89
92
  (major << 16) + (minor << 8) + patch));
90
93
  }
91
94
 
95
+ // TODO check for overflow?
96
+ function toVersion(uint64 versionNumber) external pure returns(Version) {
97
+ return Version.wrap(uint24(versionNumber));
98
+ }
99
+
92
100
  function zeroVersion() external pure returns(Version) {
93
101
  return Version.wrap(0);
94
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etherisc/gif-next",
3
- "version": "0.0.2-78bf628-134",
3
+ "version": "0.0.2-790d44b-698",
4
4
  "description": "This is the repository for the next version of the Generic Insurance Framework (GIF) smart contracts. ",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/8e55ece999861400da8a6ef1228e2169.json"
4
- }
@@ -1,10 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "CompensationModule",
4
- "sourceName": "contracts/instance/module/compensation/CompensationModule.sol",
5
- "abi": [],
6
- "bytecode": "0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220e083bd536daa38f4ab2da87a47489460180ca9e737890e3707e2279d6bddbb1d64736f6c63430008140033",
7
- "deployedBytecode": "0x6080604052600080fdfea2646970667358221220e083bd536daa38f4ab2da87a47489460180ca9e737890e3707e2279d6bddbb1d64736f6c63430008140033",
8
- "linkReferences": {},
9
- "deployedLinkReferences": {}
10
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/8e55ece999861400da8a6ef1228e2169.json"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/8e55ece999861400da8a6ef1228e2169.json"
4
- }
@@ -1,8 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
3
-
4
- import {ICompensationModule} from "./ICompensation.sol";
5
-
6
- contract CompensationModule is ICompensationModule {
7
-
8
- }
@@ -1,10 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.19;
3
-
4
- interface ICompensation {
5
-
6
- }
7
-
8
- interface ICompensationModule is ICompensation {
9
-
10
- }