From c519f06892cc0541229de6a57dd95802ea0b7a49 Mon Sep 17 00:00:00 2001 From: Yu Jiang Tham Date: Sun, 14 Jan 2024 13:17:04 -0800 Subject: [PATCH] inputs defaults and export UserInputs type --- circuit/js/package.json | 2 +- circuit/js/src/cliHandler/compile.ts | 13 ++++++++----- circuit/js/src/cliHandler/prove.ts | 13 ++++++++----- circuit/js/src/cliHandler/utils.ts | 4 ++++ circuit/js/src/index.ts | 1 + client/package.json | 6 +++--- client/pnpm-lock.yaml | 8 ++++---- client/src/cli/index.ts | 8 ++++---- client/src/version.ts | 2 +- harness/package.json | 4 ++-- harness/pnpm-lock.yaml | 20 ++++++++++---------- harness/src/version.ts | 2 +- 12 files changed, 47 insertions(+), 36 deletions(-) diff --git a/circuit/js/package.json b/circuit/js/package.json index c1e7b1d6..8c36e7e7 100644 --- a/circuit/js/package.json +++ b/circuit/js/package.json @@ -1,6 +1,6 @@ { "name": "@axiom-crypto/circuit", - "version": "0.2.2-rc2.0", + "version": "0.2.2-rc2.1", "author": "Intrinsic Technologies", "license": "MIT", "description": "Client SDK to write custom queries for Axiom, the ZK Coprocessor for Ethereum.", diff --git a/circuit/js/src/cliHandler/compile.ts b/circuit/js/src/cliHandler/compile.ts index b77e46bd..6969c813 100644 --- a/circuit/js/src/cliHandler/compile.ts +++ b/circuit/js/src/cliHandler/compile.ts @@ -1,6 +1,6 @@ import path from 'path'; import { AxiomBaseCircuit } from "../js"; -import { getFunctionFromTs, getProvider, readJsonFromFile, saveJsonToFile } from "./utils"; +import { fileExists, getFunctionFromTs, getProvider, readJsonFromFile, saveJsonToFile } from "./utils"; export const compile = async ( circuitPath: string, @@ -27,11 +27,14 @@ export const compile = async ( shouldTime: options.stats, inputSchema: f.inputSchema, }) - let circuitInputs = f.inputs; - if (options.inputs) { - circuitInputs = readJsonFromFile(options.inputs); + let inputFile = path.join(path.dirname(circuitPath), "data", "inputs.json"); + if (options.inputs !== undefined) { + inputFile = options.inputs; } - else { + let circuitInputs = f.inputs; + if (fileExists(inputFile)) { + circuitInputs = readJsonFromFile(inputFile); + } else { if (circuitInputs === undefined) { throw new Error("No inputs provided. Either export `inputs` from your circuit file or provide a path to a json file with inputs."); } diff --git a/circuit/js/src/cliHandler/prove.ts b/circuit/js/src/cliHandler/prove.ts index e9741592..f02429db 100644 --- a/circuit/js/src/cliHandler/prove.ts +++ b/circuit/js/src/cliHandler/prove.ts @@ -1,6 +1,6 @@ import path from 'path'; import { AxiomBaseCircuit } from "../js"; -import { getFunctionFromTs, getProvider, readJsonFromFile, saveJsonToFile } from "./utils"; +import { fileExists, getFunctionFromTs, getProvider, readJsonFromFile, saveJsonToFile } from "./utils"; export const prove = async ( circuitPath: string, @@ -34,11 +34,14 @@ export const prove = async ( shouldTime: options.stats, inputSchema: compiledJson.inputSchema, }) - let circuitInputs = f.inputs; - if (options.inputs) { - circuitInputs = readJsonFromFile(options.inputs); + let inputFile = path.join(path.dirname(circuitPath), "data", "inputs.json"); + if (options.inputs !== undefined) { + inputFile = options.inputs; } - else { + let circuitInputs = f.inputs; + if (fileExists(inputFile)) { + circuitInputs = readJsonFromFile(inputFile); + } else { if (circuitInputs === undefined) { throw new Error("No inputs provided. Either export `inputs` from your circuit file or provide a path to a json file with inputs."); } diff --git a/circuit/js/src/cliHandler/utils.ts b/circuit/js/src/cliHandler/utils.ts index 346e10d4..b0ac40e6 100644 --- a/circuit/js/src/cliHandler/utils.ts +++ b/circuit/js/src/cliHandler/utils.ts @@ -88,4 +88,8 @@ export function saveJsonToFile(json: any, filePath: string) { export function readJsonFromFile(relativePath: string) { return JSON.parse(fs.readFileSync(path.resolve(relativePath), 'utf8')) +} + +export function fileExists(relativePath: string) { + return fs.existsSync(path.resolve(relativePath)); } \ No newline at end of file diff --git a/circuit/js/src/index.ts b/circuit/js/src/index.ts index a9850249..ad642ab5 100644 --- a/circuit/js/src/index.ts +++ b/circuit/js/src/index.ts @@ -1,5 +1,6 @@ export * from "./subquery"; export * from "./circuitRunner"; export * from "./encoder"; +export { RawInput as UserInput } from './types'; export { CircuitValue, CircuitValue256 } from "@axiom-crypto/halo2-lib-js"; export * from "@axiom-crypto/halo2-lib-js/halo2lib/functions"; \ No newline at end of file diff --git a/client/package.json b/client/package.json index 32b33cd3..1e1bba19 100644 --- a/client/package.json +++ b/client/package.json @@ -1,12 +1,12 @@ { "name": "@axiom-crypto/client", - "version": "0.2.2-rc2.0", + "version": "0.2.2-rc2.1", "author": "Intrinsic Technologies", "license": "MIT", "description": "Client SDK to write custom queries for Axiom, the ZK Coprocessor for Ethereum.", "main": "index.js", + "types": "index.d.ts", "browser": "web/index.js", - "types": "web/index.d.ts", "scripts": { "build": "rm -rf ./dist/* && node scripts/preTsc.js && tsc && node scripts/postTsc.js", "build:docs": "./scripts/buildDocs.sh", @@ -24,7 +24,7 @@ "crypto" ], "dependencies": { - "@axiom-crypto/circuit": "0.2.2-rc2.0", + "@axiom-crypto/circuit": "0.2.2-rc2.1", "@axiom-crypto/core": "2.3.0-rc2.2", "chalk": "^4.1.2", "commander": "^11.1.0", diff --git a/client/pnpm-lock.yaml b/client/pnpm-lock.yaml index 739ed43b..3bf57773 100644 --- a/client/pnpm-lock.yaml +++ b/client/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@axiom-crypto/circuit': - specifier: 0.2.2-rc2.0 - version: 0.2.2-rc2.0(typescript@5.3.3) + specifier: 0.2.2-rc2.1 + version: 0.2.2-rc2.1(typescript@5.3.3) '@axiom-crypto/core': specifier: 2.3.0-rc2.2 version: 2.3.0-rc2.2 @@ -70,8 +70,8 @@ packages: '@jridgewell/trace-mapping': 0.3.20 dev: true - /@axiom-crypto/circuit@0.2.2-rc2.0(typescript@5.3.3): - resolution: {integrity: sha512-ed7f0B6Am+cVY98M109eVWbuP7mnf1EXnVmd+70WjHb2gmSYqF0R/uxX0IFnoyGS0EqY1mFsoJTU+U9ugC8/nQ==} + /@axiom-crypto/circuit@0.2.2-rc2.1(typescript@5.3.3): + resolution: {integrity: sha512-U7j7mfy0ZO9Ky/sHEYi43HDAEBQV6+h1EZd9nB7KpfHmDm2eLOXolro8zznC9ot+vivJ9HyWzc+Dwp/MSXComw==} dependencies: '@axiom-crypto/core': 2.3.0-rc2.2 '@axiom-crypto/halo2-lib-js': 0.2.14-rc.0 diff --git a/client/src/cli/index.ts b/client/src/cli/index.ts index 1b73174a..69b6b414 100644 --- a/client/src/cli/index.ts +++ b/client/src/cli/index.ts @@ -28,8 +28,8 @@ circuit .argument("", "path to the typescript circuit file") .option("-st, --stats", "print stats") .option("-p, --provider [provider]", "JSON-RPC provider (https)") - .option("-i, --inputs [inputs]", "inputs") - .option("-o, --outputs [outputs]", "outputs") + .option("-i, --inputs [inputs]", "inputs json file") + .option("-o, --outputs [outputs]", "outputs json file") .option("-f, --function [function]", "function name in typescript circuit") .action(compile); @@ -42,8 +42,8 @@ circuit .option("-m, --mock", "generate a mock compute proof") .option("-st, --stats", "print stats") .option("-p, --provider [provider]", "JSON-RPC provider (https)") - .option("-i, --inputs [inputs]", "inputs") - .option("-o, --outputs [outputs]", "outputs") + .option("-i, --inputs [inputs]", "inputs json file") + .option("-o, --outputs [outputs]", "outputs json file") .option("-f, --function [function]", "function name in typescript circuit") .action(prove); diff --git a/client/src/version.ts b/client/src/version.ts index 448abf71..242cb1c6 100644 --- a/client/src/version.ts +++ b/client/src/version.ts @@ -1,4 +1,4 @@ // This is an autogenerated file. It should match the version number in package.json. // Do not modify this file directly. -export const CLIENT_VERSION = "0.2.2-rc2.0"; \ No newline at end of file +export const CLIENT_VERSION = "0.2.2-rc2.1"; \ No newline at end of file diff --git a/harness/package.json b/harness/package.json index 0312f228..d5da8d2e 100644 --- a/harness/package.json +++ b/harness/package.json @@ -1,6 +1,6 @@ { "name": "@axiom-crypto/harness", - "version": "0.2.2-rc2.0", + "version": "0.2.2-rc2.1", "author": "Intrinsic Technologies", "license": "MIT", "description": "Circuit harness for axiom-client", @@ -41,6 +41,6 @@ "typescript": "^5.3.2" }, "peerDependencies": { - "@axiom-crypto/client": "0.2.2-rc2.0" + "@axiom-crypto/client": "0.2.2-rc2.1" } } \ No newline at end of file diff --git a/harness/pnpm-lock.yaml b/harness/pnpm-lock.yaml index 20c4225f..57dd31a7 100644 --- a/harness/pnpm-lock.yaml +++ b/harness/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@axiom-crypto/client': - specifier: 0.2.2-rc2.0 - version: 0.2.2-rc2.0(typescript@5.3.3) + specifier: 0.2.2-rc2.1 + version: 0.2.2-rc2.1(typescript@5.3.3) commander: specifier: ^11.1.0 version: 11.1.0 @@ -61,8 +61,8 @@ packages: '@jridgewell/trace-mapping': 0.3.20 dev: true - /@axiom-crypto/circuit@0.2.2-rc2.0(typescript@5.3.3): - resolution: {integrity: sha512-ed7f0B6Am+cVY98M109eVWbuP7mnf1EXnVmd+70WjHb2gmSYqF0R/uxX0IFnoyGS0EqY1mFsoJTU+U9ugC8/nQ==} + /@axiom-crypto/circuit@0.2.2-rc2.1(typescript@5.3.3): + resolution: {integrity: sha512-U7j7mfy0ZO9Ky/sHEYi43HDAEBQV6+h1EZd9nB7KpfHmDm2eLOXolro8zznC9ot+vivJ9HyWzc+Dwp/MSXComw==} dependencies: '@axiom-crypto/core': 2.3.0-rc2.2 '@axiom-crypto/halo2-lib-js': 0.2.14-rc.0 @@ -79,11 +79,11 @@ packages: - zod dev: false - /@axiom-crypto/client@0.2.2-rc2.0(typescript@5.3.3): - resolution: {integrity: sha512-O1EKaD/whs3rSHKx7JfOVKr8FVS4wLAJdrSzzmPgxmG7v5bcZyJ3dcZJMUIiKUaY7KpAnL2IB3UJbfOcC7HrHQ==} + /@axiom-crypto/client@0.2.2-rc2.1(typescript@5.3.3): + resolution: {integrity: sha512-9EkO9goz55ZubRmFmzSrxQwsBhI5PaIlgVSXQj6QlcpIqPr28CkUQ+d2qVufvYKu5IwCN/SL7CpSQLOiVREBdw==} hasBin: true dependencies: - '@axiom-crypto/circuit': 0.2.2-rc2.0(typescript@5.3.3) + '@axiom-crypto/circuit': 0.2.2-rc2.1(typescript@5.3.3) '@axiom-crypto/core': 2.3.0-rc2.2 chalk: 4.1.2 commander: 11.1.0 @@ -1173,7 +1173,7 @@ packages: /axios@1.6.5: resolution: {integrity: sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==} dependencies: - follow-redirects: 1.15.4 + follow-redirects: 1.15.5 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -1683,8 +1683,8 @@ packages: path-exists: 4.0.0 dev: true - /follow-redirects@1.15.4: - resolution: {integrity: sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==} + /follow-redirects@1.15.5: + resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} engines: {node: '>=4.0'} peerDependencies: debug: '*' diff --git a/harness/src/version.ts b/harness/src/version.ts index d25fc8d6..2ce94347 100644 --- a/harness/src/version.ts +++ b/harness/src/version.ts @@ -1,4 +1,4 @@ // This is an autogenerated file. It should match the version number in package.json. // Do not modify this file directly. -export const HARNESS_VERSION = "0.2.2-rc2.0"; \ No newline at end of file +export const HARNESS_VERSION = "0.2.2-rc2.1"; \ No newline at end of file