From 7df37c159291a3ba00dd4f6dfd2f879c1578b0d6 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Mon, 13 Jul 2020 08:47:02 +0200 Subject: [PATCH] fix template dir --- build/cli.cjs | 11 +++++++---- cli.js | 8 ++++++-- config/rollup.cli.config.js | 2 -- package-lock.json | 5 ----- package.json | 1 - 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/build/cli.cjs b/build/cli.cjs index bdc0e1d..57ade9c 100755 --- a/build/cli.cjs +++ b/build/cli.cjs @@ -11,7 +11,6 @@ var readline = _interopDefault(require('readline')); var crypto = _interopDefault(require('crypto')); var circomRuntime = _interopDefault(require('circom_runtime')); var path = _interopDefault(require('path')); -var appRoot = _interopDefault(require('app-root-path')); var Logger = _interopDefault(require('logplease')); async function open(fileName, openFlags, cacheSize) { @@ -740,7 +739,7 @@ async function r1csExportJson(r1csFileName, logger) { var name = "snarkjs"; var type = "module"; -var version = "0.3.1"; +var version = "0.3.2"; var description = "zkSNARKs implementation in JavaScript"; var main = "./build/main.cjs"; var module$1 = "./main.js"; @@ -777,7 +776,6 @@ var repository = { url: "https://github.com/iden3/snarkjs.git" }; var dependencies = { - "app-root-path": "^3.0.0", "blake2b-wasm": "https://github.com/jbaylina/blake2b-wasm.git", circom_runtime: "0.0.9", fastfile: "0.0.6", @@ -6109,7 +6107,12 @@ async function zkeyExportSolidityVerifier(params, options) { if (options.verbose) Logger.setLogLevel("DEBUG"); - const templateName = path.join( appRoot.path, "templates", "verifier_groth16.sol"); + let templateName; + if (path.existsSync(path.join( __dirname, "templates", "verifier_groth16.sol"))) { + templateName = path.join( __dirname, "templates", "verifier_groth16.sol"); + } else { + templateName = path.join( __dirname, "..", "templates", "verifier_groth16.sol"); + } const verifierCode = await exportSolidityVerifier(zkeyName, templateName); diff --git a/cli.js b/cli.js index 75865bd..b17f186 100755 --- a/cli.js +++ b/cli.js @@ -38,7 +38,6 @@ import * as groth16 from "./src/groth16.js"; import * as wtns from "./src/wtns.js"; import * as curves from "./src/curves.js"; import path from "path"; -import appRoot from "app-root-path"; import Logger from "logplease"; const logger = Logger.create("snarkJS", {showTimestamp:false}); @@ -520,7 +519,12 @@ async function zkeyExportSolidityVerifier(params, options) { if (options.verbose) Logger.setLogLevel("DEBUG"); - const templateName = path.join( appRoot.path, "templates", "verifier_groth16.sol"); + let templateName; + if (path.existsSync(path.join( __dirname, "templates", "verifier_groth16.sol"))) { + templateName = path.join( __dirname, "templates", "verifier_groth16.sol"); + } else { + templateName = path.join( __dirname, "..", "templates", "verifier_groth16.sol"); + } const verifierCode = await zkey.exportSolidityVerifier(zkeyName, templateName, logger); diff --git a/config/rollup.cli.config.js b/config/rollup.cli.config.js index f91930f..b5a4fbd 100644 --- a/config/rollup.cli.config.js +++ b/config/rollup.cli.config.js @@ -25,8 +25,6 @@ export default { "keccak", "yargs", "logplease", - - "app-root-path" ], plugins: [ resolve({ diff --git a/package-lock.json b/package-lock.json index 50b2acd..48b5f93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -128,11 +128,6 @@ "picomatch": "^2.0.4" } }, - "app-root-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.0.0.tgz", - "integrity": "sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw==" - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", diff --git a/package.json b/package.json index 25ffb98..c1c95d4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "url": "https://github.com/iden3/snarkjs.git" }, "dependencies": { - "app-root-path": "^3.0.0", "blake2b-wasm": "https://github.com/jbaylina/blake2b-wasm.git", "circom_runtime": "0.0.9", "fastfile": "0.0.6",