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 for adding missing assets already owned (#519)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominik Zborowski <[email protected]>
Co-authored-by: Jenea Vranceanu <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent 3a6aec9 commit b4954b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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

0 comments on commit b4954b0

Please sign in to comment.