From 0172c92e3a3df1220561a600363477b1909b1c64 Mon Sep 17 00:00:00 2001 From: w3stside Date: Wed, 15 Jun 2022 11:27:58 +0100 Subject: [PATCH 1/6] return the proper price --- src/custom/utils/price.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/custom/utils/price.ts b/src/custom/utils/price.ts index 756cb74476..9a11ce6bd1 100644 --- a/src/custom/utils/price.ts +++ b/src/custom/utils/price.ts @@ -413,9 +413,7 @@ export async function getGpUsdcPrice({ strategy, quoteParams }: Pick Date: Sat, 18 Jun 2022 16:17:04 +0100 Subject: [PATCH 2/6] use hook validTo time --- src/custom/utils/price.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/custom/utils/price.ts b/src/custom/utils/price.ts index 9a11ce6bd1..9fae815e99 100644 --- a/src/custom/utils/price.ts +++ b/src/custom/utils/price.ts @@ -20,7 +20,6 @@ import { GetQuoteResponse, OrderKind } from '@cowprotocol/contracts' import { ChainId } from 'state/lists/actions' import { toErc20Address } from 'utils/tokens' import { GpPriceStrategy } from 'hooks/useGetGpPriceStrategy' -import { MAX_VALID_TO_EPOCH } from 'hooks/useSwapCallback' import useSWR from 'swr' const FEE_EXCEEDS_FROM_ERROR = new GpQuoteError({ @@ -410,7 +409,6 @@ export async function getGpUsdcPrice({ strategy, quoteParams }: Pick Date: Mon, 20 Jun 2022 14:29:37 +0100 Subject: [PATCH 3/6] send null explicitly if currency is falsy (#699) --- src/custom/pages/Swap/SwapMod.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom/pages/Swap/SwapMod.tsx b/src/custom/pages/Swap/SwapMod.tsx index 0d0eab89a3..ffcdcba6e3 100644 --- a/src/custom/pages/Swap/SwapMod.tsx +++ b/src/custom/pages/Swap/SwapMod.tsx @@ -662,7 +662,7 @@ export default function Swap({ } value={formattedAmounts[Field.INPUT]} showMaxButton={showMaxButton} - currency={currencies[Field.INPUT]} + currency={currencies[Field.INPUT] ?? null} onUserInput={handleTypeInput} onMax={handleMaxInput} fiatValue={fiatValueInput ?? undefined} @@ -726,7 +726,7 @@ export default function Swap({ fiatValue={fiatValueOutput ?? undefined} priceImpact={onWrap ? undefined : priceImpact} priceImpactLoading={priceImpactLoading} - currency={currencies[Field.OUTPUT]} + currency={currencies[Field.OUTPUT] ?? null} onCurrencySelect={handleOutputSelect} otherCurrency={currencies[Field.INPUT]} showCommonBases={true} From cae969f93d23fb84d5396126d56f61a353a8a6a0 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 20 Jun 2022 14:32:01 +0100 Subject: [PATCH 4/6] Fix swap.cow.fi appData bug (#698) * fix env files (fixes environment regex) * Update .env Co-authored-by: Nicholas Rodrigues Lordello * Update .env.production Co-authored-by: Leandro Boscariol * Update .env.production Co-authored-by: Nicholas Rodrigues Lordello * fix barn .env * Update .env.production Co-authored-by: Anxo Rodriguez * Update .env Co-authored-by: Nicholas Rodrigues Lordello * Update .env.production Co-authored-by: Nicholas Rodrigues Lordello Co-authored-by: Leandro Boscariol Co-authored-by: Anxo Rodriguez --- .env | 6 +++--- .env.production | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 096aedf5e5..92d3ff1b84 100644 --- a/.env +++ b/.env @@ -38,8 +38,8 @@ REACT_APP_DOMAIN_REGEX_LOCAL="^(:?localhost:\d{2,5}|(?:127|192)(?:\.[0-9]{1,3}){ REACT_APP_DOMAIN_REGEX_PR="^pr\d+--cowswap\.review" REACT_APP_DOMAIN_REGEX_DEV="^cowswap\.dev" REACT_APP_DOMAIN_REGEX_STAGING="^cowswap\.staging" -REACT_APP_DOMAIN_REGEX_PROD="^cowswap\.exchange$" -REACT_APP_DOMAIN_REGEX_BARN="^barn\.cowswap\.exchange$" +REACT_APP_DOMAIN_REGEX_PROD="^(cowswap\.exchange|swap\.cow\.fi)$" +REACT_APP_DOMAIN_REGEX_BARN="^barn\.(cowswap\.exchange|swap\.cow\.fi)$" REACT_APP_DOMAIN_REGEX_ENS="(:?^cowswap\.eth|ipfs)" # Path regex (to detect environment) @@ -71,4 +71,4 @@ REACT_APP_PATH_REGEX_ENS="/ipfs" REACT_APP_MOCK=true # Locales -REACT_APP_LOCALES="locales" \ No newline at end of file +REACT_APP_LOCALES="locales" diff --git a/.env.production b/.env.production index 9b77b6f159..e12f35df3e 100644 --- a/.env.production +++ b/.env.production @@ -39,8 +39,8 @@ REACT_APP_DOMAIN_REGEX_LOCAL="^(:?localhost:\d{2,5}|(?:127|192)(?:\.[0-9]{1,3}){ REACT_APP_DOMAIN_REGEX_PR="^pr\d+--cowswap\.review" REACT_APP_DOMAIN_REGEX_DEV="^cowswap\.dev" REACT_APP_DOMAIN_REGEX_STAGING="^cowswap\.staging" -REACT_APP_DOMAIN_REGEX_PROD="^cowswap\.exchange$" -REACT_APP_DOMAIN_REGEX_BARN="^barn\.cowswap\.exchange$" +REACT_APP_DOMAIN_REGEX_PROD="^(cowswap\.exchange|swap\.cow\.fi)$" +REACT_APP_DOMAIN_REGEX_BARN="^barn\.(cowswap\.exchange|swap\.cow\.fi)$" REACT_APP_DOMAIN_REGEX_ENS="(:?^cowswap\.eth|ipfs)" # Path regex (to detect environment) From 8c752615d5f4b80262a17ab0f3470bbe90fca603 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 20 Jun 2022 14:44:25 +0100 Subject: [PATCH 5/6] FIX CYPRESS TESTS (#710) * fix cypress SwapMod output test * update gitignore w/cypress env * use GNO for native swap * comment --- .gitignore | 1 + cypress-custom/integration/swapMod.ts | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index cffb28adf8..7516b25406 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ # testing /coverage +cypress.env.json # builds /build diff --git a/cypress-custom/integration/swapMod.ts b/cypress-custom/integration/swapMod.ts index a1b3b44898..c324f4638b 100644 --- a/cypress-custom/integration/swapMod.ts +++ b/cypress-custom/integration/swapMod.ts @@ -32,25 +32,36 @@ describe('Swap (mod)', () => { }) it('can enter an amount into output', () => { - cy.get('#swap-currency-output .token-amount-input') + // first clear/reset the INPUT currency input field + // as it is auto prefilled with "1" + cy.get('#swap-currency-input .token-amount-input') + .clear() + // then we select and clear the OUTPUT field + .get('#swap-currency-output .token-amount-input') .clear() + // and type in an amount .type('0.001', { delay: 400, force: true }) .should('have.value', '0.001') }) it('zero output amount', () => { - cy.get('#swap-currency-output .token-amount-input') - // When `.clear() doesn't work, brute force it with the input below. - // From https://stackoverflow.com/a/65918033/1272513 - .type('{selectall}{backspace}{selectall}{backspace}') + // first clear/reset the INPUT currency input field + // as it is auto prefilled with "1" + cy.get('#swap-currency-input .token-amount-input') + .clear() + // then we select and clear the OUTPUT field + .get('#swap-currency-output .token-amount-input') + .clear() + // and type in an amount .type('0.0') .should('have.value', '0.0') }) - it('can swap Native for DAI', () => { + it('can find GNO and swap Native for GNO', () => { cy.get('#swap-currency-output .open-currency-select-button').click() - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) + cy.get('#token-search-input').type('GNO') + cy.get('.token-item-0xd0Dab4E640D95E9E8A47545598c33e31bDb53C7c').should('be.visible') + cy.get('.token-item-0xd0Dab4E640D95E9E8A47545598c33e31bDb53C7c').click({ force: true }) cy.get('#swap-currency-input .token-amount-input').should('be.visible') cy.get('#swap-currency-input .token-amount-input').type('{selectall}{backspace}{selectall}{backspace}').type('0.5') cy.get('#swap-currency-output .token-amount-input').should('not.equal', '') From dc6017f02d4d9fb84e7f59a9587e8fd5227e04f1 Mon Sep 17 00:00:00 2001 From: Nenad Vracar <34926005+nenadV91@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:02:24 +0200 Subject: [PATCH 6/6] Fix for connector issue when opening as safe app (#701) --- src/custom/hooks/web3.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/custom/hooks/web3.ts b/src/custom/hooks/web3.ts index 145357a87e..f3c59a94b7 100644 --- a/src/custom/hooks/web3.ts +++ b/src/custom/hooks/web3.ts @@ -34,7 +34,8 @@ export function useEagerConnect() { if (!walletType || !active) { localStorage.removeItem(STORAGE_KEY_LAST_PROVIDER) - } else { + } else if (!IS_IN_IFRAME) { + // Set if its not from an Iframe localStorage.setItem(STORAGE_KEY_LAST_PROVIDER, walletType) } }, [connector, active]) @@ -88,8 +89,8 @@ export function useEagerConnect() { if (!active) { const latestProvider = localStorage.getItem(STORAGE_KEY_LAST_PROVIDER) - // If there is no last saved provider set tried state to true - if (!latestProvider) { + // If there is no last saved provider or its running in Iframe, try connecting with safe first + if (!latestProvider || IS_IN_IFRAME) { if (!triedSafe) { // First try to connect using Gnosis Safe connectSafe()