diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d502e..76c4482 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.0.9] +This version is compatible with [`389efa3fbe65c77600da63c78d29c0866d292754`](https://github.com/Chia-Network/clvm/tree/389efa3fbe65c77600da63c78d29c0866d292754) of [clvm](https://github.com/Chia-Network/clvm) + +### Fixed +- Fixed an issue of `as_javascript` with tuples inside tuples and ending with 0 + ## [1.0.8] This version is compatible with [`2722c78ddb92f067c5025196f397e4d2955f9053`](https://github.com/Chia-Network/clvm/tree/2722c78ddb92f067c5025196f397e4d2955f9053) of [clvm](https://github.com/Chia-Network/clvm) @@ -239,6 +245,7 @@ At this version, I've managed to improve test complete time to `79s` -> `2s` by Initial (beta) release. +[1.0.9]: https://github.com/Chia-Mine/clvm-js/compare/v1.0.8...v1.0.9 [1.0.8]: https://github.com/Chia-Mine/clvm-js/compare/v1.0.7...v1.0.8 [1.0.7]: https://github.com/Chia-Mine/clvm-js/compare/v1.0.6...v1.0.7 [1.0.6]: https://github.com/Chia-Mine/clvm-js/compare/v1.0.5...v1.0.6 diff --git a/README.md b/README.md index 0188064..5e0fd73 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ If you find something not compatible with Python's clvm, please report it to Git ## Compatibility This code is compatible with: -- [`2722c78ddb92f067c5025196f397e4d2955f9053`](https://github.com/Chia-Network/clvm/tree/2722c78ddb92f067c5025196f397e4d2955f9053) of [clvm](https://github.com/Chia-Network/clvm) - - [Diff to the latest clvm](https://github.com/Chia-Network/clvm/compare/2722c78ddb92f067c5025196f397e4d2955f9053...main) +- [`389efa3fbe65c77600da63c78d29c0866d292754`](https://github.com/Chia-Network/clvm/tree/389efa3fbe65c77600da63c78d29c0866d292754) of [clvm](https://github.com/Chia-Network/clvm) + - [Diff to the latest clvm](https://github.com/Chia-Network/clvm/compare/389efa3fbe65c77600da63c78d29c0866d292754...main) - [`f9db7faa370c4743e48be8a9823232e4d906c4d0`](https://github.com/Chia-Network/bls-signatures/tree/f9db7faa370c4743e48be8a9823232e4d906c4d0) of [bls-signatures](https://github.com/Chia-Network/bls-signatures) - [Diff to the latest bls-signatures](https://github.com/Chia-Network/bls-signatures/compare/f9db7faa370c4743e48be8a9823232e4d906c4d0...main) diff --git a/package.json b/package.json index ba75d23..365fe5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clvm", - "version": "1.0.8", + "version": "1.0.9", "author": "ChiaMineJP ", "description": "Javascript implementation of chia lisp", "license": "MIT", diff --git a/src/as_javascript.ts b/src/as_javascript.ts index b75fa76..a9afd00 100644 --- a/src/as_javascript.ts +++ b/src/as_javascript.ts @@ -1,5 +1,5 @@ import {CastableType, SExp} from "./SExp"; -import {Bytes, Tuple, t} from "./__type_compatibility__"; +import {Bytes, Tuple, t, isList, isBytes} from "./__type_compatibility__"; export type TOpStack = Array<(op_stack: TOpStack, val_stack: TValStack) => unknown>; export type TValStack = Array>; @@ -18,32 +18,24 @@ export function as_javascript(sexp: SExp){ function _make_tuple(op_stack: TOpStack, val_stack: TValStack){ const left = val_stack.pop() as SExp; const right = val_stack.pop() as SExp; - if(right.equal_to(Bytes.NULL)){ + if(isBytes(right) && right.equal_to(Bytes.NULL)){ val_stack.push([left]); } + else if(isList(right)){ + const v = [left].concat(right); + val_stack.push(v); + } else{ val_stack.push(t(left, right)); } } - function _extend_list(op_stack: TOpStack, val_stack: TValStack){ - let left = [val_stack.pop()]; - const right = val_stack.pop(); - left = left.concat(right); - val_stack.push(left as SExp[]); - } - function _as_javascript(op_stack: TOpStack, val_stack: TValStack){ const v = val_stack.pop() as SExp; const pair = v.as_pair(); if(pair){ const [left, right] = pair; - if(right.listp()){ - op_stack.push(_extend_list); - } - else{ - op_stack.push(_make_tuple); - } + op_stack.push(_make_tuple); op_stack.push(_as_javascript); op_stack.push(_roll); op_stack.push(_as_javascript); diff --git a/tests/as_javascript_test.ts b/tests/as_javascript_test.ts index 735d03d..a529b80 100644 --- a/tests/as_javascript_test.ts +++ b/tests/as_javascript_test.ts @@ -42,6 +42,10 @@ test("test_null", () => { check_as_javascript(b("")); }); +test("test_embedded_tuples", () => { + check_as_javascript(t(b("10"), t(t(b("200"), b("300")), b("400")))); +}); + test("test_single_bytes", () => { for(let _=0;_<256;_++){ check_as_javascript(Bytes.from([_]));