Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packages/ui/src/components/widgets/SwapButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type SwapButtonProps = {
| 'isValidFromAddress'
| 'isValidToAddress'
| 'isValidRefundAddress'
| 'fromChainWalletVMSupported'
>

const SwapButton: FC<SwapButtonProps> = ({
Expand All @@ -39,13 +40,14 @@ const SwapButton: FC<SwapButtonProps> = ({
debouncedOutputAmountValue,
isSameCurrencySameRecipientSwap,
isValidRefundAddress,
fromChainWalletVMSupported,
onClick,
ctaCopy,
onAnalyticEvent
}) => {
const isMounted = useMounted()

if (isMounted && address) {
if (isMounted && (address || !fromChainWalletVMSupported)) {
return (
<Button
css={{ justifyContent: 'center' }}
Expand Down
50 changes: 26 additions & 24 deletions packages/ui/src/components/widgets/SwapWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ const SwapWidget: FC<SwapWidgetProps> = ({
tradeType === 'EXACT_INPUT'
? amountInputValue
: amountInputValue
? formatFixedLength(amountInputValue, 8)
: amountInputValue
? formatFixedLength(amountInputValue, 8)
: amountInputValue
}
setValue={(e) => {
setAmountInputValue(e)
Expand Down Expand Up @@ -442,9 +442,9 @@ const SwapWidget: FC<SwapWidgetProps> = ({
isSingleChainLocked
? [lockChainId]
: fromToken?.chainId !== undefined &&
fromToken?.chainId === lockChainId
? [fromToken?.chainId]
: undefined
fromToken?.chainId === lockChainId
? [fromToken?.chainId]
: undefined
}
restrictedTokensList={tokens?.filter(
(token) => token.chainId === fromToken?.chainId
Expand Down Expand Up @@ -690,15 +690,22 @@ const SwapWidget: FC<SwapWidgetProps> = ({
) : null}

{multiWalletSupportEnabled === false ||
(toChain?.vmType &&
!supportedWalletVMs.includes(toChain.vmType) &&
(!toChainWalletVMSupported &&
isMounted &&
(address || customToAddress)) ? (
<AnchorButton
<Button
color={
!toChainWalletVMSupported && !isValidToAddress
? 'primary'
: 'secondary'
}
corners="pill"
size="none"
css={{
display: 'flex',
alignItems: 'center',
gap: '2'
px: '2',
py: '1'
}}
onClick={() => {
setAddressModalOpen(true)
Expand All @@ -709,17 +716,10 @@ const SwapWidget: FC<SwapWidgetProps> = ({
>
<Text style="subtitle2" css={{ color: 'inherit' }}>
{!isValidToAddress
? `Enter ${toChain?.displayName} Address`
? `Enter Address`
: toDisplayName}
</Text>
<Box css={{ color: 'gray8' }}>
<FontAwesomeIcon
icon={faPenToSquare}
width={16}
height={16}
/>
</Box>
</AnchorButton>
</Button>
) : null}
</Flex>
{!isSingleChainLocked && (
Expand Down Expand Up @@ -751,8 +751,8 @@ const SwapWidget: FC<SwapWidgetProps> = ({
tradeType === 'EXPECTED_OUTPUT'
? amountOutputValue
: amountOutputValue
? formatFixedLength(amountOutputValue, 8)
: amountOutputValue
? formatFixedLength(amountOutputValue, 8)
: amountOutputValue
}
setValue={(e) => {
setAmountOutputValue(e)
Expand Down Expand Up @@ -839,9 +839,9 @@ const SwapWidget: FC<SwapWidgetProps> = ({
isSingleChainLocked
? [lockChainId]
: toToken?.chainId !== undefined &&
toToken?.chainId === lockChainId
? [toToken?.chainId]
: undefined
toToken?.chainId === lockChainId
? [toToken?.chainId]
: undefined
}
restrictedTokensList={tokens?.filter(
(token) => token.chainId === toToken?.chainId
Expand Down Expand Up @@ -1025,6 +1025,7 @@ const SwapWidget: FC<SwapWidgetProps> = ({
isValidFromAddress={isValidFromAddress}
isValidToAddress={isValidToAddress}
isValidRefundAddress={isValidRefundAddress}
fromChainWalletVMSupported={fromChainWalletVMSupported}
context={'Swap'}
onConnectWallet={onConnectWallet}
onAnalyticEvent={onAnalyticEvent}
Expand Down Expand Up @@ -1079,8 +1080,9 @@ const SwapWidget: FC<SwapWidgetProps> = ({
} else {
setAddressModalOpen(true)
}
} else {
setDepositAddressModalOpen(true)
}
setDepositAddressModalOpen(true)
}
}}
ctaCopy={ctaCopy}
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/widgets/SwapWidgetRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
ctaCopy = 'Insufficient Liquidity'
} else if (!isValidRefundAddress) {
ctaCopy = 'Enter Refund Address'
} else if (!toChainWalletVMSupported && !isValidToAddress) {
ctaCopy = 'Enter Address'
} else if (transactionModalOpen) {
switch (operation) {
case 'wrap': {
Expand Down