Skip to content

Commit

Permalink
Ptd 1273 (#941) [PTD-1273]
Browse files Browse the repository at this point in the history
* fix(dashboard): adjust recent TXs column widths
* fix(dashboard): do not 404 for virtual badges [PTD-1273]
  • Loading branch information
dawidsowardx authored Mar 26, 2024
1 parent dce6494 commit 0b052f4
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
}
.nft-info {
align-items: flex-start;
display: flex;
flex-direction: column;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
export const messageColumnDefinition = {
id: 'message',
width: '50px',
width: '100px',
hideMobile: true,
header: {
label: 'Message',
alignment: 'center' as const
},
component: TxMessageColumn,
componentProps: {
message: (tx: CommittedTransactionInfo) => {
Expand All @@ -43,7 +47,7 @@
export const dateAndTxIdColumnDefinition = {
id: 'date-and-tx-id',
hideMobile: true,
width: '140px',
width: '150px',
header: {
label: 'ID/DATE (GMT +00)'
},
Expand All @@ -70,7 +74,7 @@
}: { label?: string } = {}) => {
return {
id: 'other-balance-changes',
width: '190px',
width: '300px',
header: {
label: label || 'Other Balance Changes'
},
Expand Down Expand Up @@ -99,7 +103,7 @@
}: { alignment?: 'right' } = {}) => {
return {
id: 'fee',
width: '160px',
width: '130px',
...(alignment ? { alignment } : undefined),
header: {
label: 'Transaction Fee'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
</script>

<div class="header-column">
<TxMessageColumn {message} />
<div class="message">
<TxMessageColumn {message} />
</div>

<DateAndTxIdColumn {id} {date} />
<div class="ml-auto">
<IconNew icon={ChevronRight} />
</div>
</div>

<style lang="scss">
.message {
max-width: 100px;
}
.header-column {
display: flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
header: {
label: 'Withdrawn'
},
width: '190px',
component: BalanceChangesColumn,
componentProps: {
balanceChanges: '$$withdrawals'
Expand All @@ -62,7 +61,6 @@
header: {
label: 'Deposited'
},
width: '190px',
component: BalanceChangesColumn,
componentProps: {
balanceChanges: '$$deposits'
Expand Down
31 changes: 21 additions & 10 deletions apps/dashboard/src/pages/search-pages/nft/Nft.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { NonFungible } from '@api/utils/nfts'
import type { NonFungibleResource } from '@api/utils/entities/resource/non-fungible'
export let nft: Promise<NonFungible>
export let nft: Promise<NonFungible | undefined>
export let resource: Promise<NonFungibleResource>
export let associatedDapps: Promise<
{
Expand All @@ -17,13 +17,13 @@
>
$: imageUrl = Promise.all([nft, resource]).then(([nft, resource]) =>
nft.type === 'generalNft'
nft?.type === 'generalNft'
? nft.nftData.expected.key_image_url?.value
: resource.metadata.expected.icon_url?.typed.value
)
$: description = Promise.all([nft, resource]).then(([nft, resource]) =>
nft.type === 'generalNft'
nft?.type === 'generalNft'
? nft.nftData.expected.description?.value
: resource.metadata.expected.description?.typed.value
)
Expand All @@ -43,9 +43,16 @@
<h2>
{#await nft}
<SkeletonLoader />
{:then { nftData: { expected: { name } } }}
{#if name?.value}
{name?.value}
{:then nft}
{#if nft}
{@const {
nftData: {
expected: { name }
}
} = nft}
{#if name?.value}
{name?.value}
{/if}
{/if}
{/await}
</h2>
Expand All @@ -61,10 +68,14 @@
{#await nft}
<SkeletonLoader />
{:then nft}
<NftDataRow value={{ kind: 'String', field_name: 'ID', value: nft.id }} />
{#each nft.type === 'generalNft' ? nft.nftData.nonStandard : Object.values(nft.nftData.expected).filter((data) => data.field_name !== 'name') as value}
<NftDataRow {value} />
{/each}
{#if nft}
<NftDataRow
value={{ kind: 'String', field_name: 'ID', value: nft.id }}
/>
{#each nft.type === 'generalNft' ? nft.nftData.nonStandard : Object.values(nft.nftData.expected).filter((data) => data.field_name !== 'name') as value}
<NftDataRow {value} />
{/each}
{/if}
{/await}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,4 @@
export let data: LayoutData
</script>

<div class="information">
List of balance changes on this specific account. Click on Transaction ID to
get more information.
</div>
<RecentTransactions entityAddress={data.account} />

<style lang="scss">
.information {
color: var(--color-grey-2);
margin-bottom: var(--space-md);
@include mixins.desktop {
padding-top: var(--space-md);
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
export let data: PageData
</script>

{#await Promise.all( [data.promises.nft, data.promises.authResources] ) then [nft, tokenInfo]}
{#await data.promises.nft then nft}
<SearchPage
title={nft.type === 'generalNft'
title={nft?.type === 'generalNft'
? 'Non Fungible'
: 'Radix Network Stake Claim Non-fungible'}
address={data.nftAddress}
Expand Down
34 changes: 22 additions & 12 deletions apps/dashboard/src/routes/(search-pages)/nft/[nft]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { callApi } from '@api/_deprecated/gateway'
import type { PageLoad } from './$types'
import { getLinkedDappDefinitions } from '@api/utils/two-way-linking'
import {
getDappDefinitionData,
getLookupEntity,
getResourcesFromAuth
} from '../../utils'
import { getDappDefinitionData, getLookupEntity } from '../../utils'
import { map, pipe } from 'ramda'
import { transformNft } from '@api/utils/nfts'
import { handleGatewayResult } from '../../../../utils'
import { transformNonFungibleResource } from '@api/utils/entities/resource/non-fungible'
import { errorPage } from '@dashboard/stores'
import type { KnownAddresses } from '@common/ret'

export const load: PageLoad = async ({ params }) => {
export const load: PageLoad = async ({ params, fetch }) => {
const [resourceAddress, nftId] = decodeURIComponent(params.nft).split(':')

const resourceEntity = getLookupEntity(resourceAddress, {
Expand All @@ -26,9 +23,22 @@ export const load: PageLoad = async ({ params }) => {

nftData.then((data) => {
if (data.length === 0) {
errorPage.set({
message: 'NFT not found'
})
return fetch('/api/ret/known-addresses')
.then((response) => response.json())
.then(({ resourceAddresses }: KnownAddresses) => {
if (
![
resourceAddresses.ed25519SignatureVirtualBadge,
resourceAddresses.packageOfDirectCallerVirtualBadge,
resourceAddresses.secp256k1SignatureVirtualBadge,
resourceAddresses.globalCallerVirtualBadge
].includes(resourceAddress)
) {
errorPage.set({
message: 'NFT not found'
})
}
})
}
})

Expand All @@ -42,11 +52,11 @@ export const load: PageLoad = async ({ params }) => {
nftAddress: params.nft,
promises: {
nft: Promise.all([nftData, resourceEntity]).then(
([nftData, { address }]) => transformNft(address, nftData[0])
([nftData, { address }]) =>
nftData?.[0] ? transformNft(address, nftData?.[0]) : undefined
),
resource,
associatedDapps,
authResources: resource.then(({ auth }) => getResourcesFromAuth(auth))
associatedDapps
}
}
}
17 changes: 17 additions & 0 deletions apps/dashboard/src/routes/api/ret/known-addresses/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { RadixEngineToolkit } from '@common/ret'
import { CURRENT_NETWORK } from '@networks'
import { error, json } from '@sveltejs/kit'

export const GET = async () => {
try {
const knownAddresses = await RadixEngineToolkit.Utils.knownAddresses(
CURRENT_NETWORK.id
)

return json(knownAddresses, {
status: 200
})
} catch (e) {
return error(400)
}
}

0 comments on commit 0b052f4

Please sign in to comment.