Skip to content

Commit

Permalink
feat: show external urls when assets has no supported chains (#4017)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseRFelix authored Dec 18, 2024
1 parent 0e24d9e commit 1ddc917
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/web/components/bridge/amount-and-review-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export const AmountAndReviewScreen = observer(
const { supportedAssetsByChainId: counterpartySupportedAssetsByChainId } =
supportedAssets;

const hasNoSupportedChains =
!supportedAssets.isLoading &&
supportedAssets.supportedChains.length === 0;

/** Filter for bridges for the current to/from chain/asset selection. */
const supportedBridgeInfo = useMemo<SupportedBridgeInfo>(() => {
if (!fromAsset || !toAsset || !fromChain || !toChain)
Expand Down Expand Up @@ -283,6 +287,7 @@ export const AmountAndReviewScreen = observer(
isLoadingAssetsInOsmosis={isLoadingAssetsInOsmosis}
bridgesSupportedAssets={supportedAssets}
supportedBridgeInfo={supportedBridgeInfo}
hasNoSupportedChains={hasNoSupportedChains}
fromChain={fromChain}
setFromChain={setFromChain}
toChain={toChain}
Expand Down
19 changes: 16 additions & 3 deletions packages/web/components/bridge/amount-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface AmountScreenProps {

bridgesSupportedAssets: ReturnType<typeof useBridgesSupportedAssets>;
supportedBridgeInfo: SupportedBridgeInfo;
hasNoSupportedChains: boolean;

fromChain: BridgeChainWithDisplayInfo | undefined;
setFromChain: (chain: BridgeChainWithDisplayInfo) => void;
Expand Down Expand Up @@ -125,6 +126,7 @@ export const AmountScreen = observer(
isLoading: isLoadingSupportedAssets,
},
supportedBridgeInfo,
hasNoSupportedChains,

fromChain,
setFromChain,
Expand Down Expand Up @@ -829,7 +831,7 @@ export const AmountScreen = observer(
* - Quoting is disabled for the current selection, meaning providers can't provide quotes but they may provide external URLs
*/
if (
!isLoading &&
(!isLoading || hasNoSupportedChains) &&
(areAssetTransfersDisabled ||
!fromChain ||
!fromAsset ||
Expand All @@ -840,11 +842,22 @@ export const AmountScreen = observer(
) {
return (
<>
{chainSelection}
{!hasNoSupportedChains && chainSelection}
<OnlyExternalBridgeSuggest
direction={direction}
toChain={toChain}
toAsset={toAsset}
toAsset={
// If we haven't supported a chain, we can't suggest an asset
// so we use the canonical asset as a fallback
canonicalAsset && !toAsset && hasNoSupportedChains
? {
address: canonicalAsset?.coinMinimalDenom,
decimals: canonicalAsset?.coinDecimals,
denom: canonicalAsset?.coinDenom,
coinGeckoId: canonicalAsset?.coinGeckoId,
}
: toAsset
}
canonicalAssetDenom={canonicalAsset?.coinDenom}
fromChain={fromChain}
fromAsset={fromAsset}
Expand Down

0 comments on commit 1ddc917

Please sign in to comment.