Skip to content
Draft
Show file tree
Hide file tree
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
13 changes: 1 addition & 12 deletions libs/common-const/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,12 @@ export const PAGE_TITLES = {
MY_REWARDS: msg`Rewards hub - My Rewards`,
}

/**
* Should be fully replaced with BARN_ETH_FLOW_ADDRESSES once backend migrated all the networks
*/
export const OLD_BARN_ETH_FLOW_ADDRESS = '0x04501b9b1d52e67f6862d157e00d13419d2d6e95'

export const STAGING_MIGRATED_CONTRACT_NETWORKS = [SupportedChainId.MAINNET]

export function getEthFlowContractAddresses(env: CowEnv, chainId: SupportedChainId): string {
if (env === 'prod') {
return ETH_FLOW_ADDRESSES[chainId]
}

if (STAGING_MIGRATED_CONTRACT_NETWORKS.includes(chainId)) {
return BARN_ETH_FLOW_ADDRESSES[chainId]
}

return OLD_BARN_ETH_FLOW_ADDRESS
return BARN_ETH_FLOW_ADDRESSES[chainId]
}

export const V_COW_CONTRACT_ADDRESS: Record<SupportedChainId, string | null> = {
Expand Down
29 changes: 3 additions & 26 deletions libs/common-utils/src/cowProtocolContracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { OLD_BARN_ETH_FLOW_ADDRESS, STAGING_MIGRATED_CONTRACT_NETWORKS } from '@cowprotocol/common-const'
import {
AddressPerChain,
BARN_ETH_FLOW_ADDRESSES,
Expand All @@ -7,43 +6,21 @@ import {
COW_PROTOCOL_VAULT_RELAYER_ADDRESS as COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD,
COW_PROTOCOL_VAULT_RELAYER_ADDRESS_STAGING,
ETH_FLOW_ADDRESSES,
mapAddressToSupportedNetworks,
} from '@cowprotocol/cow-sdk'

import { isBarnBackendEnv } from './environments'

// When in barn backend env, use staging contracts for MAINNET only; prod for all other chains.
// TODO: the condition should be removed once all backend services migrated to the new contracts
export const COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS: AddressPerChain = isBarnBackendEnv
? ({
...COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS_PROD,
...STAGING_MIGRATED_CONTRACT_NETWORKS.reduce((acc, chainId) => {
acc[chainId] = COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS_STAGING[chainId] as `0x${string}`
return acc
}, {} as AddressPerChain),
} as AddressPerChain)
? (COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS_STAGING as AddressPerChain)
: (COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS_PROD as AddressPerChain)

// When in barn backend env, use the staging vault relayer for MAINNET only; prod for all other chains.
// TODO: the condition should be removed once all backend services migrated to the new contracts
export const COW_PROTOCOL_VAULT_RELAYER_ADDRESS: AddressPerChain = isBarnBackendEnv
? ({
...COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD,
...STAGING_MIGRATED_CONTRACT_NETWORKS.reduce((acc, chainId) => {
acc[chainId] = COW_PROTOCOL_VAULT_RELAYER_ADDRESS_STAGING[chainId] as `0x${string}`
return acc
}, {} as AddressPerChain),
} as AddressPerChain)
? (COW_PROTOCOL_VAULT_RELAYER_ADDRESS_STAGING as AddressPerChain)
: (COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD as AddressPerChain)

// When in barn backend env, use the staging vault relayer for MAINNET only; prod for all other chains.
// TODO: the condition should be removed once all backend services migrated to the new contracts
export const COW_PROTOCOL_ETH_FLOW_ADDRESS: AddressPerChain = isBarnBackendEnv
? ({
...mapAddressToSupportedNetworks(OLD_BARN_ETH_FLOW_ADDRESS),
...STAGING_MIGRATED_CONTRACT_NETWORKS.reduce((acc, chainId) => {
acc[chainId] = BARN_ETH_FLOW_ADDRESSES[chainId] as `0x${string}`
return acc
}, {} as AddressPerChain),
} as AddressPerChain)
? (BARN_ETH_FLOW_ADDRESSES as AddressPerChain)
: (ETH_FLOW_ADDRESSES as AddressPerChain)
Loading