@0xtrails/api 0.9.3 → 0.10.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 +2 -2
- package/.turbo/turbo-typecheck.log +2 -2
- package/CHANGELOG.md +49 -0
- package/dist/trails-api.gen.d.ts +163 -4
- package/dist/trails-api.gen.d.ts.map +1 -1
- package/dist/trails-api.gen.js +170 -74
- package/dist/trails-onramp.gen.d.ts +529 -0
- package/dist/trails-onramp.gen.d.ts.map +1 -0
- package/dist/trails-onramp.gen.js +887 -0
- package/package.json +1 -1
- package/src/trails-api.gen.ts +584 -288
- package/src/trails-onramp.gen.ts +1261 -0
package/src/trails-api.gen.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// trails-api v1
|
|
2
|
+
// trails-api v1 9923827ab0683bd37e4aa9e713fa728b4c930297
|
|
3
3
|
// --
|
|
4
|
-
// Code generated by Webrpc-gen@v0.
|
|
4
|
+
// Code generated by Webrpc-gen@v0.32.2 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 =
|
|
12
|
+
export const WebrpcSchemaVersion = 'v1'
|
|
13
13
|
|
|
14
14
|
// Schema hash generated from your RIDL schema
|
|
15
|
-
export const WebrpcSchemaHash =
|
|
15
|
+
export const WebrpcSchemaHash = '9923827ab0683bd37e4aa9e713fa728b4c930297'
|
|
16
16
|
|
|
17
17
|
//
|
|
18
18
|
// Client interface
|
|
@@ -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.
|
|
@@ -92,18 +100,42 @@ export interface TrailsClient {
|
|
|
92
100
|
*/
|
|
93
101
|
getTokenPrices(req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse>
|
|
94
102
|
|
|
103
|
+
/**
|
|
104
|
+
* GetExchangeRate returns the exchange rate from USD to a specified currency.
|
|
105
|
+
*/
|
|
106
|
+
getExchangeRate(req: GetExchangeRateRequest, headers?: object, signal?: AbortSignal): Promise<GetExchangeRateResponse>
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* GetCountryList returns the list of supported countries for onramp providers.
|
|
110
|
+
*/
|
|
111
|
+
getCountryList(headers?: object, signal?: AbortSignal): Promise<GetCountryListResponse>
|
|
112
|
+
|
|
95
113
|
/**
|
|
96
114
|
* GetTrailsContracts returns Trails contract addresses used by the Trails Intents stack.
|
|
97
115
|
*/
|
|
98
116
|
getTrailsContracts(headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse>
|
|
99
117
|
|
|
118
|
+
/**
|
|
119
|
+
* GetEarnPools returns aggregated pool information from DeFi protocols (Aave, Morpho).
|
|
120
|
+
* This endpoint provides yield-bearing opportunities across multiple chains.
|
|
121
|
+
*/
|
|
122
|
+
getEarnPools(req: GetEarnPoolsRequest, headers?: object, signal?: AbortSignal): Promise<GetEarnPoolsResponse>
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* GetFiatCurrencyList returns the list of supported fiat currencies for display preferences.
|
|
126
|
+
*/
|
|
127
|
+
getFiatCurrencyList(headers?: object, signal?: AbortSignal): Promise<GetFiatCurrencyListResponse>
|
|
128
|
+
|
|
100
129
|
/**
|
|
101
130
|
* @deprecated please use GetIntentHistory instead
|
|
102
131
|
*/
|
|
103
|
-
getIntentTransactionHistory(
|
|
132
|
+
getIntentTransactionHistory(
|
|
133
|
+
req: GetIntentTransactionHistoryRequest,
|
|
134
|
+
headers?: object,
|
|
135
|
+
signal?: AbortSignal
|
|
136
|
+
): Promise<GetIntentTransactionHistoryResponse>
|
|
104
137
|
}
|
|
105
138
|
|
|
106
|
-
|
|
107
139
|
//
|
|
108
140
|
// Schema types
|
|
109
141
|
//
|
|
@@ -119,9 +151,17 @@ export enum RouteProvider {
|
|
|
119
151
|
LIFI = 'LIFI',
|
|
120
152
|
RELAY = 'RELAY',
|
|
121
153
|
SUSHI = 'SUSHI',
|
|
154
|
+
WETH = 'WETH',
|
|
122
155
|
ZEROX = 'ZEROX'
|
|
123
156
|
}
|
|
124
157
|
|
|
158
|
+
export enum FundMethod {
|
|
159
|
+
WALLET = 'WALLET',
|
|
160
|
+
DIRECT_TRANSFER = 'DIRECT_TRANSFER',
|
|
161
|
+
ONRAMP_MESH = 'ONRAMP_MESH',
|
|
162
|
+
ONRAMP_MELD = 'ONRAMP_MELD'
|
|
163
|
+
}
|
|
164
|
+
|
|
125
165
|
export enum IntentStatus {
|
|
126
166
|
QUOTED = 'QUOTED',
|
|
127
167
|
COMMITTED = 'COMMITTED',
|
|
@@ -137,7 +177,8 @@ export enum TransactionType {
|
|
|
137
177
|
DEPOSIT = 'DEPOSIT',
|
|
138
178
|
ORIGIN = 'ORIGIN',
|
|
139
179
|
DESTINATION = 'DESTINATION',
|
|
140
|
-
ROUTE = 'ROUTE'
|
|
180
|
+
ROUTE = 'ROUTE',
|
|
181
|
+
REFUND = 'REFUND'
|
|
141
182
|
}
|
|
142
183
|
|
|
143
184
|
export enum TransactionContext {
|
|
@@ -174,6 +215,16 @@ export enum CCTPTransferStatus {
|
|
|
174
215
|
FAILED = 'FAILED'
|
|
175
216
|
}
|
|
176
217
|
|
|
218
|
+
export enum RelayTransferStatus {
|
|
219
|
+
UNKNOWN = 'UNKNOWN',
|
|
220
|
+
ON_HOLD = 'ON_HOLD',
|
|
221
|
+
PENDING = 'PENDING',
|
|
222
|
+
FETCHING = 'FETCHING',
|
|
223
|
+
COMPLETE = 'COMPLETE',
|
|
224
|
+
REFUNDED = 'REFUNDED',
|
|
225
|
+
FAILED = 'FAILED'
|
|
226
|
+
}
|
|
227
|
+
|
|
177
228
|
export interface QuoteIntentRequest {
|
|
178
229
|
ownerAddress: string
|
|
179
230
|
originChainId: number
|
|
@@ -186,6 +237,7 @@ export interface QuoteIntentRequest {
|
|
|
186
237
|
originTokenAmount?: bigint
|
|
187
238
|
destinationTokenAmount?: bigint
|
|
188
239
|
tradeType?: TradeType
|
|
240
|
+
fundMethod?: FundMethod
|
|
189
241
|
onlyNativeGasFee?: boolean
|
|
190
242
|
options?: QuoteIntentRequestOptions
|
|
191
243
|
}
|
|
@@ -197,6 +249,12 @@ export interface QuoteIntentRequestOptions {
|
|
|
197
249
|
trailsAddressOverrides?: TrailsAddressOverrides
|
|
198
250
|
}
|
|
199
251
|
|
|
252
|
+
export interface PassthroughInfo {
|
|
253
|
+
eligible: boolean
|
|
254
|
+
passthroughTransaction?: PassThroughTransaction
|
|
255
|
+
transactionStates?: Array<TransactionStateInfo>
|
|
256
|
+
}
|
|
257
|
+
|
|
200
258
|
export interface Intent {
|
|
201
259
|
intentId: string
|
|
202
260
|
status: IntentStatus
|
|
@@ -208,6 +266,7 @@ export interface Intent {
|
|
|
208
266
|
destinationIntentAddress?: string
|
|
209
267
|
salt: bigint
|
|
210
268
|
depositTransaction: DepositTransaction
|
|
269
|
+
passthrough?: boolean
|
|
211
270
|
originCalls: IntentCalls
|
|
212
271
|
destinationCalls?: IntentCalls
|
|
213
272
|
originPrecondition: TransactionPrecondition
|
|
@@ -228,6 +287,27 @@ export interface DepositTransaction {
|
|
|
228
287
|
tokenAddress: string
|
|
229
288
|
decimals?: number
|
|
230
289
|
amount: bigint
|
|
290
|
+
chainId: number
|
|
291
|
+
to: string
|
|
292
|
+
data: string
|
|
293
|
+
value: bigint
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface PassThroughTransaction {
|
|
297
|
+
toAddress: string
|
|
298
|
+
tokenAddress: string
|
|
299
|
+
decimals?: number
|
|
300
|
+
amount: bigint
|
|
301
|
+
chainId: number
|
|
302
|
+
to: string
|
|
303
|
+
data: string
|
|
304
|
+
value: bigint
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface TransactionStateInfo {
|
|
308
|
+
id: string
|
|
309
|
+
label: string
|
|
310
|
+
chainId: number
|
|
231
311
|
}
|
|
232
312
|
|
|
233
313
|
export interface IntentCalls {
|
|
@@ -307,6 +387,7 @@ export interface IntentReceipt {
|
|
|
307
387
|
depositTransaction: IntentTransaction
|
|
308
388
|
originTransaction: IntentTransaction
|
|
309
389
|
destinationTransaction?: IntentTransaction
|
|
390
|
+
refundTransaction?: IntentTransaction
|
|
310
391
|
summary: IntentReceiptSummary
|
|
311
392
|
updatedAt?: string
|
|
312
393
|
createdAt?: string
|
|
@@ -469,6 +550,14 @@ export interface TokenPrice {
|
|
|
469
550
|
updatedAt: string
|
|
470
551
|
}
|
|
471
552
|
|
|
553
|
+
export interface ExchangeRate {
|
|
554
|
+
name: string
|
|
555
|
+
symbol: string
|
|
556
|
+
value: number
|
|
557
|
+
vsCurrency: string
|
|
558
|
+
currencyType: string
|
|
559
|
+
}
|
|
560
|
+
|
|
472
561
|
export interface CCTPTransfer {
|
|
473
562
|
id: number
|
|
474
563
|
intentId: string
|
|
@@ -485,6 +574,21 @@ export interface CCTPTransfer {
|
|
|
485
574
|
updatedAt: string
|
|
486
575
|
}
|
|
487
576
|
|
|
577
|
+
export interface RelayTransfer {
|
|
578
|
+
id: number
|
|
579
|
+
intentId: string
|
|
580
|
+
originChainId: number
|
|
581
|
+
destinationChainId: number
|
|
582
|
+
originTxnId: number
|
|
583
|
+
originTxnHash: string
|
|
584
|
+
destinationTxnId: number
|
|
585
|
+
destinationTxnHash: string
|
|
586
|
+
status: number
|
|
587
|
+
statusReason?: string
|
|
588
|
+
createdAt: string
|
|
589
|
+
updatedAt: string
|
|
590
|
+
}
|
|
591
|
+
|
|
488
592
|
export interface GasFeeOptions {
|
|
489
593
|
gasEstimate: GasEstimate
|
|
490
594
|
feeOptions: Array<FeeOption>
|
|
@@ -507,6 +611,7 @@ export interface FeeOption {
|
|
|
507
611
|
amountUsd: number
|
|
508
612
|
feeCollectorAddress: string
|
|
509
613
|
is2612: boolean
|
|
614
|
+
isPassthroughEligible?: boolean
|
|
510
615
|
}
|
|
511
616
|
|
|
512
617
|
export interface DepositSignature {
|
|
@@ -568,6 +673,50 @@ export interface TokenInfo {
|
|
|
568
673
|
featured: boolean
|
|
569
674
|
}
|
|
570
675
|
|
|
676
|
+
export interface EarnPool {
|
|
677
|
+
id: string
|
|
678
|
+
name: string
|
|
679
|
+
protocol: string
|
|
680
|
+
chainId: number
|
|
681
|
+
apy: number
|
|
682
|
+
tvl: number
|
|
683
|
+
token: PoolTokenInfo
|
|
684
|
+
depositAddress: string
|
|
685
|
+
isActive: boolean
|
|
686
|
+
poolUrl?: string
|
|
687
|
+
protocolUrl?: string
|
|
688
|
+
wrappedTokenGatewayAddress?: string
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
export interface PoolTokenInfo {
|
|
692
|
+
symbol: string
|
|
693
|
+
name: string
|
|
694
|
+
address: string
|
|
695
|
+
decimals: number
|
|
696
|
+
logoUrl?: string
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
export interface CountryRegion {
|
|
700
|
+
regionCode: string
|
|
701
|
+
name: string
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
export interface Country {
|
|
705
|
+
countryCode: string
|
|
706
|
+
name: string
|
|
707
|
+
flag: string
|
|
708
|
+
flagImageUrl: string
|
|
709
|
+
regions?: Array<CountryRegion>
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export interface FiatCurrency {
|
|
713
|
+
code: string
|
|
714
|
+
symbol: string
|
|
715
|
+
name: string
|
|
716
|
+
flag: string
|
|
717
|
+
decimals: number
|
|
718
|
+
}
|
|
719
|
+
|
|
571
720
|
export interface MeldQuote {
|
|
572
721
|
transactionType: string
|
|
573
722
|
sourceAmount: number
|
|
@@ -617,6 +766,8 @@ export interface ServiceStatus {
|
|
|
617
766
|
export interface QuoteIntentResponse {
|
|
618
767
|
intent: Intent
|
|
619
768
|
gasFeeOptions: GasFeeOptions
|
|
769
|
+
transactionStates?: Array<TransactionStateInfo>
|
|
770
|
+
passthrough?: PassthroughInfo
|
|
620
771
|
}
|
|
621
772
|
|
|
622
773
|
export interface CommitIntentRequest {
|
|
@@ -754,6 +905,19 @@ export interface GetTokenListResponse {
|
|
|
754
905
|
tokens: Array<TokenInfo>
|
|
755
906
|
}
|
|
756
907
|
|
|
908
|
+
export interface GetEarnPoolsRequest {
|
|
909
|
+
chainIds?: Array<number>
|
|
910
|
+
protocols?: Array<string>
|
|
911
|
+
minTvl?: number
|
|
912
|
+
maxApy?: number
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
export interface GetEarnPoolsResponse {
|
|
916
|
+
pools: Array<EarnPool>
|
|
917
|
+
timestamp: string
|
|
918
|
+
cached: boolean
|
|
919
|
+
}
|
|
920
|
+
|
|
757
921
|
export interface Page {
|
|
758
922
|
column?: string
|
|
759
923
|
before?: number
|
|
@@ -779,50 +943,49 @@ export interface GetIntentTransactionHistoryResponse {
|
|
|
779
943
|
nextPage?: Page
|
|
780
944
|
}
|
|
781
945
|
|
|
782
|
-
export interface PingRequest {
|
|
783
|
-
}
|
|
946
|
+
export interface PingRequest {}
|
|
784
947
|
|
|
785
948
|
export interface PingResponse {
|
|
786
949
|
version: string
|
|
787
950
|
}
|
|
788
951
|
|
|
789
|
-
export interface RuntimeStatusRequest {
|
|
790
|
-
}
|
|
952
|
+
export interface RuntimeStatusRequest {}
|
|
791
953
|
|
|
792
954
|
export interface RuntimeStatusResponse {
|
|
793
955
|
status: RuntimeStatus
|
|
794
956
|
}
|
|
795
957
|
|
|
796
|
-
export interface ClockRequest {
|
|
797
|
-
}
|
|
958
|
+
export interface ClockRequest {}
|
|
798
959
|
|
|
799
960
|
export interface ClockResponse {
|
|
800
961
|
serverTime: string
|
|
801
962
|
}
|
|
802
963
|
|
|
964
|
+
export interface GetExchangeRateRequest {
|
|
965
|
+
toCurrency: string
|
|
966
|
+
}
|
|
803
967
|
|
|
968
|
+
export interface GetExchangeRateResponse {
|
|
969
|
+
exchangeRate: ExchangeRate
|
|
970
|
+
}
|
|
804
971
|
|
|
972
|
+
export interface GetCountryListRequest {}
|
|
805
973
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
export interface GetTrailsContractsRequest {
|
|
974
|
+
export interface GetCountryListResponse {
|
|
975
|
+
countries: Array<Country>
|
|
818
976
|
}
|
|
819
977
|
|
|
978
|
+
export interface GetTrailsContractsRequest {}
|
|
979
|
+
|
|
820
980
|
export interface GetTrailsContractsResponse {
|
|
821
981
|
TrailsContracts: TrailsContracts
|
|
822
982
|
}
|
|
823
983
|
|
|
984
|
+
export interface GetFiatCurrencyListRequest {}
|
|
824
985
|
|
|
825
|
-
|
|
986
|
+
export interface GetFiatCurrencyListResponse {
|
|
987
|
+
currencies: Array<FiatCurrency>
|
|
988
|
+
}
|
|
826
989
|
|
|
827
990
|
//
|
|
828
991
|
// Client
|
|
@@ -841,7 +1004,7 @@ export class Trails implements TrailsClient {
|
|
|
841
1004
|
private url(name: string): string {
|
|
842
1005
|
return this.hostname + this.path + name
|
|
843
1006
|
}
|
|
844
|
-
|
|
1007
|
+
|
|
845
1008
|
queryKey = {
|
|
846
1009
|
ping: () => ['Trails', 'ping'] as const,
|
|
847
1010
|
runtimeStatus: () => ['Trails', 'runtimeStatus'] as const,
|
|
@@ -860,242 +1023,345 @@ export class Trails implements TrailsClient {
|
|
|
860
1023
|
getExactInputRoutes: (req: GetExactInputRoutesRequest) => ['Trails', 'getExactInputRoutes', req] as const,
|
|
861
1024
|
getTokenList: (req: GetTokenListRequest) => ['Trails', 'getTokenList', req] as const,
|
|
862
1025
|
getTokenPrices: (req: GetTokenPricesRequest) => ['Trails', 'getTokenPrices', req] as const,
|
|
1026
|
+
getExchangeRate: (req: GetExchangeRateRequest) => ['Trails', 'getExchangeRate', req] as const,
|
|
1027
|
+
getCountryList: () => ['Trails', 'getCountryList'] as const,
|
|
863
1028
|
getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const,
|
|
864
|
-
|
|
1029
|
+
getEarnPools: (req: GetEarnPoolsRequest) => ['Trails', 'getEarnPools', req] as const,
|
|
1030
|
+
getFiatCurrencyList: () => ['Trails', 'getFiatCurrencyList'] as const,
|
|
1031
|
+
getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) =>
|
|
1032
|
+
['Trails', 'getIntentTransactionHistory', req] as const
|
|
865
1033
|
}
|
|
866
1034
|
|
|
867
1035
|
ping = (headers?: object, signal?: AbortSignal): Promise<PingResponse> => {
|
|
868
|
-
return this.fetch(
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
1036
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(
|
|
1037
|
+
res => {
|
|
1038
|
+
return buildResponse(res).then(_data => {
|
|
1039
|
+
return JsonDecode<PingResponse>(_data, 'PingResponse')
|
|
1040
|
+
})
|
|
1041
|
+
},
|
|
1042
|
+
error => {
|
|
1043
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1044
|
+
}
|
|
1045
|
+
)
|
|
877
1046
|
}
|
|
878
1047
|
|
|
879
1048
|
runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse> => {
|
|
880
|
-
return this.fetch(
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1049
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(
|
|
1050
|
+
res => {
|
|
1051
|
+
return buildResponse(res).then(_data => {
|
|
1052
|
+
return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
|
|
1053
|
+
})
|
|
1054
|
+
},
|
|
1055
|
+
error => {
|
|
1056
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1057
|
+
}
|
|
1058
|
+
)
|
|
889
1059
|
}
|
|
890
1060
|
|
|
891
1061
|
clock = (headers?: object, signal?: AbortSignal): Promise<ClockResponse> => {
|
|
892
|
-
return this.fetch(
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1062
|
+
return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then(
|
|
1063
|
+
res => {
|
|
1064
|
+
return buildResponse(res).then(_data => {
|
|
1065
|
+
return JsonDecode<ClockResponse>(_data, 'ClockResponse')
|
|
1066
|
+
})
|
|
1067
|
+
},
|
|
1068
|
+
error => {
|
|
1069
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1070
|
+
}
|
|
1071
|
+
)
|
|
901
1072
|
}
|
|
902
1073
|
|
|
903
1074
|
quoteIntent = (req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse> => {
|
|
904
|
-
return this.fetch(
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1075
|
+
return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1076
|
+
res => {
|
|
1077
|
+
return buildResponse(res).then(_data => {
|
|
1078
|
+
return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
|
|
1079
|
+
})
|
|
1080
|
+
},
|
|
1081
|
+
error => {
|
|
1082
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1083
|
+
}
|
|
1084
|
+
)
|
|
913
1085
|
}
|
|
914
1086
|
|
|
915
1087
|
commitIntent = (req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse> => {
|
|
916
|
-
return this.fetch(
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1088
|
+
return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1089
|
+
res => {
|
|
1090
|
+
return buildResponse(res).then(_data => {
|
|
1091
|
+
return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
|
|
1092
|
+
})
|
|
1093
|
+
},
|
|
1094
|
+
error => {
|
|
1095
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1096
|
+
}
|
|
1097
|
+
)
|
|
925
1098
|
}
|
|
926
1099
|
|
|
927
1100
|
executeIntent = (req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse> => {
|
|
928
|
-
return this.fetch(
|
|
929
|
-
|
|
930
|
-
|
|
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
|
-
|
|
1101
|
+
return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1102
|
+
res => {
|
|
1103
|
+
return buildResponse(res).then(_data => {
|
|
1104
|
+
return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
|
|
1105
|
+
})
|
|
1106
|
+
},
|
|
1107
|
+
error => {
|
|
1108
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1109
|
+
}
|
|
1110
|
+
)
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
waitIntentReceipt = (
|
|
1114
|
+
req: WaitIntentReceiptRequest,
|
|
1115
|
+
headers?: object,
|
|
1116
|
+
signal?: AbortSignal
|
|
1117
|
+
): Promise<WaitIntentReceiptResponse> => {
|
|
1118
|
+
return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1119
|
+
res => {
|
|
1120
|
+
return buildResponse(res).then(_data => {
|
|
1121
|
+
return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
|
|
1122
|
+
})
|
|
1123
|
+
},
|
|
1124
|
+
error => {
|
|
1125
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1126
|
+
}
|
|
1127
|
+
)
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
getIntentReceipt = (
|
|
1131
|
+
req: GetIntentReceiptRequest,
|
|
1132
|
+
headers?: object,
|
|
1133
|
+
signal?: AbortSignal
|
|
1134
|
+
): Promise<GetIntentReceiptResponse> => {
|
|
1135
|
+
return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1136
|
+
res => {
|
|
1137
|
+
return buildResponse(res).then(_data => {
|
|
1138
|
+
return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
|
|
1139
|
+
})
|
|
1140
|
+
},
|
|
1141
|
+
error => {
|
|
1142
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1143
|
+
}
|
|
1144
|
+
)
|
|
961
1145
|
}
|
|
962
1146
|
|
|
963
1147
|
getIntent = (req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse> => {
|
|
964
|
-
return this.fetch(
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1148
|
+
return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1149
|
+
res => {
|
|
1150
|
+
return buildResponse(res).then(_data => {
|
|
1151
|
+
return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
|
|
1152
|
+
})
|
|
1153
|
+
},
|
|
1154
|
+
error => {
|
|
1155
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1156
|
+
}
|
|
1157
|
+
)
|
|
973
1158
|
}
|
|
974
1159
|
|
|
975
1160
|
searchIntents = (req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse> => {
|
|
976
|
-
return this.fetch(
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1161
|
+
return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1162
|
+
res => {
|
|
1163
|
+
return buildResponse(res).then(_data => {
|
|
1164
|
+
return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
|
|
1165
|
+
})
|
|
1166
|
+
},
|
|
1167
|
+
error => {
|
|
1168
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1169
|
+
}
|
|
1170
|
+
)
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
getIntentHistory = (
|
|
1174
|
+
req: GetIntentHistoryRequest,
|
|
1175
|
+
headers?: object,
|
|
1176
|
+
signal?: AbortSignal
|
|
1177
|
+
): Promise<GetIntentHistoryResponse> => {
|
|
1178
|
+
return this.fetch(this.url('GetIntentHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1179
|
+
res => {
|
|
1180
|
+
return buildResponse(res).then(_data => {
|
|
1181
|
+
return JsonDecode<GetIntentHistoryResponse>(_data, 'GetIntentHistoryResponse')
|
|
1182
|
+
})
|
|
1183
|
+
},
|
|
1184
|
+
error => {
|
|
1185
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1186
|
+
}
|
|
1187
|
+
)
|
|
997
1188
|
}
|
|
998
1189
|
|
|
999
1190
|
abortIntent = (req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse> => {
|
|
1000
|
-
return this.fetch(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1191
|
+
return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1192
|
+
res => {
|
|
1193
|
+
return buildResponse(res).then(_data => {
|
|
1194
|
+
return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
|
|
1195
|
+
})
|
|
1196
|
+
},
|
|
1197
|
+
error => {
|
|
1198
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1199
|
+
}
|
|
1200
|
+
)
|
|
1009
1201
|
}
|
|
1010
1202
|
|
|
1011
1203
|
getChains = (req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse> => {
|
|
1012
|
-
return this.fetch(
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1204
|
+
return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1205
|
+
res => {
|
|
1206
|
+
return buildResponse(res).then(_data => {
|
|
1207
|
+
return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
|
|
1208
|
+
})
|
|
1209
|
+
},
|
|
1210
|
+
error => {
|
|
1211
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
getExactOutputRoutes = (
|
|
1217
|
+
req: GetExactOutputRoutesRequest,
|
|
1218
|
+
headers?: object,
|
|
1219
|
+
signal?: AbortSignal
|
|
1220
|
+
): Promise<GetExactOutputRoutesResponse> => {
|
|
1221
|
+
return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1222
|
+
res => {
|
|
1223
|
+
return buildResponse(res).then(_data => {
|
|
1224
|
+
return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
|
|
1225
|
+
})
|
|
1226
|
+
},
|
|
1227
|
+
error => {
|
|
1228
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1229
|
+
}
|
|
1230
|
+
)
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
getExactInputRoutes = (
|
|
1234
|
+
req: GetExactInputRoutesRequest,
|
|
1235
|
+
headers?: object,
|
|
1236
|
+
signal?: AbortSignal
|
|
1237
|
+
): Promise<GetExactInputRoutesResponse> => {
|
|
1238
|
+
return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1239
|
+
res => {
|
|
1240
|
+
return buildResponse(res).then(_data => {
|
|
1241
|
+
return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
|
|
1242
|
+
})
|
|
1243
|
+
},
|
|
1244
|
+
error => {
|
|
1245
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1246
|
+
}
|
|
1247
|
+
)
|
|
1045
1248
|
}
|
|
1046
1249
|
|
|
1047
1250
|
getTokenList = (req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse> => {
|
|
1048
|
-
return this.fetch(
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1251
|
+
return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1252
|
+
res => {
|
|
1253
|
+
return buildResponse(res).then(_data => {
|
|
1254
|
+
return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
|
|
1255
|
+
})
|
|
1256
|
+
},
|
|
1257
|
+
error => {
|
|
1258
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1259
|
+
}
|
|
1260
|
+
)
|
|
1057
1261
|
}
|
|
1058
1262
|
|
|
1059
1263
|
getTokenPrices = (req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse> => {
|
|
1060
|
-
return this.fetch(
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1264
|
+
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1265
|
+
res => {
|
|
1266
|
+
return buildResponse(res).then(_data => {
|
|
1267
|
+
return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
|
|
1268
|
+
})
|
|
1269
|
+
},
|
|
1270
|
+
error => {
|
|
1271
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1272
|
+
}
|
|
1273
|
+
)
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
getExchangeRate = (req: GetExchangeRateRequest, headers?: object, signal?: AbortSignal): Promise<GetExchangeRateResponse> => {
|
|
1277
|
+
return this.fetch(this.url('GetExchangeRate'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1278
|
+
res => {
|
|
1279
|
+
return buildResponse(res).then(_data => {
|
|
1280
|
+
return JsonDecode<GetExchangeRateResponse>(_data, 'GetExchangeRateResponse')
|
|
1281
|
+
})
|
|
1282
|
+
},
|
|
1283
|
+
error => {
|
|
1284
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1285
|
+
}
|
|
1286
|
+
)
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
getCountryList = (headers?: object, signal?: AbortSignal): Promise<GetCountryListResponse> => {
|
|
1290
|
+
return this.fetch(this.url('GetCountryList'), createHttpRequest('{}', headers, signal)).then(
|
|
1291
|
+
res => {
|
|
1292
|
+
return buildResponse(res).then(_data => {
|
|
1293
|
+
return JsonDecode<GetCountryListResponse>(_data, 'GetCountryListResponse')
|
|
1294
|
+
})
|
|
1295
|
+
},
|
|
1296
|
+
error => {
|
|
1297
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1298
|
+
}
|
|
1299
|
+
)
|
|
1069
1300
|
}
|
|
1070
1301
|
|
|
1071
1302
|
getTrailsContracts = (headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse> => {
|
|
1072
|
-
return this.fetch(
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1303
|
+
return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then(
|
|
1304
|
+
res => {
|
|
1305
|
+
return buildResponse(res).then(_data => {
|
|
1306
|
+
return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
|
|
1307
|
+
})
|
|
1308
|
+
},
|
|
1309
|
+
error => {
|
|
1310
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1311
|
+
}
|
|
1312
|
+
)
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
getEarnPools = (req: GetEarnPoolsRequest, headers?: object, signal?: AbortSignal): Promise<GetEarnPoolsResponse> => {
|
|
1316
|
+
return this.fetch(this.url('GetEarnPools'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1317
|
+
res => {
|
|
1318
|
+
return buildResponse(res).then(_data => {
|
|
1319
|
+
return JsonDecode<GetEarnPoolsResponse>(_data, 'GetEarnPoolsResponse')
|
|
1320
|
+
})
|
|
1321
|
+
},
|
|
1322
|
+
error => {
|
|
1323
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1324
|
+
}
|
|
1325
|
+
)
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
getFiatCurrencyList = (headers?: object, signal?: AbortSignal): Promise<GetFiatCurrencyListResponse> => {
|
|
1329
|
+
return this.fetch(this.url('GetFiatCurrencyList'), createHttpRequest('{}', headers, signal)).then(
|
|
1330
|
+
res => {
|
|
1331
|
+
return buildResponse(res).then(_data => {
|
|
1332
|
+
return JsonDecode<GetFiatCurrencyListResponse>(_data, 'GetFiatCurrencyListResponse')
|
|
1333
|
+
})
|
|
1334
|
+
},
|
|
1335
|
+
error => {
|
|
1336
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1337
|
+
}
|
|
1338
|
+
)
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
getIntentTransactionHistory = (
|
|
1342
|
+
req: GetIntentTransactionHistoryRequest,
|
|
1343
|
+
headers?: object,
|
|
1344
|
+
signal?: AbortSignal
|
|
1345
|
+
): Promise<GetIntentTransactionHistoryResponse> => {
|
|
1346
|
+
return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
1347
|
+
res => {
|
|
1348
|
+
return buildResponse(res).then(_data => {
|
|
1349
|
+
return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
|
|
1350
|
+
})
|
|
1351
|
+
},
|
|
1352
|
+
error => {
|
|
1353
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
|
|
1354
|
+
}
|
|
1355
|
+
)
|
|
1093
1356
|
}
|
|
1094
|
-
|
|
1095
1357
|
}
|
|
1096
1358
|
|
|
1097
1359
|
const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
|
|
1098
|
-
const reqHeaders: { [key: string]: string } = {
|
|
1360
|
+
const reqHeaders: { [key: string]: string } = {
|
|
1361
|
+
...headers,
|
|
1362
|
+
'Content-Type': 'application/json',
|
|
1363
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
1364
|
+
}
|
|
1099
1365
|
return { method: 'POST', headers: reqHeaders, body, signal }
|
|
1100
1366
|
}
|
|
1101
1367
|
|
|
@@ -1104,14 +1370,14 @@ const buildResponse = (res: Response): Promise<any> => {
|
|
|
1104
1370
|
let data
|
|
1105
1371
|
try {
|
|
1106
1372
|
data = JSON.parse(text)
|
|
1107
|
-
} catch(error) {
|
|
1373
|
+
} catch (error) {
|
|
1108
1374
|
throw WebrpcBadResponseError.new({
|
|
1109
1375
|
status: res.status,
|
|
1110
|
-
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
1111
|
-
)
|
|
1376
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
1377
|
+
})
|
|
1112
1378
|
}
|
|
1113
1379
|
if (!res.ok) {
|
|
1114
|
-
const code: number =
|
|
1380
|
+
const code: number = typeof data.code === 'number' ? data.code : 0
|
|
1115
1381
|
throw (webrpcErrorByCode[code] || WebrpcError).new(data)
|
|
1116
1382
|
}
|
|
1117
1383
|
return data
|
|
@@ -1120,10 +1386,6 @@ const buildResponse = (res: Response): Promise<any> => {
|
|
|
1120
1386
|
|
|
1121
1387
|
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
|
|
1122
1388
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
1389
|
//
|
|
1128
1390
|
// BigInt helpers
|
|
1129
1391
|
//
|
|
@@ -1132,7 +1394,7 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
|
|
|
1132
1394
|
CommitIntentRequest: [['intent', 'Intent']],
|
|
1133
1395
|
DepositIntentEntry: ['permitAmount'],
|
|
1134
1396
|
DepositSignature: ['permitAmount', ['selectedGasFeeOption', 'FeeOption']],
|
|
1135
|
-
DepositTransaction: ['amount'],
|
|
1397
|
+
DepositTransaction: ['amount', 'value'],
|
|
1136
1398
|
ExecuteIntentRequest: [['depositSignature', 'DepositSignature']],
|
|
1137
1399
|
FeeOption: ['amount'],
|
|
1138
1400
|
GasFeeOptions: [['feeOptions', 'FeeOption[]']],
|
|
@@ -1140,20 +1402,53 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
|
|
|
1140
1402
|
GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
|
|
1141
1403
|
GetIntentResponse: [['intent', 'Intent']],
|
|
1142
1404
|
GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
|
|
1143
|
-
Intent: [
|
|
1405
|
+
Intent: [
|
|
1406
|
+
['quoteRequest', 'QuoteIntentRequest'],
|
|
1407
|
+
'salt',
|
|
1408
|
+
['depositTransaction', 'DepositTransaction'],
|
|
1409
|
+
['originCalls', 'IntentCalls'],
|
|
1410
|
+
['destinationCalls', 'IntentCalls'],
|
|
1411
|
+
['originPrecondition', 'TransactionPrecondition'],
|
|
1412
|
+
['destinationPrecondition', 'TransactionPrecondition'],
|
|
1413
|
+
['quote', 'IntentProviderQuote'],
|
|
1414
|
+
['fees', 'IntentFees']
|
|
1415
|
+
],
|
|
1144
1416
|
IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
|
|
1145
|
-
IntentFees: [
|
|
1417
|
+
IntentFees: [
|
|
1418
|
+
['originGas', 'IntentTransactionGasFee'],
|
|
1419
|
+
['destinationGas', 'IntentTransactionGasFee'],
|
|
1420
|
+
['provider', 'IntentProviderFees'],
|
|
1421
|
+
'feeTokenAmount',
|
|
1422
|
+
'feeTokenTotal',
|
|
1423
|
+
'gasFeeTotal',
|
|
1424
|
+
'trailsFeeTotal',
|
|
1425
|
+
'collectorFeeTotal',
|
|
1426
|
+
'providerFeeTotal',
|
|
1427
|
+
'totalFeeAmount'
|
|
1428
|
+
],
|
|
1146
1429
|
IntentHistory: [['receipt', 'IntentReceipt']],
|
|
1147
1430
|
IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'quoteProviderWithTrailsFee', 'totalFeeAmount'],
|
|
1148
1431
|
IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
|
|
1149
|
-
IntentReceipt: [
|
|
1432
|
+
IntentReceipt: [
|
|
1433
|
+
['depositTransaction', 'IntentTransaction'],
|
|
1434
|
+
['originTransaction', 'IntentTransaction'],
|
|
1435
|
+
['destinationTransaction', 'IntentTransaction'],
|
|
1436
|
+
['refundTransaction', 'IntentTransaction'],
|
|
1437
|
+
['summary', 'IntentReceiptSummary']
|
|
1438
|
+
],
|
|
1150
1439
|
IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
1151
1440
|
IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
1152
1441
|
IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
|
|
1153
1442
|
IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
|
|
1154
1443
|
MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
|
|
1444
|
+
PassThroughTransaction: ['amount', 'value'],
|
|
1445
|
+
PassthroughInfo: [['passthroughTransaction', 'PassThroughTransaction']],
|
|
1155
1446
|
QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
|
|
1156
|
-
QuoteIntentResponse: [
|
|
1447
|
+
QuoteIntentResponse: [
|
|
1448
|
+
['intent', 'Intent'],
|
|
1449
|
+
['gasFeeOptions', 'GasFeeOptions'],
|
|
1450
|
+
['passthrough', 'PassthroughInfo']
|
|
1451
|
+
],
|
|
1157
1452
|
SearchIntentsResponse: [['intents', 'Intent[]']],
|
|
1158
1453
|
TransactionCall: ['value', 'gasLimit'],
|
|
1159
1454
|
TransactionPrecondition: ['minAmount'],
|
|
@@ -1195,7 +1490,11 @@ function decodeType(typ: string, obj: any): any {
|
|
|
1195
1490
|
for (let i = 0; i < arr.length; i++) {
|
|
1196
1491
|
const v = arr[i]
|
|
1197
1492
|
if (typeof v === 'string') {
|
|
1198
|
-
try {
|
|
1493
|
+
try {
|
|
1494
|
+
arr[i] = BigInt(v)
|
|
1495
|
+
} catch (e) {
|
|
1496
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` })
|
|
1497
|
+
}
|
|
1199
1498
|
}
|
|
1200
1499
|
}
|
|
1201
1500
|
}
|
|
@@ -1203,7 +1502,11 @@ function decodeType(typ: string, obj: any): any {
|
|
|
1203
1502
|
}
|
|
1204
1503
|
const v = obj[d]
|
|
1205
1504
|
if (typeof v === 'string') {
|
|
1206
|
-
try {
|
|
1505
|
+
try {
|
|
1506
|
+
obj[d] = BigInt(v)
|
|
1507
|
+
} catch (e) {
|
|
1508
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` })
|
|
1509
|
+
}
|
|
1207
1510
|
}
|
|
1208
1511
|
}
|
|
1209
1512
|
return obj
|
|
@@ -1211,28 +1514,27 @@ function decodeType(typ: string, obj: any): any {
|
|
|
1211
1514
|
|
|
1212
1515
|
// Encode object to JSON with BigInts converted to decimal strings.
|
|
1213
1516
|
export const JsonEncode = <T = any>(obj: T): string => {
|
|
1214
|
-
return JSON.stringify(obj, (key, value) =>
|
|
1215
|
-
typeof value === 'bigint' ? value.toString() : value
|
|
1216
|
-
)
|
|
1517
|
+
return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
|
|
1217
1518
|
}
|
|
1218
1519
|
|
|
1219
1520
|
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
1220
1521
|
export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
|
|
1221
1522
|
let parsed: any = data
|
|
1222
1523
|
if (typeof data === 'string') {
|
|
1223
|
-
try {
|
|
1524
|
+
try {
|
|
1525
|
+
parsed = JSON.parse(data)
|
|
1526
|
+
} catch (err) {
|
|
1224
1527
|
throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
|
|
1225
1528
|
}
|
|
1226
1529
|
}
|
|
1227
1530
|
return decodeType(typ, parsed) as T
|
|
1228
1531
|
}
|
|
1229
1532
|
|
|
1230
|
-
|
|
1231
1533
|
//
|
|
1232
1534
|
// Errors
|
|
1233
1535
|
//
|
|
1234
1536
|
|
|
1235
|
-
type WebrpcErrorParams = { name?: string
|
|
1537
|
+
type WebrpcErrorParams = { name?: string; code?: number; message?: string; status?: number; cause?: string }
|
|
1236
1538
|
|
|
1237
1539
|
export class WebrpcError extends Error {
|
|
1238
1540
|
code: number
|
|
@@ -1253,7 +1555,6 @@ export class WebrpcError extends Error {
|
|
|
1253
1555
|
}
|
|
1254
1556
|
}
|
|
1255
1557
|
|
|
1256
|
-
|
|
1257
1558
|
export class WebrpcEndpointError extends WebrpcError {
|
|
1258
1559
|
constructor(error: WebrpcErrorParams = {}) {
|
|
1259
1560
|
super(error)
|
|
@@ -1386,7 +1687,6 @@ export class WebrpcStreamFinishedError extends WebrpcError {
|
|
|
1386
1687
|
}
|
|
1387
1688
|
}
|
|
1388
1689
|
|
|
1389
|
-
|
|
1390
1690
|
//
|
|
1391
1691
|
// Schema errors
|
|
1392
1692
|
//
|
|
@@ -1763,7 +2063,6 @@ export class IntentsDisabledError extends WebrpcError {
|
|
|
1763
2063
|
}
|
|
1764
2064
|
}
|
|
1765
2065
|
|
|
1766
|
-
|
|
1767
2066
|
export enum errors {
|
|
1768
2067
|
WebrpcEndpoint = 'WebrpcEndpoint',
|
|
1769
2068
|
WebrpcRequestFailed = 'WebrpcRequestFailed',
|
|
@@ -1806,7 +2105,7 @@ export enum errors {
|
|
|
1806
2105
|
ClientOutdated = 'ClientOutdated',
|
|
1807
2106
|
IntentsSkipped = 'IntentsSkipped',
|
|
1808
2107
|
QuoteExpired = 'QuoteExpired',
|
|
1809
|
-
IntentsDisabled = 'IntentsDisabled'
|
|
2108
|
+
IntentsDisabled = 'IntentsDisabled'
|
|
1810
2109
|
}
|
|
1811
2110
|
|
|
1812
2111
|
export enum WebrpcErrorCodes {
|
|
@@ -1851,7 +2150,7 @@ export enum WebrpcErrorCodes {
|
|
|
1851
2150
|
ClientOutdated = 8009,
|
|
1852
2151
|
IntentsSkipped = 7000,
|
|
1853
2152
|
QuoteExpired = 7001,
|
|
1854
|
-
IntentsDisabled = 9000
|
|
2153
|
+
IntentsDisabled = 9000
|
|
1855
2154
|
}
|
|
1856
2155
|
|
|
1857
2156
|
export const webrpcErrorByCode: { [code: number]: any } = {
|
|
@@ -1896,64 +2195,61 @@ export const webrpcErrorByCode: { [code: number]: any } = {
|
|
|
1896
2195
|
[8009]: ClientOutdatedError,
|
|
1897
2196
|
[7000]: IntentsSkippedError,
|
|
1898
2197
|
[7001]: QuoteExpiredError,
|
|
1899
|
-
[9000]: IntentsDisabledError
|
|
2198
|
+
[9000]: IntentsDisabledError
|
|
1900
2199
|
}
|
|
1901
2200
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
2201
|
//
|
|
1905
2202
|
// Webrpc
|
|
1906
2203
|
//
|
|
1907
2204
|
|
|
1908
|
-
export const WebrpcHeader =
|
|
2205
|
+
export const WebrpcHeader = 'Webrpc'
|
|
1909
2206
|
|
|
1910
|
-
export const WebrpcHeaderValue =
|
|
2207
|
+
export const WebrpcHeaderValue = 'webrpc@v0.32.2;gen-typescript@v0.23.1;trails-api@v1'
|
|
1911
2208
|
|
|
1912
2209
|
type WebrpcGenVersions = {
|
|
1913
|
-
WebrpcGenVersion: string
|
|
1914
|
-
codeGenName: string
|
|
1915
|
-
codeGenVersion: string
|
|
1916
|
-
schemaName: string
|
|
1917
|
-
schemaVersion: string
|
|
1918
|
-
}
|
|
2210
|
+
WebrpcGenVersion: string
|
|
2211
|
+
codeGenName: string
|
|
2212
|
+
codeGenVersion: string
|
|
2213
|
+
schemaName: string
|
|
2214
|
+
schemaVersion: string
|
|
2215
|
+
}
|
|
1919
2216
|
|
|
1920
2217
|
export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
|
|
1921
2218
|
const headerValue = headers.get(WebrpcHeader)
|
|
1922
2219
|
if (!headerValue) {
|
|
1923
2220
|
return {
|
|
1924
|
-
WebrpcGenVersion:
|
|
1925
|
-
codeGenName:
|
|
1926
|
-
codeGenVersion:
|
|
1927
|
-
schemaName:
|
|
1928
|
-
schemaVersion:
|
|
1929
|
-
}
|
|
2221
|
+
WebrpcGenVersion: '',
|
|
2222
|
+
codeGenName: '',
|
|
2223
|
+
codeGenVersion: '',
|
|
2224
|
+
schemaName: '',
|
|
2225
|
+
schemaVersion: ''
|
|
2226
|
+
}
|
|
1930
2227
|
}
|
|
1931
2228
|
|
|
1932
2229
|
return parseWebrpcGenVersions(headerValue)
|
|
1933
2230
|
}
|
|
1934
2231
|
|
|
1935
2232
|
function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
|
|
1936
|
-
const versions = header.split(
|
|
2233
|
+
const versions = header.split(';')
|
|
1937
2234
|
if (versions.length < 3) {
|
|
1938
2235
|
return {
|
|
1939
|
-
WebrpcGenVersion:
|
|
1940
|
-
codeGenName:
|
|
1941
|
-
codeGenVersion:
|
|
1942
|
-
schemaName:
|
|
1943
|
-
schemaVersion:
|
|
1944
|
-
}
|
|
2236
|
+
WebrpcGenVersion: '',
|
|
2237
|
+
codeGenName: '',
|
|
2238
|
+
codeGenVersion: '',
|
|
2239
|
+
schemaName: '',
|
|
2240
|
+
schemaVersion: ''
|
|
2241
|
+
}
|
|
1945
2242
|
}
|
|
1946
2243
|
|
|
1947
|
-
const [_, WebrpcGenVersion] = versions[0]!.split(
|
|
1948
|
-
const [codeGenName, codeGenVersion] = versions[1]!.split(
|
|
1949
|
-
const [schemaName, schemaVersion] = versions[2]!.split(
|
|
2244
|
+
const [_, WebrpcGenVersion] = versions[0]!.split('@')
|
|
2245
|
+
const [codeGenName, codeGenVersion] = versions[1]!.split('@')
|
|
2246
|
+
const [schemaName, schemaVersion] = versions[2]!.split('@')
|
|
1950
2247
|
|
|
1951
2248
|
return {
|
|
1952
|
-
WebrpcGenVersion: WebrpcGenVersion ??
|
|
1953
|
-
codeGenName: codeGenName ??
|
|
1954
|
-
codeGenVersion: codeGenVersion ??
|
|
1955
|
-
schemaName: schemaName ??
|
|
1956
|
-
schemaVersion: schemaVersion ??
|
|
1957
|
-
}
|
|
2249
|
+
WebrpcGenVersion: WebrpcGenVersion ?? '',
|
|
2250
|
+
codeGenName: codeGenName ?? '',
|
|
2251
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
2252
|
+
schemaName: schemaName ?? '',
|
|
2253
|
+
schemaVersion: schemaVersion ?? ''
|
|
2254
|
+
}
|
|
1958
2255
|
}
|
|
1959
|
-
|