Skip to content

Commit 8b29b90

Browse files
committed
Add 'transaction.value.is_zero'
Fixes aiken-lang#67.
1 parent 6ad7ee2 commit 8b29b90

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- [`list.index_of`](https://aiken-lang.github.io/stdlib/aiken/list.html#index_of): For getting a values index in a list.
88
- [`transaction.placeholder`](https://aiken-lang.github.io/stdlib/aiken/transaction.html#placeholder): For constructing test transactions.
9+
- [`transaction.value.is_zero`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#is_zero): For checking whether a value is null.
910

1011
### Changed
1112

lib/aiken/transaction/value.ak

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ pub fn zero() -> Value {
3939
Value { inner: dict.new() }
4040
}
4141

42+
/// Check is a `Value` is zero. That is, it has no assets and holds no Ada/Lovelace.
43+
pub fn is_zero(self: Value) -> Bool {
44+
self == zero()
45+
}
46+
4247
/// Construct a `Value` from an asset identifier (i.e. `PolicyId` + `AssetName`)
4348
/// and a given quantity.
4449
pub fn from_asset(

0 commit comments

Comments
 (0)