feat: 按交易详情版式展示站内存证
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
import { readMintView } from './public-mint-view';
|
||||||
|
|
||||||
|
describe('readMintView', () => {
|
||||||
|
it('uses the frozen mint fields and ignores the rest of the raw response', () => {
|
||||||
|
const view = readMintView({
|
||||||
|
product: { productId: '154109005352', author: '黄志伟', feature: 'https://art.qclh.xyz/uploads/a.png' },
|
||||||
|
confirmation: { appKey: 'secret' },
|
||||||
|
}, '154109005352', '后来改名', '0xae3ecbac36b5874b0372686e5b88894c22be4296');
|
||||||
|
expect(view).toEqual({
|
||||||
|
author: '黄志伟',
|
||||||
|
productId: '154109005352',
|
||||||
|
feature: 'https://art.qclh.xyz/uploads/a.png',
|
||||||
|
mintTo: '0xae3ecbac36b5874b0372686e5b88894c22be4296',
|
||||||
|
});
|
||||||
|
expect(JSON.stringify(view)).not.toContain('secret');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to the artwork artist and short code when the snapshot is missing', () => {
|
||||||
|
expect(readMintView(null, '734648008702', '黄志伟', 'not-an-address')).toEqual({
|
||||||
|
author: '黄志伟',
|
||||||
|
productId: '734648008702',
|
||||||
|
feature: null,
|
||||||
|
mintTo: null,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export interface PublicMintView {
|
||||||
|
author: string | null;
|
||||||
|
productId: string;
|
||||||
|
feature: string | null;
|
||||||
|
mintTo: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function text(row: Record<string, unknown>, key: string): string | null {
|
||||||
|
const value = row[key];
|
||||||
|
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 只取出发行时保存的产品字段,不把原始响应里的其他内容交给浏览器。 */
|
||||||
|
export function readMintView(raw: unknown, shortCode: string, artist: string | null, wallet: string | null): PublicMintView {
|
||||||
|
const product = raw && typeof raw === 'object' ? (raw as { product?: unknown }).product : null;
|
||||||
|
const row = product && typeof product === 'object' ? product as Record<string, unknown> : {};
|
||||||
|
return {
|
||||||
|
author: text(row, 'author') || artist?.trim() || null,
|
||||||
|
productId: text(row, 'productId') || shortCode,
|
||||||
|
feature: text(row, 'feature'),
|
||||||
|
mintTo: wallet && /^0x[0-9a-fA-F]{40}$/.test(wallet) ? wallet : null,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -96,7 +96,8 @@ function createHarness(options: {
|
|||||||
set: jest.fn().mockResolvedValue('OK'),
|
set: jest.fn().mockResolvedValue('OK'),
|
||||||
};
|
};
|
||||||
const storage = { getUrl: jest.fn((key: string) => `/uploads/${key}`) };
|
const storage = { getUrl: jest.fn((key: string) => `/uploads/${key}`) };
|
||||||
const service = new PublicTraceService(prisma as any, storage as any, redis as any);
|
const settings = { get: jest.fn().mockResolvedValue(null) };
|
||||||
|
const service = new PublicTraceService(prisma as any, storage as any, redis as any, settings as any);
|
||||||
return { service, prisma };
|
return { service, prisma };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import {
|
|||||||
} from '@artveris/shared';
|
} from '@artveris/shared';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { StorageService } from '../storage/storage.service';
|
import { StorageService } from '../storage/storage.service';
|
||||||
|
import { SettingsService } from '../settings/settings.service';
|
||||||
import { REDIS_CLIENT } from '../redis/redis.module';
|
import { REDIS_CLIENT } from '../redis/redis.module';
|
||||||
import { parseUserAgent } from '../common/utils/ua.util';
|
import { parseUserAgent } from '../common/utils/ua.util';
|
||||||
|
import { readMintView } from './public-mint-view';
|
||||||
|
|
||||||
type TraceCodeWithRel = Prisma.TraceCodeGetPayload<{ include: { batch: true; artwork: true } }>;
|
type TraceCodeWithRel = Prisma.TraceCodeGetPayload<{ include: { batch: true; artwork: true } }>;
|
||||||
type ArtworkWithRel = Prisma.ArtworkGetPayload<{
|
type ArtworkWithRel = Prisma.ArtworkGetPayload<{
|
||||||
@@ -44,6 +46,7 @@ export class PublicTraceService {
|
|||||||
private readonly prisma: PrismaService,
|
private readonly prisma: PrismaService,
|
||||||
private readonly storage: StorageService,
|
private readonly storage: StorageService,
|
||||||
@Inject(REDIS_CLIENT) private readonly redis: Redis,
|
@Inject(REDIS_CLIENT) private readonly redis: Redis,
|
||||||
|
private readonly settings: SettingsService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private mapMedia(
|
private mapMedia(
|
||||||
@@ -265,6 +268,7 @@ export class PublicTraceService {
|
|||||||
const updated = await this.prisma.traceCode.findUniqueOrThrow({ where: { id } });
|
const updated = await this.prisma.traceCode.findUniqueOrThrow({ where: { id } });
|
||||||
|
|
||||||
const proof = await this.prisma.blockchainProof.findUnique({ where: { traceCodeId: id } });
|
const proof = await this.prisma.blockchainProof.findUnique({ where: { traceCodeId: id } });
|
||||||
|
const mintTo = await this.mintRecipient(proof);
|
||||||
|
|
||||||
const result = firstActivate ? QueryResult.FIRST_ACTIVATE : QueryResult.REPEAT;
|
const result = firstActivate ? QueryResult.FIRST_ACTIVATE : QueryResult.REPEAT;
|
||||||
await this.writeLog(id, artwork.id, shortCode, result, ctx, { ...code, ...updated });
|
await this.writeLog(id, artwork.id, shortCode, result, ctx, { ...code, ...updated });
|
||||||
@@ -276,7 +280,7 @@ export class PublicTraceService {
|
|||||||
queryCount: updated.queryCount,
|
queryCount: updated.queryCount,
|
||||||
firstActivatedAt: updated.firstActivatedAt,
|
firstActivatedAt: updated.firstActivatedAt,
|
||||||
},
|
},
|
||||||
...this.buildArtworkPayload(artwork, code, proof),
|
...this.buildArtworkPayload(artwork, code, proof, mintTo),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +325,7 @@ export class PublicTraceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const proof = await this.prisma.blockchainProof.findUnique({ where: { traceCodeId: id } });
|
const proof = await this.prisma.blockchainProof.findUnique({ where: { traceCodeId: id } });
|
||||||
|
const mintTo = await this.mintRecipient(proof);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const firstQuery = state === 'inactive';
|
const firstQuery = state === 'inactive';
|
||||||
@@ -335,7 +340,7 @@ export class PublicTraceService {
|
|||||||
queryCount: code.queryCount > 0 ? code.queryCount : 2,
|
queryCount: code.queryCount > 0 ? code.queryCount : 2,
|
||||||
firstActivatedAt: code.firstActivatedAt ?? now,
|
firstActivatedAt: code.firstActivatedAt ?? now,
|
||||||
},
|
},
|
||||||
...this.buildArtworkPayload(artwork, code, proof),
|
...this.buildArtworkPayload(artwork, code, proof, mintTo),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +348,7 @@ export class PublicTraceService {
|
|||||||
private buildArtworkPayload(
|
private buildArtworkPayload(
|
||||||
artwork: ArtworkWithRel,
|
artwork: ArtworkWithRel,
|
||||||
code: {
|
code: {
|
||||||
|
shortCode: string;
|
||||||
outbound?: {
|
outbound?: {
|
||||||
outTime: Date;
|
outTime: Date;
|
||||||
remark: string | null;
|
remark: string | null;
|
||||||
@@ -357,11 +363,15 @@ export class PublicTraceService {
|
|||||||
chainName: string | null;
|
chainName: string | null;
|
||||||
onchainAt: Date | null;
|
onchainAt: Date | null;
|
||||||
contractAddress: string | null;
|
contractAddress: string | null;
|
||||||
|
tokenId: bigint | null;
|
||||||
|
rawResponse: unknown;
|
||||||
status: string;
|
status: string;
|
||||||
failureReason: string | null;
|
failureReason: string | null;
|
||||||
submittedAt: Date | null;
|
submittedAt: Date | null;
|
||||||
} | null,
|
} | null,
|
||||||
|
mintTo: string | null,
|
||||||
) {
|
) {
|
||||||
|
const mint = proof ? readMintView(proof.rawResponse, code.shortCode, artwork.artist, mintTo) : null;
|
||||||
return {
|
return {
|
||||||
artwork: {
|
artwork: {
|
||||||
title: artwork.title,
|
title: artwork.title,
|
||||||
@@ -407,6 +417,11 @@ export class PublicTraceService {
|
|||||||
chainName: proof.chainName,
|
chainName: proof.chainName,
|
||||||
onchainAt: proof.onchainAt,
|
onchainAt: proof.onchainAt,
|
||||||
contractAddress: proof.contractAddress,
|
contractAddress: proof.contractAddress,
|
||||||
|
tokenId: proof.tokenId === null || proof.tokenId === undefined ? null : proof.tokenId.toString(),
|
||||||
|
author: mint?.author ?? null,
|
||||||
|
productId: mint?.productId ?? code.shortCode,
|
||||||
|
feature: mint?.feature ?? null,
|
||||||
|
mintTo: mint?.mintTo ?? null,
|
||||||
submittedAt: proof.submittedAt,
|
submittedAt: proof.submittedAt,
|
||||||
failureReason: this.publicFailureReason(proof.status, proof.failureReason),
|
failureReason: this.publicFailureReason(proof.status, proof.failureReason),
|
||||||
}
|
}
|
||||||
@@ -414,6 +429,12 @@ export class PublicTraceService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async mintRecipient(proof: { chainName: string | null } | null): Promise<string | null> {
|
||||||
|
if (proof?.chainName !== '天河链') return null;
|
||||||
|
const value = await this.settings.get('tianheWalletAddress');
|
||||||
|
return typeof value === 'string' && /^0x[0-9a-fA-F]{40}$/.test(value) ? value : null;
|
||||||
|
}
|
||||||
|
|
||||||
private publicFailureReason(status: string, reason: string | null): string | null {
|
private publicFailureReason(status: string, reason: string | null): string | null {
|
||||||
if (status === ProofStatus.UNKNOWN) return '链上结果暂时无法确认,请稍后重试或联系平台管理员';
|
if (status === ProofStatus.UNKNOWN) return '链上结果暂时无法确认,请稍后重试或联系平台管理员';
|
||||||
if (status === ProofStatus.FAILED) return reason ? '上链处理失败,请联系平台管理员' : '上链处理失败';
|
if (status === ProofStatus.FAILED) return reason ? '上链处理失败,请联系平台管理员' : '上链处理失败';
|
||||||
|
|||||||
@@ -68,21 +68,23 @@
|
|||||||
<div v-else class="chain-empty muted">{{ t('chain.notOnchain') }}</div>
|
<div v-else class="chain-empty muted">{{ t('chain.notOnchain') }}</div>
|
||||||
</section>
|
</section>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<dialog ref="proofDialog" class="certificate-dialog" aria-labelledby="proof-dialog-title" @cancel.prevent="closeProof">
|
<dialog ref="proofDialog" class="tx-dialog" aria-labelledby="proof-dialog-title" @cancel.prevent="closeProof">
|
||||||
<button class="certificate-close" :aria-label="t('viewer.close')" @click="closeProof">×</button>
|
<h3 id="proof-dialog-title" class="sr-only">{{ t('chain.proofTitle') }}</h3>
|
||||||
<h3 id="proof-dialog-title">{{ t('chain.proofTitle') }}</h3>
|
<trace-tx-detail
|
||||||
<div class="sheet-body">
|
:tx-hash="blockchain?.txHash"
|
||||||
<div v-for="row in proofRows" :key="row.label" class="sheet-row">
|
:succeeded="status === 'ONCHAIN'"
|
||||||
<span>{{ row.label }}</span>
|
:status-text="t(`chain.statuses.${status}`)"
|
||||||
<strong>{{ row.value }}</strong>
|
:block-height="blockchain?.blockHeight"
|
||||||
<button v-if="row.copy" class="icon-copy" :aria-label="t('chain.copy')" @click="$emit('copy', row.copy)">
|
:contract-address="blockchain?.contractAddress"
|
||||||
<svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true">
|
:onchain-at="blockchain?.onchainAt"
|
||||||
<rect x="9" y="9" width="11" height="11" rx="2" fill="none" stroke="currentColor" stroke-width="1.7" />
|
:token-id="blockchain?.tokenId"
|
||||||
<path d="M5 15V5a2 2 0 0 1 2-2h8" fill="none" stroke="currentColor" stroke-width="1.7" />
|
:author="blockchain?.author"
|
||||||
</svg>
|
:product-id="blockchain?.productId || shortCode"
|
||||||
</button>
|
:feature="blockchain?.feature"
|
||||||
</div>
|
:mint-to="blockchain?.mintTo"
|
||||||
</div>
|
@copy="(value) => $emit('copy', value)"
|
||||||
|
@close="closeProof"
|
||||||
|
/>
|
||||||
</dialog>
|
</dialog>
|
||||||
<dialog ref="certificateDialog" class="certificate-dialog" aria-labelledby="certificate-dialog-title" @cancel.prevent="closeCertificateDialog">
|
<dialog ref="certificateDialog" class="certificate-dialog" aria-labelledby="certificate-dialog-title" @cancel.prevent="closeCertificateDialog">
|
||||||
<button class="certificate-close" :aria-label="t('viewer.close')" @click="closeCertificateDialog">×</button>
|
<button class="certificate-close" :aria-label="t('viewer.close')" @click="closeCertificateDialog">×</button>
|
||||||
@@ -114,6 +116,7 @@
|
|||||||
import { computed, onUnmounted, ref, watch } from 'vue';
|
import { computed, onUnmounted, ref, watch } from 'vue';
|
||||||
import { fetchTraceCertificate, requestTraceCertificate, type TraceCertificateRecord, type TraceCertificateResult } from '@/api';
|
import { fetchTraceCertificate, requestTraceCertificate, type TraceCertificateRecord, type TraceCertificateResult } from '@/api';
|
||||||
import { downloadCertificatePng } from '@/utils/certificateImage';
|
import { downloadCertificatePng } from '@/utils/certificateImage';
|
||||||
|
import TraceTxDetail from './TraceTxDetail.vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
@@ -139,6 +142,11 @@ const props = defineProps<{
|
|||||||
blockHeight?: string | number | null;
|
blockHeight?: string | number | null;
|
||||||
onchainAt?: string | null;
|
onchainAt?: string | null;
|
||||||
blockHash?: string | null;
|
blockHash?: string | null;
|
||||||
|
tokenId?: string | number | null;
|
||||||
|
author?: string | null;
|
||||||
|
productId?: string | null;
|
||||||
|
feature?: string | null;
|
||||||
|
mintTo?: string | null;
|
||||||
failureReason?: string | null;
|
failureReason?: string | null;
|
||||||
chainName?: string | null;
|
chainName?: string | null;
|
||||||
} | null;
|
} | null;
|
||||||
@@ -228,17 +236,6 @@ const status = computed<ProofStatus>(() => {
|
|||||||
const value = props.blockchain?.status as ProofStatus | undefined;
|
const value = props.blockchain?.status as ProofStatus | undefined;
|
||||||
return value && STATUSES.has(value) ? value : 'ONCHAIN';
|
return value && STATUSES.has(value) ? value : 'ONCHAIN';
|
||||||
});
|
});
|
||||||
const proofRows = computed(() => {
|
|
||||||
const chain = props.blockchain;
|
|
||||||
if (!chain) return [];
|
|
||||||
return [
|
|
||||||
{ label: t('chain.hash'), value: chain.txHash || '-', copy: chain.txHash || '' },
|
|
||||||
{ label: t('chain.contract'), value: chain.contractAddress || '-', copy: chain.contractAddress || '' },
|
|
||||||
{ label: t('chain.blockHeight'), value: chain.blockHeight == null ? '-' : String(chain.blockHeight), copy: '' },
|
|
||||||
{ label: t('chain.blockHash'), value: chain.blockHash || '-', copy: chain.blockHash || '' },
|
|
||||||
{ label: t('chain.onchainAt'), value: chain.onchainAt ? formatTime(chain.onchainAt) : '-', copy: '' },
|
|
||||||
];
|
|
||||||
});
|
|
||||||
const certificateRows = computed(() => {
|
const certificateRows = computed(() => {
|
||||||
const record = certificateRecord.value;
|
const record = certificateRecord.value;
|
||||||
if (!record) return [];
|
if (!record) return [];
|
||||||
@@ -374,6 +371,9 @@ function formatTime(value?: string | null) {
|
|||||||
.chain-actions { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
|
.chain-actions { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
|
||||||
.certificate-link { margin-left: auto; padding: 0; border: 0; background: none; cursor: pointer; font-family: inherit; }
|
.certificate-link { margin-left: auto; padding: 0; border: 0; background: none; cursor: pointer; font-family: inherit; }
|
||||||
.certificate-link:disabled { opacity: .55; cursor: default; }
|
.certificate-link:disabled { opacity: .55; cursor: default; }
|
||||||
|
.tx-dialog { width: min(960px, calc(100vw - 16px)); max-height: calc(100vh - 16px); padding: 0; border: 0; background: transparent; box-shadow: none; overflow: auto; }
|
||||||
|
.tx-dialog::backdrop { background: #0007; }
|
||||||
|
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
|
||||||
.certificate-dialog { width: min(420px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 48px)); box-sizing: border-box; padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--card-bg); color: var(--text); box-shadow: 0 16px 60px #0003; }
|
.certificate-dialog { width: min(420px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 48px)); box-sizing: border-box; padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--card-bg); color: var(--text); box-shadow: 0 16px 60px #0003; }
|
||||||
.certificate-dialog[open] { display: flex; flex-direction: column; }
|
.certificate-dialog[open] { display: flex; flex-direction: column; }
|
||||||
.sheet-body { overflow: auto; min-height: 0; }
|
.sheet-body { overflow: auto; min-height: 0; }
|
||||||
|
|||||||
@@ -0,0 +1,235 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tx-page">
|
||||||
|
<div class="tx-top">
|
||||||
|
<h3>{{ t('chain.txTitle') }}</h3>
|
||||||
|
<div class="tx-hashbox">{{ txHash || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
<section class="tx-card">
|
||||||
|
<div class="tx-tabs" role="tablist">
|
||||||
|
<button type="button" role="tab" :class="{ active: tab === 'info' }" :aria-selected="tab === 'info'" @click="tab = 'info'">{{ t('chain.txInfo') }}</button>
|
||||||
|
<button type="button" role="tab" :class="{ active: tab === 'logs' }" :aria-selected="tab === 'logs'" @click="tab = 'logs'">{{ t('chain.txLogs') }}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="tab === 'info'" class="tx-panel" role="tabpanel">
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>{{ t('chain.txHash') }}</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<b class="mono">{{ txHash || '-' }}</b>
|
||||||
|
<button v-if="txHash" type="button" class="tx-copy" :aria-label="t('chain.copy')" @click="$emit('copy', txHash)">
|
||||||
|
<CopyIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>{{ t('chain.txStatus') }}</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<em v-if="succeeded" class="tx-ok">{{ t('chain.txSuccess') }}</em>
|
||||||
|
<em v-else class="tx-pending">{{ statusText }}</em>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="blockHeight != null" class="tx-row">
|
||||||
|
<span>{{ t('chain.blockHeight') }}</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<b>{{ blockHeight }}</b>
|
||||||
|
<button type="button" class="tx-copy" :aria-label="t('chain.copy')" @click="$emit('copy', String(blockHeight))">
|
||||||
|
<CopyIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>{{ t('chain.txAction') }}</span>
|
||||||
|
<div class="tx-value tx-action">
|
||||||
|
{{ t('chain.txIssue') }} <b>{{ tokenId || '-' }}</b>
|
||||||
|
{{ t('chain.txFromNull') }}
|
||||||
|
<span class="tx-addr">{{ zeroAddress }}</span>
|
||||||
|
<template v-if="mintTo">
|
||||||
|
{{ t('chain.txToward') }}
|
||||||
|
<span class="tx-addr">{{ mintTo }}</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="contractAddress" class="tx-row">
|
||||||
|
<span>{{ t('chain.contract') }}</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<span class="tx-addr">{{ contractAddress }}</span>
|
||||||
|
<button type="button" class="tx-copy" :aria-label="t('chain.copy')" @click="$emit('copy', contractAddress)">
|
||||||
|
<CopyIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="contractAddress" class="tx-row">
|
||||||
|
<span>{{ t('chain.txReceiver') }}</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<span class="tx-addr">{{ contractAddress }}</span>
|
||||||
|
<button type="button" class="tx-copy" :aria-label="t('chain.copy')" @click="$emit('copy', contractAddress)">
|
||||||
|
<CopyIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>{{ t('chain.txTime') }}</span>
|
||||||
|
<div class="tx-value"><b>{{ timeText }}</b></div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row tx-input-row">
|
||||||
|
<span>{{ t('chain.txInput') }}</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<div class="tx-method"><i>Method</i><b>{{ mintMethod }}</b></div>
|
||||||
|
<div class="tx-method"><i>MethodId</i><b class="mono">{{ mintMethodId }}</b></div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Input</th>
|
||||||
|
<th>{{ t('chain.txName') }}</th>
|
||||||
|
<th>{{ t('chain.txType') }}</th>
|
||||||
|
<th>{{ t('chain.txData') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="row in inputs" :key="row.name">
|
||||||
|
<td></td>
|
||||||
|
<td>{{ row.name }}</td>
|
||||||
|
<td>{{ row.type }}</td>
|
||||||
|
<td>
|
||||||
|
<span class="tx-cell">{{ row.value }}</span>
|
||||||
|
<button v-if="row.copy" type="button" class="tx-copy" :aria-label="t('chain.copy')" @click="$emit('copy', row.copy)">
|
||||||
|
<CopyIcon />
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="tx-panel" role="tabpanel">
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>Address</span>
|
||||||
|
<div class="tx-value"><span class="tx-addr">{{ contractAddress || '-' }}</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>Name</span>
|
||||||
|
<div class="tx-value"><b>Transfer(address from, address to, uint256 tokenId)</b></div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>Topics</span>
|
||||||
|
<div class="tx-value">
|
||||||
|
<div v-for="(topic, index) in topics" :key="index" class="tx-topic">
|
||||||
|
<i>[{{ index }}]</i>
|
||||||
|
<em v-if="index > 0">Dec</em>
|
||||||
|
<span class="mono">{{ topic }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tx-row">
|
||||||
|
<span>Data</span>
|
||||||
|
<div class="tx-value"><b class="mono">0x</b></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="tx-back" @click="$emit('close')">{{ t('chain.txBack') }}</button>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, defineComponent, h, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
const CopyIcon = defineComponent({
|
||||||
|
name: 'CopyIcon',
|
||||||
|
setup() {
|
||||||
|
return () => h('svg', { viewBox: '0 0 24 24', width: 14, height: 14, 'aria-hidden': 'true' }, [
|
||||||
|
h('rect', { x: 8, y: 8, width: 11, height: 11, rx: 2, fill: 'none', stroke: 'currentColor', 'stroke-width': 1.7 }),
|
||||||
|
h('path', { d: 'M5 15V5a2 2 0 0 1 2-2h8', fill: 'none', stroke: 'currentColor', 'stroke-width': 1.7 }),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ZERO_ADDRESS = '0x' + '0'.repeat(40);
|
||||||
|
const TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
|
||||||
|
const MINT_METHOD = 'mint(address to, string author, string productId, string feature, string initPrice)';
|
||||||
|
const MINT_METHOD_ID = '0xa40d1b10';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
txHash?: string | null;
|
||||||
|
succeeded: boolean;
|
||||||
|
statusText: string;
|
||||||
|
blockHeight?: string | number | null;
|
||||||
|
contractAddress?: string | null;
|
||||||
|
onchainAt?: string | null;
|
||||||
|
tokenId?: string | number | null;
|
||||||
|
author?: string | null;
|
||||||
|
productId?: string | null;
|
||||||
|
feature?: string | null;
|
||||||
|
mintTo?: string | null;
|
||||||
|
}>();
|
||||||
|
defineEmits<{ (event: 'copy', value: string): void; (event: 'close'): void }>();
|
||||||
|
const { t } = useI18n();
|
||||||
|
const tab = ref<'info' | 'logs'>('info');
|
||||||
|
const zeroAddress = ZERO_ADDRESS;
|
||||||
|
const mintMethod = MINT_METHOD;
|
||||||
|
const mintMethodId = MINT_METHOD_ID;
|
||||||
|
|
||||||
|
const timeText = computed(() => {
|
||||||
|
if (!props.onchainAt) return '-';
|
||||||
|
const parsed = dayjs(props.onchainAt);
|
||||||
|
return parsed.isValid() ? parsed.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||||
|
});
|
||||||
|
const inputs = computed(() => [
|
||||||
|
{ name: 'to', type: 'address', value: props.mintTo || '-', copy: props.mintTo || '' },
|
||||||
|
{ name: 'author', type: 'string', value: props.author || '-', copy: props.author || '' },
|
||||||
|
{ name: 'productId', type: 'string', value: props.productId || '-', copy: props.productId || '' },
|
||||||
|
{ name: 'feature', type: 'string', value: props.feature || '-', copy: props.feature || '' },
|
||||||
|
{ name: 'initPrice', type: 'string', value: '-', copy: '' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const topics = computed(() => {
|
||||||
|
const token = props.tokenId == null || props.tokenId === '' ? null : String(props.tokenId);
|
||||||
|
return [
|
||||||
|
TRANSFER_TOPIC,
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
props.mintTo || '-',
|
||||||
|
token && /^\d+$/.test(token) ? token : '-',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.tx-page { background: #f4f6fa; color: #1f2a37; border-radius: 12px; padding: 18px 18px 22px; }
|
||||||
|
.tx-top { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px; }
|
||||||
|
.tx-top h3 { margin: 0; font-size: 18px; font-weight: 600; }
|
||||||
|
.tx-hashbox { max-width: 420px; flex: 1; border: 1px solid #e3e8f0; background: #fff; border-radius: 999px; padding: 7px 14px; color: #667085; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.tx-card { background: #fff; border: 1px solid #e6ebf2; border-radius: 10px; padding: 8px 22px 22px; }
|
||||||
|
.tx-tabs { display: flex; gap: 22px; border-bottom: 1px solid #edf1f6; }
|
||||||
|
.tx-tabs button { border: 0; background: transparent; padding: 12px 0; color: #667085; font: inherit; cursor: pointer; }
|
||||||
|
.tx-tabs button.active { color: #3b6cff; box-shadow: inset 0 -2px 0 #3b6cff; }
|
||||||
|
.tx-row { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 12px; padding: 13px 0; border-bottom: 1px solid #f2f4f8; font-size: 14px; }
|
||||||
|
.tx-row > span { color: #8b95a7; }
|
||||||
|
.tx-value { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
|
||||||
|
.tx-action { line-height: 1.7; }
|
||||||
|
.tx-addr { color: #3b6cff; word-break: break-all; }
|
||||||
|
.tx-ok, .tx-pending { font-style: normal; border-radius: 6px; padding: 2px 8px; font-size: 13px; }
|
||||||
|
.tx-ok { color: #178a52; background: #e8f8ef; }
|
||||||
|
.tx-pending { color: #9a4a00; background: #fff4e8; }
|
||||||
|
.tx-copy { width: 22px; height: 22px; border: 0; background: transparent; color: #98a2b3; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
|
||||||
|
.tx-method { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px; width: 100%; padding: 4px 0; }
|
||||||
|
.tx-method i { color: #667085; font-style: normal; }
|
||||||
|
.tx-input-row .tx-value { display: block; }
|
||||||
|
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
|
||||||
|
th, td { border-bottom: 1px solid #f2f4f8; text-align: left; padding: 8px 6px; vertical-align: top; }
|
||||||
|
th { color: #667085; font-weight: 500; }
|
||||||
|
.tx-cell { word-break: break-all; white-space: pre-wrap; }
|
||||||
|
.tx-topic { display: flex; gap: 8px; align-items: flex-start; width: 100%; padding: 3px 0; }
|
||||||
|
.tx-topic i, .tx-topic em { color: #98a2b3; font-style: normal; flex: none; }
|
||||||
|
.mono { font-family: Consolas, 'SFMono-Regular', monospace; word-break: break-all; }
|
||||||
|
.tx-back { margin-top: 18px; border: 0; background: #3b6cff; color: #fff; border-radius: 6px; padding: 8px 18px; font: inherit; cursor: pointer; }
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.tx-page { padding: 12px; }
|
||||||
|
.tx-top, .tx-row { display: block; }
|
||||||
|
.tx-hashbox { max-width: none; margin-top: 10px; }
|
||||||
|
.tx-row > span { display: block; margin-bottom: 6px; }
|
||||||
|
.tx-card { padding: 8px 12px 16px; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -60,7 +60,24 @@
|
|||||||
"blockHeight": "Block Height",
|
"blockHeight": "Block Height",
|
||||||
"onchainAt": "On-chain Time",
|
"onchainAt": "On-chain Time",
|
||||||
"blockHash": "Block Hash",
|
"blockHash": "Block Hash",
|
||||||
"proofTitle": "Attestation",
|
"proofTitle": "Transaction",
|
||||||
|
"txTitle": "Transaction",
|
||||||
|
"txInfo": "Details",
|
||||||
|
"txLogs": "Logs",
|
||||||
|
"txHash": "Tx Hash",
|
||||||
|
"txStatus": "Status",
|
||||||
|
"txSuccess": "Success",
|
||||||
|
"txAction": "Action",
|
||||||
|
"txIssue": "Mint NFR ID",
|
||||||
|
"txFromNull": "from Null Address:",
|
||||||
|
"txToward": "to",
|
||||||
|
"txReceiver": "Receiver",
|
||||||
|
"txTime": "Created",
|
||||||
|
"txInput": "Input",
|
||||||
|
"txName": "Name",
|
||||||
|
"txType": "Type",
|
||||||
|
"txData": "Data",
|
||||||
|
"txBack": "Back",
|
||||||
"explorer": "View Proof",
|
"explorer": "View Proof",
|
||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
"copied": "Copied",
|
"copied": "Copied",
|
||||||
|
|||||||
@@ -60,7 +60,24 @@
|
|||||||
"blockHeight": "区块高度",
|
"blockHeight": "区块高度",
|
||||||
"onchainAt": "上链时间",
|
"onchainAt": "上链时间",
|
||||||
"blockHash": "区块哈希",
|
"blockHash": "区块哈希",
|
||||||
"proofTitle": "存证详情",
|
"proofTitle": "交易详情",
|
||||||
|
"txTitle": "交易详情",
|
||||||
|
"txInfo": "交易信息",
|
||||||
|
"txLogs": "日志",
|
||||||
|
"txHash": "交易哈希",
|
||||||
|
"txStatus": "状态",
|
||||||
|
"txSuccess": "成功",
|
||||||
|
"txAction": "交易动作",
|
||||||
|
"txIssue": "发行 NFR ID",
|
||||||
|
"txFromNull": "从 Null Address:",
|
||||||
|
"txToward": "到",
|
||||||
|
"txReceiver": "接收方",
|
||||||
|
"txTime": "交易生成时间",
|
||||||
|
"txInput": "输入信息",
|
||||||
|
"txName": "名称",
|
||||||
|
"txType": "类型",
|
||||||
|
"txData": "数据",
|
||||||
|
"txBack": "返回",
|
||||||
"explorer": "查看存证",
|
"explorer": "查看存证",
|
||||||
"copy": "复制",
|
"copy": "复制",
|
||||||
"copied": "已复制",
|
"copied": "已复制",
|
||||||
|
|||||||
Reference in New Issue
Block a user