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

sync staging to main #207

Merged
merged 9 commits into from
Mar 8, 2024
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
9 changes: 9 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ let nextConfig = {
"uuid",
]
: [],
images: {
dangerouslyAllowSVG: true,
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
webpack: (config, { dev, isServer }) => {
if (dev && isServer) checkEnv();
return config;
Expand Down
Binary file added public/logo-fallback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions src/components/AssetSelect/AssetSelectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ArrowLeftIcon } from "@heroicons/react/20/solid";
import * as ScrollArea from "@radix-ui/react-scroll-area";
import { Asset } from "@skip-router/core";
import { matchSorter } from "match-sorter";
import Image from "next/image";
import { useEffect, useMemo, useRef, useState } from "react";
import { formatUnits } from "viem";

Expand Down Expand Up @@ -93,10 +94,12 @@ function AssetSelectContent({ assets = [], balances, onChange, onClose, showChai
className="flex w-full items-center gap-4 rounded-xl p-4 text-left transition-colors hover:bg-[#ECD9D9] focus:-outline-offset-2"
onClick={() => (onClose(), onChange?.(asset))}
>
<img
alt={asset.recommendedSymbol}
className="h-12 w-12 rounded-full"
src={asset.logoURI}
<Image
height={48}
width={48}
alt={asset.recommendedSymbol || "symbol"}
className="h-12 w-12 rounded-full object-contain"
src={asset.logoURI || "/logo-fallback.png"}
onError={(e) => (e.currentTarget.src = "https://api.dicebear.com/6.x/shapes/svg")}
/>
<div className="flex-1">
Expand Down
11 changes: 7 additions & 4 deletions src/components/AssetSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChevronDownIcon } from "@heroicons/react/20/solid";
import { Asset } from "@skip-router/core";
import Image from "next/image";
import { useState } from "react";

import { Dialog, DialogContent, DialogTrigger } from "@/components/Dialog";
Expand Down Expand Up @@ -35,10 +36,12 @@ function AssetSelect({ asset, assets, balances, onChange, showChainInfo, isBalan
data-testid="select-asset"
>
{asset && (
<img
alt={asset.recommendedSymbol}
className="h-6 w-6 rounded-full"
src={asset.logoURI}
<Image
alt={asset.recommendedSymbol || "asset symbol"}
height={24}
width={24}
className="h-6 w-6 rounded-full object-contain"
src={asset.logoURI || "/logo-fallback.png"}
onError={(event) => (event.currentTarget.src = "https://api.dicebear.com/6.x/shapes/svg")}
/>
)}
Expand Down
11 changes: 7 additions & 4 deletions src/components/ChainSelect/ChainSelectContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ArrowLeftIcon } from "@heroicons/react/20/solid";
import * as ScrollArea from "@radix-ui/react-scroll-area";
import { matchSorter } from "match-sorter";
import Image from "next/image";
import { useEffect, useMemo, useRef, useState } from "react";

import { Chain } from "@/hooks/useChains";
Expand Down Expand Up @@ -86,12 +87,14 @@ function ChainSelectContent({ chains, onChange, onClose }: Props) {
onClick={() => onChange(chain)}
data-testid="chain-item"
>
<img
<Image
alt={chain.prettyName}
className="h-12 w-12 rounded-full"
src={chain.logoURI}
onError={(e) => (e.currentTarget.src = "https://api.dicebear.com/6.x/shapes/svg")}
className="h-[48px] w-[48px] rounded-full object-contain"
width={48}
height={48}
src={chain.logoURI || "/logo-fallback.png"}
/>

<div>
<p className="text-lg font-semibold">{chain.prettyName}</p>
<p className="text-sm text-neutral-500">{chain.chainID}</p>
Expand Down
7 changes: 5 additions & 2 deletions src/components/ConnectedWalletButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Image from "next/image";
import { ComponentProps, forwardRef } from "react";

import { cn } from "@/utils/ui";
Expand All @@ -22,9 +23,11 @@ export const ConnectedWalletButton = forwardRef<HTMLButtonElement, Props>(
ref={ref}
>
{walletLogo && (
<img
<Image
height={16}
width={16}
alt={walletName}
className="h-4 w-4"
className="object-contain"
src={walletLogo}
/>
)}
Expand Down
10 changes: 7 additions & 3 deletions src/components/RouteDisplay/RouteEnd.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Image from "next/image";

import { SimpleTooltip } from "../SimpleTooltip";

export interface RouteEndProps {
Expand All @@ -10,9 +12,11 @@ export interface RouteEndProps {
export const RouteEnd = ({ amount, symbol, logo, chain }: RouteEndProps) => {
return (
<div className="flex items-center gap-2">
<div className="h-14 w-14 rounded-full border-2 border-neutral-200 bg-white p-1.5">
<img
className="h-full w-full"
<div className="relative h-14 w-14 rounded-full border-2 border-neutral-200 bg-white p-1.5">
<Image
height={54}
width={54}
className="object-contain"
src={logo}
alt={chain}
/>
Expand Down
60 changes: 38 additions & 22 deletions src/components/RouteDisplay/SwapStep.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SwapVenue } from "@skip-router/core";
import Image from "next/image";
import { useMemo } from "react";

import { SWAP_VENUES } from "@/constants/swap-venues";
Expand Down Expand Up @@ -97,19 +98,23 @@ export const SwapStep = ({ action, actions, statusData }: SwapStepProps) => {
<Gap.Parent className="text-sm text-neutral-500">
<span>Swap to</span>
<Gap.Child>
<img
alt={assetOut.name}
className="inline-block h-4 w-4"
<Image
height={16}
width={16}
alt={assetOut.name || "assetOut"}
className="inline-block h-4 w-4 object-contain"
onError={onImageError}
src={assetOut.logoURI}
src={assetOut.logoURI || "/logo-fallback.png"}
/>
<span className="font-semibold text-black">{assetOut.recommendedSymbol}</span>
</Gap.Child>
<span>on</span>
<Gap.Child>
<img
<Image
height={16}
width={16}
alt={action.venue.name}
className="inline-block h-4 w-4"
className="inline-block h-4 w-4 object-contain"
onError={onImageError}
src={action.venue.logoUri}
/>
Expand Down Expand Up @@ -138,16 +143,18 @@ export const SwapStep = ({ action, actions, statusData }: SwapStepProps) => {
<Gap.Parent className="text-sm text-neutral-500">
<span>Swap</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={assetIn.logoURI}
alt={assetIn.name}
<Image
height={16}
width={16}
className="inline-block h-4 w-4 object-contain"
src={assetIn.logoURI || "/logo-fallback.png"}
alt={assetIn.name || "assetIn"}
/>
<span className="font-semibold text-black">{assetIn.recommendedSymbol}</span>
</Gap.Child>
<span>on</span>
<Gap.Child>
<img
<Image
className="inline-block h-4 w-4"
src={action.venue.logoUri}
alt={action.venue.name}
Expand Down Expand Up @@ -183,28 +190,37 @@ export const SwapStep = ({ action, actions, statusData }: SwapStepProps) => {
<Gap.Parent className="text-sm text-neutral-500">
<span>Swap</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={assetIn.logoURI}
alt={assetIn.name}
<Image
height={16}
width={16}
className="inline-block h-4 w-4 object-contain"
onError={onImageError}
src={assetIn.logoURI || "/logo-fallback.png"}
alt={assetIn.name || "assetIn"}
/>

<span className="font-semibold text-black">{assetIn.recommendedSymbol}</span>
</Gap.Child>
<span>for</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={assetOut.logoURI}
alt={assetOut.name}
<Image
height={16}
width={16}
className="inline-block h-4 w-4 object-contain"
src={assetOut.logoURI || "/logo-fallback.png"}
alt={assetOut.name || "assetOut"}
/>
<span className="font-semibold text-black">{assetOut.recommendedSymbol}</span>
</Gap.Child>
<Gap.Child>
<span>on</span>
<img
className="inline-block h-4 w-4"
src={action.venue.logoUri}
<Image
height={16}
width={16}
alt={action.venue.name}
className="inline-block h-4 w-4 object-contain"
onError={onImageError}
src={action.venue.logoUri}
/>
<span className="font-semibold text-black">{venue.prettyName}</span>
</Gap.Child>
Expand Down
55 changes: 35 additions & 20 deletions src/components/RouteDisplay/TransferStep.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BridgeType } from "@skip-router/core";
import Image from "next/image";
import { useMemo } from "react";

import { useAssets } from "@/context/assets";
Expand Down Expand Up @@ -101,9 +102,11 @@ export const TransferStep = ({ action, actions, statusData }: TransferStepProps)
<span>Transfer</span>
<span>from</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={sourceChain.logoURI}
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={sourceChain.logoURI || "/logo-fallback.png"}
alt={sourceChain.prettyName}
onError={onImageError}
/>
Expand All @@ -113,9 +116,11 @@ export const TransferStep = ({ action, actions, statusData }: TransferStepProps)
<Gap.Parent>
<span>to</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={destinationChain.logoURI}
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={destinationChain.logoURI || "/logo-fallback.png"}
alt={destinationChain.prettyName}
onError={onImageError}
/>
Expand All @@ -126,8 +131,10 @@ export const TransferStep = ({ action, actions, statusData }: TransferStepProps)
<span>with</span>
<Gap.Child>
{bridge.name.toLowerCase() !== "ibc" && (
<img
className="inline-block h-4 w-4"
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={bridge.logoURI}
alt={bridge.name}
onError={onImageError}
Expand Down Expand Up @@ -164,18 +171,22 @@ export const TransferStep = ({ action, actions, statusData }: TransferStepProps)
<Gap.Parent>
<span>Transfer</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={asset.logoURI}
alt={asset.name}
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={asset.logoURI || "/logo-fallback.png"}
alt={asset.name || "asset"}
/>
<span className="font-semibold text-black">{asset.recommendedSymbol}</span>
</Gap.Child>
<span>from</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={sourceChain.logoURI}
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={sourceChain.logoURI || "/logo-fallback.png"}
alt={sourceChain.prettyName}
onError={onImageError}
/>
Expand All @@ -185,9 +196,11 @@ export const TransferStep = ({ action, actions, statusData }: TransferStepProps)
<Gap.Parent>
<span>to</span>
<Gap.Child>
<img
className="inline-block h-4 w-4"
src={destinationChain.logoURI}
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={destinationChain.logoURI || "/logo-fallback.png"}
alt={destinationChain.prettyName}
onError={onImageError}
/>
Expand All @@ -198,8 +211,10 @@ export const TransferStep = ({ action, actions, statusData }: TransferStepProps)
<span>with</span>
<Gap.Child>
{bridge.name.toLowerCase() !== "ibc" && (
<img
className="inline-block h-4 w-4"
<Image
className="inline-block h-4 w-4 object-contain"
height={16}
width={16}
src={bridge.logoURI}
alt={bridge.name}
onError={onImageError}
Expand Down
27 changes: 20 additions & 7 deletions src/components/SwapWidget/SwapDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,29 @@ export const SwapDetails = ({
if ("axelarTransfer" in op) return op;
}
}, [route]);
const hyperlaneTransferOperation = useMemo(() => {
for (const op of route.operations) {
if ("hyperlaneTransfer" in op) return op;
}
}, [route]);

const bridgingFee = useMemo(() => {
if (!axelarTransferOperation) return;
const { feeAmount, feeAsset, usdFeeAmount } = axelarTransferOperation.axelarTransfer;
const computed = (+feeAmount / Math.pow(10, feeAsset.decimals || 18)).toLocaleString("en-US", {
maximumFractionDigits: 6,
});
if (hyperlaneTransferOperation) {
const { feeAmount, feeAsset, usdFeeAmount } = hyperlaneTransferOperation.hyperlaneTransfer;
const computed = (+feeAmount / Math.pow(10, feeAsset.decimals || 6)).toLocaleString("en-US", {
maximumFractionDigits: 6,
});
return { inAsset: `${computed} ${feeAsset.symbol}`, inUSD: usdFeeAmount && `${formatUSD(usdFeeAmount)}` };
}
if (axelarTransferOperation) {
const { feeAmount, feeAsset, usdFeeAmount } = axelarTransferOperation.axelarTransfer;
const computed = (+feeAmount / Math.pow(10, feeAsset.decimals || 18)).toLocaleString("en-US", {
maximumFractionDigits: 6,
});

return { inAsset: `${computed} ${feeAsset.symbol}`, inUSD: `${formatUSD(usdFeeAmount)}` };
}, [axelarTransferOperation]);
return { inAsset: `${computed} ${feeAsset.symbol}`, inUSD: `${formatUSD(usdFeeAmount)}` };
}
}, [axelarTransferOperation, hyperlaneTransferOperation]);

if (!(sourceChain && sourceAsset && destinationChain && destinationAsset)) {
return null;
Expand Down
Loading
Loading