Skip to content

Commit

Permalink
Fix duration too short error (#2029)
Browse files Browse the repository at this point in the history
  • Loading branch information
neven-s authored and atn4z7 committed Oct 29, 2024
1 parent a7ba971 commit 29d26fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export const Confirmation = (): JSX.Element | null => {

const { minStartTime, validatedStakingEndTime, validatedStakingDuration } =
useValidateStakingEndTime(stakingEndTime, validatorEndTimeUnix)
const localValidatedStakingEndTime = useMemo(() => {
return new Date(validatedStakingEndTime.getTime())
}, [validatedStakingEndTime])

const { data } = useEarnCalcEstimatedRewards({
amount: deductedStakingAmount,
Expand Down Expand Up @@ -349,7 +352,7 @@ export const Confirmation = (): JSX.Element | null => {
{getReadableDateDuration(validatedStakingEndTime)}
</AvaText.Heading3>
<AvaText.Body1>
{format(validatedStakingEndTime, 'MM/dd/yy H:mm aa')}
{format(localValidatedStakingEndTime, 'MM/dd/yy H:mm aa')}
</AvaText.Body1>
</Row>
</View>
Expand Down
5 changes: 3 additions & 2 deletions packages/core-mobile/app/services/wallet/WalletService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import { Account } from 'store/account/types'
import { RpcMethod } from 'store/rpc/types'
import Logger from 'utils/Logger'
import { UnsignedTx, utils } from '@avalabs/avalanchejs'
import { fromUnixTime, getUnixTime } from 'date-fns'
import { getUnixTime } from 'date-fns'
import { getMinimumStakeEndTime } from 'services/earn/utils'
import { Avax } from 'types/Avax'
import { bnToBigint } from 'utils/bigNumbers/bnToBigint'
import { SeedlessPubKeysStorage } from 'seedless/services/storage/SeedlessPubKeysStorage'
import SeedlessWallet from 'seedless/services/wallet/SeedlessWallet'
import { PChainId } from '@avalabs/glacier-sdk'
import { MessageTypes, TypedData, TypedDataV1 } from '@avalabs/vm-module-types'
import { UTCDate } from '@date-fns/utc'
import { isAvalancheTransactionRequest, isBtcTransactionRequest } from './utils'
import WalletInitializer from './WalletInitializer'
import WalletFactory from './WalletFactory'
Expand Down Expand Up @@ -533,7 +534,7 @@ class WalletService {

const minimalStakeEndDate = getMinimumStakeEndTime(
isDevMode,
fromUnixTime(startDate)
new UTCDate(startDate * 1000)
)

if (endDate < getUnixTime(minimalStakeEndDate)) {
Expand Down

0 comments on commit 29d26fe

Please sign in to comment.