Skip to content

Commit 163ee3f

Browse files
merge fix
2 parents 43b5802 + 242b9c2 commit 163ee3f

File tree

14 files changed

+152
-31
lines changed

14 files changed

+152
-31
lines changed

bitrise.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,8 @@ workflows:
965965
- abi: x86_64
966966
- profile: pixel_7_pro
967967
- custom_command_flags: -no-snapshot -noaudio -no-window
968+
- ram_size: 4096
969+
- heap_size: 576
968970
- wait-for-android-emulator@1: {}
969971
- script-runner@0:
970972
title: Appium Android testing

packages/core-mobile/app/contexts/DelegationContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ type TransactionHash = string
1717

1818
export type Delegate = ({
1919
steps,
20+
startDate,
2021
endDate,
2122
nodeId
2223
}: {
2324
steps: Step[]
25+
startDate: Date
2426
endDate: Date
2527
nodeId: string
2628
}) => Promise<TransactionHash>

packages/core-mobile/app/hooks/earn/useDelegation.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const useDelegation = (): {
108108

109109
const delegate: Delegate = useCallback(
110110
// eslint-disable-next-line @typescript-eslint/no-shadow
111-
async ({ steps, endDate, nodeId }) => {
111+
async ({ steps, startDate, endDate, nodeId }) => {
112112
if (activeAccount === undefined) {
113113
throw new Error('No active account')
114114
}
@@ -136,11 +136,19 @@ export const useDelegation = (): {
136136
// otherwise, the transaction will fail with a "Start date must be in future" error
137137
const delegateStartDate = new Date(Date.now() + 1 * 60 * 1000)
138138

139+
// get the difference in milliseconds between the original start date and the fresh start date
140+
const differenceInMilliseconds =
141+
delegateStartDate.getTime() - startDate.getTime()
142+
// add the difference in milliseconds to the original end date, so the duration is the same as the original
143+
const delegateEndDate = new Date(
144+
endDate.getTime() + differenceInMilliseconds
145+
)
146+
139147
txHash = await EarnService.issueAddDelegatorTransaction({
140148
walletId: activeWallet.id,
141149
walletType: activeWallet.type,
142150
activeAccount,
143-
endDate,
151+
endDate: delegateEndDate,
144152
isDevMode: isDeveloperMode,
145153
nodeId,
146154
stakeAmountNanoAvax: step.amount,

packages/core-mobile/app/hooks/earn/useIssueDelegation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ export const useIssueDelegation = ({
1515
}): {
1616
issueDelegation: ({
1717
nodeId,
18+
startDate,
1819
endDate,
1920
recomputeSteps
2021
}: {
2122
nodeId: string
23+
startDate: Date
2224
endDate: Date
2325
recomputeSteps?: boolean
2426
}) => Promise<void>
@@ -28,24 +30,28 @@ export const useIssueDelegation = ({
2830
const mutationFn = useCallback(
2931
async ({
3032
nodeId,
33+
startDate,
3134
endDate,
3235
recomputeSteps = false
3336
}: {
3437
nodeId: string
38+
startDate: Date
3539
endDate: Date
3640
recomputeSteps?: boolean
3741
}) => {
3842
if (recomputeSteps) {
3943
const newSteps = await compute(stakeAmount.toSubUnit())
4044
return delegate({
4145
steps: newSteps,
46+
startDate,
4247
endDate,
4348
nodeId
4449
})
4550
}
4651

4752
return delegate({
4853
steps,
54+
startDate,
4955
endDate,
5056
nodeId
5157
})

packages/core-mobile/app/new/features/portfolio/assets/components/TokenListView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const TokenListView = ({
9191
{tokenNameForDisplay}
9292
</Text>
9393
<MaskedText
94+
testID={`list_token_balance__${index}`}
9495
shouldMask={isPrivacyModeEnabled}
9596
maskWidth={55}
9697
sx={{ lineHeight: 16, flex: 1 }}

packages/core-mobile/app/new/features/portfolio/screens/PortfolioScreen.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { DeFiScreen } from 'features/portfolio/defi/components/DeFiScreen'
3434
import { useAccountPerformanceSummary } from 'features/portfolio/hooks/useAccountPerformanceSummary'
3535
import { useBalanceTotalInCurrencyForAccount } from 'features/portfolio/hooks/useBalanceTotalInCurrencyForAccount'
3636
import { useBalanceTotalPriceChangeForAccount } from 'features/portfolio/hooks/useBalanceTotalPriceChangeForAccount'
37-
import { useIsAccountBalanceAccurate } from 'features/portfolio/hooks/useIsAccountBalanceAccurate'
3837
import { useIsBalanceLoadedForAccount } from 'features/portfolio/hooks/useIsBalanceLoadedForAccount'
3938
import { useSendSelectedToken } from 'features/send/store'
4039
import { useNavigateToSwap } from 'features/swap/hooks/useNavigateToSwap'
@@ -67,6 +66,7 @@ import { selectSelectedCurrency } from 'store/settings/currency'
6766
import { selectIsPrivacyModeEnabled } from 'store/settings/securityPrivacy'
6867
import { selectActiveWallet, selectWallets } from 'store/wallet/slice'
6968
import { useFocusedSelector } from 'utils/performance/useFocusedSelector'
69+
import { useIsAllBalancesInaccurateForAccount } from '../hooks/useIsAllBalancesInaccurateForAccount'
7070
import { useIsLoadingBalancesForAccount } from '../hooks/useIsLoadingBalancesForAccount'
7171
import { useIsRefetchingBalancesForAccount } from '../hooks/useIsRefetchingBalancesForAccount'
7272

@@ -122,21 +122,22 @@ const PortfolioHomeScreen = (): JSX.Element => {
122122
const isBalanceLoaded = useIsBalanceLoadedForAccount(activeAccount)
123123
const isLoadingBalances = useIsLoadingBalancesForAccount(activeAccount)
124124
const isLoading = isRefetchingBalance || !isBalanceLoaded
125+
const allBalancesInaccurate =
126+
useIsAllBalancesInaccurateForAccount(activeAccount)
125127
const activeWallet = useSelector(selectActiveWallet)
126128
const wallets = useSelector(selectWallets)
127129
const walletsCount = Object.keys(wallets).length
128-
const balanceAccurate = useIsAccountBalanceAccurate(activeAccount)
129130
const selectedCurrency = useSelector(selectSelectedCurrency)
130131
const { formatCurrency } = useFormatCurrency()
131132
const formattedBalance = useMemo(() => {
132133
// CP-10570: Balances should never show $0.00
133-
return !balanceAccurate || balanceTotalInCurrency === 0
134+
return allBalancesInaccurate || balanceTotalInCurrency === 0
134135
? UNKNOWN_AMOUNT
135136
: formatCurrency({
136137
amount: balanceTotalInCurrency,
137138
withoutCurrencySuffix: true
138139
})
139-
}, [balanceAccurate, balanceTotalInCurrency, formatCurrency])
140+
}, [allBalancesInaccurate, balanceTotalInCurrency, formatCurrency])
140141

141142
const { percentChange24h, valueChange24h, indicatorStatus } =
142143
useAccountPerformanceSummary(activeAccount)
@@ -317,7 +318,9 @@ const PortfolioHomeScreen = (): JSX.Element => {
317318
: undefined
318319
}
319320
errorMessage={
320-
balanceAccurate ? undefined : 'Unable to load all balances'
321+
allBalancesInaccurate
322+
? 'Unable to load all balances'
323+
: undefined
321324
}
322325
onErrorPress={handleErrorPress}
323326
isLoading={isLoading && balanceTotalInCurrency === 0}
@@ -357,7 +360,7 @@ const PortfolioHomeScreen = (): JSX.Element => {
357360
valueChange24h,
358361
indicatorStatus,
359362
percentChange24h,
360-
balanceAccurate,
363+
allBalancesInaccurate,
361364
handleErrorPress,
362365
isLoading,
363366
balanceTotalInCurrency,

packages/core-mobile/app/new/routes/(signedIn)/(modals)/accountSettings/account.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { BalanceHeader, View } from '@avalabs/k2-alpine'
1+
import { BalanceHeader, showAlert, View } from '@avalabs/k2-alpine'
22
import { ScrollScreen } from 'common/components/ScrollScreen'
33
import { useFormatCurrency } from 'common/hooks/useFormatCurrency'
44
import { UNKNOWN_AMOUNT } from 'consts/amount'
55
import { useLocalSearchParams, useRouter } from 'expo-router'
66
import { AccountAddresses } from 'features/accountSettings/components/accountAddresses'
77
import { AccountButtons } from 'features/accountSettings/components/AccountButtons'
8-
import React, { useMemo } from 'react'
8+
import React, { useCallback, useMemo } from 'react'
99
import { useSelector } from 'react-redux'
1010
import { selectAccountById } from 'store/account'
1111
import { selectIsDeveloperMode } from 'store/settings/advanced'
@@ -17,8 +17,8 @@ import { CoreAccountType } from '@avalabs/types'
1717
import { WalletType } from 'services/wallet/types'
1818
import { useIsLoadingBalancesForAccount } from 'features/portfolio/hooks/useIsLoadingBalancesForAccount'
1919
import { useIsRefetchingBalancesForAccount } from 'features/portfolio/hooks/useIsRefetchingBalancesForAccount'
20-
import { useIsAccountBalanceAccurate } from 'features/portfolio/hooks/useIsAccountBalanceAccurate'
2120
import { useBalanceTotalInCurrencyForAccount } from 'features/portfolio/hooks/useBalanceTotalInCurrencyForAccount'
21+
import { useIsAllBalancesInaccurateForAccount } from 'features/portfolio/hooks/useIsAllBalancesInaccurateForAccount'
2222

2323
const AccountScreen = (): JSX.Element => {
2424
const router = useRouter()
@@ -33,18 +33,18 @@ const AccountScreen = (): JSX.Element => {
3333
account
3434
})
3535
const isLoading = isBalanceLoading || isRefetchingBalance
36-
const balanceAccurate = useIsAccountBalanceAccurate(account)
36+
const allBalancesInaccurate = useIsAllBalancesInaccurateForAccount(account)
3737
const selectedCurrency = useSelector(selectSelectedCurrency)
3838
const { formatCurrency } = useFormatCurrency()
3939
const formattedBalance = useMemo(() => {
4040
// CP-10570: Balances should never show $0.00
41-
return !balanceAccurate || balanceTotalInCurrency === 0
41+
return allBalancesInaccurate || balanceTotalInCurrency === 0
4242
? UNKNOWN_AMOUNT
4343
: formatCurrency({
4444
amount: balanceTotalInCurrency,
4545
withoutCurrencySuffix: true
4646
})
47-
}, [balanceAccurate, balanceTotalInCurrency, formatCurrency])
47+
}, [allBalancesInaccurate, balanceTotalInCurrency, formatCurrency])
4848

4949
const isPrivateKeyAvailable = useMemo(
5050
() =>
@@ -54,6 +54,15 @@ const AccountScreen = (): JSX.Element => {
5454
[account?.type, wallet?.type]
5555
)
5656

57+
const handleErrorPress = useCallback(() => {
58+
showAlert({
59+
title: 'Unable to load balances',
60+
description:
61+
'This total may be incomplete since Core was unable to load all of the balances across each network.',
62+
buttons: [{ text: 'Dismiss' }]
63+
})
64+
}, [])
65+
5766
const handleShowPrivateKey = (): void => {
5867
if (!account) {
5968
return
@@ -80,8 +89,9 @@ const AccountScreen = (): JSX.Element => {
8089
formattedBalance={formattedBalance}
8190
currency={selectedCurrency}
8291
errorMessage={
83-
balanceAccurate ? undefined : 'Unable to load account balance'
92+
allBalancesInaccurate ? 'Unable to load all balances' : undefined
8493
}
94+
onErrorPress={handleErrorPress}
8595
isLoading={isLoading}
8696
isPrivacyModeEnabled={isPrivacyModeEnabled}
8797
isDeveloperModeEnabled={isDeveloperMode}

packages/core-mobile/app/new/routes/(signedIn)/(modals)/addStake/confirm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const StakeConfirmScreen = (): JSX.Element => {
8282
}
8383
return 0
8484
}, [validator?.endTime])
85-
const { validatedStakingEndTime, validatedStakingDuration } =
85+
const { minStartTime, validatedStakingEndTime, validatedStakingDuration } =
8686
useValidateStakingEndTime(stakeEndTimeInMilliseconds, validatorEndTimeUnix)
8787

8888
const localValidatedStakingEndTime = useMemo(() => {
@@ -299,11 +299,12 @@ const StakeConfirmScreen = (): JSX.Element => {
299299

300300
issueDelegation({
301301
nodeId: validator.nodeID,
302+
startDate: minStartTime,
302303
endDate: validatedStakingEndTime,
303304
recomputeSteps
304305
})
305306
},
306-
[issueDelegation, validatedStakingEndTime, validator]
307+
[issueDelegation, minStartTime, validatedStakingEndTime, validator]
307308
)
308309

309310
usePreventScreenRemoval(isIssueDelegationPending)

packages/core-mobile/e2e-appium/pages/commonEls.page.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,11 @@ class CommonElsPage {
383383

384384
async dismissBottomSheet(element = this.grabber) {
385385
await actions.waitFor(element, 20000)
386-
await actions.dragAndDrop(this.grabber, [0, 1500])
386+
while (await actions.getVisible(element)) {
387+
await actions.dragAndDrop(element, [0, 1500])
388+
await actions.delay(1000)
389+
}
390+
console.log('Dismissed bottom sheet')
387391
}
388392

389393
async visibleDropdown(name: string, isVisible = true) {

packages/core-mobile/e2e-appium/specs/portfolioTab/assets/assetsFilterSortView.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ describe('Portfolio tab', () => {
6464

6565
previousAmount = currentAmount
6666
}
67+
68+
await commonElsPage.selectDropdown('sort', 'High to low balance')
6769
})
6870

6971
it('Assets - view assets by grid and list', async () => {

0 commit comments

Comments
 (0)