Skip to content

Commit

Permalink
Merge branch 'develop' into feature/nft-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Jul 30, 2024
2 parents c8b4ccd + 24abea3 commit b64bcf1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/constants/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ export const MainnetContractHashTags: ContractHashTag[] = [
tag: 'DID',
category: 'type',
},
{
codeHashes: ['0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf'],
txHashes: ['0x10d63a996157d32c01078058000052674ca58d15f921bec7f1dcdac2160eb66b-4'],
depType: 'code',
hashType: 'data1',
tag: 'Single Use Lock',
category: 'lock',
},
]

export const TestnetContractHashTags: ContractHashTag[] = [
Expand Down Expand Up @@ -704,6 +712,14 @@ export const TestnetContractHashTags: ContractHashTag[] = [
tag: 'Nostr',
category: 'lock',
},
{
codeHashes: ['0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf'],
txHashes: ['0xb4f171c9c9caf7401f54a8e56225ae21d95032150a87a4678eac3f66a3137b93-4'],
depType: 'code',
hashType: 'data1',
tag: 'Single Use Lock',
category: 'lock',
},
]

const getLumosScripts = (scripts: ContractHashTag[]): ScriptConfigs =>
Expand Down
48 changes: 46 additions & 2 deletions src/pages/Address/Cells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import SmallLoading from '../../components/Loading/SmallLoading'
import { TransactionCellInfo } from '../Transaction/TransactionCell'
import { CellBasicInfo } from '../../utils/transformer'
import { sliceNftName } from '../../utils/string'
import { Link } from '../../components/Link'
import { isTypeIdScript } from '../../utils/typeid'

enum Sort {
Expand Down Expand Up @@ -62,6 +63,7 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
let attribute = null
let detailInfo = null
let assetTypeText = assetType
let assetLink = null
switch (assetType) {
case 'ckb': {
assetTypeText = 'CKB'
Expand Down Expand Up @@ -113,6 +115,9 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
? parseUDTAmount(cell.extraInfo.amount, cell.extraInfo.decimal)
: 'Unknown UDT amount'
detailInfo = cell.extraInfo.amount
if (cell.extraInfo.published) {
assetLink = `/sudt/${cell.typeHash}`
}
break
}
case 'xudt_compatible': {
Expand All @@ -123,6 +128,9 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
? parseUDTAmount(cell.extraInfo.amount, cell.extraInfo.decimal)
: 'Unknown xUDT amount'
detailInfo = cell.extraInfo?.amount
if (cell.extraInfo.published) {
assetLink = `/xudt/${cell.typeHash}`
}
break
}
case 'xudt': {
Expand All @@ -134,6 +142,9 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
? parseUDTAmount(cell.extraInfo.amount, cell.extraInfo.decimal)
: 'Unknown xUDT amount'
detailInfo = cell.extraInfo?.amount
if (cell.extraInfo.published) {
assetLink = `/xudt/${cell.typeHash}`
}
break
}
case 'omiga_inscription': {
Expand All @@ -144,9 +155,11 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
? parseUDTAmount(cell.extraInfo.amount, cell.extraInfo.decimal)
: 'Unknown amount'
detailInfo = cell.extraInfo.amount
assetLink = `/inscription/${cell.typeHash}`
break
}
case 'did_cell':
case 'dob':
case 'spore_cell': {
icon = <SporeCellIcon />
assetName = 'DOB'
Expand All @@ -157,6 +170,11 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
attribute = cell.data
}
detailInfo = cell.data
if (cell.extraInfo.collection?.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.collection?.typeHash}`
} else if (cell.extraInfo.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.typeHash}`
}
break
}
case 'spore_cluster': {
Expand All @@ -169,6 +187,11 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
attribute = cell.data
}
detailInfo = cell.data
if (cell.extraInfo.collection?.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.collection?.typeHash}`
} else if (cell.extraInfo.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.typeHash}`
}
break
}
case 'nrc_721': {
Expand All @@ -182,13 +205,23 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
} else {
attribute = cell.extraInfo.amount
}
if (cell.extraInfo.collection?.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.collection?.typeHash}`
} else if (cell.extraInfo.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.typeHash}`
}
break
}
case 'm_nft': {
icon = SUDTTokenIcon
assetTypeText = 'NFT'
assetName = cell.extraInfo.className
attribute = cell.extraInfo.tokenId ? `#${parseInt(cell.extraInfo.tokenId, 16)}` : '/'
if (cell.extraInfo.collection?.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.collection?.typeHash}`
} else if (cell.extraInfo.typeHash) {
assetLink = `/nft-collections/${cell.extraInfo.typeHash}`
}
break
}
default: {
Expand All @@ -213,6 +246,7 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
} as CellBasicInfo

return {
assetLink,
ckb,
outPointStr,
icon,
Expand All @@ -229,7 +263,10 @@ const getCellDetails = (cell: LiveCell, t: TFunction) => {
const Cell: FC<{ cell: LiveCell }> = ({ cell }) => {
const { t } = useTranslation()

const { title, parsedBlockCreateAt, icon, assetName, attribute, detailInfo, cellInfo } = getCellDetails(cell, t)
const { title, parsedBlockCreateAt, icon, assetName, attribute, detailInfo, cellInfo, assetLink } = getCellDetails(
cell,
t,
)

return (
<li key={cell.txHash + cell.cellIndex} className={styles.card}>
Expand All @@ -245,7 +282,14 @@ const Cell: FC<{ cell: LiveCell }> = ({ cell }) => {
{typeof icon === 'string' ? <img src={icon} alt={assetName ?? 'sudt'} width="40" height="40" /> : null}
{icon && typeof icon !== 'string' ? icon : null}
<div className={styles.fields}>
<div className={styles.assetName}>{assetName}</div>
{assetLink ? (
<Link to={assetLink} className={styles.assetName}>
{assetName}
</Link>
) : (
<div className={styles.assetName}>{assetName}</div>
)}

<div className={styles.attribute} title={detailInfo ?? attribute}>
{attribute}
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/pages/ScriptList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ export const scripts = new Map<string, ScriptAttributes>([
code: 'https://github.com/cryptape/nostr-binding/',
},
],
[
'Single Use Lock',
{
name: 'Single Use Lock',
description: 'A lock script that can only be used once.',
code: 'https://github.com/ckb-ecofund/ckb-proxy-locks',
},
],
])

const keysWithLinkValueInScript: (keyof ScriptAttributes)[] = ['rfc', 'code', 'doc', 'deprecated', 'website']
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Xudts/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ dt {
}

.value {
word-wrap: break-word;
word-break: break-all;
color: var(--333333, #333);
font-size: 16px;
font-style: normal;
Expand Down
3 changes: 3 additions & 0 deletions src/services/ExplorerService/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ export interface LiveCell {
typeScript: Script
lockScript: Script
extraInfo: {
collection: {
typeHash: string
}
symbol: string
amount: string
decimal: string
Expand Down

0 comments on commit b64bcf1

Please sign in to comment.