File tree Expand file tree Collapse file tree 4 files changed +22
-23
lines changed Expand file tree Collapse file tree 4 files changed +22
-23
lines changed Original file line number Diff line number Diff line change 1
1
import { Chain } from "@chain-registry/types" ;
2
2
import clsx from "clsx" ;
3
- import genericAsset from "./assets/generic-asset.svg " ;
3
+ import { getChainImageUrl } from "integrations/utils " ;
4
4
5
5
type ChainCardProps = {
6
6
chain : Chain ;
7
7
} ;
8
8
9
9
export const ChainCard = ( { chain } : ChainCardProps ) : JSX . Element => {
10
- const image =
11
- chain . logo_URIs ?. svg || chain . logo_URIs ?. png || genericAsset || "" ;
10
+ const image = getChainImageUrl ( chain ) ;
12
11
return (
13
12
< span
14
13
className = { clsx (
Original file line number Diff line number Diff line change 1
1
import { Chain } from "@chain-registry/types" ;
2
2
import clsx from "clsx" ;
3
+ import { getChainImageUrl } from "integrations/utils" ;
3
4
import { GoChevronDown } from "react-icons/go" ;
4
5
import { WalletProvider } from "types" ;
5
- import genericAsset from "./assets/generic-asset.svg" ;
6
-
7
6
import { EmptyResourceIcon } from "./EmptyResourceIcon" ;
8
7
9
8
type SelectedChainProps = {
@@ -25,8 +24,7 @@ export const SelectedChain = ({
25
24
) ;
26
25
27
26
const isDisabled = ! wallet ;
28
- const logoUrl =
29
- chain ? chain . logo_URIs ?. svg || chain . logo_URIs ?. png || genericAsset : "" ;
27
+ const logoUrl = getChainImageUrl ( chain ) ;
30
28
31
29
return (
32
30
< button
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -43,9 +43,26 @@ export const findAssetByDenom = (denom: string): Asset | undefined => {
43
43
return undefined ;
44
44
} ;
45
45
46
+ const getSvgOrPng = ( image ?: {
47
+ svg ?: string ;
48
+ png ?: string ;
49
+ } ) : string | undefined => {
50
+ return image ?. svg || image ?. png ;
51
+ } ;
52
+
53
+ export const getChainImageUrl = ( chain ?: Chain ) : string => {
54
+ if ( ! chain ) return tokenImage ;
55
+ return (
56
+ getSvgOrPng ( chain . images ?. find ( ( i ) => i . theme ?. circle ) ) ||
57
+ getSvgOrPng ( chain . images ?. [ 0 ] ) ||
58
+ getSvgOrPng ( chain . logo_URIs ) ||
59
+ tokenImage
60
+ ) ;
61
+ } ;
62
+
46
63
export const getAssetImageUrl = ( asset ?: Asset ) : string => {
47
64
if ( ! asset ) return tokenImage ;
48
- return asset . logo_URIs ?. svg || asset . logo_URIs ?. png || tokenImage ;
65
+ return getSvgOrPng ( asset . logo_URIs ) || tokenImage ;
49
66
} ;
50
67
51
68
export const getIbcGasConfig = (
You can’t perform that action at this time.
0 commit comments