Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for polling block handler #1392

Merged
merged 1 commit into from Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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