Skip to content

Commit

Permalink
Merge branch 'develop' into fix/cypress-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Jan 9, 2024
2 parents 15de2b9 + 246db74 commit 99b840a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
23 changes: 6 additions & 17 deletions libs/common-const/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS,
COW_PROTOCOL_VAULT_RELAYER_ADDRESS,
IpfsConfig,
mapAddressToSupportedNetworks,
SupportedChainId,
} from '@cowprotocol/cow-sdk'
import { ethFlowBarnJson, ethFlowProdJson } from '@cowprotocol/abis'
import { Fraction, Percent } from '@uniswap/sdk-core'

import BigNumber from 'bignumber.js'
Expand All @@ -13,10 +13,6 @@ import ms from 'ms.macro'
import { PINATA_API_KEY, PINATA_SECRET_API_KEY } from './ipfs'

// TODO: move those consts to src/constants/common

const EthFlowBarn = ethFlowBarnJson.CoWSwapEthFlow
const EthFlowProd = ethFlowProdJson.CoWSwapEthFlow

export const ZERO_BIG_NUMBER = new BigNumber(0)
export const ZERO_FRACTION = new Fraction(0)

Expand Down Expand Up @@ -52,19 +48,12 @@ export const APP_TITLE = 'CoW Swap | The smartest way to trade cryptocurrencies'

type Env = 'barn' | 'prod'

const COWSWAP_ETHFLOW_CONTRACT_PROD = '0x40A50cf069e992AA4536211B23F286eF88752187'
const COWSWAP_ETHFLOW_CONTRACT_BARN = '0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93'

export const COWSWAP_ETHFLOW_CONTRACT_ADDRESS: Record<Env, Partial<Record<SupportedChainId, string>>> = {
prod: {
[SupportedChainId.MAINNET]: EthFlowProd[SupportedChainId.MAINNET].address,
[SupportedChainId.GNOSIS_CHAIN]: EthFlowProd[SupportedChainId.GNOSIS_CHAIN].address,
[SupportedChainId.GOERLI]: EthFlowProd[SupportedChainId.GOERLI].address,
[SupportedChainId.SEPOLIA]: EthFlowProd[SupportedChainId.SEPOLIA].address,
},
barn: {
[SupportedChainId.MAINNET]: EthFlowBarn[SupportedChainId.MAINNET].address,
[SupportedChainId.GNOSIS_CHAIN]: EthFlowBarn[SupportedChainId.GNOSIS_CHAIN].address,
[SupportedChainId.GOERLI]: EthFlowBarn[SupportedChainId.GOERLI].address,
[SupportedChainId.SEPOLIA]: EthFlowBarn[SupportedChainId.SEPOLIA].address,
},
prod: mapAddressToSupportedNetworks(COWSWAP_ETHFLOW_CONTRACT_PROD),
barn: mapAddressToSupportedNetworks(COWSWAP_ETHFLOW_CONTRACT_BARN),
}

export const GP_SETTLEMENT_CONTRACT_ADDRESS = COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS
Expand Down
12 changes: 8 additions & 4 deletions libs/tokens/src/migrations/tokensLegacyStateMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ function migrateLegacyTokenLists() {
source: listSource,
})

tokenListsState[chainId][listSource] = {
source: listSource,
list: list.current,
isEnabled: !!networkLists.activeListUrls?.includes(listSource),
const networkState = tokenListsState[chainId]

if (networkState) {
networkState[listSource] = {
source: listSource,
list: list.current,
isEnabled: !!networkLists.activeListUrls?.includes(listSource),
}
}
})
})
Expand Down
8 changes: 6 additions & 2 deletions libs/tokens/src/state/tokenLists/tokenListsActionsAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const upsertListsAtom = atom(null, (get, set, chainId: SupportedChainId,
const update = listsStates.reduce<{ [listId: string]: ListState }>((acc, list) => {
acc[list.source] = {
...list,
isEnabled: typeof list.isEnabled === 'boolean' ? list.isEnabled : chainState[list.source]?.isEnabled,
isEnabled: typeof list.isEnabled === 'boolean' ? list.isEnabled : chainState?.[list.source]?.isEnabled,
}

return acc
Expand Down Expand Up @@ -60,7 +60,11 @@ export const removeListAtom = atom(null, (get, set, source: string) => {

const stateCopy = { ...get(listsStatesByChainAtom) }

delete stateCopy[chainId][source]
const networkState = stateCopy[chainId]

if (networkState) {
delete networkState[source]
}

set(listsStatesByChainAtom, stateCopy)
})
Expand Down
2 changes: 1 addition & 1 deletion libs/tokens/src/state/tokenLists/tokenListsStateAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const tokenListsUpdatingAtom = atom<boolean>(false)
export const listsStatesMapAtom = atom((get) => {
const { chainId, widgetAppCode, selectedLists } = get(environmentAtom)
const allTokenListsInfo = get(listsStatesByChainAtom)
const currentNetworkLists = allTokenListsInfo[chainId]
const currentNetworkLists = allTokenListsInfo[chainId] || {}

return Object.keys(currentNetworkLists).reduce<{ [source: string]: ListState }>((acc, source) => {
const list = currentNetworkLists[source]
Expand Down
2 changes: 1 addition & 1 deletion libs/tokens/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export interface ListState {
isEnabled?: boolean
}

export type TokenListsState = Record<SupportedChainId, { [source: string]: ListState }>
export type TokenListsState = Record<SupportedChainId, { [source: string]: ListState } | undefined>

0 comments on commit 99b840a

Please sign in to comment.