Skip to content

Commit

Permalink
v3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Nov 18, 2024
1 parent f6bcb99 commit 6d94985
Show file tree
Hide file tree
Showing 34 changed files with 273 additions and 100 deletions.
1 change: 1 addition & 0 deletions changelogs/3.1.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bug fixes and performance improvements
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mytonwallet",
"version": "3.1.0",
"version": "3.1.1",
"description": "The most feature-rich web wallet and browser extension for TON – with support of multi-accounts, tokens (jettons), NFT, TON DNS, TON Sites, TON Proxy, and TON Magic.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1
Binary file added src/assets/ledger/desktop-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/ledger/desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/ledger/ios-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/ledger/ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/ledger/laptop-base-dark.png
Binary file not shown.
Binary file removed src/assets/ledger/laptop-base.png
Binary file not shown.
Binary file removed src/assets/ledger/laptop-success-dark.png
Binary file not shown.
Binary file removed src/assets/ledger/laptop-success.png
Binary file not shown.
Binary file added src/assets/ledger/mobile-bluetooth-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/ledger/mobile-bluetooth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/ledger/mobile-usb-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/ledger/mobile-usb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 108 additions & 33 deletions src/components/ledger/LedgerConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {
} from '../../lib/teact/teact';
import { getActions, withGlobal } from '../../global';

import type { Account } from '../../global/types';
import type { Account, Theme } from '../../global/types';
import type { LedgerTransport } from '../../util/ledger/types';
import { HardwareConnectState } from '../../global/types';

Expand All @@ -12,28 +12,42 @@ import { selectAccounts } from '../../global/selectors';
import buildClassName from '../../util/buildClassName';
import { closeLedgerTab } from '../../util/ledger/tab';
import resolveModalTransitionName from '../../util/resolveModalTransitionName';
import { IS_DELEGATING_BOTTOM_SHEET } from '../../util/windowEnvironment';
import { IS_DELEGATING_BOTTOM_SHEET, IS_IOS, IS_IOS_APP } from '../../util/windowEnvironment';

import useAppTheme from '../../hooks/useAppTheme';
import useHistoryBack from '../../hooks/useHistoryBack';
import useLang from '../../hooks/useLang';
import useLastCallback from '../../hooks/useLastCallback';
import useShowTransition from '../../hooks/useShowTransition';

import Button from '../ui/Button';
import Dropdown from '../ui/Dropdown';
import Image from '../ui/Image';
import ModalHeader from '../ui/ModalHeader';
import Transition from '../ui/Transition';

import settingsStyles from '../settings/Settings.module.scss';
import modalStyles from '../ui/Modal.module.scss';
import styles from './LedgerModal.module.scss';

import ledgerDesktopSrc from '../../assets/ledger/desktop.png';
import ledgerDesktopDarkSrc from '../../assets/ledger/desktop-dark.png';
import ledgerIosSrc from '../../assets/ledger/ios.png';
import ledgerIosDarkSrc from '../../assets/ledger/ios-dark.png';
import ledgerMobileBluetoothSrc from '../../assets/ledger/mobile-bluetooth.png';
import ledgerMobileBluetoothDarkSrc from '../../assets/ledger/mobile-bluetooth-dark.png';
import ledgerMobileUsbSrc from '../../assets/ledger/mobile-usb.png';
import ledgerMobileUsbDarkSrc from '../../assets/ledger/mobile-usb-dark.png';

interface OwnProps {
isActive: boolean;
isStatic?: boolean;
state?: HardwareConnectState;
isLedgerConnected?: boolean;
isTonAppConnected?: boolean;
isRemoteTab?: boolean;
onConnected: (isSingleWallet: boolean) => void;
onBackButtonClick?: NoneToVoidFunction;
onCancel?: NoneToVoidFunction;
onClose: NoneToVoidFunction;
}
Expand All @@ -42,6 +56,7 @@ interface StateProps {
availableTransports?: LedgerTransport[];
lastUsedTransport?: LedgerTransport;
accounts?: Record<string, Account>;
currentTheme: Theme;
}

const NEXT_SLIDE_DELAY = 500;
Expand All @@ -52,14 +67,17 @@ const TRANSPORT_NAMES: Record<LedgerTransport, string> = {

function LedgerConnect({
isActive,
isStatic,
state,
isLedgerConnected,
isTonAppConnected,
isRemoteTab,
availableTransports,
lastUsedTransport,
accounts,
currentTheme,
onConnected,
onBackButtonClick,
onCancel,
onClose,
}: OwnProps & StateProps) {
Expand All @@ -72,6 +90,7 @@ function LedgerConnect({

const lang = useLang();
const [selectedTransport, setSelectedTransport] = useState<LedgerTransport | undefined>(lastUsedTransport);
const appTheme = useAppTheme(currentTheme);

const isLedgerFailed = isLedgerConnected === false;
const isTonAppFailed = isTonAppConnected === false;
Expand Down Expand Up @@ -102,8 +121,11 @@ function LedgerConnect({
});

useEffect(() => {
if (!selectedTransport && availableTransports?.length) {
setSelectedTransport(availableTransports[0]);
if (selectedTransport) return;
if (availableTransports?.length) {
setSelectedTransport(availableTransports?.[0]);
} else if (IS_IOS_APP) {
setSelectedTransport('bluetooth');
}
}, [availableTransports, selectedTransport]);

Expand Down Expand Up @@ -185,40 +207,73 @@ function LedgerConnect({
}

return (
<div className={buildClassName(styles.actionBlock, isConnected && styles.actionBlock_single)}>
<div className={styles.actionBlock}>
<Button
isDisabled={isConnecting}
className={buildClassName(styles.button, isConnected && styles.button_single)}
className={styles.button}
onClick={shouldCloseOnCancel ? onClose : onCancel}
>
{lang(shouldCloseOnCancel ? 'Cancel' : 'Back')}
</Button>
{!isConnected && (
<Button
isPrimary
isLoading={isConnecting}
isDisabled={isConnecting}
className={styles.button}
onClick={handleSubmit}
>
{isFailed ? lang('Try Again') : lang('Continue')}
</Button>
)}
<Button
isPrimary
isLoading={isConnecting}
isDisabled={isConnecting || isConnected}
className={styles.button}
onClick={handleSubmit}
>
{isFailed ? lang('Try Again') : lang('Continue')}
</Button>
</div>
);
}

function getLedgerIconSrc() {
const isDarkTheme = appTheme === 'dark';
if (!IS_CAPACITOR) {
return isDarkTheme ? ledgerDesktopDarkSrc : ledgerDesktopSrc;
}

if (IS_IOS) {
return isDarkTheme ? ledgerIosDarkSrc : ledgerIosSrc;
}

if (selectedTransport === 'bluetooth') {
return isDarkTheme ? ledgerMobileBluetoothDarkSrc : ledgerMobileBluetoothSrc;
}

return isDarkTheme ? ledgerMobileUsbDarkSrc : ledgerMobileUsbSrc;
}

function renderWaitingForBrowser() {
return (
<>
<ModalHeader title={title} onClose={handleCloseWithBrowserTab} />
<div className={styles.container}>
<div
className={buildClassName(
styles.iconBlock,
styles.iconBlock_base,
)}
{!isStatic ? (
<ModalHeader
title={title}
onBackButtonClick={onBackButtonClick}
onClose={!onBackButtonClick ? handleCloseWithBrowserTab : undefined}
/>
) : (
<div className={settingsStyles.header}>
<Button isSimple isText onClick={handleCloseWithBrowserTab} className={settingsStyles.headerBack}>
<i className={buildClassName(settingsStyles.iconChevron, 'icon-chevron-left')} aria-hidden />
<span>{lang('Back')}</span>
</Button>
<span className={settingsStyles.headerTitle}>{title}</span>
</div>
)}
<div className={styles.container}>
<Transition
activeKey={!IS_CAPACITOR ? 0 : (selectedTransport !== 'bluetooth' ? 1 : 2)}
name="semiFade"
className={buildClassName(styles.iconBlock, IS_CAPACITOR && styles.mobile)}
slideClassName={styles.iconBlockSlide}
>
<Image
url={getLedgerIconSrc()}
imageClassName={styles.ledgerIcon}
/>
</Transition>
<div
className={buildClassName(
styles.textBlock,
Expand Down Expand Up @@ -250,14 +305,33 @@ function LedgerConnect({
function renderConnect() {
return (
<>
<ModalHeader title={title} onClose={onClose} />
<div className={styles.container}>
<div
className={buildClassName(
styles.iconBlock,
isConnected ? styles.iconBlock_success : styles.iconBlock_base,
)}
{!isStatic ? (
<ModalHeader
title={title}
onBackButtonClick={onBackButtonClick}
onClose={!onBackButtonClick ? onClose : undefined}
/>
) : (
<div className={settingsStyles.header}>
<Button isSimple isText onClick={onClose} className={settingsStyles.headerBack}>
<i className={buildClassName(settingsStyles.iconChevron, 'icon-chevron-left')} aria-hidden />
<span>{lang('Back')}</span>
</Button>
<span className={settingsStyles.headerTitle}>{title}</span>
</div>
)}
<div className={buildClassName(styles.container, isStatic && styles.containerStatic)}>
<Transition
activeKey={!IS_CAPACITOR ? 0 : (selectedTransport !== 'bluetooth' ? 1 : 2)}
name="semiFade"
className={buildClassName(styles.iconBlock, IS_CAPACITOR && styles.mobile)}
slideClassName={styles.iconBlockSlide}
>
<Image
url={getLedgerIconSrc()}
imageClassName={styles.ledgerIcon}
/>
</Transition>
<div
className={buildClassName(
styles.textBlock,
Expand All @@ -276,7 +350,7 @@ function LedgerConnect({
className={buildClassName(styles.textIcon, isLedgerConnected ? 'icon-accept' : 'icon-dot')}
aria-hidden
/>
{IS_CAPACITOR ? lang('Connect your Ledger') : lang('Connect your Ledger to PC')}
{lang('Connect your Ledger')}
</span>
<span
className={buildClassName(
Expand Down Expand Up @@ -329,5 +403,6 @@ export default memo(withGlobal<OwnProps>((global): StateProps => {
availableTransports,
lastUsedTransport,
accounts,
currentTheme: global.settings.theme,
};
})(LedgerConnect));
45 changes: 14 additions & 31 deletions src/components/ledger/LedgerModal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
height: 100%;
padding: 0 1rem 1rem;

:global(html:not(.is-android-app)) & {
:global(html.is-native-bottom-sheet) &,
&.containerStatic {
padding-bottom: max(var(--safe-area-bottom, 1rem), 1rem);
}
}
Expand All @@ -39,47 +40,29 @@
padding: 0 1rem 1rem;
}

.iconBlockSlide {
background-color: var(--color-background-window);
}

.iconBlock {
position: relative;

display: flex;
justify-content: center;

height: 10rem;
margin: 0 -1rem 1.25rem;

&::after {
content: "";

display: block;

width: 100%;
max-width: 23.4375rem;

background-clip: padding-box, padding-box;
background-origin: border-box;
background-size: cover, cover;
}
margin: 0 0 1.25rem;

&_base {
&::after {
background-image: url(../../assets/ledger/laptop-base.png);

:global(.theme-dark) & {
background-image: url(../../assets/ledger/laptop-base-dark.png);
}
}
&.mobile {
height: 14rem;
}
}

&_success {
&::after {
background-image: url(../../assets/ledger/laptop-success.png);
.ledgerIcon {
width: 100%;
max-width: 23.4375rem;

:global(.theme-dark) & {
background-image: url(../../assets/ledger/laptop-success-dark.png);
}
}
}
object-fit: contain;
}

.textBlock {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ledger/LedgerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function LedgerModal({

return (
<Modal
hasCloseButton
isOpen={isOpen}
hasCloseButton
onClose={onClose}
onCloseAnimationEnd={handleLedgerModalClose}
dialogClassName={buildClassName(styles.modalDialog, areSettingsOpen && styles.modalDialogInsideSettings)}
Expand Down
Loading

0 comments on commit 6d94985

Please sign in to comment.