diff --git a/packages/shared/src/lib/core/nfts/actions/getPersistedErc721Nfts.ts b/packages/shared/src/lib/core/nfts/actions/getPersistedErc721NftsForNetwork.ts similarity index 59% rename from packages/shared/src/lib/core/nfts/actions/getPersistedErc721Nfts.ts rename to packages/shared/src/lib/core/nfts/actions/getPersistedErc721NftsForNetwork.ts index 5b83de8c32..db8a148913 100644 --- a/packages/shared/src/lib/core/nfts/actions/getPersistedErc721Nfts.ts +++ b/packages/shared/src/lib/core/nfts/actions/getPersistedErc721NftsForNetwork.ts @@ -3,12 +3,15 @@ import { getActiveProfile } from '@core/profile/stores' import { NftStandard } from '../enums' import { IPersistedErc721Nft } from '../interfaces' import { persistedNfts } from '../stores' +import { NetworkId } from '@core/network' -export function getPersistedErc721Nfts(): IPersistedErc721Nft[] { +export function getPersistedErc721NftsForNetwork(networkId: NetworkId): IPersistedErc721Nft[] { const activeProfileId = getActiveProfile()?.id if (activeProfileId) { const profileNfts = Object.values(get(persistedNfts)[activeProfileId] ?? {}) - return profileNfts.filter(({ standard }) => standard === NftStandard.Erc721) as IPersistedErc721Nft[] + return profileNfts.filter( + ({ standard, networkId: _networkId }) => standard === NftStandard.Erc721 && networkId === networkId + ) as IPersistedErc721Nft[] } else { throw new Error('Unable to get active profile') } diff --git a/packages/shared/src/lib/core/nfts/actions/index.ts b/packages/shared/src/lib/core/nfts/actions/index.ts index fc75891e32..7489b48b4f 100644 --- a/packages/shared/src/lib/core/nfts/actions/index.ts +++ b/packages/shared/src/lib/core/nfts/actions/index.ts @@ -4,7 +4,7 @@ export * from './buildNftFromNftOutput' export * from './checkForUntrackedNfts' export * from './downloadNextNftInQueue' export * from './getNftByIdFromAllAccountNfts' -export * from './getPersistedErc721Nfts' +export * from './getPersistedErc721NftsForNetwork' export * from './interruptNftDownloadAfterTimeout' export * from './isNftPersisted' export * from './loadNftsForActiveProfile' diff --git a/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts b/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts index 30e2a07751..5e0e46c9e8 100644 --- a/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts +++ b/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts @@ -13,7 +13,7 @@ import { Nft } from '../interfaces' import { buildNftFromPersistedErc721Nft, getNftsFromNftIds } from '../utils' import { addNftsToDownloadQueue } from './addNftsToDownloadQueue' import { buildNftFromNftOutput } from './buildNftFromNftOutput' -import { getPersistedErc721Nfts } from './getPersistedErc721Nfts' +import { getPersistedErc721NftsForNetwork } from './getPersistedErc721NftsForNetwork' import { setAccountNftsInAllAccountNfts } from './setAccountNftsInAllAccountNfts' export async function loadNftsForActiveProfile(): Promise { @@ -70,7 +70,7 @@ export async function loadNftsForAccount(profileId: string, account: IAccountSta if (!evmAddress) { continue } - const erc721Nfts = getPersistedErc721Nfts() + const erc721Nfts = getPersistedErc721NftsForNetwork(evmNetwork.id) const convertedNfts: Nft[] = erc721Nfts.map((persistedErc721Nft) => buildNftFromPersistedErc721Nft(persistedErc721Nft, evmAddress) )