Skip to content

Commit

Permalink
v3.0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Oct 15, 2024
1 parent a179db7 commit 7acda0f
Show file tree
Hide file tree
Showing 35 changed files with 232 additions and 133 deletions.
1 change: 1 addition & 0 deletions changelogs/3.0.30.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.0.29",
"version": "3.0.30",
"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.0.29
3.0.30
15 changes: 12 additions & 3 deletions src/api/chains/ton/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { getStakingCommonCache } from '../../common/cache';
import { isAlive, isUpdaterAlive } from '../../common/helpers';
import { processNftUpdates, updateAccountNfts } from '../../common/nft';
import { addTokens } from '../../common/tokens';
import { addTokens, getTokensCache } from '../../common/tokens';
import { txCallbacks } from '../../common/txCallbacks';
import { hexToBytes } from '../../common/utils';
import { FIRST_TRANSACTIONS_LIMIT, SEC } from '../../constants';
Expand Down Expand Up @@ -144,25 +144,34 @@ async function setupBalanceBasedPolling(
if (isToncoinBalanceChanged || (doubleCheckTokensTime && doubleCheckTokensTime < Date.now())) {
doubleCheckTokensTime = isToncoinBalanceChanged ? Date.now() + DOUBLE_CHECK_TOKENS_PAUSE : undefined;
tokenBalances = await getAccountTokenBalances(accountId).catch(logAndRescue);
const slugsWithBalances = new Set(tokenBalances?.map(({ slug }) => slug));

const tokensCache = getTokensCache();
const mintlessZeroBalances = Object.fromEntries(
Object.values(tokensCache)
.filter((token) => token.customPayloadApiUrl && !slugsWithBalances.has(token.slug))
.map(({ slug }) => [slug, undefined]),
);
throwErrorIfUpdaterNotAlive(onUpdate, accountId);

if (tokenBalances) {
const tokens = tokenBalances.filter(Boolean).map(({ token }) => token);
await addTokens(tokens, onUpdate);

const cachedTokenBalances = cache?.tokenBalances || {};
tokenBalances.forEach(({ slug, balance: tokenBalance }) => {
const cachedBalance = cache?.tokenBalances && cache.tokenBalances[slug];
const cachedBalance = cachedTokenBalances[slug];
if (cachedBalance === tokenBalance) return;

changedTokenSlugs.push(slug);
balancesToUpdate[slug] = tokenBalance;
});
Object.assign(balancesToUpdate, mintlessZeroBalances);

lastBalanceCache[accountId] = {
...lastBalanceCache[accountId],
tokenBalances: Object.fromEntries(tokenBalances.map(
({ slug, balance: tokenBalance }) => [slug, tokenBalance],
({ slug, balance: tokenBalance }) => [slug, tokenBalance || 0n],
)),
};
}
Expand Down
7 changes: 6 additions & 1 deletion src/api/chains/ton/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ export async function getMintlessParams(options: {

if (!isMintlessClaimed) {
const data = await fetchMintlessTokenWalletData(token.customPayloadApiUrl!, fromAddress);
const isExpired = data
? Date.now() > new Date(Number(data.compressed_info.expired_at) * 1000).getTime()
: true;

if (data) {
if (data && !isExpired) {
customPayload = data.custom_payload;
mintlessTokenBalance = BigInt(data.compressed_info.amount);

Expand Down Expand Up @@ -301,6 +304,8 @@ async function fetchMintlessTokenWalletData(customPayloadApiUrl: string, address
state_init: string;
compressed_info: {
amount: string;
start_from: string;
expired_at: string;
};
} | undefined;
}
Expand Down
7 changes: 4 additions & 3 deletions src/api/chains/ton/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function checkTransactionDraft(
tokenAddress,
shouldEncrypt,
isBase64Data,
stateInit: stateInitString,
} = options;
let { toAddress, amount, data } = options;

Expand All @@ -131,7 +132,7 @@ export async function checkTransactionDraft(

const { isInitialized } = await getContractInfo(network, toAddress);

if (options.stateInit && !isBase64Data) {
if (stateInitString && !isBase64Data) {
return {
...result,
error: ApiTransactionDraftError.StateInitWithoutBin,
Expand All @@ -140,9 +141,9 @@ export async function checkTransactionDraft(

let stateInit;

if (options.stateInit) {
if (stateInitString) {
try {
stateInit = Cell.fromBase64(options.stateInit);
stateInit = Cell.fromBase64(stateInitString);
} catch {
return {
...result,
Expand Down
7 changes: 4 additions & 3 deletions src/api/methods/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function initPolling(_onUpdate: OnApiUpdate) {
Promise.allSettled([
tryUpdateKnownAddresses(),
tryUpdateTokens(_onUpdate, true),
tryLoadSwapTokens(_onUpdate),
tryUpdateSwapTokens(_onUpdate),
tryUpdateStakingCommonData(),
]).then(() => resolveDataPreloadPromise());

Expand Down Expand Up @@ -74,6 +74,7 @@ export async function setupLongBackendPolling() {
tryUpdateKnownAddresses(),
tryUpdateStakingCommonData(),
tryUpdateConfig(localOnUpdate),
tryUpdateSwapTokens(localOnUpdate),
]);
}
}
Expand Down Expand Up @@ -124,7 +125,7 @@ export async function tryUpdateTokens(localOnUpdate?: OnApiUpdate, isFirstRun?:
}
}

export async function tryLoadSwapTokens(localOnUpdate?: OnApiUpdate) {
export async function tryUpdateSwapTokens(localOnUpdate?: OnApiUpdate) {
if (!localOnUpdate) {
localOnUpdate = onUpdate;
}
Expand Down Expand Up @@ -153,7 +154,7 @@ export async function tryLoadSwapTokens(localOnUpdate?: OnApiUpdate) {
tokens,
});
} catch (err) {
logDebugError('tryLoadSwapTokens', err);
logDebugError('tryUpdateSwapTokens', err);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/api/types/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export enum ApiLiquidUnstakeMode {
export type ApiLoyaltyType = 'black' | 'platinum' | 'gold' | 'silver' | 'standard';

export type ApiBalanceBySlug = Record<string, bigint>;
export type ApiMaybeBalanceBySlug = Record<string, bigint | undefined>;

export type ApiWalletInfo = {
address: string;
Expand Down
4 changes: 2 additions & 2 deletions src/api/types/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import type { ApiStakingCommonData, ApiSwapAsset, ApiVestingInfo } from './backe
import type { ApiAnyDisplayError } from './errors';
import type {
ApiBackendStakingState,
ApiBalanceBySlug,
ApiBaseCurrency,
ApiChain,
ApiCountryCode,
ApiDappTransfer,
ApiMaybeBalanceBySlug,
ApiNft,
ApiStakingState,
ApiTokenWithPrice,
Expand All @@ -21,7 +21,7 @@ import type { ApiDapp, ApiTonWallet } from './storage';
export type ApiUpdateBalances = {
type: 'updateBalances';
accountId: string;
balancesToUpdate: ApiBalanceBySlug;
balancesToUpdate: ApiMaybeBalanceBySlug;
};

export type ApiUpdateNewActivities = {
Expand Down
1 change: 1 addition & 0 deletions src/assets/logoDark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/logoLight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/auth/Auth.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
.logo {
display: block !important;

width: 12.5rem;
height: 12.5rem;
width: 10rem;
height: 10rem;
margin: 5rem 0 0 0;

transition: opacity 1s ease, transform 350ms ease-out !important;
Expand Down
13 changes: 9 additions & 4 deletions src/components/auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo, useState } from '../../lib/teact/teact';
import { getActions } from '../../lib/teact/teactn';
import { withGlobal } from '../../global';

import type { GlobalState } from '../../global/types';
import type { GlobalState, Theme } from '../../global/types';
import { AuthState } from '../../global/types';

import { pick } from '../../util/iteratees';
Expand Down Expand Up @@ -33,7 +33,7 @@ import styles from './Auth.module.scss';
type StateProps = Pick<GlobalState['auth'], (
'state' | 'biometricsStep' | 'error' | 'mnemonic' | 'mnemonicCheckIndexes' | 'isLoading' | 'method'
| 'isBackupModalOpen'
)>;
)> & { theme: Theme };

const RENDER_COUNT = Object.keys(AuthState).length / 2;

Expand All @@ -46,6 +46,7 @@ const Auth = ({
mnemonicCheckIndexes,
isBackupModalOpen,
method,
theme,
}: StateProps) => {
const {
closeAbout,
Expand Down Expand Up @@ -150,7 +151,7 @@ const Auth = ({
/>
);
case AuthState.about:
return <SettingsAbout handleBackClick={closeAbout} />;
return <SettingsAbout handleBackClick={closeAbout} theme={theme} />;
}
}

Expand Down Expand Up @@ -180,8 +181,12 @@ const Auth = ({
};

export default memo(withGlobal((global): StateProps => {
return pick(global.auth, [
const authProps = pick(global.auth, [
'state', 'biometricsStep', 'error', 'mnemonic', 'mnemonicCheckIndexes', 'isLoading', 'method',
'isBackupModalOpen',
]);
return {
...authProps,
theme: global.settings.theme,
};
})(Auth));
Loading

0 comments on commit 7acda0f

Please sign in to comment.