2022-02-10 11:44:04 +01:00
|
|
|
<template>
|
|
|
|
<v-container>
|
|
|
|
<v-row class="d-flex justify-space-beetween">
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-form>
|
|
|
|
<v-text-field
|
|
|
|
background-color="white"
|
|
|
|
append-icon="mdi-magnify"
|
|
|
|
label="Search by Address / Txn Hash / Block"
|
|
|
|
outlined
|
|
|
|
clearable
|
|
|
|
></v-text-field>
|
|
|
|
</v-form>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
2022-02-18 09:04:16 +01:00
|
|
|
<v-row v-if="loaded" class="d-flex justify-space-beetween">
|
2022-02-10 11:44:04 +01:00
|
|
|
<v-col cols="12" sm="6" lg="4">
|
|
|
|
<info-card
|
2022-02-18 09:04:16 +01:00
|
|
|
icon="mdi-pound"
|
2022-02-10 11:44:04 +01:00
|
|
|
title="Block Height"
|
2022-02-18 09:04:16 +01:00
|
|
|
:sub-title="parseInt(latestBlock, 16)"
|
2022-02-10 11:44:04 +01:00
|
|
|
color="blue"
|
|
|
|
>
|
|
|
|
</info-card>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" sm="6" lg="4">
|
|
|
|
<info-card
|
|
|
|
icon="mdi-pickaxe"
|
|
|
|
title="Active Validators"
|
2022-02-18 09:04:16 +01:00
|
|
|
:sub-title="validatorCount"
|
2022-02-10 11:44:04 +01:00
|
|
|
color="red"
|
|
|
|
>
|
|
|
|
</info-card>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" sm="6" lg="4">
|
|
|
|
<info-card
|
|
|
|
icon="mdi-wallet"
|
|
|
|
title="Wallet Addresses"
|
2022-02-18 09:04:16 +01:00
|
|
|
:sub-title="walletAddresses"
|
2022-02-10 11:44:04 +01:00
|
|
|
color="green"
|
|
|
|
>
|
|
|
|
</info-card>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
2022-02-18 09:04:16 +01:00
|
|
|
<v-row v-else>
|
|
|
|
<v-col cols="12">
|
|
|
|
<loader h="100px"></loader>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
|
|
|
|
<v-row v-if="loaded" class="d-flex justify-space-between">
|
|
|
|
<v-col cols="12" lg="5">
|
|
|
|
<blocks-table :latestBlocks="lastFiveBlocks"></blocks-table>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-row else class="d-flex justify-space-between">
|
|
|
|
<v-col cols="12" lg="5">
|
|
|
|
<loader h="100px"></loader>
|
2022-02-10 11:44:04 +01:00
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-18 09:04:16 +01:00
|
|
|
import InfoCard from '~/components/landing/InfoCard.vue'
|
|
|
|
import BlocksTable from '~/components/landing/BlocksTable.vue'
|
|
|
|
import Loader from '~/components/Loader.vue'
|
|
|
|
|
2022-02-10 11:44:04 +01:00
|
|
|
export default {
|
2022-02-18 09:04:16 +01:00
|
|
|
components: {
|
|
|
|
InfoCard,
|
|
|
|
BlocksTable,
|
|
|
|
Loader,
|
|
|
|
},
|
2022-02-10 11:44:04 +01:00
|
|
|
mounted() {
|
|
|
|
let nuxtCtx = this
|
|
|
|
if (process.client) {
|
2022-02-18 09:04:16 +01:00
|
|
|
const wsConnection = new WebSocket(
|
|
|
|
'wss://kovan.infura.io/ws/v3/0971e1402a8b46af9fd4996c5a612655'
|
|
|
|
)
|
2022-02-10 11:44:04 +01:00
|
|
|
|
|
|
|
wsConnection.onmessage = function (event) {
|
|
|
|
const blockData = JSON.parse(event.data)
|
|
|
|
if (blockData?.params) {
|
|
|
|
nuxtCtx.queueBlock({
|
|
|
|
height: blockData.params.result.number,
|
2022-02-18 09:04:16 +01:00
|
|
|
signer: nuxtCtx.$ethers.utils.getAddress(
|
|
|
|
blockData.params.result.author
|
|
|
|
),
|
2022-02-10 11:44:04 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wsConnection.onopen = function (event) {
|
|
|
|
this.send(
|
|
|
|
JSON.stringify({
|
|
|
|
method: 'eth_subscribe',
|
|
|
|
params: ['newHeads'],
|
|
|
|
id: 1,
|
|
|
|
jsonrpc: '2.0',
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-02-18 09:04:16 +01:00
|
|
|
loaded: false,
|
2022-02-10 11:44:04 +01:00
|
|
|
blocksTable: [
|
|
|
|
{
|
|
|
|
text: 'Height',
|
|
|
|
value: 'height',
|
|
|
|
},
|
2022-02-18 09:04:16 +01:00
|
|
|
|
2022-02-10 11:44:04 +01:00
|
|
|
{
|
|
|
|
text: 'Miner',
|
|
|
|
value: 'miner',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
queueBlock(opts) {
|
2022-02-18 09:04:16 +01:00
|
|
|
this.lastFiveBlocks.unshift(opts)
|
2022-02-10 11:44:04 +01:00
|
|
|
this.latestBlock = opts.height
|
2022-02-18 09:04:16 +01:00
|
|
|
|
|
|
|
if (this.lastFiveBlocks.length > 5) {
|
|
|
|
this.lastFiveBlocks.pop()
|
|
|
|
}
|
2022-02-10 11:44:04 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
}
|