Skip to content

Commit

Permalink
add support for polling block handler
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Aug 21, 2023
1 parent d4d5c90 commit b86cfb8
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-maps-double.md
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': minor
---

Add support for polling block handlers in the manifest for ethereum
21 changes: 17 additions & 4 deletions packages/cli/src/protocols/ethereum/manifest.graphql
Expand Up @@ -55,13 +55,26 @@ type ContractAbi {
file: File!
}

type BlockHandler {
handler: String!
filter: BlockFilter
enum BlockFilterKind {
polling
once
call
}

type BlockFilter {
kind: String!
kind: BlockFilterKind!
}

type PollingBlockFilter {
kind: BlockFilterKind!
every: BigInt!
}

union BlockFilterType = BlockFilter | PollingBlockFilter

type BlockHandler {
handler: String!
filter: BlockFilterType
}

type CallHandler {
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/tests/cli/validation.test.ts
@@ -1,6 +1,14 @@
import { cliTest } from './util';

describe('Validation', () => {
cliTest(
'Block handler filters',
['codegen', '--skip-migrations'],
'validation/block-handler-filters',
{
exitCode: 0,
},
);
cliTest(
'Invalid subgraph manifest',
['codegen', '--skip-migrations'],
Expand Down
@@ -0,0 +1 @@
[]
Empty file.
@@ -0,0 +1,3 @@
type A @entity {
id: ID!
}
@@ -0,0 +1,29 @@
specVersion: 0.0.1
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: DataSource
source:
address: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
abi: ExampleContract
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./mapping.ts
entities:
- A
abis:
- name: ExampleContract
file: ./Abi.json
blockHandlers:
- handler: handleBlock0
- handler: handleBlock1
filter:
kind: polling
every: 2
- handler: handleBlock2
filter:
kind: once

0 comments on commit b86cfb8

Please sign in to comment.