mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 08:54:05 +00:00
Fix codegen for creating subgraph watcher for Sushiswap (#432)
* Fix EthClient import in codegen and graph-node package * Fix codegen for resolving common events between contracts
This commit is contained in:
@@ -53,6 +53,7 @@ Steps:
|
||||
port: 3008
|
||||
|
||||
# Solc version to use (optional)
|
||||
# Use longVersion prefixed with v from the release list https://binaries.soliditylang.org/bin/list.json
|
||||
# If not defined, uses solc version listed in dependencies
|
||||
solc: v0.8.0+commit.c7dfd78e
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ export class Client {
|
||||
|
||||
queryObject.params = queryObject.params.map((param) => {
|
||||
const gqlParamType = getGqlForSol(param.type);
|
||||
assert(gqlParamType);
|
||||
const tsParamType = getTsForGql(gqlParamType);
|
||||
assert(tsParamType);
|
||||
param.type = tsParamType;
|
||||
|
||||
@@ -64,7 +64,6 @@ export class Database {
|
||||
|
||||
queryObject.params = queryObject.params.map((param) => {
|
||||
const gqlParamType = getGqlForSol(param.type);
|
||||
assert(gqlParamType);
|
||||
const tsParamType = getTsForGql(gqlParamType);
|
||||
assert(tsParamType);
|
||||
param.type = tsParamType;
|
||||
|
||||
@@ -113,7 +113,6 @@ export class Entity {
|
||||
const name = param.name;
|
||||
|
||||
const gqlType = getGqlForSol(param.type);
|
||||
assert(gqlType);
|
||||
const tsType = getTsForGql(gqlType);
|
||||
assert(tsType);
|
||||
const pgType = getPgForTs(tsType);
|
||||
@@ -153,7 +152,6 @@ export class Entity {
|
||||
const baseType = getBaseType(typeName);
|
||||
assert(baseType);
|
||||
const gqlReturnType = getGqlForSol(baseType);
|
||||
assert(gqlReturnType);
|
||||
let tsReturnType = getTsForGql(gqlReturnType);
|
||||
assert(tsReturnType);
|
||||
const pgReturnType = getPgForTs(tsReturnType);
|
||||
|
||||
@@ -69,7 +69,6 @@ export class Indexer {
|
||||
const baseType = getBaseType(typeName);
|
||||
assert(baseType);
|
||||
const gqlReturnType = getGqlForSol(baseType);
|
||||
assert(gqlReturnType);
|
||||
let tsReturnType = getTsForGql(gqlReturnType);
|
||||
assert(tsReturnType);
|
||||
|
||||
@@ -107,7 +106,6 @@ export class Indexer {
|
||||
|
||||
queryObject.params = queryObject.params.map((param) => {
|
||||
const gqlParamType = getGqlForSol(param.type);
|
||||
assert(gqlParamType);
|
||||
const tsParamType = getTsForGql(gqlParamType);
|
||||
assert(tsParamType);
|
||||
param.type = tsParamType;
|
||||
|
||||
@@ -43,7 +43,6 @@ export class Resolvers {
|
||||
|
||||
queryObject.params = queryObject.params.map((param) => {
|
||||
const gqlParamType = getGqlForSol(param.type);
|
||||
assert(gqlParamType);
|
||||
const tsParamType = getTsForGql(gqlParamType);
|
||||
assert(tsParamType);
|
||||
param.type = tsParamType;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Writable } from 'stream';
|
||||
import { utils } from 'ethers';
|
||||
import { VariableDeclaration } from '@solidity-parser/parser/dist/src/ast-types';
|
||||
|
||||
import { getGqlForTs, getGqlForSol } from './utils/type-mappings';
|
||||
import { getGqlForSol } from './utils/type-mappings';
|
||||
import { Param } from './utils/types';
|
||||
import { getBaseType, isArrayType } from './utils/helpers';
|
||||
|
||||
@@ -251,7 +251,6 @@ export class Schema {
|
||||
assert(baseTypeName);
|
||||
|
||||
const gqlReturnType = getGqlForSol(baseTypeName);
|
||||
assert(gqlReturnType, `gql type for sol type ${baseTypeName} for ${functionName} not found`);
|
||||
|
||||
return {
|
||||
type: gqlReturnType,
|
||||
@@ -510,7 +509,7 @@ export class Schema {
|
||||
const newFields: any = {};
|
||||
params.forEach((param: Param) => {
|
||||
if (!commonFields.includes(param.name)) {
|
||||
newFields[param.name] = `${getGqlForTs(param.type)}`;
|
||||
newFields[param.name] = `${getGqlForSol(param.type)}`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import { SelectionNode } from 'graphql';
|
||||
|
||||
import { JsonFragment } from '@ethersproject/abi';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
import { EthClient } from '@cerc-io/ipld-eth-client';
|
||||
import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper';
|
||||
import {
|
||||
Indexer as BaseIndexer,
|
||||
@@ -42,7 +41,8 @@ import {
|
||||
ResultEvent,
|
||||
getResultEvent,
|
||||
DatabaseInterface,
|
||||
Clients
|
||||
Clients,
|
||||
EthClient
|
||||
} from '@cerc-io/util';
|
||||
{{#if (subgraphPath)}}
|
||||
import { GraphWatcher } from '@cerc-io/graph-node';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Copyright 2021 Vulcanize, Inc.
|
||||
//
|
||||
|
||||
import assert from 'assert';
|
||||
|
||||
import { solToGql } from './solToGql';
|
||||
|
||||
const _tsToGql: Map<string, string> = new Map();
|
||||
@@ -29,8 +31,11 @@ _gqlToTs.set('Boolean', 'boolean');
|
||||
_gqlToTs.set('BigDecimal', 'Decimal');
|
||||
_gqlToTs.set('Bytes', 'string');
|
||||
|
||||
function getGqlForSol (solType: string): string | undefined {
|
||||
return solToGql.get(solType);
|
||||
function getGqlForSol (solType: string): string {
|
||||
const gqlType = solToGql.get(solType);
|
||||
assert(gqlType, `GQL type for SOL type ${solType} not found`);
|
||||
|
||||
return gqlType;
|
||||
}
|
||||
|
||||
function getGqlForTs (tsType: string): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user