Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1385: Gas token send / receive #1189

Merged
merged 87 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
e7563e1
basic layout
lendihop Aug 27, 2024
a63115b
select token for tezos
lendihop Aug 29, 2024
39abe25
select token
lendihop Sep 3, 2024
f7c46de
dont show tags
lendihop Sep 3, 2024
804f710
fix select asset modal opening after page reload
lendihop Sep 4, 2024
689abf0
fix e2e ts
lendihop Sep 4, 2024
4e9c512
form refactor
lendihop Sep 5, 2024
d247267
resolving evm address from domain
lendihop Sep 5, 2024
6e97893
max amount calculation
lendihop Sep 8, 2024
996b7fe
fix logic for erc20 tokens
lendihop Sep 8, 2024
f72cee4
recipient account select main logic
lendihop Sep 9, 2024
eb334c6
address copying fixed
lendihop Sep 10, 2024
ffa5410
recipient input / select acc state connection + truncation added
lendihop Sep 10, 2024
6d4aa03
tezos form validation fixes
lendihop Sep 10, 2024
5d5192d
evm form validation + react-hook-form v7 used
lendihop Sep 12, 2024
e570f93
add active state for filter network option
lendihop Sep 12, 2024
7b3cc12
scroll to selected network
lendihop Sep 12, 2024
690438f
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Sep 13, 2024
8ddb14c
add filter network search
lendihop Sep 17, 2024
73c009e
loader added
lendihop Sep 17, 2024
644f213
always show converted amount
lendihop Sep 17, 2024
ad1da2e
show floating assetSymbol in input
lendihop Sep 18, 2024
0c21a84
track other networks addresses
lendihop Sep 18, 2024
d654a2e
show tezos error toast on form submit
lendihop Sep 18, 2024
5860f3f
maxAmount calculation fixes
lendihop Sep 18, 2024
f20b16f
fix pipeline
lendihop Sep 18, 2024
ff3d019
confirm modal base + segmented control
lendihop Sep 18, 2024
bd25713
confirmation modal layout finished
lendihop Sep 19, 2024
5d8fe51
Evm / tezos component separation Header, DetailsTab
lendihop Sep 20, 2024
98ac994
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Sep 23, 2024
1279fa7
fix after-merge conflicts
lendihop Sep 23, 2024
94d04dc
fix network icon
lendihop Sep 23, 2024
a877d1f
more after-merge fixes
lendihop Sep 23, 2024
876f9df
some more fixes
lendihop Sep 23, 2024
4b8c7c7
some more fixes
lendihop Sep 23, 2024
12ef9cd
infoIcon
lendihop Sep 23, 2024
913085d
iconBase memo
lendihop Sep 23, 2024
ed1e0fc
viem update
lendihop Sep 23, 2024
e628332
send evm transaction
lendihop Sep 24, 2024
f322519
send evm transaction / add networks support
lendihop Sep 25, 2024
82abb92
fix various ui bugs
lendihop Sep 26, 2024
f648625
fix fee options calculations
lendihop Sep 26, 2024
bafe37c
fix some more bugs
lendihop Sep 27, 2024
b5c8acf
fix import cycle
lendihop Sep 27, 2024
96b7626
custom transaction params inputs + error handling
lendihop Sep 29, 2024
78b647b
fix ts-prune
lendihop Sep 29, 2024
2000b34
major refactoring and bug fixes
lendihop Oct 2, 2024
4e5d58e
tezos fee options calculation + ui fixes
lendihop Oct 2, 2024
5b79b43
send tezos operations without old confirmation page
lendihop Oct 6, 2024
13623e3
added loading button + proper form reset
lendihop Oct 6, 2024
134cdaf
edit gas fee and storageLimit
lendihop Oct 7, 2024
62bc3d0
show default evm form values
lendihop Oct 7, 2024
083ca2f
some ui fixes
lendihop Oct 8, 2024
0e696a8
non zero validation
lendihop Oct 8, 2024
5a1727a
error tab
lendihop Oct 8, 2024
9561c5c
fix ts-prune
lendihop Oct 8, 2024
063bb51
fix fee calculation with custom gas limit
lendihop Oct 8, 2024
b726cea
refactor
lendihop Oct 10, 2024
f30e851
refactor + minor ui fixes
lendihop Oct 10, 2024
4cbeccb
show default gas fee and storage limit + non zero gas fee validation
lendihop Oct 10, 2024
4765994
storage limit handling
lendihop Oct 10, 2024
0226d97
fix ts-prune
lendihop Oct 10, 2024
e4143b1
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Oct 10, 2024
04b33b8
fix some after-merge issues
lendihop Oct 10, 2024
3824fd7
show tezos raw transaction
lendihop Oct 10, 2024
d93dcae
renaming
lendihop Oct 11, 2024
52b12b6
raw transaction json view
lendihop Oct 11, 2024
568d1b1
tezos submit errors handling
lendihop Oct 11, 2024
9b01fa8
Merge branch 'refs/heads/TW-1359-epic-evm-transactions-operations' in…
lendihop Oct 11, 2024
8db086c
fix some after-merge issues
lendihop Oct 11, 2024
39110d7
fix some after-merge issues
lendihop Oct 11, 2024
9b05f98
fix ts-prune
lendihop Oct 11, 2024
3439367
refactor
lendihop Oct 16, 2024
485edc1
more refactor
lendihop Oct 17, 2024
465900a
apply suggestion
lendihop Oct 17, 2024
19c4d5b
fix audit
lendihop Oct 25, 2024
bd6e641
minor bug fixes
lendihop Oct 29, 2024
a8ae54f
Merge branch 'refs/heads/development-2' into TW-1385-gas-token-send-r…
lendihop Oct 29, 2024
6be2621
after merge fixes
lendihop Oct 29, 2024
9c7a4a7
fix minor bugs
lendihop Oct 30, 2024
39ba572
resolve merge conflicts
lendihop Oct 31, 2024
bdac7fd
some more after-merge fixes
lendihop Oct 31, 2024
d0c8ba4
some more after-merge fixes
lendihop Oct 31, 2024
06b60c0
fix info icon size
lendihop Oct 31, 2024
72accc3
fix fiat toggle
lendihop Oct 31, 2024
2314ee5
Merge branch 'development-2' into TW-1385-gas-token-send-receive
alex-tsx Nov 4, 2024
892e9c8
Fix pipeline
alex-tsx Nov 4, 2024
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
Prev Previous commit
Next Next commit
show tezos error toast on form submit
  • Loading branch information
lendihop committed Sep 18, 2024
commit d654a2e7517cd851823a89d561e7dfbfab0e12f5
15 changes: 8 additions & 7 deletions src/app/pages/Send/form/BaseForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { FC, FocusEventHandler, useCallback, useMemo, useRef, useState } from 'react';

import { ChainIds } from '@taquito/taquito';
import BigNumber from 'bignumber.js';
import { Controller, SubmitHandler, Validate, UseFormReturn } from 'react-hook-form-v7';
import { useDebounce } from 'use-debounce';
Expand All @@ -14,7 +13,7 @@ import { StyledButton } from 'app/atoms/StyledButton';
import { SelectAccountModal } from 'app/pages/Send/modals/SelectAccount';
import { useFiatCurrency } from 'lib/fiat-currency';
import { t, T } from 'lib/i18n';
import { useBooleanState, useSafeState } from 'lib/ui/hooks';
import { useBooleanState } from 'lib/ui/hooks';
import { readClipboard } from 'lib/ui/utils';
import { ZERO } from 'lib/utils/numbers';
import { OneOfChains } from 'temple/front';
Expand All @@ -37,6 +36,9 @@ interface Props {
validateAmount: Validate<string, SendFormData>;
validateRecipient: Validate<string, SendFormData>;
onSelectAssetClick: EmptyFn;
shouldUseFiat: boolean;
canToggleFiat: boolean;
setShouldUseFiat: (value: boolean) => void;
onSubmit: SubmitHandler<SendFormData>;
maxEstimating: boolean;
maxAmount: BigNumber;
Expand All @@ -57,6 +59,9 @@ export const BaseForm: FC<Props> = ({
validateAmount,
validateRecipient,
onSelectAssetClick,
shouldUseFiat,
canToggleFiat,
setShouldUseFiat,
onSubmit,
isToFilledWithFamiliarAddress,
evm
Expand All @@ -79,14 +84,10 @@ export const BaseForm: FC<Props> = ({
const amountFieldRef = useRef<HTMLInputElement>(null);
const toFieldRef = useRef<HTMLTextAreaElement>(null);

const [shouldUseFiat, setShouldUseFiat] = useSafeState(false);

const canToggleFiat = network.chainId === ChainIds.MAINNET;

const [toFieldFocused, setToFieldFocused] = useState(false);

const floatingAssetSymbol = useMemo(
() => (shouldUseFiat ? selectedFiatCurrency.name : assetSymbol.slice(0, 5)),
() => (shouldUseFiat ? selectedFiatCurrency.name : assetSymbol.slice(0, 6)),
[assetSymbol, selectedFiatCurrency.name, shouldUseFiat]
);

Expand Down
17 changes: 11 additions & 6 deletions src/app/pages/Send/form/TezosForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useForm } from 'react-hook-form-v7';

import { ArtificialError, NotEnoughFundsError, ZeroBalanceError, ZeroTEZBalanceError } from 'app/defaults';
import { DeadEndBoundaryError } from 'app/ErrorBoundary';
import { toastError } from 'app/toaster';
import { useFormAnalytics } from 'lib/analytics';
import { isTezAsset, TEZ_TOKEN_SLUG, toPenny } from 'lib/assets';
import { toTransferParams } from 'lib/assets/contract.utils';
Expand Down Expand Up @@ -200,7 +201,8 @@ export const TezosForm: FC<Props> = ({ chainId, assetSlug, onSelectAssetClick })
const safeFeeValue = useMemo(() => (maxAddFee && feeValue > maxAddFee ? maxAddFee : feeValue), [maxAddFee, feeValue]);

const maxAmount = useMemo(() => {
if (!(baseFee instanceof BigNumber)) return balance;
if (!(baseFee instanceof BigNumber))
return shouldUseFiat ? getMaxAmountFiat(assetPrice.toNumber(), balance) : balance;

const maxAmountAsset = isTezAsset(assetSlug)
? getMaxAmountToken(account.type, balance, baseFee, safeFeeValue)
Expand Down Expand Up @@ -235,8 +237,6 @@ export const TezosForm: FC<Props> = ({ chainId, assetSlug, onSelectAssetClick })
}
}, [formState.dirtyFields, trigger, maxAmountStr]);

const [submitError, setSubmitError] = useSafeState<any>(null, `${tezos.clientId}_${toResolved}`);

const toAssetAmount = useCallback(
(fiatAmount: BigNumber.Value) =>
new BigNumber(fiatAmount)
Expand All @@ -251,7 +251,10 @@ export const TezosForm: FC<Props> = ({ chainId, assetSlug, onSelectAssetClick })
async ({ amount, fee: feeVal }: SendFormData) => {
if (formState.isSubmitting) return;

setSubmitError(null);
if (estimationError) {
toastError('Failed to estimate transaction.');
return;
}

formAnalytics.trackSubmit();

Expand Down Expand Up @@ -291,7 +294,7 @@ export const TezosForm: FC<Props> = ({ chainId, assetSlug, onSelectAssetClick })
return;
}

setSubmitError(err);
toastError('Oops, Something went wrong!');
}
},
[
Expand All @@ -301,7 +304,6 @@ export const TezosForm: FC<Props> = ({ chainId, assetSlug, onSelectAssetClick })
formAnalytics,
formState.isSubmitting,
reset,
setSubmitError,
shouldUseFiat,
tezos,
toAssetAmount,
Expand All @@ -319,6 +321,9 @@ export const TezosForm: FC<Props> = ({ chainId, assetSlug, onSelectAssetClick })
assetPrice={assetPrice}
maxAmount={maxAmount}
maxEstimating={estimating}
canToggleFiat={canToggleFiat}
shouldUseFiat={shouldUseFiat}
setShouldUseFiat={setShouldUseFiat}
assetDecimals={assetMetadata?.decimals ?? 0}
validateAmount={validateAmount}
validateRecipient={validateRecipient}
Expand Down
Loading