@etherisc/gif-next 0.0.2-7ca6cd9-950 → 0.0.2-7dc3cd3-858

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/README.md +18 -2
  2. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +4 -0
  3. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +1248 -0
  4. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +4 -0
  5. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +358 -0
  6. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +4 -0
  7. package/artifacts/contracts/authorization/IAccess.sol/IAccess.json +10 -0
  8. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +4 -0
  9. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +1032 -0
  10. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +4 -0
  11. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +258 -0
  12. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.dbg.json +4 -0
  13. package/artifacts/contracts/authorization/IModuleAuthorization.sol/IModuleAuthorization.json +290 -0
  14. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +4 -0
  15. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +129 -0
  16. package/artifacts/contracts/authorization/InstanceAdmin.sol/InstanceAdmin.dbg.json +4 -0
  17. package/artifacts/contracts/authorization/InstanceAdmin.sol/InstanceAdmin.json +1385 -0
  18. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.dbg.json +4 -0
  19. package/artifacts/contracts/authorization/ModuleAuthorization.sol/ModuleAuthorization.json +390 -0
  20. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +4 -0
  21. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +171 -0
  22. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +4 -0
  23. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +1505 -0
  24. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +4 -0
  25. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +410 -0
  26. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  27. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +17 -242
  28. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  29. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +140 -95
  30. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  31. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +48 -40
  32. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  33. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +71 -146
  34. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  35. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +45 -16
  36. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
  37. package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +33 -108
  38. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  39. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +59 -79
  40. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  41. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +142 -40
  42. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  43. package/artifacts/contracts/instance/Instance.sol/Instance.json +73 -141
  44. package/artifacts/contracts/instance/InstanceAdminNew.sol/InstanceAdminNew.dbg.json +4 -0
  45. package/artifacts/contracts/instance/InstanceAdminNew.sol/InstanceAdminNew.json +1616 -0
  46. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +4 -0
  47. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +601 -0
  48. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  49. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +110 -76
  50. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  51. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +205 -103
  52. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  53. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +32 -32
  54. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  55. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +73 -123
  56. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  57. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +2 -2
  58. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  59. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.json +0 -53
  60. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  61. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  62. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.dbg.json +1 -1
  63. package/artifacts/contracts/instance/base/ObjectManager.sol/ObjectManager.json +3 -78
  64. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
  65. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  66. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  67. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  68. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  69. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  70. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  71. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +4 -0
  72. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +1155 -0
  73. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +4 -0
  74. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +418 -0
  75. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  76. package/artifacts/contracts/oracle/IOracle.sol/IOracle.json +43 -1
  77. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  78. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +13 -0
  79. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  80. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +13 -0
  81. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  82. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +13 -96
  83. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  84. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +66 -29
  85. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  86. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +27 -15
  87. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +4 -0
  88. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +1477 -0
  89. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +4 -0
  90. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +410 -0
  91. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  92. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +78 -49
  93. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  94. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +33 -25
  95. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  96. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +13 -0
  97. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  98. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +7 -202
  99. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  100. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +13 -0
  101. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  102. package/artifacts/contracts/pool/Pool.sol/Pool.json +7 -303
  103. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  104. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +62 -41
  105. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  106. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +25 -21
  107. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  108. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +66 -37
  109. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  110. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +27 -19
  111. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +4 -0
  112. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +1299 -0
  113. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +4 -0
  114. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +410 -0
  115. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  116. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +106 -69
  117. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  118. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +47 -35
  119. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  120. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +13 -0
  121. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  122. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +13 -0
  123. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  124. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +13 -0
  125. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  126. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +13 -0
  127. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  128. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +13 -42
  129. package/artifacts/contracts/product/IProductService.sol/IProductService.dbg.json +1 -1
  130. package/artifacts/contracts/product/IProductService.sol/IProductService.json +13 -0
  131. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  132. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +84 -47
  133. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  134. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +36 -24
  135. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  136. package/artifacts/contracts/product/PricingService.sol/PricingService.json +92 -63
  137. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  138. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +40 -32
  139. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  140. package/artifacts/contracts/product/Product.sol/Product.json +13 -153
  141. package/artifacts/contracts/product/ProductService.sol/ProductService.dbg.json +1 -1
  142. package/artifacts/contracts/product/ProductService.sol/ProductService.json +54 -25
  143. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
  144. package/artifacts/contracts/product/ProductServiceManager.sol/ProductServiceManager.json +21 -13
  145. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  146. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  147. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +0 -44
  148. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  149. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +13 -0
  150. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  151. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  152. package/artifacts/contracts/registry/Registry.sol/Registry.json +20 -64
  153. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  154. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +1487 -153
  155. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  156. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +51 -14
  157. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  158. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +20 -8
  159. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
  160. package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +93 -245
  161. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +4 -0
  162. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +195 -0
  163. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  164. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +2 -2
  165. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  166. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  167. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +82 -85
  168. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  169. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +35 -43
  170. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +1 -1
  171. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +13 -0
  172. package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
  173. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  174. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  175. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +13 -0
  176. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  177. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +13 -0
  178. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
  179. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  180. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  181. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  182. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  183. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  184. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  185. package/artifacts/contracts/shared/IService.sol/IService.json +13 -0
  186. package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
  187. package/artifacts/contracts/shared/InitializableCustom.sol/InitializableCustom.dbg.json +1 -1
  188. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  189. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +13 -53
  190. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
  191. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +2 -2
  192. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  193. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.json +2 -2
  194. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.dbg.json +1 -1
  195. package/artifacts/contracts/shared/NftIdSetManager.sol/NftIdSetManager.json +2 -2
  196. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  197. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +2 -2
  198. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  199. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  200. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  201. package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +2 -2
  202. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  203. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +2 -2
  204. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  205. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  206. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  207. package/artifacts/contracts/shared/Service.sol/Service.json +13 -0
  208. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  209. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
  210. package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  211. package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
  212. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  213. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  214. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +49 -7
  215. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +1 -1
  216. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +44 -28
  217. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  218. package/artifacts/contracts/staking/Staking.sol/Staking.json +44 -84
  219. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  220. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +23 -39
  221. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  222. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +6 -6
  223. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  224. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +92 -73
  225. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  226. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +33 -41
  227. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  228. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +186 -114
  229. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  230. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +18 -18
  231. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  232. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  233. package/artifacts/contracts/type/Amount.sol/AmountLib.json +2 -2
  234. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  235. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  236. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
  237. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  238. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
  239. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  240. package/artifacts/contracts/type/Fee.sol/FeeLib.json +2 -2
  241. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  242. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  243. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  244. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +2 -2
  245. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  246. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  247. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  248. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +136 -2
  249. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  250. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
  251. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  252. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +4 -4
  253. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  254. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
  255. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  256. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +2 -2
  257. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  258. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +219 -6
  259. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  260. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +4 -0
  261. package/artifacts/contracts/type/Selector.sol/SelectorLib.json +129 -0
  262. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +4 -0
  263. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +10 -0
  264. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  265. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +4 -0
  266. package/artifacts/contracts/type/String.sol/StrLib.json +132 -0
  267. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  268. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +1 -1
  269. package/artifacts/contracts/type/UFixed.sol/MathLib.json +2 -2
  270. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  271. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +21 -2
  272. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  273. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  274. package/contracts/authorization/AccessAdmin.sol +593 -0
  275. package/contracts/authorization/Authorization.sol +218 -0
  276. package/contracts/authorization/IAccess.sol +48 -0
  277. package/contracts/authorization/IAccessAdmin.sol +136 -0
  278. package/contracts/authorization/IAuthorization.sol +54 -0
  279. package/contracts/authorization/IModuleAuthorization.sol +21 -0
  280. package/contracts/authorization/IServiceAuthorization.sol +35 -0
  281. package/contracts/authorization/InstanceAdmin.sol +108 -0
  282. package/contracts/authorization/ModuleAuthorization.sol +78 -0
  283. package/contracts/authorization/ServiceAuthorization.sol +86 -0
  284. package/contracts/distribution/BasicDistribution.sol +149 -0
  285. package/contracts/distribution/BasicDistributionAuthorization.sol +43 -0
  286. package/contracts/distribution/Distribution.sol +126 -104
  287. package/contracts/distribution/DistributionService.sol +13 -9
  288. package/contracts/distribution/IDistributionComponent.sol +17 -35
  289. package/contracts/distribution/IDistributionService.sol +5 -1
  290. package/contracts/instance/IInstance.sol +13 -9
  291. package/contracts/instance/IInstanceService.sol +28 -18
  292. package/contracts/instance/Instance.sol +106 -88
  293. package/contracts/instance/InstanceAdminNew.sol +261 -0
  294. package/contracts/instance/InstanceAuthorizationV3.sol +209 -0
  295. package/contracts/instance/InstanceReader.sol +24 -9
  296. package/contracts/instance/InstanceService.sol +143 -75
  297. package/contracts/instance/InstanceStore.sol +9 -17
  298. package/contracts/instance/base/BalanceStore.sol +11 -6
  299. package/contracts/instance/base/Cloneable.sol +2 -25
  300. package/contracts/instance/base/ObjectManager.sol +7 -10
  301. package/contracts/oracle/BasicOracle.sol +48 -0
  302. package/contracts/oracle/BasicOracleAuthorization.sol +46 -0
  303. package/contracts/oracle/IOracle.sol +16 -0
  304. package/contracts/oracle/Oracle.sol +61 -49
  305. package/contracts/oracle/OracleService.sol +5 -4
  306. package/contracts/pool/BasicPool.sol +164 -0
  307. package/contracts/pool/BasicPoolAuthorization.sol +49 -0
  308. package/contracts/pool/BundleService.sol +19 -19
  309. package/contracts/pool/IPoolComponent.sol +0 -60
  310. package/contracts/pool/Pool.sol +143 -131
  311. package/contracts/pool/PoolService.sol +7 -8
  312. package/contracts/product/ApplicationService.sol +5 -5
  313. package/contracts/product/BasicProduct.sol +82 -0
  314. package/contracts/product/BasicProductAuthorization.sol +40 -0
  315. package/contracts/product/ClaimService.sol +5 -5
  316. package/contracts/product/IProductComponent.sol +6 -9
  317. package/contracts/product/PolicyService.sol +5 -5
  318. package/contracts/product/PricingService.sol +4 -5
  319. package/contracts/product/Product.sol +103 -88
  320. package/contracts/product/ProductService.sol +5 -5
  321. package/contracts/registry/IRegistry.sol +5 -8
  322. package/contracts/registry/Registry.sol +6 -4
  323. package/contracts/registry/RegistryAdmin.sol +273 -147
  324. package/contracts/registry/RegistryService.sol +5 -5
  325. package/contracts/registry/RegistryServiceManager.sol +0 -5
  326. package/contracts/registry/ReleaseManager.sol +102 -184
  327. package/contracts/registry/ServiceAuthorizationV3.sol +200 -0
  328. package/contracts/shared/ComponentService.sol +22 -61
  329. package/contracts/shared/ComponentVerifyingService.sol +1 -1
  330. package/contracts/shared/IInstanceLinkedComponent.sol +4 -0
  331. package/contracts/shared/IService.sol +7 -0
  332. package/contracts/shared/InstanceLinkedComponent.sol +26 -19
  333. package/contracts/shared/Service.sol +27 -21
  334. package/contracts/staking/IStakingService.sol +11 -7
  335. package/contracts/staking/StakeManagerLib.sol +52 -0
  336. package/contracts/staking/Staking.sol +58 -96
  337. package/contracts/staking/StakingService.sol +61 -56
  338. package/contracts/staking/StakingServiceManager.sol +0 -1
  339. package/contracts/staking/StakingStore.sol +79 -38
  340. package/contracts/type/ObjectType.sol +169 -62
  341. package/contracts/type/RoleId.sol +103 -75
  342. package/contracts/type/Selector.sol +102 -0
  343. package/contracts/type/String.sol +53 -0
  344. package/contracts/type/UFixed.sol +6 -0
  345. package/package.json +4 -1
  346. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +0 -4
  347. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +0 -708
  348. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.dbg.json +0 -4
  349. package/artifacts/contracts/instance/InstanceAuthorizationsLib.sol/InstanceAuthorizationsLib.json +0 -228
  350. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.dbg.json +0 -4
  351. package/artifacts/contracts/registry/ServiceAuthorizationsLib.sol/ServiceAuthorizationsLib.json +0 -137
  352. package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.dbg.json +0 -4
  353. package/artifacts/contracts/shared/AccessManagerCustom.sol/AccessManagerCustom.json +0 -1193
  354. package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.dbg.json +0 -4
  355. package/artifacts/contracts/shared/AccessManagerExtended.sol/AccessManagerExtended.json +0 -1715
  356. package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.dbg.json +0 -4
  357. package/artifacts/contracts/shared/AccessManagerExtendedInitializeable.sol/AccessManagerExtendedInitializeable.json +0 -1728
  358. package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.dbg.json +0 -4
  359. package/artifacts/contracts/shared/AccessManagerExtendedWithDisable.sol/AccessManagerExtendedWithDisable.json +0 -1806
  360. package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.dbg.json +0 -4
  361. package/artifacts/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol/AccessManagerExtendedWithDisableInitializeable.json +0 -1824
  362. package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.dbg.json +0 -4
  363. package/artifacts/contracts/shared/IAccessManagerExtended.sol/IAccessManagerExtended.json +0 -1562
  364. package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.dbg.json +0 -4
  365. package/artifacts/contracts/shared/IAccessManagerExtendedWithDisable.sol/IAccessManagerExtendedWithDisable.json +0 -1600
  366. package/contracts/instance/InstanceAdmin.sol +0 -331
  367. package/contracts/instance/InstanceAuthorizationsLib.sol +0 -377
  368. package/contracts/registry/ServiceAuthorizationsLib.sol +0 -173
  369. package/contracts/shared/AccessManagerCustom.sol +0 -736
  370. package/contracts/shared/AccessManagerExtended.sol +0 -470
  371. package/contracts/shared/AccessManagerExtendedInitializeable.sol +0 -13
  372. package/contracts/shared/AccessManagerExtendedWithDisable.sol +0 -137
  373. package/contracts/shared/AccessManagerExtendedWithDisableInitializeable.sol +0 -14
  374. package/contracts/shared/IAccessManagerExtended.sol +0 -74
  375. package/contracts/shared/IAccessManagerExtendedWithDisable.sol +0 -18
@@ -0,0 +1,593 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
5
+ import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
6
+ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
7
+
8
+ import {IAccessAdmin} from "./IAccessAdmin.sol";
9
+ import {RoleId, RoleIdLib, ADMIN_ROLE, PUBLIC_ROLE} from "../type/RoleId.sol";
10
+ import {Selector, SelectorLib, SelectorSetLib} from "../type/Selector.sol";
11
+ import {Str, StrLib} from "../type/String.sol";
12
+ import {Timestamp, TimestampLib} from "../type/Timestamp.sol";
13
+
14
+
15
+ /**
16
+ * @dev A generic access amin contract that implements role based access control based on OpenZeppelin's AccessManager contract.
17
+ * The contract provides read functions to query all available roles, targets and access rights.
18
+ * This contract works for both a constructor based deployment or a deployment based on cloning and initialization.
19
+ */
20
+ contract AccessAdmin is
21
+ AccessManagedUpgradeable,
22
+ IAccessAdmin
23
+ {
24
+ using EnumerableSet for EnumerableSet.AddressSet;
25
+
26
+ string public constant ADMIN_ROLE_NAME = "AdminRole";
27
+ string public constant PUBLIC_ROLE_NAME = "PublicRole";
28
+
29
+ /// @dev the OpenZeppelin access manager driving the access admin contract
30
+ AccessManager internal _authority;
31
+
32
+ /// @dev stores the deployer address and allows to create initializers
33
+ /// that are restricted to the deployer address.
34
+ address internal _deployer;
35
+
36
+ /// @dev store role info per role id
37
+ mapping(RoleId roleId => RoleInfo info) internal _roleInfo;
38
+
39
+ /// @dev store role name info per role name
40
+ mapping(Str roleName => RoleNameInfo nameInfo) internal _roleForName;
41
+
42
+ /// @dev store array with all created roles
43
+ RoleId [] internal _roleIds;
44
+
45
+ /// @dev store set of current role members for given role
46
+ mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
47
+
48
+ /// @dev store target info per target address
49
+ mapping(address target => TargetInfo info) internal _targetInfo;
50
+
51
+ /// @dev store role name info per role name
52
+ mapping(Str targetName => address target) internal _targetForName;
53
+
54
+ /// @dev store array with all created targets
55
+ address [] internal _targets;
56
+
57
+ /// @dev store all managed functions per target
58
+ mapping(address target => SelectorSetLib.Set selectors) internal _targetFunctions;
59
+
60
+ /// @dev function infos array
61
+ mapping(address target => mapping(Selector selector => FunctionInfo)) internal _functionInfo;
62
+
63
+ /// @dev temporary dynamic functions array
64
+ bytes4[] private _functions;
65
+
66
+ modifier onlyDeployer() {
67
+ // special case for cloned AccessAdmin contracts
68
+ // IMPORTANT cloning and _initializeAuthority needs to be done in a single transaction
69
+ if (_deployer == address(0)) {
70
+ _deployer = msg.sender;
71
+ }
72
+
73
+ if (msg.sender != _deployer) {
74
+ revert ErrorNotDeployer();
75
+ }
76
+ _;
77
+ }
78
+
79
+ modifier onlyRoleAdmin(RoleId roleId) {
80
+ if (!roleExists(roleId)) {
81
+ revert ErrorRoleUnknown(roleId);
82
+ }
83
+
84
+ if (!hasAdminRole(msg.sender, roleId)) {
85
+ revert ErrorNotAdminOfRole(_roleInfo[roleId].adminRoleId);
86
+ }
87
+ _;
88
+ }
89
+
90
+ modifier onlyRoleMember(RoleId roleId) {
91
+ if (!hasRole(msg.sender, roleId)) {
92
+ revert ErrorNotRoleOwner(roleId);
93
+ }
94
+ _;
95
+ }
96
+
97
+ modifier onlyExistingRole(RoleId roleId) {
98
+ _checkRoleId(roleId);
99
+ _;
100
+ }
101
+
102
+ modifier onlyExistingTarget(address target) {
103
+ _checkTarget(target);
104
+ _;
105
+ }
106
+
107
+ constructor() {
108
+ _deployer = msg.sender;
109
+ _authority = new AccessManager(address(this));
110
+
111
+ _setAuthority(address(_authority)); // set authority for oz access managed
112
+ _createAdminAndPublicRoles();
113
+ _disableInitializers();
114
+ }
115
+
116
+ //--- view functions for roles ------------------------------------------//
117
+
118
+ function roles() external view returns (uint256 numberOfRoles) {
119
+ return _roleIds.length;
120
+ }
121
+
122
+ function getRoleId(uint256 idx) external view returns (RoleId roleId) {
123
+ return _roleIds[idx];
124
+ }
125
+
126
+ function getAdminRole() public view returns (RoleId roleId) {
127
+ return RoleId.wrap(_authority.ADMIN_ROLE());
128
+ }
129
+
130
+ function getPublicRole() public view returns (RoleId roleId) {
131
+ return RoleId.wrap(_authority.PUBLIC_ROLE());
132
+ }
133
+
134
+ function roleExists(RoleId roleId) public view returns (bool exists) {
135
+ return _roleInfo[roleId].createdAt.gtz();
136
+ }
137
+
138
+ function getRoleInfo(RoleId roleId) external view returns (RoleInfo memory) {
139
+ return _roleInfo[roleId];
140
+ }
141
+
142
+ function getRoleForName(Str name) external view returns (RoleNameInfo memory) {
143
+ return _roleForName[name];
144
+ }
145
+
146
+ function roleMembers(RoleId roleId) external view returns (uint256 numberOfMembers) {
147
+ return _roleMembers[roleId].length();
148
+ }
149
+
150
+ function getRoleMember(RoleId roleId, uint256 idx) external view returns (address account) {
151
+ return _roleMembers[roleId].at(idx);
152
+ }
153
+
154
+ function hasRole(address account, RoleId roleId) public view returns (bool) {
155
+ (bool isMember, ) = _authority.hasRole(
156
+ RoleId.unwrap(roleId),
157
+ account);
158
+ return isMember;
159
+ }
160
+
161
+ function hasAdminRole(address account, RoleId roleId)
162
+ public
163
+ virtual
164
+ view
165
+ returns (bool)
166
+ {
167
+ return hasRole(account, _roleInfo[roleId].adminRoleId);
168
+ }
169
+
170
+ //--- view functions for targets ----------------------------------------//
171
+
172
+ function targetExists(address target) public view returns (bool exists) {
173
+ return _targetInfo[target].createdAt.gtz();
174
+ }
175
+
176
+ function targets() external view returns (uint256 numberOfTargets) {
177
+ return _targets.length;
178
+ }
179
+
180
+ function getTargetAddress(uint256 idx) external view returns (address target) {
181
+ return _targets[idx];
182
+ }
183
+
184
+ function getTargetInfo(address target) external view returns (TargetInfo memory targetInfo) {
185
+ return _targetInfo[target];
186
+ }
187
+
188
+ function getTargetForName(Str name) public view returns (address target) {
189
+ return _targetForName[name];
190
+ }
191
+
192
+ function isTargetLocked(address target) public view returns (bool locked) {
193
+ return _authority.isTargetClosed(target);
194
+ }
195
+
196
+ function authorizedFunctions(address target) external view returns (uint256 numberOfFunctions) {
197
+ return SelectorSetLib.size(_targetFunctions[target]);
198
+ }
199
+
200
+ function getAuthorizedFunction(
201
+ address target,
202
+ uint256 idx
203
+ )
204
+ external
205
+ view
206
+ returns (
207
+ FunctionInfo memory func,
208
+ RoleId roleId
209
+ )
210
+ {
211
+ Selector selector = SelectorSetLib.at(_targetFunctions[target], idx);
212
+ func = _functionInfo[target][selector];
213
+ roleId = RoleIdLib.toRoleId(
214
+ _authority.getTargetFunctionRole(
215
+ target,
216
+ selector.toBytes4()));
217
+ }
218
+
219
+ function isAccessManaged(address target) public view returns (bool) {
220
+ if (!_isContract(target)) {
221
+ return false;
222
+ }
223
+
224
+ (bool success, ) = target.staticcall(
225
+ abi.encodeWithSelector(
226
+ AccessManagedUpgradeable.authority.selector));
227
+
228
+ return success;
229
+ }
230
+
231
+ function canCall(address caller, address target, Selector selector) external virtual view returns (bool can) {
232
+ (can, ) = _authority.canCall(caller, target, selector.toBytes4());
233
+ }
234
+
235
+ function toRole(RoleId adminRoleId, RoleType roleType, uint32 maxMemberCount, string memory name) public view returns (RoleInfo memory) {
236
+ return RoleInfo({
237
+ name: StrLib.toStr(name),
238
+ adminRoleId: adminRoleId,
239
+ roleType: roleType,
240
+ maxMemberCount: maxMemberCount,
241
+ createdAt: TimestampLib.blockTimestamp()
242
+ });
243
+ }
244
+
245
+ function toFunction(bytes4 selector, string memory name) public view returns (FunctionInfo memory) {
246
+ return FunctionInfo({
247
+ name: StrLib.toStr(name),
248
+ selector: SelectorLib.toSelector(selector),
249
+ createdAt: TimestampLib.blockTimestamp()});
250
+ }
251
+
252
+ function deployer() public view returns (address) {
253
+ return _deployer;
254
+ }
255
+
256
+ //--- internal/private functions -------------------------------------------------//
257
+
258
+ function _authorizeTargetFunctions(
259
+ address target,
260
+ RoleId roleId,
261
+ FunctionInfo[] memory functions
262
+ )
263
+ internal
264
+ {
265
+ if (roleId == getAdminRole()) {
266
+ revert ErrorAuthorizeForAdminRoleInvalid(target);
267
+ }
268
+
269
+ bool addFunctions = true;
270
+ bytes4[] memory functionSelectors = _processFunctionSelectors(target, functions, addFunctions);
271
+
272
+ // apply authz via access manager
273
+ _grantRoleAccessToFunctions(target, roleId, functionSelectors);
274
+ }
275
+
276
+ function _unauthorizeTargetFunctions(
277
+ address target,
278
+ FunctionInfo[] memory functions
279
+ )
280
+ internal
281
+ {
282
+ bool addFunctions = false;
283
+ bytes4[] memory functionSelectors = _processFunctionSelectors(target, functions, addFunctions);
284
+ _grantRoleAccessToFunctions(target, getAdminRole(), functionSelectors);
285
+ }
286
+
287
+ function _processFunctionSelectors(
288
+ address target,
289
+ FunctionInfo[] memory functions,
290
+ bool addFunctions
291
+ )
292
+ internal
293
+ returns (
294
+ bytes4[] memory functionSelectors
295
+ )
296
+ {
297
+ uint256 n = functions.length;
298
+ functionSelectors = new bytes4[](n);
299
+ FunctionInfo memory func;
300
+ Selector selector;
301
+
302
+ for (uint256 i = 0; i < n; i++) {
303
+ func = functions[i];
304
+ selector = func.selector;
305
+
306
+ // add function selector to target selector set if not in set
307
+ if (addFunctions) { SelectorSetLib.add(_targetFunctions[target], selector); }
308
+ else { SelectorSetLib.remove(_targetFunctions[target], selector); }
309
+
310
+ // set function name
311
+ _functionInfo[target][selector] = func;
312
+
313
+ // add bytes4 selector to function selector array
314
+ functionSelectors[i] = selector.toBytes4();
315
+ }
316
+ }
317
+
318
+ function _initializeAuthority(
319
+ address authorityAddress
320
+ )
321
+ internal
322
+ virtual
323
+ onlyInitializing()
324
+ onlyDeployer()
325
+ {
326
+ if (authority() != address(0)) {
327
+ revert ErrorAuthorityAlreadySet();
328
+ }
329
+
330
+ _authority = AccessManager(authorityAddress);
331
+
332
+ // TODO check if we really need this
333
+ // if(!hasRole(address(this), RoleId.wrap(_authority.ADMIN_ROLE()))) {
334
+ // revert ErrorAdminRoleMissing();
335
+ // }
336
+
337
+ __AccessManaged_init(address(_authority));
338
+ }
339
+
340
+
341
+ function _initializeAdminAndPublicRoles()
342
+ internal
343
+ virtual
344
+ onlyInitializing()
345
+ {
346
+ _createAdminAndPublicRoles();
347
+ }
348
+
349
+
350
+ /// @dev internal setup function that can be used in both constructor and initializer.
351
+ function _createAdminAndPublicRoles()
352
+ internal
353
+ {
354
+ RoleId adminRoleId = RoleIdLib.toRoleId(_authority.ADMIN_ROLE());
355
+ FunctionInfo[] memory functions;
356
+
357
+ // setup admin role
358
+ _createRoleUnchecked(
359
+ ADMIN_ROLE(),
360
+ toRole({
361
+ adminRoleId: ADMIN_ROLE(),
362
+ roleType: RoleType.Contract,
363
+ maxMemberCount: 1,
364
+ name: ADMIN_ROLE_NAME}));
365
+
366
+ // add this contract as admin role member
367
+ _roleMembers[adminRoleId].add(address(this));
368
+
369
+ // setup public role
370
+ _createRoleUnchecked(
371
+ PUBLIC_ROLE(),
372
+ toRole({
373
+ adminRoleId: ADMIN_ROLE(),
374
+ roleType: RoleType.Gif,
375
+ maxMemberCount: type(uint32).max,
376
+ name: PUBLIC_ROLE_NAME}));
377
+ }
378
+
379
+ /// @dev check if target exists and reverts if it doesn't
380
+ function _checkTarget(address target)
381
+ internal
382
+ {
383
+ if (_targetInfo[target].createdAt.eqz()) {
384
+ revert ErrorTargetUnknown(target);
385
+ }
386
+ }
387
+
388
+ /// @dev grant the specified role access to all functions in the provided selector list
389
+ function _grantRoleAccessToFunctions(
390
+ address target,
391
+ RoleId roleId,
392
+ bytes4[] memory functionSelectors
393
+ )
394
+ internal
395
+ {
396
+ _authority.setTargetFunctionRole(
397
+ target,
398
+ functionSelectors,
399
+ RoleId.unwrap(roleId));
400
+
401
+ // implizit logging: rely on OpenZeppelin log TargetFunctionRoleUpdated
402
+ }
403
+
404
+ /// @dev grant the specified role to the provided account
405
+ function _grantRoleToAccount(RoleId roleId, address account)
406
+ internal
407
+ {
408
+ _checkRoleId(roleId);
409
+
410
+ // check max role members will not be exceeded
411
+ if (_roleMembers[roleId].length() >= _roleInfo[roleId].maxMemberCount) {
412
+ revert ErrorRoleMembersLimitReached(roleId, _roleInfo[roleId].maxMemberCount);
413
+ }
414
+
415
+ // check account is contract for contract role
416
+ // TODO implement
417
+ if (_roleInfo[roleId].roleType == RoleType.Contract) {
418
+ }
419
+
420
+ _roleMembers[roleId].add(account);
421
+ _authority.grantRole(
422
+ RoleId.unwrap(roleId),
423
+ account,
424
+ 0);
425
+
426
+ // indirect logging: rely on OpenZeppelin log RoleGranted
427
+ }
428
+
429
+ /// @dev revoke the specified role from the provided account
430
+ function _revokeRoleFromAccount(RoleId roleId, address account)
431
+ internal
432
+ {
433
+ _checkRoleId(roleId);
434
+
435
+ // check role removal is permitted
436
+ if (_roleInfo[roleId].roleType == RoleType.Contract) {
437
+ revert ErrorRoleRemovalDisabled(roleId);
438
+ }
439
+
440
+ _roleMembers[roleId].remove(account);
441
+ _authority.revokeRole(
442
+ RoleId.unwrap(roleId),
443
+ account);
444
+
445
+ // indirect logging: rely on OpenZeppelin log RoleGranted
446
+ }
447
+
448
+
449
+ function _checkRoleId(RoleId roleId)
450
+ internal
451
+ {
452
+ if (_roleInfo[roleId].createdAt.eqz()) {
453
+ revert ErrorRoleUnknown(roleId);
454
+ }
455
+
456
+ uint64 roleIdInt = RoleId.unwrap(roleId);
457
+ if (roleIdInt == _authority.ADMIN_ROLE()
458
+ || roleIdInt == _authority.PUBLIC_ROLE())
459
+ {
460
+ revert ErrorRoleIsLocked(roleId);
461
+ }
462
+ }
463
+
464
+ /// @dev Creates a role based on the provided parameters.
465
+ /// Checks that the provided role and role id and role name not already used.
466
+ function _createRole(
467
+ RoleId roleId,
468
+ RoleInfo memory info
469
+ )
470
+ internal
471
+ {
472
+ // check role does not yet exist
473
+ if(roleExists(roleId)) {
474
+ revert ErrorRoleAlreadyCreated(
475
+ roleId,
476
+ _roleInfo[roleId].name.toString());
477
+ }
478
+
479
+ // check admin role exists
480
+ if(!roleExists(info.adminRoleId)) {
481
+ revert ErrorRoleAdminNotExisting(info.adminRoleId);
482
+ }
483
+
484
+ // check role name is not empty
485
+ if(info.name.length() == 0) {
486
+ revert ErrorRoleNameEmpty(roleId);
487
+ }
488
+
489
+ // check role name is not used for another role
490
+ if(_roleForName[info.name].exists) {
491
+ revert ErrorRoleNameAlreadyExists(
492
+ roleId,
493
+ info.name.toString(),
494
+ _roleForName[info.name].roleId);
495
+ }
496
+
497
+ _createRoleUnchecked(roleId, info);
498
+ }
499
+
500
+
501
+ function _createRoleUnchecked(
502
+ RoleId roleId,
503
+ RoleInfo memory info
504
+ )
505
+ private
506
+ {
507
+ // create role info
508
+ info.createdAt = TimestampLib.blockTimestamp();
509
+ _roleInfo[roleId] = info;
510
+
511
+ // create role name info
512
+ _roleForName[info.name] = RoleNameInfo({
513
+ roleId: roleId,
514
+ exists: true});
515
+
516
+ // add role to list of roles
517
+ _roleIds.push(roleId);
518
+
519
+ emit LogRoleCreated(roleId, info.roleType, info.adminRoleId, info.name.toString());
520
+ }
521
+
522
+
523
+ function _createTarget(
524
+ address target,
525
+ string memory targetName,
526
+ bool checkAuthority,
527
+ bool custom
528
+ )
529
+ internal
530
+ {
531
+ // check target does not yet exist
532
+ if(targetExists(target)) {
533
+ revert ErrorTargetAlreadyCreated(
534
+ target,
535
+ _targetInfo[target].name.toString());
536
+ }
537
+
538
+ // check target name is not empty
539
+ Str name = StrLib.toStr(targetName);
540
+ if(name.length() == 0) {
541
+ revert ErrorTargetNameEmpty(target);
542
+ }
543
+
544
+ // check target name is not used for another target
545
+ if( _targetForName[name] != address(0)) {
546
+ revert ErrorTargetNameAlreadyExists(
547
+ target,
548
+ targetName,
549
+ _targetForName[name]);
550
+ }
551
+
552
+ // check target is an access managed contract
553
+ if (!isAccessManaged(target)) {
554
+ revert ErrorTargetNotAccessManaged(target);
555
+ }
556
+
557
+ // check target shares authority with this contract
558
+ if (checkAuthority) {
559
+ address targetAuthority = AccessManagedUpgradeable(target).authority();
560
+ if (targetAuthority != authority()) {
561
+ revert ErrorTargetAuthorityMismatch(authority(), targetAuthority);
562
+ }
563
+ }
564
+
565
+ // create target info
566
+ _targetInfo[target] = TargetInfo({
567
+ name: name,
568
+ isCustom: custom,
569
+ createdAt: TimestampLib.blockTimestamp()
570
+ });
571
+
572
+ // create name to target mapping
573
+ _targetForName[name] = target;
574
+
575
+ // add role to list of roles
576
+ _targets.push(target);
577
+
578
+ emit LogTargetCreated(target, targetName);
579
+ }
580
+
581
+ function _isContract(address target)
582
+ internal
583
+ view
584
+ returns (bool)
585
+ {
586
+ uint256 size;
587
+ assembly {
588
+ size := extcodesize(target)
589
+ }
590
+ return size > 0;
591
+ }
592
+
593
+ }