File tree Expand file tree Collapse file tree 5 files changed +46
-7
lines changed
Expand file tree Collapse file tree 5 files changed +46
-7
lines changed Original file line number Diff line number Diff line change 1+ import Config from 'react-native-config'
12import { Environment } from '@avalabs/unified-asset-transfer'
23import { BuildTxParams } from "features/swap/services/ParaswapService"
34
@@ -100,7 +101,7 @@ export const MAX_SLIPPAGE_PERCENT = 50
100101 */
101102// TODO add to env variables once stable
102103export const MARKR_API_URL =
103- process . env . MARKR_API_URL ?? 'https://proxy-api.avax.network/proxy/markr-staging'
104+ Config . MARKR_API_URL ?? 'https://proxy-api.avax.network/proxy/markr-staging'
104105
105106/**
106107 * Determines the Fusion SDK environment based on app settings
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type { Network } from '@avalabs/core-chains-sdk'
44import { ReactQueryKeys } from 'consts/reactQueryKeys'
55import { useNetworks } from 'hooks/networks/useNetworks'
66import Logger from 'utils/Logger'
7+ import { exponentialBackoff } from 'utils/reactQuery'
78import { isAvalancheChainId } from 'services/network/utils/isAvalancheNetwork'
89import FusionService from '../services/FusionService'
910
@@ -41,7 +42,8 @@ export function useSupportedChains(): {
4142 return FusionService . getSupportedChains ( )
4243 } ,
4344 staleTime : STALE_TIME ,
44- enabled : FusionService . isInitialized ( )
45+ retry : 3 ,
46+ retryDelay : exponentialBackoff ( 5000 )
4547 } )
4648
4749 // Convert CAIP-2 IDs to Network objects from enabled networks
@@ -53,8 +55,11 @@ export function useSupportedChains(): {
5355 . filter ( ( network ) : network is Network => network !== undefined )
5456 . sort ( ( a , b ) => {
5557 // Avalanche C-Chain always first
56- if ( isAvalancheChainId ( a . chainId ) ) return - 1
57- if ( isAvalancheChainId ( b . chainId ) ) return 1
58+ const aIsAvalanche = isAvalancheChainId ( a . chainId )
59+ const bIsAvalanche = isAvalancheChainId ( b . chainId )
60+
61+ if ( aIsAvalanche && ! bIsAvalanche ) return - 1
62+ if ( ! aIsAvalanche && bIsAvalanche ) return 1
5863 return 0
5964 } )
6065
Original file line number Diff line number Diff line change @@ -7,11 +7,15 @@ import { rpcErrors } from '@metamask/rpc-errors'
77 * @param value - The value to check
88 * @param message - Optional error message
99 * @throws RPC internal error if value is falsy
10+ * @example
11+ * const foo: string | null = getValue()
12+ * assert(foo, 'foo is required')
13+ * // foo is now typed as string (non-nullable)
1014 */
11- export function assert (
12- value : unknown ,
15+ export function assert < T > (
16+ value : T ,
1317 message ?: string
14- ) : asserts value is NonNullable < unknown > {
18+ ) : asserts value is NonNullable < T > {
1519 if ( ! value ) {
1620 throw rpcErrors . internal ( {
1721 data : { reason : message || 'Assertion failed' }
Original file line number Diff line number Diff line change 11import Config from 'react-native-config'
2+ import Logger from 'utils/Logger'
23import { appCheckFetch } from '../common/appCheckFetch'
34import { CORE_HEADERS } from '../constants'
45import { createClient } from '../generated/profileApi.client/client'
56
7+ if ( ! Config . CORE_PROFILE_URL )
8+ Logger . warn (
9+ 'CORE_PROFILE_URL is missing in env file. Profile API will not work properly.'
10+ )
11+
612/**
713 * Profile API client configured with:
814 * - nitroFetch (via appCheckFetch) for better performance
Original file line number Diff line number Diff line change 1+ /**
2+ * React Query utility functions
3+ */
4+
5+ /**
6+ * Exponential backoff with a maximum delay cap for React Query retries
7+ *
8+ * @param maxDelayMs - Maximum delay in milliseconds (default: 5000ms)
9+ * @returns Function compatible with React Query's retryDelay option
10+ *
11+ * @example
12+ * useQuery({
13+ * queryKey: ['data'],
14+ * queryFn: fetchData,
15+ * retry: 3,
16+ * retryDelay: exponentialBackoff(5000) // 1s, 2s, 4s
17+ * })
18+ */
19+ export const exponentialBackoff = ( maxDelayMs = 5000 ) => {
20+ return ( attemptIndex : number ) : number => {
21+ return Math . min ( 1000 * 2 ** attemptIndex , maxDelayMs )
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments