From 28ae284221f9d271a421b1cbfb12494e6f3d2e39 Mon Sep 17 00:00:00 2001 From: nikdementev Date: Wed, 9 Jun 2021 17:04:11 +0300 Subject: [PATCH] feat: generate instance yaml --- mustache/templates/instance/contracts.js | 2 ++ mustache/templates/instance/create-yaml.js | 17 +++++++++-------- package.json | 1 + src/contractsToInstances.ts | 8 +++++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index 399d7bc..88cdb21 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -7,6 +7,8 @@ const contracts = [ { prod: 7942402, amount: '0.1', + network: 'bsc', + currency: 'bsc', name: 'Instance', address: "'0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d'", }, diff --git a/mustache/templates/instance/create-yaml.js b/mustache/templates/instance/create-yaml.js index 9900f2d..a4c7a46 100644 --- a/mustache/templates/instance/create-yaml.js +++ b/mustache/templates/instance/create-yaml.js @@ -2,7 +2,6 @@ const fs = require('fs'); const path = require('path'); const Contracts = require('./contracts'); -const { createStartBlock } = require('../common'); module.exports = { createYaml: (env) => { @@ -10,13 +9,14 @@ module.exports = { const createInstanceBlock = ({ name, startBlocks, address }) => ({ name, mappingFile: '../src/mapping-instance.ts', - startBlock: createStartBlock(startBlocks, env), + startBlock: startBlocks.prod, address, + abi: 'Instance', entities: ['Deposit', 'Withdrawal'], abis: [ { name: 'Instance', - file: './abis/Instance.json' + file: '../abis/Instance.json' } ], events: [ @@ -47,10 +47,11 @@ module.exports = { const targetFile = path.join(__dirname, '../../../src/', 'contractsToInstances.ts'); fs.writeFileSync(targetFile, contractsToInstancesContent, 'utf8'); - return Contracts.map(({ type, prod, test, name, address }) => { - const startBlocks = { prod, test }; - - return createInstanceBlock({ name, startBlocks, address }) - }); + return Contracts.map(({ prod, name, network, address }) => { + const startBlocks = { prod }; + if (network === env) { + return createInstanceBlock({ name, startBlocks, network, address }) + } + }).filter(e => e !== undefined); }, }; diff --git a/package.json b/package.json index 96385e3..d51170c 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "codegen": "graph codegen", "build": "graph build", "yaml:proxy": "node ./create-yaml-file create-yaml -s proxy -e bsc | mustache - mustache/yaml.mustache > subgraphs/proxy-tornado-subgraph.yaml", + "yaml:instance": "node ./create-yaml-file create-yaml -s instance -e bsc | mustache - mustache/yaml.mustache > subgraphs/instance-tornado-subgraph.yaml", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ tornadocash/bsc-tornado-subgraph" }, "dependencies": { diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index 2109076..f34b8b3 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -1,4 +1,6 @@ - +// this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. export let contractsToInstances = new Map(); - -contractsToInstances.set('0x0ce22770451a8acad1220d9d1678656b4fae4a1d', 'bnb-0.1'); +contractsToInstances.set('0x0ce22770451a8acad1220d9d1678656b4fae4a1d', // Instance-bsc-0.1 +  0.1-bsc +); +// this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js.