framework
framework copied to clipboard
Provable.array doesn't work as state, if passed within a struct without a key.
The following array-struct breaks the on-chain state due to Provable.witness not being able to process the dummy value we generate from the Ballot struct.
const BALLOT_LENGTH = 10;
export class Ballot extends Struct(Provable.Array(UInt64, BALLOT_LENGTH)) {
static empty(): Ballot {
const uints = new Array(10).fill(UInt64.from(0));
return new Ballot(uints);
}
}
Temporary workaround is to define the Ballot like this:
const BALLOT_LENGTH = 10;
class Ballot extends Struct({
uints: Provable.Array(UInt64, BALLOT_LENGTH),
}) {
public static empty(): Ballot {
const uints = new Array(10).fill(UInt64.from(0));
return new Ballot({ uints });
}
}