diff --git a/packages/@core-js/src/TonAPI/HttpClient.ts b/packages/@core-js/src/TonAPI/HttpClient.ts index 46897857d..08b50db7a 100644 --- a/packages/@core-js/src/TonAPI/HttpClient.ts +++ b/packages/@core-js/src/TonAPI/HttpClient.ts @@ -10,7 +10,7 @@ type CancelToken = Symbol | string | number; export type HttpClientOptions = { baseUrl: string | (() => string); - token?: string | (() => string); + baseHeaders?: { [key: string]: string } | (() => { [key: string]: string }); }; export class HttpClient { @@ -143,10 +143,10 @@ export class HttpClient { typeof this.options.baseUrl === 'function' ? this.options.baseUrl() : this.options.baseUrl; - const token = - typeof this.options.token === 'function' - ? this.options.token() - : this.options.token; + const baseHeaders = + typeof this.options.baseHeaders === 'function' + ? this.options.baseHeaders() + : this.options.baseHeaders; const response = await this.customFetch( `${baseUrl}${path}${queryString ? `?${queryString}` : ''}`, @@ -154,7 +154,7 @@ export class HttpClient { method, headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${token}`, + ...(baseHeaders ?? {}), ...(headers ?? {}), }, signal: cancelToken ? this.createAbortSignal(cancelToken) : null, diff --git a/packages/mobile/android/app/build.gradle b/packages/mobile/android/app/build.gradle index b87b4c528..cb38cb07e 100644 --- a/packages/mobile/android/app/build.gradle +++ b/packages/mobile/android/app/build.gradle @@ -92,7 +92,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 433 - versionName "3.6.1" + versionName "3.6.2" missingDimensionStrategy 'react-native-camera', 'general' missingDimensionStrategy 'store', 'play' } diff --git a/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj b/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj index 0cb37367e..1ed4ffdc8 100644 --- a/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj +++ b/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj @@ -1294,7 +1294,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1328,7 +1328,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/packages/mobile/src/core/AccessConfirmation/AccessConfirmation.tsx b/packages/mobile/src/core/AccessConfirmation/AccessConfirmation.tsx index 5d5dd596f..bd946cfb8 100644 --- a/packages/mobile/src/core/AccessConfirmation/AccessConfirmation.tsx +++ b/packages/mobile/src/core/AccessConfirmation/AccessConfirmation.tsx @@ -160,7 +160,7 @@ export const AccessConfirmation: FC = () => { } } }, - [dispatch, isBiometryFailed, isUnlock, triggerError, wallet], + [dispatch, isBiometryFailed, isUnlock, obtainTonProof, triggerError, wallet], ); const handleBiometry = useCallback(() => { @@ -175,6 +175,9 @@ export const AccessConfirmation: FC = () => { setTimeout(async () => { // Lock screen if (isUnlock) { + const keyPair = await (unlockedVault as any).getKeyPair(); + // createTronAddress(privateKey); + obtainTonProof(keyPair); dispatch(mainActions.setUnlocked(true)); } else { goBack(); @@ -187,7 +190,7 @@ export const AccessConfirmation: FC = () => { setBiometryFailed(true); triggerError(); }); - }, [dispatch, isUnlock, triggerError, wallet]); + }, [dispatch, isUnlock, obtainTonProof, triggerError, wallet]); useEffect(() => { if (params.withoutBiometryOnOpen) { diff --git a/packages/mobile/src/core/ModalContainer/NFTOperations/NFTOperations.ts b/packages/mobile/src/core/ModalContainer/NFTOperations/NFTOperations.ts index c2771dfbf..61d0df223 100644 --- a/packages/mobile/src/core/ModalContainer/NFTOperations/NFTOperations.ts +++ b/packages/mobile/src/core/ModalContainer/NFTOperations/NFTOperations.ts @@ -14,7 +14,6 @@ import { t } from '@tonkeeper/shared/i18n'; import { Ton } from '$libs/Ton'; import { getServerConfig } from '$shared/constants'; import { Configuration, NFTApi } from '@tonkeeper/core/src/legacy'; -import { sendBocWithBattery } from '@tonkeeper/shared/utils/blockchain'; import { tonapi } from '@tonkeeper/shared/tonkeeper'; const { NftItem } = TonWeb.token.nft; @@ -172,7 +171,7 @@ export class NFTOperations { const queryMsg = await methods.getQuery(); const boc = Base64.encodeBytes(await queryMsg.toBoc(false)); - await sendBocWithBattery(boc); + await tonapi.blockchain.sendBlockchainMessage({ boc }, { format: 'text' }); onDone?.(boc); }, diff --git a/packages/mobile/src/core/Settings/Settings.tsx b/packages/mobile/src/core/Settings/Settings.tsx index 6685b93ec..c2189cda5 100644 --- a/packages/mobile/src/core/Settings/Settings.tsx +++ b/packages/mobile/src/core/Settings/Settings.tsx @@ -87,7 +87,7 @@ export const Settings: FC = () => { const shouldShowTokensButton = useShouldShowTokensButton(); const showNotifications = useNotificationsStore(shouldShowNotifications); - const isBatteryVisible = !config.get('disable_battery'); + const isBatteryVisible = !!wallet && !config.get('disable_battery'); const searchEngine = useBrowserStore((state) => state.searchEngine); const setSearchEngine = useBrowserStore((state) => state.actions.setSearchEngine); diff --git a/packages/shared/components/RefillBattery/RefillBattery.tsx b/packages/shared/components/RefillBattery/RefillBattery.tsx index d07959e3b..1a2445bdf 100644 --- a/packages/shared/components/RefillBattery/RefillBattery.tsx +++ b/packages/shared/components/RefillBattery/RefillBattery.tsx @@ -24,6 +24,9 @@ export const RefillBattery = memo(() => { const { balance } = useBatteryBalance(); const batteryState = getBatteryState(balance ?? '0'); const iconName = iconNames[batteryState]; + const availableNumOfTransactionsCount = calculateAvailableNumOfTransactions( + balance ?? '0', + ); const isInAppPurchasesDisabled = config.get('disable_battery_iap_module'); @@ -39,10 +42,14 @@ export const RefillBattery = memo(() => { {t( `battery.description.${ - batteryState === BatteryState.Empty ? 'empty' : 'other' + batteryState === BatteryState.Empty + ? 'empty' + : availableNumOfTransactionsCount + ? 'other' + : 'less_10' }`, { - cnt: calculateAvailableNumOfTransactions(balance ?? '0'), + cnt: availableNumOfTransactionsCount, }, )} @@ -52,11 +59,9 @@ export const RefillBattery = memo(() => { {!isInAppPurchasesDisabled ? : null} - {!isInAppPurchasesDisabled && ( - - {t('battery.packages.disclaimer')} - - )} + + {t('battery.packages.disclaimer')} + ); diff --git a/packages/shared/i18n/locales/tonkeeper/en.json b/packages/shared/i18n/locales/tonkeeper/en.json index 9731bacc1..6ec31979f 100644 --- a/packages/shared/i18n/locales/tonkeeper/en.json +++ b/packages/shared/i18n/locales/tonkeeper/en.json @@ -136,7 +136,8 @@ }, "description": { "empty": "Send tokens and NFTs, pay for staking actions with empty main balance.", - "other": "You have enough charge battery for more than %{cnt} transactions." + "other": "You have enough charge battery for more than %{cnt} transactions.", + "less_10": "You have enough charge battery for less than 10 transactions." }, "promocode": { "button": "Recharge by Promo Code", @@ -148,9 +149,9 @@ "packages": { "title": "{{cnt}} transactions for {{price}}", "subtitle": { - "large": "Large gas fees pack", - "medium": "Medium gas fees pack", - "small": "Small gas fees pack" + "large": "Large pack", + "medium": "Medium pack", + "small": "Small pack" }, "disclaimer": "This is approximate transactions number. Some your transactions may cost more.", "buy": "Buy", diff --git a/packages/shared/i18n/locales/tonkeeper/ru-RU.json b/packages/shared/i18n/locales/tonkeeper/ru-RU.json index 45fca2666..5e21c99c0 100644 --- a/packages/shared/i18n/locales/tonkeeper/ru-RU.json +++ b/packages/shared/i18n/locales/tonkeeper/ru-RU.json @@ -981,6 +981,7 @@ }, "comment" : "Комментарий", "insufficientFunds" : { + "rechargeBattery": "Зарядить батарейку", "rechargeWallet" : "Пополнить кошелёк", "stakingFee" : { "few" : "Для совершения транзакции необходимо %{count} TON. Предполагаемая комиссия в размере %{fee} TON будет удержана, остаток будет возвращён.", @@ -1072,7 +1073,8 @@ }, "description": { "empty": "Отправляйте токены и NFT, взаимодействуйте со стейкингом при нулевом балансе кошелька.", - "other": "У вас достаточно заряда для более чем {{cnt}} транзакций." + "other": "У вас достаточно заряда для более чем {{cnt}} транзакций.", + "less_10": "У вас достаточно заряда для менее чем 10 транзакций." }, "promocode": { "button": "Зарядить с помощью промокода", diff --git a/packages/shared/tonkeeper.ts b/packages/shared/tonkeeper.ts index 7c3270e3f..d81402358 100644 --- a/packages/shared/tonkeeper.ts +++ b/packages/shared/tonkeeper.ts @@ -8,6 +8,7 @@ import { queryClient } from './queryClient'; import { TonAPI } from '@tonkeeper/core'; import { config } from './config'; import { BatteryAPI } from '@tonkeeper/core/src/BatteryAPI'; +import { i18n } from './i18n'; export const sse = new AppServerSentEvents({ baseUrl: () => config.get('tonapiIOEndpoint'), @@ -15,7 +16,9 @@ export const sse = new AppServerSentEvents({ }); export const tonapi = new TonAPI({ - token: () => config.get('tonApiV2Key'), + baseHeaders: () => ({ + Authorization: `Bearer ${config.get('tonApiV2Key')}`, + }), baseUrl: () => { if (tk.wallet?.identity.network === WalletNetwork.testnet) { return config.get('tonapiTestnetHost'); @@ -43,6 +46,9 @@ export const batteryapi = new BatteryAPI({ return config.get('batteryHost'); }, + baseHeaders: { + 'Accept-Language': i18n.locale, + }, }); export const storage = new AppStorage(); diff --git a/packages/shared/utils/battery.ts b/packages/shared/utils/battery.ts index c4f25bf35..69d9ac99b 100644 --- a/packages/shared/utils/battery.ts +++ b/packages/shared/utils/battery.ts @@ -47,5 +47,5 @@ export function calculateAvailableNumOfTransactions(batteryBalance: string) { .div(10) .decimalPlaces(0, BigNumber.ROUND_DOWN) .times(10) - .toString(); + .toNumber(); } diff --git a/packages/uikit/src/components/Input.tsx b/packages/uikit/src/components/Input.tsx index 969fdf384..1febb264d 100644 --- a/packages/uikit/src/components/Input.tsx +++ b/packages/uikit/src/components/Input.tsx @@ -231,11 +231,17 @@ export const Input = forwardRef((props, ref) => { const handlePastePress = useCallback(async () => { try { const str = await Clipboard.getString(); + if (onChangeText) { + onChangeText(str); + } setInputValue(str); } catch {} }, []); const handlePressClear = useCallback(() => { + if (onChangeText) { + onChangeText(''); + } setInputValue(''); }, []);