Skip to content

Commit

Permalink
Merge pull request #708 from cowprotocol/hotfix/1.15.5
Browse files Browse the repository at this point in the history
[ ๐Ÿ”ฅ ๐Ÿ˜ฎโ€๐Ÿ’จ H O T F I X ] 1.15.5
  • Loading branch information
W3stside authored Jun 21, 2022
2 parents 68b3a3b + dc6017f commit 8e0a89a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -71,4 +71,4 @@ REACT_APP_PATH_REGEX_ENS="/ipfs"
REACT_APP_MOCK=true

# Locales
REACT_APP_LOCALES="locales"
REACT_APP_LOCALES="locales"
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# testing
/coverage
cypress.env.json

# builds
/build
Expand Down
27 changes: 19 additions & 8 deletions cypress-custom/integration/swapMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down
7 changes: 4 additions & 3 deletions src/custom/hooks/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/custom/pages/Swap/SwapMod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
6 changes: 1 addition & 5 deletions src/custom/utils/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -410,12 +409,9 @@ export async function getGpUsdcPrice({ strategy, quoteParams }: Pick<QuoteParams
console.debug(
'[GP PRICE::API] getGpUsdcPrice - Attempting best USDC quote retrieval using COWSWAP strategy, hang tight.'
)
quoteParams.validTo = MAX_VALID_TO_EPOCH
const { quote } = await getQuote(quoteParams)

// BUY order always. We also need to add the fee to the sellAmount to get the unaffected price
const amountWithoutFee = new BigNumberJs(quote.feeAmount).plus(new BigNumberJs(quote.sellAmount))
return amountWithoutFee.toString(10)
return quote.sellAmount
} else {
console.debug(
'[GP PRICE::API] getGpUsdcPrice - Attempting best USDC quote retrieval using LEGACY strategy, hang tight.'
Expand Down

0 comments on commit 8e0a89a

Please sign in to comment.