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) 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', '') 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() 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} diff --git a/src/custom/utils/price.ts b/src/custom/utils/price.ts index 756cb74476..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,12 +409,9 @@ export async function getGpUsdcPrice({ strategy, quoteParams }: Pick