From 6d438e15158dd3d8b2a7ceabeab8c7a0190949d2 Mon Sep 17 00:00:00 2001 From: nikdementev Date: Mon, 14 Jun 2021 18:30:44 +0300 Subject: [PATCH] feat: mainnet sub graph --- .github/workflows/notification.yml | 25 ++++ mustache/templates/echoer/contracts.js | 6 + mustache/templates/instance/contracts.js | 32 ++++++ mustache/templates/proxy/contracts.js | 6 + package.json | 9 +- src/contractsToInstances.ts | 16 +++ subgraphs/tornado-subgraph-mainnet.yaml | 138 +++++++++++++++++++++++ 7 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/notification.yml create mode 100644 subgraphs/tornado-subgraph-mainnet.yaml diff --git a/.github/workflows/notification.yml b/.github/workflows/notification.yml new file mode 100644 index 0000000..1a68d4e --- /dev/null +++ b/.github/workflows/notification.yml @@ -0,0 +1,25 @@ +name: Commit notification + +on: + push: + branches: ['*'] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set short SHA + id: vars + run: echo "::set-output name=sha_short::$(echo ${GITHUB_SHA:0:7})" + - name: Telegram Notification + uses: appleboy/telegram-action@0.0.7 + with: + message: 'A new commit [${{ steps.vars.outputs.sha_short }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) to [${{ github.repository }}](https://github.com/${{ github.repository }}) by [@${{ github.event.pusher.name }}](https://github.com/${{ github.event.pusher.name }})' + format: markdown + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} +# TODO +# 1. a separate file for this thing +# 2. on push, pull_request, issue, comment, etc +# 3. add event type to the message +# 4. list of commits in message if many pushed diff --git a/mustache/templates/echoer/contracts.js b/mustache/templates/echoer/contracts.js index de3b00d..59e6efb 100644 --- a/mustache/templates/echoer/contracts.js +++ b/mustache/templates/echoer/contracts.js @@ -11,6 +11,12 @@ const contracts = [ name: 'Echoer', address: '0x88Fb545DC03438b9FFb958361b7F3CfA6ce1B9c5', }, + { + prod: 11362619, + network: 'mainnet', + name: 'Echoer', + address: '0x756C4628E57F7e7f8a459EC2752968360Cf4D1AA', + }, ]; module.exports = contracts; diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index 3c3f086..6843ba9 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -39,6 +39,38 @@ const contracts = [ name: 'Instance', address: '0x992A81FA34aa6ecD9520F39f858abc51fee6994a', }, + { + prod: 9116966, + amount: '0.1', + network: 'mainnet', + currency: 'eth', + name: 'Instance', + address: '0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc', + }, + { + prod: 9116966, + amount: '1', + network: 'mainnet', + currency: 'eth', + name: 'Instance', + address: '0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936', + }, + { + prod: 9116966, + amount: '10', + network: 'mainnet', + currency: 'eth', + name: 'Instance', + address: '0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF', + }, + { + prod: 9116966, + amount: '100', + network: 'mainnet', + currency: 'eth', + name: 'Instance', + address: '0xA160cdAB225685dA1d56aa342Ad8841c3b53f291', + }, ]; module.exports = contracts; diff --git a/mustache/templates/proxy/contracts.js b/mustache/templates/proxy/contracts.js index ae09fa4..57f24ab 100644 --- a/mustache/templates/proxy/contracts.js +++ b/mustache/templates/proxy/contracts.js @@ -11,6 +11,12 @@ const contracts = [ network: 'matic', address: '0xDC16d16341A62c60E7C9889F9d1FcE4cde57a90F', }, + { + prod: 11474713, + name: 'Proxy', + network: 'mainnet', + address: '0x722122dF12D4e14e13Ac3b6895a86e84145b6967', + }, ]; module.exports = contracts; diff --git a/package.json b/package.json index 6c75bc0..cd92a48 100644 --- a/package.json +++ b/package.json @@ -5,17 +5,22 @@ "lint": "eslint .", "generate-bsc": "yarn codegen:tornado-bsc && yarn build:tornado-bsc", "generate-matic": "yarn codegen:tornado-matic && yarn build:tornado-matic", + "generate-mainnet": "yarn codegen:tornado-mainnet && yarn build:tornado-mainnet", "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", + "yaml:tornado-mainnet": "node ./create-yaml-file create-yaml -e mainnet | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-mainnet.yaml", "codegen": "graph codegen", "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", + "codegen:tornado-mainnet": "yarn yaml:tornado-mainnet && yarn codegen -- subgraphs/tornado-subgraph-mainnet.yaml", "build": "graph build", "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", + "build:tornado-mainnet": "graph build subgraphs/tornado-subgraph-mainnet.yaml", + "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ --access-token 667f58696f044059a476ed2c4ae632f3", "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" + "deploy:tornado-matic": "yarn deploy -- tornadocash/matic-tornado-subgraph subgraphs/tornado-subgraph-matic.yaml", + "deploy:tornado-mainnet": "yarn deploy -- 0xzick/bsc-sub-graph subgraphs/tornado-subgraph-mainnet.yaml" }, "dependencies": { "@graphprotocol/graph-cli": "0.20.0", diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index 01ad6e4..50a6f20 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -20,4 +20,20 @@ contractsToInstances.set( '0x992a81fa34aa6ecd9520f39f858abc51fee6994a', // Instance-matic-0.1 'matic-0.1', ); +contractsToInstances.set( + '0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc', // Instance-eth-0.1 + 'eth-0.1', +); +contractsToInstances.set( + '0x47ce0c6ed5b0ce3d3a51fdb1c52dc66a7c3c2936', // Instance-eth-1 + 'eth-1', +); +contractsToInstances.set( + '0x910cbd523d972eb0a6f4cae4618ad62622b39dbf', // Instance-eth-10 + 'eth-10', +); +contractsToInstances.set( + '0xa160cdab225685da1d56aa342ad8841c3b53f291', // Instance-eth-100 + 'eth-100', +); // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. diff --git a/subgraphs/tornado-subgraph-mainnet.yaml b/subgraphs/tornado-subgraph-mainnet.yaml new file mode 100644 index 0000000..fd2f51e --- /dev/null +++ b/subgraphs/tornado-subgraph-mainnet.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: mainnet + source: + address: "0x756C4628E57F7e7f8a459EC2752968360Cf4D1AA" + abi: Echoer + startBlock: 11362619 + 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-eth + network: mainnet + source: + address: "0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc" + abi: Instance + startBlock: 9116966 + 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-eth + network: mainnet + source: + address: "0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936" + abi: Instance + startBlock: 9116966 + 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-eth + network: mainnet + source: + address: "0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF" + abi: Instance + startBlock: 9116966 + 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-eth + network: mainnet + source: + address: "0xA160cdAB225685dA1d56aa342Ad8841c3b53f291" + abi: Instance + startBlock: 9116966 + 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: mainnet + source: + address: "0x722122dF12D4e14e13Ac3b6895a86e84145b6967" + abi: Proxy + startBlock: 11474713 + 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