Minor updates #1

Closed
tornadocontrib wants to merge 67 commits from tornadocontrib/tornado-core:main into main
10 changed files with 91 additions and 107 deletions
Showing only changes of commit f7fdf7db0a - Show all commits

40
dist/index.js vendored

@ -1905,6 +1905,8 @@ const defaultConfig = {
gasLimit: 7e5
}
},
// Inactive tokens to filter from schema verification and syncing events
disabledTokens: ["cdai", "usdt", "usdc"],
relayerEnsSubdomain: "mainnet-tornado",
pollInterval: 15,
constants: {
@ -2362,9 +2364,16 @@ function getConfig(netId) {
}
return chainConfig;
}
function getInstanceByAddress({ netId, address }) {
const { tokens } = getConfig(netId);
function getActiveTokens(config) {
const { tokens, disabledTokens } = config;
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
}
function getInstanceByAddress(config, address) {
const { tokens, disabledTokens } = config;
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
if (disabledTokens == null ? void 0 : disabledTokens.includes(currency)) {
continue;
}
for (const [amount, instance] of Object.entries(instanceAddress)) {
if (instance === address) {
return {
@ -2375,10 +2384,6 @@ function getInstanceByAddress({ netId, address }) {
}
}
}
function getSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.map((chain) => allConfig[chain].relayerEnsSubdomain);
}
function getRelayerEnsSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.reduce((acc, chain) => {
@ -2418,7 +2423,7 @@ const statusSchema = {
required: ["rewardAccount", "instances", "netId", "tornadoServiceFee", "version", "health"]
};
function getStatusSchema(netId, config) {
const { tokens, optionalTokens = [], nativeCurrency } = config;
const { tokens, optionalTokens, disabledTokens, nativeCurrency } = config;
const schema = JSON.parse(JSON.stringify(statusSchema));
const instances = Object.keys(tokens).reduce(
(acc, token) => {
@ -2449,7 +2454,7 @@ function getStatusSchema(netId, config) {
instanceProperties.properties.symbol = { enum: [symbol] };
}
acc.properties[token] = instanceProperties;
if (!optionalTokens.includes(token)) {
if (!(optionalTokens == null ? void 0 : optionalTokens.includes(token)) && !(disabledTokens == null ? void 0 : disabledTokens.includes(token))) {
acc.required.push(token);
}
return acc;
@ -2553,18 +2558,6 @@ var __async$9 = (__this, __arguments, generator) => {
const MIN_FEE = 0.1;
const MAX_FEE = 0.6;
const MIN_STAKE_BALANCE = ethers.parseEther("500");
const semVerRegex = new RegExp("^(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)\\.(?<patch>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
function parseSemanticVersion(version) {
const { groups } = semVerRegex.exec(version);
return groups;
}
function isRelayerUpdated(relayerVersion, netId) {
const { major, patch, prerelease } = parseSemanticVersion(relayerVersion);
const requiredMajor = netId === NetId.MAINNET ? "4" : "5";
const isUpdatedMajor = major === requiredMajor;
if (prerelease) return false;
return isUpdatedMajor && (Number(patch) >= 5 || netId !== NetId.MAINNET);
}
function calculateScore({ stakeBalance, tornadoServiceFee }) {
if (tornadoServiceFee < MIN_FEE) {
tornadoServiceFee = MIN_FEE;
@ -2636,9 +2629,6 @@ class RelayerClient {
if (relayerAddress && this.netId === NetId.MAINNET && status.rewardAccount !== relayerAddress) {
throw new Error("The Relayer reward address must match registered address");
}
if (!isRelayerUpdated(status.version, this.netId)) {
throw new Error("Outdated version.");
}
return status;
});
}
@ -6721,6 +6711,7 @@ exports.factories = index;
exports.fetch = fetch;
exports.fetchData = fetchData;
exports.fetchGetUrlFunc = fetchGetUrlFunc;
exports.getActiveTokens = getActiveTokens;
exports.getAllDeposits = getAllDeposits;
exports.getAllEncryptedNotes = getAllEncryptedNotes;
exports.getAllGovernanceEvents = getAllGovernanceEvents;
@ -6743,7 +6734,6 @@ exports.getRegisters = getRegisters;
exports.getRelayerEnsSubdomains = getRelayerEnsSubdomains;
exports.getStatistic = getStatistic;
exports.getStatusSchema = getStatusSchema;
exports.getSubdomains = getSubdomains;
exports.getSupportedInstances = getSupportedInstances;
exports.getTokenBalances = getTokenBalances;
exports.getWeightRandom = getWeightRandom;
@ -6751,14 +6741,12 @@ exports.getWithdrawals = getWithdrawals;
exports.hexToBytes = hexToBytes;
exports.initGroth16 = initGroth16;
exports.isNode = isNode;
exports.isRelayerUpdated = isRelayerUpdated;
exports.jobsSchema = jobsSchema;
exports.leBuff2Int = leBuff2Int;
exports.leInt2Buff = leInt2Buff;
exports.mimc = mimc;
exports.multicall = multicall;
exports.packEncryptedMessage = packEncryptedMessage;
exports.parseSemanticVersion = parseSemanticVersion;
exports.pedersen = pedersen;
exports.pickWeightedRandomRelayer = pickWeightedRandomRelayer;
exports.populateTransaction = populateTransaction;

38
dist/index.mjs vendored

@ -1884,6 +1884,8 @@ const defaultConfig = {
gasLimit: 7e5
}
},
// Inactive tokens to filter from schema verification and syncing events
disabledTokens: ["cdai", "usdt", "usdc"],
relayerEnsSubdomain: "mainnet-tornado",
pollInterval: 15,
constants: {
@ -2341,9 +2343,16 @@ function getConfig(netId) {
}
return chainConfig;
}
function getInstanceByAddress({ netId, address }) {
const { tokens } = getConfig(netId);
function getActiveTokens(config) {
const { tokens, disabledTokens } = config;
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
}
function getInstanceByAddress(config, address) {
const { tokens, disabledTokens } = config;
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
if (disabledTokens == null ? void 0 : disabledTokens.includes(currency)) {
continue;
}
for (const [amount, instance] of Object.entries(instanceAddress)) {
if (instance === address) {
return {
@ -2354,10 +2363,6 @@ function getInstanceByAddress({ netId, address }) {
}
}
}
function getSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.map((chain) => allConfig[chain].relayerEnsSubdomain);
}
function getRelayerEnsSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.reduce((acc, chain) => {
@ -2397,7 +2402,7 @@ const statusSchema = {
required: ["rewardAccount", "instances", "netId", "tornadoServiceFee", "version", "health"]
};
function getStatusSchema(netId, config) {
const { tokens, optionalTokens = [], nativeCurrency } = config;
const { tokens, optionalTokens, disabledTokens, nativeCurrency } = config;
const schema = JSON.parse(JSON.stringify(statusSchema));
const instances = Object.keys(tokens).reduce(
(acc, token) => {
@ -2428,7 +2433,7 @@ function getStatusSchema(netId, config) {
instanceProperties.properties.symbol = { enum: [symbol] };
}
acc.properties[token] = instanceProperties;
if (!optionalTokens.includes(token)) {
if (!(optionalTokens == null ? void 0 : optionalTokens.includes(token)) && !(disabledTokens == null ? void 0 : disabledTokens.includes(token))) {
acc.required.push(token);
}
return acc;
@ -2532,18 +2537,6 @@ var __async$9 = (__this, __arguments, generator) => {
const MIN_FEE = 0.1;
const MAX_FEE = 0.6;
const MIN_STAKE_BALANCE = parseEther("500");
const semVerRegex = new RegExp("^(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)\\.(?<patch>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
function parseSemanticVersion(version) {
const { groups } = semVerRegex.exec(version);
return groups;
}
function isRelayerUpdated(relayerVersion, netId) {
const { major, patch, prerelease } = parseSemanticVersion(relayerVersion);
const requiredMajor = netId === NetId.MAINNET ? "4" : "5";
const isUpdatedMajor = major === requiredMajor;
if (prerelease) return false;
return isUpdatedMajor && (Number(patch) >= 5 || netId !== NetId.MAINNET);
}
function calculateScore({ stakeBalance, tornadoServiceFee }) {
if (tornadoServiceFee < MIN_FEE) {
tornadoServiceFee = MIN_FEE;
@ -2615,9 +2608,6 @@ class RelayerClient {
if (relayerAddress && this.netId === NetId.MAINNET && status.rewardAccount !== relayerAddress) {
throw new Error("The Relayer reward address must match registered address");
}
if (!isRelayerUpdated(status.version, this.netId)) {
throw new Error("Outdated version.");
}
return status;
});
}
@ -6631,4 +6621,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, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSubdomains, getSupportedInstances, getTokenBalances, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, isRelayerUpdated, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, parseSemanticVersion, 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, 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 };

@ -74,6 +74,7 @@ export type Config = {
subgraphs: SubgraphUrls;
tokens: TokenInstances;
optionalTokens?: string[];
disabledTokens?: string[];
relayerEnsSubdomain: string;
pollInterval: number;
constants: {
@ -107,12 +108,9 @@ export declare let customConfig: networkConfig;
export declare function addNetwork(newConfig: networkConfig): void;
export declare function getNetworkConfig(): networkConfig;
export declare function getConfig(netId: NetIdType): Config;
export declare function getInstanceByAddress({ netId, address }: {
netId: NetIdType;
address: string;
}): {
export declare function getActiveTokens(config: Config): string[];
export declare function getInstanceByAddress(config: Config, address: string): {
amount: string;
currency: string;
} | undefined;
export declare function getSubdomains(): string[];
export declare function getRelayerEnsSubdomains(): SubdomainMap;

@ -79,15 +79,33 @@ export interface RelayerTornadoJobs {
confirmations?: number;
failedReason?: string;
}
/**
const semVerRegex =
/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
export interface semanticVersion {
major: string;
minor: string;
patch: string;
prerelease?: string;
buildmetadata?: string;
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 function parseSemanticVersion(version: string) {
const { groups } = semVerRegex.exec(version) as RegExpExecArray;
return groups as unknown as semanticVersion;
}
export function isRelayerUpdated(relayerVersion: string, netId: NetIdType) {
const { major, patch, prerelease } = parseSemanticVersion(relayerVersion);
// Save backwards compatibility with V4 relayers for Ethereum Mainnet
const requiredMajor = netId === NetId.MAINNET ? '4' : '5';
const isUpdatedMajor = major === requiredMajor;
if (prerelease) return false;
return isUpdatedMajor && (Number(patch) >= 5 || netId !== NetId.MAINNET); // Patch checking - also backwards compatibility for Mainnet
}
**/
export declare function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo): bigint;
export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number;
export type RelayerInstanceList = {

44
dist/tornado.umd.js vendored

@ -61231,8 +61231,8 @@ function multicall(Multicall2, calls) {
/* harmony export */ Af: () => (/* binding */ enabledChains),
/* harmony export */ RY: () => (/* binding */ getNetworkConfig),
/* harmony export */ Zh: () => (/* binding */ getInstanceByAddress),
/* harmony export */ cF: () => (/* binding */ getSubdomains),
/* harmony export */ cX: () => (/* binding */ customConfig),
/* harmony export */ h9: () => (/* binding */ getActiveTokens),
/* harmony export */ o2: () => (/* binding */ getRelayerEnsSubdomains),
/* harmony export */ sb: () => (/* binding */ defaultConfig),
/* harmony export */ zj: () => (/* binding */ getConfig),
@ -61394,6 +61394,8 @@ const defaultConfig = {
gasLimit: 7e5
}
},
// Inactive tokens to filter from schema verification and syncing events
disabledTokens: ["cdai", "usdt", "usdc"],
relayerEnsSubdomain: "mainnet-tornado",
pollInterval: 15,
constants: {
@ -61851,9 +61853,16 @@ function getConfig(netId) {
}
return chainConfig;
}
function getInstanceByAddress({ netId, address }) {
const { tokens } = getConfig(netId);
function getActiveTokens(config) {
const { tokens, disabledTokens } = config;
return Object.keys(tokens).filter((t) => !(disabledTokens == null ? void 0 : disabledTokens.includes(t)));
}
function getInstanceByAddress(config, address) {
const { tokens, disabledTokens } = config;
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
if (disabledTokens == null ? void 0 : disabledTokens.includes(currency)) {
continue;
}
for (const [amount, instance] of Object.entries(instanceAddress)) {
if (instance === address) {
return {
@ -61864,10 +61873,6 @@ function getInstanceByAddress({ netId, address }) {
}
}
}
function getSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.map((chain) => allConfig[chain].relayerEnsSubdomain);
}
function getRelayerEnsSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.reduce((acc, chain) => {
@ -71418,9 +71423,7 @@ class TornadoBrowserProvider extends BrowserProvider {
/* harmony export */ Ss: () => (/* binding */ MIN_FEE),
/* harmony export */ XF: () => (/* binding */ getSupportedInstances),
/* harmony export */ c$: () => (/* binding */ getWeightRandom),
/* harmony export */ mU: () => (/* binding */ isRelayerUpdated),
/* harmony export */ pO: () => (/* binding */ MIN_STAKE_BALANCE),
/* harmony export */ qo: () => (/* binding */ parseSemanticVersion),
/* harmony export */ sN: () => (/* binding */ pickWeightedRandomRelayer),
/* harmony export */ zy: () => (/* binding */ calculateScore)
/* harmony export */ });
@ -71478,18 +71481,6 @@ var __async = (__this, __arguments, generator) => {
const MIN_FEE = 0.1;
const MAX_FEE = 0.6;
const MIN_STAKE_BALANCE = (0,ethers__WEBPACK_IMPORTED_MODULE_4__/* .parseEther */ .g5)("500");
const semVerRegex = new RegExp("^(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)\\.(?<patch>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
function parseSemanticVersion(version) {
const { groups } = semVerRegex.exec(version);
return groups;
}
function isRelayerUpdated(relayerVersion, netId) {
const { major, patch, prerelease } = parseSemanticVersion(relayerVersion);
const requiredMajor = netId === _networkConfig__WEBPACK_IMPORTED_MODULE_1__/* .NetId */ .zr.MAINNET ? "4" : "5";
const isUpdatedMajor = major === requiredMajor;
if (prerelease) return false;
return isUpdatedMajor && (Number(patch) >= 5 || netId !== _networkConfig__WEBPACK_IMPORTED_MODULE_1__/* .NetId */ .zr.MAINNET);
}
function calculateScore({ stakeBalance, tornadoServiceFee }) {
if (tornadoServiceFee < MIN_FEE) {
tornadoServiceFee = MIN_FEE;
@ -71561,9 +71552,6 @@ class RelayerClient {
if (relayerAddress && this.netId === _networkConfig__WEBPACK_IMPORTED_MODULE_1__/* .NetId */ .zr.MAINNET && status.rewardAccount !== relayerAddress) {
throw new Error("The Relayer reward address must match registered address");
}
if (!isRelayerUpdated(status.version, this.netId)) {
throw new Error("Outdated version.");
}
return status;
});
}
@ -71740,7 +71728,7 @@ const statusSchema = {
required: ["rewardAccount", "instances", "netId", "tornadoServiceFee", "version", "health"]
};
function getStatusSchema(netId, config) {
const { tokens, optionalTokens = [], nativeCurrency } = config;
const { tokens, optionalTokens, disabledTokens, nativeCurrency } = config;
const schema = JSON.parse(JSON.stringify(statusSchema));
const instances = Object.keys(tokens).reduce(
(acc, token) => {
@ -71771,7 +71759,7 @@ function getStatusSchema(netId, config) {
instanceProperties.properties.symbol = { enum: [symbol] };
}
acc.properties[token] = instanceProperties;
if (!optionalTokens.includes(token)) {
if (!(optionalTokens == null ? void 0 : optionalTokens.includes(token)) && !(disabledTokens == null ? void 0 : disabledTokens.includes(token))) {
acc.required.push(token);
}
return acc;
@ -173040,6 +173028,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ fetch: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.hd),
/* harmony export */ fetchData: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.Fd),
/* harmony export */ fetchGetUrlFunc: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.uY),
/* harmony export */ getActiveTokens: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.h9),
/* harmony export */ getAllDeposits: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllDeposits),
/* harmony export */ getAllEncryptedNotes: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllEncryptedNotes),
/* harmony export */ getAllGovernanceEvents: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getAllGovernanceEvents),
@ -173062,7 +173051,6 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ getRelayerEnsSubdomains: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.o2),
/* harmony export */ getStatistic: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getStatistic),
/* harmony export */ getStatusSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.c_),
/* harmony export */ getSubdomains: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.cF),
/* harmony export */ getSupportedInstances: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.XF),
/* harmony export */ getTokenBalances: () => (/* reexport safe */ _tokens__WEBPACK_IMPORTED_MODULE_16__.H),
/* harmony export */ getWeightRandom: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.c$),
@ -173070,14 +173058,12 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ hexToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_17__.aT),
/* harmony export */ initGroth16: () => (/* reexport safe */ _websnark__WEBPACK_IMPORTED_MODULE_18__.O),
/* harmony export */ isNode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_17__.Ll),
/* harmony export */ isRelayerUpdated: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.mU),
/* harmony export */ jobsSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.Us),
/* harmony export */ leBuff2Int: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_17__.ae),
/* harmony export */ leInt2Buff: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_17__.EI),
/* harmony export */ mimc: () => (/* reexport safe */ _mimc__WEBPACK_IMPORTED_MODULE_9__.f),
/* harmony export */ multicall: () => (/* reexport safe */ _multicall__WEBPACK_IMPORTED_MODULE_10__.C),
/* harmony export */ packEncryptedMessage: () => (/* reexport safe */ _encryptedNotes__WEBPACK_IMPORTED_MODULE_6__.Fr),
/* harmony export */ parseSemanticVersion: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.qo),
/* harmony export */ pedersen: () => (/* reexport safe */ _pedersen__WEBPACK_IMPORTED_MODULE_12__.NO),
/* harmony export */ pickWeightedRandomRelayer: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.sN),
/* harmony export */ populateTransaction: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.zr),

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{
"name": "@tornado/core",
"version": "1.0.13",
"version": "1.0.14",
"description": "An SDK for building applications on top of Privacy Pools",
"main": "./dist/index.js",
"module": "./dist/index.mjs",

@ -85,6 +85,7 @@ export type Config = {
subgraphs: SubgraphUrls;
tokens: TokenInstances;
optionalTokens?: string[];
disabledTokens?: string[];
relayerEnsSubdomain: string;
// Should be in seconds
pollInterval: number;
@ -234,6 +235,8 @@ export const defaultConfig: networkConfig = {
gasLimit: 700_000,
},
},
// Inactive tokens to filter from schema verification and syncing events
disabledTokens: ['cdai', 'usdt', 'usdc'],
relayerEnsSubdomain: 'mainnet-tornado',
pollInterval: 15,
constants: {
@ -722,10 +725,19 @@ export function getConfig(netId: NetIdType) {
return chainConfig;
}
export function getInstanceByAddress({ netId, address }: { netId: NetIdType; address: string }) {
const { tokens } = getConfig(netId);
export function getActiveTokens(config: Config) {
const { tokens, disabledTokens } = config;
return Object.keys(tokens).filter((t) => !disabledTokens?.includes(t));
}
export function getInstanceByAddress(config: Config, address: string) {
const { tokens, disabledTokens } = config;
for (const [currency, { instanceAddress }] of Object.entries(tokens)) {
if (disabledTokens?.includes(currency)) {
continue;
}
for (const [amount, instance] of Object.entries(instanceAddress)) {
if (instance === address) {
return {
@ -737,12 +749,6 @@ export function getInstanceByAddress({ netId, address }: { netId: NetIdType; add
}
}
export function getSubdomains() {
const allConfig = getNetworkConfig();
return enabledChains.map((chain) => allConfig[chain].relayerEnsSubdomain);
}
export function getRelayerEnsSubdomains() {
const allConfig = getNetworkConfig();

@ -93,6 +93,7 @@ export interface RelayerTornadoJobs {
failedReason?: string;
}
/**
const semVerRegex =
/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
@ -118,6 +119,7 @@ export function isRelayerUpdated(relayerVersion: string, netId: NetIdType) {
if (prerelease) return false;
return isUpdatedMajor && (Number(patch) >= 5 || netId !== NetId.MAINNET); // Patch checking - also backwards compatibility for Mainnet
}
**/
export function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo) {
if (tornadoServiceFee < MIN_FEE) {
@ -236,10 +238,6 @@ export class RelayerClient {
throw new Error('The Relayer reward address must match registered address');
}
if (!isRelayerUpdated(status.version, this.netId)) {
throw new Error('Outdated version.');
}
return status;
}

@ -111,7 +111,7 @@ const statusSchema: statusSchema = {
};
export function getStatusSchema(netId: NetIdType, config: Config) {
const { tokens, optionalTokens = [], nativeCurrency } = config;
const { tokens, optionalTokens, disabledTokens, nativeCurrency } = config;
// deep copy schema
const schema = JSON.parse(JSON.stringify(statusSchema)) as statusSchema;
@ -148,7 +148,7 @@ export function getStatusSchema(netId: NetIdType, config: Config) {
}
acc.properties[token] = instanceProperties;
if (!optionalTokens.includes(token)) {
if (!optionalTokens?.includes(token) && !disabledTokens?.includes(token)) {
acc.required.push(token);
}
return acc;