Skip to content

Commit 52bb994

Browse files
authored
fix: remove duplicated getRoutes logic (#66)
* chore: bump packages * fix: remove duplicated getRoutes logic
1 parent 5d9319c commit 52bb994

File tree

3 files changed

+164
-184
lines changed

3 files changed

+164
-184
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"dependencies": {
5252
"@ethersproject/abi": "^5.6.1",
5353
"@ethersproject/contracts": "^5.4.0",
54-
"@lifinance/types": "0.13.0",
54+
"@lifinance/types": "^0.13.1",
5555
"axios": "^0.27.2",
5656
"bignumber.js": "^9.0.1",
5757
"eth-rpc-errors": "^4.0.3",
@@ -63,26 +63,26 @@
6363
"@types/bip39": "^3.0.0",
6464
"@types/chai": "^4.3.1",
6565
"@types/hdkey": "^2.0.0",
66-
"@types/jest": "^27.5.0",
66+
"@types/jest": "^27.5.1",
6767
"@types/pino": "^7.0.5",
6868
"@types/websocket": "^1.0.4",
69-
"@typescript-eslint/eslint-plugin": "^5.22.0",
70-
"@typescript-eslint/parser": "^5.22.0",
71-
"eslint": "^8.14.0",
69+
"@typescript-eslint/eslint-plugin": "^5.23.0",
70+
"@typescript-eslint/parser": "^5.23.0",
71+
"eslint": "^8.15.0",
7272
"eslint-config-prettier": "^8.3.0",
7373
"eslint-plugin-prettier": "^4.0.0",
74-
"husky": "^7.0.2",
74+
"husky": "^8.0.1",
7575
"jest": "^28.1.0",
7676
"lint-staged": ">=12.4.1",
7777
"npm-run-all": "^4.1.5",
7878
"pino": "^7.11.0",
7979
"pinst": "^3.0.0",
8080
"prettier": "^2.4.0",
8181
"standard-version": "^9.3.2",
82-
"ts-jest": "^28.0.1",
82+
"ts-jest": "^28.0.2",
8383
"ts-loader": "^9.3.0",
8484
"typescript": "^4.6.4",
85-
"webpack": "^5.72.0",
85+
"webpack": "^5.72.1",
8686
"webpack-cli": "^4.8.0"
8787
},
8888
"directories": {

src/Lifi.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
ToolsResponse,
2020
} from '@lifinance/types'
2121
import { GetStatusRequest } from '@lifinance/types/dist/api'
22-
import axios from 'axios'
2322
import { Signer } from 'ethers'
2423
import {
2524
approveToken,
@@ -35,7 +34,7 @@ import { StepExecutor } from './execution/StepExecutor'
3534
import ApiService from './services/ApiService'
3635
import ChainsService from './services/ChainsService'
3736
import ConfigService from './services/ConfigService'
38-
import { isRoutesRequest, isToken } from './typeguards'
37+
import { isToken } from './typeguards'
3938
import {
4039
ActiveRouteDictionary,
4140
Config,
@@ -45,7 +44,6 @@ import {
4544
RevokeTokenData,
4645
} from './types'
4746
import { ValidationError } from './utils/errors'
48-
import { parseBackendError } from './utils/parseError'
4947
import { deepClone } from './utils/utils'
5048

5149
export default class LIFI {
@@ -168,29 +166,8 @@ export default class LIFI {
168166
* @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
169167
* @throws {LifiError} Throws a LifiError if request fails.
170168
*/
171-
getRoutes = async (routesRequest: RoutesRequest): Promise<RoutesResponse> => {
172-
if (!isRoutesRequest(routesRequest)) {
173-
throw new ValidationError('Invalid routes request.')
174-
}
175-
176-
const config = this.configService.getConfig()
177-
178-
// apply defaults
179-
routesRequest.options = {
180-
...config.defaultRouteOptions,
181-
...routesRequest.options,
182-
}
183-
184-
// send request
185-
try {
186-
const result = await axios.post<RoutesResponse>(
187-
config.apiUrl + 'advanced/routes',
188-
routesRequest
189-
)
190-
return result.data
191-
} catch (e) {
192-
throw parseBackendError(e)
193-
}
169+
getRoutes = async (request: RoutesRequest): Promise<RoutesResponse> => {
170+
return ApiService.getRoutes(request)
194171
}
195172

196173
/**

0 commit comments

Comments
 (0)