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(widget-configurator): use different default partner fee address per chain #4942

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 12 additions & 3 deletions apps/widget-configurator/src/app/configurator/consts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { CowWidgetEventListeners, CowWidgetEvents, ToastMessageType } from '@cowprotocol/events'
import { CowSwapWidgetPaletteParams, TokenInfo, TradeType } from '@cowprotocol/widget-lib'

import { TokenListItem } from './types'

// CoW DAO address
export const DEFAULT_PARTNER_FEE_RECIPIENT = '0xcA771eda0c70aA7d053aB1B25004559B918FE662'
// CoW DAO addresses
const MAINNET_DEFAULT_PARTNER_FEE_RECIPIENT = '0xcA771eda0c70aA7d053aB1B25004559B918FE662'
const GNOSIS_DEFAULT_PARTNER_FEE_RECIPIENT = '0x6b3214fd11dc91de14718dee98ef59bcbfcfb432'
export const DEFAULT_PARTNER_FEE_RECIPIENT_PER_NETWORK: Record<SupportedChainId, string> = {
[SupportedChainId.MAINNET]: MAINNET_DEFAULT_PARTNER_FEE_RECIPIENT,
[SupportedChainId.GNOSIS_CHAIN]: GNOSIS_DEFAULT_PARTNER_FEE_RECIPIENT,
[SupportedChainId.ARBITRUM_ONE]: MAINNET_DEFAULT_PARTNER_FEE_RECIPIENT,
[SupportedChainId.SEPOLIA]: MAINNET_DEFAULT_PARTNER_FEE_RECIPIENT,
}

export const TRADE_MODES = [TradeType.SWAP, TradeType.LIMIT, TradeType.ADVANCED]

// Sourced from https://tokenlists.org/
Expand Down Expand Up @@ -35,7 +44,7 @@ export const DEFAULT_TOKEN_LISTS: TokenListItem[] = [
{ url: 'https://wrapped.tokensoft.eth.link', enabled: false },
]
// TODO: Move default palette to a new lib that only exposes the palette colors.
// This wayit can be consumed by both the configurator and the widget.
// This way it can be consumed by both the configurator and the widget.
export const DEFAULT_LIGHT_PALETTE: CowSwapWidgetPaletteParams = {
primary: '#052b65',
background: '#FFFFFF',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const getBaseUrl = (): string => {
if (isLocalHost) return 'http://localhost:3000'
if (isDev) return 'https://dev.swap.cow.fi'
if (isVercel) {
const prKey = window.location.hostname.replace('widget-configurator-git-', '').replace('-cowswap.vercel.app', '')
return `https://swap-dev-git-${prKey}-cowswap.vercel.app`
// TODO: revert before merging!!
return 'https://swap-dev-git-fix-widget-configurator-fee-recipient-cowswap.vercel.app/'
Comment on lines -14 to +15
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't forget to revert this before merging!!

}

return 'https://swap.cow.fi'
Expand Down
14 changes: 12 additions & 2 deletions apps/widget-configurator/src/app/configurator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeEvent, useCallback, useContext, useEffect, useMemo, useState } from 'react'

import { useAvailableChains } from '@cowprotocol/common-hooks'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { CowWidgetEventListeners } from '@cowprotocol/events'
import { CowSwapWidgetParams, TokenInfo, TradeType } from '@cowprotocol/widget-lib'
import { CowSwapWidget } from '@cowprotocol/widget-react'
Expand All @@ -23,7 +24,13 @@ import ListItemText from '@mui/material/ListItemText'
import Typography from '@mui/material/Typography'
import { useWeb3ModalAccount, useWeb3ModalTheme } from '@web3modal/ethers5/react'

import { COW_LISTENERS, DEFAULT_PARTNER_FEE_RECIPIENT, DEFAULT_TOKEN_LISTS, IS_IFRAME, TRADE_MODES } from './consts'
import {
COW_LISTENERS,
DEFAULT_PARTNER_FEE_RECIPIENT_PER_NETWORK,
DEFAULT_TOKEN_LISTS,
IS_IFRAME,
TRADE_MODES,
} from './consts'
import { CurrencyInputControl } from './controls/CurrencyInputControl'
import { CurrentTradeTypeControl } from './controls/CurrentTradeTypeControl'
import { CustomImagesControl } from './controls/CustomImagesControl'
Expand Down Expand Up @@ -151,7 +158,10 @@ export function Configurator({ title }: { title: string }) {
customColors: colorPalette,
defaultColors: defaultPalette,
partnerFeeBps,
partnerFeeRecipient: DEFAULT_PARTNER_FEE_RECIPIENT,
partnerFeeRecipient:
DEFAULT_PARTNER_FEE_RECIPIENT_PER_NETWORK[
walletChainId ? (walletChainId as SupportedChainId) : SupportedChainId.MAINNET
],
standaloneMode,
disableToastMessages,
disableProgressBar,
Expand Down
Loading