bridge_ui: remove max from native

Change-Id: Iea26581292b1c51441b7328daa85c1459d9b0be8
This commit is contained in:
Evan Gray 2021-10-27 12:32:00 -04:00
parent 4f2f6922cd
commit 3491a1370b
4 changed files with 41 additions and 27 deletions

View File

@ -5,18 +5,19 @@ import {
TextFieldProps,
} from "@material-ui/core";
export default function NumberTextField(
props: TextFieldProps & { onMaxClick?: () => void }
) {
export default function NumberTextField({
onMaxClick,
...props
}: TextFieldProps & { onMaxClick?: () => void }) {
return (
<TextField
type="number"
{...props}
InputProps={{
endAdornment: props.onMaxClick ? (
endAdornment: onMaxClick ? (
<InputAdornment position="end">
<Button
onClick={props.onMaxClick}
onClick={onMaxClick}
disabled={props.disabled}
variant="outlined"
>

View File

@ -150,7 +150,11 @@ function Source() {
value={amount}
onChange={handleAmountChange}
disabled={shouldLockFields}
onMaxClick={uiAmountString ? handleMaxClick : undefined}
onMaxClick={
uiAmountString && !parsedTokenAccount.isNativeAsset
? handleMaxClick
: undefined
}
/>
) : null}
<ButtonWithLoader

View File

@ -3,6 +3,8 @@ const MM_ERR_WITH_INFO_START =
const parseError = (e: any) =>
e?.data?.message?.startsWith(MM_ERR_WITH_INFO_START)
? e.data.message.replace(MM_ERR_WITH_INFO_START, "")
: e?.response?.data?.error // terra error
? e.response.data.error
: e?.message
? e.message
: "An unknown error occurred";

View File

@ -40,6 +40,12 @@ export async function waitForTerraExecution(transaction: TxResult) {
console.error(e);
}
}
if (info.code !== undefined) {
// error code
throw new Error(
`Tx ${transaction.result.txhash}: error code ${info.code}: ${info.raw_log}`
);
}
return info;
}
@ -62,30 +68,31 @@ export async function postWithFees(
msgs: any[],
memo: string
) {
try {
const lcd = new LCDClient(TERRA_HOST);
//let gasPrices = await lcd.config.gasPrices //Unsure if the values returned from this are hardcoded or not.
//Thus, we are going to pull it directly from the current FCD.
let gasPrices = await axios
.get(TERRA_GAS_PRICES_URL)
.then((result) => result.data);
// don't try/catch, let errors propagate
const lcd = new LCDClient(TERRA_HOST);
//let gasPrices = await lcd.config.gasPrices //Unsure if the values returned from this are hardcoded or not.
//Thus, we are going to pull it directly from the current FCD.
let gasPrices = await axios
.get(TERRA_GAS_PRICES_URL)
.then((result) => result.data);
const feeEstimate = await lcd.tx.estimateFee(
wallet.walletAddress,
[...msgs],
{ memo, feeDenoms: ["uluna"], gasPrices }
);
const result = await wallet.post({
msgs: [...msgs],
const feeEstimate = await lcd.tx.estimateFee(
wallet.walletAddress,
[...msgs],
{
memo,
feeDenoms: ["uluna"],
gasPrices,
fee: feeEstimate,
});
}
);
return result;
} catch (e) {
return Promise.reject();
}
const result = await wallet.post({
msgs: [...msgs],
memo,
feeDenoms: ["uluna"],
gasPrices,
fee: feeEstimate,
});
return result;
}