Re-format and re-run all acceptance tests.
This commit is contained in:
		
							parent
							
								
									9ee2d58ba3
								
							
						
					
					
						commit
						b50e4ab63a
					
				| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn length(xs: List<a>) -> Int {
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      0
 | 
			
		||||
    [_, ..rest] ->
 | 
			
		||||
      1 + length(rest)
 | 
			
		||||
    [] -> 0
 | 
			
		||||
    [_, ..rest] -> 1 + length(rest)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      zero
 | 
			
		||||
    [x, ..rest] ->
 | 
			
		||||
      f(x, foldr(rest, f, zero))
 | 
			
		||||
    [] -> zero
 | 
			
		||||
    [x, ..rest] -> f(x, foldr(rest, f, zero))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      zero
 | 
			
		||||
    [x, ..rest] ->
 | 
			
		||||
      f(x, foldr(rest, f, zero))
 | 
			
		||||
    [] -> zero
 | 
			
		||||
    [x, ..rest] -> f(x, foldr(rest, f, zero))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,4 +10,3 @@ test bar() {
 | 
			
		|||
    False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,8 @@ pub fn unzip(xs: List<(a, b)>) -> (List<a>, List<b>) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test unzip1() {
 | 
			
		||||
  let x = [(3, #"55"), (4, #"7799")]
 | 
			
		||||
  let x =
 | 
			
		||||
    [(3, #"55"), (4, #"7799")]
 | 
			
		||||
 | 
			
		||||
  unzip(x) == ([3, 4], [#"55", #"7799"])
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn map(opt: Option<a>, f: fn(a) -> b) -> Option<b> {
 | 
			
		||||
  when opt is {
 | 
			
		||||
    None ->
 | 
			
		||||
      None
 | 
			
		||||
    Some(a) ->
 | 
			
		||||
      Some(f(a))
 | 
			
		||||
    None -> None
 | 
			
		||||
    Some(a) -> Some(f(a))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,8 @@
 | 
			
		|||
pub fn unzip(xs: List<(a, b)>) -> (List<a>, List<b>) {
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      ([], [])
 | 
			
		||||
    [] -> ([], [])
 | 
			
		||||
    [(a, b), ..rest] -> {
 | 
			
		||||
      let (a_tail, b_tail) =
 | 
			
		||||
        unzip(rest)
 | 
			
		||||
      let (a_tail, b_tail) = unzip(rest)
 | 
			
		||||
      ([a, ..a_tail], [b, ..b_tail])
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,6 @@ pub fn drop(bytes: ByteArray, n: Int) -> ByteArray {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test drop_1() {
 | 
			
		||||
  let x =
 | 
			
		||||
    #"01020304050607"
 | 
			
		||||
  let x = #"01020304050607"
 | 
			
		||||
  drop(x, 2) == #"0304050607"
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn or_else(opt: Option<a>, default: a) -> a {
 | 
			
		||||
  when opt is {
 | 
			
		||||
    None ->
 | 
			
		||||
      default
 | 
			
		||||
    Some(a) ->
 | 
			
		||||
      a
 | 
			
		||||
    None -> default
 | 
			
		||||
    Some(a) -> a
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn map(opt: Option<a>, f: fn(a) -> result) -> Option<result> {
 | 
			
		||||
  when opt is {
 | 
			
		||||
    None ->
 | 
			
		||||
      None
 | 
			
		||||
    Some(a) ->
 | 
			
		||||
      Some(f(a))
 | 
			
		||||
    None -> None
 | 
			
		||||
    Some(a) -> Some(f(a))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn map(opt: Option<a>, f: fn(a) -> result) -> Option<result> {
 | 
			
		||||
  when opt is {
 | 
			
		||||
    None ->
 | 
			
		||||
      None
 | 
			
		||||
    Some(a) ->
 | 
			
		||||
      Some(f(a))
 | 
			
		||||
    None -> None
 | 
			
		||||
    Some(a) -> Some(f(a))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      zero
 | 
			
		||||
    [x, ..rest] ->
 | 
			
		||||
      f(x, foldr(rest, f, zero))
 | 
			
		||||
    [] -> zero
 | 
			
		||||
    [x, ..rest] -> f(x, foldr(rest, f, zero))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -12,8 +10,7 @@ pub fn filter_map(xs: List<a>, f: fn(a) -> Option<b>) -> List<b> {
 | 
			
		|||
    xs,
 | 
			
		||||
    fn(x, ys) {
 | 
			
		||||
      when f(x) is {
 | 
			
		||||
        None ->
 | 
			
		||||
          ys
 | 
			
		||||
        None -> ys
 | 
			
		||||
        Some(y) ->
 | 
			
		||||
          [y, ..ys]
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,14 +4,11 @@ pub fn map2(
 | 
			
		|||
  f: fn(a, b) -> result,
 | 
			
		||||
) -> Option<result> {
 | 
			
		||||
  when opt_a is {
 | 
			
		||||
    None ->
 | 
			
		||||
      None
 | 
			
		||||
    None -> None
 | 
			
		||||
    Some(a) ->
 | 
			
		||||
      when opt_b is {
 | 
			
		||||
        None ->
 | 
			
		||||
          None
 | 
			
		||||
        Some(b) ->
 | 
			
		||||
          Some(f(a, b))
 | 
			
		||||
        None -> None
 | 
			
		||||
        Some(b) -> Some(f(a, b))
 | 
			
		||||
      }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      zero
 | 
			
		||||
    [x, ..rest] ->
 | 
			
		||||
      f(x, foldr(rest, f, zero))
 | 
			
		||||
    [] -> zero
 | 
			
		||||
    [x, ..rest] -> f(x, foldr(rest, f, zero))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,8 +13,7 @@ pub fn flat_map(xs: List<a>, f: fn(a) -> List<b>) -> List<b> {
 | 
			
		|||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      []
 | 
			
		||||
    [x, ..rest] ->
 | 
			
		||||
      concat(f(x), flat_map(rest, f))
 | 
			
		||||
    [x, ..rest] -> concat(f(x), flat_map(rest, f))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,8 +14,7 @@ fn do_from_list(xs: List<(key, value)>) -> List<(key, value)> {
 | 
			
		|||
  when xs is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      []
 | 
			
		||||
    [(k, v), ..rest] ->
 | 
			
		||||
      do_insert(do_from_list(rest), k, v)
 | 
			
		||||
    [(k, v), ..rest] -> do_insert(do_from_list(rest), k, v)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -52,10 +51,8 @@ fn do_union(
 | 
			
		|||
  right: List<(key, value)>,
 | 
			
		||||
) -> List<(key, value)> {
 | 
			
		||||
  when left is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      right
 | 
			
		||||
    [(k, v), ..rest] ->
 | 
			
		||||
      do_union(rest, do_insert(right, k, v))
 | 
			
		||||
    [] -> right
 | 
			
		||||
    [(k, v), ..rest] -> do_union(rest, do_insert(right, k, v))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
test tuple_1() {
 | 
			
		||||
  let coordinates =
 | 
			
		||||
    (14, 42)
 | 
			
		||||
  let coordinates = (14, 42)
 | 
			
		||||
  coordinates.1st == 14 && coordinates.2nd == 42
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn foldr(self: List<a>, with: fn(a, b) -> b, zero: b) -> b {
 | 
			
		||||
  when self is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      zero
 | 
			
		||||
    [x, ..xs] ->
 | 
			
		||||
      with(x, foldr(xs, with, zero))
 | 
			
		||||
    [] -> zero
 | 
			
		||||
    [x, ..xs] -> with(x, foldr(xs, with, zero))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,8 +37,7 @@ fn do_union_with(
 | 
			
		|||
  with: fn(ByteArray, value, value) -> Option<value>,
 | 
			
		||||
) -> List<(ByteArray, value)> {
 | 
			
		||||
  when left is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      right
 | 
			
		||||
    [] -> right
 | 
			
		||||
    [(k, v), ..rest] ->
 | 
			
		||||
      do_union_with(rest, do_insert_with(right, k, v, with), with)
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -58,8 +57,7 @@ fn do_insert_with(
 | 
			
		|||
        when with(k, v, v2) is {
 | 
			
		||||
          Some(combined) ->
 | 
			
		||||
            [(k, combined), ..rest]
 | 
			
		||||
          None ->
 | 
			
		||||
            rest
 | 
			
		||||
          None -> rest
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        [(k2, v2), ..do_insert_with(rest, k, v, with)]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,8 +35,7 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
 | 
			
		|||
          a0,
 | 
			
		||||
          a1,
 | 
			
		||||
          fn(_, q0, q1) {
 | 
			
		||||
            let q =
 | 
			
		||||
              q0 + q1
 | 
			
		||||
            let q = q0 + q1
 | 
			
		||||
            if q == 0 {
 | 
			
		||||
              None
 | 
			
		||||
            } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -46,19 +45,15 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
 | 
			
		|||
        )
 | 
			
		||||
 | 
			
		||||
      when dict.toList(asset) is {
 | 
			
		||||
        [] ->
 | 
			
		||||
          None
 | 
			
		||||
        _ ->
 | 
			
		||||
          Some(asset)
 | 
			
		||||
        [] -> None
 | 
			
		||||
        _ -> Some(asset)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test add_1() {
 | 
			
		||||
  let v1 =
 | 
			
		||||
    from_lovelace(1)
 | 
			
		||||
  let v2 =
 | 
			
		||||
    from_lovelace(-1)
 | 
			
		||||
  let v1 = from_lovelace(1)
 | 
			
		||||
  let v2 = from_lovelace(-1)
 | 
			
		||||
  add(v1, v2) == dict.new()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181051, nanos_since_epoch = 270212000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743641, nanos_since_epoch = 8357000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+0161cf6"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,8 +3,7 @@ use aiken/list
 | 
			
		|||
use aiken/transaction.{Output, OutputReference, ScriptContext}
 | 
			
		||||
use aiken/transaction/value.{PolicyId}
 | 
			
		||||
 | 
			
		||||
const my_policy_id: PolicyId =
 | 
			
		||||
  #"0000000000"
 | 
			
		||||
const my_policy_id: PolicyId = #"0000000000"
 | 
			
		||||
 | 
			
		||||
pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool {
 | 
			
		||||
  self.value
 | 
			
		||||
| 
						 | 
				
			
			@ -28,10 +27,8 @@ validator(output_reference: OutputReference) {
 | 
			
		|||
        fn(input) { input.output_reference == output_reference },
 | 
			
		||||
      )
 | 
			
		||||
    is {
 | 
			
		||||
      Some(_) ->
 | 
			
		||||
        True
 | 
			
		||||
      None ->
 | 
			
		||||
        False
 | 
			
		||||
      Some(_) -> True
 | 
			
		||||
      None -> False
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,7 @@
 | 
			
		|||
pub fn and_f(self: List<Bool>) -> Bool {
 | 
			
		||||
  when self is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      True
 | 
			
		||||
    [x, ..xs] ->
 | 
			
		||||
      x && and_f(xs)
 | 
			
		||||
    [] -> True
 | 
			
		||||
    [x, ..xs] -> x && and_f(xs)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -13,10 +11,8 @@ test and_f_1() {
 | 
			
		|||
 | 
			
		||||
pub fn or_f(self: List<Bool>) -> Bool {
 | 
			
		||||
  when self is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      False
 | 
			
		||||
    [x, ..xs] ->
 | 
			
		||||
      x || or_f(xs)
 | 
			
		||||
    [] -> False
 | 
			
		||||
    [x, ..xs] -> x || or_f(xs)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,23 +1,17 @@
 | 
			
		|||
test foo_1() {
 | 
			
		||||
  let a =
 | 
			
		||||
    False
 | 
			
		||||
  let a = False
 | 
			
		||||
  when a is {
 | 
			
		||||
    True ->
 | 
			
		||||
      False
 | 
			
		||||
    False ->
 | 
			
		||||
      True
 | 
			
		||||
    True -> False
 | 
			
		||||
    False -> True
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test foo_2() {
 | 
			
		||||
  let a =
 | 
			
		||||
    False
 | 
			
		||||
  let a = False
 | 
			
		||||
  let b =
 | 
			
		||||
    when a is {
 | 
			
		||||
      True ->
 | 
			
		||||
        14
 | 
			
		||||
      False ->
 | 
			
		||||
        42
 | 
			
		||||
      True -> 14
 | 
			
		||||
      False -> 42
 | 
			
		||||
    }
 | 
			
		||||
  b == 42
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,6 @@ fn fibonnaci(n) {
 | 
			
		|||
test foo() {
 | 
			
		||||
  let right =
 | 
			
		||||
    fn() { fibonnaci(15) == 610 }
 | 
			
		||||
  let left =
 | 
			
		||||
    False
 | 
			
		||||
  let left = False
 | 
			
		||||
  left || right()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,13 +2,9 @@ test sort_by_1() {
 | 
			
		|||
  let xs =
 | 
			
		||||
    [[4, 3, 2, 1], [2, 3, 4, 5]]
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [[], ys] ->
 | 
			
		||||
      False
 | 
			
		||||
    [xs, []] ->
 | 
			
		||||
      False
 | 
			
		||||
    [[x, ..xs2], [y, ..ys2]] ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    [[], ys] -> False
 | 
			
		||||
    [xs, []] -> False
 | 
			
		||||
    [[x, ..xs2], [y, ..ys2]] -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+0161cf6"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,48 +1,34 @@
 | 
			
		|||
test foo_1() {
 | 
			
		||||
  let a =
 | 
			
		||||
    False
 | 
			
		||||
  let a = False
 | 
			
		||||
  when a is {
 | 
			
		||||
    a if a ->
 | 
			
		||||
      False
 | 
			
		||||
    _ ->
 | 
			
		||||
      True
 | 
			
		||||
    a if a -> False
 | 
			
		||||
    _ -> True
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test foo_2() {
 | 
			
		||||
  let point =
 | 
			
		||||
    (14, 42)
 | 
			
		||||
  let point = (14, 42)
 | 
			
		||||
  when point is {
 | 
			
		||||
    (x, _) if x > 100 ->
 | 
			
		||||
      False
 | 
			
		||||
    (x, _) if x > 10 ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    (x, _) if x > 100 -> False
 | 
			
		||||
    (x, _) if x > 10 -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test foo_3() {
 | 
			
		||||
  let point =
 | 
			
		||||
    (14, 42)
 | 
			
		||||
  let point = (14, 42)
 | 
			
		||||
  when point is {
 | 
			
		||||
    (x, y) if x == 14 && y <= 100 ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    (x, y) if x == 14 && y <= 100 -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test foo_4() {
 | 
			
		||||
  let a =
 | 
			
		||||
    False
 | 
			
		||||
  let point =
 | 
			
		||||
    (14, 42)
 | 
			
		||||
  let a = False
 | 
			
		||||
  let point = (14, 42)
 | 
			
		||||
  when point is {
 | 
			
		||||
    (x, y) if !a ->
 | 
			
		||||
      x + y == 56
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    (x, y) if !a -> x + y == 56
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -55,12 +41,9 @@ type Seasons {
 | 
			
		|||
 | 
			
		||||
fn is_cold(season, hour) {
 | 
			
		||||
  when season is {
 | 
			
		||||
    Winter | Fall ->
 | 
			
		||||
      True
 | 
			
		||||
    _ if hour >= 18 ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    Winter | Fall -> True
 | 
			
		||||
    _ if hour >= 18 -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -70,8 +53,7 @@ test foo_5() {
 | 
			
		|||
 | 
			
		||||
fn when_tuple(a: (Int, Int)) -> Int {
 | 
			
		||||
  when a is {
 | 
			
		||||
    (a, _b) ->
 | 
			
		||||
      a
 | 
			
		||||
    (a, _b) -> a
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
pub fn when_tuple(a: (Int, Int)) -> Int {
 | 
			
		||||
  when a is {
 | 
			
		||||
    (a, b) ->
 | 
			
		||||
      a
 | 
			
		||||
    (a, b) -> a
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,55 +5,46 @@ pub type Thing {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test let_1() {
 | 
			
		||||
  let x: Data =
 | 
			
		||||
    1
 | 
			
		||||
  let x: Data = 1
 | 
			
		||||
 | 
			
		||||
  x == builtin.i_data(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test let_2() {
 | 
			
		||||
  let x: Data =
 | 
			
		||||
    1
 | 
			
		||||
  let x: Data = 1
 | 
			
		||||
 | 
			
		||||
  expect y: Int =
 | 
			
		||||
    x
 | 
			
		||||
  expect y: Int = x
 | 
			
		||||
 | 
			
		||||
  y == 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test assert_1() {
 | 
			
		||||
  expect thing: Thing =
 | 
			
		||||
    builtin.constr_data(0, [builtin.i_data(1)])
 | 
			
		||||
  expect thing: Thing = builtin.constr_data(0, [builtin.i_data(1)])
 | 
			
		||||
 | 
			
		||||
  thing.wow == 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn cast_to_thing(x: Data) -> Thing {
 | 
			
		||||
  expect x: Thing =
 | 
			
		||||
    x
 | 
			
		||||
  expect x: Thing = x
 | 
			
		||||
 | 
			
		||||
  x
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test assert_2() {
 | 
			
		||||
  let thing =
 | 
			
		||||
    Thing { wow: 1 }
 | 
			
		||||
  let thing = Thing { wow: 1 }
 | 
			
		||||
 | 
			
		||||
  let still_thing =
 | 
			
		||||
    cast_to_thing(thing)
 | 
			
		||||
  let still_thing = cast_to_thing(thing)
 | 
			
		||||
 | 
			
		||||
  still_thing.wow == 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test tuple_1() {
 | 
			
		||||
  let thing =
 | 
			
		||||
    (#"aa", #"bb", #"cc")
 | 
			
		||||
  let thing = (#"aa", #"bb", #"cc")
 | 
			
		||||
  thing.1st == #"aa"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test pair_1() {
 | 
			
		||||
  let thing =
 | 
			
		||||
    (#"aa", #"bb")
 | 
			
		||||
  let thing = (#"aa", #"bb")
 | 
			
		||||
  thing.1st == #"aa"
 | 
			
		||||
}
 | 
			
		||||
// should not typecheck
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,20 +3,16 @@ type TransactionId {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test pattern_match_let() {
 | 
			
		||||
  let x =
 | 
			
		||||
    TransactionId { inner: #"0000" }
 | 
			
		||||
  let TransactionId(y) =
 | 
			
		||||
    x
 | 
			
		||||
  let x = TransactionId { inner: #"0000" }
 | 
			
		||||
  let TransactionId(y) = x
 | 
			
		||||
  y == #"0000"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test pattern_match_when() {
 | 
			
		||||
  let x =
 | 
			
		||||
    TransactionId { inner: #"0000" }
 | 
			
		||||
  let x = TransactionId { inner: #"0000" }
 | 
			
		||||
  let y =
 | 
			
		||||
    when x is {
 | 
			
		||||
      TransactionId(y) ->
 | 
			
		||||
        y
 | 
			
		||||
      TransactionId(y) -> y
 | 
			
		||||
    }
 | 
			
		||||
  y == #"0000"
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,15 +5,12 @@ pub type LinkedList<a> {
 | 
			
		|||
 | 
			
		||||
pub fn size(t: LinkedList<alg>) -> Int {
 | 
			
		||||
  when t is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      0
 | 
			
		||||
    Node(_, tail) ->
 | 
			
		||||
      1 + size(tail)
 | 
			
		||||
    Empty -> 0
 | 
			
		||||
    Node(_, tail) -> 1 + size(tail)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test foo() {
 | 
			
		||||
  let xs =
 | 
			
		||||
    Node(0, Node(1, Node(2, Empty)))
 | 
			
		||||
  let xs = Node(0, Node(1, Node(2, Empty)))
 | 
			
		||||
  size(xs) == 3
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181048, nanos_since_epoch = 152219000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 944875000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
use aiken/transaction/value
 | 
			
		||||
 | 
			
		||||
test test_quantity_of_1() {
 | 
			
		||||
  let x =
 | 
			
		||||
    value.from_asset(#"000000", #"000020e05363726970744f776e6572", -1)
 | 
			
		||||
  let x = value.from_asset(#"000000", #"000020e05363726970744f776e6572", -1)
 | 
			
		||||
  value.quantity_of(x, #"000000", #"000020e05363726970744f776e6572") < 0
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181051, nanos_since_epoch = 995566000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 21373000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
use aiken/bytearray
 | 
			
		||||
use aiken/dict
 | 
			
		||||
use aiken/hash.{Hash, Sha2_256, sha2_256}
 | 
			
		||||
use aiken/interval.{between, intersection, is_empty, entirely_between}
 | 
			
		||||
use aiken/interval.{between, entirely_between, intersection, is_empty}
 | 
			
		||||
use aiken/list
 | 
			
		||||
use aiken/transaction.{InlineDatum}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,12 +15,9 @@ pub type MerkleTree {
 | 
			
		|||
 | 
			
		||||
pub fn root_hash(t: MerkleTree) -> Hash<Sha2_256, ByteArray> {
 | 
			
		||||
  when t is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      #""
 | 
			
		||||
    Leaf { hash, .. } ->
 | 
			
		||||
      hash
 | 
			
		||||
    Node { hash, .. } ->
 | 
			
		||||
      hash
 | 
			
		||||
    Empty -> #""
 | 
			
		||||
    Leaf { hash, .. } -> hash
 | 
			
		||||
    Node { hash, .. } -> hash
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,12 +27,9 @@ pub fn is_equal(a: MerkleTree, b: MerkleTree) -> Bool {
 | 
			
		|||
 | 
			
		||||
pub fn size(t: MerkleTree) -> Int {
 | 
			
		||||
  when t is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      0
 | 
			
		||||
    Leaf { .. } ->
 | 
			
		||||
      1
 | 
			
		||||
    Node { left, right, .. } ->
 | 
			
		||||
      size(left) + size(right)
 | 
			
		||||
    Empty -> 0
 | 
			
		||||
    Leaf { .. } -> 1
 | 
			
		||||
    Node { left, right, .. } -> size(left) + size(right)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -49,13 +43,10 @@ pub fn from_list(items0: List<ByteArray>) -> MerkleTree {
 | 
			
		|||
 | 
			
		||||
fn do_from_list(items: List<ByteArray>, len: Int) -> MerkleTree {
 | 
			
		||||
  when items is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      Empty
 | 
			
		||||
    [value] ->
 | 
			
		||||
      Leaf { hash: sha2_256(value), value }
 | 
			
		||||
    [] -> Empty
 | 
			
		||||
    [value] -> Leaf { hash: sha2_256(value), value }
 | 
			
		||||
    all -> {
 | 
			
		||||
      let cutoff: Int =
 | 
			
		||||
        len / 2
 | 
			
		||||
      let cutoff: Int = len / 2
 | 
			
		||||
      let left =
 | 
			
		||||
        all
 | 
			
		||||
          |> list.take(cutoff)
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +55,7 @@ fn do_from_list(items: List<ByteArray>, len: Int) -> MerkleTree {
 | 
			
		|||
        all
 | 
			
		||||
          |> list.drop(cutoff)
 | 
			
		||||
          |> do_from_list(len - cutoff)
 | 
			
		||||
      let hash =
 | 
			
		||||
        combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      let hash = combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      Node { hash, left, right }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -74,8 +64,7 @@ fn do_from_list(items: List<ByteArray>, len: Int) -> MerkleTree {
 | 
			
		|||
test foo() {
 | 
			
		||||
  let items =
 | 
			
		||||
    [#"aa", #"bb", #"cc"]
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items)
 | 
			
		||||
  let mt = from_list(items)
 | 
			
		||||
  size(mt) == 3
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -84,19 +73,15 @@ test some_test1() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test intersection_3() {
 | 
			
		||||
  let iv1 =
 | 
			
		||||
    between(0, 1)
 | 
			
		||||
  let iv2 =
 | 
			
		||||
    entirely_between(1, 2)
 | 
			
		||||
  let iv1 = between(0, 1)
 | 
			
		||||
  let iv2 = entirely_between(1, 2)
 | 
			
		||||
  intersection(iv1, iv2)
 | 
			
		||||
    |> is_empty
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const fooz =
 | 
			
		||||
  #"666f6f"
 | 
			
		||||
const fooz = #"666f6f"
 | 
			
		||||
 | 
			
		||||
const bar =
 | 
			
		||||
  #"626172"
 | 
			
		||||
const bar = #"626172"
 | 
			
		||||
 | 
			
		||||
fn fixture_1() {
 | 
			
		||||
  dict.new()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,9 @@
 | 
			
		|||
// Could possibly be forbidden by the parser instead if we have no intent to support that.
 | 
			
		||||
pub fn choice(self: List<Option<a>>) -> Option<a> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      None
 | 
			
		||||
    [Some(_) as result, ..] ->
 | 
			
		||||
      result
 | 
			
		||||
    [None, ..others] ->
 | 
			
		||||
      choice(others)
 | 
			
		||||
    [] -> None
 | 
			
		||||
    [Some(_) as result, ..] -> result
 | 
			
		||||
    [None, ..others] -> choice(others)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,8 @@
 | 
			
		|||
pub fn choice(self: List<Option<a>>) -> Option<a> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      None
 | 
			
		||||
    [Some(x), ..] ->
 | 
			
		||||
      Some(x)
 | 
			
		||||
    [None, ..others] ->
 | 
			
		||||
      choice(others)
 | 
			
		||||
    [] -> None
 | 
			
		||||
    [Some(x), ..] -> Some(x)
 | 
			
		||||
    [None, ..others] -> choice(others)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,8 @@
 | 
			
		|||
pub fn choice(self: List<Option<a>>) -> Option<a> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      None
 | 
			
		||||
    [None, ..others] ->
 | 
			
		||||
      choice(others)
 | 
			
		||||
    [result, ..] ->
 | 
			
		||||
      result
 | 
			
		||||
    [] -> None
 | 
			
		||||
    [None, ..others] -> choice(others)
 | 
			
		||||
    [result, ..] -> result
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,9 @@
 | 
			
		|||
pub fn alt(left: Option<a>, right: Option<a>) -> Option<a> {
 | 
			
		||||
  when (left, right) is {
 | 
			
		||||
    (Some(a), Some(_)) ->
 | 
			
		||||
      Some(a)
 | 
			
		||||
    (None, Some(a)) ->
 | 
			
		||||
      Some(a)
 | 
			
		||||
    (Some(a), None) ->
 | 
			
		||||
      Some(a)
 | 
			
		||||
    (None, None) ->
 | 
			
		||||
      None
 | 
			
		||||
    (Some(a), Some(_)) -> Some(a)
 | 
			
		||||
    (None, Some(a)) -> Some(a)
 | 
			
		||||
    (Some(a), None) -> Some(a)
 | 
			
		||||
    (None, None) -> None
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,8 @@ test foo() {
 | 
			
		|||
  let xs =
 | 
			
		||||
    [1, 2, 3]
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [x] ->
 | 
			
		||||
      x == 1
 | 
			
		||||
    _ ->
 | 
			
		||||
      whatever(xs)
 | 
			
		||||
    [x] -> x == 1
 | 
			
		||||
    _ -> whatever(xs)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -17,9 +15,7 @@ test bar() {
 | 
			
		|||
  let xs =
 | 
			
		||||
    [1, 2, 3]
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [x] ->
 | 
			
		||||
      x == 1
 | 
			
		||||
    ys ->
 | 
			
		||||
      whatever(ys)
 | 
			
		||||
    [x] -> x == 1
 | 
			
		||||
    ys -> whatever(ys)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,10 +2,8 @@ test foo() {
 | 
			
		|||
  let xs =
 | 
			
		||||
    [[1, 2], [4, 5]]
 | 
			
		||||
  when xs is {
 | 
			
		||||
    [[_, _], [_, _]] ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    [[_, _], [_, _]] -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -14,10 +12,8 @@ test sort_by_1() {
 | 
			
		|||
    [[4, 3], [2, 3]]
 | 
			
		||||
  let g =
 | 
			
		||||
    when xs is {
 | 
			
		||||
      [[x, xs2], [y, ys2]] ->
 | 
			
		||||
        True
 | 
			
		||||
      _ ->
 | 
			
		||||
        False
 | 
			
		||||
      [[x, xs2], [y, ys2]] -> True
 | 
			
		||||
      _ -> False
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g == True
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,19 +1,16 @@
 | 
			
		|||
const int_constant =
 | 
			
		||||
  42
 | 
			
		||||
const int_constant = 42
 | 
			
		||||
 | 
			
		||||
test int() {
 | 
			
		||||
  int_constant == 42
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const bytearray_constant =
 | 
			
		||||
  #"abcd"
 | 
			
		||||
const bytearray_constant = #"abcd"
 | 
			
		||||
 | 
			
		||||
test bytearray() {
 | 
			
		||||
  bytearray_constant == #"abcd"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const string_constant =
 | 
			
		||||
  "FOO"
 | 
			
		||||
const string_constant = "FOO"
 | 
			
		||||
 | 
			
		||||
test string() {
 | 
			
		||||
  string_constant == "FOO"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181064, nanos_since_epoch = 69739000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743643, nanos_since_epoch = 126963000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,11 +8,9 @@ use aiken/transaction/credential.{
 | 
			
		|||
}
 | 
			
		||||
use aiken/transaction/value
 | 
			
		||||
 | 
			
		||||
const keyhash =
 | 
			
		||||
  #"010203040506"
 | 
			
		||||
const keyhash = #"010203040506"
 | 
			
		||||
 | 
			
		||||
const scripthash =
 | 
			
		||||
  #"060504030201"
 | 
			
		||||
const scripthash = #"060504030201"
 | 
			
		||||
 | 
			
		||||
pub fn keyhash_address(with_stake_credential: Option<StakeCredential>) {
 | 
			
		||||
  Address {
 | 
			
		||||
| 
						 | 
				
			
			@ -34,8 +32,7 @@ type SampleData {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
pub fn tx_1() -> Transaction {
 | 
			
		||||
  let sample_datum =
 | 
			
		||||
    SampleData { a: 1, b: #"01" }
 | 
			
		||||
  let sample_datum = SampleData { a: 1, b: #"01" }
 | 
			
		||||
  let tx =
 | 
			
		||||
    Transaction {
 | 
			
		||||
      inputs: [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181052, nanos_since_epoch = 418642000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 40391000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,8 +4,7 @@ fn must_be_signed(signatories) {
 | 
			
		|||
      trace @"no signatories"
 | 
			
		||||
      False
 | 
			
		||||
    }
 | 
			
		||||
    [sig, ..] ->
 | 
			
		||||
      (sig == "#ffff")?
 | 
			
		||||
    [sig, ..] -> (sig == "#ffff")?
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181066, nanos_since_epoch = 607926000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743643, nanos_since_epoch = 283477000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,25 +37,19 @@ pub fn to_list(self: MerkleTree<a>) -> List<a> {
 | 
			
		|||
      []
 | 
			
		||||
    Leaf { value, .. } ->
 | 
			
		||||
      [value]
 | 
			
		||||
    Node { left, right, .. } ->
 | 
			
		||||
      list.concat(to_list(left), to_list(right))
 | 
			
		||||
    Node { left, right, .. } -> list.concat(to_list(left), to_list(right))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test to_list_1() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  items == to_list(mt)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -63,54 +57,39 @@ test to_list_1() {
 | 
			
		|||
// Function returning a hash of a given Merkle Tree element
 | 
			
		||||
pub fn root_hash(self: MerkleTree<a>) -> Hash<Sha2_256, ByteArray> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      ""
 | 
			
		||||
    Leaf { hash, .. } ->
 | 
			
		||||
      hash
 | 
			
		||||
    Node { hash, .. } ->
 | 
			
		||||
      hash
 | 
			
		||||
    Empty -> ""
 | 
			
		||||
    Leaf { hash, .. } -> hash
 | 
			
		||||
    Node { hash, .. } -> hash
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test root_hash_1() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let node_hash =
 | 
			
		||||
    hash_fn(dog)
 | 
			
		||||
  let node_hash = hash_fn(dog)
 | 
			
		||||
 | 
			
		||||
  root_hash(mt) == node_hash
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test root_hash_3() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let node_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(cat), hash_fn(mouse)))
 | 
			
		||||
  let rh =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(dog), node_hash))
 | 
			
		||||
  let node_hash = sha2_256(bytearray.concat(hash_fn(cat), hash_fn(mouse)))
 | 
			
		||||
  let rh = sha2_256(bytearray.concat(hash_fn(dog), node_hash))
 | 
			
		||||
 | 
			
		||||
  expect Node { hash: root_hash, .. } =
 | 
			
		||||
    mt
 | 
			
		||||
  expect Node { hash: root_hash, .. } = mt
 | 
			
		||||
 | 
			
		||||
  rh == root_hash
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -118,13 +97,10 @@ test root_hash_3() {
 | 
			
		|||
test root_hash_2() {
 | 
			
		||||
  let items =
 | 
			
		||||
    []
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let node_hash =
 | 
			
		||||
    #""
 | 
			
		||||
  let node_hash = #""
 | 
			
		||||
 | 
			
		||||
  root_hash(mt) == node_hash
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -137,78 +113,55 @@ pub fn is_equal(left: MerkleTree<a>, right: MerkleTree<a>) -> Bool {
 | 
			
		|||
/// Function returns a total numbers of leaves in the tree.
 | 
			
		||||
pub fn size(self: MerkleTree<a>) -> Int {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      0
 | 
			
		||||
    Leaf { .. } ->
 | 
			
		||||
      1
 | 
			
		||||
    Node { left, right, .. } ->
 | 
			
		||||
      size(left) + size(right)
 | 
			
		||||
    Empty -> 0
 | 
			
		||||
    Leaf { .. } -> 1
 | 
			
		||||
    Node { left, right, .. } -> size(left) + size(right)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test size_1() {
 | 
			
		||||
  let items =
 | 
			
		||||
    []
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
  size(mt) == 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test size_2() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list([dog, cat, mouse], hash_fn)
 | 
			
		||||
  let mt = from_list([dog, cat, mouse], hash_fn)
 | 
			
		||||
  size(mt) == 3
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test size_3() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
  size(mt) == 3
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test size_4() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let pig =
 | 
			
		||||
    "pig"
 | 
			
		||||
  let bull =
 | 
			
		||||
    "bull"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
  let pig = "pig"
 | 
			
		||||
  let bull = "bull"
 | 
			
		||||
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse, pig, bull]
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
  size(mt) == 6
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -222,28 +175,22 @@ fn combine_hash(
 | 
			
		|||
/// Function that returns whether merkle tree has any elements
 | 
			
		||||
pub fn is_empty(self: MerkleTree<a>) -> Bool {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    Empty -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test is_empty_1() {
 | 
			
		||||
  let mt =
 | 
			
		||||
    Empty
 | 
			
		||||
  let mt = Empty
 | 
			
		||||
 | 
			
		||||
  is_empty(mt)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test is_empty_2() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let hash =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let hash = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    Leaf { value: dog, hash: hash(dog) }
 | 
			
		||||
  let mt = Leaf { value: dog, hash: hash(dog) }
 | 
			
		||||
 | 
			
		||||
  is_empty(mt) == False
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -255,8 +202,7 @@ fn do_proof(
 | 
			
		|||
  hash_fn: fn(a) -> Hash<Sha2_256, a>,
 | 
			
		||||
) -> Option<Proof> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      None
 | 
			
		||||
    Empty -> None
 | 
			
		||||
    Leaf { hash, .. } ->
 | 
			
		||||
      if hash == item_hash {
 | 
			
		||||
        Some(proof)
 | 
			
		||||
| 
						 | 
				
			
			@ -264,10 +210,8 @@ fn do_proof(
 | 
			
		|||
        None
 | 
			
		||||
      }
 | 
			
		||||
    Node { left, right, .. } -> {
 | 
			
		||||
      let rh =
 | 
			
		||||
        root_hash(right)
 | 
			
		||||
      let lh =
 | 
			
		||||
        root_hash(left)
 | 
			
		||||
      let rh = root_hash(right)
 | 
			
		||||
      let lh = root_hash(left)
 | 
			
		||||
      let go_left: Option<Proof> =
 | 
			
		||||
        do_proof(left, item_hash, list.push(proof, Right { hash: rh }), hash_fn)
 | 
			
		||||
      let go_right: Option<Proof> =
 | 
			
		||||
| 
						 | 
				
			
			@ -292,130 +236,91 @@ pub fn get_proof(
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test get_proof_1() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let pig =
 | 
			
		||||
    "pig"
 | 
			
		||||
  let bull =
 | 
			
		||||
    "bull"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
  let pig = "pig"
 | 
			
		||||
  let bull = "bull"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse, pig, bull]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let maybe_proof: Option<Proof> =
 | 
			
		||||
    get_proof(mt, "parrot", hash_fn)
 | 
			
		||||
  let maybe_proof: Option<Proof> = get_proof(mt, "parrot", hash_fn)
 | 
			
		||||
 | 
			
		||||
  is_none(maybe_proof)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test get_proof_2() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let maybe_proof: Option<Proof> =
 | 
			
		||||
    get_proof(mt, dog, hash_fn)
 | 
			
		||||
  let maybe_proof: Option<Proof> = get_proof(mt, dog, hash_fn)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    maybe_proof
 | 
			
		||||
  expect Some(proof) = maybe_proof
 | 
			
		||||
 | 
			
		||||
  // when proof is empty list it actually means that root of the tree is in fact element
 | 
			
		||||
  proof == []
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test get_proof_3() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse]
 | 
			
		||||
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let node_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(cat), hash_fn(mouse)))
 | 
			
		||||
  let node_hash = sha2_256(bytearray.concat(hash_fn(cat), hash_fn(mouse)))
 | 
			
		||||
 | 
			
		||||
  let maybe_proof: Option<Proof> =
 | 
			
		||||
    get_proof(mt, dog, hash_fn)
 | 
			
		||||
  let maybe_proof: Option<Proof> = get_proof(mt, dog, hash_fn)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    maybe_proof
 | 
			
		||||
  expect Some(proof) = maybe_proof
 | 
			
		||||
 | 
			
		||||
  let size_match =
 | 
			
		||||
    list.length(proof) == 1
 | 
			
		||||
  let size_match = list.length(proof) == 1
 | 
			
		||||
 | 
			
		||||
  expect Some(p1) =
 | 
			
		||||
    list.at(proof, 0)
 | 
			
		||||
  expect Some(p1) = list.at(proof, 0)
 | 
			
		||||
 | 
			
		||||
  let h1: ByteArray =
 | 
			
		||||
    get_proof_item_value(p1)
 | 
			
		||||
  let h1: ByteArray = get_proof_item_value(p1)
 | 
			
		||||
 | 
			
		||||
  size_match && h1 == node_hash
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test get_proof_4() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let right_node_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(mouse), hash_fn(horse)))
 | 
			
		||||
  let maybe_proof: Option<Proof> =
 | 
			
		||||
    get_proof(mt, dog, hash_fn)
 | 
			
		||||
  let maybe_proof: Option<Proof> = get_proof(mt, dog, hash_fn)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    maybe_proof
 | 
			
		||||
  expect Some(proof) = maybe_proof
 | 
			
		||||
 | 
			
		||||
  let size_match =
 | 
			
		||||
    list.length(proof) == 2
 | 
			
		||||
  let size_match = list.length(proof) == 2
 | 
			
		||||
 | 
			
		||||
  expect Some(p1) =
 | 
			
		||||
    list.at(proof, 0)
 | 
			
		||||
  expect Some(p2) =
 | 
			
		||||
    list.at(proof, 1)
 | 
			
		||||
  expect Some(p1) = list.at(proof, 0)
 | 
			
		||||
  expect Some(p2) = list.at(proof, 1)
 | 
			
		||||
 | 
			
		||||
  let h1: ByteArray =
 | 
			
		||||
    get_proof_item_value(p1)
 | 
			
		||||
  let h2: ByteArray =
 | 
			
		||||
    get_proof_item_value(p2)
 | 
			
		||||
  let h1: ByteArray = get_proof_item_value(p1)
 | 
			
		||||
  let h2: ByteArray = get_proof_item_value(p2)
 | 
			
		||||
 | 
			
		||||
  size_match && h1 == hash_fn(cat) && h2 == right_node_hash
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -426,16 +331,13 @@ fn do_from_list(
 | 
			
		|||
  hash_fn: fn(a) -> Hash<Sha2_256, a>,
 | 
			
		||||
) -> MerkleTree<a> {
 | 
			
		||||
  when items is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      Empty
 | 
			
		||||
    [] -> Empty
 | 
			
		||||
    [item] -> {
 | 
			
		||||
      let hashed_item =
 | 
			
		||||
        hash_fn(item)
 | 
			
		||||
      let hashed_item = hash_fn(item)
 | 
			
		||||
      Leaf { value: item, hash: hashed_item }
 | 
			
		||||
    }
 | 
			
		||||
    all -> {
 | 
			
		||||
      let cutoff: Int =
 | 
			
		||||
        len / 2
 | 
			
		||||
      let cutoff: Int = len / 2
 | 
			
		||||
      let left =
 | 
			
		||||
        all
 | 
			
		||||
          |> list.take(cutoff)
 | 
			
		||||
| 
						 | 
				
			
			@ -444,8 +346,7 @@ fn do_from_list(
 | 
			
		|||
        all
 | 
			
		||||
          |> list.drop(cutoff)
 | 
			
		||||
          |> do_from_list(len - cutoff, hash_fn)
 | 
			
		||||
      let hash =
 | 
			
		||||
        combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      let hash = combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      Node { hash, left, right }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -462,46 +363,35 @@ pub fn from_list(
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test from_1() {
 | 
			
		||||
  let _a =
 | 
			
		||||
    -1
 | 
			
		||||
  let _a = -1
 | 
			
		||||
  let items =
 | 
			
		||||
    []
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  Empty == mt
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test from_2() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  Leaf { value: dog, hash: hash_fn(dog) } == mt
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test from_3() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat]
 | 
			
		||||
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let root_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(dog), hash_fn(cat)))
 | 
			
		||||
  let root_hash = sha2_256(bytearray.concat(hash_fn(dog), hash_fn(cat)))
 | 
			
		||||
 | 
			
		||||
  Node {
 | 
			
		||||
    hash: root_hash,
 | 
			
		||||
| 
						 | 
				
			
			@ -511,25 +401,18 @@ test from_3() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test from_4() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let node_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(cat), hash_fn(mouse)))
 | 
			
		||||
  let root_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(dog), node_hash))
 | 
			
		||||
  let node_hash = sha2_256(bytearray.concat(hash_fn(cat), hash_fn(mouse)))
 | 
			
		||||
  let root_hash = sha2_256(bytearray.concat(hash_fn(dog), node_hash))
 | 
			
		||||
 | 
			
		||||
  Node {
 | 
			
		||||
    hash: root_hash,
 | 
			
		||||
| 
						 | 
				
			
			@ -543,30 +426,22 @@ test from_4() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test from_5() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse]
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let left_node_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(dog), hash_fn(cat)))
 | 
			
		||||
  let left_node_hash = sha2_256(bytearray.concat(hash_fn(dog), hash_fn(cat)))
 | 
			
		||||
  let right_node_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(hash_fn(mouse), hash_fn(horse)))
 | 
			
		||||
 | 
			
		||||
  let root_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(left_node_hash, right_node_hash))
 | 
			
		||||
  let root_hash = sha2_256(bytearray.concat(left_node_hash, right_node_hash))
 | 
			
		||||
 | 
			
		||||
  Node {
 | 
			
		||||
    hash: root_hash,
 | 
			
		||||
| 
						 | 
				
			
			@ -594,8 +469,7 @@ pub fn member_from_hash(
 | 
			
		|||
  hash_fn: fn(a) -> Hash<Sha2_256, a>,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  when proof is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      root_hash == item_hash
 | 
			
		||||
    [] -> root_hash == item_hash
 | 
			
		||||
    [head, ..tail] ->
 | 
			
		||||
      when head is {
 | 
			
		||||
        Left { hash: l } ->
 | 
			
		||||
| 
						 | 
				
			
			@ -614,173 +488,119 @@ pub fn member(
 | 
			
		|||
  proof: Proof,
 | 
			
		||||
  hash_fn: fn(a) -> Hash<Sha2_256, a>,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  let item_hash =
 | 
			
		||||
    hash_fn(item)
 | 
			
		||||
  let item_hash = hash_fn(item)
 | 
			
		||||
  member_from_hash(item_hash, root_hash, proof, hash_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test member_1() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let item =
 | 
			
		||||
    dog
 | 
			
		||||
  let rh =
 | 
			
		||||
    root_hash(mt)
 | 
			
		||||
  let item = dog
 | 
			
		||||
  let rh = root_hash(mt)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    get_proof(mt, item, hash_fn)
 | 
			
		||||
  expect Some(proof) = get_proof(mt, item, hash_fn)
 | 
			
		||||
  member(item: item, root_hash: rh, proof: proof, hash_fn: hash_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test member_2() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let item =
 | 
			
		||||
    cat
 | 
			
		||||
  let rh =
 | 
			
		||||
    root_hash(mt)
 | 
			
		||||
  let item = cat
 | 
			
		||||
  let rh = root_hash(mt)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    get_proof(mt, item, hash_fn)
 | 
			
		||||
  expect Some(proof) = get_proof(mt, item, hash_fn)
 | 
			
		||||
  member(item: item, root_hash: rh, proof: proof, hash_fn: hash_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test member_3() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let item =
 | 
			
		||||
    cat
 | 
			
		||||
  let rh =
 | 
			
		||||
    root_hash(mt)
 | 
			
		||||
  let item = cat
 | 
			
		||||
  let rh = root_hash(mt)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    get_proof(mt, item, hash_fn)
 | 
			
		||||
  expect Some(proof) = get_proof(mt, item, hash_fn)
 | 
			
		||||
  member(item: item, root_hash: rh, proof: proof, hash_fn: hash_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test member_4() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let item =
 | 
			
		||||
    mouse
 | 
			
		||||
  let rh =
 | 
			
		||||
    root_hash(mt)
 | 
			
		||||
  let item = mouse
 | 
			
		||||
  let rh = root_hash(mt)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    get_proof(mt, item, hash_fn)
 | 
			
		||||
  expect Some(proof) = get_proof(mt, item, hash_fn)
 | 
			
		||||
  member(item: item, root_hash: rh, proof: proof, hash_fn: hash_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test member_5() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let pig =
 | 
			
		||||
    "pig"
 | 
			
		||||
  let bull =
 | 
			
		||||
    "bull"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
  let pig = "pig"
 | 
			
		||||
  let bull = "bull"
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse, pig, bull]
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let item =
 | 
			
		||||
    pig
 | 
			
		||||
  let rh =
 | 
			
		||||
    root_hash(mt)
 | 
			
		||||
  let item = pig
 | 
			
		||||
  let rh = root_hash(mt)
 | 
			
		||||
 | 
			
		||||
  expect Some(proof) =
 | 
			
		||||
    get_proof(mt, item, hash_fn)
 | 
			
		||||
  expect Some(proof) = get_proof(mt, item, hash_fn)
 | 
			
		||||
  member(item: item, root_hash: rh, proof: proof, hash_fn: hash_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test member_6() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    "dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    "cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    "mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    "horse"
 | 
			
		||||
  let pig =
 | 
			
		||||
    "pig"
 | 
			
		||||
  let bull =
 | 
			
		||||
    "bull"
 | 
			
		||||
  let dog = "dog"
 | 
			
		||||
  let cat = "cat"
 | 
			
		||||
  let mouse = "mouse"
 | 
			
		||||
  let horse = "horse"
 | 
			
		||||
  let pig = "pig"
 | 
			
		||||
  let bull = "bull"
 | 
			
		||||
 | 
			
		||||
  let hash_fn =
 | 
			
		||||
    create_string_item_hash_fn()
 | 
			
		||||
  let hash_fn = create_string_item_hash_fn()
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse, pig, bull]
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_list(items, hash_fn)
 | 
			
		||||
  let mt = from_list(items, hash_fn)
 | 
			
		||||
 | 
			
		||||
  let item =
 | 
			
		||||
    "parrot"
 | 
			
		||||
  let item = "parrot"
 | 
			
		||||
 | 
			
		||||
  let proof =
 | 
			
		||||
    get_proof(mt, item, hash_fn)
 | 
			
		||||
  let proof = get_proof(mt, item, hash_fn)
 | 
			
		||||
  proof == None
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn get_proof_item_value(proof_item: ProofItem) -> Hash<Sha2_256, ByteArray> {
 | 
			
		||||
  when proof_item is {
 | 
			
		||||
    Left(x) ->
 | 
			
		||||
      x
 | 
			
		||||
    Right(y) ->
 | 
			
		||||
      y
 | 
			
		||||
    Left(x) -> x
 | 
			
		||||
    Right(y) -> y
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181064, nanos_since_epoch = 977089000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743643, nanos_since_epoch = 186230000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,8 +40,7 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
 | 
			
		|||
          a0,
 | 
			
		||||
          a1,
 | 
			
		||||
          fn(_, q0, q1) {
 | 
			
		||||
            let q =
 | 
			
		||||
              q0 + q1
 | 
			
		||||
            let q = q0 + q1
 | 
			
		||||
            if q == 0 {
 | 
			
		||||
              None
 | 
			
		||||
            } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -78,8 +77,7 @@ pub fn flatten_with(
 | 
			
		|||
        assets,
 | 
			
		||||
        fn(asset_name, quantity, xs) {
 | 
			
		||||
          when transform(policy_id, asset_name, quantity) is {
 | 
			
		||||
            None ->
 | 
			
		||||
              xs
 | 
			
		||||
            None -> xs
 | 
			
		||||
            Some(x) ->
 | 
			
		||||
              [x, ..xs]
 | 
			
		||||
          }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705179899, nanos_since_epoch = 505049000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743643, nanos_since_epoch = 242458000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181045, nanos_since_epoch = 255817000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 944756000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+0161cf6"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,13 +69,10 @@ pub fn validate_pool_deposit(
 | 
			
		|||
  datum: PoolDatum,
 | 
			
		||||
  redeemer: PoolDepositRedeemer,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  let validator_address =
 | 
			
		||||
    scripthash_address(#"ff")
 | 
			
		||||
  let validator_address = scripthash_address(#"ff")
 | 
			
		||||
 | 
			
		||||
  expect Some(pool_output) =
 | 
			
		||||
    get_output(ctx, validator_address)
 | 
			
		||||
  expect Some(pool_input) =
 | 
			
		||||
    get_input(ctx, validator_address)
 | 
			
		||||
  expect Some(pool_output) = get_output(ctx, validator_address)
 | 
			
		||||
  expect Some(pool_input) = get_input(ctx, validator_address)
 | 
			
		||||
 | 
			
		||||
  True
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -86,34 +83,28 @@ pub fn validate_pool_borrow(
 | 
			
		|||
  datum: PoolDatum,
 | 
			
		||||
  redeemer: PoolBorrowRedeemer,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  let validator_address =
 | 
			
		||||
    scripthash_address(#"ff")
 | 
			
		||||
  let validator_address = scripthash_address(#"ff")
 | 
			
		||||
 | 
			
		||||
  expect Some(pool_output) =
 | 
			
		||||
    get_output(ctx, validator_address)
 | 
			
		||||
  expect Some(pool_input) =
 | 
			
		||||
    get_input(ctx, validator_address)
 | 
			
		||||
  expect Some(pool_output) = get_output(ctx, validator_address)
 | 
			
		||||
  expect Some(pool_input) = get_input(ctx, validator_address)
 | 
			
		||||
  True
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
validator {
 | 
			
		||||
  fn pool_contract(datum: PoolDatum, redeemer: PoolRedeemer, ctx: ScriptContext) {
 | 
			
		||||
    when redeemer.action is {
 | 
			
		||||
      PoolWithdraw(_) ->
 | 
			
		||||
        True
 | 
			
		||||
      PoolWithdraw(_) -> True
 | 
			
		||||
      PoolDeposit(pool_deposit_redeemer) ->
 | 
			
		||||
        when ctx.purpose is {
 | 
			
		||||
          Spend(output_ref) ->
 | 
			
		||||
            validate_pool_deposit(ctx, output_ref, datum, pool_deposit_redeemer)
 | 
			
		||||
          _ ->
 | 
			
		||||
            False
 | 
			
		||||
          _ -> False
 | 
			
		||||
        }
 | 
			
		||||
      PoolBorrow(pool_borrow_redeemer) ->
 | 
			
		||||
        when ctx.purpose is {
 | 
			
		||||
          Spend(output_ref) ->
 | 
			
		||||
            validate_pool_borrow(ctx, output_ref, datum, pool_borrow_redeemer)
 | 
			
		||||
          _ ->
 | 
			
		||||
            False
 | 
			
		||||
          _ -> False
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181059, nanos_since_epoch = 86246000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 736511000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,34 +30,24 @@ fn find_outbound_datum(possible_output: Option<Output>) -> Data {
 | 
			
		|||
  when possible_output is {
 | 
			
		||||
    Some(possible_output) ->
 | 
			
		||||
      when possible_output.datum is {
 | 
			
		||||
        InlineDatum(outbound_datum) ->
 | 
			
		||||
          outbound_datum
 | 
			
		||||
        _ ->
 | 
			
		||||
          error @"expected outbound inline datum"
 | 
			
		||||
        InlineDatum(outbound_datum) -> outbound_datum
 | 
			
		||||
        _ -> fail @"expected outbound inline datum"
 | 
			
		||||
      }
 | 
			
		||||
    None ->
 | 
			
		||||
      error @"no outbound datum found"
 | 
			
		||||
    None -> fail @"no outbound datum found"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn datum_a_cont() -> OtherDatum {
 | 
			
		||||
  let owner: OwnerInfo =
 | 
			
		||||
    OwnerInfo { pkh: #"", sc: #"" }
 | 
			
		||||
  let have: TokenInfo =
 | 
			
		||||
    TokenInfo { pid: #"", tkn: #"", amt: 100 }
 | 
			
		||||
  let want: TokenInfo =
 | 
			
		||||
    TokenInfo { pid: #"acab", tkn: #"beef", amt: 50 }
 | 
			
		||||
  let info: SwapInfo =
 | 
			
		||||
    SwapInfo { slip: 40 }
 | 
			
		||||
  let owner: OwnerInfo = OwnerInfo { pkh: #"", sc: #"" }
 | 
			
		||||
  let have: TokenInfo = TokenInfo { pid: #"", tkn: #"", amt: 100 }
 | 
			
		||||
  let want: TokenInfo = TokenInfo { pid: #"acab", tkn: #"beef", amt: 50 }
 | 
			
		||||
  let info: SwapInfo = SwapInfo { slip: 40 }
 | 
			
		||||
  OtherDatum { owner, have, want, info }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test foo() {
 | 
			
		||||
  let outbound_datum =
 | 
			
		||||
    InlineDatum(datum_a_cont())
 | 
			
		||||
  let outbound_output =
 | 
			
		||||
    Some(Output { datum: outbound_datum })
 | 
			
		||||
  expect outbound_datum: OtherDatum =
 | 
			
		||||
    find_outbound_datum(outbound_output)
 | 
			
		||||
  let outbound_datum = InlineDatum(datum_a_cont())
 | 
			
		||||
  let outbound_output = Some(Output { datum: outbound_datum })
 | 
			
		||||
  expect outbound_datum: OtherDatum = find_outbound_datum(outbound_output)
 | 
			
		||||
  outbound_datum == datum_a_cont()
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181056, nanos_since_epoch = 151986000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 350520000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,12 +25,9 @@ pub type ProofItem {
 | 
			
		|||
// Function returning a hash of a given Merkle Tree element
 | 
			
		||||
pub fn root_hash(self: MerkleTree<a>) -> Hash<Sha2_256, ByteArray> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      #""
 | 
			
		||||
    Leaf { hash } ->
 | 
			
		||||
      hash
 | 
			
		||||
    Node { hash, .. } ->
 | 
			
		||||
      hash
 | 
			
		||||
    Empty -> #""
 | 
			
		||||
    Leaf { hash } -> hash
 | 
			
		||||
    Node { hash, .. } -> hash
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,12 +39,9 @@ pub fn is_equal(left: MerkleTree<a>, right: MerkleTree<a>) -> Bool {
 | 
			
		|||
/// Function returns a total numbers of leaves in the tree.
 | 
			
		||||
pub fn size(self: MerkleTree<a>) -> Int {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      0
 | 
			
		||||
    Leaf { .. } ->
 | 
			
		||||
      1
 | 
			
		||||
    Node { left, right, .. } ->
 | 
			
		||||
      size(left) + size(right)
 | 
			
		||||
    Empty -> 0
 | 
			
		||||
    Leaf { .. } -> 1
 | 
			
		||||
    Node { left, right, .. } -> size(left) + size(right)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -61,10 +55,8 @@ fn combine_hash(
 | 
			
		|||
/// Function that returns whether merkle tree has any elements
 | 
			
		||||
pub fn is_empty(self: MerkleTree<a>) -> Bool {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    Empty -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -75,8 +67,7 @@ fn do_proof(
 | 
			
		|||
  serialise_fn: fn(a) -> ByteArray,
 | 
			
		||||
) -> Option<Proof> {
 | 
			
		||||
  when self is {
 | 
			
		||||
    Empty ->
 | 
			
		||||
      None
 | 
			
		||||
    Empty -> None
 | 
			
		||||
    Leaf { hash } ->
 | 
			
		||||
      if hash == item_hash {
 | 
			
		||||
        Some(proof)
 | 
			
		||||
| 
						 | 
				
			
			@ -84,10 +75,8 @@ fn do_proof(
 | 
			
		|||
        None
 | 
			
		||||
      }
 | 
			
		||||
    Node { left, right, .. } -> {
 | 
			
		||||
      let rh =
 | 
			
		||||
        root_hash(right)
 | 
			
		||||
      let lh =
 | 
			
		||||
        root_hash(left)
 | 
			
		||||
      let rh = root_hash(right)
 | 
			
		||||
      let lh = root_hash(left)
 | 
			
		||||
      let go_left: Option<Proof> =
 | 
			
		||||
        do_proof(
 | 
			
		||||
          left,
 | 
			
		||||
| 
						 | 
				
			
			@ -127,16 +116,13 @@ fn do_from_list(
 | 
			
		|||
  serialise_fn: fn(a) -> ByteArray,
 | 
			
		||||
) -> MerkleTree<a> {
 | 
			
		||||
  when items is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      Empty
 | 
			
		||||
    [] -> Empty
 | 
			
		||||
    [item] -> {
 | 
			
		||||
      let hashed_item =
 | 
			
		||||
        sha2_256(serialise_fn(item))
 | 
			
		||||
      let hashed_item = sha2_256(serialise_fn(item))
 | 
			
		||||
      Leaf { hash: hashed_item }
 | 
			
		||||
    }
 | 
			
		||||
    all -> {
 | 
			
		||||
      let cutoff: Int =
 | 
			
		||||
        len / 2
 | 
			
		||||
      let cutoff: Int = len / 2
 | 
			
		||||
      let left =
 | 
			
		||||
        all
 | 
			
		||||
          |> list.take(cutoff)
 | 
			
		||||
| 
						 | 
				
			
			@ -145,8 +131,7 @@ fn do_from_list(
 | 
			
		|||
        all
 | 
			
		||||
          |> list.drop(cutoff)
 | 
			
		||||
          |> do_from_list(len - cutoff, serialise_fn)
 | 
			
		||||
      let hash =
 | 
			
		||||
        combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      let hash = combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      Node { hash, left, right }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -167,13 +152,10 @@ fn do_from_hashes_list(
 | 
			
		|||
  len: Int,
 | 
			
		||||
) -> MerkleTree<a> {
 | 
			
		||||
  when items is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      Empty
 | 
			
		||||
    [hashed_item] ->
 | 
			
		||||
      Leaf { hash: hashed_item }
 | 
			
		||||
    [] -> Empty
 | 
			
		||||
    [hashed_item] -> Leaf { hash: hashed_item }
 | 
			
		||||
    all -> {
 | 
			
		||||
      let cutoff: Int =
 | 
			
		||||
        len / 2
 | 
			
		||||
      let cutoff: Int = len / 2
 | 
			
		||||
      let left =
 | 
			
		||||
        all
 | 
			
		||||
          |> list.take(cutoff)
 | 
			
		||||
| 
						 | 
				
			
			@ -182,8 +164,7 @@ fn do_from_hashes_list(
 | 
			
		|||
        all
 | 
			
		||||
          |> list.drop(cutoff)
 | 
			
		||||
          |> do_from_hashes_list(len - cutoff)
 | 
			
		||||
      let hash =
 | 
			
		||||
        combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      let hash = combine_hash(root_hash(left), root_hash(right))
 | 
			
		||||
      Node { hash, left, right }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -207,8 +188,7 @@ pub fn member_from_hash(
 | 
			
		|||
  serialise_fn: fn(a) -> ByteArray,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  when proof is {
 | 
			
		||||
    [] ->
 | 
			
		||||
      root_hash == item_hash
 | 
			
		||||
    [] -> root_hash == item_hash
 | 
			
		||||
    [head, ..tail] ->
 | 
			
		||||
      when head is {
 | 
			
		||||
        Left { hash: l } ->
 | 
			
		||||
| 
						 | 
				
			
			@ -237,8 +217,7 @@ pub fn member(
 | 
			
		|||
  proof: Proof,
 | 
			
		||||
  serialise_fn: fn(a) -> ByteArray,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  let item_hash =
 | 
			
		||||
    sha2_256(serialise_fn(item))
 | 
			
		||||
  let item_hash = sha2_256(serialise_fn(item))
 | 
			
		||||
  member_from_hash(item_hash, root_hash, proof, serialise_fn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -247,16 +226,12 @@ pub fn member_from_tree(
 | 
			
		|||
  item: a,
 | 
			
		||||
  serialise_fn: fn(a) -> ByteArray,
 | 
			
		||||
) -> Bool {
 | 
			
		||||
  let proof: Option<Proof> =
 | 
			
		||||
    get_proof(tree, item, serialise_fn)
 | 
			
		||||
  let rh =
 | 
			
		||||
    root_hash(tree)
 | 
			
		||||
  let proof: Option<Proof> = get_proof(tree, item, serialise_fn)
 | 
			
		||||
  let rh = root_hash(tree)
 | 
			
		||||
 | 
			
		||||
  when proof is {
 | 
			
		||||
    Some(p) ->
 | 
			
		||||
      member(item, rh, p, serialise_fn)
 | 
			
		||||
    None ->
 | 
			
		||||
      False
 | 
			
		||||
    Some(p) -> member(item, rh, p, serialise_fn)
 | 
			
		||||
    None -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -266,25 +241,18 @@ fn create_string_item_serialise_fn() -> fn(String) -> ByteArray {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
test from_hashes_list_5() {
 | 
			
		||||
  let dog =
 | 
			
		||||
    @"dog"
 | 
			
		||||
  let cat =
 | 
			
		||||
    @"cat"
 | 
			
		||||
  let mouse =
 | 
			
		||||
    @"mouse"
 | 
			
		||||
  let horse =
 | 
			
		||||
    @"horse"
 | 
			
		||||
  let dog = @"dog"
 | 
			
		||||
  let cat = @"cat"
 | 
			
		||||
  let mouse = @"mouse"
 | 
			
		||||
  let horse = @"horse"
 | 
			
		||||
 | 
			
		||||
  let serialise_fn =
 | 
			
		||||
    create_string_item_serialise_fn()
 | 
			
		||||
  let serialise_fn = create_string_item_serialise_fn()
 | 
			
		||||
 | 
			
		||||
  let items =
 | 
			
		||||
    [dog, cat, mouse, horse]
 | 
			
		||||
  let hashes_items =
 | 
			
		||||
    list.map(items, fn(item) { sha2_256(serialise_fn(item)) })
 | 
			
		||||
  let hashes_items = list.map(items, fn(item) { sha2_256(serialise_fn(item)) })
 | 
			
		||||
 | 
			
		||||
  let mt =
 | 
			
		||||
    from_hashes_list(hashes_items)
 | 
			
		||||
  let mt = from_hashes_list(hashes_items)
 | 
			
		||||
 | 
			
		||||
  let left_node_hash =
 | 
			
		||||
    sha2_256(
 | 
			
		||||
| 
						 | 
				
			
			@ -298,8 +266,7 @@ test from_hashes_list_5() {
 | 
			
		|||
      ),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
  let root_hash =
 | 
			
		||||
    sha2_256(bytearray.concat(left_node_hash, right_node_hash))
 | 
			
		||||
  let root_hash = sha2_256(bytearray.concat(left_node_hash, right_node_hash))
 | 
			
		||||
 | 
			
		||||
  Node {
 | 
			
		||||
    hash: root_hash,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
test expect_positive() {
 | 
			
		||||
  let val = 5
 | 
			
		||||
  expect True = val > 0
 | 
			
		||||
  expect val > 0
 | 
			
		||||
  True
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181044, nanos_since_epoch = 445717000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 940487000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+0161cf6"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,38 +1,31 @@
 | 
			
		|||
use aiken/list.{find, foldr}
 | 
			
		||||
use aiken/transaction.{Input, ScriptContext, Spend, OutputReference, Transaction} as tx
 | 
			
		||||
use aiken/transaction/value.{add, zero}
 | 
			
		||||
use aiken/dict
 | 
			
		||||
use aiken/list.{find, foldr}
 | 
			
		||||
use aiken/transaction.{Input,
 | 
			
		||||
  OutputReference, ScriptContext, Spend, Transaction} as tx
 | 
			
		||||
use aiken/transaction/value.{add, zero}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
type Action {
 | 
			
		||||
  Mint
 | 
			
		||||
  Burn
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
validator(token_name: ByteArray, utxo_ref: OutputReference) {
 | 
			
		||||
  fn gift_card(rdmr: Action, ctx: ScriptContext) -> Bool {
 | 
			
		||||
    let ScriptContext { transaction, purpose } =
 | 
			
		||||
      ctx
 | 
			
		||||
 
 | 
			
		||||
    expect tx.Mint(policy_id) =
 | 
			
		||||
      purpose
 | 
			
		||||
 
 | 
			
		||||
    let Transaction { inputs, mint, .. } =
 | 
			
		||||
      transaction
 | 
			
		||||
 
 | 
			
		||||
    expect [(asset_name, amount)] = mint
 | 
			
		||||
    let ScriptContext { transaction, purpose } = ctx
 | 
			
		||||
    expect tx.Mint(policy_id) = purpose
 | 
			
		||||
    let Transaction { inputs, mint, .. } = transaction
 | 
			
		||||
    expect [(asset_name, amount)] =
 | 
			
		||||
      mint
 | 
			
		||||
        |> value.from_minted_value
 | 
			
		||||
        |> value.tokens(policy_id)
 | 
			
		||||
        |> dict.to_list()
 | 
			
		||||
 
 | 
			
		||||
    when rdmr is {
 | 
			
		||||
      Mint -> {
 | 
			
		||||
        expect True =
 | 
			
		||||
        expect
 | 
			
		||||
          list.any(inputs, fn(input) { input.output_reference == utxo_ref })
 | 
			
		||||
        amount == 1 && asset_name == token_name
 | 
			
		||||
      }
 | 
			
		||||
      Burn ->
 | 
			
		||||
        todo @"burn"
 | 
			
		||||
      Burn -> todo @"burn"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,10 +10,8 @@ type DayOfTheWeek {
 | 
			
		|||
 | 
			
		||||
fn is_work(day: DayOfTheWeek) {
 | 
			
		||||
  when day is {
 | 
			
		||||
    Tuesday | Wednesday | Thursday | Friday | Saturday ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    Tuesday | Wednesday | Thursday | Friday | Saturday -> True
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -27,12 +25,10 @@ test is_work_2() {
 | 
			
		|||
 | 
			
		||||
fn is_happy_hour(day: DayOfTheWeek, current_time: Int) {
 | 
			
		||||
  when day is {
 | 
			
		||||
    Monday | Sunday ->
 | 
			
		||||
      True
 | 
			
		||||
    Monday | Sunday -> True
 | 
			
		||||
    Tuesday | Wednesday | Thursday | Friday | Saturday if current_time > 18 ->
 | 
			
		||||
      True
 | 
			
		||||
    _ ->
 | 
			
		||||
      False
 | 
			
		||||
    _ -> False
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+0161cf6"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181045, nanos_since_epoch = 361146000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 972182000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -149,36 +149,36 @@ test satisfying() {
 | 
			
		|||
      !satisfied(n, s, v)
 | 
			
		||||
    }
 | 
			
		||||
  and {
 | 
			
		||||
      satisfied(sig1, [keyHash1], validRange(0, 1))?,
 | 
			
		||||
      satisfied(sig2, [keyHash1, keyHash2], validRange(0, 1))?,
 | 
			
		||||
      satisfied(allOf, [keyHash1, keyHash2], validRange(0, 1))?,
 | 
			
		||||
      satisfied(anyOf, [keyHash2], validRange(0, 1))?,
 | 
			
		||||
      satisfied(atLeast, [keyHash2, keyHash3], validRange(0, 1))?,
 | 
			
		||||
      satisfied(before, [], validRange(0, 5))?,
 | 
			
		||||
      satisfied(after, [], validRange(15, 20))?,
 | 
			
		||||
      satisfied(after, [], validRange(10, 15))?,
 | 
			
		||||
      satisfied(between, [], validRange(12, 13))?,
 | 
			
		||||
      satisfied(vesting, [keyHash1], validRange(0, 5))?,
 | 
			
		||||
      satisfied(vesting, [keyHash2], validRange(15, 20))?,
 | 
			
		||||
      unsatisfied(sig1, [keyHash2], validRange(0, 1))?,
 | 
			
		||||
      unsatisfied(sig3, [keyHash1, keyHash2], validRange(0, 1))?,
 | 
			
		||||
      unsatisfied(allOf, [keyHash1, keyHash3], validRange(0, 1))?,
 | 
			
		||||
      unsatisfied(anyOf, [keyHash3], validRange(0, 1))?,
 | 
			
		||||
      unsatisfied(atLeast, [keyHash2], validRange(0, 1))?,
 | 
			
		||||
      unsatisfied(before, [], validRange(5, 15))?,
 | 
			
		||||
      unsatisfied(before, [], validRange(5, 10))?,
 | 
			
		||||
      unsatisfied(before, [], validRange(10, 10))?,
 | 
			
		||||
      unsatisfied(after, [], validRange(5, 15))?,
 | 
			
		||||
      unsatisfied(between, [], validRange(0, 5))?,
 | 
			
		||||
      unsatisfied(between, [], validRange(0, 13))?,
 | 
			
		||||
      unsatisfied(between, [], validRange(0, 20))?,
 | 
			
		||||
      unsatisfied(between, [], validRange(13, 20))?,
 | 
			
		||||
      unsatisfied(between, [], validRange(13, 15))?,
 | 
			
		||||
      unsatisfied(between, [], validRange(15, 20))?,
 | 
			
		||||
      unsatisfied(vesting, [keyHash2], validRange(0, 5))?,
 | 
			
		||||
      unsatisfied(vesting, [keyHash1], validRange(15, 20))?,
 | 
			
		||||
      unsatisfied(vesting, [keyHash3], validRange(10, 10))?,
 | 
			
		||||
      unsatisfied(vesting, [keyHash3], validRange(0, 5))?,
 | 
			
		||||
      unsatisfied(vesting, [keyHash3], validRange(15, 20))?,
 | 
			
		||||
    satisfied(sig1, [keyHash1], validRange(0, 1))?,
 | 
			
		||||
    satisfied(sig2, [keyHash1, keyHash2], validRange(0, 1))?,
 | 
			
		||||
    satisfied(allOf, [keyHash1, keyHash2], validRange(0, 1))?,
 | 
			
		||||
    satisfied(anyOf, [keyHash2], validRange(0, 1))?,
 | 
			
		||||
    satisfied(atLeast, [keyHash2, keyHash3], validRange(0, 1))?,
 | 
			
		||||
    satisfied(before, [], validRange(0, 5))?,
 | 
			
		||||
    satisfied(after, [], validRange(15, 20))?,
 | 
			
		||||
    satisfied(after, [], validRange(10, 15))?,
 | 
			
		||||
    satisfied(between, [], validRange(12, 13))?,
 | 
			
		||||
    satisfied(vesting, [keyHash1], validRange(0, 5))?,
 | 
			
		||||
    satisfied(vesting, [keyHash2], validRange(15, 20))?,
 | 
			
		||||
    unsatisfied(sig1, [keyHash2], validRange(0, 1))?,
 | 
			
		||||
    unsatisfied(sig3, [keyHash1, keyHash2], validRange(0, 1))?,
 | 
			
		||||
    unsatisfied(allOf, [keyHash1, keyHash3], validRange(0, 1))?,
 | 
			
		||||
    unsatisfied(anyOf, [keyHash3], validRange(0, 1))?,
 | 
			
		||||
    unsatisfied(atLeast, [keyHash2], validRange(0, 1))?,
 | 
			
		||||
    unsatisfied(before, [], validRange(5, 15))?,
 | 
			
		||||
    unsatisfied(before, [], validRange(5, 10))?,
 | 
			
		||||
    unsatisfied(before, [], validRange(10, 10))?,
 | 
			
		||||
    unsatisfied(after, [], validRange(5, 15))?,
 | 
			
		||||
    unsatisfied(between, [], validRange(0, 5))?,
 | 
			
		||||
    unsatisfied(between, [], validRange(0, 13))?,
 | 
			
		||||
    unsatisfied(between, [], validRange(0, 20))?,
 | 
			
		||||
    unsatisfied(between, [], validRange(13, 20))?,
 | 
			
		||||
    unsatisfied(between, [], validRange(13, 15))?,
 | 
			
		||||
    unsatisfied(between, [], validRange(15, 20))?,
 | 
			
		||||
    unsatisfied(vesting, [keyHash2], validRange(0, 5))?,
 | 
			
		||||
    unsatisfied(vesting, [keyHash1], validRange(15, 20))?,
 | 
			
		||||
    unsatisfied(vesting, [keyHash3], validRange(10, 10))?,
 | 
			
		||||
    unsatisfied(vesting, [keyHash3], validRange(0, 5))?,
 | 
			
		||||
    unsatisfied(vesting, [keyHash3], validRange(15, 20))?,
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181044, nanos_since_epoch = 445541000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 966665000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ fn compare_value(
 | 
			
		|||
  if
 | 
			
		||||
  value.quantity_of(val1, sym, loan_id) == value.quantity_of(val2, sym, loan_id){
 | 
			
		||||
  
 | 
			
		||||
    error @"Should not be equal"
 | 
			
		||||
    fail @"Should not be equal"
 | 
			
		||||
  } else {
 | 
			
		||||
    Less
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181045, nanos_since_epoch = 301366000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 968996000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181045, nanos_since_epoch = 320068000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743640, nanos_since_epoch = 975570000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181059, nanos_since_epoch = 76573000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 725442000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+0161cf6"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181055, nanos_since_epoch = 546831000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 191574000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181060, nanos_since_epoch = 328311000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 768373000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,4 +13,4 @@ requirements = []
 | 
			
		|||
source = "github"
 | 
			
		||||
 | 
			
		||||
[etags]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181054, nanos_since_epoch = 373675000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743642, nanos_since_epoch = 175324000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    "plutusVersion": "v2",
 | 
			
		||||
    "compiler": {
 | 
			
		||||
      "name": "Aiken",
 | 
			
		||||
      "version": "v1.0.21-alpha+9f263c4"
 | 
			
		||||
      "version": "v1.0.21-alpha+bf96c3a"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validators": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue