Skip to content

Commit

Permalink
Merge pull request #1225 from tonwhales/release/v2.4.8
Browse files Browse the repository at this point in the history
latest hotfixesa, Release/v2.4.8
  • Loading branch information
vzhovnitsky authored Dec 15, 2024
2 parents ef61c44 + b62f597 commit 22cdbda
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 92 deletions.
2 changes: 1 addition & 1 deletion VERSION_CODE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
225
226
36 changes: 16 additions & 20 deletions app/components/products/SpecialJettonProduct.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, useCallback, useEffect, useMemo } from "react";
import { memo, useCallback, useMemo } from "react";
import { ThemeType } from "../../engine/state/theme";
import { useTypedNavigation } from "../../utils/useTypedNavigation";
import { Pressable, View, Image, Text } from "react-native";
Expand All @@ -9,7 +9,7 @@ import { Address } from "@ton/core";
import { useSpecialJetton } from "../../engine/hooks/jettons/useSpecialJetton";
import { WImage } from "../WImage";
import { ItemDivider } from "../ItemDivider";
import { useBounceableWalletFormat } from "../../engine/hooks";
import { useBounceableWalletFormat, useJettonContent } from "../../engine/hooks";
import { useGaslessConfig } from "../../engine/hooks/jettons/useGaslessConfig";
import { useWalletVersion } from "../../engine/hooks/useWalletVersion";
import { GaslessInfoButton } from "../jettons/GaslessInfoButton";
Expand All @@ -29,6 +29,7 @@ export const SpecialJettonProduct = memo(({
}) => {
const navigation = useTypedNavigation();
const specialJetton = useSpecialJetton(address);
const masterContent = useJettonContent(specialJetton?.master.toString({ testOnly }));
const balance = specialJetton?.balance ?? 0n;
const [bounceableFormat] = useBounceableWalletFormat();
const ledgerAddressStr = address.toString({ bounceable: bounceableFormat, testOnly });
Expand All @@ -54,22 +55,19 @@ export const SpecialJettonProduct = memo(({
}, [gaslessConfig?.gas_jettons, walletVersion, specialJetton?.master]);

const onPress = useCallback(() => {
const jetton = specialJetton
? { master: specialJetton.master, data: specialJetton.masterContent }
: undefined;
const hasWallet = !!specialJetton?.wallet;

if (isLedger) {
if (!hasWallet || balance === 0n) {
if (!hasWallet) {
navigation.navigate(
'LedgerReceive',
{
addr: ledgerAddressStr,
ledger: true, asset: specialJetton ? {
address: specialJetton.master,
content: {
icon: specialJetton.icon,
name: specialJetton.name,
icon: masterContent?.originalImage,
name: masterContent?.name,
}
} : undefined
});
Expand Down Expand Up @@ -101,18 +99,16 @@ export const SpecialJettonProduct = memo(({
return;
}

if (balance)

navigation.navigateReceive({
asset: specialJetton ? {
address: specialJetton.master,
content: {
icon: specialJetton.icon,
name: specialJetton.name,
}
} : undefined
});
}, [specialJetton, isLedger, ledgerAddressStr, navigation]);
navigation.navigateReceive({
asset: specialJetton ? {
address: specialJetton.master,
content: {
icon: masterContent?.originalImage,
name: masterContent?.name,
}
} : undefined
});
}, [specialJetton, isLedger, ledgerAddressStr, navigation, masterContent]);

return (
<Pressable
Expand Down
2 changes: 1 addition & 1 deletion app/engine/hooks/accounts/useOldWalletsBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function useOldWalletsBalances() {
const account = useSelectedAccount();

const query = useQuery({
queryKey: Queries.Account(account!.addressString).OldWallets(),
queryKey: Queries.Account(account?.addressString!).OldWallets(),
queryFn: async () => {
return await fetchOldWalletBalances(account!.publicKey);
},
Expand Down
3 changes: 2 additions & 1 deletion app/fragments/wallet/AssetsFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ReceiveableAsset } from "./ReceiveFragment";
import { getAccountName } from "../../utils/holders/getAccountName";
import { HoldersAccountItem } from "../../components/products/HoldersAccountItem";
import { GeneralHoldersAccount } from "../../engine/api/holders/fetchAccounts";
import { hasDirectDeposit } from "../../utils/holders/hasDirectDeposit";

import IcCheck from "@assets/ic-check.svg";

Expand Down Expand Up @@ -146,7 +147,7 @@ export const AssetsFragment = fragment(() => {

const owner = isLedgerScreen ? ledgerAddress! : selected!.address;
const holdersAccStatus = useHoldersAccountStatus(owner).data;
const holdersAccounts = useHoldersAccounts(owner).data?.accounts ?? [];
const holdersAccounts = useHoldersAccounts(owner).data?.accounts?.filter(acc => hasDirectDeposit(acc)) ?? [];
const account = useAccountLite(owner);
const hints = useHintsFull(owner.toString({ testOnly: isTestnet })).data?.hints ?? [];

Expand Down
155 changes: 89 additions & 66 deletions app/fragments/wallet/ReceiveFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { View, Text, Pressable, ScrollView, Platform, Alert } from "react-native
import { t } from "../../i18n/t";
import { QRCode } from "../../components/QRCode/QRCode";
import { useParams } from "../../utils/useParams";
import { ShareButton } from "../../components/ShareButton";
import { WImage } from "../../components/WImage";
import { useTypedNavigation } from "../../utils/useTypedNavigation";
import { ScreenHeader } from "../../components/ScreenHeader";
import { captureRef } from 'react-native-view-shot';
import { useNetwork, useBounceableWalletFormat, useSelectedAccount, useTheme, useVerifyJetton, useJetton, useHoldersAccounts } from "../../engine/hooks";
import { useNetwork, useBounceableWalletFormat, useSelectedAccount, useTheme, useVerifyJetton, useJetton, useHoldersAccounts, useJettonContent } from "../../engine/hooks";
import { Address } from "@ton/core";
import { StatusBar } from "expo-status-bar";
import { Typography } from "../../components/styles";
Expand All @@ -21,14 +20,16 @@ import { getAccountName } from "../../utils/holders/getAccountName";
import Animated, { FadeInUp, FadeOutDown } from "react-native-reanimated";
import { ToastDuration, useToaster } from "../../components/toast/ToastProvider";
import { copyText } from "../../utils/copyText";
import { GeneralHoldersAccount } from "../../engine/api/holders/fetchAccounts";
import { GeneralHoldersAccount, GeneralHoldersCard } from "../../engine/api/holders/fetchAccounts";
import Share from 'react-native-share';
import { ItemDivider } from "../../components/ItemDivider";
import { AddressComponent } from "../../components/address/AddressComponent";
import { hasDirectDeposit } from "../../utils/holders/hasDirectDeposit";
import { HoldersAccountCard } from "../../components/products/HoldersAccountCard";

import CopyIcon from '@assets/ic-copy.svg';
import FromExchangeIcon from '@assets/ic-from-exchange.svg';
import ShareIcon from '@assets/ic-share.svg';
import { ItemDivider } from "../../components/ItemDivider";
import { AddressComponent } from "../../components/address/AddressComponent";

type ReceiveableAssetContent = {
icon: string | null | undefined;
Expand Down Expand Up @@ -72,7 +73,7 @@ export const ReceiveFragment = fragment(() => {
return selected!.address;
}, [selected, addr]);

const holdersAccounts = useHoldersAccounts(address).data?.accounts;
const holdersAccounts = useHoldersAccounts(address).data?.accounts?.filter(acc => hasDirectDeposit(acc));
const defaultAccount = holdersAccounts?.[0];
const holdersTarget = defaultAccount ? mapHoldersAccountTarget(defaultAccount) : undefined;
const defaultAccountMaster = holdersTarget?.jettonMaster || undefined;
Expand All @@ -99,12 +100,13 @@ export const ReceiveFragment = fragment(() => {
const [asset, setAsset] = useState<ReceiveableAsset | null>(initialAsset);

const holdersAssetTarget = !!asset?.holders?.address ? mapHoldersAccountTarget(asset?.holders) : undefined;
const holdersCards = asset?.holders?.cards || [];
const assetMaster = holdersAssetTarget
? holdersAssetTarget.jettonMaster
: asset?.address?.toString({ testOnly: network.isTestnet });
const jetton = useJetton({ owner: address, master: assetMaster ?? undefined });
const jetton = useJettonContent(assetMaster);
const jettonAssetcontent: ReceiveableAssetContent | null = jetton ? {
icon: jetton.icon,
icon: jetton.originalImage,
name: jetton.name
} : null
const icon = jettonAssetcontent?.icon;
Expand Down Expand Up @@ -349,72 +351,93 @@ export const ReceiveFragment = fragment(() => {
style={({ pressed }) => ([
{ opacity: pressed ? 0.5 : 1 },
{
flexDirection: 'row',
alignItems: 'center',
backgroundColor: theme.surfaceOnElevation,
gap: 8
}
])}
onPress={navigateToAssets}
>
<View style={{
height: 46, width: 46,
justifyContent: 'center', alignItems: 'center',
}}>
{!!icon ? (
<WImage
src={icon}
width={46}
height={46}
borderRadius={23}
lockLoading
/>
) : (
<Image
source={require('@assets/ic-ton-acc.png')}
style={{ height: 46, width: 46 }}
/>
)}
{verifIcon}
</View>
<View style={{ justifyContent: 'space-between', flexShrink: 1 }}>
<Text
style={[
{ color: theme.textPrimary, flexShrink: 1 },
Typography.semiBold17_24
]}
numberOfLines={1}
>
{`${name ?? `TON ${t('common.wallet')}`}`}
{isSCAM && (
<>
{' • '}
<Text style={{ color: theme.accentRed }}>
{'SCAM'}
</Text>
</>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 8 }}>
<View style={{
height: 46, width: 46,
justifyContent: 'center', alignItems: 'center',
}}>
{!!icon ? (
<WImage
src={icon}
width={46}
height={46}
borderRadius={23}
lockLoading
/>
) : (
<Image
source={require('@assets/ic-ton-acc.png')}
style={{ height: 46, width: 46 }}
/>
)}
</Text>
<Text
style={[{ color: theme.textSecondary }, Typography.regular15_20]}
selectable={false}
ellipsizeMode={'middle'}
>
<AddressComponent
address={friendly}
start={6}
end={6}
bounceable={bounceableFormat}
known={isHolders}
testOnly={network.isTestnet}
/>
</Text>
{verifIcon}
</View>
<View style={{ justifyContent: 'space-between', flexShrink: 1 }}>
<Text
style={[
{ color: theme.textPrimary, flexShrink: 1 },
Typography.semiBold17_24
]}
numberOfLines={1}
>
{`${name ?? `TON ${t('common.wallet')}`}`}
{isSCAM && (
<>
{' • '}
<Text style={{ color: theme.accentRed }}>
{'SCAM'}
</Text>
</>
)}
</Text>
<Text
style={[{ color: theme.textSecondary }, Typography.regular15_20]}
selectable={false}
ellipsizeMode={'middle'}
>
<AddressComponent
address={friendly}
start={6}
end={6}
bounceable={bounceableFormat}
known={isHolders}
testOnly={network.isTestnet}
/>
</Text>
</View>
<View style={{ flexGrow: 1 }} />
<Image
source={require('@assets/ic-chevron-right.png')}
style={{ height: 16, width: 16, tintColor: theme.iconPrimary }}
/>
</View>
<View style={{ flexGrow: 1 }} />
<Image
source={require('@assets/ic-chevron-right.png')}
style={{ height: 16, width: 16, tintColor: theme.iconPrimary }}
/>
{holdersCards.length > 0 && (
<ScrollView
horizontal={true}
style={[{ height: 30, marginTop: 4 }, Platform.select({ android: { marginLeft: 78 } })]}
contentContainerStyle={{ gap: 8 }}
contentInset={Platform.select({ ios: { left: 52 } })}
contentOffset={Platform.select({ ios: { x: -52, y: 0 } })}
showsHorizontalScrollIndicator={false}
alwaysBounceHorizontal={true}
>
{holdersCards.map((card, index) => {
return (
<HoldersAccountCard
key={`card-item-${index}`}
card={card as GeneralHoldersCard}
theme={theme}
/>
)
})}
</ScrollView>
)}
</Pressable>
<ItemDivider marginHorizontal={0} />
<View style={{ flexDirection: 'row', gap: 4, justifyContent: 'space-evenly' }}>
Expand Down
12 changes: 12 additions & 0 deletions app/utils/holders/hasDirectDeposit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { GeneralHoldersAccount } from "../../engine/api/holders/fetchAccounts";

export const CONTRACTS_DEPOSIT_BY_DETAILS = [
'ton.card.v7',
'ton.card.v8',
'ton.jetton.v3'
];

export function hasDirectDeposit(account: GeneralHoldersAccount) {
const contract = account.contract;
return CONTRACTS_DEPOSIT_BY_DETAILS.includes(contract);
}
4 changes: 2 additions & 2 deletions ios/wallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>2.4.7</string>
<string>2.4.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -42,7 +42,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>225</string>
<string>226</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallet",
"version": "2.4.7",
"version": "2.4.8",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
Expand Down

0 comments on commit 22cdbda

Please sign in to comment.