@etherisc/gif-next 0.0.2-9c44ae6-473 → 0.0.2-9f827bd-593

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 (235) hide show
  1. package/README.md +20 -1
  2. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +1 -1
  3. package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +155 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +143 -86
  6. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +117 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +26 -0
  11. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  12. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  13. package/artifacts/contracts/components/Pool.sol/Pool.json +168 -113
  14. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  15. package/artifacts/contracts/components/Product.sol/Product.json +141 -95
  16. package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +1 -1
  17. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +1 -1
  18. package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +1 -1
  19. package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +1 -1
  20. package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +1 -1
  21. package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +1 -1
  22. package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +1 -1
  23. package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +1 -1
  24. package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +1 -1
  25. package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +1 -1
  26. package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +1 -1
  27. package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +1 -1
  28. package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +1 -1
  29. package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +1 -1
  30. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +1 -1
  31. package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +1 -1
  32. package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +1 -1
  33. package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +1 -1
  34. package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +1 -1
  35. package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +1 -1
  36. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  37. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  38. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  39. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +45 -56
  40. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  42. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +39 -0
  43. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
  44. package/artifacts/contracts/instance/IInstanceBase.sol/IInstanceBase.json +448 -0
  45. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  46. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +99 -14
  47. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  48. package/artifacts/contracts/instance/Instance.sol/Instance.json +92 -665
  49. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  50. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +244 -114
  51. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.dbg.json +4 -0
  52. package/artifacts/contracts/instance/InstanceBase.sol/InstanceBase.json +763 -0
  53. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  54. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +2 -2
  55. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  56. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +166 -173
  57. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  58. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +26 -78
  59. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  60. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +15 -2
  61. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +1 -1
  62. package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +24 -32
  63. package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +1 -1
  64. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  65. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  66. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  67. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +59 -16
  70. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  71. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  72. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  73. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  74. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  75. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  76. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
  77. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +968 -0
  78. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
  79. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +432 -0
  80. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +39 -52
  82. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +49 -72
  84. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +13 -37
  86. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
  87. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +692 -0
  88. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +13 -13
  90. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +13 -13
  92. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
  93. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +771 -0
  94. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +15 -218
  96. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +17 -241
  98. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
  99. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1156 -0
  100. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
  101. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +492 -0
  102. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  103. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +38 -315
  104. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  105. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +13 -53
  106. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  107. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +40 -410
  108. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  109. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +13 -81
  110. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  111. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  112. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  113. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +132 -133
  114. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  115. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +94 -65
  116. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.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 +145 -227
  119. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
  120. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
  121. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  122. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +30 -128
  123. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  124. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +38 -104
  125. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
  126. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +546 -0
  127. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  128. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +14 -27
  129. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  130. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  131. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  133. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  134. package/artifacts/contracts/shared/IService.sol/IService.json +13 -13
  135. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  136. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  137. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  138. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  139. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  140. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  141. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  142. package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +1 -1
  143. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  144. package/artifacts/contracts/shared/Service.sol/Service.json +13 -13
  145. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  146. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  147. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  148. package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
  149. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  150. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  151. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  152. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +2 -2
  153. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  154. package/artifacts/contracts/test/TestService.sol/TestService.json +31 -31
  155. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  156. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  158. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  159. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  160. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  161. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  162. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  163. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  164. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  165. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  167. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  171. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  173. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  175. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  177. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  178. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  179. package/contracts/components/BaseComponent.sol +79 -11
  180. package/contracts/components/Distribution.sol +1 -1
  181. package/contracts/components/IBaseComponent.sol +9 -0
  182. package/contracts/components/IPoolComponent.sol +4 -0
  183. package/contracts/components/Pool.sol +28 -4
  184. package/contracts/components/Product.sol +9 -6
  185. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +23 -0
  186. package/contracts/instance/BundleManager.sol +1 -26
  187. package/contracts/instance/IInstance.sol +6 -0
  188. package/contracts/instance/IInstanceBase.sol +26 -0
  189. package/contracts/instance/IInstanceService.sol +10 -2
  190. package/contracts/instance/Instance.sol +36 -214
  191. package/contracts/instance/InstanceAccessManager.sol +93 -78
  192. package/contracts/instance/InstanceBase.sol +41 -0
  193. package/contracts/instance/InstanceService.sol +227 -109
  194. package/contracts/instance/InstanceServiceManager.sol +5 -8
  195. package/contracts/instance/ObjectManager.sol +7 -1
  196. package/contracts/instance/base/ComponentServiceBase.sol +32 -84
  197. package/contracts/instance/module/IAccess.sol +27 -17
  198. package/contracts/instance/service/BundleService.sol +275 -0
  199. package/contracts/instance/service/BundleServiceManager.sol +51 -0
  200. package/contracts/instance/service/ComponentOwnerService.sol +4 -6
  201. package/contracts/instance/service/DistributionService.sol +45 -20
  202. package/contracts/instance/service/DistributionServiceManager.sol +6 -9
  203. package/contracts/instance/service/IBundleService.sol +42 -0
  204. package/contracts/instance/service/IPolicyService.sol +94 -0
  205. package/contracts/instance/service/IPoolService.sol +2 -33
  206. package/contracts/instance/service/IProductService.sol +2 -72
  207. package/contracts/instance/service/PolicyService.sol +537 -0
  208. package/contracts/instance/service/PolicyServiceManager.sol +54 -0
  209. package/contracts/instance/service/PoolService.sol +45 -149
  210. package/contracts/instance/service/PoolServiceManager.sol +5 -8
  211. package/contracts/instance/service/ProductService.sol +56 -456
  212. package/contracts/registry/ChainNft.sol +1 -1
  213. package/contracts/registry/IRegistry.sol +26 -16
  214. package/contracts/registry/IRegistryService.sol +13 -5
  215. package/contracts/registry/Registry.sol +149 -201
  216. package/contracts/registry/RegistryAccessManager.sol +210 -0
  217. package/contracts/registry/RegistryService.sol +48 -83
  218. package/contracts/registry/RegistryServiceManager.sol +18 -36
  219. package/contracts/registry/ReleaseManager.sol +348 -0
  220. package/contracts/registry/TokenRegistry.sol +5 -6
  221. package/contracts/shared/IService.sol +2 -1
  222. package/contracts/shared/ProxyManager.sol +1 -1
  223. package/contracts/shared/Service.sol +10 -7
  224. package/contracts/test/TestService.sol +3 -2
  225. package/contracts/types/RoleId.sol +10 -10
  226. package/package.json +1 -1
  227. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
  228. package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +0 -101
  229. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
  230. package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1132
  231. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
  232. package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
  233. package/contracts/instance/AccessManagedSimple.sol +0 -115
  234. package/contracts/instance/AccessManagerSimple.sol +0 -692
  235. package/contracts/instance/IAccessManagerSimple.sol +0 -391
@@ -1,18 +1,21 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
4
5
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
6
 
6
- import {Registerable} from "../shared/Registerable.sol";
7
-
8
- import {IRegistry} from "../registry/IRegistry.sol";
9
- import {IInstance} from "../instance/IInstance.sol";
10
-
11
- import {IInstance} from "../instance/IInstance.sol";
12
- import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
13
7
  import {IBaseComponent} from "./IBaseComponent.sol";
8
+ import {IComponentOwnerService} from "../instance/service/IComponentOwnerService.sol";
9
+ import {IInstanceService} from "../instance/IInstanceService.sol";
10
+ import {IInstance} from "../instance/IInstance.sol";
11
+ import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
12
+ import {IRegistry} from "../registry/IRegistry.sol";
14
13
  import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
15
- import {ObjectType} from "../types/ObjectType.sol";
14
+ import {ObjectType, INSTANCE} from "../types/ObjectType.sol";
15
+ import {VersionLib} from "../types/Version.sol";
16
+ import {Registerable} from "../shared/Registerable.sol";
17
+ import {RoleId, RoleIdLib} from "../types/RoleId.sol";
18
+ import {IAccess} from "../instance/module/IAccess.sol";
16
19
 
17
20
  abstract contract BaseComponent is
18
21
  Registerable,
@@ -21,13 +24,30 @@ abstract contract BaseComponent is
21
24
  using NftIdLib for NftId;
22
25
 
23
26
  IComponentOwnerService internal _componentOwnerService;
27
+ IInstanceService internal _instanceService;
24
28
 
25
29
  address internal _deployer;
26
30
  address internal _wallet;
27
31
  IERC20Metadata internal _token;
28
32
  IInstance internal _instance;
33
+ InstanceAccessManager internal _instanceAccessManager;
29
34
  NftId internal _productNftId;
30
35
 
36
+ modifier onlyInstanceRole(uint64 roleIdNum) {
37
+ RoleId roleId = RoleIdLib.toRoleId(roleIdNum);
38
+ if( !_instanceAccessManager.hasRole(roleId, msg.sender)) {
39
+ revert ErrorBaseComponentUnauthorized(msg.sender, roleIdNum);
40
+ }
41
+ _;
42
+ }
43
+
44
+ modifier isNotLocked() {
45
+ if (_instanceAccessManager.isTargetLocked(address(this))) {
46
+ revert IAccess.ErrorIAccessTargetLocked(address(this));
47
+ }
48
+ _;
49
+ }
50
+
31
51
  constructor(
32
52
  address registry,
33
53
  NftId instanceNftId,
@@ -42,25 +62,31 @@ abstract contract BaseComponent is
42
62
 
43
63
  IRegistry.ObjectInfo memory instanceInfo = getRegistry().getObjectInfo(instanceNftId);
44
64
  _instance = IInstance(instanceInfo.objectAddress);
65
+ _instanceAccessManager = _instance.getInstanceAccessManager();
45
66
  require(
46
67
  _instance.supportsInterface(type(IInstance).interfaceId),
47
68
  ""
48
69
  );
49
70
 
50
71
  _componentOwnerService = _instance.getComponentOwnerService();
72
+ _instanceService = IInstanceService(getRegistry().getServiceAddress(INSTANCE(), VersionLib.toVersion(3, 0, 0).toMajorPart()));
51
73
  _wallet = address(this);
52
74
  _token = IERC20Metadata(token);
53
75
 
54
76
  _registerInterface(type(IBaseComponent).interfaceId);
55
77
  }
56
78
 
79
+ function getName() public pure virtual returns (string memory name);
80
+
57
81
  // from component contract
82
+ // TODO only owner and instance owner
58
83
  function lock() external onlyOwner override {
59
- _componentOwnerService.lock(this);
84
+ _instanceService.setTargetLocked(getName(), true);
60
85
  }
61
-
86
+
87
+ // TODO only owner and instance owner
62
88
  function unlock() external onlyOwner override {
63
- _componentOwnerService.unlock(this);
89
+ _instanceService.setTargetLocked(getName(), false);
64
90
  }
65
91
 
66
92
  function getWallet()
@@ -72,6 +98,48 @@ abstract contract BaseComponent is
72
98
  return _wallet;
73
99
  }
74
100
 
101
+ /// @dev Sets the wallet address for the component.
102
+ /// if the current wallet has tokens, these will be transferred.
103
+ /// if the new wallet address is externally owned, an approval from the
104
+ /// owner of the external wallet for the component to move all tokens must exist.
105
+ function setWallet(address newWallet) external override onlyOwner {
106
+ address currentWallet = _wallet;
107
+ uint256 currentBalance = _token.balanceOf(currentWallet);
108
+
109
+ // checks
110
+ if (newWallet == currentWallet) {
111
+ revert ErrorBaseComponentWalletAddressIsSameAsCurrent(newWallet);
112
+ }
113
+
114
+ if (currentBalance > 0) {
115
+ if (currentWallet == address(this)) {
116
+ // move tokens from component smart contract to external wallet
117
+ } else {
118
+ // move tokens from external wallet to component smart contract or another external wallet
119
+ uint256 allowance = _token.allowance(currentWallet, address(this));
120
+ if (allowance < currentBalance) {
121
+ revert ErrorBaseComponentWalletAllowanceTooSmall(currentWallet, newWallet, allowance, currentBalance);
122
+ }
123
+ }
124
+ }
125
+
126
+ // effects
127
+ _wallet = newWallet;
128
+ emit LogBaseComponentWalletAddressChanged(newWallet);
129
+
130
+ // interactions
131
+ if (currentBalance > 0) {
132
+ // transfer tokens from current wallet to new wallet
133
+ if (currentWallet == address(this)) {
134
+ // transferFrom requires self allowance too
135
+ _token.approve(address(this), currentBalance);
136
+ }
137
+
138
+ SafeERC20.safeTransferFrom(_token, currentWallet, newWallet, currentBalance);
139
+ emit LogBaseComponentWalletTokensTransferred(currentWallet, newWallet, currentBalance);
140
+ }
141
+ }
142
+
75
143
  function getToken() public view override returns (IERC20Metadata token) {
76
144
  return _token;
77
145
  }
@@ -16,7 +16,7 @@ import {Registerable} from "../shared/Registerable.sol";
16
16
  import {TokenHandler} from "../shared/TokenHandler.sol";
17
17
  import {InstanceReader} from "../instance/InstanceReader.sol";
18
18
 
19
- contract Distribution is
19
+ abstract contract Distribution is
20
20
  BaseComponent,
21
21
  IDistributionComponent
22
22
  {
@@ -8,6 +8,14 @@ import {IInstance} from "../instance/IInstance.sol";
8
8
  import {NftId} from "../types/NftId.sol";
9
9
 
10
10
  interface IBaseComponent is IRegisterable {
11
+ error ErrorBaseComponentWalletAddressIsSameAsCurrent(address newWallet);
12
+ error ErrorBaseComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
13
+ error ErrorBaseComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
14
+
15
+ event LogBaseComponentWalletAddressChanged(address newWallet);
16
+ event LogBaseComponentWalletTokensTransferred(address from, address to, uint256 amount);
17
+
18
+ function getName() external pure virtual returns (string memory name);
11
19
 
12
20
  function lock() external;
13
21
 
@@ -15,6 +23,7 @@ interface IBaseComponent is IRegisterable {
15
23
 
16
24
  function getToken() external view returns (IERC20Metadata token);
17
25
 
26
+ function setWallet(address walletAddress) external;
18
27
  function getWallet() external view returns (address walletAddress);
19
28
 
20
29
  function getInstance() external view returns (IInstance instance);
@@ -43,6 +43,10 @@ interface IPoolComponent {
43
43
  uint256 collateralizationAmount
44
44
  ) external;
45
45
 
46
+ function lockBundle(NftId bundleNftId) external;
47
+
48
+ function unlockBundle(NftId bundleNftId) external;
49
+
46
50
  /**
47
51
  * @dev returns true iff the policy application data in policyData matches
48
52
  * with the bundle filter criteria encoded in bundleFilter.
@@ -4,6 +4,7 @@ pragma solidity ^0.8.20;
4
4
  import {ObjectType, POOL} from "../types/ObjectType.sol";
5
5
  import {IProductService} from "../instance/service/IProductService.sol";
6
6
  import {IPoolService} from "../instance/service/IPoolService.sol";
7
+ import {IBundleService} from "../instance/service/IBundleService.sol";
7
8
  import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
8
9
  import {Fee} from "../types/Fee.sol";
9
10
  import {UFixed} from "../types/UFixed.sol";
@@ -22,7 +23,7 @@ import {InstanceReader} from "../instance/InstanceReader.sol";
22
23
  import {IRegisterable} from "../shared/IRegisterable.sol";
23
24
  import {Registerable} from "../shared/Registerable.sol";
24
25
 
25
- contract Pool is BaseComponent, IPoolComponent {
26
+ abstract contract Pool is BaseComponent, IPoolComponent {
26
27
  using NftIdLib for NftId;
27
28
 
28
29
  bool internal _isConfirmingApplication;
@@ -40,6 +41,8 @@ contract Pool is BaseComponent, IPoolComponent {
40
41
  // only relevant to protect callback functions for "active" pools
41
42
  IProductService private _productService;
42
43
 
44
+ IBundleService private _bundleService;
45
+
43
46
  modifier onlyPoolService() {
44
47
  require(
45
48
  msg.sender == address(_poolService),
@@ -80,6 +83,7 @@ contract Pool is BaseComponent, IPoolComponent {
80
83
 
81
84
  _poolService = _instance.getPoolService();
82
85
  _productService = _instance.getProductService();
86
+ _bundleService = _instance.getBundleService();
83
87
 
84
88
  _registerInterface(type(IPoolComponent).interfaceId);
85
89
  }
@@ -95,7 +99,7 @@ contract Pool is BaseComponent, IPoolComponent {
95
99
  returns(NftId bundleNftId)
96
100
  {
97
101
  address owner = msg.sender;
98
- bundleNftId = _poolService.createBundle(
102
+ bundleNftId = _bundleService.createBundle(
99
103
  owner,
100
104
  fee,
101
105
  initialAmount,
@@ -168,7 +172,27 @@ contract Pool is BaseComponent, IPoolComponent {
168
172
  override
169
173
  // TODO add onlyBundleOwner
170
174
  {
171
- _poolService.setBundleFee(bundleNftId, fee);
175
+ _bundleService.setBundleFee(bundleNftId, fee);
176
+ }
177
+
178
+ function lockBundle(
179
+ NftId bundleNftId
180
+ )
181
+ external
182
+ override
183
+ // TODO add onlyBundleOwner
184
+ {
185
+ _bundleService.lockBundle(bundleNftId);
186
+ }
187
+
188
+ function unlockBundle(
189
+ NftId bundleNftId
190
+ )
191
+ external
192
+ override
193
+ // TODO add onlyBundleOwner
194
+ {
195
+ _bundleService.unlockBundle(bundleNftId);
172
196
  }
173
197
 
174
198
  function getSetupInfo() public view returns (ISetup.PoolSetupInfo memory setupInfo) {
@@ -236,7 +260,7 @@ contract Pool is BaseComponent, IPoolComponent {
236
260
  internal
237
261
  returns(NftId bundleNftId)
238
262
  {
239
- bundleNftId = _poolService.createBundle(
263
+ bundleNftId = _bundleService.createBundle(
240
264
  bundleOwner,
241
265
  fee,
242
266
  amount,
@@ -6,6 +6,7 @@ import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IER
6
6
  import {IRisk} from "../instance/module/IRisk.sol";
7
7
  import {ITreasury} from "../instance/module/ITreasury.sol";
8
8
  import {IProductService} from "../instance/service/IProductService.sol";
9
+ import {IPolicyService} from "../instance/service/IPolicyService.sol";
9
10
  import {IProductComponent} from "./IProductComponent.sol";
10
11
  import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
11
12
  import {ObjectType, PRODUCT} from "../types/ObjectType.sol";
@@ -28,10 +29,11 @@ import {Distribution} from "../components/Distribution.sol";
28
29
 
29
30
  import {zeroNftId} from "../types/NftId.sol";
30
31
 
31
- contract Product is BaseComponent, IProductComponent {
32
+ abstract contract Product is BaseComponent, IProductComponent {
32
33
  using NftIdLib for NftId;
33
34
 
34
35
  IProductService internal _productService;
36
+ IPolicyService internal _policyService;
35
37
  Pool internal _pool;
36
38
  Distribution internal _distribution;
37
39
  Fee internal _initialProductFee;
@@ -54,6 +56,7 @@ contract Product is BaseComponent, IProductComponent {
54
56
  ) BaseComponent(registry, instanceNftid, token, PRODUCT(), isInterceptor, initialOwner) {
55
57
  // TODO add validation
56
58
  _productService = _instance.getProductService();
59
+ _policyService = _instance.getPolicyService();
57
60
  _pool = Pool(pool);
58
61
  _distribution = Distribution(distribution);
59
62
  _initialProductFee = productFee;
@@ -81,7 +84,7 @@ contract Product is BaseComponent, IProductComponent {
81
84
  override
82
85
  returns (uint256 premiumAmount)
83
86
  {
84
- (premiumAmount,,,,) = _productService.calculatePremium(
87
+ (premiumAmount,,,,) = _policyService.calculatePremium(
85
88
  riskId,
86
89
  sumInsuredAmount,
87
90
  lifetime,
@@ -154,7 +157,7 @@ contract Product is BaseComponent, IProductComponent {
154
157
  NftId bundleNftId,
155
158
  ReferralId referralId
156
159
  ) internal returns (NftId nftId) {
157
- nftId = _productService.createApplication(
160
+ nftId = _policyService.createApplication(
158
161
  applicationOwner,
159
162
  riskId,
160
163
  sumInsuredAmount,
@@ -172,7 +175,7 @@ contract Product is BaseComponent, IProductComponent {
172
175
  )
173
176
  internal
174
177
  {
175
- _productService.underwrite(
178
+ _policyService.underwrite(
176
179
  policyNftId,
177
180
  requirePremiumPayment,
178
181
  activateAt);
@@ -184,7 +187,7 @@ contract Product is BaseComponent, IProductComponent {
184
187
  )
185
188
  internal
186
189
  {
187
- _productService.collectPremium(
190
+ _policyService.collectPremium(
188
191
  policyNftId,
189
192
  activateAt);
190
193
  }
@@ -195,7 +198,7 @@ contract Product is BaseComponent, IProductComponent {
195
198
  )
196
199
  internal
197
200
  {
198
- _productService.activate(
201
+ _policyService.activate(
199
202
  policyNftId,
200
203
  activateAt);
201
204
  }
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {AccessManagerUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagerUpgradeable.sol";
5
+
6
+
7
+ contract AccessManagerUpgradeableInitializeable is AccessManagerUpgradeable {
8
+
9
+ bool private _initialized;
10
+
11
+ function __AccessManagerUpgradeableInitializeable_init(address initialAdmin) public {
12
+ require(!_initialized, "AccessManager: already initialized");
13
+
14
+ if (initialAdmin == address(0)) {
15
+ revert AccessManagerInvalidInitialAdmin(address(0));
16
+ }
17
+
18
+ // admin is active immediately and without any execution delay.
19
+ _grantRole(ADMIN_ROLE, initialAdmin, 0, 0);
20
+ _initialized = true;
21
+ }
22
+
23
+ }
@@ -39,17 +39,8 @@ contract BundleManager is
39
39
  /// @dev links a policy with its bundle
40
40
  // to link a policy it MUST NOT yet have been activated
41
41
  // the bundle MUST be unlocked (active) for linking (underwriting) and registered with this instance
42
- // TODO decide what is checked here (non upgradeable) and what is checked in the service (upgradeable)
43
42
  function linkPolicy(NftId policyNftId) external restricted() {
44
- IPolicy.PolicyInfo memory policyInfo = _instanceReader.getPolicyInfo(policyNftId);
45
-
46
- // ensure policy has not yet been activated
47
- if (policyInfo.activatedAt.gtz()) {
48
- revert ErrorBundleManagerErrorPolicyAlreadyActivated(policyNftId);
49
- }
50
-
51
- NftId bundleNftId = policyInfo.bundleNftId;
52
- // TODO decide to use instance reader or registry
43
+ NftId bundleNftId = _instanceReader.getPolicyInfo(policyNftId).bundleNftId;
53
44
  // decision will likely depend on the decision what to check here and what in the service
54
45
  NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
55
46
 
@@ -67,26 +58,10 @@ contract BundleManager is
67
58
  // to unlink a policy it must closable, ie. meet one of the following criterias
68
59
  // - the policy MUST be past its expiry period and it MUST NOT have any open claims
69
60
  // - the policy's payoutAmount MUST be equal to its sumInsuredAmount and MUST NOT have any open claims
70
- // TODO decide what is checked here (non upgradeable) and what is checked in the service (upgradeable)
71
61
  function unlinkPolicy(NftId policyNftId) external restricted() {
72
62
  IPolicy.PolicyInfo memory policyInfo = _instanceReader.getPolicyInfo(policyNftId);
73
63
 
74
- // ensure policy has no open claims
75
- if (policyInfo.openClaimsCount > 0) {
76
- revert ErrorBundleManagerPolicyWithOpenClaims(
77
- policyNftId,
78
- policyInfo.openClaimsCount);
79
- }
80
-
81
- // ensure policy is closeable
82
- if (policyInfo.expiredAt < TimestampLib.blockTimestamp()
83
- || policyInfo.payoutAmount < policyInfo.sumInsuredAmount)
84
- {
85
- revert ErrorBundleManagerPolicyNotCloseable(policyNftId);
86
- }
87
-
88
64
  NftId bundleNftId = policyInfo.bundleNftId;
89
- // TODO decide to use instance reader or registry
90
65
  // decision will likely depend on the decision what to check here and what in the service
91
66
  NftId poolNftId = _instanceReader.getBundleInfo(bundleNftId).poolNftId;
92
67
 
@@ -6,10 +6,13 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
6
  import {BundleManager} from "./BundleManager.sol";
7
7
  import {InstanceReader} from "./InstanceReader.sol";
8
8
 
9
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
9
10
  import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
10
11
  import {IDistributionService} from "./service/IDistributionService.sol";
11
12
  import {IPoolService} from "./service/IPoolService.sol";
12
13
  import {IProductService} from "./service/IProductService.sol";
14
+ import {IPolicyService} from "./service/IPolicyService.sol";
15
+ import {IBundleService} from "./service/IBundleService.sol";
13
16
  import {IBundle} from "./module/IBundle.sol";
14
17
  import {ISetup} from "./module/ISetup.sol";
15
18
  import {NftId} from "../types/NftId.sol";
@@ -26,6 +29,8 @@ interface IInstance is IERC165, IKeyValueStore {
26
29
  function getDistributionService() external view returns (IDistributionService);
27
30
  function getProductService() external view returns (IProductService);
28
31
  function getPoolService() external view returns (IPoolService);
32
+ function getPolicyService() external view returns (IPolicyService);
33
+ function getBundleService() external view returns (IBundleService);
29
34
 
30
35
  function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
31
36
  function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
@@ -51,6 +56,7 @@ interface IInstance is IERC165, IKeyValueStore {
51
56
  function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
52
57
  function updatePolicyState(NftId policyNftId, StateId newState) external;
53
58
 
59
+ function getInstanceAccessManager() external view returns (InstanceAccessManager);
54
60
  function getInstanceReader() external view returns (InstanceReader);
55
61
  function getBundleManager() external view returns (BundleManager);
56
62
  }
@@ -0,0 +1,26 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
+
6
+ import {BundleManager} from "./BundleManager.sol";
7
+ import {InstanceReader} from "./InstanceReader.sol";
8
+
9
+ import {IComponentOwnerService} from "./service/IComponentOwnerService.sol";
10
+ import {IDistributionService} from "./service/IDistributionService.sol";
11
+ import {IPoolService} from "./service/IPoolService.sol";
12
+ import {IProductService} from "./service/IProductService.sol";
13
+ import {IBundle} from "./module/IBundle.sol";
14
+ import {ISetup} from "./module/ISetup.sol";
15
+ import {NftId} from "../types/NftId.sol";
16
+ import {StateId} from "../types/StateId.sol";
17
+ import {RiskId} from "../types/RiskId.sol";
18
+ import {IRisk} from "./module/IRisk.sol";
19
+ import {IPolicy} from "./module/IPolicy.sol";
20
+ import {IKeyValueStore} from "./base/IKeyValueStore.sol";
21
+
22
+
23
+ interface IInstanceBase is IERC165, IKeyValueStore {
24
+
25
+
26
+ }
@@ -10,23 +10,31 @@ import {IRegistry} from "../registry/IRegistry.sol";
10
10
  import {IRegisterable} from "../shared/IRegisterable.sol";
11
11
  import {IBaseComponent} from "../components/IBaseComponent.sol";
12
12
 
13
- import {AccessManagerSimple} from "./AccessManagerSimple.sol";
13
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
14
14
  import {Instance} from "./Instance.sol";
15
15
  import {InstanceReader} from "./InstanceReader.sol";
16
16
  import {BundleManager} from "./BundleManager.sol";
17
17
 
18
18
  interface IInstanceService is IService {
19
19
 
20
+ error ErrorInstanceServiceRequestUnauhorized(address caller);
21
+ error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
22
+ error ErrorInstanceServiceComponentNotRegistered(address componentAddress);
23
+
20
24
  event LogInstanceCloned(address clonedAccessManagerAddress, address clonedInstanceAddress, address clonedInstanceReaderAddress, NftId clonedInstanceNftId);
21
25
 
22
26
  function createInstanceClone()
23
27
  external
24
28
  returns (
25
- AccessManagerSimple clonedAccessManager,
29
+ InstanceAccessManager clonedAccessManager,
26
30
  Instance clonedInstance,
27
31
  NftId instanceNftId,
28
32
  InstanceReader clonedInstanceReader,
29
33
  BundleManager clonedBundleManager
30
34
  );
35
+
36
+ function hasRole(address account, RoleId role, address instanceAddress) external returns (bool);
37
+ function setTargetLocked(string memory targetName, bool locked) external;
38
+
31
39
  }
32
40