Tornado CLI 1.0.8-alpha

audit provider network
This commit is contained in:
Tornado Contrib 2024-09-24 05:48:07 +00:00
parent a8fc72ccda
commit 37ce302ca5
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
5 changed files with 706 additions and 633 deletions

1262
dist/cli.js vendored

File diff suppressed because it is too large Load Diff

2
dist/program.d.ts vendored

@ -30,7 +30,7 @@ export declare function getProgramOptions(options: commonProgramOptions): Promis
fetchDataOptions: fetchDataOptions; fetchDataOptions: fetchDataOptions;
}>; }>;
export declare function getProgramGraphAPI(options: commonProgramOptions, config: Config): string; export declare function getProgramGraphAPI(options: commonProgramOptions, config: Config): string;
export declare function getProgramProvider(netId: NetIdType, rpcUrl: string | undefined, config: Config, providerOptions?: getProviderOptions): JsonRpcProvider; export declare function getProgramProvider(rpcUrl: string | undefined, providerOptions: getProviderOptions): Promise<JsonRpcProvider>;
export declare function getProgramSigner({ options, provider, }: { export declare function getProgramSigner({ options, provider, }: {
options: commonProgramOptions; options: commonProgramOptions;
provider: Provider; provider: Provider;

@ -1,6 +1,6 @@
{ {
"name": "@tornado/cli", "name": "@tornado/cli",
"version": "1.0.7-alpha", "version": "1.0.8-alpha",
"description": "Modern Toolsets for Privacy Pools on Ethereum", "description": "Modern Toolsets for Privacy Pools on Ethereum",
"main": "./dist/cli.js", "main": "./dist/cli.js",
"types": "./dist/cli.d.ts", "types": "./dist/cli.d.ts",
@ -51,7 +51,7 @@
"optionalDependencies": {}, "optionalDependencies": {},
"devDependencies": { "devDependencies": {
"@colors/colors": "1.5.0", "@colors/colors": "1.5.0",
"@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#29744cfce47aae9bb1f5d46030eb575f00211a90", "@tornado/core": "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#d0b032d7bef06de61872ba7ad07b769b9b1d9717",
"@typechain/ethers-v6": "^0.5.1", "@typechain/ethers-v6": "^0.5.1",
"@types/figlet": "^1.5.8", "@types/figlet": "^1.5.8",
"@typescript-eslint/eslint-plugin": "^8.6.0", "@typescript-eslint/eslint-plugin": "^8.6.0",

@ -37,7 +37,7 @@ import {
OffchainOracle__factory, OffchainOracle__factory,
OvmGasPriceOracle__factory, OvmGasPriceOracle__factory,
getProviderOptions, getProviderOptions,
getProviderWithNetId, getProvider,
getTokenBalances, getTokenBalances,
TornadoWallet, TornadoWallet,
TornadoVoidSigner, TornadoVoidSigner,
@ -87,6 +87,9 @@ import {
const EXEC_NAME = 'tornado-cli'; const EXEC_NAME = 'tornado-cli';
// Inactive tokens to filter from syncing (Either they have no activity for more than a year, should be filtered from event syncs and withdrawals)
const INACTIVE_TOKENS: string[] = ['cdai', 'usdc', 'usdt'];
/** /**
* Static variables, shouldn't be modified by env unless you know what they are doing * Static variables, shouldn't be modified by env unless you know what they are doing
*/ */
@ -241,17 +244,16 @@ export function getProgramGraphAPI(options: commonProgramOptions, config: Config
return ''; return '';
} }
export function getProgramProvider( export function getProgramProvider(rpcUrl: string = '', providerOptions: getProviderOptions): Promise<JsonRpcProvider> {
netId: NetIdType, const { netId } = providerOptions;
rpcUrl: string = '',
config: Config, const config = getConfig(netId);
providerOptions?: getProviderOptions,
): JsonRpcProvider {
if (!rpcUrl) { if (!rpcUrl) {
rpcUrl = Object.values(config.rpcUrls)[0].url; rpcUrl = Object.values(config.rpcUrls)[0]?.url || '';
} }
return getProviderWithNetId(netId, rpcUrl, config, providerOptions); return getProvider(rpcUrl, providerOptions);
} }
export function getProgramSigner({ export function getProgramSigner({
@ -300,7 +302,8 @@ export async function getProgramRelayer({
constants: { REGISTRY_BLOCK }, constants: { REGISTRY_BLOCK },
} = ethConfig; } = ethConfig;
const provider = getProgramProvider(RELAYER_NETWORK, ethRpc, ethConfig, { const provider = await getProgramProvider(ethRpc, {
netId: RELAYER_NETWORK,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -554,7 +557,8 @@ export function tornadoProgram() {
const isEth = nativeCurrency === currency; const isEth = nativeCurrency === currency;
const denomination = parseUnits(amount, decimals); const denomination = parseUnits(amount, decimals);
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -698,7 +702,8 @@ export function tornadoProgram() {
const isEth = nativeCurrency === currency; const isEth = nativeCurrency === currency;
const denomination = parseUnits(amount, decimals); const denomination = parseUnits(amount, decimals);
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -824,7 +829,8 @@ export function tornadoProgram() {
const firstAmount = Object.keys(currencyConfig.instanceAddress).sort((a, b) => Number(a) - Number(b))[0]; const firstAmount = Object.keys(currencyConfig.instanceAddress).sort((a, b) => Number(a) - Number(b))[0];
const isFirstAmount = Number(amount) === Number(firstAmount); const isFirstAmount = Number(amount) === Number(firstAmount);
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1168,7 +1174,8 @@ export function tornadoProgram() {
instanceAddress: { [amount]: instanceAddress }, instanceAddress: { [amount]: instanceAddress },
} = currencyConfig; } = currencyConfig;
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1297,7 +1304,8 @@ export function tornadoProgram() {
constants: { GOVERNANCE_BLOCK, REGISTRY_BLOCK, NOTE_ACCOUNT_BLOCK, ENCRYPTED_NOTES_BLOCK }, constants: { GOVERNANCE_BLOCK, REGISTRY_BLOCK, NOTE_ACCOUNT_BLOCK, ENCRYPTED_NOTES_BLOCK },
} = config; } = config;
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
const graphApi = getProgramGraphAPI(options, config); const graphApi = getProgramGraphAPI(options, config);
@ -1369,6 +1377,11 @@ export function tornadoProgram() {
const currencies = currencyOpts ? [currencyOpts.toLowerCase()] : Object.keys(tokens); const currencies = currencyOpts ? [currencyOpts.toLowerCase()] : Object.keys(tokens);
for (const currency of currencies) { for (const currency of currencies) {
// Skip syncing inactive instances
if (INACTIVE_TOKENS.includes(currency)) {
continue;
}
const currencyConfig = tokens[currency]; const currencyConfig = tokens[currency];
// Now load the denominations and address // Now load the denominations and address
const amounts = Object.keys(currencyConfig.instanceAddress); const amounts = Object.keys(currencyConfig.instanceAddress);
@ -1519,7 +1532,8 @@ export function tornadoProgram() {
constants: { ['NOTE_ACCOUNT_BLOCK']: deployedBlock }, constants: { ['NOTE_ACCOUNT_BLOCK']: deployedBlock },
} = config; } = config;
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1640,7 +1654,8 @@ export function tornadoProgram() {
constants: { ENCRYPTED_NOTES_BLOCK }, constants: { ENCRYPTED_NOTES_BLOCK },
} = config; } = config;
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1714,7 +1729,8 @@ export function tornadoProgram() {
const { currencyName, multicallContract } = config; const { currencyName, multicallContract } = config;
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1850,7 +1866,8 @@ export function tornadoProgram() {
const { currencyName, multicallContract, tornContract, tokens } = config; const { currencyName, multicallContract, tornContract, tokens } = config;
const provider = getProgramProvider(netId, rpc, config, { const provider = await getProgramProvider(rpc, {
netId,
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1906,9 +1923,8 @@ export function tornadoProgram() {
const netId = Number(deserializedTx.chainId); const netId = Number(deserializedTx.chainId);
const config = getConfig(netId); const provider = await getProgramProvider(rpc, {
netId,
const provider = getProgramProvider(netId, rpc, config, {
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -1941,9 +1957,8 @@ export function tornadoProgram() {
throw new Error('NetId for the transaction is invalid, this command only supports EIP-155 transactions'); throw new Error('NetId for the transaction is invalid, this command only supports EIP-155 transactions');
} }
const config = getConfig(netId); const provider = await getProgramProvider(rpc, {
netId,
const provider = getProgramProvider(netId, rpc, config, {
...fetchDataOptions, ...fetchDataOptions,
}); });

@ -781,9 +781,9 @@
"@openzeppelin/contracts-v3" "npm:@openzeppelin/contracts@3.2.0-rc.0" "@openzeppelin/contracts-v3" "npm:@openzeppelin/contracts@3.2.0-rc.0"
ethers "^6.4.0" ethers "^6.4.0"
"@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#29744cfce47aae9bb1f5d46030eb575f00211a90": "@tornado/core@git+https://git.tornado.ws/tornadocontrib/tornado-core.git#d0b032d7bef06de61872ba7ad07b769b9b1d9717":
version "1.0.11" version "1.0.13"
resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#29744cfce47aae9bb1f5d46030eb575f00211a90" resolved "git+https://git.tornado.ws/tornadocontrib/tornado-core.git#d0b032d7bef06de61872ba7ad07b769b9b1d9717"
dependencies: dependencies:
"@metamask/eth-sig-util" "^7.0.3" "@metamask/eth-sig-util" "^7.0.3"
"@tornado/contracts" "^1.0.1" "@tornado/contracts" "^1.0.1"