feat: generate instance yaml

This commit is contained in:
nikdementev 2021-06-09 17:04:11 +03:00 committed by 0xZick 地方分権化
parent 6342f32974
commit 28ae284221
4 changed files with 17 additions and 11 deletions

View File

@ -7,6 +7,8 @@ const contracts = [
{
prod: 7942402,
amount: '0.1',
network: 'bsc',
currency: 'bsc',
name: 'Instance',
address: "'0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d'",
},

View File

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

View File

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

View File

@ -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<string, string>();
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.