Skip to content

Commit 9974774

Browse files
feat: add square chain icons (#2302)
Co-authored-by: neocybereth <[email protected]>
1 parent efd7d83 commit 9974774

File tree

12 files changed

+85
-31
lines changed

12 files changed

+85
-31
lines changed

apps/namadillo/src/App/Ibc/IbcWithdraw.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const IbcWithdraw = ({
7474
const [amount, setAmount] = useState<BigNumber | undefined>();
7575
const [customAddress, setCustomAddress] = useState<string>("");
7676
const [sourceChannel, setSourceChannel] = useState("");
77-
const [destinationChain, setDestinationChain] = useState<Chain | undefined>();
77+
const [destinationChain] = useState<Chain | undefined>();
7878
const [completedAt, setCompletedAt] = useState<Date | undefined>();
7979
const [txHash, setTxHash] = useState<string | undefined>();
8080
// ERROR & STATUS STATE
@@ -83,12 +83,8 @@ export const IbcWithdraw = ({
8383
const [generalErrorMessage, setGeneralErrorMessage] = useState("");
8484
// GLOBAL STATE
8585
const defaultAccounts = useAtomValue(allDefaultAccountsAtom);
86-
const {
87-
walletAddress: keplrAddress,
88-
connectToChainId,
89-
chainId,
90-
loadWalletAddress,
91-
} = useWalletManager(keplrWalletManager);
86+
const { walletAddress: keplrAddress, chainId } =
87+
useWalletManager(keplrWalletManager);
9288
const transparentAccount = useAtomValue(defaultAccountAtom);
9389
const namadaChain = useAtomValue(chainAtom);
9490
const [ledgerStatus, setLedgerStatusStop] = useAtom(ledgerStatusDataAtom);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Chain } from "@chain-registry/types";
2+
import { twMerge } from "tailwind-merge";
3+
4+
export const ChainBadge = ({
5+
chain,
6+
className,
7+
}: {
8+
chain?: Chain;
9+
className?: string;
10+
}): JSX.Element => {
11+
if (!chain) {
12+
return <></>;
13+
}
14+
15+
const image = chain?.images?.find((i) => i.theme?.circle === false);
16+
const imageUrl = image?.svg ?? image?.png;
17+
18+
return (
19+
<div
20+
className={twMerge(
21+
"w-6 h-6 rounded-sm bg-black overflow-hidden",
22+
className
23+
)}
24+
>
25+
{imageUrl ?
26+
<img
27+
src={imageUrl}
28+
alt={chain.chain_name}
29+
className="w-full h-full object-contain"
30+
draggable={false}
31+
/>
32+
: <span className="text-white">
33+
{chain.chain_name.charAt(0).toUpperCase()}
34+
</span>
35+
}
36+
</div>
37+
);
38+
};

apps/namadillo/src/App/Transfer/SelectToken.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
import { Chain } from "@chain-registry/types";
2-
import namadaChain from "@namada/chain-registry/namada/chain.json";
32
import { Modal, Stack } from "@namada/components";
43
import { ModalTransition } from "App/Common/ModalTransition";
54
import { Search } from "App/Common/Search";
65
import {
76
connectedWalletsAtom,
87
getAvailableChains,
98
getChainRegistryByChainName,
9+
getNamadaChainRegistry,
1010
namadaRegistryChainAssetsMapAtom,
1111
} from "atoms/integrations";
1212
import { tokenPricesFamily } from "atoms/prices/atoms";
1313
import clsx from "clsx";
1414
import { useWalletManager } from "hooks/useWalletManager";
1515
import { KeplrWalletManager } from "integrations/Keplr";
16-
import { getChainFromAsset, getChainImageUrl } from "integrations/utils";
16+
import { getChainFromAsset } from "integrations/utils";
1717
import { useAtom, useAtomValue } from "jotai";
1818
import { useMemo, useState } from "react";
1919
import { IoClose } from "react-icons/io5";
2020
import { AssetWithAmount } from "types";
2121
import { AddressDropdown } from "./AddressDropdown";
22+
import { ChainBadge } from "./ChainBadge";
2223
import { isNamadaAddress } from "./common";
2324

2425
type SelectTokenProps = {
@@ -51,7 +52,8 @@ export const SelectToken = ({
5152
const chainAssets = useAtomValue(namadaRegistryChainAssetsMapAtom);
5253
const chainAssetsMap = Object.values(chainAssets.data ?? {});
5354
const ibcChains = useMemo(getAvailableChains, []);
54-
const allChains = [...ibcChains, namadaChain as unknown as Chain];
55+
56+
const allChains = [...ibcChains, getNamadaChainRegistry(false).chain];
5557

5658
// Create KeplrWalletManager instance and use with useWalletManager hook
5759
const keplrWallet = keplrWalletManager ?? new KeplrWalletManager();
@@ -174,17 +176,13 @@ export const SelectToken = ({
174176

175177
const getOverlayChainLogo = (token: AssetWithAmount): JSX.Element | null => {
176178
const chain = getChainFromAsset(token);
177-
const chainImageUrl = getChainImageUrl(chain);
178179
const isNamada = token.asset.symbol === "NAM";
179180
if (isNamada) return null;
180181
return (
181-
<div className="absolute -bottom-0.5 -right-0.5 w-5 h-5 rounded-full bg-black border-2 border-neutral-600 flex items-center justify-center overflow-hidden z-10">
182-
<img
183-
src={chainImageUrl}
184-
alt={chain?.chain_name || "chain"}
185-
className="w-4 h-4 object-cover rounded-full"
186-
/>
187-
</div>
182+
<ChainBadge
183+
chain={chain}
184+
className="absolute -bottom-0.5 -right-0.5 w-5 h-5 border border-neutral-600"
185+
/>
188186
);
189187
};
190188

@@ -237,19 +235,7 @@ export const SelectToken = ({
237235
: "hover:bg-neutral-800"
238236
}`}
239237
>
240-
<div className="w-7 h-7 rounded-sm flex items-center justify-center overflow-hidden">
241-
{network.logo_URIs?.svg ?
242-
<img
243-
src={network.logo_URIs?.svg}
244-
alt={network.chain_name}
245-
className="w-full h-full object-contain !rounded-none"
246-
draggable={false}
247-
/>
248-
: <span className="text-white">
249-
{network.chain_name?.charAt(0)}
250-
</span>
251-
}
252-
</div>
238+
<ChainBadge chain={network} />
253239
<span
254240
className={clsx("capitalize font-normal text-white")}
255241
>
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)