From 6ba51cb12472cea68f495549d0a72766906f96e2 Mon Sep 17 00:00:00 2001 From: mytonwalletorg Date: Tue, 6 Aug 2024 14:14:21 +0200 Subject: [PATCH] v3.0.5 --- changelogs/3.0.5.txt | 1 + package-lock.json | 4 ++-- package.json | 2 +- public/version.txt | 2 +- src/api/blockchains/ton/wallet.ts | 19 ++++++++++++++----- src/lib/rlottie/rlottie.worker.ts | 22 +++++++++++++--------- src/util/handleError.ts | 11 +++++++++-- webpack.config.ts | 3 --- 8 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 changelogs/3.0.5.txt diff --git a/changelogs/3.0.5.txt b/changelogs/3.0.5.txt new file mode 100644 index 00000000..619f4cd5 --- /dev/null +++ b/changelogs/3.0.5.txt @@ -0,0 +1 @@ +Bug fixes and performance improvements diff --git a/package-lock.json b/package-lock.json index 3f74b1e8..1b5ee599 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mytonwallet", - "version": "3.0.4", + "version": "3.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mytonwallet", - "version": "3.0.4", + "version": "3.0.5", "license": "GPL-3.0-or-later", "dependencies": { "@awesome-cordova-plugins/core": "^6.6.0", diff --git a/package.json b/package.json index 8cfc1301..e05e487f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mytonwallet", - "version": "3.0.4", + "version": "3.0.5", "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": { diff --git a/public/version.txt b/public/version.txt index b0f2dcb3..eca690e7 100644 --- a/public/version.txt +++ b/public/version.txt @@ -1 +1 @@ -3.0.4 +3.0.5 diff --git a/src/api/blockchains/ton/wallet.ts b/src/api/blockchains/ton/wallet.ts index 3381ba0f..bc9ab68d 100644 --- a/src/api/blockchains/ton/wallet.ts +++ b/src/api/blockchains/ton/wallet.ts @@ -129,18 +129,27 @@ export async function pickBestWallet(network: ApiNetwork, publicKey: Uint8Array) balance: bigint; }> { const allWallets = await getWalletVersionInfos(network, publicKey); + const defaultWallet = allWallets.filter(({ version }) => version === DEFAULT_WALLET_VERSION)[0]; + + if (defaultWallet.lastTxId) { + return defaultWallet; + } const withBiggestBalance = allWallets.reduce((best, current) => { return best && best.balance > current.balance ? best : current; }, undefined); - if (!withBiggestBalance || !withBiggestBalance.balance) { - const version = DEFAULT_WALLET_VERSION; - const wallet = buildWallet(network, publicKey, version); - return { wallet, version, balance: 0n }; + if (withBiggestBalance) { + return withBiggestBalance; + } + + const withLastTx = allWallets.find(({ lastTxId }) => !!lastTxId); + + if (withLastTx) { + return withLastTx; } - return withBiggestBalance; + return defaultWallet; } export function getWalletVersionInfos( diff --git a/src/lib/rlottie/rlottie.worker.ts b/src/lib/rlottie/rlottie.worker.ts index 5f516b71..75389212 100644 --- a/src/lib/rlottie/rlottie.worker.ts +++ b/src/lib/rlottie/rlottie.worker.ts @@ -4,15 +4,19 @@ import type { CancellableCallback } from '../../util/PostMessageConnector'; import { createPostMessageInterface } from '../../util/createPostMessageInterface'; -const { - Module, - allocate, - intArrayFromString, -}: { - Module: any; - allocate(...args: any[]): string; - intArrayFromString(str: String): string; -} = require('./rlottie-wasm.js'); +declare const Module: any; + +declare function allocate(...args: any[]): string; + +declare function intArrayFromString(str: String): string; + +declare const self: WorkerGlobalScope; + +try { + self.importScripts('rlottie-wasm.js'); +} catch (err) { + throw new Error('Failed to import rlottie-wasm.js'); +} let rLottieApi: Record; const rLottieApiPromise = new Promise((resolve) => { diff --git a/src/util/handleError.ts b/src/util/handleError.ts index 56d52100..23c0ce66 100644 --- a/src/util/handleError.ts +++ b/src/util/handleError.ts @@ -22,11 +22,18 @@ function handleErrorEvent(e: ErrorEvent | PromiseRejectionEvent) { handleError(e instanceof ErrorEvent ? (e.error || e.message) : e.reason); } -export function handleError(err: Error) { +export function handleError(err: Error | string) { // eslint-disable-next-line no-console console.error(err); + const message = typeof err === 'string' ? err : err.message; + const stack = typeof err === 'object' ? err.stack : undefined; + + if (message.endsWith('Failed to import rlottie-wasm.js')) { + return; + } + if (APP_ENV === 'development' || APP_ENV === 'staging') { - throttledAlert(`${DEBUG_ALERT_MSG}\n\n${(err?.message) || err}\n${err?.stack}`); + throttledAlert(`${DEBUG_ALERT_MSG}\n\n${(message) || err}\n${stack}`); } } diff --git a/webpack.config.ts b/webpack.config.ts index ee2e80e2..383a7ca0 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -187,9 +187,6 @@ export default function createConfig( extensions: ['.js', '.ts', '.tsx'], fallback: { crypto: false, - path: false, - fs: false, - browser: false, }, alias: { // It is used to remove duplicate dependencies