Skip to content

Commit

Permalink
Merge pull request #371 from reservoirprotocol/fix/destination-addres…
Browse files Browse the repository at this point in the history
…s-dead-address

Fix/destination address dead address
  • Loading branch information
pedromcunha authored Nov 12, 2024
2 parents 421d583 + dce3b7b commit 0786fe8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-coats-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-kit-ui': patch
---

Ensure dead address is properly generated
8 changes: 4 additions & 4 deletions packages/ui/src/components/common/CustomAddressModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const CustomAddressModal: FC<Props> = ({
setAddress('')
setInput('')
} else {
if (isValidAddress(toChain?.vmType, toAddress ?? '')) {
if (isValidAddress(toChain?.vmType, toAddress ?? '', toChain?.id)) {
setAddress(toAddress ? toAddress : '')
setInput(toAddress ? toAddress : '')
}
Expand All @@ -90,7 +90,7 @@ export const CustomAddressModal: FC<Props> = ({
)

useEffect(() => {
if (isValidAddress(toChain?.vmType, input)) {
if (isValidAddress(toChain?.vmType, input, toChain?.id)) {
setAddress(input)
} else if (resolvedENS?.address) {
setAddress(resolvedENS.address)
Expand Down Expand Up @@ -247,10 +247,10 @@ export const CustomAddressModal: FC<Props> = ({
) : null}
</Flex>
<Button
disabled={!isValidAddress(toChain?.vmType, address)}
disabled={!isValidAddress(toChain?.vmType, address, toChain?.id)}
css={{ justifyContent: 'center' }}
onClick={() => {
if (isValidAddress(toChain?.vmType, address)) {
if (isValidAddress(toChain?.vmType, address, toChain?.id)) {
onConfirmed(address)
onAnalyticEvent?.(EventNames.ADDRESS_MODAL_CONFIRMED, {
address: address,
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/src/components/widgets/SwapWidgetRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,16 @@ const SwapWidgetRenderer: FC<SwapWidgetRendererProps> = ({
connectorKeyOverrides
)

const isValidToAddress = isValidAddress(toChain?.vmType, recipient ?? '')
const toAddressWithFallback = addressWithFallback(toChain?.vmType, recipient)
const isValidToAddress = isValidAddress(
toChain?.vmType,
recipient ?? '',
toChain?.id
)
const toAddressWithFallback = addressWithFallback(
toChain?.vmType,
recipient,
toChain?.id
)

const externalLiquiditySupport = usePrice(
relayClient ? relayClient : undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/hooks/useCurrencyBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const useCurrencyBalance = ({
}
})

const _isValidAddress = isValidAddress(chain?.vmType, address)
const _isValidAddress = isValidAddress(chain?.vmType, address, chain?.id)

const duneBalances = useDuneBalances(address, {
enabled: Boolean(
Expand Down

0 comments on commit 0786fe8

Please sign in to comment.