Skip to content

Commit

Permalink
fix: avoid crash on empty NFT details (#7398)
Browse files Browse the repository at this point in the history
* fix: avoid crash when clicking empty NFT

* clean up

* fixes

---------

Co-authored-by: marc2332 <[email protected]>
Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
3 people authored Sep 12, 2023
1 parent f17ff60 commit 4db889d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
const { standard, version, type, uri, description, issuerName, collectionName, attributes, soonaverseAttributes } =
nft?.parsedMetadata || {}
const issuerAddress = getBech32AddressFromAddressTypes(issuer)
const collectionId = getHexAddressFromAddressTypes(issuer)
const issuerAddress = issuer ? getBech32AddressFromAddressTypes(issuer) : undefined
const collectionId = issuer ? getHexAddressFromAddressTypes(issuer) : undefined
let detailsList: {
[key in string]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
export let activity: NftActivity
$: nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity?.nftId)
$: issuerAddress = getBech32AddressFromAddressTypes(nft?.issuer)
$: collectionId = getHexAddressFromAddressTypes(nft?.issuer)
$: nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
$: issuerAddress = nft?.issuer && getBech32AddressFromAddressTypes(nft.issuer)
$: collectionId = nft?.issuer && getHexAddressFromAddressTypes(nft.issuer)
let detailsList: IKeyValueBoxList
$: detailsList = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function handleNewOutputEventInternal(accountIndex: number, payload

const output = outputData.output as AliasOutput

const address = getBech32AddressFromAddressTypes(outputData?.address)
const address = getBech32AddressFromAddressTypes(outputData.address)
const isNewAliasOutput =
output.type === OutputType.Alias &&
output.stateIndex === 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { api } from '@core/profile-manager'
import { Address, AddressType, AliasAddress, Ed25519Address, NftAddress } from '@iota/sdk/out/types'
import { getNetworkHrp } from '@core/profile'

export function getBech32AddressFromAddressTypes(address: Address): string | undefined {
export function getBech32AddressFromAddressTypes(address: Address): string {
const hrp = getNetworkHrp()
switch (address.type) {
case AddressType.Ed25519:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address, AddressType, AliasAddress, Ed25519Address, NftAddress } from '@iota/sdk/out/types'

export function getHexAddressFromAddressTypes(address: Address): string {
switch (address?.type) {
switch (address.type) {
case AddressType.Ed25519:
return (address as Ed25519Address).pubKeyHash
case AddressType.Alias:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getSenderFromOutput(output: CommonOutput): Subject | undefined {
const storageOrExpirationUnlockCondition = unlockCondition as
| StorageDepositReturnUnlockCondition
| ExpirationUnlockCondition
const address = getBech32AddressFromAddressTypes(storageOrExpirationUnlockCondition?.returnAddress)
const address = getBech32AddressFromAddressTypes(storageOrExpirationUnlockCondition.returnAddress)
if (address) {
return getSubjectFromAddress(address)
}
Expand Down

0 comments on commit 4db889d

Please sign in to comment.