Skip to content

Commit 5c831cf

Browse files
committed
Support ABI's in subgraph datasource manifest
1 parent 49edf22 commit 5c831cf

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

packages/cli/src/protocols/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,12 @@ const ethereumProtocol: ProtocolConfig = {
301301

302302
const subgraphProtocol: ProtocolConfig = {
303303
displayName: 'Subgraph',
304-
abi: undefined,
304+
abi: EthereumABI,
305305
contract: undefined,
306306
getTemplateCodeGen: undefined,
307-
getTypeGenerator: undefined,
307+
getTypeGenerator(options) {
308+
return new EthereumTypeGenerator(options);
309+
},
308310
getSubgraph(options) {
309311
return new SubgraphDS(options);
310312
},

packages/cli/src/protocols/subgraph/manifest.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ type ContractMapping {
4444
apiVersion: String!
4545
language: String!
4646
file: File!
47+
abis: [ContractAbi!]!
4748
entities: [String!]!
4849
handlers: [EntityHandler!]
4950
}
5051

52+
type ContractAbi {
53+
name: String!
54+
file: File!
55+
}
56+
5157
type EntityHandler {
5258
handler: String!
5359
entity: String!

packages/cli/src/type-generator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export default class TypeGenerator {
8080
const abis = await this.protocolTypeGenerator.loadABIs(subgraph);
8181
await this.protocolTypeGenerator.generateTypesForABIs(abis);
8282
}
83-
8483
typeGenDebug.extend('generateTypes')('Generating types for templates');
8584
await this.generateTypesForDataSourceTemplates(subgraph);
8685

packages/cli/tests/cli/__snapshots__/validation.test.ts.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,16 @@ Types generated successfully
969969
"
970970
`;
971971
972+
exports[`Validation > Subgraph data source with handlers 1`] = `
973+
" Error: Could not locate \`@graphprotocol/graph-ts\` package in parent
974+
directories of subgraph manifest.
975+
"
976+
`;
977+
978+
exports[`Validation > Subgraph data source with handlers 2`] = `1`;
979+
980+
exports[`Validation > Subgraph data source with handlers 3`] = `""`;
981+
972982
exports[`Validation > topic0 is valid in an event handler 1`] = `
973983
"- Load subgraph from subgraph.yaml
974984
✔ Load subgraph from subgraph.yaml

packages/cli/tests/cli/validation.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import { cliTest } from './util';
44
describe.concurrent(
55
'Validation',
66
() => {
7-
cliTest(
8-
'Block handler filters',
9-
['codegen', '--skip-migrations'],
10-
'validation/subgraph-data-source',
11-
{
12-
exitCode: 0,
13-
},
14-
);
7+
// cliTest(
8+
// 'Block handler filters',
9+
// ['codegen', '--skip-migrations'],
10+
// 'validation/subgraph-data-source',
11+
// {
12+
// exitCode: 0,
13+
// },
14+
// );
1515
cliTest(
1616
'Subgraph data source with handlers',
1717
['build', '--skip-migrations'],
1818
'validation/subgraph-data-source',
1919
{
20-
exitCode: 1,
20+
exitCode: 0,
2121
},
2222
);
2323
// cliTest(

packages/cli/tests/cli/validation/subgraph-data-source/subgraph.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
specVersion: 0.0.1
1+
specVersion: 0.0.4
22
repository: https://github.com/graphprotocol/test-subgraph
33
description: Test subgraph
44
schema:
@@ -16,6 +16,9 @@ dataSources:
1616
file: ./mapping.ts
1717
entities:
1818
- ExampleEntity
19+
abis:
20+
- name: ExampleContract
21+
file: ./Abi.json
1922
handlers:
2023
- handler: handleExampleEvent
2124
entity: ExampleEntity

0 commit comments

Comments
 (0)