@across-protocol/sdk 4.3.9 → 4.3.11

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 (91) hide show
  1. package/dist/cjs/arch/evm/index.d.ts +1 -0
  2. package/dist/cjs/arch/evm/index.js +1 -0
  3. package/dist/cjs/arch/evm/index.js.map +1 -1
  4. package/dist/cjs/arch/evm/utils/index.d.ts +1 -0
  5. package/dist/cjs/arch/evm/utils/index.js +5 -0
  6. package/dist/cjs/arch/evm/utils/index.js.map +1 -0
  7. package/dist/cjs/arch/evm/utils/wait.d.ts +17 -0
  8. package/dist/cjs/arch/evm/utils/wait.js +81 -0
  9. package/dist/cjs/arch/evm/utils/wait.js.map +1 -0
  10. package/dist/cjs/arch/svm/SpokeUtils.d.ts +2 -2
  11. package/dist/cjs/arch/svm/SpokeUtils.js +66 -52
  12. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  13. package/dist/cjs/arch/svm/provider.d.ts +2 -0
  14. package/dist/cjs/arch/svm/provider.js +7 -0
  15. package/dist/cjs/arch/svm/provider.js.map +1 -0
  16. package/dist/cjs/arch/svm/utils.d.ts +1 -0
  17. package/dist/cjs/arch/svm/utils.js +3 -1
  18. package/dist/cjs/arch/svm/utils.js.map +1 -1
  19. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +23 -3
  20. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  21. package/dist/cjs/interfaces/PubSubMechanism.d.ts +4 -0
  22. package/dist/cjs/interfaces/PubSubMechanism.js +3 -0
  23. package/dist/cjs/interfaces/PubSubMechanism.js.map +1 -0
  24. package/dist/cjs/interfaces/index.d.ts +1 -0
  25. package/dist/cjs/interfaces/index.js +1 -0
  26. package/dist/cjs/interfaces/index.js.map +1 -1
  27. package/dist/cjs/providers/types.d.ts +2 -2
  28. package/dist/cjs/typeguards/error.d.ts +2 -1
  29. package/dist/cjs/typeguards/error.js +3 -1
  30. package/dist/cjs/typeguards/error.js.map +1 -1
  31. package/dist/esm/arch/evm/index.d.ts +1 -0
  32. package/dist/esm/arch/evm/index.js +1 -0
  33. package/dist/esm/arch/evm/index.js.map +1 -1
  34. package/dist/esm/arch/evm/utils/index.d.ts +1 -0
  35. package/dist/esm/arch/evm/utils/index.js +2 -0
  36. package/dist/esm/arch/evm/utils/index.js.map +1 -0
  37. package/dist/esm/arch/evm/utils/wait.d.ts +17 -0
  38. package/dist/esm/arch/evm/utils/wait.js +77 -0
  39. package/dist/esm/arch/evm/utils/wait.js.map +1 -0
  40. package/dist/esm/arch/svm/SpokeUtils.d.ts +2 -2
  41. package/dist/esm/arch/svm/SpokeUtils.js +22 -8
  42. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  43. package/dist/esm/arch/svm/provider.d.ts +6 -0
  44. package/dist/esm/arch/svm/provider.js +7 -0
  45. package/dist/esm/arch/svm/provider.js.map +1 -0
  46. package/dist/esm/arch/svm/utils.d.ts +1 -0
  47. package/dist/esm/arch/svm/utils.js +1 -0
  48. package/dist/esm/arch/svm/utils.js.map +1 -1
  49. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +24 -4
  50. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
  51. package/dist/esm/interfaces/PubSubMechanism.d.ts +14 -0
  52. package/dist/esm/interfaces/PubSubMechanism.js +2 -0
  53. package/dist/esm/interfaces/PubSubMechanism.js.map +1 -0
  54. package/dist/esm/interfaces/index.d.ts +1 -0
  55. package/dist/esm/interfaces/index.js +1 -0
  56. package/dist/esm/interfaces/index.js.map +1 -1
  57. package/dist/esm/providers/types.d.ts +2 -2
  58. package/dist/esm/typeguards/error.d.ts +2 -1
  59. package/dist/esm/typeguards/error.js +1 -0
  60. package/dist/esm/typeguards/error.js.map +1 -1
  61. package/dist/types/arch/evm/index.d.ts +1 -0
  62. package/dist/types/arch/evm/index.d.ts.map +1 -1
  63. package/dist/types/arch/evm/utils/index.d.ts +2 -0
  64. package/dist/types/arch/evm/utils/index.d.ts.map +1 -0
  65. package/dist/types/arch/evm/utils/wait.d.ts +18 -0
  66. package/dist/types/arch/evm/utils/wait.d.ts.map +1 -0
  67. package/dist/types/arch/svm/SpokeUtils.d.ts +2 -2
  68. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  69. package/dist/types/arch/svm/provider.d.ts +7 -0
  70. package/dist/types/arch/svm/provider.d.ts.map +1 -0
  71. package/dist/types/arch/svm/utils.d.ts +1 -0
  72. package/dist/types/arch/svm/utils.d.ts.map +1 -1
  73. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
  74. package/dist/types/interfaces/PubSubMechanism.d.ts +15 -0
  75. package/dist/types/interfaces/PubSubMechanism.d.ts.map +1 -0
  76. package/dist/types/interfaces/index.d.ts +1 -0
  77. package/dist/types/interfaces/index.d.ts.map +1 -1
  78. package/dist/types/providers/types.d.ts +2 -2
  79. package/dist/types/typeguards/error.d.ts +2 -1
  80. package/dist/types/typeguards/error.d.ts.map +1 -1
  81. package/package.json +1 -1
  82. package/src/arch/evm/index.ts +1 -0
  83. package/src/arch/evm/utils/index.ts +1 -0
  84. package/src/arch/evm/utils/wait.ts +84 -0
  85. package/src/arch/svm/SpokeUtils.ts +24 -8
  86. package/src/arch/svm/provider.ts +7 -0
  87. package/src/arch/svm/utils.ts +2 -0
  88. package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +14 -4
  89. package/src/interfaces/PubSubMechanism.ts +15 -0
  90. package/src/interfaces/index.ts +1 -0
  91. package/src/typeguards/error.ts +3 -1
@@ -20,6 +20,8 @@ import { FillType, RelayData } from "../../interfaces";
20
20
  import { BigNumber, getRelayDataHash, isDefined, isUint8Array, Address as SdkAddress } from "../../utils";
21
21
  import { EventName, SVMEventNames, SVMProvider } from "./types";
22
22
 
23
+ export { isSolanaError } from "@solana/kit";
24
+
23
25
  /**
24
26
  * Basic void TransactionSigner type
25
27
  */
@@ -17,6 +17,8 @@ import {
17
17
  DepositSearchResult,
18
18
  EventSearchConfig,
19
19
  InvalidFill,
20
+ getNetworkName,
21
+ isDefined,
20
22
  MakeOptional,
21
23
  sortEventsAscendingInPlace,
22
24
  SvmAddress,
@@ -140,7 +142,7 @@ export class SVMSpokePoolClient extends SpokePoolClient {
140
142
  const timerStart = Date.now();
141
143
 
142
144
  const [currentTime, ...eventsQueried] = await Promise.all([
143
- this.svmEventsClient.getRpc().getBlockTime(BigInt(searchConfig.to)).send(),
145
+ this.getTimeAt(searchConfig.to),
144
146
  ...eventsToQuery.map(async (eventName, idx) => {
145
147
  const config = eventSearchConfigs[idx];
146
148
  const events = await this.svmEventsClient.queryEvents(
@@ -190,8 +192,16 @@ export class SVMSpokePoolClient extends SpokePoolClient {
190
192
  /**
191
193
  * Retrieves the timestamp for a given SVM slot number.
192
194
  */
193
- public override getTimestampForBlock(slot: number): Promise<number> {
194
- return getTimestampForSlot(this.svmEventsClient.getRpc(), slot);
195
+ public override async getTimestampForBlock(slot: number): Promise<number> {
196
+ let _slot = BigInt(slot);
197
+ do {
198
+ const timestamp = await getTimestampForSlot(this.svmEventsClient.getRpc(), _slot);
199
+ if (isDefined(timestamp)) {
200
+ return timestamp;
201
+ }
202
+ } while (--_slot > 0);
203
+
204
+ throw new Error(`Unable to resolve time at or before ${getNetworkName(this.chainId)} slot ${slot}`);
195
205
  }
196
206
 
197
207
  /**
@@ -200,7 +210,7 @@ export class SVMSpokePoolClient extends SpokePoolClient {
200
210
  * It is kept for consistency with the EVM SpokePoolClient.
201
211
  */
202
212
  public getTimeAt(slot: number): Promise<number> {
203
- return getTimestampForSlot(this.svmEventsClient.getRpc(), slot);
213
+ return this.getTimestampForBlock(slot);
204
214
  }
205
215
 
206
216
  /**
@@ -0,0 +1,15 @@
1
+ export interface PubSubMechanismInterface {
2
+ /**
3
+ * Subscribes to a topic.
4
+ * @param topic The topic to subscribe to.
5
+ * @param callback The callback to call when a message is received.
6
+ */
7
+ sub<T>(topic: string, callback: (message: T) => unknown): Promise<void>;
8
+
9
+ /**
10
+ * Publishes a message to the network.
11
+ * @param topic The topic to publish to.
12
+ * @param message The message to publish.
13
+ */
14
+ pub<T>(topic: string, message: T): Promise<void>;
15
+ }
@@ -6,4 +6,5 @@ export * from "./Bridge";
6
6
  export * from "./Error";
7
7
  export * from "./TypedData";
8
8
  export * from "./CachingMechanism";
9
+ export * from "./PubSubMechanism";
9
10
  export * from "./BundleData";
@@ -1,6 +1,8 @@
1
1
  import { ethers } from "ethers";
2
- import { EthersError } from "../interfaces";
3
2
  import { BaseError } from "viem";
3
+ import { EthersError } from "../interfaces";
4
+
5
+ export { isSolanaError } from "../arch/svm";
4
6
 
5
7
  export const isError = (error: unknown): error is Error => error instanceof Error;
6
8