mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-05-11 10:45:27 -04:00
change dir structure
This commit is contained in:
parent
0c6e638852
commit
23543683f3
12 changed files with 24 additions and 84 deletions
43
scripts/downloadKeys.js
Normal file
43
scripts/downloadKeys.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const axios = require('axios')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const files = ['withdraw.json', 'withdraw_proving_key.bin', 'Verifier.sol', 'withdraw_verification_key.json']
|
||||
const circuitsPath = __dirname + '/../build/circuits'
|
||||
const contractsPath = __dirname + '/../build/contracts'
|
||||
|
||||
async function downloadFile({ url, path }) {
|
||||
const writer = fs.createWriteStream(path)
|
||||
|
||||
const response = await axios({
|
||||
url,
|
||||
method: 'GET',
|
||||
responseType: 'stream',
|
||||
})
|
||||
|
||||
response.data.pipe(writer)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
writer.on('finish', resolve)
|
||||
writer.on('error', reject)
|
||||
})
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const release = await axios.get('https://api.github.com/repos/tornadocash/tornado-core/releases/latest')
|
||||
const { assets } = release.data
|
||||
if (!fs.existsSync(circuitsPath)) {
|
||||
fs.mkdirSync(circuitsPath, { recursive: true })
|
||||
fs.mkdirSync(contractsPath, { recursive: true })
|
||||
}
|
||||
for (let asset of assets) {
|
||||
if (files.includes(asset.name)) {
|
||||
console.log(`Downloading ${asset.name} ...`)
|
||||
await downloadFile({
|
||||
url: asset.browser_download_url,
|
||||
path: path.resolve(__dirname, circuitsPath, asset.name),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue