@etherisc/gif-next 0.0.2-f12cf4d-104 → 0.0.2-f13d67f-541

Sign up to get free protection for your applications and to get access to all the features.
Files changed (555) hide show
  1. package/README.md +86 -312
  2. package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.dbg.json +4 -0
  3. package/artifacts/contracts/accounting/AccountingService.sol/AccountingService.json +1075 -0
  4. package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.dbg.json +4 -0
  5. package/artifacts/contracts/accounting/AccountingServiceManager.sol/AccountingServiceManager.json +810 -0
  6. package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.dbg.json +4 -0
  7. package/artifacts/contracts/accounting/IAccountingService.sol/IAccountingService.json +843 -0
  8. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.dbg.json +1 -1
  9. package/artifacts/contracts/authorization/AccessAdmin.sol/AccessAdmin.json +729 -287
  10. package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.dbg.json +4 -0
  11. package/artifacts/contracts/authorization/AccessAdminLib.sol/AccessAdminLib.json +2008 -0
  12. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.dbg.json +1 -1
  13. package/artifacts/contracts/authorization/AccessManagerCloneable.sol/AccessManagerCloneable.json +202 -5
  14. package/artifacts/contracts/authorization/Authorization.sol/Authorization.dbg.json +1 -1
  15. package/artifacts/contracts/authorization/Authorization.sol/Authorization.json +438 -35
  16. package/artifacts/contracts/authorization/IAccess.sol/IAccess.dbg.json +1 -1
  17. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.dbg.json +1 -1
  18. package/artifacts/contracts/authorization/IAccessAdmin.sol/IAccessAdmin.json +560 -220
  19. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.dbg.json +1 -1
  20. package/artifacts/contracts/authorization/IAuthorization.sol/IAuthorization.json +191 -21
  21. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.dbg.json +1 -1
  22. package/artifacts/contracts/authorization/IServiceAuthorization.sol/IServiceAuthorization.json +256 -16
  23. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.dbg.json +1 -1
  24. package/artifacts/contracts/authorization/ServiceAuthorization.sol/ServiceAuthorization.json +426 -27
  25. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.dbg.json +1 -1
  26. package/artifacts/contracts/distribution/BasicDistribution.sol/BasicDistribution.json +128 -218
  27. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.dbg.json +1 -1
  28. package/artifacts/contracts/distribution/BasicDistributionAuthorization.sol/BasicDistributionAuthorization.json +427 -53
  29. package/artifacts/contracts/distribution/Distribution.sol/Distribution.dbg.json +1 -1
  30. package/artifacts/contracts/distribution/Distribution.sol/Distribution.json +58 -137
  31. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.dbg.json +1 -1
  32. package/artifacts/contracts/distribution/DistributionService.sol/DistributionService.json +555 -217
  33. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
  34. package/artifacts/contracts/distribution/DistributionServiceManager.sol/DistributionServiceManager.json +170 -82
  35. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
  36. package/artifacts/contracts/distribution/IDistributionComponent.sol/IDistributionComponent.json +37 -116
  37. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.dbg.json +1 -1
  38. package/artifacts/contracts/distribution/IDistributionService.sol/IDistributionService.json +401 -78
  39. package/artifacts/contracts/examples/fire/DamageLevel.sol/DamageLevelLib.dbg.json +1 -1
  40. package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.dbg.json +1 -1
  41. package/artifacts/contracts/examples/fire/FirePool.sol/FirePool.json +183 -138
  42. package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.dbg.json +1 -1
  43. package/artifacts/contracts/examples/fire/FirePoolAuthorization.sol/FirePoolAuthorization.json +401 -59
  44. package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.dbg.json +1 -1
  45. package/artifacts/contracts/examples/fire/FireProduct.sol/FireProduct.json +324 -260
  46. package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.dbg.json +1 -1
  47. package/artifacts/contracts/examples/fire/FireProductAuthorization.sol/FireProductAuthorization.json +426 -52
  48. package/artifacts/contracts/examples/fire/FireUSD.sol/FireUSD.dbg.json +1 -1
  49. package/artifacts/contracts/examples/flight/FlightLib.sol/FlightLib.dbg.json +4 -0
  50. package/artifacts/contracts/examples/flight/FlightLib.sol/FlightLib.json +408 -0
  51. package/artifacts/contracts/examples/flight/FlightOracle.sol/FlightOracle.dbg.json +4 -0
  52. package/artifacts/contracts/examples/flight/FlightOracle.sol/FlightOracle.json +1198 -0
  53. package/artifacts/contracts/examples/flight/FlightOracleAuthorization.sol/FlightOracleAuthorization.dbg.json +4 -0
  54. package/artifacts/contracts/examples/flight/FlightOracleAuthorization.sol/FlightOracleAuthorization.json +849 -0
  55. package/artifacts/contracts/examples/flight/FlightPool.sol/FlightPool.dbg.json +4 -0
  56. package/artifacts/contracts/examples/flight/FlightPool.sol/FlightPool.json +1466 -0
  57. package/artifacts/contracts/examples/flight/FlightPoolAuthorization.sol/FlightPoolAuthorization.dbg.json +4 -0
  58. package/artifacts/contracts/examples/flight/FlightPoolAuthorization.sol/FlightPoolAuthorization.json +844 -0
  59. package/artifacts/contracts/examples/flight/FlightProduct.sol/FlightProduct.dbg.json +4 -0
  60. package/artifacts/contracts/examples/flight/FlightProduct.sol/FlightProduct.json +2185 -0
  61. package/artifacts/contracts/examples/flight/FlightProductAuthorization.sol/FlightProductAuthorization.dbg.json +4 -0
  62. package/artifacts/contracts/examples/flight/FlightProductAuthorization.sol/FlightProductAuthorization.json +844 -0
  63. package/artifacts/contracts/examples/flight/FlightUSD.sol/FlightUSD.dbg.json +4 -0
  64. package/artifacts/contracts/examples/flight/FlightUSD.sol/FlightUSD.json +376 -0
  65. package/artifacts/contracts/examples/flight/originalV1.sol/FlightDelayChainlink.dbg.json +4 -0
  66. package/artifacts/contracts/examples/flight/originalV1.sol/FlightDelayChainlink.json +901 -0
  67. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.dbg.json +1 -1
  68. package/artifacts/contracts/examples/unpermissioned/SimpleDistribution.sol/SimpleDistribution.json +214 -215
  69. package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.dbg.json +4 -0
  70. package/artifacts/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol/SimpleDistributionAuthorization.json +844 -0
  71. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.dbg.json +1 -1
  72. package/artifacts/contracts/examples/unpermissioned/SimpleOracle.sol/SimpleOracle.json +94 -110
  73. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.dbg.json +1 -1
  74. package/artifacts/contracts/examples/unpermissioned/SimplePool.sol/SimplePool.json +196 -165
  75. package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.dbg.json +4 -0
  76. package/artifacts/contracts/examples/unpermissioned/SimplePoolAuthorization.sol/SimplePoolAuthorization.json +844 -0
  77. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.dbg.json +1 -1
  78. package/artifacts/contracts/examples/unpermissioned/SimpleProduct.sol/SimpleProduct.json +600 -306
  79. package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.dbg.json +4 -0
  80. package/artifacts/contracts/examples/unpermissioned/SimpleProductAuthorization.sol/SimpleProductAuthorization.json +844 -0
  81. package/artifacts/contracts/instance/BaseStore.sol/BaseStore.dbg.json +4 -0
  82. package/artifacts/contracts/{shared/IKeyValueStore.sol/IKeyValueStore.json → instance/BaseStore.sol/BaseStore.json} +51 -229
  83. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.dbg.json +1 -1
  84. package/artifacts/contracts/instance/BundleSet.sol/BundleSet.json +193 -45
  85. package/artifacts/contracts/instance/IBaseStore.sol/IBaseStore.dbg.json +4 -0
  86. package/artifacts/contracts/instance/IBaseStore.sol/IBaseStore.json +304 -0
  87. package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
  88. package/artifacts/contracts/instance/IInstance.sol/IInstance.json +551 -50
  89. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
  90. package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +415 -15
  91. package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
  92. package/artifacts/contracts/instance/Instance.sol/Instance.json +606 -112
  93. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.dbg.json +1 -1
  94. package/artifacts/contracts/instance/InstanceAdmin.sol/InstanceAdmin.json +1121 -374
  95. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.dbg.json +1 -1
  96. package/artifacts/contracts/instance/InstanceAuthorizationV3.sol/InstanceAuthorizationV3.json +379 -68
  97. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
  98. package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1136 -561
  99. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
  100. package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +419 -82
  101. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
  102. package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +100 -54
  103. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.dbg.json +1 -1
  104. package/artifacts/contracts/instance/InstanceStore.sol/InstanceStore.json +1283 -1912
  105. package/artifacts/contracts/instance/ProductStore.sol/ProductStore.dbg.json +4 -0
  106. package/artifacts/contracts/instance/ProductStore.sol/ProductStore.json +3427 -0
  107. package/artifacts/contracts/instance/RiskSet.sol/RiskSet.dbg.json +4 -0
  108. package/artifacts/contracts/instance/RiskSet.sol/RiskSet.json +866 -0
  109. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.dbg.json +1 -1
  110. package/artifacts/contracts/instance/base/BalanceStore.sol/BalanceStore.json +8 -8
  111. package/artifacts/contracts/instance/base/Cloneable.sol/Cloneable.dbg.json +1 -1
  112. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.dbg.json +1 -1
  113. package/artifacts/contracts/instance/base/ObjectCounter.sol/ObjectCounter.json +2 -2
  114. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.dbg.json +1 -1
  115. package/artifacts/contracts/instance/base/ObjectLifecycle.sol/ObjectLifecycle.json +2 -2
  116. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.dbg.json +1 -1
  117. package/artifacts/contracts/instance/base/ObjectSet.sol/ObjectSet.json +16 -5
  118. package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.dbg.json +4 -0
  119. package/artifacts/contracts/instance/base/ObjectSetHelperLib.sol/ObjectSetHelperLib.json +168 -0
  120. package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
  121. package/artifacts/contracts/instance/module/IComponents.sol/IComponents.dbg.json +1 -1
  122. package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
  123. package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
  124. package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
  125. package/artifacts/contracts/mock/Dip.sol/Dip.dbg.json +1 -1
  126. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.dbg.json +1 -1
  127. package/artifacts/contracts/oracle/BasicOracle.sol/BasicOracle.json +77 -91
  128. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.dbg.json +1 -1
  129. package/artifacts/contracts/oracle/BasicOracleAuthorization.sol/BasicOracleAuthorization.json +425 -54
  130. package/artifacts/contracts/oracle/IOracle.sol/IOracle.dbg.json +1 -1
  131. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.dbg.json +1 -1
  132. package/artifacts/contracts/oracle/IOracleComponent.sol/IOracleComponent.json +41 -55
  133. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.dbg.json +1 -1
  134. package/artifacts/contracts/oracle/IOracleService.sol/IOracleService.json +56 -3
  135. package/artifacts/contracts/oracle/Oracle.sol/Oracle.dbg.json +1 -1
  136. package/artifacts/contracts/oracle/Oracle.sol/Oracle.json +61 -75
  137. package/artifacts/contracts/oracle/OracleService.sol/OracleService.dbg.json +1 -1
  138. package/artifacts/contracts/oracle/OracleService.sol/OracleService.json +141 -81
  139. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.dbg.json +1 -1
  140. package/artifacts/contracts/oracle/OracleServiceManager.sol/OracleServiceManager.json +134 -50
  141. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.dbg.json +1 -1
  142. package/artifacts/contracts/pool/BasicPool.sol/BasicPool.json +102 -124
  143. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.dbg.json +1 -1
  144. package/artifacts/contracts/pool/BasicPoolAuthorization.sol/BasicPoolAuthorization.json +401 -59
  145. package/artifacts/contracts/pool/BundleService.sol/BundleService.dbg.json +1 -1
  146. package/artifacts/contracts/pool/BundleService.sol/BundleService.json +298 -329
  147. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
  148. package/artifacts/contracts/pool/BundleServiceManager.sol/BundleServiceManager.json +133 -97
  149. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.dbg.json +1 -1
  150. package/artifacts/contracts/pool/IBundleService.sol/IBundleService.json +200 -131
  151. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
  152. package/artifacts/contracts/pool/IPoolComponent.sol/IPoolComponent.json +59 -73
  153. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.dbg.json +1 -1
  154. package/artifacts/contracts/pool/IPoolService.sol/IPoolService.json +333 -169
  155. package/artifacts/contracts/pool/Pool.sol/Pool.dbg.json +1 -1
  156. package/artifacts/contracts/pool/Pool.sol/Pool.json +72 -86
  157. package/artifacts/contracts/pool/PoolLib.sol/PoolLib.dbg.json +4 -0
  158. package/artifacts/contracts/pool/PoolLib.sol/PoolLib.json +522 -0
  159. package/artifacts/contracts/pool/PoolService.sol/PoolService.dbg.json +1 -1
  160. package/artifacts/contracts/pool/PoolService.sol/PoolService.json +565 -367
  161. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
  162. package/artifacts/contracts/pool/PoolServiceManager.sol/PoolServiceManager.json +169 -69
  163. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.dbg.json +1 -1
  164. package/artifacts/contracts/product/ApplicationService.sol/ApplicationService.json +313 -64
  165. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +1 -1
  166. package/artifacts/contracts/product/ApplicationServiceManager.sol/ApplicationServiceManager.json +123 -47
  167. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.dbg.json +1 -1
  168. package/artifacts/contracts/product/BasicProduct.sol/BasicProduct.json +193 -192
  169. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.dbg.json +1 -1
  170. package/artifacts/contracts/product/BasicProductAuthorization.sol/BasicProductAuthorization.json +426 -52
  171. package/artifacts/contracts/product/ClaimService.sol/ClaimService.dbg.json +1 -1
  172. package/artifacts/contracts/product/ClaimService.sol/ClaimService.json +292 -195
  173. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +1 -1
  174. package/artifacts/contracts/product/ClaimServiceManager.sol/ClaimServiceManager.json +142 -94
  175. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.dbg.json +1 -1
  176. package/artifacts/contracts/product/IApplicationService.sol/IApplicationService.json +268 -10
  177. package/artifacts/contracts/product/IClaimService.sol/IClaimService.dbg.json +1 -1
  178. package/artifacts/contracts/product/IClaimService.sol/IClaimService.json +181 -19
  179. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.dbg.json +1 -1
  180. package/artifacts/contracts/product/IPolicyService.sol/IPolicyService.json +160 -55
  181. package/artifacts/contracts/product/IPricingService.sol/IPricingService.dbg.json +1 -1
  182. package/artifacts/contracts/product/IPricingService.sol/IPricingService.json +77 -3
  183. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.dbg.json +1 -1
  184. package/artifacts/contracts/product/IProductComponent.sol/IProductComponent.json +168 -167
  185. package/artifacts/contracts/product/IRiskService.sol/IRiskService.dbg.json +1 -1
  186. package/artifacts/contracts/product/IRiskService.sol/IRiskService.json +258 -22
  187. package/artifacts/contracts/product/PolicyService.sol/PolicyService.dbg.json +1 -1
  188. package/artifacts/contracts/product/PolicyService.sol/PolicyService.json +283 -195
  189. package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.dbg.json +4 -0
  190. package/artifacts/contracts/product/PolicyServiceLib.sol/PolicyServiceLib.json +783 -0
  191. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
  192. package/artifacts/contracts/product/PolicyServiceManager.sol/PolicyServiceManager.json +153 -81
  193. package/artifacts/contracts/product/PricingService.sol/PricingService.dbg.json +1 -1
  194. package/artifacts/contracts/product/PricingService.sol/PricingService.json +135 -126
  195. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.dbg.json +1 -1
  196. package/artifacts/contracts/product/PricingServiceManager.sol/PricingServiceManager.json +118 -70
  197. package/artifacts/contracts/product/Product.sol/Product.dbg.json +1 -1
  198. package/artifacts/contracts/product/Product.sol/Product.json +187 -186
  199. package/artifacts/contracts/product/RiskService.sol/RiskService.dbg.json +1 -1
  200. package/artifacts/contracts/product/RiskService.sol/RiskService.json +326 -91
  201. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.dbg.json +1 -1
  202. package/artifacts/contracts/product/RiskServiceManager.sol/RiskServiceManager.json +123 -47
  203. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
  204. package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +2 -2
  205. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
  206. package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +54 -19
  207. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
  208. package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +56 -3
  209. package/artifacts/contracts/registry/IRelease.sol/IRelease.dbg.json +4 -0
  210. package/artifacts/contracts/registry/IRelease.sol/IRelease.json +24 -0
  211. package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
  212. package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
  213. package/artifacts/contracts/registry/Registry.sol/Registry.json +92 -57
  214. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.dbg.json +1 -1
  215. package/artifacts/contracts/registry/RegistryAdmin.sol/RegistryAdmin.json +845 -489
  216. package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.dbg.json +4 -0
  217. package/artifacts/contracts/registry/RegistryAuthorization.sol/RegistryAuthorization.json +1137 -0
  218. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
  219. package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +71 -35
  220. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
  221. package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +99 -43
  222. package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.dbg.json +4 -0
  223. package/artifacts/contracts/registry/ReleaseAdmin.sol/ReleaseAdmin.json +2271 -0
  224. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.dbg.json +1 -1
  225. package/artifacts/contracts/registry/ReleaseLifecycle.sol/ReleaseLifecycle.json +2 -2
  226. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.dbg.json +1 -1
  227. package/artifacts/contracts/registry/ReleaseRegistry.sol/ReleaseRegistry.json +398 -64
  228. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.dbg.json +1 -1
  229. package/artifacts/contracts/registry/ServiceAuthorizationV3.sol/ServiceAuthorizationV3.json +459 -26
  230. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
  231. package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +120 -60
  232. package/artifacts/contracts/shared/Component.sol/Component.dbg.json +1 -1
  233. package/artifacts/contracts/shared/Component.sol/Component.json +60 -60
  234. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.dbg.json +1 -1
  235. package/artifacts/contracts/shared/ComponentService.sol/ComponentService.json +269 -561
  236. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.dbg.json +1 -1
  237. package/artifacts/contracts/shared/ComponentServiceManager.sol/ComponentServiceManager.json +134 -86
  238. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.dbg.json +1 -1
  239. package/artifacts/contracts/shared/ContractLib.sol/ContractLib.json +525 -4
  240. package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.dbg.json +4 -0
  241. package/artifacts/contracts/shared/ContractLib.sol/IInstanceAdminHelper.json +24 -0
  242. package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.dbg.json +4 -0
  243. package/artifacts/contracts/shared/ContractLib.sol/ITargetHelper.json +30 -0
  244. package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.dbg.json +4 -0
  245. package/artifacts/contracts/shared/ContractLib.sol/ITokenRegistryHelper.json +40 -0
  246. package/artifacts/contracts/shared/IComponent.sol/IComponent.dbg.json +1 -1
  247. package/artifacts/contracts/shared/IComponent.sol/IComponent.json +41 -41
  248. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.dbg.json +1 -1
  249. package/artifacts/contracts/shared/IComponentService.sol/IComponentService.json +155 -382
  250. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.dbg.json +1 -1
  251. package/artifacts/contracts/shared/IInstanceLinkedComponent.sol/IInstanceLinkedComponent.json +41 -55
  252. package/artifacts/contracts/shared/ILifecycle.sol/ILifecycle.dbg.json +1 -1
  253. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
  254. package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +19 -0
  255. package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +1 -1
  256. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
  257. package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +139 -1
  258. package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +1 -1
  259. package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
  260. package/artifacts/contracts/shared/IService.sol/IService.json +56 -3
  261. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.dbg.json +1 -1
  262. package/artifacts/contracts/shared/InitializableERC165.sol/InitializableERC165.json +2 -2
  263. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.dbg.json +1 -1
  264. package/artifacts/contracts/shared/InstanceLinkedComponent.sol/InstanceLinkedComponent.json +60 -74
  265. package/artifacts/contracts/shared/Lifecycle.sol/Lifecycle.dbg.json +1 -1
  266. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.dbg.json +1 -1
  267. package/artifacts/contracts/shared/NftIdSet.sol/NftIdSet.json +2 -2
  268. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
  269. package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +21 -2
  270. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +1 -1
  271. package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +2 -2
  272. package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
  273. package/artifacts/contracts/shared/Registerable.sol/Registerable.json +137 -62
  274. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +1 -1
  275. package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +2 -2
  276. package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
  277. package/artifacts/contracts/shared/Service.sol/Service.json +51 -11
  278. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
  279. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +63 -162
  280. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.dbg.json +1 -1
  281. package/artifacts/contracts/shared/TokenHandler.sol/TokenHandlerBase.json +118 -29
  282. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.dbg.json +1 -1
  283. package/artifacts/contracts/shared/TokenHandlerDeployerLib.sol/TokenHandlerDeployerLib.json +32 -32
  284. package/artifacts/contracts/staking/IStaking.sol/IStaking.dbg.json +1 -1
  285. package/artifacts/contracts/staking/IStaking.sol/IStaking.json +1457 -145
  286. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.dbg.json +1 -1
  287. package/artifacts/contracts/staking/IStakingService.sol/IStakingService.json +214 -110
  288. package/artifacts/contracts/staking/ITargetLimitHandler.sol/ITargetLimitHandler.dbg.json +4 -0
  289. package/artifacts/contracts/staking/ITargetLimitHandler.sol/ITargetLimitHandler.json +50 -0
  290. package/artifacts/contracts/staking/Staking.sol/Staking.dbg.json +1 -1
  291. package/artifacts/contracts/staking/Staking.sol/Staking.json +1634 -275
  292. package/artifacts/contracts/staking/StakingLib.sol/StakingLib.dbg.json +4 -0
  293. package/artifacts/contracts/staking/StakingLib.sol/StakingLib.json +470 -0
  294. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.dbg.json +1 -1
  295. package/artifacts/contracts/staking/StakingManager.sol/StakingManager.json +149 -62
  296. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.dbg.json +1 -1
  297. package/artifacts/contracts/staking/StakingReader.sol/StakingReader.json +294 -177
  298. package/artifacts/contracts/staking/StakingService.sol/StakingService.dbg.json +1 -1
  299. package/artifacts/contracts/staking/StakingService.sol/StakingService.json +253 -174
  300. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.dbg.json +1 -1
  301. package/artifacts/contracts/staking/StakingServiceManager.sol/StakingServiceManager.json +102 -50
  302. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.dbg.json +1 -1
  303. package/artifacts/contracts/staking/StakingStore.sol/StakingStore.json +1632 -818
  304. package/artifacts/contracts/staking/TargetHandler.sol/TargetHandler.dbg.json +4 -0
  305. package/artifacts/contracts/staking/TargetHandler.sol/TargetHandler.json +309 -0
  306. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.dbg.json +1 -1
  307. package/artifacts/contracts/staking/TargetManagerLib.sol/TargetManagerLib.json +160 -88
  308. package/artifacts/contracts/type/AddressSet.sol/LibAddressSet.dbg.json +1 -1
  309. package/artifacts/contracts/type/Amount.sol/AmountLib.dbg.json +1 -1
  310. package/artifacts/contracts/type/Amount.sol/AmountLib.json +11 -11
  311. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
  312. package/artifacts/contracts/type/Blocknumber.sol/BlocknumberLib.json +64 -19
  313. package/artifacts/contracts/type/ChainId.sol/ChainIdLib.dbg.json +4 -0
  314. package/artifacts/contracts/type/ChainId.sol/ChainIdLib.json +193 -0
  315. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.dbg.json +1 -1
  316. package/artifacts/contracts/type/ClaimId.sol/ClaimIdLib.json +2 -2
  317. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
  318. package/artifacts/contracts/type/DistributorType.sol/DistributorTypeLib.json +2 -2
  319. package/artifacts/contracts/type/Fee.sol/FeeLib.dbg.json +1 -1
  320. package/artifacts/contracts/type/Fee.sol/FeeLib.json +94 -38
  321. package/artifacts/contracts/type/Key32.sol/Key32Lib.dbg.json +1 -1
  322. package/artifacts/contracts/type/Key32.sol/Key32Lib.json +2 -2
  323. package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.dbg.json +4 -0
  324. package/artifacts/contracts/type/Key32Set.sol/LibKey32Set.json +33 -0
  325. package/artifacts/contracts/type/NftId.sol/NftIdLib.dbg.json +1 -1
  326. package/artifacts/contracts/type/NftId.sol/NftIdLib.json +23 -4
  327. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
  328. package/artifacts/contracts/type/NftIdSet.sol/LibNftIdSet.json +2 -2
  329. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
  330. package/artifacts/contracts/type/ObjectType.sol/ObjectTypeLib.json +49 -50
  331. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.dbg.json +1 -1
  332. package/artifacts/contracts/type/PayoutId.sol/PayoutIdLib.json +2 -2
  333. package/artifacts/contracts/type/Referral.sol/ReferralLib.dbg.json +1 -1
  334. package/artifacts/contracts/type/Referral.sol/ReferralLib.json +23 -4
  335. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.dbg.json +1 -1
  336. package/artifacts/contracts/type/RequestId.sol/RequestIdLib.json +2 -2
  337. package/artifacts/contracts/type/RequestIdSet.sol/LibRequestIdSet.dbg.json +4 -0
  338. package/artifacts/contracts/type/RequestIdSet.sol/LibRequestIdSet.json +33 -0
  339. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.dbg.json +1 -1
  340. package/artifacts/contracts/type/RiskId.sol/RiskIdLib.json +69 -7
  341. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.dbg.json +1 -1
  342. package/artifacts/contracts/type/RoleId.sol/RoleIdLib.json +42 -157
  343. package/artifacts/contracts/type/Seconds.sol/SecondsLib.dbg.json +1 -1
  344. package/artifacts/contracts/type/Seconds.sol/SecondsLib.json +64 -2
  345. package/artifacts/contracts/type/Selector.sol/SelectorLib.dbg.json +1 -1
  346. package/artifacts/contracts/type/Selector.sol/SelectorLib.json +21 -2
  347. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.dbg.json +1 -1
  348. package/artifacts/contracts/type/Selector.sol/SelectorSetLib.json +2 -2
  349. package/artifacts/contracts/type/StateId.sol/StateIdLib.dbg.json +1 -1
  350. package/artifacts/contracts/type/String.sol/StrLib.dbg.json +1 -1
  351. package/artifacts/contracts/type/String.sol/StrLib.json +69 -2
  352. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.dbg.json +1 -1
  353. package/artifacts/contracts/type/Timestamp.sol/TimestampLib.json +37 -5
  354. package/artifacts/contracts/type/UFixed.sol/UFixedLib.dbg.json +1 -1
  355. package/artifacts/contracts/type/UFixed.sol/UFixedLib.json +61 -37
  356. package/artifacts/contracts/type/Version.sol/VersionLib.dbg.json +1 -1
  357. package/artifacts/contracts/type/Version.sol/VersionLib.json +2 -21
  358. package/artifacts/contracts/type/Version.sol/VersionPartLib.dbg.json +1 -1
  359. package/artifacts/contracts/type/Version.sol/VersionPartLib.json +101 -2
  360. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.dbg.json +1 -1
  361. package/artifacts/contracts/upgradeability/IVersionable.sol/IVersionable.json +10 -0
  362. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.dbg.json +1 -1
  363. package/artifacts/contracts/upgradeability/ProxyManager.sol/ProxyManager.json +81 -27
  364. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
  365. package/artifacts/contracts/upgradeability/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +15 -2
  366. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.dbg.json +1 -1
  367. package/artifacts/contracts/upgradeability/Versionable.sol/Versionable.json +10 -0
  368. package/contracts/accounting/AccountingService.sol +274 -0
  369. package/contracts/accounting/AccountingServiceManager.sol +38 -0
  370. package/contracts/accounting/IAccountingService.sol +47 -0
  371. package/contracts/authorization/AccessAdmin.sol +389 -306
  372. package/contracts/authorization/AccessAdminLib.sol +678 -0
  373. package/contracts/authorization/AccessManagerCloneable.sol +128 -4
  374. package/contracts/authorization/Authorization.sol +161 -260
  375. package/contracts/authorization/IAccess.sol +29 -12
  376. package/contracts/authorization/IAccessAdmin.sol +89 -84
  377. package/contracts/authorization/IAuthorization.sol +9 -43
  378. package/contracts/authorization/IServiceAuthorization.sol +55 -17
  379. package/contracts/authorization/ServiceAuthorization.sol +228 -34
  380. package/contracts/distribution/BasicDistribution.sol +19 -18
  381. package/contracts/distribution/BasicDistributionAuthorization.sol +30 -10
  382. package/contracts/distribution/Distribution.sol +45 -85
  383. package/contracts/distribution/DistributionService.sol +192 -99
  384. package/contracts/distribution/DistributionServiceManager.sol +1 -1
  385. package/contracts/distribution/IDistributionComponent.sol +3 -10
  386. package/contracts/distribution/IDistributionService.sol +38 -24
  387. package/contracts/examples/fire/FirePool.sol +6 -6
  388. package/contracts/examples/fire/FirePoolAuthorization.sol +2 -1
  389. package/contracts/examples/fire/FireProduct.sol +15 -13
  390. package/contracts/examples/fire/FireProductAuthorization.sol +2 -1
  391. package/contracts/examples/flight/FlightLib.sol +279 -0
  392. package/contracts/examples/flight/FlightOracle.sol +168 -0
  393. package/contracts/examples/flight/FlightOracleAuthorization.sol +34 -0
  394. package/contracts/examples/flight/FlightPool.sol +89 -0
  395. package/contracts/examples/flight/FlightPoolAuthorization.sol +37 -0
  396. package/contracts/examples/flight/FlightProduct.sol +470 -0
  397. package/contracts/examples/flight/FlightProductAuthorization.sol +44 -0
  398. package/contracts/examples/flight/FlightUSD.sol +26 -0
  399. package/contracts/examples/flight/originalV1.sol +396 -0
  400. package/contracts/examples/unpermissioned/SimpleDistribution.sol +34 -11
  401. package/contracts/examples/unpermissioned/SimpleDistributionAuthorization.sol +28 -0
  402. package/contracts/examples/unpermissioned/SimpleOracle.sol +4 -8
  403. package/contracts/examples/unpermissioned/SimplePool.sol +7 -13
  404. package/contracts/examples/unpermissioned/SimplePoolAuthorization.sol +28 -0
  405. package/contracts/examples/unpermissioned/SimpleProduct.sol +119 -27
  406. package/contracts/examples/unpermissioned/SimpleProductAuthorization.sol +28 -0
  407. package/contracts/instance/BaseStore.sol +93 -0
  408. package/contracts/instance/BundleSet.sol +42 -38
  409. package/contracts/instance/IBaseStore.sol +37 -0
  410. package/contracts/instance/IInstance.sol +109 -19
  411. package/contracts/instance/IInstanceService.sol +59 -11
  412. package/contracts/instance/Instance.sol +184 -65
  413. package/contracts/instance/InstanceAdmin.sol +221 -191
  414. package/contracts/instance/InstanceAuthorizationV3.sol +153 -72
  415. package/contracts/instance/InstanceReader.sol +447 -314
  416. package/contracts/instance/InstanceService.sol +305 -205
  417. package/contracts/instance/InstanceServiceManager.sol +1 -1
  418. package/contracts/instance/InstanceStore.sol +152 -116
  419. package/contracts/instance/ProductStore.sol +290 -0
  420. package/contracts/instance/RiskSet.sol +126 -0
  421. package/contracts/instance/TargetNames.sol +10 -0
  422. package/contracts/instance/base/BalanceStore.sol +4 -6
  423. package/contracts/instance/base/ObjectCounter.sol +1 -2
  424. package/contracts/instance/base/ObjectLifecycle.sol +6 -8
  425. package/contracts/instance/base/ObjectSet.sol +31 -33
  426. package/contracts/instance/base/ObjectSetHelperLib.sol +30 -0
  427. package/contracts/instance/module/IBundle.sol +6 -5
  428. package/contracts/instance/module/IComponents.sol +18 -8
  429. package/contracts/instance/module/IDistribution.sol +21 -8
  430. package/contracts/instance/module/IPolicy.sol +28 -8
  431. package/contracts/instance/module/IRisk.sol +5 -0
  432. package/contracts/oracle/BasicOracle.sol +3 -6
  433. package/contracts/oracle/BasicOracleAuthorization.sol +15 -8
  434. package/contracts/oracle/IOracle.sol +9 -4
  435. package/contracts/oracle/IOracleService.sol +12 -12
  436. package/contracts/oracle/Oracle.sol +5 -9
  437. package/contracts/oracle/OracleService.sol +98 -80
  438. package/contracts/oracle/OracleServiceManager.sol +1 -1
  439. package/contracts/pool/BasicPool.sol +4 -18
  440. package/contracts/pool/BasicPoolAuthorization.sol +29 -16
  441. package/contracts/pool/BundleService.sol +66 -165
  442. package/contracts/pool/BundleServiceManager.sol +1 -1
  443. package/contracts/pool/IBundleService.sol +27 -51
  444. package/contracts/pool/IPoolService.sol +56 -58
  445. package/contracts/pool/Pool.sol +15 -29
  446. package/contracts/pool/PoolLib.sol +341 -0
  447. package/contracts/pool/PoolService.sol +221 -227
  448. package/contracts/pool/PoolServiceManager.sol +1 -1
  449. package/contracts/product/ApplicationService.sol +93 -25
  450. package/contracts/product/ApplicationServiceManager.sol +1 -1
  451. package/contracts/product/BasicProduct.sol +4 -5
  452. package/contracts/product/BasicProductAuthorization.sol +33 -11
  453. package/contracts/product/ClaimService.sol +221 -209
  454. package/contracts/product/ClaimServiceManager.sol +1 -1
  455. package/contracts/product/IApplicationService.sol +28 -3
  456. package/contracts/product/IClaimService.sol +18 -5
  457. package/contracts/product/IPolicyService.sol +31 -11
  458. package/contracts/product/IPricingService.sol +1 -0
  459. package/contracts/product/IProductComponent.sol +4 -1
  460. package/contracts/product/IRiskService.sol +25 -10
  461. package/contracts/product/PolicyService.sol +252 -302
  462. package/contracts/product/PolicyServiceLib.sol +139 -0
  463. package/contracts/product/PolicyServiceManager.sol +1 -1
  464. package/contracts/product/PricingService.sol +52 -46
  465. package/contracts/product/PricingServiceManager.sol +3 -3
  466. package/contracts/product/Product.sol +95 -36
  467. package/contracts/product/RiskService.sol +130 -37
  468. package/contracts/product/RiskServiceManager.sol +1 -1
  469. package/contracts/registry/ChainNft.sol +4 -2
  470. package/contracts/registry/IRegistry.sol +23 -24
  471. package/contracts/registry/IRelease.sol +29 -0
  472. package/contracts/registry/Registry.sol +22 -11
  473. package/contracts/registry/RegistryAdmin.sol +94 -383
  474. package/contracts/registry/RegistryAuthorization.sol +337 -0
  475. package/contracts/registry/RegistryService.sol +4 -4
  476. package/contracts/registry/RegistryServiceManager.sol +1 -1
  477. package/contracts/registry/ReleaseAdmin.sol +199 -0
  478. package/contracts/registry/ReleaseLifecycle.sol +2 -0
  479. package/contracts/registry/ReleaseRegistry.sol +157 -117
  480. package/contracts/registry/ServiceAuthorizationV3.sol +193 -54
  481. package/contracts/registry/TokenRegistry.sol +61 -59
  482. package/contracts/shared/Component.sol +36 -55
  483. package/contracts/shared/ComponentService.sol +350 -438
  484. package/contracts/shared/ComponentServiceManager.sol +1 -1
  485. package/contracts/shared/ContractLib.sol +260 -2
  486. package/contracts/shared/IComponent.sol +1 -10
  487. package/contracts/shared/IComponentService.sol +22 -41
  488. package/contracts/shared/IInstanceLinkedComponent.sol +0 -11
  489. package/contracts/shared/INftOwnable.sol +2 -0
  490. package/contracts/shared/IRegisterable.sol +15 -5
  491. package/contracts/shared/IService.sol +3 -5
  492. package/contracts/shared/InitializableERC165.sol +9 -1
  493. package/contracts/shared/InstanceLinkedComponent.sol +62 -35
  494. package/contracts/shared/NftOwnable.sol +8 -6
  495. package/contracts/shared/PolicyHolder.sol +4 -3
  496. package/contracts/shared/Registerable.sol +42 -19
  497. package/contracts/shared/RegistryLinked.sol +1 -1
  498. package/contracts/shared/Service.sol +13 -30
  499. package/contracts/shared/TokenHandler.sol +45 -100
  500. package/contracts/staking/IStaking.sol +265 -72
  501. package/contracts/staking/IStakingService.sol +45 -75
  502. package/contracts/staking/ITargetLimitHandler.sol +17 -0
  503. package/contracts/staking/Staking.sol +502 -210
  504. package/contracts/staking/{StakeManagerLib.sol → StakingLib.sol} +55 -84
  505. package/contracts/staking/StakingManager.sol +4 -3
  506. package/contracts/staking/StakingReader.sol +58 -77
  507. package/contracts/staking/StakingService.sol +62 -194
  508. package/contracts/staking/StakingServiceManager.sol +6 -4
  509. package/contracts/staking/StakingStore.sol +1093 -330
  510. package/contracts/staking/TargetHandler.sol +132 -0
  511. package/contracts/staking/TargetManagerLib.sol +69 -46
  512. package/contracts/type/Amount.sol +4 -0
  513. package/contracts/type/Blocknumber.sol +17 -22
  514. package/contracts/type/ChainId.sol +101 -0
  515. package/contracts/type/Fee.sol +8 -8
  516. package/contracts/type/Key32.sol +2 -2
  517. package/contracts/type/Key32Set.sol +62 -0
  518. package/contracts/type/NftId.sol +6 -0
  519. package/contracts/type/ObjectType.sol +70 -68
  520. package/contracts/type/Referral.sol +6 -0
  521. package/contracts/type/RequestIdSet.sol +62 -0
  522. package/contracts/type/RiskId.sol +26 -8
  523. package/contracts/type/RoleId.sol +63 -45
  524. package/contracts/type/Seconds.sol +23 -0
  525. package/contracts/type/Selector.sol +5 -0
  526. package/contracts/type/String.sol +42 -0
  527. package/contracts/type/Timestamp.sol +14 -8
  528. package/contracts/type/UFixed.sol +35 -127
  529. package/contracts/type/Version.sol +54 -5
  530. package/contracts/upgradeability/IVersionable.sol +3 -0
  531. package/contracts/upgradeability/ProxyManager.sol +27 -13
  532. package/contracts/upgradeability/UpgradableProxyWithAdmin.sol +12 -2
  533. package/contracts/upgradeability/Versionable.sol +6 -3
  534. package/package.json +2 -2
  535. package/artifacts/contracts/authorization/ReleaseAccessManager.sol/ReleaseAccessManager.dbg.json +0 -4
  536. package/artifacts/contracts/authorization/ReleaseAccessManager.sol/ReleaseAccessManager.json +0 -1196
  537. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +0 -4
  538. package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +0 -129
  539. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.dbg.json +0 -4
  540. package/artifacts/contracts/shared/ComponentVerifyingService.sol/ComponentVerifyingService.json +0 -474
  541. package/artifacts/contracts/shared/IKeyValueStore.sol/IKeyValueStore.dbg.json +0 -4
  542. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.dbg.json +0 -4
  543. package/artifacts/contracts/shared/KeyValueStore.sol/KeyValueStore.json +0 -538
  544. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.dbg.json +0 -4
  545. package/artifacts/contracts/staking/StakeManagerLib.sol/StakeManagerLib.json +0 -440
  546. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.dbg.json +0 -4
  547. package/artifacts/contracts/staking/StakingLifecycle.sol/StakingLifecycle.json +0 -205
  548. package/artifacts/contracts/type/UFixed.sol/MathLib.dbg.json +0 -4
  549. package/artifacts/contracts/type/UFixed.sol/MathLib.json +0 -16
  550. package/contracts/authorization/ReleaseAccessManager.sol +0 -38
  551. package/contracts/instance/module/IAccess.sol +0 -46
  552. package/contracts/shared/ComponentVerifyingService.sol +0 -128
  553. package/contracts/shared/IKeyValueStore.sol +0 -54
  554. package/contracts/shared/KeyValueStore.sol +0 -131
  555. package/contracts/staking/StakingLifecycle.sol +0 -23
@@ -3,15 +3,24 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
5
5
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
6
- import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
7
6
 
7
+ import {IAccess} from "./IAccess.sol";
8
+ import {IAccessAdmin} from "./IAccessAdmin.sol";
9
+ import {IAuthorization} from "./IAuthorization.sol";
10
+ import {IRegistry} from "../registry/IRegistry.sol";
11
+ import {IServiceAuthorization} from "./IServiceAuthorization.sol";
12
+
13
+ import {AccessAdminLib} from "./AccessAdminLib.sol";
8
14
  import {AccessManagerCloneable} from "./AccessManagerCloneable.sol";
15
+ import {Blocknumber, BlocknumberLib} from "../type/Blocknumber.sol";
9
16
  import {ContractLib} from "../shared/ContractLib.sol";
10
- import {IAccessAdmin} from "./IAccessAdmin.sol";
17
+ import {NftId, NftIdLib} from "../type/NftId.sol";
18
+ import {ObjectType} from "../type/ObjectType.sol";
11
19
  import {RoleId, RoleIdLib, ADMIN_ROLE, PUBLIC_ROLE} from "../type/RoleId.sol";
12
- import {Selector, SelectorLib, SelectorSetLib} from "../type/Selector.sol";
20
+ import {Selector, SelectorSetLib} from "../type/Selector.sol";
13
21
  import {Str, StrLib} from "../type/String.sol";
14
22
  import {TimestampLib} from "../type/Timestamp.sol";
23
+ import {VersionPart} from "../type/Version.sol";
15
24
 
16
25
 
17
26
  /**
@@ -21,20 +30,26 @@ import {TimestampLib} from "../type/Timestamp.sol";
21
30
  */
22
31
  contract AccessAdmin is
23
32
  AccessManagedUpgradeable,
24
- ReentrancyGuardUpgradeable,
25
33
  IAccessAdmin
26
34
  {
27
35
  using EnumerableSet for EnumerableSet.AddressSet;
28
36
 
29
- string public constant ADMIN_ROLE_NAME = "AdminRole";
30
- string public constant PUBLIC_ROLE_NAME = "PublicRole";
37
+ /// @dev admin name used for logging only
38
+ string internal _adminName;
31
39
 
32
- /// @dev the OpenZeppelin access manager driving the access admin contract
40
+ /// @dev the access manager driving the access admin contract
41
+ /// hold link to registry and release version
33
42
  AccessManagerCloneable internal _authority;
34
43
 
35
- /// @dev stores the deployer address and allows to create initializers
36
- /// that are restricted to the deployer address.
37
- address internal _deployer;
44
+ /// @dev the authorization contract used for initial access control
45
+ IAuthorization internal _authorization;
46
+
47
+ // /// @dev stores the deployer address and allows to create initializers
48
+ // /// that are restricted to the deployer address.
49
+ // address internal _deployer;
50
+
51
+ /// @dev the linked NFT ID
52
+ NftId internal _linkedNftId;
38
53
 
39
54
  /// @dev store role info per role id
40
55
  mapping(RoleId roleId => RoleInfo info) internal _roleInfo;
@@ -45,6 +60,9 @@ contract AccessAdmin is
45
60
  /// @dev store array with all created roles
46
61
  RoleId [] internal _roleIds;
47
62
 
63
+ // @dev target type specific role id counters
64
+ mapping(TargetType => uint64) internal _nextRoleId;
65
+
48
66
  /// @dev store set of current role members for given role
49
67
  mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
50
68
 
@@ -66,52 +84,92 @@ contract AccessAdmin is
66
84
  /// @dev temporary dynamic functions array
67
85
  bytes4[] private _functions;
68
86
 
69
- modifier onlyDeployer() {
70
- // special case for cloned AccessAdmin contracts
71
- // IMPORTANT cloning and _initializeAuthority needs to be done in a single transaction
72
- if (_deployer == address(0)) {
73
- _deployer = msg.sender;
74
- }
75
87
 
76
- if (msg.sender != _deployer) {
77
- revert ErrorNotDeployer();
78
- }
79
- _;
88
+ //-------------- initialization functions ------------------------------//
89
+
90
+ /// @dev Initializes this admin with the provided accessManager (and authorization specification).
91
+ /// Internally initializes access manager with this admin and creates basic role setup.
92
+ function initialize(
93
+ address authority,
94
+ string memory adminName
95
+ )
96
+ public
97
+ initializer()
98
+ {
99
+ __AccessAdmin_init(authority, adminName);
80
100
  }
81
101
 
82
- modifier onlyRoleAdmin(RoleId roleId) {
83
- _checkRoleExists(roleId, false);
84
102
 
85
- if (!hasAdminRole(msg.sender, roleId)) {
86
- revert ErrorNotAdminOfRole(_roleInfo[roleId].adminRoleId);
103
+ /// @dev Initializes this admin with the provided accessManager and name.
104
+ /// IMPORTANT
105
+ /// - cloning of an access admin and initialization MUST be done in the same tx.
106
+ /// - this function as well as any completeSetup functions MUST be called in the same tx.
107
+ function __AccessAdmin_init(
108
+ address authority,
109
+ string memory adminName
110
+ )
111
+ internal
112
+ onlyInitializing()
113
+ {
114
+ AccessAdminLib.checkInitParameters(authority, adminName);
115
+ _authority = AccessManagerCloneable(authority);
116
+ _authority.initialize(address(this));
117
+
118
+ // delayed additional check for authority after its initialization
119
+ if (!ContractLib.isAuthority(authority)) {
120
+ revert ErrorAccessAdminAccessManagerNotAccessManager(authority);
87
121
  }
88
- _;
122
+
123
+ // effects
124
+ // set and initialize this access manager contract as
125
+ // the admin (ADMIN_ROLE) of the provided authority
126
+ __AccessManaged_init(authority);
127
+
128
+ // set name for logging
129
+ _adminName = adminName;
130
+
131
+ // set initial linked NFT ID to zero
132
+ _linkedNftId = NftIdLib.zero();
133
+
134
+ // setup admin role
135
+ _createRoleUnchecked(
136
+ ADMIN_ROLE(), AccessAdminLib.adminRoleInfo());
137
+
138
+ // add this contract as admin role member, as contract roles cannot be revoked
139
+ // and max member count is 1 for admin role this access admin contract will
140
+ // always be the only admin of the access manager.
141
+ _roleMembers[
142
+ RoleIdLib.toRoleId(_authority.ADMIN_ROLE())].add(address(this));
143
+
144
+ // setup public role
145
+ _createRoleUnchecked(
146
+ PUBLIC_ROLE(), AccessAdminLib.publicRoleInfo());
89
147
  }
90
148
 
91
- modifier onlyRoleMember(RoleId roleId) {
92
- if (!hasRole(msg.sender, roleId)) {
93
- revert ErrorNotRoleOwner(roleId);
94
- }
95
- _;
149
+ //--- view functions for access admin ---------------------------------------//
150
+
151
+ function getRelease() public view virtual returns (VersionPart release) {
152
+ return _authority.getRelease();
96
153
  }
97
154
 
98
- modifier onlyExistingRole(RoleId roleId, bool onlyActiveRole) {
99
- _checkRoleExists(roleId, onlyActiveRole);
100
- _;
155
+
156
+ function getRegistry() public view returns (IRegistry registry) {
157
+ return _authority.getRegistry();
101
158
  }
102
159
 
103
- modifier onlyExistingTarget(address target) {
104
- _checkTarget(target);
105
- _;
160
+
161
+ function getLinkedNftId() external view returns (NftId linkedNftId) {
162
+ return _linkedNftId;
106
163
  }
107
164
 
108
- constructor() {
109
- _deployer = msg.sender;
110
- _authority = new AccessManagerCloneable();
111
- _authority.initialize(address(this));
112
165
 
113
- _setAuthority(address(_authority)); // set authority for oz access managed
114
- _createAdminAndPublicRoles();
166
+ function getAuthorization() public view returns (IAuthorization authorization) {
167
+ return _authorization;
168
+ }
169
+
170
+
171
+ function isLocked() public view returns (bool locked) {
172
+ return _authority.isLocked();
115
173
  }
116
174
 
117
175
  //--- view functions for roles ------------------------------------------//
@@ -133,15 +191,28 @@ contract AccessAdmin is
133
191
  }
134
192
 
135
193
  function roleExists(RoleId roleId) public view returns (bool exists) {
136
- return _roleInfo[roleId].createdAt.gtz();
194
+ return _roleInfo[roleId].targetType != TargetType.Undefined;
137
195
  }
138
196
 
139
- function getRoleInfo(RoleId roleId) external view returns (RoleInfo memory) {
197
+ function getRoleForName(string memory name) public view returns (RoleId roleId, bool exists) {
198
+ roleId = _roleForName[StrLib.toStr(name)].roleId;
199
+ exists = false;
200
+
201
+ if (roleId.gtz() || AccessAdminLib.isAdminRoleName(name)) {
202
+ exists = true;
203
+ }
204
+ }
205
+
206
+ function getRoleInfo(RoleId roleId) public view returns (RoleInfo memory) {
140
207
  return _roleInfo[roleId];
141
208
  }
142
209
 
143
- function getRoleForName(Str name) external view returns (RoleNameInfo memory) {
144
- return _roleForName[name];
210
+ function isRoleActive(RoleId roleId) external view returns (bool isActive) {
211
+ return _roleInfo[roleId].pausedAt > TimestampLib.current();
212
+ }
213
+
214
+ function isRoleCustom(RoleId roleId) external view returns (bool isActive) {
215
+ return _roleInfo[roleId].targetType == TargetType.Custom;
145
216
  }
146
217
 
147
218
  function roleMembers(RoleId roleId) external view returns (uint256 numberOfMembers) {
@@ -152,20 +223,15 @@ contract AccessAdmin is
152
223
  return _roleMembers[roleId].at(idx);
153
224
  }
154
225
 
155
- function hasRole(address account, RoleId roleId) public view returns (bool) {
226
+ function isRoleMember(RoleId roleId, address account) public view returns (bool) {
156
227
  (bool isMember, ) = _authority.hasRole(
157
228
  RoleId.unwrap(roleId),
158
229
  account);
159
230
  return isMember;
160
231
  }
161
232
 
162
- function hasAdminRole(address account, RoleId roleId)
163
- public
164
- virtual
165
- view
166
- returns (bool)
167
- {
168
- return hasRole(account, _roleInfo[roleId].adminRoleId);
233
+ function isRoleAdmin(RoleId roleId, address account) public virtual view returns (bool) {
234
+ return isRoleMember(_roleInfo[roleId].adminRoleId, account);
169
235
  }
170
236
 
171
237
  //--- view functions for targets ----------------------------------------//
@@ -182,7 +248,7 @@ contract AccessAdmin is
182
248
  return _targets[idx];
183
249
  }
184
250
 
185
- function getTargetInfo(address target) external view returns (TargetInfo memory targetInfo) {
251
+ function getTargetInfo(address target) public view returns (TargetInfo memory targetInfo) {
186
252
  return _targetInfo[target];
187
253
  }
188
254
 
@@ -191,9 +257,11 @@ contract AccessAdmin is
191
257
  }
192
258
 
193
259
  function isTargetLocked(address target) public view returns (bool locked) {
194
- return _authority.isTargetClosed(target);
260
+ return _authority.isLocked() || _authority.isTargetClosed(target);
195
261
  }
196
262
 
263
+ //--- view functions for target functions -------------------------------//
264
+
197
265
  function authorizedFunctions(address target) external view returns (uint256 numberOfFunctions) {
198
266
  return SelectorSetLib.size(_targetFunctions[target]);
199
267
  }
@@ -217,380 +285,395 @@ contract AccessAdmin is
217
285
  selector.toBytes4()));
218
286
  }
219
287
 
220
- function canCall(address caller, address target, Selector selector) external virtual view returns (bool can) {
221
- (can, ) = _authority.canCall(caller, target, selector.toBytes4());
222
- }
223
-
224
- function toRole(RoleId adminRoleId, RoleType roleType, uint32 maxMemberCount, string memory name) public view returns (RoleInfo memory) {
225
- return RoleInfo({
226
- name: StrLib.toStr(name),
227
- adminRoleId: adminRoleId,
228
- roleType: roleType,
229
- maxMemberCount: maxMemberCount,
230
- createdAt: TimestampLib.blockTimestamp(),
231
- pausedAt: TimestampLib.max()
232
- });
233
- }
234
288
 
235
- function toFunction(bytes4 selector, string memory name) public view returns (FunctionInfo memory) {
236
- return FunctionInfo({
237
- name: StrLib.toStr(name),
238
- selector: SelectorLib.toSelector(selector),
239
- createdAt: TimestampLib.blockTimestamp()});
240
- }
241
-
242
- function deployer() public view returns (address) {
243
- return _deployer;
289
+ function getFunctionInfo(address target, Selector selector)
290
+ external
291
+ view
292
+ returns (FunctionInfo memory functionInfo)
293
+ {
294
+ return _functionInfo[target][selector];
244
295
  }
245
296
 
246
297
  //--- internal/private functions -------------------------------------------------//
247
298
 
248
- function _authorizeTargetFunctions(
249
- address target,
250
- RoleId roleId,
251
- FunctionInfo[] memory functions
252
- )
253
- internal
254
- {
255
- if (roleId == getAdminRole()) {
256
- revert ErrorAuthorizeForAdminRoleInvalid(target);
299
+ function _linkToNftOwnable(address registerable) internal {
300
+ if (!getRegistry().isRegistered(registerable)) {
301
+ revert ErrorAccessAdminNotRegistered(registerable);
257
302
  }
258
303
 
259
- bool addFunctions = true;
260
- bytes4[] memory functionSelectors = _processFunctionSelectors(target, functions, addFunctions);
261
-
262
- // apply authz via access manager
263
- _grantRoleAccessToFunctions(target, roleId, functionSelectors);
304
+ _linkedNftId = getRegistry().getNftIdForAddress(registerable);
264
305
  }
265
306
 
266
- function _unauthorizeTargetFunctions(
267
- address target,
268
- FunctionInfo[] memory functions
269
- )
270
- internal
271
- {
272
- bool addFunctions = false;
273
- bytes4[] memory functionSelectors = _processFunctionSelectors(target, functions, addFunctions);
274
- _grantRoleAccessToFunctions(target, getAdminRole(), functionSelectors);
275
- }
276
307
 
277
- function _processFunctionSelectors(
278
- address target,
279
- FunctionInfo[] memory functions,
280
- bool addFunctions
308
+ function _createRoles(
309
+ IServiceAuthorization authorization
281
310
  )
282
311
  internal
283
- returns (
284
- bytes4[] memory functionSelectors
285
- )
286
312
  {
287
- uint256 n = functions.length;
288
- functionSelectors = new bytes4[](n);
289
- FunctionInfo memory func;
290
- Selector selector;
291
-
292
- for (uint256 i = 0; i < n; i++) {
293
- func = functions[i];
294
- selector = func.selector;
295
-
296
- // add function selector to target selector set if not in set
297
- if (addFunctions) { SelectorSetLib.add(_targetFunctions[target], selector); }
298
- else { SelectorSetLib.remove(_targetFunctions[target], selector); }
299
-
300
- // set function name
301
- _functionInfo[target][selector] = func;
302
-
303
- // add bytes4 selector to function selector array
304
- functionSelectors[i] = selector.toBytes4();
313
+ RoleId[] memory roles = authorization.getRoles();
314
+
315
+ for(uint256 i = 0; i < roles.length; i++) {
316
+ RoleId authzRoleId = roles[i];
317
+ IAccess.RoleInfo memory roleInfo = authorization.getRoleInfo(authzRoleId);
318
+ (RoleId roleId, bool exists) = getRoleForName(roleInfo.name.toString());
319
+
320
+ if (!exists) {
321
+ if (!AccessAdminLib.isDynamicRoleId(authzRoleId)) {
322
+ roleId = authzRoleId;
323
+ }
324
+
325
+ _createRole(
326
+ roleId,
327
+ roleInfo,
328
+ true);
329
+ }
305
330
  }
306
331
  }
307
332
 
308
- function _initializeAuthority(
309
- address authorityAddress
333
+
334
+ /// @dev Creates a role based on the provided parameters.
335
+ /// Checks that the provided role and role id and role name not already used.
336
+ function _createRole(
337
+ RoleId roleId,
338
+ RoleInfo memory info,
339
+ bool revertOnExistingRole
310
340
  )
311
341
  internal
312
- virtual
313
- onlyInitializing()
314
- onlyDeployer()
315
342
  {
316
- if (authority() != address(0)) {
317
- revert ErrorAuthorityAlreadySet();
343
+ bool isAdminOrPublicRole = AccessAdminLib.checkRoleCreation(this, roleId, info, revertOnExistingRole);
344
+ if (!isAdminOrPublicRole) {
345
+ _createRoleUnchecked(roleId, info);
318
346
  }
319
-
320
- _authority = AccessManagerCloneable(authorityAddress);
321
- __AccessManaged_init(address(_authority));
322
- }
323
-
324
-
325
- function _initializeAdminAndPublicRoles()
326
- internal
327
- virtual
328
- onlyInitializing()
329
- {
330
- _createAdminAndPublicRoles();
331
347
  }
332
348
 
333
349
 
334
- /// @dev internal setup function that can be used in both constructor and initializer.
335
- function _createAdminAndPublicRoles()
336
- internal
350
+ function _createRoleUnchecked(
351
+ RoleId roleId,
352
+ RoleInfo memory info
353
+ )
354
+ private
337
355
  {
338
- RoleId adminRoleId = RoleIdLib.toRoleId(_authority.ADMIN_ROLE());
356
+ // create role info
357
+ info.createdAt = TimestampLib.current();
358
+ info.pausedAt = TimestampLib.max();
359
+ _roleInfo[roleId] = info;
339
360
 
340
- // setup admin role
341
- _createRoleUnchecked(
342
- ADMIN_ROLE(),
343
- toRole({
344
- adminRoleId: ADMIN_ROLE(),
345
- roleType: RoleType.Contract,
346
- maxMemberCount: 1,
347
- name: ADMIN_ROLE_NAME}));
361
+ // create role name info
362
+ _roleForName[info.name] = RoleNameInfo({
363
+ roleId: roleId,
364
+ exists: true});
348
365
 
349
- // add this contract as admin role member
350
- _roleMembers[adminRoleId].add(address(this));
366
+ // add role to list of roles
367
+ _roleIds.push(roleId);
351
368
 
352
- // setup public role
353
- _createRoleUnchecked(
354
- PUBLIC_ROLE(),
355
- toRole({
356
- adminRoleId: ADMIN_ROLE(),
357
- roleType: RoleType.Gif,
358
- maxMemberCount: type(uint32).max,
359
- name: PUBLIC_ROLE_NAME}));
369
+ emit LogAccessAdminRoleCreated(_adminName, roleId, info.targetType, info.adminRoleId, info.name.toString());
360
370
  }
361
371
 
362
372
 
363
- /// @dev grant the specified role access to all functions in the provided selector list
364
- function _grantRoleAccessToFunctions(
365
- address target,
366
- RoleId roleId,
367
- bytes4[] memory functionSelectors
368
- )
373
+ /// @dev Activates or deactivates role.
374
+ /// The role activ property is indirectly controlled over the pausedAt timestamp.
375
+ function _setRoleActive(RoleId roleId, bool active)
369
376
  internal
370
377
  {
371
- _authority.setTargetFunctionRole(
372
- target,
373
- functionSelectors,
374
- RoleId.unwrap(roleId));
378
+ AccessAdminLib.checkRoleExists(this, roleId, false, false);
379
+
380
+ if (active) {
381
+ _roleInfo[roleId].pausedAt = TimestampLib.max();
382
+ } else {
383
+ _roleInfo[roleId].pausedAt = TimestampLib.current();
384
+ }
375
385
 
376
- // implizit logging: rely on OpenZeppelin log TargetFunctionRoleUpdated
386
+ Blocknumber lastUpdateIn = _roleInfo[roleId].lastUpdateIn;
387
+ _roleInfo[roleId].lastUpdateIn = BlocknumberLib.current();
388
+
389
+ emit LogAccessAdminRoleActivatedSet(_adminName, roleId, active, lastUpdateIn);
377
390
  }
378
391
 
379
392
 
380
393
  /// @dev grant the specified role to the provided account
381
394
  function _grantRoleToAccount(RoleId roleId, address account)
382
395
  internal
383
- onlyExistingRole(roleId, true)
384
396
  {
397
+ AccessAdminLib.checkRoleExists(this, roleId, true, false);
398
+
385
399
  // check max role members will not be exceeded
386
400
  if (_roleMembers[roleId].length() >= _roleInfo[roleId].maxMemberCount) {
387
- revert ErrorRoleMembersLimitReached(roleId, _roleInfo[roleId].maxMemberCount);
401
+ revert ErrorAccessAdminRoleMembersLimitReached(roleId, _roleInfo[roleId].maxMemberCount);
388
402
  }
389
403
 
390
404
  // check account is contract for contract role
391
405
  if (
392
- _roleInfo[roleId].roleType == RoleType.Contract &&
406
+ _roleInfo[roleId].targetType != TargetType.Custom &&
393
407
  !ContractLib.isContract(account) // will fail in account's constructor
394
408
  ) {
395
- revert ErrorRoleMemberNotContract(roleId, account);
409
+ revert ErrorAccessAdminRoleMemberNotContract(roleId, account);
396
410
  }
397
411
 
398
- // TODO check account already have roleId
412
+ // effects
399
413
  _roleMembers[roleId].add(account);
400
414
  _authority.grantRole(
401
415
  RoleId.unwrap(roleId),
402
416
  account,
403
417
  0);
404
418
 
405
- // indirect logging: rely on OpenZeppelin log RoleGranted
419
+ emit LogAccessAdminRoleGranted(
420
+ _adminName,
421
+ account,
422
+ AccessAdminLib.getRoleName(this, roleId));
406
423
  }
407
424
 
425
+
408
426
  /// @dev revoke the specified role from the provided account
409
427
  function _revokeRoleFromAccount(RoleId roleId, address account)
410
428
  internal
411
- onlyExistingRole(roleId, false)
412
429
  {
430
+ AccessAdminLib.checkRoleExists(this, roleId, false, false);
413
431
 
414
- // check role removal is permitted
415
- if (_roleInfo[roleId].roleType == RoleType.Contract) {
416
- revert ErrorRoleMemberRemovalDisabled(roleId, account);
432
+ // check for attempt to revoke contract role
433
+ if (_roleInfo[roleId].targetType != TargetType.Custom) {
434
+ revert ErrorAccessAdminRoleMemberRemovalDisabled(roleId, account);
417
435
  }
418
436
 
419
- // TODO check account have roleId?
437
+ // effects
420
438
  _roleMembers[roleId].remove(account);
421
439
  _authority.revokeRole(
422
440
  RoleId.unwrap(roleId),
423
441
  account);
424
442
 
425
- // indirect logging: rely on OpenZeppelin log RoleGranted
443
+ emit LogAccessAdminRoleRevoked(_adminName, account, _roleInfo[roleId].name.toString());
426
444
  }
427
445
 
428
446
 
429
- /// @dev Creates a role based on the provided parameters.
430
- /// Checks that the provided role and role id and role name not already used.
431
- function _createRole(
432
- RoleId roleId,
433
- RoleInfo memory info
447
+ function _getOrCreateTargetRoleIdAndName(
448
+ address target,
449
+ string memory targetName,
450
+ TargetType targetType
434
451
  )
435
452
  internal
453
+ returns (
454
+ RoleId roleId,
455
+ string memory roleName,
456
+ bool exists
457
+ )
436
458
  {
437
- // check role does not yet exist
438
- if(roleExists(roleId)) {
439
- revert ErrorRoleAlreadyCreated(
440
- roleId,
441
- _roleInfo[roleId].name.toString());
459
+ roleName = AccessAdminLib.toRoleName(targetName);
460
+ (roleId, exists) = getRoleForName(roleName);
461
+
462
+ if (exists) {
463
+ return (roleId, roleName, true);
464
+ }
465
+
466
+ // get roleId
467
+ if (targetType == TargetType.Service || targetType == TargetType.GenericService) {
468
+ roleId = AccessAdminLib.getServiceRoleId(target, targetType);
469
+ } else {
470
+ uint64 nextRoleId = _nextRoleId[targetType];
471
+ roleId = AccessAdminLib.getTargetRoleId(target, targetType, nextRoleId);
472
+
473
+ // increment target type specific role id counter
474
+ _nextRoleId[targetType]++;
442
475
  }
443
-
444
- // check admin role exists
445
- if(!roleExists(info.adminRoleId)) {
446
- revert ErrorRoleAdminNotExisting(info.adminRoleId);
447
- }
448
-
449
- // check role name is not empty
450
- if(info.name.length() == 0) {
451
- revert ErrorRoleNameEmpty(roleId);
452
- }
453
-
454
- // check role name is not used for another role
455
- if(_roleForName[info.name].exists) {
456
- revert ErrorRoleNameAlreadyExists(
457
- roleId,
458
- info.name.toString(),
459
- _roleForName[info.name].roleId);
460
- }
461
-
462
- _createRoleUnchecked(roleId, info);
463
476
  }
464
477
 
465
478
 
466
- function _createRoleUnchecked(
467
- RoleId roleId,
468
- RoleInfo memory info
479
+ function _createTarget(
480
+ address target,
481
+ string memory targetName,
482
+ TargetType targetType,
483
+ bool checkAuthority
469
484
  )
470
- private
485
+ internal
486
+ returns (RoleId contractRoleId)
471
487
  {
472
- // create role info
473
- info.createdAt = TimestampLib.blockTimestamp();
474
- _roleInfo[roleId] = info;
475
-
476
- // create role name info
477
- _roleForName[info.name] = RoleNameInfo({
478
- roleId: roleId,
479
- exists: true});
480
-
481
- // add role to list of roles
482
- _roleIds.push(roleId);
483
-
484
- emit LogRoleCreated(roleId, info.roleType, info.adminRoleId, info.name.toString());
488
+ // checks
489
+ AccessAdminLib.checkTargetCreation(this, target, targetName, checkAuthority);
490
+
491
+ // effects
492
+ contractRoleId = _createTargetUnchecked(
493
+ target,
494
+ targetName,
495
+ targetType,
496
+ checkAuthority);
497
+
498
+ // deal with token handler, if applicable
499
+ (
500
+ address tokenHandler,
501
+ string memory tokenHandlerName
502
+ ) = AccessAdminLib.getTokenHandler(target, targetName, targetType);
503
+
504
+ if (tokenHandler != address(0)) {
505
+ _createTargetUnchecked(
506
+ tokenHandler,
507
+ tokenHandlerName,
508
+ targetType,
509
+ checkAuthority);
510
+ }
485
511
  }
486
512
 
487
513
 
488
- function _createTarget(
514
+ /// @dev Creates a new target and a corresponding contract role.
515
+ /// The function assigns the role to the target and logs the creation.
516
+ function _createTargetUnchecked(
489
517
  address target,
490
518
  string memory targetName,
491
- bool checkAuthority,
492
- bool custom
519
+ TargetType targetType,
520
+ bool managed
493
521
  )
494
522
  internal
495
- nonReentrant()
523
+ returns (RoleId targetRoleId)
496
524
  {
497
- // check target does not yet exist
498
- if(targetExists(target)) {
499
- revert ErrorTargetAlreadyCreated(
500
- target,
501
- _targetInfo[target].name.toString());
502
- }
503
-
504
- // check target name is not empty
505
- Str name = StrLib.toStr(targetName);
506
- if(name.length() == 0) {
507
- revert ErrorTargetNameEmpty(target);
508
- }
509
-
510
- // check target name is not used for another target
511
- if( _targetForName[name] != address(0)) {
512
- revert ErrorTargetNameAlreadyExists(
513
- target,
514
- targetName,
515
- _targetForName[name]);
516
- }
517
-
518
- // check target is an access managed contract
519
- if (!ContractLib.isAccessManaged(target)) {
520
- revert ErrorTargetNotAccessManaged(target);
521
- }
522
-
523
- // check target shares authority with this contract
524
- if (checkAuthority) {
525
- address targetAuthority = AccessManagedUpgradeable(target).authority();
526
- if (targetAuthority != authority()) {
527
- revert ErrorTargetAuthorityMismatch(authority(), targetAuthority);
528
- }
525
+ // create target role (if not existing)
526
+ string memory roleName;
527
+ bool roleExists;
528
+ (targetRoleId, roleName, roleExists) = _getOrCreateTargetRoleIdAndName(target, targetName, targetType);
529
+
530
+ if (!roleExists) {
531
+ _createRole(
532
+ targetRoleId,
533
+ AccessAdminLib.roleInfo(
534
+ ADMIN_ROLE(),
535
+ targetType,
536
+ 1,
537
+ roleName),
538
+ true); // revert on existing role
529
539
  }
530
540
 
531
541
  // create target info
542
+ Str name = StrLib.toStr(targetName);
532
543
  _targetInfo[target] = TargetInfo({
533
544
  name: name,
534
- isCustom: custom,
535
- createdAt: TimestampLib.blockTimestamp()
536
- });
545
+ targetType: targetType,
546
+ roleId: targetRoleId,
547
+ createdAt: TimestampLib.current(),
548
+ lastUpdateIn: BlocknumberLib.current()});
537
549
 
538
550
  // create name to target mapping
539
551
  _targetForName[name] = target;
540
552
 
541
- // add role to list of roles
553
+ // add target to list of targets
542
554
  _targets.push(target);
543
555
 
544
- emit LogTargetCreated(target, targetName);
556
+ // grant contract role to target
557
+ _grantRoleToAccount(targetRoleId, target);
558
+
559
+ emit LogAccessAdminTargetCreated(_adminName, targetName, managed, target, targetRoleId);
545
560
  }
546
561
 
547
562
 
548
- function _setTargetClosed(address target, bool locked)
563
+ function _setTargetLocked(address target, bool locked)
549
564
  internal
550
565
  {
551
- _checkTarget(target);
566
+ AccessAdminLib.checkTargetExists(this, target);
567
+ _authority.setTargetClosed(target, locked);
552
568
 
553
- // target locked/unlocked already
554
- if(_authority.isTargetClosed(target) == locked) {
555
- revert ErrorTargetAlreadyLocked(target, locked);
556
- }
569
+ // logging
570
+ Blocknumber lastUpdateIn = _targetInfo[target].lastUpdateIn;
571
+ _targetInfo[target].lastUpdateIn = BlocknumberLib.current();
557
572
 
558
- _authority.setTargetClosed(target, locked);
573
+ emit LogAccessAdminTargetLockedSet(_adminName, target, locked, lastUpdateIn);
559
574
  }
560
575
 
561
576
 
562
- function _checkRoleExists(
577
+ /// @dev Authorize the functions of the target for the specified role.
578
+ function _authorizeFunctions(IAuthorization authorization, Str target, RoleId roleId)
579
+ internal
580
+ {
581
+ _authorizeTargetFunctions(
582
+ getTargetForName(target),
583
+ AccessAdminLib.getAuthorizedRole(
584
+ this,
585
+ authorization,
586
+ roleId),
587
+ authorization.getAuthorizedFunctions(
588
+ target,
589
+ roleId),
590
+ false,
591
+ true);
592
+ }
593
+
594
+
595
+ /// @dev Authorize the functions of the target for the specified role.
596
+ /// Flag addFunctions determines if functions are added or removed.
597
+ function _authorizeTargetFunctions(
598
+ address target,
563
599
  RoleId roleId,
564
- bool onlyActiveRole
600
+ FunctionInfo[] memory functions,
601
+ bool onlyComponentOrContractTargets,
602
+ bool addFunctions
565
603
  )
566
604
  internal
567
- view
568
605
  {
569
- if (!roleExists(roleId)) {
570
- revert ErrorRoleUnknown(roleId);
606
+ // checks
607
+ AccessAdminLib.checkTargetAndRoleForFunctions(
608
+ this,
609
+ target,
610
+ roleId,
611
+ onlyComponentOrContractTargets);
612
+
613
+ if (addFunctions && roleId == getAdminRole()) {
614
+ revert ErrorAccessAdminAuthorizeForAdminRoleInvalid(target);
571
615
  }
572
616
 
573
- uint64 roleIdInt = RoleId.unwrap(roleId);
574
- if (roleIdInt == _authority.ADMIN_ROLE()
575
- || roleIdInt == _authority.PUBLIC_ROLE())
576
- {
577
- revert ErrorRoleIsLocked(roleId);
578
- }
617
+ _authority.setTargetFunctionRole(
618
+ target,
619
+ AccessAdminLib.getSelectors(functions),
620
+ RoleId.unwrap(roleId));
579
621
 
580
- // check if role is disabled
581
- if (onlyActiveRole && _roleInfo[roleId].pausedAt <= TimestampLib.blockTimestamp()) {
582
- revert ErrorRoleIsPaused(roleId);
622
+ // update function set and log function grantings
623
+ for (uint256 i = 0; i < functions.length; i++) {
624
+ _updateFunctionAccess(
625
+ target,
626
+ roleId,
627
+ functions[i],
628
+ addFunctions);
583
629
  }
584
630
  }
585
631
 
586
632
 
587
- /// @dev check if target exists and reverts if it doesn't
588
- function _checkTarget(address target)
633
+ function _updateFunctionAccess(
634
+ address target,
635
+ RoleId roleId,
636
+ FunctionInfo memory func,
637
+ bool addFunction
638
+ )
639
+ internal
640
+ {
641
+ // update functions info
642
+ Selector selector = func.selector;
643
+ Blocknumber lastUpdateIn = _functionInfo[target][selector].lastUpdateIn;
644
+
645
+ // update function sets
646
+ if (addFunction) { SelectorSetLib.add(_targetFunctions[target], selector); }
647
+ else { SelectorSetLib.remove(_targetFunctions[target], selector); }
648
+
649
+ _functionInfo[target][selector] = func;
650
+ _functionInfo[target][selector].lastUpdateIn = BlocknumberLib.current();
651
+
652
+ // logging
653
+ emit LogAccessAdminFunctionGranted(
654
+ _adminName,
655
+ target,
656
+ AccessAdminLib.toFunctionGrantingString(this, func.name, roleId),
657
+ lastUpdateIn);
658
+ }
659
+
660
+
661
+ function _checkAuthorization(
662
+ address authorization,
663
+ ObjectType expectedDomain,
664
+ VersionPart expectedRelease,
665
+ bool expectServiceAuthorization,
666
+ bool checkAlreadyInitialized
667
+ )
589
668
  internal
590
669
  view
591
670
  {
592
- if (!targetExists(target)) {
593
- revert ErrorTargetUnknown(target);
594
- }
671
+ AccessAdminLib.checkAuthorization(
672
+ address(_authorization),
673
+ authorization,
674
+ expectedDomain,
675
+ expectedRelease,
676
+ expectServiceAuthorization,
677
+ checkAlreadyInitialized);
595
678
  }
596
679
  }