mirror of
https://github.com/tornadocash/websnark.git
synced 2025-01-15 23:47:47 +01:00
Fix borwser env for tornado snarkjs
This commit is contained in:
parent
fe9f4119c4
commit
a0a680ea80
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -22,9 +22,15 @@ const bigInt = require("big-integer");
|
|||||||
const groth16_wasm = require("../build/groth16_wasm.js");
|
const groth16_wasm = require("../build/groth16_wasm.js");
|
||||||
const assert = require("assert");
|
const assert = require("assert");
|
||||||
|
|
||||||
const inBrowser = (typeof window !== "undefined");
|
const inBrowser = (typeof window !== "undefined") || process && process.env && process.env.FOR_BROWSER === "true";
|
||||||
|
|
||||||
|
|
||||||
let NodeWorker;
|
let NodeWorker;
|
||||||
let NodeCrypto;
|
let NodeCrypto;
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`Running in browser ${inBrowser}`);
|
||||||
|
|
||||||
if (!inBrowser) {
|
if (!inBrowser) {
|
||||||
NodeWorker = require("worker_threads").Worker;
|
NodeWorker = require("worker_threads").Worker;
|
||||||
NodeCrypto = require("crypto");
|
NodeCrypto = require("crypto");
|
||||||
@ -170,7 +176,7 @@ function thread(self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We use the Object.assign approach for the backwards compatibility
|
// We use the Object.assign approach for the backwards compatibility
|
||||||
// @params Number wasmInitialMemory
|
// @params Number wasmInitialMemory
|
||||||
async function build(params) {
|
async function build(params) {
|
||||||
const defaultParams = { wasmInitialMemory: 5000 };
|
const defaultParams = { wasmInitialMemory: 5000 };
|
||||||
Object.assign(defaultParams, params);
|
Object.assign(defaultParams, params);
|
||||||
|
Loading…
Reference in New Issue
Block a user