diff --git a/src/services/subsocial/evmAddresses/mutation.tsx b/src/services/subsocial/evmAddresses/mutation.tsx index 13cb77a75..c15dfa8ae 100644 --- a/src/services/subsocial/evmAddresses/mutation.tsx +++ b/src/services/subsocial/evmAddresses/mutation.tsx @@ -5,6 +5,7 @@ import { getAccountDataQuery } from '@/services/subsocial/evmAddresses' import { useSendEvent } from '@/stores/analytics' import { MutationConfig } from '@/subsocial-query' import { useSubsocialMutation } from '@/subsocial-query/subsocial/mutation' +import { convertAddressToSubsocialAddress } from '@/utils/account' import { useQueryClient } from '@tanstack/react-query' import { useState } from 'react' import { useDisconnect } from 'wagmi' @@ -74,7 +75,10 @@ export function useLinkEvmAddress({ mutateAccountsDataCache(address) }, onSuccess: async ({ address }) => { - getAccountDataQuery.invalidate(client, address) + getAccountDataQuery.invalidate( + client, + convertAddressToSubsocialAddress(address) + ) setOnCallbackLoading(false) sendEvent('evm-address-linked', undefined, { evmLinked: true }) @@ -126,21 +130,29 @@ export function useUnlinkEvmAddress(config?: MutationConfig) { config, { txCallbacks: { - onStart: () => setOnCallbackLoading(true), + onStart: ({ address }) => { + setOnCallbackLoading(true) + mutateAccountsDataCache(address) + }, onSend: ({ address }) => { - getAccountDataQuery.setQueryData(client, address, (data) => { - if (!data) return data - return { - ...data, - evmAddress: null, - ensNames: null, + getAccountDataQuery.setQueryData( + client, + convertAddressToSubsocialAddress(address), + (data) => { + if (!data) return data + return { + ...data, + evmAddress: null, + ensNames: null, + } } - }) + ) }, onSuccess: async ({ address }) => { - await mutateAccountsDataCache(address) - - getAccountDataQuery.invalidate(client, address) + getAccountDataQuery.invalidate( + client, + convertAddressToSubsocialAddress(address) + ) setOnCallbackLoading(false) disconnect() diff --git a/src/stores/my-account.tsx b/src/stores/my-account.tsx index 91640cf3c..9a436c7c2 100644 --- a/src/stores/my-account.tsx +++ b/src/stores/my-account.tsx @@ -203,7 +203,11 @@ const useMyAccountBase = create()((set, get) => ({ const { connectedWallet } = get() if (!connectedWallet) return parentProxyAddressStorage.set(connectedWallet.address) - set({ parentProxyAddress: connectedWallet.address }) + set({ + parentProxyAddress: convertAddressToSubsocialAddress( + connectedWallet.address + ), + }) }, disconnectProxy: () => { get().connectedWallet?._unsubscribeEnergy?.() @@ -393,7 +397,8 @@ const useMyAccountBase = create()((set, get) => ({ set({ isInitialized: true, - parentProxyAddress: parentProxyAddress ?? undefined, + parentProxyAddress: + convertAddressToSubsocialAddress(parentProxyAddress ?? '') ?? undefined, }) if (parentProxyAddress) {