Initial commit

This commit is contained in:
Tornado Contrib 2024-04-28 05:08:14 +00:00
commit d50b759ebe
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
9 changed files with 4799 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

422
abis/Governance.json Normal file

@ -0,0 +1,422 @@
[
{
"inputs": [
{ "internalType": "address", "name": "_gasCompLogic", "type": "address" },
{ "internalType": "address", "name": "_userVault", "type": "address" }
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" }
],
"name": "Delegated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "uint256", "name": "id", "type": "uint256" },
{ "indexed": true, "internalType": "address", "name": "proposer", "type": "address" },
{ "indexed": false, "internalType": "address", "name": "target", "type": "address" },
{ "indexed": false, "internalType": "uint256", "name": "startTime", "type": "uint256" },
{ "indexed": false, "internalType": "uint256", "name": "endTime", "type": "uint256" },
{ "indexed": false, "internalType": "string", "name": "description", "type": "string" }
],
"name": "ProposalCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "internalType": "uint256", "name": "proposalId", "type": "uint256" }],
"name": "ProposalExecuted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" },
{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }
],
"name": "Undelegated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "internalType": "uint256", "name": "proposalId", "type": "uint256" },
{ "indexed": true, "internalType": "address", "name": "voter", "type": "address" },
{ "indexed": true, "internalType": "bool", "name": "support", "type": "bool" },
{ "indexed": false, "internalType": "uint256", "name": "votes", "type": "uint256" }
],
"name": "Voted",
"type": "event"
},
{
"inputs": [],
"name": "CLOSING_PERIOD",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "EXECUTION_DELAY",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "EXECUTION_EXPIRATION",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PROPOSAL_THRESHOLD",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "QUORUM_VOTES",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VOTE_EXTEND_TIME",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VOTING_DELAY",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VOTING_PERIOD",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32[]", "name": "domains", "type": "bytes32[]" }],
"name": "bulkResolve",
"outputs": [{ "internalType": "address[]", "name": "result", "type": "address[]" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "canWithdrawAfter",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "from", "type": "address[]" },
{ "internalType": "uint256", "name": "proposalId", "type": "uint256" },
{ "internalType": "bool", "name": "support", "type": "bool" }
],
"name": "castDelegatedVote",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "proposalId", "type": "uint256" },
{ "internalType": "bool", "name": "support", "type": "bool" }
],
"name": "castVote",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "proposalId", "type": "uint256" }],
"name": "checkIfQuorumReached",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
"name": "delegate",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "delegatedTo",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "proposalId", "type": "uint256" }],
"name": "execute",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "gasCompensationVault",
"outputs": [{ "internalType": "contract IGasCompensationVault", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "proposalId", "type": "uint256" },
{ "internalType": "address", "name": "voter", "type": "address" }
],
"name": "getReceipt",
"outputs": [
{
"components": [
{ "internalType": "bool", "name": "hasVoted", "type": "bool" },
{ "internalType": "bool", "name": "support", "type": "bool" },
{ "internalType": "uint256", "name": "votes", "type": "uint256" }
],
"internalType": "struct Governance.Receipt",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "proposalId", "type": "uint256" },
{ "internalType": "address", "name": "account", "type": "address" }
],
"name": "hasAccountVoted",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32", "name": "_torn", "type": "bytes32" }],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "latestProposalIds",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{ "internalType": "uint8", "name": "v", "type": "uint8" },
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
],
"name": "lock",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
"name": "lockWithApproval",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
"name": "lockedBalance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "proposalCount",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"name": "proposals",
"outputs": [
{ "internalType": "address", "name": "proposer", "type": "address" },
{ "internalType": "address", "name": "target", "type": "address" },
{ "internalType": "uint256", "name": "startTime", "type": "uint256" },
{ "internalType": "uint256", "name": "endTime", "type": "uint256" },
{ "internalType": "uint256", "name": "forVotes", "type": "uint256" },
{ "internalType": "uint256", "name": "againstVotes", "type": "uint256" },
{ "internalType": "bool", "name": "executed", "type": "bool" },
{ "internalType": "bool", "name": "extended", "type": "bool" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "target", "type": "address" },
{ "internalType": "string", "name": "description", "type": "string" }
],
"name": "propose",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "from", "type": "address" },
{ "internalType": "address", "name": "target", "type": "address" },
{ "internalType": "string", "name": "description", "type": "string" }
],
"name": "proposeByDelegate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32", "name": "node", "type": "bytes32" }],
"name": "resolve",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "returnMultisigAddress",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "closingPeriod", "type": "uint256" }],
"name": "setClosingPeriod",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "executionDelay", "type": "uint256" }],
"name": "setExecutionDelay",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "executionExpiration", "type": "uint256" }],
"name": "setExecutionExpiration",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "gasCompensationsLimit", "type": "uint256" }],
"name": "setGasCompensations",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "proposalThreshold", "type": "uint256" }],
"name": "setProposalThreshold",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "quorumVotes", "type": "uint256" }],
"name": "setQuorumVotes",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "voteExtendTime", "type": "uint256" }],
"name": "setVoteExtendTime",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "votingDelay", "type": "uint256" }],
"name": "setVotingDelay",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "votingPeriod", "type": "uint256" }],
"name": "setVotingPeriod",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "proposalId", "type": "uint256" }],
"name": "state",
"outputs": [{ "internalType": "enum Governance.ProposalState", "name": "", "type": "uint8" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "torn",
"outputs": [{ "internalType": "contract TORN", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{ "inputs": [], "name": "undelegate", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
{
"inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
"name": "unlock",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "userVault",
"outputs": [{ "internalType": "contract ITornadoVault", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
"name": "withdrawFromHelper",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ "stateMutability": "payable", "type": "receive" }
]

670
abis/RelayerRegistry.json Normal file

@ -0,0 +1,670 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_torn",
"type": "address"
},
{
"internalType": "address",
"name": "_governance",
"type": "address"
},
{
"internalType": "address",
"name": "_ens",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_staking",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_feeManager",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "minStakeAmount",
"type": "uint256"
}
],
"name": "MinimumStakeAmount",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "relayer",
"type": "address"
}
],
"name": "RelayerBalanceNullified",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32",
"name": "relayer",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "string",
"name": "ensName",
"type": "string"
},
{
"indexed": false,
"internalType": "address",
"name": "relayerAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "stakedAmount",
"type": "uint256"
}
],
"name": "RelayerRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "tornadoRouter",
"type": "address"
}
],
"name": "RouterRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountStakeAdded",
"type": "uint256"
}
],
"name": "StakeAddedToRelayer",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountBurned",
"type": "uint256"
}
],
"name": "StakeBurned",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "worker",
"type": "address"
}
],
"name": "WorkerRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "worker",
"type": "address"
}
],
"name": "WorkerUnregistered",
"type": "event"
},
{
"inputs": [
{
"internalType": "bytes32[]",
"name": "domains",
"type": "bytes32[]"
}
],
"name": "bulkResolve",
"outputs": [
{
"internalType": "address[]",
"name": "result",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"internalType": "contract ITornadoInstance",
"name": "pool",
"type": "address"
}
],
"name": "burn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "ens",
"outputs": [
{
"internalType": "contract IENS",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "feeManager",
"outputs": [
{
"internalType": "contract FeeManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
}
],
"name": "getRelayerBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
}
],
"name": "getRelayerEnsHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "governance",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_tornadoRouter",
"type": "bytes32"
}
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "toResolve",
"type": "address"
}
],
"name": "isRelayer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"internalType": "address",
"name": "toResolve",
"type": "address"
}
],
"name": "isRelayerRegistered",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "minStakeAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
}
],
"name": "nullifyBalance",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "ensName",
"type": "string"
},
{
"internalType": "uint256",
"name": "stake",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "workersToRegister",
"type": "address[]"
}
],
"name": "register",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "ensName",
"type": "string"
},
{
"internalType": "uint256",
"name": "stake",
"type": "uint256"
},
{
"internalType": "address[]",
"name": "workersToRegister",
"type": "address[]"
},
{
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
},
{
"internalType": "uint8",
"name": "v",
"type": "uint8"
},
{
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}
],
"name": "registerPermit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"internalType": "address",
"name": "worker",
"type": "address"
}
],
"name": "registerWorker",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "relayers",
"outputs": [
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "ensHash",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "node",
"type": "bytes32"
}
],
"name": "resolve",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "minAmount",
"type": "uint256"
}
],
"name": "setMinStakeAmount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tornadoRouterAddress",
"type": "address"
}
],
"name": "setTornadoRouter",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"internalType": "uint256",
"name": "stake",
"type": "uint256"
}
],
"name": "stakeToRelayer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "relayer",
"type": "address"
},
{
"internalType": "uint256",
"name": "stake",
"type": "uint256"
},
{
"internalType": "address",
"name": "staker",
"type": "address"
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
},
{
"internalType": "uint8",
"name": "v",
"type": "uint8"
},
{
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}
],
"name": "stakeToRelayerPermit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "staking",
"outputs": [
{
"internalType": "contract ITornadoStakingRewards",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "torn",
"outputs": [
{
"internalType": "contract TORN",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tornadoRouter",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "worker",
"type": "address"
}
],
"name": "unregisterWorker",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "workers",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]

17
package.json Normal file

@ -0,0 +1,17 @@
{
"name": "tornado-governance-subgraph",
"license": "MIT",
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"create-local": "graph create --node http://127.0.0.1:8020 tornadocash/tornado-governance",
"deploy": "graph deploy --node http://127.0.0.1:8020 --ipfs http://127.0.0.1:5001 tornadocash/tornado-governance"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.27.0",
"@graphprotocol/graph-ts": "0.24.1"
},
"resolutions": {
"concat-stream": "2.0.0"
}
}

69
schema.graphql Normal file

@ -0,0 +1,69 @@
type Proposal @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
logIndex: Int!
transactionHash: Bytes!
proposalId: Int!
proposer: Bytes!
target: Bytes!
startTime: Int!
endTime: Int!
description: String!
executed: Boolean!
}
type Voted @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
logIndex: Int!
transactionHash: Bytes!
proposalId: Int!
voter: Bytes!
support: Boolean!
votes: BigInt!
from: Bytes!
input: Bytes!
}
type Delegated @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
logIndex: Int!
transactionHash: Bytes!
account: Bytes!
delegateTo: Bytes!
}
type Undelegated @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
logIndex: Int!
transactionHash: Bytes!
account: Bytes!
delegateFrom: Bytes!
}
type StakeBurned @entity {
id: ID!
timestamp: Int!
blockNumber: Int!
logIndex: Int!
transactionHash: Bytes!
relayer: Bytes!
amountBurned: BigInt!
}
type StakeDailyBurned @entity {
id: ID!
date: Int!
dailyAmountBurned: BigInt!
}

134
src/mapping.ts Normal file

@ -0,0 +1,134 @@
import { BigInt } from "@graphprotocol/graph-ts";
import {
Proposal,
Voted,
Delegated,
Undelegated,
StakeBurned,
StakeDailyBurned,
} from "../generated/schema";
import {
ProposalCreated,
ProposalExecuted,
Voted as VotedEvent,
Delegated as DelegatedEvent,
Undelegated as UndelegatedEvent,
} from "../generated/Governance/Governance";
import {
StakeBurned as StakeBurnedEvent
} from "../generated/RelayerRegistry/RelayerRegistry";
export let ZERO_BI = BigInt.fromI32(0);
export function handleProposalCreated(event: ProposalCreated): void {
let proposal = Proposal.load(event.params.id.toString());
if (proposal === null) {
proposal = new Proposal(event.params.id.toString());
proposal.timestamp = event.block.timestamp.toI32();
proposal.blockNumber = event.block.number.toI32();
proposal.logIndex = event.logIndex.toI32();
proposal.transactionHash = event.transaction.hash;
proposal.proposalId = event.params.id.toI32();
proposal.proposer = event.params.proposer;
proposal.target = event.params.target;
proposal.startTime = event.params.startTime.toI32();
proposal.endTime = event.params.endTime.toI32();
proposal.description = event.params.description;
proposal.executed = false;
proposal.save();
}
}
export function handleProposalExecuted(event: ProposalExecuted): void {
let proposal = Proposal.load(event.params.proposalId.toString());
if (proposal !== null) {
proposal.executed = true;
proposal.save();
}
}
export function handleVoted(event: VotedEvent): void {
let voted = Voted.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (voted === null) {
voted = new Voted(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
voted.timestamp = event.block.timestamp.toI32();
voted.blockNumber = event.block.number.toI32();
voted.logIndex = event.logIndex.toI32();
voted.transactionHash = event.transaction.hash;
voted.proposalId = event.params.proposalId.toI32();
voted.voter = event.params.voter;
voted.support = event.params.support;
voted.votes = event.params.votes;
voted.from = event.transaction.from;
voted.input = event.transaction.input;
voted.save();
}
}
export function handleDelegated(event: DelegatedEvent): void {
let delegated = Delegated.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (delegated === null) {
delegated = new Delegated(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
delegated.timestamp = event.block.timestamp.toI32();
delegated.blockNumber = event.block.number.toI32();
delegated.logIndex = event.logIndex.toI32();
delegated.transactionHash = event.transaction.hash;
delegated.account = event.params.account;
delegated.delegateTo = event.params.to;
delegated.save();
}
}
export function handleUndelegated(event: UndelegatedEvent): void {
let undelegated = Undelegated.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (undelegated === null) {
undelegated = new Undelegated(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
undelegated.timestamp = event.block.timestamp.toI32();
undelegated.blockNumber = event.block.number.toI32();
undelegated.logIndex = event.logIndex.toI32();
undelegated.transactionHash = event.transaction.hash;
undelegated.account = event.params.account;
undelegated.delegateFrom = event.params.from;
undelegated.save();
}
}
export function handleStakeBurned(event: StakeBurnedEvent): void {
let stakeBurned = StakeBurned.load(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
if (stakeBurned === null) {
stakeBurned = new StakeBurned(event.transaction.hash.toHex() + '_' + event.logIndex.toString());
stakeBurned.timestamp = event.block.timestamp.toI32();
stakeBurned.blockNumber = event.block.number.toI32();
stakeBurned.logIndex = event.logIndex.toI32();
stakeBurned.transactionHash = event.transaction.hash;
stakeBurned.relayer = event.params.relayer;
stakeBurned.amountBurned = event.params.amountBurned;
stakeBurned.save();
let timestamp = event.block.timestamp.toI32();
let dayID = timestamp / 86400;
let dayStartTimestamp = dayID * 86400;
let dailyBurned = StakeDailyBurned.load(dayStartTimestamp.toString());
if (dailyBurned === null) {
dailyBurned = new StakeDailyBurned(dayStartTimestamp.toString());
dailyBurned.date = dayStartTimestamp;
dailyBurned.dailyAmountBurned = ZERO_BI;
}
dailyBurned.dailyAmountBurned = dailyBurned.dailyAmountBurned.plus(event.params.amountBurned);
dailyBurned.save();
}
}

55
subgraph.yaml Normal file

@ -0,0 +1,55 @@
specVersion: 0.0.2
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum
name: Governance
network: mainnet
source:
address: "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce"
abi: Governance
startBlock: 11474695
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- Proposal
- Voted
- Delegated
- Undelegated
abis:
- name: Governance
file: ./abis/Governance.json
eventHandlers:
- event: ProposalCreated(indexed uint256,indexed address,address,uint256,uint256,string)
handler: handleProposalCreated
- event: ProposalExecuted(indexed uint256)
handler: handleProposalExecuted
- event: Voted(indexed uint256,indexed address,indexed bool,uint256)
handler: handleVoted
- event: Delegated(indexed address,indexed address)
handler: handleDelegated
- event: Undelegated(indexed address,indexed address)
handler: handleUndelegated
file: ./src/mapping.ts
- kind: ethereum
name: RelayerRegistry
network: mainnet
source:
address: "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2"
abi: RelayerRegistry
startBlock: 14173129
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- StakeBurned
abis:
- name: RelayerRegistry
file: ./abis/RelayerRegistry.json
eventHandlers:
- event: StakeBurned(address,uint256)
handler: handleStakeBurned
file: ./src/mapping.ts

4
tsconfig.json Normal file

@ -0,0 +1,4 @@
{
"extends": "@graphprotocol/graph-ts/types/tsconfig.base.json",
"include": ["src"]
}

3359
yarn.lock Normal file

File diff suppressed because it is too large Load Diff