Skip to content

Commit 0688ea9

Browse files
committed
Merge branch 'main' into @szymon/nativeCryptoLib
# Conflicts: # packages/core-mobile/android/app/src/main/AndroidManifest.xml # yarn.lock
2 parents bda4068 + 3892a7b commit 0688ea9

File tree

85 files changed

+1836
-2630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1836
-2630
lines changed

bitrise.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ workflows:
863863
opts:
864864
is_expand: false
865865
steps:
866+
- deploy-to-bitrise-io@2:
867+
is_always_run: true
866868
- deploy-to-itunesconnect-application-loader@1:
867869
inputs:
868870
- api_key_path: $BITRISEIO_APPSTORE_CONNECT_API_KEY_URL
@@ -1002,6 +1004,8 @@ workflows:
10021004
opts:
10031005
is_expand: false
10041006
steps:
1007+
- deploy-to-bitrise-io@2:
1008+
is_always_run: true
10051009
- deploy-to-itunesconnect-application-loader@1:
10061010
inputs:
10071011
- api_key_path: $BITRISEIO_APPSTORE_CONNECT_API_KEY_URL

packages/core-mobile/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ android {
150150
internal {
151151
applicationIdSuffix ".internal"
152152
buildConfigField "boolean", "ENABLE_FLAG_SECURE", "false"
153-
manifestPlaceholders = [BRANCH_TEST_MODE:"true", BRANCH_KEY: project.env.get("BRANCH_KEY")]
153+
manifestPlaceholders = [BRANCH_TEST_MODE:"true"]
154154
}
155155
external {
156156
buildConfigField "boolean", "ENABLE_FLAG_SECURE", "false"
157-
manifestPlaceholders = [BRANCH_TEST_MODE:"false", BRANCH_KEY: project.env.get("BRANCH_KEY")]
157+
manifestPlaceholders = [BRANCH_TEST_MODE:"false"]
158158
}
159159
}
160160

packages/core-mobile/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
android:name="com.google.firebase.messaging.default_notification_icon"
3636
android:resource="@drawable/notification_icon" />
3737
<!-- Branch init -->
38-
<meta-data android:name="io.branch.sdk.BranchKey" android:value="${BRANCH_KEY}" />
39-
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="${BRANCH_KEY}" />
38+
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_iDtcATcmEAXhac4Rze6LgbllBAkfvayk" />
39+
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="key_test_huEgqNimBs9nak9ICf2TlhdfsDdptcAD" />
4040
<!-- Set to `true` to use `BranchKey.test` -->
4141
<meta-data android:name="io.branch.sdk.TestMode" android:value="${BRANCH_TEST_MODE}" />
4242
<activity

packages/core-mobile/android/app/src/main/assets/branch.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/core-mobile/app/consts/reactQueryKeys.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export enum ReactQueryKeys {
22
ACCOUNT_BALANCE = 'accountBalance',
3-
WALLET_XP_BALANCE = 'walletXpBalance',
3+
WALLET_BALANCE = 'walletBalance',
44

55
// defi
66
DEFI_EXCHANGE_RATES = 'defiExchangeRates',
@@ -44,5 +44,9 @@ export enum ReactQueryKeys {
4444
TERMS_OF_USE = 'termsOfUse',
4545

4646
// bridge
47-
BRIDGE_CONFIG = 'bridgeConfig'
47+
BRIDGE_CONFIG = 'bridgeConfig',
48+
49+
// deposit
50+
AAVE_AVAILABLE_MARKETS = 'aaveAvailableMarkets',
51+
BENQI_AVAILABLE_MARKETS = 'benqiAvailableMarkets'
4852
}

packages/core-mobile/app/new/common/containers/BalanceManager.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { addCustomNetwork, selectEnabledNetworks } from 'store/network/slice'
77
import { ReactQueryKeys } from 'consts/reactQueryKeys'
88
import NetworkService from 'services/network/NetworkService'
99
import { selectActiveAccount } from 'store/account/slice'
10-
import { selectActiveWallet } from 'store/wallet/slice'
11-
import { useWalletXpBalances } from 'features/portfolio/hooks/useWalletXpBalances'
1210
import { addCustomToken } from 'store/customToken/slice'
1311
import { addListener, isAnyOf } from '@reduxjs/toolkit'
1412

@@ -22,8 +20,7 @@ import { addListener, isAnyOf } from '@reduxjs/toolkit'
2220
*
2321
* 🔍 Responsibilities:
2422
* - Mounts:
25-
* • `useAccountBalances(activeAccount)` → fetches balances for all enabled non-XP networks (EVM, BTC, SOL, etc.)
26-
* • `useWalletXpBalances(activeWallet)` → fetches balances for all XP networks (X- and P-Chains)
23+
* • `useAccountBalances(activeAccount)` → fetches balances for the active account on all enabled networks
2724
*
2825
* - Ensures network data is preloaded (via `NetworkService.getNetworks`) when missing.
2926
*
@@ -33,10 +30,8 @@ import { addListener, isAnyOf } from '@reduxjs/toolkit'
3330
export const BalanceManager = (): null => {
3431
const dispatch = useDispatch()
3532
const activeAccount = useSelector(selectActiveAccount)
36-
const activeWallet = useSelector(selectActiveWallet)
37-
const { invalidate: invalidateAccountBalances } =
38-
useAccountBalances(activeAccount)
39-
useWalletXpBalances(activeWallet)
33+
34+
const { refetch: refetchAccountBalances } = useAccountBalances(activeAccount)
4035

4136
const queryClient = useQueryClient()
4237
const enabledNetworks = useSelector(selectEnabledNetworks)
@@ -67,11 +62,11 @@ export const BalanceManager = (): null => {
6762
matcher: isAnyOf(addCustomToken, addCustomNetwork),
6863
effect: async () => {
6964
if (!activeAccount) return
70-
await invalidateAccountBalances()
65+
await refetchAccountBalances()
7166
}
7267
})
7368
)
74-
}, [activeAccount, dispatch, invalidateAccountBalances])
69+
}, [activeAccount, dispatch, refetchAccountBalances])
7570

7671
return null
7772
}

packages/core-mobile/app/new/common/hooks/send/useEVMSend.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,10 @@ const useEVMSend: SendAdapterEVM = ({
180180

181181
const totalFee = gasLimit * maxFee
182182
const maxAmountValue = nativeToken.balance - totalFee
183+
const maxAmount = maxAmountValue > 0n ? maxAmountValue : 0n
183184

184185
if (selectedToken.type === TokenType.NATIVE) {
185-
return new TokenUnit(
186-
maxAmountValue ?? 0n,
187-
nativeToken.decimals,
188-
nativeToken.symbol
189-
)
186+
return new TokenUnit(maxAmount, nativeToken.decimals, nativeToken.symbol)
190187
} else if (selectedToken.type === TokenType.ERC20) {
191188
return new TokenUnit(
192189
selectedToken.balance,

packages/core-mobile/app/new/common/hooks/send/usePVMSend.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useCallback, useEffect, useState } from 'react'
22
import { useInAppRequest } from 'hooks/useInAppRequest'
33
import { TokenWithBalancePVM } from '@avalabs/vm-module-types'
44
import { isTokenWithBalancePVM } from '@avalabs/avalanche-module'
5-
import { GAS_LIMIT_FOR_X_CHAIN } from 'consts/fees'
65
import { TokenUnit } from '@avalabs/core-utils-sdk'
76
import Logger from 'utils/Logger'
87
import { Avalanche } from '@avalabs/core-wallets-sdk'
@@ -161,24 +160,26 @@ const usePVMSend: SendAdapterPVM = ({
161160
handleError
162161
])
163162

164-
// TODO: use correct max amount for P-chain
163+
// P-Chain uses dynamic fees
164+
// We can simulate a transaction to get the exact fee necessary
165+
// But we get the fee amount as an error string and we have to extract it and then subtract it from balance
166+
// Conservative solution: estimate as 1% of balance
165167
const getMaxAmount = useCallback(async () => {
166168
if (!selectedToken || !isTokenWithBalancePVM(selectedToken)) {
167169
return
168170
}
169171

170-
const fee = maxFee ? BigInt(GAS_LIMIT_FOR_X_CHAIN) * maxFee : 0n
171-
172172
const balance = selectedToken.available ?? 0n
173-
const maxAmountValue = balance - fee
173+
const estimatedFeePercent = balance / 100n
174+
const maxAmountValue = balance - estimatedFeePercent
174175
const maxAmount = maxAmountValue > 0n ? maxAmountValue : 0n
175176

176177
return new TokenUnit(
177178
maxAmount,
178179
selectedToken.decimals,
179180
selectedToken.symbol
180181
)
181-
}, [maxFee, selectedToken])
182+
}, [selectedToken])
182183

183184
useEffect(() => {
184185
if (canValidate) {

packages/core-mobile/app/new/common/hooks/send/useSVMSend.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ const useSVMSend: SendAdapterSVM = ({
6969
}
7070

7171
if (selectedToken.type === TokenType.NATIVE) {
72-
return new TokenUnit(
73-
selectedToken.balance - SOLANA_FIXED_BASE_FEE,
74-
nativeToken.decimals,
75-
nativeToken.symbol
76-
)
72+
const maxAmountValue = selectedToken.balance - SOLANA_FIXED_BASE_FEE
73+
const maxAmount = maxAmountValue > 0n ? maxAmountValue : 0n
74+
return new TokenUnit(maxAmount, nativeToken.decimals, nativeToken.symbol)
7775
} else {
7876
const splToken = selectedToken as TokenWithBalanceSPL
7977
return new TokenUnit(splToken.balance, splToken.decimals, splToken.symbol)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useDisableLockAppStore } from 'features/accountSettings/store'
2+
import { useEffect } from 'react'
3+
4+
/**
5+
* This is to prevent the app from locking when the user is in these routes
6+
* For example, when the user is in the add recovery methods screen, the app might prompt prompt to setup passkey or FIDO2 device
7+
*/
8+
export const useDisableLockApp = (): void => {
9+
useEffect(() => {
10+
useDisableLockAppStore.setState({ disableLockApp: true })
11+
return () => {
12+
useDisableLockAppStore.setState({ disableLockApp: false })
13+
}
14+
}, [])
15+
}

0 commit comments

Comments
 (0)