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

Integrate Order progress bar #454

Merged
merged 31 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
862c413
Progress of execution UI (#366)
alongoni Apr 8, 2022
3783673
Merge remote-tracking branch 'origin/develop' into tx-progressbar-com…
ramirotw Apr 19, 2022
2785649
Fix wallet-connect double qr code
alfetopito Apr 22, 2022
692f464
Fix for 1Inch and possibly some other wallets
nenadV91 Mar 15, 2022
3fcaf74
Updated comments and disconnect error handling
alfetopito Apr 22, 2022
2022a51
Forcing wallet connect connector type
alfetopito Apr 22, 2022
de7addd
integrate Order progress bar UX
ramirotw Apr 26, 2022
6fde192
extract Cancel order button
ramirotw Apr 26, 2022
08f7ac8
Merge remote-tracking branch 'origin/develop' into ramirotw/issue-392…
ramirotw Apr 26, 2022
c1fc6fc
fix incorrect amm state percentage
ramirotw Apr 26, 2022
500669f
improve state handling and hide progress bar when order is cancelled
ramirotw Apr 26, 2022
6c02066
hide progress bar for expired orders
ramirotw Apr 26, 2022
67fc088
hide orders that are not pending
ramirotw Apr 26, 2022
3a85ee2
initialize progress bar with current percentage
ramirotw Apr 26, 2022
c8e523d
AMMs logos per network
ramirotw Apr 26, 2022
0410fc0
Merge remote-tracking branch 'origin/fix-walletconnect-double-qr-code…
ramirotw Apr 27, 2022
dcf6e65
add GC AMMs logos
alongoni Apr 27, 2022
11f84ad
fix bao logo reference
ramirotw Apr 28, 2022
74d9acf
Update yarn lock
anxolin May 20, 2022
97871a7
Incerease update speed and improve message
anxolin May 20, 2022
f04c862
Add rotating clock
anxolin May 20, 2022
b93b312
Increase expected execution time
anxolin May 20, 2022
49d5244
Add nose picking icon
anxolin May 20, 2022
2f04b2d
Remove plural
anxolin May 20, 2022
9187e85
Change message
anxolin May 31, 2022
79bc8fb
Merge pull request #556 from cowprotocol/small-poc-progress
anxolin May 31, 2022
4f70ea6
make cow state always 30 seconds
ramirotw Jun 13, 2022
3a36867
use safe info to get better progress values
ramirotw Jun 14, 2022
17ffb82
Revert "Merge remote-tracking branch 'origin/fix-walletconnect-double…
ramirotw Jun 14, 2022
66175e9
update lock from reverted merge
ramirotw Jun 14, 2022
84623d7
Merge remote-tracking branch 'origin/develop' into ramirotw/issue-392…
ramirotw Jun 14, 2022
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
Binary file added src/custom/assets/cow-swap/ammslogo/1inch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/custom/assets/cow-swap/ammslogo/baoswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/custom/assets/cow-swap/ammslogo/honeyswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/custom/assets/cow-swap/ammslogo/paraswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/custom/assets/cow-swap/ammslogo/sushi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/custom/assets/cow-swap/ammslogo/swapr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/custom/assets/cow-swap/ammslogo/uniswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions src/custom/components/AMMsLogo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import styled from 'styled-components/macro'
import Sushi from 'assets/cow-swap/ammslogo/sushi.png'
import Paraswap from 'assets/cow-swap/ammslogo/paraswap.png'
import Oneinch from 'assets/cow-swap/ammslogo/1inch.png'
import Uniswap from 'assets/cow-swap/ammslogo/uniswap.png'
import Baoswap from 'assets/cow-swap/ammslogo/baoswap.png'
import Honeyswap from 'assets/cow-swap/ammslogo/honeyswap.png'
import Swapr from 'assets/cow-swap/ammslogo/swapr.png'
import { SupportedChainId } from 'constants/chains'

export const Wrapper = styled.div`
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border-radius: 100%;
box-shadow: 0px 0px 10px 2px ${({ theme }) => theme.bg1};
background-color: ${({ theme }) => theme.white};
transform-style: preserve-3d;
position: absolute;
top: -4px;
right: 0px;

img {
position: absolute;
left: 0;
animation: FadeInOut 6s infinite;
}
@keyframes FadeInOut {
0% {
opacity: 1;
}
17% {
opacity: 1;
}
25% {
opacity: 0;
}
92% {
opacity: 0;
}
100% {
opacity: 1;
}
}

img:nth-of-type(1) {
animation-delay: 6s;
}
img:nth-of-type(2) {
animation-delay: 4.5s;
}
img:nth-of-type(3) {
animation-delay: 3s;
}
img:nth-of-type(4) {
animation-delay: 1.5s;
}
`

type Image = { src: string; alt: string }

const SushiImage = { src: Sushi, alt: 'AMMs Sushiswap' }
const OneInchImage = { src: Oneinch, alt: 'AMMs 1inch' }
const ParaswapImage = { src: Paraswap, alt: 'AMMs Paraswap' }
const UniswapImage = { src: Uniswap, alt: 'AMMs Uniswap' }
const BaoswapImage = { src: Baoswap, alt: 'AMMs Baoswap' }
const HoneyswapImage = { src: Honeyswap, alt: 'AMMs Honeyswap' }
const SwaprImage = { src: Swapr, alt: 'AMMs Swapr' }

const LogosPerNetwork: Record<SupportedChainId, Array<Image>> = {
[SupportedChainId.MAINNET]: [SushiImage, OneInchImage, ParaswapImage, UniswapImage],
[SupportedChainId.RINKEBY]: [SushiImage, OneInchImage, ParaswapImage, UniswapImage],
[SupportedChainId.XDAI]: [SushiImage, BaoswapImage, HoneyswapImage, SwaprImage],
}

export function AMMsLogo({ chainId }: { chainId: SupportedChainId }) {
return (
<Wrapper>
{LogosPerNetwork[chainId].map(({ src, alt }, index) => (
<img key={index} src={src} alt={alt} />
))}
</Wrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Summary,
SummaryInner,
SummaryInnerRow,
TransactionAlertMessage,
TransactionInnerDetail,
TextAlert,
TransactionState as ActivityLink,
Expand All @@ -21,11 +20,10 @@ import { DEFAULT_PRECISION, V_COW_CONTRACT_ADDRESS } from 'constants/index'
import { ActivityDerivedState } from './index'
import { GnosisSafeLink } from './StatusDetails'
import CurrencyLogo from 'components/CurrencyLogo'
import AttentionIcon from 'assets/cow-swap/attention.svg'
import { useToken } from 'hooks/Tokens'
import SVG from 'react-inlinesvg'
import { ActivityStatus } from 'hooks/useRecentActivity'
import { V_COW, COW } from 'constants/tokens'
import { OrderProgressBar } from './OrderProgressBar'

const DEFAULT_ORDER_SUMMARY = {
from: '',
Expand All @@ -34,17 +32,6 @@ const DEFAULT_ORDER_SUMMARY = {
validTo: '',
}

function unfillableAlert(): JSX.Element {
return (
<>
<TransactionAlertMessage type="attention">
<SVG src={AttentionIcon} description="Limit Price Warning" />
<b>Limit price out of range:</b>&nbsp;Wait for a matching price or cancel your order.
</TransactionAlertMessage>
</>
)
}

function GnosisSafeTxDetails(props: {
chainId: number
activityDerivedState: ActivityDerivedState
Expand Down Expand Up @@ -159,8 +146,7 @@ export function ActivityDetails(props: {
creationTime?: string | undefined
}) {
const { activityDerivedState, chainId, activityLinkUrl, disableMouseActions, creationTime } = props
const { id, isOrder, summary, order, enhancedTransaction, isCancelled, isExpired, isUnfillable } =
activityDerivedState
const { id, isOrder, summary, order, enhancedTransaction, isCancelled, isExpired } = activityDerivedState
const tokenAddress =
enhancedTransaction?.approval?.tokenAddress || (enhancedTransaction?.claim && V_COW_CONTRACT_ADDRESS[chainId])
const singleToken = useToken(tokenAddress) || null
Expand Down Expand Up @@ -307,10 +293,15 @@ export function ActivityDetails(props: {
View details ↗
</ActivityLink>
)}

{isUnfillable && unfillableAlert()}

<GnosisSafeTxDetails chainId={chainId} activityDerivedState={activityDerivedState} />
{order && creationTime && validTo && (
<OrderProgressBar
activityDerivedState={activityDerivedState}
creationTime={new Date(order.creationTime)}
validTo={new Date((order.validTo as number) * 1000)}
chainId={chainId}
/>
)}
</SummaryInner>
</Summary>
)
Expand Down
29 changes: 29 additions & 0 deletions src/custom/components/AccountDetails/Transaction/CancelButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useState } from 'react'
import { LinkStyledButton } from 'theme'
import { ActivityDerivedState } from './index'
import { CancellationModal } from './CancelationModal'

export function CancelButton(props: { chainId: number; activityDerivedState: ActivityDerivedState }) {
const { activityDerivedState, chainId } = props
const { id, summary } = activityDerivedState

const [showCancelModal, setShowCancelModal] = useState(false)

const onCancelClick = () => setShowCancelModal(true)
const onDismiss = () => setShowCancelModal(false)

return (
<>
<LinkStyledButton onClick={onCancelClick}>Cancel order</LinkStyledButton>{' '}
{showCancelModal && (
<CancellationModal
chainId={chainId}
orderId={id}
summary={summary}
isOpen={showCancelModal}
onDismiss={onDismiss}
/>
)}
</>
)
}
Loading