From d9655fc137c7663f575715ebeae1cff09535fb83 Mon Sep 17 00:00:00 2001 From: microproofs Date: Wed, 27 Mar 2024 11:57:03 -0400 Subject: [PATCH] fix formatting and update workflow version --- .github/workflows/continuous-integration.yml | 2 +- lib/aiken/cbor.ak | 6 +-- lib/aiken/int.ak | 40 +++++++------- lib/aiken/math/rational.ak | 12 ++--- lib/aiken/transaction.ak | 56 ++++++++++---------- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4f51695..12e257f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -33,7 +33,7 @@ jobs: - name: 🧰 Install Aiken uses: aiken-lang/setup-aiken@v0.1.0 with: - version: v1.0.25-alpha + version: v1.0.26-alpha - name: 📝 Run fmt run: aiken fmt --check diff --git a/lib/aiken/cbor.ak b/lib/aiken/cbor.ak index 7f0db02..7de71e7 100644 --- a/lib/aiken/cbor.ak +++ b/lib/aiken/cbor.ak @@ -201,9 +201,9 @@ fn do_diagnostic(self: Data, builder: ByteArray) -> ByteArray { bytes |> encode_base16( - length_of_bytearray(bytes) - 1, - append_bytearray(#"27", builder), - ) + length_of_bytearray(bytes) - 1, + append_bytearray(#"27", builder), + ) |> append_bytearray(#"6827", _) }, ) diff --git a/lib/aiken/int.ak b/lib/aiken/int.ak index b0e7524..fd602b6 100644 --- a/lib/aiken/int.ak +++ b/lib/aiken/int.ak @@ -32,26 +32,26 @@ pub fn compare(left: Int, right: Int) -> Ordering { pub fn from_utf8(bytes: ByteArray) -> Option { bytes |> bytearray.foldr( - Some((0, 0)), - fn(byte, st) { - when st is { - None -> None - Some((n, e)) -> - if byte < 48 || byte > 57 { - if byte == 45 { - Some((-n, 0)) - } else { - None - } - } else if n < 0 { - None - } else { - let digit = byte - 48 - Some((n + digit * math.pow(10, e), e + 1)) - } - } - }, - ) + Some((0, 0)), + fn(byte, st) { + when st is { + None -> None + Some((n, e)) -> + if byte < 48 || byte > 57 { + if byte == 45 { + Some((-n, 0)) + } else { + None + } + } else if n < 0 { + None + } else { + let digit = byte - 48 + Some((n + digit * math.pow(10, e), e + 1)) + } + } + }, + ) |> option.map(fn(tuple) { tuple.1st }) } diff --git a/lib/aiken/math/rational.ak b/lib/aiken/math/rational.ak index 6e0ec04..e62a65d 100644 --- a/lib/aiken/math/rational.ak +++ b/lib/aiken/math/rational.ak @@ -644,7 +644,7 @@ test compare_with_eq() { expect Some(x) = new(2, 3) expect Some(y) = new(3, 4) - !eq(x, y)? && ( !eq(y, x)? && eq(x, x)? ) + !eq(x, y)? && !eq(y, x)? && eq(x, x)? } test compare_with_neq() { @@ -654,7 +654,7 @@ test compare_with_neq() { expect Some(x) = new(2, 3) expect Some(y) = new(3, 4) - neq(x, y)? && ( neq(y, x)? && !neq(x, x)? ) + neq(x, y)? && neq(y, x)? && !neq(x, x)? } test compare_with_gte() { @@ -664,7 +664,7 @@ test compare_with_gte() { expect Some(x) = new(2, 3) expect Some(y) = new(3, 4) - !gte(x, y)? && ( gte(y, x)? && gte(x, x)? ) + !gte(x, y)? && gte(y, x)? && gte(x, x)? } test compare_with_gt() { @@ -674,7 +674,7 @@ test compare_with_gt() { expect Some(x) = new(2, 3) expect Some(y) = new(3, 4) - !gt(x, y)? && ( gt(y, x)? && !gt(x, x)? ) + !gt(x, y)? && gt(y, x)? && !gt(x, x)? } test compare_with_lte() { @@ -684,7 +684,7 @@ test compare_with_lte() { expect Some(x) = new(2, 3) expect Some(y) = new(3, 4) - lte(x, y)? && ( !lte(y, x)? && lte(x, x)? ) + lte(x, y)? && !lte(y, x)? && lte(x, x)? } test compare_with_lt() { @@ -694,7 +694,7 @@ test compare_with_lt() { expect Some(x) = new(2, 3) expect Some(y) = new(3, 4) - lt(x, y)? && ( !lt(y, x)? && !lt(x, x)? ) + lt(x, y)? && !lt(y, x)? && !lt(x, x)? } /// Calculate the arithmetic mean between two `Rational` values. diff --git a/lib/aiken/transaction.ak b/lib/aiken/transaction.ak index 6b3cbb1..fb020ed 100644 --- a/lib/aiken/transaction.ak +++ b/lib/aiken/transaction.ak @@ -183,26 +183,26 @@ pub fn find_datum( datums |> dict.get(datum_hash) |> option.or_try( - fn() { - outputs - |> list.filter_map( - fn(output) { - when output.datum is { - InlineDatum(data) -> - if - blake2b_256(builtin.serialise_data(data)) == datum_hash{ - - Some(data) - } else { - None - } - _ -> None - } - }, - ) - |> list.head - }, - ) + fn() { + outputs + |> list.filter_map( + fn(output) { + when output.datum is { + InlineDatum(data) -> + if + blake2b_256(builtin.serialise_data(data)) == datum_hash{ + + Some(data) + } else { + None + } + _ -> None + } + }, + ) + |> list.head + }, + ) } /// Find all outputs that are paying into the given script hash, if any. This is useful for @@ -213,12 +213,12 @@ pub fn find_script_outputs( ) -> List { outputs |> list.filter( - fn(output) { - when output.address.payment_credential is { - ScriptCredential(addr_script_hash) -> - script_hash == addr_script_hash - VerificationKeyCredential(_) -> False - } - }, - ) + fn(output) { + when output.address.payment_credential is { + ScriptCredential(addr_script_hash) -> + script_hash == addr_script_hash + VerificationKeyCredential(_) -> False + } + }, + ) }