Add latestBalance params

This commit is contained in:
Tornado Contrib 2024-09-30 06:22:40 +00:00
parent a00dab8d06
commit 61266bdb6e
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
10 changed files with 51 additions and 15 deletions

11
dist/index.js vendored

@ -2390,6 +2390,7 @@ const statusSchema = {
netId: { type: "integer" }, netId: { type: "integer" },
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 }, tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
latestBlock: { type: "number" }, latestBlock: { type: "number" },
latestBalance: { type: "string", BN: true },
version: { type: "string" }, version: { type: "string" },
health: { health: {
type: "object", type: "object",
@ -2479,7 +2480,7 @@ function getStatusSchema(netId, config, tovarish) {
schema.required.push("ethPrices"); schema.required.push("ethPrices");
} }
if (tovarish) { if (tovarish) {
schema.required.push("gasPrices", "latestBlock", "syncStatus", "onSyncEvents"); schema.required.push("gasPrices", "latestBlock", "latestBalance", "syncStatus", "onSyncEvents");
} }
return schema; return schema;
} }
@ -2699,8 +2700,8 @@ class RelayerClient {
pickWeightedRandomRelayer(relayers) { pickWeightedRandomRelayer(relayers) {
return pickWeightedRandomRelayer(relayers); return pickWeightedRandomRelayer(relayers);
} }
tornadoWithdraw(_0) { tornadoWithdraw(_0, _1) {
return __async$a(this, arguments, function* ({ contract, proof, args }) { return __async$a(this, arguments, function* ({ contract, proof, args }, callback) {
const { url } = this.selectedRelayer; const { url } = this.selectedRelayer;
const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps$2(__spreadValues$2({}, this.fetchDataOptions), { const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps$2(__spreadValues$2({}, this.fetchDataOptions), {
method: "POST", method: "POST",
@ -2755,6 +2756,9 @@ class RelayerClient {
`); `);
} }
relayerStatus = status; relayerStatus = status;
if (typeof callback === "function") {
callback(jobResponse);
}
} }
yield sleep(3e3); yield sleep(3e3);
} }
@ -6800,6 +6804,7 @@ class TovarishClient extends RelayerClient {
tornadoServiceFee: status.tornadoServiceFee, tornadoServiceFee: status.tornadoServiceFee,
// Additional fields for tovarish relayer // Additional fields for tovarish relayer
latestBlock: Number(status.latestBlock), latestBlock: Number(status.latestBlock),
latestBalance: status.latestBalance,
version: status.version, version: status.version,
events: status.events, events: status.events,
syncStatus: status.syncStatus syncStatus: status.syncStatus

11
dist/index.mjs vendored

@ -2369,6 +2369,7 @@ const statusSchema = {
netId: { type: "integer" }, netId: { type: "integer" },
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 }, tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
latestBlock: { type: "number" }, latestBlock: { type: "number" },
latestBalance: { type: "string", BN: true },
version: { type: "string" }, version: { type: "string" },
health: { health: {
type: "object", type: "object",
@ -2458,7 +2459,7 @@ function getStatusSchema(netId, config, tovarish) {
schema.required.push("ethPrices"); schema.required.push("ethPrices");
} }
if (tovarish) { if (tovarish) {
schema.required.push("gasPrices", "latestBlock", "syncStatus", "onSyncEvents"); schema.required.push("gasPrices", "latestBlock", "latestBalance", "syncStatus", "onSyncEvents");
} }
return schema; return schema;
} }
@ -2678,8 +2679,8 @@ class RelayerClient {
pickWeightedRandomRelayer(relayers) { pickWeightedRandomRelayer(relayers) {
return pickWeightedRandomRelayer(relayers); return pickWeightedRandomRelayer(relayers);
} }
tornadoWithdraw(_0) { tornadoWithdraw(_0, _1) {
return __async$a(this, arguments, function* ({ contract, proof, args }) { return __async$a(this, arguments, function* ({ contract, proof, args }, callback) {
const { url } = this.selectedRelayer; const { url } = this.selectedRelayer;
const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps$2(__spreadValues$2({}, this.fetchDataOptions), { const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps$2(__spreadValues$2({}, this.fetchDataOptions), {
method: "POST", method: "POST",
@ -2734,6 +2735,9 @@ class RelayerClient {
`); `);
} }
relayerStatus = status; relayerStatus = status;
if (typeof callback === "function") {
callback(jobResponse);
}
} }
yield sleep(3e3); yield sleep(3e3);
} }
@ -6779,6 +6783,7 @@ class TovarishClient extends RelayerClient {
tornadoServiceFee: status.tornadoServiceFee, tornadoServiceFee: status.tornadoServiceFee,
// Additional fields for tovarish relayer // Additional fields for tovarish relayer
latestBlock: Number(status.latestBlock), latestBlock: Number(status.latestBlock),
latestBalance: status.latestBalance,
version: status.version, version: status.version,
events: status.events, events: status.events,
syncStatus: status.syncStatus syncStatus: status.syncStatus

@ -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): Promise<void>; tornadoWithdraw({ contract, proof, args }: TornadoWithdrawParams, callback?: (jobResp: RelayerTornadoJobs) => void): Promise<void>;
} }

@ -56,9 +56,13 @@ export type statusSchema = {
maximum: number; maximum: number;
minimum: number; minimum: number;
}; };
latestBlock?: { latestBlock: {
type: string; type: string;
}; };
latestBalance: {
type: string;
BN: boolean;
};
version: { version: {
type: string; type: string;
}; };

11
dist/tornado.umd.js vendored

@ -71729,8 +71729,8 @@ class RelayerClient {
pickWeightedRandomRelayer(relayers) { pickWeightedRandomRelayer(relayers) {
return pickWeightedRandomRelayer(relayers); return pickWeightedRandomRelayer(relayers);
} }
tornadoWithdraw(_0) { tornadoWithdraw(_0, _1) {
return __async(this, arguments, function* ({ contract, proof, args }) { return __async(this, arguments, function* ({ contract, proof, args }, callback) {
const { url } = this.selectedRelayer; const { url } = this.selectedRelayer;
const withdrawResponse = yield (0,_providers__WEBPACK_IMPORTED_MODULE_2__/* .fetchData */ .Fd)(`${url}v1/tornadoWithdraw`, __spreadProps(__spreadValues({}, this.fetchDataOptions), { const withdrawResponse = yield (0,_providers__WEBPACK_IMPORTED_MODULE_2__/* .fetchData */ .Fd)(`${url}v1/tornadoWithdraw`, __spreadProps(__spreadValues({}, this.fetchDataOptions), {
method: "POST", method: "POST",
@ -71785,6 +71785,9 @@ class RelayerClient {
`); `);
} }
relayerStatus = status; relayerStatus = status;
if (typeof callback === "function") {
callback(jobResponse);
}
} }
yield (0,_utils__WEBPACK_IMPORTED_MODULE_0__/* .sleep */ .yy)(3e3); yield (0,_utils__WEBPACK_IMPORTED_MODULE_0__/* .sleep */ .yy)(3e3);
} }
@ -71832,6 +71835,7 @@ const statusSchema = {
netId: { type: "integer" }, netId: { type: "integer" },
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 }, tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
latestBlock: { type: "number" }, latestBlock: { type: "number" },
latestBalance: { type: "string", BN: true },
version: { type: "string" }, version: { type: "string" },
health: { health: {
type: "object", type: "object",
@ -71921,7 +71925,7 @@ function getStatusSchema(netId, config, tovarish) {
schema.required.push("ethPrices"); schema.required.push("ethPrices");
} }
if (tovarish) { if (tovarish) {
schema.required.push("gasPrices", "latestBlock", "syncStatus", "onSyncEvents"); schema.required.push("gasPrices", "latestBlock", "latestBalance", "syncStatus", "onSyncEvents");
} }
return schema; return schema;
} }
@ -72174,6 +72178,7 @@ class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .Rela
tornadoServiceFee: status.tornadoServiceFee, tornadoServiceFee: status.tornadoServiceFee,
// Additional fields for tovarish relayer // Additional fields for tovarish relayer
latestBlock: Number(status.latestBlock), latestBlock: Number(status.latestBlock),
latestBalance: status.latestBalance,
version: status.version, version: status.version,
events: status.events, events: status.events,
syncStatus: status.syncStatus syncStatus: status.syncStatus

File diff suppressed because one or more lines are too long

@ -31,12 +31,14 @@ export interface TovarishSyncStatus {
gasPrice: boolean; gasPrice: boolean;
} }
export interface TovarishStatus extends RelayerStatus { export interface TovarishStatus extends RelayerStatus {
latestBalance: string;
events: TovarishEventsStatus; events: TovarishEventsStatus;
syncStatus: TovarishSyncStatus; syncStatus: TovarishSyncStatus;
onSyncEvents: boolean; onSyncEvents: boolean;
} }
export interface TovarishInfo extends RelayerInfo { export interface TovarishInfo extends RelayerInfo {
latestBlock: number; latestBlock: number;
latestBalance: string;
version: string; version: string;
events: TovarishEventsStatus; events: TovarishEventsStatus;
syncStatus: TovarishSyncStatus; syncStatus: TovarishSyncStatus;

@ -316,7 +316,10 @@ export class RelayerClient {
return pickWeightedRandomRelayer(relayers); return pickWeightedRandomRelayer(relayers);
} }
async tornadoWithdraw({ contract, proof, args }: TornadoWithdrawParams) { async tornadoWithdraw(
{ contract, proof, args }: TornadoWithdrawParams,
callback?: (jobResp: RelayerTornadoJobs) => void,
) {
const { url } = this.selectedRelayer as RelayerInfo; const { url } = this.selectedRelayer as RelayerInfo;
const withdrawResponse = (await fetchData(`${url}v1/tornadoWithdraw`, { const withdrawResponse = (await fetchData(`${url}v1/tornadoWithdraw`, {
@ -381,6 +384,10 @@ export class RelayerClient {
} }
relayerStatus = status; relayerStatus = status;
if (typeof callback === 'function') {
callback(jobResponse as unknown as RelayerTornadoJobs);
}
} }
await sleep(3000); await sleep(3000);

@ -56,9 +56,13 @@ export type statusSchema = {
maximum: number; maximum: number;
minimum: number; minimum: number;
}; };
latestBlock?: { latestBlock: {
type: string; type: string;
}; };
latestBalance: {
type: string;
BN: boolean;
};
version: { version: {
type: string; type: string;
}; };
@ -106,6 +110,7 @@ const statusSchema: statusSchema = {
netId: { type: 'integer' }, netId: { type: 'integer' },
tornadoServiceFee: { type: 'number', maximum: 20, minimum: 0 }, tornadoServiceFee: { type: 'number', maximum: 20, minimum: 0 },
latestBlock: { type: 'number' }, latestBlock: { type: 'number' },
latestBalance: { type: 'string', BN: true },
version: { type: 'string' }, version: { type: 'string' },
health: { health: {
type: 'object', type: 'object',
@ -204,7 +209,7 @@ export function getStatusSchema(netId: NetIdType, config: Config, tovarish: bool
} }
if (tovarish) { if (tovarish) {
schema.required.push('gasPrices', 'latestBlock', 'syncStatus', 'onSyncEvents'); schema.required.push('gasPrices', 'latestBlock', 'latestBalance', 'syncStatus', 'onSyncEvents');
} }
return schema; return schema;

@ -50,6 +50,7 @@ export interface TovarishSyncStatus {
// Expected response from /status endpoint // Expected response from /status endpoint
export interface TovarishStatus extends RelayerStatus { export interface TovarishStatus extends RelayerStatus {
latestBalance: string;
events: TovarishEventsStatus; events: TovarishEventsStatus;
syncStatus: TovarishSyncStatus; syncStatus: TovarishSyncStatus;
onSyncEvents: boolean; onSyncEvents: boolean;
@ -58,6 +59,7 @@ export interface TovarishStatus extends RelayerStatus {
// Formatted TovarishStatus for Frontend usage // Formatted TovarishStatus for Frontend usage
export interface TovarishInfo extends RelayerInfo { export interface TovarishInfo extends RelayerInfo {
latestBlock: number; latestBlock: number;
latestBalance: string;
version: string; version: string;
events: TovarishEventsStatus; events: TovarishEventsStatus;
syncStatus: TovarishSyncStatus; syncStatus: TovarishSyncStatus;
@ -130,6 +132,7 @@ export class TovarishClient extends RelayerClient {
tornadoServiceFee: status.tornadoServiceFee, tornadoServiceFee: status.tornadoServiceFee,
// Additional fields for tovarish relayer // Additional fields for tovarish relayer
latestBlock: Number(status.latestBlock), latestBlock: Number(status.latestBlock),
latestBalance: status.latestBalance,
version: status.version, version: status.version,
events: status.events, events: status.events,
syncStatus: status.syncStatus, syncStatus: status.syncStatus,