@etherisc/gif-next 0.0.2-e922e07-736 → 0.0.2-e9a637d-547

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. package/README.md +0 -71
  2. package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
  3. package/artifacts/contracts/components/Component.sol/Component.json +68 -0
  4. package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
  5. package/artifacts/contracts/components/Distribution.sol/Distribution.json +68 -0
  6. package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
  7. package/artifacts/contracts/components/IComponent.sol/IComponent.json +158 -0
  8. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  9. package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +158 -0
  10. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  11. package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +184 -149
  12. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  13. package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +158 -0
  14. package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
  15. package/artifacts/contracts/components/Pool.sol/Pool.json +114 -189
  16. package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
  17. package/artifacts/contracts/components/Product.sol/Product.json +68 -0
  18. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.dbg.json +4 -0
  19. package/artifacts/contracts/instance/AccessManagerUpgradeableInitializeable.sol/AccessManagerUpgradeableInitializeable.json +1206 -0
  20. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  21. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +64 -50
  22. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
  23. package/artifacts/contracts/instance/Cloneable.sol/Cloneable.json +5 -0
  24. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  25. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +214 -2063
  26. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  27. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +196 -51
  28. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  29. package/artifacts/contracts/instance/Instance.sol/Instance.json +363 -2832
  30. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
  31. package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +491 -127
  32. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  33. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +101 -167
  34. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  35. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +333 -171
  36. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +75 -23
  38. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +4 -0
  39. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +2677 -0
  40. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  41. package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +8 -13
  42. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
  43. package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +85 -30
  44. package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  45. package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  46. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  47. package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +40 -10
  48. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  49. package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +36 -11
  50. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  51. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +56 -73
  52. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  53. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +4 -0
  54. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.json +10 -0
  55. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  56. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  57. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  58. package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
  59. package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
  60. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  61. package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +124 -53
  62. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  63. package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +21 -13
  64. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
  65. package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +384 -249
  66. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  67. package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +74 -14
  68. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +1 -1
  69. package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +104 -41
  70. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  71. package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +11 -7
  72. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
  73. package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +195 -121
  74. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  75. package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +51 -47
  76. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  77. package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +80 -14
  78. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
  79. package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +212 -186
  80. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +1 -1
  81. package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +80 -14
  82. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  83. package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +101 -24
  84. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  85. package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +90 -24
  86. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
  87. package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +511 -14
  88. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
  89. package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +80 -14
  90. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
  91. package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +136 -65
  92. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  93. package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +27 -19
  94. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
  95. package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +561 -51
  96. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  97. package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +24 -12
  98. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
  99. package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +114 -51
  100. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  101. package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +16 -12
  102. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  103. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +15 -2
  104. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  105. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +19 -0
  106. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  107. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +0 -24
  108. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  109. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +18 -0
  110. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  111. package/artifacts/contracts/registry/Registry.sol/Registry.json +31 -12
  112. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
  113. package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
  114. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  115. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +17 -36
  116. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  117. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +7 -7
  118. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  119. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +23 -11
  120. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  121. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  122. package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
  123. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  124. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  125. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  126. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  127. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  128. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  129. package/artifacts/contracts/shared/IService.sol/IService.json +80 -14
  130. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  131. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  132. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  133. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  134. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  135. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  136. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  137. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  138. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  139. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  140. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  141. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  142. package/artifacts/contracts/shared/Service.sol/Service.json +86 -15
  143. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  144. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  145. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  146. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
  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/TestFee.sol/TestFee.json +2 -2
  150. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
  151. package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +2 -2
  152. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
  153. package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
  154. package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
  155. package/artifacts/contracts/test/TestService.sol/TestService.json +101 -26
  156. package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
  157. package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
  158. package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
  159. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
  160. package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +2 -2
  161. package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
  162. package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  163. package/artifacts/contracts/types/Amount.sol/AmountLib.dbg.json +4 -0
  164. package/artifacts/contracts/types/Amount.sol/AmountLib.json +161 -0
  165. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  166. package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +2 -2
  167. package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
  168. package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  169. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  170. package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
  171. package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
  172. package/artifacts/contracts/types/Fee.sol/FeeLib.json +40 -9
  173. package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
  174. package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
  175. package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
  176. package/artifacts/contracts/types/NftId.sol/NftIdLib.json +17 -4
  177. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  178. package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
  179. package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
  180. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  181. package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
  182. package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  183. package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
  184. package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
  185. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
  186. package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
  187. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
  188. package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
  189. package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +1 -1
  190. package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
  191. package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
  192. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
  193. package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +2 -2
  194. package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
  195. package/artifacts/contracts/types/UFixed.sol/MathLib.json +2 -2
  196. package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
  197. package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +2 -2
  198. package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
  199. package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
  200. package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
  201. package/artifacts/contracts/types/Version.sol/VersionPartLib.json +2 -2
  202. package/contracts/components/Component.sol +42 -10
  203. package/contracts/components/IComponent.sol +9 -1
  204. package/contracts/components/IPoolComponent.sol +5 -43
  205. package/contracts/components/Pool.sol +47 -122
  206. package/contracts/components/Product.sol +4 -0
  207. package/contracts/instance/AccessManagerUpgradeableInitializeable.sol +13 -0
  208. package/contracts/instance/BundleManager.sol +6 -4
  209. package/contracts/instance/Cloneable.sol +7 -2
  210. package/contracts/instance/IInstance.sol +23 -55
  211. package/contracts/instance/IInstanceService.sol +31 -6
  212. package/contracts/instance/Instance.sol +90 -182
  213. package/contracts/instance/InstanceAccessManager.sol +402 -159
  214. package/contracts/instance/InstanceReader.sol +12 -12
  215. package/contracts/instance/InstanceService.sol +287 -246
  216. package/contracts/instance/InstanceStore.sol +219 -0
  217. package/contracts/instance/ObjectManager.sol +6 -8
  218. package/contracts/instance/base/ComponentService.sol +17 -30
  219. package/contracts/instance/base/KeyValueStore.sol +13 -5
  220. package/contracts/instance/base/Lifecycle.sol +11 -2
  221. package/contracts/instance/module/IAccess.sol +21 -14
  222. package/contracts/instance/module/IBundle.sol +6 -4
  223. package/contracts/instance/module/IComponents.sol +41 -0
  224. package/contracts/instance/module/ISetup.sol +3 -16
  225. package/contracts/instance/service/ApplicationService.sol +18 -16
  226. package/contracts/instance/service/BundleService.sol +213 -81
  227. package/contracts/instance/service/ClaimService.sol +3 -3
  228. package/contracts/instance/service/DistributionService.sol +57 -70
  229. package/contracts/instance/service/IBundleService.sol +63 -25
  230. package/contracts/instance/service/IDistributionService.sol +1 -0
  231. package/contracts/instance/service/IPoolService.sol +82 -3
  232. package/contracts/instance/service/PolicyService.sol +68 -100
  233. package/contracts/instance/service/PoolService.sol +214 -20
  234. package/contracts/instance/service/ProductService.sol +34 -58
  235. package/contracts/registry/ChainNft.sol +8 -0
  236. package/contracts/registry/IRegistry.sol +2 -0
  237. package/contracts/registry/IRegistryService.sol +4 -3
  238. package/contracts/registry/ITransferInterceptor.sol +1 -0
  239. package/contracts/registry/Registry.sol +23 -20
  240. package/contracts/registry/RegistryService.sol +10 -11
  241. package/contracts/registry/ReleaseManager.sol +20 -18
  242. package/contracts/shared/IService.sol +4 -6
  243. package/contracts/shared/Service.sol +21 -7
  244. package/contracts/shared/TokenHandler.sol +11 -5
  245. package/contracts/test/TestService.sol +1 -1
  246. package/contracts/types/Amount.sol +60 -0
  247. package/contracts/types/Blocknumber.sol +1 -0
  248. package/contracts/types/Fee.sol +13 -5
  249. package/contracts/types/NftId.sol +8 -0
  250. package/contracts/types/ObjectType.sol +1 -0
  251. package/contracts/types/RoleId.sol +6 -4
  252. package/contracts/types/StateId.sol +1 -0
  253. package/contracts/types/Timestamp.sol +1 -0
  254. package/contracts/types/UFixed.sol +1 -0
  255. package/contracts/types/Version.sol +1 -0
  256. package/package.json +1 -1
@@ -60,9 +60,9 @@ contract ProductService is ComponentService, IProductService {
60
60
  address initialOwner;
61
61
  (registryAddress, initialOwner) = abi.decode(data, (address, address));
62
62
 
63
- initializeService(registryAddress, owner);
63
+ initializeService(registryAddress, address(0), owner);
64
64
 
65
- _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getMajorVersion()));
65
+ _poolService = IPoolService(getRegistry().getServiceAddress(POOL(), getVersion().toMajorPart()));
66
66
 
67
67
  registerInterface(type(IProductService).interfaceId);
68
68
  }
@@ -111,17 +111,25 @@ contract ProductService is ComponentService, IProductService {
111
111
  product.linkToRegisteredNftId();
112
112
 
113
113
  // create product setup in instance
114
- instance.createProductSetup(productNftId, product.getSetupInfo());
114
+ instance.getInstanceStore().createProductSetup(productNftId, product.getSetupInfo());
115
+
116
+ bytes4[][] memory selectors = new bytes4[][](1);
117
+ selectors[0] = new bytes4[](1);
118
+ selectors[0][0] = IProductComponent.setFees.selector;
119
+
120
+ RoleId[] memory roles = new RoleId[](1);
121
+ roles[0] = PRODUCT_OWNER_ROLE();
115
122
 
116
123
  // create target for instane access manager
117
124
  getInstanceService().createGifTarget(
118
125
  getRegistry().getNftId(address(instance)),
119
126
  address(product),
120
- product.getName());
121
- getInstanceService().grantProductDefaultPermissions(instance.getNftId(), address(product), product.getName());
127
+ product.getName(),
128
+ selectors,
129
+ roles);
122
130
  }
123
131
 
124
- function getDomain() public pure override(IService, Service) returns(ObjectType) {
132
+ function getDomain() public pure override returns(ObjectType) {
125
133
  return PRODUCT();
126
134
  }
127
135
 
@@ -139,38 +147,6 @@ contract ProductService is ComponentService, IProductService {
139
147
  // if(wallet == address(0)) {
140
148
  // revert WalletIsZero();
141
149
  // }
142
-
143
- // IRegistry.ObjectInfo memory tokenInfo = getRegistry().getObjectInfo(address(info.token));
144
-
145
- // if(tokenInfo.objectType != TOKEN()) {
146
- // revert InvalidToken();
147
- // }
148
-
149
- // IRegistry.ObjectInfo memory poolInfo = getRegistry().getObjectInfo(info.poolNftId);
150
-
151
- // if(poolInfo.objectType != POOL()) {
152
- // revert InvalidPool();
153
- // }
154
-
155
- // if(poolInfo.parentNftId != instanceNftId) {
156
- // revert InvalidPoolsInstance();
157
- // }
158
- // // TODO pool have the same token
159
- // //ITreasury.PoolSetup memory poolSetup = instance.getPoolSetup(info.poolNftId);
160
- // //require(tokenInfo.objectAddress == address(poolSetup.token), "ERROR:COS-018:PRODUCT_POOL_TOKEN_MISMATCH");
161
- // // TODO pool is not linked
162
-
163
- // IRegistry.ObjectInfo memory distributionInfo = getRegistry().getObjectInfo(info.distributionNftId);
164
-
165
- // if(distributionInfo.objectType != DISTRIBUTION()) {
166
- // revert InvalidDistribution();
167
- // }
168
-
169
- // if(distributionInfo.parentNftId != instanceNftId) {
170
- // revert InvalidDistributionsInstance();
171
- // }
172
- // // TODO distribution have the same token
173
- // // TODO distribution is not linked
174
150
  }
175
151
 
176
152
  function setFees(
@@ -181,32 +157,27 @@ contract ProductService is ComponentService, IProductService {
181
157
  {
182
158
  // TODO check args
183
159
 
184
- (
185
- IRegistry.ObjectInfo memory productInfo,
186
- IInstance instance
187
- ) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
188
-
160
+ (NftId productNftId, IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
189
161
  InstanceReader instanceReader = instance.getInstanceReader();
190
- NftId productNftId = productInfo.nftId;
162
+
191
163
  ISetup.ProductSetupInfo memory productSetupInfo = instanceReader.getProductSetupInfo(productNftId);
192
164
 
193
165
  productSetupInfo.productFee = productFee;
194
166
  productSetupInfo.processingFee = processingFee;
195
167
 
196
- instance.updateProductSetup(productNftId, productSetupInfo, KEEP_STATE());
168
+ instance.getInstanceStore().updateProductSetup(productNftId, productSetupInfo, KEEP_STATE());
197
169
  }
198
170
 
199
171
  function createRisk(
200
172
  RiskId riskId,
201
173
  bytes memory data
202
- ) external override {
203
- (
204
- IRegistry.ObjectInfo memory productInfo,
205
- IInstance instance
206
- ) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
207
- NftId productNftId = productInfo.nftId;
174
+ )
175
+ external
176
+ override
177
+ {
178
+ (NftId productNftId, IRegistry.ObjectInfo memory productInfo, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
208
179
  IRisk.RiskInfo memory riskInfo = IRisk.RiskInfo(productNftId, data);
209
- instance.createRisk(
180
+ instance.getInstanceStore().createRisk(
210
181
  riskId,
211
182
  riskInfo
212
183
  );
@@ -215,19 +186,24 @@ contract ProductService is ComponentService, IProductService {
215
186
  function updateRisk(
216
187
  RiskId riskId,
217
188
  bytes memory data
218
- ) external {
219
- (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
189
+ )
190
+ external
191
+ {
192
+ (,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
220
193
  InstanceReader instanceReader = instance.getInstanceReader();
194
+
221
195
  IRisk.RiskInfo memory riskInfo = instanceReader.getRiskInfo(riskId);
222
196
  riskInfo.data = data;
223
- instance.updateRisk(riskId, riskInfo, KEEP_STATE());
197
+ instance.getInstanceStore().updateRisk(riskId, riskInfo, KEEP_STATE());
224
198
  }
225
199
 
226
200
  function updateRiskState(
227
201
  RiskId riskId,
228
202
  StateId state
229
- ) external {
230
- (, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
231
- instance.updateRiskState(riskId, state);
203
+ )
204
+ external
205
+ {
206
+ (,, IInstance instance) = _getAndVerifyComponentInfoAndInstance(PRODUCT());
207
+ instance.getInstanceStore().updateRiskState(riskId, state);
232
208
  }
233
209
  }
@@ -95,6 +95,10 @@ contract ChainNft is ERC721Enumerable {
95
95
 
96
96
  _totalMinted++;
97
97
  _safeMint(to, tokenId);
98
+
99
+ if(interceptor != address(0)) {
100
+ ITransferInterceptor(interceptor).nftMint(to, tokenId);
101
+ }
98
102
  }
99
103
 
100
104
 
@@ -195,6 +199,10 @@ contract ChainNft is ERC721Enumerable {
195
199
  _chainIdDigits;
196
200
  }
197
201
 
202
+ function getNextTokenId() external view returns (uint256) {
203
+ return calculateTokenId(_idNext);
204
+ }
205
+
198
206
  function _getNextTokenId() private returns (uint256 id) {
199
207
  id = calculateTokenId(_idNext);
200
208
  _idNext++;
@@ -84,6 +84,8 @@ interface IRegistry is IERC165 {
84
84
 
85
85
  function isRegisteredService(address contractAddress) external view returns (bool);
86
86
 
87
+ function isRegisteredComponent(address object) external view returns (bool);
88
+
87
89
  function isValidRelease(VersionPart version) external view returns (bool);
88
90
 
89
91
  function getServiceAddress(
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.20;
3
3
 
4
- import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
4
+ // import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
5
5
 
6
6
  import {NftId} from "../types/NftId.sol";
7
7
  import {ObjectType} from "../types/ObjectType.sol";
@@ -13,8 +13,9 @@ import {IRegisterable} from "../shared/IRegisterable.sol";
13
13
  import {IComponent} from "../components/IComponent.sol";
14
14
 
15
15
  interface IRegistryService is
16
- IService,
17
- IAccessManaged
16
+ IService
17
+ // TODO cleanup
18
+ // IAccessManaged
18
19
  {
19
20
  error SelfRegistration();
20
21
  error NotRegistryOwner();
@@ -2,5 +2,6 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  interface ITransferInterceptor {
5
+ function nftMint(address to, uint256 tokenId) external;
5
6
  function nftTransferFrom(address from, address to, uint256 tokenId) external;
6
7
  }
@@ -149,7 +149,6 @@ contract Registry is
149
149
  }
150
150
 
151
151
  if(
152
-
153
152
  parentType == PROTOCOL() ||
154
153
  parentType == REGISTRY() ||
155
154
  parentType == SERVICE()
@@ -186,7 +185,7 @@ contract Registry is
186
185
  return _releaseManager.getReleaseInfo(version);
187
186
  }
188
187
 
189
- function getObjectCount() external view override returns (uint256) {
188
+ function getObjectCount() external view returns (uint256) {
190
189
  return _chainNft.totalSupply();
191
190
  }
192
191
 
@@ -198,11 +197,11 @@ contract Registry is
198
197
  return _registryNftId;
199
198
  }
200
199
 
201
- function getNftId(address object) external view override returns (NftId id) {
200
+ function getNftId(address object) external view returns (NftId id) {
202
201
  return _nftIdByAddress[object];
203
202
  }
204
203
 
205
- function ownerOf(NftId nftId) public view override returns (address) {
204
+ function ownerOf(NftId nftId) public view returns (address) {
206
205
  return _chainNft.ownerOf(nftId.toInt());
207
206
  }
208
207
 
@@ -210,26 +209,31 @@ contract Registry is
210
209
  return _chainNft.ownerOf(_nftIdByAddress[contractAddress].toInt());
211
210
  }
212
211
 
213
- function getObjectInfo(NftId nftId) external view override returns (ObjectInfo memory) {
212
+ function getObjectInfo(NftId nftId) external view returns (ObjectInfo memory) {
214
213
  return _info[nftId];
215
214
  }
216
215
 
217
- function getObjectInfo(address object) external view override returns (ObjectInfo memory) {
216
+ function getObjectInfo(address object) external view returns (ObjectInfo memory) {
218
217
  return _info[_nftIdByAddress[object]];
219
218
  }
220
219
 
221
- function isRegistered(NftId nftId) public view override returns (bool) {
220
+ function isRegistered(NftId nftId) public view returns (bool) {
222
221
  return _info[nftId].objectType.gtz();
223
222
  }
224
223
 
225
- function isRegistered(address object) external view override returns (bool) {
224
+ function isRegistered(address object) external view returns (bool) {
226
225
  return _nftIdByAddress[object].gtz();
227
226
  }
228
227
 
229
- function isRegisteredService(address object) external view override returns (bool) {
228
+ function isRegisteredService(address object) external view returns (bool) {
230
229
  return _info[_nftIdByAddress[object]].objectType == SERVICE();
231
230
  }
232
231
 
232
+ function isRegisteredComponent(address object) external view returns (bool) {
233
+ NftId objectParentNftId = _info[_nftIdByAddress[object]].parentNftId;
234
+ return _info[objectParentNftId].objectType == INSTANCE();
235
+ }
236
+
233
237
  function isValidRelease(VersionPart version) external view returns (bool)
234
238
  {
235
239
  return _releaseManager.isValidRelease(version);
@@ -287,18 +291,9 @@ contract Registry is
287
291
  }
288
292
 
289
293
  address interceptor = _getInterceptor(info.isInterceptor, info.objectAddress, parentInfo.isInterceptor, parentAddress);
294
+ uint256 tokenId = _chainNft.getNextTokenId();
295
+ nftId = toNftId(tokenId);
290
296
 
291
- // TODO does external call
292
- // compute next nftId, do all checks and stores, mint() at most end...
293
- uint256 mintedTokenId = _chainNft.mint(
294
- info.initialOwner,
295
- interceptor,
296
- EMPTY_URI);
297
- nftId = toNftId(mintedTokenId);
298
-
299
- // TODO move nftId out of info struct
300
- // getters by nftId -> return struct without nftId
301
- // getters by address -> return nftId AND struct
302
297
  info.nftId = nftId;
303
298
  _info[nftId] = info;
304
299
 
@@ -314,6 +309,14 @@ contract Registry is
314
309
  }
315
310
 
316
311
  emit LogRegistration(nftId, parentNftId, objectType, info.isInterceptor, info.objectAddress, info.initialOwner);
312
+
313
+ // calls nft receiver(1) and interceptor(2)
314
+ uint256 mintedTokenId = _chainNft.mint(
315
+ info.initialOwner,
316
+ interceptor,
317
+ EMPTY_URI);
318
+ assert(mintedTokenId == tokenId);
319
+
317
320
  }
318
321
 
319
322
  /// @dev obtain interceptor address for this nft if applicable, address(0) otherwise
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.20;
3
3
 
4
4
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
5
- import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
+ // import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
6
6
 
7
7
  import {IRegistry} from "./IRegistry.sol";
8
8
  import {IInstance} from "../instance/IInstance.sol";
@@ -31,7 +31,6 @@ import {IRegistryService} from "./IRegistryService.sol";
31
31
  import {Registry} from "./Registry.sol";
32
32
 
33
33
  contract RegistryService is
34
- AccessManagedUpgradeable,
35
34
  Service,
36
35
  IRegistryService
37
36
  {
@@ -41,7 +40,7 @@ contract RegistryService is
41
40
  bytes32 public constant REGISTRY_CREATION_CODE_HASH = bytes32(0);
42
41
 
43
42
  // From IService
44
- function getDomain() public pure override(IService, Service) returns(ObjectType serviceDomain) {
43
+ function getDomain() public pure override returns(ObjectType serviceDomain) {
45
44
  return REGISTRY();
46
45
  }
47
46
 
@@ -61,9 +60,8 @@ contract RegistryService is
61
60
  address initialAuthority
62
61
  ) = abi.decode(data, (address, address));
63
62
 
64
- __AccessManaged_init(initialAuthority);
63
+ initializeService(registryAddress, initialAuthority, owner);
65
64
 
66
- initializeService(registryAddress, owner);
67
65
  registerInterface(type(IRegistryService).interfaceId);
68
66
  }
69
67
 
@@ -194,17 +192,18 @@ contract RegistryService is
194
192
  config[2].serviceDomain = CLAIM();
195
193
  config[2].selectors = new bytes4[](0);
196
194
 
197
- config[3].serviceDomain = BUNDLE();
195
+ config[3].serviceDomain = PRODUCT();
198
196
  config[3].selectors = new bytes4[](1);
199
- config[3].selectors[0] = RegistryService.registerBundle.selector;
197
+ config[3].selectors[0] = RegistryService.registerProduct.selector;
200
198
 
201
- config[4].serviceDomain = PRODUCT();
199
+ config[4].serviceDomain = POOL();
202
200
  config[4].selectors = new bytes4[](1);
203
- config[4].selectors[0] = RegistryService.registerProduct.selector;
201
+ config[4].selectors[0] = RegistryService.registerPool.selector;
204
202
 
205
- config[5].serviceDomain = POOL();
203
+ // registration of bundle service must preceed registration of pool service
204
+ config[5].serviceDomain = BUNDLE();
206
205
  config[5].selectors = new bytes4[](1);
207
- config[5].selectors[0] = RegistryService.registerPool.selector;
206
+ config[5].selectors[0] = RegistryService.registerBundle.selector;
208
207
 
209
208
  config[6].serviceDomain = DISTRIBUTION();
210
209
  config[6].selectors = new bytes4[](2);
@@ -6,7 +6,7 @@ import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManage
6
6
  import {NftId} from "../types/NftId.sol";
7
7
  import {RoleId} from "../types/RoleId.sol";
8
8
  import {ObjectType, ObjectTypeLib, zeroObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
9
- import {VersionPart, VersionPartLib} from "../types/Version.sol";
9
+ import {Version, VersionLib, VersionPart, VersionPartLib} from "../types/Version.sol";
10
10
  import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
11
11
 
12
12
  import {IService} from "../shared/IService.sol";
@@ -55,19 +55,19 @@ contract ReleaseManager is AccessManaged
55
55
  RegistryAccessManager private immutable _accessManager;
56
56
  IRegistry private immutable _registry;
57
57
 
58
- VersionPart immutable _initial;// first active version
59
- VersionPart _latest;// latest active version
60
- VersionPart _next;// version to create and activate
58
+ VersionPart immutable _initial;// first active major version
59
+ VersionPart _latest;// latest active major version
60
+ VersionPart _next;// major version to create and activate
61
61
 
62
- mapping(VersionPart version => IRegistry.ReleaseInfo info) _release;
62
+ mapping(VersionPart majorVersion => IRegistry.ReleaseInfo info) _release;
63
63
 
64
- mapping(VersionPart version => mapping(ObjectType serviceDomain => bytes4[])) _selectors; // registry service function selector assigned to domain
64
+ mapping(VersionPart majorVersion => mapping(ObjectType serviceDomain => bytes4[])) _selectors; // registry service function selector assigned to domain
65
65
 
66
66
  uint _awaitingRegistration; // "services left to register" counter
67
67
 
68
68
  mapping(address registryService => bool isActive) _active;
69
69
 
70
- mapping(VersionPart version => bool isValid) _valid; // TODO refactor to use _active only
70
+ mapping(VersionPart majorVersion => bool isValid) _valid; // TODO refactor to use _active only
71
71
 
72
72
  constructor(
73
73
  RegistryAccessManager accessManager,
@@ -146,12 +146,12 @@ contract ReleaseManager is AccessManaged
146
146
 
147
147
  IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
148
148
 
149
- VersionPart version = _next;
149
+ VersionPart majorVersion = _next;
150
150
  ObjectType domain = REGISTRY();
151
- _verifyService(service, version, domain);
151
+ _verifyService(service, majorVersion, domain);
152
152
  _createRelease(service.getFunctionConfigs());
153
153
 
154
- nftId = _registry.registerService(info, version, domain);
154
+ nftId = _registry.registerService(info, majorVersion, domain);
155
155
 
156
156
  // external call
157
157
  service.linkToRegisteredNftId();
@@ -169,13 +169,13 @@ contract ReleaseManager is AccessManaged
169
169
  }
170
170
 
171
171
  IRegistry.ObjectInfo memory info = _getAndVerifyContractInfo(service, SERVICE(), msg.sender);
172
- VersionPart version = getNextVersion();
173
- ObjectType domain = _release[version].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
174
- _verifyService(service, version, domain);
172
+ VersionPart majorVersion = getNextVersion();
173
+ ObjectType domain = _release[majorVersion].domains[_awaitingRegistration];// reversed registration order of services specified in RegistryService config
174
+ _verifyService(service, majorVersion, domain);
175
175
 
176
176
  // setup and grant unique role if service does registrations
177
- bytes4[] memory selectors = _selectors[version][domain];
178
- address registryService = _registry.getServiceAddress(REGISTRY(), version);
177
+ bytes4[] memory selectors = _selectors[majorVersion][domain];
178
+ address registryService = _registry.getServiceAddress(REGISTRY(), majorVersion);
179
179
  if(selectors.length > 0) {
180
180
  _accessManager.setAndGrantUniqueRole(
181
181
  address(service),
@@ -185,7 +185,7 @@ contract ReleaseManager is AccessManaged
185
185
 
186
186
  _awaitingRegistration--;
187
187
 
188
- nftId = _registry.registerService(info, version, domain);
188
+ nftId = _registry.registerService(info, majorVersion, domain);
189
189
 
190
190
  // external call
191
191
  service.linkToRegisteredNftId();
@@ -271,8 +271,10 @@ contract ReleaseManager is AccessManaged
271
271
  view
272
272
  returns(ObjectType)
273
273
  {
274
- if(service.getMajorVersion() != expectedVersion) {
275
- revert UnexpectedServiceVersion(expectedVersion, service.getMajorVersion());
274
+ Version version = service.getVersion();
275
+ VersionPart majorVersion = version.toMajorPart();
276
+ if(majorVersion != expectedVersion) {
277
+ revert UnexpectedServiceVersion(expectedVersion, majorVersion);
276
278
  }
277
279
 
278
280
  if(service.getDomain() != expectedDomain) {
@@ -1,18 +1,16 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {VersionPart} from "../types/Version.sol";
5
- import {ObjectType} from "../types/ObjectType.sol";
4
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
6
5
 
7
6
  import {IRegisterable} from "./IRegisterable.sol";
8
7
  import {IVersionable} from "./IVersionable.sol";
8
+ import {ObjectType} from "../types/ObjectType.sol";
9
9
 
10
10
  interface IService is
11
11
  IRegisterable,
12
- IVersionable
12
+ IVersionable,
13
+ IAccessManaged
13
14
  {
14
- error ErrorIServiceCallerUnknown(address caller);
15
-
16
15
  function getDomain() external pure returns(ObjectType serviceDomain);
17
- function getMajorVersion() external view returns(VersionPart majorVersion);
18
16
  }
@@ -1,7 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.19;
3
3
 
4
- import {ObjectType, SERVICE} from "../types/ObjectType.sol";
4
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
+ import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
6
+
7
+ import {ObjectType, REGISTRY, SERVICE} from "../types/ObjectType.sol";
5
8
  import {NftId, zeroNftId} from "../types/NftId.sol";
6
9
  import {Version, VersionPart, VersionLib, VersionPartLib} from "../types/Version.sol";
7
10
 
@@ -18,14 +21,11 @@ import {IRegistry} from "../registry/IRegistry.sol";
18
21
  abstract contract Service is
19
22
  Registerable,
20
23
  Versionable,
24
+ AccessManagedUpgradeable,
21
25
  IService
22
26
  {
23
- function getDomain() public pure virtual override returns(ObjectType);
24
27
 
25
- // version major version MUST be consistent with major version of getVersion()
26
- function getMajorVersion() public view virtual override returns(VersionPart majorVersion) {
27
- return VersionPartLib.toVersionPart(3);
28
- }
28
+ uint8 private constant GIF_MAJOR_VERSION = 3;
29
29
 
30
30
  // from Versionable
31
31
  function getVersion()
@@ -34,11 +34,12 @@ abstract contract Service is
34
34
  virtual override (IVersionable, Versionable)
35
35
  returns(Version)
36
36
  {
37
- return VersionLib.toVersion(3,0,0);
37
+ return VersionLib.toVersion(GIF_MAJOR_VERSION,0,0);
38
38
  }
39
39
 
40
40
  function initializeService(
41
41
  address registry,
42
+ address authority, // real authority for registry service adress(0) for other services
42
43
  address initialOwner
43
44
  )
44
45
  public
@@ -53,6 +54,19 @@ abstract contract Service is
53
54
  initialOwner,
54
55
  ""); // data
55
56
 
57
+ // externally provided authority
58
+ if(authority != address(0)) {
59
+ __AccessManaged_init(authority);
60
+ } else {
61
+ address registryServiceAddress = getRegistry().getServiceAddress(
62
+ REGISTRY(),
63
+ VersionPartLib.toVersionPart(GIF_MAJOR_VERSION));
64
+
65
+ // copy authority from already registered registry services
66
+ __AccessManaged_init(IAccessManaged(registryServiceAddress).authority());
67
+ }
68
+
69
+ registerInterface(type(IAccessManaged).interfaceId);
56
70
  registerInterface(type(IService).interfaceId);
57
71
  }
58
72
  }
@@ -4,6 +4,8 @@ pragma solidity ^0.8.20;
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
  import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6
6
 
7
+ /// @dev token specific transfer helper
8
+ /// relies internally on oz SafeERC20.safeTransferFrom
7
9
  contract TokenHandler {
8
10
  IERC20Metadata private _token;
9
11
 
@@ -11,17 +13,21 @@ contract TokenHandler {
11
13
  _token = IERC20Metadata(token);
12
14
  }
13
15
 
14
- // TODO add logging
15
16
  function transfer(
16
17
  address from,
17
18
  address to,
18
- uint256 amount // TODO add authz (only treasury/instance/product/pool/ service)
19
- ) external {
19
+ uint256 amount
20
+ )
21
+ external
22
+ {
20
23
  SafeERC20.safeTransferFrom(_token, from, to, amount);
21
- // _token.transferFrom(from, to, amount);
22
24
  }
23
25
 
24
- function getToken() external view returns (IERC20Metadata) {
26
+ function getToken()
27
+ external
28
+ view
29
+ returns (IERC20Metadata)
30
+ {
25
31
  return _token;
26
32
  }
27
33
  }
@@ -16,7 +16,7 @@ contract TestService is Service {
16
16
  constructor(address registry, NftId registryNftId, address initialOwner)
17
17
  // solhint-disable-next-line no-empty-blocks
18
18
  {
19
- initializeService(registry, initialOwner);
19
+ initializeService(registry, address(0), initialOwner);
20
20
  }
21
21
 
22
22
  function getDomain() public pure override returns(ObjectType) {
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {UFixed, UFixedLib} from "./UFixed.sol";
5
+
6
+ type Amount is uint96;
7
+
8
+ using {
9
+ AmountLib.eqz,
10
+ AmountLib.gtz,
11
+ AmountLib.toInt,
12
+ AmountLib.toUFixed
13
+ } for Amount global;
14
+
15
+
16
+ library AmountLib {
17
+
18
+ error ErrorAmountLibValueTooBig(uint256 amount);
19
+
20
+ function zero() public pure returns (Amount) {
21
+ return Amount.wrap(0);
22
+ }
23
+
24
+ function max() public pure returns (Amount) {
25
+ return Amount.wrap(_max());
26
+ }
27
+
28
+ /// @dev converts the uint amount into Amount
29
+ /// function reverts if value is exceeding max Amount value
30
+ function toAmount(uint256 amount) public pure returns (Amount) {
31
+ if(amount > _max()) {
32
+ revert ErrorAmountLibValueTooBig(amount);
33
+ }
34
+
35
+ return Amount.wrap(uint96(amount));
36
+ }
37
+
38
+ /// @dev return true if amount equals 0
39
+ function eqz(Amount amount) public pure returns (bool) {
40
+ return Amount.unwrap(amount) == 0;
41
+ }
42
+
43
+ /// @dev return true if amount is larger than 0
44
+ function gtz(Amount amount) public pure returns (bool) {
45
+ return Amount.unwrap(amount) > 0;
46
+ }
47
+
48
+ function toInt(Amount amount) public pure returns (uint256) {
49
+ return uint256(uint96(Amount.unwrap(amount)));
50
+ }
51
+
52
+ function toUFixed(Amount amount) public pure returns (UFixed) {
53
+ return UFixedLib.toUFixed(Amount.unwrap(amount));
54
+ }
55
+
56
+ function _max() internal pure returns (uint96) {
57
+ // IMPORTANT: type nees to match with actual definition for Amount
58
+ return type(uint96).max;
59
+ }
60
+ }
@@ -52,6 +52,7 @@ function blockBlocknumber() view returns (Blocknumber) {
52
52
  return toBlocknumber(block.number);
53
53
  }
54
54
 
55
+ // TODO move to BlocknumberLib and rename to zero()
55
56
  /// @dev Return the Blocknumber zero (0)
56
57
  function zeroBlocknumber() pure returns (Blocknumber) {
57
58
  return toBlocknumber(0);