@0xtrails/api 0.9.2 → 0.9.3

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.
@@ -1,18 +1,18 @@
1
1
  /* eslint-disable */
2
- // trails-api v1-25.12.18-0c440420 09b3975a1dfcfc5531e352d55f6e474f73165f3a
2
+ // trails-api v1-25.12.21-67dea3a1 98bbae5f2233d6018b5b0fd94557b0795eecc055
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 = 'v1'
9
+ export const WebrpcVersion = "v1"
10
10
 
11
11
  // Schema version of your RIDL schema
12
- export const WebrpcSchemaVersion = 'v1-25.12.18-0c440420'
12
+ export const WebrpcSchemaVersion = "v1-25.12.21-67dea3a1"
13
13
 
14
14
  // Schema hash generated from your RIDL schema
15
- export const WebrpcSchemaHash = '09b3975a1dfcfc5531e352d55f6e474f73165f3a'
15
+ export const WebrpcSchemaHash = "98bbae5f2233d6018b5b0fd94557b0795eecc055"
16
16
 
17
17
  //
18
18
  // Client interface
@@ -52,42 +52,34 @@ 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(
69
- req: GetExactOutputRoutesRequest,
70
- headers?: object,
71
- signal?: AbortSignal
72
- ): Promise<GetExactOutputRoutesResponse>
68
+ getExactOutputRoutes(req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse>
73
69
 
74
70
  /**
75
71
  * GetExactInputRoutes will return a list of destination tokens, when given an origin chain and token,
76
72
  * that can be used to send/swap to a destination chain and token.
77
- *
73
+ *
78
74
  * The request will include the origin chain and token used for input. Optionally, the
79
75
  * user can specify a destination chain and token to further filter the results.
80
- *
76
+ *
81
77
  * The response is a list of destination tokens and their chains which can be reached from
82
78
  * the origin token and chain. These are tokens the user can send TO from the given origin token.
83
- *
79
+ *
84
80
  * aka, the 'swap' routes
85
81
  */
86
- getExactInputRoutes(
87
- req: GetExactInputRoutesRequest,
88
- headers?: object,
89
- signal?: AbortSignal
90
- ): Promise<GetExactInputRoutesResponse>
82
+ getExactInputRoutes(req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse>
91
83
 
92
84
  /**
93
85
  * GetTokenList will return a list of tokens based on the provided filters.
@@ -108,13 +100,10 @@ export interface TrailsClient {
108
100
  /**
109
101
  * @deprecated please use GetIntentHistory instead
110
102
  */
111
- getIntentTransactionHistory(
112
- req: GetIntentTransactionHistoryRequest,
113
- headers?: object,
114
- signal?: AbortSignal
115
- ): Promise<GetIntentTransactionHistoryResponse>
103
+ getIntentTransactionHistory(req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse>
116
104
  }
117
105
 
106
+
118
107
  //
119
108
  // Schema types
120
109
  //
@@ -139,7 +128,8 @@ export enum IntentStatus {
139
128
  EXECUTING = 'EXECUTING',
140
129
  FAILED = 'FAILED',
141
130
  SUCCEEDED = 'SUCCEEDED',
142
- ABORTED = 'ABORTED'
131
+ ABORTED = 'ABORTED',
132
+ REFUNDED = 'REFUNDED'
143
133
  }
144
134
 
145
135
  export enum TransactionType {
@@ -165,7 +155,8 @@ export enum TransactionStatus {
165
155
  MINING = 'MINING',
166
156
  SUCCEEDED = 'SUCCEEDED',
167
157
  FAILED = 'FAILED',
168
- ABORTED = 'ABORTED'
158
+ ABORTED = 'ABORTED',
159
+ REVERTED = 'REVERTED'
169
160
  }
170
161
 
171
162
  export enum ChainGasUsageStatus {
@@ -342,6 +333,19 @@ export interface IntentTransaction {
342
333
  createdAt?: string
343
334
  }
344
335
 
336
+ export interface PriceImpact {
337
+ priceImpact: number
338
+ priceImpactUsd: number
339
+ }
340
+
341
+ export interface PriceImpactDetails {
342
+ executionPriceImpact: PriceImpact
343
+ marketPriceImpact: PriceImpact
344
+ providerFeesPriceImpact: PriceImpact
345
+ trailsFeesPriceImpact: PriceImpact
346
+ netPriceImpact: PriceImpact
347
+ }
348
+
345
349
  export interface IntentProviderQuote {
346
350
  routeProviders: Array<RouteProvider>
347
351
  routeProvidersRequestIds: Array<string>
@@ -357,6 +361,7 @@ export interface IntentProviderQuote {
357
361
  maxSlippage: number
358
362
  priceImpact: number
359
363
  priceImpactUsd: number
364
+ priceImpactDetails: PriceImpactDetails
360
365
  }
361
366
 
362
367
  export interface IntentFees {
@@ -364,7 +369,17 @@ export interface IntentFees {
364
369
  destinationGas?: IntentTransactionGasFee
365
370
  provider: IntentProviderFees
366
371
  feeTokenAddress: string
372
+ feeTokenAmount: bigint
373
+ feeTokenUsd: number
367
374
  feeTokenTotal: bigint
375
+ gasFeeTotal: bigint
376
+ gasFeeUsd: number
377
+ trailsFeeTotal: bigint
378
+ trailsFeeUsd: number
379
+ collectorFeeTotal: bigint
380
+ collectorFeeUsd: number
381
+ providerFeeTotal: bigint
382
+ providerFeeUsd: number
368
383
  totalFeeAmount: bigint
369
384
  totalFeeUsd: number
370
385
  }
@@ -375,6 +390,8 @@ export interface IntentProviderFees {
375
390
  quoteProviderFeeUsd: number
376
391
  trailsFee: bigint
377
392
  trailsFeeUsd: number
393
+ quoteProviderWithTrailsFee: bigint
394
+ providerWithTrailsFeeUsd: number
378
395
  totalFeeAmount: bigint
379
396
  totalFeeUsd: number
380
397
  }
@@ -762,30 +779,51 @@ export interface GetIntentTransactionHistoryResponse {
762
779
  nextPage?: Page
763
780
  }
764
781
 
765
- export interface PingRequest {}
782
+ export interface PingRequest {
783
+ }
766
784
 
767
785
  export interface PingResponse {
768
786
  version: string
769
787
  }
770
788
 
771
- export interface RuntimeStatusRequest {}
789
+ export interface RuntimeStatusRequest {
790
+ }
772
791
 
773
792
  export interface RuntimeStatusResponse {
774
793
  status: RuntimeStatus
775
794
  }
776
795
 
777
- export interface ClockRequest {}
796
+ export interface ClockRequest {
797
+ }
778
798
 
779
799
  export interface ClockResponse {
780
800
  serverTime: string
781
801
  }
782
802
 
783
- export interface GetTrailsContractsRequest {}
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+ export interface GetTrailsContractsRequest {
818
+ }
784
819
 
785
820
  export interface GetTrailsContractsResponse {
786
821
  TrailsContracts: TrailsContracts
787
822
  }
788
823
 
824
+
825
+
826
+
789
827
  //
790
828
  // Client
791
829
  //
@@ -803,7 +841,7 @@ export class Trails implements TrailsClient {
803
841
  private url(name: string): string {
804
842
  return this.hostname + this.path + name
805
843
  }
806
-
844
+
807
845
  queryKey = {
808
846
  ping: () => ['Trails', 'ping'] as const,
809
847
  runtimeStatus: () => ['Trails', 'runtimeStatus'] as const,
@@ -823,288 +861,241 @@ export class Trails implements TrailsClient {
823
861
  getTokenList: (req: GetTokenListRequest) => ['Trails', 'getTokenList', req] as const,
824
862
  getTokenPrices: (req: GetTokenPricesRequest) => ['Trails', 'getTokenPrices', req] as const,
825
863
  getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const,
826
- getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) =>
827
- ['Trails', 'getIntentTransactionHistory', req] as const
864
+ getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) => ['Trails', 'getIntentTransactionHistory', req] as const,
828
865
  }
829
866
 
830
867
  ping = (headers?: object, signal?: AbortSignal): Promise<PingResponse> => {
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
- )
868
+ return this.fetch(
869
+ this.url('Ping'),
870
+ createHttpRequest('{}', headers, signal)).then((res) => {
871
+ return buildResponse(res).then(_data => {
872
+ return JsonDecode<PingResponse>(_data, 'PingResponse')
873
+ })
874
+ }, (error) => {
875
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
876
+ })
841
877
  }
842
878
 
843
879
  runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse> => {
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
- )
880
+ return this.fetch(
881
+ this.url('RuntimeStatus'),
882
+ createHttpRequest('{}', headers, signal)).then((res) => {
883
+ return buildResponse(res).then(_data => {
884
+ return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
885
+ })
886
+ }, (error) => {
887
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
888
+ })
854
889
  }
855
890
 
856
891
  clock = (headers?: object, signal?: AbortSignal): Promise<ClockResponse> => {
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
- )
892
+ return this.fetch(
893
+ this.url('Clock'),
894
+ createHttpRequest('{}', headers, signal)).then((res) => {
895
+ return buildResponse(res).then(_data => {
896
+ return JsonDecode<ClockResponse>(_data, 'ClockResponse')
897
+ })
898
+ }, (error) => {
899
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
900
+ })
867
901
  }
868
902
 
869
903
  quoteIntent = (req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse> => {
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
- )
904
+ return this.fetch(
905
+ this.url('QuoteIntent'),
906
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
907
+ return buildResponse(res).then(_data => {
908
+ return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
909
+ })
910
+ }, (error) => {
911
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
912
+ })
880
913
  }
881
914
 
882
915
  commitIntent = (req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse> => {
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
- )
916
+ return this.fetch(
917
+ this.url('CommitIntent'),
918
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
919
+ return buildResponse(res).then(_data => {
920
+ return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
921
+ })
922
+ }, (error) => {
923
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
924
+ })
893
925
  }
894
926
 
895
927
  executeIntent = (req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse> => {
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
- )
928
+ return this.fetch(
929
+ this.url('ExecuteIntent'),
930
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
931
+ return buildResponse(res).then(_data => {
932
+ return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
933
+ })
934
+ }, (error) => {
935
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
936
+ })
937
+ }
938
+
939
+ waitIntentReceipt = (req: WaitIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<WaitIntentReceiptResponse> => {
940
+ return this.fetch(
941
+ this.url('WaitIntentReceipt'),
942
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
943
+ return buildResponse(res).then(_data => {
944
+ return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
945
+ })
946
+ }, (error) => {
947
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
948
+ })
949
+ }
950
+
951
+ getIntentReceipt = (req: GetIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentReceiptResponse> => {
952
+ return this.fetch(
953
+ this.url('GetIntentReceipt'),
954
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
955
+ return buildResponse(res).then(_data => {
956
+ return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
957
+ })
958
+ }, (error) => {
959
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
960
+ })
940
961
  }
941
962
 
942
963
  getIntent = (req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse> => {
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
- )
964
+ return this.fetch(
965
+ this.url('GetIntent'),
966
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
967
+ return buildResponse(res).then(_data => {
968
+ return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
969
+ })
970
+ }, (error) => {
971
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
972
+ })
953
973
  }
954
974
 
955
975
  searchIntents = (req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse> => {
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
- )
976
+ return this.fetch(
977
+ this.url('SearchIntents'),
978
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
979
+ return buildResponse(res).then(_data => {
980
+ return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
981
+ })
982
+ }, (error) => {
983
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
984
+ })
985
+ }
986
+
987
+ getIntentHistory = (req: GetIntentHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentHistoryResponse> => {
988
+ return this.fetch(
989
+ this.url('GetIntentHistory'),
990
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
991
+ return buildResponse(res).then(_data => {
992
+ return JsonDecode<GetIntentHistoryResponse>(_data, 'GetIntentHistoryResponse')
993
+ })
994
+ }, (error) => {
995
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
996
+ })
983
997
  }
984
998
 
985
999
  abortIntent = (req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse> => {
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
- )
1000
+ return this.fetch(
1001
+ this.url('AbortIntent'),
1002
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1003
+ return buildResponse(res).then(_data => {
1004
+ return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
1005
+ })
1006
+ }, (error) => {
1007
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1008
+ })
996
1009
  }
997
1010
 
998
1011
  getChains = (req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse> => {
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
- )
1012
+ return this.fetch(
1013
+ this.url('GetChains'),
1014
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1015
+ return buildResponse(res).then(_data => {
1016
+ return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
1017
+ })
1018
+ }, (error) => {
1019
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1020
+ })
1021
+ }
1022
+
1023
+ getExactOutputRoutes = (req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse> => {
1024
+ return this.fetch(
1025
+ this.url('GetExactOutputRoutes'),
1026
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1027
+ return buildResponse(res).then(_data => {
1028
+ return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
1029
+ })
1030
+ }, (error) => {
1031
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1032
+ })
1033
+ }
1034
+
1035
+ getExactInputRoutes = (req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse> => {
1036
+ return this.fetch(
1037
+ this.url('GetExactInputRoutes'),
1038
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1039
+ return buildResponse(res).then(_data => {
1040
+ return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
1041
+ })
1042
+ }, (error) => {
1043
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1044
+ })
1043
1045
  }
1044
1046
 
1045
1047
  getTokenList = (req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse> => {
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
- )
1048
+ return this.fetch(
1049
+ this.url('GetTokenList'),
1050
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1051
+ return buildResponse(res).then(_data => {
1052
+ return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
1053
+ })
1054
+ }, (error) => {
1055
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1056
+ })
1056
1057
  }
1057
1058
 
1058
1059
  getTokenPrices = (req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse> => {
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
- )
1060
+ return this.fetch(
1061
+ this.url('GetTokenPrices'),
1062
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1063
+ return buildResponse(res).then(_data => {
1064
+ return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
1065
+ })
1066
+ }, (error) => {
1067
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1068
+ })
1069
1069
  }
1070
1070
 
1071
1071
  getTrailsContracts = (headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse> => {
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
- )
1072
+ return this.fetch(
1073
+ this.url('GetTrailsContracts'),
1074
+ createHttpRequest('{}', headers, signal)).then((res) => {
1075
+ return buildResponse(res).then(_data => {
1076
+ return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
1077
+ })
1078
+ }, (error) => {
1079
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1080
+ })
1099
1081
  }
1082
+
1083
+ getIntentTransactionHistory = (req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse> => {
1084
+ return this.fetch(
1085
+ this.url('GetIntentTransactionHistory'),
1086
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
1087
+ return buildResponse(res).then(_data => {
1088
+ return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
1089
+ })
1090
+ }, (error) => {
1091
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1092
+ })
1093
+ }
1094
+
1100
1095
  }
1101
1096
 
1102
1097
  const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
1103
- const reqHeaders: { [key: string]: string } = {
1104
- ...headers,
1105
- 'Content-Type': 'application/json',
1106
- [WebrpcHeader]: WebrpcHeaderValue
1107
- }
1098
+ const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json', [WebrpcHeader]: WebrpcHeaderValue }
1108
1099
  return { method: 'POST', headers: reqHeaders, body, signal }
1109
1100
  }
1110
1101
 
@@ -1113,14 +1104,14 @@ const buildResponse = (res: Response): Promise<any> => {
1113
1104
  let data
1114
1105
  try {
1115
1106
  data = JSON.parse(text)
1116
- } catch (error) {
1107
+ } catch(error) {
1117
1108
  throw WebrpcBadResponseError.new({
1118
1109
  status: res.status,
1119
- cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
1120
- })
1110
+ cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`},
1111
+ )
1121
1112
  }
1122
1113
  if (!res.ok) {
1123
- const code: number = typeof data.code === 'number' ? data.code : 0
1114
+ const code: number = (typeof data.code === 'number') ? data.code : 0
1124
1115
  throw (webrpcErrorByCode[code] || WebrpcError).new(data)
1125
1116
  }
1126
1117
  return data
@@ -1129,6 +1120,10 @@ const buildResponse = (res: Response): Promise<any> => {
1129
1120
 
1130
1121
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
1131
1122
 
1123
+
1124
+
1125
+
1126
+
1132
1127
  //
1133
1128
  // BigInt helpers
1134
1129
  //
@@ -1145,44 +1140,20 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
1145
1140
  GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
1146
1141
  GetIntentResponse: [['intent', 'Intent']],
1147
1142
  GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
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
- ],
1143
+ Intent: [['quoteRequest', 'QuoteIntentRequest'], 'salt', ['depositTransaction', 'DepositTransaction'], ['originCalls', 'IntentCalls'], ['destinationCalls', 'IntentCalls'], ['originPrecondition', 'TransactionPrecondition'], ['destinationPrecondition', 'TransactionPrecondition'], ['quote', 'IntentProviderQuote'], ['fees', 'IntentFees']],
1159
1144
  IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
1160
- IntentFees: [
1161
- ['originGas', 'IntentTransactionGasFee'],
1162
- ['destinationGas', 'IntentTransactionGasFee'],
1163
- ['provider', 'IntentProviderFees'],
1164
- 'feeTokenTotal',
1165
- 'totalFeeAmount'
1166
- ],
1145
+ IntentFees: [['originGas', 'IntentTransactionGasFee'], ['destinationGas', 'IntentTransactionGasFee'], ['provider', 'IntentProviderFees'], 'feeTokenAmount', 'feeTokenTotal', 'gasFeeTotal', 'trailsFeeTotal', 'collectorFeeTotal', 'providerFeeTotal', 'totalFeeAmount'],
1167
1146
  IntentHistory: [['receipt', 'IntentReceipt']],
1168
- IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'totalFeeAmount'],
1147
+ IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'quoteProviderWithTrailsFee', 'totalFeeAmount'],
1169
1148
  IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
1170
- IntentReceipt: [
1171
- ['depositTransaction', 'IntentTransaction'],
1172
- ['originTransaction', 'IntentTransaction'],
1173
- ['destinationTransaction', 'IntentTransaction'],
1174
- ['summary', 'IntentReceiptSummary']
1175
- ],
1149
+ IntentReceipt: [['depositTransaction', 'IntentTransaction'], ['originTransaction', 'IntentTransaction'], ['destinationTransaction', 'IntentTransaction'], ['summary', 'IntentReceiptSummary']],
1176
1150
  IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
1177
1151
  IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
1178
1152
  IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
1179
1153
  IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
1180
1154
  MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
1181
1155
  QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
1182
- QuoteIntentResponse: [
1183
- ['intent', 'Intent'],
1184
- ['gasFeeOptions', 'GasFeeOptions']
1185
- ],
1156
+ QuoteIntentResponse: [['intent', 'Intent'], ['gasFeeOptions', 'GasFeeOptions']],
1186
1157
  SearchIntentsResponse: [['intents', 'Intent[]']],
1187
1158
  TransactionCall: ['value', 'gasLimit'],
1188
1159
  TransactionPrecondition: ['minAmount'],
@@ -1224,11 +1195,7 @@ function decodeType(typ: string, obj: any): any {
1224
1195
  for (let i = 0; i < arr.length; i++) {
1225
1196
  const v = arr[i]
1226
1197
  if (typeof v === 'string') {
1227
- try {
1228
- arr[i] = BigInt(v)
1229
- } catch (e) {
1230
- throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` })
1231
- }
1198
+ try { arr[i] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` }) }
1232
1199
  }
1233
1200
  }
1234
1201
  }
@@ -1236,11 +1203,7 @@ function decodeType(typ: string, obj: any): any {
1236
1203
  }
1237
1204
  const v = obj[d]
1238
1205
  if (typeof v === 'string') {
1239
- try {
1240
- obj[d] = BigInt(v)
1241
- } catch (e) {
1242
- throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` })
1243
- }
1206
+ try { obj[d] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` }) }
1244
1207
  }
1245
1208
  }
1246
1209
  return obj
@@ -1248,27 +1211,28 @@ function decodeType(typ: string, obj: any): any {
1248
1211
 
1249
1212
  // Encode object to JSON with BigInts converted to decimal strings.
1250
1213
  export const JsonEncode = <T = any>(obj: T): string => {
1251
- return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
1214
+ return JSON.stringify(obj, (key, value) =>
1215
+ typeof value === 'bigint' ? value.toString() : value
1216
+ )
1252
1217
  }
1253
1218
 
1254
1219
  // Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
1255
1220
  export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
1256
1221
  let parsed: any = data
1257
1222
  if (typeof data === 'string') {
1258
- try {
1259
- parsed = JSON.parse(data)
1260
- } catch (err) {
1223
+ try { parsed = JSON.parse(data) } catch (err) {
1261
1224
  throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
1262
1225
  }
1263
1226
  }
1264
1227
  return decodeType(typ, parsed) as T
1265
1228
  }
1266
1229
 
1230
+
1267
1231
  //
1268
1232
  // Errors
1269
1233
  //
1270
1234
 
1271
- type WebrpcErrorParams = { name?: string; code?: number; message?: string; status?: number; cause?: string }
1235
+ type WebrpcErrorParams = { name?: string, code?: number, message?: string, status?: number, cause?: string }
1272
1236
 
1273
1237
  export class WebrpcError extends Error {
1274
1238
  code: number
@@ -1289,6 +1253,7 @@ export class WebrpcError extends Error {
1289
1253
  }
1290
1254
  }
1291
1255
 
1256
+
1292
1257
  export class WebrpcEndpointError extends WebrpcError {
1293
1258
  constructor(error: WebrpcErrorParams = {}) {
1294
1259
  super(error)
@@ -1421,6 +1386,7 @@ export class WebrpcStreamFinishedError extends WebrpcError {
1421
1386
  }
1422
1387
  }
1423
1388
 
1389
+
1424
1390
  //
1425
1391
  // Schema errors
1426
1392
  //
@@ -1797,6 +1763,7 @@ export class IntentsDisabledError extends WebrpcError {
1797
1763
  }
1798
1764
  }
1799
1765
 
1766
+
1800
1767
  export enum errors {
1801
1768
  WebrpcEndpoint = 'WebrpcEndpoint',
1802
1769
  WebrpcRequestFailed = 'WebrpcRequestFailed',
@@ -1839,7 +1806,7 @@ export enum errors {
1839
1806
  ClientOutdated = 'ClientOutdated',
1840
1807
  IntentsSkipped = 'IntentsSkipped',
1841
1808
  QuoteExpired = 'QuoteExpired',
1842
- IntentsDisabled = 'IntentsDisabled'
1809
+ IntentsDisabled = 'IntentsDisabled',
1843
1810
  }
1844
1811
 
1845
1812
  export enum WebrpcErrorCodes {
@@ -1884,7 +1851,7 @@ export enum WebrpcErrorCodes {
1884
1851
  ClientOutdated = 8009,
1885
1852
  IntentsSkipped = 7000,
1886
1853
  QuoteExpired = 7001,
1887
- IntentsDisabled = 9000
1854
+ IntentsDisabled = 9000,
1888
1855
  }
1889
1856
 
1890
1857
  export const webrpcErrorByCode: { [code: number]: any } = {
@@ -1929,61 +1896,64 @@ export const webrpcErrorByCode: { [code: number]: any } = {
1929
1896
  [8009]: ClientOutdatedError,
1930
1897
  [7000]: IntentsSkippedError,
1931
1898
  [7001]: QuoteExpiredError,
1932
- [9000]: IntentsDisabledError
1899
+ [9000]: IntentsDisabledError,
1933
1900
  }
1934
1901
 
1902
+
1903
+
1935
1904
  //
1936
1905
  // Webrpc
1937
1906
  //
1938
1907
 
1939
- export const WebrpcHeader = 'Webrpc'
1908
+ export const WebrpcHeader = "Webrpc"
1940
1909
 
1941
- export const WebrpcHeaderValue = 'webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.18-0c440420'
1910
+ export const WebrpcHeaderValue = "webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.21-67dea3a1"
1942
1911
 
1943
1912
  type WebrpcGenVersions = {
1944
- WebrpcGenVersion: string
1945
- codeGenName: string
1946
- codeGenVersion: string
1947
- schemaName: string
1948
- schemaVersion: string
1949
- }
1913
+ WebrpcGenVersion: string;
1914
+ codeGenName: string;
1915
+ codeGenVersion: string;
1916
+ schemaName: string;
1917
+ schemaVersion: string;
1918
+ };
1950
1919
 
1951
1920
  export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
1952
1921
  const headerValue = headers.get(WebrpcHeader)
1953
1922
  if (!headerValue) {
1954
1923
  return {
1955
- WebrpcGenVersion: '',
1956
- codeGenName: '',
1957
- codeGenVersion: '',
1958
- schemaName: '',
1959
- schemaVersion: ''
1960
- }
1924
+ WebrpcGenVersion: "",
1925
+ codeGenName: "",
1926
+ codeGenVersion: "",
1927
+ schemaName: "",
1928
+ schemaVersion: "",
1929
+ };
1961
1930
  }
1962
1931
 
1963
1932
  return parseWebrpcGenVersions(headerValue)
1964
1933
  }
1965
1934
 
1966
1935
  function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
1967
- const versions = header.split(';')
1936
+ const versions = header.split(";")
1968
1937
  if (versions.length < 3) {
1969
1938
  return {
1970
- WebrpcGenVersion: '',
1971
- codeGenName: '',
1972
- codeGenVersion: '',
1973
- schemaName: '',
1974
- schemaVersion: ''
1975
- }
1939
+ WebrpcGenVersion: "",
1940
+ codeGenName: "",
1941
+ codeGenVersion: "",
1942
+ schemaName: "",
1943
+ schemaVersion: "",
1944
+ };
1976
1945
  }
1977
1946
 
1978
- const [_, WebrpcGenVersion] = versions[0]!.split('@')
1979
- const [codeGenName, codeGenVersion] = versions[1]!.split('@')
1980
- const [schemaName, schemaVersion] = versions[2]!.split('@')
1947
+ const [_, WebrpcGenVersion] = versions[0]!.split("@")
1948
+ const [codeGenName, codeGenVersion] = versions[1]!.split("@")
1949
+ const [schemaName, schemaVersion] = versions[2]!.split("@")
1981
1950
 
1982
1951
  return {
1983
- WebrpcGenVersion: WebrpcGenVersion ?? '',
1984
- codeGenName: codeGenName ?? '',
1985
- codeGenVersion: codeGenVersion ?? '',
1986
- schemaName: schemaName ?? '',
1987
- schemaVersion: schemaVersion ?? ''
1988
- }
1952
+ WebrpcGenVersion: WebrpcGenVersion ?? "",
1953
+ codeGenName: codeGenName ?? "",
1954
+ codeGenVersion: codeGenVersion ?? "",
1955
+ schemaName: schemaName ?? "",
1956
+ schemaVersion: schemaVersion ?? "",
1957
+ };
1989
1958
  }
1959
+