From 71c9eb9a389c0a1d70d8814b410b52aa0c07fc8e Mon Sep 17 00:00:00 2001 From: FroVolod Date: Fri, 13 Oct 2023 11:05:27 +0300 Subject: [PATCH 1/5] added Deploy --- Cargo.lock | 278 ++++++++++--------- cargo-near/Cargo.toml | 11 +- cargo-near/src/commands/build_command/mod.rs | 2 +- cargo-near/src/commands/deploy/mod.rs | 147 ++++++++++ cargo-near/src/commands/mod.rs | 4 + cargo-near/src/types/utf8_path_buf.rs | 9 + integration-tests/src/lib.rs | 1 + 7 files changed, 322 insertions(+), 130 deletions(-) create mode 100644 cargo-near/src/commands/deploy/mod.rs diff --git a/Cargo.lock b/Cargo.lock index b1342e02..5337dd53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -55,7 +55,7 @@ checksum = "7c7db3d5a9718568e4cf4a537cfd7070e6e6ff7481510d0237fb529ac850f6d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -96,22 +96,11 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -218,7 +207,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" dependencies = [ - "event-listener", + "event-listener 2.5.3", "futures-core", ] @@ -229,7 +218,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] @@ -285,24 +274,23 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", ] [[package]] name = "async-process" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" dependencies = [ "async-io", "async-lock", - "autocfg", + "async-signal", "blocking", "cfg-if", - "event-listener", + "event-listener 3.0.0", "futures-lite", - "rustix 0.37.24", - "signal-hook", + "rustix 0.38.18", "windows-sys 0.48.0", ] @@ -314,7 +302,25 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", +] + +[[package]] +name = "async-signal" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2a5415b7abcdc9cd7d63d6badba5288b2ca017e3fbd4173b8f405449f1a2399" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 0.38.18", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", ] [[package]] @@ -336,7 +342,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -353,7 +359,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -524,9 +530,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blocking" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c4ef1f913d78636d78d538eec1f18de81e481f44b1be0a81060090530846e1" +checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" dependencies = [ "async-channel", "async-lock", @@ -555,7 +561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" dependencies = [ "borsh-derive 0.10.3", - "hashbrown 0.13.2", + "hashbrown 0.12.3", ] [[package]] @@ -660,9 +666,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -741,6 +747,10 @@ dependencies = [ "names", "near-abi", "near-cli-rs", + "near-crypto 0.17.0", + "near-jsonrpc-client 0.6.0", + "near-jsonrpc-primitives 0.17.0", + "near-primitives 0.17.0", "rustc_version", "schemars", "serde_json", @@ -780,9 +790,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" dependencies = [ "serde", ] @@ -902,7 +912,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1155,9 +1165,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" +checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" dependencies = [ "csv-core", "itoa", @@ -1167,9 +1177,9 @@ dependencies = [ [[package]] name = "csv-core" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" dependencies = [ "memchr", ] @@ -1191,9 +1201,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.66+curl-8.3.0" +version = "0.4.67+curl-8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70c44a72e830f0e40ad90dda8a6ab6ed6314d39776599a58a2e5e37fbc6db5b9" +checksum = "3cc35d066510b197a0f72de863736641539957628c8a42e70e27c66849e77c34" dependencies = [ "cc", "libc", @@ -1238,7 +1248,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1249,7 +1259,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1289,7 +1299,7 @@ checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1505,7 +1515,7 @@ checksum = "04d0b288e3bb1d861c4403c1774a6f7a798781dfc519b3647df2a3dd4ae95f25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1526,7 +1536,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1550,30 +1560,30 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys 0.48.0", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "event-listener" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "2.5.3" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] [[package]] name = "eyre" @@ -1797,7 +1807,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -1929,7 +1939,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.6", + "ahash", ] [[package]] @@ -1937,14 +1947,8 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash", ] [[package]] @@ -2249,9 +2253,9 @@ dependencies = [ [[package]] name = "interactive-clap" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42bd342c17d765c32d082c4ecd8d5ad7c5d872b33966145282b4e2a34e146e65" +checksum = "dce1b03179638eaf4301fd7a26e5798ba0d4c44a2277ef397914478088f97f27" dependencies = [ "interactive-clap-derive", "strum", @@ -2260,9 +2264,9 @@ dependencies = [ [[package]] name = "interactive-clap-derive" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7e9f13ff386d6b730ffe4d4d2f5cb0a38f53ebcf74e591187748723c0331cb" +checksum = "ee313b6ffaa60679c3567b1a11b9a097a4ccff299ed4e780e0b2f2e6e158f159" dependencies = [ "proc-macro-error", "proc-macro2", @@ -2303,7 +2307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.15", + "rustix 0.38.18", "windows-sys 0.48.0", ] @@ -2343,9 +2347,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] @@ -2436,9 +2440,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libgit2-sys" @@ -2517,9 +2521,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" @@ -2548,9 +2552,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -2726,8 +2730,8 @@ dependencies = [ [[package]] name = "near-cli-rs" -version = "0.6.0" -source = "git+https://github.com/near/near-cli-rs#76a7588704713d90e6dfa2248e31429fe196e131" +version = "0.6.1" +source = "git+https://github.com/near/near-cli-rs?rev=5d3a05876b58b910dfbf509bf39ef5f46b543436#5d3a05876b58b910dfbf509bf39ef5f46b543436" dependencies = [ "bip39", "bs58 0.5.0", @@ -3093,7 +3097,7 @@ checksum = "84c1eda300e2e78f4f945ae58117d49e806899f4a51ee2faa09eda5ebc2e6571" dependencies = [ "quote", "serde", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3116,7 +3120,7 @@ dependencies = [ "fs2", "near-rpc-error-core 0.17.0", "serde", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3343,9 +3347,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -3421,7 +3425,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3616,7 +3620,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -3776,9 +3780,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -4009,14 +4013,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.6" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.9", - "regex-syntax 0.7.5", + "regex-automata 0.4.1", + "regex-syntax 0.8.0", ] [[package]] @@ -4030,13 +4034,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.0", ] [[package]] @@ -4047,15 +4051,15 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64 0.21.4", "bytes", @@ -4078,6 +4082,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", "tower-service", @@ -4131,14 +4136,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.15" +version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.8", + "linux-raw-sys 0.4.10", "windows-sys 0.48.0", ] @@ -4225,7 +4230,7 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4331,9 +4336,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" dependencies = [ "serde", ] @@ -4355,7 +4360,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4388,7 +4393,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4438,7 +4443,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4491,9 +4496,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b21f559e07218024e7e9f90f96f601825397de0e25420135f7f952453fed0b" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -4612,7 +4617,7 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4762,9 +4767,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -4783,6 +4788,27 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -4809,7 +4835,7 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall 0.3.5", - "rustix 0.38.15", + "rustix 0.38.18", "windows-sys 0.48.0", ] @@ -4850,7 +4876,7 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -4954,7 +4980,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -5167,7 +5193,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] @@ -5443,7 +5469,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -5477,7 +5503,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5513,7 +5539,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.15", + "rustix 0.38.18", ] [[package]] @@ -5690,9 +5716,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] @@ -5793,7 +5819,7 @@ dependencies = [ "byteorder", "derivative", "enumflags2", - "event-listener", + "event-listener 2.5.3", "futures-core", "futures-sink", "futures-util", @@ -5857,7 +5883,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.38", ] [[package]] diff --git a/cargo-near/Cargo.toml b/cargo-near/Cargo.toml index 2c885ca4..e385c22d 100644 --- a/cargo-near/Cargo.toml +++ b/cargo-near/Cargo.toml @@ -37,10 +37,15 @@ color-eyre = "0.6" inquire = "0.6" strum = { version = "0.24", features = ["derive"] } strum_macros = "0.24" -interactive-clap = "0.2.6" -interactive-clap-derive = "0.2.6" linked-hash-map = { version = "0.5", features = ["serde_impl"] } names = { version = "0.14.0", default-features = false } -near-cli-rs = { git = "https://github.com/near/near-cli-rs" } derive_more = "0.99.9" shell-words = "1.0.0" +interactive-clap = "0.2.7" +interactive-clap-derive = "0.2.7" +near-cli-rs = { git = "https://github.com/near/near-cli-rs", rev = "5d3a05876b58b910dfbf509bf39ef5f46b543436" } + +near-crypto = "0.17.0" +near-primitives = "0.17.0" +near-jsonrpc-client = "0.6.0" +near-jsonrpc-primitives = "0.17.0" diff --git a/cargo-near/src/commands/build_command/mod.rs b/cargo-near/src/commands/build_command/mod.rs index 2aa25d24..f5b094a5 100644 --- a/cargo-near/src/commands/build_command/mod.rs +++ b/cargo-near/src/commands/build_command/mod.rs @@ -1,6 +1,6 @@ pub mod build; -#[derive(Debug, Clone, interactive_clap::InteractiveClap)] +#[derive(Debug, Default, Clone, interactive_clap::InteractiveClap)] #[interactive_clap(context = near_cli_rs::GlobalContext)] #[interactive_clap(skip_default_from_cli)] pub struct BuildCommand { diff --git a/cargo-near/src/commands/deploy/mod.rs b/cargo-near/src/commands/deploy/mod.rs new file mode 100644 index 00000000..049f5676 --- /dev/null +++ b/cargo-near/src/commands/deploy/mod.rs @@ -0,0 +1,147 @@ +use near_cli_rs::commands::contract::deploy::initialize_mode::InitializeMode; + +use crate::commands::build_command; + +#[derive(Debug, Clone, interactive_clap::InteractiveClap)] +#[interactive_clap(input_context = near_cli_rs::GlobalContext)] +#[interactive_clap(output_context = ContractContext)] +#[interactive_clap(skip_default_from_cli)] +pub struct Contract { + #[interactive_clap(skip_default_input_arg)] + #[interactive_clap(flatten)] + /// Specify a build command args: + build_command_args: build_command::BuildCommand, + #[interactive_clap(skip_default_input_arg)] + /// What is the contract account ID? + contract_account_id: near_cli_rs::types::account_id::AccountId, + #[allow(dead_code)] + #[interactive_clap(skip)] + file_path: crate::types::utf8_path_buf::Utf8PathBufInner, + #[interactive_clap(subcommand)] + initialize: InitializeMode, +} + +#[derive(Debug, Clone)] +pub struct ContractContext(near_cli_rs::commands::contract::deploy::ContractFileContext); + +impl ContractContext { + pub fn from_previous_context( + previous_context: near_cli_rs::GlobalContext, + scope: &::InteractiveClapContextScope, + ) -> color_eyre::eyre::Result { + Ok(Self( + near_cli_rs::commands::contract::deploy::ContractFileContext { + global_context: previous_context, + receiver_account_id: scope.contract_account_id.clone().into(), + signer_account_id: scope.contract_account_id.clone().into(), + code: scope.file_path.read_bytes()?, + }, + )) + } +} + +impl From for near_cli_rs::commands::contract::deploy::ContractFileContext { + fn from(item: ContractContext) -> Self { + item.0 + } +} + +impl interactive_clap::FromCli for Contract { + type FromCliContext = near_cli_rs::GlobalContext; + type FromCliError = color_eyre::eyre::Error; + fn from_cli( + optional_clap_variant: Option<::CliVariant>, + context: Self::FromCliContext, + ) -> interactive_clap::ResultFromCli< + ::CliVariant, + Self::FromCliError, + > + where + Self: Sized + interactive_clap::ToCli, + { + let mut clap_variant = optional_clap_variant.unwrap_or_default(); + + let build_command_args = + if let Some(cli_build_command_args) = &clap_variant.build_command_args { + build_command::BuildCommand { + release: cli_build_command_args.release, + embed_abi: cli_build_command_args.embed_abi, + doc: cli_build_command_args.doc, + no_abi: cli_build_command_args.no_abi, + out_dir: cli_build_command_args.out_dir.clone(), + manifest_path: cli_build_command_args.manifest_path.clone(), + color: cli_build_command_args.color.clone(), + } + } else { + build_command::BuildCommand::default() + }; + + if clap_variant.contract_account_id.is_none() { + clap_variant.contract_account_id = match Self::input_contract_account_id(&context) { + Ok(Some(contract_account_id)) => Some(contract_account_id), + Ok(None) => return interactive_clap::ResultFromCli::Cancel(Some(clap_variant)), + Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err), + }; + } + let contract_account_id = clap_variant + .contract_account_id + .clone() + .expect("Unexpected error"); + + let file_path = match build_command::build::run(build_command_args.clone()) { + Ok(compilation_artifact) => compilation_artifact.path, + Err(err) => { + return interactive_clap::ResultFromCli::Err( + Some(clap_variant), + color_eyre::eyre::eyre!(err), + ) + } + }; + + let new_context_scope = InteractiveClapContextScopeForContract { + build_command_args, + file_path: file_path.into(), + contract_account_id, + }; + + let output_context = + match ContractContext::from_previous_context(context, &new_context_scope) { + Ok(new_context) => new_context, + Err(err) => return interactive_clap::ResultFromCli::Err(Some(clap_variant), err), + }; + + match InitializeMode::from_cli(clap_variant.initialize.take(), output_context.into()) { + interactive_clap::ResultFromCli::Ok(initialize) => { + clap_variant.initialize = Some(initialize); + interactive_clap::ResultFromCli::Ok(clap_variant) + } + interactive_clap::ResultFromCli::Cancel(optional_initialize) => { + clap_variant.initialize = optional_initialize; + interactive_clap::ResultFromCli::Cancel(Some(clap_variant)) + } + interactive_clap::ResultFromCli::Back => interactive_clap::ResultFromCli::Back, + interactive_clap::ResultFromCli::Err(optional_initialize, err) => { + clap_variant.initialize = optional_initialize; + interactive_clap::ResultFromCli::Err(Some(clap_variant), err) + } + } + } +} + +impl Contract { + #[allow(dead_code)] + fn input_build_command_args( + _context: &near_cli_rs::GlobalContext, + ) -> color_eyre::eyre::Result> { + Ok(None) + } + + pub fn input_contract_account_id( + context: &near_cli_rs::GlobalContext, + ) -> color_eyre::eyre::Result> { + near_cli_rs::common::input_signer_account_id_from_used_account_list( + &context.config.credentials_home_dir, + "What is the contract account ID?", + ) + } +} diff --git a/cargo-near/src/commands/mod.rs b/cargo-near/src/commands/mod.rs index f06a42a8..2ef1f5e2 100644 --- a/cargo-near/src/commands/mod.rs +++ b/cargo-near/src/commands/mod.rs @@ -3,6 +3,7 @@ use strum::{EnumDiscriminants, EnumIter, EnumMessage}; pub mod abi_command; pub mod build_command; pub mod create_dev_account; +pub mod deploy; #[derive(Debug, EnumDiscriminants, Clone, interactive_clap::InteractiveClap)] #[interactive_clap(context = near_cli_rs::GlobalContext)] @@ -28,4 +29,7 @@ pub enum NearCommand { ))] /// Create a development account using the faucet service sponsor to cover the cost of creating an account (testnet only for now) CreateDevAccount(self::create_dev_account::CreateAccount), + #[strum_discriminants(strum(message = "deploy - Add a new contract code"))] + /// Add a new contract code + Deploy(self::deploy::Contract), } diff --git a/cargo-near/src/types/utf8_path_buf.rs b/cargo-near/src/types/utf8_path_buf.rs index 70c86fea..c9e7721f 100644 --- a/cargo-near/src/types/utf8_path_buf.rs +++ b/cargo-near/src/types/utf8_path_buf.rs @@ -1,3 +1,5 @@ +use color_eyre::eyre::Context; + #[derive( Debug, Default, @@ -19,3 +21,10 @@ impl std::fmt::Display for Utf8PathBufInner { impl interactive_clap::ToCli for Utf8PathBufInner { type CliVariant = Utf8PathBufInner; } + +impl Utf8PathBufInner { + pub fn read_bytes(&self) -> color_eyre::Result> { + std::fs::read(self.0.clone().into_std_path_buf()) + .wrap_err_with(|| format!("Error reading data from file: {:?}", self.0)) + } +} diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index dddd7a17..15688551 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -68,6 +68,7 @@ macro_rules! invoke_cargo_near { cargo_near::commands::build_command::build::run(args)?; }, Some(cargo_near::commands::CliNearCommand::CreateDevAccount(_)) => todo!(), + Some(cargo_near::commands::CliNearCommand::Deploy(_)) => todo!(), None => () } From 7cf1e5f2d72c60c6f9f63de9c6485f1360b5296f Mon Sep 17 00:00:00 2001 From: FroVolod Date: Fri, 13 Oct 2023 13:14:47 +0300 Subject: [PATCH 2/5] clippy --- cargo-near/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cargo-near/src/lib.rs b/cargo-near/src/lib.rs index d8acc010..9e99e766 100644 --- a/cargo-near/src/lib.rs +++ b/cargo-near/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::large_enum_variant)] + pub use near_cli_rs::CliResult; use strum::{EnumDiscriminants, EnumIter, EnumMessage}; From 519f45d5412c57118a3a7131f04f8048f56cd99d Mon Sep 17 00:00:00 2001 From: FroVolod Date: Wed, 18 Oct 2023 09:20:45 +0300 Subject: [PATCH 3/5] updated near-cli-rs to 0.6.2 --- Cargo.lock | 5 +++-- cargo-near/Cargo.toml | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3efd4465..f3cadafe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2837,8 +2837,9 @@ dependencies = [ [[package]] name = "near-cli-rs" -version = "0.6.1" -source = "git+https://github.com/near/near-cli-rs?rev=5d3a05876b58b910dfbf509bf39ef5f46b543436#5d3a05876b58b910dfbf509bf39ef5f46b543436" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c80aaad38d0bf04a9056ca97d1f46e8b052b7a9a8b9f4af1f417c07b8f56e25" dependencies = [ "bip39", "bs58 0.5.0", diff --git a/cargo-near/Cargo.toml b/cargo-near/Cargo.toml index 9b57c1cb..a326a927 100644 --- a/cargo-near/Cargo.toml +++ b/cargo-near/Cargo.toml @@ -43,8 +43,7 @@ derive_more = "0.99.9" shell-words = "1.0.0" interactive-clap = "0.2.7" interactive-clap-derive = "0.2.7" -near-cli-rs = { git = "https://github.com/near/near-cli-rs", rev = "5d3a05876b58b910dfbf509bf39ef5f46b543436" } - +near-cli-rs = { version = "0.6.2" } near-crypto = "0.17.0" near-primitives = "0.17.0" near-jsonrpc-client = "0.6.0" From 04f48ec691b797307b957fca529a5dcf6ed97c38 Mon Sep 17 00:00:00 2001 From: FroVolod Date: Wed, 18 Oct 2023 10:22:52 +0300 Subject: [PATCH 4/5] refactored Contract --- cargo-near/src/commands/deploy/mod.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/cargo-near/src/commands/deploy/mod.rs b/cargo-near/src/commands/deploy/mod.rs index 049f5676..a745e5b0 100644 --- a/cargo-near/src/commands/deploy/mod.rs +++ b/cargo-near/src/commands/deploy/mod.rs @@ -14,9 +14,6 @@ pub struct Contract { #[interactive_clap(skip_default_input_arg)] /// What is the contract account ID? contract_account_id: near_cli_rs::types::account_id::AccountId, - #[allow(dead_code)] - #[interactive_clap(skip)] - file_path: crate::types::utf8_path_buf::Utf8PathBufInner, #[interactive_clap(subcommand)] initialize: InitializeMode, } @@ -29,12 +26,13 @@ impl ContractContext { previous_context: near_cli_rs::GlobalContext, scope: &::InteractiveClapContextScope, ) -> color_eyre::eyre::Result { + let file_path = build_command::build::run(scope.build_command_args.clone())?.path; Ok(Self( near_cli_rs::commands::contract::deploy::ContractFileContext { global_context: previous_context, receiver_account_id: scope.contract_account_id.clone().into(), signer_account_id: scope.contract_account_id.clone().into(), - code: scope.file_path.read_bytes()?, + code: std::fs::read(file_path)?, }, )) } @@ -88,19 +86,8 @@ impl interactive_clap::FromCli for Contract { .clone() .expect("Unexpected error"); - let file_path = match build_command::build::run(build_command_args.clone()) { - Ok(compilation_artifact) => compilation_artifact.path, - Err(err) => { - return interactive_clap::ResultFromCli::Err( - Some(clap_variant), - color_eyre::eyre::eyre!(err), - ) - } - }; - let new_context_scope = InteractiveClapContextScopeForContract { build_command_args, - file_path: file_path.into(), contract_account_id, }; From 01f09c1d2383c5417e60b0e5120d9217bce23ee1 Mon Sep 17 00:00:00 2001 From: FroVolod Date: Thu, 19 Oct 2023 11:28:36 +0300 Subject: [PATCH 5/5] removed input_build_command_args() --- cargo-near/src/commands/deploy/mod.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cargo-near/src/commands/deploy/mod.rs b/cargo-near/src/commands/deploy/mod.rs index a745e5b0..e561eb6e 100644 --- a/cargo-near/src/commands/deploy/mod.rs +++ b/cargo-near/src/commands/deploy/mod.rs @@ -116,13 +116,6 @@ impl interactive_clap::FromCli for Contract { } impl Contract { - #[allow(dead_code)] - fn input_build_command_args( - _context: &near_cli_rs::GlobalContext, - ) -> color_eyre::eyre::Result> { - Ok(None) - } - pub fn input_contract_account_id( context: &near_cli_rs::GlobalContext, ) -> color_eyre::eyre::Result> {