I'm receiving the error message:
TreeVerifier.compile() depends on TreeCalculation, but we cannot find compilation output for TreeCalculation.
Try to run TreeCalculation.compile() first.
41 | it(`should compile contracts`, async () => {
42 | await TreeCalculation.compile();
> 43 | await TreeVerifier.compile();
| ^
44 | });
45 | });
46 |
when trying to compile SmartProgram and ZkProgram returned by the function. Both SmartProgram and ZkProgram use MerkleWitness, and the height of the Merkle Tree is the argument to the functions:
import { describe, expect, it } from "@jest/globals";
import { Field, MerkleWitness, ZkProgram, method, SmartContract } from "o1js";
function TreeCalculationFunction(height: number) {
class MerkleTreeWitness extends MerkleWitness(height) {}
const TreeCalculation = ZkProgram({
name: "TreeCalculation",
publicInput: Field,
methods: {
check: {
privateInputs: [MerkleTreeWitness, Field],
method(root: Field, witness: MerkleTreeWitness, value: Field) {
const calculatedRoot = witness.calculateRoot(value);
calculatedRoot.assertEquals(root);
},
},
},
});
return TreeCalculation;
}
function TreeVerifierFunction(height: number) {
const TreeCalculation = TreeCalculationFunction(height);
class TreeProof extends ZkProgram.Proof(TreeCalculation) {}
class TreeVerifier extends SmartContract {
@method verifyRedactedTree(proof: TreeProof) {
proof.verify();
}
}
return TreeVerifier;
}
const TreeCalculation = TreeCalculationFunction(4);
const TreeVerifier = TreeVerifierFunction(4);
describe(`Merkle Tree contracts`, () => {
it(`should compile contracts`, async () => {
await TreeCalculation.compile();
await TreeVerifier.compile();
});
});