@0xtrails/api 0.8.7 → 0.9.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/trails-api.gen.d.ts +77 -28
- package/dist/trails-api.gen.d.ts.map +1 -1
- package/dist/trails-api.gen.js +113 -72
- package/package.json +1 -1
- package/src/trails-api.gen.ts +428 -301
package/src/trails-api.gen.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// trails-api v1-25.12.
|
|
2
|
+
// trails-api v1-25.12.16-ee270e57 cd6fea50d2e26fb661de670279f19010f6a3f14a
|
|
3
3
|
// --
|
|
4
4
|
// Code generated by Webrpc-gen@v0.31.3 with typescript generator. DO NOT EDIT.
|
|
5
5
|
//
|
|
6
6
|
// webrpc-gen -schema=trails-api.ridl -target=typescript -client -service=Trails -methodTreeShake -ignore=@onramp -out=./clients/trails-api.gen.ts
|
|
7
7
|
|
|
8
8
|
// Webrpc description and code-gen version
|
|
9
|
-
export const WebrpcVersion =
|
|
9
|
+
export const WebrpcVersion = 'v1'
|
|
10
10
|
|
|
11
11
|
// Schema version of your RIDL schema
|
|
12
|
-
export const WebrpcSchemaVersion = 'v1-25.12.
|
|
12
|
+
export const WebrpcSchemaVersion = 'v1-25.12.16-ee270e57'
|
|
13
13
|
|
|
14
14
|
// Schema hash generated from your RIDL schema
|
|
15
|
-
export const WebrpcSchemaHash = '
|
|
15
|
+
export const WebrpcSchemaHash = 'cd6fea50d2e26fb661de670279f19010f6a3f14a'
|
|
16
16
|
|
|
17
17
|
//
|
|
18
18
|
// Client interface
|
|
@@ -39,7 +39,7 @@ export interface TrailsClient {
|
|
|
39
39
|
|
|
40
40
|
searchIntents(req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse>
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
getIntentHistory(req: GetIntentHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentHistoryResponse>
|
|
43
43
|
|
|
44
44
|
abortIntent(req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse>
|
|
45
45
|
|
|
@@ -52,34 +52,42 @@ export interface TrailsClient {
|
|
|
52
52
|
* GetExactOutputRoutes will return a list of origin tokens, when given a destination chain and token,
|
|
53
53
|
* that can be used to pay/send from an origin chain the exact output amount on the
|
|
54
54
|
* destination chain.
|
|
55
|
-
*
|
|
55
|
+
*
|
|
56
56
|
* The request will include the destination chain and token desired. Optionally, the
|
|
57
57
|
* user can specify an origin chain and token to filter results to only that specific
|
|
58
58
|
* origin token. Additionally, an optional owner address can be provided to filter
|
|
59
59
|
* results to only tokens the owner has a balance on (requires indexer gateway to be
|
|
60
60
|
* configured).
|
|
61
|
-
*
|
|
61
|
+
*
|
|
62
62
|
* The response is a list of origin tokens and their chains which can be used to fulfill
|
|
63
63
|
* the exact output request. These are tokens the user can send FROM to achieve the desired
|
|
64
64
|
* destination token amount.
|
|
65
|
-
*
|
|
65
|
+
*
|
|
66
66
|
* aka, the 'pay' routes
|
|
67
67
|
*/
|
|
68
|
-
getExactOutputRoutes(
|
|
68
|
+
getExactOutputRoutes(
|
|
69
|
+
req: GetExactOutputRoutesRequest,
|
|
70
|
+
headers?: object,
|
|
71
|
+
signal?: AbortSignal
|
|
72
|
+
): Promise<GetExactOutputRoutesResponse>
|
|
69
73
|
|
|
70
74
|
/**
|
|
71
75
|
* GetExactInputRoutes will return a list of destination tokens, when given an origin chain and token,
|
|
72
76
|
* that can be used to send/swap to a destination chain and token.
|
|
73
|
-
*
|
|
77
|
+
*
|
|
74
78
|
* The request will include the origin chain and token used for input. Optionally, the
|
|
75
79
|
* user can specify a destination chain and token to further filter the results.
|
|
76
|
-
*
|
|
80
|
+
*
|
|
77
81
|
* The response is a list of destination tokens and their chains which can be reached from
|
|
78
82
|
* the origin token and chain. These are tokens the user can send TO from the given origin token.
|
|
79
|
-
*
|
|
83
|
+
*
|
|
80
84
|
* aka, the 'swap' routes
|
|
81
85
|
*/
|
|
82
|
-
getExactInputRoutes(
|
|
86
|
+
getExactInputRoutes(
|
|
87
|
+
req: GetExactInputRoutesRequest,
|
|
88
|
+
headers?: object,
|
|
89
|
+
signal?: AbortSignal
|
|
90
|
+
): Promise<GetExactInputRoutesResponse>
|
|
83
91
|
|
|
84
92
|
/**
|
|
85
93
|
* GetTokenList will return a list of tokens based on the provided filters.
|
|
@@ -96,8 +104,16 @@ export interface TrailsClient {
|
|
|
96
104
|
* GetTrailsContracts returns Trails contract addresses used by the Trails Intents stack.
|
|
97
105
|
*/
|
|
98
106
|
getTrailsContracts(headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse>
|
|
99
|
-
}
|
|
100
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated please use GetIntentHistory instead
|
|
110
|
+
*/
|
|
111
|
+
getIntentTransactionHistory(
|
|
112
|
+
req: GetIntentTransactionHistoryRequest,
|
|
113
|
+
headers?: object,
|
|
114
|
+
signal?: AbortSignal
|
|
115
|
+
): Promise<GetIntentTransactionHistoryResponse>
|
|
116
|
+
}
|
|
101
117
|
|
|
102
118
|
//
|
|
103
119
|
// Schema types
|
|
@@ -256,6 +272,41 @@ export interface MetaTxn {
|
|
|
256
272
|
input: string
|
|
257
273
|
}
|
|
258
274
|
|
|
275
|
+
export interface IntentHistory {
|
|
276
|
+
intentId: string
|
|
277
|
+
status: IntentStatus
|
|
278
|
+
expiresAt: string
|
|
279
|
+
updatedAt?: string
|
|
280
|
+
createdAt?: string
|
|
281
|
+
receipt: IntentReceipt
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface IntentReceiptSummary {
|
|
285
|
+
intentId: string
|
|
286
|
+
status: IntentStatus
|
|
287
|
+
ownerAddress: string
|
|
288
|
+
originChainId: number
|
|
289
|
+
destinationChainId: number
|
|
290
|
+
tradeType: TradeType
|
|
291
|
+
routeProviders: Array<RouteProvider>
|
|
292
|
+
originIntentAddress: string
|
|
293
|
+
originTokenAddress: string
|
|
294
|
+
originTokenAmount: bigint
|
|
295
|
+
originTokenMetadata: TokenMetadata
|
|
296
|
+
destinationIntentAddress: string
|
|
297
|
+
destinationTokenAddress?: string
|
|
298
|
+
destinationTokenAmount?: bigint
|
|
299
|
+
destinationToAddress?: string
|
|
300
|
+
destinationTokenMetadata: TokenMetadata
|
|
301
|
+
destinationHasCallData: boolean
|
|
302
|
+
destinationHasCallValue: boolean
|
|
303
|
+
memo?: string
|
|
304
|
+
createdAt: string
|
|
305
|
+
expiresAt: string
|
|
306
|
+
startedAt?: string
|
|
307
|
+
finishedAt?: string
|
|
308
|
+
}
|
|
309
|
+
|
|
259
310
|
export interface IntentReceipt {
|
|
260
311
|
intentId: string
|
|
261
312
|
status: IntentStatus
|
|
@@ -265,12 +316,15 @@ export interface IntentReceipt {
|
|
|
265
316
|
depositTransaction: IntentTransaction
|
|
266
317
|
originTransaction: IntentTransaction
|
|
267
318
|
destinationTransaction?: IntentTransaction
|
|
319
|
+
summary: IntentReceiptSummary
|
|
268
320
|
updatedAt?: string
|
|
269
321
|
createdAt?: string
|
|
270
322
|
}
|
|
271
323
|
|
|
272
324
|
export interface IntentTransaction {
|
|
273
325
|
intentId: string
|
|
326
|
+
status: TransactionStatus
|
|
327
|
+
statusReason?: string
|
|
274
328
|
chainId: number
|
|
275
329
|
type: TransactionType
|
|
276
330
|
context: TransactionContext
|
|
@@ -284,8 +338,6 @@ export interface IntentTransaction {
|
|
|
284
338
|
depositIntentEntry?: DepositIntentEntry
|
|
285
339
|
txnHash?: string
|
|
286
340
|
txnMinedAt?: string
|
|
287
|
-
status: TransactionStatus
|
|
288
|
-
statusReason?: string
|
|
289
341
|
updatedAt?: string
|
|
290
342
|
createdAt?: string
|
|
291
343
|
}
|
|
@@ -327,25 +379,6 @@ export interface IntentProviderFees {
|
|
|
327
379
|
totalFeeUsd: number
|
|
328
380
|
}
|
|
329
381
|
|
|
330
|
-
export interface IntentTransactionGasFee {
|
|
331
|
-
chainId: number
|
|
332
|
-
totalGasLimit: bigint
|
|
333
|
-
gasPrice: bigint
|
|
334
|
-
nativeTokenSymbol: string
|
|
335
|
-
nativeTokenPriceUsd?: number
|
|
336
|
-
chainGasUsageStatus: ChainGasUsageStatus
|
|
337
|
-
totalFeeAmount: bigint
|
|
338
|
-
totalFeeUsd: string
|
|
339
|
-
metaTxnFeeDetails: MetaTxnFeeDetails
|
|
340
|
-
metaTxnGasQuote: string
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export interface MetaTxnFeeDetails {
|
|
344
|
-
metaTxnId: string
|
|
345
|
-
estimatedGasLimit: bigint
|
|
346
|
-
feeNative: bigint
|
|
347
|
-
}
|
|
348
|
-
|
|
349
382
|
export interface IntentSummary {
|
|
350
383
|
intentId: string
|
|
351
384
|
status: IntentStatus
|
|
@@ -372,6 +405,25 @@ export interface IntentSummary {
|
|
|
372
405
|
createdAt: string
|
|
373
406
|
}
|
|
374
407
|
|
|
408
|
+
export interface IntentTransactionGasFee {
|
|
409
|
+
chainId: number
|
|
410
|
+
totalGasLimit: bigint
|
|
411
|
+
gasPrice: bigint
|
|
412
|
+
nativeTokenSymbol: string
|
|
413
|
+
nativeTokenPriceUsd?: number
|
|
414
|
+
chainGasUsageStatus: ChainGasUsageStatus
|
|
415
|
+
totalFeeAmount: bigint
|
|
416
|
+
totalFeeUsd: string
|
|
417
|
+
metaTxnFeeDetails: MetaTxnFeeDetails
|
|
418
|
+
metaTxnGasQuote: string
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export interface MetaTxnFeeDetails {
|
|
422
|
+
metaTxnId: string
|
|
423
|
+
estimatedGasLimit: bigint
|
|
424
|
+
feeNative: bigint
|
|
425
|
+
}
|
|
426
|
+
|
|
375
427
|
export interface ChainMetadata {
|
|
376
428
|
chainId: number
|
|
377
429
|
name: string
|
|
@@ -610,14 +662,14 @@ export interface SearchIntentsResponse {
|
|
|
610
662
|
intents: Array<Intent>
|
|
611
663
|
}
|
|
612
664
|
|
|
613
|
-
export interface
|
|
665
|
+
export interface GetIntentHistoryRequest {
|
|
614
666
|
page?: Page
|
|
615
667
|
byProjectId?: number
|
|
616
668
|
byOwnerAddress?: string
|
|
617
669
|
}
|
|
618
670
|
|
|
619
|
-
export interface
|
|
620
|
-
intents: Array<
|
|
671
|
+
export interface GetIntentHistoryResponse {
|
|
672
|
+
intents: Array<IntentHistory>
|
|
621
673
|
nextPage?: Page
|
|
622
674
|
}
|
|
623
675
|
|
|
@@ -699,50 +751,41 @@ export interface SortBy {
|
|
|
699
751
|
order: SortOrder
|
|
700
752
|
}
|
|
701
753
|
|
|
702
|
-
export interface
|
|
754
|
+
export interface GetIntentTransactionHistoryRequest {
|
|
755
|
+
page?: Page
|
|
756
|
+
byProjectId?: number
|
|
757
|
+
byOwnerAddress?: string
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export interface GetIntentTransactionHistoryResponse {
|
|
761
|
+
intents: Array<IntentSummary>
|
|
762
|
+
nextPage?: Page
|
|
703
763
|
}
|
|
704
764
|
|
|
765
|
+
export interface PingRequest {}
|
|
766
|
+
|
|
705
767
|
export interface PingResponse {
|
|
706
768
|
version: string
|
|
707
769
|
}
|
|
708
770
|
|
|
709
|
-
export interface RuntimeStatusRequest {
|
|
710
|
-
}
|
|
771
|
+
export interface RuntimeStatusRequest {}
|
|
711
772
|
|
|
712
773
|
export interface RuntimeStatusResponse {
|
|
713
774
|
status: RuntimeStatus
|
|
714
775
|
}
|
|
715
776
|
|
|
716
|
-
export interface ClockRequest {
|
|
717
|
-
}
|
|
777
|
+
export interface ClockRequest {}
|
|
718
778
|
|
|
719
779
|
export interface ClockResponse {
|
|
720
780
|
serverTime: string
|
|
721
781
|
}
|
|
722
782
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
export interface GetTrailsContractsRequest {
|
|
738
|
-
}
|
|
783
|
+
export interface GetTrailsContractsRequest {}
|
|
739
784
|
|
|
740
785
|
export interface GetTrailsContractsResponse {
|
|
741
786
|
TrailsContracts: TrailsContracts
|
|
742
787
|
}
|
|
743
788
|
|
|
744
|
-
|
|
745
|
-
|
|
746
789
|
//
|
|
747
790
|
// Client
|
|
748
791
|
//
|
|
@@ -760,7 +803,7 @@ export class Trails implements TrailsClient {
|
|
|
760
803
|
private url(name: string): string {
|
|
761
804
|
return this.hostname + this.path + name
|
|
762
805
|
}
|
|
763
|
-
|
|
806
|
+
|
|
764
807
|
queryKey = {
|
|
765
808
|
ping: () => ['Trails', 'ping'] as const,
|
|
766
809
|
runtimeStatus: () => ['Trails', 'runtimeStatus'] as const,
|
|
@@ -772,7 +815,7 @@ export class Trails implements TrailsClient {
|
|
|
772
815
|
getIntentReceipt: (req: GetIntentReceiptRequest) => ['Trails', 'getIntentReceipt', req] as const,
|
|
773
816
|
getIntent: (req: GetIntentRequest) => ['Trails', 'getIntent', req] as const,
|
|
774
817
|
searchIntents: (req: SearchIntentsRequest) => ['Trails', 'searchIntents', req] as const,
|
|
775
|
-
|
|
818
|
+
getIntentHistory: (req: GetIntentHistoryRequest) => ['Trails', 'getIntentHistory', req] as const,
|
|
776
819
|
abortIntent: (req: AbortIntentRequest) => ['Trails', 'abortIntent', req] as const,
|
|
777
820
|
getChains: (req: GetChainsRequest) => ['Trails', 'getChains', req] as const,
|
|
778
821
|
getExactOutputRoutes: (req: GetExactOutputRoutesRequest) => ['Trails', 'getExactOutputRoutes', req] as const,
|
|
@@ -780,228 +823,288 @@ export class Trails implements TrailsClient {
|
|
|
780
823
|
getTokenList: (req: GetTokenListRequest) => ['Trails', 'getTokenList', req] as const,
|
|
781
824
|
getTokenPrices: (req: GetTokenPricesRequest) => ['Trails', 'getTokenPrices', req] as const,
|
|
782
825
|
getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const,
|
|
826
|
+
getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) =>
|
|
827
|
+
['Trails', 'getIntentTransactionHistory', req] as const
|
|
783
828
|
}
|
|
784
829
|
|
|
785
830
|
ping = (headers?: object, signal?: AbortSignal): Promise<PingResponse> => {
|
|
786
|
-
return this.fetch(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
831
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(
|
|
832
|
+
res => {
|
|
833
|
+
return buildResponse(res).then(_data => {
|
|
834
|
+
return JsonDecode<PingResponse>(_data, 'PingResponse')
|
|
835
|
+
})
|
|
836
|
+
},
|
|
837
|
+
error => {
|
|
838
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
839
|
+
}
|
|
840
|
+
)
|
|
795
841
|
}
|
|
796
842
|
|
|
797
843
|
runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse> => {
|
|
798
|
-
return this.fetch(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
844
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(
|
|
845
|
+
res => {
|
|
846
|
+
return buildResponse(res).then(_data => {
|
|
847
|
+
return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
|
|
848
|
+
})
|
|
849
|
+
},
|
|
850
|
+
error => {
|
|
851
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
852
|
+
}
|
|
853
|
+
)
|
|
807
854
|
}
|
|
808
855
|
|
|
809
856
|
clock = (headers?: object, signal?: AbortSignal): Promise<ClockResponse> => {
|
|
810
|
-
return this.fetch(
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
857
|
+
return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then(
|
|
858
|
+
res => {
|
|
859
|
+
return buildResponse(res).then(_data => {
|
|
860
|
+
return JsonDecode<ClockResponse>(_data, 'ClockResponse')
|
|
861
|
+
})
|
|
862
|
+
},
|
|
863
|
+
error => {
|
|
864
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
865
|
+
}
|
|
866
|
+
)
|
|
819
867
|
}
|
|
820
868
|
|
|
821
869
|
quoteIntent = (req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse> => {
|
|
822
|
-
return this.fetch(
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
870
|
+
return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
871
|
+
res => {
|
|
872
|
+
return buildResponse(res).then(_data => {
|
|
873
|
+
return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
|
|
874
|
+
})
|
|
875
|
+
},
|
|
876
|
+
error => {
|
|
877
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
878
|
+
}
|
|
879
|
+
)
|
|
831
880
|
}
|
|
832
881
|
|
|
833
882
|
commitIntent = (req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse> => {
|
|
834
|
-
return this.fetch(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
883
|
+
return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
884
|
+
res => {
|
|
885
|
+
return buildResponse(res).then(_data => {
|
|
886
|
+
return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
|
|
887
|
+
})
|
|
888
|
+
},
|
|
889
|
+
error => {
|
|
890
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
891
|
+
}
|
|
892
|
+
)
|
|
843
893
|
}
|
|
844
894
|
|
|
845
895
|
executeIntent = (req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse> => {
|
|
846
|
-
return this.fetch(
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
896
|
+
return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
897
|
+
res => {
|
|
898
|
+
return buildResponse(res).then(_data => {
|
|
899
|
+
return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
|
|
900
|
+
})
|
|
901
|
+
},
|
|
902
|
+
error => {
|
|
903
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
904
|
+
}
|
|
905
|
+
)
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
waitIntentReceipt = (
|
|
909
|
+
req: WaitIntentReceiptRequest,
|
|
910
|
+
headers?: object,
|
|
911
|
+
signal?: AbortSignal
|
|
912
|
+
): Promise<WaitIntentReceiptResponse> => {
|
|
913
|
+
return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
914
|
+
res => {
|
|
915
|
+
return buildResponse(res).then(_data => {
|
|
916
|
+
return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
|
|
917
|
+
})
|
|
918
|
+
},
|
|
919
|
+
error => {
|
|
920
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
921
|
+
}
|
|
922
|
+
)
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
getIntentReceipt = (
|
|
926
|
+
req: GetIntentReceiptRequest,
|
|
927
|
+
headers?: object,
|
|
928
|
+
signal?: AbortSignal
|
|
929
|
+
): Promise<GetIntentReceiptResponse> => {
|
|
930
|
+
return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
931
|
+
res => {
|
|
932
|
+
return buildResponse(res).then(_data => {
|
|
933
|
+
return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
|
|
934
|
+
})
|
|
935
|
+
},
|
|
936
|
+
error => {
|
|
937
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
938
|
+
}
|
|
939
|
+
)
|
|
879
940
|
}
|
|
880
941
|
|
|
881
942
|
getIntent = (req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse> => {
|
|
882
|
-
return this.fetch(
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
943
|
+
return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
944
|
+
res => {
|
|
945
|
+
return buildResponse(res).then(_data => {
|
|
946
|
+
return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
|
|
947
|
+
})
|
|
948
|
+
},
|
|
949
|
+
error => {
|
|
950
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
951
|
+
}
|
|
952
|
+
)
|
|
891
953
|
}
|
|
892
954
|
|
|
893
955
|
searchIntents = (req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse> => {
|
|
894
|
-
return this.fetch(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
956
|
+
return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
957
|
+
res => {
|
|
958
|
+
return buildResponse(res).then(_data => {
|
|
959
|
+
return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
|
|
960
|
+
})
|
|
961
|
+
},
|
|
962
|
+
error => {
|
|
963
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
getIntentHistory = (
|
|
969
|
+
req: GetIntentHistoryRequest,
|
|
970
|
+
headers?: object,
|
|
971
|
+
signal?: AbortSignal
|
|
972
|
+
): Promise<GetIntentHistoryResponse> => {
|
|
973
|
+
return this.fetch(this.url('GetIntentHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
974
|
+
res => {
|
|
975
|
+
return buildResponse(res).then(_data => {
|
|
976
|
+
return JsonDecode<GetIntentHistoryResponse>(_data, 'GetIntentHistoryResponse')
|
|
977
|
+
})
|
|
978
|
+
},
|
|
979
|
+
error => {
|
|
980
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
981
|
+
}
|
|
982
|
+
)
|
|
915
983
|
}
|
|
916
984
|
|
|
917
985
|
abortIntent = (req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse> => {
|
|
918
|
-
return this.fetch(
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
986
|
+
return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
987
|
+
res => {
|
|
988
|
+
return buildResponse(res).then(_data => {
|
|
989
|
+
return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
|
|
990
|
+
})
|
|
991
|
+
},
|
|
992
|
+
error => {
|
|
993
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
994
|
+
}
|
|
995
|
+
)
|
|
927
996
|
}
|
|
928
997
|
|
|
929
998
|
getChains = (req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse> => {
|
|
930
|
-
return this.fetch(
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
999
|
+
return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1000
|
+
res => {
|
|
1001
|
+
return buildResponse(res).then(_data => {
|
|
1002
|
+
return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
|
|
1003
|
+
})
|
|
1004
|
+
},
|
|
1005
|
+
error => {
|
|
1006
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1007
|
+
}
|
|
1008
|
+
)
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
getExactOutputRoutes = (
|
|
1012
|
+
req: GetExactOutputRoutesRequest,
|
|
1013
|
+
headers?: object,
|
|
1014
|
+
signal?: AbortSignal
|
|
1015
|
+
): Promise<GetExactOutputRoutesResponse> => {
|
|
1016
|
+
return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1017
|
+
res => {
|
|
1018
|
+
return buildResponse(res).then(_data => {
|
|
1019
|
+
return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
|
|
1020
|
+
})
|
|
1021
|
+
},
|
|
1022
|
+
error => {
|
|
1023
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1024
|
+
}
|
|
1025
|
+
)
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
getExactInputRoutes = (
|
|
1029
|
+
req: GetExactInputRoutesRequest,
|
|
1030
|
+
headers?: object,
|
|
1031
|
+
signal?: AbortSignal
|
|
1032
|
+
): Promise<GetExactInputRoutesResponse> => {
|
|
1033
|
+
return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1034
|
+
res => {
|
|
1035
|
+
return buildResponse(res).then(_data => {
|
|
1036
|
+
return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
|
|
1037
|
+
})
|
|
1038
|
+
},
|
|
1039
|
+
error => {
|
|
1040
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1041
|
+
}
|
|
1042
|
+
)
|
|
963
1043
|
}
|
|
964
1044
|
|
|
965
1045
|
getTokenList = (req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse> => {
|
|
966
|
-
return this.fetch(
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1046
|
+
return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1047
|
+
res => {
|
|
1048
|
+
return buildResponse(res).then(_data => {
|
|
1049
|
+
return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
|
|
1050
|
+
})
|
|
1051
|
+
},
|
|
1052
|
+
error => {
|
|
1053
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
975
1056
|
}
|
|
976
1057
|
|
|
977
1058
|
getTokenPrices = (req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse> => {
|
|
978
|
-
return this.fetch(
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1059
|
+
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1060
|
+
res => {
|
|
1061
|
+
return buildResponse(res).then(_data => {
|
|
1062
|
+
return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
|
|
1063
|
+
})
|
|
1064
|
+
},
|
|
1065
|
+
error => {
|
|
1066
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1067
|
+
}
|
|
1068
|
+
)
|
|
987
1069
|
}
|
|
988
1070
|
|
|
989
1071
|
getTrailsContracts = (headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse> => {
|
|
990
|
-
return this.fetch(
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1072
|
+
return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then(
|
|
1073
|
+
res => {
|
|
1074
|
+
return buildResponse(res).then(_data => {
|
|
1075
|
+
return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
|
|
1076
|
+
})
|
|
1077
|
+
},
|
|
1078
|
+
error => {
|
|
1079
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1080
|
+
}
|
|
1081
|
+
)
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
getIntentTransactionHistory = (
|
|
1085
|
+
req: GetIntentTransactionHistoryRequest,
|
|
1086
|
+
headers?: object,
|
|
1087
|
+
signal?: AbortSignal
|
|
1088
|
+
): Promise<GetIntentTransactionHistoryResponse> => {
|
|
1089
|
+
return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1090
|
+
res => {
|
|
1091
|
+
return buildResponse(res).then(_data => {
|
|
1092
|
+
return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
|
|
1093
|
+
})
|
|
1094
|
+
},
|
|
1095
|
+
error => {
|
|
1096
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
999
1099
|
}
|
|
1000
|
-
|
|
1001
1100
|
}
|
|
1002
1101
|
|
|
1003
1102
|
const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
|
|
1004
|
-
const reqHeaders: { [key: string]: string } = {
|
|
1103
|
+
const reqHeaders: { [key: string]: string } = {
|
|
1104
|
+
...headers,
|
|
1105
|
+
'Content-Type': 'application/json',
|
|
1106
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
1107
|
+
}
|
|
1005
1108
|
return { method: 'POST', headers: reqHeaders, body, signal }
|
|
1006
1109
|
}
|
|
1007
1110
|
|
|
@@ -1010,14 +1113,14 @@ const buildResponse = (res: Response): Promise<any> => {
|
|
|
1010
1113
|
let data
|
|
1011
1114
|
try {
|
|
1012
1115
|
data = JSON.parse(text)
|
|
1013
|
-
} catch(error) {
|
|
1116
|
+
} catch (error) {
|
|
1014
1117
|
throw WebrpcBadResponseError.new({
|
|
1015
1118
|
status: res.status,
|
|
1016
|
-
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
1017
|
-
)
|
|
1119
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
1120
|
+
})
|
|
1018
1121
|
}
|
|
1019
1122
|
if (!res.ok) {
|
|
1020
|
-
const code: number =
|
|
1123
|
+
const code: number = typeof data.code === 'number' ? data.code : 0
|
|
1021
1124
|
throw (webrpcErrorByCode[code] || WebrpcError).new(data)
|
|
1022
1125
|
}
|
|
1023
1126
|
return data
|
|
@@ -1026,10 +1129,6 @@ const buildResponse = (res: Response): Promise<any> => {
|
|
|
1026
1129
|
|
|
1027
1130
|
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
1028
1131
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
1132
|
//
|
|
1034
1133
|
// BigInt helpers
|
|
1035
1134
|
//
|
|
@@ -1042,21 +1141,48 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
|
|
|
1042
1141
|
ExecuteIntentRequest: [['depositSignature', 'DepositSignature']],
|
|
1043
1142
|
FeeOption: ['amount'],
|
|
1044
1143
|
GasFeeOptions: [['feeOptions', 'FeeOption[]']],
|
|
1144
|
+
GetIntentHistoryResponse: [['intents', 'IntentHistory[]']],
|
|
1045
1145
|
GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
|
|
1046
1146
|
GetIntentResponse: [['intent', 'Intent']],
|
|
1047
1147
|
GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
|
|
1048
|
-
Intent: [
|
|
1148
|
+
Intent: [
|
|
1149
|
+
['quoteRequest', 'QuoteIntentRequest'],
|
|
1150
|
+
'salt',
|
|
1151
|
+
['depositTransaction', 'DepositTransaction'],
|
|
1152
|
+
['originCalls', 'IntentCalls'],
|
|
1153
|
+
['destinationCalls', 'IntentCalls'],
|
|
1154
|
+
['originPrecondition', 'TransactionPrecondition'],
|
|
1155
|
+
['destinationPrecondition', 'TransactionPrecondition'],
|
|
1156
|
+
['quote', 'IntentProviderQuote'],
|
|
1157
|
+
['fees', 'IntentFees']
|
|
1158
|
+
],
|
|
1049
1159
|
IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
|
|
1050
|
-
IntentFees: [
|
|
1160
|
+
IntentFees: [
|
|
1161
|
+
['originGas', 'IntentTransactionGasFee'],
|
|
1162
|
+
['destinationGas', 'IntentTransactionGasFee'],
|
|
1163
|
+
['provider', 'IntentProviderFees'],
|
|
1164
|
+
'feeTokenTotal',
|
|
1165
|
+
'totalFeeAmount'
|
|
1166
|
+
],
|
|
1167
|
+
IntentHistory: [['receipt', 'IntentReceipt']],
|
|
1051
1168
|
IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'totalFeeAmount'],
|
|
1052
1169
|
IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
|
|
1053
|
-
IntentReceipt: [
|
|
1170
|
+
IntentReceipt: [
|
|
1171
|
+
['depositTransaction', 'IntentTransaction'],
|
|
1172
|
+
['originTransaction', 'IntentTransaction'],
|
|
1173
|
+
['destinationTransaction', 'IntentTransaction'],
|
|
1174
|
+
['summary', 'IntentReceiptSummary']
|
|
1175
|
+
],
|
|
1176
|
+
IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
1054
1177
|
IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
1055
1178
|
IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
|
|
1056
1179
|
IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
|
|
1057
1180
|
MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
|
|
1058
1181
|
QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
|
|
1059
|
-
QuoteIntentResponse: [
|
|
1182
|
+
QuoteIntentResponse: [
|
|
1183
|
+
['intent', 'Intent'],
|
|
1184
|
+
['gasFeeOptions', 'GasFeeOptions']
|
|
1185
|
+
],
|
|
1060
1186
|
SearchIntentsResponse: [['intents', 'Intent[]']],
|
|
1061
1187
|
TransactionCall: ['value', 'gasLimit'],
|
|
1062
1188
|
TransactionPrecondition: ['minAmount'],
|
|
@@ -1098,7 +1224,11 @@ function decodeType(typ: string, obj: any): any {
|
|
|
1098
1224
|
for (let i = 0; i < arr.length; i++) {
|
|
1099
1225
|
const v = arr[i]
|
|
1100
1226
|
if (typeof v === 'string') {
|
|
1101
|
-
try {
|
|
1227
|
+
try {
|
|
1228
|
+
arr[i] = BigInt(v)
|
|
1229
|
+
} catch (e) {
|
|
1230
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` })
|
|
1231
|
+
}
|
|
1102
1232
|
}
|
|
1103
1233
|
}
|
|
1104
1234
|
}
|
|
@@ -1106,7 +1236,11 @@ function decodeType(typ: string, obj: any): any {
|
|
|
1106
1236
|
}
|
|
1107
1237
|
const v = obj[d]
|
|
1108
1238
|
if (typeof v === 'string') {
|
|
1109
|
-
try {
|
|
1239
|
+
try {
|
|
1240
|
+
obj[d] = BigInt(v)
|
|
1241
|
+
} catch (e) {
|
|
1242
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` })
|
|
1243
|
+
}
|
|
1110
1244
|
}
|
|
1111
1245
|
}
|
|
1112
1246
|
return obj
|
|
@@ -1114,28 +1248,27 @@ function decodeType(typ: string, obj: any): any {
|
|
|
1114
1248
|
|
|
1115
1249
|
// Encode object to JSON with BigInts converted to decimal strings.
|
|
1116
1250
|
export const JsonEncode = <T = any>(obj: T): string => {
|
|
1117
|
-
return JSON.stringify(obj, (key, value) =>
|
|
1118
|
-
typeof value === 'bigint' ? value.toString() : value
|
|
1119
|
-
)
|
|
1251
|
+
return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
|
|
1120
1252
|
}
|
|
1121
1253
|
|
|
1122
1254
|
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
1123
1255
|
export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
|
|
1124
1256
|
let parsed: any = data
|
|
1125
1257
|
if (typeof data === 'string') {
|
|
1126
|
-
try {
|
|
1258
|
+
try {
|
|
1259
|
+
parsed = JSON.parse(data)
|
|
1260
|
+
} catch (err) {
|
|
1127
1261
|
throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
|
|
1128
1262
|
}
|
|
1129
1263
|
}
|
|
1130
1264
|
return decodeType(typ, parsed) as T
|
|
1131
1265
|
}
|
|
1132
1266
|
|
|
1133
|
-
|
|
1134
1267
|
//
|
|
1135
1268
|
// Errors
|
|
1136
1269
|
//
|
|
1137
1270
|
|
|
1138
|
-
type WebrpcErrorParams = { name?: string
|
|
1271
|
+
type WebrpcErrorParams = { name?: string; code?: number; message?: string; status?: number; cause?: string }
|
|
1139
1272
|
|
|
1140
1273
|
export class WebrpcError extends Error {
|
|
1141
1274
|
code: number
|
|
@@ -1156,7 +1289,6 @@ export class WebrpcError extends Error {
|
|
|
1156
1289
|
}
|
|
1157
1290
|
}
|
|
1158
1291
|
|
|
1159
|
-
|
|
1160
1292
|
export class WebrpcEndpointError extends WebrpcError {
|
|
1161
1293
|
constructor(error: WebrpcErrorParams = {}) {
|
|
1162
1294
|
super(error)
|
|
@@ -1289,7 +1421,6 @@ export class WebrpcStreamFinishedError extends WebrpcError {
|
|
|
1289
1421
|
}
|
|
1290
1422
|
}
|
|
1291
1423
|
|
|
1292
|
-
|
|
1293
1424
|
//
|
|
1294
1425
|
// Schema errors
|
|
1295
1426
|
//
|
|
@@ -1666,7 +1797,6 @@ export class IntentsDisabledError extends WebrpcError {
|
|
|
1666
1797
|
}
|
|
1667
1798
|
}
|
|
1668
1799
|
|
|
1669
|
-
|
|
1670
1800
|
export enum errors {
|
|
1671
1801
|
WebrpcEndpoint = 'WebrpcEndpoint',
|
|
1672
1802
|
WebrpcRequestFailed = 'WebrpcRequestFailed',
|
|
@@ -1709,7 +1839,7 @@ export enum errors {
|
|
|
1709
1839
|
ClientOutdated = 'ClientOutdated',
|
|
1710
1840
|
IntentsSkipped = 'IntentsSkipped',
|
|
1711
1841
|
QuoteExpired = 'QuoteExpired',
|
|
1712
|
-
IntentsDisabled = 'IntentsDisabled'
|
|
1842
|
+
IntentsDisabled = 'IntentsDisabled'
|
|
1713
1843
|
}
|
|
1714
1844
|
|
|
1715
1845
|
export enum WebrpcErrorCodes {
|
|
@@ -1754,7 +1884,7 @@ export enum WebrpcErrorCodes {
|
|
|
1754
1884
|
ClientOutdated = 8009,
|
|
1755
1885
|
IntentsSkipped = 7000,
|
|
1756
1886
|
QuoteExpired = 7001,
|
|
1757
|
-
IntentsDisabled = 9000
|
|
1887
|
+
IntentsDisabled = 9000
|
|
1758
1888
|
}
|
|
1759
1889
|
|
|
1760
1890
|
export const webrpcErrorByCode: { [code: number]: any } = {
|
|
@@ -1799,64 +1929,61 @@ export const webrpcErrorByCode: { [code: number]: any } = {
|
|
|
1799
1929
|
[8009]: ClientOutdatedError,
|
|
1800
1930
|
[7000]: IntentsSkippedError,
|
|
1801
1931
|
[7001]: QuoteExpiredError,
|
|
1802
|
-
[9000]: IntentsDisabledError
|
|
1932
|
+
[9000]: IntentsDisabledError
|
|
1803
1933
|
}
|
|
1804
1934
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
1935
|
//
|
|
1808
1936
|
// Webrpc
|
|
1809
1937
|
//
|
|
1810
1938
|
|
|
1811
|
-
export const WebrpcHeader =
|
|
1939
|
+
export const WebrpcHeader = 'Webrpc'
|
|
1812
1940
|
|
|
1813
|
-
export const WebrpcHeaderValue = 'webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.
|
|
1941
|
+
export const WebrpcHeaderValue = 'webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.16-ee270e57'
|
|
1814
1942
|
|
|
1815
1943
|
type WebrpcGenVersions = {
|
|
1816
|
-
WebrpcGenVersion: string
|
|
1817
|
-
codeGenName: string
|
|
1818
|
-
codeGenVersion: string
|
|
1819
|
-
schemaName: string
|
|
1820
|
-
schemaVersion: string
|
|
1821
|
-
}
|
|
1944
|
+
WebrpcGenVersion: string
|
|
1945
|
+
codeGenName: string
|
|
1946
|
+
codeGenVersion: string
|
|
1947
|
+
schemaName: string
|
|
1948
|
+
schemaVersion: string
|
|
1949
|
+
}
|
|
1822
1950
|
|
|
1823
1951
|
export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
|
|
1824
1952
|
const headerValue = headers.get(WebrpcHeader)
|
|
1825
1953
|
if (!headerValue) {
|
|
1826
1954
|
return {
|
|
1827
|
-
WebrpcGenVersion:
|
|
1828
|
-
codeGenName:
|
|
1829
|
-
codeGenVersion:
|
|
1830
|
-
schemaName:
|
|
1831
|
-
schemaVersion:
|
|
1832
|
-
}
|
|
1955
|
+
WebrpcGenVersion: '',
|
|
1956
|
+
codeGenName: '',
|
|
1957
|
+
codeGenVersion: '',
|
|
1958
|
+
schemaName: '',
|
|
1959
|
+
schemaVersion: ''
|
|
1960
|
+
}
|
|
1833
1961
|
}
|
|
1834
1962
|
|
|
1835
1963
|
return parseWebrpcGenVersions(headerValue)
|
|
1836
1964
|
}
|
|
1837
1965
|
|
|
1838
1966
|
function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
|
|
1839
|
-
const versions = header.split(
|
|
1967
|
+
const versions = header.split(';')
|
|
1840
1968
|
if (versions.length < 3) {
|
|
1841
1969
|
return {
|
|
1842
|
-
WebrpcGenVersion:
|
|
1843
|
-
codeGenName:
|
|
1844
|
-
codeGenVersion:
|
|
1845
|
-
schemaName:
|
|
1846
|
-
schemaVersion:
|
|
1847
|
-
}
|
|
1970
|
+
WebrpcGenVersion: '',
|
|
1971
|
+
codeGenName: '',
|
|
1972
|
+
codeGenVersion: '',
|
|
1973
|
+
schemaName: '',
|
|
1974
|
+
schemaVersion: ''
|
|
1975
|
+
}
|
|
1848
1976
|
}
|
|
1849
1977
|
|
|
1850
|
-
const [_, WebrpcGenVersion] = versions[0]!.split(
|
|
1851
|
-
const [codeGenName, codeGenVersion] = versions[1]!.split(
|
|
1852
|
-
const [schemaName, schemaVersion] = versions[2]!.split(
|
|
1978
|
+
const [_, WebrpcGenVersion] = versions[0]!.split('@')
|
|
1979
|
+
const [codeGenName, codeGenVersion] = versions[1]!.split('@')
|
|
1980
|
+
const [schemaName, schemaVersion] = versions[2]!.split('@')
|
|
1853
1981
|
|
|
1854
1982
|
return {
|
|
1855
|
-
WebrpcGenVersion: WebrpcGenVersion ??
|
|
1856
|
-
codeGenName: codeGenName ??
|
|
1857
|
-
codeGenVersion: codeGenVersion ??
|
|
1858
|
-
schemaName: schemaName ??
|
|
1859
|
-
schemaVersion: schemaVersion ??
|
|
1860
|
-
}
|
|
1983
|
+
WebrpcGenVersion: WebrpcGenVersion ?? '',
|
|
1984
|
+
codeGenName: codeGenName ?? '',
|
|
1985
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
1986
|
+
schemaName: schemaName ?? '',
|
|
1987
|
+
schemaVersion: schemaVersion ?? ''
|
|
1988
|
+
}
|
|
1861
1989
|
}
|
|
1862
|
-
|