diff --git a/packages/mobile/android/app/build.gradle b/packages/mobile/android/app/build.gradle index 8af57145e..c94df8b10 100644 --- a/packages/mobile/android/app/build.gradle +++ b/packages/mobile/android/app/build.gradle @@ -92,7 +92,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 433 - versionName "4.1.0" + versionName "4.1.2" missingDimensionStrategy 'react-native-camera', 'general' missingDimensionStrategy 'store', 'play' } diff --git a/packages/mobile/index.js b/packages/mobile/index.js index 6b6d6dad9..d5b3354c7 100644 --- a/packages/mobile/index.js +++ b/packages/mobile/index.js @@ -22,7 +22,6 @@ import crashlytics from '@react-native-firebase/crashlytics'; import messaging from '@react-native-firebase/messaging'; import { withIAPContext } from 'react-native-iap'; import { startApp } from './src/index'; -import { tk } from './src/wallet'; LogBox.ignoreLogs([ 'Non-serializable values were found in the navigation state', @@ -47,15 +46,17 @@ async function handleDappMessage(remoteMessage) { ) { return null; } - + await useNotificationsStore.persist.rehydrate(); if (remoteMessage.data?.type === 'better_stake_option_found') { - tk.wallet.staking.toggleRestakeBanner( - true, - remoteMessage.data.stakingAddressToMigrateFrom, - ); + useNotificationsStore + .getState() + .actions.toggleRestakeBanner( + remoteMessage.data.account, + true, + remoteMessage.data.stakingAddressToMigrateFrom, + ); } - await useNotificationsStore.persist.rehydrate(); useNotificationsStore.getState().actions.addNotification( { ...remoteMessage.data, diff --git a/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj b/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj index 5bffe413f..764467a97 100644 --- a/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj +++ b/packages/mobile/ios/ton_keeper.xcodeproj/project.pbxproj @@ -1294,7 +1294,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.1.0; + MARKETING_VERSION = 4.1.2; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1328,7 +1328,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.1.0; + MARKETING_VERSION = 4.1.2; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/packages/mobile/src/components/RestakeBanner/RestakeBanner.tsx b/packages/mobile/src/components/RestakeBanner/RestakeBanner.tsx index 3ab76b3d2..302f802d7 100644 --- a/packages/mobile/src/components/RestakeBanner/RestakeBanner.tsx +++ b/packages/mobile/src/components/RestakeBanner/RestakeBanner.tsx @@ -26,6 +26,7 @@ import { IconsComposition } from './IconsComposition'; import { useFiatValue } from '$hooks/useFiatValue'; import { CryptoCurrencies } from '$shared/constants'; import { stakingFormatter } from '$utils/formatter'; +import { useNotificationsStore } from '$store'; export interface ExtendedPoolInfo extends PoolInfo { isWithdrawal: boolean; @@ -35,6 +36,7 @@ export interface ExtendedPoolInfo extends PoolInfo { export interface RestakeBannerProps { poolsList: ExtendedPoolInfo[]; migrateFrom: string; + bypassUnstakeStep?: boolean; } export enum RestakeSteps { @@ -52,11 +54,14 @@ export const RestakeBanner = memo((props) => { ) as ExtendedPoolInfo; }, [props.poolsList]); const { handleTopUpPress } = usePoolInfo(tonstakersPool); + const toggleRestakeBanner = useNotificationsStore( + (state) => state.actions.toggleRestakeBanner, + ); const handleCloseRestakeBanner = useCallback(() => { LayoutAnimation.easeInEaseOut(); - tk.wallet.staking.toggleRestakeBanner(false); - }, []); + toggleRestakeBanner(tk.wallet.address.ton.raw, false); + }, [toggleRestakeBanner]); const poolToWithdrawal = useMemo( () => @@ -68,8 +73,6 @@ export const RestakeBanner = memo((props) => { [poolToWithdrawal], ); - const bypassStakeStep = useStakingState((s) => s.bypassStakeStep, []); - const readyWithdraw = useFiatValue( CryptoCurrencies.Ton, stakingFormatter.fromNano(toWithdrawalStakingInfo?.ready_withdraw ?? '0'), @@ -79,13 +82,17 @@ export const RestakeBanner = memo((props) => { const handleWithdrawal = useCallback( (pool: ExtendedPoolInfo, withdrawAll?: boolean) => () => { + if (pool.implementation === PoolImplementationType.Tf) { + nav.push(AppStackRouteNames.StakingSend, { + poolAddress: pool.address, + transactionType: StakingTransactionType.WITHDRAWAL_CONFIRM, + }); + return; + } nav.push(AppStackRouteNames.StakingSend, { amount: withdrawAll && pool.balance, poolAddress: pool.address, - transactionType: - pool.implementation === PoolImplementationType.Tf - ? StakingTransactionType.WITHDRAWAL_CONFIRM - : StakingTransactionType.WITHDRAWAL, + transactionType: StakingTransactionType.WITHDRAWAL, }); }, [nav], @@ -107,7 +114,11 @@ export const RestakeBanner = memo((props) => { return RestakeSteps.DONE; } // Go to last step if pool to withdrawal is empty now (or if balance so small, or step is bypassed) - if (bypassStakeStep || Number(poolToWithdrawal?.balance) < 0.1) { + if ( + props.bypassUnstakeStep || + !poolToWithdrawal?.balance || + Number(poolToWithdrawal?.balance) < 0.1 + ) { return RestakeSteps.STAKE_INTO_TONSTAKERS; } // If user has pending withdrawal, render step with waiting @@ -116,7 +127,7 @@ export const RestakeBanner = memo((props) => { } return RestakeSteps.UNSTAKE; }, [ - bypassStakeStep, + props.bypassUnstakeStep, isWaitingForWithdrawal, poolToWithdrawal?.balance, readyWithdraw.amount, @@ -130,8 +141,8 @@ export const RestakeBanner = memo((props) => { }, [currentStepId, handleCloseRestakeBanner]); const { formattedDuration, isCooldown } = useStakingCycle( - poolToWithdrawal?.cycle_start, - poolToWithdrawal?.cycle_end, + poolToWithdrawal?.cycle_start ?? Date.now(), + poolToWithdrawal?.cycle_end ?? Date.now(), isWaitingForWithdrawal, ); @@ -195,12 +206,14 @@ export const RestakeBanner = memo((props) => { }), })} />, -