Skip to content

Commit

Permalink
Merge pull request #804 from tonkeeper/release/4.3.0
Browse files Browse the repository at this point in the history
Release 4.3.0
  • Loading branch information
sorokin0andrey authored Apr 25, 2024
2 parents e32fb15 + eb7d0f9 commit a65aa45
Show file tree
Hide file tree
Showing 206 changed files with 5,718 additions and 3,993 deletions.
10 changes: 10 additions & 0 deletions packages/@core-js/src/BatteryAPI/BatteryGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export interface Status {
}

export interface Config {
/**
* with zero balance it is possible to transfer some jettons (stablecoins, jusdt, etc) to this address to refill the balance. Such transfers would be paid by Battery Service.
* @example "0:07331e629e39d006d86a8cc7659c10a97c671f7535dc8b7f251a1a944dda348e"
*/
fund_receiver: string;
/**
* when building a message to transfer an NFT or Jetton, use this address to send excess funds back to Battery Service.
* @example "0:da6b1b6663a0e4d18cc8574ccd9db5296e367dd9324706f3bbd9eb1cd2caf0bf"
Expand All @@ -31,6 +36,11 @@ export interface Config {
export interface Balance {
/** @example "10.250" */
balance: string;
/**
* reserved amount in units (TON/USD)
* @example "0.3"
*/
reserved: string;
/** @example "usd" */
units: BalanceUnitsEnum;
}
Expand Down
1 change: 1 addition & 0 deletions packages/@core-js/src/service/contractService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import nacl from 'tweetnacl';
export enum OpCodes {
JETTON_TRANSFER = 0xf8a7ea5,
NFT_TRANSFER = 0x5fcc3d14,
STONFI_SWAP = 0x25938561,
}

export enum WalletVersion {
Expand Down
23 changes: 21 additions & 2 deletions packages/@core-js/src/service/transactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function tonAddress(address: AnyAddress) {
}

export class TransactionService {
private static TTL = 5 * 60;
public static TTL = 5 * 60;

private static getTimeout() {
return Math.floor(Date.now() / 1e3) + TransactionService.TTL;
Expand Down Expand Up @@ -104,6 +104,21 @@ export class TransactionService {
let builder = beginCell();

switch (opCode) {
case OpCodes.STONFI_SWAP:
builder = builder
.storeUint(OpCodes.STONFI_SWAP, 32)
.storeAddress(slice.loadAddress())
.storeCoins(slice.loadCoins())
.storeAddress(slice.loadAddress());

if (slice.loadBoolean()) {
slice.loadAddress();
}

return builder
.storeBit(1)
.storeAddress(Address.parse(customExcessesAccount))
.endCell();
case OpCodes.NFT_TRANSFER:
builder = builder
.storeUint(OpCodes.NFT_TRANSFER, 32)
Expand All @@ -130,7 +145,11 @@ export class TransactionService {
slice.loadMaybeAddress();

while (slice.remainingRefs) {
builder = builder.storeRef(slice.loadRef());
const forwardCell = slice.loadRef();
// recursively rebuild forward payloads
builder = builder.storeRef(
this.rebuildBodyWithCustomExcessesAccount(forwardCell, customExcessesAccount),
);
}

return builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export type AmountFormatOptions = {
ignoreZeroTruncate?: boolean;
absolute?: boolean;
withPositivePrefix?: boolean;
// Truncate decimals. Required for backward compatibility
forceRespectDecimalPlaces?: boolean;
};

export type AmountFormatNanoOptions = AmountFormatOptions & {
Expand Down Expand Up @@ -144,7 +146,10 @@ export class AmountFormatter {
};

// truncate decimals 1.00 -> 1
if (!options.ignoreZeroTruncate && bn.isLessThan('1000')) {
if (
options.forceRespectDecimalPlaces ||
(!options.ignoreZeroTruncate && bn.isLessThan('1000'))
) {
bn = bn.decimalPlaces(decimals, BigNumber.ROUND_DOWN);
return bn.toFormat(formatConf);
}
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.2.0"
versionName "4.3.0"
missingDimensionStrategy 'react-native-camera', 'general'
missingDimensionStrategy 'store', 'play'
}
Expand Down
6 changes: 3 additions & 3 deletions packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@
outputFileListPaths = (
);
outputPaths = (
$SRCROOT/$PROJECT_NAME/Resources/Generated/R.generated.swift,
"$SRCROOT/$PROJECT_NAME/Resources/Generated/R.generated.swift",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -1298,7 +1298,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.2.0;
MARKETING_VERSION = 4.3.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1332,7 +1332,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.2.0;
MARKETING_VERSION = 4.3.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
29 changes: 23 additions & 6 deletions packages/mobile/src/blockchain/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ import {

import { tk } from '$wallet';
import { Address, Cell, internal } from '@ton/core';
import { emulateBoc, sendBoc } from '@tonkeeper/shared/utils/blockchain';
import {
NetworkOverloadedError,
emulateBoc,
sendBoc,
} from '@tonkeeper/shared/utils/blockchain';
import { OperationEnum, TonAPI, TypeEnum } from '@tonkeeper/core/src/TonAPI';
import { setBalanceForEmulation } from '@tonkeeper/shared/utils/wallet';
import { WalletNetwork } from '$wallet/WalletTypes';
import { createTonApiInstance } from '$wallet/utils';
import { config } from '$config';
import { toNano } from '$utils';
import { BatterySupportedTransaction } from '$wallet/managers/BatteryManager';
import { compareAddresses } from '$utils/address';

const TonWeb = require('tonweb');

Expand Down Expand Up @@ -324,9 +329,15 @@ export class TonWallet {
private async calcFee(
boc: string,
params?,
withRelayer = true,
withRelayer = false,
forceRelayer = false,
): Promise<[BigNumber, boolean]> {
const { emulateResult, battery } = await emulateBoc(boc, params, withRelayer);
const { emulateResult, battery } = await emulateBoc(
boc,
params,
withRelayer,
forceRelayer,
);
return [new BigNumber(emulateResult.event.extra).multipliedBy(-1), battery];
}

Expand Down Expand Up @@ -423,6 +434,7 @@ export class TonWallet {
tk.wallet.battery.state.data.supportedTransactions[
BatterySupportedTransaction.Jetton
],
compareAddresses(address, tk.wallet.battery.fundReceiver),
);

return [Ton.fromNano(feeNano.toString()), isBattery];
Expand Down Expand Up @@ -469,7 +481,7 @@ export class TonWallet {
}

const excessesAccount = sendWithBattery
? await tk.wallet.battery.getExcessesAccount()
? tk.wallet.battery.excessesAccount
: tk.wallet.address.ton.raw;

const boc = this.createJettonTransfer({
Expand All @@ -493,6 +505,7 @@ export class TonWallet {
tk.wallet.battery.state.data.supportedTransactions[
BatterySupportedTransaction.Jetton
],
compareAddresses(address, tk.wallet.battery.fundReceiver),
);
feeNano = fee;
isBattery = battery;
Expand All @@ -518,6 +531,9 @@ export class TonWallet {
try {
await sendBoc(boc, isBattery);
} catch (e) {
if (e instanceof NetworkOverloadedError) {
throw e;
}
if (!store.getState().main.isTimeSynced) {
throw new Error('wrong_time');
}
Expand Down Expand Up @@ -625,9 +641,7 @@ export class TonWallet {
? AddressFormatter.isBounceable(address)
: false,
});

const [feeNano, isBattery] = await this.calcFee(boc);

return [Ton.fromNano(feeNano.toString()), isBattery];
}

Expand Down Expand Up @@ -730,6 +744,9 @@ export class TonWallet {
try {
await sendBoc(boc, false);
} catch (e) {
if (e instanceof NetworkOverloadedError) {
throw e;
}
if (!store.getState().main.isTimeSynced) {
throw new Error('wrong_time');
}
Expand Down
68 changes: 0 additions & 68 deletions packages/mobile/src/components/ScanQRButton.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/mobile/src/context/WalletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ export const WalletProvider = ({ children }: { children: React.ReactNode }) => {

return unsubscribe;
}, []);

return <WalletContext.Provider value={state}>{children}</WalletContext.Provider>;
};
59 changes: 59 additions & 0 deletions packages/mobile/src/core/Colectibles/Collectibles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { memo, useMemo } from 'react';
import { View } from '$uikit';
import { NFTCardItem } from './NFTCardItem';
import { Steezy } from '$styles';
import { useWindowDimensions } from 'react-native';
import { useApprovedNfts } from '$hooks/useApprovedNfts';
import { Screen } from '@tonkeeper/uikit';
import { t } from '@tonkeeper/shared/i18n';

const mockupCardSize = {
width: 114,
height: 166,
};

const numColumn = 3;
const heightRatio = mockupCardSize.height / mockupCardSize.width;

export const Collectibles = memo(() => {
const nfts = useApprovedNfts();
const dimensions = useWindowDimensions();

const size = useMemo(() => {
const width = (dimensions.width - 48) / numColumn;
const height = width * heightRatio;

return { width, height };
}, [dimensions.width]);

return (
<Screen>
<Screen.LargeHeader title={t('tab_collectibles')} />
<Screen.FlashList
contentContainerStyle={styles.collectiblesContainer.static}
data={nfts.enabled}
numColumns={3}
columnWrapperStyle={styles.columnWrapper.static}
renderItem={({ item }) => (
<View style={size}>
<NFTCardItem item={item} />
</View>
)}
/>
</Screen>
);
});

const styles = Steezy.create({
collectiblesContainer: {
marginHorizontal: 16,
gap: 8,
},
nftElements: {
flexDirection: 'row',
flexWrap: 'wrap',
},
columnWrapper: {
gap: 8,
},
});
Loading

0 comments on commit a65aa45

Please sign in to comment.