Skip to content

Commit 25dbdb8

Browse files
authored
Fix timestamp and system operations display in linera-explorer. (#4664)
## Motivation I am seeing errors in `linera-explorer` related to timestamps. With those fixed, system operations are still displayed as "Undefined operation". Here's what I tried: ``` cargo run --bin linera net up ``` Then I pasted the exports, made a transfer from the admin chain to another chain in my wallet, and started the service: ``` export LINERA_WALLET="/tmp/.tmpyTcUrm/wallet_0.json" export LINERA_KEYSTORE="/tmp/.tmpyTcUrm/keystore_0.json" export LINERA_STORAGE="rocksdb:/tmp/.tmpyTcUrm/client_0.db" cargo run --bin linera -- wallet show cargo run --bin linera -- transfer --from 9f2047e18cd35c7509fc118c1c1df6a88d936d450ac0c2ab4752b6cf51f81f1c --to 03479ab664451306a9bad6428f9b451527009c489fe21ade5e977411931d6942 0.1 cargo run --bin linera -- service --port 8080 ``` In another tab the indexer: ``` cargo run --bin linera-indexer -- run-graph-ql ``` And in a fourth tab the explorer: ``` cd linera-explorer npm run full npm run serve ``` If I then open localhost:3000 in Firefox I get a CORS error; in Chromium I get TypeErrors. ## Proposal With Claude's help, fix timestamp handling and at least show that it is a system operation. We should improve this further, so that this can be viewed as a transfer. ## Test Plan I tried it locally: <img width="2616" height="1543" alt="image" src="https://github.com/user-attachments/assets/89c2fbe3-a66e-403f-b560-8f9e67efa451" /> ## Release Plan - These changes should be backported to `testnet_conway`. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 3b46f4e commit 25dbdb8

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

linera-explorer/src/components/Block.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const incomingBundles = computed(() => getIncomingBundles(props.block.block.body
4848
</li>
4949
<li class="list-group-item d-flex justify-content-between">
5050
<span><strong>Timestamp</strong></span>
51-
<span>{{ (new Date(block.block.header.timestamp/1000)).toLocaleString() }}</span>
51+
<span>{{ (new Date(Number(block.block.header.timestamp)/1000)).toLocaleString() }}</span>
5252
</li>
5353
<li class="list-group-item d-flex justify-content-between">
5454
<span><strong>Signer</strong></span>

linera-explorer/src/components/Blocks.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defineProps<{blocks: ConfirmedBlock[]}>()
2828
<td :title="b.hash">
2929
<a @click="$root.route('block', [['block', b.hash]])" class="btn btn-link">{{ short_hash(b.hash) }}</a>
3030
</td>
31-
<td>{{ (new Date(b.block.header.timestamp/1000)).toLocaleString() }}</td>
31+
<td>{{ (new Date(Number(b.block.header.timestamp)/1000)).toLocaleString() }}</td>
3232
<td :title="b.block.header.authenticatedSigner">{{ b.block.header.authenticatedSigner }}</td>
3333
<td>{{ b.status }}</td>
3434
<td>{{ getIncomingBundles(b.block.body.transactionMetadata).length }}</td>

linera-explorer/src/components/Op.vue

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,41 @@ defineProps<{op: any, id: string, index?: number}>()
55
</script>
66

77
<template>
8-
<div v-if="op?.System">
9-
<div v-if="op.System.Transfer">
10-
<div class="card">
11-
<div class="card-header">
12-
<div class="card-title">
13-
<span v-if="index!==undefined">{{ index+1 }}. </span>
14-
<span>Transfer</span>
15-
</div>
16-
</div>
17-
<div class="card-body d-flex justify-content-around">
18-
<span>{{ op.System.Transfer.amount }}</span>
19-
<i class="bi bi-arrow-right"></i>
20-
<a :title="op.System.Transfer.recipient.Account.chain_id" @click="$root.route('blocks', [['chain', op.System.Transfer.recipient.Account.chain_id]])" class="btn btn-link">
21-
{{ short_hash(op.System.Transfer.recipient.Account.chain_id) }}
22-
</a>
23-
</div>
24-
</div>
25-
</div>
26-
<div v-else>
27-
<div class="card">
28-
<div class="card-header">
8+
<div v-if="op?.operationType === 'System'">
9+
<div class="card">
10+
<div class="card-header">
11+
<div class="card-title">
2912
<span v-if="index!==undefined">{{ index+1 }}. </span>
30-
<span>Operation</span>
13+
<span>System Operation</span>
3114
</div>
32-
<div class="card-body">
33-
<Json :data="op"/>
15+
</div>
16+
<div class="card-body">
17+
<div v-if="op.systemBytesHex" class="mb-3">
18+
<strong>Operation Data (hex):</strong>
19+
<pre class="mt-2 p-2 bg-light"><code>{{ op.systemBytesHex }}</code></pre>
3420
</div>
21+
<Json :data="op"/>
3522
</div>
3623
</div>
3724
</div>
3825

39-
<div v-else-if="op?.User">
26+
<div v-else-if="op?.operationType === 'User'">
4027
<div class="card">
4128
<div class="card-header">
4229
<span v-if="index!==undefined">{{ index+1 }}. </span>
43-
<span>Application</span>
30+
<span>User Operation</span>
31+
<span v-if="op.applicationId" class="badge bg-secondary ms-2">{{ short_app_id(op.applicationId) }}</span>
4432
</div>
4533
<div class="card-body">
46-
<pre><code>{{ op.User.bytes }}</code></pre>
34+
<div v-if="op.applicationId" class="mb-2">
35+
<strong>Application ID:</strong>
36+
<span class="font-monospace">{{ op.applicationId }}</span>
37+
</div>
38+
<div v-if="op.userBytesHex" class="mb-3">
39+
<strong>Operation Data (hex):</strong>
40+
<pre class="mt-2 p-2 bg-light"><code>{{ op.userBytesHex }}</code></pre>
41+
</div>
42+
<Json :data="op"/>
4743
</div>
4844
</div>
4945
</div>
@@ -52,7 +48,14 @@ defineProps<{op: any, id: string, index?: number}>()
5248
<div class="card">
5349
<div class="card-header">
5450
<span v-if="index!==undefined">{{ index+1 }}. </span>
55-
<span>Undefined operation</span>
51+
<span>Unknown Operation</span>
52+
<span v-if="op?.operationType" class="badge bg-warning ms-2">{{ op.operationType }}</span>
53+
</div>
54+
<div class="card-body">
55+
<div class="alert alert-info">
56+
<strong>Operation Type:</strong> {{ op?.operationType || 'Unknown' }}
57+
</div>
58+
<Json :data="op"/>
5659
</div>
5760
</div>
5861
</div>

0 commit comments

Comments
 (0)