feat: select network from env

This commit is contained in:
nikdementev 2021-06-09 16:43:04 +03:00 committed by 0xZick 地方分権化
parent 7328da948f
commit 6342f32974
5 changed files with 11 additions and 9 deletions

View File

@ -12,8 +12,8 @@ program
) )
.option( .option(
'-e, --env <value>', '-e, --env <value>',
'defaults to "prod" and uses the prod start blocks config. Must set to "test" to use test start blocks config', 'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config',
'prod', 'bsc',
) )
.action(async ({ subgraph, env }) => { .action(async ({ subgraph, env }) => {
const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js'); const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js');

View File

@ -4,7 +4,6 @@ module.exports = {
specVersion: '0.0.2', specVersion: '0.0.2',
repository: 'https://github.com/Synthetixio/synthetix-subgraph', repository: 'https://github.com/Synthetixio/synthetix-subgraph',
dataSourceKind: 'ethereum/contract', dataSourceKind: 'ethereum/contract',
network: 'mainnet',
mapping: { mapping: {
kind: 'ethereum/events', kind: 'ethereum/events',
version: '0.0.4', version: '0.0.4',

View File

@ -7,6 +7,7 @@ const contracts = [
{ {
prod: 7942402, prod: 7942402,
name: 'Proxy', name: 'Proxy',
network: 'bsc',
address: "'0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7'", address: "'0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7'",
}, },
] ]

View File

@ -3,8 +3,9 @@ const Contracts = require('./contracts');
module.exports = { module.exports = {
createYaml: (env) => { createYaml: (env) => {
const createProxyBlock = ({ name, address }) => ({ const createProxyBlock = ({ name, network, address }) => ({
name, name,
network,
mappingFile: '../src/mapping-encrypted-note.ts', mappingFile: '../src/mapping-encrypted-note.ts',
abi: 'Proxy', abi: 'Proxy',
startBlock: 7941563, startBlock: 7941563,
@ -24,10 +25,11 @@ module.exports = {
], ],
}); });
return Contracts.map(({ prod, name, address }) => { return Contracts.map(({ prod, name, network, address }) => {
const startBlocks = { prod }; const startBlocks = { prod };
if (network === env) {
return createProxyBlock({ name, startBlocks, address }) return createProxyBlock({ name, startBlocks, network, address })
}); }
}).filter(e => e !== undefined);
}, },
}; };

View File

@ -4,7 +4,7 @@
"scripts": { "scripts": {
"codegen": "graph codegen", "codegen": "graph codegen",
"build": "graph build", "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" "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ tornadocash/bsc-tornado-subgraph"
}, },
"dependencies": { "dependencies": {