diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b81c1943..682dd740 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,4 +65,4 @@ jobs: run: cargo build - name: Run tests - run: cargo test --verbose \ No newline at end of file + run: cargo test --all-features \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 215b0c0d..3f60dc23 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", @@ -400,7 +400,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -443,7 +443,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.55", + "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,9 +486,9 @@ 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", @@ -621,19 +621,21 @@ dependencies = [ [[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.2", "async-lock 3.3.0", "async-signal", + "async-task", "blocking", "cfg-if", - "event-listener 5.2.0", + "event-listener 5.3.0", "futures-lite 2.3.0", "rustix 0.38.32", + "tracing", "windows-sys 0.52.0", ] @@ -669,7 +671,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -696,7 +698,7 @@ 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", ] @@ -1014,7 +1016,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "syn_derive", ] @@ -1044,9 +1046,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.5.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" +checksum = "125740193d7fee5cc63ab9e16c2fdc4e07c74ba755cc53b327d6ea029e9fc569" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1055,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", @@ -1193,9 +1195,9 @@ 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", @@ -1275,7 +1277,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -1287,7 +1289,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1527,7 +1529,7 @@ dependencies = [ "scale-info", "serde", "serde_json", - "strsim 0.11.0", + "strsim 0.11.1", "thiserror", "tracing", ] @@ -1748,7 +1750,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1775,7 +1777,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1792,7 +1794,7 @@ checksum = "b404f596046b0bb2d903a9c786b875a126261b52b7c3a64bbb66382c41c771df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1840,7 +1842,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1862,7 +1864,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2045,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", @@ -2096,7 +2098,7 @@ dependencies = [ "quote", "strum 0.25.0", "strum_macros 0.25.3", - "syn 2.0.55", + "syn 2.0.58", "thiserror", ] @@ -2186,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", @@ -2218,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]] @@ -2317,7 +2319,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2328,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", @@ -2347,7 +2349,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.55", + "syn 2.0.58", "termcolor", "toml 0.8.12", "walkdir", @@ -2355,9 +2357,9 @@ dependencies = [ [[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" @@ -2597,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", @@ -2618,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", ] @@ -2637,7 +2639,7 @@ dependencies = [ "prettier-please", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2807,7 +2809,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2818,7 +2820,7 @@ checksum = "d9c078db2242ea7265faa486004e7fd8daaf1a577cfcac0070ce55d926922883" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2830,7 +2832,7 @@ dependencies = [ "pmutil", "proc-macro2", "swc_macros_common", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -2943,7 +2945,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3015,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", @@ -3089,9 +3091,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -3245,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]] @@ -3780,7 +3783,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4204,7 +4207,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.12", + "getrandom 0.2.13", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4310,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.5.0", "libc", - "redox_syscall", ] [[package]] @@ -4435,7 +4437,7 @@ checksum = "adf157a4dc5a29b7b464aa8fe7edeff30076e07e13646a1c3874f58477dc99f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4932,7 +4934,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5161,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", @@ -5172,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", @@ -5182,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.55", + "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", @@ -5234,7 +5236,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5263,14 +5265,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "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" @@ -5350,7 +5352,7 @@ checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5372,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.55", + "syn 2.0.58", ] [[package]] @@ -5393,7 +5395,7 @@ dependencies = [ "polkavm-common 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5405,7 +5407,7 @@ dependencies = [ "polkavm-common 0.8.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5415,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.55", + "syn 2.0.58", ] [[package]] @@ -5497,6 +5499,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", + "regex", "reqwest", "semver 1.0.22", "serde", @@ -5508,7 +5511,7 @@ dependencies = [ "subxt 0.34.0", "subxt-signer 0.34.0", "symlink", - "syn 2.0.55", + "syn 2.0.58", "tempfile", "tokio", "toml_edit 0.22.9", @@ -5575,7 +5578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22020dfcf177fcc7bf5deaf7440af371400c67c0de14c399938d8ed4fb4645d3" dependencies = [ "proc-macro2", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5585,7 +5588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5670,7 +5673,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5682,7 +5685,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5812,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]] @@ -5835,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", ] @@ -5861,7 +5864,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -5993,7 +5996,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.12", + "getrandom 0.2.13", "libc", "spin 0.9.8", "untrusted", @@ -6193,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", @@ -6210,11 +6213,11 @@ 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", ] @@ -6258,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" @@ -6408,7 +6411,7 @@ dependencies = [ "proc-macro2", "quote", "scale-info", - "syn 2.0.55", + "syn 2.0.58", "thiserror", ] @@ -6609,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", @@ -6622,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", @@ -6690,7 +6693,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -6724,7 +6727,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7027,7 +7030,7 @@ dependencies = [ "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.3.0", ] @@ -7467,7 +7470,7 @@ checksum = "f12dae7cf6c1e825d13ffd4ce16bd9309db7c539929d0302b4443ed451a9f4e5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7478,7 +7481,7 @@ checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7628,7 +7631,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7642,7 +7645,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7874,7 +7877,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7885,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" @@ -7936,7 +7939,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -7949,7 +7952,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8055,7 +8058,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata 0.33.0", - "syn 2.0.55", + "syn 2.0.58", "thiserror", "tokio", ] @@ -8076,7 +8079,7 @@ dependencies = [ "scale-info", "scale-typegen", "subxt-metadata 0.34.0", - "syn 2.0.55", + "syn 2.0.58", "thiserror", "tokio", ] @@ -8125,7 +8128,7 @@ dependencies = [ "parity-scale-codec", "proc-macro-error", "subxt-codegen 0.33.0", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8140,7 +8143,7 @@ dependencies = [ "quote", "scale-typegen", "subxt-codegen 0.34.0", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8273,7 +8276,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8323,7 +8326,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8408,7 +8411,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8513,7 +8516,7 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8525,7 +8528,7 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8549,7 +8552,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8571,9 +8574,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -8589,7 +8592,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8716,7 +8719,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -8831,7 +8834,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -9067,7 +9070,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -9179,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" @@ -9465,7 +9478,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", "serde", ] @@ -9612,7 +9625,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -9646,7 +9659,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9934,9 +9947,9 @@ dependencies = [ [[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" @@ -10271,7 +10284,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -10291,7 +10304,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6078ca5a..bebb2f78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ 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 } @@ -75,6 +76,8 @@ contract = [ "dep:sp-weights", "dep:url", ] +e2e_contract = [] +unit_contract = [] parachain = [ "dep:dirs", "dep:indexmap", @@ -93,3 +96,5 @@ parachain = [ "cfg-expr", "prettyplease", ] +e2e_parachain = [] + diff --git a/README.md b/README.md index c072dc3e..7322e54b 100644 --- a/README.md +++ b/README.md @@ -133,17 +133,18 @@ Some of the options available are: For more information about the options, check [cargo-contract documentation](https://github.com/paritytech/cargo-contract/blob/master/crates/extrinsics/README.md#instantiate) - Interacting with the Smart Contract: -1. Read-only Operations: For operations that only require reading from the blockchain state. This approach does not require to submit an extrinsic (skip the flag `x/--execute`). -Example using the get() message: +1. Read-only Operations: For operations that only require reading from the blockchain state. This approach does not + require to submit an extrinsic (skip the flag `x/--execute`). + Example using the get() message: ```sh pop call contract -p ./my_contract --contract $INSTANTIATED_CONTRACT_ADDRESS --message get --suri //Alice ``` -2. State-modifying Operations: For operations that change a storage value, thus altering the blockchain state. Include the `x/--execute` flag to submit an extrinsic on-chain. +2. State-modifying Operations: For operations that change a storage value, thus altering the blockchain state. Include + the `x/--execute` flag to submit an extrinsic on-chain. Example executing the `flip()` message: @@ -204,3 +205,44 @@ pop up parachain -f ./tests/zombienet.toml -p https://github.com/r0gue-io/pop-no > :information_source: Pop CLI will automatically source the necessary polkadot binaries. Currently, these will be built > if on a non-linux system. + + +## Testing Pop CLI + +To test the tool locally. + +Run the unit tests: + +```sh +cargo test +``` + +Run only contracts unit tests: + +```sh +cargo test --features unit_contract +``` + +Run the contracts e2e tests: + +```sh +cargo test --features e2e_contract +``` + +Run the parachain e2e tests: + +```sh +cargo test --features e2e_parachain +``` + +Run all tests: + +```sh +cargo test --all-features +``` +## Acknowledgements + +Pop CLI would not be possible without these awesome crates! + +- Local network deployment powered by [zombienet-sdk](https://github.com/paritytech/zombienet-sdk) +- [cargo contract](https://github.com/paritytech/cargo-contract) a setup and deployment tool for developing Wasm based smart contracts via ink! diff --git a/src/commands/new/contract.rs b/src/commands/new/contract.rs index 909c1ea8..fc5c5ef6 100644 --- a/src/commands/new/contract.rs +++ b/src/commands/new/contract.rs @@ -15,7 +15,7 @@ pub struct NewContractCommand { } impl NewContractCommand { - pub(crate) fn execute(&self) -> anyhow::Result<()> { + pub(crate) fn execute(self) -> anyhow::Result<()> { clear_screen()?; intro(format!( "{}: Generating new contract \"{}\"!", @@ -23,12 +23,11 @@ impl NewContractCommand { &self.name, ))?; set_theme(Theme); - let contract_name = self.name.clone(); - let contract_path = self - .path - .as_ref() - .unwrap_or(¤t_dir().expect("current dir is inaccessible")) - .join(contract_name.clone()); + let contract_path = if let Some(ref path) = self.path { + path.join(&self.name) + } else { + current_dir()?.join(&self.name) + }; if contract_path.exists() { if !confirm(format!( "\"{}\" directory already exists. Would you like to remove it?", @@ -42,17 +41,14 @@ impl NewContractCommand { ))?; return Ok(()); } - fs::remove_dir_all(contract_path)?; + fs::remove_dir_all(contract_path.as_path())?; } + fs::create_dir_all(contract_path.as_path())?; let mut spinner = cliclack::spinner(); spinner.start("Generating contract..."); - - create_smart_contract(self.name.clone(), &self.path)?; - spinner.stop(format!( - "Smart contract created! Located in the following directory {:?}", - self.path.clone().unwrap_or(PathBuf::from(format!("/{}", self.name))).display() - )); - outro(format!("cd into \"{}\" and enjoy hacking! 🚀", &self.name))?; + create_smart_contract(self.name, contract_path.as_path())?; + spinner.stop("Smart contract created!"); + outro(format!("cd into \"{}\" and enjoy hacking! 🚀", contract_path.display()))?; Ok(()) } } @@ -74,16 +70,4 @@ mod tests { Ok(()) } - - #[test] - fn test_new_contract_command_execute_fails_path_no_exist() -> Result<()> { - let temp_contract_dir = tempfile::tempdir().expect("Could not create temp dir"); - let command = NewContractCommand { - name: "test_contract".to_string(), - path: Some(temp_contract_dir.path().join("new_contract")), - }; - let result_error = command.execute(); - assert!(result_error.is_err()); - Ok(()) - } } diff --git a/src/commands/new/parachain.rs b/src/commands/new/parachain.rs index c4e49e4d..469f220f 100644 --- a/src/commands/new/parachain.rs +++ b/src/commands/new/parachain.rs @@ -4,10 +4,10 @@ use crate::{ style::{style, Theme}, }; use clap::{Args, Parser}; -use std::{fs, path::Path}; +use std::{fs, path::PathBuf}; use strum_macros::{Display, EnumString}; -use cliclack::{clear_screen, confirm, intro, outro, outro_cancel, set_theme}; +use cliclack::{clear_screen, confirm, intro, log, outro, outro_cancel, set_theme}; #[derive(Clone, Parser, Debug, Display, EnumString, PartialEq)] pub enum Template { @@ -21,7 +21,7 @@ pub enum Template { #[derive(Args)] pub struct NewParachainCommand { - #[arg(help = "Name of the project. Also works as a directory path for your project")] + #[arg(help = "Name of the project")] pub(crate) name: String, #[arg( help = "Template to use; Options are 'cpt', 'fpt'. Leave empty for default parachain template" @@ -39,6 +39,12 @@ pub struct NewParachainCommand { default_value = "1u64 << 60" )] pub(crate) initial_endowment: Option, + #[arg( + short = 'p', + long, + help = "Path for the parachain project, [default: current directory]" + )] + pub(crate) path: Option, } impl NewParachainCommand { @@ -51,7 +57,11 @@ impl NewParachainCommand { &self.template ))?; set_theme(Theme); - let destination_path = Path::new(&self.name); + let destination_path = if let Some(ref path) = self.path { + path.join(&self.name) + } else { + PathBuf::from(&self.name) + }; if destination_path.exists() { if !confirm(format!( "\"{}\" directory already exists. Would you like to remove it?", @@ -65,26 +75,29 @@ impl NewParachainCommand { ))?; return Ok(()); } - fs::remove_dir_all(destination_path)?; + fs::remove_dir_all(destination_path.as_path())?; } let mut spinner = cliclack::spinner(); spinner.start("Generating parachain..."); - instantiate_template_dir( + let tag = instantiate_template_dir( &self.template, - destination_path, + destination_path.as_path(), Config { symbol: self.symbol.clone().expect("default values"), decimals: self.decimals.clone().expect("default values"), initial_endowment: self.initial_endowment.clone().expect("default values"), }, )?; - if let Err(err) = git_init(destination_path, "initialized parachain") { + if let Err(err) = git_init(destination_path.as_path(), "initialized parachain") { if err.class() == git2::ErrorClass::Config && err.code() == git2::ErrorCode::NotFound { outro_cancel("git signature could not be found. Please configure your git config with your name and email")?; } } spinner.stop("Generation complete"); - outro(format!("cd into \"{}\" and enjoy hacking! 🚀", &self.name))?; + if let Some(tag) = tag { + log::info(format!("Version: {}", tag))?; + } + outro(format!("cd into \"{}\" and enjoy hacking! 🚀", destination_path.display()))?; Ok(()) } } @@ -95,7 +108,7 @@ mod tests { use git2::Repository; use super::*; - use std::fs; + use std::{fs, path::Path}; #[test] fn test_new_parachain_command_execute() -> anyhow::Result<()> { @@ -105,6 +118,7 @@ mod tests { symbol: Some("UNIT".to_string()), decimals: Some(12), initial_endowment: Some("1u64 << 60".to_string()), + path: None, }; let result = command.execute(); assert!(result.is_ok()); diff --git a/src/commands/up/mod.rs b/src/commands/up/mod.rs index 0e8ec10a..c0e9cb24 100644 --- a/src/commands/up/mod.rs +++ b/src/commands/up/mod.rs @@ -15,7 +15,7 @@ pub(crate) struct UpArgs { #[derive(Subcommand)] pub(crate) enum UpCommands { #[cfg(feature = "parachain")] - /// Deploy a parachain to a network. + /// Deploy a parachain to a local network. #[clap(alias = "p")] Parachain(parachain::ZombienetCommand), #[cfg(feature = "contract")] diff --git a/src/commands/up/parachain.rs b/src/commands/up/parachain.rs index 6b1fc717..c9ac675b 100644 --- a/src/commands/up/parachain.rs +++ b/src/commands/up/parachain.rs @@ -6,8 +6,7 @@ use zombienet_sdk::NetworkNode; #[derive(Args)] pub(crate) struct ZombienetCommand { - /// The configuration file to be used. Only Zombienet configuration files are currently - /// supported. + /// The Zombienet configuration file to be used. #[arg(short, long)] file: String, /// The version of Polkadot to be used for the relay chain, as per the release tag (e.g. @@ -21,6 +20,9 @@ pub(crate) struct ZombienetCommand { /// The url of the git repository of a parachain to be used, with branch/release tag specified as #fragment (e.g. 'https://github.com/org/repository#tag'). A specific binary name can also be optionally specified via query string parameter (e.g. 'https://github.com/org/repository?binaryname#tag'), defaulting to the name of the repository when not specified. #[arg(short, long)] parachain: Option>, + /// Whether the output should be verbose. + #[arg(short, long, action)] + verbose: bool, } impl ZombienetCommand { pub(crate) async fn execute(&self) -> anyhow::Result<()> { @@ -71,12 +73,20 @@ impl ZombienetCommand { let output = |node: &NetworkNode| -> String { let name = node.name(); - format!( + let mut output = format!( "\n{bar} {name}: {bar} portal: https://polkadot.js.org/apps/?rpc={}#/explorer {bar} logs: tail -f {base_dir}/{name}/{name}.log", node.ws_uri(), - ) + ); + if self.verbose { + output += &format!( + "\n{bar} command: {} {}", + node.spec().command(), + node.args().join(" ") + ); + } + output }; // Add relay info let mut validators = network.relaychain().nodes(); diff --git a/src/engines/contract_engine.rs b/src/engines/contract_engine.rs index 09721ec6..16a1a92f 100644 --- a/src/engines/contract_engine.rs +++ b/src/engines/contract_engine.rs @@ -1,7 +1,7 @@ use anyhow::Context; use cliclack::log; use duct::cmd; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use contract_build::{ execute, new_contract_project, BuildArtifacts, BuildMode, ExecuteArgs, Features, ManifestPath, @@ -14,13 +14,19 @@ use sp_weights::Weight; use subxt::PolkadotConfig as DefaultConfig; use subxt_signer::sr25519::Keypair; -pub fn create_smart_contract(name: String, target: &Option) -> anyhow::Result<()> { - new_contract_project(&name, target.as_ref()) +/// Create a new smart contract at `target` +pub fn create_smart_contract(name: String, target: &Path) -> anyhow::Result<()> { + // In this code, out_dir will automatically join `name` to `target`, + // which is created prior to the call to this function + // So we must pass `target.parent()` + new_contract_project(&name, target.canonicalize()?.parent()) } +/// Build a smart contract pub fn build_smart_contract(path: &Option) -> anyhow::Result<()> { - // If the user specifies a path (which is not the current directory), it will have to manually add a Cargo.toml file. If not provided, pop-cli will ask the user for a specific path. or - // ask to the user the specific path (Like cargo-contract does) + // If the user specifies a path (which is not the current directory), it will have to manually + // add a Cargo.toml file. If not provided, pop-cli will ask the user for a specific path. or ask + // to the user the specific path (Like cargo-contract does) let manifest_path; if path.is_some() { let full_path: PathBuf = @@ -171,38 +177,38 @@ pub async fn dry_run_call( mod tests { use super::*; use anyhow::{Error, Result}; - use std::{fs, path::PathBuf}; + use std::fs; fn setup_test_environment() -> Result { - let temp_contract_dir = tempfile::tempdir().expect("Could not create temp dir"); - let result: anyhow::Result<()> = create_smart_contract( - "test_contract".to_string(), - &Some(PathBuf::from(temp_contract_dir.path())), - ); - - assert!(result.is_ok(), "Result should be Ok"); - - Ok(temp_contract_dir) + let temp_dir = tempfile::tempdir().expect("Could not create temp dir"); + let temp_contract_dir = temp_dir.path().join("test_contract"); + fs::create_dir(&temp_contract_dir)?; + let result = + create_smart_contract("test_contract".to_string(), temp_contract_dir.as_path()); + assert!(result.is_ok(), "Contract test environment setup failed"); + + Ok(temp_dir) } #[test] fn test_contract_create() -> Result<(), Error> { - let temp_contract_dir = setup_test_environment()?; + let temp_dir = setup_test_environment()?; // Verify that the generated smart contract contains the expected content let generated_file_content = - fs::read_to_string(temp_contract_dir.path().join("test_contract/lib.rs")) + fs::read_to_string(temp_dir.path().join("test_contract/lib.rs")) .expect("Could not read file"); assert!(generated_file_content.contains("#[ink::contract]")); assert!(generated_file_content.contains("mod test_contract {")); // Verify that the generated Cargo.toml file contains the expected content - fs::read_to_string(temp_contract_dir.path().join("test_contract/Cargo.toml")) + fs::read_to_string(temp_dir.path().join("test_contract/Cargo.toml")) .expect("Could not read file"); Ok(()) } + #[cfg(feature = "unit_contract")] #[test] fn test_contract_build() -> Result<(), Error> { let temp_contract_dir = setup_test_environment()?; @@ -229,6 +235,7 @@ mod tests { Ok(()) } + #[cfg(feature = "unit_contract")] #[test] fn test_contract_test() -> Result<(), Error> { let temp_contract_dir = setup_test_environment()?; diff --git a/src/engines/parachain_engine.rs b/src/engines/parachain_engine.rs index cf55776d..f3329093 100644 --- a/src/engines/parachain_engine.rs +++ b/src/engines/parachain_engine.rs @@ -20,7 +20,11 @@ pub struct Config { } /// Creates a new template at `target` dir -pub fn instantiate_template_dir(template: &Template, target: &Path, config: Config) -> Result<()> { +pub fn instantiate_template_dir( + template: &Template, + target: &Path, + config: Config, +) -> Result> { sanitize(target)?; use Template::*; let url = match template { @@ -30,15 +34,15 @@ pub fn instantiate_template_dir(template: &Template, target: &Path, config: Conf return instantiate_base_template(target, config); }, }; - clone_and_degit(url, target)?; + let tag = clone_and_degit(url, target)?; Repository::init(target)?; - Ok(()) + Ok(tag) } -pub fn instantiate_base_template(target: &Path, config: Config) -> Result<()> { +pub fn instantiate_base_template(target: &Path, config: Config) -> Result> { let temp_dir = ::tempfile::TempDir::new_in(std::env::temp_dir())?; let source = temp_dir.path(); - clone_and_degit("https://github.com/r0gue-io/base-parachain", source)?; + let tag = clone_and_degit("https://github.com/r0gue-io/base-parachain", source)?; for entry in WalkDir::new(&source) { let entry = entry?; @@ -66,7 +70,7 @@ pub fn instantiate_base_template(target: &Path, config: Config) -> Result<()> { let network = Network { node: "parachain-template-node".into() }; write_to_file(&target.join("network.toml"), network.render().expect("infallible").as_ref()); Repository::init(target)?; - Ok(()) + Ok(tag) } pub fn build_parachain(path: &Option) -> anyhow::Result<()> { @@ -90,7 +94,7 @@ mod tests { decimals: 18, initial_endowment: "1000000".to_string(), }; - let result: anyhow::Result<()> = instantiate_base_template(temp_dir.path(), config); + let result = instantiate_base_template(temp_dir.path(), config); assert!(result.is_ok()); Ok(temp_dir) } @@ -123,13 +127,4 @@ mod tests { Ok(()) } - - #[test] - fn test_parachain_build_after_instantiating_template() -> Result<()> { - let temp_dir = - setup_template_and_instantiate().expect("Failed to setup template and instantiate"); - let build = build_parachain(&Some(temp_dir.path().to_path_buf())); - assert!(build.is_ok(), "Result should be Ok"); - Ok(()) - } } diff --git a/src/helpers.rs b/src/helpers.rs index 86d0a199..a83d414d 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -2,6 +2,7 @@ use anyhow::Result; use cliclack::{log, outro_cancel}; use git2::{IndexAddOption, Repository, ResetType}; +use regex::Regex; use std::{ env::current_dir, fs::{self, OpenOptions}, @@ -44,11 +45,30 @@ pub(crate) fn write_to_file<'a>(path: &Path, contents: &'a str) { } /// Clone `url` into `target` and degit it -pub(crate) fn clone_and_degit(url: &str, target: &Path) -> Result<()> { +pub(crate) fn clone_and_degit(url: &str, target: &Path) -> Result> { let repo = Repository::clone(url, target)?; + + // fetch tags from remote + let release = fetch_latest_tag(&repo); + let git_dir = repo.path(); fs::remove_dir_all(&git_dir)?; - Ok(()) + Ok(release) +} + +/// Fetch the latest release from a repository +fn fetch_latest_tag(repo: &Repository) -> Option { + let version_reg = Regex::new(r"v\d+\.\d+\.\d+").expect("Valid regex"); + let tags = repo.tag_names(None).ok()?; + // Start from latest tags + for tag in tags.iter().rev() { + if let Some(tag) = tag { + if version_reg.is_match(tag) { + return Some(tag.to_string()); + } + } + } + None } /// Init a new git repo on creation of a parachain diff --git a/src/main.rs b/src/main.rs index cbf17ea1..7d0205ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,8 +55,8 @@ enum Commands { #[tokio::main] async fn main() -> Result<()> { let cli = Cli::parse(); - match &cli.command { - Commands::New(args) => match &args.command { + match cli.command { + Commands::New(args) => match args.command { #[cfg(feature = "parachain")] commands::new::NewCommands::Parachain(cmd) => cmd.execute(), #[cfg(feature = "parachain")] diff --git a/tests/build_contract.rs b/tests/build_contract.rs index 65a0bfe8..972192bc 100644 --- a/tests/build_contract.rs +++ b/tests/build_contract.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "e2e_contract")] use anyhow::{Error, Result}; use assert_cmd::Command; use predicates::prelude::*; @@ -16,7 +17,7 @@ fn setup_test_environment() -> Result { } #[test] -fn test_contract_build() -> Result<(), Error> { +fn test_contract_build_success() -> Result<(), Error> { let temp_contract_dir = setup_test_environment()?; // pop build contract diff --git a/tests/build_parachain.rs b/tests/build_parachain.rs new file mode 100644 index 00000000..06b0824a --- /dev/null +++ b/tests/build_parachain.rs @@ -0,0 +1,32 @@ +#![cfg(feature = "e2e_parachain")] +use anyhow::{Error, Result}; +use assert_cmd::Command; + +fn setup_test_environment() -> Result { + let temp_dir = tempfile::tempdir().unwrap(); + // pop new parachain test_parachain + Command::cargo_bin("pop") + .unwrap() + .current_dir(&temp_dir) + .args(&["new", "parachain", "test_parachain"]) + .assert() + .success(); + + Ok(temp_dir) +} + +#[test] +fn test_parachain_build_after_instantiating_template() -> Result<()> { + let temp_dir = setup_test_environment()?; + + // pop build contract -p "./test_parachain" + Command::cargo_bin("pop") + .unwrap() + .current_dir(&temp_dir) + .args(&["build", "parachain", "-p", "./test_parachain"]) + .assert() + .success(); + + assert!(temp_dir.path().join("test_parachain/target").exists()); + Ok(()) +}