Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add minting nft activity #5276

Merged
merged 5 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -4,17 +4,24 @@
import { truncateString } from '@core/utils'
import { Text, FontWeight, NftMediaContainer, NftMediaSize } from 'shared/components'
import { networkHrp } from '@core/network'
import { getNftByIdFromAllAccountNfts } from '@core/nfts'
import { selectedAccountIndex } from '@core/account'

export let activity: NftActivity

$: isIncoming = activity.direction === ActivityDirection.Incoming
$: title = getTitle(activity)
$: subjectLocale = getSubjectLocale(activity.subject)

$: nft = getNftByIdFromAllAccountNfts($selectedAccountIndex, activity.nftId)

function getTitle(_activity: NftActivity): string {
const { isInternal, direction, inclusionState } = _activity
const isConfirmed = inclusionState === InclusionState.Confirmed

if (direction === ActivityDirection.Minting) {
return isConfirmed ? 'general.mintedNft' : 'general.mintingNft'
}
if (isInternal) {
return isConfirmed ? 'general.transferNft' : 'general.transferringNft'
}
Expand Down Expand Up @@ -53,11 +60,15 @@
</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 },
})}
<div class="flex flex-row items-start" style="width: 70%">
<Text fontWeight={FontWeight.normal} lineHeight="140" color="gray-600" classes="truncate">
{#if activity.direction === ActivityDirection.Minting}
{nft?.name}
{:else}
{localize(isIncoming ? 'general.fromAddress' : 'general.toAddress', {
values: { account: subjectLocale },
})}
{/if}
</Text>
</div>
</div>
@@ -1,4 +1,5 @@
export enum ActivityDirection {
Incoming = 'incoming',
Minting = 'minting',
Outgoing = 'outgoing',
}
@@ -1,12 +1,13 @@
import { IProcessedTransaction } from '../../interfaces'
import { outputContainsValue, getNftOutputFromTransaction } from '..'
import { ActivityType } from '@core/wallet/enums'
import { ActivityDirection, ActivityType } from '@core/wallet/enums'
import { IAccountState } from '@core/account'
import type { INftOutput } from '@iota/types'
import { getAsyncDataFromOutput } from '../generateActivity/helper/getAsyncDataFromOutput'
import { NftActivity } from '@core/wallet/types'
import { getMetadataFromOutput, getSendingInformation, getTagFromOutput } from './helper'
import { getNftId } from '../outputs/getNftId'
import { EMPTY_HEX_ID } from '@core/wallet/constants'

export function generateNftActivity(processedTransaction: IProcessedTransaction, account: IAccountState): NftActivity {
const { outputs, claimingData, transactionInputs, time, inclusionState, transactionId } = processedTransaction
Expand All @@ -28,6 +29,10 @@ export function generateNftActivity(processedTransaction: IProcessedTransaction,
const tag = getTagFromOutput(output)

const sendingInfo = getSendingInformation(processedTransaction, output, account)
const { subject, isInternal, isSelfTransaction } = sendingInfo
let { direction } = sendingInfo

direction = output.nftId === EMPTY_HEX_ID ? ActivityDirection.Minting : direction
const asyncData = getAsyncDataFromOutput(output, transactionId, claimingData, account)

return {
Expand All @@ -47,6 +52,9 @@ export function generateNftActivity(processedTransaction: IProcessedTransaction,
metadata,
tag,
asyncData,
...sendingInfo,
subject,
isInternal,
direction,
isSelfTransaction,
}
}
15 changes: 15 additions & 0 deletions packages/shared/locales/en.json
Expand Up @@ -1160,6 +1160,8 @@
"transferring": "Transferring",
"transferNft": "Transfer NFT",
"transferringNft": "Transferring NFT",
"mintedNft": "Minted NFT",
"mintingNft": "Minting NFT",
"shimmerClaimed": "Claimed",
"shimmerClaiming": "Claiming",
"shimmerGenesis": "Shimmer Genesis",
Expand Down Expand Up @@ -1725,6 +1727,14 @@
},
"optionalInput": "This optional data will be public on the explorer and viewable by everyone.",
"transactionDetails": {
"minting": {
"storageDeposit": "A refundable token deposit needed to store your transaction on the Tangle.",
"giftedStorageDeposit": "The storage deposit for this transaction was gifted to you. You do not need to refund the deposit.",
"expirationTime": "Claim these funds before the expiration time or they will be returned to the sender.",
"timelockDate": "The sender set a timelock on these funds. You will be able to spend them once the timelock expires.",
"metadata": "An optional data field for storing data persistently on the Tangle.",
"tag": "A short optional data field. Tagging groups of transactions can make them easier to search for."
},
"incoming": {
"storageDeposit": "A refundable token deposit needed to store your transaction on the Tangle.",
"giftedStorageDeposit": "The storage deposit for this transaction was gifted to you. You do not need to refund the deposit.",
Expand Down Expand Up @@ -1839,6 +1849,11 @@
"Pending": "transferring to",
"Confirmed": "transferred to",
"Conflicting": "failed to transfer"
},
"minting": {
"Pending": "minting",
"Confirmed": "minted",
"Conflicting": "failed to mint"
}
},
"external": {
Expand Down