1
0
Fork 0
mirror of synced 2025-09-22 11:47:57 +00:00

Fix js format and clippy issues (#1339)

* js fmt

* clippy
This commit is contained in:
Darko Macesic 2023-08-22 18:37:49 +02:00 committed by GitHub
parent f900437d36
commit 296921e558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 30 additions and 30 deletions

View file

@ -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)
}
}
@ -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);
}
@ -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);
}

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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,
}
}

View file

@ -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;

View file

@ -8,7 +8,7 @@ declare module "zokrates-js" {
export type ResolveCallback = (
location: string,
path: string
path: string,
) => ResolverResult;
export interface CompileConfig {
@ -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;
@ -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;

View file

@ -22,7 +22,7 @@ const initialize = async () => {
location,
resolveCallback,
config,
curve
curve,
);
const result = Object.assign(
{
@ -30,7 +30,7 @@ const initialize = async () => {
abi: ptr.abi(),
constraintCount: ptr.constraint_count(),
},
snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {}
snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {},
);
ptr.free();
return result;
@ -47,7 +47,7 @@ const initialize = async () => {
{
snarkjs: snarkjs,
},
logCallback
logCallback,
);
const result = Object.assign(
@ -61,7 +61,7 @@ const initialize = async () => {
witness: ptr.snarkjs_witness(),
},
}
: {}
: {},
);
ptr.free();
@ -94,7 +94,7 @@ const initialize = async () => {
witness,
provingKey,
entropy,
options
options,
);
},
verify: (vk, proof, options) => {
@ -132,7 +132,7 @@ const initialize = async () => {
witness,
provingKey,
entropy,
options
options,
),
verify: (vk, proof) => defaultProvider.verify(vk, proof, options),
exportSolidityVerifier: (vk) =>

View file

@ -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}`);

View file

@ -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);
@ -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);
@ -167,7 +167,7 @@ describe("tests", () => {
["337", "113569"],
{
snarkjs: true,
}
},
);
});
@ -214,7 +214,7 @@ describe("tests", () => {
return snarkjs.zKey.newZKey(
r1csPath,
"./tests/powersOfTau5_0000.ptau",
zkeyPath
zkeyPath,
);
});
});
@ -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);
@ -240,7 +240,7 @@ describe("tests", () => {
let proof2 = provider.generateProof(
artifacts.program,
computationResult.witness,
keypair.pk
keypair.pk,
);
assert.notDeepEqual(proof, proof2);
});
@ -251,7 +251,7 @@ describe("tests", () => {
artifacts.program,
computationResult.witness,
keypair.pk,
entropy
entropy,
);
assert.ok(proof !== undefined);
assert.equal(proof.inputs.length, 2);
@ -261,7 +261,7 @@ describe("tests", () => {
artifacts.program,
computationResult.witness,
keypair.pk,
entropy
entropy,
);
assert.deepEqual(proof, proof2);
});
@ -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,
@ -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);

View file

@ -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());