Skip to content

Commit

Permalink
Merge pull request #822 from obvious-inc/current-owner-delegate-event
Browse files Browse the repository at this point in the history
subgraph: add delegator to delegationEvents
  • Loading branch information
solimander authored Dec 15, 2023
2 parents a0ebf73 + 6768363 commit beb86c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/nouns-subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ type DelegationEvent @entity {
"The Noun being delegated"
noun: Noun!

"Current delegator address"
delegator: Account!

"Previous delegate address"
previousDelegate: Delegate!

Expand Down
2 changes: 2 additions & 0 deletions packages/nouns-subgraph/src/nouns-erc-721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function handleDelegateChanged(event: DelegateChanged): void {
delegateChangedEvent.previousDelegate = previousDelegate.id
? previousDelegate.id
: tokenHolder.id;
delegateChangedEvent.delegator = tokenHolder.id.toString();
delegateChangedEvent.newDelegate = newDelegate.id ? newDelegate.id : tokenHolder.id;
delegateChangedEvent.save();
}
Expand Down Expand Up @@ -172,6 +173,7 @@ export function handleTransfer(event: Transfer): void {
delegateChangedEvent.newDelegate = toHolder.delegate
? toHolder.delegate!.toString()
: toHolder.id.toString();
delegateChangedEvent.delegator = fromHolder.id.toString();
delegateChangedEvent.save();

let toHolderDelegate = getOrCreateDelegate(toHolder.delegate ? toHolder.delegate! : toHolder.id);
Expand Down

0 comments on commit beb86c1

Please sign in to comment.