diff --git a/CHANGELOG.md b/CHANGELOG.md index 818919ea0..c50ff5506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,9 +25,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed - Compiling stuck in the browser for recursive zkprograms https://github.com/o1-labs/o1js/pull/1906 - - Error message in `rangeCheck16` gadget https://github.com/o1-labs/o1js/pull/1920 +### Added + +- Method for optional types to assert none https://github.com/o1-labs/o1js/pull/1922 + ## [2.1.0](https://github.com/o1-labs/o1js/compare/b04520d...e1bac02) - 2024-11-13 ### Added diff --git a/src/lib/provable/option.ts b/src/lib/provable/option.ts index cc82a568a..edec98d60 100644 --- a/src/lib/provable/option.ts +++ b/src/lib/provable/option.ts @@ -9,6 +9,7 @@ export { Option, OptionOrValue }; type Option = { isSome: Bool; value: T } & { assertSome(message?: string): T; + assertNone(message?: string): void; orElse(defaultValue: T | V): T; }; @@ -104,6 +105,10 @@ function Option( return this.value; } + assertNone(message?: string): void { + this.isSome.assertFalse(message); + } + static from(value?: V | T) { return value === undefined ? new Option_({