Skip to content

Commit

Permalink
Merge branch 'develop' into feature/battery-topup
Browse files Browse the repository at this point in the history
  • Loading branch information
voloshinskii authored May 13, 2024
2 parents a9a6801 + 484bb5a commit f391f0a
Show file tree
Hide file tree
Showing 126 changed files with 4,157 additions and 2,071 deletions.
6 changes: 3 additions & 3 deletions packages/@core-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"@aws-crypto/sha256-js": "^3.0.0",
"@ethersproject/shims": "^5.7.0",
"@noble/ed25519": "1.7.3",
"@ton/core": "^0.53.0",
"@ton/crypto": "^3.2.0",
"@ton/ton": "^13.9.0",
"@ton/core": "0.54.0",
"@ton/crypto": "3.2.0",
"@ton/ton": "https://github.com/tonkeeper/tonkeeper-ton#build9",
"aes-js": "3.1.2",
"bignumber.js": "^9.1.1",
"ethers": "^6.7.1",
Expand Down
13 changes: 13 additions & 0 deletions packages/@core-js/src/legacy/contracts/LockupContractV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SendMode,
} from '@ton/core';
import { Maybe } from '@ton/ton/dist/utils/maybe';
import { ExternallySingedAuthWallet3SendArgs } from '@ton/ton/dist/wallets/WalletContractV3';
import { createWalletTransferV3 } from '@ton/ton/dist/wallets/signing/createWalletTransfer';

export interface LockupContractV1AdditionalParams {
Expand Down Expand Up @@ -150,6 +151,18 @@ export class LockupContractV1 implements Contract {
});
}

createTransferAndSignRequestAsync(args: ExternallySingedAuthWallet3SendArgs) {
let sendMode = SendMode.PAY_GAS_SEPARATELY;
if (args.sendMode !== null && args.sendMode !== undefined) {
sendMode = args.sendMode;
}
return createWalletTransferV3({
...args,
sendMode,
walletId: this.walletId,
});
}

/**
* Create sender
*/
Expand Down
23 changes: 23 additions & 0 deletions packages/@core-js/src/legacy/contracts/WalletContractV4R1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import {
SendMode,
} from '@ton/core';
import { Maybe } from '@ton/ton/dist/utils/maybe';
import {
ExternallySingedAuthWallet4SendArgs,
SingedAuthWallet4SendArgs,
} from '@ton/ton/dist/wallets/WalletContractV4';
import { createWalletTransferV4 } from '@ton/ton/dist/wallets/signing/createWalletTransfer';
import {
ExternallySingedAuthSendArgs,
SingedAuthSendArgs,
} from '@ton/ton/dist/wallets/signing/singer';

export class WalletContractV4R1 implements Contract {
static create(args: {
Expand Down Expand Up @@ -123,6 +131,21 @@ export class WalletContractV4R1 implements Contract {
});
}

/**
* Create signed transfer
*/
createTransferAndSignRequestAsync(args: ExternallySingedAuthWallet4SendArgs) {
let sendMode = SendMode.PAY_GAS_SEPARATELY;
if (args.sendMode !== null && args.sendMode !== undefined) {
sendMode = args.sendMode;
}
return createWalletTransferV4({
...args,
walletId: this.walletId,
sendMode,
});
}

/**
* Create sender
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/@core-js/src/service/contractService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
import { WalletContractV3R1, WalletContractV3R2, WalletContractV4 } from '@ton/ton';
import nacl from 'tweetnacl';

export type Signer = (message: Cell) => Promise<Buffer>;

export enum OpCodes {
JETTON_TRANSFER = 0xf8a7ea5,
NFT_TRANSFER = 0x5fcc3d14,
Expand Down
20 changes: 12 additions & 8 deletions packages/@core-js/src/service/transactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
loadStateInit,
} from '@ton/core';
import { Address as AddressFormatter } from '../formatters/Address';
import { OpCodes, WalletContract } from './contractService';
import { OpCodes, Signer, WalletContract } from './contractService';
import { SignRawMessage } from '@tonkeeper/mobile/src/core/ModalContainer/NFTOperations/TxRequest.types';

export type AnyAddress = string | Address | AddressFormatter;

export interface TransferParams {
seqno: number;
timeout?: number;
sendMode?: number;
secretKey: Buffer;
messages: MessageRelaxed[];
}

Expand All @@ -35,11 +35,11 @@ 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;
}

private static externalMessage(contract: WalletContract, seqno: number, body: Cell) {
public static externalMessage(contract: WalletContract, seqno: number, body: Cell) {
return beginCell()
.storeWritable(
storeMessage(
Expand Down Expand Up @@ -161,11 +161,15 @@ export class TransactionService {
}
}

static createTransfer(contract, transferParams: TransferParams) {
const transfer = contract.createTransfer({
timeout: TransactionService.getTimeout(),
static async createTransfer(
contract: WalletContract,
signer: Signer,
transferParams: TransferParams,
) {
const transfer = await contract.createTransferAndSignRequestAsync({
timeout: transferParams.timeout ?? TransactionService.getTimeout(),
seqno: transferParams.seqno,
secretKey: transferParams.secretKey,
signer,
sendMode:
transferParams.sendMode ?? SendMode.PAY_GAS_SEPARATELY + SendMode.IGNORE_ERRORS,
messages: transferParams.messages,
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
24 changes: 24 additions & 0 deletions packages/mobile/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.NFC" />

<!-- Bluetooth permissions for SDK API 30+ -->
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Bluetooth permissions for SDK API 18-30 -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="replace" />

<!-- Bluetooth permissions for SDK API 23-30 -->
<uses-permission-sdk-23
android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="remove" />

<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />

<!-- TODO: review deprecated permissions -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

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
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
2 changes: 2 additions & 0 deletions packages/mobile/ios/ton_keeper/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
</dict>
</dict>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Tonkeeper uses bluetooth to connect your hardware Ledger Nano X</string>
<key>NSCameraUsageDescription</key>
<string>Tonkeeper uses camera to scan QR codes</string>
<key>NSFaceIDUsageDescription</key>
Expand Down
9 changes: 7 additions & 2 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"@craftzdog/react-native-buffer": "^6.0.5",
"@expo/react-native-action-sheet": "^4.0.1",
"@gorhom/bottom-sheet": "^4.6.0",
"@ledgerhq/hw-transport": "^6.30.6",
"@ledgerhq/react-native-hw-transport-ble": "^6.32.5",
"@rainbow-me/animated-charts": "https://github.com/tonkeeper/react-native-animated-charts#737b1633c41e13da437c8e111c4aedd15bd10558",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-community/clipboard": "^1.5.1",
Expand All @@ -42,8 +44,9 @@
"@react-native-firebase/messaging": "18.5.0",
"@reduxjs/toolkit": "^1.6.1",
"@shopify/flash-list": "^1.5.0",
"@ton/core": "^0.53.0",
"@ton/ton": "^13.9.0",
"@ton-community/ton-ledger": "^7.0.1",
"@ton/core": "0.54.0",
"@ton/ton": "https://github.com/tonkeeper/tonkeeper-ton#build9",
"@tonapps/tonlogin-client": "0.2.5",
"@tonconnect/protocol": "^2.2.5",
"@tonkeeper/core": "0.1.0",
Expand Down Expand Up @@ -88,6 +91,7 @@
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-apk-install": "0.1.0",
"react-native-ble-plx": "2.0.3",
"react-native-camera": "^4.2.1",
"react-native-config": "^1.5.1",
"react-native-console-time-polyfill": "^1.2.3",
Expand Down Expand Up @@ -133,6 +137,7 @@
"react-query": "^3.39.3",
"react-redux": "^7.2.4",
"redux-saga": "^1.1.3",
"rxjs": "^7.8.1",
"stream-browserify": "^3.0.0",
"styled-components": "^5.3.0",
"text-encoding-polyfill": "^0.6.7",
Expand Down
Loading

0 comments on commit f391f0a

Please sign in to comment.