This repository was archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1689 - Quote endpoint] Consolidate waterfall PRs:
* useGetGpApiStatus hook (mocked) 1. checks api to use 2. mocked right now * export type * [1689 - Quote endpoint] useOrderValidTo hook (#1728) * useOrderValidTo hook - syntactic sugar for getting validTo time (unix u32) from deadline TTL * [1689 - Quote endpoint] update Error objects to include new fee > sell error (#1758) * update Error objects to include new fee > sell error * [1689 - Quote endpoint] update gp v2 contracts 1.1.2 & set env check (#1759) * add default Gp_Api_Status to env * update to 1.1.2 gp-v2-contracts yarn lock [email protected] * [1689 - Quote Endpoint] Add new quote getting methods in API and Price (fix types) (#1772) * utils/price: add new quote logic * gnosisProtocol API - add new quote logic 1. map old params to new 2. add post logic * add legacy/new to index * use gpStatus and new api method in useRefetch and Unfillable * set mock to LEGACY (temp) * add validTo to necessary places * [1689 - Quote Endpoint] getQuote > replace getFeeQuote and getPriceQuote (#1773) * change getPriceQuote and getFeeQuote - getQuote - one endpoint * [1689 - Quote endpoint] Fix Cypress Fee test (#1775) * setup fee test for new endpoint * add mock quote data and fix command for stubs
- Loading branch information
Showing
20 changed files
with
297 additions
and
100 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
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
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
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,39 @@ | ||
import ms from 'ms.macro' | ||
import { useState, useEffect } from 'react' | ||
|
||
export type GpQuoteStatus = 'COWSWAP' | 'LEGACY' | ||
// TODO: use actual API call | ||
export async function checkGpQuoteApiStatus(): Promise<GpQuoteStatus> { | ||
return new Promise((accept) => setTimeout(() => accept('LEGACY'), 500)) | ||
} | ||
const GP_QUOTE_STATUS_INTERVAL_TIME = ms`2 hours` | ||
|
||
export default function useCheckGpQuoteStatus(defaultApiToUse: GpQuoteStatus): GpQuoteStatus { | ||
const [gpQuoteApiStatus, setGpQuoteApiStatus] = useState<GpQuoteStatus>(defaultApiToUse) | ||
|
||
useEffect(() => { | ||
console.debug('[useGetQuoteCallback::GP API Status]::', gpQuoteApiStatus) | ||
|
||
const checkStatus = () => { | ||
checkGpQuoteApiStatus() | ||
.then(setGpQuoteApiStatus) | ||
.catch((err: Error) => { | ||
console.error('[useGetQuoteCallback::useEffect] Error getting GP quote status::', err) | ||
// Fallback to LEGACY | ||
setGpQuoteApiStatus('LEGACY') | ||
}) | ||
} | ||
|
||
// Create initial call on mount | ||
checkStatus() | ||
|
||
// set interval for GP_QUOTE_STATUS_INTERVAL_TIME (2 hours) | ||
const intervalId = setInterval(() => { | ||
checkStatus() | ||
}, GP_QUOTE_STATUS_INTERVAL_TIME) | ||
|
||
return () => clearInterval(intervalId) | ||
}, [gpQuoteApiStatus]) | ||
|
||
return gpQuoteApiStatus | ||
} |
Oops, something went wrong.