Skip to content

Commit d6a0d21

Browse files
committed
handle sized array
1 parent 50aed5d commit d6a0d21

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changeset/flat-hairs-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-cli': patch
3+
---
4+
5+
handle sized arrays in abi when changetype

packages/cli/src/scaffold/mapping.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export const generateFieldAssignment = (
1515
): { assignment: string; imports: string[] } => {
1616
const safeKey = key.map(k => util.handleReservedWord(k));
1717
const safeValue = value.map(v => util.handleReservedWord(v));
18+
const cleanType = type.replace(/\[\d+\]/g, '[]');
1819

1920
let rightSide = `event.params.${safeValue.join('.')}`;
2021
const imports = [];
2122

22-
if (type in VALUE_TYPECAST_MAP) {
23-
const castTo = VALUE_TYPECAST_MAP[type];
23+
if (cleanType in VALUE_TYPECAST_MAP) {
24+
const castTo = VALUE_TYPECAST_MAP[cleanType];
2425
rightSide = `changetype<${castTo}>(${rightSide})`;
2526
imports.push(castTo.replace('[]', ''));
2627
}

0 commit comments

Comments
 (0)