Skip to content

Commit 9b48b1c

Browse files
authored
fix: example subgraph build issues (#1366)
* fix: example subgraph build issues * prettier
1 parent 76d7e22 commit 9b48b1c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

examples/example-subgraph/dist/ExampleSubgraph/abis/ExampleContract.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,4 +2391,4 @@
23912391
}
23922392
]
23932393
}
2394-
]
2394+
]

examples/example-subgraph/src/mapping.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Address, BigInt, Bytes, crypto, Entity, log, store } from '@graphprotocol/graph-ts';
2-
import { ExampleContract, ExampleEvent } from './../generated/ExampleSubgraph/ExampleContract';
3-
import { ExampleEntity } from './../generated/schema';
1+
import { Address, BigInt, Bytes, log, store } from '@graphprotocol/graph-ts';
2+
import { ExampleContract, ExampleEvent } from './types/ExampleSubgraph/ExampleContract';
3+
import { ExampleEntity } from './types/schema';
44

55
export function handleExampleEvent(event: ExampleEvent): void {
66
const entity = new ExampleEntity('example id');
@@ -57,14 +57,14 @@ export function handleExampleEvent(event: ExampleEvent): void {
5757
entity.optionalBigIntList = [new BigInt(0), new BigInt(0)];
5858
entity.optionalBigIntList = null;
5959

60-
const optionalBigInt: bigint | null = entity.optionalBigInt;
61-
const optionalBigIntList: Array<bigint> | null = entity.optionalBigIntList;
60+
const optionalBigInt: BigInt | null = entity.optionalBigInt;
61+
const optionalBigIntList: Array<BigInt> | null = entity.optionalBigIntList;
6262

6363
entity.requiredBigInt = new BigInt(0);
6464
entity.requiredBigIntList = [new BigInt(0), new BigInt(0)];
6565

66-
const requiredBigInt: bigint = entity.requiredBigInt;
67-
const requiredBigIntList: Array<bigint> = entity.requiredBigIntList;
66+
const requiredBigInt: BigInt = entity.requiredBigInt;
67+
const requiredBigIntList: Array<BigInt> = entity.requiredBigIntList;
6868

6969
entity.optionalBytes = new Bytes(0);
7070
entity.optionalBytes = null;
@@ -212,7 +212,7 @@ export function handleExampleEvent(event: ExampleEvent): void {
212212
const u8Array: Array<i32> = contract.getAndReturnUint8Array([1 as i32, 100 as i32]);
213213
const u16Array: Array<i32> = contract.getAndReturnUint16Array([1 as i32, 100 as i32]);
214214
const u24Array: Array<i32> = contract.getAndReturnUint24Array([1 as i32, 100 as i32]);
215-
const u32Array: Array<bigint> = contract.getAndReturnUint32Array([new BigInt(0), new BigInt(0)]);
215+
const u32Array: Array<BigInt> = contract.getAndReturnUint32Array([new BigInt(0), new BigInt(0)]);
216216
entity.requiredBigIntList = contract.getAndReturnUint40Array(entity.requiredBigIntList);
217217
entity.requiredBigIntList = contract.getAndReturnUint56Array(entity.requiredBigIntList);
218218
entity.requiredBigIntList = contract.getAndReturnUint64Array(entity.requiredBigIntList);
@@ -251,7 +251,9 @@ export function handleExampleEvent(event: ExampleEvent): void {
251251
// Entity load and save (using the store behind the scenes)
252252
entity.save();
253253
let other = ExampleEntity.load('other example id');
254-
other ??= new ExampleEntity('other example id');
254+
if (other == null) {
255+
other = new ExampleEntity('other example id');
256+
}
255257
other.save();
256258

257259
// BigInt math

0 commit comments

Comments
 (0)