Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/lib/components/navigation/sidemenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,30 @@
// Example: ['', 'en', 'eos', 'staking', 'withdraw']
let pathname = $derived(page.url.pathname.split('/'));

const isCurrentAccountActive = $derived(
pathname[3] === 'account' && pathname[4] === String(context.account?.name)
);

const destinations = $derived.by(() => {
const items = [
// {
// href: `/${locale}/${network}`,
// text: network.chain.name,
// active: pathname[2] === String(network) && !pathname[3]
// },
{
href: urlPath(`/explore`),
text: 'Explore',
active:
[
'explore',
'key',
'account',
'block',
'contract',
'msig',
'network',
'producers',
'prompt',
'token',
'transaction'
].includes(pathname[3]) && !isCurrentAccountActive
},
{ href: urlPath(`/send`), text: 'Send', active: pathname[3] === 'send' }
];

Expand Down Expand Up @@ -63,7 +80,7 @@
items.splice(0, 0, {
href: urlPath(`/account/${context.account.name}`),
text: 'My Account',
active: pathname[3] === 'account' && pathname[4] === String(context.account.name)
active: isCurrentAccountActive
});
}

Expand Down
38 changes: 38 additions & 0 deletions src/lib/remote/blocks.remote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { getRequestEvent, query } from '$app/server';
import { type API } from '@wharfkit/antelope';

export const getBlocks = query(async () => {
const event = getRequestEvent();
const { locals } = event;
const { network } = locals;

try {
// Get the current chain info to find the latest block number
const info = await network.client.v1.chain.get_info();
const latestBlockNum = Number(info.head_block_num);

// Get the latest 5 blocks
const blockPromises = [];
for (let i = 0; i < 5; i++) {
const blockNum = latestBlockNum - i;
if (blockNum >= 1) {
blockPromises.push(
network.client.call({
method: 'POST',
path: '/v1/chain/get_block',
params: {
block_num_or_id: blockNum
}
}) as Promise<API.v1.GetBlockResponse>
);
}
}

const blocks = await Promise.all(blockPromises);

return blocks;
} catch (error) {
console.error('Error fetching blocks:', error);
return [];
}
});
Loading