This commit is contained in:
Danil Kovtonyuk 2021-10-15 16:11:20 +10:00
commit a129d70e88
No known key found for this signature in database
GPG Key ID: E72A919BF08C3746
7 changed files with 3144 additions and 0 deletions

69
.gitignore vendored Normal file

@ -0,0 +1,69 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
build
.vscode
.idea
.env
generated
.DS_Store

152
abis/BridgeHelper.json Normal file

@ -0,0 +1,152 @@
[
{
"inputs": [
{
"internalType": "contract IOmnibridge",
"name": "_bridge",
"type": "address"
},
{ "internalType": "contract IWETH", "name": "_weth", "type": "address" },
{ "internalType": "address", "name": "_owner", "type": "address" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
"name": "key",
"type": "bytes"
}
],
"name": "PublicKey",
"type": "event"
},
{
"inputs": [],
"name": "WETH",
"outputs": [
{ "internalType": "contract IWETH", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "bridge",
"outputs": [
{ "internalType": "contract IOmnibridge", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_token", "type": "address" },
{ "internalType": "address", "name": "_to", "type": "address" }
],
"name": "claimTokens",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_token", "type": "address" },
{ "internalType": "uint256", "name": "_value", "type": "uint256" },
{ "internalType": "bytes", "name": "_data", "type": "bytes" }
],
"name": "onTokenBridged",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"components": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "bytes", "name": "publicKey", "type": "bytes" }
],
"internalType": "struct L1Helper.Account",
"name": "_account",
"type": "tuple"
}
],
"name": "register",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_newOwner", "type": "address" }
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "wrapAndRelayTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_receiver", "type": "address" },
{ "internalType": "bytes", "name": "_data", "type": "bytes" }
],
"name": "wrapAndRelayTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_receiver", "type": "address" },
{ "internalType": "bytes", "name": "_data", "type": "bytes" },
{
"components": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "bytes", "name": "publicKey", "type": "bytes" }
],
"internalType": "struct L1Helper.Account",
"name": "_account",
"type": "tuple"
}
],
"name": "wrapAndRelayTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_receiver", "type": "address" }
],
"name": "wrapAndRelayTokens",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{ "stateMutability": "payable", "type": "receive" }
]

16
package.json Normal file

@ -0,0 +1,16 @@
{
"name": "tornado-pool-subgraph",
"license": "UNLICENSED",
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ tornadocash/tornado-pool-subgraph",
"create-local": "graph create --node http://localhost:8020/ tornadocash/tornado-pool-subgraph",
"remove-local": "graph remove --node http://localhost:8020/ tornadocash/tornado-pool-subgraph",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 tornadocash/tornado-pool-subgraph"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.22.3",
"@graphprotocol/graph-ts": "0.22.1"
}
}

6
schema.graphql Normal file

@ -0,0 +1,6 @@
type Account @entity {
id: ID!
key: Bytes!
owner: Bytes!
blockNumber: BigInt!
}

14
src/mapping.ts Normal file

@ -0,0 +1,14 @@
import { Account } from "../generated/schema";
import { PublicKey } from "../generated/BridgeHelper/BridgeHelper";
export function handlePublicKey(event: PublicKey): void {
let entity = new Account(
event.transaction.from.toHex() + "-" + event.logIndex.toString()
);
entity.key = event.params.key;
entity.owner = event.params.owner;
entity.blockNumber = event.block.number;
entity.save();
}

24
subgraph.yaml Normal file

@ -0,0 +1,24 @@
specVersion: 0.0.2
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: BridgeHelper
network: bsc
source:
address: "0x2353Dcda746fa1AAD17C5650Ddf2A20112862197"
abi: BridgeHelper
startBlock: 11559625
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- PublicKey
abis:
- name: BridgeHelper
file: ./abis/BridgeHelper.json
eventHandlers:
- event: PublicKey(indexed address,bytes)
handler: handlePublicKey
file: ./src/mapping.ts

2863
yarn.lock Normal file

File diff suppressed because it is too large Load Diff