@across-protocol/sdk 4.2.16 → 4.3.1

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 (256) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +8 -3
  2. package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  4. package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
  5. package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
  6. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  7. package/dist/cjs/arch/svm/eventsClient.js +4 -2
  8. package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
  9. package/dist/cjs/arch/svm/utils.d.ts +3 -3
  10. package/dist/cjs/arch/svm/utils.js +16 -14
  11. package/dist/cjs/arch/svm/utils.js.map +1 -1
  12. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  13. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  14. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  15. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  16. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +59 -59
  17. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  18. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +16 -13
  19. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  20. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  21. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
  22. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  23. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  24. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  25. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
  26. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  27. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
  28. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +13 -8
  29. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  30. package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
  31. package/dist/cjs/clients/HubPoolClient.js +85 -58
  32. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  33. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  34. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  35. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +1 -3
  36. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  37. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  38. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +66 -46
  39. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  40. package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
  41. package/dist/cjs/clients/SpokePoolClient/index.js +3 -1
  42. package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
  43. package/dist/cjs/clients/index.d.ts +1 -1
  44. package/dist/cjs/clients/index.js +2 -1
  45. package/dist/cjs/clients/index.js.map +1 -1
  46. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
  47. package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
  48. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  49. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  50. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
  51. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  52. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  53. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +6 -4
  54. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  55. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  56. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
  57. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  58. package/dist/cjs/interfaces/HubPool.d.ts +19 -14
  59. package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
  60. package/dist/cjs/interfaces/SpokePool.js.map +1 -1
  61. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +17 -9
  62. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
  63. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  64. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  65. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
  66. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  67. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +13 -5
  68. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +61 -58
  69. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  70. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +15 -7
  71. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +13 -13
  72. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  73. package/dist/cjs/utils/AddressUtils.d.ts +12 -8
  74. package/dist/cjs/utils/AddressUtils.js +33 -36
  75. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  76. package/dist/cjs/utils/DepositUtils.d.ts +2 -2
  77. package/dist/cjs/utils/DepositUtils.js +1 -1
  78. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  79. package/dist/cjs/utils/SpokeUtils.d.ts +1 -3
  80. package/dist/cjs/utils/SpokeUtils.js +3 -25
  81. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  82. package/dist/cjs/utils/TokenUtils.d.ts +4 -4
  83. package/dist/cjs/utils/TokenUtils.js +5 -3
  84. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  85. package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
  86. package/dist/esm/arch/evm/SpokeUtils.js +29 -14
  87. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  88. package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
  89. package/dist/esm/arch/svm/SpokeUtils.js +42 -55
  90. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  91. package/dist/esm/arch/svm/eventsClient.js +5 -3
  92. package/dist/esm/arch/svm/eventsClient.js.map +1 -1
  93. package/dist/esm/arch/svm/utils.d.ts +3 -3
  94. package/dist/esm/arch/svm/utils.js +17 -15
  95. package/dist/esm/arch/svm/utils.js.map +1 -1
  96. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  97. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
  98. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  99. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  100. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +60 -60
  101. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  102. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +18 -15
  103. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  104. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  105. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +7 -7
  106. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  107. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
  108. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
  109. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
  110. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  111. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
  112. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +20 -10
  113. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  114. package/dist/esm/clients/HubPoolClient.d.ts +22 -22
  115. package/dist/esm/clients/HubPoolClient.js +93 -66
  116. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  117. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
  118. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  119. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +2 -4
  120. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  121. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  122. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +69 -48
  123. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  124. package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
  125. package/dist/esm/clients/SpokePoolClient/index.js +1 -0
  126. package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
  127. package/dist/esm/clients/index.d.ts +1 -1
  128. package/dist/esm/clients/index.js +1 -1
  129. package/dist/esm/clients/index.js.map +1 -1
  130. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
  131. package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
  132. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  133. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  134. package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
  135. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  136. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  137. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +7 -5
  138. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
  139. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  140. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
  141. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
  142. package/dist/esm/interfaces/HubPool.d.ts +19 -14
  143. package/dist/esm/interfaces/SpokePool.d.ts +18 -19
  144. package/dist/esm/interfaces/SpokePool.js.map +1 -1
  145. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
  146. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +28 -19
  147. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  148. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  149. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +9 -6
  150. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  151. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
  152. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +67 -63
  153. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  154. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
  155. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +12 -12
  156. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  157. package/dist/esm/utils/AddressUtils.d.ts +12 -8
  158. package/dist/esm/utils/AddressUtils.js +36 -38
  159. package/dist/esm/utils/AddressUtils.js.map +1 -1
  160. package/dist/esm/utils/DepositUtils.d.ts +2 -2
  161. package/dist/esm/utils/DepositUtils.js +2 -2
  162. package/dist/esm/utils/DepositUtils.js.map +1 -1
  163. package/dist/esm/utils/SpokeUtils.d.ts +1 -8
  164. package/dist/esm/utils/SpokeUtils.js +3 -29
  165. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  166. package/dist/esm/utils/TokenUtils.d.ts +6 -18
  167. package/dist/esm/utils/TokenUtils.js +6 -4
  168. package/dist/esm/utils/TokenUtils.js.map +1 -1
  169. package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
  170. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  171. package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
  172. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  173. package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
  174. package/dist/types/arch/svm/utils.d.ts +3 -3
  175. package/dist/types/arch/svm/utils.d.ts.map +1 -1
  176. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  177. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  178. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
  179. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  180. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  181. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
  182. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  183. package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
  184. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
  185. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
  186. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  187. package/dist/types/clients/HubPoolClient.d.ts +22 -22
  188. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  189. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  190. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
  191. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
  192. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  193. package/dist/types/clients/SpokePoolClient/index.d.ts +1 -0
  194. package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
  195. package/dist/types/clients/index.d.ts +1 -1
  196. package/dist/types/clients/index.d.ts.map +1 -1
  197. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
  198. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  199. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
  200. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  201. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
  202. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
  203. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
  204. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
  205. package/dist/types/interfaces/HubPool.d.ts +19 -14
  206. package/dist/types/interfaces/HubPool.d.ts.map +1 -1
  207. package/dist/types/interfaces/SpokePool.d.ts +18 -19
  208. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  209. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
  210. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  211. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  212. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  213. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
  214. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  215. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
  216. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  217. package/dist/types/utils/AddressUtils.d.ts +12 -8
  218. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  219. package/dist/types/utils/DepositUtils.d.ts +2 -2
  220. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  221. package/dist/types/utils/SpokeUtils.d.ts +1 -8
  222. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  223. package/dist/types/utils/TokenUtils.d.ts +6 -18
  224. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  225. package/package.json +1 -2
  226. package/src/arch/evm/SpokeUtils.ts +72 -22
  227. package/src/arch/svm/SpokeUtils.ts +67 -53
  228. package/src/arch/svm/eventsClient.ts +40 -8
  229. package/src/arch/svm/utils.ts +6 -6
  230. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
  231. package/src/clients/BundleDataClient/BundleDataClient.ts +56 -56
  232. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +32 -15
  233. package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
  234. package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
  235. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
  236. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +22 -10
  237. package/src/clients/HubPoolClient.ts +125 -86
  238. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -2
  239. package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
  240. package/src/clients/SpokePoolClient/SpokePoolClient.ts +122 -37
  241. package/src/clients/SpokePoolClient/index.ts +1 -0
  242. package/src/clients/index.ts +1 -0
  243. package/src/clients/mocks/MockHubPoolClient.ts +24 -19
  244. package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
  245. package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
  246. package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
  247. package/src/interfaces/HubPool.ts +20 -14
  248. package/src/interfaces/SpokePool.ts +19 -19
  249. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -21
  250. package/src/relayFeeCalculator/chain-queries/factory.ts +8 -5
  251. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +73 -58
  252. package/src/relayFeeCalculator/relayFeeCalculator.ts +23 -21
  253. package/src/utils/AddressUtils.ts +39 -51
  254. package/src/utils/DepositUtils.ts +4 -4
  255. package/src/utils/SpokeUtils.ts +8 -36
  256. package/src/utils/TokenUtils.ts +10 -8
@@ -1,4 +1,5 @@
1
1
  import winston from "winston";
2
+ import { utils as ethersUtils } from "ethers";
2
3
  import {
3
4
  AnyObject,
4
5
  BigNumber,
@@ -6,6 +7,7 @@ import {
6
7
  DefaultLogLevels,
7
8
  DepositSearchResult,
8
9
  EventSearchConfig,
10
+ EvmAddress,
9
11
  MAX_BIG_INT,
10
12
  MakeOptional,
11
13
  assign,
@@ -13,16 +15,13 @@ import {
13
15
  isDefined,
14
16
  getMessageHash,
15
17
  isSlowFill,
16
- isValidEvmAddress,
17
- isZeroAddress,
18
- toEvmAddress,
19
18
  validateFillForDeposit,
20
- chainIsEvm,
21
19
  chainIsProd,
22
20
  Address,
21
+ toAddressType,
23
22
  } from "../../utils";
24
23
  import { duplicateEvent, sortEventsAscendingInPlace } from "../../utils/EventUtils";
25
- import { ZERO_ADDRESS } from "../../constants";
24
+ import { CHAIN_IDs, ZERO_ADDRESS } from "../../constants";
26
25
  import {
27
26
  BridgedToHubPoolWithBlock,
28
27
  ClaimedRelayerRefundWithBlock,
@@ -39,6 +38,7 @@ import {
39
38
  SortableEvent,
40
39
  SpeedUpWithBlock,
41
40
  TokensBridged,
41
+ RelayExecutionEventInfo,
42
42
  } from "../../interfaces";
43
43
  import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
44
44
  import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
@@ -208,8 +208,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
208
208
  * @param relayer The relayer address.
209
209
  * @returns A list of fills.
210
210
  */
211
- public getFillsForRelayer(relayer: string): FillWithBlock[] {
212
- return this.getFills().filter((fill) => fill.relayer === relayer);
211
+ public getFillsForRelayer(relayer: Address): FillWithBlock[] {
212
+ return this.getFills().filter((fill) => fill.relayer.eq(relayer));
213
213
  }
214
214
 
215
215
  /**
@@ -273,8 +273,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
273
273
  const { depositId, depositor } = deposit;
274
274
 
275
275
  // Note: we know depositor cannot be more than 20 bytes since this is guaranteed by contracts.
276
- const speedups = this.speedUps[toEvmAddress(depositor)]?.[depositId.toString()];
277
-
276
+ // Additionally, speed ups can only be done on EVM networks.
277
+ const speedups = this.speedUps[depositor.toEvmAddress()]?.[depositId.toString()];
278
278
  if (!isDefined(speedups) || speedups.length === 0) {
279
279
  return deposit;
280
280
  }
@@ -403,11 +403,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
403
403
  // is not a valid EVM chain. In the case where the repayment address is not a valid EVM address, the dataworker
404
404
  // might be able to overwrite the repayment address to the msg.sender on the fill txn, but to keep this
405
405
  // functioon synchronous, we can't make that decision now. So this function might log some false positives.
406
- if (
407
- this.hubPoolClient &&
408
- !isSlowFill(fill) &&
409
- (!chainIsEvm(repaymentChainId) || !isValidEvmAddress(fill.relayer))
410
- ) {
406
+ if (this.hubPoolClient && !isSlowFill(fill) && !fill.relayer.isValidOn(repaymentChainId)) {
411
407
  groupedFills.unrepayableFills.push(fill);
412
408
  }
413
409
  // This fill is still valid and means that the deposit cannot be filled on-chain anymore, but it
@@ -429,7 +425,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
429
425
  chainId: this.chainId,
430
426
  message: "Unrepayable fills found where we need to switch repayment address and or chain",
431
427
  deposit,
432
- unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer, x])),
428
+ unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer.toNative(), x])),
433
429
  notificationPath: "across-unrepayable-fills",
434
430
  });
435
431
  }
@@ -501,14 +497,36 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
501
497
  const { events: queryResults, currentTime, searchEndBlock } = update;
502
498
 
503
499
  if (eventsToQuery.includes("TokensBridged")) {
504
- for (const event of queryResults[eventsToQuery.indexOf("TokensBridged")] as TokensBridged[]) {
505
- this.tokensBridged.push(event);
500
+ for (const _event of queryResults[eventsToQuery.indexOf("TokensBridged")]) {
501
+ const event = _event as TokensBridged & {
502
+ l2TokenAddress: string;
503
+ };
504
+ this.tokensBridged.push({
505
+ ...event,
506
+ l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
507
+ });
506
508
  }
507
509
  }
508
510
 
509
511
  // Performs the indexing of a deposit-like spoke pool event.
510
512
  const queryDepositEvents = async (eventName: string) => {
511
- const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as DepositWithBlock[];
513
+ const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
514
+ const event = _event as DepositWithBlock & {
515
+ depositor: string;
516
+ recipient: string;
517
+ inputToken: string;
518
+ outputToken: string;
519
+ exclusiveRelayer: string;
520
+ };
521
+ return {
522
+ ...event,
523
+ depositor: toAddressType(event.depositor, this.chainId),
524
+ recipient: toAddressType(event.recipient, event.destinationChainId),
525
+ inputToken: toAddressType(event.inputToken, this.chainId),
526
+ outputToken: toAddressType(event.outputToken, event.destinationChainId),
527
+ exclusiveRelayer: toAddressType(event.exclusiveRelayer, event.destinationChainId),
528
+ } as DepositWithBlock;
529
+ });
512
530
  if (depositEvents.length > 0) {
513
531
  this.log(
514
532
  "debug",
@@ -539,7 +557,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
539
557
  deposit.fromLiteChain = this.isOriginLiteChain(deposit);
540
558
  deposit.toLiteChain = this.isDestinationLiteChain(deposit);
541
559
 
542
- if (isZeroAddress(deposit.outputToken)) {
560
+ if (deposit.outputToken.isZeroAddress()) {
543
561
  deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
544
562
  }
545
563
 
@@ -565,11 +583,31 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
565
583
 
566
584
  // Performs indexing of a "speed up deposit"-like event.
567
585
  const querySpeedUpDepositEvents = (eventName: string) => {
568
- const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as SpeedUpWithBlock[];
586
+ const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
587
+ .map((_event) => {
588
+ const event = _event as SpeedUpWithBlock & { depositor: string; updatedRecipient: string };
589
+
590
+ const invalid = [event.depositor, event.updatedRecipient].some(
591
+ (addr) => !EvmAddress.validate(ethersUtils.arrayify(addr))
592
+ );
593
+ if (invalid) {
594
+ return;
595
+ }
596
+
597
+ return {
598
+ ...event,
599
+ depositor: EvmAddress.from(event.depositor),
600
+ updatedRecipient: EvmAddress.from(event.updatedRecipient),
601
+ } as SpeedUpWithBlock;
602
+ })
603
+ .filter(isDefined);
569
604
 
570
605
  for (const event of speedUpEvents) {
571
- const speedUp = { ...event, originChainId: this.chainId };
572
- assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]);
606
+ const speedUp = {
607
+ ...event,
608
+ originChainId: this.chainId,
609
+ };
610
+ assign(this.speedUps, [speedUp.depositor.toEvmAddress(), speedUp.depositId.toString()], [speedUp]);
573
611
 
574
612
  // Find deposit hash matching this speed up event and update the deposit data associated with the hash,
575
613
  // if the hash+data exists.
@@ -593,7 +631,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
593
631
 
594
632
  // Performs indexing of "requested slow fill"-like events.
595
633
  const queryRequestedSlowFillEvents = (eventName: string) => {
596
- const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as SlowFillRequestWithBlock[];
634
+ const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
635
+ const event = _event as SlowFillRequestWithBlock & {
636
+ depositor: string;
637
+ recipient: string;
638
+ inputToken: string;
639
+ outputToken: string;
640
+ exclusiveRelayer: string;
641
+ };
642
+ return {
643
+ ...event,
644
+ depositor: toAddressType(event.depositor, event.originChainId),
645
+ recipient: toAddressType(event.recipient, this.chainId),
646
+ inputToken: toAddressType(event.inputToken, event.originChainId),
647
+ outputToken: toAddressType(event.outputToken, this.chainId),
648
+ exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
649
+ } as SlowFillRequestWithBlock;
650
+ });
597
651
  for (const event of slowFillRequests) {
598
652
  const slowFillRequest = {
599
653
  ...event,
@@ -620,7 +674,30 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
620
674
 
621
675
  // Performs indexing of filled relay-like events.
622
676
  const queryFilledRelayEvents = (eventName: string) => {
623
- const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as FillWithBlock[];
677
+ const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
678
+ const event = _event as FillWithBlock & {
679
+ depositor: string;
680
+ recipient: string;
681
+ inputToken: string;
682
+ outputToken: string;
683
+ exclusiveRelayer: string;
684
+ relayer: string;
685
+ relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
686
+ };
687
+ return {
688
+ ...event,
689
+ depositor: toAddressType(event.depositor, event.originChainId),
690
+ recipient: toAddressType(event.recipient, this.chainId),
691
+ inputToken: toAddressType(event.inputToken, event.originChainId),
692
+ outputToken: toAddressType(event.outputToken, this.chainId),
693
+ exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
694
+ relayer: toAddressType(event.relayer, this.chainId),
695
+ relayExecutionInfo: {
696
+ ...event.relayExecutionInfo,
697
+ updatedRecipient: toAddressType(event.relayExecutionInfo.updatedRecipient, this.chainId),
698
+ },
699
+ } as FillWithBlock;
700
+ });
624
701
 
625
702
  if (fillEvents.length > 0) {
626
703
  this.log("debug", `Using ${fillEvents.length} newly queried ${eventName} events for chain ${this.chainId}`, {
@@ -656,8 +733,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
656
733
  });
657
734
 
658
735
  if (eventsToQuery.includes("EnabledDepositRoute")) {
659
- const enableDepositsEvents = (queryResults[eventsToQuery.indexOf("EnabledDepositRoute")] ??
660
- []) as EnabledDepositRouteWithBlock[];
736
+ const enableDepositsEvents = queryResults[
737
+ eventsToQuery.indexOf("EnabledDepositRoute")
738
+ ] as EnabledDepositRouteWithBlock[];
661
739
 
662
740
  for (const event of enableDepositsEvents) {
663
741
  assign(this.depositRoutes, [event.originToken, event.destinationChainId], event.enabled);
@@ -665,18 +743,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
665
743
  }
666
744
 
667
745
  if (eventsToQuery.includes("RelayedRootBundle")) {
668
- const relayedRootBundleEvents = (queryResults[eventsToQuery.indexOf("RelayedRootBundle")] ??
669
- []) as RootBundleRelayWithBlock[];
746
+ const relayedRootBundleEvents = queryResults[
747
+ eventsToQuery.indexOf("RelayedRootBundle")
748
+ ] as RootBundleRelayWithBlock[];
670
749
  for (const event of relayedRootBundleEvents) {
671
750
  this.rootBundleRelays.push(event);
672
751
  }
673
752
  }
674
753
 
675
754
  if (eventsToQuery.includes("ExecutedRelayerRefundRoot")) {
676
- const refundEvents = (queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")] ??
677
- []) as RelayerRefundExecutionWithBlock[];
678
- for (const event of refundEvents) {
679
- this.relayerRefundExecutions.push(event);
755
+ const refundEvents = queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")];
756
+ for (const _event of refundEvents) {
757
+ const event = _event as { l2TokenAddress: string; refundAddresses: string[] } & RelayerRefundExecutionWithBlock;
758
+ this.relayerRefundExecutions.push({
759
+ ...event,
760
+ l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
761
+ refundAddresses: event.refundAddresses.map((addr) => toAddressType(addr, this.chainId)),
762
+ });
680
763
  }
681
764
  }
682
765
 
@@ -743,9 +826,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
743
826
  * @param deposit The deposit to retrieve the destination token for.
744
827
  * @returns The destination token.
745
828
  */
746
- protected getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
829
+ protected getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
747
830
  if (!this.canResolveZeroAddressOutputToken(deposit)) {
748
- return ZERO_ADDRESS;
831
+ return toAddressType(ZERO_ADDRESS, CHAIN_IDs.MAINNET);
749
832
  }
750
833
  // L1 token should be resolved if we get here:
751
834
  const l1Token = this.hubPoolClient!.getL1TokenForL2TokenAtBlock(
@@ -753,10 +836,12 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
753
836
  deposit.originChainId,
754
837
  deposit.quoteBlockNumber
755
838
  )!;
756
- return (
757
- this.hubPoolClient!.getL2TokenForL1TokenAtBlock(l1Token, deposit.destinationChainId, deposit.quoteBlockNumber) ??
758
- ZERO_ADDRESS
839
+ const counterpartToken = this.hubPoolClient!.getL2TokenForL1TokenAtBlock(
840
+ l1Token,
841
+ deposit.destinationChainId,
842
+ deposit.quoteBlockNumber
759
843
  );
844
+ return counterpartToken ?? toAddressType(ZERO_ADDRESS, CHAIN_IDs.MAINNET);
760
845
  }
761
846
 
762
847
  /**
@@ -5,6 +5,7 @@ import { SpokePoolClient } from "./SpokePoolClient";
5
5
  export { EVMSpokePoolClient } from "./EVMSpokePoolClient";
6
6
  export { SpokePoolClient, SpokePoolUpdate } from "./SpokePoolClient";
7
7
  export { SVMSpokePoolClient } from "./SVMSpokePoolClient";
8
+ export { SpokePoolManager } from "./SpokePoolClientManager";
8
9
 
9
10
  /**
10
11
  * Checks if a SpokePoolClient is an EVMSpokePoolClient.
@@ -13,6 +13,7 @@ export {
13
13
  SVMSpokePoolClient,
14
14
  isEVMSpokePoolClient,
15
15
  isSVMSpokePoolClient,
16
+ SpokePoolManager,
16
17
  } from "./SpokePoolClient";
17
18
  export * as BundleDataClient from "./BundleDataClient";
18
19
  export * as mocks from "./mocks";
@@ -1,16 +1,17 @@
1
1
  import winston from "winston";
2
2
  import { Contract } from "ethers";
3
- import { BigNumber, randomAddress, assign, bnZero } from "../../utils";
4
- import { L1Token, Log, PendingRootBundle, RealizedLpFee } from "../../interfaces";
3
+ import { BigNumber, randomAddress, assign, bnZero, toAddressType, EvmAddress, Address, isDefined } from "../../utils";
4
+ import { Log, PendingRootBundle, RealizedLpFee, L1TokenInfo } from "../../interfaces";
5
5
  import { AcrossConfigStoreClient as ConfigStoreClient } from "../AcrossConfigStoreClient";
6
6
  import { HubPoolClient, HubPoolUpdate, LpFeeRequest } from "../HubPoolClient";
7
7
  import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
8
+ import { ZERO_ADDRESS } from "../../constants";
8
9
 
9
10
  const emptyRootBundle: PendingRootBundle = {
10
11
  poolRebalanceRoot: "",
11
12
  relayerRefundRoot: "",
12
13
  slowRelayRoot: "",
13
- proposer: "",
14
+ proposer: EvmAddress.from(ZERO_ADDRESS),
14
15
  unclaimedPoolRebalanceLeafCount: 0,
15
16
  challengePeriodEndTimestamp: 0,
16
17
  bundleEvaluationBlockNumbers: [],
@@ -22,9 +23,9 @@ export class MockHubPoolClient extends HubPoolClient {
22
23
  private realizedLpFeePct: BigNumber = bnZero;
23
24
  private realizedLpFeePctOverride = false;
24
25
 
25
- private l1TokensMock: L1Token[] = []; // L1Tokens and their associated info.
26
+ private l1TokensMock: L1TokenInfo[] = []; // L1Tokens and their associated info.
26
27
 
27
- private spokePoolTokens: { [l1Token: string]: { [chainId: number]: string } } = {};
28
+ private spokePoolTokens: { [l1Token: string]: { [chainId: number]: Address } } = {};
28
29
 
29
30
  private eventManager: EventManager;
30
31
 
@@ -69,7 +70,7 @@ export class MockHubPoolClient extends HubPoolClient {
69
70
  [chainId],
70
71
  [
71
72
  {
72
- spokePool: contract,
73
+ spokePool: toAddressType(contract, this.chainId),
73
74
  blockNumber: blockNumber,
74
75
  transactionIndex: 0,
75
76
  logIndex: 0,
@@ -82,7 +83,7 @@ export class MockHubPoolClient extends HubPoolClient {
82
83
  this.latestHeightSearched = blockNumber;
83
84
  }
84
85
 
85
- addL1Token(l1Token: L1Token) {
86
+ addL1Token(l1Token: L1TokenInfo) {
86
87
  this.l1TokensMock.push(l1Token);
87
88
  }
88
89
 
@@ -92,19 +93,19 @@ export class MockHubPoolClient extends HubPoolClient {
92
93
 
93
94
  setTokenMapping(l1Token: string, chainId: number, l2Token: string) {
94
95
  this.spokePoolTokens[l1Token] ??= {};
95
- this.spokePoolTokens[l1Token][chainId] = l2Token;
96
+ this.spokePoolTokens[l1Token][chainId] = toAddressType(l2Token, chainId);
96
97
  }
97
98
 
98
- l2TokenEnabledForL1TokenAtBlock(l1Token: string, destinationChainId: number, hubBlockNumber: number): boolean {
99
- if (this.spokePoolTokens[l1Token]?.[destinationChainId]) {
99
+ l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean {
100
+ if (this.spokePoolTokens[l1Token.toEvmAddress()]?.[destinationChainId]) {
100
101
  return true;
101
102
  } else {
102
103
  return super.l2TokenEnabledForL1TokenAtBlock(l1Token, destinationChainId, hubBlockNumber);
103
104
  }
104
105
  }
105
- l2TokenHasPoolRebalanceRoute(l2Token: string, chainId: number, hubPoolBlock: number): boolean {
106
+ l2TokenHasPoolRebalanceRoute(l2Token: Address, chainId: number, hubPoolBlock: number): boolean {
106
107
  const l1Token = Object.keys(this.spokePoolTokens).find(
107
- (l1Token) => this.spokePoolTokens[l1Token]?.[chainId] === l2Token
108
+ (l1Token) => this.spokePoolTokens[l1Token]?.[chainId]?.eq(l2Token)
108
109
  );
109
110
  if (!l1Token) {
110
111
  return super.l2TokenHasPoolRebalanceRoute(l2Token, chainId, hubPoolBlock);
@@ -115,20 +116,24 @@ export class MockHubPoolClient extends HubPoolClient {
115
116
  delete this.spokePoolTokens[l1Token]?.[chainId];
116
117
  }
117
118
 
118
- getL1TokenForL2TokenAtBlock(l2Token: string, chainId: number, blockNumber: number): string {
119
+ getL1TokenForL2TokenAtBlock(l2Token: Address, chainId: number, blockNumber: number): EvmAddress {
119
120
  const l1Token = Object.keys(this.spokePoolTokens).find(
120
- (l1Token) => this.spokePoolTokens[l1Token]?.[chainId] === l2Token
121
+ (l1Token) => this.spokePoolTokens[l1Token]?.[chainId].eq(l2Token)
121
122
  );
122
- return l1Token ?? super.getL1TokenForL2TokenAtBlock(l2Token, chainId, blockNumber);
123
+ if (isDefined(l1Token)) {
124
+ return EvmAddress.from(l1Token);
125
+ } else {
126
+ return super.getL1TokenForL2TokenAtBlock(l2Token, chainId, blockNumber);
127
+ }
123
128
  }
124
129
 
125
- getL2TokenForL1TokenAtBlock(l1Token: string, chainId: number, blockNumber: number): string {
126
- const l2Token = this.spokePoolTokens[l1Token]?.[chainId];
130
+ getL2TokenForL1TokenAtBlock(l1Token: EvmAddress, chainId: number, blockNumber: number): Address {
131
+ const l2Token = this.spokePoolTokens[l1Token.toEvmAddress()]?.[chainId];
127
132
  return l2Token ?? super.getL2TokenForL1TokenAtBlock(l1Token, chainId, blockNumber);
128
133
  }
129
134
 
130
- getTokenInfoForL1Token(l1Token: string): L1Token | undefined {
131
- return this.l1TokensMock.find((token) => token.address === l1Token);
135
+ getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined {
136
+ return this.l1TokensMock.find((token) => token.address.eq(l1Token));
132
137
  }
133
138
 
134
139
  _update(eventNames: string[]): Promise<HubPoolUpdate> {
@@ -2,7 +2,7 @@ import assert from "assert";
2
2
  import { Contract } from "ethers";
3
3
  import { random } from "lodash";
4
4
  import winston from "winston";
5
- import { EMPTY_MESSAGE, ZERO_ADDRESS } from "../../constants";
5
+ import { EMPTY_MESSAGE, ZERO_ADDRESS, ZERO_BYTES } from "../../constants";
6
6
  import {
7
7
  Log,
8
8
  Deposit,
@@ -27,6 +27,9 @@ import {
27
27
  bnOne,
28
28
  toBytes32,
29
29
  spreadEventWithBlockNumber,
30
+ Address,
31
+ toAddressType,
32
+ isDefined,
30
33
  } from "../../utils";
31
34
  import { EVMSpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
32
35
  import { HubPoolClient } from "../HubPoolClient";
@@ -62,8 +65,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
62
65
  this.destinationTokenForChainOverride[chainId] = token;
63
66
  }
64
67
 
65
- getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
66
- return this.destinationTokenForChainOverride[deposit.originChainId] ?? super.getDestinationTokenForDeposit(deposit);
68
+ getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
69
+ const override = this.destinationTokenForChainOverride[deposit.originChainId];
70
+ return isDefined(override)
71
+ ? toAddressType(override, deposit.destinationChainId)
72
+ : super.getDestinationTokenForDeposit(deposit);
67
73
  }
68
74
 
69
75
  setLatestBlockNumber(blockNumber: number): void {
@@ -129,23 +135,26 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
129
135
  return this._deposit("FundsDeposited", deposit);
130
136
  }
131
137
 
132
- protected _deposit(event: string, deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
138
+ protected _deposit(
139
+ event: string,
140
+ deposit: Omit<Deposit, "messageHash"> & { message?: string } & Partial<SortableEvent>
141
+ ): Log {
133
142
  const { blockNumber, txnIndex } = deposit;
134
143
  let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
135
144
  depositId ??= this.numberOfDeposits;
136
145
  this.numberOfDeposits = depositId.add(bnOne);
137
146
 
138
147
  destinationChainId ??= random(1, 42161, false);
139
- const depositor = toBytes32(deposit.depositor ?? randomAddress());
140
- const recipient = toBytes32(deposit.recipient ?? depositor);
141
- const inputToken = toBytes32(deposit.inputToken ?? randomAddress());
142
- const outputToken = toBytes32(deposit.outputToken ?? inputToken);
143
- const exclusiveRelayer = toBytes32(deposit.exclusiveRelayer ?? ZERO_ADDRESS);
148
+ const depositor = deposit.depositor?.toBytes32() ?? toBytes32(randomAddress());
149
+ const recipient = deposit.recipient?.toBytes32() ?? toBytes32(depositor);
150
+ const inputToken = deposit.inputToken?.toBytes32() ?? toBytes32(randomAddress());
151
+ const outputToken = deposit.outputToken?.toBytes32() ?? inputToken;
152
+ const exclusiveRelayer = deposit.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
144
153
 
145
154
  inputAmount ??= toBNWei(random(1, 1000, false));
146
155
  outputAmount ??= inputAmount.mul(toBN("0.95"));
147
156
 
148
- const message = deposit["message"] ?? "0x";
157
+ const message = deposit.message ?? "0x";
149
158
  const topics = [destinationChainId, depositId, depositor];
150
159
  const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
151
160
  const args = {
@@ -191,19 +200,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
191
200
  outputAmount ??= inputAmount;
192
201
  fillDeadline ??= getCurrentTime() + 60;
193
202
 
194
- const depositor = toBytes32(fill.depositor ?? randomAddress());
195
- const recipient = toBytes32(fill.recipient ?? depositor);
196
- const inputToken = toBytes32(fill.inputToken ?? randomAddress());
197
- const outputToken = toBytes32(fill.outputToken ?? ZERO_ADDRESS);
198
- const exclusiveRelayer = toBytes32(fill.exclusiveRelayer ?? ZERO_ADDRESS);
199
- const relayer = toBytes32(fill.relayer ?? randomAddress());
203
+ const depositor = fill.depositor?.toBytes32() ?? toBytes32(randomAddress());
204
+ const recipient = fill.recipient?.toBytes32() ?? toBytes32(depositor);
205
+ const inputToken = fill.inputToken?.toBytes32() ?? toBytes32(randomAddress());
206
+ const outputToken = fill.outputToken?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
207
+ const exclusiveRelayer = fill.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
208
+ const relayer = fill.relayer?.toBytes32() ?? toBytes32(randomAddress());
200
209
 
201
210
  const topics = [originChainId, depositId, relayer];
202
211
  const message = fill.message ?? EMPTY_MESSAGE;
203
212
  const updatedMessage = fill.relayExecutionInfo?.updatedMessage ?? message;
213
+ const updatedRecipient = fill.relayExecutionInfo?.updatedRecipient.toBytes32() ?? recipient;
204
214
 
205
215
  const relayExecutionInfo = {
206
- updatedRecipient: fill.relayExecutionInfo?.updatedRecipient ?? recipient,
216
+ updatedRecipient,
207
217
  updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
208
218
  fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
209
219
  };
@@ -223,7 +233,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
223
233
  depositor,
224
234
  recipient,
225
235
  relayExecutionInfo: {
226
- updatedRecipient: fill.relayExecutionInfo?.updatedRecipient ?? recipient,
236
+ updatedRecipient,
227
237
  updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
228
238
  fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
229
239
  },
@@ -253,7 +263,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
253
263
  }
254
264
 
255
265
  protected _speedUpDeposit(event: string, speedUp: SpeedUp): Log {
256
- const depositor = toBytes32(speedUp.depositor);
266
+ const depositor = speedUp.depositor.toBytes32();
257
267
  const topics = [speedUp.depositId, depositor];
258
268
  const args = { ...speedUp };
259
269
 
@@ -264,7 +274,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
264
274
  args: {
265
275
  ...args,
266
276
  depositor,
267
- updatedRecipient: toBytes32(speedUp.updatedRecipient),
277
+ updatedRecipient: speedUp.updatedRecipient.toBytes32(),
268
278
  },
269
279
  });
270
280
  }
@@ -294,7 +304,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
294
304
  const topics = [originChainId, depositId];
295
305
  const args = { ...request };
296
306
 
297
- const depositor = toBytes32(args.depositor ?? randomAddress());
307
+ const depositor = args.depositor.toBytes32() ?? toBytes32(randomAddress());
298
308
 
299
309
  return this.eventManager.generateEvent({
300
310
  event,
@@ -304,10 +314,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
304
314
  ...args,
305
315
  destinationChainId: this.chainId,
306
316
  depositor,
307
- recipient: toBytes32(args.recipient ?? depositor),
308
- inputToken: toBytes32(args.inputToken ?? randomAddress()),
309
- outputToken: toBytes32(args.outputToken ?? ZERO_ADDRESS),
310
- exclusiveRelayer: toBytes32(args.exclusiveRelayer ?? ZERO_ADDRESS),
317
+ recipient: args.recipient?.toBytes32() ?? depositor,
318
+ inputToken: args.inputToken?.toBytes32() ?? toBytes32(randomAddress()),
319
+ outputToken: args.outputToken?.toBytes32() ?? toBytes32(ZERO_ADDRESS),
320
+ exclusiveRelayer: args.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS),
321
+ messageHash: args.messageHash ?? ZERO_BYTES,
311
322
  },
312
323
  blockNumber: request.blockNumber,
313
324
  transactionIndex: request.txnIndex,
@@ -317,10 +328,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
317
328
  // This is a simple wrapper around fillRelay().
318
329
  // rootBundleId and proof are discarded here - we have no interest in verifying that.
319
330
  executeSlowRelayLeaf(leaf: Omit<SlowFillLeaf, "messageHash">): Log {
331
+ const destinationChainId = this.chainId;
320
332
  const fill = {
321
333
  ...leaf.relayData,
322
- destinationChainId: this.chainId,
323
- relayer: ZERO_ADDRESS,
334
+ destinationChainId,
335
+ relayer: toAddressType(ZERO_ADDRESS, destinationChainId),
324
336
  repaymentChainId: 0,
325
337
  relayExecutionInfo: {
326
338
  updatedRecipient: leaf.relayData.recipient,
@@ -1,4 +1,5 @@
1
1
  import assert from "assert";
2
+ import { utils as ethersUtils } from "ethers";
2
3
  import { createHash } from "crypto";
3
4
  import { hexlify, arrayify, hexZeroPad } from "ethers/lib/utils";
4
5
  import { random } from "lodash";
@@ -17,9 +18,11 @@ import {
17
18
  SVMProvider,
18
19
  getRandomSvmAddress,
19
20
  } from "../../arch/svm";
20
- import { bnZero, bnOne, bs58, getCurrentTime, randomAddress, EvmAddress } from "../../utils";
21
+ import { bnZero, bnOne, bs58, getCurrentTime, randomAddress, EvmAddress, SvmAddress } from "../../utils";
21
22
  import { FillType } from "../../interfaces";
22
23
 
24
+ const randomBytes = (n: number) => ethersUtils.hexlify(ethersUtils.randomBytes(n));
25
+
23
26
  export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
24
27
  private events: Record<EventName, EventWithData[]> = {} as Record<EventName, EventWithData[]>;
25
28
  private slotHeight: bigint = BigInt(0);
@@ -75,9 +78,9 @@ export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
75
78
 
76
79
  destinationChainId ??= BigInt(random(1, 42161, false));
77
80
  const depositor = deposit.depositor ?? getRandomSvmAddress();
78
- const recipient = deposit.recipient ?? EvmAddress.from(randomAddress()).toBase58();
81
+ const recipient = deposit.recipient ?? SvmAddress.from(randomBytes(32), "base16").toBase58();
79
82
  const inputToken = deposit.inputToken ?? getRandomSvmAddress();
80
- const outputToken = deposit.outputToken ?? EvmAddress.from(randomAddress()).toBase58();
83
+ const outputToken = deposit.outputToken ?? SvmAddress.from(randomBytes(32), "base16").toBase58();
81
84
  inputAmount ??= BigInt(random(1, 1000, false));
82
85
  outputAmount ??= (inputAmount * BigInt(95)) / BigInt(100);
83
86
  const message = deposit.message ?? new Uint8Array(32);
@@ -158,9 +161,9 @@ export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
158
161
  let { depositId, originChainId } = slowFillRequest;
159
162
  depositId ??= Uint8Array.from([random(1, 100_000, false)]);
160
163
  originChainId ??= BigInt(random(1, 42161, false));
161
- const depositor = slowFillRequest.depositor ?? EvmAddress.from(randomAddress()).toBase58();
164
+ const depositor = slowFillRequest.depositor ?? SvmAddress.from(randomBytes(32)).toBase58();
162
165
  const recipient = slowFillRequest.recipient ?? getRandomSvmAddress();
163
- const inputToken = slowFillRequest.inputToken ?? EvmAddress.from(randomAddress()).toBase58();
166
+ const inputToken = slowFillRequest.inputToken ?? SvmAddress.from(randomBytes(32)).toBase58();
164
167
  const outputToken = slowFillRequest.outputToken ?? getRandomSvmAddress();
165
168
 
166
169
  const args = {
@@ -2,7 +2,15 @@ import winston from "winston";
2
2
  import { SvmSpokeClient } from "@across-protocol/contracts";
3
3
  import { Address } from "@solana/kit";
4
4
  import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces";
5
- import { getCurrentTime, bnZero, MakeOptional, EventSearchConfig } from "../../utils";
5
+ import {
6
+ getCurrentTime,
7
+ bnZero,
8
+ MakeOptional,
9
+ EventSearchConfig,
10
+ Address as SDKAddress,
11
+ toAddressType,
12
+ isDefined,
13
+ } from "../../utils";
6
14
  import { SpokePoolUpdate, SVMSpokePoolClient } from "../SpokePoolClient";
7
15
  import { HubPoolClient } from "../HubPoolClient";
8
16
  import { EventOverrides } from "./MockEvents";
@@ -46,8 +54,9 @@ export class MockSvmSpokePoolClient extends SVMSpokePoolClient {
46
54
  this.destinationTokenForChainOverride[chainId] = token;
47
55
  }
48
56
 
49
- getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
50
- return this.destinationTokenForChainOverride[deposit.originChainId] ?? super.getDestinationTokenForDeposit(deposit);
57
+ getDestinationTokenForDeposit(deposit: DepositWithBlock): SDKAddress {
58
+ const override = this.destinationTokenForChainOverride[deposit.originChainId];
59
+ return isDefined(override) ? toAddressType(override, this.chainId) : super.getDestinationTokenForDeposit(deposit);
51
60
  }
52
61
 
53
62
  setLatestBlockNumber(blockNumber: number): void {