Skip to content

Commit

Permalink
inputs defaults and export UserInputs type
Browse files Browse the repository at this point in the history
  • Loading branch information
ytham committed Jan 14, 2024
1 parent 10f4b5f commit c519f06
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion circuit/js/package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
13 changes: 8 additions & 5 deletions circuit/js/src/cliHandler/compile.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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.");
}
Expand Down
13 changes: 8 additions & 5 deletions circuit/js/src/cliHandler/prove.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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.");
}
Expand Down
4 changes: 4 additions & 0 deletions circuit/js/src/cliHandler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
1 change: 1 addition & 0 deletions circuit/js/src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions client/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ circuit
.argument("<circuitPath>", "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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion client/src/version.ts
Original file line number Diff line number Diff line change
@@ -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";
export const CLIENT_VERSION = "0.2.2-rc2.1";
4 changes: 2 additions & 2 deletions harness/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
20 changes: 10 additions & 10 deletions harness/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion harness/src/version.ts
Original file line number Diff line number Diff line change
@@ -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";
export const HARNESS_VERSION = "0.2.2-rc2.1";

0 comments on commit c519f06

Please sign in to comment.