From 2e7c35cac8b997be6b35cc22d4c0a70750c89fb8 Mon Sep 17 00:00:00 2001 From: Danil Kovtonyuk Date: Wed, 15 Sep 2021 01:28:22 +1000 Subject: [PATCH] feat: add Avalanche --- mustache/templates/echoer/contracts.js | 6 ++ mustache/templates/instance/contracts.js | 39 +++++++++- mustache/templates/proxy/contracts.js | 6 ++ package.json | 7 +- src/contractsToInstances.ts | 6 ++ subgraphs/tornado-subgraph-avalanche.yaml | 92 +++++++++++++++++++++++ 6 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 subgraphs/tornado-subgraph-avalanche.yaml diff --git a/mustache/templates/echoer/contracts.js b/mustache/templates/echoer/contracts.js index c70d175..0adcd8a 100644 --- a/mustache/templates/echoer/contracts.js +++ b/mustache/templates/echoer/contracts.js @@ -29,6 +29,12 @@ const contracts = [ name: 'Echoer', address: '0x37e6859804b6499d1e4a86d70a5fdd5de6a0ac65', }, + { + prod: 4285638, + network: 'avalanche', + name: 'Echoer', + address: '0xEd2B6bf192cFAb45810FC06c5E44e4Df48Eef47d', + }, ]; module.exports = contracts; diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index 9bb3fe9..4002b54 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -1,9 +1,10 @@ const deployedBlocks = { + bsc: 8159290, + xdai: 17754561, + matic: 16257962, goerli: 3781595, mainnet: 9116966, - matic: 16257962, - xdai: 17754561, - bsc: 8159290, + avalanche: 4285638, }; const contracts = [ @@ -407,6 +408,38 @@ const contracts = [ name: 'Instance', address: '0x0E3A09dDA6B20aFbB34aC7cD4A6881493f3E7bf7', }, + { + prod: deployedBlocks.avalanche, + amount: '0.1', + network: 'avalanche', + currency: 'avax', + name: 'Instance', + address: '0x25b5aD99DE3a1d713d3E5578413002ff6F89744d', + }, + { + prod: deployedBlocks.avalanche, + amount: '10', + network: 'avalanche', + currency: 'avax', + name: 'Instance', + address: '0x44139ab9F929CC10cdCEBddca8008e07ac52954E', + }, + // { + // prod: deployedBlocks.avalanche, + // amount: '100', + // network: 'avalanche', + // currency: 'avax', + // name: 'Instance', + // address: '', + // }, + // { + // prod: deployedBlocks.avalanche, + // amount: '500', + // network: 'avalanche', + // currency: 'avax', + // name: 'Instance', + // address: '', + // }, ]; module.exports = contracts; diff --git a/mustache/templates/proxy/contracts.js b/mustache/templates/proxy/contracts.js index e5bf6ca..5674caa 100644 --- a/mustache/templates/proxy/contracts.js +++ b/mustache/templates/proxy/contracts.js @@ -29,6 +29,12 @@ const contracts = [ network: 'goerli', address: '0x454d870a72e29d5e5697f635128d18077bd04c60', }, + { + prod: 4285638, + name: 'Proxy', + network: 'avalanche', + address: '0xa77350E1a72bE5bC7634d359C5011b4E359f4320', + }, ]; module.exports = contracts; diff --git a/package.json b/package.json index 7903ab2..378a599 100644 --- a/package.json +++ b/package.json @@ -8,29 +8,34 @@ "generate-matic": "yarn codegen:tornado-matic && yarn build:tornado-matic", "generate-mainnet": "yarn codegen:tornado-mainnet && yarn build:tornado-mainnet", "generate-goerli": "yarn codegen:tornado-goerli && yarn build:tornado-goerli", + "generate-avalanche": "yarn codegen:tornado-avalanche && yarn build:tornado-avalanche", "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", "yaml:tornado-mainnet": "node ./create-yaml-file create-yaml -e mainnet | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph-mainnet.yaml", "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", "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", "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", "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", "build": "graph build", "build:tornado-bsc": "graph build subgraphs/tornado-subgraph-bsc.yaml", "build:tornado-xdai": "graph build subgraphs/tornado-subgraph-xdai.yaml", "build:tornado-matic": "graph build subgraphs/tornado-subgraph-matic.yaml", "build:tornado-mainnet": "graph build subgraphs/tornado-subgraph-mainnet.yaml", "build:tornado-goerli": "graph build subgraphs/tornado-subgraph-goerli.yaml", + "build:tornado-avalanche": "graph build subgraphs/tornado-subgraph-avalanche.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", "deploy:tornado-matic": "yarn deploy -- tornadocash/matic-tornado-subgraph subgraphs/tornado-subgraph-matic.yaml", "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-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" }, "dependencies": { "@graphprotocol/graph-cli": "0.20.0", diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index 0760204..bc7c076 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -150,4 +150,10 @@ contractsToInstances.set("0x723b78e67497e85279cb204544566f4dc5d2aca0", // Inst contractsToInstances.set("0x0e3a09dda6b20afbb34ac7cd4a6881493f3e7bf7", // Instance-eth-100   "eth-100" ); +contractsToInstances.set("0x25b5ad99de3a1d713d3e5578413002ff6f89744d", // Instance-avax-0.1 +  "avax-0.1" +); +contractsToInstances.set("0x44139ab9f929cc10cdcebddca8008e07ac52954e", // Instance-avax-10 +  "avax-10" +); // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. diff --git a/subgraphs/tornado-subgraph-avalanche.yaml b/subgraphs/tornado-subgraph-avalanche.yaml new file mode 100644 index 0000000..bc245d3 --- /dev/null +++ b/subgraphs/tornado-subgraph-avalanche.yaml @@ -0,0 +1,92 @@ + specVersion: 0.0.2 + description: Proxy + repository: https://github.com/tornadocash/tornado-subgraph + schema: + file: ../schema.graphql + dataSources: + - kind: ethereum/contract + name: Echoer + network: avalanche + source: + address: "0xEd2B6bf192cFAb45810FC06c5E44e4Df48Eef47d" + abi: Echoer + startBlock: 4285638 + 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-avax + network: avalanche + source: + address: "0x25b5aD99DE3a1d713d3E5578413002ff6F89744d" + abi: Instance + startBlock: 4285638 + 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-avax + network: avalanche + source: + address: "0x44139ab9F929CC10cdCEBddca8008e07ac52954E" + abi: Instance + startBlock: 4285638 + 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: avalanche + source: + address: "0xa77350E1a72bE5bC7634d359C5011b4E359f4320" + abi: Proxy + startBlock: 4285638 + 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