Skip to content

Commit

Permalink
Merge branch 'feature/deposit-addresses' of github.com:reservoirproto…
Browse files Browse the repository at this point in the history
…col/relay-sdk into feature/deposit-addresses
  • Loading branch information
pedromcunha committed Nov 25, 2024
2 parents 0bf1394 + f99914b commit 3862a8a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
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 @@ -383,8 +383,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 @@ -443,9 +443,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 @@ -691,15 +691,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 @@ -710,17 +717,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 @@ -752,8 +752,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 @@ -840,9 +840,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 @@ -1026,6 +1026,7 @@ const SwapWidget: FC<SwapWidgetProps> = ({
isValidFromAddress={isValidFromAddress}
isValidToAddress={isValidToAddress}
isValidRefundAddress={isValidRefundAddress}
fromChainWalletVMSupported={fromChainWalletVMSupported}
context={'Swap'}
onConnectWallet={onConnectWallet}
onAnalyticEvent={onAnalyticEvent}
Expand Down Expand Up @@ -1080,8 +1081,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 @@ -665,6 +665,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

0 comments on commit 3862a8a

Please sign in to comment.