-
Notifications
You must be signed in to change notification settings - Fork 103
/
NftActivityTileContent.svelte
64 lines (56 loc) · 2.35 KB
/
NftActivityTileContent.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<script lang="typescript">
import { localize } from '@core/i18n'
import { ActivityDirection, InclusionState, INftActivityData, Subject } from '@core/wallet'
import { truncateString } from '@core/utils'
import { Text, FontWeight, NftMediaContainer, NftMediaSize } from 'shared/components'
import { networkHrp } from '@core/network'
export let inclusionState: InclusionState
export let data: INftActivityData
$: isIncoming = data.direction === ActivityDirection.Incoming
$: title = getTitle(data, inclusionState)
$: subjectLocale = getSubjectLocale(data.subject)
function getTitle(txData: INftActivityData, inclusionState: InclusionState): string {
const { isInternal, direction } = txData
const isConfirmed = inclusionState === InclusionState.Confirmed
if (isInternal) {
return isConfirmed ? 'general.transferNft' : 'general.transferringNft'
}
if (direction === ActivityDirection.Incoming) {
return isConfirmed ? 'general.receivedNft' : 'general.receivingNft'
}
if (direction === ActivityDirection.Outgoing) {
return isConfirmed ? 'general.sentNft' : 'general.sendingNft'
}
}
function getSubjectLocale(subject: Subject): string {
let description
if (subject?.type === 'account') {
description = truncateString(subject?.account?.name, 13, 0)
}
if (subject?.type === 'address') {
description = truncateString(subject?.address, $networkHrp.length, 6)
}
return description ? description : localize('general.unknownAddress')
}
</script>
<div class="relative flex w-8 h-8">
<NftMediaContainer nftId={data.nftId} size={NftMediaSize.Small} />
</div>
<div class="flex flex-col w-full space-y-0.5">
<div class="flex flex-row items-start">
<Text
fontWeight={FontWeight.semibold}
lineHeight="140"
classes="overflow-hidden overflow-ellipsis multiwrap-line2"
>
{localize(title)}
</Text>
</div>
<div class="flex flex-row items-start">
<Text fontWeight={FontWeight.normal} lineHeight="140" color="gray-600">
{localize(isIncoming ? 'general.fromAddress' : 'general.toAddress', {
values: { account: subjectLocale },
})}
</Text>
</div>
</div>