Skip to content

Commit

Permalink
Merge commit '66c07d0474452c15a44e96442e3f075e896874ac' into 2392-cre…
Browse files Browse the repository at this point in the history
…ate-collectionsgallery-and-collectionsgalleryitem
  • Loading branch information
MarkNerdi committed Apr 30, 2024
2 parents 96503fd + 66c07d0 commit 4f4d854
Show file tree
Hide file tree
Showing 68 changed files with 482 additions and 446 deletions.
8 changes: 4 additions & 4 deletions packages/desktop/components/menus/TokenActionsMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@
}
function onUnverifyClick(): void {
unverifyToken(token.id, NotVerifiedStatus.Skipped)
unverifyToken(token, NotVerifiedStatus.Skipped)
updatePopupProps({
token: { ...token, verification: { verified: false, status: NotVerifiedStatus.Skipped } },
})
menu?.close()
}
function onVerifyClick(): void {
verifyToken(token.id, VerifiedStatus.SelfVerified)
verifyToken(token, VerifiedStatus.SelfVerified)
updatePopupProps({
token: { ...token, verification: { verified: true, status: VerifiedStatus.SelfVerified } },
})
menu?.close()
}
function onUnhideClick(): void {
unhideToken(token.id)
unhideToken(token)
hideActivitiesForHiddenTokens()
updatePopupProps({
token: { ...token, hidden: false },
Expand All @@ -48,7 +48,7 @@
}
function onHideClick(): void {
hideToken(token.id)
hideToken(token)
hideActivitiesForHiddenTokens()
updatePopupProps({
token: { ...token, hidden: true },
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/menus/TokenListMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { showNotification } from '@auxiliary/notification'
import { IconName, Menu } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { refreshAccountTokensForActiveProfile } from '@core/token/actions'
import { loadTokensForAllAccountBalances } from '@core/token/actions'
import { PopupId, closePopup, openPopup } from '../../lib/auxiliary/popup'
import { fetchL2BalanceForAllAccounts } from '@core/layer-2'
Expand All @@ -27,7 +27,7 @@
}
function refreshTokenMetadata(): void {
refreshAccountTokensForActiveProfile(true)
loadTokensForAllAccountBalances(true)
showNotification({
variant: 'success',
text: localize('notifications.refreshTokenMetadata.success'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import { Error } from '@bloomwalletio/ui'
import { handleError } from '@core/error/handlers/handleError'
import PopupTemplate from '../PopupTemplate.svelte'
import { getBaseToken } from '@core/profile/actions'
let isBusy = false
let error: string | undefined
const network = getL1Network()
async function onConfirmClick(): Promise<void> {
error = undefined
try {
Expand All @@ -33,7 +34,7 @@
<PopupTemplate
title={localize('popups.faucetRequest.title')}
description={localize('popups.faucetRequest.body', {
values: { token: getBaseToken().name, network: getL1Network()?.name },
values: { token: network.baseToken.name, network: network.name },
})}
backButton={{
text: localize('actions.cancel'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { checkActiveProfileAuth, getBaseToken, loadAccounts } from '@core/profile/actions'
import { activeAccounts, activeProfile, getActiveProfileId, visibleActiveAccounts } from '@core/profile/stores'
import { formatTokenAmountBestMatch } from '@core/token'
import { refreshAccountTokensForActiveProfile } from '@core/token/actions'
import { loadTokensForAllAccountBalances } from '@core/token/actions'
import { closePopup } from '@desktop/auxiliary/popup'
import { onDestroy } from 'svelte'
import PopupTemplate from '../PopupTemplate.svelte'
Expand Down Expand Up @@ -134,7 +134,7 @@
onDestroy(async () => {
if (hasUsedWalletFinder) {
const profileId = getActiveProfileId()
await refreshAccountTokensForActiveProfile()
await loadTokensForAllAccountBalances()
await generateAndStoreActivitiesForAllAccounts(profileId)
loadNftsForActiveProfile()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import { SendFlowRoute, SendFlowRouter, sendFlowRouter } from '@views/dashboard/send-flow'
import PopupTemplate from '../PopupTemplate.svelte'
export let token: ITokenWithBalance | undefined
export let token: ITokenWithBalance
export let activityId: string | undefined = undefined
$: isNewToken = token?.verification?.status === NotVerifiedStatus.New
$: isNewToken = token.verification?.status === NotVerifiedStatus.New
function onSkipClick(): void {
unverifyToken(token?.id, NotVerifiedStatus.Skipped)
unverifyToken(token, NotVerifiedStatus.Skipped)
if (activityId) {
openPopup({
id: PopupId.ActivityDetails,
Expand All @@ -31,7 +31,7 @@
}
function onVerifyClick(): void {
verifyToken(token?.id, VerifiedStatus.SelfVerified)
verifyToken(token, VerifiedStatus.SelfVerified)
if (activityId) {
openPopup({
id: PopupId.ActivityDetails,
Expand All @@ -45,7 +45,7 @@
}
function onSendClick(): void {
const sendFlowType = token?.id === BASE_TOKEN_ID ? SendFlowType.BaseCoinTransfer : SendFlowType.TokenTransfer
const sendFlowType = token.id === BASE_TOKEN_ID ? SendFlowType.BaseCoinTransfer : SendFlowType.TokenTransfer
setSendFlowParameters({
type: sendFlowType,
[sendFlowType]: {
Expand All @@ -62,7 +62,7 @@
</script>

<PopupTemplate
title={token?.metadata?.name}
title={token.metadata?.name}
backButton={isNewToken
? {
text: localize('actions.skip'),
Expand All @@ -75,7 +75,7 @@
}}
>
<div slot="menu">
{#if token?.standard === TokenStandard.Irc30 || token?.standard === TokenStandard.Erc20}
{#if token.standard === TokenStandard.Irc30 || token.standard === TokenStandard.Erc20}
<TokenActionsMenu {token} />
{/if}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@
$: selectedNetworkId = selectorOptions[selectedIndex]?.networkId
$: selectedRecipient = selectorOptions[selectedIndex]?.selectedRecipient
let hasNetworkRecipientError: boolean = false
$: {
let hasInsufficientFunds = false
$: $sendFlowParameters, void checkFundsForGas()
async function checkFundsForGas(): Promise<void> {
if (!$sendFlowParameters) {
return
}
const originNetworkId = getNetworkIdFromSendFlowParameters($sendFlowParameters)
if (originNetworkId && isEvmNetwork(originNetworkId)) {
hasNetworkRecipientError = !canAccountMakeEvmTransaction(
hasInsufficientFunds = !(await canAccountMakeEvmTransaction(
$selectedAccountIndex,
originNetworkId,
$sendFlowParameters?.type
)
$sendFlowParameters.type
))
} else {
hasNetworkRecipientError = false
hasInsufficientFunds = false
}
}
Expand Down Expand Up @@ -247,13 +252,13 @@
>
<form on:submit|preventDefault={onContinueClick} id="select-recipient-form">
<NetworkRecipientSelector
hasError={hasNetworkRecipientError}
hasError={hasInsufficientFunds}
bind:this={selector}
bind:options={selectorOptions}
bind:selectedIndex
/>
</form>
{#if hasNetworkRecipientError}
{#if hasInsufficientFunds}
<Alert variant="danger" text={localize('error.send.insufficientFundsGasFee')} />
{/if}
</PopupTemplate>
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@
$: $selectedAccountTokens, searchValue, selectedTab, setFilteredTokenList()
let tokenError: string = ''
$: if (
selectedToken &&
isEvmNetwork(selectedToken.networkId) &&
!canAccountMakeEvmTransaction($selectedAccountIndex, selectedToken.networkId, $sendFlowParameters?.type)
) {
tokenError = localize('error.send.insufficientFundsTransaction')
} else if (
selectedToken &&
isStardustNetwork(selectedToken.networkId) &&
!canAccountMakeStardustTransaction($selectedAccountIndex, $sendFlowParameters?.type)
) {
tokenError = localize('error.send.insufficientFundsTransaction')
} else {
tokenError = ''
let tokenError = ''
$: selectedToken, $sendFlowParameters, void setTokenError()
async function setTokenError(): Promise<void> {
let hasEnoughFunds = true
if (selectedToken && isEvmNetwork(selectedToken.networkId)) {
hasEnoughFunds = await canAccountMakeEvmTransaction(
$selectedAccountIndex,
selectedToken.networkId,
$sendFlowParameters?.type
)
} else if (selectedToken && isStardustNetwork(selectedToken.networkId)) {
hasEnoughFunds = canAccountMakeStardustTransaction($selectedAccountIndex, $sendFlowParameters?.type)
}
tokenError = hasEnoughFunds ? '' : localize('error.send.insufficientFundsTransaction')
}
const tabs = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
import { networks } from '@core/network'
export let account: IAccountState
const GRID_COLS = {
0: 'grid-cols-1',
1: 'grid-cols-2',
2: 'grid-cols-3',
3: 'grid-cols-4',
}
</script>

<Pane
classes="
w-full flex shrink-0 grid {$networks.length > 0
? $networks.length > 1
? 'grid-cols-4'
: 'grid-cols-3'
: 'grid-cols-2'}
w-full flex shrink-0 grid {GRID_COLS[$networks.length] ?? GRID_COLS[3]}
bg-surface dark:bg-surface-dark
border border-solid border-stroke dark:border-stroke-dark
divide-x divide-solid divide-stroke dark:divide-stroke-dark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
tokens?.baseCoin?.balance.total ?? BigInt(0),
tokens?.baseCoin?.metadata
)
$: fiatBalance =
formatCurrency(getFiatValueFromTokenAmount(BigInt(tokens?.baseCoin?.balance.total ?? 0), tokens?.baseCoin)) ??
''
$: fiatBalance = tokens
? formatCurrency(getFiatValueFromTokenAmount(BigInt(tokens?.baseCoin?.balance.total ?? 0), tokens.baseCoin))
: ''
$: address = getAddressFromAccountForNetwork(account, network.id)
$: hasTokens = tokens?.nativeTokens?.length > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,27 @@
$: $selectedAccountTokens, (token = getTokenFromActivity(activity))
function getAmount(_activity: Activity): string {
if (_activity.namespace === NetworkNamespace.Stardust) {
if (_activity.type === StardustActivityType.Basic || _activity.type === StardustActivityType.Foundry) {
const { type, namespace } = _activity
if (namespace === NetworkNamespace.Stardust) {
if (type === StardustActivityType.Basic || type === StardustActivityType.Foundry) {
const { rawAmount, tokenId } = _activity.tokenTransfer ?? _activity.baseTokenTransfer ?? {}
return getFormattedAmountFromActivity(rawAmount, tokenId, _activity.direction, _activity.action)
} else if (_activity.type === StardustActivityType.Governance) {
return getFormattedAmountFromActivity(rawAmount, tokenId, _activity)
} else if (type === StardustActivityType.Governance) {
const isVotingPowerActivity =
_activity.governanceAction === StardustGovernanceAction.DecreaseVotingPower ||
_activity.governanceAction === StardustGovernanceAction.IncreaseVotingPower
return isVotingPowerActivity ? getFormattedVotingPowerFromGovernanceActivity(_activity) : '-'
} else if (_activity.type === StardustActivityType.Nft) {
} else if (type === StardustActivityType.Nft) {
return '1 ' + localize('general.nft')
} else {
return '-'
}
} else if (_activity.namespace === NetworkNamespace.Evm) {
if (_activity.type === EvmActivityType.CoinTransfer) {
return getFormattedAmountFromActivity(
_activity.baseTokenTransfer.rawAmount,
BASE_TOKEN_ID,
_activity.direction,
_activity.action
)
} else if (namespace === NetworkNamespace.Evm) {
if (type === EvmActivityType.CoinTransfer) {
return getFormattedAmountFromActivity(_activity.baseTokenTransfer.rawAmount, BASE_TOKEN_ID, _activity)
} else if (isEvmTokenActivity(_activity)) {
if (
_activity.tokenTransfer?.standard === NftStandard.Erc721 ||
Expand All @@ -57,8 +54,7 @@
return getFormattedAmountFromActivity(
_activity.tokenTransfer.rawAmount,
_activity.tokenTransfer.tokenId,
_activity.direction,
_activity.action
_activity
)
}
} else {
Expand All @@ -70,27 +66,29 @@
}
function getFormattedMarketPrice(_activity: Activity): string | undefined {
if (_activity.namespace === NetworkNamespace.Stardust) {
const { type, namespace } = _activity
if (namespace === NetworkNamespace.Stardust) {
if (
[StardustActivityType.Basic, StardustActivityType.Governance, StardustActivityType.Foundry].includes(
_activity.type
type
) &&
token
) {
const amount = _activity.tokenTransfer?.rawAmount ?? _activity.baseTokenTransfer.rawAmount
const marketPrice = getFiatValueFromTokenAmount(amount, token)
return marketPrice ? formatCurrency(marketPrice) : '-'
} else if (_activity.type === StardustActivityType.Nft) {
} else if (type === StardustActivityType.Nft) {
return '-'
} else {
return undefined
}
} else if (_activity.namespace === NetworkNamespace.Evm) {
if (_activity.type === EvmActivityType.CoinTransfer) {
} else if (namespace === NetworkNamespace.Evm) {
if (type === EvmActivityType.CoinTransfer) {
const marketPrice = getFiatValueFromTokenAmount(_activity.baseTokenTransfer.rawAmount, token)
return marketPrice ? formatCurrency(marketPrice) : '-'
} else if (_activity.type === EvmActivityType.TokenTransfer) {
} else if (type === EvmActivityType.TokenTransfer) {
if (
_activity.tokenTransfer?.standard === TokenStandard.Erc20 ||
_activity.tokenTransfer?.standard === TokenStandard.Irc30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
{#if selectedTab.key === PopupTab.Transaction}
<EvmGenericInformation
time={activity.time}
sourceNetworkId={activity.sourceNetworkId}
destinationNetworkId={activity.destinationNetworkId}
maxGasFee={activity.maxGasFee}
transactionFee={activity.transactionFee}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
import { Table } from '@bloomwalletio/ui'
import { getFormattedTimeStamp, localize } from '@core/i18n'
import { NetworkId } from '@core/network'
import { getBaseToken } from '@core/profile/actions'
import { NetworkId, getNetwork } from '@core/network'
import { formatTokenAmountBestMatch } from '@core/token'
import { NetworkLabel } from '@ui'
export let time: Date
export let sourceNetworkId: NetworkId
export let destinationNetworkId: NetworkId
export let maxGasFee: bigint | undefined = undefined
export let transactionFee: bigint | undefined = undefined
Expand All @@ -17,7 +17,7 @@
$: formattedTransactionFee = formatAmount(transactionFee)
function formatAmount(amount: bigint | undefined): string | undefined {
return amount ? formatTokenAmountBestMatch(amount, getBaseToken()) : undefined
return amount ? formatTokenAmountBestMatch(amount, getNetwork(sourceNetworkId)?.baseToken) : undefined
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
case StardustActivityType.Foundry:
tabs = getTabItems([PopupTab.Transaction, PopupTab.Foundry, PopupTab.Token])
token = activity.tokenTransfer
? getPersistedToken(activity.tokenTransfer?.tokenId)?.metadata
? getPersistedToken(activity.sourceNetworkId, activity.tokenTransfer?.tokenId)?.metadata
: undefined
break
case StardustActivityType.Consolidation:
Expand Down
Loading

0 comments on commit 4f4d854

Please sign in to comment.