-
Notifications
You must be signed in to change notification settings - Fork 112
Feat/Crosschain LOs #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/Crosschain LOs #219
Changes from all commits
0fbf192
8e40178
ddf10ab
ed6f34c
16d832d
8480674
c0eaaea
553fed3
11b3605
0194d35
5fca9c9
df8b577
0fe432d
8c27c22
20beea5
a0c5df8
8b0b553
143ce8b
cf590c1
50ea0e9
f574096
0e5c219
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { API_URL } from '../../constants'; | ||
| import { constructSearchString } from '../../helpers/misc'; | ||
| import type { | ||
| Address, | ||
| ConstructFetchInput, | ||
|
|
@@ -10,29 +11,81 @@ import type { | |
| export type BridgeInfo = Record<number, Record<number, Address[]>>; | ||
| type BridgeInfoResponse = { supportedTokens: BridgeInfo }; | ||
|
|
||
| type GetBridgeInfo = (requestParams?: RequestParameters) => Promise<BridgeInfo>; | ||
| type GetBridgeInfoParams = { | ||
| /** @description Include tokens that can be swapped on destChain after bridge. Default is true. */ | ||
| allowBridgeAndSwap?: boolean; | ||
| /** @description Include only the specified bridges. Default is all bridges. */ | ||
| bridges?: string[]; | ||
| }; | ||
|
|
||
| type BridgeInfoQuery = { | ||
| allowBridgeAndSwap?: boolean; | ||
| bridges?: string; | ||
| }; | ||
|
|
||
| type GetBridgeInfo = ( | ||
| params?: GetBridgeInfoParams, | ||
| requestParams?: RequestParameters | ||
| ) => Promise<BridgeInfo>; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Breaking API change in
|
||
|
|
||
| export type BridgeProtocolResponse = { | ||
| protocol: string; | ||
| displayName: string; | ||
| }; | ||
|
|
||
| type BridgeProtocolsResponse = { | ||
| bridgeProtocols: BridgeProtocolResponse[]; | ||
| }; | ||
|
|
||
| type GetBridgeProtocols = ( | ||
| requestParams?: RequestParameters | ||
| ) => Promise<BridgeProtocolResponse[]>; | ||
|
|
||
| export type GetBridgeInfoFunctions = { | ||
| getBridgeInfo: GetBridgeInfo; | ||
| getBridgeProtocols: GetBridgeProtocols; | ||
| }; | ||
|
|
||
| export const constructGetBridgeInfo = ({ | ||
| apiURL = API_URL, | ||
| fetcher, | ||
| }: ConstructFetchInput): GetBridgeInfoFunctions => { | ||
| const bridgeInfoUrl = `${apiURL}/delta/prices/bridge-info` as const; | ||
| const deltaBridgeUrl = `${apiURL}/delta/prices` as const; | ||
|
|
||
| const getBridgeInfo: GetBridgeInfo = async (params = {}, requestParams) => { | ||
| const { allowBridgeAndSwap, bridges } = params; | ||
| const bridgesString = bridges ? bridges.join(',') : undefined; | ||
|
|
||
| const search = constructSearchString<BridgeInfoQuery>({ | ||
| allowBridgeAndSwap, | ||
| bridges: bridgesString, | ||
| }); | ||
|
|
||
| const fetchURL = `${deltaBridgeUrl}/bridge-info${search}` as const; | ||
|
|
||
| const getBridgeInfo: GetBridgeInfo = async (requestParams) => { | ||
| const data = await fetcher<BridgeInfoResponse>({ | ||
| url: bridgeInfoUrl, | ||
| url: fetchURL, | ||
| method: 'GET', | ||
| requestParams, | ||
| }); | ||
|
|
||
| return data.supportedTokens; | ||
| }; | ||
|
|
||
| const getBridgeProtocols: GetBridgeProtocols = async (requestParams) => { | ||
| const fetchURL = `${deltaBridgeUrl}/bridge-protocols` as const; | ||
|
|
||
| const data = await fetcher<BridgeProtocolsResponse>({ | ||
| url: fetchURL, | ||
| method: 'GET', | ||
| requestParams, | ||
| }); | ||
|
|
||
| return data.bridgeProtocols; | ||
| }; | ||
|
|
||
| return { | ||
| getBridgeInfo, | ||
| getBridgeProtocols, | ||
| }; | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.