Browse Source

Add `WorkSubmittedEvent.bounty`

Theophile Sandoz 3 years ago
parent
commit
49d6a9c1ec
2 changed files with 5 additions and 1 deletions
  1. 2 1
      query-node/mappings/src/bounty.ts
  2. 3 0
      query-node/schemas/bountyEvents.graphql

+ 2 - 1
query-node/mappings/src/bounty.ts

@@ -463,7 +463,7 @@ export async function bounty_WorkEntrySlashed({ event, store }: EventContext & S
 // Store WorkSubmitted events
 // Store WorkSubmitted events
 export async function bounty_WorkSubmitted({ event, store }: EventContext & StoreContext): Promise<void> {
 export async function bounty_WorkSubmitted({ event, store }: EventContext & StoreContext): Promise<void> {
   const workSubmittedEvent = new BountyEvents.WorkSubmittedEvent(event)
   const workSubmittedEvent = new BountyEvents.WorkSubmittedEvent(event)
-  const [, entryId, , metadataBytes] = workSubmittedEvent.params
+  const [bountyId, entryId, , metadataBytes] = workSubmittedEvent.params
 
 
   // Update the entry
   // Update the entry
   const entry = await updateEntry(store, event, entryId, () => ({
   const entry = await updateEntry(store, event, entryId, () => ({
@@ -474,6 +474,7 @@ export async function bounty_WorkSubmitted({ event, store }: EventContext & Stor
   const metadata = deserializeMetadata(BountyWorkData, metadataBytes)
   const metadata = deserializeMetadata(BountyWorkData, metadataBytes)
   const submittedInEvent = new WorkSubmittedEvent({
   const submittedInEvent = new WorkSubmittedEvent({
     ...genericEventFields(event),
     ...genericEventFields(event),
+    bounty: new Bounty({ id: String(bountyId) }),
     entry,
     entry,
     title: whenDef(metadata?.title, perpareString),
     title: whenDef(metadata?.title, perpareString),
     description: whenDef(metadata?.description, perpareString),
     description: whenDef(metadata?.description, perpareString),

+ 3 - 0
query-node/schemas/bountyEvents.graphql

@@ -282,6 +282,9 @@ type WorkSubmittedEvent implements Event @entity {
 
 
   ### SPECIFIC DATA ###
   ### SPECIFIC DATA ###
 
 
+  "The bounty which the work entry belongs to"
+  bounty: Bounty!
+
   "The entry this work was submitted into"
   "The entry this work was submitted into"
   entry: BountyEntry!
   entry: BountyEntry!