From da71c0a06472a67fe8136d9b9c98ec35c00ace78 Mon Sep 17 00:00:00 2001 From: dafuga <danielfugere28@gmail.com> Date: Wed, 2 Oct 2024 12:55:21 -0700 Subject: [PATCH] fix: fixing (explorer) type errors --- .../actions/[action]/[[data]]/+page.svelte | 14 ++++++++------ .../tables/[table]/[[scope]]/+page.svelte | 2 +- .../msig/[proposer]/[proposal]/+page.svelte | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) 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 @@ <Grid> <Card> - <Fields abi={data.abi} fields={data.actionData.fields} {state} /> + <Fields abi={data.abi} fields={data.actionData?.fields || []} {state} /> <Button onclick={transact} disabled={!decoded}>Perform Action</Button> </Card> <Card> 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); </script> <Stack> 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 @@ <script lang="ts"> - import type { PageData } from './$types'; + // import type { PageData } from './$types'; - export let data: PageData; + // export let data: PageData; </script> <!--