Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into testnet #1826

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions src/constants/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const MainnetContractHashTags: ContractHashTag[] = [
depType: 'code',
hashType: 'data1',
tag: 'xUDT',
category: 'lock',
category: 'type',
},
{
codeHashes: ['0x4a4dce1df3dffff7f8b2cd7dff7303df3b6150c9788cb75dcf6747247132b9f5'],
Expand Down Expand Up @@ -660,15 +660,15 @@ export const TestnetContractHashTags: ContractHashTag[] = [
depType: 'code',
hashType: 'type',
tag: 'xUDT(final_rls)',
category: 'lock',
category: 'type',
},
{
codeHashes: ['0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95'],
txHashes: ['0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f-0'],
depType: 'code',
hashType: 'data1',
tag: 'xUDT',
category: 'lock',
category: 'type',
},
{
codeHashes: [
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
9 changes: 8 additions & 1 deletion src/pages/Xudt/UDTComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 (
<>
Expand All @@ -203,7 +210,7 @@ export const UDTOverviewCard = ({
{tags.map(tag => (
<XUDTTag tagName={tag} to="/xudts" tooltip />
))}
{xudtCodeUrl ? (
{isOpenSourceXudt && xudtCodeUrl ? (
<Link className={styles.openSource} to={xudtCodeUrl}>
{t('scripts.open_source_script')}
<OpenSourceIcon />
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
Loading