Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async writeSubgraphToOutputDirectory(subgraph) {
const displayDir = `${this.displayPath(this.options.outputDir)}${
toolbox.filesystem.separator
}`
return await withSpinner(
`Write compiled subgraph to ${displayDir}`,
`Failed to write compiled subgraph to ${displayDir}`,
`Warnings while writing compiled subgraph to ${displayDir}`,
async spinner => {
// Copy schema and update its path
subgraph = subgraph.updateIn(['schema', 'file'], schemaFile =>
path.relative(
this.options.outputDir,
this._copySubgraphFile(
schemaFile,
this.sourceDir,
this.options.outputDir,
spinner,
const loadAbiFromFile = async filename => {
let exists = await toolbox.filesystem.exists(filename)
if (!exists) {
throw Error('File does not exist.')
} else if (exists === 'dir') {
throw Error('Path points to a directory, not a file.')
} else if (exists === 'other') {
throw Error('Not sure what this path points to.')
} else {
return await ABI.load('Contract', filename)
}
}
apply: async ({ manifestFile }) => {
let subgraph = (await Subgraph.load(manifestFile, { skipValidation: true })).result
subgraph = subgraph.update('dataSources', dataSources =>
dataSources.map(dataSource => maybeMigrateDataSource(manifestFile, dataSource)),
)
let newManifest = Subgraph.dump(subgraph)
await toolbox.filesystem.write(manifestFile, newManifest, { atomic: true })
},
}