From 6d402f57df771052e6c31e0f99b7aee9e7418273 Mon Sep 17 00:00:00 2001 From: Danil Kovtonyuk Date: Mon, 21 Feb 2022 17:01:37 +1000 Subject: [PATCH] feat: add Optimism --- mustache/templates/echoer/contracts.js | 6 + mustache/templates/instance/contracts.js | 33 ++++++ mustache/templates/proxy/contracts.js | 6 + package.json | 7 +- src/contractsToInstances.ts | 12 ++ subgraphs/tornado-subgraph-optimism.yaml | 138 +++++++++++++++++++++++ 6 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 subgraphs/tornado-subgraph-optimism.yaml diff --git a/mustache/templates/echoer/contracts.js b/mustache/templates/echoer/contracts.js index 6364693..697a5e0 100644 --- a/mustache/templates/echoer/contracts.js +++ b/mustache/templates/echoer/contracts.js @@ -41,6 +41,12 @@ const contracts = [ name: 'Echoer', address: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4', }, + { + prod: 2243694, + network: 'optimism', + name: 'Echoer', + address: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4', + }, ]; module.exports = contracts; diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index b7049a1..b15aae3 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -4,6 +4,7 @@ const deployedBlocks = { matic: 16257962, goerli: 3781595, mainnet: 9116966, + optimism: 2243689, arbitrum: 3430648, avalanche: 4429818, }; @@ -465,6 +466,38 @@ const contracts = [ name: 'Instance', address: '0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD', }, + { + prod: deployedBlocks.optimism, + amount: '0.1', + network: 'optimism', + currency: 'eth', + name: 'Instance', + address: '0x84443CFd09A48AF6eF360C6976C5392aC5023a1F', + }, + { + prod: deployedBlocks.optimism, + amount: '1', + network: 'optimism', + currency: 'eth', + name: 'Instance', + address: '0xd47438C816c9E7f2E2888E060936a499Af9582b3', + }, + { + prod: deployedBlocks.optimism, + amount: '10', + network: 'optimism', + currency: 'eth', + name: 'Instance', + address: '0x330bdFADE01eE9bF63C209Ee33102DD334618e0a', + }, + { + prod: deployedBlocks.optimism, + amount: '100', + network: 'optimism', + currency: 'eth', + name: 'Instance', + address: '0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD', + }, ]; module.exports = contracts; diff --git a/mustache/templates/proxy/contracts.js b/mustache/templates/proxy/contracts.js index df5a59f..e247a50 100644 --- a/mustache/templates/proxy/contracts.js +++ b/mustache/templates/proxy/contracts.js @@ -41,6 +41,12 @@ const contracts = [ network: 'arbitrum-one', address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', }, + { + prod: 2243689, + name: 'Proxy', + network: 'optimism', + address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', + }, ]; module.exports = contracts; diff --git a/package.json b/package.json index 386f3cd..8a4139b 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "generate-goerli": "yarn codegen:tornado-goerli && yarn build:tornado-goerli", "generate-avalanche": "yarn codegen:tornado-avalanche && yarn build:tornado-avalanche", "generate-arbitrum": "yarn codegen:tornado-arbitrum && yarn build:tornado-arbitrum", + "generate-optimism": "yarn codegen:tornado-optimism && yarn build:tornado-optimism", "yaml:tornado-bsc": "node ./create-yaml-file create-yaml -e bsc | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-bsc.yaml", "yaml:tornado-xdai": "node ./create-yaml-file create-yaml -e xdai | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-xdai.yaml", "yaml:tornado-matic": "node ./create-yaml-file create-yaml -e matic | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-matic.yaml", @@ -17,6 +18,7 @@ "yaml:tornado-goerli": "node ./create-yaml-file create-yaml -e goerli | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-goerli.yaml", "yaml:tornado-avalanche": "node ./create-yaml-file create-yaml -e avalanche | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-avalanche.yaml", "yaml:tornado-arbitrum": "node ./create-yaml-file create-yaml -e arbitrum-one | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-arbitrum.yaml", + "yaml:tornado-optimism": "node ./create-yaml-file create-yaml -e optimism | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-optimism.yaml", "codegen": "graph codegen", "codegen:tornado-bsc": "yarn yaml:tornado-bsc && yarn codegen -- subgraphs/tornado-subgraph-bsc.yaml", "codegen:tornado-xdai": "yarn yaml:tornado-xdai && yarn codegen -- subgraphs/tornado-subgraph-xdai.yaml", @@ -25,6 +27,7 @@ "codegen:tornado-goerli": "yarn yaml:tornado-goerli && yarn codegen -- subgraphs/tornado-subgraph-goerli.yaml", "codegen:tornado-avalanche": "yarn yaml:tornado-avalanche && yarn codegen -- subgraphs/tornado-subgraph-avalanche.yaml", "codegen:tornado-arbitrum": "yarn yaml:tornado-arbitrum && yarn codegen -- subgraphs/tornado-subgraph-arbitrum.yaml", + "codegen:tornado-optimism": "yarn yaml:tornado-optimism && yarn codegen -- subgraphs/tornado-subgraph-optimism.yaml", "build": "graph build", "build:tornado-bsc": "graph build subgraphs/tornado-subgraph-bsc.yaml", "build:tornado-xdai": "graph build subgraphs/tornado-subgraph-xdai.yaml", @@ -33,6 +36,7 @@ "build:tornado-goerli": "graph build subgraphs/tornado-subgraph-goerli.yaml", "build:tornado-avalanche": "graph build subgraphs/tornado-subgraph-avalanche.yaml", "build:tornado-arbitrum": "graph build subgraphs/tornado-subgraph-arbitrum.yaml", + "build:tornado-optimism": "graph build subgraphs/tornado-subgraph-optimism.yaml", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ --access-token $TOKEN", "deploy:tornado-bsc": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/tornado-subgraph-bsc.yaml", "deploy:tornado-xdai": "yarn deploy -- tornadocash/xdai-tornado-subgraph subgraphs/tornado-subgraph-xdai.yaml", @@ -40,7 +44,8 @@ "deploy:tornado-mainnet": "yarn deploy -- tornadocash/mainnet-tornado-subgraph subgraphs/tornado-subgraph-mainnet.yaml", "deploy:tornado-goerli": "yarn deploy -- tornadocash/goerli-tornado-subgraph subgraphs/tornado-subgraph-goerli.yaml", "deploy:tornado-avalanche": "yarn deploy -- tornadocash/avalanche-tornado-subgraph subgraphs/tornado-subgraph-avalanche.yaml", - "deploy:tornado-arbitrum": "yarn deploy -- tornadocash/arbitrum-tornado-subgraph subgraphs/tornado-subgraph-arbitrum.yaml" + "deploy:tornado-arbitrum": "yarn deploy -- tornadocash/arbitrum-tornado-subgraph subgraphs/tornado-subgraph-arbitrum.yaml", + "deploy:tornado-optimism": "yarn deploy -- tornadocash/optimism-tornado-subgraph subgraphs/tornado-subgraph-optimism.yaml" }, "dependencies": { "@graphprotocol/graph-cli": "0.20.0", diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index cf33e1e..21f69e5 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -171,4 +171,16 @@ contractsToInstances.set("0x330bdfade01ee9bf63c209ee33102dd334618e0a", // Inst contractsToInstances.set("0x1e34a77868e19a6647b1f2f47b51ed72dede95dd", // Instance-eth-100   "eth-100" ); +contractsToInstances.set("0x84443cfd09a48af6ef360c6976c5392ac5023a1f", // Instance-eth-0.1 +  "eth-0.1" +); +contractsToInstances.set("0xd47438c816c9e7f2e2888e060936a499af9582b3", // Instance-eth-1 +  "eth-1" +); +contractsToInstances.set("0x330bdfade01ee9bf63c209ee33102dd334618e0a", // Instance-eth-10 +  "eth-10" +); +contractsToInstances.set("0x1e34a77868e19a6647b1f2f47b51ed72dede95dd", // 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-optimism.yaml b/subgraphs/tornado-subgraph-optimism.yaml new file mode 100644 index 0000000..ccb9d2c --- /dev/null +++ b/subgraphs/tornado-subgraph-optimism.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: optimism + source: + address: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4" + abi: Echoer + startBlock: 2243694 + 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: optimism + source: + address: "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F" + abi: Instance + startBlock: 2243689 + 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: optimism + source: + address: "0xd47438C816c9E7f2E2888E060936a499Af9582b3" + abi: Instance + startBlock: 2243689 + 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: optimism + source: + address: "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a" + abi: Instance + startBlock: 2243689 + 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: optimism + source: + address: "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + abi: Instance + startBlock: 2243689 + 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: optimism + source: + address: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + abi: Proxy + startBlock: 2243689 + 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