Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
fix: repair check when adding missing assets already owned
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Oct 30, 2024
1 parent 964f05c commit 9cb4ccc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pages/settings/missing-assets/[assetAddress]/add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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<UniversalProfile>(
Expand Down
8 changes: 7 additions & 1 deletion pages/settings/missing-assets/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9cb4ccc

Please sign in to comment.