Skip to content

Commit

Permalink
Merge pull request #838 from tonkeeper/release/4.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokin0andrey authored May 12, 2024
2 parents a049f0d + 5cd00b2 commit f532652
Show file tree
Hide file tree
Showing 46 changed files with 291 additions and 488 deletions.
6 changes: 4 additions & 2 deletions packages/@core-js/src/service/transactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import {
import { Address as AddressFormatter } from '../formatters/Address';
import { OpCodes, WalletContract } from './contractService';
import { SignRawMessage } from '@tonkeeper/mobile/src/core/ModalContainer/NFTOperations/TxRequest.types';
import { tk } from '@tonkeeper/mobile/src/wallet';

This comment has been minimized.

Copy link
@mahdibiii

mahdibiii Jun 8, 2024

``


export type AnyAddress = string | Address | AddressFormatter;

export interface TransferParams {
seqno: number;
timeout?: number;
sendMode?: number;
secretKey: Buffer;
messages: MessageRelaxed[];
Expand All @@ -35,7 +37,7 @@ export function tonAddress(address: AnyAddress) {
export class TransactionService {
public static TTL = 5 * 60;

private static getTimeout() {
public static getTimeout() {
return Math.floor(Date.now() / 1e3) + TransactionService.TTL;
}

Expand Down Expand Up @@ -163,7 +165,7 @@ export class TransactionService {

static createTransfer(contract, transferParams: TransferParams) {
const transfer = contract.createTransfer({
timeout: TransactionService.getTimeout(),
timeout: transferParams.timeout ?? TransactionService.getTimeout(),
seqno: transferParams.seqno,
secretKey: transferParams.secretKey,
sendMode:
Expand Down
3 changes: 2 additions & 1 deletion packages/@core-js/src/utils/tonProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nacl from 'tweetnacl';
import naclUtils from 'tweetnacl-util';
const { createHash } = require('react-native-crypto');
import { Address } from '../formatters/Address';
import { getRawTimeFromLiteserverSafely } from '@tonkeeper/shared/utils/blockchain';

export interface TonProofArgs {
address: string;
Expand All @@ -22,7 +23,7 @@ export async function createTonProof({
}: TonProofArgs) {
try {
const address = Address.parse(_addr).toRaw();
const timestamp = Math.floor(Date.now() / 1000);
const timestamp = await getRawTimeFromLiteserverSafely();
const timestampBuffer = new Int64LE(timestamp).toBuffer();

const domainBuffer = Buffer.from(domain);
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 433
versionName "4.4.0"
versionName "4.4.1"
missingDimensionStrategy 'react-native-camera', 'general'
missingDimensionStrategy 'store', 'play'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import java.util.List;

import java.lang.reflect.Field;
import android.database.CursorWindow;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
Expand Down Expand Up @@ -69,6 +72,18 @@ public void onCreate() {
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);

// https://github.com/react-native-async-storage/async-storage/issues/537
try {
Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize");
field.setAccessible(true);
field.set(null, 300 * 1024 * 1024);
} catch (Exception e) {
if (BuildConfig.DEBUG) {
e.printStackTrace();
}
}

}

@Override
Expand Down
5 changes: 5 additions & 0 deletions packages/mobile/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@
<item name="android:textColor">@color/alert_text</item>
<item name="android:textColorPrimary">@color/alert_text</item>
</style>
<style name="Theme.FullScreenDialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
1 change: 1 addition & 0 deletions packages/mobile/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ expo.webp.animated=false

# Enable network inspector
EX_DEV_CLIENT_NETWORK_INSPECTOR=true
AsyncStorage_db_size_in_MB=100
4 changes: 2 additions & 2 deletions packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.4.0;
MARKETING_VERSION = 4.4.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1332,7 +1332,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.4.0;
MARKETING_VERSION = 4.4.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"react-native-sse": "^1.1.0",
"react-native-svg": "^13.10.0",
"react-native-svg-transformer": "^0.14.3",
"react-native-system-navigation-bar": "^2.6.4",
"react-native-tweetnacl": "^1.0.5",
"react-native-url-polyfill": "^2.0.0",
"react-native-video": "^5.2.0",
Expand Down
20 changes: 14 additions & 6 deletions packages/mobile/src/blockchain/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
NetworkOverloadedError,
emulateBoc,
sendBoc,
getTimeoutFromLiteserverSafely,
} from '@tonkeeper/shared/utils/blockchain';
import { OperationEnum, TonAPI, TypeEnum } from '@tonkeeper/core/src/TonAPI';
import { setBalanceForEmulation } from '@tonkeeper/shared/utils/wallet';
Expand All @@ -45,6 +46,7 @@ const TonWeb = require('tonweb');
export const inscriptionTransferAmount = '0.05';

interface JettonTransferParams {
timeout?: number;
seqno: number;
jettonWalletAddress: string;
recipient: Account;
Expand Down Expand Up @@ -358,6 +360,7 @@ export class TonWallet {
}

createJettonTransfer({
timeout,
seqno,
jettonWalletAddress,
recipient,
Expand All @@ -382,6 +385,7 @@ export class TonWallet {
const jettonAmount = BigInt(amountNano);

return TransactionService.createTransfer(contract, {
timeout,
seqno,
secretKey,
messages: [
Expand Down Expand Up @@ -417,7 +421,10 @@ export class TonWallet {
throw new Error(t('send_get_wallet_info_error'));
}

const timeout = await getTimeoutFromLiteserverSafely();

const boc = this.createJettonTransfer({
timeout,
seqno,
jettonWalletAddress,
recipient,
Expand Down Expand Up @@ -484,7 +491,10 @@ export class TonWallet {
? tk.wallet.battery.excessesAccount
: tk.wallet.address.ton.raw;

const timeout = await getTimeoutFromLiteserverSafely();

const boc = this.createJettonTransfer({
timeout,
seqno,
jettonWalletAddress,
recipient,
Expand Down Expand Up @@ -534,9 +544,6 @@ export class TonWallet {
if (e instanceof NetworkOverloadedError) {
throw e;
}
if (!store.getState().main.isTimeSynced) {
throw new Error('wrong_time');
}
throw new Error(t('send_publish_tx_error'));
}

Expand Down Expand Up @@ -568,7 +575,11 @@ export class TonWallet {
allowedDestinations: lockupConfig?.allowed_destinations,
},
);

const timeout = await getTimeoutFromLiteserverSafely();

return TransactionService.createTransfer(contract, {
timeout,
seqno,
secretKey,
sendMode,
Expand Down Expand Up @@ -747,9 +758,6 @@ export class TonWallet {
if (e instanceof NetworkOverloadedError) {
throw e;
}
if (!store.getState().main.isTimeSynced) {
throw new Error('wrong_time');
}
throw new Error(t('send_publish_tx_error'));
}

Expand Down
8 changes: 5 additions & 3 deletions packages/mobile/src/core/DAppBrowser/DAppBrowser.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useDeeplinking } from '$libs/deeplinking';
import { openDAppsSearch } from '$navigation';
import { getCorrectUrl, getSearchQuery, getUrlWithoutTonProxy } from '$utils';
import { getCorrectUrl, getSearchQuery, getUrlWithoutTonProxy, isIOS } from '$utils';
import React, { FC, memo, useCallback, useState } from 'react';
import { Linking, StatusBar, useWindowDimensions } from 'react-native';
import { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
Expand All @@ -16,7 +16,7 @@ import { useDAppBridge } from './hooks/useDAppBridge';
import { useWallet } from '@tonkeeper/shared/hooks';
import { Address } from '@tonkeeper/shared/Address';
import { config } from '$config';
import { Screen, isIOS } from '@tonkeeper/uikit';
import { Screen, isAndroid, useTheme } from '@tonkeeper/uikit';

export interface DAppBrowserProps {
url: string;
Expand Down Expand Up @@ -144,9 +144,11 @@ const DAppBrowserComponent: FC<DAppBrowserProps> = (props) => {
openDAppsSearch(initialQuery, openUrl);
}, [currentUrl, initialUrl, openUrl]);

const theme = useTheme();

return (
<Screen alternateBackground>
{isIOS ? <StatusBar barStyle="dark-content" /> : null}
<StatusBar barStyle={theme.isDark ? 'light-content' : 'dark-content'} />
<BrowserNavBar
title={app?.name || title}
url={currentUrl}
Expand Down
9 changes: 3 additions & 6 deletions packages/mobile/src/core/Jetton/Jetton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React, { useCallback, useMemo } from 'react';
import { JettonProps } from './Jetton.interface';
import * as S from './Jetton.style';
import { IconButton, PopupMenu, PopupMenuItem, Skeleton, SwapIcon, Text } from '$uikit';
import { ns } from '$utils';
import { PopupMenu, PopupMenuItem, Skeleton, Text } from '$uikit';
import { useJetton } from '$hooks/useJetton';
import { useTokenPrice } from '$hooks/useTokenPrice';
import { openDAppBrowser, openSend } from '$navigation';

import { formatter } from '$utils/formatter';
import { useNavigation } from '@tonkeeper/router';
import { useSwapStore } from '$store/zustand/swap';
import { shallow } from 'zustand/shallow';
import { useFlags } from '$utils/flags';
import { HideableAmount } from '$core/HideableAmount/HideableAmount';
import { Events, JettonVerification, SendAnalyticsFrom } from '$store/models';
Expand Down Expand Up @@ -54,12 +51,12 @@ export const Jetton: React.FC<JettonProps> = ({ route }) => {

const isWatchOnly = wallet && wallet.isWatchOnly;
const fiatCurrency = useWalletCurrency();
const shouldShowChart = jettonPrice.fiat !== 0;
const shouldExcludeChartPeriods = config.get('exclude_jetton_chart_periods');

const nav = useNavigation();

const showSwap = useSwapStore((s) => !!s.assets[jetton.jettonAddress], shallow);
const shouldShowChart = jettonPrice.fiat !== 0;
const showSwap = jettonPrice.fiat !== 0;

const handleSend = useCallback(() => {
trackEvent(Events.SendOpen, { from: SendAnalyticsFrom.TokenScreen });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { memo, useEffect, useMemo } from 'react';
import { NFTOperationFooter, useNFTOperationState } from '../NFTOperationFooter';
import { SignRawParams, TxBodyOptions } from '../TXRequest.types';
import { SignRawMessage, SignRawParams, TxBodyOptions } from '../TXRequest.types';
import { useUnlockVault } from '../useUnlockVault';
import { calculateMessageTransferAmount, delay } from '$utils';
import { debugLog } from '$utils/debugLog';
Expand Down Expand Up @@ -54,7 +54,11 @@ import { JettonTransferAction, NftItemTransferAction } from 'tonapi-sdk-js';
import { TokenDetailsParams } from '../../../../components/TokenDetails/TokenDetails';
import { ModalStackRouteNames } from '$navigation';
import { CanceledActionError } from '$core/Send/steps/ConfirmStep/ActionErrors';
import { emulateBoc, sendBoc } from '@tonkeeper/shared/utils/blockchain';
import {
emulateBoc,
getTimeoutFromLiteserverSafely,
sendBoc,
} from '@tonkeeper/shared/utils/blockchain';
import { openAboutRiskAmountModal } from '@tonkeeper/shared/modals/AboutRiskAmountModal';
import { toNano } from '@ton/core';
import BigNumber from 'bignumber.js';
Expand Down Expand Up @@ -115,7 +119,10 @@ export const SignRawModal = memo<SignRawModalProps>((props) => {
vault.workchain,
);

const timeout = await getTimeoutFromLiteserverSafely();

const boc = TransactionService.createTransfer(contract, {
timeout,
messages: TransactionService.parseSignRawMessages(
params.messages,
isBattery ? tk.wallet.battery.excessesAccount : undefined,
Expand Down Expand Up @@ -352,6 +359,10 @@ export const SignRawModal = memo<SignRawModalProps>((props) => {
);
});

function isValidMessage(message: SignRawMessage): boolean {
return Address.isValid(message.address) && new BigNumber(message.amount).gt('0');
}

export const openSignRawModal = async (
params: SignRawParams,
options: TxBodyOptions,
Expand All @@ -370,6 +381,10 @@ export const openSignRawModal = async (
try {
Toast.loading();

if (!params.messages.every((mes) => isValidMessage(mes))) {
throw new Error('Invalid message');
}

if (isTonConnect) {
await TonConnectRemoteBridge.closeOtherTransactions();
}
Expand All @@ -383,7 +398,9 @@ export const openSignRawModal = async (
let consequences: MessageConsequences | null = null;
let isBattery = false;
try {
const timeout = await getTimeoutFromLiteserverSafely();
const boc = TransactionService.createTransfer(contract, {
timeout,
messages: TransactionService.parseSignRawMessages(params.messages),
seqno: await getWalletSeqno(wallet),
secretKey: Buffer.alloc(64),
Expand Down
Loading

0 comments on commit f532652

Please sign in to comment.