Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…frontend into develop
  • Loading branch information
Keith-CY committed Dec 18, 2024
2 parents 09779c0 + b32833f commit 39b4589
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/TransactionParameters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FC, ReactNode } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
import classNames from 'classnames'
import { useCKBNode } from '../../hooks/useCKBNode'
import { explorerService } from '../../services/ExplorerService'
import { matchTxHash } from '../../utils/util'
import Loading from '../AwesomeLoadings/Spinner'
import HashTag from '../HashTag'
Expand Down Expand Up @@ -48,9 +48,8 @@ const Field = ({

const TransactionParameters: FC<{ hash: string }> = ({ hash }) => {
const [t] = useTranslation()
const { nodeService } = useCKBNode()

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

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

const { header_deps: headerDeps, cell_deps: cellDeps, witnesses } = data.result.transaction
const { headerDeps, cellDeps, witnesses } = data

const parameters = [
{
Expand All @@ -84,8 +83,8 @@ const TransactionParameters: FC<{ hash: string }> = ({ hash }) => {
content: cellDeps.length ? (
cellDeps.map(cellDep => {
const {
out_point: { tx_hash: txHash, index },
dep_type: depType,
outPoint: { txHash, index },
depType,
} = cellDep
const hashTag = matchTxHash(txHash, Number(index))
return (
Expand Down
3 changes: 3 additions & 0 deletions src/models/Transaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export interface Transaction {
maxCyclesInEpoch: number | null
maxCycles: number | null
createTimestamp?: number
cellDeps: CellDep[]
headerDeps: string[]
witnesses: string[]
}

export interface BtcTx {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Transaction/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const defaultTransactionInfo: Transaction = {
cycles: null,
maxCyclesInEpoch: null,
maxCycles: null,
cellDeps: [],
headerDeps: [],
witnesses: [],
}

export const defaultTransactionLiteDetails: TransactionRecord[] = [
Expand Down
3 changes: 3 additions & 0 deletions src/utils/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export const transformToTransaction = (
cycles: null,
maxCyclesInEpoch: null,
maxCycles: null,
cellDeps: [],
headerDeps: [],
witnesses: [],
}
}

Expand Down

0 comments on commit 39b4589

Please sign in to comment.