bridge_ui: prefer metaplex metadata over solana token list

Change-Id: I7a287545425852a10c07c594af8e9558317cda02
This commit is contained in:
Chase Moran 2021-11-09 12:54:54 -05:00
parent c600686677
commit 7ad15fbfc4
4 changed files with 20 additions and 16 deletions

View File

@ -123,7 +123,6 @@ function SendConfirmationContent({
originChain={originChain}
targetAsset={targetAsset ?? undefined}
targetChain={targetChain}
symbol={symbol}
/>
</DialogContent>
<DialogActions>

View File

@ -90,14 +90,12 @@ export default function TokenWarning({
originChain,
targetChain,
targetAsset,
symbol,
}: {
sourceChain?: ChainId;
sourceAsset?: string;
originChain?: ChainId;
targetChain?: ChainId;
targetAsset?: string;
symbol?: string;
}) {
if (
!(originChain && targetChain && targetAsset && sourceChain && sourceAsset)
@ -109,7 +107,9 @@ export default function TokenWarning({
? sourceAsset.toLowerCase()
: sourceAsset;
const isWormholeWrapped = originChain !== targetChain;
const isMultiChain = !!MULTI_CHAIN_TOKENS[sourceChain]?.[searchableAddress];
const multichainSymbol =
MULTI_CHAIN_TOKENS[sourceChain]?.[searchableAddress] || undefined;
const isMultiChain = !!multichainSymbol;
const isRewardsToken =
searchableAddress === "0xae7ab96520de3a18e5e111b5eaab095312d7fe84" &&
sourceChain === CHAIN_ID_ETH;
@ -122,7 +122,7 @@ export default function TokenWarning({
<>
{showMultiChainWarning ? (
<MultichainWarning
symbol={symbol || "tokens"}
symbol={multichainSymbol || "tokens"}
targetChain={targetChain}
/>
) : null}

View File

@ -17,7 +17,7 @@ export type GenericMetadata = {
symbol?: string;
logo?: string;
tokenName?: string;
decimals?: number;
//decimals?: number;
//TODO more items
raw?: any;
};
@ -36,9 +36,9 @@ const constructSolanaMetadata = (
const tokenInfo = solanaTokenMap.data?.find((x) => x.address === address);
//Both this and the token picker, at present, give priority to the tokenmap
const obj = {
symbol: tokenInfo?.symbol || metaplex?.data.symbol || undefined,
logo: tokenInfo?.logoURI || metaplex?.data.uri || undefined, //TODO is URI on metaplex actually the logo? If not, where is it?
tokenName: tokenInfo?.name || metaplex?.data.name || undefined,
symbol: metaplex?.data?.symbol || tokenInfo?.symbol || undefined,
logo: tokenInfo?.logoURI || undefined, //TODO is URI on metaplex actually the logo? If not, where is it?
tokenName: metaplex?.data?.name || tokenInfo?.name || undefined,
decimals: tokenInfo?.decimals || undefined, //TODO decimals are actually on the mint, not the metaplex account.
raw: metaplex,
};

View File

@ -631,12 +631,13 @@ export const VAA_EMITTER_ADDRESSES = [
export const WORMHOLE_EXPLORER_BASE = "https://wormholenetwork.com/en/explorer";
export const MULTI_CHAIN_TOKENS: {
[x: number]: { [address: string]: string };
} =
export type MultiChainInfo = {
[key in ChainId]: { [address: string]: string };
};
export const MULTI_CHAIN_TOKENS: MultiChainInfo =
//EVM chains should format the addresses to all lowercase
CLUSTER === "mainnet"
? {
? ({
[CHAIN_ID_SOLANA]: {
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: "USDC",
Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB: "USDT",
@ -654,12 +655,16 @@ export const MULTI_CHAIN_TOKENS: {
"0x2791bca1f2de4661ed88a30c99a7a9449aa84174": "USDC",
"0xc2132d05d31c914a87c6611c10748aeb04b58e8f": "USDT",
},
}
: {
} as MultiChainInfo)
: ({
[CHAIN_ID_SOLANA]: {
"2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ": "SOLT",
},
};
[CHAIN_ID_ETH]: {},
[CHAIN_ID_TERRA]: {},
[CHAIN_ID_BSC]: {},
[CHAIN_ID_POLYGON]: {},
} as MultiChainInfo);
export const AVAILABLE_MARKETS_URL =
"https://docs.wormholenetwork.com/wormhole/overview-liquid-markets";