From 9f914343c11f800356ec2022342db328c2110e2f Mon Sep 17 00:00:00 2001 From: Keith Date: Thu, 19 Dec 2024 00:49:10 +0800 Subject: [PATCH] feat: hide open source tag if xudt-compatible code is not public --- src/constants/scripts.ts | 6 +++--- src/pages/Xudt/UDTComp.tsx | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/constants/scripts.ts b/src/constants/scripts.ts index 76b8a9ab8..474187ec1 100644 --- a/src/constants/scripts.ts +++ b/src/constants/scripts.ts @@ -268,7 +268,7 @@ export const MainnetContractHashTags: ContractHashTag[] = [ depType: 'code', hashType: 'data1', tag: 'xUDT', - category: 'lock', + category: 'type', }, { codeHashes: ['0x4a4dce1df3dffff7f8b2cd7dff7303df3b6150c9788cb75dcf6747247132b9f5'], @@ -660,7 +660,7 @@ export const TestnetContractHashTags: ContractHashTag[] = [ depType: 'code', hashType: 'type', tag: 'xUDT(final_rls)', - category: 'lock', + category: 'type', }, { codeHashes: ['0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95'], @@ -668,7 +668,7 @@ export const TestnetContractHashTags: ContractHashTag[] = [ depType: 'code', hashType: 'data1', tag: 'xUDT', - category: 'lock', + category: 'type', }, { codeHashes: [ diff --git a/src/pages/Xudt/UDTComp.tsx b/src/pages/Xudt/UDTComp.tsx index 6218dbf1c..5ac052dd1 100644 --- a/src/pages/Xudt/UDTComp.tsx +++ b/src/pages/Xudt/UDTComp.tsx @@ -30,6 +30,10 @@ import { ReactComponent as EditIcon } from '../../assets/edit.svg' import XUDTTokenIcon from '../../assets/sudt_token.png' import { ReactComponent as OpenSourceIcon } from '../../assets/open-source.svg' import { scripts } from '../ScriptList' +import { IS_MAINNET } from '../../constants/common' +import { MainnetContractHashTags, TestnetContractHashTags } from '../../constants/scripts' + +const scriptDataList = IS_MAINNET ? MainnetContractHashTags : TestnetContractHashTags const IssuerContent: FC<{ address: string }> = ({ address }) => { const { t } = useTranslation() @@ -185,6 +189,9 @@ export const UDTOverviewCard = ({ ) const tags = xudt?.xudtTags ?? [] + const isOpenSourceXudt = xudt + ? scriptDataList.some(s => s.tag.startsWith('xUDT') && s.codeHashes.includes(xudt?.typeScript.codeHash)) + : false return ( <> @@ -203,7 +210,7 @@ export const UDTOverviewCard = ({ {tags.map(tag => ( ))} - {xudtCodeUrl ? ( + {isOpenSourceXudt && xudtCodeUrl ? ( {t('scripts.open_source_script')}