Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
59 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
{ | ||
"name": "sandbox-subgraph", | ||
"version": "0.1.0", | ||
"scripts": { | ||
"create-local-graph": "wait-on http-get://127.0.0.1:8000 && graph create pixowl/the-sandbox --node http://127.0.0.1:8020", | ||
"codegen-graph": "rm -Rf generated && graph codegen", | ||
"build-graph": "graph build", | ||
"generate-local-abis": "node scripts/generateABIs.js ./dev_contractsInfo.json", | ||
"generate-local-subgraph-yml": "node scripts/generateYml.js ./contractsInfo.json", | ||
"deploy-local-graph": "graph codegen && wait-on http://127.0.0.1:5001/api/v0/version http-get://127.0.0.1:8000 && graph deploy pixowl/the-sandbox --ipfs http://localhost:5001 --node http://127.0.0.1:8020", | ||
"generate-abis": "node scripts/generateABIs.js ./contractsInfo.json", | ||
"generate-subgraph-yml": "node scripts/generateYml.js ./contractsInfo.json", | ||
"deploy-graph": "dotenv -- cross-var graph deploy --access-token $THEGRAPH_TOKEN pixowl/the-sandbox --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug", | ||
"deploy": "run-s generate-abis generate-subgraph-yml deploy-graph" | ||
}, | ||
"devDependencies": { | ||
"@graphprotocol/graph-cli": "^0.16.0", | ||
"@graphprotocol/graph-ts": "^0.16.0", | ||
"cross-var": "^1.1.0", | ||
"dotenv-cli": "^3.1.0", | ||
"fs-extra": "^9.0.0", | ||
"handlebars": "^4.7.6", | ||
"npm-run-all": "^4.1.5", | ||
"wait-on": "^4.0.1" | ||
"wait-on": "^4.0.1", | ||
"npm-run-all": "^4.1.5" | ||
}, | ||
"scripts": { | ||
"local:setup": "wait-on http-get://127.0.0.1:8000 && graph create pixowl/the-sandbox --node http://127.0.0.1:8020", | ||
"codegen": "rm -Rf generated && graph codegen", | ||
"build": "graph build", | ||
"generate": "node scripts/generate.js", | ||
"local:redeploy": "graph codegen && wait-on http://127.0.0.1:5001/api/v0/version http-get://127.0.0.1:8000 && graph deploy pixowl/the-sandbox --ipfs http://localhost:5001 --node http://127.0.0.1:8020", | ||
"local:deploy": "npm-run-all \"generate -- {1} {2}\" local:redeploy --", | ||
"mainnet:deploy": "dotenv -- cross-var graph deploy --access-token $THEGRAPH_TOKEN pixowl/the-sandbox --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug" | ||
} | ||
} |
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,45 @@ | ||
const fs = require("fs-extra"); | ||
const path = require("path"); | ||
const Handlebars = require("handlebars"); | ||
|
||
const args = process.argv.slice(2); | ||
const pathArg = args[0]; | ||
const chainName = args[1]; | ||
|
||
if (!pathArg) { | ||
console.error(`please provide the path to contracts info, either a directory of deployemnt or a single export file`); | ||
} | ||
if (!fs.existsSync(pathArg)) { | ||
console.error(`file ${pathArg} doest not exits`); | ||
} | ||
|
||
const stat = fs.statSync(pathArg); | ||
let contractInfo; | ||
if (stat.isDirectory()) { | ||
contractsInfo = { | ||
contracts: { | ||
|
||
}, | ||
chainName | ||
}; | ||
const files = fs.readdirSync(pathArg, {withFileTypes: true}); | ||
for (const file of files) { | ||
if (!file.isDirectory() && file.name.substr(file.name.length-5) === ".json") { | ||
const contractName = file.name.substr(0, file.name.length-5); | ||
contractsInfo.contracts[contractName] = JSON.parse(fs.readFileSync(path.join(pathArg, file.name)).toString()); | ||
} | ||
} | ||
} else { | ||
contractsInfo = JSON.parse(fs.readFileSync(pathArg).toString()); | ||
} | ||
|
||
const contracts = contractsInfo.contracts; | ||
fs.emptyDirSync("./abis"); | ||
for (const contractName of Object.keys(contracts)) { | ||
const contractInfo = contracts[contractName]; | ||
fs.writeFileSync(path.join("abis", contractName + ".json"), JSON.stringify(contractInfo.abi)); | ||
} | ||
|
||
const template = Handlebars.compile(fs.readFileSync("./templates/subgraph.yaml").toString()); | ||
const result = template(contractsInfo); | ||
fs.writeFileSync("./subgraph.yaml", result); |
This file was deleted.
Oops, something went wrong.
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