Skip to content

Commit

Permalink
fix(mobile): bunch of fixes for hotfix (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
voloshinskii authored May 17, 2024
1 parent f15325e commit 2d8920f
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 33 deletions.
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 600
versionName "4.5.1"
versionName "4.5.2"
missingDimensionStrategy 'react-native-camera', 'general'
missingDimensionStrategy 'store', 'play'
}
Expand Down
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.5.1;
MARKETING_VERSION = 4.5.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1332,7 +1332,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.5.1;
MARKETING_VERSION = 4.5.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
2 changes: 2 additions & 0 deletions packages/mobile/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type AppConfigVars = {
batteryTestnetHost: string;
batteryMeanFees: string;
batteryReservedAmount: string;
batteryMaxInputAmount: string;
batteryMeanPrice_swap: string;
batteryMeanPrice_jetton: string;
batteryMeanPrice_nft: string;
Expand Down Expand Up @@ -108,6 +109,7 @@ const defaultConfig: Partial<AppConfigVars> = {
batteryTestnetHost: 'https://testnet-battery.tonkeeper.com',
batteryMeanFees: '0.0055',
batteryReservedAmount: '0.3',
batteryMaxInputAmount: '3',
batteryMeanPrice_swap: '0.22',
batteryMeanPrice_jetton: '0.06',
batteryMeanPrice_nft: '0.03',
Expand Down
13 changes: 13 additions & 0 deletions packages/mobile/src/core/BatterySend/BatterySend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Screen,
Spacer,
Steezy,
Toast,
TouchableOpacity,
View,
} from '@tonkeeper/uikit';
Expand Down Expand Up @@ -118,6 +119,18 @@ export const BatterySend: React.FC<BatterySendProps> = ({ route }) => {
Keyboard.dismiss();
const parsedAmount = parseLocaleNumber(amount.value);

if (BigNumber(parsedAmount).isGreaterThan(rechargeMethod.maxInputAmount)) {
return Toast.fail(
t('battery.max_input_amount', {
amount: formatter.format(rechargeMethod.maxInputAmount, {
decimals: 0,
currency: rechargeMethod.symbol,
forceRespectDecimalPlaces: true,
}),
}),
);
}

const commentCell = beginCell()
.storeUint(0, 32)
.storeStringTail(recipient?.address ?? '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IRechargeMethod extends RechargeMethod {
fromTon: (amount: number | string) => number;
isTon: boolean;
minInputAmount: string;
maxInputAmount: string;
iconSource: ImageProps['source'];
balance: string;
isGreaterThanBalance: (amount: string) => () => void;
Expand Down Expand Up @@ -70,6 +71,7 @@ export function useRechargeMethod(rechargeMethod: RechargeMethod): IRechargeMeth
);

const minInputAmount = fromTon(config.get('batteryReservedAmount')).toString();
const maxInputAmount = fromTon(config.get('batteryMaxInputAmount')).toString();

return useMemo(
() => ({
Expand All @@ -78,6 +80,7 @@ export function useRechargeMethod(rechargeMethod: RechargeMethod): IRechargeMeth
fromTon,
isTon,
minInputAmount,
maxInputAmount,
iconSource,
balance,
isGreaterThanBalance,
Expand All @@ -88,6 +91,7 @@ export function useRechargeMethod(rechargeMethod: RechargeMethod): IRechargeMeth
fromTon,
isTon,
minInputAmount,
maxInputAmount,
iconSource,
balance,
isGreaterThanBalance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { debugLog } from '$utils/debugLog';
import { t } from '@tonkeeper/shared/i18n';
import { Toast } from '$store';
import {
Icon,
isAndroid,
List,
ListItemContent,
Modal,
Spacer,
Steezy,
Text,
TouchableOpacity,
View,
WalletIcon,
isAndroid,
Icon,
ListItemContent,
TouchableOpacity,
} from '@tonkeeper/uikit';
import { push } from '$navigation/imperative';
import { SheetActions, useNavigation } from '@tonkeeper/router';
Expand All @@ -27,7 +27,7 @@ import {
import { TonConnectRemoteBridge } from '$tonconnect/TonConnectRemoteBridge';
import { formatter } from '$utils/formatter';
import { tk } from '$wallet';
import { MessageConsequences } from '@tonkeeper/core/src/TonAPI';
import { ActionStatusEnum, MessageConsequences } from '@tonkeeper/core/src/TonAPI';
import { Address, TransactionService } from '@tonkeeper/core';
import { ActionListItemByType } from '@tonkeeper/shared/components/ActivityList/ActionListItemByType';
import { useGetTokenPrice } from '$hooks/useTokenPrice';
Expand Down Expand Up @@ -235,6 +235,11 @@ export const SignRawModal = memo<SignRawModalProps>((props) => {
}
}, [consequences?.risk.nfts.length, fiatCurrency, totalRiskedAmount]);

const hasFailedSwap = actions.some(
(action) =>
action.status === ActionStatusEnum.Failed && action.type === ActionType.JettonSwap,
);

return (
<Modal>
<Modal.Header
Expand Down Expand Up @@ -306,6 +311,7 @@ export const SignRawModal = memo<SignRawModalProps>((props) => {
</Modal.ScrollView>
<Modal.Footer>
<NFTOperationFooter
disabled={hasFailedSwap}
withSlider={!wallet.isExternal}
onPressConfirm={handleConfirm}
redirectToActivity={redirectToActivity}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const NotCoinVouchers: React.FC = () => {
const nfts = useNftsState((s) =>
Object.values(s.accountNfts).filter(
(nft) =>
!nft.sale &&
nft.collection &&
Address.compare(nft.collection.address, config.get('notcoin_nft_collection')),
),
Expand Down
5 changes: 5 additions & 0 deletions packages/mobile/src/core/Send/hooks/useSuggestedAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Address } from '@tonkeeper/core';
import { tk } from '$wallet';
import { useWallet } from '@tonkeeper/shared/hooks';
import { ActionItem, ActionType } from '$wallet/models/ActivityModel';
import { compareAddresses } from '$utils/address';

export const DOMAIN_ADDRESS_NOT_FOUND = 'DOMAIN_ADDRESS_NOT_FOUND';

Expand Down Expand Up @@ -76,6 +77,10 @@ export const useSuggestedAddresses = () => {

const rawAddress = Address.parse(recipientAddress).toRaw();

if (compareAddresses(tk.wallet.battery.state.data.fundReceiver, rawAddress)) {
return false;
}

if (
hiddenRecentAddresses.some((addr) => Address.compare(addr, rawAddress)) ||
isFavorite
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/src/modals/BurnVouchersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const BurnVouchersModal = memo<BurnVouchersModalProps>((props) => {
const nfts = useNftsState((s) =>
Object.values(s.accountNfts).filter(
(nft) =>
!nft.sale &&
nft.collection &&
Address.parse(nft.collection.address).equals(
Address.parse(config.get('notcoin_nft_collection')),
Expand Down
10 changes: 0 additions & 10 deletions packages/mobile/src/tabs/Wallet/WalletScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import { usePreparedWalletContent } from './content-providers/utils/usePreparedW
import { FinishSetupList } from './components/FinishSetupList';
import { BackupIndicator } from './components/Tabs/BackupIndicator';
import { useExternalState } from '@tonkeeper/shared/hooks/useExternalState';
import { openActivityActionModal } from '@tonkeeper/shared/modals/ActivityActionModal';
import { ActionSource } from '$wallet/models/ActivityModel';

export const WalletScreen = memo(({ navigation }) => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -85,14 +83,6 @@ export const WalletScreen = memo(({ navigation }) => {
return unsubscribe;
}, [nav, navigation]);

useEffect(() => {
if (!isNotCoinReceived && notCoinActionId) {
openActivityActionModal(notCoinActionId, ActionSource.Ton, true);

wallet.activityList.setNotCoinReceived();
}
}, [notCoinActionId, isNotCoinReceived, wallet.activityList]);

const isWatchOnly = wallet && wallet.isWatchOnly;

const ListHeader = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class NotCoinVouchersDependency extends DependencyPrototype<NftsState, Nf
const nfts = Object.values(state.accountNfts).filter(
(nft) =>
nft.collection &&
!nft.sale &&
Address.compare(nft.collection.address, config.get('notcoin_nft_collection')),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/ActivityList/ActionListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const ActionListItem = memo<ActionListItemProps>((props) => {
</Text>
)}
{isFailed && !ignoreFailed && (
<Text type="body2" color="accentOrange" style={styles.warn.static}>
<Text type="body3" color="accentOrange" style={styles.warn.static}>
{t('transactions.failed')}
</Text>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const PureActionListItem = memo<ActionListItemProps>((props) => {
</Text>
)}
{isFailed && !ignoreFailed && (
<Text type="body2" color="accentOrange" style={styles.warn.static}>
<Text type="body3" color="accentOrange" style={styles.warn.static}>
{t('transactions.failed')}
</Text>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Address, AmountFormatter } from '@tonkeeper/core';
import { ActionStatusEnum } from '@tonkeeper/core/src/TonAPI';
import { formatTransactionTime } from '../../../utils/date';
import { View, StyleSheet } from 'react-native';
import { Text } from '@tonkeeper/uikit';
import { Spacer, Text } from '@tonkeeper/uikit';
import { memo, useMemo } from 'react';
import { t } from '../../../i18n';
import { useHideableFormatter } from '@tonkeeper/mobile/src/core/HideableAmount/useHideableFormatter';
Expand All @@ -16,6 +16,8 @@ export const JettonSwapActionListItem = memo<JettonSwapActionListItemProps>((pro
const { payload } = action;
const { formatNano } = useHideableFormatter();

const isSwapFailed = action.status === ActionStatusEnum.Failed;

const subtitle = payload.user_wallet.name
? payload.user_wallet.name
: Address.parse(payload.user_wallet.address, {
Expand Down Expand Up @@ -73,17 +75,22 @@ export const JettonSwapActionListItem = memo<JettonSwapActionListItemProps>((pro
>
<View style={styles.content}>
<View style={styles.flex}>
{action.status === ActionStatusEnum.Failed && (
<Text type="body2" color="accentOrange">
{t('transactions.failed')}
</Text>
{isSwapFailed && (
<>
<Spacer y={8} />
<Text type="body3" color="accentOrange">
{t('transactions.failed_with_reason.swap_refund_no_liq')}
</Text>
</>
)}
</View>
<View>
<Text style={styles.timeText} type="body2" color="textSecondary">
{formatTransactionTime(new Date(action.event.timestamp * 1000))}
</Text>
</View>
{!isSwapFailed && (
<View>
<Text style={styles.timeText} type="body2" color="textSecondary">
{formatTransactionTime(new Date(action.event.timestamp * 1000))}
</Text>
</View>
)}
</View>
</ActionListItem>
);
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/i18n/locales/tonkeeper/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"auth_failed": "Authentication failed",
"balances_setup_wallet": "Set up wallet",
"battery": {
"max_input_amount": "Max input amount is %{amount}",
"send_widget": {
"battery": "Battery"
},
Expand Down Expand Up @@ -946,6 +947,9 @@
"contract_deploy": "Contract Deploy",
"deposit": "Stake",
"failed": "Failed",
"failed_with_reason": {
"swap_refund_no_liq": "Failed. Increase the slippage tolerance in the swap settings to avoid this error."
},
"nft_purchase": "NFT Purchase",
"smartcontract_exec": "Call contract",
"spam": "Spam",
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/i18n/locales/tonkeeper/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,9 @@
"contract_deploy": "Создание контракта",
"deposit": "Депозит",
"failed": "Неуспешно",
"failed_with_reason": {
"swap_refund_no_liq": "Неуспешно. Увеличьте допустимый процент изменения цены (Slippage) в настройках обмена, чтобы избежать подобных ошибок."
},
"nft_purchase": "Покупка NFT",
"smartcontract_exec": "Вызов контракта",
"spam": "Спам",
Expand Down Expand Up @@ -1072,6 +1075,7 @@
"region_nokyc": "Нейтральные воды",
"nokyc": "без KYC",
"battery": {
"max_input_amount": "Максимальная сумма: %{amount}",
"send_widget": {
"battery": "Батарейка"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ActionItem,
ActionType,
} from '@tonkeeper/mobile/src/wallet/models/ActivityModel';
import { ActionStatusEnum } from '@tonkeeper/core/src/TonAPI';

interface JettonSwapActionContentProps {
action: ActionItem<ActionType.JettonSwap>;
Expand Down Expand Up @@ -115,6 +116,10 @@ export const JettonSwapActionContent = memo<JettonSwapActionContentProps>((props

return (
<ActionModalContent
failReason={
action.status === ActionStatusEnum.Failed &&
t('transactions.failed_with_reason.swap_refund_no_liq')
}
label={t('activityActionModal.swapped')}
amountFiat={amountInFiat}
action={action}
Expand Down
Loading

0 comments on commit 2d8920f

Please sign in to comment.