Fix for indexed reference type event arg in moby mask watcher

This commit is contained in:
nabarun 2022-06-28 20:22:02 +05:30 committed by Ashwin Phatak
parent 6cb424b315
commit 14a32a7d47
3 changed files with 53 additions and 7 deletions

View File

@ -465,7 +465,7 @@ export class Indexer implements IPLDIndexerInterface {
case {{capitalize event.name}}_EVENT: { case {{capitalize event.name}}_EVENT: {
eventName = logDescription.name; eventName = logDescription.name;
{{#if event.params}} {{#if event.params}}
const { {{#each event.params~}} {{this.name}} {{~#unless @last}}, {{/unless}} {{~/each}} } = logDescription.args; const [ {{#each event.params~}} {{this.name}} {{~#unless @last}}, {{/unless}} {{~/each}} ] = logDescription.args;
{{/if}} {{/if}}
eventInfo = { eventInfo = {
{{#each event.params}} {{#each event.params}}

View File

@ -97,6 +97,12 @@
yarn server yarn server
``` ```
* Run the job-runner:
```bash
yarn job-runner
```
* Clone the [MobyMask](https://github.com/vulcanize/MobyMask) repo. * Clone the [MobyMask](https://github.com/vulcanize/MobyMask) repo.
* Checkout to the branch with changes for using this watcher: * Checkout to the branch with changes for using this watcher:
@ -130,6 +136,42 @@
export MOBY_ADDRESS="<MOBY_ADDRESS>" export MOBY_ADDRESS="<MOBY_ADDRESS>"
``` ```
* Run the following GQL mutation in watcher GraphQL endpoint http://127.0.0.1:3010/graphql
```graphql
mutation {
watchContract(
address: "MOBY_ADDRESS"
kind: "PhisherRegistry"
checkpoint: true
)
}
```
* Run the following GQL subscription in generated watcher GraphQL endpoint:
```graphql
subscription {
onEvent {
event {
__typename
... on PhisherStatusUpdatedEvent {
entity
isPhisher
},
... on MemberStatusUpdatedEvent {
entity
isMember
}
},
block {
number
hash
}
}
}
```
* Update isPhiser and isMember lists with names * Update isPhiser and isMember lists with names
```bash ```bash
@ -140,6 +182,8 @@
yarn claimMember --contract $MOBY_ADDRESS --name memberName yarn claimMember --contract $MOBY_ADDRESS --name memberName
``` ```
* The events should be visible in the subscription at GQL endpoint.
* Check the names in the watcher GraphQL playground http://localhost:3010/graphql * Check the names in the watcher GraphQL playground http://localhost:3010/graphql
* Get the latest block * Get the latest block

View File

@ -577,7 +577,7 @@ export class Indexer implements IPLDIndexerInterface {
switch (logDescription.name) { switch (logDescription.name) {
case DELEGATIONTRIGGERED_EVENT: { case DELEGATIONTRIGGERED_EVENT: {
eventName = logDescription.name; eventName = logDescription.name;
const { principal, agent } = logDescription.args; const [principal, agent] = logDescription.args;
eventInfo = { eventInfo = {
principal, principal,
agent agent
@ -587,9 +587,10 @@ export class Indexer implements IPLDIndexerInterface {
} }
case MEMBERSTATUSUPDATED_EVENT: { case MEMBERSTATUSUPDATED_EVENT: {
eventName = logDescription.name; eventName = logDescription.name;
const { entity, isMember } = logDescription.args; const [entity, isMember] = logDescription.args;
eventInfo = { eventInfo = {
entity, // Indexed reference type arg
entity: entity.hash,
isMember isMember
}; };
@ -597,7 +598,7 @@ export class Indexer implements IPLDIndexerInterface {
} }
case OWNERSHIPTRANSFERRED_EVENT: { case OWNERSHIPTRANSFERRED_EVENT: {
eventName = logDescription.name; eventName = logDescription.name;
const { previousOwner, newOwner } = logDescription.args; const [previousOwner, newOwner] = logDescription.args;
eventInfo = { eventInfo = {
previousOwner, previousOwner,
newOwner newOwner
@ -607,9 +608,10 @@ export class Indexer implements IPLDIndexerInterface {
} }
case PHISHERSTATUSUPDATED_EVENT: { case PHISHERSTATUSUPDATED_EVENT: {
eventName = logDescription.name; eventName = logDescription.name;
const { entity, isPhisher } = logDescription.args; const [entity, isPhisher] = logDescription.args;
eventInfo = { eventInfo = {
entity, // Indexed reference type arg
entity: entity.hash,
isPhisher isPhisher
}; };