Skip to content

Commit 39b4589

Browse files
committed
2 parents 09779c0 + b32833f commit 39b4589

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
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/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/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)