From fe4f037db746bf7f63b97d91e220c9e6d1349758 Mon Sep 17 00:00:00 2001 From: Danil Kovtonyuk Date: Mon, 14 Jun 2021 15:33:59 +0300 Subject: [PATCH] feat: add polygon --- .gitignore | 1 + mustache/templates/echoer/contracts.js | 6 + mustache/templates/instance/contracts.js | 8 ++ mustache/templates/proxy/contracts.js | 6 + mustache/templates/proxy/create-yaml.js | 4 +- package.json | 15 ++- src/contractsToInstances.ts | 23 ++-- subgraphs/tornado-subgraph.yaml | 138 ----------------------- 8 files changed, 44 insertions(+), 157 deletions(-) delete mode 100644 subgraphs/tornado-subgraph.yaml diff --git a/.gitignore b/.gitignore index 6d810a0..de04d7f 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,4 @@ build generated .DS_Store +subgraphs diff --git a/mustache/templates/echoer/contracts.js b/mustache/templates/echoer/contracts.js index eb0689b..de3b00d 100644 --- a/mustache/templates/echoer/contracts.js +++ b/mustache/templates/echoer/contracts.js @@ -5,6 +5,12 @@ const contracts = [ name: 'Echoer', address: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4', }, + { + prod: 15586935, + network: 'matic', + name: 'Echoer', + address: '0x88Fb545DC03438b9FFb958361b7F3CfA6ce1B9c5', + }, ]; module.exports = contracts; diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index d88831a..62e3db6 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -31,6 +31,14 @@ const contracts = [ name: 'Instance', address: '0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD', }, + { + prod: 15586940, + amount: '0.1', + network: 'matic', + currency: 'matic', + name: 'Instance', + address: '0x992A81FA34aa6ecD9520F39f858abc51fee6994a', + }, ]; module.exports = contracts; diff --git a/mustache/templates/proxy/contracts.js b/mustache/templates/proxy/contracts.js index 2d5db9a..ae09fa4 100644 --- a/mustache/templates/proxy/contracts.js +++ b/mustache/templates/proxy/contracts.js @@ -5,6 +5,12 @@ const contracts = [ network: 'bsc', address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', }, + { + prod: 15586930, + name: 'Proxy', + network: 'matic', + address: '0xDC16d16341A62c60E7C9889F9d1FcE4cde57a90F', + }, ]; module.exports = contracts; diff --git a/mustache/templates/proxy/create-yaml.js b/mustache/templates/proxy/create-yaml.js index 79c9430..94a1f84 100644 --- a/mustache/templates/proxy/create-yaml.js +++ b/mustache/templates/proxy/create-yaml.js @@ -2,12 +2,12 @@ const Contracts = require('./contracts'); module.exports = { createYaml: (env) => { - const createProxyBlock = ({ name, network, address }) => ({ + const createProxyBlock = ({ name, network, startBlocks, address }) => ({ name, network, mappingFile: '../src/mapping-encrypted-note.ts', abi: 'Proxy', - startBlock: 7941563, + startBlock: startBlocks.prod, address: `"${address}"`, entities: ['EncryptedNote'], abis: [ diff --git a/package.json b/package.json index f0d7f0b..6c75bc0 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,19 @@ "license": "UNLICENSED", "scripts": { "lint": "eslint .", - "generate": "yarn codegen:tornado && yarn build:tornado", - "yaml:tornado": "node ./create-yaml-file create-yaml -e bsc | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph.yaml", + "generate-bsc": "yarn codegen:tornado-bsc && yarn build:tornado-bsc", + "generate-matic": "yarn codegen:tornado-matic && yarn build:tornado-matic", + "yaml:tornado-bsc": "node ./create-yaml-file create-yaml -e bsc | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-bsc.yaml", + "yaml:tornado-matic": "node ./create-yaml-file create-yaml -e matic | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-matic.yaml", "codegen": "graph codegen", - "codegen:tornado": "yarn yaml:tornado && yarn codegen -- subgraphs/tornado-subgraph.yaml", + "codegen:tornado-bsc": "yarn yaml:tornado-bsc && yarn codegen -- subgraphs/tornado-subgraph-bsc.yaml", + "codegen:tornado-matic": "yarn yaml:tornado-matic && yarn codegen -- subgraphs/tornado-subgraph-matic.yaml", "build": "graph build", - "build:tornado": "graph build subgraphs/tornado-subgraph.yaml", + "build:tornado-bsc": "graph build subgraphs/tornado-subgraph-bsc.yaml", + "build:tornado-matic": "graph build subgraphs/tornado-subgraph-matic.yaml", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ --access-token TOKEN", - "deploy:tornado": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/tornado-subgraph.yaml" + "deploy:tornado-bsc": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/tornado-subgraph-bsc.yaml", + "deploy:tornado-matic": "yarn deploy -- tornadocash/matic-tornado-subgraph subgraphs/tornado-subgraph-matic.yaml" }, "dependencies": { "@graphprotocol/graph-cli": "0.20.0", diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index 6765b4a..f8a4487 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -1,19 +1,18 @@ // 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" ); // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. diff --git a/subgraphs/tornado-subgraph.yaml b/subgraphs/tornado-subgraph.yaml deleted file mode 100644 index c7d0dca..0000000 --- a/subgraphs/tornado-subgraph.yaml +++ /dev/null @@ -1,138 +0,0 @@ - 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: 7941563 - 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