-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from EnsoFinance/various-features-and-clean-up
FE-1233 and refactor, clean-up
- Loading branch information
Showing
21 changed files
with
324 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Enso Finance | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import axios from 'axios'; | ||
|
||
import { ENSO_API } from '../constants'; | ||
import { API_MultichainOptions, API_MultichainResponse } from '../types/api'; | ||
import { API_Response } from '../types/enso'; | ||
import { parseApiErrorOrReturn } from '../utils/parseApiError'; | ||
|
||
export const getEnsoApiMultichainRoute = async ( | ||
options: API_MultichainOptions, | ||
): Promise<API_MultichainResponse | undefined> => { | ||
const { data } = await axios.post<API_Response<API_MultichainResponse>>( | ||
`${ENSO_API}/api/experimental/multichain/shortcut/route/${options.sourceChainId}/${options.destinationChainId}/${options.fromAddress}`, | ||
JSON.stringify({ | ||
tokenIn: options.tokenIn, | ||
tokenOut: options.tokenOut, | ||
amountIn: options.amountIn, | ||
slippage: options.slippage, | ||
}), | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${options.apiKey}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}, | ||
); | ||
|
||
return parseApiErrorOrReturn(data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { USE_POSITIONS_DATA_SOURCE } from '../constants'; | ||
import { Position } from '../types/api'; | ||
|
||
export type QueryMetaPositionsArgs = Record<never, never>; | ||
export type QueryPositionsResponse = Position[]; | ||
import axios from 'axios'; | ||
|
||
export const getEnsoApiPositions = async (): Promise<QueryPositionsResponse> => { | ||
const response = await fetch(USE_POSITIONS_DATA_SOURCE); | ||
import { USE_POSITIONS_DATA_SOURCE } from '../constants'; | ||
import { API_GetPositionsResponse } from '../types/api'; | ||
import { API_Response } from '../types/enso'; | ||
import { parseApiErrorOrReturn } from '../utils/parseApiError'; | ||
|
||
const json = (await response.json()) as QueryPositionsResponse; | ||
export const getEnsoApiPositions = async (): Promise<API_GetPositionsResponse> => { | ||
const { data } = await axios.get<API_Response<API_GetPositionsResponse>>(USE_POSITIONS_DATA_SOURCE); | ||
|
||
if (!Array.isArray(json)) throw new Error('No valid response'); | ||
return json; | ||
return parseApiErrorOrReturn(data); | ||
}; |
Oops, something went wrong.