Skip to content

Commit

Permalink
v3.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed Jan 23, 2025
1 parent a8ab6b9 commit 450f6a6
Show file tree
Hide file tree
Showing 23 changed files with 213 additions and 135 deletions.
1 change: 1 addition & 0 deletions changelogs/3.2.9.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.2.8",
"version": "3.2.9",
"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.2.8
3.2.9
19 changes: 10 additions & 9 deletions src/api/chains/ton/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { parseAccountId } from '../../../util/account';
import { bigintMultiplyToNumber } from '../../../util/bigint';
import { compareActivities } from '../../../util/compareActivities';
import { fromDecimal, toDecimal } from '../../../util/decimals';
import { getDieselTokenAmount, isDieselAvailable } from '../../../util/fee/transferFee';
import { buildCollectionByKey, omit, pick } from '../../../util/iteratees';
import { logDebug, logDebugError } from '../../../util/logs';
import { updatePoisoningCache } from '../../../util/poisoningHash';
Expand Down Expand Up @@ -104,7 +105,6 @@ const PENDING_DIESEL_TIMEOUT = 15 * 60 * 1000; // 15 min

const DIESEL_NOT_AVAILABLE: ApiFetchEstimateDieselResult = {
status: 'not-available',
amount: { token: 0n, stars: 0n },
nativeAmount: 0n,
remainingFee: 0n,
realFee: 0n,
Expand Down Expand Up @@ -277,10 +277,10 @@ export async function checkTransactionDraft(
tokenBalance: balance,
});

if (result.diesel.status === 'not-available') {
isEnoughBalance = canTransferGasfully && amount <= balance;
if (isDieselAvailable(result.diesel)) {
isEnoughBalance = amount + getDieselTokenAmount(result.diesel) <= balance;
} else {
isEnoughBalance = amount + result.diesel.amount.token <= balance;
isEnoughBalance = canTransferGasfully && amount <= balance;
}
}

Expand Down Expand Up @@ -1338,20 +1338,21 @@ async function getDiesel({
);
const diesel: ApiFetchEstimateDieselResult = {
status: rawDiesel.status,
amount: rawDiesel.status !== 'stars-fee'
? { token: fromDecimal(rawDiesel.amount ?? '0', token.decimals), stars: 0n }
: { token: 0n, stars: fromDecimal(rawDiesel.amount ?? '0', 0) },
amount: rawDiesel.amount === undefined
? undefined
: fromDecimal(rawDiesel.amount, rawDiesel.status === 'stars-fee' ? 0 : token.decimals),
nativeAmount: toncoinNeeded,
remainingFee: toncoinBalance,
realFee: fee.realFee,
};

if (diesel.status === 'not-available') {
const tokenAmount = getDieselTokenAmount(diesel);
if (tokenAmount === 0n) {
return diesel;
}

tokenBalance ??= await getTokenBalanceWithMintless(network, address, tokenAddress);
const canPayDiesel = tokenBalance >= diesel.amount.token;
const canPayDiesel = tokenBalance >= tokenAmount;
const isAwaitingNotExpiredPrevious = Boolean(
rawDiesel.pendingCreatedAt
&& Date.now() - new Date(rawDiesel.pendingCreatedAt).getTime() < PENDING_DIESEL_TIMEOUT,
Expand Down
25 changes: 10 additions & 15 deletions src/api/chains/ton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,16 @@ export type ApiFetchEstimateDieselResult = {
status: DieselStatus;
/**
* The amount of the diesel itself. It will be sent together with the actual transfer. None of this will return back
* as the excess. Charged on top of the transferred amount. The token and stars amounts can't be non-zero
* simultaneously. Warning: the values can be zeros simultaneously, e.g. when the status is 'pending-previous'.
* as the excess. Undefined means that
* gasless transfer is not available, and the diesel shouldn't be shown as the fee; nevertheless, the status should
* be displayed by the UI.
*
* - If the status is not 'stars-fee', the value is measured in the transferred token and charged on top of the
* transferred amount.
* - If the status is 'stars-fee', the value is measured in Telegram stars, and the BigInt assumes 0 decimal places
* (i.e. the number is equal to the visible number of stars).
*/
amount: {
/** Measured in the transferred token */
token: bigint;
/**
* Measured in Telegram stars. The BigInt assumes 0 decimal places (i.e. the number is equal to the visible number
* of stars).
*/
stars: 0n;
} | {
token: 0n;
stars: bigint;
};
amount?: bigint;
/**
* The native token amount covered by the diesel. Guaranteed to be > 0.
*/
Expand All @@ -143,7 +138,7 @@ export type ApiFetchEstimateDieselResult = {
*/
remainingFee: bigint;
/**
* An approximate fee that will be actually spent. The difference between `nativeAmount+nativeRemainder` and this
* An approximate fee that will be actually spent. The difference between `nativeAmount+remainingFee` and this
* number is called "excess" and will be returned back to the wallet. Measured in the native token.
*/
realFee: bigint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@
padding: 1.5px !important;

background-image: radial-gradient(30.47% 83.28% at 79.45% 3.2%, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%),
linear-gradient(258.65deg, #141518 33.29%, #292929 48.38%) !important;
linear-gradient(258.65deg, #141518 33.29%, #292929 48.38%) !important;
}

:global(.MtwCard__platinum)::before,
:global(.MtwCard__gold)::before,
:global(.MtwCard__silver)::before {
background-image: radial-gradient(30.42% 83.05% at 79.4% 3.33%, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%),
linear-gradient(258.63deg, #141518 33.33%, #292929 48.39%) !important;
background-image: radial-gradient(23.98% 49.81% at 73.98% 0.37%, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%),
linear-gradient(258.61deg, rgba(140, 148, 176, 0.5) 33.38%, rgba(186, 188, 194, 0.85) 48.39%) !important;
}

.shadow {
Expand Down
14 changes: 2 additions & 12 deletions src/components/swap/SwapInitial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import { selectCurrentAccount, selectIsMultichainAccount, selectSwapTokens } fro
import { bigintDivideToNumber, bigintMax } from '../../util/bigint';
import buildClassName from '../../util/buildClassName';
import { vibrate } from '../../util/capacitor';
import { findChainConfig, getChainConfig } from '../../util/chain';
import { findChainConfig } from '../../util/chain';
import { fromDecimal, toDecimal } from '../../util/decimals';
import { formatCurrency } from '../../util/formatNumber';
import { getIsNativeToken } from '../../util/tokens';
import { ANIMATED_STICKERS_PATHS } from '../ui/helpers/animatedAssets';

import { isBackgroundModeActive } from '../../hooks/useBackgroundMode';
Expand Down Expand Up @@ -150,7 +149,6 @@ function SwapInitial({
);
const nativeBalance = nativeUserTokenIn?.amount ?? 0n;
const isNativeIn = currentTokenInSlug && currentTokenInSlug === nativeTokenInSlug;
const chainConfigIn = nativeUserTokenIn ? getChainConfig(nativeUserTokenIn.chain as ApiChain) : undefined;
const isTonIn = tokenIn?.chain === 'ton';

const amountInBigint = amountIn && tokenIn ? fromDecimal(amountIn, tokenIn.decimals) : 0n;
Expand All @@ -160,16 +158,8 @@ function SwapInitial({
const networkFeeBigint = (() => {
let value = 0n;

if (!chainConfigIn) {
return value;
}

if (Number(networkFee) > 0) {
value = fromDecimal(networkFee, nativeUserTokenIn?.decimals);
} else if (swapType === SwapType.OnChain) {
value = chainConfigIn?.gas.maxSwap ?? 0n;
} else if (swapType === SwapType.CrosschainFromWallet) {
value = getIsNativeToken(tokenInSlug) ? chainConfigIn.gas.maxTransfer : chainConfigIn.gas.maxTransferToken;
}

return value;
Expand Down Expand Up @@ -222,7 +212,7 @@ function SwapInitial({
amountIn
&& tokenIn
&& amountInBigint > 0
&& amountInBigint <= balanceIn,
&& amountInBigint <= maxAmount,
) || (tokenIn && !nativeTokenInSlug);

const isEnoughFee = swapType !== SwapType.CrosschainToWallet
Expand Down
5 changes: 0 additions & 5 deletions src/components/transfer/Transfer.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,6 @@ textarea.inputStatic {
margin-bottom: 2rem;
}

.transitionSlide {
height: auto;
min-height: 100%;
}

.infoBox, .burnWarning, .error {
align-self: center;

Expand Down
Loading

0 comments on commit 450f6a6

Please sign in to comment.