Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into chore/rename-selec…
Browse files Browse the repository at this point in the history
…ted-chain-to-selected-network
  • Loading branch information
nicole-obrien committed May 2, 2024
2 parents f863c44 + d2aa87d commit 0a95863
Show file tree
Hide file tree
Showing 51 changed files with 227 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import { localize } from '@core/i18n'
import { isEvmNetwork } from '@core/network'
import { IIrc27Nft, Nft, getPrimaryNftUrl, isNftLocked, isValidNftUri } from '@core/nfts'
import { addNftsToDownloadQueue, updateNftInAllAccountNfts } from '@core/nfts/actions'
import { updatePersistedNft } from '@core/nfts/stores'
import { addNftsToDownloadQueue } from '@core/nfts/actions'
import { updateNftForAllAccounts, updatePersistedNft } from '@core/nfts/stores'
import { activeProfile, updateActiveProfile } from '@core/profile/stores'
import { Platform } from '@core/app'
Expand Down Expand Up @@ -36,14 +36,14 @@
}
updatePersistedNft(nft.id, { downloadMetadata: {} })
updateNftInAllAccountNfts(nft.id, { downloadMetadata: {}, isLoaded: false })
updateNftForAllAccounts({ id: nft.id, downloadMetadata: {}, isLoaded: false })
addNftsToDownloadQueue([nft])
menu?.close()
}
function onHideClick(): void {
updatePersistedNft(nft.id, { hidden: !nft.hidden })
updateNftInAllAccountNfts(nft.id, { hidden: !nft.hidden })
updateNftForAllAccounts({ id: nft.id, hidden: !nft.hidden })
menu?.close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { ExplorerEndpoint } from '@core/network'
import { getDefaultExplorerUrl } from '@core/network/utils'
import { NftStandard } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { Nft } from '@core/nfts/interfaces'
import { ownedNfts, selectedNftId } from '@core/nfts/stores'
import { ownedNfts, selectedNftId, getNftByIdForAccount } from '@core/nfts/stores'
import { CollectiblesRoute, DashboardRoute, collectiblesRouter, dashboardRouter } from '@core/router'
import { getTokenFromSelectedAccountTokens } from '@core/token/stores'
import { buildUrl, setClipboard, truncateString } from '@core/utils'
Expand Down Expand Up @@ -45,7 +44,7 @@
_activity.tokenTransfer.standard === NftStandard.Erc721 ||
_activity.tokenTransfer.standard === NftStandard.Irc27
) {
return getNftByIdFromAllAccountNfts($selectedAccountIndex, _activity.tokenTransfer.tokenId) as Nft
return getNftByIdForAccount($selectedAccountIndex, _activity.tokenTransfer.tokenId)
}
}
}
Expand All @@ -62,7 +61,7 @@
const { tokenId, rawAmount, standard } = _activity.tokenTransfer
if (standard === NftStandard.Erc721 || standard === NftStandard.Irc27) {
return {
nft: getNftByIdFromAllAccountNfts($selectedAccountIndex, _activity.tokenTransfer.tokenId) as Nft,
nft: getNftByIdForAccount($selectedAccountIndex, _activity.tokenTransfer.tokenId) as Nft,
}
} else {
const token = getTokenFromSelectedAccountTokens(tokenId, _activity.sourceNetworkId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import { getTransferInfoFromTransactionData } from '@core/layer-2/utils/getTransferInfoFromTransactionData'
import { TokenTransferData } from '@core/wallet'
import { Nft } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { Alert, Link, Table, Text } from '@bloomwalletio/ui'
import { PopupId, closePopup, modifyPopupState, openPopup } from '@desktop/auxiliary/popup'
import { buildUrl, truncateString } from '@core/utils'
Expand All @@ -33,6 +32,7 @@
import { LegacyTransaction } from '@ethereumjs/tx'
import { getActiveProfileId } from '@core/profile/stores'
import { IAccountState } from '@core/account'
import { getNftByIdForAccount } from '@core/nfts/stores'
export let preparedTransaction: EvmTransactionData
export let evmNetwork: IEvmNetwork
Expand Down Expand Up @@ -77,7 +77,7 @@
break
}
case StardustActivityType.Nft: {
nft = getNftByIdFromAllAccountNfts($selectedAccount.index, transferInfo.nftId)
nft = getNftByIdForAccount($selectedAccount.index, transferInfo.nftId)
break
}
case StardustActivityType.SmartContract: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
import PopupTemplate from '../PopupTemplate.svelte'
import { closePopup } from '@desktop/auxiliary/popup'
import { showNotification } from '@auxiliary/notification'
import {
addNftsToDownloadQueue,
addNewTrackedNftToActiveProfile,
persistErc721Nft,
updateAllAccountNftsForAccount,
} from '@core/nfts/actions'
import { addNftsToDownloadQueue, addNewTrackedNftToActiveProfile, persistErc721Nft } from '@core/nfts/actions'
import { buildNftFromPersistedErc721Nft } from '@core/nfts/utils'
import { activeAccounts } from '@core/profile/stores'
import { getAddressFromAccountForNetwork } from '@core/account'
import { TokenTrackingStatus } from '@core/token'
import { selectedAccount } from '@core/account/stores'
import { addOrUpdateNftForAccount } from '@core/nfts/stores'
let busy = false
Expand Down Expand Up @@ -46,7 +42,7 @@
for (const account of $activeAccounts) {
const l2Address = getAddressFromAccountForNetwork(account, networkId)
const nft = buildNftFromPersistedErc721Nft(persistedNft, l2Address)
updateAllAccountNftsForAccount(account.index, nft)
addOrUpdateNftForAccount(account.index, nft)
void addNftsToDownloadQueue([nft])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network'
import { getDefaultExplorerUrl } from '@core/network/utils'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { ownedNfts, selectedNftId } from '@core/nfts/stores'
import { getNftByIdForAccount, ownedNfts, selectedNftId } from '@core/nfts/stores'
import { CollectiblesRoute, DashboardRoute, collectiblesRouter, dashboardRouter } from '@core/router'
import { buildUrl, setClipboard, truncateString } from '@core/utils'
import { claimActivity, rejectActivity } from '@core/wallet'
Expand All @@ -34,7 +33,7 @@
$: transactionAssets = getTransactionAssets(activity, $selectedAccountIndex)
$: nft =
activity.type === StardustActivityType.Nft
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
? getNftByIdForAccount($selectedAccountIndex, activity.nftId)
: undefined
$: nftIsOwned = nft ? $ownedNfts.some((_nft) => _nft.id === nft?.id) : false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import { handleError } from '@core/error/handlers'
import { EvmNetworkId, NetworkNamespace, getEvmNetwork } from '@core/network'
import { buildNftFromPersistedErc721Nft } from '@core/nfts'
import { addNftsToDownloadQueue, updateAllAccountNftsForAccount } from '@core/nfts/actions'
import { addNftsToDownloadQueue } from '@core/nfts/actions'
import { persistErc721Nft } from '@core/nfts/actions/persistErc721Nft'
import { ownedNfts } from '@core/nfts/stores'
import { addOrUpdateNftForAccount, ownedNfts } from '@core/nfts/stores'
import { TideApi } from '@core/tide/apis'
import { onDestroy, onMount } from 'svelte'
import Leaderboard from '../components/Leaderboard.svelte'
Expand Down Expand Up @@ -79,7 +79,7 @@
if (persistedNft) {
const nft = buildNftFromPersistedErc721Nft(persistedNft, accountAddress)
void addNftsToDownloadQueue([nft])
updateAllAccountNftsForAccount(index, nft)
addOrUpdateNftForAccount(index, nft)
}
} catch (_) {
// Switching account too swiftly results in an error from persistErc721Nft.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import { DownloadErrorType, DownloadWarningType, IDownloadMetadata, Nft, NftDownloadOptions } from '@core/nfts'
import { Alert, Link, Text } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { addNftsToDownloadQueue, updateNftInAllAccountNfts } from '@core/nfts/actions'
import { addNftsToDownloadQueue } from '@core/nfts/actions'
import { getFormattedFileSize } from '@core/utils'
import { updateNftForAllAccounts } from '@core/nfts/stores'
export let type: DownloadErrorType | DownloadWarningType | undefined
export let message: string | undefined
Expand Down Expand Up @@ -54,7 +55,8 @@
break
}
updateNftInAllAccountNfts(nft.id, {
updateNftForAllAccounts({
id: nft.id,
isLoaded: false,
downloadMetadata: { ...nft.downloadMetadata, warning: undefined, error: undefined },
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<script lang="ts">
import { Pane } from '@ui'
import { Collection, Nft } from '@core/nfts/interfaces'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { NftStandard } from '@core/nfts/enums'
import { allAccountNfts, selectedAccountCollections, selectedCollectionId, selectedNftId } from '@core/nfts/stores'
import {
activeProfileNftsPerAccount,
getNftByIdForAccount,
selectedAccountCollections,
selectedCollectionId,
selectedNftId,
} from '@core/nfts/stores'
import { selectedAccountIndex } from '@core/account/stores'
import { CollectionDetails, Erc721CollectibleDetails, Irc27CollectibleDetails } from '../components'
import { time } from '@core/app/stores'
Expand All @@ -12,10 +17,10 @@
let nft: Nft | undefined
let collection: Collection | undefined
$: $allAccountNfts, (nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, $selectedNftId))
$: $activeProfileNftsPerAccount, (nft = getNftByIdForAccount($selectedAccountIndex, $selectedNftId))
$: collection = $selectedCollectionId ? $selectedAccountCollections[$selectedCollectionId] : undefined
$: returnIfNftWasSent($allAccountNfts[$selectedAccountIndex], $time)
$: returnIfNftWasSent($activeProfileNftsPerAccount[$selectedAccountIndex], $time)
function returnIfNftWasSent(ownedNfts: Nft[], currentTime: Date): void {
if (!nft) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import { Activity, StardustActivityType, isEvmTokenActivity } from '@core/activity'
import { getTokenFromActivity } from '@core/activity/utils/getTokenFromActivity'
import { BASE_TOKEN_ID } from '@core/token'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { getNftByIdForAccount } from '@core/nfts/stores'
import { selectedAccountIndex } from '@core/account/stores'
import { NetworkNamespace } from '@core/network/enums'
import { EvmActivityType } from '@core/activity/enums/evm'
import { NftStandard } from '@core/nfts'
import { NftStandard } from '@core/nfts/enums'
import { convertCamelCaseToPhrase } from '@core/utils/string'
export let activity: Activity
Expand All @@ -29,7 +29,7 @@
standardPill = ''
}
} else if (activity.type === StardustActivityType.Nft) {
const nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
const nft = getNftByIdForAccount($selectedAccountIndex, activity.nftId)
standardPill = nft?.standard ?? ''
typePill = 'nft'
} else if (activity.type === StardustActivityType.Alias) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
import { darkMode, time } from '@core/app/stores'
import { localize } from '@core/i18n'
import { NetworkNamespace } from '@core/network'
import { NftStandard } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { NftStandard } from '@core/nfts/enums'
import { getNftByIdForAccount, selectedAccountNfts } from '@core/nfts/stores'
import { Nft } from '@core/nfts/interfaces'
import { selectedAccountNfts } from '@core/nfts/stores'
import { ITokenWithBalance } from '@core/token'
import { selectedAccountTokens } from '@core/token/stores'
import { GovernanceAvatar, NftAvatar, TokenAvatar } from '@ui'
Expand Down Expand Up @@ -47,10 +46,10 @@
activity.tokenTransfer.standard === NftStandard.Erc721 ||
activity.tokenTransfer.standard === NftStandard.Irc27
) {
return getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.tokenTransfer.tokenId)
return getNftByIdForAccount($selectedAccountIndex, activity.tokenTransfer.tokenId)
}
} else if (activity.namespace === NetworkNamespace.Stardust && activity.type === StardustActivityType.Nft) {
return getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
return getNftByIdForAccount($selectedAccountIndex, activity.nftId)
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { DownloadPermission } from '@core/nfts'
import { activeProfile, updateActiveProfileSettings } from '@core/profile/stores'
import SettingsSection from '../SettingsSection.svelte'
import { allAccountNfts } from '@core/nfts/stores'
import { getAllNftsForActiveProfile } from '@core/nfts/stores'
import { addNftsToDownloadQueue } from '@core/nfts/actions'
const options: IOption[] = [
Expand Down Expand Up @@ -40,7 +40,7 @@
},
})
const allNfts = $allAccountNfts.flatMap((nfts) => nfts)
const allNfts = getAllNftsForActiveProfile()
await addNftsToDownloadQueue(allNfts)
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { Platform } from '@core/app'
import { localize } from '@core/i18n'
import { DownloadWarningType, Nft } from '@core/nfts'
import { addNftsToDownloadQueue, updateNftInAllAccountNfts } from '@core/nfts/actions'
import { persistedNftForActiveProfile, selectedAccountNfts } from '@core/nfts/stores'
import { addNftsToDownloadQueue } from '@core/nfts/actions'
import { persistedNftForActiveProfile, selectedAccountNfts, updateNftForAllAccounts } from '@core/nfts/stores'
import { activeProfile, updateActiveProfileSettings } from '@core/profile/stores'
import SettingsSection from '../SettingsSection.svelte'
Expand Down Expand Up @@ -69,7 +69,8 @@
}
await Platform.deleteFile(nft.downloadMetadata.filePath)
updateNftInAllAccountNfts(nft.id, {
updateNftForAllAccounts({
id: nft.id,
isLoaded: false,
downloadMetadata: {
...nft.downloadMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
import { Button } from '@bloomwalletio/ui'
import { Platform } from '@core/app'
import { localize } from '@core/i18n'
import {
addNftsToDownloadQueue,
stopDownloadingNftMediaFromQueue,
updateNftInAllAccountNfts,
} from '@core/nfts/actions'
import { selectedAccountNfts } from '@core/nfts/stores'
import { addNftsToDownloadQueue, stopDownloadingNftMediaFromQueue } from '@core/nfts/actions'
import { selectedAccountNfts, updateNftForAllAccounts } from '@core/nfts/stores'
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup'
import SettingsSection from '../SettingsSection.svelte'
Expand All @@ -34,7 +30,7 @@
await Promise.all(
$selectedAccountNfts.map(async (nft) => {
await Platform.deleteFile(nft.downloadMetadata?.filePath)
updateNftInAllAccountNfts(nft.id, { isLoaded: false })
updateNftForAllAccounts({ id: nft.id, isLoaded: false })
})
)
void addNftsToDownloadQueue($selectedAccountNfts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { EvmActivity } from '@core/activity'
import { EvmActivityType } from '@core/activity/enums/evm'
import { Nft, NftStandard } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { getNftByIdForAccount } from '@core/nfts/stores'
import { KeyValue, NftMetadataTable, PopupTab, getTabItems } from '@ui'
import { EvmGenericInformation, EvmSmartContractInformation } from './info'
import { localize } from '@core/i18n'
Expand All @@ -27,7 +27,7 @@
activity.tokenTransfer.standard === NftStandard.Erc721 ||
activity.tokenTransfer.standard === NftStandard.Irc27
) {
nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.tokenTransfer.tokenId)
nft = getNftByIdForAccount($selectedAccountIndex, activity.tokenTransfer.tokenId)
tabs = getTabItems([PopupTab.Transaction, PopupTab.NftMetadata])
} else {
tabs = getTabItems([PopupTab.Transaction])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { Tabs } from '@bloomwalletio/ui'
import { selectedAccountIndex } from '@core/account/stores'
import { StardustActivity, StardustActivityType } from '@core/activity'
import { Nft } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { Nft } from '@core/nfts/interfaces'
import { getNftByIdForAccount } from '@core/nfts/stores'
import { TokenMetadata } from '@core/token'
import { getPersistedToken } from '@core/token/stores'
import { KeyValue, NftMetadataTable, PopupTab, TokenMetadataTable, getTabItems } from '@ui'
Expand All @@ -24,7 +24,7 @@
$: {
const storedNft =
activity.type === StardustActivityType.Nft
? getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
? getNftByIdForAccount($selectedAccountIndex, activity.nftId)
: undefined
hasMetadata = !!storedNft?.metadata
}
Expand All @@ -47,7 +47,7 @@
...(hasMetadata ? [PopupTab.NftMetadata] : []),
...(activity.smartContract ? [PopupTab.SmartContract] : []),
])
nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)
nft = getNftByIdForAccount($selectedAccountIndex, activity.nftId)
break
case StardustActivityType.Foundry:
tabs = getTabItems([PopupTab.Transaction, PopupTab.Foundry, PopupTab.Token])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network/enums'
import { getDefaultExplorerUrl } from '@core/network/utils'
import { NftStandard } from '@core/nfts'
import { getNftByIdFromAllAccountNfts } from '@core/nfts/actions'
import { NftStandard } from '@core/nfts/enums'
import { getNftByIdForAccount } from '@core/nfts/stores'
import { buildUrl } from '@core/utils'
import { getBech32AddressFromAddressTypes, getHexAddressFromAddressTypes } from '@core/wallet'
import { type Address, AddressType } from '@iota/sdk/out/types'
export let activity: StardustNftActivity
$: nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity?.nftId)
$: nft = getNftByIdForAccount($selectedAccountIndex, activity?.nftId)
$: issuer = nft?.standard === NftStandard.Irc27 ? nft?.issuer : undefined
function onNftIdClick(nftId: string) {
Expand Down
Loading

0 comments on commit 0a95863

Please sign in to comment.