zonder
Version:
Ergonomic multi-chain indexing framework with dual runtime support for Ponder and Envio.
26 lines (25 loc) • 939 B
JavaScript
export function formatEventSignature(event) {
const params = event.inputs
.map((input) => {
let type = input.type;
// Handle tuples recursively
if (type.startsWith('tuple')) {
const components = input.components.map((c) => formatTupleComponent(c)).join(',');
type = `(${components})${type.slice(5)}`;
}
// Format: "type indexed name" or "type name"
const indexedKeyword = input.indexed ? ' indexed' : '';
const name = input.name || 'param';
return `${type}${indexedKeyword} ${name}`;
})
.join(', ');
return `${event.name}(${params})`;
}
function formatTupleComponent(component) {
let type = component.type;
if (type.startsWith('tuple')) {
const subComponents = component.components.map((c) => formatTupleComponent(c)).join(',');
type = `(${subComponents})${type.slice(5)}`;
}
return type;
}