Compare commits
2 Commits
5eb3a310c5
...
7dcd41c2c3
Author | SHA1 | Date | |
---|---|---|---|
7dcd41c2c3 | |||
0d8c3cc7a4 |
23745
dist/cli.js
vendored
23745
dist/cli.js
vendored
File diff suppressed because one or more lines are too long
2649
dist/index.js
vendored
2649
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
2621
dist/index.mjs
vendored
2621
dist/index.mjs
vendored
File diff suppressed because it is too large
Load Diff
30345
dist/index.umd.js
vendored
30345
dist/index.umd.js
vendored
File diff suppressed because one or more lines are too long
9
dist/program.d.ts
vendored
9
dist/program.d.ts
vendored
@ -1,13 +1,14 @@
|
||||
import 'dotenv/config';
|
||||
import { Command } from 'commander';
|
||||
import { JsonRpcProvider, Provider, TransactionLike, Wallet, VoidSigner, BigNumberish } from 'ethers';
|
||||
import { getProviderOptions, TornadoWallet, TornadoVoidSigner, Relayer, RelayerInfo, RelayerError, RelayerClient, fetchDataOptions, Config } from './services';
|
||||
import { JsonRpcProvider, Provider, TransactionLike, Wallet, VoidSigner } from 'ethers';
|
||||
import { getProviderOptions, TornadoWallet, TornadoVoidSigner, Relayer, RelayerInfo, RelayerError, RelayerClient, fetchDataOptions, NetIdType, Config } from './services';
|
||||
export type commonProgramOptions = {
|
||||
rpc?: string;
|
||||
ethRpc?: string;
|
||||
graph?: string;
|
||||
ethGraph?: string;
|
||||
disableGraph?: boolean;
|
||||
accountKey?: string;
|
||||
relayer?: string;
|
||||
walletWithdrawal?: boolean;
|
||||
torPort?: number;
|
||||
@ -29,7 +30,7 @@ export declare function getProgramOptions(options: commonProgramOptions): Promis
|
||||
fetchDataOptions: fetchDataOptions;
|
||||
}>;
|
||||
export declare function getProgramGraphAPI(options: commonProgramOptions, config: Config): string;
|
||||
export declare function getProgramProvider(netId: BigNumberish, rpcUrl: string | undefined, config: Config, providerOptions?: getProviderOptions): JsonRpcProvider;
|
||||
export declare function getProgramProvider(netId: NetIdType, rpcUrl: string | undefined, config: Config, providerOptions?: getProviderOptions): JsonRpcProvider;
|
||||
export declare function getProgramSigner({ options, provider, }: {
|
||||
options: commonProgramOptions;
|
||||
provider: Provider;
|
||||
@ -37,7 +38,7 @@ export declare function getProgramSigner({ options, provider, }: {
|
||||
export declare function getProgramRelayer({ options, fetchDataOptions, netId, }: {
|
||||
options: commonProgramOptions;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
}): Promise<{
|
||||
validRelayers?: RelayerInfo[] | Relayer[];
|
||||
invalidRelayers?: RelayerError[];
|
||||
|
6
dist/services/data.d.ts
vendored
6
dist/services/data.d.ts
vendored
@ -3,10 +3,10 @@ import { BaseEvents, MinimalEvents } from './events';
|
||||
export declare function existsAsync(fileOrDir: string): Promise<boolean>;
|
||||
export declare function zipAsync(file: AsyncZippable): Promise<Uint8Array>;
|
||||
export declare function unzipAsync(data: Uint8Array): Promise<Unzipped>;
|
||||
export declare function saveEvents<T extends MinimalEvents>({ name, userDirectory, events, }: {
|
||||
name: string;
|
||||
export declare function saveUserFile({ fileName, userDirectory, dataString, }: {
|
||||
fileName: string;
|
||||
userDirectory: string;
|
||||
events: T[];
|
||||
dataString: string;
|
||||
}): Promise<void>;
|
||||
export declare function loadSavedEvents<T extends MinimalEvents>({ name, userDirectory, deployedBlock, }: {
|
||||
name: string;
|
||||
|
9
dist/services/deposits.d.ts
vendored
9
dist/services/deposits.d.ts
vendored
@ -1,7 +1,8 @@
|
||||
import type { NetIdType } from './networkConfig';
|
||||
export type DepositType = {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: string | number;
|
||||
netId: NetIdType;
|
||||
};
|
||||
export type createDepositParams = {
|
||||
nullifier: bigint;
|
||||
@ -34,7 +35,7 @@ export declare function createDeposit({ nullifier, secret }: createDepositParams
|
||||
export interface DepositConstructor {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
nullifier: bigint;
|
||||
secret: bigint;
|
||||
note: string;
|
||||
@ -46,7 +47,7 @@ export interface DepositConstructor {
|
||||
export declare class Deposit {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
nullifier: bigint;
|
||||
secret: bigint;
|
||||
note: string;
|
||||
@ -65,7 +66,7 @@ export type parsedInvoiceExec = DepositType & {
|
||||
export declare class Invoice {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
commitment: string;
|
||||
invoice: string;
|
||||
constructor(invoiceString: string);
|
||||
|
48
dist/services/encryptedNotes.d.ts
vendored
Normal file
48
dist/services/encryptedNotes.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
import { EthEncryptedData } from '@metamask/eth-sig-util';
|
||||
import { Echoer } from '@tornado/contracts';
|
||||
import { Wallet } from 'ethers';
|
||||
import { EchoEvents, EncryptedNotesEvents } from './events';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
export interface NoteToEncrypt {
|
||||
address: string;
|
||||
noteHex: string;
|
||||
}
|
||||
export interface DecryptedNotes {
|
||||
blockNumber: number;
|
||||
address: string;
|
||||
noteHex: string;
|
||||
}
|
||||
export declare function packEncryptedMessage({ nonce, ephemPublicKey, ciphertext }: EthEncryptedData): string;
|
||||
export declare function unpackEncryptedMessage(encryptedMessage: string): EthEncryptedData & {
|
||||
messageBuff: string;
|
||||
};
|
||||
export interface NoteAccountConstructor {
|
||||
netId: NetIdType;
|
||||
blockNumber?: number;
|
||||
recoveryKey?: string;
|
||||
Echoer: Echoer;
|
||||
}
|
||||
export declare class NoteAccount {
|
||||
netId: NetIdType;
|
||||
blockNumber?: number;
|
||||
recoveryKey: string;
|
||||
recoveryAddress: string;
|
||||
recoveryPublicKey: string;
|
||||
Echoer: Echoer;
|
||||
constructor({ netId, blockNumber, recoveryKey, Echoer }: NoteAccountConstructor);
|
||||
/**
|
||||
* Intends to mock eth_getEncryptionPublicKey behavior from MetaMask
|
||||
* In order to make the recoveryKey retrival from Echoer possible from the bare private key
|
||||
*/
|
||||
static getWalletPublicKey(wallet: Wallet): string;
|
||||
getEncryptedAccount(walletPublicKey: string): {
|
||||
encryptedData: EthEncryptedData;
|
||||
data: string;
|
||||
};
|
||||
/**
|
||||
* Decrypt Echoer backuped note encryption account with private keys
|
||||
*/
|
||||
decryptAccountsWithWallet(wallet: Wallet, events: EchoEvents[]): NoteAccount[];
|
||||
decryptNotes(events: EncryptedNotesEvents[]): DecryptedNotes[];
|
||||
encryptNote({ address, noteHex }: NoteToEncrypt): string;
|
||||
}
|
43
dist/services/events/base.d.ts
vendored
43
dist/services/events/base.d.ts
vendored
@ -1,12 +1,13 @@
|
||||
import { BaseContract, Provider, EventLog, ContractEventName } from 'ethers';
|
||||
import type { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry } from '@tornado/contracts';
|
||||
import type { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry, Echoer } from '@tornado/contracts';
|
||||
import { BatchEventsService, BatchBlockService, BatchTransactionService, BatchEventOnProgress, BatchBlockOnProgress } from '../batch';
|
||||
import { fetchDataOptions } from '../providers';
|
||||
import type { BaseEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, GovernanceProposalCreatedEvents, GovernanceVotedEvents, GovernanceDelegatedEvents, GovernanceUndelegatedEvents, RegistersEvents } from './types';
|
||||
import type { NetIdType } from '../networkConfig';
|
||||
import type { BaseEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, AllGovernanceEvents, RegistersEvents, EchoEvents } from './types';
|
||||
export declare const DEPOSIT = "deposit";
|
||||
export declare const WITHDRAWAL = "withdrawal";
|
||||
export type BaseEventsServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -28,7 +29,7 @@ export type BaseGraphParams = {
|
||||
onProgress?: BatchGraphOnProgress;
|
||||
};
|
||||
export declare class BaseEventsService<EventType extends MinimalEvents> {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -81,7 +82,7 @@ export declare class BaseEventsService<EventType extends MinimalEvents> {
|
||||
}>;
|
||||
}
|
||||
export type BaseDepositsServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -110,8 +111,27 @@ export declare class BaseDepositsService extends BaseEventsService<DepositsEvent
|
||||
events: (DepositsEvents | WithdrawalsEvents)[];
|
||||
}): void;
|
||||
}
|
||||
export type BaseEchoServiceConstructor = {
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
Echoer: Echoer;
|
||||
deployedBlock?: number;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
};
|
||||
export declare class BaseEchoService extends BaseEventsService<EchoEvents> {
|
||||
constructor({ netId, provider, graphApi, subgraphName, Echoer, deployedBlock, fetchDataOptions, }: BaseEchoServiceConstructor);
|
||||
getInstanceName(): string;
|
||||
getType(): string;
|
||||
getGraphMethod(): string;
|
||||
formatEvents(events: EventLog[]): Promise<EchoEvents[]>;
|
||||
getEventsFromGraph({ fromBlock }: {
|
||||
fromBlock: number;
|
||||
}): Promise<BaseEvents<EchoEvents>>;
|
||||
}
|
||||
export type BaseEncryptedNotesServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -126,9 +146,8 @@ export declare class BaseEncryptedNotesService extends BaseEventsService<Encrypt
|
||||
getGraphMethod(): string;
|
||||
formatEvents(events: EventLog[]): Promise<EncryptedNotesEvents[]>;
|
||||
}
|
||||
export type BaseGovernanceEventTypes = GovernanceProposalCreatedEvents | GovernanceVotedEvents | GovernanceDelegatedEvents | GovernanceUndelegatedEvents;
|
||||
export type BaseGovernanceServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -136,19 +155,19 @@ export type BaseGovernanceServiceConstructor = {
|
||||
deployedBlock?: number;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
};
|
||||
export declare class BaseGovernanceService extends BaseEventsService<BaseGovernanceEventTypes> {
|
||||
export declare class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents> {
|
||||
batchTransactionService: BatchTransactionService;
|
||||
constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, }: BaseGovernanceServiceConstructor);
|
||||
getInstanceName(): string;
|
||||
getType(): string;
|
||||
getGraphMethod(): string;
|
||||
formatEvents(events: EventLog[]): Promise<BaseGovernanceEventTypes[]>;
|
||||
formatEvents(events: EventLog[]): Promise<AllGovernanceEvents[]>;
|
||||
getEventsFromGraph({ fromBlock }: {
|
||||
fromBlock: number;
|
||||
}): Promise<BaseEvents<BaseGovernanceEventTypes>>;
|
||||
}): Promise<BaseEvents<AllGovernanceEvents>>;
|
||||
}
|
||||
export type BaseRegistryServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
|
24
dist/services/events/node.d.ts
vendored
24
dist/services/events/node.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import { BatchBlockOnProgress, BatchEventOnProgress } from '../batch';
|
||||
import { BaseDepositsService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseDepositsServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseGovernanceEventTypes } from './base';
|
||||
import type { BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, RegistersEvents } from './types';
|
||||
import { BaseDepositsService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseDepositsServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseEchoServiceConstructor, BaseEchoService } from './base';
|
||||
import type { BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, RegistersEvents, AllGovernanceEvents, EchoEvents } from './types';
|
||||
export type NodeDepositsServiceConstructor = BaseDepositsServiceConstructor & {
|
||||
cacheDirectory?: string;
|
||||
userDirectory?: string;
|
||||
@ -17,6 +17,20 @@ export declare class NodeDepositsService extends BaseDepositsService {
|
||||
getEventsFromCache(): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<DepositsEvents | WithdrawalsEvents>): Promise<void>;
|
||||
}
|
||||
export type NodeEchoServiceConstructor = BaseEchoServiceConstructor & {
|
||||
cacheDirectory?: string;
|
||||
userDirectory?: string;
|
||||
};
|
||||
export declare class NodeEchoService extends BaseEchoService {
|
||||
cacheDirectory?: string;
|
||||
userDirectory?: string;
|
||||
constructor({ netId, provider, graphApi, subgraphName, Echoer, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeEchoServiceConstructor);
|
||||
updateEventProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void;
|
||||
updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void;
|
||||
getEventsFromDB(): Promise<BaseEvents<EchoEvents>>;
|
||||
getEventsFromCache(): Promise<BaseEvents<EchoEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<EchoEvents>): Promise<void>;
|
||||
}
|
||||
export type NodeEncryptedNotesServiceConstructor = BaseEncryptedNotesServiceConstructor & {
|
||||
cacheDirectory?: string;
|
||||
userDirectory?: string;
|
||||
@ -42,9 +56,9 @@ export declare class NodeGovernanceService extends BaseGovernanceService {
|
||||
updateEventProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void;
|
||||
updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters<BatchEventOnProgress>[0]): void;
|
||||
updateTransactionProgress({ currentIndex, totalIndex }: Parameters<BatchBlockOnProgress>[0]): void;
|
||||
getEventsFromDB(): Promise<BaseEvents<BaseGovernanceEventTypes>>;
|
||||
getEventsFromCache(): Promise<BaseEvents<BaseGovernanceEventTypes>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<BaseGovernanceEventTypes>): Promise<void>;
|
||||
getEventsFromDB(): Promise<BaseEvents<AllGovernanceEvents>>;
|
||||
getEventsFromCache(): Promise<BaseEvents<AllGovernanceEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<AllGovernanceEvents>): Promise<void>;
|
||||
}
|
||||
export type NodeRegistryServiceConstructor = BaseRegistryServiceConstructor & {
|
||||
cacheDirectory?: string;
|
||||
|
5
dist/services/events/types.d.ts
vendored
5
dist/services/events/types.d.ts
vendored
@ -39,6 +39,7 @@ export type GovernanceUndelegatedEvents = GovernanceEvents & {
|
||||
account: string;
|
||||
delegateFrom: string;
|
||||
};
|
||||
export type AllGovernanceEvents = GovernanceProposalCreatedEvents | GovernanceVotedEvents | GovernanceDelegatedEvents | GovernanceUndelegatedEvents;
|
||||
export type RegistersEvents = MinimalEvents & RelayerParams;
|
||||
export type DepositsEvents = MinimalEvents & {
|
||||
commitment: string;
|
||||
@ -52,6 +53,10 @@ export type WithdrawalsEvents = MinimalEvents & {
|
||||
fee: string;
|
||||
timestamp: number;
|
||||
};
|
||||
export type EchoEvents = MinimalEvents & {
|
||||
address: string;
|
||||
encryptedAccount: string;
|
||||
};
|
||||
export type EncryptedNotesEvents = MinimalEvents & {
|
||||
encryptedNote: string;
|
||||
};
|
||||
|
78
dist/services/graphql/index.d.ts
vendored
78
dist/services/graphql/index.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
import { fetchDataOptions } from '../providers';
|
||||
import type { BaseGraphEvents, RegistersEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, BatchGraphOnProgress } from '../events';
|
||||
import type { BaseGraphEvents, RegistersEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, BatchGraphOnProgress, EchoEvents, AllGovernanceEvents } from '../events';
|
||||
export * from './queries';
|
||||
export type queryGraphParams = {
|
||||
graphApi: string;
|
||||
@ -165,6 +165,29 @@ export interface getNoteAccountsReturns {
|
||||
lastSyncBlock: null | number;
|
||||
}
|
||||
export declare function getNoteAccounts({ graphApi, subgraphName, address, fetchDataOptions, }: getNoteAccountsParams): Promise<getNoteAccountsReturns>;
|
||||
export interface GraphEchoEvents {
|
||||
noteAccounts: {
|
||||
id: string;
|
||||
blockNumber: string;
|
||||
address: string;
|
||||
encryptedAccount: string;
|
||||
}[];
|
||||
_meta: {
|
||||
block: {
|
||||
number: number;
|
||||
};
|
||||
hasIndexingErrors: boolean;
|
||||
};
|
||||
}
|
||||
export interface getGraphEchoEventsParams {
|
||||
graphApi: string;
|
||||
subgraphName: string;
|
||||
fromBlock: number;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
onProgress?: BatchGraphOnProgress;
|
||||
}
|
||||
export declare function getGraphEchoEvents({ graphApi, subgraphName, fromBlock, fetchDataOptions, }: getGraphEchoEventsParams): Promise<GraphEchoEvents>;
|
||||
export declare function getAllGraphEchoEvents({ graphApi, subgraphName, fromBlock, fetchDataOptions, onProgress, }: getGraphEchoEventsParams): Promise<BaseGraphEvents<EchoEvents>>;
|
||||
export interface GraphEncryptedNotes {
|
||||
encryptedNotes: {
|
||||
blockNumber: string;
|
||||
@ -188,3 +211,56 @@ export interface getEncryptedNotesParams {
|
||||
}
|
||||
export declare function getEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions, }: getEncryptedNotesParams): Promise<GraphEncryptedNotes>;
|
||||
export declare function getAllEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions, onProgress, }: getEncryptedNotesParams): Promise<BaseGraphEvents<EncryptedNotesEvents>>;
|
||||
export interface GraphGovernanceEvents {
|
||||
proposals: {
|
||||
blockNumber: number;
|
||||
logIndex: number;
|
||||
transactionHash: string;
|
||||
proposalId: number;
|
||||
proposer: string;
|
||||
target: string;
|
||||
startTime: number;
|
||||
endTime: number;
|
||||
description: string;
|
||||
}[];
|
||||
votes: {
|
||||
blockNumber: number;
|
||||
logIndex: number;
|
||||
transactionHash: string;
|
||||
proposalId: number;
|
||||
voter: string;
|
||||
support: boolean;
|
||||
votes: string;
|
||||
from: string;
|
||||
input: string;
|
||||
}[];
|
||||
delegates: {
|
||||
blockNumber: number;
|
||||
logIndex: number;
|
||||
transactionHash: string;
|
||||
account: string;
|
||||
delegateTo: string;
|
||||
}[];
|
||||
undelegates: {
|
||||
blockNumber: number;
|
||||
logIndex: number;
|
||||
transactionHash: string;
|
||||
account: string;
|
||||
delegateFrom: string;
|
||||
}[];
|
||||
_meta: {
|
||||
block: {
|
||||
number: number;
|
||||
};
|
||||
hasIndexingErrors: boolean;
|
||||
};
|
||||
}
|
||||
export interface getGovernanceEventsParams {
|
||||
graphApi: string;
|
||||
subgraphName: string;
|
||||
fromBlock: number;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
onProgress?: BatchGraphOnProgress;
|
||||
}
|
||||
export declare function getGovernanceEvents({ graphApi, subgraphName, fromBlock, fetchDataOptions, }: getGovernanceEventsParams): Promise<GraphGovernanceEvents>;
|
||||
export declare function getAllGovernanceEvents({ graphApi, subgraphName, fromBlock, fetchDataOptions, onProgress, }: getGovernanceEventsParams): Promise<BaseGraphEvents<AllGovernanceEvents>>;
|
||||
|
3
dist/services/graphql/queries.d.ts
vendored
3
dist/services/graphql/queries.d.ts
vendored
@ -4,4 +4,7 @@ export declare const GET_REGISTERED = "\n query getRegistered($first: Int, $fro
|
||||
export declare const GET_DEPOSITS = "\n query getDeposits($currency: String!, $amount: String!, $first: Int, $fromBlock: Int) {\n deposits(first: $first, orderBy: index, orderDirection: asc, where: { \n amount: $amount,\n currency: $currency,\n blockNumber_gte: $fromBlock\n }) {\n id\n blockNumber\n commitment\n index\n timestamp\n from\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n";
|
||||
export declare const GET_WITHDRAWALS = "\n query getWithdrawals($currency: String!, $amount: String!, $first: Int, $fromBlock: Int!) {\n withdrawals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { \n currency: $currency,\n amount: $amount,\n blockNumber_gte: $fromBlock\n }) {\n id\n blockNumber\n nullifier\n to\n fee\n timestamp\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n";
|
||||
export declare const GET_NOTE_ACCOUNTS = "\n query getNoteAccount($address: String!) {\n noteAccounts(where: { address: $address }) {\n id\n index\n address\n encryptedAccount\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n";
|
||||
export declare const GET_ECHO_EVENTS = "\n query getNoteAccounts($first: Int, $fromBlock: Int) {\n noteAccounts(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n id\n blockNumber\n address\n encryptedAccount\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n";
|
||||
export declare const GET_ENCRYPTED_NOTES = "\n query getEncryptedNotes($first: Int, $fromBlock: Int) {\n encryptedNotes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n blockNumber\n index\n transactionHash\n encryptedNote\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n";
|
||||
export declare const GET_GOVERNANCE_EVENTS = "\n query getGovernanceEvents($first: Int, $fromBlock: Int) {\n proposals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n blockNumber\n logIndex\n transactionHash\n proposalId\n proposer\n target\n startTime\n endTime\n description\n }\n votes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n blockNumber\n logIndex\n transactionHash\n proposalId\n voter\n support\n votes\n from\n input\n }\n delegates(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n blockNumber\n logIndex\n transactionHash\n account\n delegateTo\n }\n undelegates(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n blockNumber\n logIndex\n transactionHash\n account\n delegateFrom\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n";
|
||||
export declare const GET_GOVERNANCE_APY = "\n stakeDailyBurns(first: 30, orderBy: date, orderDirection: desc) {\n id\n date\n dailyAmountBurned\n }\n";
|
||||
|
2
dist/services/index.d.ts
vendored
2
dist/services/index.d.ts
vendored
@ -4,6 +4,7 @@ export * from './schemas';
|
||||
export * from './batch';
|
||||
export * from './data';
|
||||
export * from './deposits';
|
||||
export * from './encryptedNotes';
|
||||
export * from './fees';
|
||||
export * from './merkleTree';
|
||||
export * from './mimc';
|
||||
@ -15,5 +16,6 @@ export * from './prices';
|
||||
export * from './providers';
|
||||
export * from './relayerClient';
|
||||
export * from './tokens';
|
||||
export * from './treeCache';
|
||||
export * from './utils';
|
||||
export * from './websnark';
|
||||
|
23
dist/services/merkleTree.d.ts
vendored
23
dist/services/merkleTree.d.ts
vendored
@ -1,10 +1,11 @@
|
||||
import { MerkleTree, Element } from '@tornado/fixed-merkle-tree';
|
||||
import { MerkleTree, PartialMerkleTree, Element, TreeEdge } from '@tornado/fixed-merkle-tree';
|
||||
import type { Tornado } from '@tornado/contracts';
|
||||
import type { DepositType } from './deposits';
|
||||
import type { DepositsEvents } from './events';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
export type MerkleTreeConstructor = DepositType & {
|
||||
Tornado: Tornado;
|
||||
commitment?: string;
|
||||
commitmentHex?: string;
|
||||
merkleTreeHeight?: number;
|
||||
emptyElement?: string;
|
||||
merkleWorkerPath?: string;
|
||||
@ -12,18 +13,18 @@ export type MerkleTreeConstructor = DepositType & {
|
||||
export declare class MerkleTreeService {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
Tornado: Tornado;
|
||||
commitment?: string;
|
||||
commitmentHex?: string;
|
||||
instanceName: string;
|
||||
merkleTreeHeight: number;
|
||||
emptyElement: string;
|
||||
merkleWorkerPath?: string;
|
||||
constructor({ netId, amount, currency, Tornado, commitment, merkleTreeHeight, emptyElement, merkleWorkerPath, }: MerkleTreeConstructor);
|
||||
createTree({ events }: {
|
||||
events: Element[];
|
||||
}): Promise<MerkleTree>;
|
||||
verifyTree({ events }: {
|
||||
events: DepositsEvents[];
|
||||
}): Promise<MerkleTree>;
|
||||
constructor({ netId, amount, currency, Tornado, commitmentHex, merkleTreeHeight, emptyElement, merkleWorkerPath, }: MerkleTreeConstructor);
|
||||
createTree(events: Element[]): Promise<MerkleTree>;
|
||||
createPartialTree({ edge, elements }: {
|
||||
edge: TreeEdge;
|
||||
elements: Element[];
|
||||
}): Promise<PartialMerkleTree>;
|
||||
verifyTree(events: DepositsEvents[]): Promise<MerkleTree>;
|
||||
}
|
||||
|
66
dist/services/networkConfig.d.ts
vendored
66
dist/services/networkConfig.d.ts
vendored
@ -1,3 +1,17 @@
|
||||
/**
|
||||
* Type of default supported networks
|
||||
*/
|
||||
export declare enum NetId {
|
||||
MAINNET = 1,
|
||||
BSC = 56,
|
||||
POLYGON = 137,
|
||||
OPTIMISM = 10,
|
||||
ARBITRUM = 42161,
|
||||
GNOSIS = 100,
|
||||
AVALANCHE = 43114,
|
||||
SEPOLIA = 11155111
|
||||
}
|
||||
export type NetIdType = NetId | number;
|
||||
export interface RpcUrl {
|
||||
name: string;
|
||||
url: string;
|
||||
@ -37,20 +51,20 @@ export type Config = {
|
||||
};
|
||||
nativeCurrency: string;
|
||||
currencyName: string;
|
||||
explorerUrl: {
|
||||
tx: string;
|
||||
address: string;
|
||||
block: string;
|
||||
};
|
||||
explorerUrl: string;
|
||||
merkleTreeHeight: number;
|
||||
emptyElement: string;
|
||||
networkName: string;
|
||||
deployedBlock: number;
|
||||
rpcUrls: RpcUrls;
|
||||
multicall: string;
|
||||
multicallContract: string;
|
||||
routerContract: string;
|
||||
registryContract?: string;
|
||||
echoContract: string;
|
||||
offchainOracleContract?: string;
|
||||
tornContract?: string;
|
||||
governanceContract?: string;
|
||||
stakingRewardsContract?: string;
|
||||
registryContract?: string;
|
||||
aggregatorContract?: string;
|
||||
reverseRecordsContract?: string;
|
||||
gasPriceOracleContract?: string;
|
||||
@ -58,6 +72,7 @@ export type Config = {
|
||||
ovmGasPriceOracleContract?: string;
|
||||
tornadoSubgraph: string;
|
||||
registrySubgraph?: string;
|
||||
governanceSubgraph?: string;
|
||||
subgraphs: SubgraphUrls;
|
||||
tokens: TokenInstances;
|
||||
optionalTokens?: string[];
|
||||
@ -70,17 +85,32 @@ export type Config = {
|
||||
REGISTRY_BLOCK?: number;
|
||||
MINING_BLOCK_TIME?: number;
|
||||
};
|
||||
'torn.contract.tornadocash.eth'?: string;
|
||||
'governance.contract.tornadocash.eth'?: string;
|
||||
'staking-rewards.contract.tornadocash.eth'?: string;
|
||||
'tornado-router.contract.tornadocash.eth'?: string;
|
||||
'tornado-proxy-light.contract.tornadocash.eth'?: string;
|
||||
};
|
||||
export type networkConfig = {
|
||||
[key in string]: Config;
|
||||
[key in NetIdType]: Config;
|
||||
};
|
||||
export declare const blockSyncInterval = 10000;
|
||||
export declare const enabledChains: string[];
|
||||
export declare const networkConfig: networkConfig;
|
||||
export declare const subdomains: string[];
|
||||
export default networkConfig;
|
||||
export declare const defaultConfig: networkConfig;
|
||||
export declare const enabledChains: number[];
|
||||
/**
|
||||
* Custom config object to extend default config
|
||||
*
|
||||
* Inspired by getUrlFunc from ethers.js
|
||||
* https://github.com/ethers-io/ethers.js/blob/v6/src.ts/utils/fetch.ts#L59
|
||||
*/
|
||||
export declare let customConfig: networkConfig;
|
||||
/**
|
||||
* Add or override existing network config object
|
||||
*
|
||||
* Could be also called on the UI hook so that the UI could allow people to use custom privacy pools
|
||||
*/
|
||||
export declare function addNetwork(newConfig: networkConfig): void;
|
||||
export declare function getNetworkConfig(): networkConfig;
|
||||
export declare function getConfig(netId: NetIdType): Config;
|
||||
export declare function getInstanceByAddress({ netId, address }: {
|
||||
netId: NetIdType;
|
||||
address: string;
|
||||
}): {
|
||||
amount: string;
|
||||
currency: string;
|
||||
} | undefined;
|
||||
export declare function getSubdomains(): string[];
|
||||
|
4
dist/services/parser.d.ts
vendored
4
dist/services/parser.d.ts
vendored
@ -4,3 +4,7 @@ export declare function parseRelayer(value?: string): string;
|
||||
export declare function parseAddress(value?: string): string;
|
||||
export declare function parseMnemonic(value?: string): string;
|
||||
export declare function parseKey(value?: string): string;
|
||||
/**
|
||||
* Recovery key shouldn't have a 0x prefix (Also this is how the UI generates)
|
||||
*/
|
||||
export declare function parseRecoveryKey(value?: string): string;
|
||||
|
8
dist/services/providers.d.ts
vendored
8
dist/services/providers.d.ts
vendored
@ -3,9 +3,9 @@
|
||||
/// <reference types="node" />
|
||||
import type { EventEmitter } from 'stream';
|
||||
import type { RequestOptions } from 'http';
|
||||
import { JsonRpcApiProvider, JsonRpcProvider, Wallet, FetchGetUrlFunc, Provider, SigningKey, TransactionRequest, JsonRpcSigner, BrowserProvider, Networkish, Eip1193Provider, VoidSigner, FetchUrlFeeDataNetworkPlugin, BigNumberish } from 'ethers';
|
||||
import { JsonRpcApiProvider, JsonRpcProvider, Wallet, FetchGetUrlFunc, Provider, SigningKey, TransactionRequest, JsonRpcSigner, BrowserProvider, Networkish, Eip1193Provider, VoidSigner, FetchUrlFeeDataNetworkPlugin } from 'ethers';
|
||||
import type { RequestInfo, RequestInit, Response, HeadersInit } from 'node-fetch';
|
||||
import type { Config } from './networkConfig';
|
||||
import type { Config, NetIdType } from './networkConfig';
|
||||
declare global {
|
||||
interface Window {
|
||||
ethereum?: Eip1193Provider & EventEmitter;
|
||||
@ -41,7 +41,7 @@ export type getProviderOptions = fetchDataOptions & {
|
||||
};
|
||||
export declare function getGasOraclePlugin(networkKey: string, fetchOptions?: getProviderOptions): FetchUrlFeeDataNetworkPlugin;
|
||||
export declare function getProvider(rpcUrl: string, fetchOptions?: getProviderOptions): Promise<JsonRpcProvider>;
|
||||
export declare function getProviderWithNetId(netId: BigNumberish, rpcUrl: string, config: Config, fetchOptions?: getProviderOptions): JsonRpcProvider;
|
||||
export declare function getProviderWithNetId(netId: NetIdType, rpcUrl: string, config: Config, fetchOptions?: getProviderOptions): JsonRpcProvider;
|
||||
export declare const populateTransaction: (signer: TornadoWallet | TornadoVoidSigner | TornadoRpcSigner, tx: TransactionRequest) => Promise<TransactionRequest>;
|
||||
export type TornadoWalletOptions = {
|
||||
gasPriceBump?: number;
|
||||
@ -80,7 +80,7 @@ export declare class TornadoRpcSigner extends JsonRpcSigner {
|
||||
export type connectWalletFunc = (...args: any[]) => Promise<void>;
|
||||
export type handleWalletFunc = (...args: any[]) => void;
|
||||
export type TornadoBrowserProviderOptions = TornadoWalletOptions & {
|
||||
webChainId?: BigNumberish;
|
||||
webChainId?: NetIdType;
|
||||
connectWallet?: connectWalletFunc;
|
||||
handleNetworkChanges?: handleWalletFunc;
|
||||
handleAccountChanges?: handleWalletFunc;
|
||||
|
32
dist/services/relayerClient.d.ts
vendored
32
dist/services/relayerClient.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import type { Aggregator } from '@tornado/contracts';
|
||||
import type { RelayerStructOutput } from '@tornado/contracts/dist/contracts/Governance/Aggregator/Aggregator';
|
||||
import type { Config } from './networkConfig';
|
||||
import { NetIdType, Config } from './networkConfig';
|
||||
import { fetchDataOptions } from './providers';
|
||||
import type { snarkProofs } from './websnark';
|
||||
export declare const MIN_STAKE_BALANCE: bigint;
|
||||
@ -9,20 +9,22 @@ export interface RelayerParams {
|
||||
relayerAddress?: string;
|
||||
}
|
||||
export interface Relayer {
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
url: string;
|
||||
hostname: string;
|
||||
rewardAccount: string;
|
||||
instances: string[];
|
||||
gasPrice?: number;
|
||||
ethPrices?: {
|
||||
[key in string]: string;
|
||||
};
|
||||
currentQueue: number;
|
||||
tornadoServiceFee: number;
|
||||
}
|
||||
export type RelayerInfo = Relayer & {
|
||||
hostname: string;
|
||||
ensName: string;
|
||||
stakeBalance: bigint;
|
||||
relayerAddress: string;
|
||||
ethPrices?: {
|
||||
[key in string]: string;
|
||||
};
|
||||
};
|
||||
export type RelayerError = {
|
||||
hostname: string;
|
||||
@ -46,7 +48,7 @@ export interface RelayerStatus {
|
||||
fast: number;
|
||||
additionalProperties?: number;
|
||||
};
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
ethPrices?: {
|
||||
[key in string]: string;
|
||||
};
|
||||
@ -84,12 +86,20 @@ export interface semanticVersion {
|
||||
buildmetadata?: string;
|
||||
}
|
||||
export declare function parseSemanticVersion(version: string): semanticVersion;
|
||||
export declare function isRelayerUpdated(relayerVersion: string, netId: number | string): boolean;
|
||||
export declare function isRelayerUpdated(relayerVersion: string, netId: NetIdType): boolean;
|
||||
export declare function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo, minFee?: number, maxFee?: number): bigint;
|
||||
export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number;
|
||||
export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[], netId: string | number): RelayerInfo;
|
||||
export type RelayerInstanceList = {
|
||||
[key in string]: {
|
||||
instanceAddress: {
|
||||
[key in string]: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
export declare function getSupportedInstances(instanceList: RelayerInstanceList): string[];
|
||||
export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[], netId: NetIdType): RelayerInfo;
|
||||
export interface RelayerClientConstructor {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
config: Config;
|
||||
Aggregator: Aggregator;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
@ -98,7 +108,7 @@ export type RelayerClientWithdraw = snarkProofs & {
|
||||
contract: string;
|
||||
};
|
||||
export declare class RelayerClient {
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
config: Config;
|
||||
Aggregator: Aggregator;
|
||||
selectedRelayer?: Relayer;
|
||||
|
4
dist/services/schemas/status.d.ts
vendored
4
dist/services/schemas/status.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import type { Config } from '../networkConfig';
|
||||
import { Config, NetIdType } from '../networkConfig';
|
||||
export type statusInstanceType = {
|
||||
type: string;
|
||||
properties: {
|
||||
@ -88,5 +88,5 @@ declare const bnType: {
|
||||
type: string;
|
||||
BN: boolean;
|
||||
};
|
||||
export declare function getStatusSchema(netId: number | string, config: Config): statusSchema;
|
||||
export declare function getStatusSchema(netId: NetIdType, config: Config): statusSchema;
|
||||
export {};
|
||||
|
35
dist/services/treeCache.d.ts
vendored
Normal file
35
dist/services/treeCache.d.ts
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Create tree cache file from node.js
|
||||
*
|
||||
* Only works for node.js, modified from https://github.com/tornadocash/tornado-classic-ui/blob/master/scripts/updateTree.js
|
||||
*/
|
||||
import { MerkleTree } from '@tornado/fixed-merkle-tree';
|
||||
import { DepositsEvents } from './events';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
export interface TreeCacheConstructor {
|
||||
netId: NetIdType;
|
||||
amount: string;
|
||||
currency: string;
|
||||
userDirectory: string;
|
||||
PARTS_COUNT?: number;
|
||||
LEAVES?: number;
|
||||
zeroElement?: string;
|
||||
}
|
||||
export interface treeMetadata {
|
||||
blockNumber: number;
|
||||
logIndex: number;
|
||||
transactionHash: string;
|
||||
timestamp: number;
|
||||
from: string;
|
||||
leafIndex: number;
|
||||
}
|
||||
export declare class TreeCache {
|
||||
netId: NetIdType;
|
||||
amount: string;
|
||||
currency: string;
|
||||
userDirectory: string;
|
||||
PARTS_COUNT: number;
|
||||
constructor({ netId, amount, currency, userDirectory, PARTS_COUNT }: TreeCacheConstructor);
|
||||
getInstanceName(): string;
|
||||
createTree(events: DepositsEvents[], tree: MerkleTree): Promise<void>;
|
||||
}
|
5
dist/services/utils.d.ts
vendored
5
dist/services/utils.d.ts
vendored
@ -1,15 +1,20 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { webcrypto } from 'crypto';
|
||||
import BN from 'bn.js';
|
||||
import type { BigNumberish } from 'ethers';
|
||||
type bnInput = number | string | number[] | Uint8Array | Buffer | BN;
|
||||
export declare const isNode: boolean;
|
||||
export declare const crypto: webcrypto.Crypto;
|
||||
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 bytesToBase64(bytes: Uint8Array): string;
|
||||
export declare function base64ToBytes(base64: string): Uint8Array;
|
||||
export declare function bytesToHex(bytes: Uint8Array): string;
|
||||
export declare function hexToBytes(hexString: string): Uint8Array;
|
||||
export declare function bytesToBN(bytes: Uint8Array): bigint;
|
||||
export declare function bnToBytes(bigint: bigint | string): Uint8Array;
|
||||
export declare function leBuff2Int(bytes: Uint8Array): BN;
|
||||
|
@ -16,7 +16,7 @@
|
||||
"lint": "eslint src/**/*.ts --ext .ts --ignore-pattern src/typechain",
|
||||
"build:node": "ts-node scripts/fflate.ts && rollup -c",
|
||||
"build:web": "webpack",
|
||||
"build": "yarn build:node && yarn build:web",
|
||||
"build": "yarn types && yarn build:node && yarn build:web",
|
||||
"start": "ts-node src/cli.ts",
|
||||
"startHelp": "ts-node src/cli.ts help",
|
||||
"createDeposit": "ts-node src/cli.ts create",
|
||||
|
@ -28,7 +28,6 @@ import {
|
||||
ZeroAddress,
|
||||
MaxUint256,
|
||||
Transaction,
|
||||
BigNumberish,
|
||||
getAddress,
|
||||
} from 'ethers';
|
||||
import type MerkleTree from '@tornado/fixed-merkle-tree';
|
||||
@ -73,6 +72,8 @@ import {
|
||||
Invoice,
|
||||
fetchData,
|
||||
fetchDataOptions,
|
||||
NetId,
|
||||
NetIdType,
|
||||
getInstanceByAddress,
|
||||
getSubdomains,
|
||||
getConfig,
|
||||
@ -87,7 +88,7 @@ import {
|
||||
|
||||
const DEFAULT_GAS_LIMIT = Number(process.env.DEFAULT_GAS_LIMIT) || 600_000;
|
||||
|
||||
const RELAYER_NETWORK = Number(process.env.RELAYER_NETWORK) || 1;
|
||||
const RELAYER_NETWORK = Number(process.env.RELAYER_NETWORK) || NetId.MAINNET;
|
||||
|
||||
// Where cached events, trees, circuits, and key is saved
|
||||
const STATIC_DIR = process.env.CACHE_DIR || path.join(__dirname, '../static');
|
||||
@ -231,7 +232,7 @@ export function getProgramGraphAPI(options: commonProgramOptions, config: Config
|
||||
}
|
||||
|
||||
export function getProgramProvider(
|
||||
netId: BigNumberish,
|
||||
netId: NetIdType,
|
||||
rpcUrl: string = '',
|
||||
config: Config,
|
||||
providerOptions?: getProviderOptions,
|
||||
@ -270,7 +271,7 @@ export async function getProgramRelayer({
|
||||
}: {
|
||||
options: commonProgramOptions;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
}): Promise<{
|
||||
validRelayers?: RelayerInfo[] | Relayer[];
|
||||
invalidRelayers?: RelayerError[];
|
||||
@ -458,7 +459,7 @@ export function tornadoProgram() {
|
||||
.argument('<netId>', 'Network Chain ID to connect with (see https://chainlist.org for examples)', parseNumber)
|
||||
.argument('<currency>', 'Currency to deposit on Tornado Cash')
|
||||
.argument('<amount>', 'Amount to deposit on Tornado Cash')
|
||||
.action(async (netId: string | number, currency: string, amount: string) => {
|
||||
.action(async (netId: NetIdType, currency: string, amount: string) => {
|
||||
currency = currency.toLowerCase();
|
||||
|
||||
const config = getConfig(netId);
|
||||
@ -518,7 +519,7 @@ export function tornadoProgram() {
|
||||
.argument('<netId>', 'Network Chain ID to connect with (see https://chainlist.org for examples)', parseNumber)
|
||||
.argument('<currency>', 'Currency to deposit on Tornado Cash')
|
||||
.argument('<amount>', 'Amount to deposit on Tornado Cash')
|
||||
.action(async (netId: string | number, currency: string, amount: string, cmdOptions: commonProgramOptions) => {
|
||||
.action(async (netId: NetIdType, currency: string, amount: string, cmdOptions: commonProgramOptions) => {
|
||||
const { options, fetchDataOptions } = await getProgramOptions(cmdOptions);
|
||||
currency = currency.toLowerCase();
|
||||
const { rpc, accountKey } = options;
|
||||
@ -1267,11 +1268,7 @@ export function tornadoProgram() {
|
||||
.argument('[netId]', 'Network Chain ID to connect with (see https://chainlist.org for examples)', parseNumber)
|
||||
.argument('[currency]', 'Currency to sync events')
|
||||
.action(
|
||||
async (
|
||||
netIdOpts: number | string | undefined,
|
||||
currencyOpts: string | undefined,
|
||||
cmdOptions: commonProgramOptions,
|
||||
) => {
|
||||
async (netIdOpts: NetIdType | undefined, currencyOpts: string | undefined, cmdOptions: commonProgramOptions) => {
|
||||
const { options, fetchDataOptions } = await getProgramOptions(cmdOptions);
|
||||
const { rpc } = options;
|
||||
|
||||
@ -1439,7 +1436,7 @@ export function tornadoProgram() {
|
||||
.command('relayers')
|
||||
.description('List all registered relayers from the tornado cash registry.\n\n')
|
||||
.argument('<netId>', 'Network Chain ID to connect with (see https://chainlist.org for examples)', parseNumber)
|
||||
.action(async (netIdOpts: number | string, cmdOptions: commonProgramOptions) => {
|
||||
.action(async (netIdOpts: NetIdType, cmdOptions: commonProgramOptions) => {
|
||||
const { options, fetchDataOptions } = await getProgramOptions(cmdOptions);
|
||||
|
||||
const allRelayers = await getProgramRelayer({
|
||||
@ -1507,7 +1504,7 @@ export function tornadoProgram() {
|
||||
'Requires a valid signable wallet (mnemonic or a private key) to work (Since they would encrypt or encrypted)',
|
||||
)
|
||||
.argument('<netId>', 'Network Chain ID to connect with (see https://chainlist.org for examples)', parseNumber)
|
||||
.action(async (netId: string | number, cmdOptions: commonProgramOptions) => {
|
||||
.action(async (netId: NetIdType, cmdOptions: commonProgramOptions) => {
|
||||
const { options, fetchDataOptions } = await getProgramOptions(cmdOptions);
|
||||
const { rpc } = options;
|
||||
|
||||
@ -1624,7 +1621,7 @@ export function tornadoProgram() {
|
||||
'Account key generated from UI or the createAccount to store encrypted notes on-chain',
|
||||
parseRecoveryKey,
|
||||
)
|
||||
.action(async (netId: string | number, accountKey: string | undefined, cmdOptions: commonProgramOptions) => {
|
||||
.action(async (netId: NetIdType, accountKey: string | undefined, cmdOptions: commonProgramOptions) => {
|
||||
const { options, fetchDataOptions } = await getProgramOptions(cmdOptions);
|
||||
const { rpc } = options;
|
||||
if (!accountKey) {
|
||||
@ -1701,7 +1698,7 @@ export function tornadoProgram() {
|
||||
.argument('[token]', 'ERC20 Token Contract to check Token Balance', parseAddress)
|
||||
.action(
|
||||
async (
|
||||
netId: string | number,
|
||||
netId: NetIdType,
|
||||
to: string,
|
||||
amountArgs: number | undefined,
|
||||
tokenArgs: string | undefined,
|
||||
@ -1838,7 +1835,7 @@ export function tornadoProgram() {
|
||||
.argument('[token]', 'ERC20 Token Contract to check Token Balance', parseAddress)
|
||||
.action(
|
||||
async (
|
||||
netId: string | number,
|
||||
netId: NetIdType,
|
||||
addressArgs: string | undefined,
|
||||
tokenArgs: string | undefined,
|
||||
cmdOptions: commonProgramOptions,
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { bnToBytes, bytesToBN, leBuff2Int, leInt2Buff, rBigInt, toFixedHex } from './utils';
|
||||
import { buffPedersenHash } from './pedersen';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
|
||||
export type DepositType = {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: string | number;
|
||||
netId: NetIdType;
|
||||
};
|
||||
|
||||
export type createDepositParams = {
|
||||
@ -61,7 +62,7 @@ export async function createDeposit({ nullifier, secret }: createDepositParams):
|
||||
export interface DepositConstructor {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
nullifier: bigint;
|
||||
secret: bigint;
|
||||
note: string;
|
||||
@ -74,7 +75,7 @@ export interface DepositConstructor {
|
||||
export class Deposit {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
|
||||
nullifier: bigint;
|
||||
secret: bigint;
|
||||
@ -148,7 +149,7 @@ export class Deposit {
|
||||
const newDeposit = new Deposit({
|
||||
currency: currency.toLowerCase(),
|
||||
amount: amount,
|
||||
netId: Number(netId),
|
||||
netId,
|
||||
note: `tornado-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.noteHex}`,
|
||||
noteHex: depositObject.noteHex,
|
||||
invoice: `tornadoInvoice-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.commitmentHex}`,
|
||||
@ -182,14 +183,14 @@ export class Deposit {
|
||||
const invoice = `tornadoInvoice-${currency}-${amount}-${netId}-${depositObject.commitmentHex}`;
|
||||
|
||||
const newDeposit = new Deposit({
|
||||
currency: currency,
|
||||
amount: amount,
|
||||
netId: netId,
|
||||
currency,
|
||||
amount,
|
||||
netId,
|
||||
note: noteString,
|
||||
noteHex: depositObject.noteHex,
|
||||
invoice: invoice,
|
||||
nullifier: nullifier,
|
||||
secret: secret,
|
||||
invoice,
|
||||
nullifier,
|
||||
secret,
|
||||
commitmentHex: depositObject.commitmentHex,
|
||||
nullifierHex: depositObject.nullifierHex,
|
||||
});
|
||||
@ -205,7 +206,7 @@ export type parsedInvoiceExec = DepositType & {
|
||||
export class Invoice {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
commitment: string;
|
||||
invoice: string;
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { Echoer } from '@tornado/contracts';
|
||||
import { Wallet, computeAddress, getAddress } from 'ethers';
|
||||
import { crypto, base64ToBytes, bytesToBase64, bytesToHex, hexToBytes, toFixedHex, concatBytes } from './utils';
|
||||
import { EchoEvents, EncryptedNotesEvents } from './events';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
|
||||
export interface NoteToEncrypt {
|
||||
address: string;
|
||||
@ -43,7 +44,7 @@ export function unpackEncryptedMessage(encryptedMessage: string) {
|
||||
}
|
||||
|
||||
export interface NoteAccountConstructor {
|
||||
netId: string | number;
|
||||
netId: NetIdType;
|
||||
blockNumber?: number;
|
||||
// hex
|
||||
recoveryKey?: string;
|
||||
@ -51,7 +52,7 @@ export interface NoteAccountConstructor {
|
||||
}
|
||||
|
||||
export class NoteAccount {
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
blockNumber?: number;
|
||||
// Dedicated 32 bytes private key only used for note encryption, backed up to an Echoer and local for future derivation
|
||||
// Note that unlike the private key it shouldn't have the 0x prefix
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
BatchBlockOnProgress,
|
||||
} from '../batch';
|
||||
import { fetchDataOptions } from '../providers';
|
||||
import type { NetIdType } from '../networkConfig';
|
||||
import type {
|
||||
BaseEvents,
|
||||
MinimalEvents,
|
||||
@ -36,7 +37,7 @@ export const DEPOSIT = 'deposit';
|
||||
export const WITHDRAWAL = 'withdrawal';
|
||||
|
||||
export type BaseEventsServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -66,7 +67,7 @@ export type BaseGraphParams = {
|
||||
};
|
||||
|
||||
export class BaseEventsService<EventType extends MinimalEvents> {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -324,7 +325,7 @@ export class BaseEventsService<EventType extends MinimalEvents> {
|
||||
}
|
||||
|
||||
export type BaseDepositsServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -464,7 +465,7 @@ export class BaseDepositsService extends BaseEventsService<DepositsEvents | With
|
||||
}
|
||||
|
||||
export type BaseEchoServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -534,7 +535,7 @@ export class BaseEchoService extends BaseEventsService<EchoEvents> {
|
||||
}
|
||||
|
||||
export type BaseEncryptedNotesServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -591,7 +592,7 @@ export class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesE
|
||||
}
|
||||
|
||||
export type BaseGovernanceServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
@ -733,7 +734,7 @@ export class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents
|
||||
}
|
||||
|
||||
export type BaseRegistryServiceConstructor = {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
provider: Provider;
|
||||
graphApi?: string;
|
||||
subgraphName?: string;
|
||||
|
@ -5,6 +5,7 @@ import { isNode, toFixedHex } from './utils';
|
||||
import { mimc } from './mimc';
|
||||
import type { DepositType } from './deposits';
|
||||
import type { DepositsEvents } from './events';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
|
||||
export type MerkleTreeConstructor = DepositType & {
|
||||
Tornado: Tornado;
|
||||
@ -17,7 +18,7 @@ export type MerkleTreeConstructor = DepositType & {
|
||||
export class MerkleTreeService {
|
||||
currency: string;
|
||||
amount: string;
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
Tornado: Tornado;
|
||||
commitmentHex?: string;
|
||||
instanceName: string;
|
||||
|
@ -1,3 +1,19 @@
|
||||
/**
|
||||
* Type of default supported networks
|
||||
*/
|
||||
export enum NetId {
|
||||
MAINNET = 1,
|
||||
BSC = 56,
|
||||
POLYGON = 137,
|
||||
OPTIMISM = 10,
|
||||
ARBITRUM = 42161,
|
||||
GNOSIS = 100,
|
||||
AVALANCHE = 43114,
|
||||
SEPOLIA = 11155111,
|
||||
}
|
||||
|
||||
export type NetIdType = NetId | number;
|
||||
|
||||
export interface RpcUrl {
|
||||
name: string;
|
||||
url: string;
|
||||
@ -85,7 +101,7 @@ export type Config = {
|
||||
};
|
||||
|
||||
export type networkConfig = {
|
||||
[key in string]: Config;
|
||||
[key in NetIdType]: Config;
|
||||
};
|
||||
|
||||
const theGraph = {
|
||||
@ -98,7 +114,7 @@ const tornado = {
|
||||
};
|
||||
|
||||
export const defaultConfig: networkConfig = {
|
||||
netId1: {
|
||||
[NetId.MAINNET]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 80,
|
||||
@ -246,7 +262,7 @@ export const defaultConfig: networkConfig = {
|
||||
MINING_BLOCK_TIME: 15,
|
||||
},
|
||||
},
|
||||
netId56: {
|
||||
[NetId.BSC]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 5,
|
||||
@ -311,7 +327,7 @@ export const defaultConfig: networkConfig = {
|
||||
ENCRYPTED_NOTES_BLOCK: 8159269,
|
||||
},
|
||||
},
|
||||
netId137: {
|
||||
[NetId.POLYGON]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 100,
|
||||
@ -369,7 +385,7 @@ export const defaultConfig: networkConfig = {
|
||||
ENCRYPTED_NOTES_BLOCK: 16257996,
|
||||
},
|
||||
},
|
||||
netId10: {
|
||||
[NetId.OPTIMISM]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 0.001,
|
||||
@ -435,7 +451,7 @@ export const defaultConfig: networkConfig = {
|
||||
ENCRYPTED_NOTES_BLOCK: 2243694,
|
||||
},
|
||||
},
|
||||
netId42161: {
|
||||
[NetId.ARBITRUM]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 4,
|
||||
@ -500,7 +516,7 @@ export const defaultConfig: networkConfig = {
|
||||
ENCRYPTED_NOTES_BLOCK: 3430605,
|
||||
},
|
||||
},
|
||||
netId100: {
|
||||
[NetId.GNOSIS]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 6,
|
||||
@ -565,7 +581,7 @@ export const defaultConfig: networkConfig = {
|
||||
ENCRYPTED_NOTES_BLOCK: 17754564,
|
||||
},
|
||||
},
|
||||
netId43114: {
|
||||
[NetId.AVALANCHE]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 225,
|
||||
@ -620,7 +636,7 @@ export const defaultConfig: networkConfig = {
|
||||
ENCRYPTED_NOTES_BLOCK: 4429813,
|
||||
},
|
||||
},
|
||||
netId11155111: {
|
||||
[NetId.SEPOLIA]: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: {
|
||||
instant: 2,
|
||||
@ -698,7 +714,7 @@ export const defaultConfig: networkConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
export const enabledChains = ['1', '10', '56', '100', '137', '42161', '43114', '11155111'];
|
||||
export const enabledChains = Object.values(NetId) as NetIdType[];
|
||||
|
||||
/**
|
||||
* Custom config object to extend default config
|
||||
@ -711,12 +727,12 @@ export let customConfig: networkConfig = {};
|
||||
/**
|
||||
* Add or override existing network config object
|
||||
*
|
||||
* Could be also called on the UI hook so that the UI could allow people to use privacy pools that it hasn't deployed
|
||||
* Could be also called on the UI hook so that the UI could allow people to use custom privacy pools
|
||||
*/
|
||||
export function addNetwork(newConfig: networkConfig) {
|
||||
enabledChains.push(
|
||||
...Object.keys(newConfig)
|
||||
.map((netId) => netId.replace('netId', ''))
|
||||
.map((netId) => Number(netId))
|
||||
.filter((netId) => !enabledChains.includes(netId)),
|
||||
);
|
||||
|
||||
@ -734,25 +750,25 @@ export function getNetworkConfig(): networkConfig {
|
||||
};
|
||||
|
||||
return enabledChains.reduce((acc, curr) => {
|
||||
acc[`netId${curr}`] = allConfig[`netId${curr}`];
|
||||
acc[curr] = allConfig[curr];
|
||||
return acc;
|
||||
}, {} as networkConfig);
|
||||
}
|
||||
|
||||
export function getConfig(netId: string | number) {
|
||||
export function getConfig(netId: NetIdType) {
|
||||
const allConfig = getNetworkConfig();
|
||||
|
||||
const chainConfig = allConfig[`netId${netId}`];
|
||||
const chainConfig = allConfig[netId];
|
||||
|
||||
if (!chainConfig) {
|
||||
const errMsg = `No config found for ${netId}!`;
|
||||
const errMsg = `No config found for network ${netId}!`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
return chainConfig;
|
||||
}
|
||||
|
||||
export function getInstanceByAddress({ netId, address }: { netId: number | string; address: string }) {
|
||||
export function getInstanceByAddress({ netId, address }: { netId: NetIdType; address: string }) {
|
||||
const { tokens } = getConfig(netId);
|
||||
|
||||
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
||||
@ -770,5 +786,5 @@ export function getInstanceByAddress({ netId, address }: { netId: number | strin
|
||||
export function getSubdomains() {
|
||||
const allConfig = getNetworkConfig();
|
||||
|
||||
return enabledChains.map((chain) => allConfig[`netId${chain}`].ensSubdomainKey);
|
||||
return enabledChains.map((chain) => allConfig[chain].ensSubdomainKey);
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import {
|
||||
Network,
|
||||
parseUnits,
|
||||
FetchUrlFeeDataNetworkPlugin,
|
||||
BigNumberish,
|
||||
FeeData,
|
||||
EnsPlugin,
|
||||
GasCostPlugin,
|
||||
@ -30,7 +29,7 @@ import {
|
||||
import type { RequestInfo, RequestInit, Response, HeadersInit } from 'node-fetch';
|
||||
import { GasPriceOracle, GasPriceOracle__factory, Multicall, Multicall__factory } from '../typechain';
|
||||
import { isNode, sleep } from './utils';
|
||||
import type { Config } from './networkConfig';
|
||||
import type { Config, NetIdType } from './networkConfig';
|
||||
import { multicall } from './multicall';
|
||||
|
||||
declare global {
|
||||
@ -366,7 +365,7 @@ export async function getProvider(rpcUrl: string, fetchOptions?: getProviderOpti
|
||||
}
|
||||
|
||||
export function getProviderWithNetId(
|
||||
netId: BigNumberish,
|
||||
netId: NetIdType,
|
||||
rpcUrl: string,
|
||||
config: Config,
|
||||
fetchOptions?: getProviderOptions,
|
||||
@ -604,7 +603,7 @@ export type handleWalletFunc = (...args: any[]) => void;
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
|
||||
export type TornadoBrowserProviderOptions = TornadoWalletOptions & {
|
||||
webChainId?: BigNumberish;
|
||||
webChainId?: NetIdType;
|
||||
connectWallet?: connectWalletFunc;
|
||||
handleNetworkChanges?: handleWalletFunc;
|
||||
handleAccountChanges?: handleWalletFunc;
|
||||
|
@ -2,7 +2,7 @@ import { getAddress, namehash, parseEther } from 'ethers';
|
||||
import type { Aggregator } from '@tornado/contracts';
|
||||
import type { RelayerStructOutput } from '@tornado/contracts/dist/contracts/Governance/Aggregator/Aggregator';
|
||||
import { sleep } from './utils';
|
||||
import type { Config } from './networkConfig';
|
||||
import { NetId, NetIdType, Config } from './networkConfig';
|
||||
import { fetchData, fetchDataOptions } from './providers';
|
||||
import { ajv, jobsSchema, getStatusSchema } from './schemas';
|
||||
import type { snarkProofs } from './websnark';
|
||||
@ -15,7 +15,7 @@ export interface RelayerParams {
|
||||
}
|
||||
|
||||
export interface Relayer {
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
url: string;
|
||||
hostname: string;
|
||||
rewardAccount: string;
|
||||
@ -57,7 +57,7 @@ export interface RelayerStatus {
|
||||
fast: number;
|
||||
additionalProperties?: number;
|
||||
};
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
ethPrices?: {
|
||||
[key in string]: string;
|
||||
};
|
||||
@ -107,14 +107,14 @@ export function parseSemanticVersion(version: string) {
|
||||
return groups as unknown as semanticVersion;
|
||||
}
|
||||
|
||||
export function isRelayerUpdated(relayerVersion: string, netId: number | string) {
|
||||
export function isRelayerUpdated(relayerVersion: string, netId: NetIdType) {
|
||||
const { major, patch, prerelease } = parseSemanticVersion(relayerVersion);
|
||||
// Save backwards compatibility with V4 relayers for Ethereum Mainnet
|
||||
const requiredMajor = netId === 1 ? '4' : '5';
|
||||
const requiredMajor = netId === NetId.MAINNET ? '4' : '5';
|
||||
const isUpdatedMajor = major === requiredMajor;
|
||||
|
||||
if (prerelease) return false;
|
||||
return isUpdatedMajor && (Number(patch) >= 5 || Number(netId) !== 1); // Patch checking - also backwards compatibility for Mainnet
|
||||
return isUpdatedMajor && (Number(patch) >= 5 || netId !== NetId.MAINNET); // Patch checking - also backwards compatibility for Mainnet
|
||||
}
|
||||
|
||||
export function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo, minFee = 0.33, maxFee = 0.53) {
|
||||
@ -159,10 +159,10 @@ export function getSupportedInstances(instanceList: RelayerInstanceList) {
|
||||
return rawList.map((l) => getAddress(l));
|
||||
}
|
||||
|
||||
export function pickWeightedRandomRelayer(relayers: RelayerInfo[], netId: string | number) {
|
||||
export function pickWeightedRandomRelayer(relayers: RelayerInfo[], netId: NetIdType) {
|
||||
let minFee: number, maxFee: number;
|
||||
|
||||
if (Number(netId) !== 1) {
|
||||
if (netId !== NetId.MAINNET) {
|
||||
minFee = 0.01;
|
||||
maxFee = 0.3;
|
||||
}
|
||||
@ -179,7 +179,7 @@ export function pickWeightedRandomRelayer(relayers: RelayerInfo[], netId: string
|
||||
}
|
||||
|
||||
export interface RelayerClientConstructor {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
config: Config;
|
||||
Aggregator: Aggregator;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
@ -190,14 +190,14 @@ export type RelayerClientWithdraw = snarkProofs & {
|
||||
};
|
||||
|
||||
export class RelayerClient {
|
||||
netId: number;
|
||||
netId: NetIdType;
|
||||
config: Config;
|
||||
Aggregator: Aggregator;
|
||||
selectedRelayer?: Relayer;
|
||||
fetchDataOptions?: fetchDataOptions;
|
||||
|
||||
constructor({ netId, config, Aggregator, fetchDataOptions }: RelayerClientConstructor) {
|
||||
this.netId = Number(netId);
|
||||
this.netId = netId;
|
||||
this.config = config;
|
||||
this.Aggregator = Aggregator;
|
||||
this.fetchDataOptions = fetchDataOptions;
|
||||
@ -240,7 +240,7 @@ export class RelayerClient {
|
||||
throw new Error('This relayer serves a different network');
|
||||
}
|
||||
|
||||
if (relayerAddress && this.netId === 1 && status.rewardAccount !== relayerAddress) {
|
||||
if (relayerAddress && this.netId === NetId.MAINNET && status.rewardAccount !== relayerAddress) {
|
||||
throw new Error('The Relayer reward address must match registered address');
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { Config } from '../networkConfig';
|
||||
import { Config, NetId, NetIdType } from '../networkConfig';
|
||||
|
||||
export type statusInstanceType = {
|
||||
type: string;
|
||||
@ -110,7 +110,7 @@ const statusSchema: statusSchema = {
|
||||
required: ['rewardAccount', 'instances', 'netId', 'tornadoServiceFee', 'version', 'health'],
|
||||
};
|
||||
|
||||
export function getStatusSchema(netId: number | string, config: Config) {
|
||||
export function getStatusSchema(netId: NetIdType, config: Config) {
|
||||
const { tokens, optionalTokens = [], nativeCurrency } = config;
|
||||
|
||||
// deep copy schema
|
||||
@ -162,7 +162,7 @@ export function getStatusSchema(netId: number | string, config: Config) {
|
||||
|
||||
schema.properties.instances = instances;
|
||||
|
||||
if (Number(netId) === 1) {
|
||||
if (netId === NetId.MAINNET) {
|
||||
const _tokens = Object.keys(tokens).filter((t) => t !== nativeCurrency);
|
||||
|
||||
const ethPrices: statusEthPricesType = {
|
||||
|
@ -7,9 +7,10 @@ import { MerkleTree } from '@tornado/fixed-merkle-tree';
|
||||
import BloomFilter from 'bloomfilter.js';
|
||||
import { saveUserFile } from './data';
|
||||
import { DepositsEvents } from './events';
|
||||
import type { NetIdType } from './networkConfig';
|
||||
|
||||
export interface TreeCacheConstructor {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
amount: string;
|
||||
currency: string;
|
||||
userDirectory: string;
|
||||
@ -28,7 +29,7 @@ export interface treeMetadata {
|
||||
}
|
||||
|
||||
export class TreeCache {
|
||||
netId: number | string;
|
||||
netId: NetIdType;
|
||||
amount: string;
|
||||
currency: string;
|
||||
userDirectory: string;
|
||||
|
2
static/merkleTreeWorker.js
vendored
2
static/merkleTreeWorker.js
vendored
@ -19824,5 +19824,5 @@ if (isNode && threads) {
|
||||
postMessage(merkleTree.toString());
|
||||
}));
|
||||
} else {
|
||||
throw new Error("This browser / environment doesn't support workers!");
|
||||
throw new Error("This browser / environment does not support workers!");
|
||||
}
|
||||
|
29627
static/merkleTreeWorker.umd.js
vendored
29627
static/merkleTreeWorker.umd.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user