Compare commits

..

No commits in common. "dev" and "master" have entirely different histories.
dev ... master

3 changed files with 8 additions and 124 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ping.pub",
"version": "3.0.1-zenith-0.2.0",
"version": "3.0.1-zenith-0.1.2",
"private": true,
"target": "",
"scripts": {

View File

@ -46,12 +46,7 @@ const chain = useBlockchain();
<tr v-for="item in txs">
<td>{{ item.injected }}</td>
<td>
<RouterLink
v-if="item.injected === 'Injected'"
:to="`/${chain.chainName}/tx/${item.hash}?type=injected`"
class="text-primary dark:invert">
{{ item.hash }}
</RouterLink>
<span v-if="item.injected === 'Injected'">{{ item.hash }}</span>
<RouterLink v-else :to="`/${chain.chainName}/tx/${item.hash}`" class="text-primary dark:invert">{{
item.hash
}}</RouterLink>

View File

@ -1,78 +1,27 @@
<script lang="ts" setup>
import { onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { JsonViewer } from 'vue3-json-viewer';
import { useBaseStore, useBlockchain, useFormatter } from '@/stores';
import DynamicComponent from '@/components/dynamic/DynamicComponent.vue';
import { computed, ref } from '@vue/reactivity';
import type { Tx, TxResponse } from '@/types';
import { JsonViewer } from 'vue3-json-viewer';
// if you used v1.0.5 or latster ,you should add import "vue3-json-viewer/dist/index.css"
import 'vue3-json-viewer/dist/index.css';
const props = defineProps(['hash', 'chain']);
const route = useRoute();
const blockchain = useBlockchain();
const baseStore = useBaseStore();
const chainStore = useBlockchain();
const format = useFormatter();
const rpcList = ref(chainStore.current?.endpoints?.rpc || [{ address: '', provider: '' }]);
let rpc = ref('');
const tx = ref(
{} as {
tx: Tx;
tx_response: TxResponse;
}
);
const voteExtension = ref(null as any);
const bundleTx = ref(null as any);
const isInjected = computed(() => route.query.type === 'injected');
onMounted(async () => {
rpc.value = rpcList.value[0].address;
if (props.hash) {
if (isInjected.value) {
getTxFromRPC(props.hash).then((data) => {
if (data.result) {
const txBytes = new Uint8Array(atob(data.result.tx).split('').map((c: string) => c.charCodeAt(0)));
const decoded = new TextDecoder().decode(txBytes);
// Check if it's a bundle tx
if (decoded.startsWith('INCLUDE_BUNDLE_TX:')) {
const bundleJson = decoded.replace('INCLUDE_BUNDLE_TX:', '');
bundleTx.value = {
...data.result,
decoded: JSON.parse(bundleJson)
};
} else {
// It's a vote extension
voteExtension.value = {
...data.result,
decoded: JSON.parse(decoded)
};
}
}
});
} else {
blockchain.rpc.getTx(props.hash).then((x) => (tx.value = x));
}
}
})
async function getTxFromRPC(hash: string) {
const response = await fetch(rpc.value + `/tx?hash=0x${hash}`);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const data = await response.json();
return data;
if (props.hash) {
blockchain.rpc.getTx(props.hash).then((x) => (tx.value = x));
}
const messages = computed(() => {
return (
tx.value.tx?.body?.messages.map((x) => {
@ -84,22 +33,6 @@ const messages = computed(() => {
}) || []
);
});
const jsonData = computed(() => {
if (tx.value.tx_response) {
return tx.value;
}
if (voteExtension.value) {
return voteExtension.value.decoded
}
if (bundleTx.value) {
return bundleTx.value.decoded
}
return undefined;
});
</script>
<template>
<div>
@ -111,50 +44,6 @@ const jsonData = computed(() => {
<a class="tab text-gray-400 uppercase tab-active">Transaction</a>
</div>
<div v-if="bundleTx" class="bg-base-100 px-4 pt-3 pb-4 rounded shadow mb-4">
<h2 class="card-title truncate mb-2">Bundle Transaction</h2>
<div class="overflow-hidden">
<table class="table text-sm">
<tbody>
<tr>
<td>Tx Hash</td>
<td class="overflow-hidden">{{ bundleTx.hash }}</td>
</tr>
<tr>
<td>Height</td>
<td>
<RouterLink :to="`/${props.chain}/block/${bundleTx.height}`" class="text-primary dark:invert"
>{{ bundleTx.height }}
</RouterLink>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div v-if="voteExtension" class="bg-base-100 px-4 pt-3 pb-4 rounded shadow mb-4">
<h2 class="card-title truncate mb-2">Vote Extension</h2>
<div class="overflow-hidden">
<table class="table text-sm">
<tbody>
<tr>
<td>Tx Hash</td>
<td class="overflow-hidden">{{ voteExtension.hash }}</td>
</tr>
<tr>
<td>Height</td>
<td>
<RouterLink :to="`/${props.chain}/block/${voteExtension.height}`" class="text-primary dark:invert"
>{{ voteExtension.height }}
</RouterLink>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div v-if="tx.tx_response" class="bg-base-100 px-4 pt-3 pb-4 rounded shadow mb-4">
<h2 class="card-title truncate mb-2">{{ $t('tx.title') }}</h2>
<div class="overflow-hidden">
@ -227,16 +116,16 @@ const jsonData = computed(() => {
<div v-if="messages.length === 0">{{ $t('tx.no_messages') }}</div>
</div>
<div v-if="jsonData" class="bg-base-100 px-4 pt-3 pb-4 rounded shadow">
<div v-if="tx.tx_response" class="bg-base-100 px-4 pt-3 pb-4 rounded shadow">
<h2 class="card-title truncate mb-2">JSON</h2>
<JsonViewer
:value="jsonData"
:value="tx"
:theme="baseStore.theme"
style="background: transparent"
copyable
boxed
sort
:expand-depth="5"
expand-depth="5"
/>
</div>
</div>