diff --git a/cli.js b/cli.js index d2bb631..05197f2 100755 --- a/cli.js +++ b/cli.js @@ -10,7 +10,6 @@ const circomlib = require('@tornado/circomlib'); const bigInt = snarkjs.bigInt; const merkleTree = require('@tornado/fixed-merkle-tree'); const Web3 = require('web3'); -const Web3HttpProvider = require('@tornado/web3-providers-http'); const buildGroth16 = require('@tornado/websnark/src/groth16'); const websnarkUtils = require('@tornado/websnark/src/utils'); const { toWei, fromWei, toBN, BN } = require('web3-utils'); @@ -1367,7 +1366,7 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', balanceC console.log('Using tor network'); web3Options = { agent: { https: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort) }, timeout: 60000 }; // Use forked web3-providers-http from local file to modify user-agent header value which improves privacy. - web3 = new Web3(new Web3HttpProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 }); + web3 = new Web3(new Web3.providers.HttpProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 }); ipOptions = { httpsAgent: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort), headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' } @@ -1376,21 +1375,22 @@ async function init({ rpc, noteNetId, currency = 'dai', amount = '100', balanceC console.log('Using tor network'); web3Options = { agent: { http: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort) }, timeout: 60000 }; // Use forked web3-providers-http from local file to modify user-agent header value which improves privacy. - web3 = new Web3(new Web3HttpProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 }); + web3 = new Web3(new Web3.providers.HttpProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 }); ipOptions = { httpsAgent: new SocksProxyAgent('socks5h://127.0.0.1:' + torPort), headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' } }; } else if (rpc.includes('ipc')) { console.log('Using ipc connection'); - web3 = new Web3(new Web3.providers.IpcProvider(rpc, net), null, { transactionConfirmationBlocks: 1 }); + web3 = new Web3(new Web3.providers.IpcProvider(rpc, {}), null, { transactionConfirmationBlocks: 1 }); } else if (rpc.startsWith('ws') || rpc.startsWith('wss')) { console.log('Using websocket connection (Note: Tor is not supported for Websocket providers)'); web3Options = { clientConfig: { keepalive: true, keepaliveInterval: -1 }, reconnect: { auto: true, delay: 1000, maxAttempts: 10, onTimeout: false } }; - web3 = new Web3(new Web3.providers.WebsocketProvider(rpc, web3Options), net, { transactionConfirmationBlocks: 1 }); + web3 = new Web3(new Web3.providers.WebsocketProvider(rpc, web3Options), null, { transactionConfirmationBlocks: 1 }); + if (!(await web3.eth.net.isListening())) throw new Error('Cannot connect to websocket provider'); } else { console.log('Connecting to remote node'); web3 = new Web3(rpc, null, { transactionConfirmationBlocks: 1 }); diff --git a/package-lock.json b/package-lock.json index c306ee0..692cc0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -686,54 +686,6 @@ } } }, - "@tornado/web3-providers-http": { - "version": "1.6.5-p1", - "resolved": "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fweb3-providers-http/-/1.6.5-p1/web3-providers-http-1.6.5-p1.tgz", - "integrity": "sha512-/YDTDWKSwsDm3dAyJv8PpTcrd3X3QUO/1hlJ7p+owWPWLoW5AeyOIHF2Fkbgr4+oBJYhW7+uh5OFmWBooIoUpQ==", - "requires": { - "@tornado/xhr2-cookies": "1.1.0-p0", - "web3-core-helpers": "1.6.1" - }, - "dependencies": { - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, - "web3-core-helpers": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.6.1.tgz", - "integrity": "sha512-om2PZvK1uoWcgMq6JfcSx3241LEIVF6qi2JuHz2SLKiKEW5UsBUaVx0mNCmcZaiuYQCyOsLS3r33q5AdM+v8ng==", - "requires": { - "web3-eth-iban": "1.6.1", - "web3-utils": "1.6.1" - } - }, - "web3-eth-iban": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.6.1.tgz", - "integrity": "sha512-91H0jXZnWlOoXmc13O9NuQzcjThnWyAHyDn5Yf7u6mmKOhpJSGF/OHlkbpXt1Y4v2eJdEPaVFa+6i8aRyagE7Q==", - "requires": { - "bn.js": "^4.11.9", - "web3-utils": "1.6.1" - } - }, - "web3-utils": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.6.1.tgz", - "integrity": "sha512-RidGKv5kOkcerI6jQqDFDoTllQQqV+rPhTzZHhmbqtFObbYpU93uc+yG1LHivRTQhA6llIx67iudc/vzisgO+w==", - "requires": { - "bn.js": "^4.11.9", - "ethereum-bloom-filters": "^1.0.6", - "ethereumjs-util": "^7.1.0", - "ethjs-unit": "0.1.6", - "number-to-bn": "1.7.0", - "randombytes": "^2.1.0", - "utf8": "3.0.0" - } - } - } - }, "@tornado/websnark": { "version": "0.0.4", "resolved": "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fwebsnark/-/0.0.4/websnark-0.0.4.tgz", @@ -750,14 +702,6 @@ } } }, - "@tornado/xhr2-cookies": { - "version": "1.1.0-p0", - "resolved": "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fxhr2-cookies/-/1.1.0-p0/xhr2-cookies-1.1.0-p0.tgz", - "integrity": "sha512-G5O36rQOfn45Ytf0BghZl2CikygfDfr5HoQA9ShnjcPWQDN0OZJV77N8HwAFzAMHuUjFcYvxQUbvyBJQOmYUMQ==", - "requires": { - "cookiejar": "^2.1.1" - } - }, "@types/bn.js": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", @@ -1440,11 +1384,6 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, - "cookiejar": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", - "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", diff --git a/package.json b/package.json index 7761a3c..76edd4c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "@tornado/fixed-merkle-tree": "0.6.1", "@tornado/snarkjs": "0.1.20", "@tornado/tornado-oracles": "^3.3.0", - "@tornado/web3-providers-http": "1.6.5-p1", "@tornado/websnark": "0.0.4", "axios": "^0.19.2", "bignumber.js": "^9.0.0", @@ -25,7 +24,7 @@ "es5-ext": "0.10.53", "private-ip": "^2.3.3", "socks-proxy-agent": "^6.1.1", - "web3": "^1.6.1" + "web3": "^1.10.2" }, "devDependencies": { "eslint": "^7.0.0"