UNPKG

pulsar-contracts

Version:

28 lines 865 B
import { Bool, Field, MerkleList, Poseidon, Provable, Struct } from 'o1js'; import { BATCH_SIZE } from '../utils/constants.js'; export { List, emptyHash, ReduceMask }; const emptyHash = Poseidon.hash([Field(0)]); const nextHash = (hash, value) => Poseidon.hash([hash, value]); class List extends MerkleList.create(Field, nextHash, emptyHash) { } class ReduceMask extends Struct({ list: Provable.Array(Bool, BATCH_SIZE), }) { static empty() { return new ReduceMask({ list: new Array(BATCH_SIZE).fill(Bool(false)), }); } static fromArray(arr) { return new ReduceMask({ list: arr.map((item) => Bool(item)), }); } toJSON() { return this.list.map((item) => item.toBoolean()); } toField() { return Field.fromBits(this.list); } } //# sourceMappingURL=common.js.map