bridge_ui: remove max from native
Change-Id: Iea26581292b1c51441b7328daa85c1459d9b0be8
This commit is contained in:
parent
4f2f6922cd
commit
3491a1370b
|
@ -5,18 +5,19 @@ import {
|
||||||
TextFieldProps,
|
TextFieldProps,
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
|
|
||||||
export default function NumberTextField(
|
export default function NumberTextField({
|
||||||
props: TextFieldProps & { onMaxClick?: () => void }
|
onMaxClick,
|
||||||
) {
|
...props
|
||||||
|
}: TextFieldProps & { onMaxClick?: () => void }) {
|
||||||
return (
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
type="number"
|
type="number"
|
||||||
{...props}
|
{...props}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment: props.onMaxClick ? (
|
endAdornment: onMaxClick ? (
|
||||||
<InputAdornment position="end">
|
<InputAdornment position="end">
|
||||||
<Button
|
<Button
|
||||||
onClick={props.onMaxClick}
|
onClick={onMaxClick}
|
||||||
disabled={props.disabled}
|
disabled={props.disabled}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>
|
>
|
||||||
|
|
|
@ -150,7 +150,11 @@ function Source() {
|
||||||
value={amount}
|
value={amount}
|
||||||
onChange={handleAmountChange}
|
onChange={handleAmountChange}
|
||||||
disabled={shouldLockFields}
|
disabled={shouldLockFields}
|
||||||
onMaxClick={uiAmountString ? handleMaxClick : undefined}
|
onMaxClick={
|
||||||
|
uiAmountString && !parsedTokenAccount.isNativeAsset
|
||||||
|
? handleMaxClick
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<ButtonWithLoader
|
<ButtonWithLoader
|
||||||
|
|
|
@ -3,6 +3,8 @@ const MM_ERR_WITH_INFO_START =
|
||||||
const parseError = (e: any) =>
|
const parseError = (e: any) =>
|
||||||
e?.data?.message?.startsWith(MM_ERR_WITH_INFO_START)
|
e?.data?.message?.startsWith(MM_ERR_WITH_INFO_START)
|
||||||
? e.data.message.replace(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
|
||||||
? e.message
|
? e.message
|
||||||
: "An unknown error occurred";
|
: "An unknown error occurred";
|
||||||
|
|
|
@ -40,6 +40,12 @@ export async function waitForTerraExecution(transaction: TxResult) {
|
||||||
console.error(e);
|
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;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,30 +68,31 @@ export async function postWithFees(
|
||||||
msgs: any[],
|
msgs: any[],
|
||||||
memo: string
|
memo: string
|
||||||
) {
|
) {
|
||||||
try {
|
// don't try/catch, let errors propagate
|
||||||
const lcd = new LCDClient(TERRA_HOST);
|
const lcd = new LCDClient(TERRA_HOST);
|
||||||
//let gasPrices = await lcd.config.gasPrices //Unsure if the values returned from this are hardcoded or not.
|
//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.
|
//Thus, we are going to pull it directly from the current FCD.
|
||||||
let gasPrices = await axios
|
let gasPrices = await axios
|
||||||
.get(TERRA_GAS_PRICES_URL)
|
.get(TERRA_GAS_PRICES_URL)
|
||||||
.then((result) => result.data);
|
.then((result) => result.data);
|
||||||
|
|
||||||
const feeEstimate = await lcd.tx.estimateFee(
|
const feeEstimate = await lcd.tx.estimateFee(
|
||||||
wallet.walletAddress,
|
wallet.walletAddress,
|
||||||
[...msgs],
|
[...msgs],
|
||||||
{ memo, feeDenoms: ["uluna"], gasPrices }
|
{
|
||||||
);
|
|
||||||
|
|
||||||
const result = await wallet.post({
|
|
||||||
msgs: [...msgs],
|
|
||||||
memo,
|
memo,
|
||||||
feeDenoms: ["uluna"],
|
feeDenoms: ["uluna"],
|
||||||
gasPrices,
|
gasPrices,
|
||||||
fee: feeEstimate,
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
return result;
|
const result = await wallet.post({
|
||||||
} catch (e) {
|
msgs: [...msgs],
|
||||||
return Promise.reject();
|
memo,
|
||||||
}
|
feeDenoms: ["uluna"],
|
||||||
|
gasPrices,
|
||||||
|
fee: feeEstimate,
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue