Skip to content

Commit

Permalink
v1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Feb 11, 2024
1 parent 95d939a commit 07265fb
Show file tree
Hide file tree
Showing 52 changed files with 579 additions and 195 deletions.
1 change: 1 addition & 0 deletions changelogs/1.18.2.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": "1.18.1",
"version": "1.18.2",
"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 @@
1.18.1
1.18.2
30 changes: 18 additions & 12 deletions src/api/blockchains/ton/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ export async function submitTransfer(
// Fix address format for `waitTxComplete` to work properly
const normalizedAddress = toBase64Address(toAddress);

if (data && typeof data === 'string') {
if (isBase64Data) {
if (typeof data === 'string') {
if (!data) {
data = undefined;
} else if (isBase64Data) {
data = parseBase64(data);
} else if (shouldEncrypt) {
const toPublicKey = (await getWalletPublicKey(network, toAddress))!;
Expand Down Expand Up @@ -379,17 +381,19 @@ async function signTransaction(
payload = packBytesAsSnake(payload, 0) as Cell;
}

const init = stateInit ? {
code: stateInit.refs[0],
data: stateInit.refs[1],
} : undefined;

const transaction = wallet.createTransfer({
seqno,
secretKey: Buffer.from(privateKey),
messages: [internal({
value: amount,
to: toAddress,
body: payload,
init: {
code: stateInit?.refs[0],
data: stateInit?.refs[1],
},
init,
bounce: parseAddress(toAddress).isBounceable,
})],
sendMode: SendMode.PAY_GAS_SEPARATELY + SendMode.IGNORE_ERRORS,
Expand Down Expand Up @@ -642,15 +646,17 @@ async function signMultiTransaction(
payload = Cell.fromBase64(payload);
}

const init = stateInit ? {
code: stateInit.refs[0],
data: stateInit.refs[1],
} : undefined;

return internal({
value: amount,
to: toAddress,
body: payload as Cell | string | undefined, // TODO
body: payload as Cell | string | undefined, // TODO Fix Uint8Array type
bounce: parseAddress(toAddress).isBounceable,
init: {
code: stateInit?.refs[0],
data: stateInit?.refs[1],
},
init,
});
});

Expand Down Expand Up @@ -707,7 +713,7 @@ async function waitIncrementSeqno(network: ApiNetwork, address: string, seqno: n
}

async function calculateFee(network: ApiNetwork, wallet: TonWallet, transaction: Cell) {
const { source_fees: fees } = await getTonClient('mainnet').estimateExternalMessageFee(wallet.address, {
const { source_fees: fees } = await getTonClient(network).estimateExternalMessageFee(wallet.address, {
body: transaction,
// eslint-disable-next-line no-null/no-null
initCode: null,
Expand Down
5 changes: 3 additions & 2 deletions src/api/blockchains/ton/util/tonapiio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { TONAPIIO_MAINNET_URL, TONAPIIO_TESTNET_URL } from '../../../../config';
import fetchWithTimeout from '../../../../util/fetchWithTimeout';
import { getEnvironment } from '../../../environment';

const MAX_LIMIT = 1000;
const MAX_LIMIT = 500;
const EVENTS_LIMIT = 100;

let apiByNetwork: Record<ApiNetwork, Api<unknown>> | undefined;

Expand Down Expand Up @@ -64,7 +65,7 @@ export async function fetchAccountNfts(network: ApiNetwork, address: string, opt

export async function fetchAccountEvents(network: ApiNetwork, address: string, fromSec: number, limit?: number) {
return (await getApi(network).accounts.getAccountEvents(address, {
limit: limit ?? MAX_LIMIT,
limit: limit ?? EVENTS_LIMIT,
start_date: fromSec,
})).events;
}
9 changes: 5 additions & 4 deletions src/api/methods/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ export function initPolling(_onUpdate: OnApiUpdate, _isAccountActive: IsAccountA
tryUpdateTokens(_onUpdate),
tryLoadSwapTokens(_onUpdate),
tryUpdateStakingCommonData(),
tryUpdateRegion(_onUpdate),
]);

void tryUpdateRegion(_onUpdate);

void setupBackendPolling();
void setupLongBackendPolling();
}
Expand Down Expand Up @@ -229,7 +230,7 @@ export async function setupBalanceBasedPolling(accountId: string, newestTxIds: A

i++;
} catch (err) {
logDebugError('setupBalancePolling', err);
logDebugError('setupBalanceBasedPolling', err);
}

await pause(POLLING_INTERVAL);
Expand Down Expand Up @@ -276,7 +277,7 @@ export async function setupStakingPolling(accountId: string) {
});
}
} catch (err) {
logDebugError('setupBalancePolling', err);
logDebugError('setupStakingPolling', err);
}

await pause(POLLING_INTERVAL);
Expand Down Expand Up @@ -534,7 +535,7 @@ export async function setupSwapPolling(accountId: string) {
});
}
} catch (err) {
logDebugError('setupSwapCexPolling', err);
logDebugError('setupSwapPolling', err);
}

await pause(SWAP_POLLING_INTERVAL);
Expand Down
1 change: 0 additions & 1 deletion src/assets/arrow-right-white.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/arrow-right.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/close.svg

This file was deleted.

22 changes: 12 additions & 10 deletions src/components/Dialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { FC } from '../lib/teact/teact';
import React, { memo, useEffect } from '../lib/teact/teact';
import { getActions, withGlobal } from '../global';

import type { DialogType } from '../global/types';

import renderText from '../global/helpers/renderText';
import { pick } from '../util/iteratees';
import { IS_DELEGATED_BOTTOM_SHEET, IS_DELEGATING_BOTTOM_SHEET } from '../util/windowEnvironment';
Expand All @@ -16,7 +18,7 @@ import Modal from './ui/Modal';
import modalStyles from './ui/Modal.module.scss';

type StateProps = {
dialogs: string[];
dialogs: DialogType[];
};

const Dialogs: FC<StateProps> = ({ dialogs }) => {
Expand All @@ -25,27 +27,27 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
const lang = useLang();
const [isModalOpen, openModal, closeModal] = useFlag();

const message = dialogs[dialogs.length - 1];
const title = lang('Something went wrong');
const dialog = dialogs[dialogs.length - 1];
const title = lang(dialog?.title ?? 'Something went wrong');

useEffect(() => {
if (IS_DELEGATING_BOTTOM_SHEET || IS_DELEGATED_BOTTOM_SHEET) {
if (message) {
if (dialog) {
Dialog.alert({
title,
message: lang(message),
message: lang(dialog.message),
}).then(() => {
dismissDialog();
});
}
} else if (message) {
} else if (dialog) {
openModal();
} else {
closeModal();
}
}, [dialogs, lang, message, openModal, title]);
}, [dialogs, lang, dialog, openModal, title]);

if (!message || IS_DELEGATING_BOTTOM_SHEET || IS_DELEGATED_BOTTOM_SHEET) {
if (!dialog || IS_DELEGATING_BOTTOM_SHEET || IS_DELEGATED_BOTTOM_SHEET) {
return undefined;
}

Expand All @@ -58,10 +60,10 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
onCloseAnimationEnd={dismissDialog}
>
<div>
{renderText(lang(message))}
{renderText(lang(dialog.message))}
</div>
<div className={modalStyles.buttons}>
<Button onClick={closeModal}>OK</Button>
<Button onClick={closeModal}>{lang('OK')}</Button>
</div>
</Modal>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/addbuy/AddBuyModal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}

.actionButtons {
overflow: hidden;
display: flex;
flex-direction: column;

Expand Down
4 changes: 2 additions & 2 deletions src/components/dapps/DappConnectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function DappConnectModal({
<>
<ModalHeader title={lang('Connect Dapp')} onClose={closeModal} />
<div className={modalStyles.transitionContent}>
<div className={styles.dappInfoSkeleton}>
<div className={buildClassName(styles.dappInfoSkeleton, styles.dapp_first)}>
<div className={styles.dappInfoIconSkeleton} />
<div className={styles.dappInfoTextSkeleton}>
<div className={styles.nameSkeleton} />
Expand All @@ -221,7 +221,7 @@ function DappConnectModal({

function renderDappInfoWithSkeleton() {
return (
<Transition name="fade" activeKey={isLoading ? 0 : 1} slideClassName={styles.skeletonTransitionWrapper}>
<Transition name="semiFade" activeKey={isLoading ? 0 : 1} slideClassName={styles.skeletonTransitionWrapper}>
{isLoading ? renderWaitForConnection() : renderDappInfo()}
</Transition>
);
Expand Down
6 changes: 6 additions & 0 deletions src/components/main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import windowSize from '../../util/windowSize';

import { useOpenFromMainBottomSheet } from '../../hooks/useDelegatedBottomSheet';
import { useDeviceScreen } from '../../hooks/useDeviceScreen';
import useEffectOnce from '../../hooks/useEffectOnce';
import useFlag from '../../hooks/useFlag';
import useLastCallback from '../../hooks/useLastCallback';
import useShowTransition from '../../hooks/useShowTransition';
Expand Down Expand Up @@ -70,6 +71,7 @@ function Main({
openStakingInfo,
closeStakingInfo,
setLandscapeActionsActiveTabIndex,
loadDappCatalog,
} = getActions();

// eslint-disable-next-line no-null/no-null
Expand All @@ -89,6 +91,10 @@ function Main({
transitionClassNames: stickyCardTransitionClassNames,
} = useShowTransition(canRenderStickyCard);

useEffectOnce(() => {
loadDappCatalog();
});

useEffect(() => {
setStatusBarStyle(shouldRenderDarkStatusBar);
}, [shouldRenderDarkStatusBar]);
Expand Down
8 changes: 4 additions & 4 deletions src/components/main/sections/Card/AccountSelector.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
overflow: hidden;

max-width: calc(100% - 4rem);
padding: 0.75rem;
padding: 0.75rem 0.6875rem 0.75rem 0.75rem;

font-size: 1.0625rem;
font-weight: 700;
Expand All @@ -24,7 +24,7 @@
content: '';

position: absolute;
top: calc(50% - 0.0625rem);
top: 50%;
right: 0;

width: 0.4375rem;
Expand Down Expand Up @@ -61,7 +61,7 @@
top: 1.125rem;
left: 1rem;

padding: 0 0.75rem 0 0;
padding: 0 0.6875rem 0 0;
}
}

Expand Down Expand Up @@ -187,7 +187,7 @@
.container {
position: absolute;
z-index: 3;
top: 2.75rem;
top: 2.8125rem;
right: 0.5rem;
left: 0.5rem;

Expand Down
7 changes: 6 additions & 1 deletion src/components/main/sections/Card/AccountSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface StateProps {
accounts?: Record<string, Account>;
}

const HARDWARE_ACCOUNT_ADDRESS_SHIFT = 3;
const ACCOUNT_ADDRESS_SHIFT = 4;
const ACCOUNTS_AMOUNT_FOR_COMPACT_DIALOG = 3;

Expand Down Expand Up @@ -141,7 +142,11 @@ function AccountSelector({
<div className={styles.accountAddressBlock}>
{isHardware && <i className="icon-ledger" aria-hidden />}
<span>
{shortenAddress(address, ACCOUNT_ADDRESS_SHIFT)}
{shortenAddress(
address,
isHardware ? HARDWARE_ACCOUNT_ADDRESS_SHIFT : ACCOUNT_ADDRESS_SHIFT,
ACCOUNT_ADDRESS_SHIFT,
)}
</span>
</div>

Expand Down
28 changes: 28 additions & 0 deletions src/components/main/sections/Card/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

.containerWrapper {
position: relative;
z-index: var(--z-card);

box-sizing: border-box;
width: 100%;
Expand Down Expand Up @@ -159,6 +160,33 @@
color: var(--color-card-second-text);
}

.iconCaret {
position: relative;
top: -0.1875rem;
left: -0.0625rem;

font-size: 1.125rem;
}

.iconCaretSmall {
font-size: 0.875rem;
line-height: 0.875rem;
vertical-align: -1px;
}

.iconCaretFraction {
position: relative;
top: 0.0625rem;
left: 0.0625rem;

font-size: 0.875rem;
color: var(--color-card-second-text);
}

.currencySwitcher {
cursor: var(--custom-cursor, pointer);
}

.addressContainer {
margin-top: auto;
margin-bottom: 0.375rem;
Expand Down
Loading

0 comments on commit 07265fb

Please sign in to comment.