Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix js format and clippy issues #1339

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions zokrates_analysis/src/boolean_array_comparator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct BooleanArrayComparator;

impl BooleanArrayComparator {
pub fn simplify<T: Field>(p: TypedProgram<T>) -> TypedProgram<T> {
Self::default().fold_program(p)
Self.fold_program(p)
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ mod tests {
]),
));

let res = BooleanArrayComparator::default().fold_boolean_expression(e);
let res = BooleanArrayComparator.fold_boolean_expression(e);

assert_eq!(res, expected);
}
Expand Down Expand Up @@ -171,7 +171,7 @@ mod tests {
]),
));

let res = BooleanArrayComparator::default().fold_boolean_expression(e);
let res = BooleanArrayComparator.fold_boolean_expression(e);

assert_eq!(res, expected);
}
Expand Down
2 changes: 1 addition & 1 deletion zokrates_analysis/src/log_ignorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub struct LogIgnorer;

impl LogIgnorer {
pub fn ignore<T: Field>(p: TypedProgram<T>) -> TypedProgram<T> {
Self::default().fold_program(p)
Self.fold_program(p)
}
}

Expand Down
2 changes: 1 addition & 1 deletion zokrates_analysis/src/out_of_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl fmt::Display for Error {
}
impl OutOfBoundsChecker {
pub fn check<T: Field>(p: TypedProgram<T>) -> Result<TypedProgram<T>, Error> {
Self::default().fold_program(p)
Self.fold_program(p)
}
}

Expand Down
2 changes: 1 addition & 1 deletion zokrates_ast/src/ir/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'ast, T: Field, I: IntoIterator<Item = Statement<'ast, T>>> ProgIterator<'a
statements: self
.statements
.into_iter()
.flat_map(|s| Cleaner::default().fold_statement(s)),
.flat_map(|s| Cleaner.fold_statement(s)),
solvers: self.solvers,
}
}
Expand Down
4 changes: 2 additions & 2 deletions zokrates_core/src/optimizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub fn optimize<'ast, T: Field, I: IntoIterator<Item = Statement<'ast, T>>>(

// define all optimizer steps
let mut redefinition_optimizer = RedefinitionOptimizer::init(&p);
let mut tautologies_optimizer = TautologyOptimizer::default();
let mut tautologies_optimizer = TautologyOptimizer;
let mut directive_optimizer = DirectiveOptimizer::default();
let mut canonicalizer = Canonicalizer::default();
let mut canonicalizer = Canonicalizer;
let mut duplicate_optimizer = DuplicateOptimizer::default();

use zokrates_ast::ir::folder::Folder;
Expand Down
8 changes: 4 additions & 4 deletions zokrates_js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare module "zokrates-js" {

export type ResolveCallback = (
location: string,
path: string
path: string,
) => ResolverResult;

export interface CompileConfig {
Expand Down Expand Up @@ -78,12 +78,12 @@ declare module "zokrates-js" {
withOptions(options: Options): ZoKratesProvider;
compile(
source: string,
compileOptions?: CompileOptions
compileOptions?: CompileOptions,
): CompilationArtifacts;
computeWitness(
input: CompilationArtifacts | Uint8Array,
args: any[],
options?: ComputeOptions
options?: ComputeOptions,
): ComputationResult;
setup(program: Uint8Array, entropy?: string): SetupKeypair;
universalSetup(size: number, entropy?: string): Uint8Array;
Expand All @@ -92,7 +92,7 @@ declare module "zokrates-js" {
program: Uint8Array,
witness: Uint8Array,
provingKey: Uint8Array,
entropy?: string
entropy?: string,
): Proof;
verify(verificationKey: VerificationKey, proof: Proof): boolean;
exportSolidityVerifier(verificationKey: VerificationKey): string;
Expand Down
12 changes: 6 additions & 6 deletions zokrates_js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const initialize = async () => {
location,
resolveCallback,
config,
curve
curve,
);
const result = Object.assign(
{
program: ptr.program(),
abi: ptr.abi(),
constraintCount: ptr.constraint_count(),
},
snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {}
snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {},
);
ptr.free();
return result;
Expand All @@ -47,7 +47,7 @@ const initialize = async () => {
{
snarkjs: snarkjs,
},
logCallback
logCallback,
);

const result = Object.assign(
Expand All @@ -61,7 +61,7 @@ const initialize = async () => {
witness: ptr.snarkjs_witness(),
},
}
: {}
: {},
);

ptr.free();
Expand Down Expand Up @@ -94,7 +94,7 @@ const initialize = async () => {
witness,
provingKey,
entropy,
options
options,
);
},
verify: (vk, proof, options) => {
Expand Down Expand Up @@ -132,7 +132,7 @@ const initialize = async () => {
witness,
provingKey,
entropy,
options
options,
),
verify: (vk, proof) => defaultProvider.verify(vk, proof, options),
exportSolidityVerifier: (vk) =>
Expand Down
2 changes: 1 addition & 1 deletion zokrates_js/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pako from "pako";

(async function () {
const packageObject = JSON.parse(
await fs.readFile("pkg/package.json", { encoding: "utf-8" })
await fs.readFile("pkg/package.json", { encoding: "utf-8" }),
);
const wasmPath = packageObject.files.find((file) => file.endsWith(".wasm"));
const wasm = await fs.readFile(`pkg/${wasmPath}`);
Expand Down
20 changes: 10 additions & 10 deletions zokrates_js/tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("tests", () => {
describe("compilation", () => {
it("should compile", () => {
const artifacts = zokratesProvider.compile(
"def main() -> field { return 42; }"
"def main() -> field { return 42; }",
);
assert.ok(artifacts);
assert.ok(artifacts.snarkjs === undefined);
Expand All @@ -49,7 +49,7 @@ describe("tests", () => {
it("should compile with snarkjs output", () => {
const artifacts = zokratesProvider.compile(
"def main() -> field { return 42; }",
{ snarkjs: true }
{ snarkjs: true },
);
assert.ok(artifacts);
assert.ok(artifacts.snarkjs.program !== undefined);
Expand Down Expand Up @@ -167,7 +167,7 @@ describe("tests", () => {
["337", "113569"],
{
snarkjs: true,
}
},
);
});

Expand Down Expand Up @@ -214,7 +214,7 @@ describe("tests", () => {
return snarkjs.zKey.newZKey(
r1csPath,
"./tests/powersOfTau5_0000.ptau",
zkeyPath
zkeyPath,
);
});
});
Expand All @@ -231,7 +231,7 @@ describe("tests", () => {
proof = provider.generateProof(
artifacts.program,
computationResult.witness,
keypair.pk
keypair.pk,
);
assert.ok(proof !== undefined);
assert.equal(proof.inputs.length, 2);
Expand All @@ -240,7 +240,7 @@ describe("tests", () => {
let proof2 = provider.generateProof(
artifacts.program,
computationResult.witness,
keypair.pk
keypair.pk,
);
assert.notDeepEqual(proof, proof2);
});
Expand All @@ -251,7 +251,7 @@ describe("tests", () => {
artifacts.program,
computationResult.witness,
keypair.pk,
entropy
entropy,
);
assert.ok(proof !== undefined);
assert.equal(proof.inputs.length, 2);
Expand All @@ -261,7 +261,7 @@ describe("tests", () => {
artifacts.program,
computationResult.witness,
keypair.pk,
entropy
entropy,
);
assert.deepEqual(proof, proof2);
});
Expand Down Expand Up @@ -333,7 +333,7 @@ describe("tests", () => {

const fileSystemResolver = (from, to) => {
let parsedPath = path.parse(
path.resolve(path.dirname(path.resolve(from)), to)
path.resolve(path.dirname(path.resolve(from)), to),
);
const location = path.format({
...parsedPath,
Expand Down Expand Up @@ -368,7 +368,7 @@ describe("tests", () => {
try {
const result = specializedProvider.computeWitness(
input,
t.input.values
t.input.values,
);
const value = JSON.parse(result.output);
assert.deepEqual({ Ok: { value } }, t.output);
Expand Down
2 changes: 1 addition & 1 deletion zokrates_js/tests/umd/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("umd web tests", () => {
const page = await browser.newPage();

let response = await page.goto(
path.dirname(import.meta.url) + "/index.html"
path.dirname(import.meta.url) + "/index.html",
);
assert(response.ok());

Expand Down
Loading