Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #34

Merged
merged 14 commits into from
Nov 19, 2024
25 changes: 0 additions & 25 deletions .github/workflows/rollout.staging.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/rollout.yml

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^2.1.1",
"@sveltejs/kit": "^2.5.26",
"@sveltejs/vite-plugin-svelte": "3.1.2",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"autoprefixer": "^10.4.20",
Expand Down Expand Up @@ -52,7 +53,7 @@
"svelte-tags-input": "^5.0.0",
"tailwind-merge": "^1.14.0",
"tailwind-variants": "^0.1.20",
"viem": "^2.21.4"
"viem": "^2.21.48"
},
"trustedDependencies": [
"@sveltejs/kit",
Expand Down
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
31 changes: 20 additions & 11 deletions src/routes/diamond/[address]/EditFacet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
parseAbi,
zeroAddress,
type WriteContractReturnType,
type AbiItem,
type AbiFunction,
} from 'viem'
import type { Chain } from 'viem/chains'
import ConnectWallet from './ConnectWallet.svelte'
Expand Down Expand Up @@ -263,6 +265,13 @@
}
}
}

const getFunctionSelector = (m: AbiFunction) => {
if (m.name.indexOf('unknown_') > -1) {
return m.name.split('_')[1]
}
return toFunctionSelector(m)
}
</script>

<div class="flex flex-row items-center justify-between p-2 space-x-3">
Expand Down Expand Up @@ -364,23 +373,23 @@
<Table.Cell class="text-left">
<div>
<Checkbox
bind:this={checkboxes[f.address.slice(0, 5) + toFunctionSelector(m)]}
bind:this={checkboxes[f.address.slice(0, 5) + getFunctionSelector(m)]}
onCheckedChange={updateAdditionsAndReplacements(
f.address,
toFunctionSelector(m),
getFunctionSelector(m),
)}
/>
</div>
</Table.Cell>
<Table.Cell class="font-medium text-left w-full text-lg">
<div
class:bg-green-500={strategy.additions[f.address] &&
strategy.additions[f.address].includes(toFunctionSelector(m))}
strategy.additions[f.address].includes(getFunctionSelector(m))}
class:bg-yellow-500={strategy.replacements[f.address] &&
strategy.replacements[f.address].includes(toFunctionSelector(m))}
strategy.replacements[f.address].includes(getFunctionSelector(m))}
class="flex items-center p-1 rounded-md bg-opacity-90"
>
<Badge class="mr-2">{toFunctionSelector(m)}</Badge>
<Badge class="mr-2">{getFunctionSelector(m)}</Badge>
{m.name}
</div>
</Table.Cell>
Expand Down Expand Up @@ -423,23 +432,23 @@
<Table.Row class="border-none">
<Table.Cell class="text-left">
<Checkbox
bind:this={checkboxes[f.address.slice(0, 5) + toFunctionSelector(m)]}
onCheckedChange={updateRemovals(f.address, toFunctionSelector(m))}
bind:this={checkboxes[f.address.slice(0, 5) + getFunctionSelector(m)]}
onCheckedChange={updateRemovals(f.address, getFunctionSelector(m))}
disabled={Object.values(strategy.replacements).some((r) =>
r.includes(toFunctionSelector(m)),
r.includes(getFunctionSelector(m)),
)}
/>
</Table.Cell>
<Table.Cell class="font-medium text-left w-full text-lg">
<div
class:bg-red-500={strategy.removals[f.address] &&
strategy.removals[f.address].includes(toFunctionSelector(m))}
strategy.removals[f.address].includes(getFunctionSelector(m))}
class:bg-yellow-500={Object.values(strategy.replacements).some((r) =>
r.includes(toFunctionSelector(m)),
r.includes(getFunctionSelector(m)),
)}
class="flex items-center p-1 rounded-md bg-opacity-90"
>
<Badge class="mr-2">{toFunctionSelector(m)}</Badge>
<Badge class="mr-2">{getFunctionSelector(m)}</Badge>
{m.name}
</div>
</Table.Cell>
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