astreum 0.2.29__tar.gz → 0.2.30__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {astreum-0.2.29/src/astreum.egg-info → astreum-0.2.30}/PKG-INFO +1 -1
- {astreum-0.2.29 → astreum-0.2.30}/pyproject.toml +1 -1
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/node.py +184 -6
- {astreum-0.2.29 → astreum-0.2.30/src/astreum.egg-info}/PKG-INFO +1 -1
- {astreum-0.2.29 → astreum-0.2.30}/LICENSE +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/README.md +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/setup.cfg +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/__init__.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/crypto/__init__.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/crypto/ed25519.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/crypto/quadratic_form.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/crypto/wesolowski.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/crypto/x25519.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/format.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/lispeum/__init__.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/lispeum/environment.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/lispeum/expression.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/lispeum/parser.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/lispeum/tokenizer.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/__init__.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/account.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/accounts.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/block.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/merkle.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/message.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/patricia.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/models/transaction.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/relay/__init__.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/relay/peer.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/relay/route.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/relay/setup.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/storage/__init__.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/storage/object.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum/storage/setup.py +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum.egg-info/SOURCES.txt +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum.egg-info/dependency_links.txt +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum.egg-info/requires.txt +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/src/astreum.egg-info/top_level.txt +0 -0
- {astreum-0.2.29 → astreum-0.2.30}/tests/test_node_machine.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.30
|
|
4
4
|
Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
|
|
5
5
|
Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/astreum/lib
|
|
@@ -463,7 +463,7 @@ class Node:
|
|
|
463
463
|
elif first.value == "def":
|
|
464
464
|
args = expr.elements[1:]
|
|
465
465
|
if len(args) != 2:
|
|
466
|
-
return Expr.Error(
|
|
466
|
+
return Expr.Error("def expects key value", origin=expr)
|
|
467
467
|
if not isinstance(args[0], Expr.Symbol):
|
|
468
468
|
return Expr.Error(message="first argument to 'def' must be a symbol", origin=args[0])
|
|
469
469
|
result = self.machine_expr_eval(env_id=env_id, expr=args[1])
|
|
@@ -473,13 +473,191 @@ class Node:
|
|
|
473
473
|
self.machine_expr_put(env_id=env_id, name=args[0].value, expr=result)
|
|
474
474
|
return result
|
|
475
475
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
## List: ints -> (1 2)
|
|
477
|
+
# push: (list.push 3 ints) -> (1 2 3) / (list.push 0 0 ints) -> (0 1 2)
|
|
478
|
+
elif first.value == "list.push":
|
|
479
|
+
args = expr.elements[1:]
|
|
480
|
+
if len(args) == 2:
|
|
481
|
+
val_expr, list_expr = args
|
|
482
|
+
idx = None
|
|
483
|
+
elif len(args) == 3:
|
|
484
|
+
idx_expr, val_expr, list_expr = args
|
|
485
|
+
idx = self.machine_expr_eval(env_id, idx_expr)
|
|
486
|
+
if isinstance(idx, Expr.Error): return idx
|
|
487
|
+
if not isinstance(idx, Expr.IntExpr):
|
|
488
|
+
return Expr.Error("index must be int", origin=idx_expr)
|
|
489
|
+
idx = idx.value
|
|
490
|
+
else:
|
|
491
|
+
return Expr.Error("list.push expects (value list) or (index value list)", origin=expr)
|
|
492
|
+
|
|
493
|
+
lst = self.machine_expr_eval(env_id, list_expr)
|
|
494
|
+
if isinstance(lst, Expr.Error): return lst
|
|
495
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
496
|
+
return Expr.Error("last arg to list.push must be a list", origin=list_expr)
|
|
497
|
+
|
|
498
|
+
val = self.machine_expr_eval(env_id, val_expr)
|
|
499
|
+
if isinstance(val, Expr.Error): return val
|
|
479
500
|
|
|
480
|
-
|
|
501
|
+
elems = list(lst.elements)
|
|
502
|
+
if idx is None:
|
|
503
|
+
elems.append(val)
|
|
504
|
+
else:
|
|
505
|
+
if idx < 0 or idx > len(elems):
|
|
506
|
+
return Expr.Error("index out of range", origin=idx_expr)
|
|
507
|
+
elems.insert(idx, val)
|
|
508
|
+
return Expr.ListExpr(elems)
|
|
509
|
+
|
|
510
|
+
# pop: (list.pop 1 ints) -> 2
|
|
511
|
+
elif first.value == "list.pop":
|
|
512
|
+
if len(expr.elements) < 3:
|
|
513
|
+
return Expr.Error("list.pop expects index list", origin=expr)
|
|
514
|
+
|
|
515
|
+
idx_expr, list_expr = expr.elements[1], expr.elements[2]
|
|
516
|
+
idx = self.machine_expr_eval(env_id, idx_expr)
|
|
517
|
+
if isinstance(idx, Expr.Error): return idx
|
|
518
|
+
if not isinstance(idx, Expr.IntExpr):
|
|
519
|
+
return Expr.Error("index must be int", origin=idx_expr)
|
|
520
|
+
idx = idx.value
|
|
521
|
+
|
|
522
|
+
lst = self.machine_expr_eval(env_id, list_expr)
|
|
523
|
+
if isinstance(lst, Expr.Error): return lst
|
|
524
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
525
|
+
return Expr.Error("second arg to list.pop must be a list", origin=list_expr)
|
|
526
|
+
|
|
527
|
+
elems = list(lst.elements)
|
|
528
|
+
if idx < 0 or idx >= len(elems):
|
|
529
|
+
return Expr.Error("index out of range", origin=idx_expr)
|
|
530
|
+
del elems[idx]
|
|
531
|
+
return Expr.ListExpr(elems)
|
|
532
|
+
|
|
533
|
+
# get: (list.get 1 ints) -> 2
|
|
534
|
+
elif first.value == "list.get":
|
|
535
|
+
if len(expr.elements) < 3:
|
|
536
|
+
return Expr.Error("list.get expects index list", origin=expr)
|
|
537
|
+
|
|
538
|
+
idx_expr, list_expr = expr.elements[1], expr.elements[2]
|
|
539
|
+
idx = self.machine_expr_eval(env_id, idx_expr)
|
|
540
|
+
if isinstance(idx, Expr.Error): return idx
|
|
541
|
+
if not isinstance(idx, Expr.IntExpr):
|
|
542
|
+
return Expr.Error("index must be int", origin=idx_expr)
|
|
543
|
+
idx = idx.value
|
|
544
|
+
|
|
545
|
+
lst = self.machine_expr_eval(env_id, list_expr)
|
|
546
|
+
if isinstance(lst, Expr.Error): return lst
|
|
547
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
548
|
+
return Expr.Error("second arg to list.get must be a list", origin=list_expr)
|
|
549
|
+
|
|
550
|
+
if idx < 0 or idx >= len(lst.elements):
|
|
551
|
+
return Expr.Error("index out of range", origin=idx_expr)
|
|
552
|
+
return lst.elements[idx]
|
|
553
|
+
|
|
554
|
+
# set: (list.set 1 3 ints) -> (1 3)
|
|
555
|
+
elif first.value == "list.set":
|
|
556
|
+
if len(expr.elements) < 4:
|
|
557
|
+
return Expr.Error("list.set expects index value list", origin=expr)
|
|
558
|
+
idx_expr, val_expr, list_expr = expr.elements[1], expr.elements[2], expr.elements[3]
|
|
559
|
+
idx = self.machine_expr_eval(env_id, idx_expr)
|
|
560
|
+
if isinstance(idx, Expr.Error): return idx
|
|
561
|
+
if not isinstance(idx, Expr.IntExpr):
|
|
562
|
+
return Expr.Error("index must be int", origin=idx_expr)
|
|
563
|
+
idx = idx.value
|
|
564
|
+
|
|
565
|
+
val = self.machine_expr_eval(env_id, val_expr)
|
|
566
|
+
if isinstance(val, Expr.Error): return val
|
|
567
|
+
|
|
568
|
+
lst = self.machine_expr_eval(env_id, list_expr)
|
|
569
|
+
if isinstance(lst, Expr.Error): return lst
|
|
570
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
571
|
+
return Expr.Error("third arg to list.set must be a list", origin=list_expr)
|
|
481
572
|
|
|
482
|
-
|
|
573
|
+
elems = list(lst.elements)
|
|
574
|
+
if idx < 0 or idx >= len(elems):
|
|
575
|
+
return Expr.Error("index out of range", origin=idx_expr)
|
|
576
|
+
elems[idx] = val
|
|
577
|
+
return Expr.ListExpr(elems)
|
|
578
|
+
|
|
579
|
+
### each: (list.each fn list) -> ()
|
|
580
|
+
elif first.value == "list.each":
|
|
581
|
+
if len(expr.elements) < 3:
|
|
582
|
+
return Expr.Error("list.each expects fn list", origin=expr)
|
|
583
|
+
fn_expr, list_expr = expr.elements[1], expr.elements[2]
|
|
584
|
+
lst = self.machine_expr_eval(env_id, list_expr)
|
|
585
|
+
if isinstance(lst, Expr.Error):
|
|
586
|
+
return lst
|
|
587
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
588
|
+
return Expr.Error("second arg to list.each must be a list", origin=list_expr)
|
|
589
|
+
|
|
590
|
+
for el in lst.elements:
|
|
591
|
+
res = self.machine_expr_eval(env_id, Expr.ListExpr([fn_expr, el]))
|
|
592
|
+
if isinstance(res, Expr.Error):
|
|
593
|
+
return res
|
|
594
|
+
return Expr.ListExpr([])
|
|
595
|
+
|
|
596
|
+
### fold: (list.fold fn init list) / (list.fold + 0 ints) -> 3
|
|
597
|
+
elif first.value == "list.fold":
|
|
598
|
+
fn_expr, init_expr, list_expr = expr.elements[1], expr.elements[2], expr.elements[3]
|
|
599
|
+
acc = self.machine_expr_eval(env_id, init_expr)
|
|
600
|
+
if isinstance(acc, Expr.Error):
|
|
601
|
+
return acc
|
|
602
|
+
|
|
603
|
+
lst = self.machine_expr_eval(env_id, list_expr)
|
|
604
|
+
if isinstance(lst, Expr.Error):
|
|
605
|
+
return lst
|
|
606
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
607
|
+
return Expr.Error("third arg to list.fold must be a list", origin=list_expr)
|
|
608
|
+
|
|
609
|
+
for el in lst.elements:
|
|
610
|
+
call = Expr.ListExpr([fn_expr, acc, el])
|
|
611
|
+
res = self.machine_expr_eval(env_id, call)
|
|
612
|
+
if isinstance(res, Expr.Error):
|
|
613
|
+
return res
|
|
614
|
+
acc = res
|
|
615
|
+
|
|
616
|
+
return acc
|
|
617
|
+
|
|
618
|
+
### sort: (list.sort fn list) / (list.sort (fn (a b) (a < b)) ints) -> (2 1)
|
|
619
|
+
elif first.value == "list.sort":
|
|
620
|
+
if len(expr.elements) < 3:
|
|
621
|
+
return Expr.Error("list.sort fn list", origin=expr)
|
|
622
|
+
fn_e, lst_e = expr.elements[1], expr.elements[2]
|
|
623
|
+
|
|
624
|
+
lst = self.machine_expr_eval(env_id, lst_e)
|
|
625
|
+
if isinstance(lst, Expr.Error): return lst
|
|
626
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
627
|
+
return Expr.Error("second arg must be list", origin=lst_e)
|
|
628
|
+
|
|
629
|
+
elems = list(lst.elements)
|
|
630
|
+
for i in range(1, len(elems)):
|
|
631
|
+
j = i
|
|
632
|
+
while j > 0:
|
|
633
|
+
cmp_res = self.machine_expr_eval(
|
|
634
|
+
env_id,
|
|
635
|
+
Expr.ListExpr([fn_e, elems[j-1], elems[j]])
|
|
636
|
+
)
|
|
637
|
+
if isinstance(cmp_res, Expr.Error): return cmp_res
|
|
638
|
+
if not isinstance(cmp_res, Expr.BoolExpr):
|
|
639
|
+
return Expr.Error("comparator must return bool", origin=fn_e)
|
|
640
|
+
|
|
641
|
+
if cmp_res.value:
|
|
642
|
+
elems[j-1], elems[j] = elems[j], elems[j-1]
|
|
643
|
+
j -= 1
|
|
644
|
+
else:
|
|
645
|
+
break
|
|
646
|
+
return Expr.ListExpr(elems)
|
|
647
|
+
|
|
648
|
+
### len: (list.len list) -> Int / (list.len ints) -> Integer(2)
|
|
649
|
+
elif first.value == "list.len":
|
|
650
|
+
if len(expr.elements) < 2:
|
|
651
|
+
return Expr.Error("list.len list", origin=expr)
|
|
652
|
+
lst_e = expr.elements[1]
|
|
653
|
+
lst = self.machine_expr_eval(env_id, lst_e)
|
|
654
|
+
if isinstance(lst, Expr.Error): return lst
|
|
655
|
+
if not isinstance(lst, Expr.ListExpr):
|
|
656
|
+
return Expr.Error("arg must be list", origin=lst_e)
|
|
657
|
+
return Expr.Integer(len(lst.elements))
|
|
658
|
+
|
|
659
|
+
## Integer
|
|
660
|
+
### add
|
|
483
661
|
elif first.value == "+":
|
|
484
662
|
args = expr.elements[1:]
|
|
485
663
|
if not args:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.30
|
|
4
4
|
Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
|
|
5
5
|
Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/astreum/lib
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|