From 83d5beaa6880a2c86324fb2889b3f39cdf617c60 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Fri, 31 Jan 2025 18:29:33 -0800 Subject: [PATCH] Some initial work on the actions page --- src/lib/components/elements/contract.svelte | 6 +- .../contract/[contract]/+layout.svelte | 2 +- .../contract/[contract]/actions/+page.svelte | 12 +- .../contract/[contract]/actions/action.svelte | 121 ++++++++++++++++++ 4 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 src/routes/[network]/(explorer)/contract/[contract]/actions/action.svelte diff --git a/src/lib/components/elements/contract.svelte b/src/lib/components/elements/contract.svelte index 49f6ccb53..940e81615 100644 --- a/src/lib/components/elements/contract.svelte +++ b/src/lib/components/elements/contract.svelte @@ -10,16 +10,20 @@ children?: Snippet; name?: Name | string; action?: Name | string; + struct?: Name; class?: string; } - let { name, action, children, ...props }: Props = $props(); + let { name, action, struct, children, ...props }: Props = $props(); let href = $derived.by(() => { const base = `/${network}/contract/${String(name)}`; if (action) { return base + `/actions/${action}`; } + if (struct) { + return base + `/structs/${struct}`; + } return base; }); diff --git a/src/routes/[network]/(explorer)/contract/[contract]/+layout.svelte b/src/routes/[network]/(explorer)/contract/[contract]/+layout.svelte index eb3a9d985..6787c2b56 100644 --- a/src/routes/[network]/(explorer)/contract/[contract]/+layout.svelte +++ b/src/routes/[network]/(explorer)/contract/[contract]/+layout.svelte @@ -43,6 +43,6 @@ - + {@render children()} diff --git a/src/routes/[network]/(explorer)/contract/[contract]/actions/+page.svelte b/src/routes/[network]/(explorer)/contract/[contract]/actions/+page.svelte index e37c77915..e88e060dd 100644 --- a/src/routes/[network]/(explorer)/contract/[contract]/actions/+page.svelte +++ b/src/routes/[network]/(explorer)/contract/[contract]/actions/+page.svelte @@ -1,13 +1,15 @@ - {#each data.abi.actions as action} - - {action.name} - - {/each} +

The actions for this contract with their input parameters and potential response data.

+
    + {#each data.abi.actions as action} + + {/each} +
diff --git a/src/routes/[network]/(explorer)/contract/[contract]/actions/action.svelte b/src/routes/[network]/(explorer)/contract/[contract]/actions/action.svelte new file mode 100644 index 000000000..50b5de97d --- /dev/null +++ b/src/routes/[network]/(explorer)/contract/[contract]/actions/action.svelte @@ -0,0 +1,121 @@ + + +
  • +
    +
    +
    Action
    +
    + + {action.name} + +
    +
    +
    + +
    +
    +
    +
    Parameters
    + {#each struct.fields as field} + {@const fieldType = abi.structs.find((s) => s.name === parseType(field.type))} +
    + + {field.name} + + + {#if fieldType} + + {field.type} + + {:else} + {field.type} + {/if} + +
    + {:else} + No action parameters. + {/each} + {#if context.settings.data.debugMode} + {JSON.stringify(struct, null, 2)} + {/if} +
    +
    +
    Response Data
    + {#each response as field} + {@const fieldType = abi.structs.find((s) => s.name === parseType(field.type))} +
    + + {field.name} + + + {#if fieldType} + + {field.type} + + {:else} + {field.type} + {/if} + +
    + {:else} +

    No response data.

    + {/each} + {#if context.settings.data.debugMode} + {JSON.stringify(response, null, 2)} + {/if} +
    +
    +
    +