tornado-core/scripts/hash.ts
tornadocontrib 8b6887108f
Use simplified websnark & snarkjs
* Use simplified websnark & snarkjs
* Added Base & Blast pools
* Added additional pools for optimism & arbitrum
* Added token transfer events
2024-12-04 03:30:35 +00:00

36 lines
879 B
TypeScript

import path from 'path'
import { readFile, readdir, writeFile } from 'fs/promises';
import { bytesToBase64, digest } from '../src';
async function content(file: string) {
const content = new Uint8Array(await readFile(file));
const hash = 'sha384-' + bytesToBase64(await digest(content));
return hash;
}
async function hash() {
const staticFiles = await readdir('dist');
const hashes = {} as {
[key: string]: string;
};
for (const filePath of staticFiles) {
const file = path.join('dist', filePath).replaceAll(path.sep, path.posix.sep);
if (!['.js', '.mjs'].includes(path.extname(file))) {
continue;
}
const hash = await content(file);
hashes[file] = hash;
}
await writeFile('dist/hashes.json', JSON.stringify(hashes, null, 2));
console.log('hashes', hashes);
}
hash();