@0xtrails/api 0.9.3 → 0.9.4

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.21-67dea3a1 98bbae5f2233d6018b5b0fd94557b0795eecc055
2
+ // trails-api v1-25.12.24-aa15bcd 894b96262ee91cc331115b7f7aaeb656c8d7b55d
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.21-67dea3a1"
12
+ export const WebrpcSchemaVersion = 'v1-25.12.24-aa15bcd'
13
13
 
14
14
  // Schema hash generated from your RIDL schema
15
- export const WebrpcSchemaHash = "98bbae5f2233d6018b5b0fd94557b0795eecc055"
15
+ export const WebrpcSchemaHash = '894b96262ee91cc331115b7f7aaeb656c8d7b55d'
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(req: GetExactOutputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactOutputRoutesResponse>
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(req: GetExactInputRoutesRequest, headers?: object, signal?: AbortSignal): Promise<GetExactInputRoutesResponse>
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.
@@ -100,10 +108,13 @@ export interface TrailsClient {
100
108
  /**
101
109
  * @deprecated please use GetIntentHistory instead
102
110
  */
103
- getIntentTransactionHistory(req: GetIntentTransactionHistoryRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentTransactionHistoryResponse>
111
+ getIntentTransactionHistory(
112
+ req: GetIntentTransactionHistoryRequest,
113
+ headers?: object,
114
+ signal?: AbortSignal
115
+ ): Promise<GetIntentTransactionHistoryResponse>
104
116
  }
105
117
 
106
-
107
118
  //
108
119
  // Schema types
109
120
  //
@@ -779,51 +790,30 @@ export interface GetIntentTransactionHistoryResponse {
779
790
  nextPage?: Page
780
791
  }
781
792
 
782
- export interface PingRequest {
783
- }
793
+ export interface PingRequest {}
784
794
 
785
795
  export interface PingResponse {
786
796
  version: string
787
797
  }
788
798
 
789
- export interface RuntimeStatusRequest {
790
- }
799
+ export interface RuntimeStatusRequest {}
791
800
 
792
801
  export interface RuntimeStatusResponse {
793
802
  status: RuntimeStatus
794
803
  }
795
804
 
796
- export interface ClockRequest {
797
- }
805
+ export interface ClockRequest {}
798
806
 
799
807
  export interface ClockResponse {
800
808
  serverTime: string
801
809
  }
802
810
 
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
-
814
-
815
-
816
-
817
- export interface GetTrailsContractsRequest {
818
- }
811
+ export interface GetTrailsContractsRequest {}
819
812
 
820
813
  export interface GetTrailsContractsResponse {
821
814
  TrailsContracts: TrailsContracts
822
815
  }
823
816
 
824
-
825
-
826
-
827
817
  //
828
818
  // Client
829
819
  //
@@ -841,7 +831,7 @@ export class Trails implements TrailsClient {
841
831
  private url(name: string): string {
842
832
  return this.hostname + this.path + name
843
833
  }
844
-
834
+
845
835
  queryKey = {
846
836
  ping: () => ['Trails', 'ping'] as const,
847
837
  runtimeStatus: () => ['Trails', 'runtimeStatus'] as const,
@@ -861,241 +851,288 @@ export class Trails implements TrailsClient {
861
851
  getTokenList: (req: GetTokenListRequest) => ['Trails', 'getTokenList', req] as const,
862
852
  getTokenPrices: (req: GetTokenPricesRequest) => ['Trails', 'getTokenPrices', req] as const,
863
853
  getTrailsContracts: () => ['Trails', 'getTrailsContracts'] as const,
864
- getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) => ['Trails', 'getIntentTransactionHistory', req] as const,
854
+ getIntentTransactionHistory: (req: GetIntentTransactionHistoryRequest) =>
855
+ ['Trails', 'getIntentTransactionHistory', req] as const
865
856
  }
866
857
 
867
858
  ping = (headers?: object, signal?: AbortSignal): Promise<PingResponse> => {
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
- })
859
+ return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(
860
+ res => {
861
+ return buildResponse(res).then(_data => {
862
+ return JsonDecode<PingResponse>(_data, 'PingResponse')
863
+ })
864
+ },
865
+ error => {
866
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
867
+ }
868
+ )
877
869
  }
878
870
 
879
871
  runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusResponse> => {
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
- })
872
+ return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(
873
+ res => {
874
+ return buildResponse(res).then(_data => {
875
+ return JsonDecode<RuntimeStatusResponse>(_data, 'RuntimeStatusResponse')
876
+ })
877
+ },
878
+ error => {
879
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
880
+ }
881
+ )
889
882
  }
890
883
 
891
884
  clock = (headers?: object, signal?: AbortSignal): Promise<ClockResponse> => {
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
- })
885
+ return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then(
886
+ res => {
887
+ return buildResponse(res).then(_data => {
888
+ return JsonDecode<ClockResponse>(_data, 'ClockResponse')
889
+ })
890
+ },
891
+ error => {
892
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
893
+ }
894
+ )
901
895
  }
902
896
 
903
897
  quoteIntent = (req: QuoteIntentRequest, headers?: object, signal?: AbortSignal): Promise<QuoteIntentResponse> => {
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
- })
898
+ return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
899
+ res => {
900
+ return buildResponse(res).then(_data => {
901
+ return JsonDecode<QuoteIntentResponse>(_data, 'QuoteIntentResponse')
902
+ })
903
+ },
904
+ error => {
905
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
906
+ }
907
+ )
913
908
  }
914
909
 
915
910
  commitIntent = (req: CommitIntentRequest, headers?: object, signal?: AbortSignal): Promise<CommitIntentResponse> => {
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
- })
911
+ return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
912
+ res => {
913
+ return buildResponse(res).then(_data => {
914
+ return JsonDecode<CommitIntentResponse>(_data, 'CommitIntentResponse')
915
+ })
916
+ },
917
+ error => {
918
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
919
+ }
920
+ )
925
921
  }
926
922
 
927
923
  executeIntent = (req: ExecuteIntentRequest, headers?: object, signal?: AbortSignal): Promise<ExecuteIntentResponse> => {
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
- })
924
+ return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
925
+ res => {
926
+ return buildResponse(res).then(_data => {
927
+ return JsonDecode<ExecuteIntentResponse>(_data, 'ExecuteIntentResponse')
928
+ })
929
+ },
930
+ error => {
931
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
932
+ }
933
+ )
934
+ }
935
+
936
+ waitIntentReceipt = (
937
+ req: WaitIntentReceiptRequest,
938
+ headers?: object,
939
+ signal?: AbortSignal
940
+ ): Promise<WaitIntentReceiptResponse> => {
941
+ return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
942
+ res => {
943
+ return buildResponse(res).then(_data => {
944
+ return JsonDecode<WaitIntentReceiptResponse>(_data, 'WaitIntentReceiptResponse')
945
+ })
946
+ },
947
+ error => {
948
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
949
+ }
950
+ )
951
+ }
952
+
953
+ getIntentReceipt = (
954
+ req: GetIntentReceiptRequest,
955
+ headers?: object,
956
+ signal?: AbortSignal
957
+ ): Promise<GetIntentReceiptResponse> => {
958
+ return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
959
+ res => {
960
+ return buildResponse(res).then(_data => {
961
+ return JsonDecode<GetIntentReceiptResponse>(_data, 'GetIntentReceiptResponse')
962
+ })
963
+ },
964
+ error => {
965
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
966
+ }
967
+ )
961
968
  }
962
969
 
963
970
  getIntent = (req: GetIntentRequest, headers?: object, signal?: AbortSignal): Promise<GetIntentResponse> => {
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
- })
971
+ return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
972
+ res => {
973
+ return buildResponse(res).then(_data => {
974
+ return JsonDecode<GetIntentResponse>(_data, 'GetIntentResponse')
975
+ })
976
+ },
977
+ error => {
978
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
979
+ }
980
+ )
973
981
  }
974
982
 
975
983
  searchIntents = (req: SearchIntentsRequest, headers?: object, signal?: AbortSignal): Promise<SearchIntentsResponse> => {
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
- })
984
+ return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then(
985
+ res => {
986
+ return buildResponse(res).then(_data => {
987
+ return JsonDecode<SearchIntentsResponse>(_data, 'SearchIntentsResponse')
988
+ })
989
+ },
990
+ error => {
991
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
992
+ }
993
+ )
994
+ }
995
+
996
+ getIntentHistory = (
997
+ req: GetIntentHistoryRequest,
998
+ headers?: object,
999
+ signal?: AbortSignal
1000
+ ): Promise<GetIntentHistoryResponse> => {
1001
+ return this.fetch(this.url('GetIntentHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1002
+ res => {
1003
+ return buildResponse(res).then(_data => {
1004
+ return JsonDecode<GetIntentHistoryResponse>(_data, 'GetIntentHistoryResponse')
1005
+ })
1006
+ },
1007
+ error => {
1008
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1009
+ }
1010
+ )
997
1011
  }
998
1012
 
999
1013
  abortIntent = (req: AbortIntentRequest, headers?: object, signal?: AbortSignal): Promise<AbortIntentResponse> => {
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
- })
1014
+ return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1015
+ res => {
1016
+ return buildResponse(res).then(_data => {
1017
+ return JsonDecode<AbortIntentResponse>(_data, 'AbortIntentResponse')
1018
+ })
1019
+ },
1020
+ error => {
1021
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1022
+ }
1023
+ )
1009
1024
  }
1010
1025
 
1011
1026
  getChains = (req: GetChainsRequest, headers?: object, signal?: AbortSignal): Promise<GetChainsResponse> => {
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
- })
1027
+ return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1028
+ res => {
1029
+ return buildResponse(res).then(_data => {
1030
+ return JsonDecode<GetChainsResponse>(_data, 'GetChainsResponse')
1031
+ })
1032
+ },
1033
+ error => {
1034
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1035
+ }
1036
+ )
1037
+ }
1038
+
1039
+ getExactOutputRoutes = (
1040
+ req: GetExactOutputRoutesRequest,
1041
+ headers?: object,
1042
+ signal?: AbortSignal
1043
+ ): Promise<GetExactOutputRoutesResponse> => {
1044
+ return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1045
+ res => {
1046
+ return buildResponse(res).then(_data => {
1047
+ return JsonDecode<GetExactOutputRoutesResponse>(_data, 'GetExactOutputRoutesResponse')
1048
+ })
1049
+ },
1050
+ error => {
1051
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1052
+ }
1053
+ )
1054
+ }
1055
+
1056
+ getExactInputRoutes = (
1057
+ req: GetExactInputRoutesRequest,
1058
+ headers?: object,
1059
+ signal?: AbortSignal
1060
+ ): Promise<GetExactInputRoutesResponse> => {
1061
+ return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1062
+ res => {
1063
+ return buildResponse(res).then(_data => {
1064
+ return JsonDecode<GetExactInputRoutesResponse>(_data, 'GetExactInputRoutesResponse')
1065
+ })
1066
+ },
1067
+ error => {
1068
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1069
+ }
1070
+ )
1045
1071
  }
1046
1072
 
1047
1073
  getTokenList = (req: GetTokenListRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenListResponse> => {
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
- })
1074
+ return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1075
+ res => {
1076
+ return buildResponse(res).then(_data => {
1077
+ return JsonDecode<GetTokenListResponse>(_data, 'GetTokenListResponse')
1078
+ })
1079
+ },
1080
+ error => {
1081
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1082
+ }
1083
+ )
1057
1084
  }
1058
1085
 
1059
1086
  getTokenPrices = (req: GetTokenPricesRequest, headers?: object, signal?: AbortSignal): Promise<GetTokenPricesResponse> => {
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
- })
1087
+ return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1088
+ res => {
1089
+ return buildResponse(res).then(_data => {
1090
+ return JsonDecode<GetTokenPricesResponse>(_data, 'GetTokenPricesResponse')
1091
+ })
1092
+ },
1093
+ error => {
1094
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1095
+ }
1096
+ )
1069
1097
  }
1070
1098
 
1071
1099
  getTrailsContracts = (headers?: object, signal?: AbortSignal): Promise<GetTrailsContractsResponse> => {
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
- })
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
- })
1100
+ return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then(
1101
+ res => {
1102
+ return buildResponse(res).then(_data => {
1103
+ return JsonDecode<GetTrailsContractsResponse>(_data, 'GetTrailsContractsResponse')
1104
+ })
1105
+ },
1106
+ error => {
1107
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1108
+ }
1109
+ )
1110
+ }
1111
+
1112
+ getIntentTransactionHistory = (
1113
+ req: GetIntentTransactionHistoryRequest,
1114
+ headers?: object,
1115
+ signal?: AbortSignal
1116
+ ): Promise<GetIntentTransactionHistoryResponse> => {
1117
+ return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
1118
+ res => {
1119
+ return buildResponse(res).then(_data => {
1120
+ return JsonDecode<GetIntentTransactionHistoryResponse>(_data, 'GetIntentTransactionHistoryResponse')
1121
+ })
1122
+ },
1123
+ error => {
1124
+ throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` })
1125
+ }
1126
+ )
1093
1127
  }
1094
-
1095
1128
  }
1096
1129
 
1097
1130
  const createHttpRequest = (body: string = '{}', headers: object = {}, signal: AbortSignal | null = null): object => {
1098
- const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json', [WebrpcHeader]: WebrpcHeaderValue }
1131
+ const reqHeaders: { [key: string]: string } = {
1132
+ ...headers,
1133
+ 'Content-Type': 'application/json',
1134
+ [WebrpcHeader]: WebrpcHeaderValue
1135
+ }
1099
1136
  return { method: 'POST', headers: reqHeaders, body, signal }
1100
1137
  }
1101
1138
 
@@ -1104,14 +1141,14 @@ const buildResponse = (res: Response): Promise<any> => {
1104
1141
  let data
1105
1142
  try {
1106
1143
  data = JSON.parse(text)
1107
- } catch(error) {
1144
+ } catch (error) {
1108
1145
  throw WebrpcBadResponseError.new({
1109
1146
  status: res.status,
1110
- cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`},
1111
- )
1147
+ cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
1148
+ })
1112
1149
  }
1113
1150
  if (!res.ok) {
1114
- const code: number = (typeof data.code === 'number') ? data.code : 0
1151
+ const code: number = typeof data.code === 'number' ? data.code : 0
1115
1152
  throw (webrpcErrorByCode[code] || WebrpcError).new(data)
1116
1153
  }
1117
1154
  return data
@@ -1120,10 +1157,6 @@ const buildResponse = (res: Response): Promise<any> => {
1120
1157
 
1121
1158
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
1122
1159
 
1123
-
1124
-
1125
-
1126
-
1127
1160
  //
1128
1161
  // BigInt helpers
1129
1162
  //
@@ -1140,20 +1173,49 @@ const BIG_INT_FIELDS: { [typ: string]: (string | [string, string])[] } = {
1140
1173
  GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
1141
1174
  GetIntentResponse: [['intent', 'Intent']],
1142
1175
  GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
1143
- Intent: [['quoteRequest', 'QuoteIntentRequest'], 'salt', ['depositTransaction', 'DepositTransaction'], ['originCalls', 'IntentCalls'], ['destinationCalls', 'IntentCalls'], ['originPrecondition', 'TransactionPrecondition'], ['destinationPrecondition', 'TransactionPrecondition'], ['quote', 'IntentProviderQuote'], ['fees', 'IntentFees']],
1176
+ Intent: [
1177
+ ['quoteRequest', 'QuoteIntentRequest'],
1178
+ 'salt',
1179
+ ['depositTransaction', 'DepositTransaction'],
1180
+ ['originCalls', 'IntentCalls'],
1181
+ ['destinationCalls', 'IntentCalls'],
1182
+ ['originPrecondition', 'TransactionPrecondition'],
1183
+ ['destinationPrecondition', 'TransactionPrecondition'],
1184
+ ['quote', 'IntentProviderQuote'],
1185
+ ['fees', 'IntentFees']
1186
+ ],
1144
1187
  IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
1145
- IntentFees: [['originGas', 'IntentTransactionGasFee'], ['destinationGas', 'IntentTransactionGasFee'], ['provider', 'IntentProviderFees'], 'feeTokenAmount', 'feeTokenTotal', 'gasFeeTotal', 'trailsFeeTotal', 'collectorFeeTotal', 'providerFeeTotal', 'totalFeeAmount'],
1188
+ IntentFees: [
1189
+ ['originGas', 'IntentTransactionGasFee'],
1190
+ ['destinationGas', 'IntentTransactionGasFee'],
1191
+ ['provider', 'IntentProviderFees'],
1192
+ 'feeTokenAmount',
1193
+ 'feeTokenTotal',
1194
+ 'gasFeeTotal',
1195
+ 'trailsFeeTotal',
1196
+ 'collectorFeeTotal',
1197
+ 'providerFeeTotal',
1198
+ 'totalFeeAmount'
1199
+ ],
1146
1200
  IntentHistory: [['receipt', 'IntentReceipt']],
1147
1201
  IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'quoteProviderWithTrailsFee', 'totalFeeAmount'],
1148
1202
  IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
1149
- IntentReceipt: [['depositTransaction', 'IntentTransaction'], ['originTransaction', 'IntentTransaction'], ['destinationTransaction', 'IntentTransaction'], ['summary', 'IntentReceiptSummary']],
1203
+ IntentReceipt: [
1204
+ ['depositTransaction', 'IntentTransaction'],
1205
+ ['originTransaction', 'IntentTransaction'],
1206
+ ['destinationTransaction', 'IntentTransaction'],
1207
+ ['summary', 'IntentReceiptSummary']
1208
+ ],
1150
1209
  IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
1151
1210
  IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
1152
1211
  IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
1153
1212
  IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
1154
1213
  MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
1155
1214
  QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
1156
- QuoteIntentResponse: [['intent', 'Intent'], ['gasFeeOptions', 'GasFeeOptions']],
1215
+ QuoteIntentResponse: [
1216
+ ['intent', 'Intent'],
1217
+ ['gasFeeOptions', 'GasFeeOptions']
1218
+ ],
1157
1219
  SearchIntentsResponse: [['intents', 'Intent[]']],
1158
1220
  TransactionCall: ['value', 'gasLimit'],
1159
1221
  TransactionPrecondition: ['minAmount'],
@@ -1195,7 +1257,11 @@ function decodeType(typ: string, obj: any): any {
1195
1257
  for (let i = 0; i < arr.length; i++) {
1196
1258
  const v = arr[i]
1197
1259
  if (typeof v === 'string') {
1198
- try { arr[i] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` }) }
1260
+ try {
1261
+ arr[i] = BigInt(v)
1262
+ } catch (e) {
1263
+ throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` })
1264
+ }
1199
1265
  }
1200
1266
  }
1201
1267
  }
@@ -1203,7 +1269,11 @@ function decodeType(typ: string, obj: any): any {
1203
1269
  }
1204
1270
  const v = obj[d]
1205
1271
  if (typeof v === 'string') {
1206
- try { obj[d] = BigInt(v) } catch (e) { throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` }) }
1272
+ try {
1273
+ obj[d] = BigInt(v)
1274
+ } catch (e) {
1275
+ throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` })
1276
+ }
1207
1277
  }
1208
1278
  }
1209
1279
  return obj
@@ -1211,28 +1281,27 @@ function decodeType(typ: string, obj: any): any {
1211
1281
 
1212
1282
  // Encode object to JSON with BigInts converted to decimal strings.
1213
1283
  export const JsonEncode = <T = any>(obj: T): string => {
1214
- return JSON.stringify(obj, (key, value) =>
1215
- typeof value === 'bigint' ? value.toString() : value
1216
- )
1284
+ return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
1217
1285
  }
1218
1286
 
1219
1287
  // Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
1220
1288
  export const JsonDecode = <T = any>(data: string | any, typ: string = ''): T => {
1221
1289
  let parsed: any = data
1222
1290
  if (typeof data === 'string') {
1223
- try { parsed = JSON.parse(data) } catch (err) {
1291
+ try {
1292
+ parsed = JSON.parse(data)
1293
+ } catch (err) {
1224
1294
  throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${(err as Error).message}` })
1225
1295
  }
1226
1296
  }
1227
1297
  return decodeType(typ, parsed) as T
1228
1298
  }
1229
1299
 
1230
-
1231
1300
  //
1232
1301
  // Errors
1233
1302
  //
1234
1303
 
1235
- type WebrpcErrorParams = { name?: string, code?: number, message?: string, status?: number, cause?: string }
1304
+ type WebrpcErrorParams = { name?: string; code?: number; message?: string; status?: number; cause?: string }
1236
1305
 
1237
1306
  export class WebrpcError extends Error {
1238
1307
  code: number
@@ -1253,7 +1322,6 @@ export class WebrpcError extends Error {
1253
1322
  }
1254
1323
  }
1255
1324
 
1256
-
1257
1325
  export class WebrpcEndpointError extends WebrpcError {
1258
1326
  constructor(error: WebrpcErrorParams = {}) {
1259
1327
  super(error)
@@ -1386,7 +1454,6 @@ export class WebrpcStreamFinishedError extends WebrpcError {
1386
1454
  }
1387
1455
  }
1388
1456
 
1389
-
1390
1457
  //
1391
1458
  // Schema errors
1392
1459
  //
@@ -1763,7 +1830,6 @@ export class IntentsDisabledError extends WebrpcError {
1763
1830
  }
1764
1831
  }
1765
1832
 
1766
-
1767
1833
  export enum errors {
1768
1834
  WebrpcEndpoint = 'WebrpcEndpoint',
1769
1835
  WebrpcRequestFailed = 'WebrpcRequestFailed',
@@ -1806,7 +1872,7 @@ export enum errors {
1806
1872
  ClientOutdated = 'ClientOutdated',
1807
1873
  IntentsSkipped = 'IntentsSkipped',
1808
1874
  QuoteExpired = 'QuoteExpired',
1809
- IntentsDisabled = 'IntentsDisabled',
1875
+ IntentsDisabled = 'IntentsDisabled'
1810
1876
  }
1811
1877
 
1812
1878
  export enum WebrpcErrorCodes {
@@ -1851,7 +1917,7 @@ export enum WebrpcErrorCodes {
1851
1917
  ClientOutdated = 8009,
1852
1918
  IntentsSkipped = 7000,
1853
1919
  QuoteExpired = 7001,
1854
- IntentsDisabled = 9000,
1920
+ IntentsDisabled = 9000
1855
1921
  }
1856
1922
 
1857
1923
  export const webrpcErrorByCode: { [code: number]: any } = {
@@ -1896,64 +1962,61 @@ export const webrpcErrorByCode: { [code: number]: any } = {
1896
1962
  [8009]: ClientOutdatedError,
1897
1963
  [7000]: IntentsSkippedError,
1898
1964
  [7001]: QuoteExpiredError,
1899
- [9000]: IntentsDisabledError,
1965
+ [9000]: IntentsDisabledError
1900
1966
  }
1901
1967
 
1902
-
1903
-
1904
1968
  //
1905
1969
  // Webrpc
1906
1970
  //
1907
1971
 
1908
- export const WebrpcHeader = "Webrpc"
1972
+ export const WebrpcHeader = 'Webrpc'
1909
1973
 
1910
- export const WebrpcHeaderValue = "webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.21-67dea3a1"
1974
+ export const WebrpcHeaderValue = 'webrpc@v0.31.3;gen-typescript@v0.23.1;trails-api@v1-25.12.24-aa15bcd'
1911
1975
 
1912
1976
  type WebrpcGenVersions = {
1913
- WebrpcGenVersion: string;
1914
- codeGenName: string;
1915
- codeGenVersion: string;
1916
- schemaName: string;
1917
- schemaVersion: string;
1918
- };
1977
+ WebrpcGenVersion: string
1978
+ codeGenName: string
1979
+ codeGenVersion: string
1980
+ schemaName: string
1981
+ schemaVersion: string
1982
+ }
1919
1983
 
1920
1984
  export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
1921
1985
  const headerValue = headers.get(WebrpcHeader)
1922
1986
  if (!headerValue) {
1923
1987
  return {
1924
- WebrpcGenVersion: "",
1925
- codeGenName: "",
1926
- codeGenVersion: "",
1927
- schemaName: "",
1928
- schemaVersion: "",
1929
- };
1988
+ WebrpcGenVersion: '',
1989
+ codeGenName: '',
1990
+ codeGenVersion: '',
1991
+ schemaName: '',
1992
+ schemaVersion: ''
1993
+ }
1930
1994
  }
1931
1995
 
1932
1996
  return parseWebrpcGenVersions(headerValue)
1933
1997
  }
1934
1998
 
1935
1999
  function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
1936
- const versions = header.split(";")
2000
+ const versions = header.split(';')
1937
2001
  if (versions.length < 3) {
1938
2002
  return {
1939
- WebrpcGenVersion: "",
1940
- codeGenName: "",
1941
- codeGenVersion: "",
1942
- schemaName: "",
1943
- schemaVersion: "",
1944
- };
2003
+ WebrpcGenVersion: '',
2004
+ codeGenName: '',
2005
+ codeGenVersion: '',
2006
+ schemaName: '',
2007
+ schemaVersion: ''
2008
+ }
1945
2009
  }
1946
2010
 
1947
- const [_, WebrpcGenVersion] = versions[0]!.split("@")
1948
- const [codeGenName, codeGenVersion] = versions[1]!.split("@")
1949
- const [schemaName, schemaVersion] = versions[2]!.split("@")
2011
+ const [_, WebrpcGenVersion] = versions[0]!.split('@')
2012
+ const [codeGenName, codeGenVersion] = versions[1]!.split('@')
2013
+ const [schemaName, schemaVersion] = versions[2]!.split('@')
1950
2014
 
1951
2015
  return {
1952
- WebrpcGenVersion: WebrpcGenVersion ?? "",
1953
- codeGenName: codeGenName ?? "",
1954
- codeGenVersion: codeGenVersion ?? "",
1955
- schemaName: schemaName ?? "",
1956
- schemaVersion: schemaVersion ?? "",
1957
- };
2016
+ WebrpcGenVersion: WebrpcGenVersion ?? '',
2017
+ codeGenName: codeGenName ?? '',
2018
+ codeGenVersion: codeGenVersion ?? '',
2019
+ schemaName: schemaName ?? '',
2020
+ schemaVersion: schemaVersion ?? ''
2021
+ }
1958
2022
  }
1959
-