From 2d53ee717a14a27d157da14a71e8209e63cfe9fd Mon Sep 17 00:00:00 2001 From: nikdementev Date: Mon, 14 Jun 2021 15:58:57 +0300 Subject: [PATCH] feat: generated index ts --- .gitignore | 1 - mustache/templates/instance/contracts.js | 2 +- mustache/templates/instance/create-yaml.js | 9 +- src/contractsToInstances.ts | 25 ++-- src/mapping-instance.ts | 2 +- subgraphs/tornado-subgraph-bsc.yaml | 138 +++++++++++++++++++++ subgraphs/tornado-subgraph-matic.yaml | 69 +++++++++++ 7 files changed, 232 insertions(+), 14 deletions(-) create mode 100644 subgraphs/tornado-subgraph-bsc.yaml create mode 100644 subgraphs/tornado-subgraph-matic.yaml diff --git a/.gitignore b/.gitignore index de04d7f..6d810a0 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,3 @@ build generated .DS_Store -subgraphs diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index 62e3db6..3c3f086 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -38,7 +38,7 @@ const contracts = [ currency: 'matic', name: 'Instance', address: '0x992A81FA34aa6ecD9520F39f858abc51fee6994a', - }, + }, ]; module.exports = contracts; diff --git a/mustache/templates/instance/create-yaml.js b/mustache/templates/instance/create-yaml.js index 2cab543..09a79af 100644 --- a/mustache/templates/instance/create-yaml.js +++ b/mustache/templates/instance/create-yaml.js @@ -36,17 +36,24 @@ module.exports = { const space = '\xa0'; const doubleSpace = space + space; let contractsToInstancesContent = `${readOnlyComment}export let contractsToInstances = new Map();${newLine}`; + let reExportContent = ''; - Contracts.forEach(({ address, name, amount, currency }) => { + Contracts.forEach(({ address, name, network, amount, currency }) => { if (address != null) { contractsToInstancesContent += `contractsToInstances.set("${address.toLowerCase()}",${space}//${space}${name}-${currency}-${amount}${newLine}${doubleSpace}"${currency}${'-'}${amount}"${newLine});${newLine}`; } + if (network === env && reExportContent === '') { + reExportContent += `${readOnlyComment}${newLine}export * from "./${name}-${amount}-${currency}/Instance";${newLine}`; + } }); contractsToInstancesContent += readOnlyComment; const targetFile = path.join(__dirname, '../../../src/', 'contractsToInstances.ts'); fs.writeFileSync(targetFile, contractsToInstancesContent, 'utf8'); + const targetIndexFile = path.join(__dirname, '../../../generated/', 'index.ts'); + fs.writeFileSync(targetIndexFile, reExportContent, 'utf8'); + return Contracts.map(({ prod, name, amount, currency, network, address }) => { const startBlocks = { prod }; if (network === env) { diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index f8a4487..01ad6e4 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -1,18 +1,23 @@ // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. export let contractsToInstances = new Map(); -contractsToInstances.set("0x84443cfd09a48af6ef360c6976c5392ac5023a1f", // Instance-bnb-0.1 -  "bnb-0.1" +contractsToInstances.set( + '0x84443cfd09a48af6ef360c6976c5392ac5023a1f', // Instance-bnb-0.1 + 'bnb-0.1', ); -contractsToInstances.set("0xd47438c816c9e7f2e2888e060936a499af9582b3", // Instance-bnb-1 -  "bnb-1" +contractsToInstances.set( + '0xd47438c816c9e7f2e2888e060936a499af9582b3', // Instance-bnb-1 + 'bnb-1', ); -contractsToInstances.set("0x330bdfade01ee9bf63c209ee33102dd334618e0a", // Instance-bnb-10 -  "bnb-10" +contractsToInstances.set( + '0x330bdfade01ee9bf63c209ee33102dd334618e0a', // Instance-bnb-10 + 'bnb-10', ); -contractsToInstances.set("0x1e34a77868e19a6647b1f2f47b51ed72dede95dd", // Instance-bnb-100 -  "bnb-100" +contractsToInstances.set( + '0x1e34a77868e19a6647b1f2f47b51ed72dede95dd', // Instance-bnb-100 + 'bnb-100', ); -contractsToInstances.set("0x992a81fa34aa6ecd9520f39f858abc51fee6994a", // Instance-matic-0.1 -  "matic-0.1" +contractsToInstances.set( + '0x992a81fa34aa6ecd9520f39f858abc51fee6994a', // Instance-matic-0.1 + 'matic-0.1', ); // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. diff --git a/src/mapping-instance.ts b/src/mapping-instance.ts index 82a1454..36912f8 100644 --- a/src/mapping-instance.ts +++ b/src/mapping-instance.ts @@ -1,4 +1,4 @@ -import { Withdrawal, Deposit } from '../generated/Instance-1-bnb/Instance'; +import { Withdrawal, Deposit } from '../generated'; import { Withdrawal as WithdrawalEntity, Deposit as DepositEntity } from '../generated/schema'; import { contractsToInstances } from './contractsToInstances'; diff --git a/subgraphs/tornado-subgraph-bsc.yaml b/subgraphs/tornado-subgraph-bsc.yaml new file mode 100644 index 0000000..6117c6f --- /dev/null +++ b/subgraphs/tornado-subgraph-bsc.yaml @@ -0,0 +1,138 @@ + specVersion: 0.0.2 + description: Proxy + repository: https://github.com/tornadocash/tornado-subgraph + schema: + file: ../schema.graphql + dataSources: + - kind: ethereum/contract + name: Echoer + network: bsc + source: + address: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4" + abi: Echoer + startBlock: 8159269 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-echo-account.ts + entities: + - NoteAccount + abis: + - name: Echoer + file: ../abis/Echoer.json + eventHandlers: + - event: Echo(indexed address,bytes) + handler: handleEcho + - kind: ethereum/contract + name: Instance-0.1-bnb + network: bsc + source: + address: "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F" + abi: Instance + startBlock: 8159279 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-instance.ts + entities: + - Deposit + - Withdrawal + abis: + - name: Instance + file: ../abis/Instance.json + eventHandlers: + - event: Deposit(indexed bytes32,uint32,uint256) + handler: handleDeposit + - event: Withdrawal(address,bytes32,indexed address,uint256) + handler: handleWithdrawal + - kind: ethereum/contract + name: Instance-1-bnb + network: bsc + source: + address: "0xd47438C816c9E7f2E2888E060936a499Af9582b3" + abi: Instance + startBlock: 8159286 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-instance.ts + entities: + - Deposit + - Withdrawal + abis: + - name: Instance + file: ../abis/Instance.json + eventHandlers: + - event: Deposit(indexed bytes32,uint32,uint256) + handler: handleDeposit + - event: Withdrawal(address,bytes32,indexed address,uint256) + handler: handleWithdrawal + - kind: ethereum/contract + name: Instance-10-bnb + network: bsc + source: + address: "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a" + abi: Instance + startBlock: 8159290 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-instance.ts + entities: + - Deposit + - Withdrawal + abis: + - name: Instance + file: ../abis/Instance.json + eventHandlers: + - event: Deposit(indexed bytes32,uint32,uint256) + handler: handleDeposit + - event: Withdrawal(address,bytes32,indexed address,uint256) + handler: handleWithdrawal + - kind: ethereum/contract + name: Instance-100-bnb + network: bsc + source: + address: "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + abi: Instance + startBlock: 8159296 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-instance.ts + entities: + - Deposit + - Withdrawal + abis: + - name: Instance + file: ../abis/Instance.json + eventHandlers: + - event: Deposit(indexed bytes32,uint32,uint256) + handler: handleDeposit + - event: Withdrawal(address,bytes32,indexed address,uint256) + handler: handleWithdrawal + - kind: ethereum/contract + name: Proxy + network: bsc + source: + address: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + abi: Proxy + startBlock: 8158799 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-encrypted-note.ts + entities: + - EncryptedNote + abis: + - name: Proxy + file: ../abis/Proxy.json + eventHandlers: + - event: EncryptedNote(indexed address,bytes) + handler: handleEncryptedNote diff --git a/subgraphs/tornado-subgraph-matic.yaml b/subgraphs/tornado-subgraph-matic.yaml new file mode 100644 index 0000000..65615f7 --- /dev/null +++ b/subgraphs/tornado-subgraph-matic.yaml @@ -0,0 +1,69 @@ + specVersion: 0.0.2 + description: Proxy + repository: https://github.com/tornadocash/tornado-subgraph + schema: + file: ../schema.graphql + dataSources: + - kind: ethereum/contract + name: Echoer + network: matic + source: + address: "0x88Fb545DC03438b9FFb958361b7F3CfA6ce1B9c5" + abi: Echoer + startBlock: 15586935 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-echo-account.ts + entities: + - NoteAccount + abis: + - name: Echoer + file: ../abis/Echoer.json + eventHandlers: + - event: Echo(indexed address,bytes) + handler: handleEcho + - kind: ethereum/contract + name: Instance-0.1-matic + network: matic + source: + address: "0x992A81FA34aa6ecD9520F39f858abc51fee6994a" + abi: Instance + startBlock: 15586940 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-instance.ts + entities: + - Deposit + - Withdrawal + abis: + - name: Instance + file: ../abis/Instance.json + eventHandlers: + - event: Deposit(indexed bytes32,uint32,uint256) + handler: handleDeposit + - event: Withdrawal(address,bytes32,indexed address,uint256) + handler: handleWithdrawal + - kind: ethereum/contract + name: Proxy + network: matic + source: + address: "0xDC16d16341A62c60E7C9889F9d1FcE4cde57a90F" + abi: Proxy + startBlock: 15586930 + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + file: ../src/mapping-encrypted-note.ts + entities: + - EncryptedNote + abis: + - name: Proxy + file: ../abis/Proxy.json + eventHandlers: + - event: EncryptedNote(indexed address,bytes) + handler: handleEncryptedNote