@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.
55 lines (52 loc) • 4.56 kB
JavaScript
import { T as store_get, a0 as ensure_array_like, Z as attr, _ as stringify, X as escape_html, W as unsubscribe_stores, a1 as bind_props, x as pop, v as push } from './index-vBtQgGkr.js';
import { l as lovelaceToAda } from './ada_util-BMIfqJSl.js';
import { p as page } from './stores-B4ORdDby.js';
import './client-x9PZM0zh.js';
import './exports-DAzLyLdf.js';
function _page($$payload, $$props) {
push();
var $$store_subs;
let activeUrl;
let data = $$props["data"];
var truncate = function(fullStr, strLen, separator) {
if (fullStr.length <= strLen) return fullStr;
separator = separator || "...";
var sepLen = separator.length, charsToShow = strLen - sepLen, frontChars = Math.ceil(charsToShow / 2), backChars = Math.floor(charsToShow / 2);
return fullStr.substr(0, frontChars) + separator + fullStr.substr(fullStr.length - backChars);
};
let pages = [];
let searchTx = "";
activeUrl = store_get($$store_subs ??= {}, "$page", page).url.searchParams.get("page");
{
pages.forEach((page2) => {
let splitUrl = page2.href.split("?");
let queryString = splitUrl.slice(1).join("?");
const hrefParams = new URLSearchParams(queryString);
let hrefValue = hrefParams.get("page");
if (hrefValue === activeUrl) {
page2.active = true;
} else {
page2.active = false;
}
});
pages = pages;
}
const each_array = ensure_array_like(data.txs);
$$payload.out += `<section class="container mx-auto mt-4 px-4"><div class="mb-4 flex justify-center"><form class="flex items-center w-full max-w-lg"><input type="search" id="search"${attr("value", searchTx)} placeholder="Transaction Hash" required class="px-4 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500 w-full"> <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-r-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500">Search</button></form></div></section> <section class="container mx-auto text-sm px-4"><div class="flex flex-wrap justify-between mb-2"><button class="px-4 py-2 text-blue-500 font-medium rounded-md bg-gray-100 hover:bg-gray-200 transition-colors">< Previous</button> <button class="px-4 py-2 text-blue-500 font-medium rounded-md bg-gray-100 hover:bg-gray-200 transition-colors">Next ></button></div> <div class="overflow-x-auto"><table class="w-full bg-white border border-gray-300"><thead><tr><th class="py-2 px-4 bg-gray-100 font-bold">Tx Hash</th><th class="py-2 px-4 bg-gray-100 font-bold text-center">Block / Slot</th><th class="py-2 px-4 bg-gray-100 font-bold text-center">Total Output (Ada)</th><th class="py-2 px-4 bg-gray-100 font-bold text-center">Fee (Ada)</th><th class="py-2 px-4 bg-gray-100 font-bold">Output Addresses</th></tr></thead><tbody><!--[-->`;
for (let index = 0, $$length = each_array.length; index < $$length; index++) {
let tx = each_array[index];
const each_array_1 = ensure_array_like(tx.output_addresses);
$$payload.out += `<tr${attr("class", index % 2 === 0 ? "bg-gray-50" : "bg-white")}><td class="py-2 px-4"><a${attr("href", `/transactions/${stringify(tx.tx_hash)}`)} class="text-blue-500"><span class="block md:hidden">${escape_html(tx.tx_hash.slice(0, 6))}...</span> <span class="hidden md:block break-all">${escape_html(tx.tx_hash)}</span></a></td><td class="py-2 px-4 text-center"><a${attr("href", `/blocks/${stringify(tx.block_number)}`)} class="text-blue-500">${escape_html(tx.block_number)}</a> / <br>${escape_html(tx.slot)}</td><td class="py-2 px-4 text-center">${escape_html(lovelaceToAda(tx.total_output))}</td><td class="py-2 px-4 text-center">${escape_html(lovelaceToAda(tx.fee))}</td><td class="py-2 px-4"><!--[-->`;
for (let $$index = 0, $$length2 = each_array_1.length; $$index < $$length2; $$index++) {
let address = each_array_1[$$index];
$$payload.out += `<!---->${escape_html(truncate(address, 25, "..."))}<br>`;
}
$$payload.out += `<!--]--></td></tr>`;
}
$$payload.out += `<!--]--></tbody></table></div> <div class="flex flex-wrap justify-between mt-2 mb-4"><button class="px-4 py-2 text-blue-500 font-medium rounded-md bg-gray-100 hover:bg-gray-200 transition-colors">< Previous</button> <button class="px-4 py-2 text-blue-500 font-medium rounded-md bg-gray-100 hover:bg-gray-200 transition-colors">Next ></button></div></section>`;
if ($$store_subs) unsubscribe_stores($$store_subs);
bind_props($$props, { data });
pop();
}
export { _page as default };
//# sourceMappingURL=_page.svelte-DFFatDcE.js.map