Skip to content

Commit 36d7b55

Browse files
committed
fix: fix types for requests cancellation
1 parent 15f2dfd commit 36d7b55

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

src/Lifi.ts

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import {
33
Chain,
44
ChainId,
55
ChainKey,
6+
GetStatusRequest,
67
PossibilitiesRequest,
78
PossibilitiesResponse,
89
QuoteRequest,
10+
RequestOptions,
911
Route,
1012
RoutesRequest,
1113
RoutesResponse,
@@ -18,7 +20,6 @@ import {
1820
ToolsRequest,
1921
ToolsResponse,
2022
} from '@lifinance/types'
21-
import { GetStatusRequest } from '@lifinance/types/dist/api'
2223
import { Signer } from 'ethers'
2324
import {
2425
approveToken,
@@ -97,9 +98,10 @@ export default class LIFI {
9798
* @throws {LifiError} Throws a LifiError if request fails.
9899
*/
99100
getPossibilities = async (
100-
request?: PossibilitiesRequest
101+
request?: PossibilitiesRequest,
102+
options?: RequestOptions
101103
): Promise<PossibilitiesResponse> => {
102-
return ApiService.getPossibilities(request)
104+
return ApiService.getPossibilities(request, options)
103105
}
104106

105107
/**
@@ -110,45 +112,58 @@ export default class LIFI {
110112
*/
111113
getToken = async (
112114
chain: ChainKey | ChainId,
113-
token: string
115+
token: string,
116+
options?: RequestOptions
114117
): Promise<Token> => {
115-
return ApiService.getToken(chain, token)
118+
return ApiService.getToken(chain, token, options)
116119
}
117120

118121
/**
119122
* Get a quote for a token transfer
120123
* @param {QuoteRequest} request - The configuration of the requested quote
121124
* @throws {LifiError} - Throws a LifiError if request fails
122125
*/
123-
getQuote = async (request: QuoteRequest): Promise<Step> => {
124-
return ApiService.getQuote(request)
126+
getQuote = async (
127+
request: QuoteRequest,
128+
options?: RequestOptions
129+
): Promise<Step> => {
130+
return ApiService.getQuote(request, options)
125131
}
126132

127133
/**
128134
* Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
129135
* @param {GetStatusRequest} request - Configuration of the requested status
130136
* @throws {LifiError} - Throws a LifiError if request fails
131137
*/
132-
getStatus = async (request: GetStatusRequest): Promise<StatusResponse> => {
133-
return ApiService.getStatus(request)
138+
getStatus = async (
139+
request: GetStatusRequest,
140+
options?: RequestOptions
141+
): Promise<StatusResponse> => {
142+
return ApiService.getStatus(request, options)
134143
}
135144

136145
/**
137146
* Get the available tools to bridge and swap tokens.
138147
* @param {ToolsRequest?} request - The configuration of the requested tools
139148
* @returns The tools that are available on the requested chains
140149
*/
141-
getTools = async (request?: ToolsRequest): Promise<ToolsResponse> => {
142-
return ApiService.getTools(request || {})
150+
getTools = async (
151+
request?: ToolsRequest,
152+
options?: RequestOptions
153+
): Promise<ToolsResponse> => {
154+
return ApiService.getTools(request || {}, options)
143155
}
144156

145157
/**
146158
* Get all known tokens.
147159
* @param {TokensRequest?} request - The configuration of the requested tokens
148160
* @returns The tokens that are available on the requested chains
149161
*/
150-
getTokens = async (request?: TokensRequest): Promise<TokensResponse> => {
151-
return ApiService.getTokens(request || {})
162+
getTokens = async (
163+
request?: TokensRequest,
164+
options?: RequestOptions
165+
): Promise<TokensResponse> => {
166+
return ApiService.getTokens(request || {}, options)
152167
}
153168

154169
/**
@@ -166,8 +181,11 @@ export default class LIFI {
166181
* @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
167182
* @throws {LifiError} Throws a LifiError if request fails.
168183
*/
169-
getRoutes = async (request: RoutesRequest): Promise<RoutesResponse> => {
170-
return ApiService.getRoutes(request)
184+
getRoutes = async (
185+
request: RoutesRequest,
186+
options?: RequestOptions
187+
): Promise<RoutesResponse> => {
188+
return ApiService.getRoutes(request, options)
171189
}
172190

173191
/**
@@ -176,8 +194,11 @@ export default class LIFI {
176194
* @return {Promise<Step>} The step populated with the transaction data.
177195
* @throws {LifiError} Throws a LifiError if request fails.
178196
*/
179-
getStepTransaction = async (step: Step): Promise<Step> => {
180-
return ApiService.getStepTransaction(step)
197+
getStepTransaction = async (
198+
step: Step,
199+
options?: RequestOptions
200+
): Promise<Step> => {
201+
return ApiService.getStepTransaction(step, options)
181202
}
182203

183204
/**

0 commit comments

Comments
 (0)