feat: generated index ts

This commit is contained in:
nikdementev 2021-06-14 15:58:57 +03:00 committed by 0xZick 地方分権化
parent fe4f037db7
commit 2d53ee717a
7 changed files with 232 additions and 14 deletions

1
.gitignore vendored
View File

@ -67,4 +67,3 @@ build
generated generated
.DS_Store .DS_Store
subgraphs

View File

@ -36,17 +36,24 @@ module.exports = {
const space = '\xa0'; const space = '\xa0';
const doubleSpace = space + space; const doubleSpace = space + space;
let contractsToInstancesContent = `${readOnlyComment}export let contractsToInstances = new Map<string, string>();${newLine}`; let contractsToInstancesContent = `${readOnlyComment}export let contractsToInstances = new Map<string, string>();${newLine}`;
let reExportContent = '';
Contracts.forEach(({ address, name, amount, currency }) => { Contracts.forEach(({ address, name, network, amount, currency }) => {
if (address != null) { if (address != null) {
contractsToInstancesContent += `contractsToInstances.set("${address.toLowerCase()}",${space}//${space}${name}-${currency}-${amount}${newLine}${doubleSpace}"${currency}${'-'}${amount}"${newLine});${newLine}`; contractsToInstancesContent += `contractsToInstances.set("${address.toLowerCase()}",${space}//${space}${name}-${currency}-${amount}${newLine}${doubleSpace}"${currency}${'-'}${amount}"${newLine});${newLine}`;
} }
if (network === env && reExportContent === '') {
reExportContent += `${readOnlyComment}${newLine}export * from "./${name}-${amount}-${currency}/Instance";${newLine}`;
}
}); });
contractsToInstancesContent += readOnlyComment; contractsToInstancesContent += readOnlyComment;
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');
const targetIndexFile = path.join(__dirname, '../../../generated/', 'index.ts');
fs.writeFileSync(targetIndexFile, reExportContent, 'utf8');
return Contracts.map(({ prod, name, amount, currency, network, address }) => { return Contracts.map(({ prod, name, amount, currency, network, address }) => {
const startBlocks = { prod }; const startBlocks = { prod };
if (network === env) { if (network === env) {

View File

@ -1,18 +1,23 @@
// 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("0x84443cfd09a48af6ef360c6976c5392ac5023a1f", // Instance-bnb-0.1 contractsToInstances.set(
  "bnb-0.1" '0x84443cfd09a48af6ef360c6976c5392ac5023a1f', // Instance-bnb-0.1
'bnb-0.1',
); );
contractsToInstances.set("0xd47438c816c9e7f2e2888e060936a499af9582b3", // Instance-bnb-1 contractsToInstances.set(
  "bnb-1" '0xd47438c816c9e7f2e2888e060936a499af9582b3', // Instance-bnb-1
'bnb-1',
); );
contractsToInstances.set("0x330bdfade01ee9bf63c209ee33102dd334618e0a", // Instance-bnb-10 contractsToInstances.set(
  "bnb-10" '0x330bdfade01ee9bf63c209ee33102dd334618e0a', // Instance-bnb-10
'bnb-10',
); );
contractsToInstances.set("0x1e34a77868e19a6647b1f2f47b51ed72dede95dd", // Instance-bnb-100 contractsToInstances.set(
  "bnb-100" '0x1e34a77868e19a6647b1f2f47b51ed72dede95dd', // Instance-bnb-100
'bnb-100',
); );
contractsToInstances.set("0x992a81fa34aa6ecd9520f39f858abc51fee6994a", // Instance-matic-0.1 contractsToInstances.set(
  "matic-0.1" '0x992a81fa34aa6ecd9520f39f858abc51fee6994a', // Instance-matic-0.1
'matic-0.1',
); );
// 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.

View File

@ -1,4 +1,4 @@
import { Withdrawal, Deposit } from '../generated/Instance-1-bnb/Instance'; 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';

View File

@ -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: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4"
abi: Echoer
startBlock: 8159269
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: 8158799
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

View File

@ -0,0 +1,69 @@
specVersion: 0.0.2
description: Proxy
repository: https://github.com/tornadocash/tornado-subgraph
schema:
file: ../schema.graphql
dataSources:
- kind: ethereum/contract
name: Echoer
network: matic
source:
address: "0x88Fb545DC03438b9FFb958361b7F3CfA6ce1B9c5"
abi: Echoer
startBlock: 15586935
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-matic
network: matic
source:
address: "0x992A81FA34aa6ecD9520F39f858abc51fee6994a"
abi: Instance
startBlock: 15586940
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: matic
source:
address: "0xDC16d16341A62c60E7C9889F9d1FcE4cde57a90F"
abi: Proxy
startBlock: 15586930
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