Skip to content

Commit

Permalink
Merge branch 'refactor/tokens-lib-wiring-4' of https://github.com/cow…
Browse files Browse the repository at this point in the history
…protocol/cowswap into refactor/tokens-lib-wiring-5
  • Loading branch information
shoom3301 committed Oct 23, 2023
2 parents cfe1c48 + 8f60b4e commit 1e701c6
Show file tree
Hide file tree
Showing 182 changed files with 3,543 additions and 1,383 deletions.
97 changes: 97 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,102 @@
# Changelog

## [1.48.7](https://github.com/cowprotocol/cowswap/compare/v1.48.6...v1.48.7) (2023-10-19)


### Bug Fixes

* **swap:** periodically refresh unsupported tokens state ([#3252](https://github.com/cowprotocol/cowswap/issues/3252)) ([f5986a3](https://github.com/cowprotocol/cowswap/commit/f5986a30f850eead4eb633069967ac34947ab68e))

## [1.48.6](https://github.com/cowprotocol/cowswap/compare/v1.48.5...v1.48.6) (2023-10-18)


### Bug Fixes

* **permit:** usdc limit orders warning ([#3247](https://github.com/cowprotocol/cowswap/issues/3247)) ([d958d0f](https://github.com/cowprotocol/cowswap/commit/d958d0fefb6f18418fb596b75b872e5b381d915d))

## [1.48.5](https://github.com/cowprotocol/cowswap/compare/v1.48.4...v1.48.5) (2023-10-18)


### Features

* deploy to IPFS ([#3237](https://github.com/cowprotocol/cowswap/issues/3237)) ([e69af4d](https://github.com/cowprotocol/cowswap/commit/e69af4d7140e384180c98b4c5175b341a2e9a542))


### Bug Fixes

* display token logos from CoW Protocol correctly ([#3244](https://github.com/cowprotocol/cowswap/issues/3244)) ([caaf980](https://github.com/cowprotocol/cowswap/commit/caaf9800da89e1df21cdffe2afc4eaa98260d0c3))

## [1.48.4](https://github.com/cowprotocol/cowswap/compare/v1.48.3...v1.48.4) (2023-10-18)


### Bug Fixes

* **permit:** add support for usdc mainnet ([#3231](https://github.com/cowprotocol/cowswap/issues/3231)) ([8de7cfc](https://github.com/cowprotocol/cowswap/commit/8de7cfc51e2324f75b968aee015a2488d4dd2ba9))

## [1.48.3](https://github.com/cowprotocol/cowswap/compare/v1.48.2...v1.48.3) (2023-10-18)


### Bug Fixes

* display trade menu item badge ([#3236](https://github.com/cowprotocol/cowswap/issues/3236)) ([9d54b0a](https://github.com/cowprotocol/cowswap/commit/9d54b0acc8fd1af409776d005a2858647db817c6))

## [1.48.2](https://github.com/cowprotocol/cowswap/compare/v1.48.1...v1.48.2) (2023-10-17)


### Bug Fixes

* **swap:** don't reset swap form on recipient ens input ([#3234](https://github.com/cowprotocol/cowswap/issues/3234)) ([9c1f2f1](https://github.com/cowprotocol/cowswap/commit/9c1f2f1b13597a4af5600c1c915bd59ecf14f578))

## [1.48.1](https://github.com/cowprotocol/cowswap/compare/v1.48.0...v1.48.1) (2023-10-17)


### Bug Fixes

* **swap:** don't crash app when token decimals eq 0 ([#3228](https://github.com/cowprotocol/cowswap/issues/3228)) ([aad09c6](https://github.com/cowprotocol/cowswap/commit/aad09c6b71c1c0a8dabb1f3ea85292bed332dbc7))
* **wc:** add back patch which fixes WC path issue ([#3230](https://github.com/cowprotocol/cowswap/issues/3230)) ([4f4b7d5](https://github.com/cowprotocol/cowswap/commit/4f4b7d56e1cf806d52f09875f95c0afa15a06985))

## [1.48.0](https://github.com/cowprotocol/cowswap/compare/v1.47.1...v1.48.0) (2023-10-16)


### Features

* **permit:** allowance warning ([#3184](https://github.com/cowprotocol/cowswap/issues/3184)) ([f4700d9](https://github.com/cowprotocol/cowswap/commit/f4700d9ac34bf281f6efb9bcbc60bebacb8ac68f))
* **permit:** disable permit for SC wallets ([#3213](https://github.com/cowprotocol/cowswap/issues/3213)) ([29e5178](https://github.com/cowprotocol/cowswap/commit/29e5178a4c15eb56568f5da0d0a30990a47bc76f))
* **permit:** modals LIMIT ([#3164](https://github.com/cowprotocol/cowswap/issues/3164)) ([70e5653](https://github.com/cowprotocol/cowswap/commit/70e56534eaa17456e42e2ba30541537e44d76c78))
* **permit:** modals SWAP ([#3158](https://github.com/cowprotocol/cowswap/issues/3158)) ([ed53662](https://github.com/cowprotocol/cowswap/commit/ed53662eedec3fb4ce3d880c9303df701f5059c1))
* **permit:** refactor permit caching ([#3183](https://github.com/cowprotocol/cowswap/issues/3183)) ([e902e36](https://github.com/cowprotocol/cowswap/commit/e902e36d6d6320dfa1649a448a834df49f115ce4))
* remove walletConnect v1 and use v2 by default ([#3156](https://github.com/cowprotocol/cowswap/issues/3156)) ([4b3fbc0](https://github.com/cowprotocol/cowswap/commit/4b3fbc0f6de2f89235cc69fdc6e7eaefb9bd12b6))
* **tokens:** new UI component for token select modal ([#3166](https://github.com/cowprotocol/cowswap/issues/3166)) ([d5b69cd](https://github.com/cowprotocol/cowswap/commit/d5b69cd4716d1a77e94a4ecba808186e96ef4794))
* **tokens:** new UI for tokens management ([#3174](https://github.com/cowprotocol/cowswap/issues/3174)) ([6c2c253](https://github.com/cowprotocol/cowswap/commit/6c2c2535a11707ad1cc30aa17bd003863d832faa))


### Bug Fixes

* **eth-flow:** update refund info for expired orders ([#3222](https://github.com/cowprotocol/cowswap/issues/3222)) ([dede0d0](https://github.com/cowprotocol/cowswap/commit/dede0d0431511ad1b1ed0548f6d42f881b0f95e0))
* **permit:** improve permittable detection ([#3226](https://github.com/cowprotocol/cowswap/issues/3226)) ([79cb48a](https://github.com/cowprotocol/cowswap/commit/79cb48aa9cd21689d64e13fe57044c4f345c4118))
* **swap:** handle errors from order posting API ([#3224](https://github.com/cowprotocol/cowswap/issues/3224)) ([99df6d2](https://github.com/cowprotocol/cowswap/commit/99df6d2ca9fd5040624977f385e03b2442587c15))

## [1.47.1](https://github.com/cowprotocol/cowswap/compare/v1.47.0...v1.47.1) (2023-09-29)


### Features

* allow to change rpc nodes ([#3160](https://github.com/cowprotocol/cowswap/issues/3160)) ([b9b4be2](https://github.com/cowprotocol/cowswap/commit/b9b4be24ece99ddef83f351d47cc86a9ac3ff5da))
* **orders-table:** approve order token from allowance warn tooltip ([#3144](https://github.com/cowprotocol/cowswap/issues/3144)) ([aa943bf](https://github.com/cowprotocol/cowswap/commit/aa943bf06ab2ba3bb3040bae96106b4463f1283a))
* update approve button color ([#3169](https://github.com/cowprotocol/cowswap/issues/3169)) ([802f288](https://github.com/cowprotocol/cowswap/commit/802f288379329d6a526933be988e6669020bb872))


### Bug Fixes

* don't fetch tokens list ens hashes ([#3152](https://github.com/cowprotocol/cowswap/issues/3152)) ([49989f9](https://github.com/cowprotocol/cowswap/commit/49989f987e729749c17c64984ca3338f774198f9))
* fix bad import ([8546bbc](https://github.com/cowprotocol/cowswap/commit/8546bbc6e792cd913511c87ecfa3ab7453648ce6))
* **twap:** approve infinite amount ([#3141](https://github.com/cowprotocol/cowswap/issues/3141)) ([c5ab768](https://github.com/cowprotocol/cowswap/commit/c5ab768f85a0a463accaf436114fdcab7b538d80))


### Miscellaneous Chores

* **release:** hotfix 1.47.1 Merge pull request [#3171](https://github.com/cowprotocol/cowswap/issues/3171) from cowprotocol/hotfix/1.47.1 ([ce8671f](https://github.com/cowprotocol/cowswap/commit/ce8671fe3705f79a0bb73729855dfd59bbd48b52))

## [1.47.0](https://github.com/cowprotocol/cowswap/compare/v1.47.0-RC.0...v1.47.0) (2023-09-11)


Expand Down
14 changes: 4 additions & 10 deletions apps/cowswap-frontend/src/api/gnosisProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
CowEnv,
EnrichedOrder,
NativePriceResponse,
OrderBookApiError,
OrderKind,
OrderQuoteRequest,
OrderQuoteResponse,
Expand All @@ -25,9 +24,11 @@ import { LegacyFeeQuoteParams as FeeQuoteParams } from 'legacy/state/price/types

import { getAppData } from 'modules/appData'

import { ApiErrorCodes, ApiErrorObject } from 'api/gnosisProtocol/errors/OperatorError'
import { ApiErrorCodes } from 'api/gnosisProtocol/errors/OperatorError'
import GpQuoteError, { GpQuoteErrorDetails, mapOperatorErrorToQuoteError } from 'api/gnosisProtocol/errors/QuoteError'

import { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

function getProfileUrl(): Partial<Record<ChainId, string>> {
if (isLocal || isDev || isPr || isBarn) {
return {
Expand Down Expand Up @@ -153,7 +154,7 @@ export async function getQuote(params: FeeQuoteParams): Promise<OrderQuoteRespon
}

return orderBookApi.getQuote(quoteParams, { chainId }).catch((error) => {
if (isOrderbookTypedError(error)) {
if (getIsOrderBookTypedError(error)) {
const errorObject = mapOperatorErrorToQuoteError(error.body)

return Promise.reject(errorObject ? new GpQuoteError(errorObject) : error)
Expand All @@ -163,13 +164,6 @@ export async function getQuote(params: FeeQuoteParams): Promise<OrderQuoteRespon
})
}

export type OrderbookTypedError = OrderBookApiError<ApiErrorObject>

function isOrderbookTypedError(e: any): e is OrderbookTypedError {
const error = e as OrderbookTypedError
return error.body.errorType !== undefined && error.body.description !== undefined
}

export async function getOrder(chainId: ChainId, orderId: string, env?: CowEnv): Promise<EnrichedOrder | null> {
const contextOverride = {
chainId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { OrderBookApiError } from '@cowprotocol/cow-sdk'

import { ApiErrorObject } from './errors/OperatorError'

export type OrderBookTypedError = OrderBookApiError<ApiErrorObject>

export function getIsOrderBookTypedError(e: any): e is OrderBookTypedError {
const error = e as OrderBookTypedError
return error.body.errorType !== undefined && error.body.description !== undefined
}
2 changes: 2 additions & 0 deletions apps/cowswap-frontend/src/api/gnosisProtocol/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as realApi from './api'
import * as mockApi from './mock'

export { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

const useMock = process.env.REACT_APP_MOCK === 'true'

// Re-exporting the result, mocked or not.
Expand Down
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/assets/icon/carret.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/assets/icon/gas-free.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/assets/icon/wallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/assets/logo/cow-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/cowswap-frontend/src/common/constants/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export enum UI {

// Icons
ICON_SIZE_NORMAL = '--cow-icon-size-normal',
ICON_SIZE_SMALL = '--cow-icon-size-small',
ICON_SIZE_XSMALL = '--cow-icon-size-xsmall',
ICON_SIZE_LARGE = '--cow-icon-size-large',
ICON_COLOR_NORMAL = '--cow-icon-color-normal',

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { useIsSmartContractWallet } from '@cowprotocol/wallet'

import { useFeatureFlags } from './useFeatureFlags'

export function useIsPermitEnabled(chainId: SupportedChainId | undefined): boolean {
const isSmartContractWallet = useIsSmartContractWallet()
const { permitEnabledMainnet, permitEnabledGoerli, permitEnabledGnosis } = useFeatureFlags()

// Permit is only available for EOAs
if (isSmartContractWallet) {
return false
}

switch (chainId) {
case SupportedChainId.MAINNET:
return !!permitEnabledMainnet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,19 @@ export const StepsWrapper = styled.div`
margin: auto;
position: absolute;
width: 100%;
max-width: 162px;
max-width: 35%;
left: 0;
right: 0;
top: 32px;
z-index: 1;
${({ theme }) => theme.mediaWidth.upToSmall`
max-width: 25%;
`}
${({ theme }) => theme.mediaWidth.upToVerySmall`
max-width: 20%;
`}
}
> hr::before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,29 @@ function getTokenLogoURI(address: string, chainId: SupportedChainId = SupportedC

const currencyLogoCache = new Map<string, Array<string>>()

const COW_PROTOCOL_REPO = 'cowprotocol/token-lists'
function getLogoURI(currency: Currency | null): string | null {
if (!currency) return null

const logoURI = (currency as Currency & { logoURI: string }).logoURI

if (!logoURI) return null

// Always lowercase logo URI if it's from CoW Protocol repo
// Because CoW Protocol repo has all logos in lowercase
if (logoURI.includes(COW_PROTOCOL_REPO)) return logoURI.toLowerCase()

return logoURI
}

// TODO: must be refactored
export default function useCurrencyLogoURIs(currency?: Currency | null): string[] {
const currencyAddress = currency ? (currency.isNative ? NATIVE_CURRENCY_BUY_ADDRESS : currency.address) : null
// There is a modification of Token in useDetectNativeToken()
const externalLogo = useProxyTokenLogo(currency?.chainId, currencyAddress)
const cacheKey = `${currencyAddress}|${currency?.chainId}`
const cached = currencyLogoCache.get(cacheKey)
const logoURI = currency ? (currency as Currency & { logoURI: string }).logoURI : null
const logoURI = getLogoURI(currency || null)
const imageOverride = currency?.isToken ? ADDRESS_IMAGE_OVERRIDE[currency.address] : null

if (cached) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ReactComponent as DropDown } from '@cowprotocol/assets/images/dropdown.
import { lighten, transparentize } from 'polished'
import styled from 'styled-components/macro'

import { UI } from 'common/constants/theme'

export const CurrencySelectWrapper = styled.button<{ isLoading: boolean; $stubbed: boolean; readonlyMode: boolean }>`
display: flex;
justify-content: space-between;
Expand All @@ -19,7 +21,7 @@ export const CurrencySelectWrapper = styled.button<{ isLoading: boolean; $stubbe
: `0px 4px 8px ${transparentize(0.96, theme.text1)}`};
opacity: ${({ isLoading }) => (isLoading ? 0.6 : 1)};
pointer-events: ${({ readonlyMode }) => (readonlyMode ? 'none' : '')};
border-radius: 16px;
border-radius: var(${UI.BORDER_RADIUS_NORMAL});
padding: 6px;
transition: background-color 0.15s ease-in-out;
max-width: 190px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ModalContentWrapper = styled.div`
padding: 24px;
color: var(${UI.COLOR_TEXT2});
background-color: var(${UI.COLOR_CONTAINER_BG_01});
border-radius: 24px;
border-radius: var(${UI.BORDER_RADIUS_NORMAL});
> p {
line-height: 1.4;
Expand Down
47 changes: 47 additions & 0 deletions apps/cowswap-frontend/src/common/pure/PoweredFooter/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { COW_PROTOCOL_LINK } from '@cowprotocol/common-const'
import { ExternalLink } from '@cowprotocol/ui'

import { Trans } from '@lingui/macro'
import cowIcon from 'assets/logo/cow-icon.svg'
import SVG from 'react-inlinesvg'
import styled from 'styled-components/macro'

import { UI } from 'common/constants/theme'

const Wrapper = styled.div`
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: center;
font-size: var(${UI.FONT_SIZE_SMALLER});
padding: 4px 0;
`

const StyledExternalLink = styled(ExternalLink)`
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
color: var(${UI.COLOR_TEXT2});
> svg {
--size: 14px;
width: var(--size);
height: var(--size);
}
> svg > g > path {
fill: var(${UI.COLOR_TEXT2});
}
`

export function PoweredFooter() {
return (
<Wrapper>
<StyledExternalLink href={COW_PROTOCOL_LINK}>
<SVG src={cowIcon} title="CoW Protocol" />
<Trans>Powered by CoW Protocol</Trans>
</StyledExternalLink>
</Wrapper>
)
}
Loading

0 comments on commit 1e701c6

Please sign in to comment.