Skip to content

Commit 2b5d4f4

Browse files
committed
Fix display of NFT when minting
Closes #1533
1 parent 71cf8bd commit 2b5d4f4

File tree

12 files changed

+80
-43
lines changed

12 files changed

+80
-43
lines changed

.changeset/tender-walls-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'alephium-desktop-wallet': patch
3+
---
4+
5+
Fix display of NFT when minting

.changeset/whole-aliens-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@alephium/mobile-wallet': patch
3+
---
4+
5+
Fix display of NFT when minting

apps/desktop-wallet/src/components/TokenAmountsBox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ interface AssetAmountRowProps extends AmountBaseProps {
9090
tokenId: string
9191
amount: string
9292
extraAlphForDust: bigint
93+
skipCaching?: boolean
9394
}
9495

9596
const AssetAmountRow = ({ tokenId, amount, extraAlphForDust, ...props }: AssetAmountRowProps) => {

apps/desktop-wallet/src/features/transactionsDisplay/TransactionSummary.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import { TransactionDisplayProps } from '@/features/transactionsDisplay/transact
77
interface TransactionSummaryProps extends TransactionDisplayProps {
88
hideType?: boolean
99
className?: string
10+
skipCaching?: boolean
1011
}
1112

12-
const TransactionSummary = ({ tx, referenceAddress, hideType, className }: TransactionSummaryProps) => (
13+
const TransactionSummary = ({ tx, referenceAddress, hideType, className, skipCaching }: TransactionSummaryProps) => (
1314
<SummaryStyled className={className}>
1415
<SummaryContent>
1516
{!hideType && <TransactionType tx={tx} referenceAddress={referenceAddress} />}
16-
<TransactionAmounts tx={tx} referenceAddress={referenceAddress} />
17+
<TransactionAmounts tx={tx} referenceAddress={referenceAddress} skipCaching={skipCaching} />
1718
</SummaryContent>
1819
</SummaryStyled>
1920
)

apps/desktop-wallet/src/features/transactionsDisplay/transactionDetailsModal/TransactionAmounts.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import { useTransactionAmountDeltas, useTransactionInfoType } from '@alephium/shared-react'
1+
import { NOCACHE_PREFIX, useTransactionAmountDeltas, useTransactionInfoType } from '@alephium/shared-react'
22
import { ALPH } from '@alephium/token-list'
33
import { useMemo } from 'react'
44

55
import TokenAmountsBox from '@/components/TokenAmountsBox'
66
import { TransactionDisplayProps } from '@/features/transactionsDisplay/transactionDisplayTypes'
77

8-
const TransactionAmounts = ({ tx, referenceAddress }: TransactionDisplayProps) => {
8+
const TransactionAmounts = ({
9+
tx,
10+
referenceAddress,
11+
skipCaching
12+
}: TransactionDisplayProps & { skipCaching?: boolean }) => {
913
const { alphAmount, tokenAmounts } = useTransactionAmountDeltas(tx, referenceAddress)
10-
const assetAmounts = useMemo(
11-
() => (alphAmount !== BigInt(0) ? [{ id: ALPH.id, amount: alphAmount }, ...tokenAmounts] : tokenAmounts),
12-
[alphAmount, tokenAmounts]
13-
)
14+
const assetAmounts = useMemo(() => {
15+
const _tokenAmounts = tokenAmounts.map((t) => ({ ...t, id: skipCaching ? `${NOCACHE_PREFIX}${t.id}` : t.id }))
16+
return alphAmount !== BigInt(0) ? [{ id: ALPH.id, amount: alphAmount }, ..._tokenAmounts] : _tokenAmounts
17+
}, [alphAmount, skipCaching, tokenAmounts])
1418

1519
const infoType = useTransactionInfoType({ tx, referenceAddress: referenceAddress, view: 'wallet' })
1620

apps/desktop-wallet/src/features/walletConnect/SignExecuteScriptTxModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const SimulatedResult = ({
120120
<SectionTitle>{t('Simulated result')}</SectionTitle>
121121
{isRelevant ? (
122122
<>
123-
<TransactionSummaryStyled tx={unsignedData} referenceAddress={txParams.signerAddress} hideType />
123+
<TransactionSummaryStyled tx={unsignedData} referenceAddress={txParams.signerAddress} hideType skipCaching />
124124
<Box hasBg hasHorizontalPadding>
125125
<AddressesDataRows tx={unsignedData} referenceAddress={txParams.signerAddress} />
126126
</Box>

apps/mobile-wallet/src/features/ecosystem/modals/SignExecuteScriptTxModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const SimulatedResult = ({
152152
/>
153153
</Row>
154154
)}
155-
<TransactionAmounts tx={unsignedData} referenceAddress={txParams.signerAddress} isLast />
155+
<TransactionAmounts tx={unsignedData} referenceAddress={txParams.signerAddress} isLast skipCaching />
156156
</>
157157
) : (
158158
<AppText style={{ textAlign: 'center', marginTop: DEFAULT_MARGIN }} color="secondary">

apps/mobile-wallet/src/features/transactionsDisplay/TransactionModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,16 @@ const TransactionStatus = ({ tx }: Pick<TransactionModalSubcomponentProps, 'tx'>
193193

194194
interface TransactionAmountsProps extends TransactionModalSubcomponentProps {
195195
isLast?: boolean
196+
skipCaching?: boolean
196197
}
197198

198-
export const TransactionAmounts = ({ tx, referenceAddress, isLast }: TransactionAmountsProps) => {
199+
export const TransactionAmounts = ({ tx, referenceAddress, isLast, skipCaching }: TransactionAmountsProps) => {
199200
const { t } = useTranslation()
200201
const theme = useTheme()
201202
const dispatch = useAppDispatch()
202203
const {
203204
data: { fungibleTokens, nfts, nsts }
204-
} = useFetchTransactionTokens(tx, referenceAddress)
205+
} = useFetchTransactionTokens(tx, referenceAddress, skipCaching)
205206
const infoType = useTransactionInfoType({ tx, referenceAddress, view: 'wallet' })
206207

207208
const groupedFtAmounts = useMemo(

packages/shared-react/src/api/apiDataHooks/token/useFetchToken.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { useQuery } from '@tanstack/react-query'
44
import { tokenQuery } from '@/api/queries/tokenQueries'
55
import { useCurrentlyOnlineNetworkId } from '@/network'
66

7-
export const useFetchToken = (id: TokenId) => {
7+
export const useFetchToken = (id: TokenId, skipCaching?: boolean) => {
88
const networkId = useCurrentlyOnlineNetworkId()
99

10-
const { data, isLoading } = useQuery(tokenQuery({ id, networkId }))
10+
const { data, isLoading } = useQuery(tokenQuery({ id, networkId, skipCaching }))
1111

1212
return {
1313
data,

packages/shared-react/src/api/apiDataHooks/transaction/useFetchTransactionTokens.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ type TransactionTokens = {
3737

3838
export const useFetchTransactionTokens = (
3939
tx: e.Transaction | e.PendingTransaction | SentTransaction | ExecuteScriptTx,
40-
addressHash: AddressHash
40+
addressHash: AddressHash,
41+
skipCaching: boolean = false
4142
): TransactionTokens => {
4243
const networkId = useCurrentlyOnlineNetworkId()
4344
const { alphAmount, tokenAmounts } = useTransactionAmountDeltas(tx, addressHash)
4445

4546
const { data: tokens, isLoading } = useQueries({
46-
queries: tokenAmounts.map(({ id }) => tokenQuery({ id, networkId })),
47+
queries: tokenAmounts.map(({ id }) => tokenQuery({ id, networkId, skipCaching })),
4748
combine: (results) => combineTokens(results, tokenAmounts)
4849
})
4950

0 commit comments

Comments
 (0)