Skip to content

Commit

Permalink
v1.19.27
Browse files Browse the repository at this point in the history
  • Loading branch information
mytonwalletorg committed May 14, 2024
1 parent 50229eb commit af7dcf7
Show file tree
Hide file tree
Showing 29 changed files with 147 additions and 46 deletions.
1 change: 1 addition & 0 deletions changelogs/1.19.27.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.19.26",
"version": "1.19.27",
"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.19.26
1.19.27
32 changes: 24 additions & 8 deletions src/api/blockchains/ton/util/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import { Dictionary } from '@ton/core/dist/dict/Dictionary';
import type { ApiNetwork, ApiNft, ApiParsedPayload } from '../../../types';
import type { ApiTransactionExtra, JettonMetadata } from '../types';

import { DEBUG, LIQUID_JETTON, NFT_FRAGMENT_COLLECTIONS } from '../../../../config';
import {
COLLECTIONS_WITH_LINK,
DEBUG,
LIQUID_JETTON,
NFT_FRAGMENT_COLLECTIONS,
RE_LINK_TEMPLATE,
} from '../../../../config';
import { pick, range } from '../../../../util/iteratees';
import { logDebugError } from '../../../../util/logs';
import { fetchJsonMetadata, fixIpfsUrl } from '../../../../util/metadata';
Expand Down Expand Up @@ -467,17 +473,26 @@ export function buildNft(network: ApiNetwork, rawNft: NftItem): ApiNft | undefin
address,
index,
collection,
metadata: {
name,
image,
description,
render_type: renderType,
},
metadata,
previews,
sale,
} = rawNft;

const isHidden = renderType === 'hidden' || description === 'SCAM';
const {
name, image, description, render_type: renderType,
} = metadata as {
name?: string;
image?: string;
description?: string;
render_type?: string;
};

const collectionAddress = collection && toBase64Address(collection.address, true, network);
const hasLink = Boolean(name?.match(RE_LINK_TEMPLATE) || description?.match(RE_LINK_TEMPLATE));
const hasScamLink = hasLink && (!collectionAddress || !COLLECTIONS_WITH_LINK.has(collectionAddress));

const isScam = description === 'SCAM' || hasScamLink;
const isHidden = renderType === 'hidden' || isScam;
const imageFromPreview = previews!.find((x) => x.resolution === '1500x1500')!.url;

return {
Expand All @@ -488,6 +503,7 @@ export function buildNft(network: ApiNetwork, rawNft: NftItem): ApiNft | undefin
thumbnail: previews!.find((x) => x.resolution === '500x500')!.url,
isOnSale: Boolean(sale),
isHidden,
isScam,
description,
...(collection && {
collectionAddress: toBase64Address(collection.address, true, network),
Expand Down
1 change: 1 addition & 0 deletions src/api/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export * from './swap';
export * from './other';
export * from './prices';
export * from './preload';
export * from './vesting';
9 changes: 8 additions & 1 deletion src/api/methods/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,15 @@ export async function tryLoadSwapTokens(localOnUpdate?: OnApiUpdate) {

export async function tryUpdateConfig(localOnUpdate: OnApiUpdate) {
try {
const { isLimited, isCopyStorageEnabled = false, now: serverUtc } = await callBackendGet<{
const {
isLimited,
isCopyStorageEnabled = false,
isBurnNotcoinDisabled = false,
now: serverUtc,
} = await callBackendGet<{
isLimited: boolean;
isCopyStorageEnabled?: boolean;
isBurnNotcoinDisabled?: boolean;
now: number;
}>('/utils/get-config');

Expand All @@ -475,6 +481,7 @@ export async function tryUpdateConfig(localOnUpdate: OnApiUpdate) {
type: 'updateConfig',
isLimited,
isCopyStorageEnabled,
isBurnNotcoinDisabled,
});

const localUtc = (new Date()).getTime();
Expand Down
13 changes: 13 additions & 0 deletions src/api/methods/vesting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ApiVestingInfo } from '../types';

import { parseAccountId } from '../../util/account';
import { fetchStoredAddress } from '../common/accounts';
import { callBackendGet } from '../common/backend';

export async function fetchVestings(accountId: string) {
const { network } = parseAccountId(accountId);
const isTestnet = network === 'testnet';
const address = await fetchStoredAddress(accountId);

return callBackendGet<ApiVestingInfo>(`/vesting/${address}`, { isTestnet });
}
15 changes: 15 additions & 0 deletions src/api/types/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,18 @@ export type ApiSite = {

// Prices
export type ApiPriceHistoryPeriod = '1D' | '7D' | '1M' | '3M' | '1Y' | 'ALL';

// Vesting
export type ApiVestingPartStatus = 'frozen' | 'ready' | 'unfrozen' | 'missed';

export type ApiVestingInfo = {
id: number;
startsAt: Date;
initialAmount: number;
parts: {
id: number;
time: Date;
amount: number;
status: ApiVestingPartStatus;
}[];
};
1 change: 1 addition & 0 deletions src/api/types/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface ApiNft {
isOnSale: boolean;
isHidden?: boolean;
isOnFragment?: boolean;
isScam?: boolean;
}

export type ApiHistoryList = Array<[number, number]>;
Expand Down
1 change: 1 addition & 0 deletions src/api/types/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export type ApiUpdateConfig = {
type: 'updateConfig';
isLimited: boolean;
isCopyStorageEnabled: boolean;
isBurnNotcoinDisabled: boolean;
};

export type ApiUpdateWalletVersions = {
Expand Down
31 changes: 27 additions & 4 deletions src/components/auth/Auth.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -523,25 +523,48 @@
.importButtonsBlock {
display: flex;
flex-direction: column;
gap: 2rem;
align-items: center;

width: 100%;
margin-top: auto;
}

.importText {
margin-top: 2rem;
position: relative;

font-size: 1.0625rem !important;
font-weight: 600;
font-size: 0.9375rem !important;
font-weight: 400;
line-height: 1.0625rem;
color: var(--color-gray-3);

&::before,
&::after {
content: '';

position: absolute;
right: 0;
bottom: 0.5rem;
left: -5.125rem;

width: 4.5rem;
height: 0.0625rem;
/* stylelint-disable-next-line plugin/whole-pixel */
box-shadow: inset 0 -0.0375rem 0 0 var(--color-separator);
}

&::after {
position: absolute;
right: -5.125rem;
left: auto;
}
}

.importButtons {
display: flex;
gap: 1rem;

margin: 0.75rem -1rem 0;
margin: 0 -1rem;
}

.biometricsStep {
Expand Down
2 changes: 1 addition & 1 deletion src/components/auth/AuthStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function AuthStart({ hasAccounts, isLoading }: StateProps) {
>
{lang('Create Wallet')}
</Button>
<span className={styles.importText}>{lang('Or import from...')}</span>
<span className={styles.importText}>{lang('or import from')}</span>
<div className={styles.importButtons}>
<Button
className={buildClassName(styles.btn, !IS_LEDGER_SUPPORTED && styles.btn_single)}
Expand Down
8 changes: 6 additions & 2 deletions src/components/main/sections/Content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface StateProps {
selectedAddresses?: string[];
activeContentTab?: ContentTab;
currentTokenSlug?: string;
isBurnNotcoinDisabled?: boolean;
}

function Content({
Expand All @@ -61,6 +62,7 @@ function Content({
selectedAddresses,
onStakedTokenClick,
currentTokenSlug,
isBurnNotcoinDisabled,
}: OwnProps & StateProps) {
const {
selectToken,
Expand Down Expand Up @@ -120,13 +122,13 @@ function Content({
menuItems: nftCollections,
onMenuItemClick: handleNftCollectionClick,
},
...(nftCollections.some(({ value }) => value === NOTCOIN_VOUCHERS_ADDRESS) ? [{
...(!isBurnNotcoinDisabled && nftCollections.some(({ value }) => value === NOTCOIN_VOUCHERS_ADDRESS) ? [{
id: ContentTab.NotcoinVouchers,
title: 'NOT Vouchers',
className: styles.tab,
}] : []),
],
[lang, nftCollections, shouldShowSeparateAssetsPanel],
[isBurnNotcoinDisabled, lang, nftCollections, shouldShowSeparateAssetsPanel],
);

const activeTabIndex = useMemo(
Expand Down Expand Up @@ -308,6 +310,7 @@ export default memo(
currentCollectionAddress,
selectedAddresses,
} = selectCurrentAccountState(global)?.nfts || {};
const { isBurnNotcoinDisabled } = global.restrictions;

return {
nfts,
Expand All @@ -316,6 +319,7 @@ export default memo(
tokensCount,
activeContentTab: accountState?.activeContentTab,
currentTokenSlug: accountState?.currentTokenSlug,
isBurnNotcoinDisabled,
};
},
(global, _, stickToFirst) => stickToFirst(global.currentAccountId),
Expand Down
14 changes: 12 additions & 2 deletions src/components/main/sections/Content/Nfts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ interface StateProps {
selectedAddresses?: string[];
byAddress?: Record<string, ApiNft>;
currentCollectionAddress?: string;
isBurnNotcoinDisabled?: boolean;
isHardware?: boolean;
isTestnet?: boolean;
}

const GETGEMS_ENABLED = !IS_IOS_APP && !IS_ANDROID_APP;

function Nfts({
isActive, orderedAddresses, selectedAddresses, byAddress, currentCollectionAddress, isHardware, isTestnet,
isActive,
orderedAddresses,
selectedAddresses,
byAddress,
currentCollectionAddress,
isHardware,
isTestnet,
isBurnNotcoinDisabled,
}: OwnProps & StateProps) {
const { clearNftsSelection, startTransfer, submitTransferInitial } = getActions();

Expand Down Expand Up @@ -143,7 +151,7 @@ function Nfts({

return (
<div>
{currentCollectionAddress === NOTCOIN_VOUCHERS_ADDRESS && (
{currentCollectionAddress === NOTCOIN_VOUCHERS_ADDRESS && !isBurnNotcoinDisabled && (
<Button
isPrimary
className={styles.notcoinVoucherButton}
Expand All @@ -163,6 +171,7 @@ function Nfts({
export default memo(
withGlobal<OwnProps>(
(global): StateProps => {
const { isBurnNotcoinDisabled } = global.restrictions;
const {
orderedAddresses,
byAddress,
Expand All @@ -174,6 +183,7 @@ export default memo(
orderedAddresses,
selectedAddresses,
byAddress,
isBurnNotcoinDisabled,
isHardware: selectIsHardwareAccount(global),
currentCollectionAddress,
isTestnet: global.settings.isTestnet,
Expand Down
14 changes: 7 additions & 7 deletions src/components/mediaViewer/hooks/useNftMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const ON_SALE_ITEM: DropdownItem = {
description: 'NFT is for sale',
isDisabled: true,
};
const TON_DNS_ITEM: DropdownItem = {
name: 'Configure DNS',
value: 'tondns',
fontIcon: 'external',
};
const SEND_ITEM: DropdownItem = {
name: 'Send',
value: 'send',
Expand All @@ -44,11 +49,6 @@ const TONSCAN_ITEM: DropdownItem = {
value: 'tonscan',
fontIcon: 'external',
};
const TON_DNS_ITEM: DropdownItem = {
name: 'Configure DNS',
value: 'tondns',
fontIcon: 'external',
};
const COLLECTION_ITEM: DropdownItem = {
name: 'Collection',
value: 'collection',
Expand Down Expand Up @@ -148,11 +148,11 @@ export default function useNftMenu(nft?: ApiNft) {
if (!nft) return [];

return [
nft.isOnSale ? ON_SALE_ITEM : SEND_ITEM,
...(nft.collectionAddress === TON_DNS_COLLECTION ? [TON_DNS_ITEM] : []),
nft.isOnSale ? ON_SALE_ITEM : SEND_ITEM,
...(nft.isOnFragment ? [FRAGMENT_ITEM] : []),
GETGEMS_ITEM,
TONSCAN_ITEM,
...(nft.isOnFragment ? [FRAGMENT_ITEM] : []),
...(nft.collectionAddress ? [COLLECTION_ITEM] : []),
...(!nft.isOnSale ? [
BURN_ITEM,
Expand Down
7 changes: 3 additions & 4 deletions src/components/transfer/TransferConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getActions, withGlobal } from '../../global';
import type { GlobalState } from '../../global/types';

import {
ANIMATED_STICKER_SMALL_SIZE_PX, BURN_ADDRESS, BURN_CHUNK_DURATION_APPROX_SEC, TON_SYMBOL,
ANIMATED_STICKER_SMALL_SIZE_PX, BURN_ADDRESS, BURN_CHUNK_DURATION_APPROX_SEC, NFT_BATCH_SIZE, TON_SYMBOL,
} from '../../config';
import renderText from '../../global/helpers/renderText';
import buildClassName from '../../util/buildClassName';
Expand Down Expand Up @@ -96,7 +96,7 @@ function TransferConfirm({
}

function renderFeeForNft() {
const totalFee = (NFT_TRANSFER_TON_AMOUNT + (fee ?? 0n)) * BigInt(Math.ceil(nfts!.length / 4));
const totalFee = (NFT_TRANSFER_TON_AMOUNT + (fee ?? 0n)) * BigInt(Math.ceil(nfts!.length / NFT_BATCH_SIZE));

return (
<>
Expand Down Expand Up @@ -142,7 +142,7 @@ function TransferConfirm({
}

const burningDurationMin = nfts?.length
? (Math.ceil(nfts.length / 4) * BURN_CHUNK_DURATION_APPROX_SEC) / 60
? (Math.ceil(nfts.length / NFT_BATCH_SIZE) * BURN_CHUNK_DURATION_APPROX_SEC) / 60
: undefined;

return (
Expand Down Expand Up @@ -198,7 +198,6 @@ function TransferConfirm({
{(
nfts?.length === 1
? renderText(lang('Are you sure you want to burn this NFT? It will be lost forever.'))
// eslint-disable-next-line max-len
: [
renderText(lang('$multi_burn_nft_warning', { amount: nfts.length })),
' ',
Expand Down
Loading

0 comments on commit af7dcf7

Please sign in to comment.