feat: lint

This commit is contained in:
nikdementev 2021-06-09 17:39:13 +03:00 committed by 0xZick 地方分権化
parent e41ccc05a4
commit f48236f744
20 changed files with 1281 additions and 203 deletions

46
.eslintrc.js Normal file

@ -0,0 +1,46 @@
module.exports = {
env: {
es6: true,
node: true,
},
plugins: ['import'],
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
// use <root>/tsconfig.json
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<roo/>@types` directory even it doesn't contain any source code, like `@types/unist`
},
},
},
ignorePatterns: ['**/generated/**/*', '**/build/**/*'],
rules: {
quotes: ['error', 'single'],
'import/no-unresolved': 2,
'no-undef': 2,
'prefer-const': 0,
semi: ['error', 'always'],
'no-console': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/class-name-casing': 0,
'@typescript-eslint/no-var-requires': 0,
},
};

7
.prettierrc.js Normal file

@ -0,0 +1,7 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};

@ -21,9 +21,7 @@ program
const dataSourcesPath = path.join(__dirname, 'mustache', 'templates', subgraph, 'create-yaml.js'); const dataSourcesPath = path.join(__dirname, 'mustache', 'templates', subgraph, 'create-yaml.js');
const subgraphDataSourcesData = require(dataSourcesPath); const subgraphDataSourcesData = require(dataSourcesPath);
const dataSourcesData = [ const dataSourcesData = [...subgraphDataSourcesData.createYaml(env)];
...subgraphDataSourcesData.createYaml(env),
];
const indexData = require(baseIndexPath); const indexData = require(baseIndexPath);

@ -1,14 +1,6 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
import { import { ethereum, JSONValue, TypedMap, Entity, Bytes, Address, BigInt } from '@graphprotocol/graph-ts';
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 {
@ -34,6 +26,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,14 +1,6 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
import { import { ethereum, JSONValue, TypedMap, Entity, Bytes, Address, BigInt } from '@graphprotocol/graph-ts';
ethereum,
JSONValue,
TypedMap,
Entity,
Bytes,
Address,
BigInt
} from "@graphprotocol/graph-ts";
export class Deposit extends ethereum.Event { export class Deposit extends ethereum.Event {
get params(): Deposit__Params { get params(): Deposit__Params {
@ -68,6 +60,6 @@ export class Withdrawal__Params {
export class Instance extends ethereum.SmartContract { export class Instance extends ethereum.SmartContract {
static bind(address: Address): Instance { static bind(address: Address): Instance {
return new Instance("Instance", address); return new Instance('Instance', address);
} }
} }

@ -1,14 +1,6 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
import { import { ethereum, JSONValue, TypedMap, Entity, Bytes, Address, BigInt } from '@graphprotocol/graph-ts';
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 {
@ -34,6 +26,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,3 +1,3 @@
export * from './Proxy/Proxy' export * from './Proxy/Proxy';
export * from './Echoer/Echoer' export * from './Echoer/Echoer';
export * from './Instance/Instance' export * from './Instance/Instance';

@ -1,344 +1,333 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
import { import { TypedMap, Entity, Value, ValueKind, store, Address, Bytes, BigInt, BigDecimal } from '@graphprotocol/graph-ts';
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. " + 'Cannot save Deposit 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("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,4 +1,3 @@
module.exports = { module.exports = {
base: { base: {
specVersion: '0.0.2', specVersion: '0.0.2',
@ -11,7 +10,7 @@ module.exports = {
name: 'Instance', name: 'Instance',
network: 'bsc', network: 'bsc',
dataSourceKind: 'ethereum/contract', dataSourceKind: 'ethereum/contract',
address: "0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7", address: '0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7',
abi: 'Instance', abi: 'Instance',
startBlock: 7941563, startBlock: 7941563,
mapping: { mapping: {
@ -31,16 +30,16 @@ module.exports = {
{ {
event: 'Withdrawal(address,bytes32,indexed address,uint256)', event: 'Withdrawal(address,bytes32,indexed address,uint256)',
handler: 'handleWithdrawal', handler: 'handleWithdrawal',
} },
], ],
file: './src/mapping-proxy.ts', file: './src/mapping-proxy.ts',
} },
}, },
{ {
name: 'Echoer', name: 'Echoer',
network: 'bsc', network: 'bsc',
dataSourceKind: 'ethereum/contract', dataSourceKind: 'ethereum/contract',
address: "0x60eaCBd5535ADB86955A0154E44Aded78F161643", address: '0x60eaCBd5535ADB86955A0154E44Aded78F161643',
abi: 'Echoer', abi: 'Echoer',
startBlock: 7941563, startBlock: 7941563,
mapping: { mapping: {
@ -59,12 +58,12 @@ module.exports = {
}, },
], ],
file: './src/mapping-echo-account.ts', file: './src/mapping-echo-account.ts',
} },
}, },
{ {
name: 'Proxy', name: 'Proxy',
dataSourceKind: 'ethereum/contract', dataSourceKind: 'ethereum/contract',
address: "0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d", address: '0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d',
abi: 'Proxy', abi: 'Proxy',
startBlock: 7941563, startBlock: 7941563,
mapping: { mapping: {
@ -83,7 +82,7 @@ module.exports = {
}, },
], ],
file: './src/mapping-encrypted-note.ts', file: './src/mapping-encrypted-note.ts',
} },
}, },
], ],
}; };

@ -4,14 +4,14 @@ const createStartBlock = (blocks, env) => {
? blocks.exchanger.test ? blocks.exchanger.test
? blocks.exchanger.test ? blocks.exchanger.test
: blocks.exchanger.prod : blocks.exchanger.prod
: blocks.test || blocks.prod : blocks.test || blocks.prod;
} else if (env === 'prod') { } else if (env === 'prod') {
return blocks.exchanger && blocks.exchanger.prod ? blocks.exchanger.prod : blocks.prod return blocks.exchanger && blocks.exchanger.prod ? blocks.exchanger.prod : blocks.prod;
} else { } else {
throw new Error('Invalid env for creating a yaml file') throw new Error('Invalid env for creating a yaml file');
}
} }
};
module.exports = { module.exports = {
createStartBlock, createStartBlock,
} };

@ -1,8 +1,3 @@
const duplicateStartBlocks = {
one: 10773070,
two: 10873070,
};
const contracts = [ const contracts = [
{ {
prod: 7942402, prod: 7942402,
@ -10,8 +5,8 @@ const contracts = [
network: 'bsc', network: 'bsc',
currency: 'bsc', currency: 'bsc',
name: 'Instance', name: 'Instance',
address: "'0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d'", address: '0x0Ce22770451A8acAD1220D9d1678656b4fAe4a1d',
}, },
] ];
module.exports = contracts; module.exports = contracts;

@ -5,7 +5,6 @@ const Contracts = require('./contracts');
module.exports = { module.exports = {
createYaml: (env) => { createYaml: (env) => {
const createInstanceBlock = ({ name, network, startBlocks, address }) => ({ const createInstanceBlock = ({ name, network, startBlocks, address }) => ({
name, name,
network, network,
@ -17,8 +16,8 @@ module.exports = {
abis: [ abis: [
{ {
name: 'Instance', name: 'Instance',
path: '../abis/Instance.json' path: '../abis/Instance.json',
} },
], ],
events: [ events: [
{ {
@ -28,7 +27,7 @@ module.exports = {
{ {
event: 'Withdrawal(address,bytes32,indexed address,uint256)', event: 'Withdrawal(address,bytes32,indexed address,uint256)',
handler: 'handleWithdrawal', handler: 'handleWithdrawal',
} },
], ],
}); });
@ -51,8 +50,8 @@ module.exports = {
return Contracts.map(({ prod, name, network, address }) => { return Contracts.map(({ prod, name, network, address }) => {
const startBlocks = { prod }; const startBlocks = { prod };
if (network === env) { if (network === env) {
return createInstanceBlock({ name, startBlocks, network, address }) return createInstanceBlock({ name, startBlocks, network, address });
} }
}).filter(e => e !== undefined); }).filter((e) => e !== undefined);
}, },
}; };

@ -1,15 +1,10 @@
const duplicateStartBlocks = {
one: 10773070,
two: 10873070,
};
const contracts = [ const contracts = [
{ {
prod: 7942402, prod: 7942402,
name: 'Proxy', name: 'Proxy',
network: 'bsc', network: 'bsc',
address: "'0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7'", address: '0x5D595DB16eb6d074E0e7E7f0bE37E7e75f23BEc7',
}, },
] ];
module.exports = contracts; module.exports = contracts;

@ -2,7 +2,6 @@ const Contracts = require('./contracts');
module.exports = { module.exports = {
createYaml: (env) => { createYaml: (env) => {
const createProxyBlock = ({ name, network, address }) => ({ const createProxyBlock = ({ name, network, address }) => ({
name, name,
network, network,
@ -14,22 +13,22 @@ module.exports = {
abis: [ abis: [
{ {
event: 'Proxy', event: 'Proxy',
path: '../abis/Proxy.json' path: '../abis/Proxy.json',
} },
], ],
events: [ events: [
{ {
event: 'EncryptedNote(indexed address,bytes)', event: 'EncryptedNote(indexed address,bytes)',
handler: 'handleEncryptedNote', handler: 'handleEncryptedNote',
} },
], ],
}); });
return Contracts.map(({ prod, name, network, address }) => { return Contracts.map(({ prod, name, network, address }) => {
const startBlocks = { prod }; const startBlocks = { prod };
if (network === env) { if (network === env) {
return createProxyBlock({ name, startBlocks, network, address }) return createProxyBlock({ name, startBlocks, network, address });
} }
}).filter(e => e !== undefined); }).filter((e) => e !== undefined);
}, },
}; };

@ -2,6 +2,7 @@
"name": "sub-graph-proxy", "name": "sub-graph-proxy",
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "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: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", "yaml:instance": "node ./create-yaml-file create-yaml -s instance -e bsc | mustache - mustache/yaml.mustache > subgraphs/instance-tornado-subgraph.yaml",
"codegen": "graph codegen", "codegen": "graph codegen",
@ -19,7 +20,16 @@
"@graphprotocol/graph-ts": "0.20.0" "@graphprotocol/graph-ts": "0.20.0"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"commander": "^7.2.0", "commander": "^7.2.0",
"mustache": "^4.2.0" "eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"mustache": "^4.2.0",
"prettier": "^2.3.1",
"typescript": "^4.3.2"
} }
} }

@ -1,6 +1,7 @@
// 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('0x0ce22770451a8acad1220d9d1678656b4fae4a1d', // Instance-bsc-0.1 contractsToInstances.set(
  "0.1-bsc" '0x0ce22770451a8acad1220d9d1678656b4fae4a1d', // Instance-bsc-0.1
'0.1-bsc',
); );
// 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.

@ -1,5 +1,5 @@
import { Echo } from '../generated' import { Echo } from '../generated';
import { NoteAccount as NoteAccountEntity } from '../generated/schema' import { NoteAccount as NoteAccountEntity } from '../generated/schema';
export function handleEcho(event: Echo): void { export function handleEcho(event: Echo): void {
let entity = new NoteAccountEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString()); let entity = new NoteAccountEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString());

@ -1,5 +1,5 @@
import { EncryptedNote } from '../generated' import { EncryptedNote } from '../generated';
import { EncryptedNote as EncryptedNoteEntity } from '../generated/schema' import { EncryptedNote as EncryptedNoteEntity } from '../generated/schema';
export function handleEncryptedNote(event: EncryptedNote): void { export function handleEncryptedNote(event: EncryptedNote): void {
let entity = new EncryptedNoteEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString()); let entity = new EncryptedNoteEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString());

@ -1,7 +1,7 @@
import { Withdrawal, Deposit } from '../generated' import { Withdrawal, Deposit } from '../generated';
import { Withdrawal as WithdrawalEntity, Deposit as DepositEntity } from '../generated/schema' import { Withdrawal as WithdrawalEntity, Deposit as DepositEntity } from '../generated/schema';
import { contractsToInstances } from './contractsToInstances' import { contractsToInstances } from './contractsToInstances';
export function handleWithdrawal(event: Withdrawal): void { export function handleWithdrawal(event: Withdrawal): void {
let entity = new WithdrawalEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString()); let entity = new WithdrawalEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString());
@ -23,7 +23,7 @@ export function handleWithdrawal(event: Withdrawal): void {
} }
export function handleDeposit(event: Deposit): void { export function handleDeposit(event: Deposit): void {
let entity = new DepositEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString()) let entity = new DepositEntity(event.transaction.hash.toHex() + '-' + event.logIndex.toString());
let result = contractsToInstances.get(event.address.toHexString()).split('-'); let result = contractsToInstances.get(event.address.toHexString()).split('-');
@ -36,5 +36,5 @@ export function handleDeposit(event: Deposit): void {
entity.commitment = event.params.commitment; entity.commitment = event.params.commitment;
entity.transactionHash = event.transaction.hash; entity.transactionHash = event.transaction.hash;
entity.save() entity.save();
} }

1106
yarn.lock

File diff suppressed because it is too large Load Diff