diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 740fe7b6..e57a2876 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -3,6 +3,16 @@ name: Code Checks on: push: +env: + PUBLIC_LOCAL_SIGNER: '' + API_EOS_CHAIN: '' + API_EOS_HISTORY: '' + API_EOS_METRICS: '' + API_JUNGLE4_CHAIN: '' + API_JUNGLE4_HISTORY: '' + API_KYLIN_CHAIN: '' + API_KYLIN_HISTORY: '' + jobs: formatting: runs-on: ubuntu-latest @@ -13,7 +23,7 @@ jobs: fetch-depth: 1 - uses: oven-sh/setup-bun@v2 - run: bun install - - run: bun lint + - run: bun run lint types: runs-on: ubuntu-latest steps: @@ -23,4 +33,17 @@ jobs: fetch-depth: 1 - uses: oven-sh/setup-bun@v2 - run: bun install + - run: bun run build-paraglide - run: bunx tsc --noemit + + sveltekit-check: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: oven-sh/setup-bun@v2 + - run: bun install + - run: bun run build-paraglide + - run: bun run check diff --git a/bun.lockb b/bun.lockb index b9c658fc..c003760c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/eslint.config.js b/eslint.config.js index a351fa90..4825bcce 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -28,6 +28,6 @@ export default [ } }, { - ignores: ['build/', '.svelte-kit/', 'dist/'] + ignores: ['build/', '.svelte-kit/', 'dist/', 'src/lib/wharf/contracts/'] } ]; diff --git a/package.json b/package.json index 218500f8..4a1ef862 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "dev": "vite dev", - "build": "npx @inlang/paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide && vite build", + "build-paraglide": "npx @inlang/paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide", + "build": "bun run build-paraglide && vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 8482bd23..a066b93a 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,7 +1,7 @@ import { sequence } from '@sveltejs/kit/hooks'; import type { Handle, RequestEvent } from '@sveltejs/kit'; -import { availableLanguageTags } from '$lib/paraglide/runtime'; +import { availableLanguageTags } from '$lib/paraglide/runtime.js'; import { i18n } from '$lib/i18n'; import { isNetworkShortName } from '$lib/wharf/chains'; @@ -14,7 +14,7 @@ export function getHeaderLang(event: RequestEvent) { acceptLanguage?.split(',')?.map((lang: string) => lang.split(';')[0].split('-')[0].trim()) ?? []; for (const locale of locales) { - if (availableLanguageTags.includes(locale)) { + if (availableLanguageTags.find((l: string) => l.toLowerCase() === locale)) { return locale; } } @@ -25,16 +25,12 @@ function isAPIPath(pathname: string) { return /^\/[a-z0-9]+\/api/gm.test(pathname); } -function isDevPath(pathname: string) { - return /^\/[a-z0-9]+\/debug/gm.test(pathname); -} - function skipRedirect(pathname: string) { return isAPIPath(pathname); } function isLanguage(value: string) { - return availableLanguageTags.find((l) => l.toLowerCase() === value); + return availableLanguageTags.find((l: string) => l.toLowerCase() === value); } function isNetwork(value: string) { @@ -77,7 +73,8 @@ export async function redirectHandle({ event, resolve }: HandleParams): Promise< pathMore.unshift(pathFirst); } - event.locals.lang = lang; + // Ensure that the 'lang' property exists on the 'Locals' type + (event.locals as { lang: string }).lang = lang; let url = `/${lang}`; if (network) { diff --git a/src/lib/components/circleprogress.svelte b/src/lib/components/circleprogress.svelte index 9b711602..bdd1ca29 100644 --- a/src/lib/components/circleprogress.svelte +++ b/src/lib/components/circleprogress.svelte @@ -1,8 +1,7 @@ diff --git a/src/lib/components/input/search.svelte b/src/lib/components/input/search.svelte index 0d3e7828..1be2a380 100644 --- a/src/lib/components/input/search.svelte +++ b/src/lib/components/input/search.svelte @@ -15,7 +15,6 @@ } let { - autofocus = false, network, ref = $bindable(), debug = false, @@ -26,6 +25,8 @@ let searchValue: string = $state(''); const searchType = $derived.by(() => { + /* eslint-disable @typescript-eslint/no-unused-vars */ + /* eslint-disable no-empty */ try { PublicKey.from(searchValue); return 'key'; @@ -45,6 +46,8 @@ return 'block'; } catch (e) {} return 'unknown'; + /* eslint-enable @typescript-eslint/no-unused-vars */ + /* eslint-enable no-empty */ }); const result = $derived.by(() => { @@ -91,13 +94,14 @@ searchValue = ''; } - debug && + if (debug) { $inspect({ searchValue, searchType, result, open: $open }); + } diff --git a/src/lib/components/layout/grid.svelte b/src/lib/components/layout/grid.svelte index fb55666a..7eb317d8 100644 --- a/src/lib/components/layout/grid.svelte +++ b/src/lib/components/layout/grid.svelte @@ -9,7 +9,7 @@ itemWidth?: string; } - const { class: className = '', children, itemWidth = '20ch', ...props }: Props = $props(); + const { children, itemWidth = '20ch', ...props }: Props = $props();
diff --git a/src/lib/components/layout/sidebar/content.svelte b/src/lib/components/layout/sidebar/content.svelte index df0bbf34..8d694c0f 100644 --- a/src/lib/components/layout/sidebar/content.svelte +++ b/src/lib/components/layout/sidebar/content.svelte @@ -9,13 +9,7 @@ class?: string; children: Snippet; } - const { - threshold = '50%', - children, - tag = 'div', - class: className = '', - ...props - }: Props = $props(); + const { threshold = '50%', children, tag = 'div', ...props }: Props = $props(); + + diff --git a/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.ts b/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.ts index 2ca7f7bf..36fb3d7f 100644 --- a/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.ts +++ b/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.ts @@ -1,10 +1,9 @@ -import { error } from '@sveltejs/kit'; -import { Name, type API } from '@wharfkit/antelope'; +// import { error } from '@sveltejs/kit'; +// import { Name, type API } from '@wharfkit/antelope'; import type { PageLoad } from './$types'; -import * as m from '$lib/paraglide/messages.js'; -export const load: PageLoad = async ({ fetch, params }) => { +export const load: PageLoad = async () => { // const result = await getClient(fetch).v1.chain.get_table_rows({ // code: 'eosio.msig', // scope: params.proposer, diff --git a/src/routes/[network]/(explorer)/network/+page.svelte b/src/routes/[network]/(explorer)/network/+page.svelte index 139679ed..f2ee704e 100644 --- a/src/routes/[network]/(explorer)/network/+page.svelte +++ b/src/routes/[network]/(explorer)/network/+page.svelte @@ -1,6 +1,4 @@ {#if data.transaction && data.transaction.trx} - {#each data.transaction.trx.trx.actions as action} - {@const summaryComponent = summaryMap[action.account][action.name]} - {#if summaryComponent} - + {@const actions = data.transaction.trx.trx.actions as Action[]} + {#each actions as action} + {#if isValidAccount(action.account)} + {@const accountMap = summaryMap[action.account]} + {#if isValidActionName(action.account, action.name)} + {@const summaryComponent = accountMap[action.name]} + + {:else} +

Unknown action: {action.account}::{action.name}

+ {/if} {:else} -

Unknown action: {action.account}::{action.name}

+

Unknown account: {action.account}

{/if} {JSON.stringify(action, null, 2)} {/each} @@ -40,7 +67,7 @@ {#if data.seq} {@const trace = data.transaction.traces.find( - (t) => String(t.receipt.global_sequence) === data.seq + (t: { receipt: { global_sequence: number } }) => String(t.receipt.global_sequence) === data.seq )} {JSON.stringify(trace, null, 2)} {:else} diff --git a/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/data/+page.svelte b/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/data/+page.svelte index b2916990..3c84ecf2 100644 --- a/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/data/+page.svelte +++ b/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/data/+page.svelte @@ -1,6 +1,5 @@ diff --git a/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/resources/+page.svelte b/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/resources/+page.svelte index 95747ef0..0fda1405 100644 --- a/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/resources/+page.svelte +++ b/src/routes/[network]/(explorer)/transaction/[id]/[[seq]]/resources/+page.svelte @@ -1,6 +1,5 @@ diff --git a/src/routes/[network]/(homepage)/+page.svelte b/src/routes/[network]/(homepage)/+page.svelte index 1f3c5da3..79fb4569 100644 --- a/src/routes/[network]/(homepage)/+page.svelte +++ b/src/routes/[network]/(homepage)/+page.svelte @@ -1,5 +1,4 @@