built files

This commit is contained in:
Tornado Contrib 2024-10-16 14:19:49 +00:00
parent 666b0eba66
commit f3a8438187
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
25 changed files with 9718 additions and 9997 deletions

4
dist/batch.d.ts vendored

@ -62,11 +62,11 @@ export type BatchEventOnProgress = ({ percentage, type, fromBlock, toBlock, coun
toBlock?: number;
count?: number;
}) => void;
export type EventInput = {
export interface EventInput {
fromBlock: number;
toBlock: number;
type: ContractEventName;
};
}
/**
* Fetch events from web3 provider on bulk
*/

32
dist/deposits.d.ts vendored

@ -1,36 +1,28 @@
import type { NetIdType } from './networkConfig';
export type DepositType = {
export interface DepositType {
currency: string;
amount: string;
netId: NetIdType;
};
export type createDepositParams = {
}
export interface createDepositParams {
nullifier: bigint;
secret: bigint;
};
export type createDepositObject = {
}
export interface createDepositObject {
preimage: Uint8Array;
noteHex: string;
commitment: bigint;
commitmentHex: string;
nullifierHash: bigint;
nullifierHex: string;
};
export type createNoteParams = DepositType & {
}
export interface createNoteParams extends DepositType {
nullifier?: bigint;
secret?: bigint;
};
export type parsedNoteExec = DepositType & {
}
export interface parsedNoteExec extends DepositType {
note: string;
};
export type depositTx = {
from: string;
transactionHash: string;
};
export type withdrawalTx = {
to: string;
transactionHash: string;
};
}
export declare function createDeposit({ nullifier, secret }: createDepositParams): Promise<createDepositObject>;
export interface DepositConstructor {
currency: string;
@ -60,9 +52,9 @@ export declare class Deposit {
static createNote({ currency, amount, netId, nullifier, secret }: createNoteParams): Promise<Deposit>;
static parseNote(noteString: string): Promise<Deposit>;
}
export type parsedInvoiceExec = DepositType & {
export interface parsedInvoiceExec extends DepositType {
commitment: string;
};
}
export declare class Invoice {
currency: string;
amount: string;

75
dist/events/base.d.ts vendored

@ -8,29 +8,29 @@ import type { TovarishClient } from '../tovarishClient';
import type { BaseEvents, CachedEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, AllGovernanceEvents, RegistersEvents, EchoEvents } from './types';
export declare const DEPOSIT = "deposit";
export declare const WITHDRAWAL = "withdrawal";
export type BaseEventsServiceConstructor = {
export interface BaseEventsServiceConstructor {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
contract: BaseContract;
type?: string;
type: string;
deployedBlock?: number;
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
}
export type BatchGraphOnProgress = ({ type, fromBlock, toBlock, count, }: {
type?: ContractEventName;
fromBlock?: number;
toBlock?: number;
count?: number;
}) => void;
export type BaseGraphParams = {
export interface BaseGraphParams {
graphApi: string;
subgraphName: string;
fetchDataOptions?: fetchDataOptions;
onProgress?: BatchGraphOnProgress;
};
}
export declare class BaseEventsService<EventType extends MinimalEvents> {
netId: NetIdType;
provider: Provider;
@ -89,29 +89,20 @@ export declare class BaseEventsService<EventType extends MinimalEvents> {
lastBlock: number;
}>;
}
export type BaseTornadoServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
export interface BaseTornadoServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract'> {
Tornado: Tornado;
type: string;
amount: string;
currency: string;
deployedBlock?: number;
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
export type DepositsGraphParams = BaseGraphParams & {
}
export interface DepositsGraphParams extends BaseGraphParams {
amount: string;
currency: string;
};
}
export declare class BaseTornadoService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> {
amount: string;
currency: string;
batchTransactionService: BatchTransactionService;
batchBlockService: BatchBlockService;
tovarishClient?: TovarishClient;
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, tovarishClient, }: BaseTornadoServiceConstructor);
getInstanceName(): string;
getGraphMethod(): string;
@ -124,59 +115,35 @@ export declare class BaseTornadoService extends BaseEventsService<DepositsEvents
fromBlock: number;
}): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>;
}
export type BaseEchoServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
export interface BaseEchoServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
Echoer: Echoer;
deployedBlock?: number;
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
}
export declare class BaseEchoService extends BaseEventsService<EchoEvents> {
constructor({ netId, provider, graphApi, subgraphName, Echoer, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEchoServiceConstructor);
getInstanceName(): string;
getType(): string;
getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<EchoEvents[]>;
getEventsFromGraph({ fromBlock }: {
fromBlock: number;
}): Promise<BaseEvents<EchoEvents>>;
}
export type BaseEncryptedNotesServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
export interface BaseEncryptedNotesServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
Router: TornadoRouter | TornadoProxyLight;
deployedBlock?: number;
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
}
export declare class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesEvents> {
constructor({ netId, provider, graphApi, subgraphName, Router, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEncryptedNotesServiceConstructor);
getInstanceName(): string;
getType(): string;
getTovarishType(): string;
getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<EncryptedNotesEvents[]>;
}
export type BaseGovernanceServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
export interface BaseGovernanceServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
Governance: Governance;
deployedBlock?: number;
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
}
export declare class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents> {
batchTransactionService: BatchTransactionService;
constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, tovarishClient, }: BaseGovernanceServiceConstructor);
getInstanceName(): string;
getType(): string;
getTovarishType(): string;
getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<AllGovernanceEvents[]>;
@ -204,25 +171,17 @@ export interface CachedRelayers {
relayers: CachedRelayerInfo[];
fromCache?: boolean;
}
export type BaseRegistryServiceConstructor = {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
export interface BaseRegistryServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
RelayerRegistry: RelayerRegistry;
Aggregator: Aggregator;
relayerEnsSubdomains: SubdomainMap;
deployedBlock?: number;
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
}
export declare class BaseRegistryService extends BaseEventsService<RegistersEvents> {
Aggregator: Aggregator;
relayerEnsSubdomains: SubdomainMap;
updateInterval: number;
constructor({ netId, provider, graphApi, subgraphName, RelayerRegistry, Aggregator, relayerEnsSubdomains, deployedBlock, fetchDataOptions, tovarishClient, }: BaseRegistryServiceConstructor);
getInstanceName(): string;
getType(): string;
getTovarishType(): string;
getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<{

@ -15,51 +15,51 @@ export interface MinimalEvents {
logIndex: number;
transactionHash: string;
}
export type GovernanceEvents = MinimalEvents & {
export interface GovernanceEvents extends MinimalEvents {
event: string;
};
export type GovernanceProposalCreatedEvents = GovernanceEvents & {
}
export interface GovernanceProposalCreatedEvents extends GovernanceEvents {
id: number;
proposer: string;
target: string;
startTime: number;
endTime: number;
description: string;
};
export type GovernanceVotedEvents = GovernanceEvents & {
}
export interface GovernanceVotedEvents extends GovernanceEvents {
proposalId: number;
voter: string;
support: boolean;
votes: string;
from: string;
input: string;
};
export type GovernanceDelegatedEvents = GovernanceEvents & {
}
export interface GovernanceDelegatedEvents extends GovernanceEvents {
account: string;
delegateTo: string;
};
export type GovernanceUndelegatedEvents = GovernanceEvents & {
}
export interface GovernanceUndelegatedEvents extends GovernanceEvents {
account: string;
delegateFrom: string;
};
}
export type AllGovernanceEvents = GovernanceProposalCreatedEvents | GovernanceVotedEvents | GovernanceDelegatedEvents | GovernanceUndelegatedEvents;
export type RegistersEvents = MinimalEvents & RelayerParams;
export type DepositsEvents = MinimalEvents & {
export interface DepositsEvents extends MinimalEvents {
commitment: string;
leafIndex: number;
timestamp: number;
from: string;
};
export type WithdrawalsEvents = MinimalEvents & {
}
export interface WithdrawalsEvents extends MinimalEvents {
nullifierHash: string;
to: string;
fee: string;
timestamp: number;
};
export type EchoEvents = MinimalEvents & {
}
export interface EchoEvents extends MinimalEvents {
address: string;
encryptedAccount: string;
};
export type EncryptedNotesEvents = MinimalEvents & {
}
export interface EncryptedNotesEvents extends MinimalEvents {
encryptedNote: string;
};
}

13
dist/gaszip.d.ts vendored Normal file

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

@ -1,7 +1,7 @@
import { fetchDataOptions } from '../providers';
import type { BaseGraphEvents, RegistersEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, BatchGraphOnProgress, EchoEvents, AllGovernanceEvents } from '../events';
export * from './queries';
export type queryGraphParams = {
export interface queryGraphParams {
graphApi: string;
subgraphName: string;
query: string;
@ -9,7 +9,7 @@ export type queryGraphParams = {
[key: string]: string | number;
};
fetchDataOptions?: fetchDataOptions;
};
}
export declare function queryGraph<T>({ graphApi, subgraphName, query, variables, fetchDataOptions, }: queryGraphParams): Promise<T>;
export interface GraphStatistic {
deposits: {

1
dist/index.d.ts vendored

@ -6,6 +6,7 @@ export * from './batch';
export * from './deposits';
export * from './encryptedNotes';
export * from './fees';
export * from './gaszip';
export * from './idb';
export * from './merkleTree';
export * from './mimc';

1953
dist/index.js vendored

File diff suppressed because it is too large Load Diff

1952
dist/index.mjs vendored

File diff suppressed because it is too large Load Diff

@ -3,13 +3,13 @@ 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 & {
export interface MerkleTreeConstructor extends DepositType {
Tornado: Tornado;
commitmentHex?: string;
merkleTreeHeight?: number;
emptyElement?: string;
merkleWorkerPath?: string;
};
}
export declare class MerkleTreeService {
currency: string;
amount: string;

@ -1805,47 +1805,23 @@ class MimcSponge {
}
}
var __async$1 = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
class Mimc {
sponge;
hash;
mimcPromise;
constructor() {
this.mimcPromise = this.initMimc();
}
initMimc() {
return __async$1(this, null, function* () {
this.sponge = yield buildMimcSponge();
this.hash = (left, right) => {
var _a, _b;
return (_b = this.sponge) == null ? void 0 : _b.F.toString((_a = this.sponge) == null ? void 0 : _a.multiHash([BigInt(left), BigInt(right)]));
};
});
async initMimc() {
this.sponge = await buildMimcSponge();
this.hash = (left, right) => this.sponge?.F.toString(this.sponge?.multiHash([BigInt(left), BigInt(right)]));
}
getHash() {
return __async$1(this, null, function* () {
yield this.mimcPromise;
async getHash() {
await this.mimcPromise;
return {
sponge: this.sponge,
hash: this.hash
};
});
}
}
const mimc = new Mimc();
@ -1855,29 +1831,8 @@ BigInt.prototype.toJSON = function() {
};
const isNode = !process.browser && typeof globalThis.window === "undefined";
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
function nodePostWork() {
return __async(this, null, function* () {
const { hash: hashFunction } = yield mimc.getHash();
async function nodePostWork() {
const { hash: hashFunction } = await mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = workerThreads.workerData;
if (edge) {
const merkleTree2 = new libExports.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -1892,19 +1847,18 @@ function nodePostWork() {
hashFunction
});
workerThreads.parentPort.postMessage(merkleTree.toString());
});
}
if (isNode && workerThreads) {
nodePostWork();
} else if (!isNode && typeof addEventListener === "function" && typeof postMessage === "function") {
addEventListener("message", (e) => __async(undefined, null, function* () {
addEventListener("message", async (e) => {
let data;
if (e.data) {
data = e.data;
} else {
data = e;
}
const { hash: hashFunction } = yield mimc.getHash();
const { hash: hashFunction } = await mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = data;
if (edge) {
const merkleTree2 = new libExports.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -1919,7 +1873,7 @@ if (isNode && workerThreads) {
hashFunction
});
postMessage(merkleTree.toString());
}));
});
} else {
throw new Error("This browser / environment does not support workers!");
}

@ -101976,48 +101976,24 @@ const poseidonContract=(/* unused pure expression or super */ null && (_poseidon
;// ./src/mimc.ts
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
class Mimc {
sponge;
hash;
mimcPromise;
constructor() {
this.mimcPromise = this.initMimc();
}
initMimc() {
return __async(this, null, function* () {
this.sponge = yield mimcsponge_buildMimcSponge();
this.hash = (left, right) => {
var _a, _b;
return (_b = this.sponge) == null ? void 0 : _b.F.toString((_a = this.sponge) == null ? void 0 : _a.multiHash([BigInt(left), BigInt(right)]));
};
});
async initMimc() {
this.sponge = await mimcsponge_buildMimcSponge();
this.hash = (left, right) => this.sponge?.F.toString(this.sponge?.multiHash([BigInt(left), BigInt(right)]));
}
getHash() {
return __async(this, null, function* () {
yield this.mimcPromise;
async getHash() {
await this.mimcPromise;
return {
sponge: this.sponge,
hash: this.hash
};
});
}
}
const mimc = new Mimc();
@ -102028,26 +102004,6 @@ var crypto_browserify = __webpack_require__(1565);
var bn = __webpack_require__(9404);
;// ./src/utils.ts
var utils_async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
BigInt.prototype.toJSON = function() {
@ -102066,7 +102022,7 @@ function validateUrl(url, protocols) {
return protocols.map((p) => p.toLowerCase()).includes(parsedUrl.protocol);
}
return true;
} catch (e) {
} catch {
return false;
}
}
@ -102138,41 +102094,18 @@ function substring(str, length = 10) {
}
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
}
function digest(bytes, algo = "SHA-384") {
return utils_async(this, null, function* () {
return new Uint8Array(yield utils_crypto.subtle.digest(algo, bytes));
});
async function digest(bytes, algo = "SHA-384") {
return new Uint8Array(await utils_crypto.subtle.digest(algo, bytes));
}
;// ./src/merkleTreeWorker.ts
var merkleTreeWorker_async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
function nodePostWork() {
return merkleTreeWorker_async(this, null, function* () {
const { hash: hashFunction } = yield mimc.getHash();
async function nodePostWork() {
const { hash: hashFunction } = await mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = (worker_threads_ignored_default()).workerData;
if (edge) {
const merkleTree2 = new lib.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -102187,19 +102120,18 @@ function nodePostWork() {
hashFunction
});
worker_threads_ignored_default().parentPort.postMessage(merkleTree.toString());
});
}
if (isNode && (worker_threads_ignored_default())) {
nodePostWork();
} else if (!isNode && typeof addEventListener === "function" && typeof postMessage === "function") {
addEventListener("message", (e) => merkleTreeWorker_async(undefined, null, function* () {
addEventListener("message", async (e) => {
let data;
if (e.data) {
data = e.data;
} else {
data = e;
}
const { hash: hashFunction } = yield mimc.getHash();
const { hash: hashFunction } = await mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = data;
if (edge) {
const merkleTree2 = new lib.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -102214,7 +102146,7 @@ if (isNode && (worker_threads_ignored_default())) {
hashFunction
});
postMessage(merkleTree.toString());
}));
});
} else {
throw new Error("This browser / environment does not support workers!");
}

File diff suppressed because one or more lines are too long

@ -16,19 +16,19 @@ export interface RpcUrl {
name: string;
url: string;
}
export type RpcUrls = {
[key in string]: RpcUrl;
};
export interface RpcUrls {
[key: string]: RpcUrl;
}
export interface SubgraphUrl {
name: string;
url: string;
}
export type SubgraphUrls = {
[key in string]: SubgraphUrl;
};
export type TornadoInstance = {
export interface SubgraphUrls {
[key: string]: SubgraphUrl;
}
export interface TornadoInstance {
instanceAddress: {
[key in string]: string;
[key: string]: string;
};
optionalInstances?: string[];
tokenAddress?: string;
@ -36,11 +36,11 @@ export type TornadoInstance = {
symbol: string;
decimals: number;
gasLimit?: number;
};
export type TokenInstances = {
[key in string]: TornadoInstance;
};
export type Config = {
}
export interface TokenInstances {
[key: string]: TornadoInstance;
}
export interface Config {
rpcCallRetryAttempt?: number;
gasPrices: {
instant: number;
@ -57,6 +57,7 @@ export type Config = {
networkName: string;
deployedBlock: number;
rpcUrls: RpcUrls;
stablecoin: string;
multicallContract: string;
routerContract: string;
echoContract: string;
@ -84,13 +85,13 @@ export type Config = {
REGISTRY_BLOCK?: number;
MINING_BLOCK_TIME?: number;
};
};
export type networkConfig = {
[key in NetIdType]: Config;
};
export type SubdomainMap = {
[key in NetIdType]: string;
};
}
export interface networkConfig {
[key: NetIdType]: Config;
}
export interface SubdomainMap {
[key: NetIdType]: string;
}
export declare const defaultConfig: networkConfig;
export declare const enabledChains: NetIdType[];
/**

10
dist/prices.d.ts vendored

@ -1,12 +1,20 @@
import { type Provider } from 'ethers';
import type { OffchainOracle, Multicall } from './typechain';
import { OffchainOracle, Multicall } from './typechain';
import { Call3 } from './multicall';
export declare class TokenPriceOracle {
oracle?: OffchainOracle;
multicall: Multicall;
provider: Provider;
constructor(provider: Provider, multicall: Multicall, oracle?: OffchainOracle);
buildCalls(tokens: {
tokenAddress: string;
decimals: number;
}[]): Call3[];
buildStable(stablecoinAddress: string): Call3[];
fetchPrice(tokenAddress: string, decimals: number): Promise<bigint>;
fetchPrices(tokens: {
tokenAddress: string;
decimals: number;
}[]): Promise<bigint[]>;
fetchEthUSD(stablecoinAddress: string): Promise<number>;
}

8
dist/providers.d.ts vendored

@ -38,12 +38,12 @@ export type getProviderOptions = fetchDataOptions & {
export declare function getProvider(rpcUrl: string, fetchOptions?: getProviderOptions): Promise<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 = {
export interface TornadoWalletOptions {
gasPriceBump?: number;
gasLimitBump?: number;
gasFailover?: boolean;
bumpNonce?: boolean;
};
}
export declare class TornadoWallet extends Wallet {
nonce?: number;
gasPriceBump: number;
@ -74,13 +74,13 @@ export declare class TornadoRpcSigner extends JsonRpcSigner {
}
export type connectWalletFunc = (...args: any[]) => Promise<void>;
export type handleWalletFunc = (...args: any[]) => void;
export type TornadoBrowserProviderOptions = TornadoWalletOptions & {
export interface TornadoBrowserProviderOptions extends TornadoWalletOptions {
netId?: NetIdType;
connectWallet?: connectWalletFunc;
handleNetworkChanges?: handleWalletFunc;
handleAccountChanges?: handleWalletFunc;
handleAccountDisconnect?: handleWalletFunc;
};
}
export declare class TornadoBrowserProvider extends BrowserProvider {
options?: TornadoBrowserProviderOptions;
constructor(ethereum: Eip1193Provider, network?: Networkish, options?: TornadoBrowserProviderOptions);

@ -12,7 +12,7 @@ export interface RelayerParams {
/**
* Info from relayer status
*/
export type RelayerInfo = RelayerParams & {
export interface RelayerInfo extends RelayerParams {
netId: NetIdType;
url: string;
hostname: string;
@ -25,13 +25,13 @@ export type RelayerInfo = RelayerParams & {
};
currentQueue: number;
tornadoServiceFee: number;
};
export type RelayerError = {
}
export interface RelayerError {
hostname: string;
relayerAddress?: string;
errorMessage?: string;
hasError: boolean;
};
}
export interface RelayerStatus {
url: string;
rewardAccount: string;
@ -63,9 +63,9 @@ export interface RelayerStatus {
};
currentQueue: number;
}
export type TornadoWithdrawParams = snarkProofs & {
export interface TornadoWithdrawParams extends snarkProofs {
contract: string;
};
}
export interface RelayerTornadoWithdraw {
id?: string;
error?: string;
@ -111,13 +111,13 @@ 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 type RelayerInstanceList = {
[key in string]: {
export interface RelayerInstanceList {
[key: string]: {
instanceAddress: {
[key in string]: string;
};
[key: string]: string;
};
};
}
export declare function getSupportedInstances(instanceList: RelayerInstanceList): string[];
export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
export interface RelayerClientConstructor {
@ -143,5 +143,5 @@ export declare class RelayerClient {
invalidRelayers: RelayerError[];
}>;
pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
tornadoWithdraw({ contract, proof, args }: TornadoWithdrawParams, callback?: (jobResp: RelayerTornadoJobs) => void): Promise<void>;
tornadoWithdraw({ contract, proof, args }: TornadoWithdrawParams, callback?: (jobResp: RelayerTornadoWithdraw | RelayerTornadoJobs) => void): Promise<void>;
}

@ -1,4 +1,4 @@
export type jobsSchema = {
export interface jobsSchema {
type: string;
properties: {
error: {
@ -36,5 +36,6 @@ export type jobsSchema = {
};
};
required: string[];
};
}
export declare const jobsSchema: jobsSchema;
export declare const jobRequestSchema: jobsSchema;

@ -1,6 +1,6 @@
import { Config, NetIdType } from '../networkConfig';
import { addressSchemaType, bnSchemaType } from '.';
export type statusInstanceType = {
export interface statusInstanceType {
type: string;
properties: {
instanceAddress: {
@ -19,22 +19,22 @@ export type statusInstanceType = {
};
};
required: string[];
};
export type statusInstancesType = {
}
export interface statusInstancesType {
type: string;
properties: {
[key in string]: statusInstanceType;
};
required: string[];
};
export type statusEthPricesType = {
}
export interface statusEthPricesType {
type: string;
properties: {
[key in string]: typeof bnSchemaType;
};
required?: string[];
};
export type statusSchema = {
}
export interface statusSchema {
type: string;
properties: {
rewardAccount: typeof addressSchemaType;
@ -102,5 +102,5 @@ export type statusSchema = {
};
};
required: string[];
};
}
export declare function getStatusSchema(netId: NetIdType, config: Config, tovarish: boolean): statusSchema;

2169
dist/tornado.umd.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

File diff suppressed because one or more lines are too long

@ -62,10 +62,22 @@ export declare class TovarishClient extends RelayerClient {
url?: string;
relayerAddress?: string;
}): Promise<TovarishStatus>;
/**
* Ask status for all enabled chains for tovarish relayer
*/
askAllStatus({ hostname, url, relayerAddress, }: {
hostname?: string;
url?: string;
relayerAddress?: string;
}): Promise<TovarishStatus[]>;
filterRelayer(relayer: CachedRelayerInfo): Promise<TovarishInfo | RelayerError | undefined>;
getValidRelayers(relayers: CachedRelayerInfo[]): Promise<{
validRelayers: TovarishInfo[];
invalidRelayers: RelayerError[];
}>;
getTovarishRelayers(relayers: CachedRelayerInfo[]): Promise<{
validRelayers: TovarishInfo[];
invalidRelayers: RelayerError[];
}>;
getEvents<T extends MinimalEvents>({ type, currency, amount, fromBlock, recent, }: TovarishEventsQuery): Promise<BaseTovarishEvents<T>>;
}

8
dist/websnark.d.ts vendored

@ -1,5 +1,5 @@
import type { Element } from '@tornado/fixed-merkle-tree';
export type snarkInputs = {
export interface snarkInputs {
root: Element;
nullifierHex: string;
recipient: string;
@ -10,7 +10,7 @@ export type snarkInputs = {
secret: bigint;
pathElements: Element[];
pathIndices: Element[];
};
}
export type snarkArgs = [
_root: string,
_nullifierHash: string,
@ -19,9 +19,9 @@ export type snarkArgs = [
_fee: string,
_refund: string
];
export type snarkProofs = {
export interface snarkProofs {
proof: string;
args: snarkArgs;
};
}
export declare function initGroth16(): Promise<void>;
export declare function calculateSnarkProof(input: snarkInputs, circuit: object, provingKey: ArrayBuffer): Promise<snarkProofs>;