@hyperbridge/sdk 1.0.0 → 1.1.12

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 (78) hide show
  1. package/README.md +45 -3
  2. package/dist/browser/index.d.ts +1952 -0
  3. package/dist/browser/index.js +6827 -0
  4. package/dist/browser/index.js.map +1 -0
  5. package/dist/browser/web_bg.wasm +0 -0
  6. package/dist/node/index.d.ts +1952 -0
  7. package/dist/node/index.js +6778 -0
  8. package/dist/node/index.js.map +1 -0
  9. package/dist/node/node_bg.wasm +0 -0
  10. package/package.json +43 -15
  11. package/plugins/vite.d.ts +11 -0
  12. package/plugins/vite.js +55 -0
  13. package/dist/abis/erc6160.d.ts +0 -370
  14. package/dist/abis/erc6160.js +0 -238
  15. package/dist/abis/erc6160.js.map +0 -1
  16. package/dist/abis/evmHost.d.ts +0 -1752
  17. package/dist/abis/evmHost.js +0 -2250
  18. package/dist/abis/evmHost.js.map +0 -1
  19. package/dist/abis/handler.d.ts +0 -580
  20. package/dist/abis/handler.js +0 -750
  21. package/dist/abis/handler.js.map +0 -1
  22. package/dist/abis/pingModule.d.ts +0 -594
  23. package/dist/abis/pingModule.js +0 -765
  24. package/dist/abis/pingModule.js.map +0 -1
  25. package/dist/abis/tokenGateway.d.ts +0 -839
  26. package/dist/abis/tokenGateway.js +0 -471
  27. package/dist/abis/tokenGateway.js.map +0 -1
  28. package/dist/chain.d.ts +0 -83
  29. package/dist/chain.js +0 -34
  30. package/dist/chain.js.map +0 -1
  31. package/dist/chains/evm.d.ts +0 -86
  32. package/dist/chains/evm.js +0 -249
  33. package/dist/chains/evm.js.map +0 -1
  34. package/dist/chains/substrate.d.ts +0 -88
  35. package/dist/chains/substrate.js +0 -287
  36. package/dist/chains/substrate.js.map +0 -1
  37. package/dist/client.d.ts +0 -216
  38. package/dist/client.js +0 -774
  39. package/dist/client.js.map +0 -1
  40. package/dist/index.d.ts +0 -6
  41. package/dist/index.js +0 -7
  42. package/dist/index.js.map +0 -1
  43. package/dist/queries.d.ts +0 -3
  44. package/dist/queries.js +0 -78
  45. package/dist/queries.js.map +0 -1
  46. package/dist/tests/hyperbridgeRequests.test.d.ts +0 -1
  47. package/dist/tests/hyperbridgeRequests.test.js +0 -415
  48. package/dist/tests/hyperbridgeRequests.test.js.map +0 -1
  49. package/dist/tests/postRequest.test.d.ts +0 -1
  50. package/dist/tests/postRequest.test.js +0 -293
  51. package/dist/tests/postRequest.test.js.map +0 -1
  52. package/dist/tests/setup.d.ts +0 -1
  53. package/dist/tests/setup.js +0 -6
  54. package/dist/tests/setup.js.map +0 -1
  55. package/dist/tests/tokenGateway.test.d.ts +0 -1
  56. package/dist/tests/tokenGateway.test.js +0 -85
  57. package/dist/tests/tokenGateway.test.js.map +0 -1
  58. package/dist/tests/xcmGateway.test.d.ts +0 -1
  59. package/dist/tests/xcmGateway.test.js +0 -71
  60. package/dist/tests/xcmGateway.test.js.map +0 -1
  61. package/dist/types/index.d.ts +0 -238
  62. package/dist/types/index.js +0 -30
  63. package/dist/types/index.js.map +0 -1
  64. package/dist/utils/mmr.d.ts +0 -13
  65. package/dist/utils/mmr.js +0 -153
  66. package/dist/utils/mmr.js.map +0 -1
  67. package/dist/utils/substrate.d.ts +0 -1913
  68. package/dist/utils/substrate.js +0 -361
  69. package/dist/utils/substrate.js.map +0 -1
  70. package/dist/utils/tokenGateway.d.ts +0 -68
  71. package/dist/utils/tokenGateway.js +0 -151
  72. package/dist/utils/tokenGateway.js.map +0 -1
  73. package/dist/utils/xcmGateway.d.ts +0 -81
  74. package/dist/utils/xcmGateway.js +0 -218
  75. package/dist/utils/xcmGateway.js.map +0 -1
  76. package/dist/utils.d.ts +0 -57
  77. package/dist/utils.js +0 -96
  78. package/dist/utils.js.map +0 -1
@@ -0,0 +1,1952 @@
1
+ import { ConsolaInstance } from 'consola';
2
+ import { GraphQLClient } from 'graphql-request';
3
+ import { Hex, Log, PublicClient } from 'viem';
4
+ import { ApiPromise } from '@polkadot/api';
5
+ import { SignerOptions } from '@polkadot/api/types';
6
+
7
+ type HexString = `0x${string}`;
8
+ interface IConfig {
9
+ source: IEvmConfig | ISubstrateConfig;
10
+ dest: IEvmConfig | ISubstrateConfig;
11
+ hyperbridge: IHyperbridgeConfig;
12
+ tracing?: boolean;
13
+ }
14
+ interface IEvmConfig {
15
+ rpcUrl: string;
16
+ stateMachineId: string;
17
+ host: string;
18
+ consensusStateId: string;
19
+ }
20
+ interface ISubstrateConfig {
21
+ wsUrl: string;
22
+ consensusStateId: string;
23
+ hasher: "Keccak" | "Blake2";
24
+ stateMachineId: string;
25
+ }
26
+ interface IHyperbridgeConfig {
27
+ wsUrl: string;
28
+ stateMachineId: string;
29
+ consensusStateId: string;
30
+ }
31
+ interface IPostRequest {
32
+ source: string;
33
+ dest: string;
34
+ from: HexString;
35
+ to: HexString;
36
+ nonce: bigint;
37
+ body: HexString;
38
+ timeoutTimestamp: bigint;
39
+ }
40
+ interface IGetRequest {
41
+ source: string;
42
+ dest: string;
43
+ from: HexString;
44
+ nonce: bigint;
45
+ height: bigint;
46
+ keys: HexString[];
47
+ timeoutTimestamp: bigint;
48
+ context: HexString;
49
+ }
50
+ interface GetResponseStorageValues {
51
+ key: HexString;
52
+ value: HexString;
53
+ }
54
+ interface IPostResponse {
55
+ post: IPostRequest;
56
+ response: string;
57
+ timeoutTimestamp: bigint;
58
+ }
59
+ type IMessage = {
60
+ Requests: HexString[];
61
+ } | {
62
+ Responses: HexString[];
63
+ };
64
+ type IndexerQueryClient = GraphQLClient;
65
+ interface ClientConfig {
66
+ pollInterval: number;
67
+ queryClient: IndexerQueryClient;
68
+ tracing?: boolean;
69
+ source: IEvmConfig | ISubstrateConfig;
70
+ dest: IEvmConfig | ISubstrateConfig;
71
+ hyperbridge: IHyperbridgeConfig;
72
+ }
73
+ interface RetryConfig {
74
+ maxRetries: number;
75
+ backoffMs: number;
76
+ logMessage?: string;
77
+ logger?: ConsolaInstance;
78
+ }
79
+ interface IsmpRequest {
80
+ source: string;
81
+ dest: string;
82
+ from: string;
83
+ to: string;
84
+ nonce: bigint;
85
+ body: string;
86
+ timeoutTimestamp: bigint;
87
+ storage_key?: string;
88
+ }
89
+ declare const RequestStatus: Readonly<{
90
+ SOURCE: "SOURCE";
91
+ SOURCE_FINALIZED: "SOURCE_FINALIZED";
92
+ HYPERBRIDGE_DELIVERED: "HYPERBRIDGE_DELIVERED";
93
+ HYPERBRIDGE_FINALIZED: "HYPERBRIDGE_FINALIZED";
94
+ DESTINATION: "DESTINATION";
95
+ TIMED_OUT: "TIMED_OUT";
96
+ HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT";
97
+ }>;
98
+ type RequestStatus = typeof RequestStatus;
99
+ type RequestStatusKey = keyof typeof RequestStatus;
100
+ declare const TimeoutStatus: Readonly<{
101
+ PENDING_TIMEOUT: "PENDING_TIMEOUT";
102
+ DESTINATION_FINALIZED_TIMEOUT: "DESTINATION_FINALIZED_TIMEOUT";
103
+ HYPERBRIDGE_TIMED_OUT: "HYPERBRIDGE_TIMED_OUT";
104
+ HYPERBRIDGE_FINALIZED_TIMEOUT: "HYPERBRIDGE_FINALIZED_TIMEOUT";
105
+ TIMED_OUT: "TIMED_OUT";
106
+ }>;
107
+ type TimeoutStatus = typeof TimeoutStatus;
108
+ type TimeoutStatusKey = keyof typeof TimeoutStatus;
109
+ type AllStatusKey = RequestStatusKey | TimeoutStatusKey;
110
+ declare enum HyperClientStatus {
111
+ PENDING = "PENDING",
112
+ SOURCE_FINALIZED = "SOURCE_FINALIZED",
113
+ HYPERBRIDGE_FINALIZED = "HYPERBRIDGE_FINALIZED",
114
+ HYPERBRIDGE_VERIFIED = "HYPERBRIDGE_VERIFIED",
115
+ DESTINATION = "DESTINATION",
116
+ TIMED_OUT = "TIMED_OUT",
117
+ HYPERBRIDGE_TIMED_OUT = "HYPERBRIDGE_TIMED_OUT",
118
+ ERROR = "ERROR"
119
+ }
120
+ declare enum OrderStatus {
121
+ PLACED = "PLACED",
122
+ FILLED = "FILLED",
123
+ REDEEMED = "REDEEMED",
124
+ REFUNDED = "REFUNDED"
125
+ }
126
+ declare enum TeleportStatus {
127
+ TELEPORTED = "TELEPORTED",
128
+ RECEIVED = "RECEIVED",
129
+ REFUNDED = "REFUNDED"
130
+ }
131
+ interface TokenGatewayAssetTeleportedResponse {
132
+ tokenGatewayAssetTeleporteds: {
133
+ nodes: Array<{
134
+ id: string;
135
+ from: string;
136
+ to: string;
137
+ sourceChain: string;
138
+ destChain: string;
139
+ commitment: string;
140
+ amount: string;
141
+ usdValue: string;
142
+ assetId: string;
143
+ redeem: boolean;
144
+ status: TeleportStatus;
145
+ createdAt: string;
146
+ blockNumber: string;
147
+ blockTimestamp: string;
148
+ transactionHash: string;
149
+ statusMetadata: {
150
+ nodes: Array<{
151
+ status: TeleportStatus;
152
+ chain: string;
153
+ timestamp: string;
154
+ blockNumber: string;
155
+ blockHash: string;
156
+ transactionHash: string;
157
+ }>;
158
+ };
159
+ }>;
160
+ };
161
+ }
162
+ interface TokenGatewayAssetTeleportedWithStatus {
163
+ id: string;
164
+ from: string;
165
+ to: string;
166
+ sourceChain: string;
167
+ destChain: string;
168
+ commitment: string;
169
+ amount: bigint;
170
+ usdValue: string;
171
+ assetId: string;
172
+ redeem: boolean;
173
+ status: TeleportStatus;
174
+ createdAt: Date;
175
+ blockNumber: bigint;
176
+ blockTimestamp: bigint;
177
+ transactionHash: string;
178
+ statuses: Array<{
179
+ status: TeleportStatus;
180
+ metadata: {
181
+ blockHash: string;
182
+ blockNumber: number;
183
+ transactionHash: string;
184
+ timestamp: bigint;
185
+ };
186
+ }>;
187
+ }
188
+ interface BlockMetadata {
189
+ blockHash: string;
190
+ blockNumber: number;
191
+ transactionHash: string;
192
+ calldata?: string;
193
+ timestamp?: number;
194
+ }
195
+ interface PostRequestStatus {
196
+ status: RequestStatusKey;
197
+ metadata: Partial<BlockMetadata>;
198
+ }
199
+ interface PostRequestTimeoutStatus {
200
+ status: TimeoutStatusKey;
201
+ metadata?: Partial<BlockMetadata>;
202
+ }
203
+ interface StateMachineUpdate {
204
+ height: number;
205
+ chain: string;
206
+ blockHash: string;
207
+ blockNumber: number;
208
+ transactionHash: string;
209
+ transactionIndex: number;
210
+ stateMachineId: string;
211
+ timestamp: number;
212
+ }
213
+ interface RequestResponse {
214
+ requests: {
215
+ nodes: Array<{
216
+ source: string;
217
+ dest: string;
218
+ to: HexString;
219
+ from: HexString;
220
+ nonce: bigint;
221
+ body: HexString;
222
+ timeoutTimestamp: bigint;
223
+ statusMetadata: {
224
+ nodes: Array<{
225
+ blockHash: string;
226
+ blockNumber: string;
227
+ timestamp: string;
228
+ chain: string;
229
+ status: string;
230
+ transactionHash: string;
231
+ }>;
232
+ };
233
+ }>;
234
+ };
235
+ }
236
+ interface GetRequestResponse {
237
+ getRequests: {
238
+ nodes: Array<{
239
+ source: string;
240
+ dest: string;
241
+ to: HexString;
242
+ from: HexString;
243
+ nonce: bigint;
244
+ height: bigint;
245
+ keys: HexString[];
246
+ context: HexString;
247
+ timeoutTimestamp: bigint;
248
+ statusMetadata: {
249
+ nodes: Array<{
250
+ blockHash: string;
251
+ blockNumber: string;
252
+ timestamp: string;
253
+ chain: string;
254
+ status: string;
255
+ transactionHash: string;
256
+ }>;
257
+ };
258
+ }>;
259
+ };
260
+ }
261
+ type RequestStatusWithMetadata = {
262
+ status: RequestStatus["SOURCE"];
263
+ metadata: {
264
+ blockHash: string;
265
+ blockNumber: number;
266
+ transactionHash: string;
267
+ timestamp?: number;
268
+ };
269
+ } | {
270
+ status: RequestStatus["SOURCE_FINALIZED"];
271
+ metadata: {
272
+ blockHash: string;
273
+ blockNumber: number;
274
+ transactionHash: string;
275
+ timestamp?: number;
276
+ };
277
+ } | {
278
+ status: RequestStatus["HYPERBRIDGE_DELIVERED"];
279
+ metadata: {
280
+ blockHash: string;
281
+ blockNumber: number;
282
+ transactionHash: string;
283
+ timestamp?: number;
284
+ };
285
+ } | {
286
+ status: RequestStatus["HYPERBRIDGE_FINALIZED"];
287
+ metadata: {
288
+ calldata: Hex;
289
+ blockHash: string;
290
+ blockNumber: number;
291
+ transactionHash: string;
292
+ timestamp?: number;
293
+ };
294
+ } | {
295
+ status: RequestStatus["DESTINATION"];
296
+ metadata: {
297
+ blockHash: string;
298
+ blockNumber: number;
299
+ transactionHash: string;
300
+ timestamp?: number;
301
+ };
302
+ } | {
303
+ status: TimeoutStatus["PENDING_TIMEOUT"];
304
+ metadata: {
305
+ blockHash: string;
306
+ blockNumber: number;
307
+ transactionHash: string;
308
+ };
309
+ } | {
310
+ status: TimeoutStatus["DESTINATION_FINALIZED_TIMEOUT"];
311
+ metadata: {
312
+ blockHash: string;
313
+ blockNumber: number;
314
+ transactionHash: string;
315
+ timestamp?: number;
316
+ };
317
+ } | {
318
+ status: TimeoutStatus["HYPERBRIDGE_TIMED_OUT"];
319
+ metadata: {
320
+ blockHash: string;
321
+ blockNumber: number;
322
+ transactionHash: string;
323
+ timestamp?: number;
324
+ };
325
+ } | {
326
+ status: TimeoutStatus["HYPERBRIDGE_FINALIZED_TIMEOUT"];
327
+ metadata: {
328
+ calldata: Hex;
329
+ blockHash: string;
330
+ blockNumber: number;
331
+ transactionHash: string;
332
+ timestamp?: number;
333
+ };
334
+ } | {
335
+ status: TimeoutStatus["TIMED_OUT"];
336
+ metadata: {
337
+ blockHash: string;
338
+ blockNumber: number;
339
+ transactionHash: string;
340
+ timestamp?: number;
341
+ };
342
+ };
343
+ interface GenericRequestWithStatuses {
344
+ source: string;
345
+ dest: string;
346
+ from: HexString;
347
+ nonce: bigint;
348
+ timeoutTimestamp: bigint;
349
+ statuses: Array<RequestStatusWithMetadata>;
350
+ }
351
+ interface PostRequestWithStatus extends GenericRequestWithStatuses {
352
+ to: HexString;
353
+ body: HexString;
354
+ }
355
+ interface GetRequestWithStatus extends GenericRequestWithStatuses {
356
+ height: bigint;
357
+ keys: HexString[];
358
+ context: HexString;
359
+ }
360
+ interface GetResponseByRequestIdResponse {
361
+ getResponses: {
362
+ nodes: Array<{
363
+ id: string;
364
+ commitment: string;
365
+ responseMessage: string[];
366
+ }>;
367
+ };
368
+ }
369
+ interface ResponseCommitmentWithValues {
370
+ commitment: string;
371
+ values: string[];
372
+ }
373
+ interface RequestCommitment {
374
+ requests: {
375
+ nodes: Array<{
376
+ id: string;
377
+ commitment: string;
378
+ }>;
379
+ };
380
+ }
381
+ interface StateMachineResponse {
382
+ stateMachineUpdateEvents: {
383
+ nodes: {
384
+ height: number;
385
+ chain: string;
386
+ blockHash: string;
387
+ blockNumber: number;
388
+ transactionHash: string;
389
+ transactionIndex: number;
390
+ stateMachineId: string;
391
+ createdAt: string;
392
+ }[];
393
+ };
394
+ }
395
+ interface AssetTeleported {
396
+ id: string;
397
+ from: string;
398
+ to: string;
399
+ amount: bigint;
400
+ dest: string;
401
+ commitment: string;
402
+ createdAt: Date;
403
+ blockNumber: number;
404
+ }
405
+ interface AssetTeleportedResponse {
406
+ assetTeleporteds: {
407
+ nodes: AssetTeleported[];
408
+ };
409
+ }
410
+ interface StateMachineIdParams {
411
+ stateId: {
412
+ Evm?: number;
413
+ Substrate?: HexString;
414
+ Polkadot?: number;
415
+ Kusama?: number;
416
+ };
417
+ consensusStateId: HexString;
418
+ }
419
+ /**
420
+ * Configuration for a blockchain chain
421
+ */
422
+ interface ChainConfig {
423
+ /**
424
+ * The unique identifier for the chain
425
+ */
426
+ chainId: number;
427
+ /**
428
+ * The RPC URL to connect to the chain
429
+ */
430
+ rpcUrl: string;
431
+ /**
432
+ * The address of the IntentGateway contract on this chain
433
+ */
434
+ intentGatewayAddress: string;
435
+ }
436
+ /**
437
+ * Represents token information for an order
438
+ */
439
+ interface TokenInfo {
440
+ /**
441
+ * The address of the ERC20 token
442
+ * address(0) is used as a sentinel for the native token
443
+ */
444
+ token: HexString;
445
+ /**
446
+ * The amount of the token
447
+ */
448
+ amount: bigint;
449
+ }
450
+ /**
451
+ * Represents payment information for an order
452
+ */
453
+ interface PaymentInfo extends TokenInfo {
454
+ /**
455
+ * The address to receive the output tokens
456
+ */
457
+ beneficiary: HexString;
458
+ }
459
+ /**
460
+ * Represents an order in the IntentGateway
461
+ */
462
+ interface Order {
463
+ /**
464
+ * The unique identifier for the order
465
+ */
466
+ id?: string;
467
+ /**
468
+ * The address of the user who is initiating the transfer
469
+ */
470
+ user: HexString;
471
+ /**
472
+ * The state machine identifier of the origin chain
473
+ */
474
+ sourceChain: string;
475
+ /**
476
+ * The state machine identifier of the destination chain
477
+ */
478
+ destChain: string;
479
+ /**
480
+ * The block number by which the order must be filled on the destination chain
481
+ */
482
+ deadline: bigint;
483
+ /**
484
+ * The nonce of the order
485
+ */
486
+ nonce: bigint;
487
+ /**
488
+ * Represents the dispatch fees associated with the IntentGateway
489
+ */
490
+ fees: bigint;
491
+ /**
492
+ * The tokens that the filler will provide
493
+ */
494
+ outputs: PaymentInfo[];
495
+ /**
496
+ * The tokens that are escrowed for the filler
497
+ */
498
+ inputs: TokenInfo[];
499
+ /**
500
+ * A bytes array to store the calls if any
501
+ */
502
+ callData: HexString;
503
+ /**
504
+ * The transaction hash of the order
505
+ */
506
+ transactionHash?: HexString;
507
+ }
508
+ interface DecodedOrderPlacedLog extends Log {
509
+ eventName: string;
510
+ args: {
511
+ user: HexString;
512
+ sourceChain: Hex;
513
+ destChain: Hex;
514
+ deadline: bigint;
515
+ nonce: bigint;
516
+ fees: bigint;
517
+ outputs: Array<{
518
+ token: HexString;
519
+ amount: bigint;
520
+ beneficiary: HexString;
521
+ }>;
522
+ inputs: Array<{
523
+ token: HexString;
524
+ amount: bigint;
525
+ }>;
526
+ callData: HexString;
527
+ };
528
+ transactionHash: HexString;
529
+ }
530
+ /**
531
+ * Options for filling an order
532
+ */
533
+ interface FillOptions {
534
+ /**
535
+ * The fee paid to the relayer for processing transactions
536
+ */
537
+ relayerFee: bigint;
538
+ }
539
+ /**
540
+ * Options for canceling an order
541
+ */
542
+ interface CancelOptions {
543
+ /**
544
+ * The fee paid to the relayer for processing transactions
545
+ */
546
+ relayerFee: string;
547
+ /**
548
+ * Stores the height value
549
+ */
550
+ height: string;
551
+ }
552
+ /**
553
+ * Represents a new deployment of IntentGateway
554
+ */
555
+ interface NewDeployment {
556
+ /**
557
+ * Identifier for the state machine
558
+ */
559
+ stateMachineId: HexString;
560
+ /**
561
+ * The gateway identifier
562
+ */
563
+ gateway: HexString;
564
+ }
565
+ /**
566
+ * Represents the body of a request
567
+ */
568
+ interface RequestBody {
569
+ /**
570
+ * Represents the commitment of an order
571
+ */
572
+ commitment: HexString;
573
+ /**
574
+ * Stores the identifier for the beneficiary
575
+ */
576
+ beneficiary: HexString;
577
+ /**
578
+ * An array of token identifiers
579
+ */
580
+ tokens: TokenInfo[];
581
+ }
582
+ /**
583
+ * Represents the parameters for the IntentGateway module
584
+ */
585
+ interface IntentGatewayParams {
586
+ /**
587
+ * The address of the host contract
588
+ */
589
+ host: string;
590
+ /**
591
+ * Address of the dispatcher contract responsible for handling intents
592
+ */
593
+ dispatcher: string;
594
+ }
595
+ /**
596
+ * Enum representing the different kinds of incoming requests
597
+ */
598
+ declare enum RequestKind {
599
+ /**
600
+ * Identifies a request for redeeming an escrow
601
+ */
602
+ RedeemEscrow = 0,
603
+ /**
604
+ * Identifies a request for recording new contract deployments
605
+ */
606
+ NewDeployment = 1,
607
+ /**
608
+ * Identifies a request for updating parameters
609
+ */
610
+ UpdateParams = 2
611
+ }
612
+ /**
613
+ * Configuration for the IntentFiller
614
+ */
615
+ interface FillerConfig {
616
+ /**
617
+ * Policy for determining confirmation requirements
618
+ */
619
+ confirmationPolicy: {
620
+ getConfirmationBlocks: (chainId: number, amount: bigint) => number;
621
+ };
622
+ /**
623
+ * Maximum number of orders to process concurrently
624
+ */
625
+ maxConcurrentOrders?: number;
626
+ /**
627
+ * Minimum profitability threshold to consider filling an order
628
+ * Expressed as a percentage (e.g., 0.5 = 0.5%)
629
+ */
630
+ minProfitabilityThreshold?: number;
631
+ /**
632
+ * Gas price strategy for each chain
633
+ * Maps chainId to a gas price strategy function
634
+ */
635
+ gasPriceStrategy?: Record<string, () => Promise<string>>;
636
+ /**
637
+ * Maximum gas price willing to pay for each chain
638
+ * Maps chainId to maximum gas price in wei
639
+ */
640
+ maxGasPrice?: Record<string, string>;
641
+ /**
642
+ * Retry configuration for failed transactions
643
+ */
644
+ retryConfig?: {
645
+ /**
646
+ * Maximum number of retry attempts
647
+ */
648
+ maxAttempts: number;
649
+ /**
650
+ * Initial delay between retries in ms
651
+ */
652
+ initialDelayMs: number;
653
+ };
654
+ /**
655
+ * Configuration for the pending queue
656
+ */
657
+ pendingQueueConfig?: {
658
+ /**
659
+ * Delay in milliseconds before rechecking an order for confirmations
660
+ * Default: 30000 (30 seconds)
661
+ */
662
+ recheckDelayMs?: number;
663
+ /**
664
+ * Maximum number of times to recheck an order before giving up
665
+ * Default: 10
666
+ */
667
+ maxRechecks?: number;
668
+ };
669
+ }
670
+ /**
671
+ * Result of an order execution attempt
672
+ */
673
+ interface ExecutionResult {
674
+ /**
675
+ * Whether the execution was successful
676
+ */
677
+ success: boolean;
678
+ /**
679
+ * The transaction hash if successful
680
+ */
681
+ txHash?: string;
682
+ /**
683
+ * Error message if unsuccessful
684
+ */
685
+ error?: string;
686
+ /**
687
+ * Gas used by the transaction
688
+ */
689
+ gasUsed?: string;
690
+ /**
691
+ * Gas price used for the transaction
692
+ */
693
+ gasPrice?: string;
694
+ /**
695
+ * Total transaction cost in wei
696
+ */
697
+ txCost?: string;
698
+ /**
699
+ * Block number when the transaction was confirmed
700
+ */
701
+ confirmedAtBlock?: number;
702
+ /**
703
+ * Timestamp when the transaction was confirmed
704
+ */
705
+ confirmedAt?: Date;
706
+ /**
707
+ * Actual profitability achieved
708
+ */
709
+ actualProfitability?: number;
710
+ /**
711
+ * Strategy used to fill the order
712
+ */
713
+ strategyUsed?: string;
714
+ /**
715
+ * Any tokens exchanged during the fill process
716
+ */
717
+ exchanges?: Array<{
718
+ fromToken: HexString;
719
+ toToken: HexString;
720
+ fromAmount: string;
721
+ toAmount: string;
722
+ exchangeRate: string;
723
+ }>;
724
+ /**
725
+ * The time it took to fill the order
726
+ */
727
+ processingTimeMs?: number;
728
+ }
729
+ /**
730
+ * Represents a dispatch post for cross-chain communication
731
+ */
732
+ interface DispatchPost {
733
+ /**
734
+ * Bytes representation of the destination state machine
735
+ */
736
+ dest: HexString;
737
+ /**
738
+ * The destination module
739
+ */
740
+ to: HexString;
741
+ /**
742
+ * The request body
743
+ */
744
+ body: HexString;
745
+ /**
746
+ * Timeout for this request in seconds
747
+ */
748
+ timeout: bigint;
749
+ /**
750
+ * The amount put up to be paid to the relayer,
751
+ * this is charged in `IIsmpHost.feeToken` to `msg.sender`
752
+ */
753
+ fee: bigint;
754
+ /**
755
+ * Who pays for this request?
756
+ */
757
+ payer: HexString;
758
+ }
759
+ interface DispatchGet {
760
+ /**
761
+ * Bytes representation of the destination state machine
762
+ */
763
+ dest: HexString;
764
+ /**
765
+ * Height at which to read the state machine
766
+ */
767
+ height: bigint;
768
+ /**
769
+ * Raw storage keys to fetch values from the counterparty
770
+ */
771
+ keys: HexString[];
772
+ /**
773
+ * Timeout for this request in seconds
774
+ */
775
+ timeout: bigint;
776
+ /**
777
+ * The amount put up to be paid to the relayer
778
+ */
779
+ fee: bigint;
780
+ /**
781
+ * Context for the request
782
+ */
783
+ context: HexString;
784
+ }
785
+ interface StateMachineHeight {
786
+ id: {
787
+ stateId: {
788
+ Evm?: number;
789
+ Substrate?: HexString;
790
+ Polkadot?: number;
791
+ Kusama?: number;
792
+ };
793
+ consensusStateId: HexString;
794
+ };
795
+ height: bigint;
796
+ }
797
+ /**
798
+ * The EvmHost protocol parameters
799
+ */
800
+ interface HostParams {
801
+ /**
802
+ * The default timeout in seconds for messages. If messages are dispatched
803
+ * with a timeout value lower than this this value will be used instead
804
+ */
805
+ defaultTimeout: bigint;
806
+ /**
807
+ * The default per byte fee
808
+ */
809
+ perByteFee: bigint;
810
+ /**
811
+ * The cost for applications to access the hyperbridge state commitment.
812
+ * They might do so because the hyperbridge state contains the verified state commitments
813
+ * for all chains and they want to directly read the state of these chains state bypassing
814
+ * the ISMP protocol entirely.
815
+ */
816
+ stateCommitmentFee: bigint;
817
+ /**
818
+ * The fee token contract address. This will typically be DAI.
819
+ * but we allow it to be configurable to prevent future regrets.
820
+ */
821
+ feeToken: HexString;
822
+ /**
823
+ * The admin account, this only has the rights to freeze, or unfreeze the bridge
824
+ */
825
+ admin: HexString;
826
+ /**
827
+ * Ismp message handler contract. This performs all verification logic
828
+ * needed to validate cross-chain messages before they are dispatched to local modules
829
+ */
830
+ handler: HexString;
831
+ /**
832
+ * The authorized host manager contract, is itself an `IIsmpModule`
833
+ * which receives governance requests from the Hyperbridge chain to either
834
+ * withdraw revenue from the host or update its protocol parameters
835
+ */
836
+ hostManager: HexString;
837
+ /**
838
+ * The local UniswapV2Router02 contract, used for swapping the native token to the feeToken.
839
+ */
840
+ uniswapV2: HexString;
841
+ /**
842
+ * The unstaking period of Polkadot's validators. In order to prevent long-range attacks
843
+ */
844
+ unStakingPeriod: bigint;
845
+ /**
846
+ * Minimum challenge period for state commitments in seconds
847
+ */
848
+ challengePeriod: bigint;
849
+ /**
850
+ * The consensus client contract which handles consensus proof verification
851
+ */
852
+ consensusClient: HexString;
853
+ /**
854
+ * State machines whose state commitments are accepted
855
+ */
856
+ readonly stateMachines: readonly bigint[];
857
+ /**
858
+ * The state machine identifier for hyperbridge
859
+ */
860
+ hyperbridge: HexString;
861
+ }
862
+ declare enum EvmLanguage {
863
+ Solidity = 0,
864
+ Vyper = 1
865
+ }
866
+ interface OrderStatusMetadata {
867
+ status: OrderStatus;
868
+ chain: string;
869
+ timestamp: bigint;
870
+ blockNumber: string;
871
+ transactionHash: string;
872
+ filler?: string;
873
+ }
874
+ interface OrderWithStatus {
875
+ id: string;
876
+ user: string;
877
+ sourceChain: string;
878
+ destChain: string;
879
+ commitment: string;
880
+ deadline: bigint;
881
+ nonce: bigint;
882
+ fees: bigint;
883
+ inputTokens: string[];
884
+ inputAmounts: bigint[];
885
+ inputValuesUSD: string[];
886
+ inputUSD: string;
887
+ outputTokens: string[];
888
+ outputAmounts: bigint[];
889
+ outputBeneficiaries: string[];
890
+ calldata: string;
891
+ status: OrderStatus;
892
+ createdAt: Date;
893
+ blockNumber: bigint;
894
+ blockTimestamp: bigint;
895
+ transactionHash: string;
896
+ statuses: Array<{
897
+ status: OrderStatus;
898
+ metadata: {
899
+ blockHash: string;
900
+ blockNumber: number;
901
+ transactionHash: string;
902
+ timestamp: bigint;
903
+ filler?: string;
904
+ };
905
+ }>;
906
+ }
907
+ interface OrderResponse {
908
+ orderPlaceds: {
909
+ nodes: Array<{
910
+ id: string;
911
+ user: string;
912
+ sourceChain: string;
913
+ destChain: string;
914
+ commitment: string;
915
+ deadline: string;
916
+ nonce: string;
917
+ fees: string;
918
+ inputTokens: string[];
919
+ inputAmounts: string[];
920
+ inputValuesUSD: string[];
921
+ inputUSD: string;
922
+ outputTokens: string[];
923
+ outputAmounts: string[];
924
+ outputBeneficiaries: string[];
925
+ calldata: string;
926
+ status: OrderStatus;
927
+ createdAt: string;
928
+ blockNumber: string;
929
+ blockTimestamp: string;
930
+ transactionHash: string;
931
+ statusMetadata: {
932
+ nodes: Array<{
933
+ status: OrderStatus;
934
+ chain: string;
935
+ timestamp: string;
936
+ blockNumber: string;
937
+ blockHash: string;
938
+ transactionHash: string;
939
+ filler?: string;
940
+ }>;
941
+ };
942
+ }>;
943
+ };
944
+ }
945
+ declare class AbortSignalInternal extends Error {
946
+ constructor(message: string);
947
+ static isError(error: unknown): error is AbortSignalInternal;
948
+ }
949
+
950
+ /**
951
+ * The default address used as fallback when no address is provided.
952
+ * This represents the zero address in EVM chains.
953
+ */
954
+ declare const DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
955
+ /**
956
+ * Parameters for an EVM chain.
957
+ */
958
+ interface EvmChainParams {
959
+ /**
960
+ * The chain ID of the EVM chain.
961
+ */
962
+ chainId: number;
963
+ /**
964
+ * The host address of the EVM chain.
965
+ */
966
+ host: HexString;
967
+ /**
968
+ * The URL of the EVM chain.
969
+ */
970
+ url: string;
971
+ }
972
+ /**
973
+ * Encapsulates an EVM chain.
974
+ */
975
+ declare class EvmChain implements IChain {
976
+ private readonly params;
977
+ private publicClient;
978
+ constructor(params: EvmChainParams);
979
+ /**
980
+ * Derives the key for the request receipt.
981
+ * @param {HexString} commitment - The commitment to derive the key from.
982
+ * @returns {HexString} The derived key.
983
+ */
984
+ requestReceiptKey(commitment: HexString): HexString;
985
+ /**
986
+ * Queries the request receipt.
987
+ * @param {HexString} commitment - The commitment to query.
988
+ * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
989
+ */
990
+ queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
991
+ /**
992
+ * Queries the proof of the commitments.
993
+ * @param {IMessage} message - The message to query.
994
+ * @param {string} counterparty - The counterparty address.
995
+ * @param {bigint} [at] - The block number to query at.
996
+ * @returns {Promise<HexString>} The proof.
997
+ */
998
+ queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
999
+ /**
1000
+ * Query and return the encoded storage proof for the provided keys at the given height.
1001
+ * @param {bigint} at - The block height at which to query the storage proof.
1002
+ * @param {HexString[]} keys - The keys for which to query the storage proof.
1003
+ * @returns {Promise<HexString>} The encoded storage proof.
1004
+ */
1005
+ queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
1006
+ /**
1007
+ * Returns the current timestamp of the chain.
1008
+ * @returns {Promise<bigint>} The current timestamp.
1009
+ */
1010
+ timestamp(): Promise<bigint>;
1011
+ /**
1012
+ * Get the latest state machine height for a given state machine ID.
1013
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1014
+ * @returns {Promise<bigint>} The latest state machine height.
1015
+ */
1016
+ latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1017
+ /**
1018
+ * Get the state machine update time for a given state machine height.
1019
+ * @param {StateMachineHeight} stateMachineheight - The state machine height.
1020
+ * @returns {Promise<bigint>} The statemachine update time in seconds.
1021
+ */
1022
+ stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1023
+ /**
1024
+ * Get the challenge period for a given state machine id.
1025
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1026
+ * @returns {Promise<bigint>} The challenge period in seconds.
1027
+ */
1028
+ challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1029
+ /**
1030
+ * Encodes an ISMP message for the EVM chain.
1031
+ * @param {IIsmpMessage} message The ISMP message to encode.
1032
+ * @returns {HexString} The encoded calldata.
1033
+ */
1034
+ encode(message: IIsmpMessage): HexString;
1035
+ }
1036
+ /**
1037
+ * Slot for storing request commitments.
1038
+ */
1039
+ declare const REQUEST_COMMITMENTS_SLOT = 0n;
1040
+ /**
1041
+ * Slot index for response commitments map
1042
+ */
1043
+ declare const RESPONSE_COMMITMENTS_SLOT = 1n;
1044
+ /**
1045
+ * Slot index for requests receipts map
1046
+ */
1047
+ declare const REQUEST_RECEIPTS_SLOT = 2n;
1048
+ /**
1049
+ * Slot index for response receipts map
1050
+ */
1051
+ declare const RESPONSE_RECEIPTS_SLOT = 3n;
1052
+ /**
1053
+ * Slot index for state commitment map
1054
+ */
1055
+ declare const STATE_COMMITMENTS_SLOT = 5n;
1056
+ /**
1057
+ * Derives the storage slot for a specific field in the StateCommitment struct
1058
+ *
1059
+ * struct StateCommitment {
1060
+ * uint256 timestamp; // slot + 0
1061
+ * bytes32 overlayRoot; // slot + 1
1062
+ * bytes32 stateRoot; // slot + 2
1063
+ * }
1064
+ *
1065
+ * @param stateMachineId - The state machine ID
1066
+ * @param height - The block height
1067
+ * @param field - The field index in the struct (0 for timestamp, 1 for overlayRoot, 2 for stateRoot)
1068
+ * @returns The storage slot for the specific field
1069
+ */
1070
+ declare function getStateCommitmentFieldSlot(stateMachineId: bigint, height: bigint, field: 0 | 1 | 2): HexString;
1071
+ declare function getStateCommitmentSlot(stateMachineId: bigint, height: bigint): HexString;
1072
+
1073
+ /**
1074
+ * Generates a Merkle Mountain Range (MMR) root hash and proof for a post request.
1075
+ *
1076
+ * This function takes a post request and tree size, encodes it according to the PostRequest format,
1077
+ * and generates both the MMR root hash and a proof. The function builds an MMR with `treeSize` leaves,
1078
+ * where most leaves are variations of the encoded request (XORed with their index), except for the
1079
+ * last leaf, which is the unmodified request. The proof is generated for this unmodified leaf.
1080
+ *
1081
+ * @param postRequest - The post request to generate the MMR root and proof for
1082
+ * @param treeSize - Controls how many leaves will be added to the MMR (exactly `treeSize` leaves)
1083
+ * @returns An object containing:
1084
+ * - root: The MMR root hash as a hex string
1085
+ * - proof: An array of hex strings representing the MMR proof for the unmodified request
1086
+ * - index: The index of the unmodified request in the MMR
1087
+ * - kIndex: The k-index of the unmodified request in the MMR
1088
+ * - treeSize: The number of leaves in the MMR
1089
+ * - mmrSize: The size of the MMR in nodes
1090
+ */
1091
+ declare function generateRootWithProof(postRequest: IPostRequest, treeSize: bigint): Promise<{
1092
+ root: HexString;
1093
+ proof: HexString[];
1094
+ index: bigint;
1095
+ kIndex: bigint;
1096
+ treeSize: bigint;
1097
+ mmrSize: bigint;
1098
+ }>;
1099
+ declare function __test(): Promise<string>;
1100
+
1101
+ type IStateMachine = {
1102
+ tag: "Evm";
1103
+ value: number;
1104
+ } | {
1105
+ tag: "Polkadot";
1106
+ value: number;
1107
+ } | {
1108
+ tag: "Kusama";
1109
+ value: number;
1110
+ } | {
1111
+ tag: "Substrate";
1112
+ value: number[];
1113
+ } | {
1114
+ tag: "Tendermint";
1115
+ value: number[];
1116
+ };
1117
+
1118
+ declare const ADDRESS_ZERO: HexString;
1119
+ declare const DUMMY_PRIVATE_KEY: HexString;
1120
+ /**
1121
+ * Calculates the commitment hash for a post request.
1122
+ * @param post The post request to calculate the commitment hash for.
1123
+ * @returns The commitment hash and the encode packed data.
1124
+ */
1125
+ declare function postRequestCommitment(post: IPostRequest): {
1126
+ commitment: HexString;
1127
+ encodePacked: HexString;
1128
+ };
1129
+ declare function orderCommitment(order: Order): HexString;
1130
+ /**
1131
+ * Converts a bytes32 token address to bytes20 format
1132
+ * This removes the extra padded zeros from the address
1133
+ */
1134
+ declare function bytes32ToBytes20(bytes32Address: string): HexString;
1135
+ declare function bytes20ToBytes32(bytes20Address: string): HexString;
1136
+ declare function hexToString(hex: string): string;
1137
+ /**
1138
+ * Calculates the commitment hash for a get request.
1139
+ * @param get The get request to calculate the commitment hash for.
1140
+ * @returns The commitment hash.
1141
+ */
1142
+ declare function getRequestCommitment(get: IGetRequest): HexString;
1143
+ /**
1144
+ * Estimates the gas required for a post request transaction on the source chain.
1145
+ * This function constructs a post request, generates mock proofs, and estimates
1146
+ * the gas cost for executing the transaction on the source chain.
1147
+ */
1148
+ declare function estimateGasForPost(params: {
1149
+ postRequest: IPostRequest;
1150
+ sourceClient: PublicClient;
1151
+ hostLatestStateMachineHeight: bigint;
1152
+ hostAddress: HexString;
1153
+ }): Promise<bigint>;
1154
+ /**
1155
+ * Constructs the request body for a redeem escrow operation.
1156
+ * This function encodes the order commitment, beneficiary address, and token inputs
1157
+ * to match the format expected by the IntentGateway contract.
1158
+ */
1159
+ declare function constructRedeemEscrowRequestBody(order: Order, beneficiary: HexString): HexString;
1160
+ /**
1161
+ * Calculates the balance mapping location for a given slot and holder address.
1162
+ * This function handles the different encoding formats used by Solidity and Vyper.
1163
+ *
1164
+ * @param slot - The slot number to calculate the mapping location for.
1165
+ * @param holder - The address of the holder to calculate the mapping location for.
1166
+ * @param language - The language of the contract.
1167
+ * @returns The balance mapping location as a HexString.
1168
+ */
1169
+ declare function calculateBalanceMappingLocation(slot: bigint, holder: string, language: EvmLanguage): HexString;
1170
+
1171
+ interface SubstrateChainParams {
1172
+ ws: string;
1173
+ hasher: "Keccak" | "Blake2";
1174
+ }
1175
+ declare class SubstrateChain implements IChain {
1176
+ private readonly params;
1177
+ api?: ApiPromise;
1178
+ constructor(params: SubstrateChainParams);
1179
+ connect(): Promise<void>;
1180
+ /**
1181
+ * Disconnects the Substrate chain connection.
1182
+ */
1183
+ disconnect(): Promise<void>;
1184
+ /**
1185
+ * Returns the storage key for a request receipt in the child trie
1186
+ * The request commitment is the key
1187
+ * @param key - The H256 hash key (as a 0x-prefixed hex string)
1188
+ * @returns The storage key as a hex string
1189
+ */
1190
+ requestReceiptKey(key: HexString): HexString;
1191
+ /**
1192
+ * Returns the storage key for a request commitment in the child trie
1193
+ * The request commitment is the key
1194
+ * @param key - The H256 hash key (as a 0x-prefixed hex string)
1195
+ * @returns The storage key as a hex string
1196
+ */
1197
+ requestCommitmentKey(key: HexString): HexString;
1198
+ /**
1199
+ * Queries a request commitment from the ISMP child trie storage.
1200
+ * @param {HexString} commitment - The commitment hash to look up.
1201
+ * @returns {Promise<HexString | undefined>} The commitment data if found, undefined otherwise.
1202
+ */
1203
+ queryRequestCommitment(commitment: HexString): Promise<HexString | undefined>;
1204
+ /**
1205
+ * Queries the request receipt.
1206
+ * @param {HexString} commitment - The commitment to query.
1207
+ * @returns {Promise<HexString | undefined>} The relayer address responsible for delivering the request.
1208
+ */
1209
+ queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1210
+ /**
1211
+ * Returns the current timestamp of the chain.
1212
+ * @returns {Promise<bigint>} The current timestamp.
1213
+ */
1214
+ timestamp(): Promise<bigint>;
1215
+ /**
1216
+ * Queries the proof of the commitments.
1217
+ * @param {IMessage} message - The message to query.
1218
+ * @param {string} counterparty - The counterparty address.
1219
+ * @param {bigint} [at] - The block number to query at.
1220
+ * @returns {Promise<HexString>} The proof.
1221
+ */
1222
+ queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1223
+ /**
1224
+ * Submit an unsigned ISMP transaction to the chain. Resolves when the transaction is finalized.
1225
+ * @param message - The message to be submitted.
1226
+ * @returns A promise that resolves to an object containing the transaction hash, block hash, and block number.
1227
+ */
1228
+ submitUnsigned(message: IIsmpMessage): Promise<{
1229
+ transactionHash: string;
1230
+ blockHash: string;
1231
+ blockNumber: number;
1232
+ timestamp: number;
1233
+ }>;
1234
+ /**
1235
+ * Query the state proof for a given set of keys at a specific block height.
1236
+ * @param at The block height to query the state proof at.
1237
+ * @param keys The keys to query the state proof for.
1238
+ * @returns The state proof as a hexadecimal string.
1239
+ */
1240
+ queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
1241
+ /**
1242
+ * Get the latest state machine height for a given state machine ID.
1243
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1244
+ * @returns {Promise<bigint>} The latest state machine height.
1245
+ */
1246
+ latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1247
+ /**
1248
+ * Get the state machine update time for a given state machine height.
1249
+ * @param {StateMachineHeight} stateMachineheight - The state machine height.
1250
+ * @returns {Promise<bigint>} The statemachine update time in seconds.
1251
+ */
1252
+ stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1253
+ /**
1254
+ * Get the challenge period for a given state machine id.
1255
+ * @param {StateMachineIdParams} stateMachineId - The state machine ID.
1256
+ * @returns {Promise<bigint>} The challenge period in seconds.
1257
+ */
1258
+ challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1259
+ /**
1260
+ * Encode an ISMP calldata for a substrate chain.
1261
+ * @param message The ISMP message to encode.
1262
+ * @returns The encoded message as a hexadecimal string.
1263
+ */
1264
+ encode(message: IIsmpMessage): HexString;
1265
+ /**
1266
+ * Returns the index of a pallet by its name, by looking up the pallets in the runtime metadata.
1267
+ * @param {string} name - The name of the pallet.
1268
+ * @returns {number} The index of the pallet.
1269
+ */
1270
+ private getPalletIndex;
1271
+ }
1272
+ /**
1273
+ * Converts a state machine ID string to an enum value.
1274
+ * @param {string} id - The state machine ID string.
1275
+ * @returns {IStateMachine} The corresponding enum value.
1276
+ */
1277
+ declare function convertStateMachineIdToEnum(id: string): IStateMachine;
1278
+ declare function encodeISMPMessage(message: IIsmpMessage): Uint8Array;
1279
+
1280
+ /**
1281
+ * Type representing an ISMP message.
1282
+ */
1283
+ type IIsmpMessage = IRequestMessage | ITimeoutPostRequestMessage | IGetResponseMessage;
1284
+ interface IRequestMessage {
1285
+ /**
1286
+ * The kind of message.
1287
+ */
1288
+ kind: "PostRequest";
1289
+ /**
1290
+ * The requests to be posted.
1291
+ */
1292
+ requests: IPostRequest[];
1293
+ /**
1294
+ * The proof of the requests.
1295
+ */
1296
+ proof: IProof;
1297
+ /**
1298
+ * The signer of the message.
1299
+ */
1300
+ signer: HexString;
1301
+ }
1302
+ interface IGetRequestMessage {
1303
+ /**
1304
+ * The kind of message.
1305
+ */
1306
+ kind: "GetRequest";
1307
+ /**
1308
+ * The requests to be posted.
1309
+ */
1310
+ requests: IGetRequest[];
1311
+ /**
1312
+ * The proof of the requests.
1313
+ */
1314
+ proof: IProof;
1315
+ /**
1316
+ * The signer of the message.
1317
+ */
1318
+ signer: HexString;
1319
+ }
1320
+ interface IGetResponse {
1321
+ /**
1322
+ * The request that triggered this response.
1323
+ */
1324
+ get: IGetRequest;
1325
+ /**
1326
+ * The response message.
1327
+ */
1328
+ values: GetResponseStorageValues[];
1329
+ }
1330
+ interface IGetResponseMessage {
1331
+ /**
1332
+ * The kind of message.
1333
+ */
1334
+ kind: "GetResponse";
1335
+ /**
1336
+ * The responses to be posted.
1337
+ */
1338
+ responses: IGetResponse[];
1339
+ /**
1340
+ * The proof of the responses.
1341
+ */
1342
+ proof: IProof;
1343
+ /**
1344
+ * The signer of the message.
1345
+ */
1346
+ signer: HexString;
1347
+ }
1348
+ interface ITimeoutPostRequestMessage {
1349
+ /**
1350
+ * The kind of message.
1351
+ */
1352
+ kind: "TimeoutPostRequest";
1353
+ /**
1354
+ * The requests to be posted.
1355
+ */
1356
+ requests: IPostRequest[];
1357
+ /**
1358
+ * The proof of the requests.
1359
+ */
1360
+ proof: IProof;
1361
+ }
1362
+ interface IProof {
1363
+ /**
1364
+ * The height of the proof.
1365
+ */
1366
+ height: bigint;
1367
+ /**
1368
+ * The state machine identifier of the proof.
1369
+ */
1370
+ stateMachine: string;
1371
+ /**
1372
+ * The associated consensus state identifier of the proof.
1373
+ */
1374
+ consensusStateId: string;
1375
+ /**
1376
+ * The encoded storage proof
1377
+ */
1378
+ proof: HexString;
1379
+ }
1380
+ /**
1381
+ * Interface representing a chain.
1382
+ */
1383
+ interface IChain {
1384
+ timestamp(): Promise<bigint>;
1385
+ /**
1386
+ * Returns the state trie key for the request-receipt storage item for the given request commitment.
1387
+ */
1388
+ requestReceiptKey(commitment: HexString): HexString;
1389
+ /**
1390
+ * Query and return the request-receipt for the given request commitment.
1391
+ */
1392
+ queryRequestReceipt(commitment: HexString): Promise<HexString | undefined>;
1393
+ /**
1394
+ * Query and return the encoded storage proof for the provided keys at the given height.
1395
+ */
1396
+ queryStateProof(at: bigint, keys: HexString[]): Promise<HexString>;
1397
+ queryProof(message: IMessage, counterparty: string, at?: bigint): Promise<HexString>;
1398
+ encode(message: IIsmpMessage): HexString;
1399
+ /**
1400
+ * Get the latest state machine height for a given state machine ID.
1401
+ */
1402
+ latestStateMachineHeight(stateMachineId: StateMachineIdParams): Promise<bigint>;
1403
+ /**
1404
+ * Get the challenge period for a given state machine ID.
1405
+ */
1406
+ challengePeriod(stateMachineId: StateMachineIdParams): Promise<bigint>;
1407
+ /**
1408
+ * Get the update time for a statemachine height.
1409
+ */
1410
+ stateMachineUpdateTime(stateMachineHeight: StateMachineHeight): Promise<bigint>;
1411
+ }
1412
+ /**
1413
+ * Returns the chain interface for a given state machine identifier
1414
+ * @param chainConfig - Chain configuration
1415
+ * @returns Chain interface
1416
+ */
1417
+ declare function getChain(chainConfig: IEvmConfig | ISubstrateConfig): Promise<IChain>;
1418
+
1419
+ /**
1420
+ * IndexerClient provides methods for interacting with the Hyperbridge indexer.
1421
+ *
1422
+ * This client facilitates querying and tracking cross-chain requests and their status
1423
+ * through the Hyperbridge protocol. It supports:
1424
+ *
1425
+ * - Querying state machine updates by block height or timestamp
1426
+ * - Retrieving request status information by transaction hash
1427
+ * - Monitoring request status changes through streaming interfaces
1428
+ * - Handling request timeout flows and related proof generation
1429
+ * - Tracking request finalization across source and destination chains
1430
+ *
1431
+ * The client implements automatic retries with exponential backoff for network
1432
+ * resilience and provides both simple query methods and advanced streaming
1433
+ * interfaces for real-time status tracking.
1434
+ *
1435
+ * The URLs provided in the configuration must point to archive nodes to allow the client to query for storage proofs
1436
+ * of potentially much older blocks. Regular nodes only store the state for recent blocks and will not be able
1437
+ * to provide the necessary proofs for cross-chain verification, especially in timeout scenarios.
1438
+ *
1439
+ * @example
1440
+ * ```typescript
1441
+ * const client = new IndexerClient({
1442
+ * url: "https://indexer.hyperbridge.xyz/graphql",
1443
+ * pollInterval: 2000,
1444
+ * source: {
1445
+ * stateMachineId: "EVM-1",
1446
+ * consensusStateId: "ETH0"
1447
+ * rpcUrl: "",
1448
+ * host: "0x87ea45..",
1449
+ * },
1450
+ * dest: {
1451
+ * stateMachineId: "EVM-42161",
1452
+ * consensusStateId: "ETH0"
1453
+ * rpcUrl: "",
1454
+ * host: "0x87ea42345..",
1455
+ * },
1456
+ * hyperbridge: {
1457
+ * stateMachineId: "POLKADOT-3367",
1458
+ * consensusStateId: "DOT0"
1459
+ * wsUrl: "ws://localhost:9944"
1460
+ * }
1461
+ * });
1462
+ *
1463
+ * // Query a request status
1464
+ * const status = await client.queryRequestWithStatus("0x1234...");
1465
+ *
1466
+ * // Stream status updates
1467
+ * for await (const update of client.postRequestStatusStream("0x1234...")) {
1468
+ * console.log(`Request status: ${update.status}`);
1469
+ * }
1470
+ * ```
1471
+ */
1472
+ declare class IndexerClient {
1473
+ /**
1474
+ * GraphQL client used for making requests to the indexer
1475
+ */
1476
+ private client;
1477
+ /**
1478
+ * Configuration for the IndexerClient including URLs, poll intervals, and chain-specific settings
1479
+ */
1480
+ private config;
1481
+ private logger;
1482
+ /**
1483
+ * Default configuration for retry behavior when network requests fail
1484
+ * - maxRetries: Maximum number of retry attempts before failing
1485
+ * - backoffMs: Initial backoff time in milliseconds (doubles with each retry)
1486
+ */
1487
+ private defaultRetryConfig;
1488
+ /**
1489
+ * Creates a new IndexerClient instance
1490
+ */
1491
+ constructor(config: PartialClientConfig);
1492
+ /**
1493
+ * Query for a single state machine update event greater than or equal to the given height.
1494
+ * @params statemachineId - ID of the state machine
1495
+ * @params height - Starting block height
1496
+ * @params chain - The identifier for the chain where the state machine update should be queried (corresponds to a stateMachineId)
1497
+ * @returns Closest state machine update
1498
+ */
1499
+ queryStateMachineUpdateByHeight({ statemachineId, height, chain, }: {
1500
+ statemachineId: string;
1501
+ chain: string;
1502
+ height: number;
1503
+ }): Promise<StateMachineUpdate | undefined>;
1504
+ /**
1505
+ * Query for a single state machine update event greater than or equal to the given timestamp.
1506
+ * @params statemachineId - ID of the state machine
1507
+ * @params timestamp - Starting block timestamp
1508
+ * @params chain - The identifier for the chain where the state machine update should be queried (corresponds to a stateMachineId)
1509
+ * @returns Closest state machine update
1510
+ */
1511
+ queryStateMachineUpdateByTimestamp({ statemachineId, commitmentTimestamp, chain, }: {
1512
+ statemachineId: string;
1513
+ commitmentTimestamp: bigint;
1514
+ chain: string;
1515
+ }): Promise<StateMachineUpdate | undefined>;
1516
+ /**
1517
+ * Queries a request by CommitmentHash
1518
+ *
1519
+ * @param commitment_hash - Can be commitment
1520
+ * @returns Latest status and block metadata of the request
1521
+ */
1522
+ queryPostRequest(commitment_hash: string): Promise<PostRequestWithStatus | undefined>;
1523
+ /**
1524
+ * Queries a request by any of its associated hashes and returns it alongside its statuses
1525
+ * Statuses will be one of SOURCE, HYPERBRIDGE_DELIVERED and DESTINATION
1526
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1527
+ * @returns Latest status and block metadata of the request
1528
+ */
1529
+ queryGetRequest(hash: string): Promise<GetRequestWithStatus | undefined>;
1530
+ /**
1531
+ * Queries the response associated with a specific request ID and returns its commitment
1532
+ * @param requestId - The ID of the request to find the associated response for
1533
+ * @returns The response associated with the given request ID, or undefined if not found
1534
+ */
1535
+ queryResponseByRequestId(requestId: string): Promise<ResponseCommitmentWithValues | undefined>;
1536
+ /**
1537
+ * Enhances a request with finality events by querying state machine updates.
1538
+ *
1539
+ * This method augments a request object with additional inferred status events
1540
+ * that represent chain finality confirmations. It adds:
1541
+ * - SOURCE_FINALIZED: When the source chain has finalized the request
1542
+ * - HYPERBRIDGE_FINALIZED: When Hyperbridge has finalized the delivery confirmation
1543
+ *
1544
+ * The method also generates appropriate calldata for submitting cross-chain proofs
1545
+ * when applicable.
1546
+ *
1547
+ * @param request - The request to enhance with finality events
1548
+ * @returns The request with finality events added
1549
+ * @private
1550
+ */
1551
+ private addRequestFinalityEvents;
1552
+ /**
1553
+ * Adds timeout finality events to a request by querying for relevant timeout proofs and
1554
+ * chain state necessary for timeout processing.
1555
+ *
1556
+ * This method enhances a request object with additional status events related to the
1557
+ * timeout flow, including:
1558
+ * - PENDING_TIMEOUT: When a request has passed its timeout timestamp
1559
+ * - DESTINATION_FINALIZED: When the destination chain has finalized the timeout timestamp
1560
+ * - HYPERBRIDGE_FINALIZED_TIMEOUT: When hyperbridge has finalized the timeout state
1561
+ *
1562
+ * The method also generates appropriate calldata for submitting timeout proofs.
1563
+ *
1564
+ * @param request - Request to fill timeout events for
1565
+ * @returns Request with timeout events filled in, including any proof calldata for timeout submissions
1566
+ * @private
1567
+ */
1568
+ private addTimeoutFinalityEvents;
1569
+ /**
1570
+ * Queries a request returns it alongside its statuses,
1571
+ * including any finalization events.
1572
+ * @param hash - Commitment hash
1573
+ * @returns Full request data with all inferred status events, including SOURCE_FINALIZED and HYPERBRIDGE_FINALIZED
1574
+ * @remarks Unlike queryRequest(), this method adds derived finalization status events by querying state machine updates
1575
+ */
1576
+ queryRequestWithStatus(hash: string): Promise<PostRequestWithStatus | undefined>;
1577
+ /**
1578
+ * Create a Stream of status updates for a post request.
1579
+ * Stream ends when either the request reaches the destination or times out.
1580
+ * If the stream yields TimeoutStatus.PENDING_TIMEOUT, use postRequestTimeoutStream() to begin timeout processing.
1581
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1582
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1583
+ * @example
1584
+ *
1585
+ * let client = new IndexerClient(config)
1586
+ * let stream = client.postRequestStatusStream(hash)
1587
+ *
1588
+ * // you can use a for-await-of loop
1589
+ * for await (const status of stream) {
1590
+ * console.log(status)
1591
+ * }
1592
+ *
1593
+ * // you can also use a while loop
1594
+ * while (true) {
1595
+ * const status = await stream.next()
1596
+ * if (status.done) {
1597
+ * break
1598
+ * }
1599
+ * console.log(status.value)
1600
+ * }
1601
+ *
1602
+ */
1603
+ postRequestStatusStream(hash: HexString): AsyncGenerator<RequestStatusWithMetadata, void>;
1604
+ timeoutStream(timeoutTimestamp: bigint, chain: IChain): AsyncGenerator<RequestStatusWithMetadata, void>;
1605
+ /**
1606
+ * Create a Stream of status updates
1607
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1608
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1609
+ */
1610
+ private postRequestStatusStreamInternal;
1611
+ private sleep_for;
1612
+ private sleep_for_interval;
1613
+ /**
1614
+ * Create a Stream of status updates for a get request.
1615
+ * Stream ends when either the request reaches the destination or times out.
1616
+ * If the stream yields TimeoutStatus.PENDING_TIMEOUT, use postRequestTimeoutStream() to begin timeout processing.
1617
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1618
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1619
+ * @example
1620
+ *
1621
+ * let client = new IndexerClient(config)
1622
+ * let stream = client.getRequestStatusStream(hash)
1623
+ *
1624
+ * // you can use a for-await-of loop
1625
+ * for await (const status of stream) {
1626
+ * console.log(status)
1627
+ * }
1628
+ *
1629
+ * // you can also use a while loop
1630
+ * while (true) {
1631
+ * const status = await stream.next()
1632
+ * if (status.done) {
1633
+ * break
1634
+ * }
1635
+ * console.log(status.value)
1636
+ * }
1637
+ *
1638
+ */
1639
+ getRequestStatusStream(hash: HexString): AsyncGenerator<RequestStatusWithMetadata, void>;
1640
+ /**
1641
+ * Create a Stream of status updates
1642
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1643
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1644
+ */
1645
+ private getRequestStatusStreamInternal;
1646
+ /**
1647
+ * Create a Stream of status updates for a timed out post request.
1648
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1649
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1650
+ * @example
1651
+ *
1652
+ * let client = new IndexerClient(config)
1653
+ * let stream = client.postRequestTimeoutStream(hash)
1654
+ *
1655
+ * // you can use a for-await-of loop
1656
+ * for await (const status of stream) {
1657
+ * console.log(status)
1658
+ * }
1659
+ *
1660
+ * // you can also use a while loop
1661
+ * while (true) {
1662
+ * const status = await stream.next()
1663
+ * if (status.done) {
1664
+ * break
1665
+ * }
1666
+ * console.log(status.value)
1667
+ * }
1668
+ */
1669
+ postRequestTimeoutStream(hash: HexString): AsyncGenerator<PostRequestTimeoutStatus, void>;
1670
+ /**
1671
+ * Create a Stream of status updates for a timed out post request.
1672
+ * @param hash - Can be commitment, hyperbridge tx hash, source tx hash, destination tx hash, or timeout tx hash
1673
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1674
+ */
1675
+ postRequestTimeoutStreamInternal(hash: HexString, signal: AbortSignal): AsyncGenerator<PostRequestTimeoutStatus, void>;
1676
+ /**
1677
+ * Query for asset teleported events by sender, recipient, and destination chain
1678
+ * @param from - The sender address
1679
+ * @param to - The recipient address
1680
+ * @param dest - The destination chain ID
1681
+ * @returns The asset teleported event if found, undefined otherwise
1682
+ */
1683
+ queryAssetTeleported(from: string, to: string, dest: string, blockNumber: number): Promise<AssetTeleported | undefined>;
1684
+ /**
1685
+ * Executes an async operation with exponential backoff retry
1686
+ * @param operation - Async function to execute
1687
+ * @param retryConfig - Optional retry configuration
1688
+ * @returns Result of the operation
1689
+ * @throws Last encountered error after all retries are exhausted
1690
+ *
1691
+ * @example
1692
+ * const result = await this.withRetry(() => this.queryStatus(hash));
1693
+ */
1694
+ private withRetry;
1695
+ /**
1696
+ * Query for an order by its commitment hash
1697
+ * @param commitment - The commitment hash of the order
1698
+ * @returns The order with its status if found, undefined otherwise
1699
+ */
1700
+ queryOrder(commitment: HexString): Promise<OrderWithStatus | undefined>;
1701
+ /**
1702
+ * Create a Stream of status updates for an order.
1703
+ * Stream ends when the order reaches a terminal state (FILLED, REDEEMED, or REFUNDED).
1704
+ * @param commitment - The commitment hash of the order
1705
+ * @returns AsyncGenerator that emits status updates until a terminal state is reached
1706
+ * @example
1707
+ *
1708
+ * let client = new IndexerClient(config)
1709
+ * let stream = client.orderStatusStream(commitment)
1710
+ *
1711
+ * // you can use a for-await-of loop
1712
+ * for await (const status of stream) {
1713
+ * console.log(status)
1714
+ * }
1715
+ *
1716
+ * // you can also use a while loop
1717
+ * while (true) {
1718
+ * const status = await stream.next()
1719
+ * if (status.done) {
1720
+ * break
1721
+ * }
1722
+ * console.log(status.value)
1723
+ * }
1724
+ */
1725
+ orderStatusStream(commitment: HexString): AsyncGenerator<{
1726
+ status: OrderStatus;
1727
+ metadata: {
1728
+ blockHash: string;
1729
+ blockNumber: number;
1730
+ transactionHash: string;
1731
+ timestamp: bigint;
1732
+ filler?: string;
1733
+ };
1734
+ }, void>;
1735
+ tokenGatewayAssetTeleportedStatusStream(commitment: HexString): AsyncGenerator<{
1736
+ status: TeleportStatus;
1737
+ metadata: {
1738
+ blockHash: string;
1739
+ blockNumber: number;
1740
+ transactionHash: string;
1741
+ timestamp: bigint;
1742
+ };
1743
+ }, void>;
1744
+ private queryTokenGatewayAssetTeleported;
1745
+ /**
1746
+ * Aggregate transactions with commitment.
1747
+ * @param commitment
1748
+ * @returns an object containing the transaction hash, block hash, block number, timestamp.
1749
+ */
1750
+ aggregateTransactionWithCommitment(commitment: HexString): Promise<Awaited<ReturnType<SubstrateChain["submitUnsigned"]>>>;
1751
+ waitOrAbort<T>(params: {
1752
+ signal: AbortSignal;
1753
+ promise: () => Promise<T>;
1754
+ predicate?: (a: T) => boolean;
1755
+ }): Promise<NonNullable<T>>;
1756
+ }
1757
+ interface PartialClientConfig extends Omit<ClientConfig, "pollInterval"> {
1758
+ pollInterval?: number;
1759
+ }
1760
+
1761
+ declare function createQueryClient(config: {
1762
+ url: string;
1763
+ }): GraphQLClient;
1764
+ /**
1765
+ * Queries a request by CommitmentHash
1766
+ *
1767
+ * @example
1768
+ * import { createQueryClient, queryRequest } from "@hyperbridge/sdk"
1769
+ *
1770
+ * const queryClient = createQueryClient({
1771
+ * url: "http://localhost:3000", // URL of the Hyperbridge indexer API
1772
+ * })
1773
+ * const commitmentHash = "0x...."
1774
+ * const request = await queryPostRequest({ commitmentHash, queryClient })
1775
+ */
1776
+ declare function queryPostRequest(params: {
1777
+ commitmentHash: string;
1778
+ queryClient: IndexerQueryClient;
1779
+ }): Promise<PostRequestWithStatus | undefined>;
1780
+ /**
1781
+ * Queries a GET Request by CommitmentHash
1782
+ *
1783
+ * @example
1784
+ * import { createQueryClient, queryRequest } from "@hyperbridge/sdk"
1785
+ *
1786
+ * const queryClient = createQueryClient({
1787
+ * url: "http://localhost:3000", // URL of the Hyperbridge indexer API
1788
+ * })
1789
+ * const commitmentHash = "0x...."
1790
+ * const request = await queryGetRequest({ commitmentHash, queryClient })
1791
+ */
1792
+ declare function queryGetRequest(params: {
1793
+ commitmentHash: string;
1794
+ queryClient: IndexerQueryClient;
1795
+ }): Promise<GetRequestWithStatus | undefined>;
1796
+
1797
+ type HyperbridgeTxEvents = {
1798
+ kind: "Ready";
1799
+ transaction_hash: HexString;
1800
+ } | {
1801
+ kind: "Dispatched";
1802
+ transaction_hash: HexString;
1803
+ block_number: bigint;
1804
+ commitment: HexString;
1805
+ } | {
1806
+ kind: "Finalized";
1807
+ transaction_hash: HexString;
1808
+ block_number?: bigint;
1809
+ commitment?: HexString;
1810
+ } | {
1811
+ kind: "Error";
1812
+ error: unknown;
1813
+ };
1814
+ /**
1815
+ * Parameters for teleporting DOT from Polkadot relay chain to EVM-based destination
1816
+ */
1817
+ type XcmGatewayParams = {
1818
+ /**
1819
+ * Destination state machine ID (chain ID) where assets will be teleported to
1820
+ * This value identifies the specific EVM chain in the destination network
1821
+ */
1822
+ destination: number;
1823
+ /**
1824
+ * The recipient address on the destination chain (in hex format)
1825
+ * This is the EVM address that will receive the teleported assets
1826
+ */
1827
+ recipient: HexString;
1828
+ /**
1829
+ * Amount of DOT to teleport
1830
+ * This will be converted to the appropriate format internally
1831
+ */
1832
+ amount: number;
1833
+ /**
1834
+ * Request timeout value in blocks or timestamp
1835
+ * Specifies how long the teleport request remains valid before expiring
1836
+ */
1837
+ timeout: bigint;
1838
+ /**
1839
+ * The parachain ID of the Hyperbridge
1840
+ */
1841
+ paraId: number;
1842
+ };
1843
+ /**
1844
+ * Teleports DOT tokens from Polkadot relay chain to an EVM-based destination chain
1845
+ * using XCM (Cross-Consensus Message Format) and uses the indexer client to track
1846
+ * the transaction instead of polling hyperbridge blocks.
1847
+ *
1848
+ * This function initiates a teleport transaction, monitors its status through the indexer,
1849
+ * and yields events about the transaction's progress through a ReadableStream.
1850
+ * It handles the complete lifecycle of a teleport operation:
1851
+ * 1. Transaction preparation and signing
1852
+ * 2. Broadcasting to the relay chain
1853
+ * 3. Tracking the transaction via the indexer client
1854
+ * 4. Yielding events about transaction status
1855
+ *
1856
+ * Note: There is no guarantee that both Dispatched and Finalized events will be yielded.
1857
+ * Consumers should listen for either one of these events instead of expecting both.
1858
+ *
1859
+ * @param relayApi - Polkadot API instance connected to the relay chain
1860
+ * @param hyperbridge - Polkadot API instance connected to the Hyperbridge parachain
1861
+ * @param who - Sender's SS58Address address
1862
+ * @param options - Transaction signing options
1863
+ * @param params - Teleport parameters including destination, recipient, and amount
1864
+ * @param indexerClient - The indexer client to track the transaction
1865
+ * @param pollInterval - Optional polling interval in milliseconds (default: 2000)
1866
+ * @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
1867
+ */
1868
+ declare function teleportDot(param_: {
1869
+ relayApi: ApiPromise;
1870
+ hyperbridge: ApiPromise;
1871
+ who: string;
1872
+ xcmGatewayParams: XcmGatewayParams;
1873
+ indexerClient: IndexerClient;
1874
+ pollInterval?: number;
1875
+ options: Partial<SignerOptions>;
1876
+ }): Promise<ReadableStream<HyperbridgeTxEvents>>;
1877
+
1878
+ type Params = {
1879
+ /** Asset symbol for the teleport operation */
1880
+ symbol: string;
1881
+ /**
1882
+ * Destination state machine identifier (e.g., "EVM-1", "SUBSTRATE-cere")
1883
+ * that specifies the target blockchain or network
1884
+ */
1885
+ destination: string;
1886
+ /**
1887
+ * Recipient address in hexadecimal format where the assets will be sent
1888
+ * on the destination chain
1889
+ */
1890
+ recipient: HexString;
1891
+ /**
1892
+ * Amount of tokens to teleport, represented as a bigint to handle
1893
+ * large numeric values precisely
1894
+ */
1895
+ amount: bigint;
1896
+ /**
1897
+ * Request timeout in block numbers or timestamp, after which the
1898
+ * teleport operation will be considered failed
1899
+ */
1900
+ timeout: bigint;
1901
+ /**
1902
+ * Address of the token gateway contract on the destination chain
1903
+ * that will process the teleported assets
1904
+ */
1905
+ tokenGatewayAddress: Uint8Array;
1906
+ /**
1907
+ * Fee paid to relayers who process the cross-chain transaction,
1908
+ * represented as a bigint
1909
+ */
1910
+ relayerFee: bigint;
1911
+ /**
1912
+ * Optional call data to be executed on the destination chain
1913
+ * as part of the teleport operation
1914
+ */
1915
+ callData?: Uint8Array;
1916
+ /**
1917
+ * Flag indicating whether to automatically redeem the tokens
1918
+ * for erc20
1919
+ */
1920
+ redeem: boolean;
1921
+ };
1922
+ /**
1923
+ * Teleports assets from Substrate to other chains via the token gateway
1924
+ *
1925
+ * Note: There is no guarantee that both Dispatched and Finalized events will be yielded.
1926
+ * Consumers should listen for either one of these events instead of expecting both.
1927
+ *
1928
+ *
1929
+ * @param apiPromise - Polkadot API instance
1930
+ * @param who - SS58Address
1931
+ * @param params - Teleport parameters
1932
+ * @param params.symbol - Asset symbol
1933
+ * @param params.destination - Target state machine ID
1934
+ * @param params.recipient - Recipient address
1935
+ * @param params.amount - Amount to teleport
1936
+ * @param params.timeout - Operation timeout
1937
+ * @param params.tokenGatewayAddress - Gateway contract address
1938
+ * @param params.relayerFee - Fee for the relayer
1939
+ * @param params.redeem - Whether to redeem on arrival
1940
+ * @param params.callData - Optional additional call data
1941
+ * @param options - Signer options
1942
+ * @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
1943
+ * @throws Error when asset ID is unknown or transaction fails
1944
+ */
1945
+ declare function teleport(teleport_param: {
1946
+ who: string;
1947
+ params: Params;
1948
+ apiPromise: ApiPromise;
1949
+ options: Partial<SignerOptions>;
1950
+ }): Promise<ReadableStream<HyperbridgeTxEvents>>;
1951
+
1952
+ export { ADDRESS_ZERO, AbortSignalInternal, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, type ClientConfig, DEFAULT_ADDRESS, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, EvmChain, type EvmChainParams, EvmLanguage, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type XcmGatewayParams, __test, bytes20ToBytes32, bytes32ToBytes20, calculateBalanceMappingLocation, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, encodeISMPMessage, estimateGasForPost, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot };