Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/components/Elixir/AddLiquidity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const AddLiquidity: React.FC<AddLiquidityProps> = (props) => {
depositADisabled,
depositBDisabled,
parsedAmounts,
errorMessage,
errorMessage, // Real-time field base error message
pricesAtLimit,
position,
} = useDerivedMintInfo(existingPosition);
Expand All @@ -108,6 +108,7 @@ const AddLiquidity: React.FC<AddLiquidityProps> = (props) => {
// modal and loading
const [showConfirm, setShowConfirm] = useState<boolean>(false);
const [attemptingTxn, setAttemptingTxn] = useState<boolean>(false);
const [error, setError] = useState<string | undefined>(undefined); // txn error

// txn values
const deadline = useTransactionDeadline(); // custom from users settings
Expand Down Expand Up @@ -209,20 +210,20 @@ const AddLiquidity: React.FC<AddLiquidityProps> = (props) => {
};

const response = await addLiquidity(addData);

setTxHash(response?.hash as string);

mixpanel.track(MixPanelEvents.ADD_LIQUIDITY, {
chainId: chainId,
tokenA: currency0?.symbol,
tokenB: currency1?.symbol,
tokenA_Address: wrappedCurrency(currency0, chainId)?.address,
tokenB_Address: wrappedCurrency(currency1, chainId)?.address,
});
onResetMintState();
if (response?.hash) {
mixpanel.track(MixPanelEvents.ADD_LIQUIDITY, {
chainId: chainId,
tokenA: currency0?.symbol,
tokenB: currency1?.symbol,
tokenA_Address: wrappedCurrency(currency0, chainId)?.address,
tokenB_Address: wrappedCurrency(currency1, chainId)?.address,
});
onResetMintState();
}
} catch (err) {
const _err = err as any;

setError(_err?.message);
console.error(_err);
} finally {
setAttemptingTxn(false);
Expand All @@ -235,6 +236,7 @@ const AddLiquidity: React.FC<AddLiquidityProps> = (props) => {
// if (txHash) {
// onFieldAInput('', pairAddress);
// }
setError(undefined);
setTxHash('');
setAttemptingTxn(false);
}, [txHash]);
Expand Down Expand Up @@ -592,7 +594,7 @@ const AddLiquidity: React.FC<AddLiquidityProps> = (props) => {
{showConfirm && (
<ConfirmDrawer
isOpen={showConfirm}
poolErrorMessage={errorMessage}
poolErrorMessage={errorMessage || error}
currencies={currencies}
noLiquidity={noLiquidity}
onAdd={onAdd}
Expand Down
3 changes: 2 additions & 1 deletion src/state/pwallet/elixir/hooks/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ export function useElixirAddLiquidity() {
const _err = err as any;
// we only care if the error is something _other_ than the user rejected the tx
if (_err?.code !== 4001) {
console.error(_err);
throw new Error('User Rejected Transaction');
}
throw _err;
} finally {
// This is intentional
}
Expand Down