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; toBlock?: number;
count?: number; count?: number;
}) => void; }) => void;
export type EventInput = { export interface EventInput {
fromBlock: number; fromBlock: number;
toBlock: number; toBlock: number;
type: ContractEventName; type: ContractEventName;
}; }
/** /**
* Fetch events from web3 provider on bulk * Fetch events from web3 provider on bulk
*/ */

32
dist/deposits.d.ts vendored

@ -1,36 +1,28 @@
import type { NetIdType } from './networkConfig'; import type { NetIdType } from './networkConfig';
export type DepositType = { export interface DepositType {
currency: string; currency: string;
amount: string; amount: string;
netId: NetIdType; netId: NetIdType;
}; }
export type createDepositParams = { export interface createDepositParams {
nullifier: bigint; nullifier: bigint;
secret: bigint; secret: bigint;
}; }
export type createDepositObject = { export interface createDepositObject {
preimage: Uint8Array; preimage: Uint8Array;
noteHex: string; noteHex: string;
commitment: bigint; commitment: bigint;
commitmentHex: string; commitmentHex: string;
nullifierHash: bigint; nullifierHash: bigint;
nullifierHex: string; nullifierHex: string;
}; }
export type createNoteParams = DepositType & { export interface createNoteParams extends DepositType {
nullifier?: bigint; nullifier?: bigint;
secret?: bigint; secret?: bigint;
}; }
export type parsedNoteExec = DepositType & { export interface parsedNoteExec extends DepositType {
note: string; 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 declare function createDeposit({ nullifier, secret }: createDepositParams): Promise<createDepositObject>;
export interface DepositConstructor { export interface DepositConstructor {
currency: string; currency: string;
@ -60,9 +52,9 @@ export declare class Deposit {
static createNote({ currency, amount, netId, nullifier, secret }: createNoteParams): Promise<Deposit>; static createNote({ currency, amount, netId, nullifier, secret }: createNoteParams): Promise<Deposit>;
static parseNote(noteString: string): Promise<Deposit>; static parseNote(noteString: string): Promise<Deposit>;
} }
export type parsedInvoiceExec = DepositType & { export interface parsedInvoiceExec extends DepositType {
commitment: string; commitment: string;
}; }
export declare class Invoice { export declare class Invoice {
currency: string; currency: string;
amount: 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'; import type { BaseEvents, CachedEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, AllGovernanceEvents, RegistersEvents, EchoEvents } from './types';
export declare const DEPOSIT = "deposit"; export declare const DEPOSIT = "deposit";
export declare const WITHDRAWAL = "withdrawal"; export declare const WITHDRAWAL = "withdrawal";
export type BaseEventsServiceConstructor = { export interface BaseEventsServiceConstructor {
netId: NetIdType; netId: NetIdType;
provider: Provider; provider: Provider;
graphApi?: string; graphApi?: string;
subgraphName?: string; subgraphName?: string;
contract: BaseContract; contract: BaseContract;
type?: string; type: string;
deployedBlock?: number; deployedBlock?: number;
fetchDataOptions?: fetchDataOptions; fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient; tovarishClient?: TovarishClient;
}; }
export type BatchGraphOnProgress = ({ type, fromBlock, toBlock, count, }: { export type BatchGraphOnProgress = ({ type, fromBlock, toBlock, count, }: {
type?: ContractEventName; type?: ContractEventName;
fromBlock?: number; fromBlock?: number;
toBlock?: number; toBlock?: number;
count?: number; count?: number;
}) => void; }) => void;
export type BaseGraphParams = { export interface BaseGraphParams {
graphApi: string; graphApi: string;
subgraphName: string; subgraphName: string;
fetchDataOptions?: fetchDataOptions; fetchDataOptions?: fetchDataOptions;
onProgress?: BatchGraphOnProgress; onProgress?: BatchGraphOnProgress;
}; }
export declare class BaseEventsService<EventType extends MinimalEvents> { export declare class BaseEventsService<EventType extends MinimalEvents> {
netId: NetIdType; netId: NetIdType;
provider: Provider; provider: Provider;
@ -89,29 +89,20 @@ export declare class BaseEventsService<EventType extends MinimalEvents> {
lastBlock: number; lastBlock: number;
}>; }>;
} }
export type BaseTornadoServiceConstructor = { export interface BaseTornadoServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract'> {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
Tornado: Tornado; Tornado: Tornado;
type: string;
amount: string; amount: string;
currency: string; currency: string;
deployedBlock?: number; }
fetchDataOptions?: fetchDataOptions; export interface DepositsGraphParams extends BaseGraphParams {
tovarishClient?: TovarishClient;
};
export type DepositsGraphParams = BaseGraphParams & {
amount: string; amount: string;
currency: string; currency: string;
}; }
export declare class BaseTornadoService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> { export declare class BaseTornadoService extends BaseEventsService<DepositsEvents | WithdrawalsEvents> {
amount: string; amount: string;
currency: string; currency: string;
batchTransactionService: BatchTransactionService; batchTransactionService: BatchTransactionService;
batchBlockService: BatchBlockService; batchBlockService: BatchBlockService;
tovarishClient?: TovarishClient;
constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, tovarishClient, }: BaseTornadoServiceConstructor); constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, tovarishClient, }: BaseTornadoServiceConstructor);
getInstanceName(): string; getInstanceName(): string;
getGraphMethod(): string; getGraphMethod(): string;
@ -124,59 +115,35 @@ export declare class BaseTornadoService extends BaseEventsService<DepositsEvents
fromBlock: number; fromBlock: number;
}): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>; }): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>;
} }
export type BaseEchoServiceConstructor = { export interface BaseEchoServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
Echoer: Echoer; Echoer: Echoer;
deployedBlock?: number; }
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
export declare class BaseEchoService extends BaseEventsService<EchoEvents> { export declare class BaseEchoService extends BaseEventsService<EchoEvents> {
constructor({ netId, provider, graphApi, subgraphName, Echoer, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEchoServiceConstructor); constructor({ netId, provider, graphApi, subgraphName, Echoer, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEchoServiceConstructor);
getInstanceName(): string; getInstanceName(): string;
getType(): string;
getGraphMethod(): string; getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<EchoEvents[]>; formatEvents(events: EventLog[]): Promise<EchoEvents[]>;
getEventsFromGraph({ fromBlock }: { getEventsFromGraph({ fromBlock }: {
fromBlock: number; fromBlock: number;
}): Promise<BaseEvents<EchoEvents>>; }): Promise<BaseEvents<EchoEvents>>;
} }
export type BaseEncryptedNotesServiceConstructor = { export interface BaseEncryptedNotesServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
Router: TornadoRouter | TornadoProxyLight; Router: TornadoRouter | TornadoProxyLight;
deployedBlock?: number; }
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
export declare class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesEvents> { export declare class BaseEncryptedNotesService extends BaseEventsService<EncryptedNotesEvents> {
constructor({ netId, provider, graphApi, subgraphName, Router, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEncryptedNotesServiceConstructor); constructor({ netId, provider, graphApi, subgraphName, Router, deployedBlock, fetchDataOptions, tovarishClient, }: BaseEncryptedNotesServiceConstructor);
getInstanceName(): string; getInstanceName(): string;
getType(): string;
getTovarishType(): string; getTovarishType(): string;
getGraphMethod(): string; getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<EncryptedNotesEvents[]>; formatEvents(events: EventLog[]): Promise<EncryptedNotesEvents[]>;
} }
export type BaseGovernanceServiceConstructor = { export interface BaseGovernanceServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
Governance: Governance; Governance: Governance;
deployedBlock?: number; }
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
export declare class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents> { export declare class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents> {
batchTransactionService: BatchTransactionService; batchTransactionService: BatchTransactionService;
constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, tovarishClient, }: BaseGovernanceServiceConstructor); constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, tovarishClient, }: BaseGovernanceServiceConstructor);
getInstanceName(): string; getInstanceName(): string;
getType(): string;
getTovarishType(): string; getTovarishType(): string;
getGraphMethod(): string; getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<AllGovernanceEvents[]>; formatEvents(events: EventLog[]): Promise<AllGovernanceEvents[]>;
@ -204,25 +171,17 @@ export interface CachedRelayers {
relayers: CachedRelayerInfo[]; relayers: CachedRelayerInfo[];
fromCache?: boolean; fromCache?: boolean;
} }
export type BaseRegistryServiceConstructor = { export interface BaseRegistryServiceConstructor extends Omit<BaseEventsServiceConstructor, 'contract' | 'type'> {
netId: NetIdType;
provider: Provider;
graphApi?: string;
subgraphName?: string;
RelayerRegistry: RelayerRegistry; RelayerRegistry: RelayerRegistry;
Aggregator: Aggregator; Aggregator: Aggregator;
relayerEnsSubdomains: SubdomainMap; relayerEnsSubdomains: SubdomainMap;
deployedBlock?: number; }
fetchDataOptions?: fetchDataOptions;
tovarishClient?: TovarishClient;
};
export declare class BaseRegistryService extends BaseEventsService<RegistersEvents> { export declare class BaseRegistryService extends BaseEventsService<RegistersEvents> {
Aggregator: Aggregator; Aggregator: Aggregator;
relayerEnsSubdomains: SubdomainMap; relayerEnsSubdomains: SubdomainMap;
updateInterval: number; updateInterval: number;
constructor({ netId, provider, graphApi, subgraphName, RelayerRegistry, Aggregator, relayerEnsSubdomains, deployedBlock, fetchDataOptions, tovarishClient, }: BaseRegistryServiceConstructor); constructor({ netId, provider, graphApi, subgraphName, RelayerRegistry, Aggregator, relayerEnsSubdomains, deployedBlock, fetchDataOptions, tovarishClient, }: BaseRegistryServiceConstructor);
getInstanceName(): string; getInstanceName(): string;
getType(): string;
getTovarishType(): string; getTovarishType(): string;
getGraphMethod(): string; getGraphMethod(): string;
formatEvents(events: EventLog[]): Promise<{ formatEvents(events: EventLog[]): Promise<{

@ -15,51 +15,51 @@ export interface MinimalEvents {
logIndex: number; logIndex: number;
transactionHash: string; transactionHash: string;
} }
export type GovernanceEvents = MinimalEvents & { export interface GovernanceEvents extends MinimalEvents {
event: string; event: string;
}; }
export type GovernanceProposalCreatedEvents = GovernanceEvents & { export interface GovernanceProposalCreatedEvents extends GovernanceEvents {
id: number; id: number;
proposer: string; proposer: string;
target: string; target: string;
startTime: number; startTime: number;
endTime: number; endTime: number;
description: string; description: string;
}; }
export type GovernanceVotedEvents = GovernanceEvents & { export interface GovernanceVotedEvents extends GovernanceEvents {
proposalId: number; proposalId: number;
voter: string; voter: string;
support: boolean; support: boolean;
votes: string; votes: string;
from: string; from: string;
input: string; input: string;
}; }
export type GovernanceDelegatedEvents = GovernanceEvents & { export interface GovernanceDelegatedEvents extends GovernanceEvents {
account: string; account: string;
delegateTo: string; delegateTo: string;
}; }
export type GovernanceUndelegatedEvents = GovernanceEvents & { export interface GovernanceUndelegatedEvents extends GovernanceEvents {
account: string; account: string;
delegateFrom: string; delegateFrom: string;
}; }
export type AllGovernanceEvents = GovernanceProposalCreatedEvents | GovernanceVotedEvents | GovernanceDelegatedEvents | GovernanceUndelegatedEvents; export type AllGovernanceEvents = GovernanceProposalCreatedEvents | GovernanceVotedEvents | GovernanceDelegatedEvents | GovernanceUndelegatedEvents;
export type RegistersEvents = MinimalEvents & RelayerParams; export type RegistersEvents = MinimalEvents & RelayerParams;
export type DepositsEvents = MinimalEvents & { export interface DepositsEvents extends MinimalEvents {
commitment: string; commitment: string;
leafIndex: number; leafIndex: number;
timestamp: number; timestamp: number;
from: string; from: string;
}; }
export type WithdrawalsEvents = MinimalEvents & { export interface WithdrawalsEvents extends MinimalEvents {
nullifierHash: string; nullifierHash: string;
to: string; to: string;
fee: string; fee: string;
timestamp: number; timestamp: number;
}; }
export type EchoEvents = MinimalEvents & { export interface EchoEvents extends MinimalEvents {
address: string; address: string;
encryptedAccount: string; encryptedAccount: string;
}; }
export type EncryptedNotesEvents = MinimalEvents & { export interface EncryptedNotesEvents extends MinimalEvents {
encryptedNote: string; 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 { fetchDataOptions } from '../providers';
import type { BaseGraphEvents, RegistersEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, BatchGraphOnProgress, EchoEvents, AllGovernanceEvents } from '../events'; import type { BaseGraphEvents, RegistersEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, BatchGraphOnProgress, EchoEvents, AllGovernanceEvents } from '../events';
export * from './queries'; export * from './queries';
export type queryGraphParams = { export interface queryGraphParams {
graphApi: string; graphApi: string;
subgraphName: string; subgraphName: string;
query: string; query: string;
@ -9,7 +9,7 @@ export type queryGraphParams = {
[key: string]: string | number; [key: string]: string | number;
}; };
fetchDataOptions?: fetchDataOptions; fetchDataOptions?: fetchDataOptions;
}; }
export declare function queryGraph<T>({ graphApi, subgraphName, query, variables, fetchDataOptions, }: queryGraphParams): Promise<T>; export declare function queryGraph<T>({ graphApi, subgraphName, query, variables, fetchDataOptions, }: queryGraphParams): Promise<T>;
export interface GraphStatistic { export interface GraphStatistic {
deposits: { deposits: {

1
dist/index.d.ts vendored

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

1985
dist/index.js vendored

File diff suppressed because it is too large Load Diff

1984
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 { DepositType } from './deposits';
import type { DepositsEvents } from './events'; import type { DepositsEvents } from './events';
import type { NetIdType } from './networkConfig'; import type { NetIdType } from './networkConfig';
export type MerkleTreeConstructor = DepositType & { export interface MerkleTreeConstructor extends DepositType {
Tornado: Tornado; Tornado: Tornado;
commitmentHex?: string; commitmentHex?: string;
merkleTreeHeight?: number; merkleTreeHeight?: number;
emptyElement?: string; emptyElement?: string;
merkleWorkerPath?: string; merkleWorkerPath?: string;
}; }
export declare class MerkleTreeService { export declare class MerkleTreeService {
currency: string; currency: string;
amount: 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 { class Mimc {
sponge;
hash;
mimcPromise;
constructor() { constructor() {
this.mimcPromise = this.initMimc(); this.mimcPromise = this.initMimc();
} }
initMimc() { async initMimc() {
return __async$1(this, null, function* () { this.sponge = await buildMimcSponge();
this.sponge = yield buildMimcSponge(); this.hash = (left, right) => this.sponge?.F.toString(this.sponge?.multiHash([BigInt(left), BigInt(right)]));
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)]));
};
});
} }
getHash() { async getHash() {
return __async$1(this, null, function* () { await this.mimcPromise;
yield this.mimcPromise;
return { return {
sponge: this.sponge, sponge: this.sponge,
hash: this.hash hash: this.hash
}; };
});
} }
} }
const mimc = new Mimc(); const mimc = new Mimc();
@ -1855,29 +1831,8 @@ BigInt.prototype.toJSON = function() {
}; };
const isNode = !process.browser && typeof globalThis.window === "undefined"; const isNode = !process.browser && typeof globalThis.window === "undefined";
var __async = (__this, __arguments, generator) => { async function nodePostWork() {
return new Promise((resolve, reject) => { const { hash: hashFunction } = await mimc.getHash();
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();
const { merkleTreeHeight, edge, elements, zeroElement } = workerThreads.workerData; const { merkleTreeHeight, edge, elements, zeroElement } = workerThreads.workerData;
if (edge) { if (edge) {
const merkleTree2 = new libExports.PartialMerkleTree(merkleTreeHeight, edge, elements, { const merkleTree2 = new libExports.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -1892,19 +1847,18 @@ function nodePostWork() {
hashFunction hashFunction
}); });
workerThreads.parentPort.postMessage(merkleTree.toString()); workerThreads.parentPort.postMessage(merkleTree.toString());
});
} }
if (isNode && workerThreads) { if (isNode && workerThreads) {
nodePostWork(); nodePostWork();
} else if (!isNode && typeof addEventListener === "function" && typeof postMessage === "function") { } else if (!isNode && typeof addEventListener === "function" && typeof postMessage === "function") {
addEventListener("message", (e) => __async(undefined, null, function* () { addEventListener("message", async (e) => {
let data; let data;
if (e.data) { if (e.data) {
data = e.data; data = e.data;
} else { } else {
data = e; data = e;
} }
const { hash: hashFunction } = yield mimc.getHash(); const { hash: hashFunction } = await mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = data; const { merkleTreeHeight, edge, elements, zeroElement } = data;
if (edge) { if (edge) {
const merkleTree2 = new libExports.PartialMerkleTree(merkleTreeHeight, edge, elements, { const merkleTree2 = new libExports.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -1919,7 +1873,7 @@ if (isNode && workerThreads) {
hashFunction hashFunction
}); });
postMessage(merkleTree.toString()); postMessage(merkleTree.toString());
})); });
} else { } else {
throw new Error("This browser / environment does not support workers!"); 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 ;// ./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 { class Mimc {
sponge;
hash;
mimcPromise;
constructor() { constructor() {
this.mimcPromise = this.initMimc(); this.mimcPromise = this.initMimc();
} }
initMimc() { async initMimc() {
return __async(this, null, function* () { this.sponge = await mimcsponge_buildMimcSponge();
this.sponge = yield mimcsponge_buildMimcSponge(); this.hash = (left, right) => this.sponge?.F.toString(this.sponge?.multiHash([BigInt(left), BigInt(right)]));
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)]));
};
});
} }
getHash() { async getHash() {
return __async(this, null, function* () { await this.mimcPromise;
yield this.mimcPromise;
return { return {
sponge: this.sponge, sponge: this.sponge,
hash: this.hash hash: this.hash
}; };
});
} }
} }
const mimc = new Mimc(); const mimc = new Mimc();
@ -102028,26 +102004,6 @@ var crypto_browserify = __webpack_require__(1565);
var bn = __webpack_require__(9404); var bn = __webpack_require__(9404);
;// ./src/utils.ts ;// ./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() { BigInt.prototype.toJSON = function() {
@ -102066,7 +102022,7 @@ function validateUrl(url, protocols) {
return protocols.map((p) => p.toLowerCase()).includes(parsedUrl.protocol); return protocols.map((p) => p.toLowerCase()).includes(parsedUrl.protocol);
} }
return true; return true;
} catch (e) { } catch {
return false; return false;
} }
} }
@ -102138,41 +102094,18 @@ function substring(str, length = 10) {
} }
return `${str.substring(0, length)}...${str.substring(str.length - length)}`; return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
} }
function digest(bytes, algo = "SHA-384") { async function digest(bytes, algo = "SHA-384") {
return utils_async(this, null, function* () { return new Uint8Array(await utils_crypto.subtle.digest(algo, bytes));
return new Uint8Array(yield utils_crypto.subtle.digest(algo, bytes));
});
} }
;// ./src/merkleTreeWorker.ts ;// ./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() { async function nodePostWork() {
return merkleTreeWorker_async(this, null, function* () { const { hash: hashFunction } = await mimc.getHash();
const { hash: hashFunction } = yield mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = (worker_threads_ignored_default()).workerData; const { merkleTreeHeight, edge, elements, zeroElement } = (worker_threads_ignored_default()).workerData;
if (edge) { if (edge) {
const merkleTree2 = new lib.PartialMerkleTree(merkleTreeHeight, edge, elements, { const merkleTree2 = new lib.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -102187,19 +102120,18 @@ function nodePostWork() {
hashFunction hashFunction
}); });
worker_threads_ignored_default().parentPort.postMessage(merkleTree.toString()); worker_threads_ignored_default().parentPort.postMessage(merkleTree.toString());
});
} }
if (isNode && (worker_threads_ignored_default())) { if (isNode && (worker_threads_ignored_default())) {
nodePostWork(); nodePostWork();
} else if (!isNode && typeof addEventListener === "function" && typeof postMessage === "function") { } else if (!isNode && typeof addEventListener === "function" && typeof postMessage === "function") {
addEventListener("message", (e) => merkleTreeWorker_async(undefined, null, function* () { addEventListener("message", async (e) => {
let data; let data;
if (e.data) { if (e.data) {
data = e.data; data = e.data;
} else { } else {
data = e; data = e;
} }
const { hash: hashFunction } = yield mimc.getHash(); const { hash: hashFunction } = await mimc.getHash();
const { merkleTreeHeight, edge, elements, zeroElement } = data; const { merkleTreeHeight, edge, elements, zeroElement } = data;
if (edge) { if (edge) {
const merkleTree2 = new lib.PartialMerkleTree(merkleTreeHeight, edge, elements, { const merkleTree2 = new lib.PartialMerkleTree(merkleTreeHeight, edge, elements, {
@ -102214,7 +102146,7 @@ if (isNode && (worker_threads_ignored_default())) {
hashFunction hashFunction
}); });
postMessage(merkleTree.toString()); postMessage(merkleTree.toString());
})); });
} else { } else {
throw new Error("This browser / environment does not support workers!"); 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; name: string;
url: string; url: string;
} }
export type RpcUrls = { export interface RpcUrls {
[key in string]: RpcUrl; [key: string]: RpcUrl;
}; }
export interface SubgraphUrl { export interface SubgraphUrl {
name: string; name: string;
url: string; url: string;
} }
export type SubgraphUrls = { export interface SubgraphUrls {
[key in string]: SubgraphUrl; [key: string]: SubgraphUrl;
}; }
export type TornadoInstance = { export interface TornadoInstance {
instanceAddress: { instanceAddress: {
[key in string]: string; [key: string]: string;
}; };
optionalInstances?: string[]; optionalInstances?: string[];
tokenAddress?: string; tokenAddress?: string;
@ -36,11 +36,11 @@ export type TornadoInstance = {
symbol: string; symbol: string;
decimals: number; decimals: number;
gasLimit?: number; gasLimit?: number;
}; }
export type TokenInstances = { export interface TokenInstances {
[key in string]: TornadoInstance; [key: string]: TornadoInstance;
}; }
export type Config = { export interface Config {
rpcCallRetryAttempt?: number; rpcCallRetryAttempt?: number;
gasPrices: { gasPrices: {
instant: number; instant: number;
@ -57,6 +57,7 @@ export type Config = {
networkName: string; networkName: string;
deployedBlock: number; deployedBlock: number;
rpcUrls: RpcUrls; rpcUrls: RpcUrls;
stablecoin: string;
multicallContract: string; multicallContract: string;
routerContract: string; routerContract: string;
echoContract: string; echoContract: string;
@ -84,13 +85,13 @@ export type Config = {
REGISTRY_BLOCK?: number; REGISTRY_BLOCK?: number;
MINING_BLOCK_TIME?: number; MINING_BLOCK_TIME?: number;
}; };
}; }
export type networkConfig = { export interface networkConfig {
[key in NetIdType]: Config; [key: NetIdType]: Config;
}; }
export type SubdomainMap = { export interface SubdomainMap {
[key in NetIdType]: string; [key: NetIdType]: string;
}; }
export declare const defaultConfig: networkConfig; export declare const defaultConfig: networkConfig;
export declare const enabledChains: NetIdType[]; export declare const enabledChains: NetIdType[];
/** /**

10
dist/prices.d.ts vendored

@ -1,12 +1,20 @@
import { type Provider } from 'ethers'; import { type Provider } from 'ethers';
import type { OffchainOracle, Multicall } from './typechain'; import { OffchainOracle, Multicall } from './typechain';
import { Call3 } from './multicall';
export declare class TokenPriceOracle { export declare class TokenPriceOracle {
oracle?: OffchainOracle; oracle?: OffchainOracle;
multicall: Multicall; multicall: Multicall;
provider: Provider; provider: Provider;
constructor(provider: Provider, multicall: Multicall, oracle?: OffchainOracle); 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: { fetchPrices(tokens: {
tokenAddress: string; tokenAddress: string;
decimals: number; decimals: number;
}[]): Promise<bigint[]>; }[]): 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 getProvider(rpcUrl: string, fetchOptions?: getProviderOptions): Promise<JsonRpcProvider>;
export declare function getProviderWithNetId(netId: NetIdType, 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 declare const populateTransaction: (signer: TornadoWallet | TornadoVoidSigner | TornadoRpcSigner, tx: TransactionRequest) => Promise<TransactionRequest>;
export type TornadoWalletOptions = { export interface TornadoWalletOptions {
gasPriceBump?: number; gasPriceBump?: number;
gasLimitBump?: number; gasLimitBump?: number;
gasFailover?: boolean; gasFailover?: boolean;
bumpNonce?: boolean; bumpNonce?: boolean;
}; }
export declare class TornadoWallet extends Wallet { export declare class TornadoWallet extends Wallet {
nonce?: number; nonce?: number;
gasPriceBump: number; gasPriceBump: number;
@ -74,13 +74,13 @@ export declare class TornadoRpcSigner extends JsonRpcSigner {
} }
export type connectWalletFunc = (...args: any[]) => Promise<void>; export type connectWalletFunc = (...args: any[]) => Promise<void>;
export type handleWalletFunc = (...args: any[]) => void; export type handleWalletFunc = (...args: any[]) => void;
export type TornadoBrowserProviderOptions = TornadoWalletOptions & { export interface TornadoBrowserProviderOptions extends TornadoWalletOptions {
netId?: NetIdType; netId?: NetIdType;
connectWallet?: connectWalletFunc; connectWallet?: connectWalletFunc;
handleNetworkChanges?: handleWalletFunc; handleNetworkChanges?: handleWalletFunc;
handleAccountChanges?: handleWalletFunc; handleAccountChanges?: handleWalletFunc;
handleAccountDisconnect?: handleWalletFunc; handleAccountDisconnect?: handleWalletFunc;
}; }
export declare class TornadoBrowserProvider extends BrowserProvider { export declare class TornadoBrowserProvider extends BrowserProvider {
options?: TornadoBrowserProviderOptions; options?: TornadoBrowserProviderOptions;
constructor(ethereum: Eip1193Provider, network?: Networkish, options?: TornadoBrowserProviderOptions); constructor(ethereum: Eip1193Provider, network?: Networkish, options?: TornadoBrowserProviderOptions);

@ -12,7 +12,7 @@ export interface RelayerParams {
/** /**
* Info from relayer status * Info from relayer status
*/ */
export type RelayerInfo = RelayerParams & { export interface RelayerInfo extends RelayerParams {
netId: NetIdType; netId: NetIdType;
url: string; url: string;
hostname: string; hostname: string;
@ -25,13 +25,13 @@ export type RelayerInfo = RelayerParams & {
}; };
currentQueue: number; currentQueue: number;
tornadoServiceFee: number; tornadoServiceFee: number;
}; }
export type RelayerError = { export interface RelayerError {
hostname: string; hostname: string;
relayerAddress?: string; relayerAddress?: string;
errorMessage?: string; errorMessage?: string;
hasError: boolean; hasError: boolean;
}; }
export interface RelayerStatus { export interface RelayerStatus {
url: string; url: string;
rewardAccount: string; rewardAccount: string;
@ -63,9 +63,9 @@ export interface RelayerStatus {
}; };
currentQueue: number; currentQueue: number;
} }
export type TornadoWithdrawParams = snarkProofs & { export interface TornadoWithdrawParams extends snarkProofs {
contract: string; contract: string;
}; }
export interface RelayerTornadoWithdraw { export interface RelayerTornadoWithdraw {
id?: string; id?: string;
error?: 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 calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo): bigint;
export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number; export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number;
export type RelayerInstanceList = { export interface RelayerInstanceList {
[key in string]: { [key: string]: {
instanceAddress: { instanceAddress: {
[key in string]: string; [key: string]: string;
}; };
}; };
}; }
export declare function getSupportedInstances(instanceList: RelayerInstanceList): string[]; export declare function getSupportedInstances(instanceList: RelayerInstanceList): string[];
export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo; export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
export interface RelayerClientConstructor { export interface RelayerClientConstructor {
@ -143,5 +143,5 @@ export declare class RelayerClient {
invalidRelayers: RelayerError[]; invalidRelayers: RelayerError[];
}>; }>;
pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo; 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; type: string;
properties: { properties: {
error: { error: {
@ -36,5 +36,6 @@ export type jobsSchema = {
}; };
}; };
required: string[]; required: string[];
}; }
export declare const jobsSchema: jobsSchema; export declare const jobsSchema: jobsSchema;
export declare const jobRequestSchema: jobsSchema;

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

2197
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; url?: string;
relayerAddress?: string; relayerAddress?: string;
}): Promise<TovarishStatus>; }): 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>; filterRelayer(relayer: CachedRelayerInfo): Promise<TovarishInfo | RelayerError | undefined>;
getValidRelayers(relayers: CachedRelayerInfo[]): Promise<{ getValidRelayers(relayers: CachedRelayerInfo[]): Promise<{
validRelayers: TovarishInfo[]; validRelayers: TovarishInfo[];
invalidRelayers: RelayerError[]; invalidRelayers: RelayerError[];
}>; }>;
getTovarishRelayers(relayers: CachedRelayerInfo[]): Promise<{
validRelayers: TovarishInfo[];
invalidRelayers: RelayerError[];
}>;
getEvents<T extends MinimalEvents>({ type, currency, amount, fromBlock, recent, }: TovarishEventsQuery): Promise<BaseTovarishEvents<T>>; 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'; import type { Element } from '@tornado/fixed-merkle-tree';
export type snarkInputs = { export interface snarkInputs {
root: Element; root: Element;
nullifierHex: string; nullifierHex: string;
recipient: string; recipient: string;
@ -10,7 +10,7 @@ export type snarkInputs = {
secret: bigint; secret: bigint;
pathElements: Element[]; pathElements: Element[];
pathIndices: Element[]; pathIndices: Element[];
}; }
export type snarkArgs = [ export type snarkArgs = [
_root: string, _root: string,
_nullifierHash: string, _nullifierHash: string,
@ -19,9 +19,9 @@ export type snarkArgs = [
_fee: string, _fee: string,
_refund: string _refund: string
]; ];
export type snarkProofs = { export interface snarkProofs {
proof: string; proof: string;
args: snarkArgs; args: snarkArgs;
}; }
export declare function initGroth16(): Promise<void>; export declare function initGroth16(): Promise<void>;
export declare function calculateSnarkProof(input: snarkInputs, circuit: object, provingKey: ArrayBuffer): Promise<snarkProofs>; export declare function calculateSnarkProof(input: snarkInputs, circuit: object, provingKey: ArrayBuffer): Promise<snarkProofs>;