Skip to content

Commit

Permalink
Better handling for unknown selectors (#30)
Browse files Browse the repository at this point in the history
* Update config stuff

* Add more logging

* move hooks to only run on the server

* move sqlite deps out of client

* use older version of bun...

* bump version

* Add better handling for unknown selectors
  • Loading branch information
ezynda3 authored Sep 19, 2024
1 parent d7edd31 commit 70d367c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/lib/utils.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ export const getFuncSigBySelector = async (selector: string): Promise<string> =>
return data.result.function[selector][0].name
}

return 'unknown()'
return `unknown_${selector}()`
}
1 change: 1 addition & 0 deletions src/routes/diamond/[address]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const buildFacet = async (

const fileredAbi: Abi = facet.abi.filter((item) => {
if (item.type !== 'function') return true
if (item.name.indexOf('unknown_') > -1) return true
if (!item.outputs) {
item.outputs = []
}
Expand Down
36 changes: 25 additions & 11 deletions src/routes/diamond/[address]/FacetsTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,31 @@
</code>
<Separator orientation="vertical" />

<code
class="rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold"
>
{toFunctionSelector(m)}
</code>
<Button
variant="ghost"
on:click={() => copyToClipboard(toFunctionSelector(m))}
>
<Copy />
</Button>
{#if m.name.indexOf('unknown_') > -1}
<code
class="rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold"
>
{m.name.split('_')[1]}
</code>
<Button
variant="ghost"
on:click={() => copyToClipboard(m.name.split('_')[1])}
>
<Copy />
</Button>
{:else}
<code
class="rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold"
>
{toFunctionSelector(m)}
</code>
<Button
variant="ghost"
on:click={() => copyToClipboard(toFunctionSelector(m))}
>
<Copy />
</Button>
{/if}
</div>
</li>
{/each}
Expand Down
5 changes: 5 additions & 0 deletions src/routes/diamond/[address]/json/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ const buildFacet = async (

const fileredAbi: Abi = facet.abi.filter((item) => {
if (item.type !== 'function') return true
if (item.name.indexOf('unknown_') > -1) {
if (selectors.includes(item.name.split('_')[1])) {
return true
}
}
if (!item.outputs) {
item.outputs = []
}
Expand Down

0 comments on commit 70d367c

Please sign in to comment.