diff --git a/Cargo.lock b/Cargo.lock index 9e24dc0a..947fb770 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,6 +56,12 @@ version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + [[package]] name = "asn1-rs" version = "0.6.2" @@ -201,6 +207,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "binascii" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" + [[package]] name = "bindgen" version = "0.69.5" @@ -305,6 +317,15 @@ dependencies = [ "wyz", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -314,6 +335,20 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "digest 0.9.0", + "ff", + "group", + "pairing", + "rand_core", + "subtle", +] + [[package]] name = "blst" version = "0.3.13" @@ -344,6 +379,15 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +[[package]] +name = "bytestream" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04f720842a717d6afaf69fee2dc69b771edc165f12cc3eb1b0e8eeef53a86454" +dependencies = [ + "byteorder", +] + [[package]] name = "cc" version = "1.1.12" @@ -403,7 +447,7 @@ dependencies = [ "hex", "hkdf", "lru", - "sha2", + "sha2 0.10.8", "thiserror", ] @@ -421,7 +465,7 @@ dependencies = [ "hkdf", "linked-hash-map", "serde", - "sha2", + "sha2 0.10.8", "thiserror", ] @@ -523,13 +567,14 @@ dependencies = [ "chia-secp", "clvm-traits", "clvm-utils", + "clvm_tools_rs", "clvmr", "hex", "num-bigint", "paste", "rand", "rand_chacha", - "sha2", + "sha2 0.10.8", ] [[package]] @@ -728,7 +773,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7020f53eeae8b4c24c5666165738173a167c6478e0c0a9e1c428a491a2e1383d" dependencies = [ - "sha2", + "sha2 0.10.8", ] [[package]] @@ -737,7 +782,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320474241a5e4b4eb7c7935ddac6e893cc4237d5fab58f1855c1aa48a97b1474" dependencies = [ - "sha2", + "sha2 0.10.8", ] [[package]] @@ -829,7 +874,7 @@ dependencies = [ "bindy", "bindy-macro", "chia-sdk-bindings", - "getrandom", + "getrandom 0.2.15", "js-sys", "wasm-bindgen", ] @@ -906,6 +951,39 @@ dependencies = [ "hex", ] +[[package]] +name = "clvm_tools_rs" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1b9d827d0d9bf3acbcb3be107efea37186c042976ac9073015bea3138a8eba" +dependencies = [ + "binascii", + "bls12_381", + "bytestream", + "clvmr", + "do-notation", + "encoding8", + "getrandom 0.2.15", + "hashlink", + "hex", + "indoc", + "js-sys", + "lazy_static", + "num", + "num-bigint", + "num-traits", + "pyo3-build-config 0.21.2", + "regex", + "serde", + "serde_json", + "sha2 0.9.9", + "tempfile", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-test", + "yaml-rust2", +] + [[package]] name = "clvmr" version = "0.12.0" @@ -1056,13 +1134,22 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -1079,6 +1166,12 @@ dependencies = [ "syn", ] +[[package]] +name = "do-notation" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e16a80c1dda2cf52fa07106427d3d798b6331dca8155fcb8c39f7fc78f6dd2" + [[package]] name = "dunce" version = "1.0.5" @@ -1092,7 +1185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest", + "digest 0.10.7", "elliptic-curve", "rfc6979", "signature", @@ -1113,7 +1206,7 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "digest", + "digest 0.10.7", "ff", "generic-array", "group", @@ -1125,6 +1218,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "encoding8" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3144e455c7aeda487c72555cac2ef84ccac173b29a57b07382ba27016e57b246" + [[package]] name = "encoding_rs" version = "0.8.35" @@ -1142,12 +1241,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1162,6 +1261,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ + "bitvec", "rand_core", "subtle", ] @@ -1334,10 +1434,22 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + [[package]] name = "gimli" version = "0.29.0" @@ -1396,6 +1508,15 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "heck" version = "0.5.0" @@ -1441,7 +1562,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -1660,7 +1781,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", - "sha2", + "sha2 0.10.8", "signature", ] @@ -1781,6 +1902,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minicov" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1813,7 +1944,7 @@ checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -1902,6 +2033,20 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -1910,6 +2055,7 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", + "serde", ] [[package]] @@ -1929,6 +2075,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -1955,6 +2110,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1999,6 +2165,12 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + [[package]] name = "openssl" version = "0.10.68" @@ -2062,7 +2234,16 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2", + "sha2 0.10.8", +] + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", ] [[package]] @@ -2240,12 +2421,22 @@ dependencies = [ "num-bigint", "once_cell", "portable-atomic", - "pyo3-build-config", + "pyo3-build-config 0.23.4", "pyo3-ffi", "pyo3-macros", "unindent", ] +[[package]] +name = "pyo3-build-config" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +dependencies = [ + "once_cell", + "target-lexicon", +] + [[package]] name = "pyo3-build-config" version = "0.23.4" @@ -2263,7 +2454,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d" dependencies = [ "libc", - "pyo3-build-config", + "pyo3-build-config 0.23.4", ] [[package]] @@ -2286,7 +2477,7 @@ checksum = "43abc3b80bc20f3facd86cd3c60beed58c3e2aa26213f3cda368de39c60a27e4" dependencies = [ "heck", "proc-macro2", - "pyo3-build-config", + "pyo3-build-config 0.23.4", "quote", "syn", ] @@ -2333,7 +2524,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -2361,9 +2552,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -2373,9 +2564,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -2384,9 +2575,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" @@ -2456,7 +2647,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", "spin", "untrusted 0.9.0", @@ -2470,7 +2661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" dependencies = [ "const-oid", - "digest", + "digest 0.10.7", "num-bigint-dig", "num-integer", "num-traits", @@ -2545,15 +2736,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2610,6 +2801,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.23" @@ -2720,7 +2920,20 @@ checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", ] [[package]] @@ -2731,7 +2944,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -2740,7 +2953,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest", + "digest 0.10.7", "keccak", ] @@ -2765,7 +2978,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", + "digest 0.10.7", "rand_core", ] @@ -2882,12 +3095,13 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -3191,9 +3405,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unindent" @@ -3242,6 +3456,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -3257,6 +3481,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -3266,6 +3499,8 @@ dependencies = [ "cfg-if", "once_cell", "rustversion", + "serde", + "serde_json", "wasm-bindgen-macro", ] @@ -3328,6 +3563,30 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-bindgen-test" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" +dependencies = [ + "js-sys", + "minicov", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "web-sys" version = "0.3.77" @@ -3359,6 +3618,15 @@ dependencies = [ "rustix", ] +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "windows-registry" version = "0.2.0" @@ -3480,6 +3748,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + [[package]] name = "wyz" version = "0.5.1" @@ -3507,6 +3784,17 @@ dependencies = [ "time", ] +[[package]] +name = "yaml-rust2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a1a1c0bc9823338a3bdf8c61f994f23ac004c6fa32c08cd152984499b445e8d" +dependencies = [ + "arraydeque", + "encoding_rs", + "hashlink", +] + [[package]] name = "yasna" version = "0.5.2" diff --git a/Cargo.toml b/Cargo.toml index 508ba837..6d22f08e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -162,6 +162,7 @@ sha2 = "0.10.8" pyo3 = "0.23.3" js-sys = "0.3.77" parking_lot = "0.12.3" +clvm_tools_rs = "0.1.46" [profile.release] lto = true diff --git a/bindings/clvm.json b/bindings/clvm.json index 04d92657..922d6d43 100644 --- a/bindings/clvm.json +++ b/bindings/clvm.json @@ -19,6 +19,12 @@ "coin_spends": { "return": "Vec" }, + "parse": { + "args": { + "program": "String" + }, + "return": "Program" + }, "deserialize": { "args": { "value": "SerializedProgram" diff --git a/bindings/program.json b/bindings/program.json index d41336f9..b6e57f7a 100644 --- a/bindings/program.json +++ b/bindings/program.json @@ -2,6 +2,12 @@ "Program": { "type": "class", "methods": { + "compile": { + "return": "Output" + }, + "unparse": { + "return": "String" + }, "serialize": { "return": "SerializedProgram" }, diff --git a/crates/chia-sdk-bindings/Cargo.toml b/crates/chia-sdk-bindings/Cargo.toml index ed3f08ab..1a16811c 100644 --- a/crates/chia-sdk-bindings/Cargo.toml +++ b/crates/chia-sdk-bindings/Cargo.toml @@ -40,3 +40,4 @@ rand = { workspace = true } rand_chacha = { workspace = true } num-bigint = { workspace = true } paste = { workspace = true } +clvm_tools_rs = { workspace = true } diff --git a/crates/chia-sdk-bindings/src/clvm.rs b/crates/chia-sdk-bindings/src/clvm.rs index 44454dd4..219f2883 100644 --- a/crates/chia-sdk-bindings/src/clvm.rs +++ b/crates/chia-sdk-bindings/src/clvm.rs @@ -4,6 +4,7 @@ use bindy::{Error, Result}; use chia_protocol::{Bytes, Bytes32, Program as SerializedProgram}; use chia_puzzle_types::nft; use chia_sdk_driver::{HashedPtr, Launcher, SpendContext, StandardLayer}; +use clvm_tools_rs::classic::clvm_tools::binutils::assemble; use clvm_traits::{clvm_quote, ToClvm}; use clvm_utils::TreeHash; use clvmr::{ @@ -207,6 +208,12 @@ impl Clvm { }) } + pub fn parse(&self, program: String) -> Result { + let mut ctx = self.0.write().unwrap(); + let ptr = assemble(&mut ctx.allocator, &program)?; + Ok(Program(self.0.clone(), ptr)) + } + pub fn deserialize(&self, value: SerializedProgram) -> Result { let mut ctx = self.0.write().unwrap(); let ptr = node_from_bytes(&mut ctx.allocator, &value)?; diff --git a/crates/chia-sdk-bindings/src/program.rs b/crates/chia-sdk-bindings/src/program.rs index df79513e..1d51b461 100644 --- a/crates/chia-sdk-bindings/src/program.rs +++ b/crates/chia-sdk-bindings/src/program.rs @@ -4,6 +4,11 @@ use bindy::{Error, Result}; use chia_protocol::{Bytes, Program as SerializedProgram}; use chia_puzzle_types::nft; use chia_sdk_driver::SpendContext; +use clvm_tools_rs::classic::clvm_tools::stages::run; +use clvm_tools_rs::classic::clvm_tools::stages::stage_0::TRunProgram; +use clvm_tools_rs::classic::clvm_tools::{ + binutils::disassemble, stages::stage_2::operators::run_program_for_search_paths, +}; use clvm_traits::{ClvmDecoder, ClvmEncoder, FromClvm}; use clvm_utils::{tree_hash, TreeHash}; use clvmr::{ @@ -19,6 +24,25 @@ use crate::{CurriedProgram, NftMetadata, Output, Pair, Puzzle}; pub struct Program(pub(crate) Arc>, pub(crate) NodePtr); impl Program { + pub fn compile(&self) -> Result { + let mut ctx = self.0.write().unwrap(); + + let invoke = run(&mut ctx.allocator); + let input = ctx.allocator.new_pair(self.1, NodePtr::NIL)?; + let run_program = run_program_for_search_paths("program.clsp", &[], false); + let output = run_program.run_program(&mut ctx.allocator, invoke, input, None)?; + + Ok(Output { + value: Program(self.0.clone(), output.1), + cost: output.0, + }) + } + + pub fn unparse(&self) -> Result { + let ctx = self.0.read().unwrap(); + Ok(disassemble(&ctx.allocator, self.1, None)) + } + pub fn serialize(&self) -> Result { let ctx = self.0.read().unwrap(); Ok(node_to_bytes(&ctx.allocator, self.1)?.into()) diff --git a/napi/index.d.ts b/napi/index.d.ts index 1e12b591..2eee9960 100644 --- a/napi/index.d.ts +++ b/napi/index.d.ts @@ -446,6 +446,8 @@ export declare class Mnemonic { toSeed(password: string): Uint8Array } export declare class Program { + compile(): Output + unparse(): string serialize(): Uint8Array serializeWithBackrefs(): Uint8Array run(solution: Program, maxCost: bigint, mempoolMode: boolean): Output @@ -588,6 +590,7 @@ export declare class Clvm { addCoinSpend(coinSpend: CoinSpend): void spendCoin(coin: Coin, spend: Spend): void coinSpends(): Array + parse(program: string): Program deserialize(value: Uint8Array): Program deserializeWithBackrefs(value: Uint8Array): Program pair(first: Program, rest: Program): Program