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

feat(address): nrc 721 #298

Merged
merged 4 commits into from
May 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions src/pages/Address/AddressAssetComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { formatNftDisplayId, handleNftImgError, hexToBase64, patchMibaoImg } fro
import { getDobs } from '../../services/DobsService'
import { sliceNftName } from '../../utils/string'
import styles from './addressAssetComp.module.scss'
import EllipsisMiddle from '../../components/EllipsisMiddle'

export const AddressAssetComp = ({
href,
Expand Down Expand Up @@ -51,9 +52,7 @@ export const AddressAssetComp = ({
)}
<div className={styles.fields}>
<div className={styles.assetName}>{name}</div>
<div className={styles.attribute} title={property}>
{property}
</div>
<EllipsisMiddle className={styles.attribute} text={property} />
</div>
</div>
</a>
Expand Down Expand Up @@ -177,16 +176,7 @@ export const AddressMNFTComp = ({ account, isRGBPP }: { account: MNFT; isRGBPP?:
)
}

export const AddressNRC721Comp = ({
account,
isRGBPP,
isMerged = false,
}: {
account: NRC721
isRGBPP?: boolean
isMerged?: boolean
}) => {
const { t } = useTranslation()
export const AddressNRC721Comp = ({ account, isRGBPP }: { account: NRC721; isRGBPP?: boolean }) => {
const { symbol, amount, udtIconFile, collection } = account
const [icon, setIcon] = useState(udtIconFile)

Expand All @@ -205,17 +195,12 @@ export const AddressNRC721Comp = ({
})
}, [udtIconFile])

let name = !symbol ? '?' : sliceNftName(symbol)
if (isMerged) {
name = `${t('rgbpp.amount')}: ${(+amount).toLocaleString('en')}`
}

return (
<AddressAssetComp
isRGBPP={isRGBPP ?? false}
href={`/nft-collections/${collection?.typeHash}`}
property={!symbol ? '?' : `#${amount}`}
name={name}
property={`id: ${amount}`}
name={!symbol ? '?' : sliceNftName(`${symbol} #${collection.typeHash.slice(2, 5)}`)}
isUnverified={!symbol}
udtLabel="NRC 721"
icon={{
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Address/AddressComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ export const AddressOverviewCard: FC<{ address: Address }> = ({ address }) => {

case 'm_nft_token':
return <AddressMNFTComp account={udt} key={udt.symbol + udt.udtType + udt.amount} />

case 'nrc_721_token':
return <AddressNRC721Comp account={udt} key={udt.symbol + udt.udtType + udt.amount} />

default:
return null
}
Expand Down
9 changes: 6 additions & 3 deletions src/pages/Address/Cells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useSetToast } from '../../components/Toast'
import { PAGE_SIZE } from '../../constants/common'
import styles from './cells.module.scss'
import SmallLoading from '../../components/Loading/SmallLoading'
import { sliceNftName } from '../../utils/string'

enum Sort {
TimeAsc = 'block_timestamp.asc',
Expand Down Expand Up @@ -164,8 +165,10 @@ const Cell: FC<{ cell: LiveCell }> = ({ cell }) => {
}
case 'nrc_721': {
icon = SUDTTokenIcon
assetName = 'NRC 721'
attribute = '-'
assetName = !cell.extraInfo.symbol
? '?'
: sliceNftName(`${cell.extraInfo.symbol} #${cell.extraInfo.typeHash.slice(0, 3)}`)
attribute = cell.extraInfo.amount
break
}
case 'm_nft': {
Expand Down Expand Up @@ -201,7 +204,7 @@ const Cell: FC<{ cell: LiveCell }> = ({ cell }) => {
<div className={styles.fields}>
<div className={styles.assetName}>{assetName}</div>
<div className={styles.attribute} title={detailInfo ?? attribute}>
{attribute}
<div className={styles.attributeContent}>{attribute}</div>
{detailInfo ? (
<button type="button" className={styles.copy} data-detail={detailInfo} onClick={handleCopy}>
<CopyIcon />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Address/MergedAssetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const MergedAssetList: FC<{
case 'spore_cell':
return <AddressSporeComp isRGBPP isMerged account={nft} key={nft.symbol + nft.udtType + nft.amount} />
case 'nrc_721_token':
return <AddressNRC721Comp isRGBPP isMerged account={nft} key={nft.symbol + nft.udtType + nft.amount} />
return <AddressNRC721Comp isRGBPP account={nft} key={nft.symbol + nft.udtType + nft.amount} />
case 'm_nft_token':
return <AddressMNFTComp isRGBPP account={nft} key={nft.symbol + nft.udtType + nft.amount} />
default:
Expand Down
1 change: 1 addition & 0 deletions src/pages/Address/addressAssetComp.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
}

.fields {
width: 100%;
min-width: 0;
display: flex;
flex-direction: column;
Expand Down
6 changes: 6 additions & 0 deletions src/pages/Address/cells.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@

.attribute {
display: flex;

&Content {
text-overflow: ellipsis;
overflow: hidden;
}
}

.copy {
Expand All @@ -147,6 +152,7 @@
}

.fields {
min-width: 0;
display: flex;
flex-direction: column;
justify-content: space-around;
Expand Down
Loading