From 9b2116f783f7b12033aa2a44d715ed516ffe9db9 Mon Sep 17 00:00:00 2001 From: nikdementev Date: Thu, 10 Jun 2021 11:49:47 +0300 Subject: [PATCH] feat: new generate --- .idea/tornado-subgraph.iml | 1 + build/Echoer/Echoer.wasm | Bin 7537 -> 7558 bytes build/subgraph.yaml | 121 +++++++++++++- create-yaml-file.js | 39 +++-- generated/Echoer/Echoer.ts | 12 +- generated/Proxy/Proxy.ts | 12 +- generated/schema.ts | 175 +++++++++++---------- mustache/bsc.js | 88 ----------- mustache/templates/echoer/contracts.js | 10 ++ mustache/templates/echoer/create-yaml.js | 34 ++++ mustache/templates/echoer/index.js | 4 + mustache/templates/instance/contracts.js | 30 +++- mustache/templates/instance/create-yaml.js | 12 +- mustache/templates/proxy/contracts.js | 4 +- mustache/templates/proxy/create-yaml.js | 2 +- package.json | 13 +- src/contractsToInstances.ts | 16 +- subgraph.yaml | 2 +- subgraphs/instance-tornado-subgraph.yaml | 29 ---- subgraphs/proxy-tornado-subgraph.yaml | 26 --- subgraphs/tornado-subgraph.yaml | 138 ++++++++++++++++ 21 files changed, 499 insertions(+), 269 deletions(-) delete mode 100644 mustache/bsc.js create mode 100644 mustache/templates/echoer/contracts.js create mode 100644 mustache/templates/echoer/create-yaml.js create mode 100644 mustache/templates/echoer/index.js delete mode 100644 subgraphs/instance-tornado-subgraph.yaml delete mode 100644 subgraphs/proxy-tornado-subgraph.yaml create mode 100644 subgraphs/tornado-subgraph.yaml diff --git a/.idea/tornado-subgraph.iml b/.idea/tornado-subgraph.iml index 0c8867d..10840bb 100644 --- a/.idea/tornado-subgraph.iml +++ b/.idea/tornado-subgraph.iml @@ -5,6 +5,7 @@ + diff --git a/build/Echoer/Echoer.wasm b/build/Echoer/Echoer.wasm index 84a39d89111d7e788388031194f4644cb0c8bc23..50619a5d225d7479ff52b8d58f860034d89a08d1 100644 GIT binary patch delta 103 zcmexp)n>inl>p<_&94O}GI8mPF)%Rb0ipip2H`!7oQDKh@)C1X8Fy`V6|G}s(bm(` zpL|4WIg2rfF;7}mAUQv;xTL5wxg@_xMjt4+d7iW|BZ~@1dXtP2iyDY=Rb~zVp0yv6 delta 79 zcmV-V0I>gtJMlWO>JS0Xv+EF%0t6`&006Uw6TATlvk(MsVQpmrtFucLegy$2lg%2Z l0Wg!T8zqyS8w>#~v#lEw0RbVC%^DpBb76L6AtRIO9Gp*d8kqn9 diff --git a/build/subgraph.yaml b/build/subgraph.yaml index c8ae49d..4b20e25 100644 --- a/build/subgraph.yaml +++ b/build/subgraph.yaml @@ -1,21 +1,41 @@ specVersion: 0.0.2 -description: Instance +description: Proxy repository: https://github.com/tornadocash/tornado-subgraph schema: file: schema.graphql dataSources: - kind: ethereum/contract - name: Instance + name: Echoer network: bsc source: - address: "0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d" - abi: Instance - startBlock: 7942402 + address: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + abi: Echoer + startBlock: 8158799 mapping: kind: ethereum/events apiVersion: 0.0.4 language: wasm/assemblyscript - file: Instance/Instance.wasm + file: Echoer/Echoer.wasm + 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: Instance-0.1-bnb/Instance-0.1-bnb.wasm entities: - Deposit - Withdrawal @@ -27,3 +47,92 @@ dataSources: 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: Instance-0.1-bnb/Instance-0.1-bnb.wasm + 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: Instance-0.1-bnb/Instance-0.1-bnb.wasm + 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: Instance-0.1-bnb/Instance-0.1-bnb.wasm + 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: Proxy/Proxy.wasm + entities: + - EncryptedNote + abis: + - name: Proxy + file: abis/Proxy.json + eventHandlers: + - event: EncryptedNote(indexed address,bytes) + handler: handleEncryptedNote diff --git a/create-yaml-file.js b/create-yaml-file.js index a2b84ac..b0f6e0f 100644 --- a/create-yaml-file.js +++ b/create-yaml-file.js @@ -6,28 +6,45 @@ const program = require('commander'); program .command('create-yaml') .description('Creates yaml files using the mustache templating engine') - .option( - '-s, --subgraph ', - 'the subgraph for which you are creating the yaml file. Currently only "proxy", "instance" and "echoer" are supported', - ) .option( '-e, --env ', 'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config', 'bsc', ) - .action(async ({ subgraph, env }) => { + .action(async ({ env }) => { const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js'); - const specificIndexPath = path.join(__dirname, 'mustache', 'templates', subgraph, 'index.js'); - const dataSourcesPath = path.join(__dirname, 'mustache', 'templates', subgraph, 'create-yaml.js'); - const subgraphDataSourcesData = require(dataSourcesPath); - const dataSourcesData = [...subgraphDataSourcesData.createYaml(env)]; + const echoerIndexPath = path.join(__dirname, 'mustache', 'templates', 'echoer', 'index.js'); + const dataEchoerSourcesPath = path.join(__dirname, 'mustache', 'templates', 'echoer', 'create-yaml.js'); + + const instancesIndexPath = path.join(__dirname, 'mustache', 'templates', 'instance', 'index.js'); + const dataInstancesSourcesPath = path.join(__dirname, 'mustache', 'templates', 'instance', 'create-yaml.js'); + + const proxyIndexPath = path.join(__dirname, 'mustache', 'templates', 'proxy', 'index.js'); + const dataProxySourcesPath = path.join(__dirname, 'mustache', 'templates', 'proxy', 'create-yaml.js'); + + const echoerDataSourcesData = require(dataEchoerSourcesPath); + const instancesDataSourcesData = require(dataInstancesSourcesPath); + const proxyDataSourcesData = require(dataProxySourcesPath); + + const dataSourcesData = [ + ...echoerDataSourcesData.createYaml(env), + ...instancesDataSourcesData.createYaml(env), + ...proxyDataSourcesData.createYaml(env), + ]; const indexData = require(baseIndexPath); - const specificIndexData = require(specificIndexPath); + const specificEchoerIndexData = require(echoerIndexPath); + const specificInstancesIndexData = require(instancesIndexPath); + const specificProxyIndexData = require(proxyIndexPath); - indexData.yaml[0] = { ...indexData.yaml[0], ...specificIndexData }; + indexData.yaml[0] = { + ...indexData.yaml[0], + ...specificEchoerIndexData, + ...specificInstancesIndexData, + ...specificProxyIndexData, + }; indexData.yaml[0].dataSources = dataSourcesData; return console.log(JSON.stringify(indexData, null, 2) + '\n'); diff --git a/generated/Echoer/Echoer.ts b/generated/Echoer/Echoer.ts index 55e9e8a..3ffdc4f 100644 --- a/generated/Echoer/Echoer.ts +++ b/generated/Echoer/Echoer.ts @@ -1,6 +1,14 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -import { ethereum, JSONValue, TypedMap, Entity, Bytes, Address, BigInt } from '@graphprotocol/graph-ts'; +import { + ethereum, + JSONValue, + TypedMap, + Entity, + Bytes, + Address, + BigInt +} from "@graphprotocol/graph-ts"; export class Echo extends ethereum.Event { get params(): Echo__Params { @@ -26,6 +34,6 @@ export class Echo__Params { export class Echoer extends ethereum.SmartContract { static bind(address: Address): Echoer { - return new Echoer('Echoer', address); + return new Echoer("Echoer", address); } } diff --git a/generated/Proxy/Proxy.ts b/generated/Proxy/Proxy.ts index 3b78e70..7700179 100644 --- a/generated/Proxy/Proxy.ts +++ b/generated/Proxy/Proxy.ts @@ -1,6 +1,14 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -import { ethereum, JSONValue, TypedMap, Entity, Bytes, Address, BigInt } from '@graphprotocol/graph-ts'; +import { + ethereum, + JSONValue, + TypedMap, + Entity, + Bytes, + Address, + BigInt +} from "@graphprotocol/graph-ts"; export class EncryptedNote extends ethereum.Event { get params(): EncryptedNote__Params { @@ -26,6 +34,6 @@ export class EncryptedNote__Params { export class Proxy extends ethereum.SmartContract { static bind(address: Address): Proxy { - return new Proxy('Proxy', address); + return new Proxy("Proxy", address); } } diff --git a/generated/schema.ts b/generated/schema.ts index 0d64fad..75c95b2 100644 --- a/generated/schema.ts +++ b/generated/schema.ts @@ -1,333 +1,344 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -import { TypedMap, Entity, Value, ValueKind, store, Address, Bytes, BigInt, BigDecimal } from '@graphprotocol/graph-ts'; +import { + TypedMap, + Entity, + Value, + ValueKind, + store, + Address, + Bytes, + BigInt, + BigDecimal +} from "@graphprotocol/graph-ts"; export class Deposit extends Entity { constructor(id: string) { super(); - this.set('id', Value.fromString(id)); + this.set("id", Value.fromString(id)); } save(): void { - let id = this.get('id'); - assert(id !== null, 'Cannot save Deposit entity without an ID'); + let id = this.get("id"); + assert(id !== null, "Cannot save Deposit entity without an ID"); assert( id.kind == ValueKind.STRING, - 'Cannot save Deposit entity with non-string ID. ' + 'Considering using .toHex() to convert the "id" to a string.', + "Cannot save Deposit entity with non-string ID. " + + 'Considering using .toHex() to convert the "id" to a string.' ); - store.set('Deposit', id.toString(), this); + store.set("Deposit", id.toString(), this); } static load(id: string): Deposit | null { - return store.get('Deposit', id) as Deposit | null; + return store.get("Deposit", id) as Deposit | null; } get id(): string { - let value = this.get('id'); + let value = this.get("id"); return value.toString(); } set id(value: string) { - this.set('id', Value.fromString(value)); + this.set("id", Value.fromString(value)); } get index(): BigInt { - let value = this.get('index'); + let value = this.get("index"); return value.toBigInt(); } set index(value: BigInt) { - this.set('index', Value.fromBigInt(value)); + this.set("index", Value.fromBigInt(value)); } get amount(): string { - let value = this.get('amount'); + let value = this.get("amount"); return value.toString(); } set amount(value: string) { - this.set('amount', Value.fromString(value)); + this.set("amount", Value.fromString(value)); } get currency(): string { - let value = this.get('currency'); + let value = this.get("currency"); return value.toString(); } set currency(value: string) { - this.set('currency', Value.fromString(value)); + this.set("currency", Value.fromString(value)); } get commitment(): Bytes { - let value = this.get('commitment'); + let value = this.get("commitment"); return value.toBytes(); } set commitment(value: Bytes) { - this.set('commitment', Value.fromBytes(value)); + this.set("commitment", Value.fromBytes(value)); } get timestamp(): BigInt { - let value = this.get('timestamp'); + let value = this.get("timestamp"); return value.toBigInt(); } set timestamp(value: BigInt) { - this.set('timestamp', Value.fromBigInt(value)); + this.set("timestamp", Value.fromBigInt(value)); } get blockNumber(): BigInt { - let value = this.get('blockNumber'); + let value = this.get("blockNumber"); return value.toBigInt(); } set blockNumber(value: BigInt) { - this.set('blockNumber', Value.fromBigInt(value)); + this.set("blockNumber", Value.fromBigInt(value)); } get transactionHash(): Bytes { - let value = this.get('transactionHash'); + let value = this.get("transactionHash"); return value.toBytes(); } set transactionHash(value: Bytes) { - this.set('transactionHash', Value.fromBytes(value)); + this.set("transactionHash", Value.fromBytes(value)); } } export class Withdrawal extends Entity { constructor(id: string) { super(); - this.set('id', Value.fromString(id)); + this.set("id", Value.fromString(id)); } save(): void { - let id = this.get('id'); - assert(id !== null, 'Cannot save Withdrawal entity without an ID'); + let id = this.get("id"); + assert(id !== null, "Cannot save Withdrawal entity without an ID"); assert( id.kind == ValueKind.STRING, - 'Cannot save Withdrawal entity with non-string ID. ' + - 'Considering using .toHex() to convert the "id" to a string.', + "Cannot save Withdrawal entity with non-string ID. " + + 'Considering using .toHex() to convert the "id" to a string.' ); - store.set('Withdrawal', id.toString(), this); + store.set("Withdrawal", id.toString(), this); } static load(id: string): Withdrawal | null { - return store.get('Withdrawal', id) as Withdrawal | null; + return store.get("Withdrawal", id) as Withdrawal | null; } get id(): string { - let value = this.get('id'); + let value = this.get("id"); return value.toString(); } set id(value: string) { - this.set('id', Value.fromString(value)); + this.set("id", Value.fromString(value)); } get to(): Bytes { - let value = this.get('to'); + let value = this.get("to"); return value.toBytes(); } set to(value: Bytes) { - this.set('to', Value.fromBytes(value)); + this.set("to", Value.fromBytes(value)); } get fee(): BigInt { - let value = this.get('fee'); + let value = this.get("fee"); return value.toBigInt(); } set fee(value: BigInt) { - this.set('fee', Value.fromBigInt(value)); + this.set("fee", Value.fromBigInt(value)); } get index(): BigInt { - let value = this.get('index'); + let value = this.get("index"); return value.toBigInt(); } set index(value: BigInt) { - this.set('index', Value.fromBigInt(value)); + this.set("index", Value.fromBigInt(value)); } get amount(): string { - let value = this.get('amount'); + let value = this.get("amount"); return value.toString(); } set amount(value: string) { - this.set('amount', Value.fromString(value)); + this.set("amount", Value.fromString(value)); } get currency(): string { - let value = this.get('currency'); + let value = this.get("currency"); return value.toString(); } set currency(value: string) { - this.set('currency', Value.fromString(value)); + this.set("currency", Value.fromString(value)); } get nullifier(): Bytes { - let value = this.get('nullifier'); + let value = this.get("nullifier"); return value.toBytes(); } set nullifier(value: Bytes) { - this.set('nullifier', Value.fromBytes(value)); + this.set("nullifier", Value.fromBytes(value)); } get timestamp(): BigInt { - let value = this.get('timestamp'); + let value = this.get("timestamp"); return value.toBigInt(); } set timestamp(value: BigInt) { - this.set('timestamp', Value.fromBigInt(value)); + this.set("timestamp", Value.fromBigInt(value)); } get blockNumber(): BigInt { - let value = this.get('blockNumber'); + let value = this.get("blockNumber"); return value.toBigInt(); } set blockNumber(value: BigInt) { - this.set('blockNumber', Value.fromBigInt(value)); + this.set("blockNumber", Value.fromBigInt(value)); } get transactionHash(): Bytes { - let value = this.get('transactionHash'); + let value = this.get("transactionHash"); return value.toBytes(); } set transactionHash(value: Bytes) { - this.set('transactionHash', Value.fromBytes(value)); + this.set("transactionHash", Value.fromBytes(value)); } } export class EncryptedNote extends Entity { constructor(id: string) { super(); - this.set('id', Value.fromString(id)); + this.set("id", Value.fromString(id)); } save(): void { - let id = this.get('id'); - assert(id !== null, 'Cannot save EncryptedNote entity without an ID'); + let id = this.get("id"); + assert(id !== null, "Cannot save EncryptedNote entity without an ID"); assert( id.kind == ValueKind.STRING, - 'Cannot save EncryptedNote entity with non-string ID. ' + - 'Considering using .toHex() to convert the "id" to a string.', + "Cannot save EncryptedNote entity with non-string ID. " + + 'Considering using .toHex() to convert the "id" to a string.' ); - store.set('EncryptedNote', id.toString(), this); + store.set("EncryptedNote", id.toString(), this); } static load(id: string): EncryptedNote | null { - return store.get('EncryptedNote', id) as EncryptedNote | null; + return store.get("EncryptedNote", id) as EncryptedNote | null; } get id(): string { - let value = this.get('id'); + let value = this.get("id"); return value.toString(); } set id(value: string) { - this.set('id', Value.fromString(value)); + this.set("id", Value.fromString(value)); } get index(): BigInt { - let value = this.get('index'); + let value = this.get("index"); return value.toBigInt(); } set index(value: BigInt) { - this.set('index', Value.fromBigInt(value)); + this.set("index", Value.fromBigInt(value)); } get blockNumber(): BigInt { - let value = this.get('blockNumber'); + let value = this.get("blockNumber"); return value.toBigInt(); } set blockNumber(value: BigInt) { - this.set('blockNumber', Value.fromBigInt(value)); + this.set("blockNumber", Value.fromBigInt(value)); } get encryptedNote(): Bytes { - let value = this.get('encryptedNote'); + let value = this.get("encryptedNote"); return value.toBytes(); } set encryptedNote(value: Bytes) { - this.set('encryptedNote', Value.fromBytes(value)); + this.set("encryptedNote", Value.fromBytes(value)); } get transactionHash(): Bytes { - let value = this.get('transactionHash'); + let value = this.get("transactionHash"); return value.toBytes(); } set transactionHash(value: Bytes) { - this.set('transactionHash', Value.fromBytes(value)); + this.set("transactionHash", Value.fromBytes(value)); } } export class NoteAccount extends Entity { constructor(id: string) { super(); - this.set('id', Value.fromString(id)); + this.set("id", Value.fromString(id)); } save(): void { - let id = this.get('id'); - assert(id !== null, 'Cannot save NoteAccount entity without an ID'); + let id = this.get("id"); + assert(id !== null, "Cannot save NoteAccount entity without an ID"); assert( id.kind == ValueKind.STRING, - 'Cannot save NoteAccount entity with non-string ID. ' + - 'Considering using .toHex() to convert the "id" to a string.', + "Cannot save NoteAccount entity with non-string ID. " + + 'Considering using .toHex() to convert the "id" to a string.' ); - store.set('NoteAccount', id.toString(), this); + store.set("NoteAccount", id.toString(), this); } static load(id: string): NoteAccount | null { - return store.get('NoteAccount', id) as NoteAccount | null; + return store.get("NoteAccount", id) as NoteAccount | null; } get id(): string { - let value = this.get('id'); + let value = this.get("id"); return value.toString(); } set id(value: string) { - this.set('id', Value.fromString(value)); + this.set("id", Value.fromString(value)); } get index(): BigInt { - let value = this.get('index'); + let value = this.get("index"); return value.toBigInt(); } set index(value: BigInt) { - this.set('index', Value.fromBigInt(value)); + this.set("index", Value.fromBigInt(value)); } get address(): Bytes { - let value = this.get('address'); + let value = this.get("address"); return value.toBytes(); } set address(value: Bytes) { - this.set('address', Value.fromBytes(value)); + this.set("address", Value.fromBytes(value)); } get encryptedAccount(): Bytes { - let value = this.get('encryptedAccount'); + let value = this.get("encryptedAccount"); return value.toBytes(); } set encryptedAccount(value: Bytes) { - this.set('encryptedAccount', Value.fromBytes(value)); + this.set("encryptedAccount", Value.fromBytes(value)); } } diff --git a/mustache/bsc.js b/mustache/bsc.js deleted file mode 100644 index edf163c..0000000 --- a/mustache/bsc.js +++ /dev/null @@ -1,88 +0,0 @@ -module.exports = { - base: { - specVersion: '0.0.2', - description: '', - repository: 'https://github.com/tornadocash/bsc-tornado-subgraph', - network: 'bsc', - }, - dataSources: [ - { - name: 'Instance', - network: 'bsc', - dataSourceKind: 'ethereum/contract', - address: '0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7', - abi: 'Instance', - startBlock: 7941563, - mapping: { - kind: 'ethereum/events', - apiVersion: '0.0.4', - language: 'wasm/assemblyscript', - 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', - }, - ], - file: './src/mapping-proxy.ts', - }, - }, - { - name: 'Echoer', - network: 'bsc', - dataSourceKind: 'ethereum/contract', - address: '0x60eaCBd5535ADB86955A0154E44Aded78F161643', - abi: 'Echoer', - startBlock: 7941563, - mapping: { - kind: 'ethereum/events', - apiVersion: '0.0.4', - language: 'wasm/assemblyscript', - entities: ['NoteAccount'], - abis: { - name: 'Echoer', - file: './abis/Echoer.json', - }, - eventHandlers: [ - { - event: 'Echo(indexed address,bytes)', - handler: 'handleEcho', - }, - ], - file: './src/mapping-echo-account.ts', - }, - }, - { - name: 'Proxy', - dataSourceKind: 'ethereum/contract', - address: '0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d', - abi: 'Proxy', - startBlock: 7941563, - mapping: { - kind: 'ethereum/events', - apiVersion: '0.0.4', - language: 'wasm/assemblyscript', - entities: ['EncryptedNote'], - abis: { - name: 'Proxy', - file: './abis/Proxy.json', - }, - eventHandlers: [ - { - event: 'EncryptedNote(indexed address,bytes)', - handler: 'handleEncryptedNote', - }, - ], - file: './src/mapping-encrypted-note.ts', - }, - }, - ], -}; diff --git a/mustache/templates/echoer/contracts.js b/mustache/templates/echoer/contracts.js new file mode 100644 index 0000000..4cc7e6b --- /dev/null +++ b/mustache/templates/echoer/contracts.js @@ -0,0 +1,10 @@ +const contracts = [ + { + prod: 8158799, + network: 'bsc', + name: 'Echoer', + address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', + }, +]; + +module.exports = contracts; diff --git a/mustache/templates/echoer/create-yaml.js b/mustache/templates/echoer/create-yaml.js new file mode 100644 index 0000000..eeb976b --- /dev/null +++ b/mustache/templates/echoer/create-yaml.js @@ -0,0 +1,34 @@ +const Contracts = require('./contracts'); + +module.exports = { + createYaml: (env) => { + const createEchoerBlock = ({ name, network, startBlocks, address }) => ({ + name, + network, + mappingFile: '../src/mapping-echo-account.ts', + startBlock: startBlocks.prod, + address: `"${address}"`, + abi: 'Echoer', + entities: ['NoteAccount'], + abis: [ + { + name: 'Echoer', + path: '../abis/Echoer.json', + }, + ], + events: [ + { + event: 'Echo(indexed address,bytes)', + handler: 'handleEcho', + }, + ], + }); + + return Contracts.map(({ prod, name, network, address }) => { + const startBlocks = { prod }; + if (network === env) { + return createEchoerBlock({ name, startBlocks, network, address }); + } + }).filter((e) => e !== undefined); + }, +}; diff --git a/mustache/templates/echoer/index.js b/mustache/templates/echoer/index.js new file mode 100644 index 0000000..3a53e18 --- /dev/null +++ b/mustache/templates/echoer/index.js @@ -0,0 +1,4 @@ +module.exports = { + description: 'Echoer', + schemaFile: '../schema.graphql', +}; diff --git a/mustache/templates/instance/contracts.js b/mustache/templates/instance/contracts.js index 63706a7..d88831a 100644 --- a/mustache/templates/instance/contracts.js +++ b/mustache/templates/instance/contracts.js @@ -1,11 +1,35 @@ const contracts = [ { - prod: 7942402, + prod: 8159279, amount: '0.1', network: 'bsc', - currency: 'bsc', + currency: 'bnb', name: 'Instance', - address: '0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d', + address: '0x84443CFd09A48AF6eF360C6976C5392aC5023a1F', + }, + { + prod: 8159286, + amount: '1', + network: 'bsc', + currency: 'bnb', + name: 'Instance', + address: '0xd47438C816c9E7f2E2888E060936a499Af9582b3', + }, + { + prod: 8159290, + amount: '10', + network: 'bsc', + currency: 'bnb', + name: 'Instance', + address: '0x330bdFADE01eE9bF63C209Ee33102DD334618e0a', + }, + { + prod: 8159296, + amount: '100', + network: 'bsc', + currency: 'bnb', + name: 'Instance', + address: '0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD', }, ]; diff --git a/mustache/templates/instance/create-yaml.js b/mustache/templates/instance/create-yaml.js index f238a22..276685c 100644 --- a/mustache/templates/instance/create-yaml.js +++ b/mustache/templates/instance/create-yaml.js @@ -5,12 +5,12 @@ const Contracts = require('./contracts'); module.exports = { createYaml: (env) => { - const createInstanceBlock = ({ name, network, startBlocks, address }) => ({ - name, + const createInstanceBlock = ({ name, amount, currency, network, startBlocks, address }) => ({ + name: `${name}-${amount}-${currency}`, network, mappingFile: '../src/mapping-instance.ts', startBlock: startBlocks.prod, - address, + address: `"${address}"`, abi: 'Instance', entities: ['Deposit', 'Withdrawal'], abis: [ @@ -39,7 +39,7 @@ module.exports = { Contracts.forEach(({ address, name, amount, currency }) => { if (address != null) { - contractsToInstancesContent += `contractsToInstances.set(${address.toLowerCase()},${space}//${space}${name}-${currency}-${amount}${newLine}${doubleSpace}"${amount}${'-'}${currency}"${newLine});${newLine}`; + contractsToInstancesContent += `contractsToInstances.set("${address.toLowerCase()}",${space}//${space}${name}-${currency}-${amount}${newLine}${doubleSpace}"${amount}${'-'}${currency}"${newLine});${newLine}`; } }); @@ -47,10 +47,10 @@ module.exports = { const targetFile = path.join(__dirname, '../../../src/', 'contractsToInstances.ts'); fs.writeFileSync(targetFile, contractsToInstancesContent, 'utf8'); - return Contracts.map(({ prod, name, network, address }) => { + return Contracts.map(({ prod, name, amount, currency, network, address }) => { const startBlocks = { prod }; if (network === env) { - return createInstanceBlock({ name, startBlocks, network, address }); + return createInstanceBlock({ name, startBlocks, amount, currency, network, address }); } }).filter((e) => e !== undefined); }, diff --git a/mustache/templates/proxy/contracts.js b/mustache/templates/proxy/contracts.js index 66ccd04..2d5db9a 100644 --- a/mustache/templates/proxy/contracts.js +++ b/mustache/templates/proxy/contracts.js @@ -1,9 +1,9 @@ const contracts = [ { - prod: 7942402, + prod: 8158799, name: 'Proxy', network: 'bsc', - address: '0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7', + address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', }, ]; diff --git a/mustache/templates/proxy/create-yaml.js b/mustache/templates/proxy/create-yaml.js index 7e7a990..79c9430 100644 --- a/mustache/templates/proxy/create-yaml.js +++ b/mustache/templates/proxy/create-yaml.js @@ -8,7 +8,7 @@ module.exports = { mappingFile: '../src/mapping-encrypted-note.ts', abi: 'Proxy', startBlock: 7941563, - address, + address: `"${address}"`, entities: ['EncryptedNote'], abis: [ { diff --git a/package.json b/package.json index 6c684c9..3e9c9be 100644 --- a/package.json +++ b/package.json @@ -3,17 +3,14 @@ "license": "UNLICENSED", "scripts": { "lint": "eslint .", - "yaml:proxy": "node ./create-yaml-file create-yaml -s proxy -e bsc | mustache - mustache/yaml.mustache > subgraphs/proxy-tornado-subgraph.yaml", - "yaml:instance": "node ./create-yaml-file create-yaml -s instance -e bsc | mustache - mustache/yaml.mustache > subgraphs/instance-tornado-subgraph.yaml", + "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", "codegen": "graph codegen", - "codegen:proxy": "yarn yaml:proxy && yarn codegen -- subgraphs/proxy-tornado-subgraph.yaml", - "codegen:instance": "yarn yaml:instance && yarn codegen -- subgraphs/instance-tornado-subgraph.yaml", + "codegen:tornado": "yarn yaml:tornado && yarn codegen -- subgraphs/tornado-subgraph.yaml", "build": "graph build", - "build:proxy": "graph build subgraphs/proxy-tornado-subgraph.yaml", - "build:instance": "graph build subgraphs/instance-tornado-subgraph.yaml", + "build:tornado": "graph build subgraphs/tornado-subgraph.yaml", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ tornadocash/bsc-tornado-subgraph", - "deploy:proxy": "yarn deploy -- tornadocash/bsc-tornado-subgraph ubgraphs/proxy-tornado-subgraph.yaml", - "deploy:instance": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/instance-tornado-subgraph.yaml" + "deploy:tornado": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/tornado-subgraph.yaml" }, "dependencies": { "@graphprotocol/graph-cli": "0.20.0", diff --git a/src/contractsToInstances.ts b/src/contractsToInstances.ts index c037fda..a48e41b 100644 --- a/src/contractsToInstances.ts +++ b/src/contractsToInstances.ts @@ -1,7 +1,19 @@ // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. export let contractsToInstances = new Map(); contractsToInstances.set( - '0x0ce22770451a8acad1220d9d1678656b4fae4a1d', // Instance-bsc-0.1 - '0.1-bsc', + '0x84443cfd09a48af6ef360c6976c5392ac5023a1f', // Instance-bnb-0.1 + '0.1-bnb', +); +contractsToInstances.set( + '0xd47438c816c9e7f2e2888e060936a499af9582b3', // Instance-bnb-1 + '1-bnb', +); +contractsToInstances.set( + '0x330bdfade01ee9bf63c209ee33102dd334618e0a', // Instance-bnb-10 + '10-bnb', +); +contractsToInstances.set( + '0x1e34a77868e19a6647b1f2f47b51ed72dede95dd', // Instance-bnb-100 + '100-bnb', ); // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. diff --git a/subgraph.yaml b/subgraph.yaml index 824e67c..7b35600 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -6,7 +6,7 @@ dataSources: name: Proxy network: bsc source: - address: "0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7" + address: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" abi: Proxy startBlock: 7941563 mapping: diff --git a/subgraphs/instance-tornado-subgraph.yaml b/subgraphs/instance-tornado-subgraph.yaml deleted file mode 100644 index 4330534..0000000 --- a/subgraphs/instance-tornado-subgraph.yaml +++ /dev/null @@ -1,29 +0,0 @@ - specVersion: 0.0.2 - description: Instance - repository: https://github.com/tornadocash/tornado-subgraph - schema: - file: ../schema.graphql - dataSources: - - kind: ethereum/contract - name: Instance - network: bsc - source: - address: '0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d' - abi: Instance - startBlock: 7942402 - 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 diff --git a/subgraphs/proxy-tornado-subgraph.yaml b/subgraphs/proxy-tornado-subgraph.yaml deleted file mode 100644 index b7c4310..0000000 --- a/subgraphs/proxy-tornado-subgraph.yaml +++ /dev/null @@ -1,26 +0,0 @@ - specVersion: 0.0.2 - description: Proxy - repository: https://github.com/Synthetixio/synthetix-subgraph - schema: - file: ../schema.graphql - dataSources: - - kind: ethereum/contract - name: Proxy - network: bsc - source: - address: '0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7' - 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 diff --git a/subgraphs/tornado-subgraph.yaml b/subgraphs/tornado-subgraph.yaml new file mode 100644 index 0000000..257c28c --- /dev/null +++ b/subgraphs/tornado-subgraph.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: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + abi: Echoer + startBlock: 8158799 + 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