@across-protocol/sdk 4.3.111-alpha.3 → 4.3.111

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 (566) hide show
  1. package/dist/cjs/addressAggregator/adapters/abstract.js +64 -50
  2. package/dist/cjs/addressAggregator/adapters/abstract.js.map +1 -1
  3. package/dist/cjs/addressAggregator/adapters/bybit.js +29 -16
  4. package/dist/cjs/addressAggregator/adapters/bybit.js.map +1 -1
  5. package/dist/cjs/addressAggregator/adapters/env.js +15 -11
  6. package/dist/cjs/addressAggregator/adapters/env.js.map +1 -1
  7. package/dist/cjs/addressAggregator/adapters/file.js +45 -32
  8. package/dist/cjs/addressAggregator/adapters/file.js.map +1 -1
  9. package/dist/cjs/addressAggregator/adapters/index.js +1 -1
  10. package/dist/cjs/addressAggregator/adapters/risklabs.js +36 -22
  11. package/dist/cjs/addressAggregator/adapters/risklabs.js.map +1 -1
  12. package/dist/cjs/addressAggregator/index.js +87 -57
  13. package/dist/cjs/addressAggregator/index.js.map +1 -1
  14. package/dist/cjs/apiClient/abstractClient.js +8 -9
  15. package/dist/cjs/apiClient/abstractClient.js.map +1 -1
  16. package/dist/cjs/apiClient/index.js +1 -1
  17. package/dist/cjs/apiClient/mockedClient.js +29 -23
  18. package/dist/cjs/apiClient/mockedClient.js.map +1 -1
  19. package/dist/cjs/apiClient/productionClient.js +103 -65
  20. package/dist/cjs/apiClient/productionClient.js.map +1 -1
  21. package/dist/cjs/arch/evm/BlockUtils.js +208 -122
  22. package/dist/cjs/arch/evm/BlockUtils.js.map +1 -1
  23. package/dist/cjs/arch/evm/MessageUtils.js +1 -1
  24. package/dist/cjs/arch/evm/MessageUtils.js.map +1 -1
  25. package/dist/cjs/arch/evm/SpokeUtils.js +288 -134
  26. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  27. package/dist/cjs/arch/evm/index.js +1 -1
  28. package/dist/cjs/arch/evm/utils/index.js +1 -1
  29. package/dist/cjs/arch/evm/utils/wait.js +49 -38
  30. package/dist/cjs/arch/evm/utils/wait.js.map +1 -1
  31. package/dist/cjs/arch/index.js +1 -1
  32. package/dist/cjs/arch/svm/BlockUtils.js +158 -102
  33. package/dist/cjs/arch/svm/BlockUtils.js.map +1 -1
  34. package/dist/cjs/arch/svm/MessageUtils.js +2 -2
  35. package/dist/cjs/arch/svm/MessageUtils.js.map +1 -1
  36. package/dist/cjs/arch/svm/SpokeUtils.js +1147 -708
  37. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  38. package/dist/cjs/arch/svm/encoders.js +1 -1
  39. package/dist/cjs/arch/svm/encoders.js.map +1 -1
  40. package/dist/cjs/arch/svm/eventsClient.js +236 -174
  41. package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
  42. package/dist/cjs/arch/svm/index.js +1 -1
  43. package/dist/cjs/arch/svm/provider.js +3 -3
  44. package/dist/cjs/arch/svm/provider.js.map +1 -1
  45. package/dist/cjs/arch/svm/utils.js +355 -166
  46. package/dist/cjs/arch/svm/utils.js.map +1 -1
  47. package/dist/cjs/caching/Arweave/ArweaveClient.js +246 -168
  48. package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -1
  49. package/dist/cjs/caching/Arweave/index.js +1 -1
  50. package/dist/cjs/caching/IPFS/PinataIPFSClient.js +49 -40
  51. package/dist/cjs/caching/IPFS/PinataIPFSClient.js.map +1 -1
  52. package/dist/cjs/caching/IPFS/index.js +1 -1
  53. package/dist/cjs/caching/Memory/MemoryCacheClient.js +18 -13
  54. package/dist/cjs/caching/Memory/MemoryCacheClient.js.map +1 -1
  55. package/dist/cjs/caching/Memory/index.js +1 -1
  56. package/dist/cjs/caching/index.js +1 -1
  57. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +381 -302
  58. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  59. package/dist/cjs/clients/AcrossConfigStoreClient/index.js +1 -1
  60. package/dist/cjs/clients/BaseAbstractClient.js +83 -58
  61. package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
  62. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +900 -709
  63. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  64. package/dist/cjs/clients/BundleDataClient/index.js +1 -1
  65. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +128 -95
  66. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  67. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +53 -48
  68. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  69. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +8 -10
  70. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  71. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +90 -67
  72. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  73. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +24 -46
  74. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  75. package/dist/cjs/clients/BundleDataClient/utils/index.js +1 -1
  76. package/dist/cjs/clients/HubPoolClient.js +708 -526
  77. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  78. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +179 -133
  79. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  80. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -124
  81. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  82. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +389 -357
  83. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  84. package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js +8 -9
  85. package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
  86. package/dist/cjs/clients/SpokePoolClient/index.js +3 -3
  87. package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
  88. package/dist/cjs/clients/index.js +1 -1
  89. package/dist/cjs/clients/mocks/MockConfigStoreClient.js +67 -58
  90. package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
  91. package/dist/cjs/clients/mocks/MockEvents.js +52 -47
  92. package/dist/cjs/clients/mocks/MockEvents.js.map +1 -1
  93. package/dist/cjs/clients/mocks/MockHubPoolClient.js +185 -142
  94. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  95. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +192 -208
  96. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  97. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +143 -140
  98. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  99. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +73 -57
  100. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  101. package/dist/cjs/clients/mocks/index.js +1 -1
  102. package/dist/cjs/coingecko/Coingecko.js +437 -285
  103. package/dist/cjs/coingecko/Coingecko.js.map +1 -1
  104. package/dist/cjs/coingecko/index.js +1 -1
  105. package/dist/cjs/constants.js +30 -23
  106. package/dist/cjs/constants.js.map +1 -1
  107. package/dist/cjs/contracts/acrossConfigStore.js +48 -27
  108. package/dist/cjs/contracts/acrossConfigStore.js.map +1 -1
  109. package/dist/cjs/contracts/hubPool.js +20 -36
  110. package/dist/cjs/contracts/hubPool.js.map +1 -1
  111. package/dist/cjs/contracts/index.js +1 -1
  112. package/dist/cjs/contracts/utils.js +8 -6
  113. package/dist/cjs/contracts/utils.js.map +1 -1
  114. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +16 -7
  115. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  116. package/dist/cjs/gasPriceOracle/adapters/ethereum.js +45 -26
  117. package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
  118. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +28 -16
  119. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  120. package/dist/cjs/gasPriceOracle/adapters/polygon.js +112 -73
  121. package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
  122. package/dist/cjs/gasPriceOracle/adapters/solana.js +33 -20
  123. package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -1
  124. package/dist/cjs/gasPriceOracle/oracle.js +104 -77
  125. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  126. package/dist/cjs/gasPriceOracle/types.js +3 -3
  127. package/dist/cjs/gasPriceOracle/types.js.map +1 -1
  128. package/dist/cjs/gasPriceOracle/util.js +8 -8
  129. package/dist/cjs/gasPriceOracle/util.js.map +1 -1
  130. package/dist/cjs/index.js +1 -1
  131. package/dist/cjs/interfaces/index.js +1 -1
  132. package/dist/cjs/lpFeeCalculator/index.js +1 -1
  133. package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js +35 -33
  134. package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
  135. package/dist/cjs/lpFeeCalculator/rateModel.js +9 -7
  136. package/dist/cjs/lpFeeCalculator/rateModel.js.map +1 -1
  137. package/dist/cjs/merkleDistributor/MerkleDistributor.js +18 -20
  138. package/dist/cjs/merkleDistributor/MerkleDistributor.js.map +1 -1
  139. package/dist/cjs/merkleDistributor/index.js +1 -1
  140. package/dist/cjs/merkleDistributor/model/index.js +1 -1
  141. package/dist/cjs/pool/TransactionManager.js +100 -45
  142. package/dist/cjs/pool/TransactionManager.js.map +1 -1
  143. package/dist/cjs/pool/index.js +1 -1
  144. package/dist/cjs/pool/poolClient.js +731 -464
  145. package/dist/cjs/pool/poolClient.js.map +1 -1
  146. package/dist/cjs/pool/uma/across/index.js +1 -1
  147. package/dist/cjs/pool/uma/across/transactionManager.js +100 -45
  148. package/dist/cjs/pool/uma/across/transactionManager.js.map +1 -1
  149. package/dist/cjs/pool/uma/clients/erc20/client.js +16 -18
  150. package/dist/cjs/pool/uma/clients/erc20/client.js.map +1 -1
  151. package/dist/cjs/pool/uma/clients/erc20/index.js +1 -1
  152. package/dist/cjs/pool/uma/clients/index.js +1 -1
  153. package/dist/cjs/pool/uma/index.js +1 -1
  154. package/dist/cjs/pool/uma/oracle/index.js +1 -1
  155. package/dist/cjs/pool/uma/oracle/utils.js +5 -4
  156. package/dist/cjs/pool/uma/oracle/utils.js.map +1 -1
  157. package/dist/cjs/pool/uma/utils.js +30 -11
  158. package/dist/cjs/pool/uma/utils.js.map +1 -1
  159. package/dist/cjs/priceClient/adapters/acrossApi.js +39 -22
  160. package/dist/cjs/priceClient/adapters/acrossApi.js.map +1 -1
  161. package/dist/cjs/priceClient/adapters/baseAdapter.js +73 -49
  162. package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -1
  163. package/dist/cjs/priceClient/adapters/coingecko.js +61 -34
  164. package/dist/cjs/priceClient/adapters/coingecko.js.map +1 -1
  165. package/dist/cjs/priceClient/adapters/default.js +31 -16
  166. package/dist/cjs/priceClient/adapters/default.js.map +1 -1
  167. package/dist/cjs/priceClient/adapters/defiLlama.js +74 -40
  168. package/dist/cjs/priceClient/adapters/defiLlama.js.map +1 -1
  169. package/dist/cjs/priceClient/adapters/index.js +1 -1
  170. package/dist/cjs/priceClient/index.js +1 -1
  171. package/dist/cjs/priceClient/priceClient.js +159 -110
  172. package/dist/cjs/priceClient/priceClient.js.map +1 -1
  173. package/dist/cjs/providers/alchemy.js +19 -17
  174. package/dist/cjs/providers/alchemy.js.map +1 -1
  175. package/dist/cjs/providers/cachedProvider.js +129 -88
  176. package/dist/cjs/providers/cachedProvider.js.map +1 -1
  177. package/dist/cjs/providers/drpc.js +11 -9
  178. package/dist/cjs/providers/drpc.js.map +1 -1
  179. package/dist/cjs/providers/index.js +1 -1
  180. package/dist/cjs/providers/infura.js +12 -10
  181. package/dist/cjs/providers/infura.js.map +1 -1
  182. package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +15 -7
  183. package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
  184. package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -6
  185. package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
  186. package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js +15 -7
  187. package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
  188. package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +66 -42
  189. package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
  190. package/dist/cjs/providers/mocks/index.js +1 -1
  191. package/dist/cjs/providers/mocks/mockEthersProvider.js +31 -29
  192. package/dist/cjs/providers/mocks/mockEthersProvider.js.map +1 -1
  193. package/dist/cjs/providers/quicknode.js +21 -19
  194. package/dist/cjs/providers/quicknode.js.map +1 -1
  195. package/dist/cjs/providers/rateLimitedProvider.js +79 -64
  196. package/dist/cjs/providers/rateLimitedProvider.js.map +1 -1
  197. package/dist/cjs/providers/retryProvider.js +246 -163
  198. package/dist/cjs/providers/retryProvider.js.map +1 -1
  199. package/dist/cjs/providers/solana/baseRpcFactories.js +18 -14
  200. package/dist/cjs/providers/solana/baseRpcFactories.js.map +1 -1
  201. package/dist/cjs/providers/solana/cachedRpcFactory.js +112 -70
  202. package/dist/cjs/providers/solana/cachedRpcFactory.js.map +1 -1
  203. package/dist/cjs/providers/solana/defaultRpcFactory.js +15 -8
  204. package/dist/cjs/providers/solana/defaultRpcFactory.js.map +1 -1
  205. package/dist/cjs/providers/solana/index.js +1 -1
  206. package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js +191 -135
  207. package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
  208. package/dist/cjs/providers/solana/rateLimitedRpcFactory.js +90 -67
  209. package/dist/cjs/providers/solana/rateLimitedRpcFactory.js.map +1 -1
  210. package/dist/cjs/providers/solana/retryRpcFactory.js +79 -52
  211. package/dist/cjs/providers/solana/retryRpcFactory.js.map +1 -1
  212. package/dist/cjs/providers/solana/utils.js +2 -2
  213. package/dist/cjs/providers/solana/utils.js.map +1 -1
  214. package/dist/cjs/providers/speedProvider.js +53 -31
  215. package/dist/cjs/providers/speedProvider.js.map +1 -1
  216. package/dist/cjs/providers/types.js +1 -1
  217. package/dist/cjs/providers/types.js.map +1 -1
  218. package/dist/cjs/providers/utils.js +28 -26
  219. package/dist/cjs/providers/utils.js.map +1 -1
  220. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +162 -108
  221. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  222. package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js +26 -14
  223. package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
  224. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +29 -20
  225. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  226. package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -1
  227. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +137 -88
  228. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  229. package/dist/cjs/relayFeeCalculator/index.js +1 -1
  230. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +297 -199
  231. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  232. package/dist/cjs/typeguards/error.js +7 -5
  233. package/dist/cjs/typeguards/error.js.map +1 -1
  234. package/dist/cjs/typeguards/index.js +1 -1
  235. package/dist/cjs/utils/AddressUtils.js +144 -117
  236. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  237. package/dist/cjs/utils/ArrayUtils.js +78 -21
  238. package/dist/cjs/utils/ArrayUtils.js.map +1 -1
  239. package/dist/cjs/utils/BigNumberUtils.js +10 -9
  240. package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
  241. package/dist/cjs/utils/BlockExplorerUtils.js +30 -26
  242. package/dist/cjs/utils/BlockExplorerUtils.js.map +1 -1
  243. package/dist/cjs/utils/BlockFinder.js +5 -2
  244. package/dist/cjs/utils/BlockFinder.js.map +1 -1
  245. package/dist/cjs/utils/BlockUtils.js +41 -24
  246. package/dist/cjs/utils/BlockUtils.js.map +1 -1
  247. package/dist/cjs/utils/BundleUtils.js +24 -21
  248. package/dist/cjs/utils/BundleUtils.js.map +1 -1
  249. package/dist/cjs/utils/CCTPUtils.js +126 -62
  250. package/dist/cjs/utils/CCTPUtils.js.map +1 -1
  251. package/dist/cjs/utils/CachingUtils.js +42 -20
  252. package/dist/cjs/utils/CachingUtils.js.map +1 -1
  253. package/dist/cjs/utils/ContractUtils.js +5 -5
  254. package/dist/cjs/utils/ContractUtils.js.map +1 -1
  255. package/dist/cjs/utils/DepositUtils.js +99 -122
  256. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  257. package/dist/cjs/utils/EventUtils.js +70 -49
  258. package/dist/cjs/utils/EventUtils.js.map +1 -1
  259. package/dist/cjs/utils/FormattingUtils.js +32 -26
  260. package/dist/cjs/utils/FormattingUtils.js.map +1 -1
  261. package/dist/cjs/utils/HyperLiquidUtils.js +23 -10
  262. package/dist/cjs/utils/HyperLiquidUtils.js.map +1 -1
  263. package/dist/cjs/utils/IPFSUtils.js +34 -16
  264. package/dist/cjs/utils/IPFSUtils.js.map +1 -1
  265. package/dist/cjs/utils/JSONUtils.js +6 -6
  266. package/dist/cjs/utils/JSONUtils.js.map +1 -1
  267. package/dist/cjs/utils/LogUtils.js +12 -10
  268. package/dist/cjs/utils/LogUtils.js.map +1 -1
  269. package/dist/cjs/utils/Multicall.js +115 -56
  270. package/dist/cjs/utils/Multicall.js.map +1 -1
  271. package/dist/cjs/utils/NetworkUtils.js +28 -12
  272. package/dist/cjs/utils/NetworkUtils.js.map +1 -1
  273. package/dist/cjs/utils/NumberUtils.js +3 -1
  274. package/dist/cjs/utils/NumberUtils.js.map +1 -1
  275. package/dist/cjs/utils/ObjectUtils.js +41 -27
  276. package/dist/cjs/utils/ObjectUtils.js.map +1 -1
  277. package/dist/cjs/utils/Profiler.js +83 -80
  278. package/dist/cjs/utils/Profiler.js.map +1 -1
  279. package/dist/cjs/utils/ReviverUtils.js +9 -5
  280. package/dist/cjs/utils/ReviverUtils.js.map +1 -1
  281. package/dist/cjs/utils/SpokeUtils.js +84 -84
  282. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  283. package/dist/cjs/utils/TokenUtils.js +64 -41
  284. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  285. package/dist/cjs/utils/TypeGuards.js +1 -1
  286. package/dist/cjs/utils/TypeGuards.js.map +1 -1
  287. package/dist/cjs/utils/ValidatorUtils.js +7 -7
  288. package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
  289. package/dist/cjs/utils/abi/contracts/index.js +1 -1
  290. package/dist/cjs/utils/abi/index.js +22 -12
  291. package/dist/cjs/utils/abi/index.js.map +1 -1
  292. package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js +12 -9
  293. package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
  294. package/dist/cjs/utils/abi/typechain/index.js +1 -1
  295. package/dist/cjs/utils/common.js +53 -40
  296. package/dist/cjs/utils/common.js.map +1 -1
  297. package/dist/cjs/utils/index.js +1 -1
  298. package/dist/esm/addressAggregator/adapters/abstract.js +64 -48
  299. package/dist/esm/addressAggregator/adapters/abstract.js.map +1 -1
  300. package/dist/esm/addressAggregator/adapters/bybit.js +29 -15
  301. package/dist/esm/addressAggregator/adapters/bybit.js.map +1 -1
  302. package/dist/esm/addressAggregator/adapters/env.js +14 -9
  303. package/dist/esm/addressAggregator/adapters/env.js.map +1 -1
  304. package/dist/esm/addressAggregator/adapters/file.js +43 -29
  305. package/dist/esm/addressAggregator/adapters/file.js.map +1 -1
  306. package/dist/esm/addressAggregator/adapters/risklabs.js +35 -20
  307. package/dist/esm/addressAggregator/adapters/risklabs.js.map +1 -1
  308. package/dist/esm/addressAggregator/index.js +83 -52
  309. package/dist/esm/addressAggregator/index.js.map +1 -1
  310. package/dist/esm/addressAggregator/types.js +1 -1
  311. package/dist/esm/addressAggregator/types.js.map +1 -1
  312. package/dist/esm/apiClient/abstractClient.js +9 -15
  313. package/dist/esm/apiClient/abstractClient.js.map +1 -1
  314. package/dist/esm/apiClient/mockedClient.js +26 -21
  315. package/dist/esm/apiClient/mockedClient.js.map +1 -1
  316. package/dist/esm/apiClient/productionClient.js +101 -61
  317. package/dist/esm/apiClient/productionClient.js.map +1 -1
  318. package/dist/esm/arch/evm/BlockUtils.js +217 -139
  319. package/dist/esm/arch/evm/BlockUtils.js.map +1 -1
  320. package/dist/esm/arch/evm/SpokeUtils.js +289 -146
  321. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  322. package/dist/esm/arch/evm/utils/wait.js +46 -34
  323. package/dist/esm/arch/evm/utils/wait.js.map +1 -1
  324. package/dist/esm/arch/svm/BlockUtils.js +166 -118
  325. package/dist/esm/arch/svm/BlockUtils.js.map +1 -1
  326. package/dist/esm/arch/svm/SpokeUtils.js +1150 -738
  327. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  328. package/dist/esm/arch/svm/constants.js +1 -1
  329. package/dist/esm/arch/svm/constants.js.map +1 -1
  330. package/dist/esm/arch/svm/eventsClient.js +232 -172
  331. package/dist/esm/arch/svm/eventsClient.js.map +1 -1
  332. package/dist/esm/arch/svm/provider.js +1 -1
  333. package/dist/esm/arch/svm/provider.js.map +1 -1
  334. package/dist/esm/arch/svm/utils.js +345 -155
  335. package/dist/esm/arch/svm/utils.js.map +1 -1
  336. package/dist/esm/caching/Arweave/ArweaveClient.js +256 -182
  337. package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -1
  338. package/dist/esm/caching/IPFS/PinataIPFSClient.js +48 -47
  339. package/dist/esm/caching/IPFS/PinataIPFSClient.js.map +1 -1
  340. package/dist/esm/caching/Memory/MemoryCacheClient.js +19 -13
  341. package/dist/esm/caching/Memory/MemoryCacheClient.js.map +1 -1
  342. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +408 -333
  343. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  344. package/dist/esm/clients/BaseAbstractClient.js +92 -66
  345. package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
  346. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1054 -927
  347. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  348. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +131 -102
  349. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  350. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +59 -57
  351. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  352. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -7
  353. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  354. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +94 -75
  355. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  356. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +23 -45
  357. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  358. package/dist/esm/clients/HubPoolClient.js +740 -581
  359. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  360. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +178 -133
  361. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  362. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -126
  363. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  364. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +399 -372
  365. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  366. package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js +9 -9
  367. package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
  368. package/dist/esm/clients/SpokePoolClient/index.js +2 -2
  369. package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
  370. package/dist/esm/clients/SpokePoolClient/types.js +2 -2
  371. package/dist/esm/clients/SpokePoolClient/types.js.map +1 -1
  372. package/dist/esm/clients/mocks/MockConfigStoreClient.js +64 -53
  373. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  374. package/dist/esm/clients/mocks/MockEvents.js +49 -42
  375. package/dist/esm/clients/mocks/MockEvents.js.map +1 -1
  376. package/dist/esm/clients/mocks/MockHubPoolClient.js +182 -138
  377. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  378. package/dist/esm/clients/mocks/MockSpokePoolClient.js +188 -202
  379. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  380. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +132 -127
  381. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  382. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +69 -53
  383. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  384. package/dist/esm/coingecko/Coingecko.js +443 -298
  385. package/dist/esm/coingecko/Coingecko.js.map +1 -1
  386. package/dist/esm/constants.js +47 -40
  387. package/dist/esm/constants.js.map +1 -1
  388. package/dist/esm/contracts/acrossConfigStore.js +46 -24
  389. package/dist/esm/contracts/acrossConfigStore.js.map +1 -1
  390. package/dist/esm/contracts/hubPool.js +18 -34
  391. package/dist/esm/contracts/hubPool.js.map +1 -1
  392. package/dist/esm/contracts/utils.js +5 -3
  393. package/dist/esm/contracts/utils.js.map +1 -1
  394. package/dist/esm/gasPriceOracle/adapters/arbitrum.js +14 -6
  395. package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  396. package/dist/esm/gasPriceOracle/adapters/ethereum.js +42 -22
  397. package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
  398. package/dist/esm/gasPriceOracle/adapters/linea-viem.js +25 -13
  399. package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  400. package/dist/esm/gasPriceOracle/adapters/polygon.js +108 -72
  401. package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
  402. package/dist/esm/gasPriceOracle/adapters/solana.js +31 -22
  403. package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -1
  404. package/dist/esm/gasPriceOracle/oracle.js +96 -70
  405. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  406. package/dist/esm/gasPriceOracle/types.js +2 -2
  407. package/dist/esm/gasPriceOracle/types.js.map +1 -1
  408. package/dist/esm/gasPriceOracle/util.js +4 -4
  409. package/dist/esm/gasPriceOracle/util.js.map +1 -1
  410. package/dist/esm/lpFeeCalculator/lpFeeCalculator.js +33 -30
  411. package/dist/esm/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
  412. package/dist/esm/lpFeeCalculator/rateModel.js +9 -7
  413. package/dist/esm/lpFeeCalculator/rateModel.js.map +1 -1
  414. package/dist/esm/merkleDistributor/MerkleDistributor.js +17 -18
  415. package/dist/esm/merkleDistributor/MerkleDistributor.js.map +1 -1
  416. package/dist/esm/pool/TransactionManager.js +100 -45
  417. package/dist/esm/pool/TransactionManager.js.map +1 -1
  418. package/dist/esm/pool/poolClient.js +740 -479
  419. package/dist/esm/pool/poolClient.js.map +1 -1
  420. package/dist/esm/pool/uma/across/constants.js +2 -2
  421. package/dist/esm/pool/uma/across/constants.js.map +1 -1
  422. package/dist/esm/pool/uma/across/transactionManager.js +100 -45
  423. package/dist/esm/pool/uma/across/transactionManager.js.map +1 -1
  424. package/dist/esm/pool/uma/clients/erc20/client.js +13 -15
  425. package/dist/esm/pool/uma/clients/erc20/client.js.map +1 -1
  426. package/dist/esm/pool/uma/oracle/utils.js +3 -2
  427. package/dist/esm/pool/uma/oracle/utils.js.map +1 -1
  428. package/dist/esm/pool/uma/utils.js +28 -9
  429. package/dist/esm/pool/uma/utils.js.map +1 -1
  430. package/dist/esm/priceClient/adapters/acrossApi.js +40 -21
  431. package/dist/esm/priceClient/adapters/acrossApi.js.map +1 -1
  432. package/dist/esm/priceClient/adapters/baseAdapter.js +72 -46
  433. package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -1
  434. package/dist/esm/priceClient/adapters/coingecko.js +61 -33
  435. package/dist/esm/priceClient/adapters/coingecko.js.map +1 -1
  436. package/dist/esm/priceClient/adapters/default.js +31 -15
  437. package/dist/esm/priceClient/adapters/default.js.map +1 -1
  438. package/dist/esm/priceClient/adapters/defiLlama.js +73 -38
  439. package/dist/esm/priceClient/adapters/defiLlama.js.map +1 -1
  440. package/dist/esm/priceClient/priceClient.js +158 -109
  441. package/dist/esm/priceClient/priceClient.js.map +1 -1
  442. package/dist/esm/providers/alchemy.js +18 -16
  443. package/dist/esm/providers/alchemy.js.map +1 -1
  444. package/dist/esm/providers/cachedProvider.js +134 -99
  445. package/dist/esm/providers/cachedProvider.js.map +1 -1
  446. package/dist/esm/providers/constants.js +3 -3
  447. package/dist/esm/providers/constants.js.map +1 -1
  448. package/dist/esm/providers/drpc.js +10 -8
  449. package/dist/esm/providers/drpc.js.map +1 -1
  450. package/dist/esm/providers/infura.js +11 -9
  451. package/dist/esm/providers/infura.js.map +1 -1
  452. package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +15 -6
  453. package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
  454. package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -5
  455. package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
  456. package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js +15 -6
  457. package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
  458. package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +66 -41
  459. package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
  460. package/dist/esm/providers/mocks/mockEthersProvider.js +30 -27
  461. package/dist/esm/providers/mocks/mockEthersProvider.js.map +1 -1
  462. package/dist/esm/providers/quicknode.js +20 -18
  463. package/dist/esm/providers/quicknode.js.map +1 -1
  464. package/dist/esm/providers/rateLimitedProvider.js +80 -68
  465. package/dist/esm/providers/rateLimitedProvider.js.map +1 -1
  466. package/dist/esm/providers/retryProvider.js +259 -186
  467. package/dist/esm/providers/retryProvider.js.map +1 -1
  468. package/dist/esm/providers/solana/baseRpcFactories.js +19 -13
  469. package/dist/esm/providers/solana/baseRpcFactories.js.map +1 -1
  470. package/dist/esm/providers/solana/cachedRpcFactory.js +112 -75
  471. package/dist/esm/providers/solana/cachedRpcFactory.js.map +1 -1
  472. package/dist/esm/providers/solana/defaultRpcFactory.js +14 -6
  473. package/dist/esm/providers/solana/defaultRpcFactory.js.map +1 -1
  474. package/dist/esm/providers/solana/quorumFallbackRpcFactory.js +202 -149
  475. package/dist/esm/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
  476. package/dist/esm/providers/solana/rateLimitedRpcFactory.js +90 -70
  477. package/dist/esm/providers/solana/rateLimitedRpcFactory.js.map +1 -1
  478. package/dist/esm/providers/solana/retryRpcFactory.js +74 -50
  479. package/dist/esm/providers/solana/retryRpcFactory.js.map +1 -1
  480. package/dist/esm/providers/solana/utils.js +1 -1
  481. package/dist/esm/providers/solana/utils.js.map +1 -1
  482. package/dist/esm/providers/speedProvider.js +51 -28
  483. package/dist/esm/providers/speedProvider.js.map +1 -1
  484. package/dist/esm/providers/types.js +2 -2
  485. package/dist/esm/providers/types.js.map +1 -1
  486. package/dist/esm/providers/utils.js +20 -17
  487. package/dist/esm/providers/utils.js.map +1 -1
  488. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +152 -98
  489. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  490. package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js +26 -13
  491. package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
  492. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +19 -9
  493. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  494. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +128 -83
  495. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  496. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +299 -211
  497. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  498. package/dist/esm/typeguards/error.js +5 -3
  499. package/dist/esm/typeguards/error.js.map +1 -1
  500. package/dist/esm/utils/AddressUtils.js +147 -115
  501. package/dist/esm/utils/AddressUtils.js.map +1 -1
  502. package/dist/esm/utils/ArrayUtils.js +78 -21
  503. package/dist/esm/utils/ArrayUtils.js.map +1 -1
  504. package/dist/esm/utils/BigNumberUtils.js +12 -11
  505. package/dist/esm/utils/BigNumberUtils.js.map +1 -1
  506. package/dist/esm/utils/BlockExplorerUtils.js +23 -19
  507. package/dist/esm/utils/BlockExplorerUtils.js.map +1 -1
  508. package/dist/esm/utils/BlockFinder.js +6 -2
  509. package/dist/esm/utils/BlockFinder.js.map +1 -1
  510. package/dist/esm/utils/BlockUtils.js +40 -31
  511. package/dist/esm/utils/BlockUtils.js.map +1 -1
  512. package/dist/esm/utils/BundleUtils.js +24 -21
  513. package/dist/esm/utils/BundleUtils.js.map +1 -1
  514. package/dist/esm/utils/CCTPUtils.js +123 -62
  515. package/dist/esm/utils/CCTPUtils.js.map +1 -1
  516. package/dist/esm/utils/CachingUtils.js +38 -17
  517. package/dist/esm/utils/CachingUtils.js.map +1 -1
  518. package/dist/esm/utils/ContractUtils.js +3 -3
  519. package/dist/esm/utils/ContractUtils.js.map +1 -1
  520. package/dist/esm/utils/DepositUtils.js +98 -121
  521. package/dist/esm/utils/DepositUtils.js.map +1 -1
  522. package/dist/esm/utils/EventUtils.js +69 -52
  523. package/dist/esm/utils/EventUtils.js.map +1 -1
  524. package/dist/esm/utils/FormattingUtils.js +26 -20
  525. package/dist/esm/utils/FormattingUtils.js.map +1 -1
  526. package/dist/esm/utils/HyperLiquidUtils.js +22 -8
  527. package/dist/esm/utils/HyperLiquidUtils.js.map +1 -1
  528. package/dist/esm/utils/IPFSUtils.js +35 -16
  529. package/dist/esm/utils/IPFSUtils.js.map +1 -1
  530. package/dist/esm/utils/JSONUtils.js +4 -4
  531. package/dist/esm/utils/JSONUtils.js.map +1 -1
  532. package/dist/esm/utils/LogUtils.js +12 -8
  533. package/dist/esm/utils/LogUtils.js.map +1 -1
  534. package/dist/esm/utils/Multicall.js +110 -50
  535. package/dist/esm/utils/Multicall.js.map +1 -1
  536. package/dist/esm/utils/NetworkUtils.js +28 -12
  537. package/dist/esm/utils/NetworkUtils.js.map +1 -1
  538. package/dist/esm/utils/NumberUtils.js +3 -1
  539. package/dist/esm/utils/NumberUtils.js.map +1 -1
  540. package/dist/esm/utils/ObjectUtils.js +41 -27
  541. package/dist/esm/utils/ObjectUtils.js.map +1 -1
  542. package/dist/esm/utils/Profiler.js +82 -77
  543. package/dist/esm/utils/Profiler.js.map +1 -1
  544. package/dist/esm/utils/ReviverUtils.js +7 -3
  545. package/dist/esm/utils/ReviverUtils.js.map +1 -1
  546. package/dist/esm/utils/SpokeUtils.js +78 -83
  547. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  548. package/dist/esm/utils/TokenUtils.js +57 -33
  549. package/dist/esm/utils/TokenUtils.js.map +1 -1
  550. package/dist/esm/utils/ValidatorUtils.js +4 -4
  551. package/dist/esm/utils/ValidatorUtils.js.map +1 -1
  552. package/dist/esm/utils/abi/index.js +20 -10
  553. package/dist/esm/utils/abi/index.js.map +1 -1
  554. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js +12 -8
  555. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
  556. package/dist/esm/utils/common.js +52 -38
  557. package/dist/esm/utils/common.js.map +1 -1
  558. package/dist/types/constants.d.ts.map +1 -1
  559. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  560. package/dist/types/utils/Multicall.d.ts.map +1 -1
  561. package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
  562. package/package.json +3 -3
  563. package/src/constants.ts +1 -0
  564. package/src/gasPriceOracle/oracle.ts +1 -0
  565. package/src/utils/Multicall.ts +1 -0
  566. package/src/utils/NetworkUtils.ts +8 -1
@@ -1,3 +1,4 @@
1
+ import { __assign, __awaiter, __extends, __generator, __rest, __spreadArray } from "tslib";
1
2
  import assert from "assert";
2
3
  import { isError } from "../../typeguards";
3
4
  import { averageBlockTime } from "../../arch/evm";
@@ -8,7 +9,7 @@ import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "
8
9
  import { parseAndReturnRateModelFromString } from "../../lpFeeCalculator/rateModel";
9
10
  // Version 0 is the implicit ConfigStore version from before the version attribute was introduced.
10
11
  // @dev Do not change this value.
11
- export const DEFAULT_CONFIG_STORE_VERSION = 0;
12
+ export var DEFAULT_CONFIG_STORE_VERSION = 0;
12
13
  export var GLOBAL_CONFIG_STORE_KEYS;
13
14
  (function (GLOBAL_CONFIG_STORE_KEYS) {
14
15
  GLOBAL_CONFIG_STORE_KEYS["MAX_RELAYER_REPAYMENT_LEAF_SIZE"] = "MAX_RELAYER_REPAYMENT_LEAF_SIZE";
@@ -19,7 +20,7 @@ export var GLOBAL_CONFIG_STORE_KEYS;
19
20
  GLOBAL_CONFIG_STORE_KEYS["LITE_CHAIN_ID_INDICES"] = "LITE_CHAIN_ID_INDICES";
20
21
  })(GLOBAL_CONFIG_STORE_KEYS || (GLOBAL_CONFIG_STORE_KEYS = {}));
21
22
  // Conveniently store known invalid token config update hashes to avoid spamming debug logs.
22
- const KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
23
+ var KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
23
24
  "0x422abc617c6598e4b91859f99c392939d2034c1a839a342a963a34a2f0390195",
24
25
  "0x36c85e388279714b2c98d46e3377dc37a1575665b2cac5e52fe97d8d77efcd2b",
25
26
  "0x6f0a93119e538dd84e02adfce821fb4e6dd9baddcceb041977e8ba3c39185ab8",
@@ -34,52 +35,55 @@ const KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
34
35
  "0x89830f5e81b9e8b44ac2f8966b2fa4bf8e71d7f546e2bc0e773d8ee8df4bdb36",
35
36
  "0xb0ad6270124c925a234d9c4f87b60396f2b52fdc250cd2fc9cac792d0d62e467",
36
37
  "0x779bc3bf2dba1128d5dda6be8ae99b503cae23343a7265a86bca3d5572ed4268",
37
- ].map((hash) => hash.toLowerCase());
38
- export class AcrossConfigStoreClient extends BaseAbstractClient {
39
- logger;
40
- configStore;
41
- configStoreVersion;
42
- cumulativeRateModelUpdates = [];
43
- cumulativeRouteRateModelUpdates = [];
44
- cumulativeMaxRefundCountUpdates = [];
45
- cumulativeMaxL1TokenCountUpdates = [];
46
- chainIdIndicesUpdates = [];
47
- liteChainIndicesUpdates = [];
48
- cumulativeSpokeTargetBalanceUpdates = [];
49
- cumulativeConfigStoreVersionUpdates = [];
50
- cumulativeDisabledChainUpdates = [];
51
- hasLatestConfigStoreVersion = false;
52
- chainId;
53
- constructor(logger, configStore, eventSearchConfig = { from: 0, maxLookBack: 0 }, configStoreVersion) {
54
- super(eventSearchConfig);
55
- this.logger = logger;
56
- this.configStore = configStore;
57
- this.configStoreVersion = configStoreVersion;
58
- this.firstHeightToSearch = eventSearchConfig.from;
59
- this.latestHeightSearched = 0;
38
+ ].map(function (hash) { return hash.toLowerCase(); });
39
+ var AcrossConfigStoreClient = /** @class */ (function (_super) {
40
+ __extends(AcrossConfigStoreClient, _super);
41
+ function AcrossConfigStoreClient(logger, configStore, eventSearchConfig, configStoreVersion) {
42
+ if (eventSearchConfig === void 0) { eventSearchConfig = { from: 0, maxLookBack: 0 }; }
43
+ var _this = _super.call(this, eventSearchConfig) || this;
44
+ _this.logger = logger;
45
+ _this.configStore = configStore;
46
+ _this.configStoreVersion = configStoreVersion;
47
+ _this.cumulativeRateModelUpdates = [];
48
+ _this.cumulativeRouteRateModelUpdates = [];
49
+ _this.cumulativeMaxRefundCountUpdates = [];
50
+ _this.cumulativeMaxL1TokenCountUpdates = [];
51
+ _this.chainIdIndicesUpdates = [];
52
+ _this.liteChainIndicesUpdates = [];
53
+ _this.cumulativeSpokeTargetBalanceUpdates = [];
54
+ _this.cumulativeConfigStoreVersionUpdates = [];
55
+ _this.cumulativeDisabledChainUpdates = [];
56
+ _this.hasLatestConfigStoreVersion = false;
57
+ _this.firstHeightToSearch = eventSearchConfig.from;
58
+ _this.latestHeightSearched = 0;
59
+ return _this;
60
60
  }
61
- getRateModelForBlockNumber(l1Token, originChainId, destinationChainId, blockNumber = undefined) {
61
+ AcrossConfigStoreClient.prototype.getRateModelForBlockNumber = function (l1Token, originChainId, destinationChainId, blockNumber) {
62
+ if (blockNumber === void 0) { blockNumber = undefined; }
62
63
  // Use route-rate model if available, otherwise use default rate model for l1Token.
63
- const route = `${originChainId}-${destinationChainId}`;
64
- const routeRateModel = this.getRouteRateModelForBlockNumber(l1Token, route, blockNumber);
64
+ var route = "".concat(originChainId, "-").concat(destinationChainId);
65
+ var routeRateModel = this.getRouteRateModelForBlockNumber(l1Token, route, blockNumber);
65
66
  if (routeRateModel) {
66
67
  return routeRateModel;
67
68
  }
68
- const defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find((config) => config.blockNumber <= (blockNumber ?? 0) &&
69
- config.l1Token === l1Token.toEvmAddress() &&
70
- config.rateModel !== undefined);
69
+ var defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find(function (config) {
70
+ return config.blockNumber <= (blockNumber !== null && blockNumber !== void 0 ? blockNumber : 0) &&
71
+ config.l1Token === l1Token.toEvmAddress() &&
72
+ config.rateModel !== undefined;
73
+ });
71
74
  if (!defaultRateModelUpdate) {
72
- throw new Error(`Could not find TokenConfig update for ${l1Token} at block ${blockNumber}`);
75
+ throw new Error("Could not find TokenConfig update for ".concat(l1Token, " at block ").concat(blockNumber));
73
76
  }
74
77
  return parseAndReturnRateModelFromString(defaultRateModelUpdate.rateModel);
75
- }
76
- getRouteRateModelForBlockNumber(l1Token, route, blockNumber = undefined) {
77
- const config = sortEventsDescending(this.cumulativeRouteRateModelUpdates).find((config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token.toEvmAddress());
78
- if (config?.routeRateModel[route] === undefined) {
78
+ };
79
+ AcrossConfigStoreClient.prototype.getRouteRateModelForBlockNumber = function (l1Token, route, blockNumber) {
80
+ if (blockNumber === void 0) { blockNumber = undefined; }
81
+ var config = sortEventsDescending(this.cumulativeRouteRateModelUpdates).find(function (config) { return config.blockNumber <= (blockNumber !== null && blockNumber !== void 0 ? blockNumber : 0) && config.l1Token === l1Token.toEvmAddress(); });
82
+ if ((config === null || config === void 0 ? void 0 : config.routeRateModel[route]) === undefined) {
79
83
  return undefined;
80
84
  }
81
85
  return parseAndReturnRateModelFromString(config.routeRateModel[route]);
82
- }
86
+ };
83
87
  /**
84
88
  * Resolve the implied set of chain ID indices based on the chain ID of the ConfigStore.
85
89
  * @param chainId Chain ID of the ConfigStore.
@@ -88,10 +92,10 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
88
92
  * @dev The protocol defaults are [1, 10, 137, 288, 42161] (outlined in UMIP-157).
89
93
  * @dev chainId is marked optional to appease tsc. It must always be passed in.
90
94
  */
91
- implicitChainIdIndices(chainId) {
95
+ AcrossConfigStoreClient.prototype.implicitChainIdIndices = function (chainId) {
92
96
  assert(isDefined(chainId), "ConfigStoreClient used before update");
93
97
  return PROTOCOL_DEFAULT_CHAIN_ID_INDICES[0] === chainId ? PROTOCOL_DEFAULT_CHAIN_ID_INDICES : [chainId];
94
- }
98
+ };
95
99
  /**
96
100
  * Resolves the chain ids that were available to the protocol at a given block range.
97
101
  * @param blockNumber Block number to search for. Defaults to latest block.
@@ -103,64 +107,75 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
103
107
  * this key/value entry, the function will return the default list of chain IDs as
104
108
  * outlined per the UMIP (https://github.com/UMAprotocol/UMIPs/pull/590).
105
109
  */
106
- getChainIdIndicesForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
110
+ AcrossConfigStoreClient.prototype.getChainIdIndicesForBlock = function (blockNumber) {
111
+ var _a;
112
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
107
113
  // Resolve the chain ID indices for the block number requested.
108
- const chainIdUpdates = sortEventsDescending(this.chainIdIndicesUpdates);
114
+ var chainIdUpdates = sortEventsDescending(this.chainIdIndicesUpdates);
109
115
  // Iterate through each of the chain ID updates and resolve the first update that is
110
116
  // less than or equal to the block number requested.
111
- const chainIdIndices = chainIdUpdates.find((update) => update.blockNumber <= blockNumber)?.value;
117
+ var chainIdIndices = (_a = chainIdUpdates.find(function (update) { return update.blockNumber <= blockNumber; })) === null || _a === void 0 ? void 0 : _a.value;
112
118
  // Return either the found value or the protocol default.
113
- return chainIdIndices ?? this.implicitChainIdIndices(this.chainId);
114
- }
119
+ return chainIdIndices !== null && chainIdIndices !== void 0 ? chainIdIndices : this.implicitChainIdIndices(this.chainId);
120
+ };
115
121
  /**
116
122
  * Resolves the lite chain ids that were available to the protocol at a given block range.
117
123
  * @param blockNumber Block number to search for. Defaults to latest block.
118
124
  * @returns List of lite chain IDs that were available to the protocol at the given block number.
119
125
  * @note This dynamic functionality has been added after the launch of Across.
120
126
  */
121
- getLiteChainIdIndicesForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
122
- const liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
123
- return liteChainIdList.find((update) => update.blockNumber <= blockNumber)?.value ?? [];
124
- }
127
+ AcrossConfigStoreClient.prototype.getLiteChainIdIndicesForBlock = function (blockNumber) {
128
+ var _a, _b;
129
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
130
+ var liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
131
+ return (_b = (_a = liteChainIdList.find(function (update) { return update.blockNumber <= blockNumber; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : [];
132
+ };
125
133
  /**
126
134
  * Resolves the lite chain ids that were available to the protocol at a given timestamp.
127
135
  * @param timestamp Timestamp to search for. Defaults to latest time - in seconds.
128
136
  * @returns List of lite chain IDs that were available to the protocol at the given timestamp.
129
137
  * @note This dynamic functionality has been added after the launch of Across.
130
138
  */
131
- getLiteChainIdIndicesForTimestamp(timestamp = Number.MAX_SAFE_INTEGER) {
132
- const liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
133
- return liteChainIdList.find((update) => update.timestamp <= timestamp)?.value ?? [];
134
- }
139
+ AcrossConfigStoreClient.prototype.getLiteChainIdIndicesForTimestamp = function (timestamp) {
140
+ var _a, _b;
141
+ if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
142
+ var liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
143
+ return (_b = (_a = liteChainIdList.find(function (update) { return update.timestamp <= timestamp; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : [];
144
+ };
135
145
  /**
136
146
  * Checks if a chain ID was a lite chain at a given timestamp.
137
147
  * @param chainId The chain ID to check.
138
148
  * @param timestamp The timestamp to check. Defaults to latest time - in seconds.
139
149
  * @returns True if the chain ID was a lite chain at the given timestamp. False otherwise.
140
150
  */
141
- isChainLiteChainAtTimestamp(chainId, timestamp = Number.MAX_SAFE_INTEGER) {
151
+ AcrossConfigStoreClient.prototype.isChainLiteChainAtTimestamp = function (chainId, timestamp) {
152
+ if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
142
153
  return this.getLiteChainIdIndicesForTimestamp(timestamp).includes(chainId);
143
- }
144
- getSpokeTargetBalancesForBlock(l1Token, chainId, blockNumber = Number.MAX_SAFE_INTEGER) {
145
- const config = sortEventsDescending(this.cumulativeSpokeTargetBalanceUpdates).find((config) => config.l1Token === l1Token && config.blockNumber <= blockNumber);
146
- const targetBalance = config?.spokeTargetBalances?.[chainId];
154
+ };
155
+ AcrossConfigStoreClient.prototype.getSpokeTargetBalancesForBlock = function (l1Token, chainId, blockNumber) {
156
+ var _a;
157
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
158
+ var config = sortEventsDescending(this.cumulativeSpokeTargetBalanceUpdates).find(function (config) { return config.l1Token === l1Token && config.blockNumber <= blockNumber; });
159
+ var targetBalance = (_a = config === null || config === void 0 ? void 0 : config.spokeTargetBalances) === null || _a === void 0 ? void 0 : _a[chainId];
147
160
  return targetBalance || { target: toBN(0), threshold: toBN(0) };
148
- }
161
+ };
149
162
  // <-- END LEGACY CONFIGURATION OBJECTS -->
150
- getMaxRefundCountForRelayerRefundLeafForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
151
- const config = sortEventsDescending(this.cumulativeMaxRefundCountUpdates).find((config) => config.blockNumber <= blockNumber);
163
+ AcrossConfigStoreClient.prototype.getMaxRefundCountForRelayerRefundLeafForBlock = function (blockNumber) {
164
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
165
+ var config = sortEventsDescending(this.cumulativeMaxRefundCountUpdates).find(function (config) { return config.blockNumber <= blockNumber; });
152
166
  if (!config) {
153
- throw new Error(`Could not find MaxRefundCount before block ${blockNumber}`);
167
+ throw new Error("Could not find MaxRefundCount before block ".concat(blockNumber));
154
168
  }
155
169
  return Number(config.value);
156
- }
157
- getMaxL1TokenCountForPoolRebalanceLeafForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
158
- const config = sortEventsDescending(this.cumulativeMaxL1TokenCountUpdates).find((config) => config.blockNumber <= blockNumber);
170
+ };
171
+ AcrossConfigStoreClient.prototype.getMaxL1TokenCountForPoolRebalanceLeafForBlock = function (blockNumber) {
172
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
173
+ var config = sortEventsDescending(this.cumulativeMaxL1TokenCountUpdates).find(function (config) { return config.blockNumber <= blockNumber; });
159
174
  if (!config) {
160
- throw new Error(`Could not find MaxL1TokenCount before block ${blockNumber}`);
175
+ throw new Error("Could not find MaxL1TokenCount before block ".concat(blockNumber));
161
176
  }
162
177
  return Number(config.value);
163
- }
178
+ };
164
179
  /**
165
180
  * Returns list of chains that have been enabled at least once in the block range.
166
181
  * If a chain was disabled in the block range, it will be included in the list provided it was enabled
@@ -171,25 +186,26 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
171
186
  * up until `latest`.
172
187
  * @returns List of chain IDs that have been enabled at least once in the block range. Sorted from lowest to highest.
173
188
  */
174
- getEnabledChainsInBlockRange(fromBlock, toBlock = Number.MAX_SAFE_INTEGER) {
189
+ AcrossConfigStoreClient.prototype.getEnabledChainsInBlockRange = function (fromBlock, toBlock) {
190
+ if (toBlock === void 0) { toBlock = Number.MAX_SAFE_INTEGER; }
175
191
  // If our fromBlock is greater than our toBlock, then we have an invalid range.
176
192
  if (fromBlock > toBlock) {
177
- throw new Error(`Invalid block range: fromBlock ${fromBlock} > toBlock ${toBlock}`);
193
+ throw new Error("Invalid block range: fromBlock ".concat(fromBlock, " > toBlock ").concat(toBlock));
178
194
  }
179
195
  // Initiate list with all possible chains enabled at the toBlock while removing any chains
180
196
  // that were disabled at the from block.
181
- const disabledChainsAtFromBlock = this.getDisabledChainsForBlock(fromBlock);
182
- const allPossibleChains = this.getChainIdIndicesForBlock(toBlock);
183
- const enabledChainsInBlockRange = allPossibleChains.filter((chainId) => !disabledChainsAtFromBlock.includes(chainId));
197
+ var disabledChainsAtFromBlock = this.getDisabledChainsForBlock(fromBlock);
198
+ var allPossibleChains = this.getChainIdIndicesForBlock(toBlock);
199
+ var enabledChainsInBlockRange = allPossibleChains.filter(function (chainId) { return !disabledChainsAtFromBlock.includes(chainId); });
184
200
  // If there are any disabled chain updates in the block range, then we might need to update the list of enabled
185
201
  // chains in the block range.
186
202
  this.cumulativeDisabledChainUpdates
187
- .filter((e) => e.blockNumber <= toBlock && e.blockNumber >= fromBlock)
188
- .forEach((e) => {
203
+ .filter(function (e) { return e.blockNumber <= toBlock && e.blockNumber >= fromBlock; })
204
+ .forEach(function (e) {
189
205
  // If disabled chain update no longer includes a previously disabled chain, then add it back to the enabled chains
190
206
  // list.
191
- const newDisabledSet = e.chainIds;
192
- disabledChainsAtFromBlock.forEach((disabledChain) => {
207
+ var newDisabledSet = e.chainIds;
208
+ disabledChainsAtFromBlock.forEach(function (disabledChain) {
193
209
  // New disabled set doesn't include this chain that was previously disabled so it was re-enabled at this point
194
210
  // in the block range.
195
211
  if (!newDisabledSet.includes(disabledChain)) {
@@ -198,297 +214,356 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
198
214
  });
199
215
  });
200
216
  // Return the enabled chains in the block range sorted in the same order as the chain indices.
201
- return allPossibleChains.filter((chainId) => enabledChainsInBlockRange.includes(chainId));
202
- }
203
- getEnabledChains(block = Number.MAX_SAFE_INTEGER) {
217
+ return allPossibleChains.filter(function (chainId) { return enabledChainsInBlockRange.includes(chainId); });
218
+ };
219
+ AcrossConfigStoreClient.prototype.getEnabledChains = function (block) {
220
+ if (block === void 0) { block = Number.MAX_SAFE_INTEGER; }
204
221
  // Get most recent disabled chain list before the block specified.
205
- const currentlyDisabledChains = this.getDisabledChainsForBlock(block);
206
- return this.getChainIdIndicesForBlock(block).filter((chainId) => !currentlyDisabledChains.includes(chainId));
207
- }
208
- getDisabledChainsForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
209
- return (sortEventsDescending(this.cumulativeDisabledChainUpdates).find((config) => config.blockNumber <= blockNumber)
210
- ?.chainIds ?? []);
211
- }
212
- getConfigStoreVersionForTimestamp(timestamp = Number.MAX_SAFE_INTEGER) {
213
- const config = this.cumulativeConfigStoreVersionUpdates.find((config) => config.timestamp <= timestamp);
222
+ var currentlyDisabledChains = this.getDisabledChainsForBlock(block);
223
+ return this.getChainIdIndicesForBlock(block).filter(function (chainId) { return !currentlyDisabledChains.includes(chainId); });
224
+ };
225
+ AcrossConfigStoreClient.prototype.getDisabledChainsForBlock = function (blockNumber) {
226
+ var _a, _b;
227
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
228
+ return ((_b = (_a = sortEventsDescending(this.cumulativeDisabledChainUpdates).find(function (config) { return config.blockNumber <= blockNumber; })) === null || _a === void 0 ? void 0 : _a.chainIds) !== null && _b !== void 0 ? _b : []);
229
+ };
230
+ AcrossConfigStoreClient.prototype.getConfigStoreVersionForTimestamp = function (timestamp) {
231
+ if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
232
+ var config = this.cumulativeConfigStoreVersionUpdates.find(function (config) { return config.timestamp <= timestamp; });
214
233
  return isDefined(config) ? Number(config.value) : DEFAULT_CONFIG_STORE_VERSION;
215
- }
216
- getConfigStoreVersionForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
217
- const config = this.cumulativeConfigStoreVersionUpdates.find((config) => config.blockNumber <= blockNumber);
234
+ };
235
+ AcrossConfigStoreClient.prototype.getConfigStoreVersionForBlock = function (blockNumber) {
236
+ if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
237
+ var config = this.cumulativeConfigStoreVersionUpdates.find(function (config) { return config.blockNumber <= blockNumber; });
218
238
  return isDefined(config) ? Number(config.value) : DEFAULT_CONFIG_STORE_VERSION;
219
- }
220
- hasValidConfigStoreVersionForTimestamp(timestamp = Number.MAX_SAFE_INTEGER) {
221
- const version = this.getConfigStoreVersionForTimestamp(timestamp);
239
+ };
240
+ AcrossConfigStoreClient.prototype.hasValidConfigStoreVersionForTimestamp = function (timestamp) {
241
+ if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
242
+ var version = this.getConfigStoreVersionForTimestamp(timestamp);
222
243
  return this.configStoreVersion >= version;
223
- }
244
+ };
224
245
  /**
225
246
  * Resolve the chain ID for the ConfigStore Provider instance.
226
247
  * @dev When the provider is a StatisJsonRpcProvider instance, the getNetwork() is non-blocking.
227
248
  * @returns Chain ID for the ConfigStore deployment.
228
249
  */
229
- async resolveChainId() {
230
- return this.chainId ?? (await this.configStore.provider.getNetwork()).chainId;
231
- }
232
- async _update() {
233
- const chainId = await this.resolveChainId();
234
- const searchConfig = await this.updateSearchConfig(this.configStore.provider);
235
- if (isUpdateFailureReason(searchConfig)) {
236
- const reason = searchConfig;
237
- return { success: false, reason };
238
- }
239
- this.logger.debug({ at: "AcrossConfigStore", message: "Updating ConfigStore client", searchConfig });
240
- const [updatedTokenConfigEvents, updatedGlobalConfigEvents] = await Promise.all([
241
- paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedTokenConfig(), searchConfig),
242
- paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedGlobalConfig(), searchConfig),
243
- ]);
244
- const updatedTokenConfigSortableEvents = updatedTokenConfigEvents.map(spreadEventWithBlockNumber);
245
- const updatedGlobalConfigSortableEvents = updatedGlobalConfigEvents.map(spreadEventWithBlockNumber);
246
- // Events *should* normally be received in ascending order, but explicitly enforce the ordering.
247
- [updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents].forEach((events) => sortEventsAscendingInPlace(events));
248
- const globalConfigUpdateTimes = (await Promise.all(updatedGlobalConfigEvents.map((event) => this.configStore.provider.getBlock(event.blockNumber)))).map((block) => block.timestamp);
249
- return {
250
- success: true,
251
- chainId,
252
- searchEndBlock: searchConfig.to,
253
- events: {
254
- updatedTokenConfigEvents: updatedTokenConfigSortableEvents,
255
- updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
256
- globalConfigUpdateTimes,
257
- },
258
- };
259
- }
260
- async update() {
261
- const result = await this._update();
262
- if (!result.success) {
263
- if (result.reason !== UpdateFailureReason.AlreadyUpdated) {
264
- throw new Error(`Unable to update ConfigStoreClient: ${result.reason}`);
265
- }
266
- // No need to touch `this.isUpdated` because it should already be set from a previous update.
267
- return;
268
- }
269
- const { chainId } = result;
270
- const { updatedTokenConfigEvents, updatedGlobalConfigEvents, globalConfigUpdateTimes } = result.events;
271
- assert(updatedGlobalConfigEvents.length === globalConfigUpdateTimes.length, `GlobalConfigUpdate events mismatch (${updatedGlobalConfigEvents.length} != ${globalConfigUpdateTimes.length})`);
272
- // Save new TokenConfig updates.
273
- for (const event of updatedTokenConfigEvents) {
274
- // If transaction hash is known to be invalid, skip it immediately to avoid creating extra logs.
275
- if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.txnRef.toLowerCase())) {
276
- continue;
277
- }
278
- const args = event;
279
- try {
280
- const { rateModel, routeRateModel, spokeTargetBalances } = this.validateTokenConfigUpdate(args);
281
- const { value, key: l1Token, ...eventData } = args;
282
- if (rateModel !== undefined) {
283
- this.cumulativeRateModelUpdates.push({ ...eventData, rateModel, l1Token });
284
- this.cumulativeSpokeTargetBalanceUpdates.push({
285
- ...eventData,
286
- spokeTargetBalances,
287
- l1Token,
288
- });
289
- this.cumulativeRouteRateModelUpdates.push({ ...eventData, routeRateModel, l1Token });
290
- }
291
- }
292
- catch (err) {
293
- const { average: blockTime } = await averageBlockTime(this.configStore.provider);
294
- const maxWarnAge = (24 * 60 * 60) / blockTime;
295
- if (result.searchEndBlock - event.blockNumber < maxWarnAge) {
296
- const errMsg = isError(err) ? err.message : "unknown error";
297
- // This will emit warning logs for any invalid historical updates and it will be very noisy, so
298
- // developer should move over known invalid hashes to KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES to
299
- // suppress these warnings.
300
- this.logger.warn({
301
- at: "ConfigStore::update",
302
- message: `Caught error during ConfigStore update: ${errMsg}`,
303
- update: args,
304
- });
250
+ AcrossConfigStoreClient.prototype.resolveChainId = function () {
251
+ return __awaiter(this, void 0, void 0, function () {
252
+ var _a;
253
+ var _b;
254
+ return __generator(this, function (_c) {
255
+ switch (_c.label) {
256
+ case 0:
257
+ if (!((_b = this.chainId) !== null && _b !== void 0)) return [3 /*break*/, 1];
258
+ _a = _b;
259
+ return [3 /*break*/, 3];
260
+ case 1: return [4 /*yield*/, this.configStore.provider.getNetwork()];
261
+ case 2:
262
+ _a = (_c.sent()).chainId;
263
+ _c.label = 3;
264
+ case 3: return [2 /*return*/, _a];
305
265
  }
306
- else {
307
- this.logger.debug({
308
- at: "ConfigStoreClient::update",
309
- message: `Skipping invalid historical update at block ${event.blockNumber}`,
310
- txnRef: event.txnRef,
311
- });
312
- }
313
- continue;
314
- }
315
- }
316
- // Save new Global config updates.
317
- for (let i = 0; i < updatedGlobalConfigEvents.length; i++) {
318
- const args = updatedGlobalConfigEvents[i];
319
- if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_RELAYER_REPAYMENT_LEAF_SIZE)) {
320
- if (!isNaN(args.value)) {
321
- this.cumulativeMaxRefundCountUpdates.push(args);
322
- }
323
- }
324
- else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.LITE_CHAIN_ID_INDICES)) {
325
- // We need to parse the chain ID indices array from the stringified JSON. However,
326
- // the on-chain string has quotes around the array, which will parse our JSON as a
327
- // string instead of an array. We need to remove these quotes before parsing.
328
- // To be sure, we can check for single quotes, double quotes, and spaces.
329
- // Use a regular expression to check if the string is a valid array. We need to check for
330
- // leading and trailing quotes, as well as leading and trailing whitespace. We also need to
331
- // check for commas between the numbers. Alternatively, this can be an empty array.
332
- if (!/^\s*["']?\[(\d+(,\d+)*)?\]["']?\s*$/.test(args.value)) {
333
- this.logger.warn({ at: "ConfigStore", message: `The lite chain indices array ${args.value} is invalid.` });
334
- // If not a valid array, skip.
335
- continue;
336
- }
337
- const chainIndices = JSON.parse(args.value.replace(/['"\s]/g, ""));
338
- // Check that the array is valid and that every element is a number.
339
- if (!isArrayOf(chainIndices, isPositiveInteger)) {
340
- this.logger.warn({ at: "ConfigStore", message: `The array ${chainIndices} is invalid.` });
341
- // If not a valid array, skip.
342
- continue;
343
- }
344
- // Let's also check that the array doesn't contain any duplicates.
345
- if (new Set(chainIndices).size !== chainIndices.length) {
346
- this.logger.warn({
347
- at: "ConfigStore",
348
- message: `The array ${chainIndices} contains duplicates making it invalid.`,
349
- });
350
- // If not a valid array, skip.
351
- continue;
352
- }
353
- // If all else passes, we can add this update.
354
- this.liteChainIndicesUpdates.push({ ...args, value: chainIndices, timestamp: globalConfigUpdateTimes[i] });
355
- }
356
- else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.CHAIN_ID_INDICES)) {
357
- try {
358
- // We need to parse the chain ID indices array from the stringified JSON. However,
359
- // the on-chain string has quotes around the array, which will parse our JSON as a
360
- // string instead of an array. We need to remove these quotes before parsing.
361
- // To be sure, we can check for single quotes, double quotes, and spaces.
362
- const chainIndices = JSON.parse(args.value.replace(/['"\s]/g, ""));
363
- // Check that the array is valid and that every element is a number.
364
- if (!isArrayOf(chainIndices, isPositiveInteger)) {
365
- this.logger.warn({ at: "ConfigStore", message: `The array ${chainIndices} is invalid.` });
366
- // If not a valid array, skip.
367
- continue;
368
- }
369
- // Let's also check that the array doesn't contain any duplicates.
370
- if (new Set(chainIndices).size !== chainIndices.length) {
371
- this.logger.warn({
372
- at: "ConfigStore",
373
- message: `The array ${chainIndices} contains duplicates making it invalid.`,
374
- });
375
- // If not a valid array, skip.
376
- continue;
377
- }
378
- // Now check that we're only appending positive integers to the chainIndices array on each
379
- // update. If this isn't the case, skip the update & warn. If there is no previous update,
380
- // resolve an implicit chain ID list.
381
- const previousUpdate = this.chainIdIndicesUpdates.at(-1)?.value ?? this.implicitChainIdIndices(chainId);
382
- // We should now check that previousUpdate is a subset of chainIndices.
383
- if (!previousUpdate.every((chainId, idx) => chainIndices[idx] === chainId)) {
384
- this.logger.warn({
385
- at: "ConfigStoreClient#update",
386
- message: `The array ${chainIndices} is invalid. It must be a superset of the previous array ${previousUpdate}`,
266
+ });
267
+ });
268
+ };
269
+ AcrossConfigStoreClient.prototype._update = function () {
270
+ return __awaiter(this, void 0, void 0, function () {
271
+ var chainId, searchConfig, reason, _a, updatedTokenConfigEvents, updatedGlobalConfigEvents, updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents, globalConfigUpdateTimes;
272
+ var _this = this;
273
+ return __generator(this, function (_b) {
274
+ switch (_b.label) {
275
+ case 0: return [4 /*yield*/, this.resolveChainId()];
276
+ case 1:
277
+ chainId = _b.sent();
278
+ return [4 /*yield*/, this.updateSearchConfig(this.configStore.provider)];
279
+ case 2:
280
+ searchConfig = _b.sent();
281
+ if (isUpdateFailureReason(searchConfig)) {
282
+ reason = searchConfig;
283
+ return [2 /*return*/, { success: false, reason: reason }];
284
+ }
285
+ this.logger.debug({ at: "AcrossConfigStore", message: "Updating ConfigStore client", searchConfig: searchConfig });
286
+ return [4 /*yield*/, Promise.all([
287
+ paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedTokenConfig(), searchConfig),
288
+ paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedGlobalConfig(), searchConfig),
289
+ ])];
290
+ case 3:
291
+ _a = _b.sent(), updatedTokenConfigEvents = _a[0], updatedGlobalConfigEvents = _a[1];
292
+ updatedTokenConfigSortableEvents = updatedTokenConfigEvents.map(spreadEventWithBlockNumber);
293
+ updatedGlobalConfigSortableEvents = updatedGlobalConfigEvents.map(spreadEventWithBlockNumber);
294
+ // Events *should* normally be received in ascending order, but explicitly enforce the ordering.
295
+ [updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents].forEach(function (events) {
296
+ return sortEventsAscendingInPlace(events);
387
297
  });
388
- continue;
389
- }
390
- // If all else passes, we can add this update.
391
- this.chainIdIndicesUpdates.push({ ...args, value: chainIndices });
392
- }
393
- catch (e) {
394
- this.logger.warn({ at: "ConfigStore::update", message: `Failed to parse chain ID indices: ${args.value}` });
395
- }
396
- }
397
- else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_POOL_REBALANCE_LEAF_SIZE)) {
398
- if (!isNaN(args.value)) {
399
- this.cumulativeMaxL1TokenCountUpdates.push(args);
400
- }
401
- }
402
- else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.VERSION)) {
403
- // If not a number, skip.
404
- if (isNaN(args.value)) {
405
- continue;
406
- }
407
- const value = Number(args.value);
408
- // If not an integer, skip.
409
- if (!Number.isInteger(value)) {
410
- continue;
298
+ return [4 /*yield*/, Promise.all(updatedGlobalConfigEvents.map(function (event) { return _this.configStore.provider.getBlock(event.blockNumber); }))];
299
+ case 4:
300
+ globalConfigUpdateTimes = (_b.sent()).map(function (block) { return block.timestamp; });
301
+ return [2 /*return*/, {
302
+ success: true,
303
+ chainId: chainId,
304
+ searchEndBlock: searchConfig.to,
305
+ events: {
306
+ updatedTokenConfigEvents: updatedTokenConfigSortableEvents,
307
+ updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
308
+ globalConfigUpdateTimes: globalConfigUpdateTimes,
309
+ },
310
+ }];
411
311
  }
412
- // Extract the current highest version. Require that the version always increments, otherwise skip the update.
413
- const lastValue = Number(this.cumulativeConfigStoreVersionUpdates[0]?.value ?? DEFAULT_CONFIG_STORE_VERSION);
414
- if (value <= lastValue) {
415
- continue;
416
- }
417
- // Prepend the update to impose descending ordering for version updates.
418
- this.cumulativeConfigStoreVersionUpdates = [
419
- { ...args, timestamp: globalConfigUpdateTimes[i] },
420
- ...this.cumulativeConfigStoreVersionUpdates,
421
- ];
422
- }
423
- else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.DISABLED_CHAINS)) {
424
- try {
425
- const chainIds = this.filterDisabledChains(JSON.parse(args.value));
426
- this.cumulativeDisabledChainUpdates.push({ ...args, chainIds });
427
- }
428
- catch (err) {
429
- // Can't parse list, skip.
312
+ });
313
+ });
314
+ };
315
+ AcrossConfigStoreClient.prototype.update = function () {
316
+ return __awaiter(this, void 0, void 0, function () {
317
+ var result, chainId, _a, updatedTokenConfigEvents, updatedGlobalConfigEvents, globalConfigUpdateTimes, _i, updatedTokenConfigEvents_1, event_1, args, _b, rateModel, routeRateModel, spokeTargetBalances, value, l1Token, eventData, err_1, blockTime, maxWarnAge, errMsg, _loop_1, this_1, i;
318
+ var _c, _d, _e, _f, _g;
319
+ return __generator(this, function (_h) {
320
+ switch (_h.label) {
321
+ case 0: return [4 /*yield*/, this._update()];
322
+ case 1:
323
+ result = _h.sent();
324
+ if (!result.success) {
325
+ if (result.reason !== UpdateFailureReason.AlreadyUpdated) {
326
+ throw new Error("Unable to update ConfigStoreClient: ".concat(result.reason));
327
+ }
328
+ // No need to touch `this.isUpdated` because it should already be set from a previous update.
329
+ return [2 /*return*/];
330
+ }
331
+ chainId = result.chainId;
332
+ _a = result.events, updatedTokenConfigEvents = _a.updatedTokenConfigEvents, updatedGlobalConfigEvents = _a.updatedGlobalConfigEvents, globalConfigUpdateTimes = _a.globalConfigUpdateTimes;
333
+ assert(updatedGlobalConfigEvents.length === globalConfigUpdateTimes.length, "GlobalConfigUpdate events mismatch (".concat(updatedGlobalConfigEvents.length, " != ").concat(globalConfigUpdateTimes.length, ")"));
334
+ _i = 0, updatedTokenConfigEvents_1 = updatedTokenConfigEvents;
335
+ _h.label = 2;
336
+ case 2:
337
+ if (!(_i < updatedTokenConfigEvents_1.length)) return [3 /*break*/, 7];
338
+ event_1 = updatedTokenConfigEvents_1[_i];
339
+ // If transaction hash is known to be invalid, skip it immediately to avoid creating extra logs.
340
+ if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event_1.txnRef.toLowerCase())) {
341
+ return [3 /*break*/, 6];
342
+ }
343
+ args = event_1;
344
+ _h.label = 3;
345
+ case 3:
346
+ _h.trys.push([3, 4, , 6]);
347
+ _b = this.validateTokenConfigUpdate(args), rateModel = _b.rateModel, routeRateModel = _b.routeRateModel, spokeTargetBalances = _b.spokeTargetBalances;
348
+ value = args.value, l1Token = args.key, eventData = __rest(args, ["value", "key"]);
349
+ if (rateModel !== undefined) {
350
+ this.cumulativeRateModelUpdates.push(__assign(__assign({}, eventData), { rateModel: rateModel, l1Token: l1Token }));
351
+ this.cumulativeSpokeTargetBalanceUpdates.push(__assign(__assign({}, eventData), { spokeTargetBalances: spokeTargetBalances, l1Token: l1Token }));
352
+ this.cumulativeRouteRateModelUpdates.push(__assign(__assign({}, eventData), { routeRateModel: routeRateModel, l1Token: l1Token }));
353
+ }
354
+ return [3 /*break*/, 6];
355
+ case 4:
356
+ err_1 = _h.sent();
357
+ return [4 /*yield*/, averageBlockTime(this.configStore.provider)];
358
+ case 5:
359
+ blockTime = (_h.sent()).average;
360
+ maxWarnAge = (24 * 60 * 60) / blockTime;
361
+ if (result.searchEndBlock - event_1.blockNumber < maxWarnAge) {
362
+ errMsg = isError(err_1) ? err_1.message : "unknown error";
363
+ // This will emit warning logs for any invalid historical updates and it will be very noisy, so
364
+ // developer should move over known invalid hashes to KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES to
365
+ // suppress these warnings.
366
+ this.logger.warn({
367
+ at: "ConfigStore::update",
368
+ message: "Caught error during ConfigStore update: ".concat(errMsg),
369
+ update: args,
370
+ });
371
+ }
372
+ else {
373
+ this.logger.debug({
374
+ at: "ConfigStoreClient::update",
375
+ message: "Skipping invalid historical update at block ".concat(event_1.blockNumber),
376
+ txnRef: event_1.txnRef,
377
+ });
378
+ }
379
+ return [3 /*break*/, 6];
380
+ case 6:
381
+ _i++;
382
+ return [3 /*break*/, 2];
383
+ case 7:
384
+ _loop_1 = function (i) {
385
+ var args = updatedGlobalConfigEvents[i];
386
+ if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_RELAYER_REPAYMENT_LEAF_SIZE)) {
387
+ if (!isNaN(args.value)) {
388
+ this_1.cumulativeMaxRefundCountUpdates.push(args);
389
+ }
390
+ }
391
+ else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.LITE_CHAIN_ID_INDICES)) {
392
+ // We need to parse the chain ID indices array from the stringified JSON. However,
393
+ // the on-chain string has quotes around the array, which will parse our JSON as a
394
+ // string instead of an array. We need to remove these quotes before parsing.
395
+ // To be sure, we can check for single quotes, double quotes, and spaces.
396
+ // Use a regular expression to check if the string is a valid array. We need to check for
397
+ // leading and trailing quotes, as well as leading and trailing whitespace. We also need to
398
+ // check for commas between the numbers. Alternatively, this can be an empty array.
399
+ if (!/^\s*["']?\[(\d+(,\d+)*)?\]["']?\s*$/.test(args.value)) {
400
+ this_1.logger.warn({ at: "ConfigStore", message: "The lite chain indices array ".concat(args.value, " is invalid.") });
401
+ return "continue";
402
+ }
403
+ var chainIndices = JSON.parse(args.value.replace(/['"\s]/g, ""));
404
+ // Check that the array is valid and that every element is a number.
405
+ if (!isArrayOf(chainIndices, isPositiveInteger)) {
406
+ this_1.logger.warn({ at: "ConfigStore", message: "The array ".concat(chainIndices, " is invalid.") });
407
+ return "continue";
408
+ }
409
+ // Let's also check that the array doesn't contain any duplicates.
410
+ if (new Set(chainIndices).size !== chainIndices.length) {
411
+ this_1.logger.warn({
412
+ at: "ConfigStore",
413
+ message: "The array ".concat(chainIndices, " contains duplicates making it invalid."),
414
+ });
415
+ return "continue";
416
+ }
417
+ // If all else passes, we can add this update.
418
+ this_1.liteChainIndicesUpdates.push(__assign(__assign({}, args), { value: chainIndices, timestamp: globalConfigUpdateTimes[i] }));
419
+ }
420
+ else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.CHAIN_ID_INDICES)) {
421
+ try {
422
+ // We need to parse the chain ID indices array from the stringified JSON. However,
423
+ // the on-chain string has quotes around the array, which will parse our JSON as a
424
+ // string instead of an array. We need to remove these quotes before parsing.
425
+ // To be sure, we can check for single quotes, double quotes, and spaces.
426
+ var chainIndices_1 = JSON.parse(args.value.replace(/['"\s]/g, ""));
427
+ // Check that the array is valid and that every element is a number.
428
+ if (!isArrayOf(chainIndices_1, isPositiveInteger)) {
429
+ this_1.logger.warn({ at: "ConfigStore", message: "The array ".concat(chainIndices_1, " is invalid.") });
430
+ return "continue";
431
+ }
432
+ // Let's also check that the array doesn't contain any duplicates.
433
+ if (new Set(chainIndices_1).size !== chainIndices_1.length) {
434
+ this_1.logger.warn({
435
+ at: "ConfigStore",
436
+ message: "The array ".concat(chainIndices_1, " contains duplicates making it invalid."),
437
+ });
438
+ return "continue";
439
+ }
440
+ // Now check that we're only appending positive integers to the chainIndices array on each
441
+ // update. If this isn't the case, skip the update & warn. If there is no previous update,
442
+ // resolve an implicit chain ID list.
443
+ var previousUpdate = (_d = (_c = this_1.chainIdIndicesUpdates.at(-1)) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : this_1.implicitChainIdIndices(chainId);
444
+ // We should now check that previousUpdate is a subset of chainIndices.
445
+ if (!previousUpdate.every(function (chainId, idx) { return chainIndices_1[idx] === chainId; })) {
446
+ this_1.logger.warn({
447
+ at: "ConfigStoreClient#update",
448
+ message: "The array ".concat(chainIndices_1, " is invalid. It must be a superset of the previous array ").concat(previousUpdate),
449
+ });
450
+ return "continue";
451
+ }
452
+ // If all else passes, we can add this update.
453
+ this_1.chainIdIndicesUpdates.push(__assign(__assign({}, args), { value: chainIndices_1 }));
454
+ }
455
+ catch (e) {
456
+ this_1.logger.warn({ at: "ConfigStore::update", message: "Failed to parse chain ID indices: ".concat(args.value) });
457
+ }
458
+ }
459
+ else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_POOL_REBALANCE_LEAF_SIZE)) {
460
+ if (!isNaN(args.value)) {
461
+ this_1.cumulativeMaxL1TokenCountUpdates.push(args);
462
+ }
463
+ }
464
+ else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.VERSION)) {
465
+ // If not a number, skip.
466
+ if (isNaN(args.value)) {
467
+ return "continue";
468
+ }
469
+ var value = Number(args.value);
470
+ // If not an integer, skip.
471
+ if (!Number.isInteger(value)) {
472
+ return "continue";
473
+ }
474
+ // Extract the current highest version. Require that the version always increments, otherwise skip the update.
475
+ var lastValue = Number((_f = (_e = this_1.cumulativeConfigStoreVersionUpdates[0]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : DEFAULT_CONFIG_STORE_VERSION);
476
+ if (value <= lastValue) {
477
+ return "continue";
478
+ }
479
+ // Prepend the update to impose descending ordering for version updates.
480
+ this_1.cumulativeConfigStoreVersionUpdates = __spreadArray([
481
+ __assign(__assign({}, args), { timestamp: globalConfigUpdateTimes[i] })
482
+ ], this_1.cumulativeConfigStoreVersionUpdates, true);
483
+ }
484
+ else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.DISABLED_CHAINS)) {
485
+ try {
486
+ var chainIds = this_1.filterDisabledChains(JSON.parse(args.value));
487
+ this_1.cumulativeDisabledChainUpdates.push(__assign(__assign({}, args), { chainIds: chainIds }));
488
+ }
489
+ catch (err) {
490
+ // Can't parse list, skip.
491
+ }
492
+ }
493
+ else {
494
+ return "continue";
495
+ }
496
+ };
497
+ this_1 = this;
498
+ // Save new Global config updates.
499
+ for (i = 0; i < updatedGlobalConfigEvents.length; i++) {
500
+ _loop_1(i);
501
+ }
502
+ this.hasLatestConfigStoreVersion = this.hasValidConfigStoreVersionForTimestamp();
503
+ this.latestHeightSearched = result.searchEndBlock;
504
+ this.firstHeightToSearch = result.searchEndBlock + 1; // Next iteration should start off from where this one ended.
505
+ this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary
506
+ this.chainId = (_g = this.chainId) !== null && _g !== void 0 ? _g : chainId; // Update on the first run only.
507
+ this.isUpdated = true;
508
+ this.logger.debug({ at: "ConfigStore", message: "ConfigStore client updated!" });
509
+ return [2 /*return*/];
430
510
  }
431
- }
432
- else {
433
- continue;
434
- }
435
- }
436
- this.hasLatestConfigStoreVersion = this.hasValidConfigStoreVersionForTimestamp();
437
- this.latestHeightSearched = result.searchEndBlock;
438
- this.firstHeightToSearch = result.searchEndBlock + 1; // Next iteration should start off from where this one ended.
439
- this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary
440
- this.chainId = this.chainId ?? chainId; // Update on the first run only.
441
- this.isUpdated = true;
442
- this.logger.debug({ at: "ConfigStore", message: "ConfigStore client updated!" });
443
- }
444
- validateTokenConfigUpdate(args) {
445
- const { value, key, txnRef } = args;
446
- const parsedValue = parseJSONWithNumericString(value);
447
- const l1Token = key;
511
+ });
512
+ });
513
+ };
514
+ AcrossConfigStoreClient.prototype.validateTokenConfigUpdate = function (args) {
515
+ var _this = this;
516
+ var value = args.value, key = args.key, txnRef = args.txnRef;
517
+ var parsedValue = parseJSONWithNumericString(value);
518
+ var l1Token = key;
448
519
  // Return the following parameters if the TokenConfig update is valid, otherwise throw an error.
449
520
  // Remove any config updates with invalid rate models by throwing an error if any part of the TokenConfig
450
521
  // is wrong before we push any events into this client's state.
451
- let rateModelForToken = undefined;
452
- let spokeTargetBalances = {};
453
- let routeRateModel = {};
522
+ var rateModelForToken = undefined;
523
+ var spokeTargetBalances = {};
524
+ var routeRateModel = {};
454
525
  // Drop value and key before passing args.
455
- if (parsedValue?.rateModel !== undefined) {
456
- const rateModel = parsedValue.rateModel;
457
- assert(this.isValidRateModel(rateModel), `Invalid rateModel UBar for ${l1Token} at transaction ${txnRef}, ${JSON.stringify(rateModel)}`);
526
+ if ((parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.rateModel) !== undefined) {
527
+ var rateModel = parsedValue.rateModel;
528
+ assert(this.isValidRateModel(rateModel), "Invalid rateModel UBar for ".concat(l1Token, " at transaction ").concat(txnRef, ", ").concat(JSON.stringify(rateModel)));
458
529
  rateModelForToken = JSON.stringify(rateModel);
459
530
  // Store spokeTargetBalances
460
- if (parsedValue?.spokeTargetBalances) {
531
+ if (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.spokeTargetBalances) {
461
532
  // Note: cast is required because fromEntries always produces string keys, despite the function returning a
462
533
  // numerical key.
463
- spokeTargetBalances = Object.fromEntries(Object.entries(parsedValue.spokeTargetBalances).map(([chainId, targetBalance]) => {
464
- const target = max(toBN(targetBalance.target), toBN(0));
465
- const threshold = max(toBN(targetBalance.threshold), toBN(0));
466
- return [chainId, { target, threshold }];
534
+ spokeTargetBalances = Object.fromEntries(Object.entries(parsedValue.spokeTargetBalances).map(function (_a) {
535
+ var chainId = _a[0], targetBalance = _a[1];
536
+ var target = max(toBN(targetBalance.target), toBN(0));
537
+ var threshold = max(toBN(targetBalance.threshold), toBN(0));
538
+ return [chainId, { target: target, threshold: threshold }];
467
539
  }));
468
540
  }
469
541
  // Store route-specific rate models
470
- if (parsedValue?.routeRateModel) {
471
- routeRateModel = Object.fromEntries(Object.entries(parsedValue.routeRateModel).map(([path, routeRateModel]) => {
472
- assert(this.isValidRateModel(routeRateModel) &&
473
- `Invalid routeRateModel UBar for ${path} for ${l1Token} at transaction ${txnRef}, ${JSON.stringify(routeRateModel)}`);
542
+ if (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.routeRateModel) {
543
+ routeRateModel = Object.fromEntries(Object.entries(parsedValue.routeRateModel).map(function (_a) {
544
+ var path = _a[0], routeRateModel = _a[1];
545
+ assert(_this.isValidRateModel(routeRateModel) &&
546
+ "Invalid routeRateModel UBar for ".concat(path, " for ").concat(l1Token, " at transaction ").concat(txnRef, ", ").concat(JSON.stringify(routeRateModel)));
474
547
  return [path, JSON.stringify(routeRateModel)];
475
548
  }));
476
549
  }
477
550
  }
478
551
  return {
479
- spokeTargetBalances,
552
+ spokeTargetBalances: spokeTargetBalances,
480
553
  rateModel: rateModelForToken,
481
- routeRateModel,
554
+ routeRateModel: routeRateModel,
482
555
  };
483
- }
484
- isValidRateModel(rateModel) {
556
+ };
557
+ AcrossConfigStoreClient.prototype.isValidRateModel = function (rateModel) {
485
558
  // UBar should be between 0% and 100%.
486
559
  return toBN(rateModel.UBar).gt(0) && toBN(rateModel.UBar).lt(toWei("1"));
487
- }
488
- filterDisabledChains(disabledChains) {
560
+ };
561
+ AcrossConfigStoreClient.prototype.filterDisabledChains = function (disabledChains) {
489
562
  // If any chain ID's are not integers then ignore. UMIP-157 requires that this key cannot include
490
563
  // the chain ID 1.
491
- return disabledChains.filter((chainId) => !isNaN(chainId) && Number.isInteger(chainId) && chainId !== 1);
492
- }
493
- }
564
+ return disabledChains.filter(function (chainId) { return !isNaN(chainId) && Number.isInteger(chainId) && chainId !== 1; });
565
+ };
566
+ return AcrossConfigStoreClient;
567
+ }(BaseAbstractClient));
568
+ export { AcrossConfigStoreClient };
494
569
  //# sourceMappingURL=AcrossConfigStoreClient.js.map