forked from cowprotocol/subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to graph studio (cowprotocol#70)
* Update cli version * Update deploy script to use new approach * Update example .env * Remove removal of ABIs for UniswapV2 * Update scripts to use npm package version * Update example env file * Fix gnosis naming and subgraph * Update README.md * Remove rinkeby * Add additional scripts to deploy all * Remove usesUniV2
- Loading branch information
Showing
11 changed files
with
2,061 additions
and
1,034 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"network": "gnosis", | ||
"startBlock": 16465100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,93 @@ | ||
const assert = require('assert') | ||
const { series } = require('async') | ||
const { default: chalk } = require('chalk') | ||
const { exec } = require('child_process') | ||
const { confirm } = require('./utils') | ||
const assert = require("assert"); | ||
const { series } = require("async"); | ||
const { default: chalk } = require("chalk"); | ||
const { exec } = require("child_process"); | ||
const { confirm } = require("./utils"); | ||
|
||
require('dotenv').config() | ||
require("dotenv").config(); | ||
|
||
const NETWORK = process.env.NETWORK | ||
assert(NETWORK, 'NETWORK env var is required') | ||
const NETWORK = process.env.NETWORK; | ||
assert(NETWORK, "NETWORK env var is required"); | ||
|
||
const SUBGRAPH = process.env.SUBGRAPH | ||
assert(SUBGRAPH, 'SUBGRAPH env var is required') | ||
const SUBGRAPH = process.env.SUBGRAPH; | ||
assert(SUBGRAPH, "SUBGRAPH env var is required"); | ||
|
||
console.log(`Prepare subgraph config for network ${NETWORK}`) | ||
console.log(` Generate subgraph.yaml`) | ||
const AUTH_TOKEN = process.env.AUTH_TOKEN; | ||
assert(AUTH_TOKEN, "AUTH_TOKEN env var is required"); | ||
|
||
series([ | ||
(callback) => exec(`mustache config/${NETWORK}.json subgraph.yaml.mustache > subgraph.yaml`, null, callback), | ||
const VERSION = process.env.npm_package_version; | ||
assert( | ||
VERSION, | ||
"npm_package_version env var is required. This is defined by npm when version field is defined in the package.json file." | ||
); | ||
|
||
(callback) => { | ||
console.log('\n📝 Generate code from your GraphQL schema') | ||
return exec('yarn codegen', undefined, callback) | ||
}, | ||
console.log(`Prepare subgraph config for network ${NETWORK}`); | ||
console.log(` Generate subgraph.yaml`); | ||
|
||
(callback) => { | ||
console.log(`\n⬆️ Deploying graph: | ||
${chalk.blue('Subgraph')}: ${SUBGRAPH} | ||
${chalk.blue('Network')}: ${NETWORK} | ||
`) | ||
confirm({ | ||
message: chalk.red('Are you sure you want to deploy?'), | ||
callbackYes() { | ||
exec(`graph deploy ${SUBGRAPH} --product hosted-service`, (error) => { | ||
if (error) { | ||
console.log(`${chalk.red('\n\n🚩 There was an error deploying the subgraph 🚩')} \n\n`) | ||
console.error(`${error}`) | ||
return | ||
} | ||
}) | ||
console.log(`\n🚀 Deploy graph to https://thegraph.com/hosted-service/subgraph/${SUBGRAPH}`) | ||
callback() | ||
}, | ||
callbackNo() { | ||
console.log('\n🤗 Ok, not deploying then'); callback() | ||
} | ||
}) | ||
series( | ||
[ | ||
(callback) => { | ||
return exec( | ||
`mustache config/${NETWORK}.json subgraph.yaml.mustache > subgraph.yaml`, | ||
callback | ||
); | ||
}, | ||
(callback) => { | ||
console.log("\n📝 Generate code from your GraphQL schema"); | ||
return exec("yarn codegen", callback); | ||
}, | ||
(callback) => { | ||
console.log("\n📝 Build subgraph"); | ||
return exec("yarn build", callback); | ||
}, | ||
(callback) => { | ||
console.log("\n📝 Authenticate with the Graph Studio"); | ||
return exec(`graph auth --studio ${AUTH_TOKEN}`, callback); | ||
}, | ||
(callback) => { | ||
console.log(`\n⬆️ Deploying graph: | ||
${chalk.blue("Subgraph")}: ${SUBGRAPH} | ||
${chalk.blue("Network")}: ${NETWORK} | ||
`); | ||
confirm({ | ||
message: chalk.red("Are you sure you want to deploy?"), | ||
callbackYes() { | ||
exec( | ||
`graph deploy --studio ${SUBGRAPH} --version-label ${VERSION}`, | ||
(error) => { | ||
if (error) { | ||
console.log( | ||
`${chalk.red( | ||
"\n\n🚩 There was an error deploying the subgraph 🚩" | ||
)} \n\n` | ||
); | ||
console.error(`${error}`); | ||
return; | ||
} | ||
} | ||
); | ||
console.log( | ||
`\n🚀 Deploy graph to https://thegraph.com/studio/subgraph/${SUBGRAPH}` | ||
); | ||
callback(); | ||
}, | ||
callbackNo() { | ||
console.log("\n🤗 Ok, not deploying then"); | ||
callback(); | ||
}, | ||
}); | ||
}, | ||
], | ||
(error) => { | ||
if (error) { | ||
console.log( | ||
`${chalk.red( | ||
"\n\n🚩 There was an error preparing the subgraph 🚩" | ||
)} \n\n` | ||
); | ||
console.error(`${error}`); | ||
return; | ||
} | ||
return; | ||
} | ||
], (error) => { | ||
if (error) { | ||
console.log(`${chalk.red('\n\n🚩 There was an error preparing the subgraph 🚩')} \n\n`) | ||
console.error(`${error}`) | ||
return | ||
} | ||
return | ||
}); | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.