Skip to content

Commit

Permalink
Eth flow/updated contract to 0.0.0 rc4 (#1509)
Browse files Browse the repository at this point in the history
* Updated node version on nvmrc

* Updated ethflow contract

* Actually, this is the latest contract

* Loading ethflow contract addresses per network

* Loading the prod ethflow contract when prod, staging or ens, barn otherwise
  • Loading branch information
alfetopito authored Nov 28, 2022
1 parent a8c0026 commit e5a7c78
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/*
lts/gallium
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
"license": "GPL-3.0-or-later",
"dependencies": {
"@amplitude/analytics-browser": "^1.1.4",
"@cowprotocol/ethflowcontract": "cowprotocol/ethflowcontract.git#main-artifacts",
"@cowprotocol/ethflowcontract": "cowprotocol/ethflowcontract.git#0.0.0-rc4-artifacts",
"@babel/runtime": "^7.17.0",
"@coinbase/wallet-sdk": "^3.3.0",
"@cowprotocol/contracts": "^1.3.1",
Expand Down

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions src/custom/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Token, Fraction, Percent } from '@uniswap/sdk-core'
import { transactions as EthFlowTransactions } from '@cowprotocol/ethflowcontract/broadcast/Deploy.sol/5/deployment.json'
import { CoWSwapEthFlow as EthFlowBarn } from '@cowprotocol/ethflowcontract/networks.barn.json'
import { CoWSwapEthFlow as EthFlowProd } from '@cowprotocol/ethflowcontract/networks.prod.json'
import { GPv2Settlement, GPv2VaultRelayer } from '@cowprotocol/contracts/networks.json'

import { SupportedChainId as ChainId } from 'constants/chains'
Expand Down Expand Up @@ -44,11 +45,16 @@ export const APP_TITLE = 'CoW Swap | The smartest way to trade cryptocurrencies'
// Smart contract wallets are filtered out by default, no need to add them to this list
export const UNSUPPORTED_WC_WALLETS = new Set(['DeFi Wallet', 'WallETH'])

export const COWSWAP_ETHFLOW_CONTRACT_ADDRESS: Partial<Record<number, string>> = {
// [ChainId.MAINNET]: CoWSwapEthFlow[ChainId.MAINNET].address,
// [ChainId.RINKEBY]: CoWSwapEthFlow[ChainId.RINKEBY].address,
// [ChainId.GNOSIS_CHAIN]: CoWSwapEthFlow[ChainId.GNOSIS_CHAIN].address,
[ChainId.GOERLI]: EthFlowTransactions[0].contractAddress,
type Env = 'barn' | 'prod'

export const COWSWAP_ETHFLOW_CONTRACT_ADDRESS: Record<Env, Partial<Record<number, string>>> = {
// TODO: add other networks when available
prod: {
[ChainId.GOERLI]: EthFlowProd[ChainId.GOERLI].address,
},
barn: {
[ChainId.GOERLI]: EthFlowBarn[ChainId.GOERLI].address,
},
}

export const GP_SETTLEMENT_CONTRACT_ADDRESS: Partial<Record<number, string>> = {
Expand Down
8 changes: 7 additions & 1 deletion src/custom/hooks/useContract/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useWeb3React } from '@web3-react/core'
import { getContract } from 'utils'

import { useContract } from '@src/hooks/useContract'
import { isEns, isProd, isStaging } from 'utils/environments'

export * from '@src/hooks/useContract'
export * from './useContractMod'
Expand All @@ -28,9 +29,14 @@ export * from './useContractMod'

export function useEthFlowContract(): CoWSwapEthFlow | null {
const { chainId } = useWeb3React()

const contractEnv = isProd || isStaging || isEns ? 'prod' : 'barn'

const contractAddress = chainId ? COWSWAP_ETHFLOW_CONTRACT_ADDRESS[contractEnv][chainId] : undefined

return useContract<CoWSwapEthFlow>(
// TODO: get the networks.json when contracts deployed
chainId ? COWSWAP_ETHFLOW_CONTRACT_ADDRESS[chainId] : undefined,
contractAddress,
COWSWAP_ETHFLOW_ABI,
true
)
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1305,9 +1305,9 @@
loglevel "^1.8.0"
multiformats "^9.6.4"

"@cowprotocol/ethflowcontract@cowprotocol/ethflowcontract.git#main-artifacts":
version "0.0.0-rc.2"
resolved "https://codeload.github.com/cowprotocol/ethflowcontract/tar.gz/7d5ed9adf9f59dd041051f30ea740bbeb4dea7c5"
"@cowprotocol/ethflowcontract@cowprotocol/ethflowcontract.git#0.0.0-rc4-artifacts":
version "0.0.0-rc.4"
resolved "https://codeload.github.com/cowprotocol/ethflowcontract/tar.gz/c2b8b4c0b463bc68f23c20fafbe5a0df39cfe621"

"@craco/craco@^5.7.0":
version "5.9.0"
Expand Down

0 comments on commit e5a7c78

Please sign in to comment.