From 6342f32974b6ff68449dc4147622e4bde8c43121 Mon Sep 17 00:00:00 2001 From: nikdementev Date: Wed, 9 Jun 2021 16:43:04 +0300 Subject: [PATCH] feat: select network from env --- create-yaml-file.js | 4 ++-- mustache/templates/base/index.js | 1 - mustache/templates/proxy/contracts.js | 1 + mustache/templates/proxy/create-yaml.js | 12 +++++++----- package.json | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/create-yaml-file.js b/create-yaml-file.js index 73e2738..2614714 100644 --- a/create-yaml-file.js +++ b/create-yaml-file.js @@ -12,8 +12,8 @@ program ) .option( '-e, --env ', - 'defaults to "prod" and uses the prod start blocks config. Must set to "test" to use test start blocks config', - 'prod', + 'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config', + 'bsc', ) .action(async ({ subgraph, env }) => { const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js'); diff --git a/mustache/templates/base/index.js b/mustache/templates/base/index.js index 252c832..0f0197d 100644 --- a/mustache/templates/base/index.js +++ b/mustache/templates/base/index.js @@ -4,7 +4,6 @@ module.exports = { specVersion: '0.0.2', repository: 'https://github.com/Synthetixio/synthetix-subgraph', dataSourceKind: 'ethereum/contract', - network: 'mainnet', mapping: { kind: 'ethereum/events', version: '0.0.4', diff --git a/mustache/templates/proxy/contracts.js b/mustache/templates/proxy/contracts.js index 1af1225..6332430 100644 --- a/mustache/templates/proxy/contracts.js +++ b/mustache/templates/proxy/contracts.js @@ -7,6 +7,7 @@ const contracts = [ { prod: 7942402, name: 'Proxy', + network: 'bsc', address: "'0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7'", }, ] diff --git a/mustache/templates/proxy/create-yaml.js b/mustache/templates/proxy/create-yaml.js index 9452b58..6f96c89 100644 --- a/mustache/templates/proxy/create-yaml.js +++ b/mustache/templates/proxy/create-yaml.js @@ -3,8 +3,9 @@ const Contracts = require('./contracts'); module.exports = { createYaml: (env) => { - const createProxyBlock = ({ name, address }) => ({ + const createProxyBlock = ({ name, network, address }) => ({ name, + network, mappingFile: '../src/mapping-encrypted-note.ts', abi: 'Proxy', startBlock: 7941563, @@ -24,10 +25,11 @@ module.exports = { ], }); - return Contracts.map(({ prod, name, address }) => { + return Contracts.map(({ prod, name, network, address }) => { const startBlocks = { prod }; - - return createProxyBlock({ name, startBlocks, address }) - }); + if (network === env) { + return createProxyBlock({ name, startBlocks, network, address }) + } + }).filter(e => e !== undefined); }, }; diff --git a/package.json b/package.json index 1702f71..96385e3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "codegen": "graph codegen", "build": "graph build", - "yaml:proxy": "node ./create-yaml-file create-yaml -s proxy -e prod | mustache - mustache/yaml.mustache > subgraphs/proxy-tornado-subgraph.yaml", + "yaml:proxy": "node ./create-yaml-file create-yaml -s proxy -e bsc | mustache - mustache/yaml.mustache > subgraphs/proxy-tornado-subgraph.yaml", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ tornadocash/bsc-tornado-subgraph" }, "dependencies": {