Compare commits

...

2 Commits

Author SHA1 Message Date
20bb8c25a1
Update Dockerfile 2024-12-23 02:56:15 +00:00
d143bc2923
1.0.20
* Use latest dependencies
* Rename package to tornado-scripts
* Added fallback RPCs
* Latest eslint support
2024-12-23 02:55:45 +00:00
51 changed files with 28710 additions and 62533 deletions

View File

@ -1,44 +0,0 @@
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
'prettier',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:prettier/recommended',
],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': [
'error',
{
tabWidth: 4,
printWidth: 120,
singleQuote: true,
},
],
'import/order': ['error'],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/no-unused-expressions': ['off'],
},
};

2
.gitattributes vendored
View File

@ -1 +1 @@
dist/* linguist-vendored
dist/**/* linguist-vendored

1
.npmrc
View File

@ -1 +0,0 @@
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/

View File

@ -1,13 +1,13 @@
# Dockefile from https://notes.ethereum.org/@GW1ZUbNKR5iRjjKYx6_dJQ/Bk8zsJ9xj
# FROM node:20.18.0-bullseye-slim
FROM node@sha256:9b558df8f10198fcd1f48cf344c55c4442c3446b8a9a69487523b3d890a4a59e
# FROM node:22.12.0-bullseye-slim
FROM node@sha256:9f385b101f66ecdf9ed9218d000cd5a35600722f0aab8112632371765109c065
# install wget, git and necessary certificates
RUN apt update && apt install --yes --no-install-recommends wget git apt-transport-https ca-certificates && rm -rf /var/lib/apt/lists/*
ENV GIT_REPOSITORY=https://git.tornado.ws/tornadocontrib/tornado-core.git
# From development branch, double check with tornado.ws
ENV GIT_COMMIT_HASH=f16bb2ed12464dce4f31aa5a237bb1643989e02d
ENV GIT_REPOSITORY=https://github.com/tornadocontrib/tornado-scripts.git
# From main branch, double check with git.tornado.ws and codeberg.org
ENV GIT_COMMIT_HASH=d143bc2923e4dcb1c84e4123fbc56cb406e6db6f
# clone the repository
RUN mkdir /app/

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Tornado Cash
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -2,9 +2,7 @@
<img src="./logo2.png">
# Tornado Core (@tornado/core)
### Notice: Repository migrated to [tornado-scripts](https://github.com/tornadocontrib/tornado-scripts) to avoid naming conflict with legacy tornado-core repository
# Tornado Scripts (tornado-scripts)
🛠 An SDK for building applications on top of [Privacy Pools](https://www.forbes.com/sites/tomerniv/2023/09/07/privacy-pools-bridging-the-gap-between-blockchain-and-regulatory-compliance)
@ -12,9 +10,9 @@
</div>
### About Tornado Core
### About Tornado Scripts
Tornado Core is a modern building block for Privacy Pools to build anything from custom UI or CLI tools
Tornado Scripts is a modern building block for Privacy Pools to build anything from custom UI or CLI tools
+ Written in [TypeScript](https://www.typescriptlang.org/)

2
dist/contracts.d.ts vendored
View File

@ -1,2 +1,2 @@
export * from '@tornado/contracts';
export * from 'tornado-contracts';
export { Multicall, Multicall__factory, OffchainOracle, OffchainOracle__factory, OvmGasPriceOracle, OvmGasPriceOracle__factory, ReverseRecords, ReverseRecords__factory, ENSNameWrapper, ENSNameWrapper__factory, ENSRegistry, ENSRegistry__factory, ENSResolver, ENSResolver__factory, } from './typechain';

6
dist/ens.d.ts vendored
View File

@ -8,13 +8,11 @@ export declare function makeLabelNodeAndParent(name: string): {
labelhash: string;
parentNode: string;
};
export declare const EnsContracts: {
[key: NetIdType]: {
export declare const EnsContracts: Record<NetIdType, {
ensRegistry: string;
ensPublicResolver: string;
ensNameWrapper: string;
};
};
}>;
/**
* ENSUtils to manage on-chain registered relayers
*/

18
dist/events/base.d.ts vendored
View File

@ -1,5 +1,5 @@
import { BaseContract, Provider, EventLog } from 'ethers';
import { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry, Echoer, Aggregator } from '@tornado/contracts';
import { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry, Echoer, Aggregator } from 'tornado-contracts';
import type { MerkleTree } from 'fixed-merkle-tree';
import { BatchEventsService, BatchBlockService, BatchTransactionService, BatchEventOnProgress, BatchBlockOnProgress } from '../batch';
import { fetchDataOptions } from '../providers';
@ -98,16 +98,12 @@ export declare class BaseTornadoService extends BaseEventsService<DepositsEvents
}): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>;
}
export interface BaseMultiTornadoServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
instances: {
[key in string]: DepositType;
};
instances: Record<string, DepositType>;
optionalTree?: boolean;
merkleTreeService?: MerkleTreeService;
}
export declare class BaseMultiTornadoService extends BaseEventsService<MultiDepositsEvents | MultiWithdrawalsEvents> {
instances: {
[key in string]: DepositType;
};
instances: Record<string, DepositType>;
optionalTree?: boolean;
merkleTreeService?: MerkleTreeService;
batchTransactionService: BatchTransactionService;
@ -143,9 +139,7 @@ export declare class BaseEncryptedNotesService extends BaseEventsService<Encrypt
getTovarishType(): string;
formatEvents(events: EventLog[]): Promise<EncryptedNotesEvents[]>;
}
export declare const proposalState: {
[key: string]: string;
};
export declare const proposalState: Record<string, string>;
export interface GovernanceProposals extends GovernanceProposalCreatedEvents {
title: string;
proposerName?: string;
@ -182,9 +176,7 @@ export declare class BaseGovernanceService extends BaseEventsService<AllGovernan
delegatedAccs: string[];
undelegatedAccs: string[];
uniq: string[];
uniqNames: {
[key: string]: string;
};
uniqNames: Record<string, string>;
balances: bigint[];
balance: bigint;
}>;

8
dist/gaszip.d.ts vendored
View File

@ -1,10 +1,6 @@
import { NetIdType } from './networkConfig';
export declare const gasZipInbounds: {
[key in NetIdType]: string;
};
export declare const gasZipID: {
[key in NetIdType]: number;
};
export declare const gasZipInbounds: Record<NetIdType, string>;
export declare const gasZipID: Record<NetIdType, number>;
export declare function gasZipInput(to: string, shorts: number[]): string | null;
export declare function gasZipMinMax(ethUsd: number): {
min: number;

View File

@ -12,9 +12,7 @@ export interface queryGraphParams {
graphApi: string;
subgraphName: string;
query: string;
variables?: {
[key: string]: string | number;
};
variables?: Record<string, string | number>;
fetchDataOptions?: fetchDataOptions;
}
export declare function queryGraph<T>({ graphApi, subgraphName, query, variables, fetchDataOptions, }: queryGraphParams): Promise<T>;

18
dist/hashes.json vendored
View File

@ -1,11 +1,11 @@
{
"dist/index.js": "sha384-txpjgDLxNbeXsLgVCyNAwpaJRS0SmFN/ITfadSo8+xzSvLqwa5bQ9GoxQ1Su8QEr",
"dist/index.mjs": "sha384-CrEHmX4zKIv/68CKWElNzvKk6FWRMMkKV8JmqL1KqYCxO73LPEAjDqxTYpxUuDBy",
"dist/merkleTreeWorker.js": "sha384-XVv9HRGDZlaF0LeEZNQygle31UY6yvIwsZ4GWCTZUX7O/hZ7N5Zwpi3GqnHSBYzW",
"dist/merkleTreeWorker.umd.js": "sha384-e5B65ZZ4IxKVOU1o02K6IL2tjJof20QCcEtD+vKe1cPmyfW2BPCHWDPIbPksIpvJ",
"dist/merkleTreeWorker.umd.min.js": "sha384-AxQv1da+lSi3gMYkdGQuR1WN1+4HB8IT3cPFa17HBj14+ZzdZN6SS1fCw5Izc2rr",
"dist/tornado.umd.js": "sha384-xTUkkUTm3aBsnHCUnVGxRgieAu3z4wCwrKT1DFj8VyCk/eZZO9nq+yP4/McLRfB4",
"dist/tornado.umd.min.js": "sha384-ubqr6m6jEOPf7LQz0pXKmEo7tCCbNUAE+iSZWK6X/f7i4wt14rYW7pUcSzw5glth",
"dist/tornadoContracts.umd.js": "sha384-bFq/cemb0bP0JbIq8p75n0UR8smQ/2Yh69pjegzSuu0upawO3sKOjehY8SjX85Xh",
"dist/tornadoContracts.umd.min.js": "sha384-4ay7cmK0auAgZH1xfAsqyN6GtnHBNNgh9C22qy0rHxKicDzNtTsnNZDbz0qmd9GI"
"dist/index.js": "sha384-9VSo+DyOg7bk9fplN0eusAdRqdhB/o9VBM9Y4TinC0tYBljNm2IDfxC4G60luJDp",
"dist/index.mjs": "sha384-Cm+w57MAhudCJ1Xk+H0dwspZlGJV3Yny1uFzoQBbNaCNaLwTH9CqDHdmu2mAYQxJ",
"dist/merkleTreeWorker.js": "sha384-HPaQH762jYxlfAdS4KPJou1AXG9Ww4N+PDEc6vHgFeIX1HI8S/StRmOoJR+gHScM",
"dist/merkleTreeWorker.umd.js": "sha384-+VOeGAa/XGNYsar06LgAquRWKO3CG7anvbpVvlWIa6J9pg9+DskqaDkAusiVz8HZ",
"dist/merkleTreeWorker.umd.min.js": "sha384-fOCKW9eYxMVLFTOQcuKJxJwNyRu6MRIzmPFHqzxlp0P/ZT24y+A3HcgCylohIfJ0",
"dist/tornado.umd.js": "sha384-/dWCQ81GwzoRqHnv+pi9tsHj2mzMyvxBk5ttIbOLe/0MIcSw9aBoSr3vgRoSlWZ+",
"dist/tornado.umd.min.js": "sha384-CgPo6GlnCtdGLqeu7OIcOliLTRQy289Q3CxWv5xqXCQhrHxSUupP8nBv55xQiqkW",
"dist/tornadoContracts.umd.js": "sha384-Gmawcz/XTH7WFUFnMJKPUCy2zrjDOhf/DtSv9xfHBulPyCEJwI70Hw+n7E1Y60EU",
"dist/tornadoContracts.umd.min.js": "sha384-Sclkp3xkhjmDekfQaQFkgUctmauYUF7ieeyyFhFBnwAzyp2eFBS5qzxvOIBhlJza"
}

75
dist/index.js vendored
View File

@ -1,7 +1,7 @@
'use strict';
var ethers = require('ethers');
var contracts = require('@tornado/contracts');
var tornadoContracts = require('tornado-contracts');
var crypto$1 = require('crypto');
var BN = require('bn.js');
var contentHashUtils = require('@ensdomains/content-hash');
@ -865,9 +865,9 @@ const defaultConfig = {
name: "MEV Blocker",
url: "https://rpc.mevblocker.io"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com"
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/mainnet"
},
keydonix: {
name: "Horswap ( Keydonix )",
@ -1016,9 +1016,9 @@ const defaultConfig = {
name: "BNB Chain 2",
url: "https://bsc-dataseed1.ninicoin.io"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com/bsc"
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/bsc"
},
nodereal: {
name: "NodeReal",
@ -1104,6 +1104,14 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/matic-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/polygon"
},
polygon: {
name: "Polygon",
url: "https://polygon-rpc.com"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/matic"
@ -1156,6 +1164,14 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/optimism-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/op"
},
optimism: {
name: "Optimism",
url: "https://mainnet.optimism.io"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/op"
@ -1214,9 +1230,9 @@ const defaultConfig = {
name: "Arbitrum",
url: "https://arb1.arbitrum.io/rpc"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com/arbitrum"
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/arbitrum"
},
stackup: {
name: "Stackup",
@ -1277,6 +1293,10 @@ const defaultConfig = {
name: "Base",
url: "https://mainnet.base.org"
},
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/base"
},
stackup: {
name: "Stackup",
url: "https://public.stackup.sh/api/v1/node/base-mainnet"
@ -1364,6 +1384,10 @@ const defaultConfig = {
name: "Blast",
url: "https://rpc.blast.io"
},
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/blast"
},
blastApi: {
name: "BlastApi",
url: "https://blastl2-mainnet.public.blastapi.io"
@ -1417,6 +1441,10 @@ const defaultConfig = {
name: "Gnosis",
url: "https://rpc.gnosischain.com"
},
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/gnosis"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/gnosis"
@ -1464,10 +1492,18 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/ext/bc/C/rpc"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/avax/c"
},
avalanche: {
name: "Avalanche",
url: "https://api.avax.network/ext/bc/C/rpc"
},
stackup: {
name: "Stackup",
url: "https://public.stackup.sh/api/v1/node/avalanche-mainnet"
@ -1520,14 +1556,14 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/sepolia-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/sepolia"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/sepolia"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com/sepolia"
},
sepolia: {
name: "Sepolia RPC",
url: "https://rpc.sepolia.org"
@ -2057,13 +2093,10 @@ function getStatusSchema(netId, config, tovarish) {
properties: {
instanceAddress: {
type: "object",
properties: amounts.reduce(
(acc2, cur) => {
properties: amounts.reduce((acc2, cur) => {
acc2[cur] = addressSchemaType;
return acc2;
},
{}
),
}, {}),
required: amounts.filter((amount) => !optionalInstances.includes(amount))
},
decimals: { enum: [decimals] }
@ -2652,7 +2685,7 @@ class BaseMultiTornadoService extends BaseEventsService {
batchBlockService;
constructor(serviceConstructor) {
const { instances, provider, optionalTree, merkleTreeService } = serviceConstructor;
const contract = merkleTreeService?.Tornado || contracts.Tornado__factory.connect(Object.keys(instances)[0], provider);
const contract = merkleTreeService?.Tornado || tornadoContracts.Tornado__factory.connect(Object.keys(instances)[0], provider);
super({
...serviceConstructor,
contract,
@ -3378,7 +3411,7 @@ class BaseRevenueService extends BaseEventsService {
...new Set(events.map(({ transactionHash }) => transactionHash))
]);
const registeredRelayers = new Set(events.map(({ args }) => args.relayer));
const tornadoInterface = contracts.Tornado__factory.createInterface();
const tornadoInterface = tornadoContracts.Tornado__factory.createInterface();
const withdrawHash = tornadoInterface.getEvent("Withdrawal").topicHash;
const withdrawalLogs = receipts.map(
(receipt) => receipt.logs.map((log) => {

71
dist/index.mjs vendored
View File

@ -1,5 +1,5 @@
import { isHexString, assertArgument, assert, EventLog, UndecodedEventLog, Log, FetchRequest, JsonRpcProvider, Network, EnsPlugin, GasCostPlugin, Wallet, HDNodeWallet, VoidSigner, JsonRpcSigner, BrowserProvider, isAddress, parseEther, getAddress, AbiCoder, formatEther, namehash, dataSlice, dataLength, Interface, Contract, computeAddress, keccak256, EnsResolver, parseUnits, Transaction, Signature, MaxUint256, ZeroAddress } from 'ethers';
import { Tornado__factory } from '@tornado/contracts';
import { Tornado__factory } from 'tornado-contracts';
import { webcrypto } from 'crypto';
import BN from 'bn.js';
import * as contentHashUtils from '@ensdomains/content-hash';
@ -843,9 +843,9 @@ const defaultConfig = {
name: "MEV Blocker",
url: "https://rpc.mevblocker.io"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com"
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/mainnet"
},
keydonix: {
name: "Horswap ( Keydonix )",
@ -994,9 +994,9 @@ const defaultConfig = {
name: "BNB Chain 2",
url: "https://bsc-dataseed1.ninicoin.io"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com/bsc"
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/bsc"
},
nodereal: {
name: "NodeReal",
@ -1082,6 +1082,14 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/matic-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/polygon"
},
polygon: {
name: "Polygon",
url: "https://polygon-rpc.com"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/matic"
@ -1134,6 +1142,14 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/optimism-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/op"
},
optimism: {
name: "Optimism",
url: "https://mainnet.optimism.io"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/op"
@ -1192,9 +1208,9 @@ const defaultConfig = {
name: "Arbitrum",
url: "https://arb1.arbitrum.io/rpc"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com/arbitrum"
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/arbitrum"
},
stackup: {
name: "Stackup",
@ -1255,6 +1271,10 @@ const defaultConfig = {
name: "Base",
url: "https://mainnet.base.org"
},
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/base"
},
stackup: {
name: "Stackup",
url: "https://public.stackup.sh/api/v1/node/base-mainnet"
@ -1342,6 +1362,10 @@ const defaultConfig = {
name: "Blast",
url: "https://rpc.blast.io"
},
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/blast"
},
blastApi: {
name: "BlastApi",
url: "https://blastl2-mainnet.public.blastapi.io"
@ -1395,6 +1419,10 @@ const defaultConfig = {
name: "Gnosis",
url: "https://rpc.gnosischain.com"
},
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/gnosis"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/gnosis"
@ -1442,10 +1470,18 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/ext/bc/C/rpc"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/avax/c"
},
avalanche: {
name: "Avalanche",
url: "https://api.avax.network/ext/bc/C/rpc"
},
stackup: {
name: "Stackup",
url: "https://public.stackup.sh/api/v1/node/avalanche-mainnet"
@ -1498,14 +1534,14 @@ const defaultConfig = {
tornadoSubgraph: "tornadocash/sepolia-tornado-subgraph",
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: "Tornado Withdraw",
url: "https://tornadowithdraw.com/sepolia"
},
oneRpc: {
name: "1RPC",
url: "https://1rpc.io/sepolia"
},
tornadoRpc: {
name: "Tornado RPC",
url: "https://tornadocash-rpc.com/sepolia"
},
sepolia: {
name: "Sepolia RPC",
url: "https://rpc.sepolia.org"
@ -2035,13 +2071,10 @@ function getStatusSchema(netId, config, tovarish) {
properties: {
instanceAddress: {
type: "object",
properties: amounts.reduce(
(acc2, cur) => {
properties: amounts.reduce((acc2, cur) => {
acc2[cur] = addressSchemaType;
return acc2;
},
{}
),
}, {}),
required: amounts.filter((amount) => !optionalInstances.includes(amount))
},
decimals: { enum: [decimals] }

View File

@ -1,5 +1,5 @@
import { MerkleTree, PartialMerkleTree, Element, TreeEdge } from 'fixed-merkle-tree';
import type { Tornado } from '@tornado/contracts';
import type { Tornado } from 'tornado-contracts';
import type { DepositType } from './deposits';
import type { DepositsEvents } from './events';
import type { NetIdType } from './networkConfig';

20499
dist/merkleTreeWorker.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -15,12 +15,3 @@
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/

View File

@ -19,20 +19,14 @@ export interface RpcUrl {
name: string;
url: string;
}
export interface RpcUrls {
[key: string]: RpcUrl;
}
export type RpcUrls = Record<string, RpcUrl>;
export interface SubgraphUrl {
name: string;
url: string;
}
export interface SubgraphUrls {
[key: string]: SubgraphUrl;
}
export type SubgraphUrls = Record<string, SubgraphUrl>;
export interface TornadoInstance {
instanceAddress: {
[key: string]: string;
};
instanceAddress: Record<string, string>;
instanceApproval?: boolean;
optionalInstances?: string[];
tokenAddress?: string;
@ -41,9 +35,7 @@ export interface TornadoInstance {
decimals: number;
gasLimit?: number;
}
export interface TokenInstances {
[key: string]: TornadoInstance;
}
export type TokenInstances = Record<string, TornadoInstance>;
export interface Config {
rpcCallRetryAttempt?: number;
gasPrices: {
@ -90,12 +82,8 @@ export interface Config {
MINING_BLOCK_TIME?: number;
};
}
export interface networkConfig {
[key: NetIdType]: Config;
}
export interface SubdomainMap {
[key: NetIdType]: string;
}
export type networkConfig = Record<NetIdType, Config>;
export type SubdomainMap = Record<NetIdType, string>;
export declare const defaultConfig: networkConfig;
export declare const enabledChains: NetIdType[];
/**
@ -123,6 +111,4 @@ export declare function getInstanceByAddress(config: Config, address: string): {
tokenAddress: string | undefined;
} | undefined;
export declare function getRelayerEnsSubdomains(): SubdomainMap;
export declare function getMultiInstances(netId: NetIdType, config: Config): {
[key in string]: DepositType;
};
export declare function getMultiInstances(netId: NetIdType, config: Config): Record<string, DepositType>;

6
dist/permit.d.ts vendored
View File

@ -1,4 +1,4 @@
import { ERC20Permit, ERC20Mock, TORN } from '@tornado/contracts';
import { ERC20Permit, ERC20Mock, TORN } from 'tornado-contracts';
import { Signature, Signer, TypedDataField } from 'ethers';
export interface PermitValue {
spender: string;
@ -18,9 +18,7 @@ export declare const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA
*/
export interface Witness {
witnessTypeName: string;
witnessType: {
[key: string]: TypedDataField[];
};
witnessType: Record<string, TypedDataField[]>;
witness: any;
}
export declare function getPermitSignature({ Token, signer, spender, value, nonce, deadline, }: PermitValue & {

View File

@ -20,9 +20,7 @@ export interface RelayerInfo extends RelayerParams {
instances: string[];
stakeBalance?: string;
gasPrice?: number;
ethPrices?: {
[key in string]: string;
};
ethPrices?: Record<string, string>;
currentQueue: number;
tornadoServiceFee: number;
}
@ -35,24 +33,18 @@ export interface RelayerError {
export interface RelayerStatus {
url: string;
rewardAccount: string;
instances: {
[key in string]: {
instanceAddress: {
[key in string]: string;
};
instances: Record<string, {
instanceAddress: Record<string, string>;
tokenAddress?: string;
symbol: string;
decimals: number;
};
};
}>;
gasPrices?: {
fast: number;
additionalProperties?: number;
};
netId: NetIdType;
ethPrices?: {
[key in string]: string;
};
ethPrices?: Record<string, string>;
tornadoServiceFee: number;
latestBlock?: number;
version: string;
@ -111,13 +103,9 @@ export function isRelayerUpdated(relayerVersion: string, netId: NetIdType) {
**/
export declare function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo): bigint;
export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number;
export interface RelayerInstanceList {
[key: string]: {
instanceAddress: {
[key: string]: string;
};
};
}
export type RelayerInstanceList = Record<string, {
instanceAddress: Record<string, string>;
}>;
export declare function getSupportedInstances(instanceList: RelayerInstanceList): string[];
export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
export interface RelayerClientConstructor {

View File

@ -5,9 +5,7 @@ export interface statusInstanceType {
properties: {
instanceAddress: {
type: string;
properties: {
[key in string]: typeof addressSchemaType;
};
properties: Record<string, typeof addressSchemaType>;
required: string[];
};
tokenAddress?: typeof addressSchemaType;
@ -22,16 +20,12 @@ export interface statusInstanceType {
}
export interface statusInstancesType {
type: string;
properties: {
[key in string]: statusInstanceType;
};
properties: Record<string, statusInstanceType>;
required: string[];
}
export interface statusEthPricesType {
type: string;
properties: {
[key in string]: typeof bnSchemaType;
};
properties: Record<string, typeof bnSchemaType>;
required?: string[];
}
export interface statusSchema {
@ -41,11 +35,9 @@ export interface statusSchema {
instances?: statusInstancesType;
gasPrices: {
type: string;
properties: {
[key in string]: {
properties: Record<string, {
type: string;
};
};
}>;
required: string[];
};
netId: {

33352
dist/tornado.umd.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,12 +23,3 @@
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

12
dist/utils.d.ts vendored
View File

@ -8,22 +8,22 @@ export declare const chunk: <T>(arr: T[], size: number) => T[][];
export declare function sleep(ms: number): Promise<unknown>;
export declare function validateUrl(url: string, protocols?: string[]): boolean;
export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
export declare function bufferToBytes(b: Buffer): Uint8Array;
export declare function bufferToBytes(b: Buffer): Uint8Array<ArrayBufferLike>;
export declare function bytesToBase64(bytes: Uint8Array): string;
export declare function base64ToBytes(base64: string): Uint8Array;
export declare function base64ToBytes(base64: string): Uint8Array<ArrayBuffer>;
export declare function bytesToHex(bytes: Uint8Array): string;
export declare function hexToBytes(hexString: string): Uint8Array;
export declare function hexToBytes(hexString: string): Uint8Array<ArrayBuffer>;
export declare function bytesToBN(bytes: Uint8Array): bigint;
export declare function bnToBytes(bigint: bigint | string): Uint8Array;
export declare function bnToBytes(bigint: bigint | string): Uint8Array<ArrayBuffer>;
export declare function leBuff2Int(bytes: Uint8Array): BN;
export declare function leInt2Buff(bigint: bnInput | bigint): Uint8Array;
export declare function leInt2Buff(bigint: bnInput | bigint): Uint8Array<ArrayBuffer>;
export declare function toFixedHex(numberish: BigNumberish, length?: number): string;
export declare function toFixedLength(string: string, length?: number): string;
export declare function rBigInt(nbytes?: number): bigint;
export declare function rHex(nbytes?: number): string;
export declare function bigIntReplacer(key: any, value: any): any;
export declare function substring(str: string, length?: number): string;
export declare function digest(bytes: Uint8Array, algo?: string): Promise<Uint8Array>;
export declare function digest(bytes: Uint8Array, algo?: string): Promise<Uint8Array<ArrayBuffer>>;
export declare function numberFormatter(num: string | number | bigint, digits?: number): string;
export declare function isHex(value: string): boolean;
export declare function toContentHash(ipfsUrl: string): any;

55
eslint.config.mjs Normal file
View File

@ -0,0 +1,55 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import prettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
export default tseslint.config(
{
files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.tsx'],
extends: [eslint.configs.recommended, prettierRecommendedConfig],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
rules: {
'prettier/prettier': [
'error',
{
tabWidth: 4,
printWidth: 120,
singleQuote: true,
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
],
rules: {
'import/order': ['error'],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/no-unused-expressions': ['off'],
'@typescript-eslint/no-empty-function': ['off'],
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
languageOptions: {
parserOptions: {
projectService: true,
},
},
},
);

View File

@ -1,6 +1,6 @@
{
"name": "@tornado/core",
"version": "1.0.19",
"name": "tornado-scripts",
"version": "1.0.20",
"description": "An SDK for building applications on top of Privacy Pools",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@ -10,7 +10,7 @@
"scripts": {
"typechain": "typechain --target ethers-v6 --out-dir src/typechain src/abi/*.json",
"types": "tsc --declaration --emitDeclarationOnly -p tsconfig.build.json",
"lint": "eslint src/**/*.ts test/**/*.ts --ext .ts --ignore-pattern src/typechain",
"lint": "eslint src/**/*.ts test/**/*.ts --ignore-pattern src/typechain",
"build:node": "rollup -c",
"build:web": "webpack",
"build:hash": "ts-node scripts/hash.ts",
@ -19,7 +19,7 @@
"ipfs:hash": "docker container run --rm -it --entrypoint cat tornado-core /app/dist/hashes.json",
"test": "nyc mocha --require ts-node/register --require source-map-support/register --recursive 'test/**/*.ts' --timeout '300000'"
},
"author": "",
"author": "Tornado Contrib",
"license": "MIT",
"files": [
"dist",
@ -36,72 +36,69 @@
],
"dependencies": {
"@ensdomains/content-hash": "2.5.7",
"@metamask/eth-sig-util": "^8.0.0",
"@tornado/contracts": "git+https://git.tornado.ws/tornadocontrib/tornado-contracts.git#093ae2210e1f1b016b756b4db200c4a1b3308408",
"@metamask/eth-sig-util": "^8.1.2",
"ajv": "^8.17.1",
"bn.js": "^5.2.1",
"circomlibjs": "0.1.7",
"cross-fetch": "^4.0.0",
"circomlibjs": "git+https://github.com/tornadocontrib/circomlibjs.git#2aef7aade8e2b8d103250e4b24c7f1526cf1dd8d",
"cross-fetch": "^4.1.0",
"ethers": "^6.13.4",
"ffjavascript": "0.2.48",
"ffjavascript": "^0.3.1",
"fflate": "^0.8.2",
"fixed-merkle-tree": "0.7.3",
"idb": "^8.0.0",
"idb": "^8.0.1",
"snarkjs": "git+https://github.com/tornadocontrib/snarkjs.git#2c964b3fe6019e057acab04cc17705d1f7fdaf9a",
"websnark": "git+https://github.com/tornadocontrib/websnark.git#f0ddbf34b3045cac9e6d3e4d977bf3b439869fae"
"tornado-contracts": "git+https://github.com/tornadocontrib/tornado-contracts.git#4c2fe0b80fa1a0571ffa538a046e234d4e38d140",
"websnark": "git+https://github.com/tornadocontrib/websnark.git#e5a79cca905d1ffb61a69739492be58d438c9f17"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-ignition": "^0.15.5",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
"@nomicfoundation/hardhat-ignition": "^0.15.9",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.9",
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.10",
"@nomicfoundation/ignition-core": "^0.15.5",
"@rollup/plugin-commonjs": "^28.0.1",
"@nomicfoundation/hardhat-verify": "^2.0.12",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/bn.js": "^5.1.6",
"@types/chai": "^4.2.0",
"@types/chai": "^5.0.1",
"@types/circomlibjs": "^0.1.6",
"@types/mocha": "^10.0.9",
"@types/node": "^22.8.0",
"@types/node-fetch": "^2.6.11",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"chai": "4.5.0",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.2",
"@types/node-fetch": "^2.6.12",
"chai": "^4.5.0",
"esbuild-loader": "^4.2.2",
"eslint": "8.57.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-import-resolver-typescript": "^3.7.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"fetch-mock": "^12.0.2",
"hardhat": "^2.22.10",
"hardhat-gas-reporter": "^2.2.1",
"mocha": "^10.7.3",
"node-polyfill-webpack-plugin": "^4.0.0",
"fetch-mock": "^12.2.0",
"hardhat": "^2.22.17",
"hardhat-gas-reporter": "^2.2.2",
"mocha": "^11.0.1",
"node-polyfill-webpack-plugin": "^4.1.0",
"nyc": "^17.1.0",
"prettier": "^3.3.3",
"rollup": "^4.24.0",
"prettier": "^3.4.2",
"rollup": "^4.29.1",
"rollup-plugin-esbuild": "^6.1.1",
"solidity-coverage": "^0.8.13",
"solidity-coverage": "^0.8.14",
"ts-node": "^10.9.2",
"tsc": "^2.0.4",
"typechain": "^8.3.2",
"typescript": "^5.6.3",
"webpack": "^5.95.0",
"webpack-cli": "^5.1.4"
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.1",
"webpack": "^5.97.1",
"webpack-cli": "^6.0.1"
},
"resolutions": {
"strip-ansi": "6.0.1",
"@adraffy/ens-normalize": "1.10.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"big-integer": "1.6.52",
"ffjavascript": "0.2.48"
"ffjavascript": "^0.3.1"
}
}

View File

@ -42,7 +42,7 @@ export async function getSubInfo(
tag: string;
topics: TopicFilter;
}> {
let topics: Array<null | string | Array<string>>;
let topics: (null | string | string[])[];
let fragment: null | EventFragment = null;
// Convert named events to topicHash and get the fragment for
@ -242,7 +242,6 @@ export class BatchBlockService {
let retries = 0;
let err;
// eslint-disable-next-line no-unmodified-loop-condition
while ((!this.shouldRetry && retries === 0) || (this.shouldRetry && retries < this.retryMax)) {
try {
return await Promise.all(blocks.map((b) => this.getBlock(b)));
@ -346,7 +345,6 @@ export class BatchTransactionService {
let retries = 0;
let err;
// eslint-disable-next-line no-unmodified-loop-condition
while ((!this.shouldRetry && retries === 0) || (this.shouldRetry && retries < this.retryMax)) {
try {
if (!receipt) {
@ -491,7 +489,6 @@ export class BatchEventsService {
let err;
let retries = 0;
// eslint-disable-next-line no-unmodified-loop-condition
while ((!this.shouldRetry && retries === 0) || (this.shouldRetry && retries < this.retryMax)) {
try {
if (this.address) {

View File

@ -1,4 +1,4 @@
export * from '@tornado/contracts';
export * from 'tornado-contracts';
export {
Multicall,
Multicall__factory,

View File

@ -40,13 +40,14 @@ export function makeLabelNodeAndParent(name: string) {
}
// https://github.com/ensdomains/ensjs/blob/main/packages/ensjs/src/contracts/consts.ts
export const EnsContracts: {
[key: NetIdType]: {
export const EnsContracts: Record<
NetIdType,
{
ensRegistry: string;
ensPublicResolver: string;
ensNameWrapper: string;
};
} = {
}
> = {
[NetId.MAINNET]: {
ensRegistry: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
ensPublicResolver: '0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63',

View File

@ -20,7 +20,7 @@ import {
Echoer,
Aggregator,
Tornado__factory,
} from '@tornado/contracts';
} from 'tornado-contracts';
import type { MerkleTree } from 'fixed-merkle-tree';
import {
@ -131,7 +131,6 @@ export class BaseEventsService<EventType extends MinimalEvents> {
/* eslint-enable @typescript-eslint/no-unused-vars */
async formatEvents(events: EventLog[]): Promise<EventType[]> {
// eslint-disable-next-line no-return-await
return await new Promise((resolve) => resolve(events as unknown as EventType[]));
}
@ -440,17 +439,13 @@ export class BaseTornadoService extends BaseEventsService<DepositsEvents | Withd
}
export interface BaseMultiTornadoServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
instances: {
[key in string]: DepositType;
};
instances: Record<string, DepositType>;
optionalTree?: boolean;
merkleTreeService?: MerkleTreeService;
}
export class BaseMultiTornadoService extends BaseEventsService<MultiDepositsEvents | MultiWithdrawalsEvents> {
instances: {
[key in string]: DepositType;
};
instances: Record<string, DepositType>;
optionalTree?: boolean;
merkleTreeService?: MerkleTreeService;
@ -717,7 +712,7 @@ export class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesE
const abiCoder = AbiCoder.defaultAbiCoder();
export const proposalState: { [key: string]: string } = {
export const proposalState: Record<string, string> = {
0: 'Pending',
1: 'Active',
2: 'Defeated',
@ -966,7 +961,7 @@ export class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents
}
return acc;
},
{} as { [key: string]: string },
{} as Record<string, string>,
);
return proposalEvents.map((event, index) => {
@ -1018,7 +1013,7 @@ export class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents
}
return acc;
},
{} as { [key: string]: string },
{} as Record<string, string>,
);
const votes = votedEvents.map((event) => {
@ -1077,7 +1072,7 @@ export class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents
}
return acc;
},
{} as { [key: string]: string },
{} as Record<string, string>,
);
return {

View File

@ -17,7 +17,7 @@ const DUMMY_WITHDRAW_DATA =
export function convertETHToTokenAmount(
amountInWei: BigNumberish,
tokenPriceInWei: BigNumberish,
tokenDecimals: number = 18,
tokenDecimals = 18,
): bigint {
const tokenDecimalsMultiplier = BigInt(10 ** Number(tokenDecimals));
return (BigInt(amountInWei) * tokenDecimalsMultiplier) / BigInt(tokenPriceInWei);

View File

@ -2,7 +2,7 @@ import { isAddress } from 'ethers';
import { NetId, NetIdType } from './networkConfig';
// https://dev.gas.zip/gas/chain-support/inbound
export const gasZipInbounds: { [key in NetIdType]: string } = {
export const gasZipInbounds: Record<NetIdType, string> = {
[NetId.MAINNET]: '0x391E7C679d29bD940d63be94AD22A25d25b5A604',
[NetId.BSC]: '0x391E7C679d29bD940d63be94AD22A25d25b5A604',
[NetId.POLYGON]: '0x391E7C679d29bD940d63be94AD22A25d25b5A604',
@ -15,7 +15,7 @@ export const gasZipInbounds: { [key in NetIdType]: string } = {
};
// https://dev.gas.zip/gas/chain-support/outbound
export const gasZipID: { [key in NetIdType]: number } = {
export const gasZipID: Record<NetIdType, number> = {
[NetId.MAINNET]: 255,
[NetId.BSC]: 14,
[NetId.POLYGON]: 17,

View File

@ -49,9 +49,7 @@ export interface queryGraphParams {
graphApi: string;
subgraphName: string;
query: string;
variables?: {
[key: string]: string | number;
};
variables?: Record<string, string | number>;
fetchDataOptions?: fetchDataOptions;
}
@ -270,7 +268,6 @@ export async function getAllRegisters({
const events = [];
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
let {
relayers: result,
@ -406,7 +403,6 @@ export async function getAllDeposits({
const events = [];
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
let {
deposits: result,
@ -552,7 +548,6 @@ export async function getAllWithdrawals({
const events = [];
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
let {
withdrawals: result,
@ -756,7 +751,6 @@ export async function getAllGraphEchoEvents({
const events = [];
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
let {
noteAccounts: result,
@ -888,7 +882,6 @@ export async function getAllEncryptedNotes({
const events = [];
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
let {
encryptedNotes: result,
@ -1046,7 +1039,6 @@ export async function getAllGovernanceEvents({
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
const {
proposals,

View File

@ -1,6 +1,6 @@
import { Worker as NodeWorker } from 'worker_threads';
import { MerkleTree, PartialMerkleTree, Element, TreeEdge } from 'fixed-merkle-tree';
import type { Tornado } from '@tornado/contracts';
import type { Tornado } from 'tornado-contracts';
import { isNode, toFixedHex } from './utils';
import { mimc } from './mimc';
import type { DepositType } from './deposits';

View File

@ -23,23 +23,17 @@ export interface RpcUrl {
url: string;
}
export interface RpcUrls {
[key: string]: RpcUrl;
}
export type RpcUrls = Record<string, RpcUrl>;
export interface SubgraphUrl {
name: string;
url: string;
}
export interface SubgraphUrls {
[key: string]: SubgraphUrl;
}
export type SubgraphUrls = Record<string, SubgraphUrl>;
export interface TornadoInstance {
instanceAddress: {
[key: string]: string;
};
instanceAddress: Record<string, string>;
instanceApproval?: boolean;
optionalInstances?: string[];
tokenAddress?: string;
@ -49,9 +43,7 @@ export interface TornadoInstance {
gasLimit?: number;
}
export interface TokenInstances {
[key: string]: TornadoInstance;
}
export type TokenInstances = Record<string, TornadoInstance>;
export interface Config {
rpcCallRetryAttempt?: number;
@ -106,13 +98,9 @@ export interface Config {
};
}
export interface networkConfig {
[key: NetIdType]: Config;
}
export type networkConfig = Record<NetIdType, Config>;
export interface SubdomainMap {
[key: NetIdType]: string;
}
export type SubdomainMap = Record<NetIdType, string>;
export const defaultConfig: networkConfig = {
[NetId.MAINNET]: {
@ -135,9 +123,9 @@ export const defaultConfig: networkConfig = {
name: 'MEV Blocker',
url: 'https://rpc.mevblocker.io',
},
tornadoRpc: {
name: 'Tornado RPC',
url: 'https://tornadocash-rpc.com',
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/mainnet',
},
keydonix: {
name: 'Horswap ( Keydonix )',
@ -286,9 +274,9 @@ export const defaultConfig: networkConfig = {
name: 'BNB Chain 2',
url: 'https://bsc-dataseed1.ninicoin.io',
},
tornadoRpc: {
name: 'Tornado RPC',
url: 'https://tornadocash-rpc.com/bsc',
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/bsc',
},
nodereal: {
name: 'NodeReal',
@ -374,6 +362,14 @@ export const defaultConfig: networkConfig = {
tornadoSubgraph: 'tornadocash/matic-tornado-subgraph',
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/polygon',
},
polygon: {
name: 'Polygon',
url: 'https://polygon-rpc.com',
},
oneRpc: {
name: '1RPC',
url: 'https://1rpc.io/matic',
@ -426,6 +422,14 @@ export const defaultConfig: networkConfig = {
tornadoSubgraph: 'tornadocash/optimism-tornado-subgraph',
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/op',
},
optimism: {
name: 'Optimism',
url: 'https://mainnet.optimism.io',
},
oneRpc: {
name: '1RPC',
url: 'https://1rpc.io/op',
@ -484,9 +488,9 @@ export const defaultConfig: networkConfig = {
name: 'Arbitrum',
url: 'https://arb1.arbitrum.io/rpc',
},
tornadoRpc: {
name: 'Tornado RPC',
url: 'https://tornadocash-rpc.com/arbitrum',
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/arbitrum',
},
stackup: {
name: 'Stackup',
@ -547,6 +551,10 @@ export const defaultConfig: networkConfig = {
name: 'Base',
url: 'https://mainnet.base.org',
},
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/base',
},
stackup: {
name: 'Stackup',
url: 'https://public.stackup.sh/api/v1/node/base-mainnet',
@ -634,6 +642,10 @@ export const defaultConfig: networkConfig = {
name: 'Blast',
url: 'https://rpc.blast.io',
},
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/blast',
},
blastApi: {
name: 'BlastApi',
url: 'https://blastl2-mainnet.public.blastapi.io',
@ -687,6 +699,10 @@ export const defaultConfig: networkConfig = {
name: 'Gnosis',
url: 'https://rpc.gnosischain.com',
},
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/gnosis',
},
oneRpc: {
name: '1RPC',
url: 'https://1rpc.io/gnosis',
@ -734,10 +750,18 @@ export const defaultConfig: networkConfig = {
tornadoSubgraph: 'tornadocash/avalanche-tornado-subgraph',
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/ext/bc/C/rpc',
},
oneRpc: {
name: '1RPC',
url: 'https://1rpc.io/avax/c',
},
avalanche: {
name: 'Avalanche',
url: 'https://api.avax.network/ext/bc/C/rpc',
},
stackup: {
name: 'Stackup',
url: 'https://public.stackup.sh/api/v1/node/avalanche-mainnet',
@ -790,14 +814,14 @@ export const defaultConfig: networkConfig = {
tornadoSubgraph: 'tornadocash/sepolia-tornado-subgraph',
subgraphs: {},
rpcUrls: {
tornadoWithdraw: {
name: 'Tornado Withdraw',
url: 'https://tornadowithdraw.com/sepolia',
},
oneRpc: {
name: '1RPC',
url: 'https://1rpc.io/sepolia',
},
tornadoRpc: {
name: 'Tornado RPC',
url: 'https://tornadocash-rpc.com/sepolia',
},
sepolia: {
name: 'Sepolia RPC',
url: 'https://rpc.sepolia.org',
@ -949,7 +973,7 @@ export function getRelayerEnsSubdomains() {
}, {} as SubdomainMap);
}
export function getMultiInstances(netId: NetIdType, config: Config): { [key in string]: DepositType } {
export function getMultiInstances(netId: NetIdType, config: Config): Record<string, DepositType> {
return Object.entries(config.tokens).reduce(
(acc, [currency, { instanceAddress }]) => {
Object.entries(instanceAddress).forEach(([amount, contractAddress]) => {
@ -961,6 +985,6 @@ export function getMultiInstances(netId: NetIdType, config: Config): { [key in s
});
return acc;
},
{} as { [key in string]: DepositType },
{} as Record<string, DepositType>,
);
}

View File

@ -1,4 +1,4 @@
import { ERC20Permit, ERC20Mock, TORN } from '@tornado/contracts';
import { ERC20Permit, ERC20Mock, TORN } from 'tornado-contracts';
import { MaxUint256, Provider, Signature, Signer, TypedDataField } from 'ethers';
export interface PermitValue {
@ -22,9 +22,7 @@ export const permit2Address = '0x000000000022D473030F116dDEE9F6B43aC78BA3';
*/
export interface Witness {
witnessTypeName: string;
witnessType: {
[key: string]: TypedDataField[];
};
witnessType: Record<string, TypedDataField[]>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
witness: any;
}

View File

@ -244,7 +244,7 @@ export const fetchGetUrlFunc =
const resp = await fetchData(req.url, init);
const headers = {} as { [key in string]: any };
const headers = {} as Record<string, any>;
resp.headers.forEach((value: any, key: string) => {
headers[key.toLowerCase()] = value;
});

View File

@ -28,9 +28,7 @@ export interface RelayerInfo extends RelayerParams {
instances: string[];
stakeBalance?: string;
gasPrice?: number;
ethPrices?: {
[key in string]: string;
};
ethPrices?: Record<string, string>;
currentQueue: number;
tornadoServiceFee: number;
}
@ -45,24 +43,21 @@ export interface RelayerError {
export interface RelayerStatus {
url: string;
rewardAccount: string;
instances: {
[key in string]: {
instanceAddress: {
[key in string]: string;
};
instances: Record<
string,
{
instanceAddress: Record<string, string>;
tokenAddress?: string;
symbol: string;
decimals: number;
};
};
}
>;
gasPrices?: {
fast: number;
additionalProperties?: number;
};
netId: NetIdType;
ethPrices?: {
[key in string]: string;
};
ethPrices?: Record<string, string>;
tornadoServiceFee: number;
latestBlock?: number;
version: string;
@ -149,13 +144,12 @@ export function getWeightRandom(weightsScores: bigint[], random: bigint) {
return Math.floor(Math.random() * weightsScores.length);
}
export interface RelayerInstanceList {
[key: string]: {
instanceAddress: {
[key: string]: string;
};
};
export type RelayerInstanceList = Record<
string,
{
instanceAddress: Record<string, string>;
}
>;
export function getSupportedInstances(instanceList: RelayerInstanceList) {
const rawList = Object.values(instanceList)

View File

@ -6,9 +6,7 @@ export interface statusInstanceType {
properties: {
instanceAddress: {
type: string;
properties: {
[key in string]: typeof addressSchemaType;
};
properties: Record<string, typeof addressSchemaType>;
required: string[];
};
tokenAddress?: typeof addressSchemaType;
@ -20,17 +18,13 @@ export interface statusInstanceType {
export interface statusInstancesType {
type: string;
properties: {
[key in string]: statusInstanceType;
};
properties: Record<string, statusInstanceType>;
required: string[];
}
export interface statusEthPricesType {
type: string;
properties: {
[key in string]: typeof bnSchemaType;
};
properties: Record<string, typeof bnSchemaType>;
required?: string[];
}
@ -41,11 +35,12 @@ export interface statusSchema {
instances?: statusInstancesType;
gasPrices: {
type: string;
properties: {
[key in string]: {
properties: Record<
string,
{
type: string;
};
};
}
>;
required: string[];
};
netId: {
@ -148,18 +143,10 @@ export function getStatusSchema(netId: NetIdType, config: Config, tovarish: bool
properties: {
instanceAddress: {
type: 'object',
properties: amounts.reduce(
(
acc: {
[key in string]: typeof addressSchemaType;
},
cur,
) => {
properties: amounts.reduce((acc: Record<string, typeof addressSchemaType>, cur) => {
acc[cur] = addressSchemaType;
return acc;
},
{},
),
}, {}),
required: amounts.filter((amount) => !optionalInstances.includes(amount)),
},
decimals: { enum: [decimals] },
@ -203,7 +190,7 @@ export function getStatusSchema(netId: NetIdType, config: Config, tovarish: bool
if (_tokens.length) {
const ethPrices: statusEthPricesType = {
type: 'object',
properties: _tokens.reduce((acc: { [key in string]: typeof bnSchemaType }, token: string) => {
properties: _tokens.reduce((acc: Record<string, typeof bnSchemaType>, token: string) => {
acc[token] = bnSchemaType;
return acc;
}, {}),

View File

@ -327,7 +327,6 @@ export class TovarishClient extends RelayerClient {
const events = [];
let lastSyncBlock = fromBlock;
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line prefer-const
let { events: fetchedEvents, lastSyncBlock: currentBlock } = (await fetchData(url, {

View File

@ -122,17 +122,17 @@ export function toFixedHex(numberish: BigNumberish, length = 32) {
);
}
export function toFixedLength(string: string, length: number = 32) {
export function toFixedLength(string: string, length = 32) {
string = string.replace('0x', '');
return '0x' + string.padStart(length * 2, '0');
}
// Random BigInt in a range of bytes
export function rBigInt(nbytes: number = 31) {
export function rBigInt(nbytes = 31) {
return bytesToBN(crypto.getRandomValues(new Uint8Array(nbytes)));
}
export function rHex(nbytes: number = 32) {
export function rHex(nbytes = 32) {
return bytesToHex(crypto.getRandomValues(new Uint8Array(nbytes)));
}
@ -142,7 +142,7 @@ export function bigIntReplacer(key: any, value: any) {
return typeof value === 'bigint' ? value.toString() : value;
}
export function substring(str: string, length: number = 10) {
export function substring(str: string, length = 10) {
if (str.length < length * 2) {
return str;
}
@ -150,11 +150,11 @@ export function substring(str: string, length: number = 10) {
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
}
export async function digest(bytes: Uint8Array, algo: string = 'SHA-384') {
export async function digest(bytes: Uint8Array, algo = 'SHA-384') {
return new Uint8Array(await crypto.subtle.digest(algo, bytes));
}
export function numberFormatter(num: string | number | bigint, digits: number = 3): string {
export function numberFormatter(num: string | number | bigint, digits = 3): string {
const lookup = [
{ value: 1, symbol: '' },
{ value: 1e3, symbol: 'K' },

View File

@ -4,7 +4,7 @@ import { ethers } from 'hardhat';
import { expect } from 'chai';
import { formatEther } from 'ethers';
import { ETHTornado__factory, Verifier__factory } from '@tornado/contracts';
import { ETHTornado__factory, Verifier__factory } from 'tornado-contracts';
import { Deposit, deployHasher } from '../src';
const { getSigners } = ethers;

View File

@ -3,5 +3,7 @@
"compilerOptions": {
"rootDir": "./src"
},
"include": ["./src/**/*"],
"exclude": ["./test/**/*"],
"files": []
}

View File

@ -110,6 +110,9 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["./src/**/*"],
"include": [
"./src/**/*",
"./test/**/*"
],
"files": ["./hardhat.config.ts"]
}

View File

@ -2,14 +2,23 @@ const { BannerPlugin } = require('webpack');
const path = require('path');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const esbuildLoader = {
const commonRules = [
{
test: /\.ts?$/,
loader: 'esbuild-loader',
options: {
loader: 'ts',
target: 'es2022',
}
},
// Disable strict dependency resolution for ESM modules, so that polyfill plugin can handle the rest
{
test: /\.m?js$/,
resolve: {
fullySpecified: false
}
}
]
const commonAlias = {
fs: false,
@ -26,7 +35,7 @@ module.exports = [
{
mode: 'production',
module: {
rules: [esbuildLoader]
rules: [...commonRules]
},
entry: './src/index.ts',
output: {
@ -51,7 +60,7 @@ module.exports = [
{
mode: 'production',
module: {
rules: [esbuildLoader]
rules: [...commonRules]
},
entry: './src/index.ts',
output: {
@ -73,7 +82,7 @@ module.exports = [
{
mode: 'production',
module: {
rules: [esbuildLoader]
rules: [...commonRules]
},
entry: './src/merkleTreeWorker.ts',
output: {
@ -101,7 +110,7 @@ module.exports = [
{
mode: 'production',
module: {
rules: [esbuildLoader]
rules: [...commonRules]
},
entry: './src/merkleTreeWorker.ts',
output: {
@ -126,7 +135,7 @@ module.exports = [
{
mode: 'production',
module: {
rules: [esbuildLoader]
rules: [...commonRules]
},
entry: './src/contracts.ts',
output: {
@ -151,7 +160,7 @@ module.exports = [
{
mode: 'production',
module: {
rules: [esbuildLoader]
rules: [...commonRules]
},
entry: './src/contracts.ts',
output: {

1927
yarn.lock

File diff suppressed because it is too large Load Diff