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-1110 Change Wert popup UI and UX #1063

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f8d4ef0
TW-1110 Change Wert popup UI and UX
keshan3262 Mar 15, 2024
197fb74
TW-1110 Refactor and change UX according to a new discussion
keshan3262 Mar 18, 2024
93a2b9b
TW-1110 Add forgotten changes
keshan3262 Mar 18, 2024
b9db33c
TW-1110 Refactoring according to comments
keshan3262 Mar 18, 2024
f7e62e5
Merge branch 'development' of https://github.com/madfish-solutions/te…
keshan3262 Mar 20, 2024
a85feec
TW-1110 Join resetting loader and onramp overlay into one action
keshan3262 Mar 20, 2024
4614784
TW-1110 Remove some hooks is RootStack
keshan3262 Mar 21, 2024
d95073b
TW-1110 Remove an unused Redux state variable
keshan3262 Mar 21, 2024
6958af8
Merge branch 'development' of https://github.com/madfish-solutions/te…
keshan3262 Mar 25, 2024
6bf1a8b
TW-1110 Refactoring according to comments
keshan3262 Mar 25, 2024
d5d3611
Merge branch 'development' of https://github.com/madfish-solutions/te…
keshan3262 Mar 27, 2024
89bc848
TW-1110 Refactoring according to comments
keshan3262 Mar 27, 2024
0fc4731
TW-1110 Fix ts error
keshan3262 Mar 27, 2024
3a26079
TW-1110 Remove unused Redux state fragment
keshan3262 Mar 27, 2024
ef14414
Merge branch 'development' of https://github.com/madfish-solutions/te…
keshan3262 Apr 3, 2024
4df98ad
TW-1110 Render bottom sheets for some time before opening
keshan3262 Apr 3, 2024
6230aba
TW-1110 Add memoization for WalletOverlay
keshan3262 Apr 3, 2024
ad16d68
TW-1110 Use 'index' property of GorhomBottomSheet
keshan3262 Apr 3, 2024
199237f
TW-1110 Remove an obsolete comment
keshan3262 Apr 3, 2024
78b617d
Merge branch 'development' of https://github.com/madfish-solutions/te…
keshan3262 Apr 4, 2024
c647029
TW-1110 Additional bugfixes
keshan3262 Apr 4, 2024
26f31b6
TW-1110 Implement suggestions from comments
keshan3262 Apr 5, 2024
3c9219c
Merge branch 'development' of https://github.com/madfish-solutions/te…
keshan3262 Apr 11, 2024
eed44c2
TW-1110 Fix effect error for iOS
keshan3262 Apr 12, 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
4 changes: 3 additions & 1 deletion src/hooks/use-on-ramp-continue-overlay.hook.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useIsFocused } from '@react-navigation/native';
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';

Expand All @@ -6,9 +7,10 @@ import { setOnRampOverlayStateAction } from 'src/store/settings/settings-actions
import { useOnRampOverlayStateSelector } from 'src/store/settings/settings-selectors';

export const useOnRampContinueOverlay = () => {
const isFocused = useIsFocused();
const dispatch = useDispatch();
const state = useOnRampOverlayStateSelector();
const isOpened = state === OnRampOverlayState.Continue;
const isOpened = isFocused && state === OnRampOverlayState.Continue;

const onClose = useCallback(() => dispatch(setOnRampOverlayStateAction(OnRampOverlayState.Closed)), [dispatch]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,35 @@ import { sendTransaction$ } from 'src/utils/wallet.utils';
import { InternalOperationsConfirmationModalParams } from '../confirmation-modal.params';
import { OperationsConfirmation } from '../operations-confirmation/operations-confirmation';

const NOT_ENOUGH_TEZ_ERRORS_KEYWORDS = ['empty_implicit_contract', 'empty_implicit_delegated_contract'];
const NOT_ENOUGH_TEZ_ESTIMATION_ERRORS_KEYWORDS = [
'empty_implicit_contract',
'empty_implicit_delegated_contract',
'storage_exhausted'
];

const isNotEnoughTezForDelegationFeeError = (error: string, senderPkh: string): boolean => {
/* An example of matching value: `HttpResponseError: Http error response: (500) [
{"kind":"temporary","id":"proto.018-Proxford.contract.balance_too_low","contract":"tz1dmR1BEyVW8fYyHT4QjarrRXyMJ1F4DciT","balance":"20","amount":"374"},
{"kind":"temporary","id":"proto.018-Proxford.tez.subtraction_underflow","amounts":["20","374"]}]`
*/

if (!error.startsWith('HttpResponseError')) {
keshan3262 marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

const firstLine = error.split('\n')[0];
const rawResponseBody = firstLine.slice(firstLine.indexOf(')') + 1).trim();
try {
const responseBody = JSON.parse(rawResponseBody);

return (
Array.isArray(responseBody) &&
responseBody.some(({ id, contract }) => id.includes('balance_too_low') && contract === senderPkh)
);
} catch (e) {
return false;
}
};

type Props = Omit<InternalOperationsConfirmationModalParams, 'type'>;

Expand Down Expand Up @@ -102,10 +130,12 @@ export const InternalOperationsConfirmation: FC<Props> = ({ opParams, modalTitle

const handleEstimationError = useCallback(
(error: string) =>
NOT_ENOUGH_TEZ_ERRORS_KEYWORDS.some(keyword => error.includes(keyword)) && canUseOnRamp
(NOT_ENOUGH_TEZ_ESTIMATION_ERRORS_KEYWORDS.some(keyword => error.includes(keyword)) ||
isNotEnoughTezForDelegationFeeError(error, selectedAccount!.publicKeyHash)) &&
canUseOnRamp
keshan3262 marked this conversation as resolved.
Show resolved Hide resolved
? updateOverlayState(OnRampOverlayState.Continue)
: console.error(error),
[canUseOnRamp, updateOverlayState]
[canUseOnRamp, selectedAccount, updateOverlayState]
);

const handleTotalTezValue = useCallback(
Expand Down
10 changes: 0 additions & 10 deletions src/screens/wallet/on-ramp-overlay/on-ramp-overlay.styles.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { StyleSheet } from 'react-native';

import { createUseStyles } from 'src/styles/create-use-styles';
import { formatSize } from 'src/styles/format-size';
export const useOnRampOverlayStyles = createUseStyles(({ colors, typography }) => ({
backdrop: {
...StyleSheet.absoluteFillObject,
backgroundColor: colors.black16,
flexDirection: 'column',
justifyContent: 'flex-end'
},
root: {
height: 'auto',
paddingBottom: formatSize(2),
backgroundColor: colors.pageBG
},
title: {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/wallet/on-ramp-overlay/on-ramp-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const OverlayBody = memo<OverlayBodyProps>(({ isStart }) => {
);

return (
<View style={dropdownBottomSheetStyles.headerContainer}>
<View style={[dropdownBottomSheetStyles.headerContainer, styles.root]}>
<Text style={styles.title}>{isStart ? 'Jump in Tezos right now!' : 'Insufficient TEZ balance'}</Text>
<Divider size={formatSize(8)} />
{isStart ? (
Expand Down
Loading