feat: new generate

This commit is contained in:
nikdementev 2021-06-10 11:49:47 +03:00 committed by 0xZick 地方分権化
parent f48236f744
commit 9b2116f783
21 changed files with 499 additions and 269 deletions

@ -5,6 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/temp" /> <excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" /> <excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" /> <excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

Binary file not shown.

@ -1,21 +1,41 @@
specVersion: 0.0.2 specVersion: 0.0.2
description: Instance description: Proxy
repository: https://github.com/tornadocash/tornado-subgraph repository: https://github.com/tornadocash/tornado-subgraph
schema: schema:
file: schema.graphql file: schema.graphql
dataSources: dataSources:
- kind: ethereum/contract - kind: ethereum/contract
name: Instance name: Echoer
network: bsc network: bsc
source: source:
address: "0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d" address: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17"
abi: Instance abi: Echoer
startBlock: 7942402 startBlock: 8158799
mapping: mapping:
kind: ethereum/events kind: ethereum/events
apiVersion: 0.0.4 apiVersion: 0.0.4
language: wasm/assemblyscript 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: entities:
- Deposit - Deposit
- Withdrawal - Withdrawal
@ -27,3 +47,92 @@ dataSources:
handler: handleDeposit handler: handleDeposit
- event: Withdrawal(address,bytes32,indexed address,uint256) - event: Withdrawal(address,bytes32,indexed address,uint256)
handler: handleWithdrawal 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

@ -6,28 +6,45 @@ const program = require('commander');
program program
.command('create-yaml') .command('create-yaml')
.description('Creates yaml files using the mustache templating engine') .description('Creates yaml files using the mustache templating engine')
.option(
'-s, --subgraph <value>',
'the subgraph for which you are creating the yaml file. Currently only "proxy", "instance" and "echoer" are supported',
)
.option( .option(
'-e, --env <value>', '-e, --env <value>',
'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config', 'defaults to "bsc" and uses the bsc start blocks config. Must set to "goerli" to use test start blocks config',
'bsc', 'bsc',
) )
.action(async ({ subgraph, env }) => { .action(async ({ env }) => {
const baseIndexPath = path.join(__dirname, 'mustache', 'templates', 'base', 'index.js'); 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 echoerIndexPath = path.join(__dirname, 'mustache', 'templates', 'echoer', 'index.js');
const dataSourcesData = [...subgraphDataSourcesData.createYaml(env)]; 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 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; indexData.yaml[0].dataSources = dataSourcesData;
return console.log(JSON.stringify(indexData, null, 2) + '\n'); return console.log(JSON.stringify(indexData, null, 2) + '\n');

@ -1,6 +1,14 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // 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 { export class Echo extends ethereum.Event {
get params(): Echo__Params { get params(): Echo__Params {
@ -26,6 +34,6 @@ export class Echo__Params {
export class Echoer extends ethereum.SmartContract { export class Echoer extends ethereum.SmartContract {
static bind(address: Address): Echoer { static bind(address: Address): Echoer {
return new Echoer('Echoer', address); return new Echoer("Echoer", address);
} }
} }

@ -1,6 +1,14 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // 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 { export class EncryptedNote extends ethereum.Event {
get params(): EncryptedNote__Params { get params(): EncryptedNote__Params {
@ -26,6 +34,6 @@ export class EncryptedNote__Params {
export class Proxy extends ethereum.SmartContract { export class Proxy extends ethereum.SmartContract {
static bind(address: Address): Proxy { static bind(address: Address): Proxy {
return new Proxy('Proxy', address); return new Proxy("Proxy", address);
} }
} }

@ -1,333 +1,344 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // 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 { export class Deposit extends Entity {
constructor(id: string) { constructor(id: string) {
super(); super();
this.set('id', Value.fromString(id)); this.set("id", Value.fromString(id));
} }
save(): void { save(): void {
let id = this.get('id'); let id = this.get("id");
assert(id !== null, 'Cannot save Deposit entity without an ID'); assert(id !== null, "Cannot save Deposit entity without an ID");
assert( assert(
id.kind == ValueKind.STRING, 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 { 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 { get id(): string {
let value = this.get('id'); let value = this.get("id");
return value.toString(); return value.toString();
} }
set id(value: string) { set id(value: string) {
this.set('id', Value.fromString(value)); this.set("id", Value.fromString(value));
} }
get index(): BigInt { get index(): BigInt {
let value = this.get('index'); let value = this.get("index");
return value.toBigInt(); return value.toBigInt();
} }
set index(value: BigInt) { set index(value: BigInt) {
this.set('index', Value.fromBigInt(value)); this.set("index", Value.fromBigInt(value));
} }
get amount(): string { get amount(): string {
let value = this.get('amount'); let value = this.get("amount");
return value.toString(); return value.toString();
} }
set amount(value: string) { set amount(value: string) {
this.set('amount', Value.fromString(value)); this.set("amount", Value.fromString(value));
} }
get currency(): string { get currency(): string {
let value = this.get('currency'); let value = this.get("currency");
return value.toString(); return value.toString();
} }
set currency(value: string) { set currency(value: string) {
this.set('currency', Value.fromString(value)); this.set("currency", Value.fromString(value));
} }
get commitment(): Bytes { get commitment(): Bytes {
let value = this.get('commitment'); let value = this.get("commitment");
return value.toBytes(); return value.toBytes();
} }
set commitment(value: Bytes) { set commitment(value: Bytes) {
this.set('commitment', Value.fromBytes(value)); this.set("commitment", Value.fromBytes(value));
} }
get timestamp(): BigInt { get timestamp(): BigInt {
let value = this.get('timestamp'); let value = this.get("timestamp");
return value.toBigInt(); return value.toBigInt();
} }
set timestamp(value: BigInt) { set timestamp(value: BigInt) {
this.set('timestamp', Value.fromBigInt(value)); this.set("timestamp", Value.fromBigInt(value));
} }
get blockNumber(): BigInt { get blockNumber(): BigInt {
let value = this.get('blockNumber'); let value = this.get("blockNumber");
return value.toBigInt(); return value.toBigInt();
} }
set blockNumber(value: BigInt) { set blockNumber(value: BigInt) {
this.set('blockNumber', Value.fromBigInt(value)); this.set("blockNumber", Value.fromBigInt(value));
} }
get transactionHash(): Bytes { get transactionHash(): Bytes {
let value = this.get('transactionHash'); let value = this.get("transactionHash");
return value.toBytes(); return value.toBytes();
} }
set transactionHash(value: Bytes) { set transactionHash(value: Bytes) {
this.set('transactionHash', Value.fromBytes(value)); this.set("transactionHash", Value.fromBytes(value));
} }
} }
export class Withdrawal extends Entity { export class Withdrawal extends Entity {
constructor(id: string) { constructor(id: string) {
super(); super();
this.set('id', Value.fromString(id)); this.set("id", Value.fromString(id));
} }
save(): void { save(): void {
let id = this.get('id'); let id = this.get("id");
assert(id !== null, 'Cannot save Withdrawal entity without an ID'); assert(id !== null, "Cannot save Withdrawal entity without an ID");
assert( assert(
id.kind == ValueKind.STRING, id.kind == ValueKind.STRING,
'Cannot save Withdrawal entity with non-string ID. ' + "Cannot save Withdrawal entity with non-string ID. " +
'Considering using .toHex() to convert the "id" to a string.', '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 { 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 { get id(): string {
let value = this.get('id'); let value = this.get("id");
return value.toString(); return value.toString();
} }
set id(value: string) { set id(value: string) {
this.set('id', Value.fromString(value)); this.set("id", Value.fromString(value));
} }
get to(): Bytes { get to(): Bytes {
let value = this.get('to'); let value = this.get("to");
return value.toBytes(); return value.toBytes();
} }
set to(value: Bytes) { set to(value: Bytes) {
this.set('to', Value.fromBytes(value)); this.set("to", Value.fromBytes(value));
} }
get fee(): BigInt { get fee(): BigInt {
let value = this.get('fee'); let value = this.get("fee");
return value.toBigInt(); return value.toBigInt();
} }
set fee(value: BigInt) { set fee(value: BigInt) {
this.set('fee', Value.fromBigInt(value)); this.set("fee", Value.fromBigInt(value));
} }
get index(): BigInt { get index(): BigInt {
let value = this.get('index'); let value = this.get("index");
return value.toBigInt(); return value.toBigInt();
} }
set index(value: BigInt) { set index(value: BigInt) {
this.set('index', Value.fromBigInt(value)); this.set("index", Value.fromBigInt(value));
} }
get amount(): string { get amount(): string {
let value = this.get('amount'); let value = this.get("amount");
return value.toString(); return value.toString();
} }
set amount(value: string) { set amount(value: string) {
this.set('amount', Value.fromString(value)); this.set("amount", Value.fromString(value));
} }
get currency(): string { get currency(): string {
let value = this.get('currency'); let value = this.get("currency");
return value.toString(); return value.toString();
} }
set currency(value: string) { set currency(value: string) {
this.set('currency', Value.fromString(value)); this.set("currency", Value.fromString(value));
} }
get nullifier(): Bytes { get nullifier(): Bytes {
let value = this.get('nullifier'); let value = this.get("nullifier");
return value.toBytes(); return value.toBytes();
} }
set nullifier(value: Bytes) { set nullifier(value: Bytes) {
this.set('nullifier', Value.fromBytes(value)); this.set("nullifier", Value.fromBytes(value));
} }
get timestamp(): BigInt { get timestamp(): BigInt {
let value = this.get('timestamp'); let value = this.get("timestamp");
return value.toBigInt(); return value.toBigInt();
} }
set timestamp(value: BigInt) { set timestamp(value: BigInt) {
this.set('timestamp', Value.fromBigInt(value)); this.set("timestamp", Value.fromBigInt(value));
} }
get blockNumber(): BigInt { get blockNumber(): BigInt {
let value = this.get('blockNumber'); let value = this.get("blockNumber");
return value.toBigInt(); return value.toBigInt();
} }
set blockNumber(value: BigInt) { set blockNumber(value: BigInt) {
this.set('blockNumber', Value.fromBigInt(value)); this.set("blockNumber", Value.fromBigInt(value));
} }
get transactionHash(): Bytes { get transactionHash(): Bytes {
let value = this.get('transactionHash'); let value = this.get("transactionHash");
return value.toBytes(); return value.toBytes();
} }
set transactionHash(value: Bytes) { set transactionHash(value: Bytes) {
this.set('transactionHash', Value.fromBytes(value)); this.set("transactionHash", Value.fromBytes(value));
} }
} }
export class EncryptedNote extends Entity { export class EncryptedNote extends Entity {
constructor(id: string) { constructor(id: string) {
super(); super();
this.set('id', Value.fromString(id)); this.set("id", Value.fromString(id));
} }
save(): void { save(): void {
let id = this.get('id'); let id = this.get("id");
assert(id !== null, 'Cannot save EncryptedNote entity without an ID'); assert(id !== null, "Cannot save EncryptedNote entity without an ID");
assert( assert(
id.kind == ValueKind.STRING, id.kind == ValueKind.STRING,
'Cannot save EncryptedNote entity with non-string ID. ' + "Cannot save EncryptedNote entity with non-string ID. " +
'Considering using .toHex() to convert the "id" to a string.', '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 { 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 { get id(): string {
let value = this.get('id'); let value = this.get("id");
return value.toString(); return value.toString();
} }
set id(value: string) { set id(value: string) {
this.set('id', Value.fromString(value)); this.set("id", Value.fromString(value));
} }
get index(): BigInt { get index(): BigInt {
let value = this.get('index'); let value = this.get("index");
return value.toBigInt(); return value.toBigInt();
} }
set index(value: BigInt) { set index(value: BigInt) {
this.set('index', Value.fromBigInt(value)); this.set("index", Value.fromBigInt(value));
} }
get blockNumber(): BigInt { get blockNumber(): BigInt {
let value = this.get('blockNumber'); let value = this.get("blockNumber");
return value.toBigInt(); return value.toBigInt();
} }
set blockNumber(value: BigInt) { set blockNumber(value: BigInt) {
this.set('blockNumber', Value.fromBigInt(value)); this.set("blockNumber", Value.fromBigInt(value));
} }
get encryptedNote(): Bytes { get encryptedNote(): Bytes {
let value = this.get('encryptedNote'); let value = this.get("encryptedNote");
return value.toBytes(); return value.toBytes();
} }
set encryptedNote(value: Bytes) { set encryptedNote(value: Bytes) {
this.set('encryptedNote', Value.fromBytes(value)); this.set("encryptedNote", Value.fromBytes(value));
} }
get transactionHash(): Bytes { get transactionHash(): Bytes {
let value = this.get('transactionHash'); let value = this.get("transactionHash");
return value.toBytes(); return value.toBytes();
} }
set transactionHash(value: Bytes) { set transactionHash(value: Bytes) {
this.set('transactionHash', Value.fromBytes(value)); this.set("transactionHash", Value.fromBytes(value));
} }
} }
export class NoteAccount extends Entity { export class NoteAccount extends Entity {
constructor(id: string) { constructor(id: string) {
super(); super();
this.set('id', Value.fromString(id)); this.set("id", Value.fromString(id));
} }
save(): void { save(): void {
let id = this.get('id'); let id = this.get("id");
assert(id !== null, 'Cannot save NoteAccount entity without an ID'); assert(id !== null, "Cannot save NoteAccount entity without an ID");
assert( assert(
id.kind == ValueKind.STRING, id.kind == ValueKind.STRING,
'Cannot save NoteAccount entity with non-string ID. ' + "Cannot save NoteAccount entity with non-string ID. " +
'Considering using .toHex() to convert the "id" to a string.', '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 { 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 { get id(): string {
let value = this.get('id'); let value = this.get("id");
return value.toString(); return value.toString();
} }
set id(value: string) { set id(value: string) {
this.set('id', Value.fromString(value)); this.set("id", Value.fromString(value));
} }
get index(): BigInt { get index(): BigInt {
let value = this.get('index'); let value = this.get("index");
return value.toBigInt(); return value.toBigInt();
} }
set index(value: BigInt) { set index(value: BigInt) {
this.set('index', Value.fromBigInt(value)); this.set("index", Value.fromBigInt(value));
} }
get address(): Bytes { get address(): Bytes {
let value = this.get('address'); let value = this.get("address");
return value.toBytes(); return value.toBytes();
} }
set address(value: Bytes) { set address(value: Bytes) {
this.set('address', Value.fromBytes(value)); this.set("address", Value.fromBytes(value));
} }
get encryptedAccount(): Bytes { get encryptedAccount(): Bytes {
let value = this.get('encryptedAccount'); let value = this.get("encryptedAccount");
return value.toBytes(); return value.toBytes();
} }
set encryptedAccount(value: Bytes) { set encryptedAccount(value: Bytes) {
this.set('encryptedAccount', Value.fromBytes(value)); this.set("encryptedAccount", Value.fromBytes(value));
} }
} }

@ -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',
},
},
],
};

@ -0,0 +1,10 @@
const contracts = [
{
prod: 8158799,
network: 'bsc',
name: 'Echoer',
address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
},
];
module.exports = contracts;

@ -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);
},
};

@ -0,0 +1,4 @@
module.exports = {
description: 'Echoer',
schemaFile: '../schema.graphql',
};

@ -1,11 +1,35 @@
const contracts = [ const contracts = [
{ {
prod: 7942402, prod: 8159279,
amount: '0.1', amount: '0.1',
network: 'bsc', network: 'bsc',
currency: 'bsc', currency: 'bnb',
name: 'Instance', 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',
}, },
]; ];

@ -5,12 +5,12 @@ const Contracts = require('./contracts');
module.exports = { module.exports = {
createYaml: (env) => { createYaml: (env) => {
const createInstanceBlock = ({ name, network, startBlocks, address }) => ({ const createInstanceBlock = ({ name, amount, currency, network, startBlocks, address }) => ({
name, name: `${name}-${amount}-${currency}`,
network, network,
mappingFile: '../src/mapping-instance.ts', mappingFile: '../src/mapping-instance.ts',
startBlock: startBlocks.prod, startBlock: startBlocks.prod,
address, address: `"${address}"`,
abi: 'Instance', abi: 'Instance',
entities: ['Deposit', 'Withdrawal'], entities: ['Deposit', 'Withdrawal'],
abis: [ abis: [
@ -39,7 +39,7 @@ module.exports = {
Contracts.forEach(({ address, name, amount, currency }) => { Contracts.forEach(({ address, name, amount, currency }) => {
if (address != null) { 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'); const targetFile = path.join(__dirname, '../../../src/', 'contractsToInstances.ts');
fs.writeFileSync(targetFile, contractsToInstancesContent, 'utf8'); fs.writeFileSync(targetFile, contractsToInstancesContent, 'utf8');
return Contracts.map(({ prod, name, network, address }) => { return Contracts.map(({ prod, name, amount, currency, network, address }) => {
const startBlocks = { prod }; const startBlocks = { prod };
if (network === env) { if (network === env) {
return createInstanceBlock({ name, startBlocks, network, address }); return createInstanceBlock({ name, startBlocks, amount, currency, network, address });
} }
}).filter((e) => e !== undefined); }).filter((e) => e !== undefined);
}, },

@ -1,9 +1,9 @@
const contracts = [ const contracts = [
{ {
prod: 7942402, prod: 8158799,
name: 'Proxy', name: 'Proxy',
network: 'bsc', network: 'bsc',
address: '0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7', address: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
}, },
]; ];

@ -8,7 +8,7 @@ module.exports = {
mappingFile: '../src/mapping-encrypted-note.ts', mappingFile: '../src/mapping-encrypted-note.ts',
abi: 'Proxy', abi: 'Proxy',
startBlock: 7941563, startBlock: 7941563,
address, address: `"${address}"`,
entities: ['EncryptedNote'], entities: ['EncryptedNote'],
abis: [ abis: [
{ {

@ -3,17 +3,14 @@
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",
"yaml:proxy": "node ./create-yaml-file create-yaml -s proxy -e bsc | mustache - mustache/yaml.mustache > subgraphs/proxy-tornado-subgraph.yaml", "generate": "yarn codegen:tornado && yarn build:tornado",
"yaml:instance": "node ./create-yaml-file create-yaml -s instance -e bsc | mustache - mustache/yaml.mustache > subgraphs/instance-tornado-subgraph.yaml", "yaml:tornado": "node ./create-yaml-file create-yaml -e bsc | mustache - mustache/yaml.mustache > subgraphs/tornado-subgraph.yaml",
"codegen": "graph codegen", "codegen": "graph codegen",
"codegen:proxy": "yarn yaml:proxy && yarn codegen -- subgraphs/proxy-tornado-subgraph.yaml", "codegen:tornado": "yarn yaml:tornado && yarn codegen -- subgraphs/tornado-subgraph.yaml",
"codegen:instance": "yarn yaml:instance && yarn codegen -- subgraphs/instance-tornado-subgraph.yaml",
"build": "graph build", "build": "graph build",
"build:proxy": "graph build subgraphs/proxy-tornado-subgraph.yaml", "build:tornado": "graph build subgraphs/tornado-subgraph.yaml",
"build:instance": "graph build subgraphs/instance-tornado-subgraph.yaml",
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ tornadocash/bsc-tornado-subgraph", "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:tornado": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/tornado-subgraph.yaml"
"deploy:instance": "yarn deploy -- tornadocash/bsc-tornado-subgraph subgraphs/instance-tornado-subgraph.yaml"
}, },
"dependencies": { "dependencies": {
"@graphprotocol/graph-cli": "0.20.0", "@graphprotocol/graph-cli": "0.20.0",

@ -1,7 +1,19 @@
// this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js. // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js.
export let contractsToInstances = new Map<string, string>(); export let contractsToInstances = new Map<string, string>();
contractsToInstances.set( contractsToInstances.set(
'0x0ce22770451a8acad1220d9d1678656b4fae4a1d', // Instance-bsc-0.1 '0x84443cfd09a48af6ef360c6976c5392ac5023a1f', // Instance-bnb-0.1
'0.1-bsc', '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. // this is a read only file generated by manual inputs to file mustache/templates/rates/contracts.js.

@ -6,7 +6,7 @@ dataSources:
name: Proxy name: Proxy
network: bsc network: bsc
source: source:
address: "0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7" address: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17"
abi: Proxy abi: Proxy
startBlock: 7941563 startBlock: 7941563
mapping: mapping:

@ -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

@ -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

@ -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