diff --git a/bridge_ui/src/App.js b/bridge_ui/src/App.js index 4051af418..8fc82b2df 100644 --- a/bridge_ui/src/App.js +++ b/bridge_ui/src/App.js @@ -168,7 +168,7 @@ function App() { - + diff --git a/bridge_ui/src/components/Migration/Workflow.tsx b/bridge_ui/src/components/Migration/Workflow.tsx index 2c98bc018..888d362f1 100644 --- a/bridge_ui/src/components/Migration/Workflow.tsx +++ b/bridge_ui/src/components/Migration/Workflow.tsx @@ -26,7 +26,6 @@ import { COLORS } from "../../muiTheme"; import { MIGRATION_PROGRAM_ADDRESS, SOLANA_HOST } from "../../utils/consts"; import { getMultipleAccounts, signSendAndConfirm } from "../../utils/solana"; import ButtonWithLoader from "../ButtonWithLoader"; -import LowBalanceWarning from "../LowBalanceWarning"; import ShowTx from "../ShowTx"; import SmartAddress from "../SmartAddress"; import SolanaCreateAssociatedAddress, { @@ -94,9 +93,11 @@ const getBalance = async ( export default function Workflow({ fromMint, toMint, + fromTokenAccount, }: { fromMint: string; toMint: string; + fromTokenAccount: string; }) { const classes = useStyles(); @@ -112,9 +113,6 @@ export default function Workflow({ const [poolAddress, setPoolAddress] = useState(""); const [poolExists, setPoolExists] = useState(undefined); - const [fromTokenAccount, setFromTokenAccount] = useState( - undefined - ); const [fromTokenAccountBalance, setFromTokenAccountBalance] = useState< string | undefined >(undefined); @@ -254,23 +252,6 @@ export default function Workflow({ } }, [poolAddress]); - //Set the associated token accounts when the designated mint changes - useEffect(() => { - if (wallet?.publicKey && fromMint) { - Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - new PublicKey(fromMint), - wallet?.publicKey || new PublicKey([]) - ).then( - (result) => { - setFromTokenAccount(result.toString()); - }, - (error) => {} - ); - } - }, [fromMint, wallet?.publicKey]); - useEffect(() => { if (wallet?.publicKey && toMint) { Token.getAssociatedTokenAddress( @@ -426,12 +407,11 @@ export default function Workflow({ Convert assets from legacy bridges to Wormhole V2 tokens - - - {fromTokenAccount && toTokenAccount && fromTokenAccountBalance ? ( +
+ {fromTokenAccount && toTokenAccount ? ( <> - + This will migrate {fromMintPretty} tokens in this account: @@ -446,7 +426,7 @@ export default function Workflow({ })`}
- + into {toMintPretty} tokens in this account: @@ -476,7 +456,7 @@ export default function Workflow({ {poolAddress && toCustodyAddress && toCustodyBalance ? ( <>
- + Using pool {} const MigrationRoot: React.FC = (props) => { const legacyAsset: string = props.match.params.legacyAsset; + const fromTokenAccount: string = props.match.params.fromTokenAccount; const targetAsset: string | undefined = MIGRATION_ASSET_MAP.get(legacyAsset); let fromMint: string | undefined = ""; let toMint: string | undefined = ""; + let fromTokenAcct: string | undefined = ""; try { fromMint = legacyAsset && new PublicKey(legacyAsset).toString(); toMint = targetAsset && new PublicKey(targetAsset).toString(); + fromTokenAcct = + fromTokenAccount && new PublicKey(fromTokenAccount).toString(); } catch (e) {} - if (fromMint && toMint) { - return ; - } else { + if (!fromMint || !toMint) { return ( This asset is not eligible for migration. ); + } else if (!fromTokenAcct) { + return ( + + Invalid token account. + + ); + } else { + return ( + + ); } }; diff --git a/bridge_ui/src/components/Transfer/Source.tsx b/bridge_ui/src/components/Transfer/Source.tsx index ad40036ea..546894771 100644 --- a/bridge_ui/src/components/Transfer/Source.tsx +++ b/bridge_ui/src/components/Transfer/Source.tsx @@ -57,8 +57,9 @@ function Source({ const shouldLockFields = useSelector(selectTransferShouldLockFields); const { isReady, statusMessage } = useIsWalletReady(sourceChain); const handleMigrationClick = useCallback(() => { - parsedTokenAccount?.mintKey && - history.push("/migrate/" + parsedTokenAccount.mintKey); + history.push( + `/migrate/${parsedTokenAccount?.mintKey}/${parsedTokenAccount?.publicKey}` + ); }, [history, parsedTokenAccount]); const handleSourceChange = useCallback( (event) => {