-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Ohmage and switch to cow swap widget on trade page
- Loading branch information
1 parent
449c5aa
commit 41b0e7a
Showing
13 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
apps/dapp/src/components/Pages/Core/DappPages/Trade/TradeWidget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { | ||
CowSwapWidget, | ||
EthereumProvider, | ||
TradeType, | ||
} from '@cowprotocol/widget-react'; | ||
|
||
import { CowSwapWidgetParams } from '@cowprotocol/widget-react'; | ||
import { useSetChain } from '@web3-onboard/react'; | ||
import Loader from 'components/Loader/Loader'; | ||
import env from 'constants/env'; | ||
import { useWallet } from 'providers/WalletProvider'; | ||
import styled from 'styled-components'; | ||
|
||
export const TradeWidget = () => { | ||
const [{ connectedChain }] = useSetChain(); | ||
const { ethersProvider } = useWallet(); | ||
|
||
const params: CowSwapWidgetParams = { | ||
appCode: 'Temple Dapp', | ||
width: '100%', | ||
height: '640px', | ||
chainId: Number(connectedChain?.id) || 1, | ||
tokenLists: [env.tradeTokenListUrl], | ||
tradeType: TradeType.SWAP, | ||
sell: { | ||
asset: 'DAI', | ||
amount: '100', | ||
}, | ||
buy: { | ||
asset: 'TEMPLE', | ||
amount: '100', | ||
}, | ||
forcedOrderDeadline: { | ||
swap: 2, | ||
}, | ||
enabledTradeTypes: [TradeType.SWAP], | ||
theme: { | ||
baseTheme: 'dark', | ||
primary: '#bd7b4f', | ||
paper: '#0c0b0b', | ||
info: '#4a90e2', | ||
success: '#28a745', | ||
background: '#0c0b0b', | ||
danger: '#ff4343', | ||
warning: '#ffa500', | ||
alert: '#ff8c00', | ||
text: '#ffdec9', | ||
}, | ||
standaloneMode: false, | ||
disableToastMessages: false, | ||
disableProgressBar: false, | ||
hideBridgeInfo: false, | ||
hideOrdersTable: false, | ||
images: { | ||
emptyOrders: null, | ||
}, | ||
sounds: { | ||
postOrder: null, | ||
orderError: null, | ||
orderExecuted: null, | ||
}, | ||
customTokens: [ | ||
{ | ||
chainId: Number(connectedChain?.id) || 1, | ||
address: env.tokens.temple.address, | ||
name: env.tokens.temple.name, | ||
symbol: 'TEMPLE', | ||
decimals: env.tokens.temple.decimals, | ||
logoURI: | ||
'https://raw.githubusercontent.com/TempleDAO/temple/refs/heads/stage/apps/dapp/src/assets/icons/android-chrome-192x192.png', | ||
}, | ||
], | ||
}; | ||
|
||
return ( | ||
<WidgetContainer> | ||
{!ethersProvider && <Loader />} | ||
{ethersProvider && ( | ||
<CowSwapWidget | ||
params={params} | ||
provider={ethersProvider.provider as unknown as EthereumProvider} | ||
/> | ||
)} | ||
</WidgetContainer> | ||
); | ||
}; | ||
|
||
const WidgetContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 10px; | ||
height: 100%; | ||
width: 500px; | ||
`; |
34 changes: 32 additions & 2 deletions
34
apps/dapp/src/components/Pages/Core/DappPages/TradePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters