Skip to content

Commit

Permalink
remove sol in solana, improve image
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki committed Apr 6, 2024
1 parent a9d25b7 commit a27f989
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/context/assets.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Asset, FeeAsset } from "@skip-router/core";
import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo } from "react";
import { createContext, ReactNode, useCallback, useContext, useMemo } from "react";

import { useChains } from "@/hooks/useChains";
import { sortFeeAssets } from "@/utils/chain";
Expand Down Expand Up @@ -89,20 +89,20 @@ export function AssetsProvider({ children }: { children: ReactNode }) {

const isReady = useMemo(() => Object.keys(assets).length > 0, [assets]);

useEffect(() => {
if (!isReady || !chains || !assets) return;
const load = (src: string) => {
const img = new Image();
img.src = src;
img.onload = () => img.remove();
};
chains.forEach(({ chainID, logoURI }) => {
logoURI && load(logoURI);
(assets[chainID] || []).forEach(({ logoURI }) => {
logoURI && load(logoURI);
});
});
}, [assets, chains, isReady]);
// useEffect(() => {
// if (!isReady || !chains || !assets) return;
// const load = (src: string) => {
// const img = new Image();
// img.src = src;
// img.onload = () => img.remove();
// };
// chains.forEach(({ chainID, logoURI }) => {
// logoURI && load(logoURI);
// (assets[chainID] || []).forEach(({ logoURI }) => {
// logoURI && load(logoURI);
// });
// });
// }, [assets, chains, isReady]);

return (
<AssetsContext.Provider
Expand Down
12 changes: 12 additions & 0 deletions src/solve/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ export function useAssets(options: AssetsRequest = {}) {
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
select: (assets) => {
return Object.fromEntries(
Object.entries(assets).map(([chainID, chainAssets]) => {
return [
chainID,
chainAssets.filter((asset) => {
return !(asset.denom === "solana-devnet-native" || asset.denom === "solana-native");
}),
];
}),
);
},
});
}

Expand Down

0 comments on commit a27f989

Please sign in to comment.