Skip to content

Commit be68d95

Browse files
fix: add usdc back to select chain modal (#2229)
Co-authored-by: Mateusz Jasiuk <mateusz.jasiuk@gmail.com>
1 parent 7b78563 commit be68d95

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { allDefaultAccountsAtom } from "atoms/accounts";
1010
import {
1111
assetBalanceAtomFamily,
1212
getAvailableChains,
13-
getNamadaAssetByIbcAsset,
1413
ibcChannelsFamily,
1514
namadaChainRegistryAtom,
15+
SUPPORTED_ASSETS_MAP,
1616
} from "atoms/integrations";
1717
import BigNumber from "bignumber.js";
1818
import { useFathomTracker } from "hooks/useFathomTracker";
@@ -84,24 +84,22 @@ export const IbcTransfer = (): JSX.Element => {
8484
selectedAssetBase ? userAssets?.[selectedAssetBase]?.asset : undefined;
8585

8686
const availableAssets = useMemo(() => {
87-
if (!userAssets || !chainRegistry) return undefined;
87+
if (!userAssets || !registry) return undefined;
8888

8989
const output: Record<BaseDenom, AssetWithAmount> = {};
9090

9191
Object.entries(userAssets).forEach(([key, { asset }]) => {
92-
const namadaAsset = getNamadaAssetByIbcAsset(
93-
asset,
94-
chainRegistry.assets.assets
95-
);
96-
97-
// Include if asset has a corresponding Namada asset, and it's either native or native for namada
98-
if (namadaAsset && (!asset.traces || !namadaAsset.traces)) {
92+
if (
93+
SUPPORTED_ASSETS_MAP.get(registry.chain.chain_name)?.includes(
94+
asset.symbol
95+
)
96+
) {
9997
output[key] = { ...userAssets[key] };
10098
}
10199
});
102100

103101
return output;
104-
}, [Object.keys(userAssets || {}).join(""), chainRegistry?.chain.chain_id]);
102+
}, [Object.keys(userAssets || {}).join(""), registry?.chain.chain_name]);
105103

106104
// Manage the history of transactions
107105
const { storeTransaction } = useTransactionActions();

apps/namadillo/src/atoms/integrations/functions.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ const SUPPORTED_CHAINS_MAP = new Map<string, ChainRegistryEntry>(
105105
})
106106
);
107107

108+
export const SUPPORTED_ASSETS_MAP = new Map<string, string[]>(
109+
Object.entries({
110+
osmosis: ["NAM", "OSMO"],
111+
cosmoshub: ["ATOM"],
112+
celestia: ["TIA"],
113+
nyx: ["NYX"],
114+
stride: ["stOSMO", "stATOM", "stTIA"],
115+
neutron: ["NTRN"],
116+
noble: ["USDC"],
117+
})
118+
);
119+
108120
export const getRpcByIndex = (chain: Chain, index = 0): RpcStorage => {
109121
const availableRpcs = chain.apis?.rpc;
110122
if (!availableRpcs) {
@@ -211,26 +223,6 @@ export const getIbcAssetByNamadaAsset = (
211223
return ibcAsset;
212224
};
213225

214-
export const getNamadaAssetByIbcAsset = (
215-
asset: Asset,
216-
namadaAssets: NamadaAsset[]
217-
): NamadaAsset | undefined => {
218-
// Returns base denom for provided asset(e.g. "uosmo", "uatom", "unam")
219-
const counterpartyBaseDenom =
220-
asset.traces?.[0].counterparty.base_denom || asset.base;
221-
222-
const namadaAsset = namadaAssets.find((namadaAsset) => {
223-
return (
224-
// Match native token(unam)
225-
counterpartyBaseDenom === namadaAsset.base ||
226-
// Match any other token
227-
counterpartyBaseDenom === namadaAsset.traces?.[0].counterparty.base_denom
228-
);
229-
});
230-
231-
return namadaAsset;
232-
};
233-
234226
export const getNamadaIbcInfo = (isHousefire: boolean): IBCInfo[] => {
235227
const ibcInfo = getNamadaChainRegistry(isHousefire).ibc;
236228
invariant(ibcInfo, "Namada IBC info is not available");

0 commit comments

Comments
 (0)