Skip to content

Commit 3d59dad

Browse files
committed
set idAsString in handleStreamUpdate()
1 parent d5dcc2a commit 3d59dad

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/network-subgraphs/src/streamRegistry.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ export function handleStreamUpdate(event: StreamUpdated): void {
3838
[event.params.id, event.params.metadata, event.block.number.toString()])
3939
let stream = Stream.load(event.params.id)
4040
if (stream === null) {
41+
// If the stream was initialized using the trustedSetStreamMetadata() method instead of the usual createStream(),
42+
// the Stream entity does not yet exist. This pattern was used at least in the brubeck-migration-script
43+
// (see: https://polygonscan.com/tx/0x8b3f4eee260cab5b7eed2f90f09db14f35d96bf231368df44988b3035b41a543),
44+
// and possibly in ENS stream creation as well (see: https://github.com/streamr-dev/network-contracts/pull/109).
45+
// The trustedSetStreamMetadata() method, which existed in StreamRegistry before version 5,
46+
// only emitted a StreamUpdated event. Since no StreamCreated event was triggered during this process,
47+
// the handleStreamCreation() function was never called, and the Stream entity wasn't created.
48+
// Therefore, we need to create it here manually.
4149
stream = new Stream(event.params.id)
50+
stream.idAsString = event.params.id
4251
stream.createdAt = event.block.timestamp
4352
}
4453
stream.metadata = event.params.metadata

0 commit comments

Comments
 (0)