From aae12131d470e2c268c6db7e3051a0398f34f393 Mon Sep 17 00:00:00 2001 From: dafuga Date: Wed, 2 Oct 2024 12:15:48 -0700 Subject: [PATCH 01/16] fix: fixing type errors --- .../msig/[proposer]/[proposal]/+page.svelte | 10 +++-- .../[network]/(explorer)/network/+page.svelte | 4 +- .../transaction/[id]/[[seq]]/+page.svelte | 44 +++++++++++++++---- .../[id]/[[seq]]/data/+page.svelte | 3 +- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte b/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte index 84627052a..f4706bc9f 100644 --- a/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte +++ b/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte @@ -1,12 +1,16 @@ -

{data.proposer}/{data.name}

+ + + diff --git a/src/routes/[network]/(explorer)/network/+page.svelte b/src/routes/[network]/(explorer)/network/+page.svelte index 139679edc..f2ee704ef 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 +68,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 b29169907..3c84ecf2b 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 @@ From 915745cde4ee5373b36306e73e61a9511ec21ec2 Mon Sep 17 00:00:00 2001 From: dafuga Date: Wed, 2 Oct 2024 12:55:21 -0700 Subject: [PATCH 02/16] fix: fixing (explorer) type errors --- bun.lockb | Bin 251158 -> 251158 bytes .../resources/components/forms/staking.svelte | 4 ++-- .../resources/components/state/prices.svelte | 6 +++-- .../(dev)/debug/state/account/+page.svelte | 2 +- .../account/[name]/ram/+page.svelte | 2 +- .../(explorer)/block/[number]/+page.ts | 21 ++++++++++-------- .../actions/[action]/[[data]]/+page.svelte | 14 +++++++----- .../tables/[table]/[[scope]]/+page.svelte | 2 +- .../msig/[proposer]/[proposal]/+page.svelte | 4 ++-- 9 files changed, 31 insertions(+), 24 deletions(-) diff --git a/bun.lockb b/bun.lockb index b9c658fc7d0f9615333a43465b4c73ae153eec9f..c003760c3f58792295261cb01b5dce23336054fa 100755 GIT binary patch delta 31 lcmbQXihtTF{)QIDElkNX*csyt^?pgn5_)Ap {/if} -
+ { if (context.network) { - powerupPrice = context.network.powerupprice; + // TODO: we need to get the powerupprice from the stakingprice + // powerupPrice = context.network.powerupprice; + // stakingPrice = context.network.stakingprice; + rexPrice = context.network.rexprice; - stakingPrice = context.network.stakingprice; } else { powerupPrice = undefined; rexPrice = undefined; diff --git a/src/routes/[network]/(dev)/debug/state/account/+page.svelte b/src/routes/[network]/(dev)/debug/state/account/+page.svelte index fca6bc0d0..602a2401c 100644 --- a/src/routes/[network]/(dev)/debug/state/account/+page.svelte +++ b/src/routes/[network]/(dev)/debug/state/account/+page.svelte @@ -12,7 +12,7 @@

Account State

The account state for the currently active session.

{#if context.account} - diff --git a/src/routes/[network]/(explorer)/account/[name]/ram/+page.svelte b/src/routes/[network]/(explorer)/account/[name]/ram/+page.svelte index a8d71b229..220d05211 100644 --- a/src/routes/[network]/(explorer)/account/[name]/ram/+page.svelte +++ b/src/routes/[network]/(explorer)/account/[name]/ram/+page.svelte @@ -87,7 +87,7 @@
  • {data.account.network.ramprice?.eos.value || 'N/A'} - {data.account.network.chain.systemToken.symbol.code}/KB + {data.account.network.chain.systemToken?.symbol.code || ''}/KB
  • ${data.account.network.ramprice?.usd?.value || 'N/A'} USD/KB
diff --git a/src/routes/[network]/(explorer)/block/[number]/+page.ts b/src/routes/[network]/(explorer)/block/[number]/+page.ts index 061214d1e..d2826e7cb 100644 --- a/src/routes/[network]/(explorer)/block/[number]/+page.ts +++ b/src/routes/[network]/(explorer)/block/[number]/+page.ts @@ -1,18 +1,21 @@ import type { Load } from '@sveltejs/kit'; import * as m from '$lib/paraglide/messages.js'; -import { API, TimePointSec } from '@wharfkit/antelope'; +import { TimePointSec, Transaction } from '@wharfkit/antelope'; export const load: Load = async ({ fetch, params }) => { const response = await fetch(`/${params.network}/api/block/${params.number}`); const json = await response.json(); const block = json.block; // Create metadata for the page - const actions = block.transactions.reduce((acc, tx) => { - if (!tx.trx.transaction) { - return acc; - } - return acc + tx.trx.transaction.actions.length; - }, 0); + const actions = block.transactions.reduce( + (acc: number, tx: { trx: { transaction: Transaction } }) => { + if (!tx.trx.transaction) { + return acc; + } + return acc + tx.trx.transaction.actions.length; + }, + 0 + ); const description = m.block_height_numbered_description({ height: String(params.number), producer: block.producer, @@ -23,9 +26,9 @@ export const load: Load = async ({ fetch, params }) => { return { block, network: params.network, - height: params.number, + height: Number(params.number), pageMetaTags: { - title: m.block_height_numbered({ height: params.number }), + title: m.block_height_numbered({ height: Number(params.number) }), description } }; diff --git a/src/routes/[network]/(explorer)/contract/[contract]/actions/[action]/[[data]]/+page.svelte b/src/routes/[network]/(explorer)/contract/[contract]/actions/[action]/[[data]]/+page.svelte index f78646b5a..ca9f18738 100644 --- a/src/routes/[network]/(explorer)/contract/[contract]/actions/[action]/[[data]]/+page.svelte +++ b/src/routes/[network]/(explorer)/contract/[contract]/actions/[action]/[[data]]/+page.svelte @@ -48,11 +48,13 @@ const action = Serializer.decode({ data: Bytes.from(data.data), abi: data.abi, - type: data.action.name + type: String(data.action.name) }); - state = flatten(Serializer.objectify(action)); + if (action) { + state = flatten(Serializer.objectify(action)); + } } catch (e) { - console.log(e); + console.error('Error decoding action:', e); } } @@ -76,7 +78,7 @@ return Serializer.encode({ object: restructured, abi: data.abi, - type: data.action.name + type: String(data.action.name) }); } catch (e) { console.log(e); @@ -89,7 +91,7 @@ return Serializer.decode({ data: serialized, abi: data.abi, - type: data.action.name + type: String(data.action.name) }); } catch (e) { console.log(e); @@ -133,7 +135,7 @@ - + diff --git a/src/routes/[network]/(explorer)/contract/[contract]/tables/[table]/[[scope]]/+page.svelte b/src/routes/[network]/(explorer)/contract/[contract]/tables/[table]/[[scope]]/+page.svelte index 09ed0282d..a55a997de 100644 --- a/src/routes/[network]/(explorer)/contract/[contract]/tables/[table]/[[scope]]/+page.svelte +++ b/src/routes/[network]/(explorer)/contract/[contract]/tables/[table]/[[scope]]/+page.svelte @@ -9,7 +9,7 @@ const { data } = $props(); const tableDef = data.abi.tables.find((t: ABI.Table) => t.name === data.table); - const struct = data.abi.structs.find((s: ABI.Struct) => s.name === tableDef.type); + const struct = data.abi.structs.find((s: ABI.Struct) => s.name === tableDef?.type); diff --git a/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte b/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte index f4706bc9f..bb02bd936 100644 --- a/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte +++ b/src/routes/[network]/(explorer)/msig/[proposer]/[proposal]/+page.svelte @@ -1,7 +1,7 @@