forked from tornado-packages/tornado-core
tornado-core 1.0.15
use more universal type defs for snark proofs
This commit is contained in:
parent
f7fdf7db0a
commit
69faa7a974
5
dist/events/base.d.ts
vendored
5
dist/events/base.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
import { BaseContract, Provider, EventLog, ContractEventName } from 'ethers';
|
import { BaseContract, Provider, EventLog, ContractEventName } from 'ethers';
|
||||||
import type { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry, Echoer, Aggregator } from '@tornado/contracts';
|
import type { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry, Echoer, Aggregator } from '@tornado/contracts';
|
||||||
import { BatchEventsService, BatchBlockService, BatchTransactionService, BatchEventOnProgress, BatchBlockOnProgress } from '../batch';
|
import { BatchEventsService, BatchBlockService, BatchTransactionService, BatchEventOnProgress, BatchBlockOnProgress } from '../batch';
|
||||||
import type { fetchDataOptions } from '../providers';
|
import { fetchDataOptions } from '../providers';
|
||||||
import type { NetIdType, SubdomainMap } from '../networkConfig';
|
import type { NetIdType, SubdomainMap } from '../networkConfig';
|
||||||
import { RelayerParams } from '../relayerClient';
|
import { RelayerParams } from '../relayerClient';
|
||||||
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';
|
||||||
@ -170,6 +170,7 @@ export declare class BaseGovernanceService extends BaseEventsService<AllGovernan
|
|||||||
fromBlock: number;
|
fromBlock: number;
|
||||||
}): Promise<BaseEvents<AllGovernanceEvents>>;
|
}): Promise<BaseEvents<AllGovernanceEvents>>;
|
||||||
}
|
}
|
||||||
|
export declare function getTovarishNetworks(registryService: BaseRegistryService, relayers: CachedRelayerInfo[]): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Essential params:
|
* Essential params:
|
||||||
* ensName, relayerAddress, hostnames
|
* ensName, relayerAddress, hostnames
|
||||||
@ -180,6 +181,8 @@ export interface CachedRelayerInfo extends RelayerParams {
|
|||||||
owner?: string;
|
owner?: string;
|
||||||
stakeBalance?: string;
|
stakeBalance?: string;
|
||||||
hostnames: SubdomainMap;
|
hostnames: SubdomainMap;
|
||||||
|
tovarishUrl?: string;
|
||||||
|
tovarishNetworks?: number[];
|
||||||
}
|
}
|
||||||
export interface CachedRelayers {
|
export interface CachedRelayers {
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
68
dist/index.js
vendored
68
dist/index.js
vendored
@ -2368,6 +2368,15 @@ function getActiveTokens(config) {
|
|||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
|
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
|
||||||
}
|
}
|
||||||
|
function getActiveTokenInstances(config) {
|
||||||
|
const { tokens, disabledTokens } = config;
|
||||||
|
return Object.entries(tokens).reduce((acc, [token, instances]) => {
|
||||||
|
if (!(disabledTokens == null ? void 0 : disabledTokens.includes(token))) {
|
||||||
|
acc[token] = instances;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
function getInstanceByAddress(config, address) {
|
function getInstanceByAddress(config, address) {
|
||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
||||||
@ -2556,7 +2565,7 @@ var __async$9 = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
const MIN_FEE = 0.1;
|
const MIN_FEE = 0.1;
|
||||||
const MAX_FEE = 0.6;
|
const MAX_FEE = 0.9;
|
||||||
const MIN_STAKE_BALANCE = ethers.parseEther("500");
|
const MIN_STAKE_BALANCE = ethers.parseEther("500");
|
||||||
function calculateScore({ stakeBalance, tornadoServiceFee }) {
|
function calculateScore({ stakeBalance, tornadoServiceFee }) {
|
||||||
if (tornadoServiceFee < MIN_FEE) {
|
if (tornadoServiceFee < MIN_FEE) {
|
||||||
@ -2804,13 +2813,13 @@ class BaseEventsService {
|
|||||||
contract,
|
contract,
|
||||||
type = "",
|
type = "",
|
||||||
deployedBlock = 0,
|
deployedBlock = 0,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
this.netId = netId;
|
this.netId = netId;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.graphApi = graphApi;
|
this.graphApi = graphApi;
|
||||||
this.subgraphName = subgraphName;
|
this.subgraphName = subgraphName;
|
||||||
this.fetchDataOptions = fetchDataOptions;
|
this.fetchDataOptions = fetchDataOptions2;
|
||||||
this.contract = contract;
|
this.contract = contract;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.deployedBlock = deployedBlock;
|
this.deployedBlock = deployedBlock;
|
||||||
@ -3008,9 +3017,9 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
amount,
|
amount,
|
||||||
currency,
|
currency,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
this.batchTransactionService = new BatchTransactionService({
|
this.batchTransactionService = new BatchTransactionService({
|
||||||
@ -3104,9 +3113,9 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Echoer,
|
Echoer,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Echoer, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Echoer, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
}
|
}
|
||||||
getInstanceName() {
|
getInstanceName() {
|
||||||
return `echo_${this.netId}`;
|
return `echo_${this.netId}`;
|
||||||
@ -3155,9 +3164,9 @@ class BaseEncryptedNotesService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Router,
|
Router,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
}
|
}
|
||||||
getInstanceName() {
|
getInstanceName() {
|
||||||
return `encrypted_notes_${this.netId}`;
|
return `encrypted_notes_${this.netId}`;
|
||||||
@ -3194,9 +3203,9 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Governance,
|
Governance,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.batchTransactionService = new BatchTransactionService({
|
this.batchTransactionService = new BatchTransactionService({
|
||||||
provider,
|
provider,
|
||||||
onProgress: this.updateTransactionProgress
|
onProgress: this.updateTransactionProgress
|
||||||
@ -3290,6 +3299,26 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function getTovarishNetworks(registryService, relayers) {
|
||||||
|
return __async$8(this, null, function* () {
|
||||||
|
yield Promise.all(
|
||||||
|
relayers.filter((r) => r.tovarishUrl).map((relayer) => __async$8(this, null, function* () {
|
||||||
|
var _a, _b;
|
||||||
|
try {
|
||||||
|
relayer.tovarishNetworks = yield fetchData(relayer.tovarishUrl, __spreadProps(__spreadValues({}, registryService.fetchDataOptions), {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
timeout: ((_a = registryService.fetchDataOptions) == null ? void 0 : _a.torPort) ? 1e4 : 3e3,
|
||||||
|
maxRetry: ((_b = registryService.fetchDataOptions) == null ? void 0 : _b.torPort) ? 2 : 0
|
||||||
|
}));
|
||||||
|
} catch (e) {
|
||||||
|
relayer.tovarishNetworks = [];
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
class BaseRegistryService extends BaseEventsService {
|
class BaseRegistryService extends BaseEventsService {
|
||||||
constructor({
|
constructor({
|
||||||
netId,
|
netId,
|
||||||
@ -3300,9 +3329,9 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
Aggregator,
|
Aggregator,
|
||||||
relayerEnsSubdomains,
|
relayerEnsSubdomains,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.Aggregator = Aggregator;
|
this.Aggregator = Aggregator;
|
||||||
this.relayerEnsSubdomains = relayerEnsSubdomains;
|
this.relayerEnsSubdomains = relayerEnsSubdomains;
|
||||||
this.updateInterval = 86400;
|
this.updateInterval = 86400;
|
||||||
@ -3379,13 +3408,18 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
const relayerNameHashes = uniqueRegisters.map((r) => ethers.namehash(r.ensName));
|
const relayerNameHashes = uniqueRegisters.map((r) => ethers.namehash(r.ensName));
|
||||||
const [relayersData, timestamp] = yield Promise.all([
|
const [relayersData, timestamp] = yield Promise.all([
|
||||||
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains),
|
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains.concat("tovarish-relayer")),
|
||||||
this.provider.getBlock("latest").then((b) => Number(b == null ? void 0 : b.timestamp))
|
this.provider.getBlock("latest").then((b) => Number(b == null ? void 0 : b.timestamp))
|
||||||
]);
|
]);
|
||||||
const relayers = relayersData.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
const relayers = relayersData.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
||||||
const { ensName, relayerAddress } = uniqueRegisters[index];
|
const { ensName, relayerAddress } = uniqueRegisters[index];
|
||||||
|
let tovarishUrl = void 0;
|
||||||
const hostnames = records.reduce((acc, record, recordIndex) => {
|
const hostnames = records.reduce((acc, record, recordIndex) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
|
if (recordIndex === records.length - 1) {
|
||||||
|
tovarishUrl = record;
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
@ -3400,10 +3434,12 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
isRegistered,
|
isRegistered,
|
||||||
owner,
|
owner,
|
||||||
stakeBalance: ethers.formatEther(stakeBalance),
|
stakeBalance: ethers.formatEther(stakeBalance),
|
||||||
hostnames
|
hostnames,
|
||||||
|
tovarishUrl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).filter((r) => r);
|
}).filter((r) => r);
|
||||||
|
yield getTovarishNetworks(this, relayers);
|
||||||
return {
|
return {
|
||||||
timestamp,
|
timestamp,
|
||||||
relayers
|
relayers
|
||||||
@ -6711,6 +6747,7 @@ exports.factories = index;
|
|||||||
exports.fetch = fetch;
|
exports.fetch = fetch;
|
||||||
exports.fetchData = fetchData;
|
exports.fetchData = fetchData;
|
||||||
exports.fetchGetUrlFunc = fetchGetUrlFunc;
|
exports.fetchGetUrlFunc = fetchGetUrlFunc;
|
||||||
|
exports.getActiveTokenInstances = getActiveTokenInstances;
|
||||||
exports.getActiveTokens = getActiveTokens;
|
exports.getActiveTokens = getActiveTokens;
|
||||||
exports.getAllDeposits = getAllDeposits;
|
exports.getAllDeposits = getAllDeposits;
|
||||||
exports.getAllEncryptedNotes = getAllEncryptedNotes;
|
exports.getAllEncryptedNotes = getAllEncryptedNotes;
|
||||||
@ -6736,6 +6773,7 @@ exports.getStatistic = getStatistic;
|
|||||||
exports.getStatusSchema = getStatusSchema;
|
exports.getStatusSchema = getStatusSchema;
|
||||||
exports.getSupportedInstances = getSupportedInstances;
|
exports.getSupportedInstances = getSupportedInstances;
|
||||||
exports.getTokenBalances = getTokenBalances;
|
exports.getTokenBalances = getTokenBalances;
|
||||||
|
exports.getTovarishNetworks = getTovarishNetworks;
|
||||||
exports.getWeightRandom = getWeightRandom;
|
exports.getWeightRandom = getWeightRandom;
|
||||||
exports.getWithdrawals = getWithdrawals;
|
exports.getWithdrawals = getWithdrawals;
|
||||||
exports.hexToBytes = hexToBytes;
|
exports.hexToBytes = hexToBytes;
|
||||||
|
68
dist/index.mjs
vendored
68
dist/index.mjs
vendored
@ -2347,6 +2347,15 @@ function getActiveTokens(config) {
|
|||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
|
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
|
||||||
}
|
}
|
||||||
|
function getActiveTokenInstances(config) {
|
||||||
|
const { tokens, disabledTokens } = config;
|
||||||
|
return Object.entries(tokens).reduce((acc, [token, instances]) => {
|
||||||
|
if (!(disabledTokens == null ? void 0 : disabledTokens.includes(token))) {
|
||||||
|
acc[token] = instances;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
function getInstanceByAddress(config, address) {
|
function getInstanceByAddress(config, address) {
|
||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
||||||
@ -2535,7 +2544,7 @@ var __async$9 = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
const MIN_FEE = 0.1;
|
const MIN_FEE = 0.1;
|
||||||
const MAX_FEE = 0.6;
|
const MAX_FEE = 0.9;
|
||||||
const MIN_STAKE_BALANCE = parseEther("500");
|
const MIN_STAKE_BALANCE = parseEther("500");
|
||||||
function calculateScore({ stakeBalance, tornadoServiceFee }) {
|
function calculateScore({ stakeBalance, tornadoServiceFee }) {
|
||||||
if (tornadoServiceFee < MIN_FEE) {
|
if (tornadoServiceFee < MIN_FEE) {
|
||||||
@ -2783,13 +2792,13 @@ class BaseEventsService {
|
|||||||
contract,
|
contract,
|
||||||
type = "",
|
type = "",
|
||||||
deployedBlock = 0,
|
deployedBlock = 0,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
this.netId = netId;
|
this.netId = netId;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.graphApi = graphApi;
|
this.graphApi = graphApi;
|
||||||
this.subgraphName = subgraphName;
|
this.subgraphName = subgraphName;
|
||||||
this.fetchDataOptions = fetchDataOptions;
|
this.fetchDataOptions = fetchDataOptions2;
|
||||||
this.contract = contract;
|
this.contract = contract;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.deployedBlock = deployedBlock;
|
this.deployedBlock = deployedBlock;
|
||||||
@ -2987,9 +2996,9 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
amount,
|
amount,
|
||||||
currency,
|
currency,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
this.batchTransactionService = new BatchTransactionService({
|
this.batchTransactionService = new BatchTransactionService({
|
||||||
@ -3083,9 +3092,9 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Echoer,
|
Echoer,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Echoer, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Echoer, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
}
|
}
|
||||||
getInstanceName() {
|
getInstanceName() {
|
||||||
return `echo_${this.netId}`;
|
return `echo_${this.netId}`;
|
||||||
@ -3134,9 +3143,9 @@ class BaseEncryptedNotesService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Router,
|
Router,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
}
|
}
|
||||||
getInstanceName() {
|
getInstanceName() {
|
||||||
return `encrypted_notes_${this.netId}`;
|
return `encrypted_notes_${this.netId}`;
|
||||||
@ -3173,9 +3182,9 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Governance,
|
Governance,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.batchTransactionService = new BatchTransactionService({
|
this.batchTransactionService = new BatchTransactionService({
|
||||||
provider,
|
provider,
|
||||||
onProgress: this.updateTransactionProgress
|
onProgress: this.updateTransactionProgress
|
||||||
@ -3269,6 +3278,26 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function getTovarishNetworks(registryService, relayers) {
|
||||||
|
return __async$8(this, null, function* () {
|
||||||
|
yield Promise.all(
|
||||||
|
relayers.filter((r) => r.tovarishUrl).map((relayer) => __async$8(this, null, function* () {
|
||||||
|
var _a, _b;
|
||||||
|
try {
|
||||||
|
relayer.tovarishNetworks = yield fetchData(relayer.tovarishUrl, __spreadProps(__spreadValues({}, registryService.fetchDataOptions), {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
timeout: ((_a = registryService.fetchDataOptions) == null ? void 0 : _a.torPort) ? 1e4 : 3e3,
|
||||||
|
maxRetry: ((_b = registryService.fetchDataOptions) == null ? void 0 : _b.torPort) ? 2 : 0
|
||||||
|
}));
|
||||||
|
} catch (e) {
|
||||||
|
relayer.tovarishNetworks = [];
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
class BaseRegistryService extends BaseEventsService {
|
class BaseRegistryService extends BaseEventsService {
|
||||||
constructor({
|
constructor({
|
||||||
netId,
|
netId,
|
||||||
@ -3279,9 +3308,9 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
Aggregator,
|
Aggregator,
|
||||||
relayerEnsSubdomains,
|
relayerEnsSubdomains,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.Aggregator = Aggregator;
|
this.Aggregator = Aggregator;
|
||||||
this.relayerEnsSubdomains = relayerEnsSubdomains;
|
this.relayerEnsSubdomains = relayerEnsSubdomains;
|
||||||
this.updateInterval = 86400;
|
this.updateInterval = 86400;
|
||||||
@ -3358,13 +3387,18 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
const relayerNameHashes = uniqueRegisters.map((r) => namehash(r.ensName));
|
const relayerNameHashes = uniqueRegisters.map((r) => namehash(r.ensName));
|
||||||
const [relayersData, timestamp] = yield Promise.all([
|
const [relayersData, timestamp] = yield Promise.all([
|
||||||
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains),
|
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains.concat("tovarish-relayer")),
|
||||||
this.provider.getBlock("latest").then((b) => Number(b == null ? void 0 : b.timestamp))
|
this.provider.getBlock("latest").then((b) => Number(b == null ? void 0 : b.timestamp))
|
||||||
]);
|
]);
|
||||||
const relayers = relayersData.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
const relayers = relayersData.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
||||||
const { ensName, relayerAddress } = uniqueRegisters[index];
|
const { ensName, relayerAddress } = uniqueRegisters[index];
|
||||||
|
let tovarishUrl = void 0;
|
||||||
const hostnames = records.reduce((acc, record, recordIndex) => {
|
const hostnames = records.reduce((acc, record, recordIndex) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
|
if (recordIndex === records.length - 1) {
|
||||||
|
tovarishUrl = record;
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
@ -3379,10 +3413,12 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
isRegistered,
|
isRegistered,
|
||||||
owner,
|
owner,
|
||||||
stakeBalance: formatEther(stakeBalance),
|
stakeBalance: formatEther(stakeBalance),
|
||||||
hostnames
|
hostnames,
|
||||||
|
tovarishUrl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).filter((r) => r);
|
}).filter((r) => r);
|
||||||
|
yield getTovarishNetworks(this, relayers);
|
||||||
return {
|
return {
|
||||||
timestamp,
|
timestamp,
|
||||||
relayers
|
relayers
|
||||||
@ -6621,4 +6657,4 @@ function calculateSnarkProof(input, circuit, provingKey) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, Invoice, MAX_FEE, MIN_FEE, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, digest, enabledChains, index as factories, fetch, fetchData, fetchGetUrlFunc, getActiveTokens, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSupportedInstances, getTokenBalances, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, validateUrl };
|
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, Invoice, MAX_FEE, MIN_FEE, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, digest, enabledChains, index as factories, fetch, fetchData, fetchGetUrlFunc, getActiveTokenInstances, getActiveTokens, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSupportedInstances, getTokenBalances, getTovarishNetworks, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, validateUrl };
|
||||||
|
1
dist/networkConfig.d.ts
vendored
1
dist/networkConfig.d.ts
vendored
@ -109,6 +109,7 @@ export declare function addNetwork(newConfig: networkConfig): void;
|
|||||||
export declare function getNetworkConfig(): networkConfig;
|
export declare function getNetworkConfig(): networkConfig;
|
||||||
export declare function getConfig(netId: NetIdType): Config;
|
export declare function getConfig(netId: NetIdType): Config;
|
||||||
export declare function getActiveTokens(config: Config): string[];
|
export declare function getActiveTokens(config: Config): string[];
|
||||||
|
export declare function getActiveTokenInstances(config: Config): TokenInstances;
|
||||||
export declare function getInstanceByAddress(config: Config, address: string): {
|
export declare function getInstanceByAddress(config: Config, address: string): {
|
||||||
amount: string;
|
amount: string;
|
||||||
currency: string;
|
currency: string;
|
||||||
|
10
dist/relayerClient.d.ts
vendored
10
dist/relayerClient.d.ts
vendored
@ -3,7 +3,7 @@ import { fetchDataOptions } from './providers';
|
|||||||
import type { snarkProofs } from './websnark';
|
import type { snarkProofs } from './websnark';
|
||||||
import { CachedRelayerInfo } from './events/base';
|
import { CachedRelayerInfo } from './events/base';
|
||||||
export declare const MIN_FEE = 0.1;
|
export declare const MIN_FEE = 0.1;
|
||||||
export declare const MAX_FEE = 0.6;
|
export declare const MAX_FEE = 0.9;
|
||||||
export declare const MIN_STAKE_BALANCE: bigint;
|
export declare const MIN_STAKE_BALANCE: bigint;
|
||||||
export interface RelayerParams {
|
export interface RelayerParams {
|
||||||
ensName: string;
|
ensName: string;
|
||||||
@ -63,6 +63,9 @@ export interface RelayerStatus {
|
|||||||
};
|
};
|
||||||
currentQueue: number;
|
currentQueue: number;
|
||||||
}
|
}
|
||||||
|
export type TornadoWithdrawParams = snarkProofs & {
|
||||||
|
contract: string;
|
||||||
|
};
|
||||||
export interface RelayerTornadoWithdraw {
|
export interface RelayerTornadoWithdraw {
|
||||||
id?: string;
|
id?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
@ -122,9 +125,6 @@ export interface RelayerClientConstructor {
|
|||||||
config: Config;
|
config: Config;
|
||||||
fetchDataOptions?: fetchDataOptions;
|
fetchDataOptions?: fetchDataOptions;
|
||||||
}
|
}
|
||||||
export type RelayerClientWithdraw = snarkProofs & {
|
|
||||||
contract: string;
|
|
||||||
};
|
|
||||||
export declare class RelayerClient {
|
export declare class RelayerClient {
|
||||||
netId: NetIdType;
|
netId: NetIdType;
|
||||||
config: Config;
|
config: Config;
|
||||||
@ -141,5 +141,5 @@ export declare class RelayerClient {
|
|||||||
invalidRelayers: RelayerError[];
|
invalidRelayers: RelayerError[];
|
||||||
}>;
|
}>;
|
||||||
pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
|
pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo;
|
||||||
tornadoWithdraw({ contract, proof, args }: RelayerClientWithdraw): Promise<void>;
|
tornadoWithdraw({ contract, proof, args }: TornadoWithdrawParams): Promise<void>;
|
||||||
}
|
}
|
||||||
|
90
dist/tornado.umd.js
vendored
90
dist/tornado.umd.js
vendored
@ -59060,6 +59060,7 @@ class NoteAccount {
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ EU: () => (/* binding */ getTovarishNetworks),
|
||||||
/* harmony export */ GS: () => (/* binding */ BaseEchoService),
|
/* harmony export */ GS: () => (/* binding */ BaseEchoService),
|
||||||
/* harmony export */ JJ: () => (/* binding */ BaseGovernanceService),
|
/* harmony export */ JJ: () => (/* binding */ BaseGovernanceService),
|
||||||
/* harmony export */ Lx: () => (/* binding */ DEPOSIT),
|
/* harmony export */ Lx: () => (/* binding */ DEPOSIT),
|
||||||
@ -59069,12 +59070,13 @@ class NoteAccount {
|
|||||||
/* harmony export */ oW: () => (/* binding */ WITHDRAWAL),
|
/* harmony export */ oW: () => (/* binding */ WITHDRAWAL),
|
||||||
/* harmony export */ uw: () => (/* binding */ BaseEventsService)
|
/* harmony export */ uw: () => (/* binding */ BaseEventsService)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(30031);
|
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(30031);
|
||||||
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(64563);
|
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(64563);
|
||||||
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(99770);
|
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(99770);
|
||||||
/* harmony import */ var _graphql__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(52049);
|
/* harmony import */ var _graphql__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(52049);
|
||||||
/* harmony import */ var _batch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9723);
|
/* harmony import */ var _batch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9723);
|
||||||
/* harmony import */ var _relayerClient__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(57194);
|
/* harmony import */ var _providers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(68434);
|
||||||
|
/* harmony import */ var _relayerClient__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(57194);
|
||||||
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __defProps = Object.defineProperties;
|
var __defProps = Object.defineProperties;
|
||||||
@ -59122,6 +59124,7 @@ var __async = (__this, __arguments, generator) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const DEPOSIT = "deposit";
|
const DEPOSIT = "deposit";
|
||||||
const WITHDRAWAL = "withdrawal";
|
const WITHDRAWAL = "withdrawal";
|
||||||
class BaseEventsService {
|
class BaseEventsService {
|
||||||
@ -59133,13 +59136,13 @@ class BaseEventsService {
|
|||||||
contract,
|
contract,
|
||||||
type = "",
|
type = "",
|
||||||
deployedBlock = 0,
|
deployedBlock = 0,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
this.netId = netId;
|
this.netId = netId;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.graphApi = graphApi;
|
this.graphApi = graphApi;
|
||||||
this.subgraphName = subgraphName;
|
this.subgraphName = subgraphName;
|
||||||
this.fetchDataOptions = fetchDataOptions;
|
this.fetchDataOptions = fetchDataOptions2;
|
||||||
this.contract = contract;
|
this.contract = contract;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.deployedBlock = deployedBlock;
|
this.deployedBlock = deployedBlock;
|
||||||
@ -59337,9 +59340,9 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
amount,
|
amount,
|
||||||
currency,
|
currency,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
this.batchTransactionService = new _batch__WEBPACK_IMPORTED_MODULE_1__/* .BatchTransactionService */ .AF({
|
this.batchTransactionService = new _batch__WEBPACK_IMPORTED_MODULE_1__/* .BatchTransactionService */ .AF({
|
||||||
@ -59399,7 +59402,7 @@ class BaseTornadoService extends BaseEventsService {
|
|||||||
logIndex,
|
logIndex,
|
||||||
transactionHash,
|
transactionHash,
|
||||||
nullifierHash: String(nullifierHash),
|
nullifierHash: String(nullifierHash),
|
||||||
to: (0,ethers__WEBPACK_IMPORTED_MODULE_3__/* .getAddress */ .b)(to),
|
to: (0,ethers__WEBPACK_IMPORTED_MODULE_4__/* .getAddress */ .b)(to),
|
||||||
fee: String(fee)
|
fee: String(fee)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -59433,9 +59436,9 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Echoer,
|
Echoer,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Echoer, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Echoer, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
}
|
}
|
||||||
getInstanceName() {
|
getInstanceName() {
|
||||||
return `echo_${this.netId}`;
|
return `echo_${this.netId}`;
|
||||||
@ -59484,9 +59487,9 @@ class BaseEncryptedNotesService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Router,
|
Router,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
}
|
}
|
||||||
getInstanceName() {
|
getInstanceName() {
|
||||||
return `encrypted_notes_${this.netId}`;
|
return `encrypted_notes_${this.netId}`;
|
||||||
@ -59523,9 +59526,9 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
subgraphName,
|
subgraphName,
|
||||||
Governance,
|
Governance,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.batchTransactionService = new _batch__WEBPACK_IMPORTED_MODULE_1__/* .BatchTransactionService */ .AF({
|
this.batchTransactionService = new _batch__WEBPACK_IMPORTED_MODULE_1__/* .BatchTransactionService */ .AF({
|
||||||
provider,
|
provider,
|
||||||
onProgress: this.updateTransactionProgress
|
onProgress: this.updateTransactionProgress
|
||||||
@ -59619,6 +59622,26 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function getTovarishNetworks(registryService, relayers) {
|
||||||
|
return __async(this, null, function* () {
|
||||||
|
yield Promise.all(
|
||||||
|
relayers.filter((r) => r.tovarishUrl).map((relayer) => __async(this, null, function* () {
|
||||||
|
var _a, _b;
|
||||||
|
try {
|
||||||
|
relayer.tovarishNetworks = yield (0,_providers__WEBPACK_IMPORTED_MODULE_2__/* .fetchData */ .Fd)(relayer.tovarishUrl, __spreadProps(__spreadValues({}, registryService.fetchDataOptions), {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
timeout: ((_a = registryService.fetchDataOptions) == null ? void 0 : _a.torPort) ? 1e4 : 3e3,
|
||||||
|
maxRetry: ((_b = registryService.fetchDataOptions) == null ? void 0 : _b.torPort) ? 2 : 0
|
||||||
|
}));
|
||||||
|
} catch (e) {
|
||||||
|
relayer.tovarishNetworks = [];
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
class BaseRegistryService extends BaseEventsService {
|
class BaseRegistryService extends BaseEventsService {
|
||||||
constructor({
|
constructor({
|
||||||
netId,
|
netId,
|
||||||
@ -59629,9 +59652,9 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
Aggregator,
|
Aggregator,
|
||||||
relayerEnsSubdomains,
|
relayerEnsSubdomains,
|
||||||
deployedBlock,
|
deployedBlock,
|
||||||
fetchDataOptions
|
fetchDataOptions: fetchDataOptions2
|
||||||
}) {
|
}) {
|
||||||
super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions });
|
super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions: fetchDataOptions2 });
|
||||||
this.Aggregator = Aggregator;
|
this.Aggregator = Aggregator;
|
||||||
this.relayerEnsSubdomains = relayerEnsSubdomains;
|
this.relayerEnsSubdomains = relayerEnsSubdomains;
|
||||||
this.updateInterval = 86400;
|
this.updateInterval = 86400;
|
||||||
@ -59706,21 +59729,26 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
const relayerNameHashes = uniqueRegisters.map((r) => (0,ethers__WEBPACK_IMPORTED_MODULE_4__/* .namehash */ .kM)(r.ensName));
|
const relayerNameHashes = uniqueRegisters.map((r) => (0,ethers__WEBPACK_IMPORTED_MODULE_5__/* .namehash */ .kM)(r.ensName));
|
||||||
const [relayersData, timestamp] = yield Promise.all([
|
const [relayersData, timestamp] = yield Promise.all([
|
||||||
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains),
|
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains.concat("tovarish-relayer")),
|
||||||
this.provider.getBlock("latest").then((b) => Number(b == null ? void 0 : b.timestamp))
|
this.provider.getBlock("latest").then((b) => Number(b == null ? void 0 : b.timestamp))
|
||||||
]);
|
]);
|
||||||
const relayers = relayersData.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
const relayers = relayersData.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
||||||
const { ensName, relayerAddress } = uniqueRegisters[index];
|
const { ensName, relayerAddress } = uniqueRegisters[index];
|
||||||
|
let tovarishUrl = void 0;
|
||||||
const hostnames = records.reduce((acc, record, recordIndex) => {
|
const hostnames = records.reduce((acc, record, recordIndex) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
|
if (recordIndex === records.length - 1) {
|
||||||
|
tovarishUrl = record;
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
const isOwner = !relayerAddress || relayerAddress === owner;
|
const isOwner = !relayerAddress || relayerAddress === owner;
|
||||||
const hasMinBalance = stakeBalance >= _relayerClient__WEBPACK_IMPORTED_MODULE_2__/* .MIN_STAKE_BALANCE */ .pO;
|
const hasMinBalance = stakeBalance >= _relayerClient__WEBPACK_IMPORTED_MODULE_3__/* .MIN_STAKE_BALANCE */ .pO;
|
||||||
const preCondition = Object.keys(hostnames).length && isOwner && isRegistered && hasMinBalance;
|
const preCondition = Object.keys(hostnames).length && isOwner && isRegistered && hasMinBalance;
|
||||||
if (preCondition) {
|
if (preCondition) {
|
||||||
return {
|
return {
|
||||||
@ -59728,11 +59756,13 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
relayerAddress,
|
relayerAddress,
|
||||||
isRegistered,
|
isRegistered,
|
||||||
owner,
|
owner,
|
||||||
stakeBalance: (0,ethers__WEBPACK_IMPORTED_MODULE_5__/* .formatEther */ .ck)(stakeBalance),
|
stakeBalance: (0,ethers__WEBPACK_IMPORTED_MODULE_6__/* .formatEther */ .ck)(stakeBalance),
|
||||||
hostnames
|
hostnames,
|
||||||
|
tovarishUrl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}).filter((r) => r);
|
}).filter((r) => r);
|
||||||
|
yield getTovarishNetworks(this, relayers);
|
||||||
return {
|
return {
|
||||||
timestamp,
|
timestamp,
|
||||||
relayers
|
relayers
|
||||||
@ -59783,7 +59813,8 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ BaseRegistryService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.cE),
|
/* harmony export */ BaseRegistryService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.cE),
|
||||||
/* harmony export */ BaseTornadoService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.e0),
|
/* harmony export */ BaseTornadoService: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.e0),
|
||||||
/* harmony export */ DEPOSIT: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.Lx),
|
/* harmony export */ DEPOSIT: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.Lx),
|
||||||
/* harmony export */ WITHDRAWAL: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.oW)
|
/* harmony export */ WITHDRAWAL: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.oW),
|
||||||
|
/* harmony export */ getTovarishNetworks: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_1__.EU)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(61060);
|
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(61060);
|
||||||
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_0__);
|
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
@ -61234,6 +61265,7 @@ function multicall(Multicall2, calls) {
|
|||||||
/* harmony export */ cX: () => (/* binding */ customConfig),
|
/* harmony export */ cX: () => (/* binding */ customConfig),
|
||||||
/* harmony export */ h9: () => (/* binding */ getActiveTokens),
|
/* harmony export */ h9: () => (/* binding */ getActiveTokens),
|
||||||
/* harmony export */ o2: () => (/* binding */ getRelayerEnsSubdomains),
|
/* harmony export */ o2: () => (/* binding */ getRelayerEnsSubdomains),
|
||||||
|
/* harmony export */ oY: () => (/* binding */ getActiveTokenInstances),
|
||||||
/* harmony export */ sb: () => (/* binding */ defaultConfig),
|
/* harmony export */ sb: () => (/* binding */ defaultConfig),
|
||||||
/* harmony export */ zj: () => (/* binding */ getConfig),
|
/* harmony export */ zj: () => (/* binding */ getConfig),
|
||||||
/* harmony export */ zr: () => (/* binding */ NetId)
|
/* harmony export */ zr: () => (/* binding */ NetId)
|
||||||
@ -61857,6 +61889,15 @@ function getActiveTokens(config) {
|
|||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
|
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
|
||||||
}
|
}
|
||||||
|
function getActiveTokenInstances(config) {
|
||||||
|
const { tokens, disabledTokens } = config;
|
||||||
|
return Object.entries(tokens).reduce((acc, [token, instances]) => {
|
||||||
|
if (!(disabledTokens == null ? void 0 : disabledTokens.includes(token))) {
|
||||||
|
acc[token] = instances;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
function getInstanceByAddress(config, address) {
|
function getInstanceByAddress(config, address) {
|
||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
|
||||||
@ -71479,7 +71520,7 @@ var __async = (__this, __arguments, generator) => {
|
|||||||
|
|
||||||
|
|
||||||
const MIN_FEE = 0.1;
|
const MIN_FEE = 0.1;
|
||||||
const MAX_FEE = 0.6;
|
const MAX_FEE = 0.9;
|
||||||
const MIN_STAKE_BALANCE = (0,ethers__WEBPACK_IMPORTED_MODULE_4__/* .parseEther */ .g5)("500");
|
const MIN_STAKE_BALANCE = (0,ethers__WEBPACK_IMPORTED_MODULE_4__/* .parseEther */ .g5)("500");
|
||||||
function calculateScore({ stakeBalance, tornadoServiceFee }) {
|
function calculateScore({ stakeBalance, tornadoServiceFee }) {
|
||||||
if (tornadoServiceFee < MIN_FEE) {
|
if (tornadoServiceFee < MIN_FEE) {
|
||||||
@ -173028,6 +173069,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ fetch: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.hd),
|
/* harmony export */ fetch: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.hd),
|
||||||
/* harmony export */ fetchData: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.Fd),
|
/* harmony export */ fetchData: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.Fd),
|
||||||
/* harmony export */ fetchGetUrlFunc: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.uY),
|
/* harmony export */ fetchGetUrlFunc: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.uY),
|
||||||
|
/* harmony export */ getActiveTokenInstances: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.oY),
|
||||||
/* harmony export */ getActiveTokens: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.h9),
|
/* harmony export */ getActiveTokens: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.h9),
|
||||||
/* harmony export */ getAllDeposits: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllDeposits),
|
/* harmony export */ getAllDeposits: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllDeposits),
|
||||||
/* harmony export */ getAllEncryptedNotes: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllEncryptedNotes),
|
/* harmony export */ getAllEncryptedNotes: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllEncryptedNotes),
|
||||||
|
2
dist/tornado.umd.min.js
vendored
2
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
17
dist/websnark.d.ts
vendored
17
dist/websnark.d.ts
vendored
@ -1,10 +1,9 @@
|
|||||||
import type { Element } from '@tornado/fixed-merkle-tree';
|
import type { Element } from '@tornado/fixed-merkle-tree';
|
||||||
import type { AddressLike, BytesLike, BigNumberish } from 'ethers';
|
|
||||||
export type snarkInputs = {
|
export type snarkInputs = {
|
||||||
root: Element;
|
root: Element;
|
||||||
nullifierHex: string;
|
nullifierHex: string;
|
||||||
recipient: AddressLike;
|
recipient: string;
|
||||||
relayer: AddressLike;
|
relayer: string;
|
||||||
fee: bigint;
|
fee: bigint;
|
||||||
refund: bigint;
|
refund: bigint;
|
||||||
nullifier: bigint;
|
nullifier: bigint;
|
||||||
@ -12,17 +11,9 @@ export type snarkInputs = {
|
|||||||
pathElements: Element[];
|
pathElements: Element[];
|
||||||
pathIndices: Element[];
|
pathIndices: Element[];
|
||||||
};
|
};
|
||||||
export type snarkArgs = [
|
|
||||||
_root: BytesLike,
|
|
||||||
_nullifierHash: BytesLike,
|
|
||||||
_recipient: AddressLike,
|
|
||||||
_relayer: AddressLike,
|
|
||||||
_fee: BigNumberish,
|
|
||||||
_refund: BigNumberish
|
|
||||||
];
|
|
||||||
export type snarkProofs = {
|
export type snarkProofs = {
|
||||||
proof: BytesLike;
|
proof: string;
|
||||||
args: snarkArgs;
|
args: string[];
|
||||||
};
|
};
|
||||||
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>;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tornado/core",
|
"name": "@tornado/core",
|
||||||
"version": "1.0.14",
|
"version": "1.0.15",
|
||||||
"description": "An SDK for building applications on top of Privacy Pools",
|
"description": "An SDK for building applications on top of Privacy Pools",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
|
@ -30,7 +30,7 @@ import {
|
|||||||
BatchBlockOnProgress,
|
BatchBlockOnProgress,
|
||||||
} from '../batch';
|
} from '../batch';
|
||||||
|
|
||||||
import type { fetchDataOptions } from '../providers';
|
import { fetchData, fetchDataOptions } from '../providers';
|
||||||
import type { NetIdType, SubdomainMap } from '../networkConfig';
|
import type { NetIdType, SubdomainMap } from '../networkConfig';
|
||||||
import { RelayerParams, MIN_STAKE_BALANCE } from '../relayerClient';
|
import { RelayerParams, MIN_STAKE_BALANCE } from '../relayerClient';
|
||||||
|
|
||||||
@ -734,6 +734,28 @@ export class BaseGovernanceService extends BaseEventsService<AllGovernanceEvents
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getTovarishNetworks(registryService: BaseRegistryService, relayers: CachedRelayerInfo[]) {
|
||||||
|
await Promise.all(
|
||||||
|
relayers
|
||||||
|
.filter((r) => r.tovarishUrl)
|
||||||
|
.map(async (relayer) => {
|
||||||
|
try {
|
||||||
|
relayer.tovarishNetworks = await fetchData(relayer.tovarishUrl as string, {
|
||||||
|
...registryService.fetchDataOptions,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
timeout: registryService.fetchDataOptions?.torPort ? 10000 : 3000,
|
||||||
|
maxRetry: registryService.fetchDataOptions?.torPort ? 2 : 0,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// Ignore error and disable relayer
|
||||||
|
relayer.tovarishNetworks = [];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Essential params:
|
* Essential params:
|
||||||
* ensName, relayerAddress, hostnames
|
* ensName, relayerAddress, hostnames
|
||||||
@ -744,6 +766,8 @@ export interface CachedRelayerInfo extends RelayerParams {
|
|||||||
owner?: string;
|
owner?: string;
|
||||||
stakeBalance?: string;
|
stakeBalance?: string;
|
||||||
hostnames: SubdomainMap;
|
hostnames: SubdomainMap;
|
||||||
|
tovarishUrl?: string;
|
||||||
|
tovarishNetworks?: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CachedRelayers {
|
export interface CachedRelayers {
|
||||||
@ -867,7 +891,7 @@ export class BaseRegistryService extends BaseEventsService<RegistersEvents> {
|
|||||||
const relayerNameHashes = uniqueRegisters.map((r) => namehash(r.ensName));
|
const relayerNameHashes = uniqueRegisters.map((r) => namehash(r.ensName));
|
||||||
|
|
||||||
const [relayersData, timestamp] = await Promise.all([
|
const [relayersData, timestamp] = await Promise.all([
|
||||||
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains),
|
this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains.concat('tovarish-relayer')),
|
||||||
this.provider.getBlock('latest').then((b) => Number(b?.timestamp)),
|
this.provider.getBlock('latest').then((b) => Number(b?.timestamp)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -875,8 +899,16 @@ export class BaseRegistryService extends BaseEventsService<RegistersEvents> {
|
|||||||
.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
.map(({ owner, balance: stakeBalance, records, isRegistered }, index) => {
|
||||||
const { ensName, relayerAddress } = uniqueRegisters[index];
|
const { ensName, relayerAddress } = uniqueRegisters[index];
|
||||||
|
|
||||||
|
let tovarishUrl = undefined;
|
||||||
|
|
||||||
const hostnames = records.reduce((acc, record, recordIndex) => {
|
const hostnames = records.reduce((acc, record, recordIndex) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
|
// tovarish-relayer.relayer.eth
|
||||||
|
if (recordIndex === records.length - 1) {
|
||||||
|
tovarishUrl = record;
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
acc[Number(Object.keys(this.relayerEnsSubdomains)[recordIndex])] = record;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
@ -895,11 +927,14 @@ export class BaseRegistryService extends BaseEventsService<RegistersEvents> {
|
|||||||
owner,
|
owner,
|
||||||
stakeBalance: formatEther(stakeBalance),
|
stakeBalance: formatEther(stakeBalance),
|
||||||
hostnames,
|
hostnames,
|
||||||
|
tovarishUrl,
|
||||||
} as CachedRelayerInfo;
|
} as CachedRelayerInfo;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter((r) => r) as CachedRelayerInfo[];
|
.filter((r) => r) as CachedRelayerInfo[];
|
||||||
|
|
||||||
|
await getTovarishNetworks(this, relayers);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
timestamp,
|
timestamp,
|
||||||
relayers,
|
relayers,
|
||||||
|
@ -725,12 +725,23 @@ export function getConfig(netId: NetIdType) {
|
|||||||
return chainConfig;
|
return chainConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getActiveTokens(config: Config) {
|
export function getActiveTokens(config: Config): string[] {
|
||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
|
|
||||||
return Object.keys(tokens).filter((t) => !disabledTokens?.includes(t));
|
return Object.keys(tokens).filter((t) => !disabledTokens?.includes(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getActiveTokenInstances(config: Config): TokenInstances {
|
||||||
|
const { tokens, disabledTokens } = config;
|
||||||
|
|
||||||
|
return Object.entries(tokens).reduce((acc, [token, instances]) => {
|
||||||
|
if (!disabledTokens?.includes(token)) {
|
||||||
|
acc[token] = instances;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {} as TokenInstances);
|
||||||
|
}
|
||||||
|
|
||||||
export function getInstanceByAddress(config: Config, address: string) {
|
export function getInstanceByAddress(config: Config, address: string) {
|
||||||
const { tokens, disabledTokens } = config;
|
const { tokens, disabledTokens } = config;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import { CachedRelayerInfo } from './events/base';
|
|||||||
|
|
||||||
export const MIN_FEE = 0.1;
|
export const MIN_FEE = 0.1;
|
||||||
|
|
||||||
export const MAX_FEE = 0.6;
|
export const MAX_FEE = 0.9;
|
||||||
|
|
||||||
export const MIN_STAKE_BALANCE = parseEther('500');
|
export const MIN_STAKE_BALANCE = parseEther('500');
|
||||||
|
|
||||||
@ -75,6 +75,10 @@ export interface RelayerStatus {
|
|||||||
currentQueue: number;
|
currentQueue: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TornadoWithdrawParams = snarkProofs & {
|
||||||
|
contract: string;
|
||||||
|
};
|
||||||
|
|
||||||
export interface RelayerTornadoWithdraw {
|
export interface RelayerTornadoWithdraw {
|
||||||
id?: string;
|
id?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
@ -181,10 +185,6 @@ export interface RelayerClientConstructor {
|
|||||||
fetchDataOptions?: fetchDataOptions;
|
fetchDataOptions?: fetchDataOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RelayerClientWithdraw = snarkProofs & {
|
|
||||||
contract: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class RelayerClient {
|
export class RelayerClient {
|
||||||
netId: NetIdType;
|
netId: NetIdType;
|
||||||
config: Config;
|
config: Config;
|
||||||
@ -304,7 +304,7 @@ export class RelayerClient {
|
|||||||
return pickWeightedRandomRelayer(relayers);
|
return pickWeightedRandomRelayer(relayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tornadoWithdraw({ contract, proof, args }: RelayerClientWithdraw) {
|
async tornadoWithdraw({ contract, proof, args }: TornadoWithdrawParams) {
|
||||||
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`, {
|
||||||
|
@ -3,15 +3,14 @@ import * as websnarkUtils from '@tornado/websnark/src/utils';
|
|||||||
// @ts-expect-error no-websnark-types
|
// @ts-expect-error no-websnark-types
|
||||||
import websnarkGroth from '@tornado/websnark/src/groth16';
|
import websnarkGroth from '@tornado/websnark/src/groth16';
|
||||||
import type { Element } from '@tornado/fixed-merkle-tree';
|
import type { Element } from '@tornado/fixed-merkle-tree';
|
||||||
import type { AddressLike, BytesLike, BigNumberish } from 'ethers';
|
|
||||||
import { toFixedHex } from './utils';
|
import { toFixedHex } from './utils';
|
||||||
|
|
||||||
export type snarkInputs = {
|
export type snarkInputs = {
|
||||||
// Public snark inputs
|
// Public snark inputs
|
||||||
root: Element;
|
root: Element;
|
||||||
nullifierHex: string;
|
nullifierHex: string;
|
||||||
recipient: AddressLike;
|
recipient: string;
|
||||||
relayer: AddressLike;
|
relayer: string;
|
||||||
fee: bigint;
|
fee: bigint;
|
||||||
refund: bigint;
|
refund: bigint;
|
||||||
|
|
||||||
@ -22,18 +21,9 @@ export type snarkInputs = {
|
|||||||
pathIndices: Element[];
|
pathIndices: Element[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type snarkArgs = [
|
|
||||||
_root: BytesLike,
|
|
||||||
_nullifierHash: BytesLike,
|
|
||||||
_recipient: AddressLike,
|
|
||||||
_relayer: AddressLike,
|
|
||||||
_fee: BigNumberish,
|
|
||||||
_refund: BigNumberish,
|
|
||||||
];
|
|
||||||
|
|
||||||
export type snarkProofs = {
|
export type snarkProofs = {
|
||||||
proof: BytesLike;
|
proof: string;
|
||||||
args: snarkArgs;
|
args: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -71,17 +61,17 @@ export async function calculateSnarkProof(
|
|||||||
console.log('Start generating SNARK proof', snarkInput);
|
console.log('Start generating SNARK proof', snarkInput);
|
||||||
console.time('SNARK proof time');
|
console.time('SNARK proof time');
|
||||||
const proofData = await websnarkUtils.genWitnessAndProve(await groth16, snarkInput, circuit, provingKey);
|
const proofData = await websnarkUtils.genWitnessAndProve(await groth16, snarkInput, circuit, provingKey);
|
||||||
const proof = websnarkUtils.toSolidityInput(proofData).proof as BytesLike;
|
const proof = websnarkUtils.toSolidityInput(proofData).proof;
|
||||||
console.timeEnd('SNARK proof time');
|
console.timeEnd('SNARK proof time');
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
toFixedHex(input.root, 32) as BytesLike,
|
toFixedHex(input.root, 32),
|
||||||
toFixedHex(input.nullifierHex, 32) as BytesLike,
|
toFixedHex(input.nullifierHex, 32),
|
||||||
input.recipient,
|
input.recipient,
|
||||||
input.relayer,
|
input.relayer,
|
||||||
toFixedHex(input.fee, 32) as BigNumberish,
|
toFixedHex(input.fee, 32),
|
||||||
toFixedHex(input.refund, 32) as BigNumberish,
|
toFixedHex(input.refund, 32),
|
||||||
] as snarkArgs;
|
];
|
||||||
|
|
||||||
return { proof, args };
|
return { proof, args };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user