Skip to content

Commit 62f212a

Browse files
committed
stop indexing send events
1 parent 22223af commit 62f212a

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

packages/subgraph/schema.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,9 @@ type MintedEvent implements Event @entity(immutable: true) {
13851385
operatorData: Bytes!
13861386
}
13871387

1388+
"""
1389+
WARNING: This event has been deprecated. It is not indexed anymore. It's kept in schema to avoid breakage in the schema.
1390+
"""
13881391
type SentEvent implements Event @entity(immutable: true) {
13891392
id: ID!
13901393
transactionHash: Bytes!

packages/subgraph/src/mappingHelpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,6 @@ export function updateATSStreamedAndBalanceUntilUpdatedAt(
10821082
): void {
10831083
const block = event.block;
10841084

1085-
// update the updatedAt property of the account that just made an update
1086-
updateAccountUpdatedAt(accountAddress, block);
1087-
10881085
let accountTokenSnapshot = getOrInitAccountTokenSnapshot(
10891086
accountAddress,
10901087
tokenAddress,
@@ -1104,7 +1101,7 @@ export function updateATSStreamedAndBalanceUntilUpdatedAt(
11041101

11051102
const balanceUntilUpdatedAtAfterUpdate = accountTokenSnapshot.balanceUntilUpdatedAt;
11061103

1107-
if (accountTokenSnapshot.updatedAtBlockNumber === block.number && balanceUntilUpdatedAtAfterUpdate.equals(balanceUntilUpdatedAtBeforeUpdate)) {
1104+
if (accountTokenSnapshot.updatedAtBlockNumber === block.number && balanceUntilUpdatedAtBeforeUpdate.equals(balanceUntilUpdatedAtAfterUpdate)) {
11081105
// ATS has already been updated in the block and no new balance change discovered. It's safe to return early.
11091106
return;
11101107
}
@@ -1197,6 +1194,9 @@ export function updateATSStreamedAndBalanceUntilUpdatedAt(
11971194
tokenStatistic.save();
11981195
}
11991196

1197+
// update the updatedAt property of the account that just made an update
1198+
updateAccountUpdatedAt(accountAddress, block);
1199+
12001200
_createAccountTokenSnapshotLogEntity(
12011201
event,
12021202
accountAddress,

packages/subgraph/subgraph.template.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,10 @@ templates:
380380
- event: Minted(indexed address,indexed address,uint256,bytes,bytes)
381381
handler: handleMinted
382382
receipt: true
383-
- event: Sent(indexed address,indexed address,indexed address,uint256,bytes,bytes)
384-
handler: handleSent
385-
receipt: true
383+
# Not indexing Sent event anymore. Use Transfer instead.
384+
# - event: Sent(indexed address,indexed address,indexed address,uint256,bytes,bytes)
385+
# handler: handleSent
386+
# receipt: true
386387
- event: TokenUpgraded(indexed address,uint256)
387388
handler: handleTokenUpgraded
388389
receipt: true

packages/subgraph/tests/superToken/event/superToken.event.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,26 @@ describe("SuperToken Mapper Unit Tests", () => {
516516
to,
517517
value
518518
);
519+
transferEvent.block.timestamp = BigInt.fromI32(1);
520+
transferEvent.block.number = BigInt.fromI32(1);
521+
522+
mockedRealtimeBalanceOf(
523+
transferEvent.address.toHex(),
524+
from,
525+
transferEvent.block.timestamp,
526+
value,
527+
BIG_INT_ZERO,
528+
BIG_INT_ZERO
529+
);
530+
531+
mockedRealtimeBalanceOf(
532+
transferEvent.address.toHex(),
533+
to,
534+
transferEvent.block.timestamp,
535+
value,
536+
BIG_INT_ZERO,
537+
BIG_INT_ZERO
538+
);
519539

520540
handleTransfer(transferEvent);
521541

@@ -564,6 +584,8 @@ describe("SuperToken Mapper Unit Tests", () => {
564584
to,
565585
value
566586
);
587+
secondTransferEvent.block.timestamp = BigInt.fromI32(2);
588+
secondTransferEvent.block.number = BigInt.fromI32(2);
567589

568590
mockedRealtimeBalanceOf(
569591
secondTransferEvent.address.toHex(),
@@ -574,6 +596,15 @@ describe("SuperToken Mapper Unit Tests", () => {
574596
BIG_INT_ZERO
575597
);
576598

599+
mockedRealtimeBalanceOf(
600+
secondTransferEvent.address.toHex(),
601+
to,
602+
secondTransferEvent.block.timestamp,
603+
value.times(BigInt.fromI32(2)),
604+
BIG_INT_ZERO,
605+
BIG_INT_ZERO
606+
);
607+
577608
handleTransfer(secondTransferEvent);
578609

579610
assertTokenStatisticProperties(

0 commit comments

Comments
 (0)