diff --git a/packages/db/src/resources/bytecodes.ts b/packages/db/src/resources/bytecodes.ts index 6540ad5b6fb..ef799603d1a 100644 --- a/packages/db/src/resources/bytecodes.ts +++ b/packages/db/src/resources/bytecodes.ts @@ -1,10 +1,10 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions:bytecodes"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources:bytecodes"); import gql from "graphql-tag"; import CodeUtils from "@truffle/code-utils"; -import { Definition } from "./types"; +import {Definition} from "./types"; export const bytecodes: Definition<"bytecodes"> = { createIndexes: [], @@ -47,16 +47,14 @@ export const bytecodes: Definition<"bytecodes"> = { resolvers: { Bytecode: { instructions: { - async resolve({ bytes }, { count = null }) { + async resolve({bytes}, {count = null}) { const parsed = CodeUtils.parseCode(`0x${bytes}`, count); - return parsed.map( - ({ name: opcode, pc: programCounter, pushData }) => ({ - opcode, - programCounter, - pushData - }) - ); + return parsed.map(({name: opcode, pc: programCounter, pushData}) => ({ + opcode, + programCounter, + pushData + })); } } } diff --git a/packages/db/src/resources/compilations.ts b/packages/db/src/resources/compilations.ts index d9b786b038e..5f41fbcd89a 100644 --- a/packages/db/src/resources/compilations.ts +++ b/packages/db/src/resources/compilations.ts @@ -1,5 +1,5 @@ import {logger} from "@truffle/db/logger"; -const debug = logger("db:definitions:compilations"); +const debug = logger("db:resources:compilations"); import gql from "graphql-tag"; diff --git a/packages/db/src/resources/contractInstances.ts b/packages/db/src/resources/contractInstances.ts index bed75a0667f..9f35688bc2a 100644 --- a/packages/db/src/resources/contractInstances.ts +++ b/packages/db/src/resources/contractInstances.ts @@ -1,9 +1,9 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions:contractInstances"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources:contractInstances"); import gql from "graphql-tag"; -import { Definition } from "./types"; +import {Definition} from "./types"; export const contractInstances: Definition<"contractInstances"> = { createIndexes: [], @@ -79,7 +79,7 @@ export const contractInstances: Definition<"contractInstances"> = { resolvers: { ContractInstance: { network: { - resolve: async ({ network: { id } }, _, { workspace }) => { + resolve: async ({network: {id}}, _, {workspace}) => { debug("Resolving ContractInstance.network..."); const result = await workspace.get("networks", id); @@ -89,7 +89,7 @@ export const contractInstances: Definition<"contractInstances"> = { } }, contract: { - resolve: async ({ contract: { id } }, _, { workspace }) => { + resolve: async ({contract: {id}}, _, {workspace}) => { debug("Resolving ContractInstance.contract..."); const result = await workspace.get("contracts", id); @@ -98,7 +98,7 @@ export const contractInstances: Definition<"contractInstances"> = { } }, callBytecode: { - resolve: async ({ callBytecode }, _, { workspace }) => { + resolve: async ({callBytecode}, _, {workspace}) => { debug("Resolving ContractInstance.callBytecode..."); const bytecode = await workspace.get( @@ -106,7 +106,7 @@ export const contractInstances: Definition<"contractInstances"> = { callBytecode.bytecode.id ); const linkValues = callBytecode.linkValues.map( - ({ value, linkReference }) => { + ({value, linkReference}) => { return { value: value, linkReference: bytecode.linkReferences[linkReference.index] @@ -122,7 +122,7 @@ export const contractInstances: Definition<"contractInstances"> = { } }, creation: { - resolve: async (input, _, { workspace }) => { + resolve: async (input, _, {workspace}) => { debug("Resolving ContractInstance.creation..."); let bytecode = await workspace.get( @@ -131,7 +131,7 @@ export const contractInstances: Definition<"contractInstances"> = { ); let transactionHash = input.creation.transactionHash; let linkValues = input.creation.constructor.createBytecode.linkValues.map( - ({ value, linkReference }) => { + ({value, linkReference}) => { return { value: value, linkReference: bytecode.linkReferences[linkReference.index] diff --git a/packages/db/src/resources/contracts.ts b/packages/db/src/resources/contracts.ts index c723bab76fb..d29d2a694e5 100644 --- a/packages/db/src/resources/contracts.ts +++ b/packages/db/src/resources/contracts.ts @@ -1,9 +1,9 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions:contracts"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources:contracts"); import gql from "graphql-tag"; -import { Definition } from "./types"; +import {Definition} from "./types"; export const contracts: Definition<"contracts"> = { createIndexes: [ @@ -50,7 +50,7 @@ export const contracts: Definition<"contracts"> = { resolvers: { Contract: { compilation: { - resolve: async ({ compilation: { id } }, _, { workspace }) => { + resolve: async ({compilation: {id}}, _, {workspace}) => { debug("Resolving Contract.compilation..."); const result = workspace.get("compilations", id); @@ -62,27 +62,27 @@ export const contracts: Definition<"contracts"> = { processedSource: { fragment: `... on Contract { compilation { id } }`, resolve: async ( - { processedSource, compilation: { id } }, + {processedSource, compilation: {id}}, _, - { workspace } + {workspace} ) => { debug("Resolving Contract.processedSource..."); - const { processedSources } = await workspace.get("compilations", id); + const {processedSources} = await workspace.get("compilations", id); debug("Resolved Contract.processedSource."); return processedSources[processedSource.index]; } }, createBytecode: { - resolve: async ({ createBytecode }, _, { workspace }) => { + resolve: async ({createBytecode}, _, {workspace}) => { debug("Resolving Contract.createBytecode..."); if (!createBytecode) { return; } - const { id } = createBytecode; + const {id} = createBytecode; const result = await workspace.get("bytecodes", id); @@ -91,14 +91,14 @@ export const contracts: Definition<"contracts"> = { } }, callBytecode: { - resolve: async ({ callBytecode }, _, { workspace }) => { + resolve: async ({callBytecode}, _, {workspace}) => { debug("Resolving Contract.callBytecode..."); if (!callBytecode) { return; } - const { id } = callBytecode; + const {id} = callBytecode; const result = await workspace.get("bytecodes", id); diff --git a/packages/db/src/resources/index.ts b/packages/db/src/resources/index.ts index 60eebbf45d3..0b3da401637 100644 --- a/packages/db/src/resources/index.ts +++ b/packages/db/src/resources/index.ts @@ -1,19 +1,19 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources"); -import { Definitions } from "./types"; +import {Definitions} from "./types"; export * from "./types"; -import { sources } from "./sources"; -import { bytecodes } from "./bytecodes"; -import { compilations } from "./compilations"; -import { contracts } from "./contracts"; -import { contractInstances } from "./contractInstances"; -import { networks } from "./networks"; -import { nameRecords } from "./nameRecords"; -import { projects } from "./projects"; -import { projectNames } from "./projectNames"; -import { networkGenealogies } from "./networkGenealogies"; +import {sources} from "./sources"; +import {bytecodes} from "./bytecodes"; +import {compilations} from "./compilations"; +import {contracts} from "./contracts"; +import {contractInstances} from "./contractInstances"; +import {networks} from "./networks"; +import {nameRecords} from "./nameRecords"; +import {projects} from "./projects"; +import {projectNames} from "./projectNames"; +import {networkGenealogies} from "./networkGenealogies"; export const definitions: Definitions = { sources, diff --git a/packages/db/src/resources/projectNames.ts b/packages/db/src/resources/projectNames.ts index ea4d6d67aed..940f0ea110e 100644 --- a/packages/db/src/resources/projectNames.ts +++ b/packages/db/src/resources/projectNames.ts @@ -1,9 +1,9 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions:projectNames"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources:projectNames"); import gql from "graphql-tag"; -import { Definition } from "./types"; +import {Definition} from "./types"; export const projectNames: Definition<"projectNames"> = { createIndexes: [ @@ -38,7 +38,7 @@ export const projectNames: Definition<"projectNames"> = { resolvers: { ProjectName: { project: { - resolve: async ({ project: { id } }, _, { workspace }) => { + resolve: async ({project: {id}}, _, {workspace}) => { debug("Resolving ProjectName.project..."); const result = await workspace.get("projects", id); @@ -48,7 +48,7 @@ export const projectNames: Definition<"projectNames"> = { } }, nameRecord: { - resolve: async ({ nameRecord: { id } }, _, { workspace }) => { + resolve: async ({nameRecord: {id}}, _, {workspace}) => { debug("Resolving ProjectName.nameRecord..."); const result = await workspace.get("nameRecords", id); diff --git a/packages/db/src/resources/projects.ts b/packages/db/src/resources/projects.ts index e02014ca431..478933d893c 100644 --- a/packages/db/src/resources/projects.ts +++ b/packages/db/src/resources/projects.ts @@ -1,9 +1,9 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions:projects"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources:projects"); import gql from "graphql-tag"; -import { Definition } from "./types"; +import {Definition} from "./types"; export const projects: Definition<"projects"> = { createIndexes: [], @@ -26,18 +26,18 @@ export const projects: Definition<"projects"> = { resolvers: { Project: { resolve: { - resolve: async ({ id }, { name, type }, { workspace }) => { + resolve: async ({id}, {name, type}, {workspace}) => { debug("Resolving Project.resolve..."); const results = await workspace.find("projectNames", { - selector: { "project.id": id, name, type } + selector: {"project.id": id, name, type} }); - const nameRecordIds = results.map(({ nameRecord: { id } }) => id); + const nameRecordIds = results.map(({nameRecord: {id}}) => id); const result = await workspace.find("nameRecords", { selector: { - id: { $in: nameRecordIds } + id: {$in: nameRecordIds} } }); @@ -46,23 +46,23 @@ export const projects: Definition<"projects"> = { } }, network: { - resolve: async ({ id }, { name }, { workspace }) => { + resolve: async ({id}, {name}, {workspace}) => { debug("Resolving Project.network..."); const results = await workspace.find("projectNames", { - selector: { "project.id": id, name, "type": "Network" } + selector: {"project.id": id, name, "type": "Network"} }); - const nameRecordIds = results.map(({ nameRecord: { id } }) => id); + const nameRecordIds = results.map(({nameRecord: {id}}) => id); const nameRecords = await workspace.find("nameRecords", { selector: { - id: { $in: nameRecordIds } + id: {$in: nameRecordIds} } }); if (nameRecords.length === 0) { return; } - const { resource } = nameRecords[0]; + const {resource} = nameRecords[0]; const result = await workspace.get("networks", resource.id); @@ -71,23 +71,23 @@ export const projects: Definition<"projects"> = { } }, contract: { - resolve: async ({ id }, { name }, { workspace }) => { + resolve: async ({id}, {name}, {workspace}) => { debug("Resolving Project.contract..."); const results = await workspace.find("projectNames", { - selector: { "project.id": id, name, "type": "Contract" } + selector: {"project.id": id, name, "type": "Contract"} }); - const nameRecordIds = results.map(({ nameRecord: { id } }) => id); + const nameRecordIds = results.map(({nameRecord: {id}}) => id); const nameRecords = await workspace.find("nameRecords", { selector: { - id: { $in: nameRecordIds } + id: {$in: nameRecordIds} } }); if (nameRecords.length === 0) { return; } - const { resource } = nameRecords[0]; + const {resource} = nameRecords[0]; const result = await workspace.get("contracts", resource.id); diff --git a/packages/db/src/resources/sources.ts b/packages/db/src/resources/sources.ts index bc630e5c019..e38d2f8f4b3 100644 --- a/packages/db/src/resources/sources.ts +++ b/packages/db/src/resources/sources.ts @@ -1,9 +1,9 @@ -import { logger } from "@truffle/db/logger"; -const debug = logger("db:definitions:sources"); +import {logger} from "@truffle/db/logger"; +const debug = logger("db:resources:sources"); import gql from "graphql-tag"; -import { Definition } from "./types"; +import {Definition} from "./types"; export const sources: Definition<"sources"> = { createIndexes: [], diff --git a/packages/db/src/resources/types.ts b/packages/db/src/resources/types.ts index 87ad703b8e5..f3a20bb7ae2 100644 --- a/packages/db/src/resources/types.ts +++ b/packages/db/src/resources/types.ts @@ -1,5 +1,5 @@ import {logger} from "@truffle/db/logger"; -const debug = logger("db:definitions:types"); +const debug = logger("db:resources:types"); import * as Meta from "@truffle/db/meta"; import * as Pouch from "@truffle/db/pouch";