Skip to content

Commit 89b066e

Browse files
authored
Merge pull request #1826 from nervosnetwork/develop
Merge develop into testnet
2 parents e56884a + 9f91434 commit 89b066e

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

src/components/TransactionParameters/index.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FC, ReactNode } from 'react'
33
import { Trans, useTranslation } from 'react-i18next'
44
import { Link } from 'react-router-dom'
55
import classNames from 'classnames'
6-
import { useCKBNode } from '../../hooks/useCKBNode'
6+
import { explorerService } from '../../services/ExplorerService'
77
import { matchTxHash } from '../../utils/util'
88
import Loading from '../AwesomeLoadings/Spinner'
99
import HashTag from '../HashTag'
@@ -48,9 +48,8 @@ const Field = ({
4848

4949
const TransactionParameters: FC<{ hash: string }> = ({ hash }) => {
5050
const [t] = useTranslation()
51-
const { nodeService } = useCKBNode()
5251

53-
const { data, isLoading } = useQuery(['tx', hash], () => nodeService.getTx(hash))
52+
const { data, isLoading } = useQuery(['explorer-tx', hash], () => explorerService.api.fetchTransactionByHash(hash))
5453
if (isLoading) {
5554
return (
5655
<div className={styles.loading}>
@@ -59,9 +58,9 @@ const TransactionParameters: FC<{ hash: string }> = ({ hash }) => {
5958
)
6059
}
6160

62-
if (!data?.result?.transaction) return <div>{`Transaction ${hash} not loaded`}</div>
61+
if (!data) return <div>{`Transaction ${hash} not loaded`}</div>
6362

64-
const { header_deps: headerDeps, cell_deps: cellDeps, witnesses } = data.result.transaction
63+
const { headerDeps, cellDeps, witnesses } = data
6564

6665
const parameters = [
6766
{
@@ -84,8 +83,8 @@ const TransactionParameters: FC<{ hash: string }> = ({ hash }) => {
8483
content: cellDeps.length ? (
8584
cellDeps.map(cellDep => {
8685
const {
87-
out_point: { tx_hash: txHash, index },
88-
dep_type: depType,
86+
outPoint: { txHash, index },
87+
depType,
8988
} = cellDep
9089
const hashTag = matchTxHash(txHash, Number(index))
9190
return (

src/constants/scripts.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export const MainnetContractHashTags: ContractHashTag[] = [
268268
depType: 'code',
269269
hashType: 'data1',
270270
tag: 'xUDT',
271-
category: 'lock',
271+
category: 'type',
272272
},
273273
{
274274
codeHashes: ['0x4a4dce1df3dffff7f8b2cd7dff7303df3b6150c9788cb75dcf6747247132b9f5'],
@@ -660,15 +660,15 @@ export const TestnetContractHashTags: ContractHashTag[] = [
660660
depType: 'code',
661661
hashType: 'type',
662662
tag: 'xUDT(final_rls)',
663-
category: 'lock',
663+
category: 'type',
664664
},
665665
{
666666
codeHashes: ['0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95'],
667667
txHashes: ['0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f-0'],
668668
depType: 'code',
669669
hashType: 'data1',
670670
tag: 'xUDT',
671-
category: 'lock',
671+
category: 'type',
672672
},
673673
{
674674
codeHashes: [

src/models/Transaction/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export interface Transaction {
3535
maxCyclesInEpoch: number | null
3636
maxCycles: number | null
3737
createTimestamp?: number
38+
cellDeps: CellDep[]
39+
headerDeps: string[]
40+
witnesses: string[]
3841
}
3942

4043
export interface BtcTx {

src/pages/Transaction/state.ts

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const defaultTransactionInfo: Transaction = {
2626
cycles: null,
2727
maxCyclesInEpoch: null,
2828
maxCycles: null,
29+
cellDeps: [],
30+
headerDeps: [],
31+
witnesses: [],
2932
}
3033

3134
export const defaultTransactionLiteDetails: TransactionRecord[] = [

src/pages/Xudt/UDTComp.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ import { ReactComponent as EditIcon } from '../../assets/edit.svg'
3030
import XUDTTokenIcon from '../../assets/sudt_token.png'
3131
import { ReactComponent as OpenSourceIcon } from '../../assets/open-source.svg'
3232
import { scripts } from '../ScriptList'
33+
import { IS_MAINNET } from '../../constants/common'
34+
import { MainnetContractHashTags, TestnetContractHashTags } from '../../constants/scripts'
35+
36+
const scriptDataList = IS_MAINNET ? MainnetContractHashTags : TestnetContractHashTags
3337

3438
const IssuerContent: FC<{ address: string }> = ({ address }) => {
3539
const { t } = useTranslation()
@@ -185,6 +189,9 @@ export const UDTOverviewCard = ({
185189
)
186190

187191
const tags = xudt?.xudtTags ?? []
192+
const isOpenSourceXudt = xudt
193+
? scriptDataList.some(s => s.tag.startsWith('xUDT') && s.codeHashes.includes(xudt?.typeScript.codeHash))
194+
: false
188195

189196
return (
190197
<>
@@ -203,7 +210,7 @@ export const UDTOverviewCard = ({
203210
{tags.map(tag => (
204211
<XUDTTag tagName={tag} to="/xudts" tooltip />
205212
))}
206-
{xudtCodeUrl ? (
213+
{isOpenSourceXudt && xudtCodeUrl ? (
207214
<Link className={styles.openSource} to={xudtCodeUrl}>
208215
{t('scripts.open_source_script')}
209216
<OpenSourceIcon />

src/utils/transformer.ts

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export const transformToTransaction = (
3535
cycles: null,
3636
maxCyclesInEpoch: null,
3737
maxCycles: null,
38+
cellDeps: [],
39+
headerDeps: [],
40+
witnesses: [],
3841
}
3942
}
4043

0 commit comments

Comments
 (0)