diff --git a/Cargo.lock b/Cargo.lock index 850322be5..3f60dc236 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,7 +86,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", "once_cell", "version_check", ] @@ -98,7 +98,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.12", + "getrandom 0.2.13", "once_cell", "version_check", "zerocopy", @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "ark-bls12-377" @@ -400,7 +400,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -443,7 +443,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -464,17 +464,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.2.0", - "event-listener-strategy 0.5.0", + "event-listener 5.3.0", + "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", ] [[package]] name = "async-compression" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" +checksum = "07dbbf24db18d609b1462965249abdf49129ccad073ec257da372adc83259c60" dependencies = [ "brotli", "flate2", @@ -486,15 +486,15 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +checksum = "5f98c37cf288e302c16ef6c8472aad1e034c6c84ce5ea7b8101c98eb4a802fee" dependencies = [ "async-lock 3.3.0", "async-task", "concurrent-queue", - "fastrand 2.0.1", - "futures-lite 2.2.0", + "fastrand 2.0.2", + "futures-lite 2.3.0", "slab", ] @@ -518,7 +518,7 @@ checksum = "bc19683171f287921f2405677dd2ed2549c3b3bda697a563ebc3a121ace2aba1" dependencies = [ "async-lock 3.3.0", "blocking", - "futures-lite 2.2.0", + "futures-lite 2.3.0", ] [[package]] @@ -543,18 +543,18 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65" +checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" dependencies = [ "async-lock 3.3.0", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "parking", - "polling 3.5.0", - "rustix 0.38.31", + "polling 3.6.0", + "rustix 0.38.32", "slab", "tracing", "windows-sys 0.52.0", @@ -597,9 +597,9 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" dependencies = [ - "async-io 2.3.1", + "async-io 2.3.2", "blocking", - "futures-lite 2.2.0", + "futures-lite 2.3.0", ] [[package]] @@ -615,25 +615,27 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.31", + "rustix 0.38.32", "windows-sys 0.48.0", ] [[package]] name = "async-process" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451e3cf68011bd56771c79db04a9e333095ab6349f7e47592b788e9b98720cc8" +checksum = "d999d925640d51b662b7b4e404224dd81de70f4aa4a199383c2c5e5b86885fa3" dependencies = [ "async-channel 2.2.0", - "async-io 2.3.1", + "async-io 2.3.2", "async-lock 3.3.0", "async-signal", + "async-task", "blocking", "cfg-if", - "event-listener 5.2.0", - "futures-lite 2.2.0", - "rustix 0.38.31", + "event-listener 5.3.0", + "futures-lite 2.3.0", + "rustix 0.38.32", + "tracing", "windows-sys 0.52.0", ] @@ -643,13 +645,13 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.3.1", + "async-io 2.3.2", "async-lock 2.8.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.31", + "rustix 0.38.32", "signal-hook-registry", "slab", "windows-sys 0.48.0", @@ -663,13 +665,13 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -686,9 +688,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backoff" @@ -696,16 +698,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", "instant", "rand 0.8.5", ] [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line 0.21.0", "cc", @@ -746,13 +748,28 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + +[[package]] +name = "base64-simd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5" +dependencies = [ + "simd-abstraction", +] + [[package]] name = "base64-simd" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" dependencies = [ - "outref", + "outref 0.5.1", "vsimd", ] @@ -764,9 +781,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" +checksum = "823388e228f614e9558c6804262db37960ec8821856535f5c3f59913140558f8" dependencies = [ "serde", ] @@ -825,9 +842,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitvec" @@ -928,20 +945,20 @@ dependencies = [ "async-channel 2.2.0", "async-lock 3.3.0", "async-task", - "fastrand 2.0.1", + "fastrand 2.0.2", "futures-io", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "piper", "tracing", ] [[package]] name = "bollard" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83545367eb6428eb35c29cdec3a1f350fa8d6d9085d59a7d7bcb637f2e38db5a" +checksum = "0aed08d3adb6ebe0eff737115056652670ae290f177759aac19c30456135f94c" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "bollard-stubs", "bytes", "futures-core", @@ -981,9 +998,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" +checksum = "0901fc8eb0aca4c83be0106d6f2db17d86a08dfc2c25f0e84464bf381158add6" dependencies = [ "borsh-derive", "cfg_aliases", @@ -991,15 +1008,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" +checksum = "51670c3aa053938b0ee3bd67c3817e471e626151131b934038e83c5bf8de48f5" dependencies = [ "once_cell", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "syn_derive", ] @@ -1029,9 +1046,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.4.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" +checksum = "125740193d7fee5cc63ab9e16c2fdc4e07c74ba755cc53b327d6ea029e9fc569" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1040,9 +1057,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" +checksum = "65622a320492e09b5e0ac436b14c54ff68199bac392d0e89a6832c4518eea525" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1065,9 +1082,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] @@ -1131,9 +1148,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "camino" @@ -1146,9 +1163,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] @@ -1178,14 +1195,23 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" dependencies = [ "jobserver", "libc", ] +[[package]] +name = "cfg-expr" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" +dependencies = [ + "smallvec", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -1211,9 +1237,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1234,9 +1260,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -1251,19 +1277,19 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1394,9 +1420,9 @@ checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" [[package]] name = "contract-build" -version = "4.0.0-rc.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0cace153488962932541d89bc7e8e515cf1c4606ea45fe55826d59505078fa4" +checksum = "a1419d360c4519b3995a7e390f0f6a72a386c2cfb9a187f1114a3e9c719e02c1" dependencies = [ "anyhow", "blake2", @@ -1407,7 +1433,7 @@ dependencies = [ "contract-metadata", "crossterm", "duct", - "heck", + "heck 0.5.0", "hex", "impl-serde", "parity-scale-codec", @@ -1417,26 +1443,26 @@ dependencies = [ "semver 1.0.22", "serde", "serde_json", - "strum 0.26.1", + "strum 0.26.2", "tempfile", "term_size", "tokio", "tokio-stream", - "toml 0.8.10", + "toml 0.8.12", "tracing", "url", "uzers", "walkdir", "wasm-opt", - "which 6.0.0", + "which 6.0.1", "zip", ] [[package]] name = "contract-extrinsics" -version = "4.0.0-rc.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74055aad722db419082ac0615daa2f4b6099f20eddb78213dc17bc06fc4943bc" +checksum = "fc0cd1533705bd07c376992b9dfc31751da41376450da0481f6c89f864d7847a" dependencies = [ "anyhow", "blake2", @@ -1468,9 +1494,9 @@ dependencies = [ [[package]] name = "contract-metadata" -version = "4.0.0-rc.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664ab6d50dbdba63b7c4e61ca9830252c69e0e507a20f2f74fc2c6b6582e3bf1" +checksum = "7b31736c09a0d23fec6263686d4bce595634faeed1875520fecf191985f7a2db" dependencies = [ "anyhow", "impl-serde", @@ -1482,9 +1508,9 @@ dependencies = [ [[package]] name = "contract-transcode" -version = "4.0.0-rc.4" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf881647e38164a63be6dfed4af4ce2bf418c4464fc8cb15eb495292c149dc3" +checksum = "0e17348a8e977b53dbdc8fde57861726f98fbb89eee36d8884c85b9838769430" dependencies = [ "anyhow", "base58", @@ -1492,7 +1518,7 @@ dependencies = [ "contract-metadata", "escape8259", "hex", - "indexmap 2.2.5", + "indexmap 2.2.6", "ink_env", "ink_metadata", "itertools 0.12.1", @@ -1503,7 +1529,7 @@ dependencies = [ "scale-info", "serde", "serde_json", - "strsim 0.11.0", + "strsim 0.11.1", "thiserror", "tracing", ] @@ -1596,7 +1622,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossterm_winapi", "libc", "mio", @@ -1724,14 +1750,14 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "cxx" -version = "1.0.119" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "635179be18797d7e10edb9cd06c859580237750c7351f39ed9b298bfc17544ad" +checksum = "ff4dc7287237dd438b926a81a1a5605dad33d286870e5eee2db17bf2bcd9e92a" dependencies = [ "cc", "cxxbridge-flags", @@ -1741,9 +1767,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.119" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9324397d262f63ef77eb795d900c0d682a34a43ac0932bec049ed73055d52f63" +checksum = "f47c6c8ad7c1a10d3ef0fe3ff6733f4db0d78f08ef0b13121543163ef327058b" dependencies = [ "cc", "codespan-reporting", @@ -1751,24 +1777,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "cxxbridge-flags" -version = "1.0.119" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a87ff7342ffaa54b7c61618e0ce2bbcf827eba6d55b923b83d82551acbbecfe5" +checksum = "701a1ac7a697e249cdd8dc026d7a7dafbfd0dbcd8bd24ec55889f2bc13dd6287" [[package]] name = "cxxbridge-macro" -version = "1.0.119" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70b5b86cf65fa0626d85720619d80b288013477a91a0389fa8bc716bf4903ad1" +checksum = "b404f596046b0bb2d903a9c786b875a126261b52b7c3a64bbb66382c41c771df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1816,7 +1842,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1838,7 +1864,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1960,7 +1986,7 @@ dependencies = [ "serde_json", "serde_v8", "smallvec", - "sourcemap 7.0.1", + "sourcemap 7.1.1", "tokio", "url", "v8", @@ -2021,9 +2047,9 @@ dependencies = [ [[package]] name = "deno_media_type" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a798670c20308e5770cc0775de821424ff9e85665b602928509c8c70430b3ee0" +checksum = "edf9879493856d1622be70f396b0b0d3e519538dd6501b7c609ecbaa7e2194d2" dependencies = [ "data-url", "serde", @@ -2072,7 +2098,7 @@ dependencies = [ "quote", "strum 0.25.0", "strum_macros 0.25.3", - "syn 2.0.52", + "syn 2.0.58", "thiserror", ] @@ -2119,7 +2145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a054195576d4629bb1dde11756d8ba980f6a7c2805d3f21c83dfde8d0d4bd6f6" dependencies = [ "async-trait", - "base64-simd", + "base64-simd 0.8.0", "bytes", "deno_core", "encoding_rs", @@ -2162,9 +2188,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "pem-rfc7468", @@ -2194,13 +2220,13 @@ dependencies = [ [[package]] name = "derive-syn-parse" -version = "0.1.5" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.58", ] [[package]] @@ -2293,7 +2319,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2304,18 +2330,18 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "docify" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc4fd38aaa9fb98ac70794c82a00360d1e165a87fbf96a8a91f9dfc602aaee2" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" dependencies = [ "docify_macros", ] [[package]] name = "docify_macros" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63fa215f3a0d40fb2a221b3aa90d8e1fbb8379785a990cb60d62ac71ebdc6460" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" dependencies = [ "common-path", "derive-syn-parse", @@ -2323,17 +2349,17 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.52", + "syn 2.0.58", "termcolor", - "toml 0.8.10", + "toml 0.8.12", "walkdir", ] [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dprint-swc-ext" @@ -2506,7 +2532,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2573,9 +2599,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" dependencies = [ "concurrent-queue", "parking", @@ -2594,11 +2620,11 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ - "event-listener 5.2.0", + "event-listener 5.3.0", "pin-project-lite", ] @@ -2613,7 +2639,7 @@ dependencies = [ "prettier-please", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2639,9 +2665,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fastwebsockets" @@ -2672,9 +2698,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" +checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" [[package]] name = "filetime" @@ -2773,6 +2799,30 @@ dependencies = [ "serde", ] +[[package]] +name = "frame-support-procedural-tools" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ac1266522a8c9a2d2d26d205ec3028b88582d5f3cd5cbc75d0ec8271d197b7" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c078db2242ea7265faa486004e7fd8daaf1a577cfcac0070ce55d926922883" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "from_variant" version = "0.1.6" @@ -2782,7 +2832,7 @@ dependencies = [ "pmutil", "proc-macro2", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2876,11 +2926,11 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.1", + "fastrand 2.0.2", "futures-core", "futures-io", "parking", @@ -2895,7 +2945,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2967,9 +3017,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "libc", @@ -3015,11 +3065,11 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "git2" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b3ba52851e73b46a4c3df1d89343741112003f0f6f13beb0dfac9e457c3fdcd" +checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "libgit2-sys", "log", @@ -3051,7 +3101,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -3108,6 +3158,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -3191,15 +3247,16 @@ dependencies = [ [[package]] name = "hstr" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fafeca18cf0927e23ea44d7a5189c10536279dfe9094e0dfa953053fbb5377" +checksum = "b0f5356d62012374578cd3a5c013d6586de3efbca3b53379fc1edfbb95c9db14" dependencies = [ + "hashbrown 0.14.3", "new_debug_unreachable", "once_cell", "phf", "rustc-hash", - "smallvec", + "triomphe", ] [[package]] @@ -3247,12 +3304,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" dependencies = [ "bytes", - "futures-util", + "futures-core", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", @@ -3302,7 +3359,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -3523,9 +3580,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -3553,18 +3610,18 @@ dependencies = [ [[package]] name = "ink_allocator" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4509501e7eaee3988cc7f22a044f3be6599c8532a303b80b0c5761c8d940e413" +checksum = "5cee56055bac6d928d425e944c5f3b69baa33c9635822fd1c00cd4afc70fde3e" dependencies = [ "cfg-if", ] [[package]] name = "ink_engine" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1967c441dd9cca93af1cea6601115b8ac5a596befd01090ddf68607259dc57" +checksum = "4f357e2e867f4e222ffc4015a6e61d1073548de89f70a4e36a8b0385562777fa" dependencies = [ "blake2", "derive_more", @@ -3578,9 +3635,9 @@ dependencies = [ [[package]] name = "ink_env" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff8e745688bfe87f6d5ecb39ad3e3d712465a756f4a7b76fd9214b8310061c" +checksum = "42cec50b7e4f8406aab25801b015d3802a52d76cfbe48ce11cfb4200fa88e296" dependencies = [ "blake2", "cfg-if", @@ -3608,9 +3665,9 @@ dependencies = [ [[package]] name = "ink_metadata" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7a6dbb5dee1ed28e022cd99866ae426cae4e8172d66f40349fe1c022034579" +checksum = "a98fcc0ff9292ff68c7ee7b84c93533c9ff13859ec3b148faa822e2da9954fe6" dependencies = [ "derive_more", "impl-serde", @@ -3625,18 +3682,18 @@ dependencies = [ [[package]] name = "ink_prelude" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfed647babce3e9f2ca528866b16edce8156b49550fa971bf11e52410239703" +checksum = "ea1734d058c80aa72e59c8ae75624fd8a51791efba21469f273156c0f4cad5c9" dependencies = [ "cfg-if", ] [[package]] name = "ink_primitives" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22dcad2912e7faadd116fc7952956c87225fe751a99da77d051a83d8fa404ca7" +checksum = "11ec35ef7f45e67a53b6142d7e7f18e6d9292d76c3a2a1da14cf8423e481813d" dependencies = [ "derive_more", "ink_prelude", @@ -3649,9 +3706,9 @@ dependencies = [ [[package]] name = "ink_storage_traits" -version = "5.0.0-rc.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782122a6be4e7a0022d4e9ad70d99311adc64402635731436d26bbee5eb3c590" +checksum = "83ce49e3d2935fc1ec3e73117119712b187d3123339f6a31624e92f75fa2293d" dependencies = [ "ink_metadata", "ink_prelude", @@ -3726,7 +3783,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3758,9 +3815,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" @@ -4150,7 +4207,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.12", + "getrandom 0.2.13", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4221,7 +4278,7 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "999ec70441b2fb35355076726a6bc466c932e9bdc66f6a11c6c0aa17c7ab9be0" dependencies = [ - "bs58 0.5.0", + "bs58 0.5.1", "ed25519-dalek", "hkdf", "multihash", @@ -4256,13 +4313,12 @@ dependencies = [ [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -4339,9 +4395,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.15" +version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" +checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" dependencies = [ "cc", "libc", @@ -4381,7 +4437,7 @@ checksum = "adf157a4dc5a29b7b464aa8fe7edeff30076e07e13646a1c3874f58477dc99f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4468,9 +4524,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memfd" @@ -4478,7 +4534,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.31", + "rustix 0.38.32", ] [[package]] @@ -4640,9 +4696,9 @@ dependencies = [ [[package]] name = "new_debug_unreachable" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nix" @@ -4650,7 +4706,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "libc", ] @@ -4861,7 +4917,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -4878,7 +4934,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -4889,9 +4945,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -4924,6 +4980,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "outref" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" + [[package]] name = "outref" version = "0.5.1" @@ -5101,9 +5163,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" dependencies = [ "memchr", "thiserror", @@ -5112,9 +5174,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" dependencies = [ "pest", "pest_generator", @@ -5122,22 +5184,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "pest_meta" -version = "2.7.8" +version = "2.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" dependencies = [ "once_cell", "pest", @@ -5174,7 +5236,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5203,14 +5265,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -5225,7 +5287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" dependencies = [ "atomic-waker", - "fastrand 2.0.1", + "fastrand 2.0.2", "futures-io", ] @@ -5278,9 +5340,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platforms" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" +checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" [[package]] name = "pmutil" @@ -5290,7 +5352,7 @@ checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5312,7 +5374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6380dbe1fb03ecc74ad55d841cfc75480222d153ba69ddcb00977866cbdabdb8" dependencies = [ "polkavm-derive-impl 0.5.0", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5333,7 +5395,7 @@ dependencies = [ "polkavm-common 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5345,7 +5407,7 @@ dependencies = [ "polkavm-common 0.8.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5355,7 +5417,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e85319a0d5129dc9f021c62607e0804f5fb777a05cdda44d750ac0732def66" dependencies = [ "polkavm-derive-impl 0.8.0", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5376,14 +5438,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" +checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" dependencies = [ "cfg-if", "concurrent-queue", + "hermit-abi", "pin-project-lite", - "rustix 0.38.31", + "rustix 0.38.32", "tracing", "windows-sys 0.52.0", ] @@ -5419,6 +5482,7 @@ dependencies = [ "anyhow", "askama", "assert_cmd", + "cfg-expr", "clap", "cliclack", "console", @@ -5426,27 +5490,34 @@ dependencies = [ "contract-extrinsics", "dirs", "duct", + "frame-support-procedural-tools", "git2", - "indexmap 2.2.5", + "indexmap 2.2.6", "ink_env", "log", "predicates", + "prettyplease", + "proc-macro2", + "quote", "regex", "reqwest", + "semver 1.0.22", "serde", "serde_json", "sp-core 30.0.0", "sp-weights", - "strum 0.26.1", - "strum_macros 0.26.1", + "strum 0.26.2", + "strum_macros 0.26.2", "subxt 0.34.0", "subxt-signer 0.34.0", "symlink", + "syn 2.0.58", "tempfile", "tokio", - "toml_edit 0.22.6", + "toml_edit 0.22.9", "tracing-subscriber 0.3.18", "url", + "uuid", "walkdir", "zombienet-sdk", "zombienet-support", @@ -5507,7 +5578,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22020dfcf177fcc7bf5deaf7440af371400c67c0de14c399938d8ed4fb4645d3" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.58", +] + +[[package]] +name = "prettyplease" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +dependencies = [ + "proc-macro2", + "syn 2.0.58", ] [[package]] @@ -5592,7 +5673,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -5604,14 +5685,14 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -5734,7 +5815,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", ] [[package]] @@ -5757,11 +5838,11 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", "libredox", "thiserror", ] @@ -5783,19 +5864,19 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.6", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -5815,7 +5896,7 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -5826,9 +5907,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rend" @@ -5841,9 +5922,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "async-compression", "base64 0.21.7", @@ -5915,7 +5996,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.12", + "getrandom 0.2.13", "libc", "spin 0.9.8", "untrusted", @@ -5979,9 +6060,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.34.3" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39449a79f45e8da28c57c341891b69a183044b29518bb8f86dbac9df60bb7df" +checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" dependencies = [ "arrayvec 0.7.4", "borsh", @@ -6059,11 +6140,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys 0.4.13", @@ -6084,9 +6165,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" dependencies = [ "log", "ring", @@ -6115,7 +6196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "schannel", "security-framework", @@ -6132,19 +6213,19 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" [[package]] name = "rustls-tokio-stream" @@ -6180,9 +6261,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ruzstd" @@ -6296,9 +6377,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.10.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +checksum = "788745a868b0e751750388f4e6546eb921ef714a4317fa6954f7cde114eb2eb7" dependencies = [ "bitvec", "cfg-if", @@ -6311,9 +6392,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.10.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +checksum = "7dc2f4e8bc344b9fc3d5f74f72c2e55bfc38d28dc2ebc69c194a3df424e4d9ac" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -6330,7 +6411,7 @@ dependencies = [ "proc-macro2", "quote", "scale-info", - "syn 2.0.52", + "syn 2.0.58", "thiserror", ] @@ -6531,9 +6612,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -6544,9 +6625,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -6612,7 +6693,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -6628,11 +6709,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -6646,7 +6727,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -6687,15 +6768,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" +checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" dependencies = [ "base64 0.21.7", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_derive", "serde_json", @@ -6704,11 +6785,11 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -6855,6 +6936,15 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simd-abstraction" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987" +dependencies = [ + "outref 0.1.0", +] + [[package]] name = "simdutf8" version = "0.1.4" @@ -6875,9 +6965,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "siphasher" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" @@ -6890,9 +6980,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smartstring" @@ -6937,12 +7027,12 @@ dependencies = [ "async-channel 2.2.0", "async-executor", "async-fs 2.1.1", - "async-io 2.3.1", + "async-io 2.3.2", "async-lock 3.3.0", "async-net 2.0.0", - "async-process 2.1.0", + "async-process 2.2.0", "blocking", - "futures-lite 2.2.0", + "futures-lite 2.3.0", ] [[package]] @@ -6957,7 +7047,7 @@ dependencies = [ "base64 0.21.7", "bip39", "blake2-rfc", - "bs58 0.5.0", + "bs58 0.5.1", "chacha20", "crossbeam-queue", "derive_more", @@ -6965,7 +7055,7 @@ dependencies = [ "either", "event-listener 3.1.0", "fnv", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "futures-util", "hashbrown 0.14.3", "hex", @@ -6990,7 +7080,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "sha3", - "siphasher 1.0.0", + "siphasher 1.0.1", "slab", "smallvec", "soketto", @@ -7012,7 +7102,7 @@ dependencies = [ "base64 0.21.7", "bip39", "blake2-rfc", - "bs58 0.5.0", + "bs58 0.5.1", "chacha20", "crossbeam-queue", "derive_more", @@ -7020,7 +7110,7 @@ dependencies = [ "either", "event-listener 4.0.3", "fnv", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "futures-util", "hashbrown 0.14.3", "hex", @@ -7045,7 +7135,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "sha3", - "siphasher 1.0.0", + "siphasher 1.0.1", "slab", "smallvec", "soketto", @@ -7070,7 +7160,7 @@ dependencies = [ "event-listener 3.1.0", "fnv", "futures-channel", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "futures-util", "hashbrown 0.14.3", "hex", @@ -7084,7 +7174,7 @@ dependencies = [ "rand_chacha 0.3.1", "serde", "serde_json", - "siphasher 1.0.0", + "siphasher 1.0.1", "slab", "smol 1.3.0", "smoldot 0.14.0", @@ -7106,7 +7196,7 @@ dependencies = [ "event-listener 4.0.3", "fnv", "futures-channel", - "futures-lite 2.2.0", + "futures-lite 2.3.0", "futures-util", "hashbrown 0.14.3", "hex", @@ -7120,7 +7210,7 @@ dependencies = [ "rand_chacha 0.3.1", "serde", "serde_json", - "siphasher 1.0.0", + "siphasher 1.0.1", "slab", "smol 2.0.0", "smoldot 0.16.0", @@ -7180,17 +7270,18 @@ dependencies = [ [[package]] name = "sourcemap" -version = "7.0.1" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10da010a590ed2fa9ca8467b00ce7e9c5a8017742c0c09c45450efc172208c4b" +checksum = "e7768edd06c02535e0d50653968f46e1e0d3aa54742190d35dd9466f59de9c71" dependencies = [ + "base64-simd 0.7.0", "data-encoding", "debugid", "if_chain", "rustc_version 0.2.3", "serde", "serde_json", - "unicode-id", + "unicode-id-start", "url", ] @@ -7280,7 +7371,7 @@ dependencies = [ "bitflags 1.3.2", "blake2", "bounded-collections 0.2.0", - "bs58 0.5.0", + "bs58 0.5.1", "dyn-clonable", "ed25519-zebra 3.1.0", "futures", @@ -7379,7 +7470,7 @@ checksum = "f12dae7cf6c1e825d13ffd4ce16bd9309db7c539929d0302b4443ed451a9f4e5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -7390,7 +7481,7 @@ checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -7540,7 +7631,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -7554,7 +7645,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -7738,9 +7829,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.46.0" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1114ee5900b8569bbc8b1a014a942f937b752af4b44f4607430b5f86cedaac0" +checksum = "4743ce898933fbff7bbf414f497c459a782d496269644b3d650a398ae6a487ba" dependencies = [ "Inflector", "num-format", @@ -7786,7 +7877,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -7797,9 +7888,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -7818,11 +7909,11 @@ dependencies = [ [[package]] name = "strum" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.26.1", + "strum_macros 0.26.2", ] [[package]] @@ -7831,7 +7922,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -7844,24 +7935,24 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "strum_macros" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -7959,7 +8050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12800ad6128b4bfc93d2af89b7d368bff7ea2f6604add35f96f6a8c06c7f9abf" dependencies = [ "frame-metadata 16.0.0", - "heck", + "heck 0.4.1", "hex", "jsonrpsee 0.20.3", "parity-scale-codec", @@ -7967,7 +8058,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata 0.33.0", - "syn 2.0.52", + "syn 2.0.58", "thiserror", "tokio", ] @@ -7979,7 +8070,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d0e58c3f88651cff26aa52bae0a0a85f806a2e923a20eb438c16474990743ea" dependencies = [ "frame-metadata 16.0.0", - "heck", + "heck 0.4.1", "hex", "jsonrpsee 0.21.0", "parity-scale-codec", @@ -7988,7 +8079,7 @@ dependencies = [ "scale-info", "scale-typegen", "subxt-metadata 0.34.0", - "syn 2.0.52", + "syn 2.0.58", "thiserror", "tokio", ] @@ -8037,7 +8128,7 @@ dependencies = [ "parity-scale-codec", "proc-macro-error", "subxt-codegen 0.33.0", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8052,7 +8143,7 @@ dependencies = [ "quote", "scale-typegen", "subxt-codegen 0.34.0", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8185,7 +8276,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8194,7 +8285,7 @@ version = "0.110.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c3d416121da2d56bcbd1b1623725a68890af4552fef0c6d1e4bfa92776ccd6a" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "is-macro", "num-bigint", "phf", @@ -8235,7 +8326,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8280,7 +8371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d74ca42a400257d8563624122813c1849c3d87e7abe3b9b2ed7514c76f64ad2f" dependencies = [ "better_scoped_tls", - "bitflags 2.4.2", + "bitflags 2.5.0", "indexmap 1.9.3", "once_cell", "phf", @@ -8320,7 +8411,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8425,7 +8516,7 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8437,7 +8528,7 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8461,7 +8552,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8483,9 +8574,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -8501,7 +8592,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8512,20 +8603,20 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "system-configuration" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -8561,8 +8652,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.1", - "rustix 0.38.31", + "fastrand 2.0.2", + "rustix 0.38.32", "windows-sys 0.52.0", ] @@ -8613,22 +8704,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8708,9 +8799,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -8743,7 +8834,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -8772,7 +8863,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.2", + "rustls 0.22.3", "rustls-pki-types", "tokio", ] @@ -8791,9 +8882,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -8842,14 +8933,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.6", + "toml_edit 0.22.9", ] [[package]] @@ -8867,7 +8958,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -8880,7 +8971,7 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "toml_datetime", "winnow 0.5.40", ] @@ -8891,18 +8982,18 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -8933,7 +9024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "base64 0.21.7", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytes", "futures-core", "futures-util", @@ -8979,7 +9070,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -9091,6 +9182,16 @@ dependencies = [ "hash-db", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "trust-dns-proto" version = "0.22.0" @@ -9267,6 +9368,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" +[[package]] +name = "unicode-id-start" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" + [[package]] name = "unicode-ident" version = "1.0.12" @@ -9312,9 +9419,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "unsigned-varint" @@ -9367,11 +9474,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", "serde", ] @@ -9518,7 +9625,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -9552,7 +9659,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9823,27 +9930,26 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.31", + "rustix 0.38.32", ] [[package]] name = "which" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa5e0c10bf77f44aac573e498d1a82d5fbd5e91f6fc0a99e7be4b38e85e101c" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" dependencies = [ "either", "home", - "once_cell", - "rustix 0.38.31", - "windows-sys 0.52.0", + "rustix 0.38.32", + "winsafe", ] [[package]] name = "widestring" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" @@ -10111,6 +10217,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "wyz" version = "0.5.1" @@ -10140,7 +10252,7 @@ checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", "linux-raw-sys 0.4.13", - "rustix 0.38.31", + "rustix 0.38.32", ] [[package]] @@ -10172,7 +10284,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -10192,7 +10304,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 80ea50189..bebb2f78c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,20 +17,24 @@ console = "0.15" duct = "0.13" git2 = "0.18" log = "0.4" -# semver = "1.0.20" +semver = "1.0.20" strum = "0.26" strum_macros = "0.26" tempfile = "3.8" tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } url = { version = "2.5", optional = true } walkdir = "2.4" +toml_edit = { version = "0.22.7" } regex="1.5.4" # contracts contract-build = { version = "4.0.0-rc.3", optional = true } contract-extrinsics = { version = "4.0.0-rc.3", optional = true } sp-core = { version = "30.0.0", optional = true } -subxt-signer = { version = "0.34.0", features = ["subxt", "sr25519"], optional = true } +subxt-signer = { version = "0.34.0", features = [ + "subxt", + "sr25519", +], optional = true } subxt = { version = "0.34.0", optional = true } ink_env = { version = "5.0.0-rc.2", optional = true } sp-weights = { version = "29.0.0", optional = true } @@ -43,10 +47,18 @@ reqwest = { version = "0.11", optional = true } serde_json = { version = "1.0", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } symlink = { version = "0.1", optional = true } -toml_edit = { version = "0.22", optional = true } tracing-subscriber = { version = "0.3", optional = true } zombienet-sdk = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", optional = true } zombienet-support = { git = "https://github.com/r0gue-io/zombienet-sdk", branch = "pop", optional = true } +uuid = { version = "1.7.0", features = ["v4"], optional = true } +frame-support-procedural-tools = { version = "9.0.0", optional = true } +proc-macro2 = { version = "1.0.70", features = [ + "span-locations", +], optional = true } +quote = { version = "1.0.33", optional = true } +syn = { version = "2.0.52", features = ["full"], optional = true } +cfg-expr = { version = "0.15.5", optional = true } +prettyplease = { version = "0.2.15", optional = true } [dev-dependencies] assert_cmd = "2.0.14" @@ -72,11 +84,17 @@ parachain = [ "dep:reqwest", "dep:serde_json", "dep:symlink", - "dep:toml_edit", "dep:tracing-subscriber", "dep:url", "dep:zombienet-sdk", - "dep:zombienet-support" + "dep:zombienet-support", + "uuid", + "frame-support-procedural-tools", + "proc-macro2", + "quote", + "syn", + "cfg-expr", + "prettyplease", ] e2e_parachain = [] diff --git a/README.md b/README.md index 1151783e4..7322e54ba 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ There's also the shorter version: pop new parachain my-app -s DOT -d 6 -i 1_000_000_000 ``` -To create a new pallet, simply `pop new pallet`. And that's it. You will have a new `pallet-template` ready for hacking. +To create a new pallet, simply `pop new pallet`. And that's it. You will have a new `pallet-parachain-template` ready for hacking. To customize the new pallet you can follow these options: ```sh diff --git a/src/commands/add/mod.rs b/src/commands/add/mod.rs new file mode 100644 index 000000000..4cdd11cca --- /dev/null +++ b/src/commands/add/mod.rs @@ -0,0 +1,85 @@ +#![cfg(feature = "parachain")] +use std::path::PathBuf; + +use crate::engines::pallet_engine; +use clap::{Args, Subcommand}; +use cliclack::{intro, outro}; +use console::style; + +#[derive(Args)] +#[command(args_conflicts_with_subcommands = true)] +pub(crate) struct AddArgs { + #[command(subcommand)] + commands: AddCommands, + #[arg(global = true, short, long = "runtime")] + /// Runtime path; for example: `sub0/runtime/src/lib.rs` + /// Runtime cargo manifest path will be inferred as `(parent of lib.rs)/Cargo.toml` + pub(crate) runtime_path: Option, +} +#[derive(Subcommand)] +#[command(subcommand_required = true)] +pub(crate) enum AddCommands { + #[command(subcommand)] + /// Add a pallet + #[clap(alias = "p")] + Pallet(AddPallet), +} + +#[derive(Subcommand, Clone)] +#[command(subcommand_required = true)] +pub(crate) enum AddPallet { + /// Insert `pallet-parachain-template` into the runtime. + Template, + /// Insert a frame-pallet into the runtime. + Frame(FrameArgs), +} + +#[derive(Args, Clone)] +pub(crate) struct FrameArgs { + #[arg(short, long)] + // TODO: Not ready for use + pub(crate) name: String, +} + +impl AddArgs { + pub(crate) fn execute(&self) -> anyhow::Result<()> { + match self.commands { + AddCommands::Pallet(ref cmd) => cmd.clone().execute(&self.runtime_path), + } + } +} +impl AddPallet { + pub(crate) fn execute(self, runtime_path: &Option) -> anyhow::Result<()> { + let runtime_path = match runtime_path { + Some(ref s) => { + let path = PathBuf::from(s); + if !path.exists() { + anyhow::bail!("Invalid runtime path: {}", path.display()); + } + path + }, + None => { + // TODO: Fetch runtime either from cache + unimplemented!( + "provide a runtime path until feat:cache is implemented: --runtime " + ); + }, + }; + let pallet = match self { + AddPallet::Template => "pallet-parachain-template".to_string(), + AddPallet::Frame(FrameArgs { .. }) => { + eprintln!("Sorry, frame pallets cannot be added right now"); + std::process::exit(1); + // format!("FRAME pallet-{name}") + }, + }; + intro(format!( + "{}: Adding pallet \"{}\"!", + style(" Pop CLI ").black().on_magenta(), + &pallet, + ))?; + pallet_engine::execute(self, runtime_path.clone())?; + outro(format!("Added {}\n-> to {}", pallet, runtime_path.display()))?; + Ok(()) + } +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 8d0fc9718..ab203b7c6 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,3 +1,4 @@ +pub(crate) mod add; pub(crate) mod build; pub(crate) mod call; pub(crate) mod new; diff --git a/src/commands/new/pallet.rs b/src/commands/new/pallet.rs index 1f685ff16..f89a8c264 100644 --- a/src/commands/new/pallet.rs +++ b/src/commands/new/pallet.rs @@ -10,7 +10,7 @@ use std::fs; #[derive(Args)] pub struct NewPalletCommand { - #[arg(help = "Name of the pallet", default_value = "pallet-template")] + #[arg(help = "Name of the pallet", default_value = "pallet-parachain-template")] pub(crate) name: String, #[arg(short, long, help = "Name of authors", default_value = "Anonymous")] pub(crate) authors: Option, diff --git a/src/engines/pallet_engine/dependency.rs b/src/engines/pallet_engine/dependency.rs new file mode 100644 index 000000000..2e52fd115 --- /dev/null +++ b/src/engines/pallet_engine/dependency.rs @@ -0,0 +1,137 @@ +//! Dependency representations for Pallets +use std::path::{self, Path, PathBuf}; +use strum_macros::{Display, EnumString}; + +#[derive(EnumString, Display, Debug)] +pub(super) enum Features { + #[strum(serialize = "std")] + Std, + #[strum(serialize = "runtime-benchmarks")] + RuntimeBenchmarks, + #[strum(serialize = "try-runtime")] + TryRuntime, + /// Custom feature + Custom(String), +} +#[derive(Display, Debug, Clone)] +pub(super) enum Location { + /// Local path is form `path = "X"` + Local(std::path::PathBuf, Option), + /// `git = {url}` + Git(reqwest::Url, Option), + /// String should be of format `version = "X"` + CratesIO(semver::Version), +} +impl From for Location { + fn from(url: reqwest::Url) -> Self { + Self::Git(url, None) + } +} +impl From for Location { + fn from(path: std::path::PathBuf) -> Self { + Self::Local(path, None) + } +} +impl From<(std::path::PathBuf, semver::Version)> for Location { + fn from(info: (std::path::PathBuf, semver::Version)) -> Self { + Self::Local(info.0, Some(info.1)) + } +} +impl<'a> From<&'a std::path::Path> for Location { + fn from(path: &'a std::path::Path) -> Self { + Self::Local(path.to_path_buf(), None) + } +} +impl<'a> From<(&'a std::path::Path, semver::Version)> for Location { + fn from(info: (&'a std::path::Path, semver::Version)) -> Self { + Self::Local(info.0.to_path_buf(), Some(info.1.into())) + } +} +impl From for Location { + fn from(version: semver::Version) -> Self { + Self::CratesIO(version) + } +} +impl Into for Location { + fn into(self) -> String { + match self { + Location::Local(path, Some(version)) => { + format!("{{ path = \"{}\", version = \"{}\" }}", path.display(), version) + }, + Location::Local(path, _) => format!("{{ path = \"{}\" }}", path.display()), + Location::Git(url, Some(version)) => { + format!("{{ git = \"{}\", version = \"{}\" }}", url, version) + }, + Location::Git(url, _) => format!("{{ git = \"{}\" }}", url), + Location::CratesIO(version) => format!("{{ version = \"{}\" }}", version), + } + } +} +impl Into for Location { + fn into(self) -> toml_edit::Value { + let s = Into::::into(self); + let t = s + .parse::() + .expect("Location String parse as Toml Value failed"); + toml_edit::Value::InlineTable( + t.as_inline_table().expect(" Parsed Location -> ILT cast infallible").to_owned(), + ) + } +} + +#[derive(Debug)] +pub(super) struct Dependency { + /// Name for the dependency + pub(super) name: String, + /// Additional features that need to be enabled. Format -> {name}/{feature} + pub(super) features: Vec, + /// Maybe local path, git url, or from crates.io in which case we will use this for version + pub(super) path: Location, + /// Default features such as `std` are disabled by default for runtime pallet dependencies + pub(super) default_features: bool, +} + +impl Dependency { + /// Generate the main dependency as an inline table + pub(super) fn entry(&self) -> toml_edit::InlineTable { + let mut t = toml_edit::Table::new(); + let location = Into::::into(self.path.clone()); + t.extend( + location + .as_inline_table() + .expect("Location to String should produce valid inline table") + .to_owned(), + ); + t["default-features"] = toml_edit::value(self.default_features); + t.into_inline_table() + } + /// Create dependencies required for adding a local pallet to runtime + /// $(workspace_root)/pallets/pallet-name + // Todo: Some values are hardcoded for now as this only deals with the pallet-parachain-template + // Should be moved to args once that's not the case + pub(super) fn local_template_runtime(pallet_name: &'static str, workspace: &PathBuf) -> Self { + let name = format!("{pallet_name}"); + Self { + features: vec![Features::RuntimeBenchmarks, Features::TryRuntime, Features::Std], + path: ( + // The reason is, `pop new pallet` places a new pallet on $(workspace_root)/pallets + workspace.join("pallets/").join(&name).to_path_buf(), + semver::Version::new(1, 0, 0), + ) + .into(), + default_features: false, + name, + } + } + // TODO: Remove code - Node doesn't require template pallet deps by default + // but this maybe desirable for custom pallets. + // /// Create dependencies required for adding a pallet-parachain-template to node + // pub(super) fn template_node() -> Self { + // Self { + // features: vec![Features::RuntimeBenchmarks, Features::TryRuntime], + // // TODO hardcode for now + // path: format!("../pallets/pallet-parachain-template"), + // default_features: true, + // } + // } +} diff --git a/src/engines/pallet_engine/mod.rs b/src/engines/pallet_engine/mod.rs new file mode 100644 index 000000000..c822e8432 --- /dev/null +++ b/src/engines/pallet_engine/mod.rs @@ -0,0 +1,582 @@ +#![allow(unused)] +//! Pallet Engine - A set of tools to add pallets to your runtime +//! To add a pallet one usually needs to consider a few pieces of information together: +//! +//! 1. How is the pallet going to be configured? (impl pallet::Config for Runtime) +//! 2. How is the runtime instantiated in the current input source? (i.e. what kind of runtime declaration are we working with?) +//! 3. Are there benchmarks for the current pallet that would need to be included in the runtime and subsequently the runtime manifest? (including entries for list_benchmarks!) +//! +//! These are some necessary questions, but not an exhaustive list. One might further have to answer the following: +//! 1. Does adding this pallet exceed the total number of pallets > 255? +//! 2. Does the computed pallet index overflow the u8 bound? (gaps in explicit pallet index declarations) +//! 3. Is the pallet already in the runtime? If yes, do we add a second instance or abort? +//! 4. Does this pallet require a genesis configuration? +//! +//! It is the goal of this module, to answer all of these questions. + +mod dependency; +mod pallet_entry; +mod parser; +mod steps; +mod template; + +use crate::commands::add::AddPallet; +use crate::helpers::{is_git_repo_with_commits, write_to_file}; +use anyhow::{anyhow, bail, Context}; +use dependency::{Dependency, Features}; +use log::warn; +use pallet_entry::Numbers; +use pallet_entry::{AddPalletEntry, ReadPalletEntry}; +use parser::RuntimeDeclaration; +use proc_macro2::TokenStream; +use quote::quote; +use std::io::Read; +use std::{ + collections::HashMap, + fs::{self, File, OpenOptions}, + io::{BufRead, BufReader, Write}, + path::{Path, PathBuf}, +}; +use steps::{run_steps, step_builder}; +use syn::{spanned::Spanned, Item, ItemMacro}; +pub use template::{create_pallet_template, TemplatePalletConfig}; +use toml_edit::DocumentMut; + +/// The main entry point into the engine. +pub fn execute(pallet: AddPallet, runtime_path: PathBuf) -> anyhow::Result<()> { + let mut pe = PalletEngine::new(&runtime_path)?; + // Todo: Add option to source from cli + let te = TomlEditor::infer(&runtime_path)?; + // Check if workspace has uncommitted changes, if yes, abort + if !is_git_repo_with_commits(&te.workspace)? { + cliclack::log::error(format!("Workspace -> {}", te.workspace.display())); + bail!("Workspace has uncommitted changes, aborting pallet addition"); + } + let steps = step_builder(pallet, &te)?; + run_steps(pe, te, steps) +} +#[derive(Default)] +struct TomlEditor { + /// Path to workspace toml file + workspace: PathBuf, + /// Path to runtime toml file + runtime: PathBuf, + /// Path to node toml file + node: PathBuf, +} +impl TomlEditor { + fn new(workspace: &Path, runtime: &Path, node: &Path) -> Self { + Self { + workspace: workspace.to_path_buf(), + runtime: runtime.to_path_buf(), + node: node.to_path_buf(), + } + } + /// Infer a given runtime and node manifest paths from the given runtime path + /// runtime -> ../Cargo.toml + /// node -> ../../node/Cargo.toml + /// workspace -> ../../Cargo.toml + fn infer(runtime_path: &Path) -> anyhow::Result { + let runtime_path = fs::canonicalize(runtime_path).with_context(|| { + format!("Failed to resolve {} into absolute path", runtime_path.display()) + })?; + let workspace_manifest = runtime_path + .parent() // src + .unwrap() + .parent() // runtime + .unwrap() + .parent() + .unwrap(); // workspace + let runtime_manifest = workspace_manifest.join("runtime/Cargo.toml"); + let node_manifest = workspace_manifest.join("node/Cargo.toml"); + Ok(Self { + workspace: workspace_manifest.to_path_buf(), + runtime: runtime_manifest, + node: node_manifest, + }) + } + /// Inject a dependency into the node manifest + fn inject_node(&self, dep: Dependency) -> anyhow::Result<()> { + let mut s = String::new(); + let mut f = BufReader::new(File::open(&self.node)?); + f.read_to_string(&mut s) + .context("Dependency Injection: Failed to read node:Cargo.toml")?; + let doc = s.parse::().context("Cannot parse toml")?; + let updated_doc = self.inject(doc, dep)?.to_string(); + use std::io::Write; + let mut file = OpenOptions::new() + .write(true) + .truncate(true) + .create(false) + .open(&self.node) + .unwrap(); + file.write_all(updated_doc.as_bytes()) + .context("failed to update node:Cargo.toml") + } + /// Inject a dependency into the runtime manifest + fn inject_runtime(&self, dep: Dependency) -> anyhow::Result<()> { + let mut s = String::new(); + let mut f = BufReader::new(File::open(&self.runtime)?); + f.read_to_string(&mut s) + .context("Dependency Injection: Failed to read runtime:Cargo.toml")?; + let doc = s.parse::().context("Cannot parse toml")?; + let updated_doc = self.inject(doc, dep)?.to_string(); + use std::io::Write; + let mut file = OpenOptions::new() + .write(true) + .truncate(true) + .create(false) + .open(&self.runtime) + .unwrap(); + file.write_all(updated_doc.as_bytes()) + .context("failed to update runtime:Cargo.toml") + } + /// Inject a dependency to a DocumentMut representation of a toml file + fn inject(&self, mut doc: DocumentMut, dep: Dependency) -> anyhow::Result { + use toml_edit::{value, Item, Table}; + doc["dependencies"][&dep.name] = value(dep.entry()); + let Dependency { name, features, .. } = dep; + for feature in features { + match feature { + Features::Std => { + // features + let std = doc["features"]["std"].as_value_mut().expect("feature std not found"); + let arr = std.as_array_mut().unwrap(); + arr.push_formatted(format!("{}/std", name).into()); + }, + Features::RuntimeBenchmarks => { + let rt_bnch = doc["features"]["runtime-benchmarks"] + .as_value_mut() + .expect("feature runtime-benchmarks not found"); + let arr = rt_bnch.as_array_mut().unwrap(); + arr.push_formatted(format!("{}/runtime-benchmarks", name).into()); + }, + Features::TryRuntime => { + let try_rt = doc["features"]["try-runtime"] + .as_value_mut() + .expect("feature try-runtime not found"); + let arr = try_rt.as_array_mut().unwrap(); + arr.push_formatted(format!("{}/try-runtime", name).into()); + }, + Features::Custom(_) => unimplemented!("Custom features not supported yet"), + } + } + Ok(doc) + } +} + +/// State of PalletEngine at any given moment in time +#[derive(Debug, Default, PartialEq)] +// TODO: Impl sequence checking through discriminants +enum State { + #[default] + Init, + Import, + Config, + ConstructRuntime, + Benchmarks, + ImplRuntimeApi, +} +/// The Pallet Engine has two Paths `input` and `output`. +/// During processing, we keep the input source as read only and perform all processing into the `output` sink +/// This allows for manual checking using a diff tool that the edits performed are indeed satisfactory before calling merge +/// which will overwrite `input` with the processed `output` +pub struct PalletEngine { + /// Input source to PalletEngine - This will be the path to the runtime/src/lib.rs + /// In code, this is never touched directly until the final step where it's overwritten + /// Interim, it's treated as immutable data + input: PathBuf, + /// Stores the details of the runtime pallets built from input + details: PalletDetails, + /// Stores imports necessary to make new items available + imports: ImportDetails, + /// This stores the path to the runtime file being processed + /// User must have read/write permissions for potentially destructive editing + /// All insertions are ultimately written here + output: PathBuf, + // /// This stores the path to the runtime manifest file runtime/Cargo.toml + // manifest: PathBuf, + /// State + state: State, + /// Cursor for tracking where we are in the output + cursor: usize, +} +impl Drop for PalletEngine { + fn drop(&mut self) { + let output_dir = self.output.parent().unwrap(); + let _ = fs::remove_dir_all(output_dir); + } +} + +/// PalletDetails is data generated after parsing of a given `input` runtime file +/// This will make observations as to which pallets are there, if there are instances of the pallets +/// among details such as the span of the construct_runtime! macro, the type of runtime declaration etc. +struct PalletDetails { + /// Number of pallets in the runtime, changes based on pallets added to output + pallets: Vec, + /// construct_runtime! macro span start location. Any pallet that's being added + /// should search, uptil this point to make sure existing pallets do not conflict + /// Note: Read-only from self.input + crt_start: usize, + /// construct_runtime! macro span end location. + /// For changes that happen after construct_runtime! is edited + /// Note: Read-only from self.input + crt_end: usize, + /// Total number of lines in input. Useful for inserting lines. + file_end: usize, + /// Type of runtime declaration being processed + declaration: RuntimeDeclaration, +} +struct ImportDetails { + /// On reading the source file, we obtain `last_import` which is the ending line of final import + /// statement, and also from where additional pallet imports must be added + last_import: usize, +} +// Public API +impl PalletEngine { + /// Query the output path + pub fn output(&self) -> &Path { + &self.output + } + /// Consume self merging `output` and `input` + /// Call this to finalize edits + pub fn merge(mut self) -> anyhow::Result<()> { + // TODO: since we are not interacting with any post-CRT items, this is ok + &mut self.append_lines_from(self.details.crt_end + 1, self.details.file_end)?; + fs::copy(&self.output, &self.input)?; + fs::remove_file(&self.output); + Ok(()) + } + /// Create a new PalletEngine + pub fn new(input: &PathBuf) -> anyhow::Result { + let tmp_dir = PathBuf::from(format!("/tmp/pallet_engine_{}", uuid::Uuid::new_v4())); + fs::create_dir(&tmp_dir) + .context("Failed to create temporary directory for PalletEngine")?; + let output: PathBuf = tmp_dir.join("out_lib.rs"); + // Open the file specified in `output`. If non-empty, delete its contents. + if output.exists() && output.is_file() { + std::fs::remove_file(output.as_path())?; + } + File::create(&output) + .context(format!("Failed to create PalletEngine with output: {}", output.display()))?; + // Build Pallet Details + let __buf = BufReader::new(File::open(&input)?); + let file_end = __buf.lines().count(); + let rt = fs::read_to_string(&input)?; + let ast: syn::File = syn::parse_file(rt.as_ref())?; + let mut details = Option::::None; + let mut last_import = None; + let mut _macro_cross = false; + for item in ast.items.iter() { + match item { + Item::Use(_) => { + // Fetch last import + // Note, other use statements are present inside modules in a standard runtime + // Additional safety mechanism to make sure pallet-imports are always before construct_runtime! + if !_macro_cross { + last_import = Some(item.span().end().line); + } + }, + Item::Macro(ItemMacro { mac, .. }) => { + if let Some(mac_id) = mac.path.get_ident() { + if mac_id == "construct_runtime" { + _macro_cross = true; + let (crt_start, crt_end) = + (item.span().start().line, item.span().end().line); + let declaration = + mac.parse_body::().map_err(|e| { + anyhow!("Cannot parse construct_runtime from input").context(e) + })?; + let pallets = Self::build_pallet_details(&declaration)?; + details = Some(PalletDetails { + pallets, + crt_start, + crt_end, + file_end, + declaration, + }); + } + } + }, + _ => {}, + }; + } + let imports = + ImportDetails { last_import: last_import.expect("Imports are always present") }; + let Some(details) = details else { + bail!("No pallets/construct_runtime! found in input"); + }; + Ok(Self { + input: input.to_owned(), + imports, + output, + details, + state: State::Init, + cursor: 0, + }) + } + /// Helper for PalletEngine::new, Builds pallet details from the construct_runtime! macro + fn build_pallet_details( + declaration: &RuntimeDeclaration, + ) -> anyhow::Result> { + // Instance map to track the number of current instances for a pallet entry + let mut imap: HashMap = HashMap::new(); + let mut pe: HashMap = HashMap::new(); + let pallet_entries = match declaration { + RuntimeDeclaration::Implicit(i) => { + for pallet in i.pallets.iter() { + let entry: String = pallet.span.source_text().unwrap(); + let entry = entry.split(':').next().unwrap().to_string(); + let index = pallet.index; + if pallet.instance.is_some() { + // If using instance syntax i.e. pallet:: set instance to 1 + imap.entry(entry.clone()).and_modify(|e| *e += 1).or_insert(1); + }; + pe.entry(entry.clone()) + .and_modify(|e| { + let v = imap.get(&entry).unwrap_or(&0); + e.numbers.instance = *v; + }) + .or_insert(ReadPalletEntry { + entry: entry.to_string(), + numbers: Numbers { index, instance: 0 }, + }); + } + pe.into_iter().map(|e| e.1).collect() + }, + RuntimeDeclaration::Explicit(e) | RuntimeDeclaration::ExplicitExpanded(e) => { + for pallet in e.pallets.iter() { + let entry: String = pallet.span.source_text().unwrap(); + let entry = entry.split(':').next().unwrap().to_string(); + let index = Some(pallet.index); + if pallet.instance.is_some() { + // If using instance syntax i.e. pallet:: set instance to 1 + imap.entry(entry.clone()).and_modify(|e| *e += 1).or_insert(1); + }; + pe.entry(entry.clone()) + .and_modify(|e| { + let v = imap.get(&entry).unwrap_or(&0); + e.numbers.instance = *v; + }) + .or_insert(ReadPalletEntry { + entry: entry.to_string(), + numbers: Numbers { index, instance: 0 }, + }); + } + pe.into_iter().map(|e| e.1).collect() + }, + }; + Ok(pallet_entries) + } +} + +// Private methods for internal use. +// Note: Some methods update `self.cursor` and they take exclusive refs (&mut self) +// For functions which don't do that (i.e. take ref by &self), the caller must decide how to increment cursor +// This is relevant when calling methods like `append_tokens` or `append_str` which append single and multi-line strs +// without analyzing it for newlines. +#[allow(unused)] +impl PalletEngine { + /// Prepare `output` by first, adding pre-CRT items such as imports and modules + /// Then adding the construct_runtime! macro + /// And finally adding the post-CRT items such as benchmarks, impl_runtime_apis! and so forth + fn prepare_output(&mut self) -> anyhow::Result<()> { + if self.state != State::Init { + bail!("PalletEngine is not in Init stage, cursor: {}", self.cursor); + } else { + // First pre-CRT items - imports + self.append_lines_from(0, self.imports.last_import)?; + + self.state = State::Import; + Ok(()) + } + } + /// Prepare `output` for taking new pallet configurations + fn prepare_config(&mut self) -> anyhow::Result<()> { + if self.state != State::Import { + bail!("PalletEngine is not in Import stage, cursor: {}", self.cursor); + } else { + self.append_lines_from(self.imports.last_import + 1, self.details.crt_start - 1); + self.state = State::Config; + Ok(()) + } + } + /// Prepare `output` for CRT items + fn prepare_crt(&mut self) -> anyhow::Result<()> { + if self.state != State::Config { + bail!("PalletEngine is not in Config stage, cursor: {}", self.cursor); + } else if self.state == State::ConstructRuntime { + warn!("PalletEngine is already in ConstructRuntime stage, cursor: {}", self.cursor); + return Ok(()); + } + self.add_new_line(1)?; + self.append_lines_from(self.details.crt_start, self.details.crt_end); + self.state = State::ConstructRuntime; + Ok(()) + } + /// Add `n` line-breaks to output + fn add_new_line(&mut self, n: usize) -> anyhow::Result<()> { + let mut file = OpenOptions::new().append(true).open(&self.output)?; + let newlines: String = std::iter::repeat('\n').take(n).collect(); + let rs = file.write_all(format!("{newlines}").as_bytes())?; + self.cursor += n; + Ok(rs) + } + /// Append raw tokens to `output` file, cursor should be handled by caller + fn append_tokens(&self, tokens: TokenStream) -> anyhow::Result<()> { + let content = prettyplease::unparse(&syn::parse_file(&tokens.to_string())?); + let mut file = OpenOptions::new().append(true).open(&self.output)?; + file.write_all(content.as_bytes())?; + Ok(()) + } + /// Append string as is to `output` file, cursor should be handled by caller + fn append_str(&self, content: String) -> anyhow::Result<()> { + let mut file = OpenOptions::new().append(true).open(&self.output)?; + file.write_all(content.as_bytes())?; + Ok(()) + } + /// Insert import statement + /// As of now, it's imperative to call this function for pre-CRT item insertions + /// The correctness of calling this function depends on the `state` of PalletEngine + /// and the step_runner makes sure that it will only call this function when State is either + /// `State::Init` or `State::Import` + fn insert_import(&mut self, import_stmt: (TokenStream, usize)) -> anyhow::Result<()> { + self.append_tokens(import_stmt.0); + self.cursor += import_stmt.1; + Ok(()) + } + /// Insert configuartion for a pallet - only for pallet-template atm + fn insert_config(&mut self, config: (TokenStream, usize)) -> anyhow::Result<()> { + self.append_tokens(config.0); + self.cursor += config.1; + Ok(()) + } + /// Append lines [start..end] from `input` source to `output`. + /// Typically used to scaffold the `output` before and after making changes + /// Increment cursor by exactly the number of lines inserted + fn append_lines_from(&mut self, start: usize, end: usize) -> anyhow::Result<()> { + let file = File::open(self.input.as_path())?; + let reader = BufReader::new(file); + // Assuming a worst case of 150 chars per line which is almost never the case in a typical substrate runtime file + // In the kitchensink node the maximum line length is 138 chars wide + let mut snip = String::with_capacity(150 * (end - start)); + let mut current_line = 0; + + for line in reader.lines() { + current_line += 1; + + if current_line < start { + // Skip lines until start + continue; + } else if current_line > end { + // Stop reading after end + break; + } + + snip.push_str(&line?); + snip.push('\n'); + } + let mut file = OpenOptions::new() + .append(true) + .open(&self.output) + .context("fn append_lines_from - cannot open output")?; + file.write_all(snip.as_bytes())?; + self.cursor += end - start; + Ok(()) + } + /// Same as `append_lines_from` but doesn't update cursor + fn append_lines_from_no_update(&mut self, start: usize, end: usize) -> anyhow::Result<()> { + self.append_lines_from(start, end)?; + self.cursor -= (end - start); + Ok(()) + } + /// Insert string at line. Errors if line number doesn't exist in `output` + /// cursor should be handled by caller + fn insert_at(&self, line: usize, str: &str) -> anyhow::Result<()> { + let reader = BufReader::new(File::open(&self.output)?); + let mut temp_file = tempfile::NamedTempFile::new()?; + let temp_path = &temp_file.path().to_path_buf(); + let mut written = false; + for (idx, l) in reader.lines().enumerate() { + if idx == line { + writeln!(temp_file, "{str}")?; + written = true; + } + writeln!(temp_file, "{}", l?)?; + } + fs::rename(temp_path, &self.output)?; + if !written { + bail!("PalletEngine output doesn't have line {line} to insert at"); + } + Ok(()) + } + /// Insert raw string at construct_runtime! Fails if there's no construct_runtime! in `output` + /// By default inserts at the end of the macro. + /// Note: cursor is only incremented by one, so `str` is expected to be a single line + fn insert_str_runtime(&mut self, str: &str) -> anyhow::Result<()> { + let runtime_contents = fs::read_to_string(&self.output)?; + let ast: syn::File = syn::parse_file(runtime_contents.as_ref())?; + let mut runtime_found = false; + for item in ast.items.iter() { + match item { + syn::Item::Macro(syn::ItemMacro { mac, .. }) => { + if let Some(mac_id) = mac.path.get_ident() { + if mac_id == "construct_runtime" { + runtime_found = true; + let r: RuntimeDeclaration = mac.parse_body().map_err(|err| { + anyhow!("PalletEngine output is in not parseable").context(err) + })?; + match r { + RuntimeDeclaration::Implicit(i) => { + let ultimate = i + .pallets + .last() + // This may be handled in the case that there's no pallets in CRT to begin with + // And subsequent pallets will be added + .expect("Fatal: No pallets defined in construct_runtime!") + .clone(); + let end = ultimate.span.end().line; + self.insert_at(end, str)?; + }, + RuntimeDeclaration::Explicit(e) + | RuntimeDeclaration::ExplicitExpanded(e) => { + let end = e + .pallets + .last() + .expect("Fatal: No pallets defined in construct_runtime!") + .span + .end() + .line; + self.insert_at(end, str)?; + }, + } + } + } + }, + _ => {}, + } + } + if !runtime_found { + // Should never happen + panic!("Construct Runtime not found in PalletEngine output. Cannot add pallet"); + } + // Typically insert_str_runtime would be used to insert a single pallet entry so this is okay + self.cursor += 1; + Ok(()) + } + /// Add a new pallet to RuntimeDeclaration and return it. + /// Used to pass a typed AddPallet to modify the RuntimeDeclaration + /// Overwrites existing CRT in output, this means that `self.cursor` has to backtracked to crt_start + /// and updated after the pallet entry has been inserted + fn add_pallet_runtime(&mut self, new_pallet: AddPalletEntry) -> anyhow::Result<()> { + let mut entry = String::new(); + let AddPalletEntry { name, path, index } = new_pallet; + if let Some(idx) = index { + entry = format!("\t\t{}: {} = {},", name, path, idx); + } else { + entry = format!("\t\t{}: {},", name, path); + } + self.insert_str_runtime(&entry)?; + Ok(()) + } +} diff --git a/src/engines/pallet_engine/pallet_entry.rs b/src/engines/pallet_engine/pallet_entry.rs new file mode 100644 index 000000000..0fa381e45 --- /dev/null +++ b/src/engines/pallet_engine/pallet_entry.rs @@ -0,0 +1,42 @@ +#![allow(unused)] +use syn::Ident; + +/// Format containing necessary information for appending pallets +#[derive(Debug)] +pub(super) struct AddPalletEntry { + pub(super) index: Option, + pub(super) path: Ident, + pub(super) name: Ident, +} +impl AddPalletEntry { + pub(super) fn new(index: Option, path: &str, name: &str) -> Self { + let path = Ident::new(path, proc_macro2::Span::call_site()); + let name = Ident::new(name, proc_macro2::Span::call_site()); + Self { index, path, name } + } +} + +impl From for AddPalletEntry { + fn from(value: ReadPalletEntry) -> Self { + todo!("") + } +} + +/// All information that's needed to represent a pallet in a construct_runtime! invocation +/// The processing must be based on the context i.e. the type of RuntimeDeclaration in the runtime +pub(super) struct ReadPalletEntry { + /// Pallet identifier. "System" in `System: frame_system = 1` + pub(super) entry: String, + /// Stores a tuple of information (index, instance). For single instances, instance = 0 + pub(super) numbers: Numbers, +} +#[derive(Default, Debug)] +pub(super) struct Numbers { + /// Stores the first index as parsed from input file + pub(super) index: Option, + /// Counts the number of instances in runtime file + /// 0 means only 1 unique instance was found + /// 1 means the pallet is using instance syntax pallet:: + /// >1 means multiple pallet instances were found + pub(super) instance: u8, +} diff --git a/src/engines/pallet_engine/parser.rs b/src/engines/pallet_engine/parser.rs new file mode 100644 index 000000000..26c139be5 --- /dev/null +++ b/src/engines/pallet_engine/parser.rs @@ -0,0 +1,913 @@ +#![allow(unused)] +// This file is part of Substrate modified to fit pallet manipulation needs for pop-cli + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use frame_support_procedural_tools::syn_ext as ext; +use proc_macro2::{Delimiter, Group, Punct, Spacing, Span, TokenStream}; +use quote::{quote, ToTokens, TokenStreamExt}; +use std::{ + collections::{HashMap, HashSet}, + str::FromStr, +}; +use syn::{ + ext::IdentExt, + parse::{Parse, ParseStream}, + parse_quote, + punctuated::Punctuated, + spanned::Spanned, + token, Attribute, Error, Ident, Path, Result, Token, +}; +/// Span for delimiting tokens. +macro_rules! bs_delim_span { + ($d:ident) => { + proc_macro2::Group::new(proc_macro2::Delimiter::$d, proc_macro2::TokenStream::new()) + .delim_span() + }; + ($d:ident, $group:tt) => { + proc_macro2::Group::new(proc_macro2::Delimiter::$d, $group).delim_span() + }; +} +/// Tokens that delimit a group +macro_rules! delim_token { + (Parenthesis, $group:tt) => { + syn::token::Paren { span: bs_delim_span!(Parenthesis, $group) } + }; + ($d:ident) => { + syn::token::$d { span: bs_delim_span!($d) } + }; + ($d:ident, $group:tt) => { + syn::token::$d { span: bs_delim_span!($d, $group) } + }; +} +mod keyword { + syn::custom_keyword!(Block); + syn::custom_keyword!(NodeBlock); + syn::custom_keyword!(UncheckedExtrinsic); + syn::custom_keyword!(Pallet); + syn::custom_keyword!(Call); + syn::custom_keyword!(Storage); + syn::custom_keyword!(Event); + syn::custom_keyword!(Error); + syn::custom_keyword!(Config); + syn::custom_keyword!(Origin); + syn::custom_keyword!(Inherent); + syn::custom_keyword!(ValidateUnsigned); + syn::custom_keyword!(FreezeReason); + syn::custom_keyword!(HoldReason); + syn::custom_keyword!(LockId); + syn::custom_keyword!(SlashReason); + syn::custom_keyword!(exclude_parts); + syn::custom_keyword!(use_parts); + syn::custom_keyword!(expanded); +} + +/// Declaration of a runtime. +/// +/// Pallet declare their part either explicitly or implicitly (using no part declaration) +/// If all pallet have explicit parts then the runtime declaration is explicit, otherwise it is +/// implicit. +#[derive(Debug)] +pub enum RuntimeDeclaration { + Implicit(ImplicitRuntimeDeclaration), + Explicit(ExplicitRuntimeDeclaration), + ExplicitExpanded(ExplicitRuntimeDeclaration), +} + +impl ToTokens for RuntimeDeclaration { + fn to_tokens(&self, tokens: &mut TokenStream) { + let group = match self { + RuntimeDeclaration::Implicit(i) => i.to_token_stream(), + RuntimeDeclaration::Explicit(_) | RuntimeDeclaration::ExplicitExpanded(_) => { + unimplemented!() + }, + }; + let crt = syn::Macro { + path: parse_quote!(construct_runtime), + bang_token: Token![!](Span::call_site()), + tokens: group.clone(), + delimiter: syn::MacroDelimiter::Paren(delim_token!(Parenthesis, group)), + }; + tokens.extend(crt.into_token_stream()); + } +} + +/// Declaration of a runtime with some pallet with implicit declaration of parts. +#[derive(Debug)] +pub struct ImplicitRuntimeDeclaration { + pub name: Ident, + pub where_section: Option, + pub pallets: Vec, +} +impl ToTokens for ImplicitRuntimeDeclaration { + fn to_tokens(&self, tokens: &mut TokenStream) { + let (name, where_section) = (&self.name, &self.where_section); + tokens.extend(quote!( + pub struct #name #where_section)); + let mut pallets = TokenStream::new(); + for p in &self.pallets { + pallets.extend(p.to_token_stream()); + } + tokens.append(Group::new(Delimiter::Brace, pallets)); + } +} + +/// Declaration of a runtime with all pallet having explicit declaration of parts. +#[derive(Debug)] +pub struct ExplicitRuntimeDeclaration { + pub name: Ident, + pub where_section: Option, + pub pallets: Vec, + pub pallets_token: token::Brace, +} + +impl Parse for RuntimeDeclaration { + fn parse(input: ParseStream) -> Result { + input.parse::()?; + + // Support either `enum` or `struct`. + if input.peek(Token![struct]) { + input.parse::()?; + } else { + input.parse::()?; + } + + let name = input.parse::()?; + let where_section = if input.peek(token::Where) { Some(input.parse()?) } else { None }; + let pallets = + input.parse::>>()?; + let pallets_token = pallets.token; + + match convert_pallets(pallets.content.inner.into_iter().collect())? { + PalletsConversion::Implicit(pallets) => { + Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { + name, + where_section, + pallets, + })) + }, + PalletsConversion::Explicit(pallets) => { + Ok(RuntimeDeclaration::Explicit(ExplicitRuntimeDeclaration { + name, + where_section, + pallets, + pallets_token, + })) + }, + PalletsConversion::ExplicitExpanded(pallets) => { + Ok(RuntimeDeclaration::ExplicitExpanded(ExplicitRuntimeDeclaration { + name, + where_section, + pallets, + pallets_token, + })) + }, + } + } +} + +#[derive(Debug)] +pub struct WhereSection { + pub span: Span, + pub block: syn::TypePath, + pub node_block: syn::TypePath, + pub unchecked_extrinsic: syn::TypePath, +} + +impl ToTokens for WhereSection { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.extend(quote!()); + } +} + +impl Parse for WhereSection { + fn parse(input: ParseStream) -> Result { + input.parse::()?; + + let mut definitions = Vec::new(); + while !input.peek(token::Brace) { + let definition: WhereDefinition = input.parse()?; + definitions.push(definition); + if !input.peek(Token![,]) { + if !input.peek(token::Brace) { + return Err(input.error("Expected `,` or `{`")); + } + break; + } + input.parse::()?; + } + let block = remove_kind(input, WhereKind::Block, &mut definitions)?.value; + let node_block = remove_kind(input, WhereKind::NodeBlock, &mut definitions)?.value; + let unchecked_extrinsic = + remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; + if let Some(WhereDefinition { ref kind_span, ref kind, .. }) = definitions.first() { + let msg = format!( + "`{:?}` was declared above. Please use exactly one declaration for `{:?}`.", + kind, kind + ); + return Err(Error::new(*kind_span, msg)); + } + Ok(Self { span: input.span(), block, node_block, unchecked_extrinsic }) + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] +pub enum WhereKind { + Block, + NodeBlock, + UncheckedExtrinsic, +} + +#[derive(Debug)] +pub struct WhereDefinition { + pub kind_span: Span, + pub kind: WhereKind, + pub value: syn::TypePath, +} + +impl Parse for WhereDefinition { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + let (kind_span, kind) = if lookahead.peek(keyword::Block) { + (input.parse::()?.span(), WhereKind::Block) + } else if lookahead.peek(keyword::NodeBlock) { + (input.parse::()?.span(), WhereKind::NodeBlock) + } else if lookahead.peek(keyword::UncheckedExtrinsic) { + (input.parse::()?.span(), WhereKind::UncheckedExtrinsic) + } else { + return Err(lookahead.error()); + }; + + Ok(Self { + kind_span, + kind, + value: { + let _: Token![=] = input.parse()?; + input.parse()? + }, + }) + } +} + +/// The declaration of a pallet. +#[derive(Debug, Clone)] +pub struct PalletDeclaration { + /// Span for current pallet + pub span: Span, + /// Is this pallet fully expanded? + pub is_expanded: bool, + /// The name of the pallet, e.g.`System` in `System: frame_system`. + pub name: Ident, + /// Optional attributes tagged right above a pallet declaration. + pub attrs: Vec, + /// Optional fixed index, e.g. `MyPallet ... = 3,`. + pub index: Option, + /// The path of the pallet, e.g. `frame_system` in `System: frame_system`. + pub path: PalletPath, + /// The instance of the pallet, e.g. `Instance1` in `Council: pallet_collective::`. + pub instance: Option, + /// The declared pallet parts, + /// e.g. `Some([Pallet, Call])` for `System: system::{Pallet, Call}` + /// or `None` for `System: system`. + pub pallet_parts: Option>, + /// The specified parts, either use_parts or exclude_parts. + pub specified_parts: SpecifiedParts, +} + +impl ToTokens for PalletDeclaration { + fn to_tokens(&self, tokens: &mut TokenStream) { + let PalletDeclaration { name, path, .. } = self; + tokens.extend(quote!(#name )); + if let Some(instance) = &self.instance { + tokens.extend(quote!(: #path::<#instance>)); + } else { + tokens.extend(quote!(: #path)) + } + if let Some(idx) = self.index { + let idx = format!(" = {},", idx); + // This means no help from rustfmt + tokens.extend(TokenStream::from_str(&idx)); + // If we want rustfmt we would have to handroll our own solution or forgo indices + // (which is bad and probably not what the developer wants which is to delete code) + // tokens.extend(quote!(,)); + } else { + tokens.append(Punct::new(',', Spacing::Alone)); + } + } +} + +/// The possible declaration of pallet parts to use. +#[derive(Debug, Clone)] +pub enum SpecifiedParts { + /// Use all the pallet parts except those specified. + Exclude(Vec), + /// Use only the specified pallet parts. + Use(Vec), + /// Use the all the pallet parts. + All, +} + +impl Parse for PalletDeclaration { + fn parse(input: ParseStream) -> Result { + let attrs = input.call(Attribute::parse_outer)?; + let span = input.span(); + let name = input.parse()?; + let _: Token![:] = input.parse()?; + let path = input.parse()?; + + // Parse for instance. + let instance = if input.peek(Token![::]) && input.peek3(Token![<]) { + let _: Token![::] = input.parse()?; + let _: Token![<] = input.parse()?; + let res = Some(input.parse()?); + let _: Token![>] = input.parse()?; + res + } else if !(input.peek(Token![::]) && input.peek3(token::Brace)) + && !input.peek(keyword::expanded) + && !input.peek(keyword::exclude_parts) + && !input.peek(keyword::use_parts) + && !input.peek(Token![=]) + && !input.peek(Token![,]) + && !input.is_empty() + { + return Err(input.error( + "Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,`", + )); + } else { + None + }; + + // Check if the pallet is fully expanded. + let (is_expanded, extra_parts) = if input.peek(keyword::expanded) { + let _: keyword::expanded = input.parse()?; + let _: Token![::] = input.parse()?; + (true, parse_pallet_parts(input)?) + } else { + (false, vec![]) + }; + + // Parse for explicit parts + let pallet_parts = if input.peek(Token![::]) && input.peek3(token::Brace) { + let _: Token![::] = input.parse()?; + let mut parts = parse_pallet_parts(input)?; + parts.extend(extra_parts.into_iter()); + Some(parts) + } else if !input.peek(keyword::exclude_parts) + && !input.peek(keyword::use_parts) + && !input.peek(Token![=]) + && !input.peek(Token![,]) + && !input.is_empty() + { + return Err(input.error( + "Unexpected tokens, expected one of `::{`, `exclude_parts`, `use_parts`, `=`, `,`", + )); + } else { + is_expanded.then_some(extra_parts) + }; + + // Parse for specified parts + let specified_parts = if input.peek(keyword::exclude_parts) { + let _: keyword::exclude_parts = input.parse()?; + SpecifiedParts::Exclude(parse_pallet_parts_no_generic(input)?) + } else if input.peek(keyword::use_parts) { + let _: keyword::use_parts = input.parse()?; + SpecifiedParts::Use(parse_pallet_parts_no_generic(input)?) + } else if !input.peek(Token![=]) && !input.peek(Token![,]) && !input.is_empty() { + return Err(input.error("Unexpected tokens, expected one of `exclude_parts`, `=`, `,`")); + } else { + SpecifiedParts::All + }; + + // Parse for pallet index + let index = if input.peek(Token![=]) { + input.parse::()?; + let index = input.parse::()?; + let index = index.base10_parse::()?; + Some(index) + } else if !input.peek(Token![,]) && !input.is_empty() { + return Err(input.error("Unexpected tokens, expected one of `=`, `,`")); + } else { + None + }; + + Ok(Self { + span, + is_expanded, + attrs, + name, + path, + instance, + pallet_parts, + specified_parts, + index, + }) + } +} + +/// A struct representing a path to a pallet. `PalletPath` is almost identical to the standard +/// Rust path with a few restrictions: +/// - No leading colons allowed +/// - Path segments can only consist of identifers separated by colons +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct PalletPath { + pub inner: Path, +} + +impl PalletPath { + pub fn module_name(&self) -> String { + self.inner.segments.iter().fold(String::new(), |mut acc, segment| { + if !acc.is_empty() { + acc.push_str("::"); + } + acc.push_str(&segment.ident.to_string()); + acc + }) + } +} + +impl Parse for PalletPath { + fn parse(input: ParseStream) -> Result { + let mut res = + PalletPath { inner: Path { leading_colon: None, segments: Punctuated::new() } }; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![crate]) + || lookahead.peek(Token![self]) + || lookahead.peek(Token![super]) + || lookahead.peek(Ident) + { + let ident = input.call(Ident::parse_any)?; + res.inner.segments.push(ident.into()); + } else { + return Err(lookahead.error()); + } + + while input.peek(Token![::]) && input.peek3(Ident) { + input.parse::()?; + let ident = input.parse::()?; + res.inner.segments.push(ident.into()); + } + Ok(res) + } +} + +impl quote::ToTokens for PalletPath { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.inner.to_tokens(tokens); + } +} + +/// Parse [`PalletPart`]'s from a braces enclosed list that is split by commas, e.g. +/// +/// `{ Call, Event }` +fn parse_pallet_parts(input: ParseStream) -> Result> { + let pallet_parts: ext::Braces> = input.parse()?; + + let mut resolved = HashSet::new(); + for part in pallet_parts.content.inner.iter() { + if !resolved.insert(part.name()) { + let msg = format!( + "`{}` was already declared before. Please remove the duplicate declaration", + part.name(), + ); + return Err(Error::new(part.keyword.span(), msg)); + } + } + + Ok(pallet_parts.content.inner.into_iter().collect()) +} + +#[derive(Debug, Clone)] +pub enum PalletPartKeyword { + Pallet(keyword::Pallet), + Call(keyword::Call), + Storage(keyword::Storage), + Event(keyword::Event), + Error(keyword::Error), + Config(keyword::Config), + Origin(keyword::Origin), + Inherent(keyword::Inherent), + ValidateUnsigned(keyword::ValidateUnsigned), + FreezeReason(keyword::FreezeReason), + HoldReason(keyword::HoldReason), + LockId(keyword::LockId), + SlashReason(keyword::SlashReason), +} + +impl Parse for PalletPartKeyword { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + + if lookahead.peek(keyword::Pallet) { + Ok(Self::Pallet(input.parse()?)) + } else if lookahead.peek(keyword::Call) { + Ok(Self::Call(input.parse()?)) + } else if lookahead.peek(keyword::Storage) { + Ok(Self::Storage(input.parse()?)) + } else if lookahead.peek(keyword::Event) { + Ok(Self::Event(input.parse()?)) + } else if lookahead.peek(keyword::Error) { + Ok(Self::Error(input.parse()?)) + } else if lookahead.peek(keyword::Config) { + Ok(Self::Config(input.parse()?)) + } else if lookahead.peek(keyword::Origin) { + Ok(Self::Origin(input.parse()?)) + } else if lookahead.peek(keyword::Inherent) { + Ok(Self::Inherent(input.parse()?)) + } else if lookahead.peek(keyword::ValidateUnsigned) { + Ok(Self::ValidateUnsigned(input.parse()?)) + } else if lookahead.peek(keyword::FreezeReason) { + Ok(Self::FreezeReason(input.parse()?)) + } else if lookahead.peek(keyword::HoldReason) { + Ok(Self::HoldReason(input.parse()?)) + } else if lookahead.peek(keyword::LockId) { + Ok(Self::LockId(input.parse()?)) + } else if lookahead.peek(keyword::SlashReason) { + Ok(Self::SlashReason(input.parse()?)) + } else { + Err(lookahead.error()) + } + } +} + +impl PalletPartKeyword { + /// Returns the name of `Self`. + fn name(&self) -> &'static str { + match self { + Self::Pallet(_) => "Pallet", + Self::Call(_) => "Call", + Self::Storage(_) => "Storage", + Self::Event(_) => "Event", + Self::Error(_) => "Error", + Self::Config(_) => "Config", + Self::Origin(_) => "Origin", + Self::Inherent(_) => "Inherent", + Self::ValidateUnsigned(_) => "ValidateUnsigned", + Self::FreezeReason(_) => "FreezeReason", + Self::HoldReason(_) => "HoldReason", + Self::LockId(_) => "LockId", + Self::SlashReason(_) => "SlashReason", + } + } + + /// Returns `true` if this pallet part is allowed to have generic arguments. + fn allows_generic(&self) -> bool { + Self::all_generic_arg().iter().any(|n| *n == self.name()) + } + + /// Returns the names of all pallet parts that allow to have a generic argument. + fn all_generic_arg() -> &'static [&'static str] { + &["Event", "Error", "Origin", "Config"] + } +} + +impl ToTokens for PalletPartKeyword { + fn to_tokens(&self, tokens: &mut TokenStream) { + match self { + Self::Pallet(inner) => inner.to_tokens(tokens), + Self::Call(inner) => inner.to_tokens(tokens), + Self::Storage(inner) => inner.to_tokens(tokens), + Self::Event(inner) => inner.to_tokens(tokens), + Self::Error(inner) => inner.to_tokens(tokens), + Self::Config(inner) => inner.to_tokens(tokens), + Self::Origin(inner) => inner.to_tokens(tokens), + Self::Inherent(inner) => inner.to_tokens(tokens), + Self::ValidateUnsigned(inner) => inner.to_tokens(tokens), + Self::FreezeReason(inner) => inner.to_tokens(tokens), + Self::HoldReason(inner) => inner.to_tokens(tokens), + Self::LockId(inner) => inner.to_tokens(tokens), + Self::SlashReason(inner) => inner.to_tokens(tokens), + } + } +} + +#[derive(Debug, Clone)] +pub struct PalletPart { + pub keyword: PalletPartKeyword, + pub generics: syn::Generics, +} + +impl Parse for PalletPart { + fn parse(input: ParseStream) -> Result { + let keyword: PalletPartKeyword = input.parse()?; + + let generics: syn::Generics = input.parse()?; + if !generics.params.is_empty() && !keyword.allows_generic() { + let valid_generics = PalletPart::format_names(PalletPartKeyword::all_generic_arg()); + let msg = format!( + "`{}` is not allowed to have generics. \ + Only the following pallets are allowed to have generics: {}.", + keyword.name(), + valid_generics, + ); + return Err(syn::Error::new(keyword.span(), msg)); + } + + Ok(Self { keyword, generics }) + } +} + +impl PalletPart { + pub fn format_names(names: &[&'static str]) -> String { + let res: Vec<_> = names.iter().map(|s| format!("`{}`", s)).collect(); + res.join(", ") + } + + /// The name of this pallet part. + pub fn name(&self) -> &'static str { + self.keyword.name() + } +} + +fn remove_kind( + input: ParseStream, + kind: WhereKind, + definitions: &mut Vec, +) -> Result { + if let Some(pos) = definitions.iter().position(|d| d.kind == kind) { + Ok(definitions.remove(pos)) + } else { + let msg = format!( + "Missing associated type for `{:?}`. Add `{:?}` = ... to where section.", + kind, kind + ); + Err(input.error(msg)) + } +} + +/// The declaration of a part without its generics +#[derive(Debug, Clone)] +pub struct PalletPartNoGeneric { + keyword: PalletPartKeyword, +} + +impl Parse for PalletPartNoGeneric { + fn parse(input: ParseStream) -> Result { + Ok(Self { keyword: input.parse()? }) + } +} + +/// Parse [`PalletPartNoGeneric`]'s from a braces enclosed list that is split by commas, e.g. +/// +/// `{ Call, Event }` +fn parse_pallet_parts_no_generic(input: ParseStream) -> Result> { + let pallet_parts: ext::Braces> = + input.parse()?; + + let mut resolved = HashSet::new(); + for part in pallet_parts.content.inner.iter() { + if !resolved.insert(part.keyword.name()) { + let msg = format!( + "`{}` was already declared before. Please remove the duplicate declaration", + part.keyword.name(), + ); + return Err(Error::new(part.keyword.span(), msg)); + } + } + + Ok(pallet_parts.content.inner.into_iter().collect()) +} + +/// The final definition of a pallet with the resulting fixed index and explicit parts. +#[derive(Debug, Clone)] +pub struct Pallet { + /// Span for current pallet + pub span: Span, + /// Is this pallet fully expanded? + pub is_expanded: bool, + /// The name of the pallet, e.g.`System` in `System: frame_system`. + pub name: Ident, + /// Either automatically infered, or defined (e.g. `MyPallet ... = 3,`). + pub index: u8, + /// The path of the pallet, e.g. `frame_system` in `System: frame_system`. + pub path: PalletPath, + /// The instance of the pallet, e.g. `Instance1` in `Council: pallet_collective::`. + pub instance: Option, + /// The pallet parts to use for the pallet. + pub pallet_parts: Vec, + /// Expressions specified inside of a #[cfg] attribute. + pub cfg_pattern: Vec, +} + +impl Pallet { + /// Get resolved pallet parts + pub fn pallet_parts(&self) -> &[PalletPart] { + &self.pallet_parts + } + + /// Find matching parts + pub fn find_part(&self, name: &str) -> Option<&PalletPart> { + self.pallet_parts.iter().find(|part| part.name() == name) + } + + /// Return whether pallet contains part + pub fn exists_part(&self, name: &str) -> bool { + self.find_part(name).is_some() + } +} + +/// Result of a conversion of a declaration of pallets. +/// +/// # State Transitions +/// +/// ```ignore +/// +----------+ +----------+ +------------------+ +/// | Implicit | -> | Explicit | -> | ExplicitExpanded | +/// +----------+ +----------+ +------------------+ +/// ``` +enum PalletsConversion { + /// Pallets implicitely declare parts. + /// + /// `System: frame_system`. + Implicit(Vec), + /// Pallets explicitly declare parts. + /// + /// `System: frame_system::{Pallet, Call}` + /// + /// However, for backwards compatibility with Polkadot/Kusama + /// we must propagate some other parts to the pallet by default. + Explicit(Vec), + /// Pallets explicitly declare parts that are fully expanded. + /// + /// This is the end state that contains extra parts included by + /// default by Subtrate. + /// + /// `System: frame_system expanded::{Error} ::{Pallet, Call}` + /// + /// For this example, the `Pallet`, `Call` and `Error` parts are collected. + ExplicitExpanded(Vec), +} + +/// Convert from the parsed pallet declaration to their final information. +/// +/// Check if all pallet have explicit declaration of their parts, if so then assign index to each +/// pallet using same rules as rust for fieldless enum. I.e. implicit are assigned number +/// incrementedly from last explicit or 0. +fn convert_pallets(pallets: Vec) -> syn::Result { + if pallets.iter().any(|pallet| pallet.pallet_parts.is_none()) { + return Ok(PalletsConversion::Implicit(pallets)); + } + + let mut indices = HashMap::new(); + let mut last_index: Option = None; + let mut names = HashMap::new(); + let mut is_expanded = true; + + let pallets = pallets + .into_iter() + .map(|pallet| { + let final_index = match pallet.index { + Some(i) => i, + None => last_index.map_or(Some(0), |i| i.checked_add(1)).ok_or_else(|| { + let msg = "Pallet index doesn't fit into u8, index is 256"; + syn::Error::new(pallet.name.span(), msg) + })?, + }; + + last_index = Some(final_index); + + if let Some(used_pallet) = indices.insert(final_index, pallet.name.clone()) { + let msg = format!( + "Pallet indices are conflicting: Both pallets {} and {} are at index {}", + used_pallet, pallet.name, final_index, + ); + let mut err = syn::Error::new(used_pallet.span(), &msg); + err.combine(syn::Error::new(pallet.name.span(), msg)); + return Err(err); + } + + if let Some(used_pallet) = names.insert(pallet.name.clone(), pallet.name.span()) { + let msg = "Two pallets with the same name!"; + + let mut err = syn::Error::new(used_pallet, &msg); + err.combine(syn::Error::new(pallet.name.span(), &msg)); + return Err(err); + } + + let mut pallet_parts = pallet.pallet_parts.expect("Checked above"); + + let available_parts = + pallet_parts.iter().map(|part| part.keyword.name()).collect::>(); + + // Check parts are correctly specified + match &pallet.specified_parts { + SpecifiedParts::Exclude(parts) | SpecifiedParts::Use(parts) => { + for part in parts { + if !available_parts.contains(part.keyword.name()) { + let msg = format!( + "Invalid pallet part specified, the pallet `{}` doesn't have the \ + `{}` part. Available parts are: {}.", + pallet.name, + part.keyword.name(), + pallet_parts.iter().fold(String::new(), |fold, part| { + if fold.is_empty() { + format!("`{}`", part.keyword.name()) + } else { + format!("{}, `{}`", fold, part.keyword.name()) + } + }) + ); + return Err(syn::Error::new(part.keyword.span(), msg)); + } + } + }, + SpecifiedParts::All => (), + } + + // Set only specified parts. + match pallet.specified_parts { + SpecifiedParts::Exclude(excluded_parts) => pallet_parts.retain(|part| { + !excluded_parts + .iter() + .any(|excluded_part| excluded_part.keyword.name() == part.keyword.name()) + }), + SpecifiedParts::Use(used_parts) => pallet_parts.retain(|part| { + used_parts.iter().any(|use_part| use_part.keyword.name() == part.keyword.name()) + }), + SpecifiedParts::All => (), + } + + let cfg_pattern = pallet + .attrs + .iter() + .map(|attr| { + if attr.path().segments.first().map_or(false, |s| s.ident != "cfg") { + let msg = "Unsupported attribute, only #[cfg] is supported on pallet \ + declarations in `construct_runtime`"; + return Err(syn::Error::new(attr.span(), msg)); + } + + attr.parse_args_with(|input: syn::parse::ParseStream| { + // Required, otherwise the parse stream doesn't advance and will result in + // an error. + let input = input.parse::()?; + cfg_expr::Expression::parse(&input.to_string()) + .map_err(|e| syn::Error::new(attr.span(), e.to_string())) + }) + }) + .collect::>>()?; + + is_expanded &= pallet.is_expanded; + + Ok(Pallet { + span: pallet.span, + is_expanded: pallet.is_expanded, + name: pallet.name, + index: final_index, + path: pallet.path, + instance: pallet.instance, + cfg_pattern, + pallet_parts, + }) + }) + .collect::>>()?; + + if is_expanded { + Ok(PalletsConversion::ExplicitExpanded(pallets)) + } else { + Ok(PalletsConversion::Explicit(pallets)) + } +} +pub fn check_pallet_number(input: proc_macro2::TokenStream, pallet_num: usize) -> Result<()> { + let max_pallet_num = { + if cfg!(feature = "tuples-96") { + 96 + } else if cfg!(feature = "tuples-128") { + 128 + } else { + 64 + } + }; + + if pallet_num > max_pallet_num { + let no_feature = max_pallet_num == 128; + return Err(syn::Error::new( + input.span(), + format!( + "{} To increase this limit, enable the tuples-{} feature of [frame_support]. {}", + "The number of pallets exceeds the maximum number of tuple elements.", + max_pallet_num + 32, + if no_feature { + "If the feature does not exist - it needs to be implemented." + } else { + "" + }, + ), + )); + } + + Ok(()) +} diff --git a/src/engines/pallet_engine/steps.rs b/src/engines/pallet_engine/steps.rs new file mode 100644 index 000000000..2560a5470 --- /dev/null +++ b/src/engines/pallet_engine/steps.rs @@ -0,0 +1,134 @@ +use super::{pallet_entry::AddPalletEntry, Dependency, Features, PalletEngine, State, TomlEditor}; +use crate::commands::add::AddPallet; +use anyhow::Result; +use log::{error, warn}; +use proc_macro2::TokenStream as TokenStream2; +use quote::quote; +use Steps::*; +/// Define the steps needed for a particular pallet insertion +/// As of now, there's no clean solution to find out the newlines (\n) in a TokenStream +/// so variants expecting Tokenstreams accompany a line count datum for PalletEngine cursor. +#[derive(Debug)] +pub(super) enum Steps { + /// Import statements for pallet + RuntimePalletImport((TokenStream2, usize)), + /// Every pallet must impl pallet::Config for Runtime + RuntimePalletConfiguration((TokenStream2, usize)), + /// The runtime/Cargo.toml needs an import for the pallet being inserted + /// This includes features [try-runtime, runtime-benchmarks, std], path information for `git` or local path + RuntimePalletDependency(Dependency), + /// ConstructRuntime! entry + ConstructRuntimeEntry(AddPalletEntry), + /// Include a `list_benchmarks!` entry + ListBenchmarks(String), + /// Does pallet require a genesis configuration? + ChainspecGenesisConfig(String), + /// ChainSpec imports if necessary + ChainspecGenesisImport((TokenStream2, usize)), + /// Node specific imports if the above two are required + NodePalletDependency(Dependency), + /// PalletEngine State transitions + SwitchTo(State), +} +/// Some rules to follow when constructing steps: +/// The pallet engine state expects to go as edits would, i.e. top to bottom lexically +/// So it makes sense for any given file, to first include an import, then items that refer to it +/// In case of a pallet, you'd always put `RuntimePalletImport`, `RuntimePalletConfiguration`, `ConstructRuntimeEntry` in that order. +pub(super) fn step_builder( + pallet: AddPallet, + &TomlEditor { ref workspace, .. }: &TomlEditor, +) -> Result> { + let mut steps: Vec = vec![]; + match pallet { + // Adding a pallet-parachain-template requires 5 distinct steps + AddPallet::Template => { + steps.push(RuntimePalletImport(( + quote!( + // Imports by pop-cli + pub use pallet_parachain_template; + ), + 2, + ))); + steps.push(SwitchTo(State::Config)); + steps.push(RuntimePalletConfiguration(( + quote!( + /// Configure the pallet template in pallets/template. + impl pallet_parachain_template::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + } + ), + 5, + ))); + steps.push(SwitchTo(State::ConstructRuntime)); + steps.push(ConstructRuntimeEntry(AddPalletEntry::new( + // Index - None, means Pallet Engine will automatically compute an index + None, + // Path + "pallet_parachain_template", + // Pallet name + "Template", + ))); + steps.push(RuntimePalletDependency(Dependency::local_template_runtime( + "pallet-parachain-template", + workspace, + ))); + }, + AddPallet::Frame(_) => unimplemented!("Frame pallets not yet implemented"), + }; + Ok(steps) +} +/// Execute steps on PalletEngine. +/// Each execution edits a file. +/// Sequence of steps matters so take care when ordering them +/// Works only for Template pallets at the moment.. See config and CRT inserts +pub(super) fn run_steps(mut pe: PalletEngine, mut te: TomlEditor, steps: Vec) -> Result<()> { + use super::State::*; + pe.prepare_output()?; + for step in steps.into_iter() { + match step { + RuntimePalletDependency(dep) => te.inject_runtime(dep)?, + RuntimePalletImport(stmt) => { + match pe.state { + Init => { + warn!("`prepare_output` was not called"); + pe.state = Import; + pe.insert_import(stmt); + }, + Import => pe.insert_import(stmt)?, + _ => { + // We don't support writing import statements in any other engine state + // Log non-fatal error and continue + error!( + "Cannot write import stmts in state {0:?}. Check step builder", + pe.state + ); + continue; + }, + }; + }, + SwitchTo(State::Config) => pe.prepare_config()?, + RuntimePalletConfiguration(config) => { + if pe.state != Config { + // Not really a fatal error, but may cause unexpected behaviour + warn!("Engine not in Config state, executing config insertion anyways"); + } + pe.insert_config(config)? + }, + SwitchTo(State::ConstructRuntime) => pe.prepare_crt()?, + ConstructRuntimeEntry(entry) => pe.add_pallet_runtime(entry)?, + RuntimePalletDependency(dep) => te.inject_runtime(dep)?, + // NodePalletDependency(dep) => te.inject_node(dep)?, + // ListBenchmarks(step) => pe.insert(step), + // ListBenchmarks(step) => pe.insert(step), + // ChainspecGenesisConfig(step) => pe.insert(step), + // ChainspecGenesisImport(step) => pe.insert(step), + step => { + unimplemented!("{step:?} unimplemented") + }, + }; // -- match -- + } // -- for -- + // Finalize runtime edits + pe.merge()?; + // TODO: Finalize toml and chainspec edits + Ok(()) +} diff --git a/src/engines/pallet_engine.rs b/src/engines/pallet_engine/template.rs similarity index 86% rename from src/engines/pallet_engine.rs rename to src/engines/pallet_engine/template.rs index f3d06ea47..4b84165a4 100644 --- a/src/engines/pallet_engine.rs +++ b/src/engines/pallet_engine/template.rs @@ -9,18 +9,25 @@ pub fn create_pallet_template( config: TemplatePalletConfig, ) -> anyhow::Result<()> { let target = resolve_pallet_path(path); + // TODO : config.name might use `-` or use snake_case. We want to use pallet_template for the pallet dirs + // and PalletTemplate for the runtime macro + // TODO: this can be further polished (edge cases: no pallet prefix.) let pallet_name = config.name.clone(); let pallet_path = target.join(pallet_name.clone()); sanitize(&pallet_path)?; generate_pallet_structure(&target, &pallet_name)?; - + // todo let pallet_module_name = ... ; render_pallet(pallet_name, config, &pallet_path)?; Ok(()) } +#[derive(clap::Args, Clone)] pub struct TemplatePalletConfig { - pub(crate) name: String, - pub(crate) authors: String, - pub(crate) description: String, + #[arg(short, long, default_value_t = String::from("template"))] + pub name: String, + #[arg(short, long, default_value_t = String::from("author"))] + pub authors: String, + #[arg(short, long, default_value_t = String::from("description"))] + pub description: String, } /// Generate a pallet folder and file structure fn generate_pallet_structure(target: &PathBuf, pallet_name: &str) -> anyhow::Result<()> { @@ -41,7 +48,7 @@ fn render_pallet( config: TemplatePalletConfig, pallet_path: &PathBuf, ) -> anyhow::Result<()> { - let pallet_name = pallet_name.replace('-', "_"); + // let pallet_name = pallet_name.replace('-', "_"); use crate::engines::generator::{ PalletBenchmarking, PalletCargoToml, PalletLib, PalletMock, PalletTests, }; diff --git a/src/helpers.rs b/src/helpers.rs index 63c4eb68a..a83d414d1 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,3 +1,4 @@ +#![allow(unused)] use anyhow::Result; use cliclack::{log, outro_cancel}; use git2::{IndexAddOption, Repository, ResetType}; @@ -120,6 +121,28 @@ pub(crate) fn resolve_pallet_path(path: Option) -> PathBuf { } } +pub(crate) fn is_git_repo_with_commits(repo_path: &Path) -> anyhow::Result { + match Repository::open(repo_path) { + Ok(repo) => { + let mut status_opts = git2::StatusOptions::new(); + status_opts.include_untracked(false); + let statuses = repo.statuses(Some(&mut status_opts))?; + + // Check if there are no changes to commit + Ok(if !statuses.iter().any(|s| s.status() != git2::Status::CURRENT) { + true + } else { + log::warning(format!("Repository has uncommitted changes.")); + false + }) + }, + Err(e) => { + log::error(format!("Failed to open repository: {}", e)); + Err(e.into()) + }, + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/main.rs b/src/main.rs index e1b36f38b..7d0205ca3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,6 +46,10 @@ enum Commands { #[clap(alias = "t")] #[cfg(feature = "contract")] Test(commands::test::TestArgs), + #[cfg(feature = "parachain")] + #[clap(alias = "a")] + /// Add a pallet to the runtime + Add(commands::add::AddArgs), } #[tokio::main] @@ -80,6 +84,8 @@ async fn main() -> Result<()> { Commands::Test(args) => match &args.command { commands::test::TestCommands::Contract(cmd) => cmd.execute(), }, + #[cfg(feature = "parachain")] + Commands::Add(args) => args.execute(), } } diff --git a/src/parachains/zombienet.rs b/src/parachains/zombienet.rs index 95274db14..c6d186751 100644 --- a/src/parachains/zombienet.rs +++ b/src/parachains/zombienet.rs @@ -15,7 +15,7 @@ use std::{ }; use symlink::{remove_symlink_file, symlink_file}; use tempfile::{Builder, NamedTempFile}; -use toml_edit::{value, Document, Formatted, Item, Table, Value}; +use toml_edit::{value, DocumentMut, Formatted, Item, Table, Value}; use url::Url; use zombienet_sdk::{Network, NetworkConfig, NetworkConfigExt}; use zombienet_support::fs::local::LocalFileSystem; @@ -26,7 +26,7 @@ pub struct Zombienet { /// The cache location, used for caching binaries. cache: PathBuf, /// The config to be used to launch a network. - network_config: (PathBuf, Document), + network_config: (PathBuf, DocumentMut), /// The binary required to launch the relay chain. relay_chain: Binary, /// The binaries required to launch parachains. @@ -43,7 +43,7 @@ impl Zombienet { ) -> Result { // Parse network config let network_config_path = PathBuf::from(network_config); - let config = std::fs::read_to_string(&network_config_path)?.parse::()?; + let config = std::fs::read_to_string(&network_config_path)?.parse::()?; // Determine binaries let relay_chain_binary = Self::relay_chain(relay_chain_version, &config, &cache).await?; let mut parachain_binaries = IndexMap::new(); @@ -257,7 +257,7 @@ impl Zombienet { async fn relay_chain( version: Option<&String>, - network_config: &Document, + network_config: &DocumentMut, cache: &PathBuf, ) -> Result { const BINARY: &str = "polkadot"; diff --git a/templates/pallet/Cargo.templ b/templates/pallet/Cargo.templ index f3e2c9074..5474d7dc9 100644 --- a/templates/pallet/Cargo.templ +++ b/templates/pallet/Cargo.templ @@ -2,7 +2,7 @@ name = "^^name^^" authors = ["^^authors^^"] description = "^^description^^" -version = "0.1.0" +version = "1.0.0" license = "Unlicense" edition = "2021" @@ -14,17 +14,17 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } # Substrate -frame-benchmarking = { version = "26.0.0", default-features = false, optional = true} -frame-support = { version = "26.0.0", default-features = false} -frame-system = { version = "26.0.0", default-features = false} +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } [dev-dependencies] serde = { version = "1.0.188" } # Substrate -sp-core = { version = "26.0.0", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } # sp-io = { version = "28.0.0", default-features = false} -sp-runtime = { version = "29.0.0", default-features = false} +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.1", default-features = false } [features] default = [ "std" ] diff --git a/tests/add_pallet.rs b/tests/add_pallet.rs new file mode 100644 index 000000000..7410bfd4e --- /dev/null +++ b/tests/add_pallet.rs @@ -0,0 +1,63 @@ +use assert_cmd::Command; +use std::fs; +use tempfile::tempdir; +use toml_edit::DocumentMut; + +#[test] +fn add_parachain_pallet_template() { + let temp_dir = tempdir().unwrap(); + // Setup new parachain + Command::cargo_bin("pop") + .unwrap() + .current_dir(&temp_dir) + .args(&["new", "parachain", "testchain"]) + .assert() + .success(); + // Add pallet-parachain-template + Command::cargo_bin("pop") + .unwrap() + .args(&["add", "pallet", "template", "-r", "testchain/runtime/src/lib.rs"]) + .current_dir(&temp_dir.path()) + .assert() + .success(); + + let runtime_contents = + fs::read_to_string(&temp_dir.path().join("testchain/runtime/src/lib.rs")).unwrap(); + let runtime_manifest = + fs::read_to_string(&temp_dir.path().join("testchain/runtime/Cargo.toml")).unwrap(); + // Check runtime entries + assert_eq!(runtime_contents.matches("pub use pallet_parachain_template;").count(), 1); + assert_eq!( + runtime_contents + .matches("impl pallet_parachain_template::Config for Runtime {") + .count(), + 1 + ); + assert_eq!(runtime_contents.matches("Template: pallet_parachain_template").count(), 1); + // Check runtime manifest entries + let toml = runtime_manifest.parse::().unwrap(); + assert!(toml["dependencies"]["pallet-parachain-template"].is_value()); + let std = toml["features"]["std"].as_value().unwrap().as_array().unwrap(); + assert_eq!( + std.iter() + .filter(|val| val.as_str().unwrap() == "pallet-parachain-template/std") + .count(), + 1 + ); + let rt_bench = toml["features"]["runtime-benchmarks"].as_value().unwrap().as_array().unwrap(); + assert_eq!( + rt_bench + .iter() + .filter(|val| val.as_str().unwrap() == "pallet-parachain-template/runtime-benchmarks") + .count(), + 1 + ); + let try_rt = toml["features"]["try-runtime"].as_value().unwrap().as_array().unwrap(); + assert_eq!( + try_rt + .iter() + .filter(|val| val.as_str().unwrap() == "pallet-parachain-template/try-runtime") + .count(), + 1 + ); +}