Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hard code eth-flow contract addresses #3587

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
Comment on lines +55 to +56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure.
Right now the addresses are the same, but it's not guaranteed.
See what Federico said

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I understand.
For some reason, locally, yarn wrongly resolves @cowprotocol/ethflowcontract package:
https://cowservices.slack.com/archives/C0361CDG8GP/p1704727878010159

I have no idea why it's happening, but I also faced it before and can't reproduce now.
The only way I see to solve it - hardcoding

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it has something to do with yarn.lock?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see it contains proper data

}

export const GP_SETTLEMENT_CONTRACT_ADDRESS = COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS
Expand Down
Loading