@0xtrails/api 0.10.4 → 0.11.0

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.
@@ -0,0 +1,2244 @@
1
+ /* eslint-disable */
2
+ // trails-api v1-26.2.10-fcbe559 739a9f32a6c6cb2dabf3c8843e28a336430d748b
3
+ // --
4
+ // Code generated by Webrpc-gen@v0.32.2 with typescript generator. DO NOT EDIT.
5
+ //
6
+ // webrpc-gen -schema=trails-api.ridl -target=typescript -client -service=Trails -methodTreeShake -ignore=@onramp -out=./clients/trails-api.gen.ts
7
+
8
+ // Webrpc description and code-gen version
9
+ export const WebrpcVersion = "v1"
10
+
11
+ // Schema version of your RIDL schema
12
+ export const WebrpcSchemaVersion = "v1-26.2.10-fcbe559"
13
+
14
+ // Schema hash generated from your RIDL schema
15
+ export const WebrpcSchemaHash = "739a9f32a6c6cb2dabf3c8843e28a336430d748b"
16
+
17
+ //
18
+ // Client interface
19
+ //
20
+
21
+ export interface TrailsClient {
22
+ ping(headers?: object, signal?: AbortSignal): Promise<PingResponse>
23
+
24
+ runtimeStatus(headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse>
25
+
26
+ clock(headers?: object, signal?: AbortSignal): Promise<ClockResponse>
27
+
28
+ quoteIntent(req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse>
29
+
30
+ commitIntent(req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse>
31
+
32
+ executeIntent(req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse>
33
+
34
+ waitIntentReceipt(req: WaitIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<WaitIntentReceiptResponse>
35
+
36
+ getIntentReceipt(req: GetIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentReceiptResponse>
37
+
38
+ getIntent(req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse>
39
+
40
+ searchIntents(req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse>
41
+
42
+ getIntentConfig(req: GetIntentConfigRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentConfigResponse>
43
+
44
+ getIntentHistory(req: GetIntentHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentHistoryResponse>
45
+
46
+ abortIntent(req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse>
47
+
48
+ /**
49
+ * GetChains will return the list of supported chains by Trails.
50
+ */
51
+ getChains(req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse>
52
+
53
+ /**
54
+ * GetExactOutputRoutes will return a list of origin tokens, when given a destination chain and token,
55
+ * that can be used to pay/send from an origin chain the exact output amount on the
56
+ * destination chain.
57
+ *
58
+ * The request will include the destination chain and token desired. Optionally, the
59
+ * user can specify an origin chain and token to filter results to only that specific
60
+ * origin token. Additionally, an optional owner address can be provided to filter
61
+ * results to only tokens the owner has a balance on (requires indexer gateway to be
62
+ * configured).
63
+ *
64
+ * The response is a list of origin tokens and their chains which can be used to fulfill
65
+ * the exact output request. These are tokens the user can send FROM to achieve the desired
66
+ * destination token amount.
67
+ *
68
+ * aka, the 'pay' routes
69
+ */
70
+ getExactOutputRoutes(req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse>
71
+
72
+ /**
73
+ * GetExactInputRoutes will return a list of destination tokens, when given an origin chain and token,
74
+ * that can be used to send/swap to a destination chain and token.
75
+ *
76
+ * The request will include the origin chain and token used for input. Optionally, the
77
+ * user can specify a destination chain and token to further filter the results.
78
+ *
79
+ * The response is a list of destination tokens and their chains which can be reached from
80
+ * the origin token and chain. These are tokens the user can send TO from the given origin token.
81
+ *
82
+ * aka, the 'swap' routes
83
+ */
84
+ getExactInputRoutes(req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse>
85
+
86
+ /**
87
+ * GetTokenList will return a list of tokens based on the provided filters.
88
+ * NOTE: there are many filters and options on GetTokenListRequest
89
+ */
90
+ getTokenList(req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse>
91
+
92
+ /**
93
+ * GetTokenPrices will return the live prices for a list of tokens.
94
+ */
95
+ getTokenPrices(req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse>
96
+
97
+ /**
98
+ * GetExchangeRate returns the exchange rate from USD to a specified currency.
99
+ */
100
+ getExchangeRate(req: GetExchangeRateRequest, headers?: object, signal?: AbortSignal): Promise<GetExchangeRateResponse>
101
+
102
+ /**
103
+ * GetCountryList returns the list of supported countries for onramp providers.
104
+ */
105
+ getCountryList(headers?: object, signal?: AbortSignal): Promise<GetCountryListResponse>
106
+
107
+ /**
108
+ * GetTrailsContracts returns Trails contract addresses used by the Trails Intents stack.
109
+ */
110
+ getTrailsContracts(headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse>
111
+
112
+ getSupportedIntentProtocolVersions(headers?: object, signal?: AbortSignal): Promise<GetSupportedIntentProtocolVersionsResponse>
113
+
114
+ /**
115
+ * GetEarnPools returns aggregated pool information from DeFi protocols (Aave, Morpho).
116
+ * This endpoint provides yield-bearing opportunities across multiple chains.
117
+ */
118
+ getEarnPools(req: GetEarnPoolsRequest, headers?: object, signal?: AbortSignal): Promise<GetEarnPoolsResponse>
119
+
120
+ /**
121
+ * GetFiatCurrencyList returns the list of supported fiat currencies for display preferences.
122
+ */
123
+ getFiatCurrencyList(headers?: object, signal?: AbortSignal): Promise<GetFiatCurrencyListResponse>
124
+
125
+ /**
126
+ * @deprecated please use GetIntentHistory instead
127
+ */
128
+ getIntentTransactionHistory(req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse>
129
+ }
130
+
131
+
132
+ //
133
+ // Schema types
134
+ //
135
+
136
+ export enum TradeType {
137
+ EXACT_INPUT = 'EXACT_INPUT',
138
+ EXACT_OUTPUT = 'EXACT_OUTPUT'
139
+ }
140
+
141
+ export enum RouteProvider {
142
+ AUTO = 'AUTO',
143
+ CCTP = 'CCTP',
144
+ LIFI = 'LIFI',
145
+ RELAY = 'RELAY',
146
+ SUSHI = 'SUSHI',
147
+ WETH = 'WETH',
148
+ ZEROX = 'ZEROX'
149
+ }
150
+
151
+ export enum FundMethod {
152
+ WALLET = 'WALLET',
153
+ DIRECT_TRANSFER = 'DIRECT_TRANSFER',
154
+ ONRAMP_MESH = 'ONRAMP_MESH',
155
+ ONRAMP_MELD = 'ONRAMP_MELD'
156
+ }
157
+
158
+ export enum IntentProtocolVersion {
159
+ v1 = 'v1',
160
+ v1_5 = 'v1_5'
161
+ }
162
+
163
+ export enum IntentSource {
164
+ ORIGIN = 'ORIGIN',
165
+ DESTINATION = 'DESTINATION'
166
+ }
167
+
168
+ export enum IntentStatus {
169
+ QUOTED = 'QUOTED',
170
+ COMMITTED = 'COMMITTED',
171
+ EXECUTING = 'EXECUTING',
172
+ FAILED = 'FAILED',
173
+ SUCCEEDED = 'SUCCEEDED',
174
+ ABORTED = 'ABORTED',
175
+ REFUNDED = 'REFUNDED'
176
+ }
177
+
178
+ export enum TransactionType {
179
+ UNKNOWN = 'UNKNOWN',
180
+ DEPOSIT = 'DEPOSIT',
181
+ ORIGIN = 'ORIGIN',
182
+ DESTINATION = 'DESTINATION',
183
+ ROUTE = 'ROUTE',
184
+ REFUND = 'REFUND'
185
+ }
186
+
187
+ export enum TransactionContext {
188
+ NONE = 'NONE',
189
+ CCTPV2_MESSAGE = 'CCTPV2_MESSAGE'
190
+ }
191
+
192
+ export enum TransactionStatus {
193
+ UNKNOWN = 'UNKNOWN',
194
+ ON_HOLD = 'ON_HOLD',
195
+ PENDING = 'PENDING',
196
+ RELAYING = 'RELAYING',
197
+ SENT = 'SENT',
198
+ ERRORED = 'ERRORED',
199
+ MINING = 'MINING',
200
+ SUCCEEDED = 'SUCCEEDED',
201
+ FAILED = 'FAILED',
202
+ ABORTED = 'ABORTED',
203
+ REVERTED = 'REVERTED'
204
+ }
205
+
206
+ export enum ChainGasUsageStatus {
207
+ NORMAL = 'NORMAL',
208
+ BUSY = 'BUSY',
209
+ VERY_BUSY = 'VERY_BUSY'
210
+ }
211
+
212
+ export enum CCTPTransferStatus {
213
+ UNKNOWN = 'UNKNOWN',
214
+ ON_HOLD = 'ON_HOLD',
215
+ PENDING = 'PENDING',
216
+ FETCHING = 'FETCHING',
217
+ COMPLETE = 'COMPLETE',
218
+ FAILED = 'FAILED'
219
+ }
220
+
221
+ export enum RelayTransferStatus {
222
+ UNKNOWN = 'UNKNOWN',
223
+ ON_HOLD = 'ON_HOLD',
224
+ PENDING = 'PENDING',
225
+ FETCHING = 'FETCHING',
226
+ COMPLETE = 'COMPLETE',
227
+ REFUNDED = 'REFUNDED',
228
+ FAILED = 'FAILED'
229
+ }
230
+
231
+ export interface QuoteIntentRequest {
232
+ ownerAddress: string
233
+ originChainId: number
234
+ originTokenAddress: string
235
+ destinationChainId: number
236
+ destinationTokenAddress: string
237
+ destinationToAddress?: string
238
+ destinationApproveAddress?: string
239
+ destinationCallData?: string
240
+ destinationCallValue?: bigint
241
+ originTokenAmount?: bigint
242
+ destinationTokenAmount?: bigint
243
+ tradeType?: TradeType
244
+ fundMethod?: FundMethod
245
+ onlyNativeGasFee?: boolean
246
+ options?: QuoteIntentRequestOptions
247
+ }
248
+
249
+ export interface QuoteIntentRequestOptions {
250
+ swapProvider?: RouteProvider
251
+ bridgeProvider?: RouteProvider
252
+ slippageTolerance?: number
253
+ trailsAddressOverrides?: TrailsAddressOverrides
254
+ }
255
+
256
+ export interface PassthroughInfo {
257
+ eligible: boolean
258
+ passthroughTransaction?: PassThroughTransaction
259
+ transactionStates?: Array<TransactionStateInfo>
260
+ }
261
+
262
+ export interface Intent {
263
+ intentId: string
264
+ status: IntentStatus
265
+ quoteRequest: QuoteIntentRequest
266
+ ownerAddress: string
267
+ originChainId: number
268
+ destinationChainId: number
269
+ originIntentAddress: string
270
+ destinationIntentAddress?: string
271
+ salt: bigint
272
+ depositTransaction: DepositTransaction
273
+ passthrough?: boolean
274
+ originCalls: IntentCalls
275
+ destinationCalls?: IntentCalls
276
+ originPrecondition: TransactionPrecondition
277
+ destinationPrecondition?: TransactionPrecondition
278
+ originMetaTxn: MetaTxn
279
+ destinationMetaTxn?: MetaTxn
280
+ quote: IntentProviderQuote
281
+ fees: IntentFees
282
+ trailsVersion: string
283
+ intentProtocolVersion?: IntentProtocolVersion
284
+ trailsContracts: TrailsContracts
285
+ expiresAt: string
286
+ updatedAt?: string
287
+ createdAt?: string
288
+ }
289
+
290
+ export interface DepositTransaction {
291
+ toAddress: string
292
+ tokenAddress: string
293
+ decimals?: number
294
+ amount: bigint
295
+ chainId: number
296
+ to: string
297
+ data: string
298
+ value: bigint
299
+ }
300
+
301
+ export interface PassThroughTransaction {
302
+ toAddress: string
303
+ tokenAddress: string
304
+ decimals?: number
305
+ amount: bigint
306
+ chainId: number
307
+ to: string
308
+ data: string
309
+ value: bigint
310
+ }
311
+
312
+ export interface TransactionStateInfo {
313
+ id: string
314
+ label: string
315
+ chainId: number
316
+ }
317
+
318
+ export interface IntentCalls {
319
+ chainId: number
320
+ space?: bigint
321
+ nonce?: bigint
322
+ calls: Array<TransactionCall>
323
+ }
324
+
325
+ export interface TransactionCall {
326
+ to: string
327
+ value?: bigint
328
+ data?: string
329
+ gasLimit?: bigint
330
+ delegateCall?: boolean
331
+ onlyFallback?: boolean
332
+ behaviorOnError?: number
333
+ }
334
+
335
+ export interface TransactionPrecondition {
336
+ type: string
337
+ chainId: number
338
+ ownerAddress: string
339
+ tokenAddress: string
340
+ minAmount: bigint
341
+ }
342
+
343
+ export interface MetaTxn {
344
+ id: string
345
+ chainId: number
346
+ walletAddress: string
347
+ contract: string
348
+ input: string
349
+ }
350
+
351
+ export interface IntentHistory {
352
+ intentId: string
353
+ status: IntentStatus
354
+ expiresAt: string
355
+ updatedAt?: string
356
+ createdAt?: string
357
+ receipt: IntentReceipt
358
+ }
359
+
360
+ export interface IntentReceiptSummary {
361
+ intentId: string
362
+ status: IntentStatus
363
+ ownerAddress: string
364
+ originChainId: number
365
+ destinationChainId: number
366
+ tradeType: TradeType
367
+ routeProviders: Array<RouteProvider>
368
+ originIntentAddress: string
369
+ originTokenAddress: string
370
+ originTokenAmount: bigint
371
+ originTokenMetadata: TokenMetadata
372
+ destinationIntentAddress: string
373
+ destinationTokenAddress?: string
374
+ destinationTokenAmount?: bigint
375
+ destinationToAddress?: string
376
+ destinationTokenMetadata: TokenMetadata
377
+ destinationHasCallData: boolean
378
+ destinationHasCallValue: boolean
379
+ memo?: string
380
+ createdAt: string
381
+ expiresAt: string
382
+ startedAt?: string
383
+ finishedAt?: string
384
+ }
385
+
386
+ export interface IntentReceipt {
387
+ intentId: string
388
+ status: IntentStatus
389
+ ownerAddress: string
390
+ originChainId: number
391
+ destinationChainId: number
392
+ depositTransaction: IntentTransaction
393
+ originTransaction: IntentTransaction
394
+ destinationTransaction?: IntentTransaction
395
+ refundTransaction?: IntentTransaction
396
+ summary: IntentReceiptSummary
397
+ updatedAt?: string
398
+ createdAt?: string
399
+ }
400
+
401
+ export interface IntentTransaction {
402
+ intentId: string
403
+ status: TransactionStatus
404
+ statusReason?: string
405
+ chainId: number
406
+ type: TransactionType
407
+ context: TransactionContext
408
+ fromAddress: string
409
+ toAddress: string
410
+ tokenAddress: string
411
+ tokenAmount: bigint
412
+ metaTxnId?: string
413
+ metaTxnFeeQuote?: string
414
+ precondition?: TransactionPrecondition
415
+ depositIntentEntry?: DepositIntentEntry
416
+ txnHash?: string
417
+ txnMinedAt?: string
418
+ updatedAt?: string
419
+ createdAt?: string
420
+ }
421
+
422
+ export interface PriceImpact {
423
+ priceImpact: number
424
+ priceImpactUsd: number
425
+ }
426
+
427
+ export interface PriceImpactDetails {
428
+ executionPriceImpact: PriceImpact
429
+ marketPriceImpact: PriceImpact
430
+ providerFeesPriceImpact: PriceImpact
431
+ trailsFeesPriceImpact: PriceImpact
432
+ netPriceImpact: PriceImpact
433
+ }
434
+
435
+ export interface IntentProviderQuote {
436
+ routeProviders: Array<RouteProvider>
437
+ routeProvidersRequestIds: Array<string>
438
+ routeProvidersFeeUsd: Array<number>
439
+ fromAmount: bigint
440
+ fromAmountMin: bigint
441
+ fromAmountUsd: number
442
+ fromAmountMinUsd: number
443
+ toAmount: bigint
444
+ toAmountMin: bigint
445
+ toAmountUsd: number
446
+ toAmountMinUsd: number
447
+ maxSlippage: number
448
+ priceImpact: number
449
+ priceImpactUsd: number
450
+ priceImpactDetails: PriceImpactDetails
451
+ }
452
+
453
+ export interface IntentFees {
454
+ originGas: IntentTransactionGasFee
455
+ destinationGas?: IntentTransactionGasFee
456
+ provider: IntentProviderFees
457
+ feeTokenAddress: string
458
+ feeTokenAmount: bigint
459
+ feeTokenUsd: number
460
+ feeTokenTotal: bigint
461
+ gasFeeTotal: bigint
462
+ gasFeeUsd: number
463
+ trailsFeeTotal: bigint
464
+ trailsFeeUsd: number
465
+ collectorFeeTotal: bigint
466
+ collectorFeeUsd: number
467
+ providerFeeTotal: bigint
468
+ providerFeeUsd: number
469
+ totalFeeAmount: bigint
470
+ totalFeeUsd: number
471
+ }
472
+
473
+ export interface IntentProviderFees {
474
+ quoteProvider: string
475
+ quoteProviderFee: bigint
476
+ quoteProviderFeeUsd: number
477
+ trailsFee: bigint
478
+ trailsFeeUsd: number
479
+ quoteProviderWithTrailsFee: bigint
480
+ providerWithTrailsFeeUsd: number
481
+ totalFeeAmount: bigint
482
+ totalFeeUsd: number
483
+ }
484
+
485
+ export interface IntentSummary {
486
+ intentId: string
487
+ status: IntentStatus
488
+ ownerAddress: string
489
+ originChainId: number
490
+ destinationChainId: number
491
+ originIntentAddress: string
492
+ destinationIntentAddress: string
493
+ depositTransactionHash?: string
494
+ depositTransactionStatus: TransactionStatus
495
+ originTransactionHash?: string
496
+ originTransactionStatus: TransactionStatus
497
+ destinationTransactionHash?: string
498
+ destinationTransactionStatus: TransactionStatus
499
+ originTokenAddress: string
500
+ originTokenAmount: bigint
501
+ originTokenMetadata: TokenMetadata
502
+ destinationTokenAddress: string
503
+ destinationTokenAmount: bigint
504
+ destinationTokenMetadata: TokenMetadata
505
+ destinationToAddress: string
506
+ expiresAt: string
507
+ updatedAt?: string
508
+ createdAt: string
509
+ }
510
+
511
+ export interface IntentTransactionGasFee {
512
+ chainId: number
513
+ totalGasLimit: bigint
514
+ gasPrice: bigint
515
+ nativeTokenSymbol: string
516
+ nativeTokenPriceUsd?: number
517
+ chainGasUsageStatus: ChainGasUsageStatus
518
+ totalFeeAmount: bigint
519
+ totalFeeUsd: string
520
+ metaTxnFeeDetails: MetaTxnFeeDetails
521
+ metaTxnGasQuote: string
522
+ }
523
+
524
+ export interface MetaTxnFeeDetails {
525
+ metaTxnId: string
526
+ estimatedGasLimit: bigint
527
+ feeNative: bigint
528
+ }
529
+
530
+ export interface ChainMetadata {
531
+ chainId: number
532
+ name: string
533
+ logoUri?: string
534
+ testnet?: boolean
535
+ }
536
+
537
+ export interface TokenMetadata {
538
+ chainId: number
539
+ tokenAddress: string
540
+ name: string
541
+ symbol: string
542
+ decimals?: number
543
+ logoUri?: string
544
+ }
545
+
546
+ export interface Token {
547
+ chainId: number
548
+ tokenAddress: string
549
+ tokenSymbol?: string
550
+ }
551
+
552
+ export interface TokenPrice {
553
+ token: Token
554
+ priceUsd?: number
555
+ updatedAt: string
556
+ }
557
+
558
+ export interface ExchangeRate {
559
+ name: string
560
+ symbol: string
561
+ value: number
562
+ vsCurrency: string
563
+ currencyType: string
564
+ }
565
+
566
+ export interface CCTPTransfer {
567
+ id: number
568
+ intentId: string
569
+ originChainId: number
570
+ destinationChainId: number
571
+ originTxnId: number
572
+ originTxnHash: string
573
+ destinationTxnId: number
574
+ message: string
575
+ attestation: string
576
+ status: number
577
+ statusReason?: string
578
+ createdAt: string
579
+ updatedAt: string
580
+ }
581
+
582
+ export interface RelayTransfer {
583
+ id: number
584
+ intentId: string
585
+ originChainId: number
586
+ destinationChainId: number
587
+ originTxnId: number
588
+ originTxnHash: string
589
+ destinationTxnId: number
590
+ destinationTxnHash: string
591
+ status: number
592
+ statusReason?: string
593
+ createdAt: string
594
+ updatedAt: string
595
+ }
596
+
597
+ export interface GasFeeOptions {
598
+ gasEstimate: GasEstimate
599
+ feeOptions: Array<FeeOption>
600
+ expiresAt: string
601
+ feeCollectorAddress: string
602
+ }
603
+
604
+ export interface GasEstimate {
605
+ totalGas: number
606
+ gasPrice: string
607
+ nativeCost: string
608
+ nativeCostUsd: number
609
+ }
610
+
611
+ export interface FeeOption {
612
+ tokenAddress: string
613
+ tokenSymbol: string
614
+ tokenDecimals: number
615
+ amount: bigint
616
+ amountUsd: number
617
+ feeCollectorAddress: string
618
+ is2612: boolean
619
+ isPassthroughEligible?: boolean
620
+ }
621
+
622
+ export interface DepositSignature {
623
+ permitSignature?: string
624
+ permitDeadline?: number
625
+ permitAmount?: bigint
626
+ selectedGasFeeOption: FeeOption
627
+ deadline: number
628
+ }
629
+
630
+ export interface DepositIntentEntry {
631
+ permitSignature?: string
632
+ permitDeadline?: number
633
+ permitAmount?: bigint
634
+ feeAmount: string
635
+ feeToken: string
636
+ feeCollector: string
637
+ deadline: number
638
+ }
639
+
640
+ export interface TrailsAddressOverrides {
641
+ sequenceWalletFactoryAddress?: string
642
+ sequenceWalletMainModuleAddress?: string
643
+ sequenceWalletMainModuleUpgradableAddress?: string
644
+ sequenceWalletGuestModuleAddress?: string
645
+ sequenceWalletUtilsAddress?: string
646
+ }
647
+
648
+ export interface TrailsContracts {
649
+ trailsUtilsAddress: string
650
+ }
651
+
652
+ export interface ChainInfo {
653
+ id: number
654
+ name: string
655
+ tokenName: string
656
+ tokenSymbol: string
657
+ tokenDecimals: number
658
+ isTestnet: boolean
659
+ supportsBridging: boolean
660
+ logoUri?: string
661
+ blockExplorerUrl?: string
662
+ }
663
+
664
+ export interface TokenInfo {
665
+ chainId: number
666
+ address: string
667
+ name: string
668
+ symbol: string
669
+ decimals: number
670
+ supportsBridging?: boolean
671
+ logoUri?: string
672
+ featured: boolean
673
+ }
674
+
675
+ export interface EarnPool {
676
+ id: string
677
+ name: string
678
+ protocol: string
679
+ chainId: number
680
+ apy: number
681
+ tvl: number
682
+ token: PoolTokenInfo
683
+ depositAddress: string
684
+ isActive: boolean
685
+ poolUrl?: string
686
+ protocolUrl?: string
687
+ wrappedTokenGatewayAddress?: string
688
+ }
689
+
690
+ export interface PoolTokenInfo {
691
+ symbol: string
692
+ name: string
693
+ address: string
694
+ decimals: number
695
+ logoUrl?: string
696
+ }
697
+
698
+ export interface CountryRegion {
699
+ regionCode: string
700
+ name: string
701
+ }
702
+
703
+ export interface Country {
704
+ countryCode: string
705
+ name: string
706
+ flag: string
707
+ flagImageUrl: string
708
+ regions?: Array<CountryRegion>
709
+ }
710
+
711
+ export interface FiatCurrency {
712
+ code: string
713
+ symbol: string
714
+ name: string
715
+ flag: string
716
+ decimals: number
717
+ }
718
+
719
+ export interface MeldQuote {
720
+ transactionType: string
721
+ sourceAmount: number
722
+ sourceAmountWithoutFees: number
723
+ fiatAmountWithoutFees: number
724
+ destinationAmountWithoutFees?: number
725
+ sourceCurrencyCode: string
726
+ countryCode: string
727
+ totalFee: number
728
+ networkFee: number
729
+ transactionFee: number
730
+ destinationAmount: number
731
+ destinationCurrencyCode: string
732
+ exchangeRate: number
733
+ paymentMethodType: string
734
+ customerScore: number
735
+ serviceProvider: string
736
+ institutionName?: string
737
+ lowKyc?: boolean
738
+ partnerFee: number
739
+ }
740
+
741
+ export enum SortOrder {
742
+ DESC = 'DESC',
743
+ ASC = 'ASC'
744
+ }
745
+
746
+ export interface RuntimeStatus {
747
+ healthOK: boolean
748
+ version: string
749
+ branch: string
750
+ commitHash: string
751
+ startTime: string
752
+ uptime: string
753
+ hostname: string
754
+ runnables: any
755
+ services: Array<ServiceStatus>
756
+ }
757
+
758
+ export interface ServiceStatus {
759
+ name: string
760
+ healthy: boolean
761
+ error?: string
762
+ latency: string
763
+ }
764
+
765
+ export interface QuoteIntentResponse {
766
+ intent: Intent
767
+ gasFeeOptions: GasFeeOptions
768
+ transactionStates?: Array<TransactionStateInfo>
769
+ passthrough?: PassthroughInfo
770
+ }
771
+
772
+ export interface CommitIntentRequest {
773
+ intent: Intent
774
+ }
775
+
776
+ export interface CommitIntentResponse {
777
+ intentId: string
778
+ }
779
+
780
+ export interface ExecuteIntentRequest {
781
+ intentId: string
782
+ depositTransactionHash?: string
783
+ depositSignature?: DepositSignature
784
+ }
785
+
786
+ export interface ExecuteIntentResponse {
787
+ intentId: string
788
+ intentStatus: IntentStatus
789
+ }
790
+
791
+ export interface GetIntentReceiptRequest {
792
+ intentId: string
793
+ }
794
+
795
+ export interface GetIntentReceiptResponse {
796
+ intentReceipt: IntentReceipt
797
+ }
798
+
799
+ export interface WaitIntentReceiptRequest {
800
+ intentId: string
801
+ lastReceiptStates?: Array<TransactionStatus>
802
+ }
803
+
804
+ export interface WaitIntentReceiptResponse {
805
+ intentReceipt: IntentReceipt
806
+ receiptStates: Array<TransactionStatus>
807
+ done: boolean
808
+ }
809
+
810
+ export interface GetIntentRequest {
811
+ intentId: string
812
+ }
813
+
814
+ export interface GetIntentResponse {
815
+ intent: Intent
816
+ }
817
+
818
+ export interface SearchIntentsRequest {
819
+ byIntentId?: string
820
+ byProjectId?: number
821
+ byTransactionHash?: string
822
+ byOwnerAddress?: string
823
+ byOriginIntentAddress?: string
824
+ byDestinationIntentAddress?: string
825
+ byQueryString?: string
826
+ }
827
+
828
+ export interface SearchIntentsResponse {
829
+ intents: Array<Intent>
830
+ }
831
+
832
+ export interface GetIntentConfigRequest {
833
+ intentId: string
834
+ intentSource: IntentSource
835
+ }
836
+
837
+ export interface GetIntentConfigResponse {
838
+ address: string
839
+ imageHash: string
840
+ walletConfiguration: any
841
+ }
842
+
843
+ export interface GetIntentHistoryRequest {
844
+ page?: Page
845
+ byProjectId?: number
846
+ byOwnerAddress?: string
847
+ }
848
+
849
+ export interface GetIntentHistoryResponse {
850
+ intents: Array<IntentHistory>
851
+ nextPage?: Page
852
+ }
853
+
854
+ export interface AbortIntentRequest {
855
+ intentId: string
856
+ chainId: number
857
+ abortTransactionHash: string
858
+ }
859
+
860
+ export interface AbortIntentResponse {
861
+ intentId: string
862
+ status: IntentStatus
863
+ }
864
+
865
+ export interface GetTokenPricesRequest {
866
+ tokens: Array<Token>
867
+ }
868
+
869
+ export interface GetTokenPricesResponse {
870
+ tokenPrices: Array<TokenPrice>
871
+ }
872
+
873
+ export interface GetChainsRequest {
874
+ routeProvider?: string
875
+ }
876
+
877
+ export interface GetChainsResponse {
878
+ chains: Array<ChainInfo>
879
+ }
880
+
881
+ export interface GetExactOutputRoutesRequest {
882
+ destinationChainId: number
883
+ destinationTokenAddress: string
884
+ originChainId?: number
885
+ originTokenAddress?: string
886
+ ownerAddress?: string
887
+ }
888
+
889
+ export interface GetExactOutputRoutesResponse {
890
+ tokens: Array<TokenInfo>
891
+ }
892
+
893
+ export interface GetExactInputRoutesRequest {
894
+ originChainId: number
895
+ originTokenAddress: string
896
+ destinationChainId?: number
897
+ destinationTokenAddress?: string
898
+ }
899
+
900
+ export interface GetExactInputRoutesResponse {
901
+ tokens: Array<TokenInfo>
902
+ }
903
+
904
+ export interface GetTokenListRequest {
905
+ chainIds: Array<number>
906
+ searchQuery?: string
907
+ limit?: number
908
+ tokenAddress?: string
909
+ includeAllListed?: boolean
910
+ includeExternal?: boolean
911
+ excludeTokens?: Array<string>
912
+ }
913
+
914
+ export interface GetTokenListResponse {
915
+ tokens: Array<TokenInfo>
916
+ }
917
+
918
+ export interface GetEarnPoolsRequest {
919
+ chainIds?: Array<number>
920
+ protocols?: Array<string>
921
+ minTvl?: number
922
+ maxApy?: number
923
+ }
924
+
925
+ export interface GetEarnPoolsResponse {
926
+ pools: Array<EarnPool>
927
+ timestamp: string
928
+ cached: boolean
929
+ }
930
+
931
+ export interface Page {
932
+ column?: string
933
+ before?: number
934
+ after?: number
935
+ sort?: Array<SortBy>
936
+ pageSize?: number
937
+ more?: boolean
938
+ }
939
+
940
+ export interface SortBy {
941
+ column: string
942
+ order: SortOrder
943
+ }
944
+
945
+ export interface GetIntentTransactionHistoryRequest {
946
+ page?: Page
947
+ byProjectId?: number
948
+ byOwnerAddress?: string
949
+ }
950
+
951
+ export interface GetIntentTransactionHistoryResponse {
952
+ intents: Array<IntentSummary>
953
+ nextPage?: Page
954
+ }
955
+
956
+ export interface PingRequest {
957
+ }
958
+
959
+ export interface PingResponse {
960
+ version: string
961
+ }
962
+
963
+ export interface RuntimeStatusRequest {
964
+ }
965
+
966
+ export interface RuntimeStatusResponse {
967
+ status: RuntimeStatus
968
+ }
969
+
970
+ export interface ClockRequest {
971
+ }
972
+
973
+ export interface ClockResponse {
974
+ serverTime: string
975
+ }
976
+
977
+
978
+
979
+
980
+
981
+
982
+
983
+
984
+
985
+
986
+
987
+
988
+
989
+
990
+
991
+
992
+ export interface GetExchangeRateRequest {
993
+ toCurrency: string
994
+ }
995
+
996
+ export interface GetExchangeRateResponse {
997
+ exchangeRate: ExchangeRate
998
+ }
999
+
1000
+ export interface GetCountryListRequest {
1001
+ }
1002
+
1003
+ export interface GetCountryListResponse {
1004
+ countries: Array<Country>
1005
+ }
1006
+
1007
+ export interface GetTrailsContractsRequest {
1008
+ }
1009
+
1010
+ export interface GetTrailsContractsResponse {
1011
+ TrailsContracts: TrailsContracts
1012
+ }
1013
+
1014
+ export interface GetSupportedIntentProtocolVersionsRequest {
1015
+ }
1016
+
1017
+ export interface GetSupportedIntentProtocolVersionsResponse {
1018
+ versions: Array<IntentProtocolVersion>
1019
+ }
1020
+
1021
+
1022
+ export interface GetFiatCurrencyListRequest {
1023
+ }
1024
+
1025
+ export interface GetFiatCurrencyListResponse {
1026
+ currencies: Array<FiatCurrency>
1027
+ }
1028
+
1029
+
1030
+
1031
+
1032
+ //
1033
+ // Client
1034
+ //
1035
+
1036
+ export class Trails implements TrailsClient {
1037
+ protected hostname: string
1038
+ protected fetch: Fetch
1039
+ protected path = '/rpc/Trails/'
1040
+
1041
+ constructor(hostname: string, fetch: Fetch) {
1042
+ this.hostname = hostname.replace(/\/*$/, '')
1043
+ this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
1044
+ }
1045
+
1046
+ private url(name: string): string {
1047
+ return this.hostname + this.path + name
1048
+ }
1049
+
1050
+ queryKey = {
1051
+ ping: () => ['Trails', 'ping'] as const,
1052
+ runtimeStatus: () => ['Trails', 'runtimeStatus'] as const,
1053
+ clock: () => ['Trails', 'clock'] as const,
1054
+ quoteIntent: (req: QuoteIntentRequest) => ['Trails', 'quoteIntent', req] as const,
1055
+ commitIntent: (req: CommitIntentRequest) => ['Trails', 'commitIntent', req] as const,
1056
+ executeIntent: (req: ExecuteIntentRequest) => ['Trails', 'executeIntent', req] as const,
1057
+ waitIntentReceipt: (req: WaitIntentReceiptRequest) => ['Trails', 'waitIntentReceipt', req] as const,
1058
+ getIntentReceipt: (req: GetIntentReceiptRequest) => ['Trails', 'getIntentReceipt', req] as const,
1059
+ getIntent: (req: GetIntentRequest) => ['Trails', 'getIntent', req] as const,
1060
+ searchIntents: (req: SearchIntentsRequest) => ['Trails', 'searchIntents', req] as const,
1061
+ getIntentConfig: (req: GetIntentConfigRequest) => ['Trails', 'getIntentConfig', req] as const,
1062
+ getIntentHistory: (req: GetIntentHistoryRequest) => ['Trails', 'getIntentHistory', req] as const,
1063
+ abortIntent: (req: AbortIntentRequest) => ['Trails', 'abortIntent', req] as const,
1064
+ getChains: (req: GetChainsRequest) => ['Trails', 'getChains', req] as const,
1065
+ getExactOutputRoutes: (req: GetExactOutputRoutesRequest) => ['Trails', 'getExactOutputRoutes', req] as const,
1066
+ getExactInputRoutes: (req: GetExactInputRoutesRequest) => ['Trails', 'getExactInputRoutes', req] as const,
1067
+ getTokenList: (req: GetTokenListRequest) => ['Trails', 'getTokenList', req] as const,
1068
+ getTokenPrices: (req: GetTokenPricesRequest) => ['Trails', 'getTokenPrices', req] as const,
1069
+ getExchangeRate: (req: GetExchangeRateRequest) => ['Trails', 'getExchangeRate', req] as const,
1070
+ getCountryList: () => ['Trails', 'getCountryList'] as const,
1071
+ getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const,
1072
+ getSupportedIntentProtocolVersions: () => ['Trails', 'getSupportedIntentProtocolVersions'] as const,
1073
+ getEarnPools: (req: GetEarnPoolsRequest) => ['Trails', 'getEarnPools', req] as const,
1074
+ getFiatCurrencyList: () => ['Trails', 'getFiatCurrencyList'] as const,
1075
+ getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) => ['Trails', 'getIntentTransactionHistory', req] as const,
1076
+ }
1077
+
1078
+ ping = (headers?: object, signal?: AbortSignal): Promise<PingResponse> => {
1079
+ return this.fetch(
1080
+ this.url('Ping'),
1081
+ createHttpRequest('{}', headers, signal)).then((res) => {
1082
+ return buildResponse(res).then(_data => {
1083
+ return JsonDecode<PingResponse>(_data, 'PingResponse')
1084
+ })
1085
+ }, (error) => {
1086
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1087
+ })
1088
+ }
1089
+
1090
+ runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse> => {
1091
+ return this.fetch(
1092
+ this.url('RuntimeStatus'),
1093
+ createHttpRequest('{}', headers, signal)).then((res) => {
1094
+ return buildResponse(res).then(_data => {
1095
+ return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
1096
+ })
1097
+ }, (error) => {
1098
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1099
+ })
1100
+ }
1101
+
1102
+ clock = (headers?: object, signal?: AbortSignal): Promise<ClockResponse> => {
1103
+ return this.fetch(
1104
+ this.url('Clock'),
1105
+ createHttpRequest('{}', headers, signal)).then((res) => {
1106
+ return buildResponse(res).then(_data => {
1107
+ return JsonDecode<ClockResponse>(_data, 'ClockResponse')
1108
+ })
1109
+ }, (error) => {
1110
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1111
+ })
1112
+ }
1113
+
1114
+ quoteIntent = (req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse> => {
1115
+ return this.fetch(
1116
+ this.url('QuoteIntent'),
1117
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1118
+ return buildResponse(res).then(_data => {
1119
+ return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
1120
+ })
1121
+ }, (error) => {
1122
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1123
+ })
1124
+ }
1125
+
1126
+ commitIntent = (req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse> => {
1127
+ return this.fetch(
1128
+ this.url('CommitIntent'),
1129
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1130
+ return buildResponse(res).then(_data => {
1131
+ return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
1132
+ })
1133
+ }, (error) => {
1134
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1135
+ })
1136
+ }
1137
+
1138
+ executeIntent = (req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse> => {
1139
+ return this.fetch(
1140
+ this.url('ExecuteIntent'),
1141
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1142
+ return buildResponse(res).then(_data => {
1143
+ return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
1144
+ })
1145
+ }, (error) => {
1146
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1147
+ })
1148
+ }
1149
+
1150
+ waitIntentReceipt = (req: WaitIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<WaitIntentReceiptResponse> => {
1151
+ return this.fetch(
1152
+ this.url('WaitIntentReceipt'),
1153
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1154
+ return buildResponse(res).then(_data => {
1155
+ return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
1156
+ })
1157
+ }, (error) => {
1158
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1159
+ })
1160
+ }
1161
+
1162
+ getIntentReceipt = (req: GetIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentReceiptResponse> => {
1163
+ return this.fetch(
1164
+ this.url('GetIntentReceipt'),
1165
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1166
+ return buildResponse(res).then(_data => {
1167
+ return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
1168
+ })
1169
+ }, (error) => {
1170
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1171
+ })
1172
+ }
1173
+
1174
+ getIntent = (req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse> => {
1175
+ return this.fetch(
1176
+ this.url('GetIntent'),
1177
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1178
+ return buildResponse(res).then(_data => {
1179
+ return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
1180
+ })
1181
+ }, (error) => {
1182
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1183
+ })
1184
+ }
1185
+
1186
+ searchIntents = (req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse> => {
1187
+ return this.fetch(
1188
+ this.url('SearchIntents'),
1189
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1190
+ return buildResponse(res).then(_data => {
1191
+ return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
1192
+ })
1193
+ }, (error) => {
1194
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1195
+ })
1196
+ }
1197
+
1198
+ getIntentConfig = (req: GetIntentConfigRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentConfigResponse> => {
1199
+ return this.fetch(
1200
+ this.url('GetIntentConfig'),
1201
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1202
+ return buildResponse(res).then(_data => {
1203
+ return JsonDecode<GetIntentConfigResponse>(_data, 'GetIntentConfigResponse')
1204
+ })
1205
+ }, (error) => {
1206
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1207
+ })
1208
+ }
1209
+
1210
+ getIntentHistory = (req: GetIntentHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentHistoryResponse> => {
1211
+ return this.fetch(
1212
+ this.url('GetIntentHistory'),
1213
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1214
+ return buildResponse(res).then(_data => {
1215
+ return JsonDecode<GetIntentHistoryResponse>(_data, 'GetIntentHistoryResponse')
1216
+ })
1217
+ }, (error) => {
1218
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1219
+ })
1220
+ }
1221
+
1222
+ abortIntent = (req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse> => {
1223
+ return this.fetch(
1224
+ this.url('AbortIntent'),
1225
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1226
+ return buildResponse(res).then(_data => {
1227
+ return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
1228
+ })
1229
+ }, (error) => {
1230
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1231
+ })
1232
+ }
1233
+
1234
+ getChains = (req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse> => {
1235
+ return this.fetch(
1236
+ this.url('GetChains'),
1237
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1238
+ return buildResponse(res).then(_data => {
1239
+ return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
1240
+ })
1241
+ }, (error) => {
1242
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1243
+ })
1244
+ }
1245
+
1246
+ getExactOutputRoutes = (req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse> => {
1247
+ return this.fetch(
1248
+ this.url('GetExactOutputRoutes'),
1249
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1250
+ return buildResponse(res).then(_data => {
1251
+ return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
1252
+ })
1253
+ }, (error) => {
1254
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1255
+ })
1256
+ }
1257
+
1258
+ getExactInputRoutes = (req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse> => {
1259
+ return this.fetch(
1260
+ this.url('GetExactInputRoutes'),
1261
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1262
+ return buildResponse(res).then(_data => {
1263
+ return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
1264
+ })
1265
+ }, (error) => {
1266
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1267
+ })
1268
+ }
1269
+
1270
+ getTokenList = (req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse> => {
1271
+ return this.fetch(
1272
+ this.url('GetTokenList'),
1273
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1274
+ return buildResponse(res).then(_data => {
1275
+ return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
1276
+ })
1277
+ }, (error) => {
1278
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1279
+ })
1280
+ }
1281
+
1282
+ getTokenPrices = (req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse> => {
1283
+ return this.fetch(
1284
+ this.url('GetTokenPrices'),
1285
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1286
+ return buildResponse(res).then(_data => {
1287
+ return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
1288
+ })
1289
+ }, (error) => {
1290
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1291
+ })
1292
+ }
1293
+
1294
+ getExchangeRate = (req: GetExchangeRateRequest, headers?: object, signal?: AbortSignal): Promise<GetExchangeRateResponse> => {
1295
+ return this.fetch(
1296
+ this.url('GetExchangeRate'),
1297
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1298
+ return buildResponse(res).then(_data => {
1299
+ return JsonDecode<GetExchangeRateResponse>(_data, 'GetExchangeRateResponse')
1300
+ })
1301
+ }, (error) => {
1302
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1303
+ })
1304
+ }
1305
+
1306
+ getCountryList = (headers?: object, signal?: AbortSignal): Promise<GetCountryListResponse> => {
1307
+ return this.fetch(
1308
+ this.url('GetCountryList'),
1309
+ createHttpRequest('{}', headers, signal)).then((res) => {
1310
+ return buildResponse(res).then(_data => {
1311
+ return JsonDecode<GetCountryListResponse>(_data, 'GetCountryListResponse')
1312
+ })
1313
+ }, (error) => {
1314
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1315
+ })
1316
+ }
1317
+
1318
+ getTrailsContracts = (headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse> => {
1319
+ return this.fetch(
1320
+ this.url('GetTrailsContracts'),
1321
+ createHttpRequest('{}', headers, signal)).then((res) => {
1322
+ return buildResponse(res).then(_data => {
1323
+ return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
1324
+ })
1325
+ }, (error) => {
1326
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1327
+ })
1328
+ }
1329
+
1330
+ getSupportedIntentProtocolVersions = (headers?: object, signal?: AbortSignal): Promise<GetSupportedIntentProtocolVersionsResponse> => {
1331
+ return this.fetch(
1332
+ this.url('GetSupportedIntentProtocolVersions'),
1333
+ createHttpRequest('{}', headers, signal)).then((res) => {
1334
+ return buildResponse(res).then(_data => {
1335
+ return JsonDecode<GetSupportedIntentProtocolVersionsResponse>(_data, 'GetSupportedIntentProtocolVersionsResponse')
1336
+ })
1337
+ }, (error) => {
1338
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1339
+ })
1340
+ }
1341
+
1342
+ getEarnPools = (req: GetEarnPoolsRequest, headers?: object, signal?: AbortSignal): Promise<GetEarnPoolsResponse> => {
1343
+ return this.fetch(
1344
+ this.url('GetEarnPools'),
1345
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1346
+ return buildResponse(res).then(_data => {
1347
+ return JsonDecode<GetEarnPoolsResponse>(_data, 'GetEarnPoolsResponse')
1348
+ })
1349
+ }, (error) => {
1350
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1351
+ })
1352
+ }
1353
+
1354
+ getFiatCurrencyList = (headers?: object, signal?: AbortSignal): Promise<GetFiatCurrencyListResponse> => {
1355
+ return this.fetch(
1356
+ this.url('GetFiatCurrencyList'),
1357
+ createHttpRequest('{}', headers, signal)).then((res) => {
1358
+ return buildResponse(res).then(_data => {
1359
+ return JsonDecode<GetFiatCurrencyListResponse>(_data, 'GetFiatCurrencyListResponse')
1360
+ })
1361
+ }, (error) => {
1362
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1363
+ })
1364
+ }
1365
+
1366
+ getIntentTransactionHistory = (req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse> => {
1367
+ return this.fetch(
1368
+ this.url('GetIntentTransactionHistory'),
1369
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1370
+ return buildResponse(res).then(_data => {
1371
+ return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
1372
+ })
1373
+ }, (error) => {
1374
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1375
+ })
1376
+ }
1377
+
1378
+ }
1379
+
1380
+ const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
1381
+ const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json', [WebrpcHeader]: WebrpcHeaderValue }
1382
+ return { method: 'POST', headers: reqHeaders, body, signal }
1383
+ }
1384
+
1385
+ const buildResponse = (res: Response): Promise<any> => {
1386
+ return res.text().then(text => {
1387
+ let data
1388
+ try {
1389
+ data = JSON.parse(text)
1390
+ } catch(error) {
1391
+ throw WebrpcBadResponseError.new({
1392
+ status: res.status,
1393
+ cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`},
1394
+ )
1395
+ }
1396
+ if (!res.ok) {
1397
+ const code: number = (typeof data.code === 'number') ? data.code : 0
1398
+ throw (webrpcErrorByCode[code] || WebrpcError).new(data)
1399
+ }
1400
+ return data
1401
+ })
1402
+ }
1403
+
1404
+ export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
1405
+
1406
+
1407
+
1408
+
1409
+
1410
+ //
1411
+ // BigInt helpers
1412
+ //
1413
+
1414
+ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
1415
+ CommitIntentRequest: [['intent', 'Intent']],
1416
+ DepositIntentEntry: ['permitAmount'],
1417
+ DepositSignature: ['permitAmount', ['selectedGasFeeOption', 'FeeOption']],
1418
+ DepositTransaction: ['amount', 'value'],
1419
+ ExecuteIntentRequest: [['depositSignature', 'DepositSignature']],
1420
+ FeeOption: ['amount'],
1421
+ GasFeeOptions: [['feeOptions', 'FeeOption[]']],
1422
+ GetIntentHistoryResponse: [['intents', 'IntentHistory[]']],
1423
+ GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
1424
+ GetIntentResponse: [['intent', 'Intent']],
1425
+ GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
1426
+ Intent: [['quoteRequest', 'QuoteIntentRequest'], 'salt', ['depositTransaction', 'DepositTransaction'], ['originCalls', 'IntentCalls'], ['destinationCalls', 'IntentCalls'], ['originPrecondition', 'TransactionPrecondition'], ['destinationPrecondition', 'TransactionPrecondition'], ['quote', 'IntentProviderQuote'], ['fees', 'IntentFees']],
1427
+ IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
1428
+ IntentFees: [['originGas', 'IntentTransactionGasFee'], ['destinationGas', 'IntentTransactionGasFee'], ['provider', 'IntentProviderFees'], 'feeTokenAmount', 'feeTokenTotal', 'gasFeeTotal', 'trailsFeeTotal', 'collectorFeeTotal', 'providerFeeTotal', 'totalFeeAmount'],
1429
+ IntentHistory: [['receipt', 'IntentReceipt']],
1430
+ IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'quoteProviderWithTrailsFee', 'totalFeeAmount'],
1431
+ IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
1432
+ IntentReceipt: [['depositTransaction', 'IntentTransaction'], ['originTransaction', 'IntentTransaction'], ['destinationTransaction', 'IntentTransaction'], ['refundTransaction', 'IntentTransaction'], ['summary', 'IntentReceiptSummary']],
1433
+ IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
1434
+ IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
1435
+ IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
1436
+ IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
1437
+ MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
1438
+ PassThroughTransaction: ['amount', 'value'],
1439
+ PassthroughInfo: [['passthroughTransaction', 'PassThroughTransaction']],
1440
+ QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
1441
+ QuoteIntentResponse: [['intent', 'Intent'], ['gasFeeOptions', 'GasFeeOptions'], ['passthrough', 'PassthroughInfo']],
1442
+ SearchIntentsResponse: [['intents', 'Intent[]']],
1443
+ TransactionCall: ['value', 'gasLimit'],
1444
+ TransactionPrecondition: ['minAmount'],
1445
+ WaitIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']]
1446
+ }
1447
+
1448
+ // Decode in-place: mutate object graph; throw if expected numeric string is invalid.
1449
+ function decodeType(typ: string, obj: any): any {
1450
+ if (obj == null || typeof obj !== 'object') return obj
1451
+ const descs = BIG_INT_FIELDS[typ] || []
1452
+ if (!descs.length) return obj
1453
+ for (const d of descs) {
1454
+ if (Array.isArray(d)) {
1455
+ const [fieldName, nestedType] = d
1456
+ if (fieldName.endsWith('[]')) {
1457
+ const base = fieldName.slice(0, -2)
1458
+ const arr = obj[base]
1459
+ if (Array.isArray(arr)) {
1460
+ for (let i = 0; i < arr.length; i++) arr[i] = decodeType(nestedType, arr[i])
1461
+ }
1462
+ } else if (obj[fieldName]) {
1463
+ // Handle nestedType that might be an array type like 'Message[]'
1464
+ if (nestedType.endsWith('[]')) {
1465
+ const baseType = nestedType.slice(0, -2)
1466
+ const arr = obj[fieldName]
1467
+ if (Array.isArray(arr)) {
1468
+ for (let i = 0; i < arr.length; i++) arr[i] = decodeType(baseType, arr[i])
1469
+ }
1470
+ } else {
1471
+ obj[fieldName] = decodeType(nestedType, obj[fieldName])
1472
+ }
1473
+ }
1474
+ continue
1475
+ }
1476
+ if (d.endsWith('[]')) {
1477
+ const base = d.slice(0, -2)
1478
+ const arr = obj[base]
1479
+ if (Array.isArray(arr)) {
1480
+ for (let i = 0; i < arr.length; i++) {
1481
+ const v = arr[i]
1482
+ if (typeof v === 'string') {
1483
+ try { arr[i] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` }) }
1484
+ }
1485
+ }
1486
+ }
1487
+ continue
1488
+ }
1489
+ const v = obj[d]
1490
+ if (typeof v === 'string') {
1491
+ try { obj[d] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` }) }
1492
+ }
1493
+ }
1494
+ return obj
1495
+ }
1496
+
1497
+ // Encode object to JSON with BigInts converted to decimal strings.
1498
+ export const JsonEncode = <T = any>(obj: T): string => {
1499
+ return JSON.stringify(obj, (key, value) =>
1500
+ typeof value === 'bigint' ? value.toString() : value
1501
+ )
1502
+ }
1503
+
1504
+ // Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
1505
+ export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
1506
+ let parsed: any = data
1507
+ if (typeof data === 'string') {
1508
+ try { parsed = JSON.parse(data) } catch (err) {
1509
+ throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
1510
+ }
1511
+ }
1512
+ return decodeType(typ, parsed) as T
1513
+ }
1514
+
1515
+
1516
+ //
1517
+ // Errors
1518
+ //
1519
+
1520
+ type WebrpcErrorParams = { name?: string, code?: number, message?: string, status?: number, cause?: string }
1521
+
1522
+ export class WebrpcError extends Error {
1523
+ code: number
1524
+ status: number
1525
+
1526
+ constructor(error: WebrpcErrorParams = {}) {
1527
+ super(error.message)
1528
+ this.name = error.name || 'WebrpcEndpointError'
1529
+ this.code = typeof error.code === 'number' ? error.code : 0
1530
+ this.message = error.message || `endpoint error`
1531
+ this.status = typeof error.status === 'number' ? error.status : 400
1532
+ if (error.cause !== undefined) this.cause = error.cause
1533
+ Object.setPrototypeOf(this, WebrpcError.prototype)
1534
+ }
1535
+
1536
+ static new(payload: any): WebrpcError {
1537
+ return new this({ message: payload.message, code: payload.code, status: payload.status, cause: payload.cause })
1538
+ }
1539
+ }
1540
+
1541
+
1542
+ export class WebrpcEndpointError extends WebrpcError {
1543
+ constructor(error: WebrpcErrorParams = {}) {
1544
+ super(error)
1545
+ this.name = error.name || 'WebrpcEndpoint'
1546
+ this.code = typeof error.code === 'number' ? error.code : 0
1547
+ this.message = error.message || `endpoint error`
1548
+ this.status = typeof error.status === 'number' ? error.status : 400
1549
+ if (error.cause !== undefined) this.cause = error.cause
1550
+ Object.setPrototypeOf(this, WebrpcEndpointError.prototype)
1551
+ }
1552
+ }
1553
+
1554
+ export class WebrpcRequestFailedError extends WebrpcError {
1555
+ constructor(error: WebrpcErrorParams = {}) {
1556
+ super(error)
1557
+ this.name = error.name || 'WebrpcRequestFailed'
1558
+ this.code = typeof error.code === 'number' ? error.code : -1
1559
+ this.message = error.message || `request failed`
1560
+ this.status = typeof error.status === 'number' ? error.status : 400
1561
+ if (error.cause !== undefined) this.cause = error.cause
1562
+ Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype)
1563
+ }
1564
+ }
1565
+
1566
+ export class WebrpcBadRouteError extends WebrpcError {
1567
+ constructor(error: WebrpcErrorParams = {}) {
1568
+ super(error)
1569
+ this.name = error.name || 'WebrpcBadRoute'
1570
+ this.code = typeof error.code === 'number' ? error.code : -2
1571
+ this.message = error.message || `bad route`
1572
+ this.status = typeof error.status === 'number' ? error.status : 404
1573
+ if (error.cause !== undefined) this.cause = error.cause
1574
+ Object.setPrototypeOf(this, WebrpcBadRouteError.prototype)
1575
+ }
1576
+ }
1577
+
1578
+ export class WebrpcBadMethodError extends WebrpcError {
1579
+ constructor(error: WebrpcErrorParams = {}) {
1580
+ super(error)
1581
+ this.name = error.name || 'WebrpcBadMethod'
1582
+ this.code = typeof error.code === 'number' ? error.code : -3
1583
+ this.message = error.message || `bad method`
1584
+ this.status = typeof error.status === 'number' ? error.status : 405
1585
+ if (error.cause !== undefined) this.cause = error.cause
1586
+ Object.setPrototypeOf(this, WebrpcBadMethodError.prototype)
1587
+ }
1588
+ }
1589
+
1590
+ export class WebrpcBadRequestError extends WebrpcError {
1591
+ constructor(error: WebrpcErrorParams = {}) {
1592
+ super(error)
1593
+ this.name = error.name || 'WebrpcBadRequest'
1594
+ this.code = typeof error.code === 'number' ? error.code : -4
1595
+ this.message = error.message || `bad request`
1596
+ this.status = typeof error.status === 'number' ? error.status : 400
1597
+ if (error.cause !== undefined) this.cause = error.cause
1598
+ Object.setPrototypeOf(this, WebrpcBadRequestError.prototype)
1599
+ }
1600
+ }
1601
+
1602
+ export class WebrpcBadResponseError extends WebrpcError {
1603
+ constructor(error: WebrpcErrorParams = {}) {
1604
+ super(error)
1605
+ this.name = error.name || 'WebrpcBadResponse'
1606
+ this.code = typeof error.code === 'number' ? error.code : -5
1607
+ this.message = error.message || `bad response`
1608
+ this.status = typeof error.status === 'number' ? error.status : 500
1609
+ if (error.cause !== undefined) this.cause = error.cause
1610
+ Object.setPrototypeOf(this, WebrpcBadResponseError.prototype)
1611
+ }
1612
+ }
1613
+
1614
+ export class WebrpcServerPanicError extends WebrpcError {
1615
+ constructor(error: WebrpcErrorParams = {}) {
1616
+ super(error)
1617
+ this.name = error.name || 'WebrpcServerPanic'
1618
+ this.code = typeof error.code === 'number' ? error.code : -6
1619
+ this.message = error.message || `server panic`
1620
+ this.status = typeof error.status === 'number' ? error.status : 500
1621
+ if (error.cause !== undefined) this.cause = error.cause
1622
+ Object.setPrototypeOf(this, WebrpcServerPanicError.prototype)
1623
+ }
1624
+ }
1625
+
1626
+ export class WebrpcInternalErrorError extends WebrpcError {
1627
+ constructor(error: WebrpcErrorParams = {}) {
1628
+ super(error)
1629
+ this.name = error.name || 'WebrpcInternalError'
1630
+ this.code = typeof error.code === 'number' ? error.code : -7
1631
+ this.message = error.message || `internal error`
1632
+ this.status = typeof error.status === 'number' ? error.status : 500
1633
+ if (error.cause !== undefined) this.cause = error.cause
1634
+ Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
1635
+ }
1636
+ }
1637
+
1638
+ export class WebrpcClientAbortedError extends WebrpcError {
1639
+ constructor(error: WebrpcErrorParams = {}) {
1640
+ super(error)
1641
+ this.name = error.name || 'WebrpcClientAborted'
1642
+ this.code = typeof error.code === 'number' ? error.code : -8
1643
+ this.message = error.message || `request aborted by client`
1644
+ this.status = typeof error.status === 'number' ? error.status : 400
1645
+ if (error.cause !== undefined) this.cause = error.cause
1646
+ Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype)
1647
+ }
1648
+ }
1649
+
1650
+ export class WebrpcStreamLostError extends WebrpcError {
1651
+ constructor(error: WebrpcErrorParams = {}) {
1652
+ super(error)
1653
+ this.name = error.name || 'WebrpcStreamLost'
1654
+ this.code = typeof error.code === 'number' ? error.code : -9
1655
+ this.message = error.message || `stream lost`
1656
+ this.status = typeof error.status === 'number' ? error.status : 400
1657
+ if (error.cause !== undefined) this.cause = error.cause
1658
+ Object.setPrototypeOf(this, WebrpcStreamLostError.prototype)
1659
+ }
1660
+ }
1661
+
1662
+ export class WebrpcStreamFinishedError extends WebrpcError {
1663
+ constructor(error: WebrpcErrorParams = {}) {
1664
+ super(error)
1665
+ this.name = error.name || 'WebrpcStreamFinished'
1666
+ this.code = typeof error.code === 'number' ? error.code : -10
1667
+ this.message = error.message || `stream finished`
1668
+ this.status = typeof error.status === 'number' ? error.status : 200
1669
+ if (error.cause !== undefined) this.cause = error.cause
1670
+ Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype)
1671
+ }
1672
+ }
1673
+
1674
+
1675
+ //
1676
+ // Schema errors
1677
+ //
1678
+
1679
+ export class UnauthorizedError extends WebrpcError {
1680
+ constructor(error: WebrpcErrorParams = {}) {
1681
+ super(error)
1682
+ this.name = error.name || 'Unauthorized'
1683
+ this.code = typeof error.code === 'number' ? error.code : 1000
1684
+ this.message = error.message || `Unauthorized access`
1685
+ this.status = typeof error.status === 'number' ? error.status : 401
1686
+ if (error.cause !== undefined) this.cause = error.cause
1687
+ Object.setPrototypeOf(this, UnauthorizedError.prototype)
1688
+ }
1689
+ }
1690
+
1691
+ export class PermissionDeniedError extends WebrpcError {
1692
+ constructor(error: WebrpcErrorParams = {}) {
1693
+ super(error)
1694
+ this.name = error.name || 'PermissionDenied'
1695
+ this.code = typeof error.code === 'number' ? error.code : 1001
1696
+ this.message = error.message || `Permission denied`
1697
+ this.status = typeof error.status === 'number' ? error.status : 403
1698
+ if (error.cause !== undefined) this.cause = error.cause
1699
+ Object.setPrototypeOf(this, PermissionDeniedError.prototype)
1700
+ }
1701
+ }
1702
+
1703
+ export class SessionExpiredError extends WebrpcError {
1704
+ constructor(error: WebrpcErrorParams = {}) {
1705
+ super(error)
1706
+ this.name = error.name || 'SessionExpired'
1707
+ this.code = typeof error.code === 'number' ? error.code : 1002
1708
+ this.message = error.message || `Session expired`
1709
+ this.status = typeof error.status === 'number' ? error.status : 403
1710
+ if (error.cause !== undefined) this.cause = error.cause
1711
+ Object.setPrototypeOf(this, SessionExpiredError.prototype)
1712
+ }
1713
+ }
1714
+
1715
+ export class MethodNotFoundError extends WebrpcError {
1716
+ constructor(error: WebrpcErrorParams = {}) {
1717
+ super(error)
1718
+ this.name = error.name || 'MethodNotFound'
1719
+ this.code = typeof error.code === 'number' ? error.code : 1003
1720
+ this.message = error.message || `Method not found`
1721
+ this.status = typeof error.status === 'number' ? error.status : 404
1722
+ if (error.cause !== undefined) this.cause = error.cause
1723
+ Object.setPrototypeOf(this, MethodNotFoundError.prototype)
1724
+ }
1725
+ }
1726
+
1727
+ export class RequestConflictError extends WebrpcError {
1728
+ constructor(error: WebrpcErrorParams = {}) {
1729
+ super(error)
1730
+ this.name = error.name || 'RequestConflict'
1731
+ this.code = typeof error.code === 'number' ? error.code : 1004
1732
+ this.message = error.message || `Conflict with target resource`
1733
+ this.status = typeof error.status === 'number' ? error.status : 409
1734
+ if (error.cause !== undefined) this.cause = error.cause
1735
+ Object.setPrototypeOf(this, RequestConflictError.prototype)
1736
+ }
1737
+ }
1738
+
1739
+ export class AbortedError extends WebrpcError {
1740
+ constructor(error: WebrpcErrorParams = {}) {
1741
+ super(error)
1742
+ this.name = error.name || 'Aborted'
1743
+ this.code = typeof error.code === 'number' ? error.code : 1005
1744
+ this.message = error.message || `Request aborted`
1745
+ this.status = typeof error.status === 'number' ? error.status : 400
1746
+ if (error.cause !== undefined) this.cause = error.cause
1747
+ Object.setPrototypeOf(this, AbortedError.prototype)
1748
+ }
1749
+ }
1750
+
1751
+ export class GeoblockedError extends WebrpcError {
1752
+ constructor(error: WebrpcErrorParams = {}) {
1753
+ super(error)
1754
+ this.name = error.name || 'Geoblocked'
1755
+ this.code = typeof error.code === 'number' ? error.code : 1006
1756
+ this.message = error.message || `Geoblocked region`
1757
+ this.status = typeof error.status === 'number' ? error.status : 451
1758
+ if (error.cause !== undefined) this.cause = error.cause
1759
+ Object.setPrototypeOf(this, GeoblockedError.prototype)
1760
+ }
1761
+ }
1762
+
1763
+ export class RateLimitedError extends WebrpcError {
1764
+ constructor(error: WebrpcErrorParams = {}) {
1765
+ super(error)
1766
+ this.name = error.name || 'RateLimited'
1767
+ this.code = typeof error.code === 'number' ? error.code : 1007
1768
+ this.message = error.message || `Rate-limited. Please slow down.`
1769
+ this.status = typeof error.status === 'number' ? error.status : 429
1770
+ if (error.cause !== undefined) this.cause = error.cause
1771
+ Object.setPrototypeOf(this, RateLimitedError.prototype)
1772
+ }
1773
+ }
1774
+
1775
+ export class ProjectNotFoundError extends WebrpcError {
1776
+ constructor(error: WebrpcErrorParams = {}) {
1777
+ super(error)
1778
+ this.name = error.name || 'ProjectNotFound'
1779
+ this.code = typeof error.code === 'number' ? error.code : 1008
1780
+ this.message = error.message || `Project not found`
1781
+ this.status = typeof error.status === 'number' ? error.status : 401
1782
+ if (error.cause !== undefined) this.cause = error.cause
1783
+ Object.setPrototypeOf(this, ProjectNotFoundError.prototype)
1784
+ }
1785
+ }
1786
+
1787
+ export class AccessKeyNotFoundError extends WebrpcError {
1788
+ constructor(error: WebrpcErrorParams = {}) {
1789
+ super(error)
1790
+ this.name = error.name || 'AccessKeyNotFound'
1791
+ this.code = typeof error.code === 'number' ? error.code : 1101
1792
+ this.message = error.message || `Access key not found`
1793
+ this.status = typeof error.status === 'number' ? error.status : 401
1794
+ if (error.cause !== undefined) this.cause = error.cause
1795
+ Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype)
1796
+ }
1797
+ }
1798
+
1799
+ export class AccessKeyMismatchError extends WebrpcError {
1800
+ constructor(error: WebrpcErrorParams = {}) {
1801
+ super(error)
1802
+ this.name = error.name || 'AccessKeyMismatch'
1803
+ this.code = typeof error.code === 'number' ? error.code : 1102
1804
+ this.message = error.message || `Access key mismatch`
1805
+ this.status = typeof error.status === 'number' ? error.status : 409
1806
+ if (error.cause !== undefined) this.cause = error.cause
1807
+ Object.setPrototypeOf(this, AccessKeyMismatchError.prototype)
1808
+ }
1809
+ }
1810
+
1811
+ export class InvalidOriginError extends WebrpcError {
1812
+ constructor(error: WebrpcErrorParams = {}) {
1813
+ super(error)
1814
+ this.name = error.name || 'InvalidOrigin'
1815
+ this.code = typeof error.code === 'number' ? error.code : 1103
1816
+ this.message = error.message || `Invalid origin for Access Key`
1817
+ this.status = typeof error.status === 'number' ? error.status : 403
1818
+ if (error.cause !== undefined) this.cause = error.cause
1819
+ Object.setPrototypeOf(this, InvalidOriginError.prototype)
1820
+ }
1821
+ }
1822
+
1823
+ export class InvalidServiceError extends WebrpcError {
1824
+ constructor(error: WebrpcErrorParams = {}) {
1825
+ super(error)
1826
+ this.name = error.name || 'InvalidService'
1827
+ this.code = typeof error.code === 'number' ? error.code : 1104
1828
+ this.message = error.message || `Service not enabled for Access key`
1829
+ this.status = typeof error.status === 'number' ? error.status : 403
1830
+ if (error.cause !== undefined) this.cause = error.cause
1831
+ Object.setPrototypeOf(this, InvalidServiceError.prototype)
1832
+ }
1833
+ }
1834
+
1835
+ export class UnauthorizedUserError extends WebrpcError {
1836
+ constructor(error: WebrpcErrorParams = {}) {
1837
+ super(error)
1838
+ this.name = error.name || 'UnauthorizedUser'
1839
+ this.code = typeof error.code === 'number' ? error.code : 1105
1840
+ this.message = error.message || `Unauthorized user`
1841
+ this.status = typeof error.status === 'number' ? error.status : 403
1842
+ if (error.cause !== undefined) this.cause = error.cause
1843
+ Object.setPrototypeOf(this, UnauthorizedUserError.prototype)
1844
+ }
1845
+ }
1846
+
1847
+ export class QuotaExceededError extends WebrpcError {
1848
+ constructor(error: WebrpcErrorParams = {}) {
1849
+ super(error)
1850
+ this.name = error.name || 'QuotaExceeded'
1851
+ this.code = typeof error.code === 'number' ? error.code : 1200
1852
+ this.message = error.message || `Quota request exceeded`
1853
+ this.status = typeof error.status === 'number' ? error.status : 429
1854
+ if (error.cause !== undefined) this.cause = error.cause
1855
+ Object.setPrototypeOf(this, QuotaExceededError.prototype)
1856
+ }
1857
+ }
1858
+
1859
+ export class QuotaRateLimitError extends WebrpcError {
1860
+ constructor(error: WebrpcErrorParams = {}) {
1861
+ super(error)
1862
+ this.name = error.name || 'QuotaRateLimit'
1863
+ this.code = typeof error.code === 'number' ? error.code : 1201
1864
+ this.message = error.message || `Quota rate limit exceeded`
1865
+ this.status = typeof error.status === 'number' ? error.status : 429
1866
+ if (error.cause !== undefined) this.cause = error.cause
1867
+ Object.setPrototypeOf(this, QuotaRateLimitError.prototype)
1868
+ }
1869
+ }
1870
+
1871
+ export class NoDefaultKeyError extends WebrpcError {
1872
+ constructor(error: WebrpcErrorParams = {}) {
1873
+ super(error)
1874
+ this.name = error.name || 'NoDefaultKey'
1875
+ this.code = typeof error.code === 'number' ? error.code : 1300
1876
+ this.message = error.message || `No default access key found`
1877
+ this.status = typeof error.status === 'number' ? error.status : 403
1878
+ if (error.cause !== undefined) this.cause = error.cause
1879
+ Object.setPrototypeOf(this, NoDefaultKeyError.prototype)
1880
+ }
1881
+ }
1882
+
1883
+ export class MaxAccessKeysError extends WebrpcError {
1884
+ constructor(error: WebrpcErrorParams = {}) {
1885
+ super(error)
1886
+ this.name = error.name || 'MaxAccessKeys'
1887
+ this.code = typeof error.code === 'number' ? error.code : 1301
1888
+ this.message = error.message || `Access keys limit reached`
1889
+ this.status = typeof error.status === 'number' ? error.status : 403
1890
+ if (error.cause !== undefined) this.cause = error.cause
1891
+ Object.setPrototypeOf(this, MaxAccessKeysError.prototype)
1892
+ }
1893
+ }
1894
+
1895
+ export class AtLeastOneKeyError extends WebrpcError {
1896
+ constructor(error: WebrpcErrorParams = {}) {
1897
+ super(error)
1898
+ this.name = error.name || 'AtLeastOneKey'
1899
+ this.code = typeof error.code === 'number' ? error.code : 1302
1900
+ this.message = error.message || `You need at least one Access Key`
1901
+ this.status = typeof error.status === 'number' ? error.status : 403
1902
+ if (error.cause !== undefined) this.cause = error.cause
1903
+ Object.setPrototypeOf(this, AtLeastOneKeyError.prototype)
1904
+ }
1905
+ }
1906
+
1907
+ export class TimeoutError extends WebrpcError {
1908
+ constructor(error: WebrpcErrorParams = {}) {
1909
+ super(error)
1910
+ this.name = error.name || 'Timeout'
1911
+ this.code = typeof error.code === 'number' ? error.code : 1900
1912
+ this.message = error.message || `Request timed out`
1913
+ this.status = typeof error.status === 'number' ? error.status : 408
1914
+ if (error.cause !== undefined) this.cause = error.cause
1915
+ Object.setPrototypeOf(this, TimeoutError.prototype)
1916
+ }
1917
+ }
1918
+
1919
+ export class InvalidArgumentError extends WebrpcError {
1920
+ constructor(error: WebrpcErrorParams = {}) {
1921
+ super(error)
1922
+ this.name = error.name || 'InvalidArgument'
1923
+ this.code = typeof error.code === 'number' ? error.code : 2000
1924
+ this.message = error.message || `Invalid argument`
1925
+ this.status = typeof error.status === 'number' ? error.status : 400
1926
+ if (error.cause !== undefined) this.cause = error.cause
1927
+ Object.setPrototypeOf(this, InvalidArgumentError.prototype)
1928
+ }
1929
+ }
1930
+
1931
+ export class UnexpectedError extends WebrpcError {
1932
+ constructor(error: WebrpcErrorParams = {}) {
1933
+ super(error)
1934
+ this.name = error.name || 'Unexpected'
1935
+ this.code = typeof error.code === 'number' ? error.code : 2001
1936
+ this.message = error.message || `Unexpected server error`
1937
+ this.status = typeof error.status === 'number' ? error.status : 500
1938
+ if (error.cause !== undefined) this.cause = error.cause
1939
+ Object.setPrototypeOf(this, UnexpectedError.prototype)
1940
+ }
1941
+ }
1942
+
1943
+ export class UnavailableError extends WebrpcError {
1944
+ constructor(error: WebrpcErrorParams = {}) {
1945
+ super(error)
1946
+ this.name = error.name || 'Unavailable'
1947
+ this.code = typeof error.code === 'number' ? error.code : 2002
1948
+ this.message = error.message || `Unavailable resource`
1949
+ this.status = typeof error.status === 'number' ? error.status : 400
1950
+ if (error.cause !== undefined) this.cause = error.cause
1951
+ Object.setPrototypeOf(this, UnavailableError.prototype)
1952
+ }
1953
+ }
1954
+
1955
+ export class QueryFailedError extends WebrpcError {
1956
+ constructor(error: WebrpcErrorParams = {}) {
1957
+ super(error)
1958
+ this.name = error.name || 'QueryFailed'
1959
+ this.code = typeof error.code === 'number' ? error.code : 2003
1960
+ this.message = error.message || `Query failed`
1961
+ this.status = typeof error.status === 'number' ? error.status : 400
1962
+ if (error.cause !== undefined) this.cause = error.cause
1963
+ Object.setPrototypeOf(this, QueryFailedError.prototype)
1964
+ }
1965
+ }
1966
+
1967
+ export class IntentStatusError extends WebrpcError {
1968
+ constructor(error: WebrpcErrorParams = {}) {
1969
+ super(error)
1970
+ this.name = error.name || 'IntentStatus'
1971
+ this.code = typeof error.code === 'number' ? error.code : 2004
1972
+ this.message = error.message || `Invalid intent status`
1973
+ this.status = typeof error.status === 'number' ? error.status : 422
1974
+ if (error.cause !== undefined) this.cause = error.cause
1975
+ Object.setPrototypeOf(this, IntentStatusError.prototype)
1976
+ }
1977
+ }
1978
+
1979
+ export class NotFoundError extends WebrpcError {
1980
+ constructor(error: WebrpcErrorParams = {}) {
1981
+ super(error)
1982
+ this.name = error.name || 'NotFound'
1983
+ this.code = typeof error.code === 'number' ? error.code : 8000
1984
+ this.message = error.message || `Resource not found`
1985
+ this.status = typeof error.status === 'number' ? error.status : 400
1986
+ if (error.cause !== undefined) this.cause = error.cause
1987
+ Object.setPrototypeOf(this, NotFoundError.prototype)
1988
+ }
1989
+ }
1990
+
1991
+ export class UnsupportedNetworkError extends WebrpcError {
1992
+ constructor(error: WebrpcErrorParams = {}) {
1993
+ super(error)
1994
+ this.name = error.name || 'UnsupportedNetwork'
1995
+ this.code = typeof error.code === 'number' ? error.code : 8008
1996
+ this.message = error.message || `Unsupported network`
1997
+ this.status = typeof error.status === 'number' ? error.status : 422
1998
+ if (error.cause !== undefined) this.cause = error.cause
1999
+ Object.setPrototypeOf(this, UnsupportedNetworkError.prototype)
2000
+ }
2001
+ }
2002
+
2003
+ export class ClientOutdatedError extends WebrpcError {
2004
+ constructor(error: WebrpcErrorParams = {}) {
2005
+ super(error)
2006
+ this.name = error.name || 'ClientOutdated'
2007
+ this.code = typeof error.code === 'number' ? error.code : 8009
2008
+ this.message = error.message || `Client is outdated`
2009
+ this.status = typeof error.status === 'number' ? error.status : 422
2010
+ if (error.cause !== undefined) this.cause = error.cause
2011
+ Object.setPrototypeOf(this, ClientOutdatedError.prototype)
2012
+ }
2013
+ }
2014
+
2015
+ export class IntentsSkippedError extends WebrpcError {
2016
+ constructor(error: WebrpcErrorParams = {}) {
2017
+ super(error)
2018
+ this.name = error.name || 'IntentsSkipped'
2019
+ this.code = typeof error.code === 'number' ? error.code : 7000
2020
+ this.message = error.message || `Intents skipped as client is attempting a transaction that does not require intents`
2021
+ this.status = typeof error.status === 'number' ? error.status : 400
2022
+ if (error.cause !== undefined) this.cause = error.cause
2023
+ Object.setPrototypeOf(this, IntentsSkippedError.prototype)
2024
+ }
2025
+ }
2026
+
2027
+ export class QuoteExpiredError extends WebrpcError {
2028
+ constructor(error: WebrpcErrorParams = {}) {
2029
+ super(error)
2030
+ this.name = error.name || 'QuoteExpired'
2031
+ this.code = typeof error.code === 'number' ? error.code : 7001
2032
+ this.message = error.message || `Intent quote has expired. Please try again.`
2033
+ this.status = typeof error.status === 'number' ? error.status : 400
2034
+ if (error.cause !== undefined) this.cause = error.cause
2035
+ Object.setPrototypeOf(this, QuoteExpiredError.prototype)
2036
+ }
2037
+ }
2038
+
2039
+ export class IntentsDisabledError extends WebrpcError {
2040
+ constructor(error: WebrpcErrorParams = {}) {
2041
+ super(error)
2042
+ this.name = error.name || 'IntentsDisabled'
2043
+ this.code = typeof error.code === 'number' ? error.code : 9000
2044
+ this.message = error.message || `Intents service is currently unavailable`
2045
+ this.status = typeof error.status === 'number' ? error.status : 400
2046
+ if (error.cause !== undefined) this.cause = error.cause
2047
+ Object.setPrototypeOf(this, IntentsDisabledError.prototype)
2048
+ }
2049
+ }
2050
+
2051
+
2052
+ export enum errors {
2053
+ WebrpcEndpoint = 'WebrpcEndpoint',
2054
+ WebrpcRequestFailed = 'WebrpcRequestFailed',
2055
+ WebrpcBadRoute = 'WebrpcBadRoute',
2056
+ WebrpcBadMethod = 'WebrpcBadMethod',
2057
+ WebrpcBadRequest = 'WebrpcBadRequest',
2058
+ WebrpcBadResponse = 'WebrpcBadResponse',
2059
+ WebrpcServerPanic = 'WebrpcServerPanic',
2060
+ WebrpcInternalError = 'WebrpcInternalError',
2061
+ WebrpcClientAborted = 'WebrpcClientAborted',
2062
+ WebrpcStreamLost = 'WebrpcStreamLost',
2063
+ WebrpcStreamFinished = 'WebrpcStreamFinished',
2064
+ Unauthorized = 'Unauthorized',
2065
+ PermissionDenied = 'PermissionDenied',
2066
+ SessionExpired = 'SessionExpired',
2067
+ MethodNotFound = 'MethodNotFound',
2068
+ RequestConflict = 'RequestConflict',
2069
+ Aborted = 'Aborted',
2070
+ Geoblocked = 'Geoblocked',
2071
+ RateLimited = 'RateLimited',
2072
+ ProjectNotFound = 'ProjectNotFound',
2073
+ AccessKeyNotFound = 'AccessKeyNotFound',
2074
+ AccessKeyMismatch = 'AccessKeyMismatch',
2075
+ InvalidOrigin = 'InvalidOrigin',
2076
+ InvalidService = 'InvalidService',
2077
+ UnauthorizedUser = 'UnauthorizedUser',
2078
+ QuotaExceeded = 'QuotaExceeded',
2079
+ QuotaRateLimit = 'QuotaRateLimit',
2080
+ NoDefaultKey = 'NoDefaultKey',
2081
+ MaxAccessKeys = 'MaxAccessKeys',
2082
+ AtLeastOneKey = 'AtLeastOneKey',
2083
+ Timeout = 'Timeout',
2084
+ InvalidArgument = 'InvalidArgument',
2085
+ Unexpected = 'Unexpected',
2086
+ Unavailable = 'Unavailable',
2087
+ QueryFailed = 'QueryFailed',
2088
+ IntentStatus = 'IntentStatus',
2089
+ NotFound = 'NotFound',
2090
+ UnsupportedNetwork = 'UnsupportedNetwork',
2091
+ ClientOutdated = 'ClientOutdated',
2092
+ IntentsSkipped = 'IntentsSkipped',
2093
+ QuoteExpired = 'QuoteExpired',
2094
+ IntentsDisabled = 'IntentsDisabled',
2095
+ }
2096
+
2097
+ export enum WebrpcErrorCodes {
2098
+ WebrpcEndpoint = 0,
2099
+ WebrpcRequestFailed = -1,
2100
+ WebrpcBadRoute = -2,
2101
+ WebrpcBadMethod = -3,
2102
+ WebrpcBadRequest = -4,
2103
+ WebrpcBadResponse = -5,
2104
+ WebrpcServerPanic = -6,
2105
+ WebrpcInternalError = -7,
2106
+ WebrpcClientAborted = -8,
2107
+ WebrpcStreamLost = -9,
2108
+ WebrpcStreamFinished = -10,
2109
+ Unauthorized = 1000,
2110
+ PermissionDenied = 1001,
2111
+ SessionExpired = 1002,
2112
+ MethodNotFound = 1003,
2113
+ RequestConflict = 1004,
2114
+ Aborted = 1005,
2115
+ Geoblocked = 1006,
2116
+ RateLimited = 1007,
2117
+ ProjectNotFound = 1008,
2118
+ AccessKeyNotFound = 1101,
2119
+ AccessKeyMismatch = 1102,
2120
+ InvalidOrigin = 1103,
2121
+ InvalidService = 1104,
2122
+ UnauthorizedUser = 1105,
2123
+ QuotaExceeded = 1200,
2124
+ QuotaRateLimit = 1201,
2125
+ NoDefaultKey = 1300,
2126
+ MaxAccessKeys = 1301,
2127
+ AtLeastOneKey = 1302,
2128
+ Timeout = 1900,
2129
+ InvalidArgument = 2000,
2130
+ Unexpected = 2001,
2131
+ Unavailable = 2002,
2132
+ QueryFailed = 2003,
2133
+ IntentStatus = 2004,
2134
+ NotFound = 8000,
2135
+ UnsupportedNetwork = 8008,
2136
+ ClientOutdated = 8009,
2137
+ IntentsSkipped = 7000,
2138
+ QuoteExpired = 7001,
2139
+ IntentsDisabled = 9000,
2140
+ }
2141
+
2142
+ export const webrpcErrorByCode: { [code: number]: any } = {
2143
+ [0]: WebrpcEndpointError,
2144
+ [-1]: WebrpcRequestFailedError,
2145
+ [-2]: WebrpcBadRouteError,
2146
+ [-3]: WebrpcBadMethodError,
2147
+ [-4]: WebrpcBadRequestError,
2148
+ [-5]: WebrpcBadResponseError,
2149
+ [-6]: WebrpcServerPanicError,
2150
+ [-7]: WebrpcInternalErrorError,
2151
+ [-8]: WebrpcClientAbortedError,
2152
+ [-9]: WebrpcStreamLostError,
2153
+ [-10]: WebrpcStreamFinishedError,
2154
+ [1000]: UnauthorizedError,
2155
+ [1001]: PermissionDeniedError,
2156
+ [1002]: SessionExpiredError,
2157
+ [1003]: MethodNotFoundError,
2158
+ [1004]: RequestConflictError,
2159
+ [1005]: AbortedError,
2160
+ [1006]: GeoblockedError,
2161
+ [1007]: RateLimitedError,
2162
+ [1008]: ProjectNotFoundError,
2163
+ [1101]: AccessKeyNotFoundError,
2164
+ [1102]: AccessKeyMismatchError,
2165
+ [1103]: InvalidOriginError,
2166
+ [1104]: InvalidServiceError,
2167
+ [1105]: UnauthorizedUserError,
2168
+ [1200]: QuotaExceededError,
2169
+ [1201]: QuotaRateLimitError,
2170
+ [1300]: NoDefaultKeyError,
2171
+ [1301]: MaxAccessKeysError,
2172
+ [1302]: AtLeastOneKeyError,
2173
+ [1900]: TimeoutError,
2174
+ [2000]: InvalidArgumentError,
2175
+ [2001]: UnexpectedError,
2176
+ [2002]: UnavailableError,
2177
+ [2003]: QueryFailedError,
2178
+ [2004]: IntentStatusError,
2179
+ [8000]: NotFoundError,
2180
+ [8008]: UnsupportedNetworkError,
2181
+ [8009]: ClientOutdatedError,
2182
+ [7000]: IntentsSkippedError,
2183
+ [7001]: QuoteExpiredError,
2184
+ [9000]: IntentsDisabledError,
2185
+ }
2186
+
2187
+
2188
+
2189
+ //
2190
+ // Webrpc
2191
+ //
2192
+
2193
+ export const WebrpcHeader = "Webrpc"
2194
+
2195
+ export const WebrpcHeaderValue = "webrpc@v0.32.2;gen-typescript@v0.23.1;trails-api@v1-26.2.10-fcbe559"
2196
+
2197
+ type WebrpcGenVersions = {
2198
+ WebrpcGenVersion: string;
2199
+ codeGenName: string;
2200
+ codeGenVersion: string;
2201
+ schemaName: string;
2202
+ schemaVersion: string;
2203
+ };
2204
+
2205
+ export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
2206
+ const headerValue = headers.get(WebrpcHeader)
2207
+ if (!headerValue) {
2208
+ return {
2209
+ WebrpcGenVersion: "",
2210
+ codeGenName: "",
2211
+ codeGenVersion: "",
2212
+ schemaName: "",
2213
+ schemaVersion: "",
2214
+ };
2215
+ }
2216
+
2217
+ return parseWebrpcGenVersions(headerValue)
2218
+ }
2219
+
2220
+ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
2221
+ const versions = header.split(";")
2222
+ if (versions.length < 3) {
2223
+ return {
2224
+ WebrpcGenVersion: "",
2225
+ codeGenName: "",
2226
+ codeGenVersion: "",
2227
+ schemaName: "",
2228
+ schemaVersion: "",
2229
+ };
2230
+ }
2231
+
2232
+ const [_, WebrpcGenVersion] = versions[0]!.split("@")
2233
+ const [codeGenName, codeGenVersion] = versions[1]!.split("@")
2234
+ const [schemaName, schemaVersion] = versions[2]!.split("@")
2235
+
2236
+ return {
2237
+ WebrpcGenVersion: WebrpcGenVersion ?? "",
2238
+ codeGenName: codeGenName ?? "",
2239
+ codeGenVersion: codeGenVersion ?? "",
2240
+ schemaName: schemaName ?? "",
2241
+ schemaVersion: schemaVersion ?? "",
2242
+ };
2243
+ }
2244
+