bridge_ui: add mw + solflare, zero migrate check
Change-Id: Ica3374357b7a009a56ea674d2892ce61912e03f0
This commit is contained in:
parent
57a3e55608
commit
6cb244ba83
|
@ -332,21 +332,33 @@ export default function Workflow({
|
|||
]);
|
||||
|
||||
const fromParse = (amount: string) => {
|
||||
return parseUnits(amount, fromMintDecimals).toBigInt();
|
||||
try {
|
||||
return parseUnits(amount, fromMintDecimals).toBigInt();
|
||||
} catch (e) {
|
||||
return BigInt(0);
|
||||
}
|
||||
};
|
||||
|
||||
const hasRequisiteData = fromMint && toMint && poolAddress && poolExists;
|
||||
const accountsReady =
|
||||
fromTokenAccountExists && toTokenAccountExists && poolExists;
|
||||
const sufficientBalances =
|
||||
toCustodyBalance &&
|
||||
const amountGreaterThanZero = fromParse(migrationAmount) > BigInt(0);
|
||||
const sufficientFromTokens =
|
||||
fromTokenAccountBalance &&
|
||||
migrationAmount &&
|
||||
fromParse(migrationAmount) <= fromParse(fromTokenAccountBalance) &&
|
||||
fromParse(migrationAmount) <= fromParse(fromTokenAccountBalance);
|
||||
const sufficientPoolBalance =
|
||||
toCustodyBalance &&
|
||||
migrationAmount &&
|
||||
parseFloat(migrationAmount) <= parseFloat(toCustodyBalance);
|
||||
|
||||
const isReadyToTransfer =
|
||||
isReady && sufficientBalances && accountsReady && hasRequisiteData;
|
||||
isReady &&
|
||||
amountGreaterThanZero &&
|
||||
sufficientFromTokens &&
|
||||
sufficientPoolBalance &&
|
||||
accountsReady &&
|
||||
hasRequisiteData;
|
||||
|
||||
const getNotReadyCause = () => {
|
||||
if (!fromMint || !toMint || !poolAddress || !poolExists) {
|
||||
|
@ -357,8 +369,12 @@ export default function Workflow({
|
|||
return "You have not created the necessary token accounts.";
|
||||
} else if (!migrationAmount) {
|
||||
return "Enter an amount to transfer.";
|
||||
} else if (!sufficientBalances) {
|
||||
return "There are not sufficient funds for this transfer.";
|
||||
} else if (!amountGreaterThanZero) {
|
||||
return "Enter an amount greater than zero.";
|
||||
} else if (!sufficientFromTokens) {
|
||||
return "There are not sufficient funds in your wallet for this transfer.";
|
||||
} else if (!sufficientPoolBalance) {
|
||||
return "There are not sufficient funds in the pool for this transfer.";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ import { WalletDialogProvider } from "@solana/wallet-adapter-material-ui";
|
|||
import { useWallet, WalletProvider } from "@solana/wallet-adapter-react";
|
||||
import {
|
||||
getPhantomWallet,
|
||||
getSolflareWallet,
|
||||
getSolletWallet,
|
||||
getMathWallet,
|
||||
} from "@solana/wallet-adapter-wallets";
|
||||
import React, { FC, useMemo } from "react";
|
||||
|
||||
|
@ -12,13 +14,13 @@ export const SolanaWalletProvider: FC = (props) => {
|
|||
const wallets = useMemo(() => {
|
||||
return [
|
||||
getPhantomWallet(),
|
||||
// getSolflareWallet(),
|
||||
getSolflareWallet(),
|
||||
// getTorusWallet({
|
||||
// options: { clientId: 'Go to https://developer.tor.us and create a client ID' }
|
||||
// }),
|
||||
// getLedgerWallet(),
|
||||
// getSolongWallet(),
|
||||
// getMathWallet(),
|
||||
getMathWallet(),
|
||||
getSolletWallet(),
|
||||
];
|
||||
}, []);
|
||||
|
|
Loading…
Reference in New Issue