Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/core-mobile/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ module.exports = {
'android/app/build/**',
'expo-env.d.ts',
'ios/DerivedData',
'app/utils/api/generated/**',
'app/utils/apiClient/generated/**'
'app/utils/api/generated/**'
],
overrides: [
{
Expand Down
2 changes: 0 additions & 2 deletions packages/core-mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,4 @@ expo-env.d.ts
/ios/config.xcconfig

# generated api clients
app/utils/apiClient/generated/profileApi.client.ts
app/utils/apiClient/generated/balanceApi.client/
app/utils/api/generated
1 change: 1 addition & 0 deletions packages/core-mobile/aggregator-api.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const isCI = process.env.APP_ENV === 'ci'

// use production environment on CI for stability
const TOKEN_AGGREGATOR_SCHEMA_URL = isCI
? 'https://core-token-aggregator.avax.network/schema.json'
: 'https://core-token-aggregator.avax-test.network/schema.json'
Expand Down
4 changes: 4 additions & 0 deletions packages/core-mobile/app/consts/reactQueryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export enum ReactQueryKeys {
// bridge
BRIDGE_CONFIG = 'bridgeConfig',

// fusion
FUSION_SUPPORTED_CHAINS = 'fusionSupportedChains',
FUSION_TOKENS = 'fusionTokens',

// deposit
AAVE_AVAILABLE_MARKETS = 'aaveAvailableMarkets',
BENQI_AVAILABLE_MARKETS = 'benqiAvailableMarkets',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery, UseQueryResult } from '@tanstack/react-query'
import { ReactQueryKeys } from 'consts/reactQueryKeys'
import { queryClient } from 'contexts/ReactQueryProvider'
import { getV1BalanceGetSupportedChains } from 'utils/apiClient/generated/balanceApi.client'
import { getV1BalanceGetSupportedChains } from 'utils/api/generated/balanceApi.client'
import { balanceApiClient } from 'utils/api/clients/balanceApiClient'

const STALE_TIME = 5 * 60 * 1000 // 5 minutes
Expand Down
26 changes: 20 additions & 6 deletions packages/core-mobile/app/hooks/networks/useNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export const useNetworks = () => {
const chainId = parseInt(key)
const network = rawNetworks[chainId]
if (network && network.isTestnet === isDeveloperMode) {
reducedNetworks[chainId] = network
reducedNetworks[chainId] = {
...network,
caip2ChainId: getCaip2ChainId(chainId)
}
}
return reducedNetworks
},
Expand All @@ -61,7 +64,10 @@ export const useNetworks = () => {
const network = _customNetworks[chainId]

if (network && network.isTestnet === isDeveloperMode) {
reducedNetworks[chainId] = network
reducedNetworks[chainId] = {
...network,
caip2ChainId: getCaip2ChainId(chainId)
}
}
return reducedNetworks
},
Expand All @@ -70,7 +76,7 @@ export const useNetworks = () => {
return { ...populatedNetworks, ...populatedCustomNetworks }
}, [rawNetworks, _customNetworks, isDeveloperMode])

const customNetworks = useMemo(() => {
const customNetworks: NetworkWithCaip2ChainId[] = useMemo(() => {
if (networks === undefined) return []

const customNetworkChainIds = Object.values(_customNetworks).map(
Expand All @@ -81,7 +87,7 @@ export const useNetworks = () => {
)
}, [networks, _customNetworks])

const enabledNetworks = useMemo(() => {
const enabledNetworks: NetworkWithCaip2ChainId[] = useMemo(() => {
if (networks === undefined) return []

const lastTransactedChainIds = lastTransactedChains
Expand All @@ -93,10 +99,10 @@ export const useNetworks = () => {
const enabled = allChainIds.reduce((acc, chainId) => {
const network = networks[chainId]
if (network && network.isTestnet === isDeveloperMode) {
acc.push(network)
acc.push({ ...network, caip2ChainId: getCaip2ChainId(network.chainId) })
}
return acc
}, [] as Network[])
}, [] as NetworkWithCaip2ChainId[])

// sort all C/X/P networks to the top
return enabled.sort((a, b) => {
Expand Down Expand Up @@ -162,6 +168,13 @@ export const useNetworks = () => {
[allNetworks]
)

const getEnabledNetworkByCaip2ChainId = useCallback(
(caip2ChainId: string) => {
return enabledNetworks.find(n => n.caip2ChainId === caip2ChainId)
},
[enabledNetworks]
)
Comment on lines +171 to +176
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caip2ChainId property is defined as optional (caip2ChainId?: string) in the NetworkWithCaip2ChainId type, but this code assumes it will always be present by using strict equality comparison (n.caip2ChainId === caip2Id). If caip2ChainId is undefined, this comparison will never match, potentially returning undefined even when a matching network exists. Consider either:

  1. Making caip2ChainId required in the type definition
  2. Adding a guard to handle undefined caip2ChainId values
  3. Ensuring all networks always have caip2ChainId populated before being added to enabledNetworks

Copilot uses AI. Check for mistakes.

const getFromPopulatedNetwork = useCallback(
(chainId?: number) => {
if (chainId === undefined || networks === undefined) return
Expand All @@ -180,6 +193,7 @@ export const useNetworks = () => {
getSomeNetworks,
getNetwork,
getNetworkByCaip2ChainId,
getEnabledNetworkByCaip2ChainId,
getFromPopulatedNetwork,
toggleNetwork
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ class MeldService {
countries
}: MeldDefaultParams): Promise<Country[]> {
return this.#meldApiClient.getCountries({
queries: {
serviceProviders: serviceProviders?.join(','),
categories: categories.join(','),
accountFilter,
countries: countries?.join(',')
}
serviceProviders: serviceProviders?.join(','),
categories: categories.join(','),
accountFilter,
countries: countries?.join(',')
})
}

Expand All @@ -52,13 +50,11 @@ class MeldService {
countries
}: SearchFiatCurrenciesParams): Promise<FiatCurrency[]> {
return this.#meldApiClient.getFiatCurrencies({
queries: {
serviceProviders: serviceProviders?.join(','),
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
fiatCurrencies: fiatCurrencies?.join(',')
}
serviceProviders: serviceProviders?.join(','),
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
fiatCurrencies: fiatCurrencies?.join(',')
})
}

Expand All @@ -69,15 +65,12 @@ class MeldService {
cryptoCurrencies,
accountFilter = true
}: SearchCryptoCurrenciesParams): Promise<CryptoCurrency[]> {
const queries = {
return this.#meldApiClient.getCryptoCurrencies({
serviceProviders: serviceProviders?.join(','),
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
cryptoCurrencies: cryptoCurrencies?.join(',')
}
return this.#meldApiClient.getCryptoCurrencies({
queries
})
}

Expand All @@ -87,14 +80,11 @@ class MeldService {
accountFilter = true,
cryptoCurrencies
}: SearchServiceProvidersParams): Promise<ServiceProvider[]> {
const queries = {
return this.#meldApiClient.getServiceProviders({
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
cryptoCurrencies: cryptoCurrencies?.join(',')
}
return this.#meldApiClient.getServiceProviders({
queries
})
}

Expand All @@ -103,12 +93,11 @@ class MeldService {
countries,
accountFilter = true
}: SearchDefaultsByCountryParams): Promise<SearchDefaultsByCountry[]> {
const queries = {
return this.#meldApiClient.getDefaultsByCountry({
categories: categories.join(','),
accountFilter,
countries: countries?.join(',')
}
return this.#meldApiClient.getDefaultsByCountry({ queries })
})
}

async getPurchaseLimits({
Expand All @@ -120,16 +109,15 @@ class MeldService {
cryptoCurrencyCodes,
includeDetails = false
}: GetTradeLimitsParams): Promise<GetTradeLimits[]> {
const queries = {
return this.#meldApiClient.getPurchaseLimits({
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
serviceProviders: serviceProviders?.join(','),
fiatCurrencies: fiatCurrencies?.join(','),
cryptoCurrencies: cryptoCurrencyCodes?.join(','),
includeDetails
}
return this.#meldApiClient.getPurchaseLimits({ queries })
})
}

async getSellLimits({
Expand All @@ -141,16 +129,15 @@ class MeldService {
cryptoCurrencyCodes,
includeDetails = false
}: GetTradeLimitsParams): Promise<GetTradeLimits[]> {
const queries = {
return this.#meldApiClient.getSellLimits({
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
serviceProviders: serviceProviders?.join(','),
fiatCurrencies: fiatCurrencies?.join(','),
cryptoCurrencies: cryptoCurrencyCodes?.join(','),
includeDetails
}
return this.#meldApiClient.getSellLimits({ queries })
})
}

async searchPaymentMethods({
Expand All @@ -161,15 +148,14 @@ class MeldService {
fiatCurrencies,
cryptoCurrencyCodes
}: SearchPaymentMethodsParams): Promise<SearchPaymentMethods[]> {
const queries = {
return this.#meldApiClient.getPaymentMethods({
categories: categories.join(','),
accountFilter,
countries: countries?.join(','),
serviceProviders: serviceProviders?.join(','),
fiatCurrencies: fiatCurrencies?.join(','),
cryptoCurrencies: cryptoCurrencyCodes?.join(',')
}
return this.#meldApiClient.getPaymentMethods({ queries })
})
}

async createCryptoQuote({
Expand Down Expand Up @@ -236,9 +222,7 @@ class MeldService {
}: {
sessionId: string
}): Promise<MeldTransaction | undefined> {
return await this.#meldApiClient.fetchTransactionBySessionId({
params: { id: sessionId }
})
return await this.#meldApiClient.fetchTransactionBySessionId(sessionId)
}
}

Expand Down
Loading
Loading