From fb6f43ff21a1abe85e1c983c768c3d745004315d Mon Sep 17 00:00:00 2001 From: querolita Date: Mon, 25 Nov 2024 17:01:32 +0100 Subject: [PATCH 1/3] add assertNone method for options --- src/lib/provable/option.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/provable/option.ts b/src/lib/provable/option.ts index cc82a568a..c579e2401 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(): void; orElse(defaultValue: T | V): T; }; @@ -104,6 +105,10 @@ function Option( return this.value; } + assertNone(): void { + this.isSome.assertFalse(); + } + static from(value?: V | T) { return value === undefined ? new Option_({ From 1adb75953033a32bf238b29fc1d2d6b883c6fcdb Mon Sep 17 00:00:00 2001 From: querolita Date: Mon, 25 Nov 2024 17:03:24 +0100 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da97589a3..d09013958 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Compiling stuck in the browser for recursive zkprograms https://github.com/o1-labs/o1js/pull/1906 +### 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 From 610b2eb56da96c2ce72b22dca4d30c9652500b80 Mon Sep 17 00:00:00 2001 From: querolita Date: Wed, 27 Nov 2024 12:10:10 +0100 Subject: [PATCH 3/3] optional error message in assert none --- src/lib/provable/option.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/provable/option.ts b/src/lib/provable/option.ts index c579e2401..edec98d60 100644 --- a/src/lib/provable/option.ts +++ b/src/lib/provable/option.ts @@ -9,7 +9,7 @@ export { Option, OptionOrValue }; type Option = { isSome: Bool; value: T } & { assertSome(message?: string): T; - assertNone(): void; + assertNone(message?: string): void; orElse(defaultValue: T | V): T; }; @@ -105,8 +105,8 @@ function Option( return this.value; } - assertNone(): void { - this.isSome.assertFalse(); + assertNone(message?: string): void { + this.isSome.assertFalse(message); } static from(value?: V | T) {