Skip to content

Commit

Permalink
fix: missing Event suffix in subgraph transfferred event and from/to
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed Feb 22, 2024
1 parent 8f471c0 commit 0bfbfda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ type SubgraphL2TransferFinalizedEvent implements SubgraphEvent & Event @entity(i
tx_cumulativeGasUsed: BigInt!
}

type SubgraphTransferred implements SubgraphEvent & GraphAccountEvent & Event
type SubgraphTransferredEvent implements SubgraphEvent & GraphAccountEvent & Event
@entity(immutable: true) {
id: ID!

Expand All @@ -610,6 +610,10 @@ type SubgraphTransferred implements SubgraphEvent & GraphAccountEvent & Event

subgraph: Subgraph!

from: GraphAccount!

to: GraphAccount!

"User that triggered the Event"
accounts: [GraphAccount!]!

Expand Down
10 changes: 6 additions & 4 deletions src/mappings/gns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
ParameterUpdatedEvent,
SetDefaultNameEvent,
SubgraphVersionMetadataUpdatedEvent,
SubgraphTransferred,
SubgraphTransferredEvent,
} from '../types/schema'

import {
Expand Down Expand Up @@ -897,8 +897,8 @@ export function handleTransfer(event: Transfer): void {
let oldOwner = createOrLoadGraphAccount(event.params.from.toHexString())
let subgraphID = convertBigIntSubgraphIDToBase58(event.params.tokenId)
let accounts = new Array<String>()
accounts.push(newOwner.id)
accounts.push(oldOwner.id)
accounts.push(newOwner.id)

// Update subgraph v2
let subgraph = createOrLoadSubgraph(
Expand All @@ -909,16 +909,18 @@ export function handleTransfer(event: Transfer): void {
subgraph.save()

//todo
let otherEventEntity = new SubgraphTransferred(eventId)
let otherEventEntity = new SubgraphTransferredEvent(eventId)
otherEventEntity.timestamp = event.block.timestamp
otherEventEntity.tx_gasLimit = event.transaction.gasLimit
otherEventEntity.tx_gasPrice = event.transaction.gasPrice
otherEventEntity.tx_gasUsed = event.receipt!.gasUsed
otherEventEntity.tx_cumulativeGasUsed = event.receipt!.cumulativeGasUsed
otherEventEntity.blockNumber = event.block.number
otherEventEntity.tx_hash = event.transaction.hash
otherEventEntity.typename = 'SubgraphTransferred'
otherEventEntity.typename = 'SubgraphTransferredEvent'
otherEventEntity.subgraph = subgraph.id
otherEventEntity.from = oldOwner.id
otherEventEntity.to = newOwner.id
otherEventEntity.accounts = accounts
otherEventEntity.save()

Expand Down

0 comments on commit 0bfbfda

Please sign in to comment.