From 835d9bee7fedc5639cfd1bb66f21e1e75b363567 Mon Sep 17 00:00:00 2001 From: Evan Gray Date: Wed, 15 Sep 2021 10:33:07 -0400 Subject: [PATCH] bridge_ui: update migration assets Change-Id: I7c2adf547a8a386570b5644bf355d7356bfe04cc --- .../src/components/Migration/Workflow.tsx | 34 +++++-- bridge_ui/src/components/Migration/index.tsx | 6 +- .../TokenSelectors/SourceTokenSelector.tsx | 6 +- bridge_ui/src/utils/consts.ts | 99 +++++++++++++++++-- 4 files changed, 130 insertions(+), 15 deletions(-) diff --git a/bridge_ui/src/components/Migration/Workflow.tsx b/bridge_ui/src/components/Migration/Workflow.tsx index 686d5ac1a..875e06346 100644 --- a/bridge_ui/src/components/Migration/Workflow.tsx +++ b/bridge_ui/src/components/Migration/Workflow.tsx @@ -84,7 +84,6 @@ const getBalance = async ( const info = await connection.getParsedAccountInfo(pk); // @ts-ignore const balance = info.value?.data.parsed.info.tokenAmount.uiAmountString; - console.log(`${address} has a balance of ${balance}`); setter(balance); } catch (e) { console.log(`Unable to determine balance of ${address}`); @@ -194,7 +193,7 @@ export default function Workflow({ if (toCustodyAddress) { getBalance(connection, toCustodyAddress, setToCustodyBalance); } else { - setToCustodyAddress(undefined); + setToCustodyBalance(undefined); } }, [connection, toCustodyAddress, setToCustodyBalance]); @@ -242,9 +241,17 @@ export default function Workflow({ //Set relevant information derived from poolAddress useEffect(() => { - getToCustodyAddress(MIGRATION_PROGRAM_ADDRESS, poolAddress).then( - (result: any) => setToCustodyAddress(new PublicKey(result).toString()) - ); + if (poolAddress) { + getToCustodyAddress(MIGRATION_PROGRAM_ADDRESS, poolAddress) + .then((result: any) => + setToCustodyAddress(new PublicKey(result).toString()) + ) + .catch((e) => { + setToCustodyAddress(undefined); + }); + } else { + setToCustodyAddress(undefined); + } }, [poolAddress]); //Set the associated token accounts when the designated mint changes @@ -338,8 +345,6 @@ export default function Workflow({ fromParse(migrationAmount) <= fromParse(fromTokenAccountBalance) && parseFloat(migrationAmount) <= parseFloat(toCustodyBalance); - console.log("rendered"); - const isReadyToTransfer = isReady && sufficientBalances && accountsReady && hasRequisiteData; @@ -429,6 +434,21 @@ export default function Workflow({ associatedAccountExists={toTokenAccountExists} setAssociatedAccountExists={setToTokenAccountExists} /> + {poolAddress && toCustodyAddress && toCustodyBalance ? ( + <> +
+ + Using pool {shortenAddress(poolAddress)} holding tokens in + this account: + + + {shortenAddress(toCustodyAddress) + + ` (Balance: ${toCustodyBalance}${ + toMetadata.symbol && " " + toMetadata.symbol + })`} + + + ) : null} ) : null}
diff --git a/bridge_ui/src/components/Migration/index.tsx b/bridge_ui/src/components/Migration/index.tsx index 5511de998..cc214273d 100644 --- a/bridge_ui/src/components/Migration/index.tsx +++ b/bridge_ui/src/components/Migration/index.tsx @@ -25,7 +25,11 @@ const MigrationRoot: React.FC = (props) => { if (fromMint && toMint) { return ; } else { - return This asset is not eligible for migration.; + return ( + + This asset is not eligible for migration. + + ); } }; diff --git a/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx b/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx index 742176dc1..0b10689cb 100644 --- a/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx +++ b/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx @@ -27,6 +27,7 @@ import { import EthereumSourceTokenSelector from "./EthereumSourceTokenSelector"; import SolanaSourceTokenSelector from "./SolanaSourceTokenSelector"; import TerraSourceTokenSelector from "./TerraSourceTokenSelector"; +import RefreshButtonWrapper from "./RefreshButtonWrapper"; type TokenSelectorProps = { disabled: boolean; @@ -73,6 +74,7 @@ export const TokenSelector = (props: TokenSelectorProps) => { ); const maps = useGetSourceParsedTokens(nft); + const resetAccountWrapper = maps?.resetAccounts || (() => {}); //This should never happen. //This is only for errors so bad that we shouldn't even mount the component const fatalError = @@ -81,7 +83,9 @@ export const TokenSelector = (props: TokenSelectorProps) => { maps?.tokenAccounts?.error; //Terra & ETH can proceed because it has advanced mode const content = fatalError ? ( - {fatalError} + + {fatalError} + ) : lookupChain === CHAIN_ID_SOLANA ? ( ([ - [ - "2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ", - "ApgUoB1467PXXofoLWFELH2Kz9DKB8WXdU2szGSsFKhX", - ], -]); +export const MIGRATION_ASSET_MAP = new Map( + CLUSTER === "mainnet" + ? [ + [ + // HUSD + "BybpSTBoZHsmKnfxYG47GDhVPKrnEKX31CScShbrzUhX", + "7VQo3HFLNH5QqGtM8eC3XQbPkJUu7nS9LeGWjerRh5Sw", + ], + [ + // BUSD + "AJ1W9A9N9dEMdVyoDiam2rV44gnBm2csrPDP7xqcapgX", + "33fsBLA8djQm82RpHmE3SuVrPGtZBWNYExsEUeKX1HXX", + ], + [ + // HBTC + "8pBc4v9GAwCBNWPB5XKA93APexMGAS4qMr37vNke9Ref", + "7dVH61ChzgmN9BwG4PkzwRP8PbYwPJ7ZPNF2vamKT2H8", + ], + [ + // DAI + "FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1", + "EjmyN6qEC1Tf1JxiG1ae7UTJhUxSwk1TCWNWqxWV4J6o", + ], + [ + // FRAX + "8L8pDf3jutdpdr4m3np68CL9ZroLActrqwxi6s9Ah5xU", + "FR87nWEUxVgerFGhZM8Y4AggKGLnaXswr1Pd8wZ4kZcp", + ], + [ + // USDK + "2kycGCD8tJbrjJJqWN2Qz5ysN9iB4Bth3Uic4mSB7uak", + "43m2ewFV5nDepieFjT9EmAQnc1HRtAF247RBpLGFem5F", + ], + [ + // UST + "CXLBjMMcwkc17GfJtBos6rQCo1ypeH6eDbB82Kby4MRm", + "5Un6AdG9GBjxVhTSvvt2x6X6vtN1zrDxkkDpDcShnHfF", + ], + [ + // Wrapped LUNA + "2Xf2yAXJfg82sWwdLUo2x9mZXy6JCdszdMZkcF1Hf4KV", + "EQTV1LW23Mgtjb5LXSg9NGw1J32oqTV4HCPmHCVSGmqD", + ], + [ + // FTT + "GbBWwtYTMPis4VHb8MrBbdibPhn28TSrLB53KvUmb7Gi", + "EzfgjvkSwthhgHaceR3LnKXUoRkP6NUhfghdaHAj1tUv", + ], + [ + // SRM + "2jXy799YnEcRXneFo2GEAB6SDRsAa767HpWmktRr1DaP", + "xnorPhAzWXUczCP3KjU5yDxmKKZi5cSbxytQ1LgE3kG", + ], + [ + // FTT (Sollet) + "AGFEad2et2ZJif9jaGpdMixQqvW5i81aBdvKe7PHNfz3", + "EzfgjvkSwthhgHaceR3LnKXUoRkP6NUhfghdaHAj1tUv", + ], + [ + // WETH (Sollet) + "2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk", + "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", + ], + [ + // UNI (Sollet) + "DEhAasscXF4kEGxFgJ3bq4PpVGp5wyUxMRvn6TzGVHaw", + "8FU95xFJhUUkyyCLU13HSzDLs7oC4QZdXQHL6SCeab36", + ], + [ + // HXRO (Sollet) + "DJafV9qemGp7mLMEn5wrfqaFwxsbLgUsGVS16zKRk9kc", + "HxhWkVpk5NS4Ltg5nij2G671CKXFRKPK8vy271Ub4uEK", + ], + [ + // ALEPH (Sollet) + "CsZ5LZkDS7h9TDKjrbL7VAwQZ9nsRu8vJLhRYfmGaN8K", + "3UCMiSnkcnkPE1pgQ5ggPCBv6dXgVUy16TmMUe1WpG9x", + ], + [ + // TOMOE (Sollet) + "GXMvfY2jpQctDqZ9RoU3oWPhufKiCcFEfchvYumtX7jd", + "46AiRdka3HYGkhV6r9gyS6Teo9cojfGXfK8oniALYMZx", + ], + ] + : CLUSTER === "testnet" + ? [] + : [ + // [ + // "2WDq7wSs9zYrpx2kbHDA4RUTRch2CCTP6ZWaH4GNfnQQ", + // "ApgUoB1467PXXofoLWFELH2Kz9DKB8WXdU2szGSsFKhX", + // ], + ] +);