bridge_ui: gas fees warning on terra
Change-Id: Ifbeafde1ac430de8fba05c23656ebff70e873b66
This commit is contained in:
parent
6c1d777b6f
commit
7fede406a4
|
@ -2,7 +2,7 @@ import { makeStyles, Typography } from "@material-ui/core";
|
||||||
import { Alert } from "@material-ui/lab";
|
import { Alert } from "@material-ui/lab";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { EthGasEstimateSummary } from "../../hooks/useTransactionFees";
|
import { GasEstimateSummary } from "../../hooks/useTransactionFees";
|
||||||
import { incrementStep, setTargetChain } from "../../store/attestSlice";
|
import { incrementStep, setTargetChain } from "../../store/attestSlice";
|
||||||
import {
|
import {
|
||||||
selectAttestIsTargetComplete,
|
selectAttestIsTargetComplete,
|
||||||
|
@ -62,7 +62,7 @@ function Target() {
|
||||||
{CHAINS_BY_ID[targetChain].name} to attest this token.{" "}
|
{CHAINS_BY_ID[targetChain].name} to attest this token.{" "}
|
||||||
</Typography>
|
</Typography>
|
||||||
{isEVMChain(targetChain) && (
|
{isEVMChain(targetChain) && (
|
||||||
<EthGasEstimateSummary
|
<GasEstimateSummary
|
||||||
methodType="createWrapped"
|
methodType="createWrapped"
|
||||||
chainId={targetChain}
|
chainId={targetChain}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { useCallback, useMemo } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import useIsWalletReady from "../../hooks/useIsWalletReady";
|
import useIsWalletReady from "../../hooks/useIsWalletReady";
|
||||||
import useSyncTargetAddress from "../../hooks/useSyncTargetAddress";
|
import useSyncTargetAddress from "../../hooks/useSyncTargetAddress";
|
||||||
import { EthGasEstimateSummary } from "../../hooks/useTransactionFees";
|
import { GasEstimateSummary } from "../../hooks/useTransactionFees";
|
||||||
import { incrementStep, setTargetChain } from "../../store/nftSlice";
|
import { incrementStep, setTargetChain } from "../../store/nftSlice";
|
||||||
import {
|
import {
|
||||||
selectNFTIsTargetComplete,
|
selectNFTIsTargetComplete,
|
||||||
|
@ -132,7 +132,7 @@ function Target() {
|
||||||
{CHAINS_BY_ID[targetChain].name} to redeem your NFT.
|
{CHAINS_BY_ID[targetChain].name} to redeem your NFT.
|
||||||
</Typography>
|
</Typography>
|
||||||
{isEVMChain(targetChain) && (
|
{isEVMChain(targetChain) && (
|
||||||
<EthGasEstimateSummary methodType="nft" chainId={targetChain} />
|
<GasEstimateSummary methodType="nft" chainId={targetChain} />
|
||||||
)}
|
)}
|
||||||
</Alert>
|
</Alert>
|
||||||
<LowBalanceWarning chainId={targetChain} />
|
<LowBalanceWarning chainId={targetChain} />
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
import { CHAIN_ID_SOLANA, hexToNativeString } from "@certusone/wormhole-sdk";
|
import {
|
||||||
|
CHAIN_ID_SOLANA,
|
||||||
|
CHAIN_ID_TERRA,
|
||||||
|
hexToNativeString,
|
||||||
|
} from "@certusone/wormhole-sdk";
|
||||||
import { makeStyles, Typography } from "@material-ui/core";
|
import { makeStyles, Typography } from "@material-ui/core";
|
||||||
import { Alert } from "@material-ui/lab";
|
import { Alert } from "@material-ui/lab";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
|
@ -6,7 +10,7 @@ import { useDispatch, useSelector } from "react-redux";
|
||||||
import useIsWalletReady from "../../hooks/useIsWalletReady";
|
import useIsWalletReady from "../../hooks/useIsWalletReady";
|
||||||
import useMetadata from "../../hooks/useMetadata";
|
import useMetadata from "../../hooks/useMetadata";
|
||||||
import useSyncTargetAddress from "../../hooks/useSyncTargetAddress";
|
import useSyncTargetAddress from "../../hooks/useSyncTargetAddress";
|
||||||
import { EthGasEstimateSummary } from "../../hooks/useTransactionFees";
|
import { GasEstimateSummary } from "../../hooks/useTransactionFees";
|
||||||
import {
|
import {
|
||||||
selectTransferAmount,
|
selectTransferAmount,
|
||||||
selectTransferIsTargetComplete,
|
selectTransferIsTargetComplete,
|
||||||
|
@ -168,8 +172,8 @@ function Target() {
|
||||||
You will have to pay transaction fees on{" "}
|
You will have to pay transaction fees on{" "}
|
||||||
{CHAINS_BY_ID[targetChain].name} to redeem your tokens.
|
{CHAINS_BY_ID[targetChain].name} to redeem your tokens.
|
||||||
</Typography>
|
</Typography>
|
||||||
{isEVMChain(targetChain) && (
|
{(isEVMChain(targetChain) || targetChain === CHAIN_ID_TERRA) && (
|
||||||
<EthGasEstimateSummary methodType="transfer" chainId={targetChain} />
|
<GasEstimateSummary methodType="transfer" chainId={targetChain} />
|
||||||
)}
|
)}
|
||||||
</Alert>
|
</Alert>
|
||||||
<LowBalanceWarning chainId={targetChain} />
|
<LowBalanceWarning chainId={targetChain} />
|
||||||
|
|
|
@ -209,7 +209,7 @@ export function useEthereumGasPrice(contract: MethodType, chainId: ChainId) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EthGasEstimateSummary({
|
function EthGasEstimateSummary({
|
||||||
methodType,
|
methodType,
|
||||||
chainId,
|
chainId,
|
||||||
}: {
|
}: {
|
||||||
|
@ -244,7 +244,14 @@ export function EthGasEstimateSummary({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const estimatesByContract = {
|
const terraEstimatesByContract = {
|
||||||
|
transfer: {
|
||||||
|
lowGasEstimate: BigInt(50000),
|
||||||
|
highGasEstimate: BigInt(90000),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const evmEstimatesByContract = {
|
||||||
transfer: {
|
transfer: {
|
||||||
lowGasEstimate: BigInt(80000),
|
lowGasEstimate: BigInt(80000),
|
||||||
highGasEstimate: BigInt(130000),
|
highGasEstimate: BigInt(130000),
|
||||||
|
@ -263,8 +270,9 @@ export async function getGasEstimates(
|
||||||
provider: Provider,
|
provider: Provider,
|
||||||
contract: MethodType
|
contract: MethodType
|
||||||
): Promise<GasEstimate | null> {
|
): Promise<GasEstimate | null> {
|
||||||
const lowEstimateGasAmount = estimatesByContract[contract].lowGasEstimate;
|
const lowEstimateGasAmount = evmEstimatesByContract[contract].lowGasEstimate;
|
||||||
const highEstimateGasAmount = estimatesByContract[contract].highGasEstimate;
|
const highEstimateGasAmount =
|
||||||
|
evmEstimatesByContract[contract].highGasEstimate;
|
||||||
|
|
||||||
let lowEstimate;
|
let lowEstimate;
|
||||||
let highEstimate;
|
let highEstimate;
|
||||||
|
@ -293,3 +301,58 @@ export async function getGasEstimates(
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TerraGasEstimateSummary({
|
||||||
|
methodType,
|
||||||
|
chainId,
|
||||||
|
}: {
|
||||||
|
methodType: MethodType;
|
||||||
|
chainId: ChainId;
|
||||||
|
}) {
|
||||||
|
if (methodType === "transfer") {
|
||||||
|
const lowEstimate = formatUnits(
|
||||||
|
terraEstimatesByContract.transfer.lowGasEstimate,
|
||||||
|
NATIVE_TERRA_DECIMALS
|
||||||
|
);
|
||||||
|
const highEstimate = formatUnits(
|
||||||
|
terraEstimatesByContract.transfer.highGasEstimate,
|
||||||
|
NATIVE_TERRA_DECIMALS
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Typography
|
||||||
|
component="div"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
marginTop: 8,
|
||||||
|
flexWrap: "wrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
Est. Fees: {lowEstimate} - {highEstimate}{" "}
|
||||||
|
{getDefaultNativeCurrencySymbol(chainId)}
|
||||||
|
</div>
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GasEstimateSummary({
|
||||||
|
methodType,
|
||||||
|
chainId,
|
||||||
|
}: {
|
||||||
|
methodType: MethodType;
|
||||||
|
chainId: ChainId;
|
||||||
|
}) {
|
||||||
|
if (isEVMChain(chainId)) {
|
||||||
|
return <EthGasEstimateSummary chainId={chainId} methodType={methodType} />;
|
||||||
|
} else if (chainId === CHAIN_ID_TERRA) {
|
||||||
|
return (
|
||||||
|
<TerraGasEstimateSummary chainId={chainId} methodType={methodType} />
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue