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

@ -12,8 +12,8 @@ program
)
.option(
'-e, --env <value>',
'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');

@ -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',

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

@ -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);
},
};

@ -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": {