UNPKG

@bloxbean/yaci-viewer

Version:

A Cardano blockchain data viewer for developers. It works with the Yaci-Store backend, supporting both a local devnet and public networks.

3 lines (2 loc) 7.96 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../chunks/store.3kMI1D0r.js","../chunks/index.DQ_X5mOz.js","../chunks/runtime.NVyxXVLy.js"])))=>i.map(i=>d[i]); import{_ as W}from"../chunks/preload-helper.C1FmrZbK.js";import{c as Z,a as m,t as u}from"../chunks/disclose-version.BTC8Bk4r.js";import"../chunks/legacy.DKpsC3nd.js";import{p as R,s as r,d as e,f as j,g as s,r as a,b as C,t as B,e as X,c as T,m as G,aC as P}from"../chunks/runtime.NVyxXVLy.js";import{i as z}from"../chunks/if.DkuB8BPo.js";import{i as I}from"../chunks/lifecycle.BF-zkLgr.js";import{o as J,a as tt}from"../chunks/index-client.TDQqURXd.js";import{s as _}from"../chunks/render.Dr_6zaa7.js";import{e as Q,i as U}from"../chunks/each.e-7RQQYD.js";import{s as q}from"../chunks/attributes.CqauuZ_8.js";import{p as H}from"../chunks/props.Btle0pBM.js";import{h as st}from"../chunks/moment.C5S46NFB.js";import{g as at,t as Y}from"../chunks/util.8sVtkjoC.js";import{l as et}from"../chunks/ada_util.zWFYliEg.js";var ot=u('<div class="bg-gray-100 p-4 rounded-md"><h3 class="text-sm font-bold"><span class="font-bold">Block</span> <a class="text-blue-500 hover:underline"> </a></h3> <p class="text-sm text-gray-600"><span class="font-bold">Slot</span> </p> <p class="text-sm text-gray-600"><span class="font-bold">Txs</span> </p> <p class="text-sm text-gray-600"><span class="font-bold">Size</span> </p> <p class="text-sm text-gray-600 break-words"><span class="font-bold">Pool</span> </p> <p class="text-sm text-gray-600"><span class="text-xs text-gray-500"> </span></p></div>'),rt=u('<div class="bg-white rounded-lg shadow-lg p-6"><h2 class="text-xl font-bold mb-4">Recent Blocks</h2> <div class="space-y-4"></div></div>');function lt(f,p){R(p,!1);let t=H(p,"blocks",8),c=H(p,"noOfBlocks",8,10);I();var l=rt(),y=r(e(l),2);Q(y,5,()=>[...t()].slice(0,c()),U,(O,o)=>{var v=Z(),k=j(v);{var $=x=>{var d=ot(),g=e(d),b=r(e(g),2),w=e(b,!0);a(b),a(g);var D=r(g,2),S=r(e(D));a(D);var i=r(D,2),n=r(e(i));a(i);var h=r(i,2),A=r(e(h));a(h);var E=r(h,2),V=r(e(E));a(E);var F=r(E,2),N=e(F);const L=X(()=>at(s(o).block_time)??""),K=X(()=>st(s(o).block_time*1e3).fromNow()??"");var M=e(N);B(()=>_(M,`${s(L)}, ${s(K)}`)),a(N),a(F),a(d),B(()=>{q(b,"href",`/blocks/${s(o).number??""}`),_(w,s(o).number),_(S,` ${s(o).slot??""}`),_(n,` ${s(o).ntx??""}`),_(A,` ${s(o).size/1e3}`),_(V,` ${s(o).slot_leader??""}`)}),m(x,d)};z(k,x=>{s(o).number&&x($)})}m(O,v)}),a(y),a(l),m(f,l),C()}function it(f,p){R(p,!1);let t=G([]);J(async()=>{const c=await W(()=>import("../chunks/store.3kMI1D0r.js"),__vite__mapDeps([0,1,2]),import.meta.url);console.log(c.subscribe),T(t,c.blocksCache),c.blocksStore.subscribe(l=>{s(t).length>30?T(t,[l,...s(t).slice(0,30)]):T(t,[l,...s(t)])}),c.aggregateStore.subscribe(l=>{})}),I(),lt(f,{get blocks(){return s(t)},noOfBlocks:"10"}),C()}var ct=u('<p class="text-sm text-gray-600"> </p>'),nt=u('<div class="bg-gray-100 p-4 rounded-md"><p class="text-sm text-gray-600 py-1"><span class="font-bold">Tx Hash</span> <span class="text-gray-600 text-right overflow-auto md:overflow-hidden"><a class="text-blue-500 hover:underline"> </a></span></p> <p class="text-sm text-gray-600 py-1"><span class="font-bold">Block / Slot</span> <a class="text-blue-500 hover:underline"> </a> </p> <p class="text-sm text-gray-600"><span class="font-bold">Output Addresses</span></p> <div class="flex flex-col items-begin py-1 break-words"></div> <p class="text-sm text-gray-600 py-1"><span class="font-bold">Output</span> </p></div>'),pt=u('<div class="bg-white rounded-lg shadow-lg p-6"><h2 class="text-xl font-bold mb-4">Transactions</h2> <div class="space-y-4"></div></div>');function vt(f,p){R(p,!1);let t=H(p,"txs",8),c=H(p,"noOfTxs",8,10);I();var l=pt(),y=r(e(l),2);Q(y,5,()=>[...t()].slice(0,c()),U,(O,o)=>{var v=Z(),k=j(v);{var $=x=>{var d=nt(),g=e(d),b=r(e(g),2),w=e(b),D=e(w,!0);B(()=>_(D,Y(s(o).hash,38,"..."))),a(w),a(b),a(g);var S=r(g,2),i=r(e(S),2),n=e(i,!0);a(i);var h=r(i);a(S);var A=r(S,4);Q(A,5,()=>s(o).output_addresses,U,(F,N)=>{var L=ct(),K=e(L,!0);B(()=>_(K,Y(s(N),60,"..."))),a(L),m(F,L)}),a(A);var E=r(A,2),V=r(e(E));B(()=>_(V,` ${et(s(o).output,2)??""} Ada`)),a(E),a(d),B(()=>{q(w,"href",`/transactions/${s(o).hash??""}`),q(i,"href",`/blocks/${s(o).block??""}`),_(n,s(o).block),_(h,` / ${s(o).slot??""}`)}),m(x,d)};z(k,x=>{s(o).hash&&x($)})}m(O,v)}),a(y),a(l),m(f,l),C()}function dt(f,p){R(p,!1);let t=G([]);J(async()=>{const c=await W(()=>import("../chunks/store.3kMI1D0r.js"),__vite__mapDeps([0,1,2]),import.meta.url);console.log(c.subscribe),T(t,c.txCache),c.recentTxStore.subscribe(l=>{s(t).length>30?T(t,[l,...s(t).slice(0,30)]):T(t,[l,...s(t)])})}),I(),vt(f,{get txs(){return s(t)},noOfTxs:"10"}),C()}var _t=u('<p class="text-gray-700"> </p>'),mt=u('<div class="flex items-center"><div class="w-3/4 bg-gray-300 rounded-lg overflow-hidden"><div class="bg-blue-500 h-2"></div></div> <p class="ml-2 text-gray-700"> </p></div>'),xt=u('<section class="bg-white py-12"><div class="container mx-auto grid grid-cols-1 md:grid-cols-4 gap-4"><div class="bg-gray-100 rounded-lg p-4"><h3 class="text-xl font-semibold mb-2">Epoch</h3> <p class="text-gray-700"> </p></div> <div class="bg-gray-100 rounded-lg p-4"><h3 class="text-xl font-semibold mb-2">Current Block</h3> <p class="text-gray-700"> </p></div> <div class="bg-gray-100 rounded-lg p-4"><h3 class="text-xl font-semibold mb-2">Slot</h3> <!></div> <div class="bg-gray-100 rounded-lg p-4"><h3 class="text-xl font-semibold mb-2">Epoch Progress</h3> <!></div></div></section>');function ft(f,p){R(p,!1);let t=G({}),c;J(async()=>{const i=await W(()=>import("../chunks/store.3kMI1D0r.js"),__vite__mapDeps([0,1,2]),import.meta.url);console.log(i.subscribe),T(t,{}),c=i.blocksStore.subscribe(n=>{P(t,s(t).epoch=n.epoch),P(t,s(t).number=n.number),P(t,s(t).block_time=n.block_time),P(t,s(t).slot=n.slot),P(t,s(t).epoch_slot=n.epoch_slot),P(t,s(t).slots_per_epoch=n.slots_per_epoch),s(t).epoch_slot&&s(t).slots_per_epoch&&P(t,s(t).epoch_progress=(s(t).epoch_slot/s(t).slots_per_epoch*100).toFixed(2))}),tt(c)}),I();var l=xt(),y=e(l),O=e(y),o=r(e(O),2),v=e(o,!0);a(o),a(O);var k=r(O,2),$=r(e(k),2),x=e($,!0);a($),a(k);var d=r(k,2),g=r(e(d),2);{var b=i=>{var n=_t(),h=e(n);a(n),B(()=>_(h,`${s(t).epoch_slot??""}/${s(t).slots_per_epoch??""}`)),m(i,n)};z(g,i=>{s(t).epoch_slot&&i(b)})}a(d);var w=r(d,2),D=r(e(w),2);{var S=i=>{var n=mt(),h=e(n),A=e(h);a(h);var E=r(h,2),V=e(E);a(E),a(n),B(()=>{q(A,"style",`width: ${s(t).epoch_progress??""}%;`),_(V,`${s(t).epoch_progress??""}%`)}),m(i,n)};z(D,i=>{s(t).epoch_progress&&i(S)})}a(w),a(y),a(l),B(()=>{_(v,s(t).epoch?s(t).epoch:0),_(x,s(t).number?s(t).number:0)}),m(f,l),C()}var gt=u('<section class="flex flex-col items-center mt-24"><span class="text-xl font-bold mb-2 text-gray-800 px-4 py-2 rounded-lg">Waiting for live data</span> <span class="loading loading-ring loading-lg"></span></section>'),bt=u('<!> <section class="container mx-auto py-10"><div class="flex flex-col md:flex-row md:space-x-8"><div class="w-full md:w-1/2"><!></div> <div class="w-full md:w-1/2 mt-4 md:mt-0"><!></div></div></section>',1),ht=u('<section class="bg-gradient-to-r from-gray-900 to-black text-white py-20"><div class="container mx-auto text-center"><h1 class="text-4xl font-bold mb-4">A Blockchain DataViewer For Developers</h1> <p class="text-xl">Explore the latest blocks and transactions on the blockchain</p></div></section> <!>',1);function Ct(f,p){R(p,!1);let t=G([]);J(async()=>{const o=await W(()=>import("../chunks/store.3kMI1D0r.js"),__vite__mapDeps([0,1,2]),import.meta.url);T(t,o.blocksCache),o.recentTxStore.subscribe(v=>{s(t).length>30?T(t,[v,...s(t).slice(0,30)]):T(t,[v,...s(t)])})}),I();var c=ht(),l=r(j(c),2);{var y=o=>{var v=gt();m(o,v)},O=o=>{var v=bt(),k=j(v);ft(k,{});var $=r(k,2),x=e($),d=e(x),g=e(d);it(g,{}),a(d);var b=r(d,2),w=e(b);dt(w,{}),a(b),a(x),a($),m(o,v)};z(l,o=>{s(t).length==0||s(t).length>0&&Object.keys(s(t)[0]).length===0?o(y):o(O,!1)})}m(f,c),C()}export{Ct as component};