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

fix: repair check for adding missing assets already owned #519

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ALGOLIA_APPLICATION_ID=YOUR_ALGOLIA_APPLICATION_ID
ALGOLIA_API_KEY=YOUR_ALGOLIA_API_KEY

# dev envs not needed in production
YATA_API_TOKEN=YOUR_YATA_API_TOKEN # yata api token for fetching translations

Expand Down
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)
.filter(asset => !!asset)
if (filteredAssetsAddresses?.includes(assetAddress.value)) {
checkError.value = formatMessage('errors_already_owned')
return
}
Expand Down
Loading