tornado-core/dist/relayerClient.d.ts

128 lines
3.7 KiB
TypeScript
Raw Normal View History

2024-04-29 18:55:15 +03:00
import { NetIdType, Config } from './networkConfig';
import { fetchDataOptions } from './providers';
import type { snarkProofs } from './websnark';
import { CachedRelayerInfo } from './events/base';
export declare const MIN_FEE = 0.1;
export declare const MAX_FEE = 0.6;
2024-04-29 18:55:15 +03:00
export declare const MIN_STAKE_BALANCE: bigint;
export interface RelayerParams {
ensName: string;
relayerAddress: string;
2024-04-29 18:55:15 +03:00
}
/**
* Info from relayer status
*/
export type RelayerInfo = RelayerParams & {
2024-04-29 18:55:15 +03:00
netId: NetIdType;
url: string;
hostname: string;
rewardAccount: string;
instances: string[];
stakeBalance?: string;
2024-04-29 18:55:15 +03:00
gasPrice?: number;
ethPrices?: {
[key in string]: string;
};
currentQueue: number;
tornadoServiceFee: number;
};
export type RelayerError = {
hostname: string;
relayerAddress?: string;
errorMessage?: string;
hasError: boolean;
2024-04-29 18:55:15 +03:00
};
export interface RelayerStatus {
url: string;
rewardAccount: string;
instances: {
[key in string]: {
instanceAddress: {
[key in string]: string;
};
tokenAddress?: string;
symbol: string;
decimals: number;
};
};
gasPrices?: {
fast: number;
additionalProperties?: number;
};
netId: NetIdType;
ethPrices?: {
[key in string]: string;
};
tornadoServiceFee: number;
latestBlock?: number;
version: string;
health: {
status: string;
error: string;
errorsLog: any[];
};
currentQueue: number;
}
export interface RelayerTornadoWithdraw {
id?: string;
error?: string;
}
export interface RelayerTornadoJobs {
error?: string;
id: string;
type?: string;
status: string;
contract?: string;
proof?: string;
args?: string[];
txHash?: string;
confirmations?: number;
failedReason?: string;
}
export interface semanticVersion {
major: string;
minor: string;
patch: string;
prerelease?: string;
buildmetadata?: string;
}
export declare function parseSemanticVersion(version: string): semanticVersion;
export declare function isRelayerUpdated(relayerVersion: string, netId: NetIdType): boolean;
export declare function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo): bigint;
2024-04-29 18:55:15 +03:00
export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number;
export type RelayerInstanceList = {
[key in string]: {
instanceAddress: {
[key in string]: string;
};
};
};
export declare function getSupportedInstances(instanceList: RelayerInstanceList): string[];
export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
2024-04-29 18:55:15 +03:00
export interface RelayerClientConstructor {
netId: NetIdType;
config: Config;
fetchDataOptions?: fetchDataOptions;
}
export type RelayerClientWithdraw = snarkProofs & {
contract: string;
};
export declare class RelayerClient {
netId: NetIdType;
config: Config;
selectedRelayer?: RelayerInfo;
2024-04-29 18:55:15 +03:00
fetchDataOptions?: fetchDataOptions;
constructor({ netId, config, fetchDataOptions }: RelayerClientConstructor);
2024-04-29 18:55:15 +03:00
askRelayerStatus({ hostname, relayerAddress, }: {
hostname: string;
relayerAddress?: string;
}): Promise<RelayerStatus>;
filterRelayer(relayer: CachedRelayerInfo): Promise<RelayerInfo | RelayerError | undefined>;
getValidRelayers(relayers: CachedRelayerInfo[]): Promise<{
2024-04-29 18:55:15 +03:00
validRelayers: RelayerInfo[];
invalidRelayers: RelayerError[];
}>;
pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
tornadoWithdraw({ contract, proof, args }: RelayerClientWithdraw): Promise<void>;
}