Repository: AudiusProject/audius-protocol
Pull request #12020: [PE-6095] Deprecate audius-query user saga fetches
Author: login: DejayJD
Labels: name: size/L
Created: 2025-05-02T19:12:24Z | Merged: 2025-05-05T21:02:48Z

### Description

- Replaces the saga fetches with queryClient + queryFn fetches
- Refactored the hook `useCurrentUser` - there were some issues here. This hook was using the same queryKey as `useCurrentAccount` but with a string (wallet) instead of a number (user id). While running the app this hook was barely used and the places referencing it seem to be assuming this is the `currentAccount` slice. The only active place this query key was being used is `useCurrentAccount` which is keyed by user ID (not wallet string).
- TODO: more cleanup with the "account" hooks - need to sort out some more here, but will tackle more with the account hook migration

### How Has This Been Tested?

web:stage
- [x] Sign up account
- [x] Sign in account 
- [x] Misc app features 



Diff:
diff --git a/packages/common/src/api/index.ts b/packages/common/src/api/index.ts
index bff8dcec58c..9b01ab416a7 100644
--- a/packages/common/src/api/index.ts
+++ b/packages/common/src/api/index.ts
@@ -88,7 +88,7 @@ export * from './tan-query/tracks/useRemixedTracks'
 
 // Users
 export * from './tan-query/users/account/useCurrentUserId'
-export * from './tan-query/users/account/useCurrentUser'
+export * from './tan-query/users/account/useWalletUser'
 export * from './tan-query/users/account/useAddToPlaylistFolder'
 export * from './tan-query/users/account/useCurrentAccount'
 export * from './tan-query/users/account/usePlaylistLibrary'
diff --git a/packages/common/src/api/tan-query/queryKeys.ts b/packages/common/src/api/tan-query/queryKeys.ts
index 4409333524c..7e0d04a392d 100644
--- a/packages/common/src/api/tan-query/queryKeys.ts
+++ b/packages/common/src/api/tan-query/queryKeys.ts
@@ -1,6 +1,8 @@
 export const QUERY_KEYS = {
   aiTracks: 'aiTracks',
   accountUser: 'accountUser',
+  walletUser: 'walletUser',
+  walletAccount: 'walletAccount',
   trackCommentList: 'trackCommentList',
   userCommentList: 'userCommentList',
   comment: 'comment',
diff --git a/packages/common/src/api/tan-query/tracks/useDeleteTrack.ts b/packages/common/src/api/tan-query/tracks/useDeleteTrack.ts
index c222c986059..22b6fd306d4 100644
--- a/packages/common/src/api/tan-query/tracks/useDeleteTrack.ts
+++ b/packages/common/src/api/tan-query/tracks/useDeleteTrack.ts
@@ -1,6 +1,6 @@
 import { Id } from '@audius/sdk'
 import { useMutation, useQueryClient } from '@tanstack/react-query'
-import { useDispatch, useSelector } from 'react-redux'
+import { useDispatch } from 'react-redux'
 
 import { useAudiusQueryContext } from '~/audius-query'
 import { useAppContext } from '~/context/appContext'
@@ -9,10 +9,8 @@ import { Feature } from '~/models/ErrorReporting'
 import { ID } from '~/models/Identifiers'
 import { Track } from '~/models/Track'
 import { UserMetadata } from '~/models/User'
-import { getWalletAddresses } from '~/store/account/selectors'
 import { deleteTrackRequested } from '~/store/cache/tracks/actions'
 
-import { getCurrentUserQueryKey } from '../users/account/useCurrentUser'
 import { useCurrentUserId } from '../users/account/useCurrentUserId'
 import { useUser } from '../users/useUser'
 import { primeTrackData } from '../utils/primeTrackData'
@@ -35,7 +33,6 @@ export const useDeleteTrack = () => {
   const queryClient = useQueryClient()
   const dispatch = useDispatch()
   const { data: currentUserId } = useCurrentUserId()
-  const { currentUser: currentUserWallet } = useSelector(getWalletAddresses)
   const { data: currentUser } = useUser(currentUserId)
   const {
     analytics: { track: trackEvent }
@@ -78,11 +75,6 @@ export const useDeleteTrack = () => {
           dispatch,
           forceReplace: true
         })
-
-        queryClient.setQueryData(
-          getCurrentUserQueryKey(currentUserWallet),
-          updatedCurrentUser
-        )
       }
 
       // Optimistic update in cache
diff --git a/packages/common/src/api/tan-query/users/account/useCurrentUser.ts b/packages/common/src/api/tan-query/users/account/useCurrentUser.ts
deleted file mode 100644
index bc57d3ca64c..00000000000
--- a/packages/common/src/api/tan-query/users/account/useCurrentUser.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { useQuery } from '@tanstack/react-query'
-import { useSelector } from 'react-redux'
-
-import { accountFromSDK } from '~/adapters/user'
-import { useAudiusQueryContext } from '~/audius-query'
-import { UserMetadata } from '~/models/User'
-import { getWalletAddresses } from '~/store/account/selectors'
-
-import { QUERY_KEYS } from '../../queryKeys'
-import { QueryKey, SelectableQueryOptions } from '../../types'
-
-export const getCurrentUserQueryKey = (
-  currentUser: string | null | undefined
-) =>
-  [
-    QUERY_KEYS.accountUser,
-    currentUser
-  ] as unknown as QueryKey<UserMetadata | null>
-
-/**
- * Hook to get the currently logged in user's data
- */
-export const useCurrentUser = <TResult = UserMetadata | null | undefined>(
-  options?: SelectableQueryOptions<UserMetadata | null | undefined, TResult>
-) => {
-  const { audiusSdk } = useAudiusQueryContext()
-  const { currentUser } = useSelector(getWalletAddresses)
-
-  return useQuery({
-    queryKey: getCurrentUserQueryKey(currentUser),
-    queryFn: async () => {
-      const sdk = await audiusSdk()
-      const { data } = await sdk.full.users.getUserAccount({
-        wallet: currentUser!
-      })
-
-      if (!data) {
-        console.warn('Missing user from account response')
-        return null
-      }
-
-      const account = accountFromSDK(data)
-      return account?.user
-    },
-    ...options,
-    enabled: options?.enabled !== false && !!currentUser
-  })
-}
diff --git a/packages/common/src/api/tan-query/users/account/useWalletUser.ts b/packages/common/src/api/tan-query/users/account/useWalletUser.ts
new file mode 100644
index 00000000000..e3e6aff889b
--- /dev/null
+++ b/packages/common/src/api/tan-query/users/account/useWalletUser.ts
@@ -0,0 +1,59 @@
+import { AudiusSdk } from '@audius/sdk'
+import { useQuery } from '@tanstack/react-query'
+import { useSelector } from 'react-redux'
+
+import { accountFromSDK } from '~/adapters/user'
+import { useAudiusQueryContext } from '~/audius-query'
+import { AccountUserMetadata, ID } from '~/models'
+import { getWalletAddresses } from '~/store/account/selectors'
+
+import { QUERY_KEYS } from '../../queryKeys'
+import { QueryKey, SelectableQueryOptions } from '../../types'
+
+export const getWalletAccountQueryKey = (wallet: string | null | undefined) =>
+  [
+    QUERY_KEYS.walletAccount,
+    wallet
+  ] as unknown as QueryKey<AccountUserMetadata | null>
+
+export const getWalletUserQueryKey = (wallet: string | null | undefined) =>
+  [QUERY_KEYS.walletUser, wallet] as unknown as QueryKey<ID | null>
+
+// This queryFn is separate in order to be used in sagas
+export const getWalletAccountQueryFn = async (
+  wallet: string,
+  sdk: AudiusSdk
+) => {
+  const { data } = await sdk.full.users.getUserAccount({
+    wallet
+  })
+
+  if (!data) {
+    console.warn('Missing user from account response')
+    return null
+  }
+
+  const account = accountFromSDK(data)
+  return account
+}
+
+/**
+ * Hook to get the currently logged in user's data
+ */
+export const useWalletUser = <TResult = ID | null | undefined>(
+  options?: SelectableQueryOptions<ID | null | undefined, TResult>
+) => {
+  const { audiusSdk } = useAudiusQueryContext()
+  const { currentUser: currentUserWallet } = useSelector(getWalletAddresses)
+
+  return useQuery({
+    queryKey: getWalletUserQueryKey(currentUserWallet),
+    queryFn: async () => {
+      const sdk = await audiusSdk()
+      return (await getWalletAccountQueryFn(currentUserWallet!, sdk))?.user
+        ?.user_id
+    },
+    ...options,
+    enabled: options?.enabled !== false && !!currentUserWallet
+  })
+}
diff --git a/packages/common/src/api/tan-query/users/useUpdateUser.ts b/packages/common/src/api/tan-query/users/useUpdateUser.ts
index fe9950b899d..b79b27e8af5 100644
--- a/packages/common/src/api/tan-query/users/useUpdateUser.ts
+++ b/packages/common/src/api/tan-query/users/useUpdateUser.ts
@@ -7,7 +7,7 @@ import { ID } from '~/models/Identifiers'
 import { PlaylistLibrary } from '~/models/PlaylistLibrary'
 import { UserMetadata } from '~/models/User'
 
-import { getCurrentUserQueryKey } from './account/useCurrentUser'
+import { getCurrentAccountQueryKey } from './account/useCurrentAccount'
 import { getUserQueryKey } from './useUser'
 
 type MutationContext = {
@@ -53,7 +53,7 @@ export const useUpdateUser = () => {
       // Snapshot the previous account user if it matches
       const previousAccountUser = queryClient
         .getQueriesData<UserMetadata>({
-          queryKey: getCurrentUserQueryKey(userId.toString())
+          queryKey: getCurrentAccountQueryKey(userId)
         })
         .find(([_, data]) => data?.user_id === userId)?.[1]
 
@@ -65,7 +65,7 @@ export const useUpdateUser = () => {
 
       // Optimistically update accountUser queries if they match the user
       queryClient.setQueriesData(
-        { queryKey: getCurrentUserQueryKey(userId.toString()) },
+        { queryKey: getCurrentAccountQueryKey(userId) },
         (oldData: any) => {
           if (!oldData?.user_id || oldData.user_id !== userId) return oldData
           return { ...oldData, ...metadata }
@@ -84,7 +84,7 @@ export const useUpdateUser = () => {
       // Roll back accountUser queries if we have the previous state
       if (context?.previousAccountUser) {
         queryClient.setQueriesData(
-          { queryKey: getCurrentUserQueryKey(userId.toString()) },
+          { queryKey: getCurrentAccountQueryKey(userId) },
           (oldData: any) => {
             if (!oldData?.user_id || oldData.user_id !== userId) return oldData
             return context.previousAccountUser
diff --git a/packages/common/src/api/user.ts b/packages/common/src/api/user.ts
index 1491b283210..5a59a8b290f 100644
--- a/packages/common/src/api/user.ts
+++ b/packages/common/src/api/user.ts
@@ -1,6 +1,6 @@
 import { full, Id, OptionalId } from '@audius/sdk'
 
-import { accountFromSDK, userMetadataListFromSDK } from '~/adapters/user'
+import { userMetadataListFromSDK } from '~/adapters/user'
 import { createApi } from '~/audius-query'
 import { ID, Kind, StringUSDC } from '~/models'
 import {
@@ -8,7 +8,6 @@ import {
   USDCTransactionMethod,
   USDCTransactionType
 } from '~/models/USDCTransactions'
-import { isResponseError } from '~/utils'
 import { Nullable } from '~/utils/typeUtils'
 
 type GetUSDCTransactionListArgs = {
@@ -43,30 +42,7 @@ const parseTransaction = ({
 const userApi = createApi({
   reducerPath: 'userApi',
   endpoints: {
-    // TODO: Remove this once saga calls are removed
-    getUserAccount: {
-      fetch: async ({ wallet }: { wallet: string }, { audiusSdk }) => {
-        try {
-          const sdk = await audiusSdk()
-          const { data } = await sdk.full.users.getUserAccount({ wallet })
-          if (!data) {
-            console.warn('Missing user from account response')
-            return null
-          }
-
-          return accountFromSDK(data)
-        } catch (e) {
-          // Account doesn't exist, don't bubble up an error, just return null
-          if (isResponseError(e) && [401, 404].includes(e.response.status)) {
-            return null
-          }
-          throw e
-        }
-      },
-      options: {
-        schemaKey: 'accountUser'
-      }
-    },
+    // TODO: Remove these once fetch export calls are removed
     getUserByHandle: {
       fetch: async (
         {
@@ -135,6 +111,5 @@ const userApi = createApi({
 
 export const userApiReducer = userApi.reducer
 export const userApiFetch = userApi.fetch
-export const userApiFetchSaga = userApi.fetchSaga
 export const userApiActions = userApi.actions
 export const userApiUtils = userApi.util
diff --git a/packages/common/src/store/account/sagas.ts b/packages/common/src/store/account/sagas.ts
index 0be9e393322..d61c82c72fd 100644
--- a/packages/common/src/store/account/sagas.ts
+++ b/packages/common/src/store/account/sagas.ts
@@ -9,7 +9,7 @@ import {
   takeLatest
 } from 'typed-redux-saga'
 
-import { userApiFetchSaga } from '~/api/user'
+import { getWalletAccountQueryFn, getWalletAccountQueryKey } from '~/api'
 import { AccountUserMetadata, ErrorLevel, Kind, UserMetadata } from '~/models'
 import { getContext } from '~/store/effects'
 import { chatActions } from '~/store/pages/chat'
@@ -103,15 +103,18 @@ function* initializeMetricsForUser({
   const solanaWalletService = yield* getContext('solanaWalletService')
   const analytics = yield* getContext('analytics')
   const sdk = yield* getSDK()
+  const queryClient = yield* getContext('queryClient')
 
   if (accountUser && accountUser.handle) {
     const [web3WalletAddress] = yield* call([
       sdk.services.audiusWalletClient,
       sdk.services.audiusWalletClient.getAddresses
     ])
-    const { user: web3User } = yield* call(userApiFetchSaga.getUserAccount, {
-      wallet: web3WalletAddress
-    })
+    const accountData = (yield* call([queryClient, queryClient.fetchQuery], {
+      queryKey: getWalletAccountQueryKey(web3WalletAddress),
+      queryFn: async () => getWalletAccountQueryFn(web3WalletAddress, sdk)
+    })) as AccountUserMetadata | undefined
+    const { user: web3User } = accountData ?? {}
 
     let solanaWallet
     let managerUserId
@@ -164,13 +167,15 @@ export function* fetchAccountAsync({
   const localStorage = yield* getContext('localStorage')
   const reportToSentry = yield* getContext('reportToSentry')
   const sdk = yield* getSDK()
+  const queryClient = yield* getContext('queryClient')
 
   // Don't revert successful local account fetch
   if (shouldMarkAccountAsLoading) {
     yield* put(fetchAccountRequested())
   }
 
-  let wallet, web3WalletAddress
+  let wallet: string | undefined
+  let web3WalletAddress: string | undefined
   try {
     const connectedWallets = yield* call([
       sdk.services.audiusWalletClient,
@@ -200,13 +205,10 @@ export function* fetchAccountAsync({
     return
   }
 
-  const accountData: AccountUserMetadata | undefined = yield* call(
-    userApiFetchSaga.getUserAccount,
-    {
-      wallet
-    },
-    true // force refresh to get updated user w handle
-  )
+  const accountData = (yield* call([queryClient, queryClient.fetchQuery], {
+    queryKey: getWalletAccountQueryKey(wallet),
+    queryFn: async () => getWalletAccountQueryFn(wallet!, sdk)
+  })) as AccountUserMetadata | undefined
 
   if (!accountData) {
     yield* put(resetAccount())
diff --git a/packages/web/src/common/store/pages/signon/sagas.ts b/packages/web/src/common/store/pages/signon/sagas.ts
index 768357bfbcc..868ea18bca9 100644
--- a/packages/web/src/common/store/pages/signon/sagas.ts
+++ b/packages/web/src/common/store/pages/signon/sagas.ts
@@ -1,4 +1,7 @@
-import { userApiFetchSaga } from '@audius/common/api'
+import {
+  getWalletAccountQueryFn,
+  getWalletAccountQueryKey
+} from '@audius/common/api'
 import { GUEST_EMAIL } from '@audius/common/hooks'
 import {
   Name,
@@ -538,6 +541,7 @@ function* createGuestAccount(
 function* signUp() {
   const reportToSentry = yield* getContext('reportToSentry')
   const localStorage = yield* getContext('localStorage')
+  const queryClient = yield* getContext('queryClient')
 
   try {
     const signOn = yield* select(getSignOn)
@@ -587,12 +591,14 @@ function* signUp() {
                 sdk.services.audiusWalletClient,
                 sdk.services.audiusWalletClient.getAddresses
               ])
-              const account: AccountUserMetadata | null = yield* call(
-                userApiFetchSaga.getUserAccount,
+              const account = (yield* call(
+                [queryClient, queryClient.fetchQuery],
                 {
-                  wallet
+                  queryKey: getWalletAccountQueryKey(wallet),
+                  queryFn: async () => getWalletAccountQueryFn(wallet!, sdk)
                 }
-              )
+              )) as AccountUserMetadata | undefined
+              // TODO: Do I need to prime the accountUser slice here?
               if (!account) {
                 throw new Error('Account user ID does not exist')
               }
@@ -858,6 +864,7 @@ function* signIn(action: ReturnType<typeof signOnActions.signIn>) {
   const authService = yield* getContext('authService')
   const isNativeMobile = yield* getContext('isNativeMobile')
   const isElectron = yield* getContext('isElectron')
+  const queryClient = yield* getContext('queryClient')
   const clientOrigin = isNativeMobile
     ? 'mobile'
     : isElectron
@@ -896,12 +903,11 @@ function* signIn(action: ReturnType<typeof signOnActions.signIn>) {
       return
     }
 
-    const account: AccountUserMetadata | null = yield* call(
-      userApiFetchSaga.getUserAccount,
-      {
-        wallet: signInResponse.walletAddress
-      }
-    )
+    const account = (yield* call([queryClient, queryClient.fetchQuery], {
+      queryKey: getWalletAccountQueryKey(signInResponse.walletAddress),
+      queryFn: async () =>
+        getWalletAccountQueryFn(signInResponse.walletAddress, sdk)
+    })) as AccountUserMetadata | undefined
 
     // Login succeeded but we found no account for the user (incomplete signup)
     if (!account) {
diff --git a/packages/web/src/hooks/useConnectAndAssociateWallets.ts b/packages/web/src/hooks/useConnectAndAssociateWallets.ts
index 18e47e3aaea..7a5710783a7 100644
--- a/packages/web/src/hooks/useConnectAndAssociateWallets.ts
+++ b/packages/web/src/hooks/useConnectAndAssociateWallets.ts
@@ -3,9 +3,9 @@ import { useRef, useCallback, useEffect } from 'react'
 import {
   type ConnectedWallet,
   useConnectedWallets,
-  useAddConnectedWallet
+  useAddConnectedWallet,
+  useCurrentAccount
 } from '@audius/common/api'
-import { useCurrentUser } from '@audius/common/api'
 import { useAppContext } from '@audius/common/context'
 import { Name, Chain } from '@audius/common/models'
 import { useTheme } from '@emotion/react'
@@ -89,7 +89,8 @@ export const useConnectAndAssociateWallets = (
   const theme = useTheme()
   const { open } = useAppKit()
   const { signMessageAgnostic } = useSignMessageAgnostic()
-  const currentUser = useCurrentUser()
+  const { data: currentAccount } = useCurrentAccount()
+  const currentUser = currentAccount!.user
   const { data: connectedWallets } = useConnectedWallets()
   const { switchAccountAsync } = useSwitchAccount()
   const { disconnect } = useDisconnect()
@@ -141,7 +142,7 @@ export const useConnectAndAssociateWallets = (
       const chainId = await connector!.getChainId()
       const connectedAccountIsUserWallet =
         accounts &&
-        accounts[0]?.toLowerCase() === currentUser.data?.wallet?.toLowerCase()
+        accounts[0]?.toLowerCase() === currentUser?.wallet?.toLowerCase()
       if (!connectedAccountIsUserWallet || chainId !== audiusChain.id) {
         console.debug(
           '[associate-wallet]',
@@ -153,7 +154,7 @@ export const useConnectAndAssociateWallets = (
         await switchAccountAsync({ connector })
       }
     }
-  }, [currentUser.data?.wallet, switchAccountAsync])
+  }, [currentUser.wallet, switchAccountAsync])
 
   /**
    * Associates any Reown connected wallets to the user's account.
@@ -164,7 +165,7 @@ export const useConnectAndAssociateWallets = (
       isAssociatingRef.current = true
       track(make({ eventName: Name.CONNECT_WALLET_NEW_WALLET_START }))
       const activeAccount = appkitModal.getAccount()
-      const originalAddress = currentUser?.data?.wallet
+      const originalAddress = currentUser?.wallet
 
       // Map the wallets to add our chain format
       const wallets =
@@ -218,7 +219,7 @@ export const useConnectAndAssociateWallets = (
           })
         )
         const signature = await signMessageAgnostic(
-          `AudiusUserID:${currentUser.data?.user_id}`,
+          `AudiusUserID:${currentUser.user_id}`,
           address,
           namespace
         )
@@ -259,8 +260,8 @@ export const useConnectAndAssociateWallets = (
   }, [
     addConnectedWalletAsync,
     connectedWallets,
-    currentUser.data?.user_id,
-    currentUser.data?.wallet,
+    currentUser.user_id,
+    currentUser.wallet,
     make,
     onError,
     onSuccess,


Reviews:
user: login: rickyrombo
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:30:52Z
user: login: DejayJD
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:35:34Z
user: login: schottra
body: I would add to your testing cases:
* Manager Mode (switching, adding/removing manager flow)
* Guest checkout
* Signup _with_ OTP
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T15:44:39Z
user: login: DejayJD
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T16:04:41Z
user: login: DejayJD
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T20:41:06Z

Review comments:
diff_hunk: @@ -0,0 +1,58 @@
+import { AudiusSdk } from '@audius/sdk'
+import { useQuery } from '@tanstack/react-query'
+import { useSelector } from 'react-redux'
+
+import { accountFromSDK } from '~/adapters/user'
+import { useAudiusQueryContext } from '~/audius-query'
+import { AccountUserMetadata, UserMetadata } from '~/models/User'
+import { getWalletAddresses } from '~/store/account/selectors'
+
+import { QUERY_KEYS } from '../../queryKeys'
+import { QueryKey, SelectableQueryOptions } from '../../types'
+
+export const getWalletAccountQueryKey = (wallet: string | null | undefined) =>
+  [
+    QUERY_KEYS.walletAccount,
+    wallet
+  ] as unknown as QueryKey<AccountUserMetadata | null>
+
+export const getWalletUserQueryKey = (wallet: string | null | undefined) =>
+  [QUERY_KEYS.walletUser, wallet] as unknown as QueryKey<UserMetadata | null>
path: packages/common/src/api/tan-query/users/account/useWalletUser.ts
user: login: rickyrombo
body: is it too soon to think about having this only cache the user ID and stick it's user metadata into the users cache (and the library etc elsewhere)?

Worried that updates/refetches of the current user will not effect this cache and this will get out of sync with the actual profile things...
created_at: 2025-05-02T19:30:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,58 @@
+import { AudiusSdk } from '@audius/sdk'
+import { useQuery } from '@tanstack/react-query'
+import { useSelector } from 'react-redux'
+
+import { accountFromSDK } from '~/adapters/user'
+import { useAudiusQueryContext } from '~/audius-query'
+import { AccountUserMetadata, UserMetadata } from '~/models/User'
+import { getWalletAddresses } from '~/store/account/selectors'
+
+import { QUERY_KEYS } from '../../queryKeys'
+import { QueryKey, SelectableQueryOptions } from '../../types'
+
+export const getWalletAccountQueryKey = (wallet: string | null | undefined) =>
+  [
+    QUERY_KEYS.walletAccount,
+    wallet
+  ] as unknown as QueryKey<AccountUserMetadata | null>
+
+export const getWalletUserQueryKey = (wallet: string | null | undefined) =>
+  [QUERY_KEYS.walletUser, wallet] as unknown as QueryKey<UserMetadata | null>
path: packages/common/src/api/tan-query/users/account/useWalletUser.ts
user: login: DejayJD
body: No thats a good catch, we should normalize this data 🫡
created_at: 2025-05-02T19:35:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,58 @@
+import { AudiusSdk } from '@audius/sdk'
+import { useQuery } from '@tanstack/react-query'
+import { useSelector } from 'react-redux'
+
+import { accountFromSDK } from '~/adapters/user'
+import { useAudiusQueryContext } from '~/audius-query'
+import { AccountUserMetadata, UserMetadata } from '~/models/User'
+import { getWalletAddresses } from '~/store/account/selectors'
+
+import { QUERY_KEYS } from '../../queryKeys'
+import { QueryKey, SelectableQueryOptions } from '../../types'
+
+export const getWalletAccountQueryKey = (wallet: string | null | undefined) =>
+  [
+    QUERY_KEYS.walletAccount,
+    wallet
+  ] as unknown as QueryKey<AccountUserMetadata | null>
+
+export const getWalletUserQueryKey = (wallet: string | null | undefined) =>
+  [QUERY_KEYS.walletUser, wallet] as unknown as QueryKey<UserMetadata | null>
path: packages/common/src/api/tan-query/users/account/useWalletUser.ts
user: login: schottra
body: The only caveat here is that I believe there are sagas elsewhere which modify the account data (mostly playlist library) and those need to be migrated simultaneously. Otherwise, I'm in favor of splitting them up asap.
created_at: 2025-05-05T15:40:01Z
author_association: CONTRIBUTOR
diff_hunk: @@ -200,13 +205,10 @@ export function* fetchAccountAsync({
     return
   }
 
-  const accountData: AccountUserMetadata | undefined = yield* call(
-    userApiFetchSaga.getUserAccount,
-    {
-      wallet
-    },
-    true // force refresh to get updated user w handle
-  )
+  const accountData = (yield* call([queryClient, queryClient.fetchQuery], {
+    queryKey: getWalletAccountQueryKey(web3WalletAddress),
path: packages/common/src/store/account/sagas.ts
user: login: schottra
body: I think you want this to be the `wallet`, not the web3 wallet?
Can confirm by testing manager mode, which will probably break here when the two wallets differ.
created_at: 2025-05-05T15:42:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -200,13 +205,10 @@ export function* fetchAccountAsync({
     return
   }
 
-  const accountData: AccountUserMetadata | undefined = yield* call(
-    userApiFetchSaga.getUserAccount,
-    {
-      wallet
-    },
-    true // force refresh to get updated user w handle
-  )
+  const accountData = (yield* call([queryClient, queryClient.fetchQuery], {
+    queryKey: getWalletAccountQueryKey(web3WalletAddress),
path: packages/common/src/store/account/sagas.ts
user: login: DejayJD
body: good catch, yes this should be the `wallet`
created_at: 2025-05-05T16:04:41Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,58 @@
+import { AudiusSdk } from '@audius/sdk'
+import { useQuery } from '@tanstack/react-query'
+import { useSelector } from 'react-redux'
+
+import { accountFromSDK } from '~/adapters/user'
+import { useAudiusQueryContext } from '~/audius-query'
+import { AccountUserMetadata, UserMetadata } from '~/models/User'
+import { getWalletAddresses } from '~/store/account/selectors'
+
+import { QUERY_KEYS } from '../../queryKeys'
+import { QueryKey, SelectableQueryOptions } from '../../types'
+
+export const getWalletAccountQueryKey = (wallet: string | null | undefined) =>
+  [
+    QUERY_KEYS.walletAccount,
+    wallet
+  ] as unknown as QueryKey<AccountUserMetadata | null>
+
+export const getWalletUserQueryKey = (wallet: string | null | undefined) =>
+  [QUERY_KEYS.walletUser, wallet] as unknown as QueryKey<UserMetadata | null>
path: packages/common/src/api/tan-query/users/account/useWalletUser.ts
user: login: DejayJD
body: Good callout but will be more relevant later when we actually move more account logic into tan-query. Currently my focus is just moving things out of audius-query - this PR mainly is mainly shifting from using audius-query to fetch inside a saga to using tq to fetch instead.
The data is being stored in tq but not really used anywhere yet. The new useConnectAndAssociateWallet hook is basically the only place using this hook & its actually just pulling from localStorage anyways so its not even doing any fetching atm.
created_at: 2025-05-05T20:41:06Z
author_association: CONTRIBUTOR

PR comments:
user: login: changeset-bot[bot]
created_at: 2025-05-02T19:12:28Z
body: ###  ⚠️  No Changeset found

Latest commit: 5096af33d522f15db83973bcd5af9dcbafbea659

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/AudiusProject/audius-protocol/new/jd/deprecate-aquery-user-sagas?filename=.changeset/slimy-jeans-burn.md&value=---%0A%22%40audius%2Fcommon%22%3A%20patch%0A%22%40audius%2Fweb%22%3A%20patch%0A---%0A%0A%5BPE-6095%5D%20Deprecate%20audius-query%20user%20saga%20fetches%0A)


author_association: NONE
user: login: DejayJD
created_at: 2025-05-02T19:13:53Z
body: @rickyrombo @schottra added yall as potential reviewers but optional! Just since yall have account/wallet context
author_association: CONTRIBUTOR