Skip to content

Commit 11b4d9e

Browse files
author
AmineAfia
committed
Add support for tuple types in ABI event and function signatures (#7415)
# [Dashboard] Fix: Improve ABI type handling for tuple types in webhook signatures ## Notes for the reviewer This PR adds support for properly handling tuple types in ABI event and function signatures. Previously, we were only extracting the basic type string, which doesn't correctly represent tuple structures. Now we recursively build the canonical type representation for tuples, including nested tuples and array dimensions. ## How to test The changes can be tested by creating webhooks with contracts that use tuple types in their events or functions. The signature extraction should now correctly represent the canonical format for these complex types. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of tuple types in ABI inputs to ensure accurate event and function signature generation, especially for nested tuple structures. - **New Features** - Function signature labels in transaction filters are now truncated for better readability without affecting underlying data. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily enhances the handling of function signatures in the `FilterDetailsStep.tsx` component and improves the extraction of ABI input types in `abiUtils.ts`. It introduces a helper function to manage tuple types and modifies how function signatures are displayed. ### Detailed summary - In `FilterDetailsStep.tsx`, updated the label for function signatures to use `truncateMiddle(sig.name, 30, 15)` for better readability. - Added a new helper function `getCanonicalType` in `abiUtils.ts` to recursively handle tuple types in ABI inputs. - Modified the extraction of canonical input types in both `extractEventSignatures` and `extractFunctionSignatures` to use `getCanonicalType` instead of directly mapping the type. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent ad5aabc commit 11b4d9e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/FilterDetailsStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export function FilterDetailsStep({
344344
}}
345345
options={functionSignatures.map((sig) => ({
346346
abi: sig.abi,
347-
label: sig.name,
347+
label: truncateMiddle(sig.name, 30, 15),
348348
value: sig.signature,
349349
}))}
350350
placeholder="Select or enter a function signature"

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/utils/abiUtils.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ function isAbiInput(
2828
);
2929
}
3030

31+
// Helper to recursively get canonical type for ABI input (handles tuples)
32+
function getCanonicalType(input: any): string {
33+
if (input.type.startsWith("tuple")) {
34+
// Recursively build tuple type string
35+
const components = input.components || [];
36+
const tupleType = `(${components.map(getCanonicalType).join(",")})`;
37+
// Handle tuple arrays (tuple[], tuple[2], etc)
38+
const arraySuffix = input.type.slice("tuple".length);
39+
return tupleType + arraySuffix;
40+
}
41+
return input.type;
42+
}
43+
3144
/**
3245
* Extracts event signatures from ABI data
3346
* @param abiData Array of ABI data objects
@@ -80,7 +93,7 @@ export const extractEventSignatures = (
8093
const canonicalInputs = Array.isArray(event.inputs)
8194
? event.inputs
8295
.filter((input: unknown) => isAbiInput(input))
83-
.map((input: { type: string }) => input.type)
96+
.map((input: any) => getCanonicalType(input))
8497
.join(",")
8598
: "";
8699

@@ -162,7 +175,7 @@ export const extractFunctionSignatures = (
162175
const canonicalInputs = Array.isArray(func.inputs)
163176
? func.inputs
164177
.filter((input: unknown) => isAbiInput(input))
165-
.map((input: { type: string }) => input.type)
178+
.map((input: any) => getCanonicalType(input))
166179
.join(",")
167180
: "";
168181

0 commit comments

Comments
 (0)