Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quick-zoos-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

`graph init`: fix tests generation for events with [][] params #1878
8 changes: 7 additions & 1 deletion packages/cli/src/scaffold/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ const isNativeType = (type: string) => {
return natives.some(rx => rx.test(type));
};

const fetchArrayInnerType = (type: string) => type.match(/Array<(.*?)>/);
// get inner type: Array<T> -> T, Array<Array<T>> -> T
const fetchArrayInnerType = (type: string): RegExpMatchArray | null => {
const match = type.match(/Array<(.+)>/);
if (!match) return null;

return fetchArrayInnerType(match[1]) || match;
};

// Generates the example test.ts file
const generateExampleTest = (
Expand Down
Loading