Skip to content

Commit

Permalink
reorganise script + use template
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Jun 25, 2020
1 parent cec363d commit e4dfcfa
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ cache/
deployments/localhost_*
log*
contracts.json
subgraph.yaml
11 changes: 11 additions & 0 deletions generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require("fs-extra");
const Handlebars = require("handlebars");

const args = process.argv.slice(2);
const chainName = args[0];
const startBlock = args[1];
// # startBlock: 6367157 # erro on 0x00 string
// # startBlock: 5806610 #PoloDod (0x7b70405fba653cc8eff5afad1c5079d7da0a0247)
const template = Handlebars.compile(fs.readFileSync("./templates/subgraph.yaml").toString());
const result = template({chainName, startBlock});
fs.writeFileSync("./subgraph.yaml", result);
33 changes: 21 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@
"license": "AGPL-3.0-only",
"bin": "bin/index.js",
"scripts": {
"codegen-graph": "rm -Rf generated && graph codegen",
"build-graph": "graph build",
"externals-down": "docker-compose down -v",
"local:setup": "wait-on http-get://127.0.0.1:8000 && graph create wighawag/eip721-subgraph --node http://127.0.0.1:8020",
"codegen": "rm -Rf generated && graph codegen",
"build": "graph build",
"generate": "node 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 wighawag/eip721-subgraph --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
"local:deploy": "npm-run-all \"generate mainnet 0\" local:redeploy --",
"mainnet:redeploy": "dotenv -- cross-var graph deploy --access-token $THEGRAPH_TOKEN wighawag/eip721-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug",
"mainnet:deploy": "npm-run-all \"generate mainnet 5806610\" mainnet:redeploy --",
"rinkeby:redeploy": "dotenv -- cross-var graph deploy --access-token $THEGRAPH_TOKEN wighawag/eip721-subgraph-rinkeby --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug",
"rinkeby:deploy": "npm-run-all \"generate rinkeby 0\" rinkeby:redeploy --",
"kovan:redeploy": "dotenv -- cross-var graph deploy --access-token $THEGRAPH_TOKEN wighawag/eip721-subgraph-kovan --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug",
"kovan:deploy": "npm-run-all \"generate kovan 0\" kovan:redeploy --",
"externals:down": "docker-compose down -v",
"externals": "docker-compose up",
"shell:externals": "newshell \"npm run externals\"",
"create-local-graph": "wait-on http-get://127.0.0.1:8000 && graph create wighawag/eip721-subgraph --node http://127.0.0.1:8020",
"deploy-local-contracts": "wait-on tcp:8545 && buidler --network localhost deploy --export ./contracts.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 wighawag/eip721-subgraph --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
"deploy-local": "npm-run-all -l --parallel deploy-local-contracts deploy-local-graph",
"create-and-deploy-local": "npm-run-all -l create-local-graph deploy-local",
"setup": "npm-run-all -l externals-down --parallel shell:externals create-local-graph",
"dev": "npm-run-all -l externals-down --parallel externals create-and-deploy-local",
"shell:dev": "npm-run-all -l externals-down --parallel shell:externals create-and-deploy-local",
"deploy-graph": "dotenv -- cross-var graph deploy --access-token $THEGRAPH_TOKEN wighawag/eip721-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug",
"local:contracts": "wait-on tcp:8545 && buidler --network localhost deploy --export ./contracts.json",
"local:dev": "npm-run-all -l --parallel local:contracts local:deploy",
"local:setup:deploy": "npm-run-all -l local:setup local:dev",
"setup": "npm-run-all -l externals:down --parallel shell:externals local:setup",
"dev": "npm-run-all -l externals:down --parallel externals local:setup:deploy",
"shell:dev": "npm-run-all -l externals:down --parallel shell:externals local:setup:deploy",
"run:local": "cross-env BUIDLER_NETWORK=localhost node"
},
"devDependencies": {
Expand All @@ -30,6 +37,8 @@
"dotenv": "^8.2.0",
"dotenv-cli": "^3.1.0",
"ethers": "^5.0.0-beta.180",
"fs-extra": "^9.0.1",
"handlebars": "^4.7.6",
"newshell": "^0.1.0",
"npm-run-all": "^4.1.5",
"wait-on": "^4.0.1"
Expand Down
30 changes: 0 additions & 30 deletions subgraph.yaml

This file was deleted.

60 changes: 58 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ asynckit@^0.4.0:
resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=

at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==

aws-sign2@~0.7.0:
version "0.7.0"
resolved "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
Expand Down Expand Up @@ -3080,6 +3085,16 @@ fs-extra@^8.1.0:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"
integrity sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^1.0.0"

fs-jetpack@^2.2.2:
version "2.2.3"
resolved "https://registry.yarnpkg.com/fs-jetpack/-/fs-jetpack-2.2.3.tgz#75113dcf1e4a9c7c7275732f2b7305656df114c8"
Expand Down Expand Up @@ -3296,6 +3311,18 @@ [email protected]:
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==

handlebars@^4.7.6:
version "4.7.6"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
dependencies:
minimist "^1.2.5"
neo-async "^2.6.0"
source-map "^0.6.1"
wordwrap "^1.0.0"
optionalDependencies:
uglify-js "^3.1.4"

har-schema@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"
Expand Down Expand Up @@ -3989,6 +4016,15 @@ jsonfile@^4.0.0:
optionalDependencies:
graceful-fs "^4.1.6"

jsonfile@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.0.1.tgz#98966cba214378c8c84b82e085907b40bf614179"
integrity sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==
dependencies:
universalify "^1.0.0"
optionalDependencies:
graceful-fs "^4.1.6"

jsonparse@^1.2.0:
version "1.3.1"
resolved "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
Expand Down Expand Up @@ -4540,7 +4576,7 @@ [email protected]:
resolved "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=

minimist@^1.1.3:
minimist@^1.1.3, minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
Expand Down Expand Up @@ -4711,6 +4747,11 @@ napi-build-utils@^1.0.1:
split2 "^3.1.0"
through2 "^3.0.0"

neo-async@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==

newshell@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/newshell/-/newshell-0.1.0.tgz#5c5e2669a75a619ff0eac1abc73f5958da9a9b28"
Expand Down Expand Up @@ -5877,7 +5918,7 @@ source-map@^0.5.6, source-map@^0.5.7:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=

source-map@^0.6.0:
source-map@^0.6.0, source-map@^0.6.1:
version "0.6.1"
resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
Expand Down Expand Up @@ -6354,6 +6395,11 @@ typeforce@^1.11.5:
resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc"
integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==

uglify-js@^3.1.4:
version "3.10.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.10.0.tgz#397a7e6e31ce820bfd1cb55b804ee140c587a9e7"
integrity sha512-Esj5HG5WAyrLIdYU74Z3JdG2PxdIusvj6IWHMtlyESxc7kcDz7zYlYjpnSokn1UbpV0d/QX9fan7gkCNd/9BQA==

unbzip2-stream@^1.0.9:
version "1.4.0"
resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.4.0.tgz#097ca7b18b5b71e6c8bc8e514a0f1884a12d6eb1"
Expand All @@ -6379,6 +6425,11 @@ universalify@^0.1.0:
resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==

universalify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
Expand Down Expand Up @@ -6515,6 +6566,11 @@ wif@^2.0.6:
dependencies:
bs58check "<3.0.0"

wordwrap@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
Expand Down

0 comments on commit e4dfcfa

Please sign in to comment.