@0xtrails/api 0.8.5 → 0.8.7

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.11-a36d5bb7 11b65deb56f7065d2af9e60794eec15a08b660d3
2
+ // trails-api v1-25.12.13-fc788f3e b1288915141440e4ee1408ee66d337a1c6c35088
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.11-a36d5bb7'
12
+ export const WebrpcSchemaVersion = 'v1-25.12.13-fc788f3e'
13
13
 
14
14
  // Schema hash generated from your RIDL schema
15
- export const WebrpcSchemaHash = '11b65deb56f7065d2af9e60794eec15a08b660d3'
15
+ export const WebrpcSchemaHash = 'b1288915141440e4ee1408ee66d337a1c6c35088'
16
16
 
17
17
  //
18
18
  // Client interface
@@ -39,11 +39,7 @@ export interface TrailsClient {
39
39
 
40
40
  searchIntents(req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse>
41
41
 
42
- getIntentTransactionHistory(
43
- req: GetIntentTransactionHistoryRequest,
44
- headers?: object,
45
- signal?: AbortSignal
46
- ): Promise<GetIntentTransactionHistoryResponse>
42
+ getIntentTransactionHistory(req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse>
47
43
 
48
44
  abortIntent(req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse>
49
45
 
@@ -56,42 +52,34 @@ export interface TrailsClient {
56
52
  * GetExactOutputRoutes will return a list of origin tokens, when given a destination chain and token,
57
53
  * that can be used to pay/send from an origin chain the exact output amount on the
58
54
  * destination chain.
59
- *
55
+ *
60
56
  * The request will include the destination chain and token desired. Optionally, the
61
57
  * user can specify an origin chain and token to filter results to only that specific
62
58
  * origin token. Additionally, an optional owner address can be provided to filter
63
59
  * results to only tokens the owner has a balance on (requires indexer gateway to be
64
60
  * configured).
65
- *
61
+ *
66
62
  * The response is a list of origin tokens and their chains which can be used to fulfill
67
63
  * the exact output request. These are tokens the user can send FROM to achieve the desired
68
64
  * destination token amount.
69
- *
65
+ *
70
66
  * aka, the 'pay' routes
71
67
  */
72
- getExactOutputRoutes(
73
- req: GetExactOutputRoutesRequest,
74
- headers?: object,
75
- signal?: AbortSignal
76
- ): Promise<GetExactOutputRoutesResponse>
68
+ getExactOutputRoutes(req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse>
77
69
 
78
70
  /**
79
71
  * GetExactInputRoutes will return a list of destination tokens, when given an origin chain and token,
80
72
  * that can be used to send/swap to a destination chain and token.
81
- *
73
+ *
82
74
  * The request will include the origin chain and token used for input. Optionally, the
83
75
  * user can specify a destination chain and token to further filter the results.
84
- *
76
+ *
85
77
  * The response is a list of destination tokens and their chains which can be reached from
86
78
  * the origin token and chain. These are tokens the user can send TO from the given origin token.
87
- *
79
+ *
88
80
  * aka, the 'swap' routes
89
81
  */
90
- getExactInputRoutes(
91
- req: GetExactInputRoutesRequest,
92
- headers?: object,
93
- signal?: AbortSignal
94
- ): Promise<GetExactInputRoutesResponse>
82
+ getExactInputRoutes(req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse>
95
83
 
96
84
  /**
97
85
  * GetTokenList will return a list of tokens based on the provided filters.
@@ -110,6 +98,7 @@ export interface TrailsClient {
110
98
  getTrailsContracts(headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse>
111
99
  }
112
100
 
101
+
113
102
  //
114
103
  // Schema types
115
104
  //
@@ -307,8 +296,12 @@ export interface IntentProviderQuote {
307
296
  routeProvidersFeeUsd: Array<number>
308
297
  fromAmount: bigint
309
298
  fromAmountMin: bigint
299
+ fromAmountUsd: number
300
+ fromAmountMinUsd: number
310
301
  toAmount: bigint
311
302
  toAmountMin: bigint
303
+ toAmountUsd: number
304
+ toAmountMinUsd: number
312
305
  maxSlippage: number
313
306
  priceImpact: number
314
307
  priceImpactUsd: number
@@ -374,6 +367,7 @@ export interface IntentSummary {
374
367
  destinationTokenAmount: bigint
375
368
  destinationTokenMetadata: TokenMetadata
376
369
  destinationToAddress: string
370
+ expiresAt: string
377
371
  updatedAt?: string
378
372
  createdAt: string
379
373
  }
@@ -705,30 +699,50 @@ export interface SortBy {
705
699
  order: SortOrder
706
700
  }
707
701
 
708
- export interface PingRequest {}
702
+ export interface PingRequest {
703
+ }
709
704
 
710
705
  export interface PingResponse {
711
706
  version: string
712
707
  }
713
708
 
714
- export interface RuntimeStatusRequest {}
709
+ export interface RuntimeStatusRequest {
710
+ }
715
711
 
716
712
  export interface RuntimeStatusResponse {
717
713
  status: RuntimeStatus
718
714
  }
719
715
 
720
- export interface ClockRequest {}
716
+ export interface ClockRequest {
717
+ }
721
718
 
722
719
  export interface ClockResponse {
723
720
  serverTime: string
724
721
  }
725
722
 
726
- export interface GetTrailsContractsRequest {}
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+ export interface GetTrailsContractsRequest {
738
+ }
727
739
 
728
740
  export interface GetTrailsContractsResponse {
729
741
  TrailsContracts: TrailsContracts
730
742
  }
731
743
 
744
+
745
+
732
746
  //
733
747
  // Client
734
748
  //
@@ -746,7 +760,7 @@ export class Trails implements TrailsClient {
746
760
  private url(name: string): string {
747
761
  return this.hostname + this.path + name
748
762
  }
749
-
763
+
750
764
  queryKey = {
751
765
  ping: () => ['Trails', 'ping'] as const,
752
766
  runtimeStatus: () => ['Trails', 'runtimeStatus'] as const,
@@ -758,278 +772,236 @@ export class Trails implements TrailsClient {
758
772
  getIntentReceipt: (req: GetIntentReceiptRequest) => ['Trails', 'getIntentReceipt', req] as const,
759
773
  getIntent: (req: GetIntentRequest) => ['Trails', 'getIntent', req] as const,
760
774
  searchIntents: (req: SearchIntentsRequest) => ['Trails', 'searchIntents', req] as const,
761
- getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) =>
762
- ['Trails', 'getIntentTransactionHistory', req] as const,
775
+ getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) => ['Trails', 'getIntentTransactionHistory', req] as const,
763
776
  abortIntent: (req: AbortIntentRequest) => ['Trails', 'abortIntent', req] as const,
764
777
  getChains: (req: GetChainsRequest) => ['Trails', 'getChains', req] as const,
765
778
  getExactOutputRoutes: (req: GetExactOutputRoutesRequest) => ['Trails', 'getExactOutputRoutes', req] as const,
766
779
  getExactInputRoutes: (req: GetExactInputRoutesRequest) => ['Trails', 'getExactInputRoutes', req] as const,
767
780
  getTokenList: (req: GetTokenListRequest) => ['Trails', 'getTokenList', req] as const,
768
781
  getTokenPrices: (req: GetTokenPricesRequest) => ['Trails', 'getTokenPrices', req] as const,
769
- getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const
782
+ getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const,
770
783
  }
771
784
 
772
785
  ping = (headers?: object, signal?: AbortSignal): Promise<PingResponse> => {
773
- return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(
774
- res => {
775
- return buildResponse(res).then(_data => {
776
- return JsonDecode<PingResponse>(_data, 'PingResponse')
777
- })
778
- },
779
- error => {
780
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
781
- }
782
- )
786
+ return this.fetch(
787
+ this.url('Ping'),
788
+ createHttpRequest('{}', headers, signal)).then((res) => {
789
+ return buildResponse(res).then(_data => {
790
+ return JsonDecode<PingResponse>(_data, 'PingResponse')
791
+ })
792
+ }, (error) => {
793
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
794
+ })
783
795
  }
784
796
 
785
797
  runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse> => {
786
- return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(
787
- res => {
788
- return buildResponse(res).then(_data => {
789
- return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
790
- })
791
- },
792
- error => {
793
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
794
- }
795
- )
798
+ return this.fetch(
799
+ this.url('RuntimeStatus'),
800
+ createHttpRequest('{}', headers, signal)).then((res) => {
801
+ return buildResponse(res).then(_data => {
802
+ return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
803
+ })
804
+ }, (error) => {
805
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
806
+ })
796
807
  }
797
808
 
798
809
  clock = (headers?: object, signal?: AbortSignal): Promise<ClockResponse> => {
799
- return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then(
800
- res => {
801
- return buildResponse(res).then(_data => {
802
- return JsonDecode<ClockResponse>(_data, 'ClockResponse')
803
- })
804
- },
805
- error => {
806
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
807
- }
808
- )
810
+ return this.fetch(
811
+ this.url('Clock'),
812
+ createHttpRequest('{}', headers, signal)).then((res) => {
813
+ return buildResponse(res).then(_data => {
814
+ return JsonDecode<ClockResponse>(_data, 'ClockResponse')
815
+ })
816
+ }, (error) => {
817
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
818
+ })
809
819
  }
810
820
 
811
821
  quoteIntent = (req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse> => {
812
- return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
813
- res => {
814
- return buildResponse(res).then(_data => {
815
- return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
816
- })
817
- },
818
- error => {
819
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
820
- }
821
- )
822
+ return this.fetch(
823
+ this.url('QuoteIntent'),
824
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
825
+ return buildResponse(res).then(_data => {
826
+ return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
827
+ })
828
+ }, (error) => {
829
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
830
+ })
822
831
  }
823
832
 
824
833
  commitIntent = (req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse> => {
825
- return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
826
- res => {
827
- return buildResponse(res).then(_data => {
828
- return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
829
- })
830
- },
831
- error => {
832
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
833
- }
834
- )
834
+ return this.fetch(
835
+ this.url('CommitIntent'),
836
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
837
+ return buildResponse(res).then(_data => {
838
+ return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
839
+ })
840
+ }, (error) => {
841
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
842
+ })
835
843
  }
836
844
 
837
845
  executeIntent = (req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse> => {
838
- return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
839
- res => {
840
- return buildResponse(res).then(_data => {
841
- return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
842
- })
843
- },
844
- error => {
845
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
846
- }
847
- )
848
- }
849
-
850
- waitIntentReceipt = (
851
- req: WaitIntentReceiptRequest,
852
- headers?: object,
853
- signal?: AbortSignal
854
- ): Promise<WaitIntentReceiptResponse> => {
855
- return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
856
- res => {
857
- return buildResponse(res).then(_data => {
858
- return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
859
- })
860
- },
861
- error => {
862
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
863
- }
864
- )
865
- }
866
-
867
- getIntentReceipt = (
868
- req: GetIntentReceiptRequest,
869
- headers?: object,
870
- signal?: AbortSignal
871
- ): Promise<GetIntentReceiptResponse> => {
872
- return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
873
- res => {
874
- return buildResponse(res).then(_data => {
875
- return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
876
- })
877
- },
878
- error => {
879
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
880
- }
881
- )
846
+ return this.fetch(
847
+ this.url('ExecuteIntent'),
848
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
849
+ return buildResponse(res).then(_data => {
850
+ return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
851
+ })
852
+ }, (error) => {
853
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
854
+ })
855
+ }
856
+
857
+ waitIntentReceipt = (req: WaitIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<WaitIntentReceiptResponse> => {
858
+ return this.fetch(
859
+ this.url('WaitIntentReceipt'),
860
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
861
+ return buildResponse(res).then(_data => {
862
+ return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
863
+ })
864
+ }, (error) => {
865
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
866
+ })
867
+ }
868
+
869
+ getIntentReceipt = (req: GetIntentReceiptRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentReceiptResponse> => {
870
+ return this.fetch(
871
+ this.url('GetIntentReceipt'),
872
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
873
+ return buildResponse(res).then(_data => {
874
+ return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
875
+ })
876
+ }, (error) => {
877
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
878
+ })
882
879
  }
883
880
 
884
881
  getIntent = (req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse> => {
885
- return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
886
- res => {
887
- return buildResponse(res).then(_data => {
888
- return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
889
- })
890
- },
891
- error => {
892
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
893
- }
894
- )
882
+ return this.fetch(
883
+ this.url('GetIntent'),
884
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
885
+ return buildResponse(res).then(_data => {
886
+ return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
887
+ })
888
+ }, (error) => {
889
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
890
+ })
895
891
  }
896
892
 
897
893
  searchIntents = (req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse> => {
898
- return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then(
899
- res => {
900
- return buildResponse(res).then(_data => {
901
- return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
902
- })
903
- },
904
- error => {
905
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
906
- }
907
- )
908
- }
909
-
910
- getIntentTransactionHistory = (
911
- req: GetIntentTransactionHistoryRequest,
912
- headers?: object,
913
- signal?: AbortSignal
914
- ): Promise<GetIntentTransactionHistoryResponse> => {
915
- return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
916
- res => {
917
- return buildResponse(res).then(_data => {
918
- return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
919
- })
920
- },
921
- error => {
922
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
923
- }
924
- )
894
+ return this.fetch(
895
+ this.url('SearchIntents'),
896
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
897
+ return buildResponse(res).then(_data => {
898
+ return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
899
+ })
900
+ }, (error) => {
901
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
902
+ })
903
+ }
904
+
905
+ getIntentTransactionHistory = (req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse> => {
906
+ return this.fetch(
907
+ this.url('GetIntentTransactionHistory'),
908
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
909
+ return buildResponse(res).then(_data => {
910
+ return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
911
+ })
912
+ }, (error) => {
913
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
914
+ })
925
915
  }
926
916
 
927
917
  abortIntent = (req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse> => {
928
- return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
929
- res => {
930
- return buildResponse(res).then(_data => {
931
- return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
932
- })
933
- },
934
- error => {
935
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
936
- }
937
- )
918
+ return this.fetch(
919
+ this.url('AbortIntent'),
920
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
921
+ return buildResponse(res).then(_data => {
922
+ return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
923
+ })
924
+ }, (error) => {
925
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
926
+ })
938
927
  }
939
928
 
940
929
  getChains = (req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse> => {
941
- return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(
942
- res => {
943
- return buildResponse(res).then(_data => {
944
- return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
945
- })
946
- },
947
- error => {
948
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
949
- }
950
- )
951
- }
952
-
953
- getExactOutputRoutes = (
954
- req: GetExactOutputRoutesRequest,
955
- headers?: object,
956
- signal?: AbortSignal
957
- ): Promise<GetExactOutputRoutesResponse> => {
958
- return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
959
- res => {
960
- return buildResponse(res).then(_data => {
961
- return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
962
- })
963
- },
964
- error => {
965
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
966
- }
967
- )
968
- }
969
-
970
- getExactInputRoutes = (
971
- req: GetExactInputRoutesRequest,
972
- headers?: object,
973
- signal?: AbortSignal
974
- ): Promise<GetExactInputRoutesResponse> => {
975
- return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
976
- res => {
977
- return buildResponse(res).then(_data => {
978
- return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
979
- })
980
- },
981
- error => {
982
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
983
- }
984
- )
930
+ return this.fetch(
931
+ this.url('GetChains'),
932
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
933
+ return buildResponse(res).then(_data => {
934
+ return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
935
+ })
936
+ }, (error) => {
937
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
938
+ })
939
+ }
940
+
941
+ getExactOutputRoutes = (req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse> => {
942
+ return this.fetch(
943
+ this.url('GetExactOutputRoutes'),
944
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
945
+ return buildResponse(res).then(_data => {
946
+ return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
947
+ })
948
+ }, (error) => {
949
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
950
+ })
951
+ }
952
+
953
+ getExactInputRoutes = (req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse> => {
954
+ return this.fetch(
955
+ this.url('GetExactInputRoutes'),
956
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
957
+ return buildResponse(res).then(_data => {
958
+ return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
959
+ })
960
+ }, (error) => {
961
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
962
+ })
985
963
  }
986
964
 
987
965
  getTokenList = (req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse> => {
988
- return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then(
989
- res => {
990
- return buildResponse(res).then(_data => {
991
- return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
992
- })
993
- },
994
- error => {
995
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
996
- }
997
- )
966
+ return this.fetch(
967
+ this.url('GetTokenList'),
968
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
969
+ return buildResponse(res).then(_data => {
970
+ return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
971
+ })
972
+ }, (error) => {
973
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
974
+ })
998
975
  }
999
976
 
1000
977
  getTokenPrices = (req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse> => {
1001
- return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1002
- res => {
1003
- return buildResponse(res).then(_data => {
1004
- return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
1005
- })
1006
- },
1007
- error => {
1008
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1009
- }
1010
- )
978
+ return this.fetch(
979
+ this.url('GetTokenPrices'),
980
+ createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
981
+ return buildResponse(res).then(_data => {
982
+ return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
983
+ })
984
+ }, (error) => {
985
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
986
+ })
1011
987
  }
1012
988
 
1013
989
  getTrailsContracts = (headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse> => {
1014
- return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then(
1015
- res => {
1016
- return buildResponse(res).then(_data => {
1017
- return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
1018
- })
1019
- },
1020
- error => {
1021
- throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1022
- }
1023
- )
990
+ return this.fetch(
991
+ this.url('GetTrailsContracts'),
992
+ createHttpRequest('{}', headers, signal)).then((res) => {
993
+ return buildResponse(res).then(_data => {
994
+ return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
995
+ })
996
+ }, (error) => {
997
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
998
+ })
1024
999
  }
1000
+
1025
1001
  }
1026
1002
 
1027
1003
  const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
1028
- const reqHeaders: { [key: string]: string } = {
1029
- ...headers,
1030
- 'Content-Type': 'application/json',
1031
- [WebrpcHeader]: WebrpcHeaderValue
1032
- }
1004
+ const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json', [WebrpcHeader]: WebrpcHeaderValue }
1033
1005
  return { method: 'POST', headers: reqHeaders, body, signal }
1034
1006
  }
1035
1007
 
@@ -1038,14 +1010,14 @@ const buildResponse = (res: Response): Promise<any> => {
1038
1010
  let data
1039
1011
  try {
1040
1012
  data = JSON.parse(text)
1041
- } catch (error) {
1013
+ } catch(error) {
1042
1014
  throw WebrpcBadResponseError.new({
1043
1015
  status: res.status,
1044
- cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
1045
- })
1016
+ cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`},
1017
+ )
1046
1018
  }
1047
1019
  if (!res.ok) {
1048
- const code: number = typeof data.code === 'number' ? data.code : 0
1020
+ const code: number = (typeof data.code === 'number') ? data.code : 0
1049
1021
  throw (webrpcErrorByCode[code] || WebrpcError).new(data)
1050
1022
  }
1051
1023
  return data
@@ -1054,6 +1026,10 @@ const buildResponse = (res: Response): Promise<any> => {
1054
1026
 
1055
1027
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
1056
1028
 
1029
+
1030
+
1031
+
1032
+
1057
1033
  //
1058
1034
  // BigInt helpers
1059
1035
  //
@@ -1069,41 +1045,18 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
1069
1045
  GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
1070
1046
  GetIntentResponse: [['intent', 'Intent']],
1071
1047
  GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
1072
- Intent: [
1073
- ['quoteRequest', 'QuoteIntentRequest'],
1074
- 'salt',
1075
- ['depositTransaction', 'DepositTransaction'],
1076
- ['originCalls', 'IntentCalls'],
1077
- ['destinationCalls', 'IntentCalls'],
1078
- ['originPrecondition', 'TransactionPrecondition'],
1079
- ['destinationPrecondition', 'TransactionPrecondition'],
1080
- ['quote', 'IntentProviderQuote'],
1081
- ['fees', 'IntentFees']
1082
- ],
1048
+ Intent: [['quoteRequest', 'QuoteIntentRequest'], 'salt', ['depositTransaction', 'DepositTransaction'], ['originCalls', 'IntentCalls'], ['destinationCalls', 'IntentCalls'], ['originPrecondition', 'TransactionPrecondition'], ['destinationPrecondition', 'TransactionPrecondition'], ['quote', 'IntentProviderQuote'], ['fees', 'IntentFees']],
1083
1049
  IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
1084
- IntentFees: [
1085
- ['originGas', 'IntentTransactionGasFee'],
1086
- ['destinationGas', 'IntentTransactionGasFee'],
1087
- ['provider', 'IntentProviderFees'],
1088
- 'feeTokenTotal',
1089
- 'totalFeeAmount'
1090
- ],
1050
+ IntentFees: [['originGas', 'IntentTransactionGasFee'], ['destinationGas', 'IntentTransactionGasFee'], ['provider', 'IntentProviderFees'], 'feeTokenTotal', 'totalFeeAmount'],
1091
1051
  IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'totalFeeAmount'],
1092
1052
  IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
1093
- IntentReceipt: [
1094
- ['depositTransaction', 'IntentTransaction'],
1095
- ['originTransaction', 'IntentTransaction'],
1096
- ['destinationTransaction', 'IntentTransaction']
1097
- ],
1053
+ IntentReceipt: [['depositTransaction', 'IntentTransaction'], ['originTransaction', 'IntentTransaction'], ['destinationTransaction', 'IntentTransaction']],
1098
1054
  IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
1099
1055
  IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
1100
1056
  IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
1101
1057
  MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
1102
1058
  QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
1103
- QuoteIntentResponse: [
1104
- ['intent', 'Intent'],
1105
- ['gasFeeOptions', 'GasFeeOptions']
1106
- ],
1059
+ QuoteIntentResponse: [['intent', 'Intent'], ['gasFeeOptions', 'GasFeeOptions']],
1107
1060
  SearchIntentsResponse: [['intents', 'Intent[]']],
1108
1061
  TransactionCall: ['value', 'gasLimit'],
1109
1062
  TransactionPrecondition: ['minAmount'],
@@ -1145,11 +1098,7 @@ function decodeType(typ: string, obj: any): any {
1145
1098
  for (let i = 0; i < arr.length; i++) {
1146
1099
  const v = arr[i]
1147
1100
  if (typeof v === 'string') {
1148
- try {
1149
- arr[i] = BigInt(v)
1150
- } catch (e) {
1151
- throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` })
1152
- }
1101
+ try { arr[i] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` }) }
1153
1102
  }
1154
1103
  }
1155
1104
  }
@@ -1157,11 +1106,7 @@ function decodeType(typ: string, obj: any): any {
1157
1106
  }
1158
1107
  const v = obj[d]
1159
1108
  if (typeof v === 'string') {
1160
- try {
1161
- obj[d] = BigInt(v)
1162
- } catch (e) {
1163
- throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` })
1164
- }
1109
+ try { obj[d] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` }) }
1165
1110
  }
1166
1111
  }
1167
1112
  return obj
@@ -1169,27 +1114,28 @@ function decodeType(typ: string, obj: any): any {
1169
1114
 
1170
1115
  // Encode object to JSON with BigInts converted to decimal strings.
1171
1116
  export const JsonEncode = <T = any>(obj: T): string => {
1172
- return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
1117
+ return JSON.stringify(obj, (key, value) =>
1118
+ typeof value === 'bigint' ? value.toString() : value
1119
+ )
1173
1120
  }
1174
1121
 
1175
1122
  // Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
1176
1123
  export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
1177
1124
  let parsed: any = data
1178
1125
  if (typeof data === 'string') {
1179
- try {
1180
- parsed = JSON.parse(data)
1181
- } catch (err) {
1126
+ try { parsed = JSON.parse(data) } catch (err) {
1182
1127
  throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
1183
1128
  }
1184
1129
  }
1185
1130
  return decodeType(typ, parsed) as T
1186
1131
  }
1187
1132
 
1133
+
1188
1134
  //
1189
1135
  // Errors
1190
1136
  //
1191
1137
 
1192
- type WebrpcErrorParams = { name?: string; code?: number; message?: string; status?: number; cause?: string }
1138
+ type WebrpcErrorParams = { name?: string, code?: number, message?: string, status?: number, cause?: string }
1193
1139
 
1194
1140
  export class WebrpcError extends Error {
1195
1141
  code: number
@@ -1210,6 +1156,7 @@ export class WebrpcError extends Error {
1210
1156
  }
1211
1157
  }
1212
1158
 
1159
+
1213
1160
  export class WebrpcEndpointError extends WebrpcError {
1214
1161
  constructor(error: WebrpcErrorParams = {}) {
1215
1162
  super(error)
@@ -1342,6 +1289,7 @@ export class WebrpcStreamFinishedError extends WebrpcError {
1342
1289
  }
1343
1290
  }
1344
1291
 
1292
+
1345
1293
  //
1346
1294
  // Schema errors
1347
1295
  //
@@ -1718,6 +1666,7 @@ export class IntentsDisabledError extends WebrpcError {
1718
1666
  }
1719
1667
  }
1720
1668
 
1669
+
1721
1670
  export enum errors {
1722
1671
  WebrpcEndpoint = 'WebrpcEndpoint',
1723
1672
  WebrpcRequestFailed = 'WebrpcRequestFailed',
@@ -1760,7 +1709,7 @@ export enum errors {
1760
1709
  ClientOutdated = 'ClientOutdated',
1761
1710
  IntentsSkipped = 'IntentsSkipped',
1762
1711
  QuoteExpired = 'QuoteExpired',
1763
- IntentsDisabled = 'IntentsDisabled'
1712
+ IntentsDisabled = 'IntentsDisabled',
1764
1713
  }
1765
1714
 
1766
1715
  export enum WebrpcErrorCodes {
@@ -1805,7 +1754,7 @@ export enum WebrpcErrorCodes {
1805
1754
  ClientOutdated = 8009,
1806
1755
  IntentsSkipped = 7000,
1807
1756
  QuoteExpired = 7001,
1808
- IntentsDisabled = 9000
1757
+ IntentsDisabled = 9000,
1809
1758
  }
1810
1759
 
1811
1760
  export const webrpcErrorByCode: { [code: number]: any } = {
@@ -1850,61 +1799,64 @@ export const webrpcErrorByCode: { [code: number]: any } = {
1850
1799
  [8009]: ClientOutdatedError,
1851
1800
  [7000]: IntentsSkippedError,
1852
1801
  [7001]: QuoteExpiredError,
1853
- [9000]: IntentsDisabledError
1802
+ [9000]: IntentsDisabledError,
1854
1803
  }
1855
1804
 
1805
+
1806
+
1856
1807
  //
1857
1808
  // Webrpc
1858
1809
  //
1859
1810
 
1860
- export const WebrpcHeader = 'Webrpc'
1811
+ export const WebrpcHeader = "Webrpc"
1861
1812
 
1862
- export const WebrpcHeaderValue = 'webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.11-a36d5bb7'
1813
+ export const WebrpcHeaderValue = 'webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.13-fc788f3e'
1863
1814
 
1864
1815
  type WebrpcGenVersions = {
1865
- WebrpcGenVersion: string
1866
- codeGenName: string
1867
- codeGenVersion: string
1868
- schemaName: string
1869
- schemaVersion: string
1870
- }
1816
+ WebrpcGenVersion: string;
1817
+ codeGenName: string;
1818
+ codeGenVersion: string;
1819
+ schemaName: string;
1820
+ schemaVersion: string;
1821
+ };
1871
1822
 
1872
1823
  export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
1873
1824
  const headerValue = headers.get(WebrpcHeader)
1874
1825
  if (!headerValue) {
1875
1826
  return {
1876
- WebrpcGenVersion: '',
1877
- codeGenName: '',
1878
- codeGenVersion: '',
1879
- schemaName: '',
1880
- schemaVersion: ''
1881
- }
1827
+ WebrpcGenVersion: "",
1828
+ codeGenName: "",
1829
+ codeGenVersion: "",
1830
+ schemaName: "",
1831
+ schemaVersion: "",
1832
+ };
1882
1833
  }
1883
1834
 
1884
1835
  return parseWebrpcGenVersions(headerValue)
1885
1836
  }
1886
1837
 
1887
1838
  function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
1888
- const versions = header.split(';')
1839
+ const versions = header.split(";")
1889
1840
  if (versions.length < 3) {
1890
1841
  return {
1891
- WebrpcGenVersion: '',
1892
- codeGenName: '',
1893
- codeGenVersion: '',
1894
- schemaName: '',
1895
- schemaVersion: ''
1896
- }
1842
+ WebrpcGenVersion: "",
1843
+ codeGenName: "",
1844
+ codeGenVersion: "",
1845
+ schemaName: "",
1846
+ schemaVersion: "",
1847
+ };
1897
1848
  }
1898
1849
 
1899
- const [_, WebrpcGenVersion] = versions[0]!.split('@')
1900
- const [codeGenName, codeGenVersion] = versions[1]!.split('@')
1901
- const [schemaName, schemaVersion] = versions[2]!.split('@')
1850
+ const [_, WebrpcGenVersion] = versions[0]!.split("@")
1851
+ const [codeGenName, codeGenVersion] = versions[1]!.split("@")
1852
+ const [schemaName, schemaVersion] = versions[2]!.split("@")
1902
1853
 
1903
1854
  return {
1904
- WebrpcGenVersion: WebrpcGenVersion ?? '',
1905
- codeGenName: codeGenName ?? '',
1906
- codeGenVersion: codeGenVersion ?? '',
1907
- schemaName: schemaName ?? '',
1908
- schemaVersion: schemaVersion ?? ''
1909
- }
1855
+ WebrpcGenVersion: WebrpcGenVersion ?? "",
1856
+ codeGenName: codeGenName ?? "",
1857
+ codeGenVersion: codeGenVersion ?? "",
1858
+ schemaName: schemaName ?? "",
1859
+ schemaVersion: schemaVersion ?? "",
1860
+ };
1910
1861
  }
1862
+