From 9cb4ccce863181d2424dcd0ee543a7197295077a Mon Sep 17 00:00:00 2001 From: CJ42 Date: Wed, 30 Oct 2024 17:09:34 +0100 Subject: [PATCH] fix: repair check when adding missing assets already owned --- pages/settings/missing-assets/[assetAddress]/add.vue | 9 ++++++++- pages/settings/missing-assets/index.vue | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pages/settings/missing-assets/[assetAddress]/add.vue b/pages/settings/missing-assets/[assetAddress]/add.vue index 4774b529..2a64010e 100644 --- a/pages/settings/missing-assets/[assetAddress]/add.vue +++ b/pages/settings/missing-assets/[assetAddress]/add.vue @@ -5,6 +5,8 @@ import type { UniversalProfile } from '@/contracts' import type { AbiItem } from 'web3-utils' const connectedProfile = useProfile().connectedProfile() +const address = computed(() => connectedProfile.value?.address) +const assetsData = useProfileAssets()(address.value) const assetAddress = useRouter().currentRoute.value.params?.assetAddress const isPending = ref(false) const { providerWeb3Instance } = useBaseProvider() @@ -27,11 +29,16 @@ const handleAddAsset = async () => { ).filter(([, value]) => value)[0]?.[0] const profileAddress = connectedProfile.value?.address + const filteredAssetsAddresses = assetsData.value + ?.filter(asset => asset.isOwned) + .map(asset => asset.address) + .filter(asset => !!asset) + const { keys, values } = generateAddReceivedAssetKeys( assetAddress, interfaceId, profileAddress, - connectedProfile.value?.receivedAssets + filteredAssetsAddresses ) const { contract } = providerWeb3Instance.value const profileContract = contract( diff --git a/pages/settings/missing-assets/index.vue b/pages/settings/missing-assets/index.vue index 343a6327..42137486 100644 --- a/pages/settings/missing-assets/index.vue +++ b/pages/settings/missing-assets/index.vue @@ -6,6 +6,8 @@ import { balanceOfABI } from '@/shared/abis/balanceOfABI' import type { LSP7DigitalAsset as LSP7DigitalAssetInterface } from '@/contracts' const connectedProfile = useProfile().connectedProfile() +const address = computed(() => connectedProfile.value?.address) +const assetsData = useProfileAssets()(address.value) const { formatMessage } = useIntl() const checkError = ref('') const assetAddress = ref('') @@ -60,7 +62,11 @@ const handleInput = async (customEvent: CustomEvent) => { assertAddress(assetAddress.value) // check if user doesn't already have the asset - if (connectedProfile.value?.receivedAssets?.includes(assetAddress.value)) { + const filteredAssetsAddresses = assetsData.value + ?.filter(asset => asset.isOwned) + .map(asset => asset.address) + + if (filteredAssetsAddresses?.includes(assetAddress.value)) { checkError.value = formatMessage('errors_already_owned') return }