@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
@@ -4,38 +4,47 @@ pragma solidity ^0.8.20;
4
4
  import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
5
5
  import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
6
6
 
7
- import {Instance} from "./Instance.sol";
8
- import {IInstance} from "./IInstance.sol";
9
- import {InstanceAccessManager} from "./InstanceAccessManager.sol";
10
- import {IInstanceService} from "./IInstanceService.sol";
11
- import {InstanceReader} from "./InstanceReader.sol";
12
- import {BundleManager} from "./BundleManager.sol";
13
- import {AccessManagerUpgradeableInitializeable} from "./AccessManagerUpgradeableInitializeable.sol";
14
- import {IRegistry} from "../registry/IRegistry.sol";
15
- import {IRegistryService} from "../registry/IRegistryService.sol";
16
- import {ChainNft} from "../registry/ChainNft.sol";
17
- import {Service} from "../../contracts/shared/Service.sol";
18
- import {IService} from "../shared/IService.sol";
19
7
  import {NftId} from "../../contracts/types/NftId.sol";
20
8
  import {RoleId} from "../types/RoleId.sol";
21
9
  import {ADMIN_ROLE, INSTANCE_OWNER_ROLE, DISTRIBUTION_OWNER_ROLE, POOL_OWNER_ROLE, PRODUCT_OWNER_ROLE, INSTANCE_SERVICE_ROLE, DISTRIBUTION_SERVICE_ROLE, POOL_SERVICE_ROLE, PRODUCT_SERVICE_ROLE, APPLICATION_SERVICE_ROLE, POLICY_SERVICE_ROLE, CLAIM_SERVICE_ROLE, BUNDLE_SERVICE_ROLE, INSTANCE_ROLE} from "../types/RoleId.sol";
22
10
  import {ObjectType, INSTANCE, BUNDLE, APPLICATION, POLICY, CLAIM, PRODUCT, DISTRIBUTION, REGISTRY, POOL} from "../types/ObjectType.sol";
11
+
12
+ import {Service} from "../shared/Service.sol";
13
+ import {IService} from "../shared/IService.sol";
14
+ import {AccessManagerUpgradeableInitializeable} from "../shared/AccessManagerUpgradeableInitializeable.sol";
15
+
23
16
  import {IDistributionComponent} from "../components/IDistributionComponent.sol";
24
17
  import {IPoolComponent} from "../components/IPoolComponent.sol";
25
18
  import {IProductComponent} from "../components/IProductComponent.sol";
26
19
 
20
+ import {IRegistry} from "../registry/IRegistry.sol";
21
+ import {IRegistryService} from "../registry/IRegistryService.sol";
22
+ import {ChainNft} from "../registry/ChainNft.sol";
23
+
24
+ import {Instance} from "./Instance.sol";
25
+ import {IInstance} from "./IInstance.sol";
26
+ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
27
+ import {IInstanceService} from "./IInstanceService.sol";
28
+ import {InstanceReader} from "./InstanceReader.sol";
29
+ import {BundleManager} from "./BundleManager.sol";
30
+ import {InstanceStore} from "./InstanceStore.sol";
31
+ import {InstanceAuthorizationsLib} from "./InstanceAuthorizationsLib.sol";
32
+
27
33
  contract InstanceService is
28
34
  Service,
29
35
  IInstanceService
30
36
  {
37
+
38
+ // TODO update to real hash when instance is stable
39
+ bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
40
+
41
+ IRegistryService internal _registryService;
31
42
  address internal _masterOzAccessManager;
32
43
  address internal _masterInstanceAccessManager;
33
44
  address internal _masterInstance;
34
45
  address internal _masterInstanceReader;
35
46
  address internal _masterInstanceBundleManager;
36
-
37
- // TODO update to real hash when instance is stable
38
- bytes32 public constant INSTANCE_CREATION_CODE_HASH = bytes32(0);
47
+ address internal _masterInstanceStore;
39
48
 
40
49
  modifier onlyInstanceOwner(NftId instanceNftId) {
41
50
  if(msg.sender != getRegistry().ownerOf(instanceNftId)) {
@@ -62,22 +71,12 @@ contract InstanceService is
62
71
  function createInstanceClone()
63
72
  external
64
73
  returns (
65
- AccessManagerUpgradeableInitializeable clonedOzAccessManager,
66
- InstanceAccessManager clonedInstanceAccessManager,
67
74
  Instance clonedInstance,
68
- NftId clonedInstanceNftId,
69
- InstanceReader clonedInstanceReader,
70
- BundleManager clonedBundleManager
75
+ NftId clonedInstanceNftId
71
76
  )
72
77
  {
73
78
  address instanceOwner = msg.sender;
74
- IRegistry registry = getRegistry();
75
- address registryAddress = address(registry);
76
- NftId registryNftId = registry.getNftId(registryAddress);
77
- address registryServiceAddress = registry.getServiceAddress(REGISTRY(), getMajorVersion());
78
- IRegistryService registryService = IRegistryService(registryServiceAddress);
79
-
80
- clonedOzAccessManager = AccessManagerUpgradeableInitializeable(
79
+ AccessManagerUpgradeableInitializeable clonedOzAccessManager = AccessManagerUpgradeableInitializeable(
81
80
  Clones.clone(_masterOzAccessManager));
82
81
 
83
82
  // initially grants ADMIN_ROLE to this (being the instance service).
@@ -89,239 +88,54 @@ contract InstanceService is
89
88
  clonedInstance = Instance(Clones.clone(_masterInstance));
90
89
  clonedInstance.initialize(
91
90
  address(clonedOzAccessManager),
92
- registryAddress,
91
+ address(getRegistry()),
93
92
  instanceOwner);
93
+ // initialize and set before instance reader
94
+ InstanceStore clonedInstanceStore = InstanceStore(Clones.clone(address(_masterInstanceStore)));
95
+ clonedInstanceStore.initialize(address(clonedInstance));
96
+ clonedInstance.setInstanceStore(clonedInstanceStore);
94
97
 
95
- clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
98
+ InstanceReader clonedInstanceReader = InstanceReader(Clones.clone(address(_masterInstanceReader)));
96
99
  clonedInstanceReader.initialize(address(clonedInstance));
97
100
  clonedInstance.setInstanceReader(clonedInstanceReader);
98
101
 
99
- clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
102
+ BundleManager clonedBundleManager = BundleManager(Clones.clone(_masterInstanceBundleManager));
100
103
  clonedBundleManager.initialize(address(clonedInstance));
101
104
  clonedInstance.setBundleManager(clonedBundleManager);
102
105
 
103
- clonedInstanceAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
106
+ InstanceAccessManager clonedInstanceAccessManager = InstanceAccessManager(Clones.clone(_masterInstanceAccessManager));
104
107
  clonedOzAccessManager.grantRole(ADMIN_ROLE().toInt(), address(clonedInstanceAccessManager), 0);
105
108
  clonedInstanceAccessManager.initialize(address(clonedInstance));
106
109
  clonedInstance.setInstanceAccessManager(clonedInstanceAccessManager);
107
110
 
108
111
  // TODO amend setters with instance specific , policy manager ...
109
112
 
110
- _grantInitialAuthorizations(clonedInstanceAccessManager, clonedInstance, clonedBundleManager, instanceOwner);
113
+ // TODO library does external calls -> but it is registry and access manager -> find out is it best practice
114
+ InstanceAuthorizationsLib.grantInitialAuthorizations(
115
+ clonedInstanceAccessManager,
116
+ clonedInstance,
117
+ clonedBundleManager,
118
+ clonedInstanceStore,
119
+ instanceOwner,
120
+ getRegistry(),
121
+ getVersion().toMajorPart());
111
122
 
112
123
  clonedOzAccessManager.renounceRole(ADMIN_ROLE().toInt(), address(this));
113
124
 
114
- IRegistry.ObjectInfo memory info = registryService.registerInstance(clonedInstance, instanceOwner);
125
+ IRegistry.ObjectInfo memory info = _registryService.registerInstance(clonedInstance, instanceOwner);
115
126
  clonedInstanceNftId = info.nftId;
116
- // clonedInstance.linkToRegisteredNftId();
117
127
 
118
128
  emit LogInstanceCloned(
119
129
  address(clonedOzAccessManager),
120
130
  address(clonedInstanceAccessManager),
121
- address(clonedInstance),
131
+ address(clonedInstance),
132
+ address(clonedInstanceStore),
122
133
  address(clonedBundleManager),
123
134
  address(clonedInstanceReader),
124
135
  clonedInstanceNftId);
125
136
  }
126
137
 
127
- function _grantInitialAuthorizations(
128
- InstanceAccessManager clonedAccessManager,
129
- Instance clonedInstance,
130
- BundleManager clonedBundleManager,
131
- address instanceOwner)
132
- internal
133
- {
134
- _createCoreAndGifRoles(clonedAccessManager);
135
- _createCoreTargets(clonedAccessManager, clonedInstance, clonedBundleManager);
136
- _grantDistributionServiceAuthorizations(clonedAccessManager, clonedInstance);
137
- _grantPoolServiceAuthorizations(clonedAccessManager, clonedInstance);
138
- _grantProductServiceAuthorizations(clonedAccessManager, clonedInstance);
139
- _grantApplicationServiceAuthorizations(clonedAccessManager, clonedInstance);
140
- _grantPolicyServiceAuthorizations(clonedAccessManager, clonedInstance);
141
- _grantClaimServiceAuthorizations(clonedAccessManager, clonedInstance);
142
- _grantBundleServiceAuthorizations(clonedAccessManager, clonedInstance, clonedBundleManager);
143
- _grantInstanceServiceAuthorizations(clonedAccessManager, clonedInstance);
144
- _grantInstanceOwnerAuthorizations(clonedAccessManager, instanceOwner);
145
- }
146
-
147
- function _createCoreAndGifRoles(InstanceAccessManager clonedAccessManager) internal {
148
- // default roles controlled by ADMIN_ROLE -> core roles
149
- // all set/granted only once during cloning (the only exception is INSTANCE_OWNER_ROLE, hooked to instance nft)
150
- clonedAccessManager.createCoreRole(INSTANCE_SERVICE_ROLE(), "InstanceServiceRole");
151
- clonedAccessManager.createCoreRole(DISTRIBUTION_SERVICE_ROLE(), "DistributionServiceRole");
152
- clonedAccessManager.createCoreRole(POOL_SERVICE_ROLE(), "PoolServiceRole");
153
- clonedAccessManager.createCoreRole(APPLICATION_SERVICE_ROLE(), "ApplicationServiceRole");
154
- clonedAccessManager.createCoreRole(PRODUCT_SERVICE_ROLE(), "ProductServiceRole");
155
- clonedAccessManager.createCoreRole(CLAIM_SERVICE_ROLE(), "ClaimServiceRole");
156
- clonedAccessManager.createCoreRole(POLICY_SERVICE_ROLE(), "PolicyServiceRole");
157
- clonedAccessManager.createCoreRole(BUNDLE_SERVICE_ROLE(), "BundleServiceRole");
158
- // default roles controlled by INSTANCE_OWNER_ROLE -> gif roles
159
- clonedAccessManager.createGifRole(DISTRIBUTION_OWNER_ROLE(), "DistributionOwnerRole", INSTANCE_OWNER_ROLE());
160
- clonedAccessManager.createGifRole(POOL_OWNER_ROLE(), "PoolOwnerRole", INSTANCE_OWNER_ROLE());
161
- clonedAccessManager.createGifRole(PRODUCT_OWNER_ROLE(), "ProductOwnerRole", INSTANCE_OWNER_ROLE());
162
- }
163
-
164
- function _createCoreTargets(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
165
- clonedAccessManager.createCoreTarget(address(clonedAccessManager), "InstanceAccessManager");
166
- clonedAccessManager.createCoreTarget(address(clonedInstance), "Instance");
167
- clonedAccessManager.createCoreTarget(address(clonedBundleManager), "BundleManager");
168
- }
169
-
170
- function _grantDistributionServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
171
- // configure authorization for distribution service on instance
172
- address distributionServiceAddress = getRegistry().getServiceAddress(DISTRIBUTION(), getMajorVersion());
173
- clonedAccessManager.grantRole(DISTRIBUTION_SERVICE_ROLE(), distributionServiceAddress);
174
- bytes4[] memory instanceDistributionServiceSelectors = new bytes4[](11);
175
- instanceDistributionServiceSelectors[0] = clonedInstance.createDistributionSetup.selector;
176
- instanceDistributionServiceSelectors[1] = clonedInstance.updateDistributionSetup.selector;
177
- instanceDistributionServiceSelectors[2] = clonedInstance.createDistributorType.selector;
178
- instanceDistributionServiceSelectors[3] = clonedInstance.updateDistributorType.selector;
179
- instanceDistributionServiceSelectors[4] = clonedInstance.updateDistributorTypeState.selector;
180
- instanceDistributionServiceSelectors[5] = clonedInstance.createDistributor.selector;
181
- instanceDistributionServiceSelectors[6] = clonedInstance.updateDistributor.selector;
182
- instanceDistributionServiceSelectors[7] = clonedInstance.updateDistributorState.selector;
183
- instanceDistributionServiceSelectors[8] = clonedInstance.createReferral.selector;
184
- instanceDistributionServiceSelectors[9] = clonedInstance.updateReferral.selector;
185
- instanceDistributionServiceSelectors[10] = clonedInstance.updateReferralState.selector;
186
- clonedAccessManager.setCoreTargetFunctionRole(
187
- "Instance",
188
- instanceDistributionServiceSelectors,
189
- DISTRIBUTION_SERVICE_ROLE());
190
- }
191
-
192
- function _grantPoolServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
193
- // configure authorization for pool service on instance
194
- address poolServiceAddress = getRegistry().getServiceAddress(POOL(), getMajorVersion());
195
- clonedAccessManager.grantRole(POOL_SERVICE_ROLE(), address(poolServiceAddress));
196
- bytes4[] memory instancePoolServiceSelectors = new bytes4[](4);
197
- instancePoolServiceSelectors[0] = clonedInstance.createPoolSetup.selector;
198
- instancePoolServiceSelectors[1] = clonedInstance.updatePoolSetup.selector;
199
- clonedAccessManager.setCoreTargetFunctionRole(
200
- "Instance",
201
- instancePoolServiceSelectors,
202
- POOL_SERVICE_ROLE());
203
- }
204
-
205
- function _grantProductServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
206
- // configure authorization for product service on instance
207
- address productServiceAddress = getRegistry().getServiceAddress(PRODUCT(), getMajorVersion());
208
- clonedAccessManager.grantRole(PRODUCT_SERVICE_ROLE(), address(productServiceAddress));
209
- bytes4[] memory instanceProductServiceSelectors = new bytes4[](5);
210
- instanceProductServiceSelectors[0] = clonedInstance.createProductSetup.selector;
211
- instanceProductServiceSelectors[1] = clonedInstance.updateProductSetup.selector;
212
- instanceProductServiceSelectors[2] = clonedInstance.createRisk.selector;
213
- instanceProductServiceSelectors[3] = clonedInstance.updateRisk.selector;
214
- instanceProductServiceSelectors[4] = clonedInstance.updateRiskState.selector;
215
- clonedAccessManager.setCoreTargetFunctionRole(
216
- "Instance",
217
- instanceProductServiceSelectors,
218
- PRODUCT_SERVICE_ROLE());
219
- }
220
-
221
- function _grantApplicationServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
222
- // configure authorization for application services on instance
223
- address applicationServiceAddress = getRegistry().getServiceAddress(APPLICATION(), getMajorVersion());
224
- clonedAccessManager.grantRole(APPLICATION_SERVICE_ROLE(), applicationServiceAddress);
225
- bytes4[] memory instanceApplicationServiceSelectors = new bytes4[](3);
226
- instanceApplicationServiceSelectors[0] = clonedInstance.createApplication.selector;
227
- instanceApplicationServiceSelectors[1] = clonedInstance.updateApplication.selector;
228
- instanceApplicationServiceSelectors[2] = clonedInstance.updateApplicationState.selector;
229
- clonedAccessManager.setCoreTargetFunctionRole(
230
- "Instance",
231
- instanceApplicationServiceSelectors,
232
- APPLICATION_SERVICE_ROLE());
233
- }
234
-
235
- function _grantPolicyServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
236
- // configure authorization for policy services on instance
237
- address policyServiceAddress = getRegistry().getServiceAddress(POLICY(), getMajorVersion());
238
- clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), policyServiceAddress);
239
- bytes4[] memory instancePolicyServiceSelectors = new bytes4[](2);
240
- instancePolicyServiceSelectors[0] = clonedInstance.updatePolicy.selector;
241
- instancePolicyServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
242
- clonedAccessManager.setCoreTargetFunctionRole(
243
- "Instance",
244
- instancePolicyServiceSelectors,
245
- POLICY_SERVICE_ROLE());
246
- }
247
-
248
- function _grantClaimServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
249
- // configure authorization for claim/payout services on instance
250
- address claimServiceAddress = getRegistry().getServiceAddress(CLAIM(), getMajorVersion());
251
- clonedAccessManager.grantRole(POLICY_SERVICE_ROLE(), claimServiceAddress);
252
- // TODO add claims function authz
253
- bytes4[] memory instanceClaimServiceSelectors = new bytes4[](0);
254
- // instanceClaimServiceSelectors[0] = clonedInstance.updatePolicy.selector;
255
- // instanceClaimServiceSelectors[1] = clonedInstance.updatePolicyState.selector;
256
- clonedAccessManager.setCoreTargetFunctionRole(
257
- "Instance",
258
- instanceClaimServiceSelectors,
259
- CLAIM_SERVICE_ROLE());
260
- }
261
-
262
- function _grantBundleServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance, BundleManager clonedBundleManager) internal {
263
- // configure authorization for bundle service on instance
264
- address bundleServiceAddress = getRegistry().getServiceAddress(BUNDLE(), getMajorVersion());
265
- clonedAccessManager.grantRole(BUNDLE_SERVICE_ROLE(), address(bundleServiceAddress));
266
- bytes4[] memory instanceBundleServiceSelectors = new bytes4[](3);
267
- instanceBundleServiceSelectors[0] = clonedInstance.createBundle.selector;
268
- instanceBundleServiceSelectors[1] = clonedInstance.updateBundle.selector;
269
- instanceBundleServiceSelectors[2] = clonedInstance.updateBundleState.selector;
270
- clonedAccessManager.setCoreTargetFunctionRole(
271
- "Instance",
272
- instanceBundleServiceSelectors,
273
- BUNDLE_SERVICE_ROLE());
274
-
275
- // configure authorization for bundle service on bundle manager
276
- bytes4[] memory bundleManagerBundleServiceSelectors = new bytes4[](5);
277
- bundleManagerBundleServiceSelectors[0] = clonedBundleManager.linkPolicy.selector;
278
- bundleManagerBundleServiceSelectors[1] = clonedBundleManager.unlinkPolicy.selector;
279
- bundleManagerBundleServiceSelectors[2] = clonedBundleManager.add.selector;
280
- bundleManagerBundleServiceSelectors[3] = clonedBundleManager.lock.selector;
281
- bundleManagerBundleServiceSelectors[4] = clonedBundleManager.unlock.selector;
282
- clonedAccessManager.setCoreTargetFunctionRole(
283
- "BundleManager",
284
- bundleManagerBundleServiceSelectors,
285
- BUNDLE_SERVICE_ROLE());
286
- }
287
-
288
- function _grantInstanceServiceAuthorizations(InstanceAccessManager clonedAccessManager, Instance clonedInstance) internal {
289
- // configure authorization for instance service on instance
290
- address instanceServiceAddress = getRegistry().getServiceAddress(INSTANCE(), getMajorVersion());
291
- clonedAccessManager.grantRole(INSTANCE_SERVICE_ROLE(), instanceServiceAddress);
292
- bytes4[] memory instanceInstanceServiceSelectors = new bytes4[](1);
293
- instanceInstanceServiceSelectors[0] = clonedInstance.setInstanceReader.selector;
294
- clonedAccessManager.setCoreTargetFunctionRole(
295
- "Instance",
296
- instanceInstanceServiceSelectors,
297
- INSTANCE_SERVICE_ROLE());
298
-
299
- // configure authorizations for instance service on instance access manager
300
- bytes4[] memory accessManagerInstanceServiceSelectors = new bytes4[](3);
301
- accessManagerInstanceServiceSelectors[0] = clonedAccessManager.createGifTarget.selector;
302
- accessManagerInstanceServiceSelectors[1] = clonedAccessManager.setTargetLocked.selector;
303
- accessManagerInstanceServiceSelectors[2] = clonedAccessManager.setCoreTargetFunctionRole.selector;
304
- clonedAccessManager.setCoreTargetFunctionRole(
305
- "InstanceAccessManager",
306
- accessManagerInstanceServiceSelectors,
307
- INSTANCE_SERVICE_ROLE());
308
- }
309
-
310
- function _grantInstanceOwnerAuthorizations(InstanceAccessManager clonedAccessManager, address instanceOwner) internal {
311
- // configure authorization for instance owner on instance access manager
312
- // instance owner role is granted/revoked ONLY by INSTANCE_ROLE
313
- bytes4[] memory accessManagerInstanceOwnerSelectors = new bytes4[](3);
314
- accessManagerInstanceOwnerSelectors[0] = clonedAccessManager.createRole.selector;
315
- accessManagerInstanceOwnerSelectors[1] = clonedAccessManager.createTarget.selector;
316
- accessManagerInstanceOwnerSelectors[2] = clonedAccessManager.setTargetFunctionRole.selector;
317
- clonedAccessManager.setCoreTargetFunctionRole(
318
- "InstanceAccessManager",
319
- accessManagerInstanceOwnerSelectors,
320
- INSTANCE_OWNER_ROLE());
321
- }
322
-
323
-
324
- function setAndRegisterMasterInstance(address instanceAddress)
138
+ function setAndRegisterMasterInstance(address instanceAddress)
325
139
  external
326
140
  onlyOwner
327
141
  returns(NftId masterInstanceNftId)
@@ -334,37 +148,36 @@ contract InstanceService is
334
148
  if(instanceAddress == address(0)) { revert ErrorInstanceServiceInstanceAddressZero(); }
335
149
 
336
150
  IInstance instance = IInstance(instanceAddress);
337
- AccessManagerUpgradeableInitializeable ozAccessManager = AccessManagerUpgradeableInitializeable(instance.authority());
338
- address ozAccessManagerAddress = address(ozAccessManager);
339
151
  InstanceAccessManager instanceAccessManager = instance.getInstanceAccessManager();
340
152
  address instanceAccessManagerAddress = address(instanceAccessManager);
341
153
  InstanceReader instanceReader = instance.getInstanceReader();
342
154
  address instanceReaderAddress = address(instanceReader);
343
155
  BundleManager bundleManager = instance.getBundleManager();
344
156
  address bundleManagerAddress = address(bundleManager);
157
+ InstanceStore instanceStore = instance.getInstanceStore();
158
+ address instanceStoreAddress = address(instanceStore);
345
159
 
346
- if(ozAccessManagerAddress == address(0)) { revert ErrorInstanceServiceOzAccessManagerZero();}
347
160
  if(instanceAccessManagerAddress == address(0)) { revert ErrorInstanceServiceInstanceAccessManagerZero(); }
348
161
  if(instanceReaderAddress == address(0)) { revert ErrorInstanceServiceInstanceReaderZero(); }
349
162
  if(bundleManagerAddress == address(0)) { revert ErrorInstanceServiceBundleManagerZero(); }
163
+ if(instanceStoreAddress == address(0)) { revert ErrorInstanceServiceInstanceStoreZero(); }
350
164
 
351
165
  if(instance.authority() != instanceAccessManager.authority()) { revert ErrorInstanceServiceInstanceAuthorityMismatch(); }
352
166
  if(bundleManager.authority() != instanceAccessManager.authority()) { revert ErrorInstanceServiceBundleManagerAuthorityMismatch(); }
353
- if(instanceReader.getInstance() != instance) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch2(); }
167
+ if(instanceStore.authority() != instanceAccessManager.authority()) { revert ErrorInstanceServiceInstanceStoreAuthorityMismatch(); }
354
168
  if(bundleManager.getInstance() != instance) { revert ErrorInstanceServiceBundleMangerInstanceMismatch(); }
169
+ if(instanceReader.getInstance() != instance) { revert ErrorInstanceServiceInstanceReaderInstanceMismatch2(); }
355
170
 
356
- _masterOzAccessManager = ozAccessManagerAddress;
171
+ _masterOzAccessManager = instance.authority();
357
172
  _masterInstanceAccessManager = instanceAccessManagerAddress;
358
173
  _masterInstance = instanceAddress;
359
174
  _masterInstanceReader = instanceReaderAddress;
360
175
  _masterInstanceBundleManager = bundleManagerAddress;
176
+ _masterInstanceStore = instanceStoreAddress;
361
177
 
362
- IRegistryService registryService = IRegistryService(getRegistry().getServiceAddress(REGISTRY(), getMajorVersion()));
363
178
  IInstance masterInstance = IInstance(_masterInstance);
364
- IRegistry.ObjectInfo memory info = registryService.registerInstance(masterInstance, getOwner());
179
+ IRegistry.ObjectInfo memory info = _registryService.registerInstance(masterInstance, getOwner());
365
180
  masterInstanceNftId = info.nftId;
366
-
367
- // masterInstance.linkToRegisteredNftId();
368
181
  }
369
182
 
370
183
  function setMasterInstanceReader(address instanceReaderAddress) external onlyOwner {
@@ -391,44 +204,6 @@ contract InstanceService is
391
204
  instance.setInstanceReader(upgradedInstanceReaderClone);
392
205
  }
393
206
 
394
- function getMasterInstanceReader() external view returns (address) {
395
- return _masterInstanceReader;
396
- }
397
-
398
- function getMasterInstance() external view returns (address) {
399
- return _masterInstance;
400
- }
401
-
402
- function getMasterInstanceAccessManager() external view returns (address) {
403
- return _masterInstanceAccessManager;
404
- }
405
-
406
- function getMasterInstanceBundleManager() external view returns (address) {
407
- return _masterInstanceBundleManager;
408
- }
409
-
410
- // From IService
411
- function getDomain() public pure override(Service, IService) returns(ObjectType) {
412
- return INSTANCE();
413
- }
414
-
415
- /// @dev top level initializer
416
- function _initialize(
417
- address owner,
418
- bytes memory data
419
- )
420
- internal
421
- initializer
422
- virtual override
423
- {
424
- address initialOwner;
425
- address registryAddress;
426
- (registryAddress, initialOwner) = abi.decode(data, (address, address));
427
- // TODO while InstanceService is not deployed in InstanceServiceManager constructor
428
- // owner is InstanceServiceManager deployer
429
- initializeService(registryAddress, owner);
430
- registerInterface(type(IInstanceService).interfaceId);
431
- }
432
207
 
433
208
  // all gif targets MUST be childs of instanceNftId
434
209
  function createGifTarget(
@@ -443,13 +218,13 @@ contract InstanceService is
443
218
  {
444
219
  (
445
220
  IInstance instance, // or instanceInfo
446
- NftId targetNftId // or targetInfo
221
+ // or targetInfo
447
222
  ) = _validateInstanceAndComponent(instanceNftId, targetAddress);
448
223
 
449
224
  InstanceAccessManager accessManager = instance.getInstanceAccessManager();
450
225
  accessManager.createGifTarget(targetAddress, targetName);
451
226
  // set proposed target config
452
- // TODO restriction: for gif targets can set only once and only here?
227
+ // TODO restriction: gif targets are set only once and only here?
453
228
  // assume config is a mix of gif and custom roles and no further configuration by INSTANCE_OWNER_ROLE is ever needed?
454
229
  for(uint roleIdx = 0; roleIdx < roles.length; roleIdx++)
455
230
  {
@@ -457,22 +232,60 @@ contract InstanceService is
457
232
  }
458
233
  }
459
234
 
235
+
460
236
  // TODO called by component, but target can be component helper...so needs target name
461
237
  // TODO check that targetName associated with component...how???
462
- //function setTargetLocked(string memory targetName, bool locked) onlyComponent external {
463
238
  function setComponentLocked(bool locked) onlyComponent external {
239
+
464
240
  address componentAddress = msg.sender;
465
241
  IRegistry registry = getRegistry();
466
242
  NftId instanceNftId = registry.getObjectInfo(componentAddress).parentNftId;
467
- address instanceAddress = registry.getObjectInfo(instanceNftId).objectAddress;
468
- IInstance instance = IInstance(instanceAddress);
469
243
 
470
- InstanceAccessManager accessManager = instance.getInstanceAccessManager();
471
- // TODO setLocked by target address?
472
- string memory componentName = ShortStrings.toString(accessManager.getTargetInfo(componentAddress).name);
473
- accessManager.setTargetLocked(componentName, locked);
244
+ IInstance instance = IInstance(
245
+ registry.getObjectInfo(
246
+ instanceNftId).objectAddress);
247
+
248
+ instance.getInstanceAccessManager().setTargetLockedByService(
249
+ componentAddress,
250
+ locked);
251
+ }
252
+
253
+
254
+ function getMasterInstanceReader() external view returns (address) {
255
+ return _masterInstanceReader;
474
256
  }
475
257
 
258
+ // From IService
259
+ function getDomain() public pure override returns(ObjectType) {
260
+ return INSTANCE();
261
+ }
262
+
263
+ /// @dev top level initializer
264
+ function _initialize(
265
+ address owner,
266
+ bytes memory data
267
+ )
268
+ internal
269
+ initializer
270
+ virtual override
271
+ {
272
+ (
273
+ address registryAddress,
274
+ address initialOwner
275
+ ) = abi.decode(data, (address, address));
276
+
277
+ _registryService = IRegistryService(
278
+ IRegistry(registryAddress).getServiceAddress(
279
+ REGISTRY(),
280
+ getVersion().toMajorPart()));
281
+
282
+ // TODO while InstanceService is not deployed in InstanceServiceManager constructor
283
+ // owner is InstanceServiceManager deployer
284
+ initializeService(registryAddress, address(0), owner);
285
+ registerInterface(type(IInstanceService).interfaceId);
286
+ }
287
+
288
+
476
289
  function _validateInstanceAndComponent(NftId instanceNftId, address componentAddress)
477
290
  internal
478
291
  view