Skip to content

Commit

Permalink
Merge pull request #593 from tonkeeper/release/3.4.1
Browse files Browse the repository at this point in the history
Release 3.4.1
  • Loading branch information
sorokin0andrey authored Oct 9, 2023
2 parents 7bab6bb + b9b1899 commit af37c5e
Show file tree
Hide file tree
Showing 96 changed files with 1,769 additions and 1,004 deletions.
9 changes: 8 additions & 1 deletion packages/@core-js/src/Tonkeeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export class Tonkeeper {

// TODO: for temp, rewrite it when ton wallet will it be moved here;
// init() must be called when app starts
public async init(address: string, isTestnet: boolean, tronAddress: string) {
public async init(
address: string,
isTestnet: boolean,
tronAddress: string,
// TODO: remove after transition to UQ address format
bounceable = true,
) {
try {
this.destroy();
if (address) {
Expand All @@ -75,6 +81,7 @@ export class Tonkeeper {
network: isTestnet ? WalletNetwork.testnet : WalletNetwork.mainnet,
tronAddress: tronAddress,
address: address,
bounceable,
},
);

Expand Down
4 changes: 3 additions & 1 deletion packages/@core-js/src/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export class Wallet {
network: walletInfo.network,
};

const tonAddresses = Address.parse(walletInfo.address).toAll({
const tonAddresses = Address.parse(walletInfo.address, {
bounceable: walletInfo.bounceable,
}).toAll({
testOnly: walletInfo.network === WalletNetwork.testnet,
});

Expand Down
20 changes: 9 additions & 11 deletions packages/@core-js/src/formatters/Address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Address {
private address: AddressType;

constructor(source: string, formatOptions: Partial<DefaultFormatOptions> = {}) {
this.formatOptions = Object.assign(defaultFormatOptions, formatOptions);
this.formatOptions = { ...defaultFormatOptions, ...formatOptions };
this.address = new TonWeb.Address(source);
}

Expand Down Expand Up @@ -137,14 +137,12 @@ export class Address {
}

private mergeOptions(options: FormatOptions = {}): Required<FormatOptions> {
return Object.assign(
{
bounceable: this.getFormatOption(this.formatOptions.bounceable),
testOnly: this.getFormatOption(this.formatOptions.testOnly),
urlSafe: this.getFormatOption(this.formatOptions.urlSafe),
},
options,
);
return {
bounceable: this.getFormatOption(this.formatOptions.bounceable),
testOnly: this.getFormatOption(this.formatOptions.testOnly),
urlSafe: this.getFormatOption(this.formatOptions.urlSafe),
...options,
};
}

private getFormatOption(option: (() => boolean) | boolean) {
Expand All @@ -160,8 +158,8 @@ export class Address {
export class AddressFormatter {
constructor(private options?: Partial<DefaultFormatOptions>) {} // Save and redirect to Address class

public parse(source: string) {
return Address.parse(source, this.options);
public parse(source: string, options?: Partial<DefaultFormatOptions>) {
return Address.parse(source, { ...this.options, ...options });
}

public fromPubkey = Address.fromPubkey;
Expand Down
31 changes: 31 additions & 0 deletions packages/@core-js/src/formatters/DNS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// list of know for client TLDs for TON DNS
export enum KnownTLDs {
TON = 'ton',
TELEGRAM = 't.me',
}

export class DNS {
// get known TLD from domain. Uses for TLD-specific features like Telegram buttons in UI
static getTLD(domain: string) {
if (!DNS.isValid(domain)) {
return null;
}

if (domain.endsWith(KnownTLDs.TON)) {
return KnownTLDs.TON;
}

if (domain.endsWith(KnownTLDs.TELEGRAM)) {
return KnownTLDs.TELEGRAM;
}

return null;
}

static isValid(domain?: string) {
if (!domain) {
return false;
}
return domain.includes('.');
}
}
1 change: 1 addition & 0 deletions packages/@core-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { TonAPI, useTonAPI, TonAPIProvider } from './TonAPI';
export * from './formatters/Address';
export * from './formatters/DNS';

export * from './utils/AmountFormatter/FiatCurrencyConfig';
export * from './utils/AmountFormatter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class ActivityModel {
payload,
amount,
source,
initialActionType: ActionType[event.actions[event.actions.length - 1].type],
event,
type,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface ActionItem<T extends ActionType = ActionType> {
isLast?: boolean;
event: ActionEvent;
source: ActionSource;
initialActionType: ActionType;
amount?: ActionAmount | null;
status: ActionStatusEnum;
destination: ActionDestination;
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ android {
applicationId "com.ton_keeper"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 378
versionName "3.4"
versionCode 382
versionName "3.4.1"
missingDimensionStrategy 'react-native-camera', 'general'
}

Expand Down
6 changes: 1 addition & 5 deletions packages/mobile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ async function handleDappMessage(remoteMessage) {
if (remoteMessage.notification?.body) {
return null;
}
if (
!['bridge_dapp_notification', 'console_dapp_notification'].includes(
remoteMessage.data?.type,
)
) {
if (!['console_dapp_notification'].includes(remoteMessage.data?.type)) {
return null;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = ton_keeper/ton_keeper.entitlements;
CURRENT_PROJECT_VERSION = 378;
CURRENT_PROJECT_VERSION = 382;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = CT523DK2KC;
ENABLE_BITCODE = NO;
Expand All @@ -1244,7 +1244,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.4;
MARKETING_VERSION = 3.4.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1269,7 +1269,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = ton_keeper/ton_keeper.entitlements;
CURRENT_PROJECT_VERSION = 378;
CURRENT_PROJECT_VERSION = 382;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = CT523DK2KC;
INFOPLIST_FILE = ton_keeper/SupportingFiles/Info.plist;
Expand All @@ -1278,7 +1278,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.4;
MARKETING_VERSION = 3.4.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
8 changes: 2 additions & 6 deletions packages/mobile/src/blockchain/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,8 @@ export class TonWallet {
if (new BigNumber(balances[0]).minus(amount).isLessThan(-balances[1])) {
throw new Error(t('send_insufficient_funds'));
}
} else {
if (
new BigNumber(amountNano)
.plus(sendMode === 128 ? 0 : feeNano)
.isGreaterThan(fromInfo.balance)
) {
} else if (sendMode !== 128) {
if (new BigNumber(amountNano).plus(feeNano).isGreaterThan(fromInfo.balance)) {
throw new Error(t('send_insufficient_funds'));
}
}
Expand Down
150 changes: 150 additions & 0 deletions packages/mobile/src/core/AddressUpdateInfo/AddressUpdateInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { copyText } from '$hooks/useCopyText';
import { Spacer } from '$uikit';
import { Address } from '@tonkeeper/core';
import { t } from '@tonkeeper/shared/i18n';
import { tk } from '@tonkeeper/shared/tonkeeper';
import { Pressable, Screen, Steezy, Text, View } from '@tonkeeper/uikit';
import { DarkTheme } from '@tonkeeper/uikit/src/styles/themes/dark';
import React, { FC } from 'react';
import { Platform } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';

const fontFamily = Platform.select({
ios: 'SFMono-Medium',
android: 'RobotoMono-Medium',
});

const splitAddress = (address: string) => {
return {
start: address.substring(0, 2),
middle: address.substring(2, address.length - 4),
end: address.substring(address.length - 4, address.length),
};
};

export const AddressUpdateInfo: FC = () => {
const oldAddress = Address.parse(tk.wallet.address.ton.raw).toFriendly({
bounceable: true,
});
const newAddress = Address.parse(tk.wallet.address.ton.raw).toFriendly({
bounceable: false,
});
const oldStyle = splitAddress(oldAddress);
const newStyle = splitAddress(newAddress);

return (
<Screen>
<Screen.Header title={t('address_update.title')} />
<Screen.ScrollView>
<View style={styles.content}>
<Text type="body2" color="textSecondary">
{t('address_update.post_top')}
</Text>
<Spacer y={16} />
<View style={styles.labelContainer}>
<Text type="label1">{t('address_update.your_wallet')}</Text>
</View>
<Pressable
underlayColor={DarkTheme.backgroundContentTint}
backgroundColor={DarkTheme.fieldBackground}
style={styles.addressContainer}
onPress={() => copyText(oldAddress)}
>
<Text type="body3" color="textSecondary">
{t('address_update.old_style')}
</Text>
<Text numberOfLines={1} ellipsizeMode="middle" style={{ fontFamily }}>
<Text color="textAccent" style={{ fontFamily }}>
{oldStyle.start}
</Text>
{oldStyle.middle}
<Text color="textAccent" style={{ fontFamily }}>
{oldStyle.end}
</Text>
</Text>
</Pressable>
<Spacer y={16} />
<Pressable
underlayColor={DarkTheme.backgroundContentTint}
backgroundColor={DarkTheme.fieldBackground}
style={styles.addressContainer}
onPress={() => copyText(newAddress)}
>
<Text type="body3" color="textSecondary">
{t('address_update.new_style')}
</Text>
<Text numberOfLines={1} ellipsizeMode="middle" style={{ fontFamily }}>
<Text color="textAccent" style={{ fontFamily }}>
{newStyle.start}
</Text>
{newStyle.middle}
<Text color="textAccent" style={{ fontFamily }}>
{newStyle.end}
</Text>
</Text>
</Pressable>
<Spacer y={16} />
<View style={styles.labelContainer}>
<Text type="label1">{t('address_update.why_change')}</Text>
</View>
<Text type="body2" color="textSecondary">
{t('address_update.post_rest')}
</Text>
<View style={styles.option}>
<View style={styles.optionNum}>
<Text type="body2" color="textSecondary">
{'1. '}
</Text>
</View>
<Text type="body2" color="textSecondary">
{t('address_update.first_option')}
</Text>
</View>
<View style={styles.option}>
<View style={styles.optionNum}>
<Text type="body2" color="textSecondary">
{'2. '}
</Text>
</View>
<Text type="body2" color="textSecondary">
{t('address_update.second_option')}
</Text>
</View>
<Text type="body2" color="textSecondary">
{t('address_update.post_dates')}
</Text>
</View>
<SafeAreaView edges={['bottom']} />
</Screen.ScrollView>
</Screen>
);
};

const styles = Steezy.create(({ colors, corners }) => ({
container: {
flex: 1,
},
content: {
paddingTop: 12,
paddingBottom: 16,
paddingHorizontal: 16,
},
labelContainer: {
paddingVertical: 12,
},
option: {
paddingLeft: 22,
position: 'relative',
},
optionNum: {
position: 'absolute',
top: 0,
left: 5,
},
addressContainer: {
paddingHorizontal: 16,
paddingVertical: 12,
backgroundColor: colors.fieldBackground,
borderRadius: corners.medium,
},
}));
Loading

0 comments on commit af37c5e

Please sign in to comment.