Skip to content

Commit

Permalink
Merge pull request #1922 from o1-labs/features/option/none
Browse files Browse the repository at this point in the history
[easy] Add assertNone method for options
  • Loading branch information
querolita authored Nov 27, 2024
2 parents 50306ef + 834e752 commit cb0b270
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/lib/provable/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { Option, OptionOrValue };

type Option<T, V = any> = { isSome: Bool; value: T } & {
assertSome(message?: string): T;
assertNone(message?: string): void;
orElse(defaultValue: T | V): T;
};

Expand Down Expand Up @@ -104,6 +105,10 @@ function Option<A extends ProvableType>(
return this.value;
}

assertNone(message?: string): void {
this.isSome.assertFalse(message);
}

static from(value?: V | T) {
return value === undefined
? new Option_({
Expand Down

0 comments on commit cb0b270

Please sign in to comment.