diff --git a/Cargo.lock b/Cargo.lock index 50f907130f..40e9c164a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,7 @@ dependencies = [ "log", "mime", "percent-encoding", - "pin-project 1.0.2", + "pin-project 1.0.3", "rand 0.7.3", "regex", "serde", @@ -310,7 +310,7 @@ dependencies = [ "log", "mime", "openssl", - "pin-project 1.0.2", + "pin-project 1.0.3", "regex", "rustls", "serde", @@ -346,9 +346,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli", ] @@ -376,9 +376,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4" +checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" [[package]] name = "arrayref" @@ -554,34 +554,13 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.3", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -619,12 +598,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.3.4" @@ -725,7 +698,7 @@ dependencies = [ "indexmap", "lazy_static", "os_str_bytes", - "strsim 0.10.0", + "strsim", "termcolor", "textwrap", "unicode-width", @@ -824,9 +797,9 @@ dependencies = [ [[package]] name = "console" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a50aab2529019abfabfa93f1e6c41ef392f91fbf179b347a7e96abb524884a08" +checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa" dependencies = [ "encode_unicode", "lazy_static", @@ -835,24 +808,13 @@ dependencies = [ "terminal_size", "unicode-width", "winapi 0.3.9", - "winapi-util", -] - -[[package]] -name = "console_error_panic_hook" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211" -dependencies = [ - "cfg-if 0.1.10", - "wasm-bindgen", ] [[package]] name = "const_fn" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "constant_time_eq" @@ -1026,6 +988,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "ctrlc" version = "3.1.7" @@ -1044,9 +1012,9 @@ checksum = "da251be9c00cade565f17c1ce87232ad626e32c506774288ca4970094642693d" [[package]] name = "derivative" -version = "2.1.1" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183" dependencies = [ "proc-macro2", "quote", @@ -1153,22 +1121,13 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.3", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array", ] [[package]] @@ -1215,18 +1174,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "docopt" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f525a586d310c87df72ebcd98009e57f1cc030c8c268305287a476beb653969" -dependencies = [ - "lazy_static", - "regex", - "serde", - "strsim 0.9.3", -] - [[package]] name = "downcast" version = "0.10.0" @@ -1235,9 +1182,9 @@ checksum = "4bb454f0228b18c7f4c3b0ebbee346ed9c52e7443b0999cd543ff3571205701d" [[package]] name = "dtoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" [[package]] name = "either" @@ -1296,9 +1243,9 @@ dependencies = [ [[package]] name = "erased-serde" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ca8b296792113e1500fd935ae487be6e00ce318952a6880555554824d6ebf38" +checksum = "0465971a8cc1fa2455c8465aaa377131e1f1cf4983280f474a13e68793aa770c" dependencies = [ "serde", ] @@ -1315,12 +1262,6 @@ dependencies = [ "syn", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "filetime" version = "0.2.13" @@ -1507,7 +1448,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project 1.0.2", + "pin-project 1.0.3", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1523,15 +1464,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.4" @@ -1544,11 +1476,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -1593,9 +1525,9 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] @@ -1628,9 +1560,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26" dependencies = [ "bytes", "fnv", @@ -1690,7 +1622,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.2", + "pin-project 1.0.3", "socket2", "tokio", "tower-service", @@ -1730,7 +1662,7 @@ dependencies = [ [[package]] name = "ic-agent" version = "0.1.0" -source = "git+https://github.com/dfinity/agent-rs.git?branch=next#5d6ed55236641c136c941707c751b020822cee16" +source = "git+https://github.com/dfinity/agent-rs.git?branch=pshahi/update-create-settings#b7041cb63e06a81a2b99800b439bb366b9000a05" dependencies = [ "async-trait", "base32", @@ -1760,7 +1692,7 @@ dependencies = [ [[package]] name = "ic-identity-hsm" version = "0.1.0" -source = "git+https://github.com/dfinity/agent-rs.git?branch=next#5d6ed55236641c136c941707c751b020822cee16" +source = "git+https://github.com/dfinity/agent-rs.git?branch=pshahi/update-create-settings#b7041cb63e06a81a2b99800b439bb366b9000a05" dependencies = [ "hex", "ic-agent", @@ -1775,19 +1707,19 @@ dependencies = [ [[package]] name = "ic-types" version = "0.1.2" -source = "git+https://github.com/dfinity/agent-rs.git?branch=next#edfbf7ee3c4f03b09f43e8bcccdeb4e13929dd27" +source = "git+https://github.com/dfinity/agent-rs.git?branch=pshahi/update-create-settings#b7041cb63e06a81a2b99800b439bb366b9000a05" dependencies = [ "base32", "crc32fast", "serde", - "sha2 0.9.2", + "sha2", "thiserror", ] [[package]] name = "ic-utils" version = "0.1.0" -source = "git+https://github.com/dfinity/agent-rs.git?branch=next#5d6ed55236641c136c941707c751b020822cee16" +source = "git+https://github.com/dfinity/agent-rs.git?branch=pshahi/update-create-settings#b7041cb63e06a81a2b99800b439bb366b9000a05" dependencies = [ "async-trait", "candid", @@ -1811,9 +1743,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg 1.0.1", "hashbrown", @@ -1825,7 +1757,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8572bccfb0665e70b7faf44ee28841b8e0823450cd4ad562a76b5a3c4bf48487" dependencies = [ - "console 0.13.0", + "console 0.14.0", "lazy_static", "number_prefix", "regex", @@ -1878,9 +1810,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" @@ -1903,34 +1835,35 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.19.1" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60fb56191fb8ed5311597e5750debe6779c9fdb487dbaa5ff302592897d7a2c8" +checksum = "5c64e04d8ea9c95c2135dfc4298088eafaf956bc90ba372eb1bea4f715634587" dependencies = [ "ascii-canvas", "atty", "bit-set", "diff", - "docopt", "ena", "itertools", "lalrpop-util", "petgraph", + "pico-args", "regex", "regex-syntax", - "serde", - "serde_derive", - "sha2 0.8.2", "string_cache", "term 0.5.2", + "tiny-keccak", "unicode-xid", ] [[package]] name = "lalrpop-util" -version = "0.19.1" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6771161eff561647fad8bb7e745e002c304864fb8f436b52b30acda51fca4408" +checksum = "f9de203e2fa3e883364fcc778a1293ab4d936f6cff400433013c20105df178c5" +dependencies = [ + "regex", +] [[package]] name = "language-tags" @@ -1958,9 +1891,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" [[package]] name = "libflate" @@ -2198,9 +2131,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" dependencies = [ "lazy_static", "libc", @@ -2350,12 +2283,6 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -2364,9 +2291,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.31" +version = "0.10.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d008f51b1acffa0d3450a68606e6a51c123012edaacb0f4e1426bd978869187" +checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -2384,9 +2311,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.59" +version = "0.9.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe" +checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" dependencies = [ "autocfg 1.0.1", "cc", @@ -2414,9 +2341,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" dependencies = [ "cfg-if 1.0.0", "instant", @@ -2479,6 +2406,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1" + [[package]] name = "pin-project" version = "0.4.27" @@ -2490,11 +2423,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" +checksum = "5a83804639aad6ba65345661744708855f9fbcb71176ea8d28d05aeb11d975e7" dependencies = [ - "pin-project-internal 1.0.2", + "pin-project-internal 1.0.3", ] [[package]] @@ -2510,9 +2443,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" +checksum = "b7bcc46b8f73443d15bc1c5fecbb315718491fa9187fa483f0e359323cde8b3a" dependencies = [ "proc-macro2", "quote", @@ -2527,9 +2460,9 @@ checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" [[package]] name = "pin-project-lite" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "e36743d754ccdf9954c2e352ce2d4b106e024c814f6499c2dadff80da9a442d8" [[package]] name = "pin-utils" @@ -2567,9 +2500,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "predicates" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a" +checksum = "73dd9b7b200044694dfede9edf907c1ca19630908443e9447e624993700c6932" dependencies = [ "difference", "float-cmp", @@ -2580,15 +2513,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +checksum = "fb3dbeaaf793584e29c58c7e3a82bbb3c7c06b63cea68d13b0e3cddc124104dc" [[package]] name = "predicates-tree" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +checksum = "aee95d988ee893cb35c06b148c80ed2cd52c8eea927f50ba7a0be1a786aeab73" dependencies = [ "predicates-core", "treeline", @@ -2686,9 +2619,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -2920,9 +2853,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.10.9" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce" +checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c" dependencies = [ "base64 0.13.0", "bytes", @@ -2942,7 +2875,7 @@ dependencies = [ "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite 0.2.0", + "pin-project-lite 0.2.1", "rustls", "serde", "serde_json", @@ -2953,7 +2886,6 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-bindgen-test", "web-sys", "webpki-roots", "winreg 0.7.0", @@ -3067,12 +2999,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" @@ -3168,9 +3094,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "itoa", "ryu", @@ -3218,11 +3144,11 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce3cdf1b5e620a498ee6f2a171885ac7e22f0e12089ec4b3d22b84921792507c" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -3231,29 +3157,17 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha2" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if 1.0.0", "cpuid-bool", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest", + "opaque-debug", ] [[package]] @@ -3264,9 +3178,9 @@ checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" [[package]] name = "signal-hook-registry" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ "libc", ] @@ -3327,19 +3241,18 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" +checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" [[package]] name = "socket2" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] @@ -3351,9 +3264,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "standback" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8" +checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0" dependencies = [ "version_check 0.9.2", ] @@ -3417,15 +3330,8 @@ dependencies = [ "new_debug_unreachable", "phf_shared", "precomputed-hash", - "serde", ] -[[package]] -name = "strsim" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" - [[package]] name = "strsim" version = "0.10.0" @@ -3434,9 +3340,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.54" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" +checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" dependencies = [ "proc-macro2", "quote", @@ -3548,18 +3454,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2", "quote", @@ -3633,6 +3539,15 @@ dependencies = [ "syn", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" version = "1.1.0" @@ -3719,9 +3634,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] @@ -3740,7 +3655,7 @@ checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.0", + "pin-project-lite 0.2.1", "tracing-core", ] @@ -4062,30 +3977,6 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" -[[package]] -name = "wasm-bindgen-test" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "wasmparser" version = "0.45.2" diff --git a/Cargo.toml b/Cargo.toml index 51de49590c..4645dbad6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,23 +6,23 @@ members = [ [patch.crates-io.ic-agent] version = "0.1.0" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [patch.crates-io.ic-identity-hsm] version = "0.1.0" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [patch.crates-io.ic-types] version = "0.1.2" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [patch.crates-io.ic-utils] version = "0.1.0" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" diff --git a/e2e/bats/controller.bash b/e2e/bats/update_settings.bash similarity index 68% rename from e2e/bats/controller.bash rename to e2e/bats/update_settings.bash index 65f869d6f6..bb5840cba2 100644 --- a/e2e/bats/controller.bash +++ b/e2e/bats/update_settings.bash @@ -18,7 +18,7 @@ teardown() { rm -rf $(pwd)/home-for-test } -@test "set controller" { +@test "update controller" { # Create two identities and get their Principals assert_command dfx identity new jose assert_command dfx identity new juana @@ -34,8 +34,8 @@ teardown() { ID=$(dfx canister id hello) # Set controller using canister name and identity name - assert_command dfx canister set-controller hello juana - assert_match "Set \"juana\" as controller of \"hello\"." + assert_command dfx canister update-settings hello --controller juana + assert_match "Updated \"juana\" as controller of \"hello\"." # Juana is controller, Jose cannot reinstall assert_command_fail dfx canister install hello -m reinstall @@ -51,22 +51,22 @@ teardown() { assert_command dfx identity use juana # Set controller using canister id and principal - assert_command dfx canister set-controller ${ID} ${JOSE_PRINCIPAL} - assert_match "Set \"${JOSE_PRINCIPAL}\" as controller of \"${ID}\"." + assert_command dfx canister update-settings ${ID} --controller ${JOSE_PRINCIPAL} + assert_match "Updated \"${JOSE_PRINCIPAL}\" as controller of \"${ID}\"." assert_command_fail dfx canister install hello -m reinstall # Set controller using combination of name/id and identity/principal - assert_command dfx --identity jose canister set-controller hello ${JUANA_PRINCIPAL} - assert_match "Set \"${JUANA_PRINCIPAL}\" as controller of \"hello\"." + assert_command dfx --identity jose canister update-settings hello --controller ${JUANA_PRINCIPAL} + assert_match "Updated \"${JUANA_PRINCIPAL}\" as controller of \"hello\"." - assert_command dfx --identity juana canister set-controller ${ID} jose - assert_match "Set \"jose\" as controller of \"${ID}\"." + assert_command dfx --identity juana canister update-settings ${ID} --controller jose + assert_match "Updated \"jose\" as controller of \"${ID}\"." # Set controller using invalid principal/identity fails - assert_command_fail dfx --identity jose canister set-controller hello bob + assert_command_fail dfx --identity jose canister update-settings hello --controller bob assert_match "Identity bob does not exist" # Set controller using invalid canister name/id fails - assert_command_fail dfx --identity jose canister set-controller hello_assets juana + assert_command_fail dfx --identity jose canister update-settings hello_assets --controller juana assert_match "Cannot find canister id. Please issue 'dfx canister create hello_assets'." } diff --git a/nix/sources.json b/nix/sources.json index 750bc424f4..c680da1f37 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -45,8 +45,8 @@ }, "ic-ref": { "repo": "ssh://git@github.com/dfinity-lab/ic-ref", - "rev": "4f4e3a151b621b902e44e18a860c20493698abc4", - "tag": "0.14.0", + "rev": "54e08f4e65c49f59caf7b18bd8874275436874e8", + "branch": "joachim/impl-settings", "type": "git" }, "motoko": { diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index bcb9117a81..f8de38333e 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -71,26 +71,26 @@ wasmparser = "0.45.0" [dependencies.ic-agent] version = "0.1.0" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [dependencies.ic-identity-hsm] version = "0.1.0" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [dependencies.ic-types] version = "0.1.2" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [dependencies.ic-utils] version = "0.1.0" git = "https://github.com/dfinity/agent-rs.git" -branch = "next" -rev = "5d6ed55236641c136c941707c751b020822cee16" +branch = "pshahi/update-create-settings" +rev = "7e098b2bb4877c98f31588acc7715c19eb50cc9a" [dev-dependencies] env_logger = "0.6" diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index 1a3c4a951a..7b43028d12 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -1,11 +1,18 @@ +use crate::config::dfinity::ConfigInterface; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; +use crate::lib::identity::identity_manager::IdentityManager; use crate::lib::operations::canister::create_canister; use crate::lib::root_key::fetch_root_key_if_needed; +use crate::util::clap::validators::{compute_allocation_validator, memory_allocation_validator}; use crate::util::expiry_duration; -use anyhow::bail; +use anyhow::{anyhow, bail}; use clap::Clap; +use humanize_rs::bytes::Bytes; +use ic_types::principal::Principal as CanisterId; +use ic_utils::interfaces::management_canister::attributes::{ComputeAllocation, MemoryAllocation}; +use std::convert::TryFrom; /// Creates an empty canister on the Internet Computer and /// associates the Internet Computer assigned Canister ID to the canister name. @@ -17,6 +24,44 @@ pub struct CanisterCreateOpts { /// Creates all canisters configured in dfx.json. #[clap(long, required_unless_present("canister-name"))] all: bool, + + /// Specifies the identity name or the principal of the new controller. + controller: Option, + + /// Specifies the canister's compute allocation. This should be a percent in the range [0..100] + #[clap(long, short('c'), validator(compute_allocation_validator))] + compute_allocation: Option, + + /// Specifies how much memory the canister is allowed to use in total. + /// This should be a value in the range [0..256 TB] + #[clap(long, validator(memory_allocation_validator))] + memory_allocation: Option, +} + +fn get_compute_allocation( + compute_allocation: Option, + config_interface: &ConfigInterface, + canister_name: &str, +) -> DfxResult> { + Ok(compute_allocation + .or(config_interface.get_compute_allocation(canister_name)?) + .map(|arg| { + ComputeAllocation::try_from(arg.parse::().unwrap()) + .expect("Compute Allocation must be a percentage.") + })) +} + +fn get_memory_allocation( + memory_allocation: Option, + config_interface: &ConfigInterface, + canister_name: &str, +) -> DfxResult> { + Ok(memory_allocation + .or(config_interface.get_memory_allocation(canister_name)?) + .map(|arg| { + MemoryAllocation::try_from(u64::try_from(arg.parse::().unwrap().size()).unwrap()) + .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") + })) } pub async fn exec(env: &dyn Environment, opts: CanisterCreateOpts) -> DfxResult { @@ -24,14 +69,65 @@ pub async fn exec(env: &dyn Environment, opts: CanisterCreateOpts) -> DfxResult let timeout = expiry_duration(); fetch_root_key_if_needed(env).await?; + let config_interface = config.get_config(); + + let controller = if let Some(controller) = opts.controller { + match CanisterId::from_text(controller.clone()) { + Ok(principal) => Some(principal), + Err(_) => Some( + IdentityManager::new(env)? + .instantiate_identity_from_name(controller.as_str())? + .sender() + .map_err(|err| anyhow!(err))?, + ), + } + } else { + None + }; - if let Some(canister_name) = opts.canister_name.clone() { - create_canister(env, canister_name.as_str(), timeout).await + if let Some(canister_name) = opts.canister_name.as_deref() { + let compute_allocation = get_compute_allocation( + opts.compute_allocation.clone(), + config_interface, + canister_name, + )?; + let memory_allocation = get_memory_allocation( + opts.memory_allocation.clone(), + config_interface, + canister_name, + )?; + create_canister( + env, + canister_name, + timeout, + controller, + compute_allocation, + memory_allocation, + ) + .await } else if opts.all { // Create all canisters. if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - create_canister(env, canister_name, timeout).await?; + let compute_allocation = get_compute_allocation( + opts.compute_allocation.clone(), + config_interface, + canister_name, + )?; + let memory_allocation = get_memory_allocation( + opts.memory_allocation.clone(), + config_interface, + canister_name, + )?; + create_canister( + env, + canister_name, + timeout, + controller.clone(), + compute_allocation, + memory_allocation, + ) + .await?; } } Ok(()) diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index de891fec27..9acaf388b0 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -1,18 +1,14 @@ -use crate::config::dfinity::ConfigInterface; use crate::lib::canister_info::CanisterInfo; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::operations::canister::install_canister; use crate::lib::root_key::fetch_root_key_if_needed; -use crate::util::clap::validators::{compute_allocation_validator, memory_allocation_validator}; use crate::util::{blob_from_arguments, expiry_duration, get_candid_init_type}; use anyhow::{anyhow, bail}; use clap::Clap; -use humanize_rs::bytes::Bytes; -use ic_utils::interfaces::management_canister::{ComputeAllocation, InstallMode, MemoryAllocation}; -use std::convert::TryFrom; +use ic_utils::interfaces::management_canister::builders::InstallMode; use std::str::FromStr; /// Deploys compiled code as a canister on the Internet Computer. @@ -41,41 +37,6 @@ pub struct CanisterInstallOpts { /// Specifies the data type for the argument when making the call using an argument. #[clap(long, requires("argument"), possible_values(&["idl", "raw"]))] argument_type: Option, - - /// Specifies the canister's compute allocation. This should be a percent in the range [0..100] - #[clap(long, short('c'), validator(compute_allocation_validator))] - compute_allocation: Option, - - /// Specifies how much memory the canister is allowed to use in total. - /// This should be a value in the range [0..256 TB] - #[clap(long, validator(memory_allocation_validator))] - memory_allocation: Option, -} - -fn get_compute_allocation( - compute_allocation: Option, - config_interface: &ConfigInterface, - canister_name: &str, -) -> DfxResult> { - Ok(compute_allocation - .or(config_interface.get_compute_allocation(canister_name)?) - .map(|arg| { - ComputeAllocation::try_from(arg.parse::().unwrap()) - .expect("Compute Allocation must be a percentage.") - })) -} - -fn get_memory_allocation( - memory_allocation: Option, - config_interface: &ConfigInterface, - canister_name: &str, -) -> DfxResult> { - Ok(memory_allocation - .or(config_interface.get_memory_allocation(canister_name)?) - .map(|arg| { - MemoryAllocation::try_from(u64::try_from(arg.parse::().unwrap().size()).unwrap()) - .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") - })) } pub async fn exec(env: &dyn Environment, opts: CanisterInstallOpts) -> DfxResult { @@ -87,7 +48,6 @@ pub async fn exec(env: &dyn Environment, opts: CanisterInstallOpts) -> DfxResult fetch_root_key_if_needed(env).await?; - let config_interface = config.get_config(); let mode = InstallMode::from_str(opts.mode.as_str()).map_err(|err| anyhow!(err))?; let canister_id_store = CanisterIdStore::for_env(env)?; @@ -101,28 +61,7 @@ pub async fn exec(env: &dyn Environment, opts: CanisterInstallOpts) -> DfxResult let arg_type = opts.argument_type.as_deref(); let install_args = blob_from_arguments(arguments, arg_type, &init_type)?; - let compute_allocation = get_compute_allocation( - opts.compute_allocation.clone(), - config_interface, - canister_name, - )?; - let memory_allocation = get_memory_allocation( - opts.memory_allocation.clone(), - config_interface, - canister_name, - )?; - - install_canister( - env, - &agent, - &canister_info, - &install_args, - compute_allocation, - mode, - memory_allocation, - timeout, - ) - .await + install_canister(env, &agent, &canister_info, &install_args, mode, timeout).await } else if opts.all { // Install all canisters. if let Some(canisters) = &config.get_config().canisters { @@ -132,28 +71,7 @@ pub async fn exec(env: &dyn Environment, opts: CanisterInstallOpts) -> DfxResult let install_args = []; - let compute_allocation = get_compute_allocation( - opts.compute_allocation.clone(), - config_interface, - canister_name, - )?; - let memory_allocation = get_memory_allocation( - opts.memory_allocation.clone(), - config_interface, - canister_name, - )?; - - install_canister( - env, - &agent, - &canister_info, - &install_args, - compute_allocation, - mode, - memory_allocation, - timeout, - ) - .await?; + install_canister(env, &agent, &canister_info, &install_args, mode, timeout).await?; } } Ok(()) diff --git a/src/dfx/src/commands/canister/mod.rs b/src/dfx/src/commands/canister/mod.rs index c4daf2cb70..1f4d9224c8 100644 --- a/src/dfx/src/commands/canister/mod.rs +++ b/src/dfx/src/commands/canister/mod.rs @@ -11,16 +11,16 @@ mod delete; mod id; mod install; mod request_status; -mod set_controller; mod start; mod status; mod stop; +mod update_settings; /// Manages canisters deployed on a network replica. #[derive(Clap)] #[clap(name("canister"))] pub struct CanisterOpts { - // Override the compute network to connect to. By default, the local network is used. + /// Override the compute network to connect to. By default, the local network is used. #[clap(long)] network: Option, @@ -36,10 +36,10 @@ enum SubCommand { Id(id::CanisterIdOpts), Install(install::CanisterInstallOpts), RequestStatus(request_status::RequestStatusOpts), - SetController(set_controller::SetControllerOpts), Start(start::CanisterStartOpts), Status(status::CanisterStatusOpts), Stop(stop::CanisterStopOpts), + UpdateSettings(update_settings::UpdateSettingsOpts), } pub fn exec(env: &dyn Environment, opts: CanisterOpts) -> DfxResult { @@ -53,10 +53,10 @@ pub fn exec(env: &dyn Environment, opts: CanisterOpts) -> DfxResult { SubCommand::Id(v) => id::exec(&agent_env, v).await, SubCommand::Install(v) => install::exec(&agent_env, v).await, SubCommand::RequestStatus(v) => request_status::exec(&agent_env, v).await, - SubCommand::SetController(v) => set_controller::exec(&agent_env, v).await, SubCommand::Start(v) => start::exec(&agent_env, v).await, SubCommand::Status(v) => status::exec(&agent_env, v).await, SubCommand::Stop(v) => stop::exec(&agent_env, v).await, + SubCommand::UpdateSettings(v) => update_settings::exec(&agent_env, v).await, } }) } diff --git a/src/dfx/src/commands/canister/set_controller.rs b/src/dfx/src/commands/canister/set_controller.rs deleted file mode 100644 index 8bfb3b8b63..0000000000 --- a/src/dfx/src/commands/canister/set_controller.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::lib::environment::Environment; -use crate::lib::error::DfxResult; -use crate::lib::identity::identity_manager::IdentityManager; -use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::root_key::fetch_root_key_if_needed; -use crate::lib::waiter::waiter_with_timeout; -use crate::util::expiry_duration; - -use anyhow::anyhow; -use clap::Clap; -use ic_types::principal::Principal as CanisterId; -use ic_utils::call::AsyncCall; -use ic_utils::interfaces::ManagementCanister; - -/// Sets the provided identity's name or its principal as the -/// new controller of a canister on the Internet Computer network. -#[derive(Clap)] -pub struct SetControllerOpts { - /// Specifies the canister name or the canister identifier for the canister to be controlled. - canister: String, - - /// Specifies the identity name or the principal of the new controller. - new_controller: String, -} - -pub async fn exec(env: &dyn Environment, opts: SetControllerOpts) -> DfxResult { - let canister_id = match CanisterId::from_text(&opts.canister) { - Ok(id) => id, - Err(_) => CanisterIdStore::for_env(env)?.get(&opts.canister)?, - }; - - let controller_principal = match CanisterId::from_text(&opts.new_controller) { - Ok(principal) => principal, - Err(_) => IdentityManager::new(env)? - .instantiate_identity_from_name(&opts.new_controller)? - .sender() - .map_err(|err| anyhow!(err))?, - }; - - let agent = env - .get_agent() - .ok_or_else(|| anyhow!("Cannot get HTTP client from environment."))?; - let timeout = expiry_duration(); - - fetch_root_key_if_needed(env).await?; - - let mgr = ManagementCanister::create(agent); - - mgr.set_controller(&canister_id, &controller_principal) - .call_and_wait(waiter_with_timeout(timeout)) - .await?; - - println!( - "Set {:?} as controller of {:?}.", - opts.new_controller, opts.canister - ); - Ok(()) -} diff --git a/src/dfx/src/commands/canister/update_settings.rs b/src/dfx/src/commands/canister/update_settings.rs new file mode 100644 index 0000000000..94a21da76c --- /dev/null +++ b/src/dfx/src/commands/canister/update_settings.rs @@ -0,0 +1,161 @@ +use crate::config::dfinity::ConfigInterface; +// use crate::lib::canister_info::CanisterInfo; +use crate::lib::environment::Environment; +use crate::lib::error::DfxResult; +use crate::lib::identity::identity_manager::IdentityManager; +use crate::lib::models::canister_id_store::CanisterIdStore; +use crate::lib::root_key::fetch_root_key_if_needed; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::clap::validators::{compute_allocation_validator, memory_allocation_validator}; +use crate::util::expiry_duration; + +use anyhow::{anyhow, bail}; +use clap::Clap; +use humanize_rs::bytes::Bytes; +use ic_types::principal::Principal as CanisterId; +use ic_utils::interfaces::management_canister::attributes::{ComputeAllocation, MemoryAllocation}; +use ic_utils::interfaces::ManagementCanister; +use std::convert::TryFrom; + +/// Update one or more of a canisters settings (i.e its controller, compute allocation, or memory allocation.) +#[derive(Clap)] +pub struct UpdateSettingsOpts { + /// Specifies the canister name to update. You must specify either canister name or the --all option. + canister_name: Option, + + /// Updates the settings of all canisters configured in the project dfx.json files. + #[clap(long, required_unless_present("canister-name"))] + all: bool, + + /// Specifies the identity name or the principal of the new controller. + #[clap(long)] + controller: Option, + + /// Specifies the canister's compute allocation. This should be a percent in the range [0..100] + #[clap(long, short('c'), validator(compute_allocation_validator))] + compute_allocation: Option, + + /// Specifies how much memory the canister is allowed to use in total. + /// This should be a value in the range [0..256 TB] + #[clap(long, validator(memory_allocation_validator))] + memory_allocation: Option, +} + +fn get_compute_allocation( + compute_allocation: Option, + config_interface: &ConfigInterface, + canister_name: &str, +) -> DfxResult> { + Ok(compute_allocation + .or(config_interface.get_compute_allocation(canister_name)?) + .map(|arg| { + ComputeAllocation::try_from(arg.parse::().unwrap()) + .expect("Compute Allocation must be a percentage.") + })) +} + +fn get_memory_allocation( + memory_allocation: Option, + config_interface: &ConfigInterface, + canister_name: &str, +) -> DfxResult> { + Ok(memory_allocation + .or(config_interface.get_memory_allocation(canister_name)?) + .map(|arg| { + MemoryAllocation::try_from(u64::try_from(arg.parse::().unwrap().size()).unwrap()) + .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") + })) +} + +pub async fn exec(env: &dyn Environment, opts: UpdateSettingsOpts) -> DfxResult { + let config = env.get_config_or_anyhow()?; + let timeout = expiry_duration(); + let agent = env + .get_agent() + .ok_or_else(|| anyhow!("Cannot get HTTP client from environment."))?; + let config_interface = config.get_config(); + fetch_root_key_if_needed(env).await?; + + let controller = if let Some(controller) = opts.controller.clone() { + match CanisterId::from_text(controller.clone()) { + Ok(principal) => Some(principal), + Err(_) => Some( + IdentityManager::new(env)? + .instantiate_identity_from_name(controller.as_str())? + .sender() + .map_err(|err| anyhow!(err))?, + ), + } + } else { + None + }; + + let mgr = ManagementCanister::create(agent); + let canister_id_store = CanisterIdStore::for_env(env)?; + + if let Some(canister_name_or_id) = opts.canister_name.as_deref() { + let canister_id = match CanisterId::from_text(canister_name_or_id) { + Ok(id) => id, + Err(_) => canister_id_store.get(canister_name_or_id)?, + }; + let textual_cid = canister_id.to_text(); + let canister_name = canister_id_store + .get_name(&textual_cid) + .ok_or_else(|| anyhow!("Cannot find canister name for id '{}'.", textual_cid))?; + let compute_allocation = get_compute_allocation( + opts.compute_allocation.clone(), + config_interface, + canister_name, + )?; + let memory_allocation = get_memory_allocation( + opts.memory_allocation.clone(), + config_interface, + canister_name, + )?; + mgr.update_canister_settings(&canister_id) + .with_optional_controller(controller.clone()) + .with_optional_compute_allocation(compute_allocation) + .with_optional_memory_allocation(memory_allocation) + .call_and_wait(waiter_with_timeout(timeout)) + .await?; + if let Some(new_controller) = opts.controller.clone() { + println!( + "Updated {:?} as controller of {:?}.", + new_controller, canister_name_or_id + ); + }; + } else if opts.all { + // Update all canister settings. + if let Some(canisters) = &config.get_config().canisters { + for canister_name in canisters.keys() { + let canister_id = canister_id_store.get(canister_name)?; + let compute_allocation = get_compute_allocation( + opts.compute_allocation.clone(), + config_interface, + canister_name, + )?; + let memory_allocation = get_memory_allocation( + opts.memory_allocation.clone(), + config_interface, + canister_name, + )?; + mgr.update_canister_settings(&canister_id) + .with_optional_controller(controller.clone()) + .with_optional_compute_allocation(compute_allocation) + .with_optional_memory_allocation(memory_allocation) + .call_and_wait(waiter_with_timeout(timeout)) + .await?; + if let Some(new_controller) = opts.controller.clone() { + println!( + "Updated {:?} as controller of {:?}.", + new_controller, canister_name + ); + }; + } + } + } else { + bail!("Cannot find canister name.") + } + + Ok(()) +} diff --git a/src/dfx/src/commands/new.rs b/src/dfx/src/commands/new.rs index 9ee4b9653c..679aafba16 100644 --- a/src/dfx/src/commands/new.rs +++ b/src/dfx/src/commands/new.rs @@ -322,23 +322,8 @@ pub fn exec(env: &dyn Environment, opts: NewOpts) -> DfxResult { // Any version that contains a `-` is a local build. // TODO: when adding alpha/beta, take that into account. // TODO: move this to a Version type. - let is_dirty = dfx_version_str().contains('-'); - - let js_agent_version = if is_dirty { - // file!() returns a path like `src/dfx/src/commands/new.rs`, but since we are - // running from a directory outside the source tree, this does not help. - let agent_path = std::env::current_exe()? - .parent() - .unwrap() - .join("../../src/agent/javascript"); - agent_path - .canonicalize() - .context("Cannot canonicalize agent path.")? - .to_string_lossy() - .to_string() - } else { - dfx_version_str().to_owned() - }; + + let js_agent_version = dfx_version_str().to_owned(); let variables: BTreeMap = [ ("project_name".to_string(), project_name_str.to_string()), diff --git a/src/dfx/src/lib/operations/canister/create_canister.rs b/src/dfx/src/lib/operations/canister/create_canister.rs index f86b470607..a49e5f398d 100644 --- a/src/dfx/src/lib/operations/canister/create_canister.rs +++ b/src/dfx/src/lib/operations/canister/create_canister.rs @@ -5,7 +5,8 @@ use crate::lib::provider::get_network_context; use crate::lib::waiter::waiter_with_timeout; use anyhow::anyhow; -use ic_utils::call::AsyncCall; +use ic_types::principal::Principal; +use ic_utils::interfaces::management_canister::attributes::{ComputeAllocation, MemoryAllocation}; use ic_utils::interfaces::ManagementCanister; use slog::info; use std::format; @@ -15,6 +16,9 @@ pub async fn create_canister( env: &dyn Environment, canister_name: &str, timeout: Duration, + controller: Option, + compute_allocation: Option, + memory_allocation: Option, ) -> DfxResult { let log = env.get_logger(); info!(log, "Creating canister {:?}...", canister_name); @@ -49,6 +53,9 @@ pub async fn create_canister( let mgr = ManagementCanister::create(agent); let (cid,) = mgr .create_canister() + .with_optional_controller(controller) + .with_optional_compute_allocation(compute_allocation) + .with_optional_memory_allocation(memory_allocation) .call_and_wait(waiter_with_timeout(timeout)) .await?; let canister_id = cid.to_text(); diff --git a/src/dfx/src/lib/operations/canister/deploy_canisters.rs b/src/dfx/src/lib/operations/canister/deploy_canisters.rs index 54e8353555..3652709389 100644 --- a/src/dfx/src/lib/operations/canister/deploy_canisters.rs +++ b/src/dfx/src/lib/operations/canister/deploy_canisters.rs @@ -12,7 +12,8 @@ use crate::util::{blob_from_arguments, get_candid_init_type}; use anyhow::anyhow; use humanize_rs::bytes::Bytes; use ic_agent::AgentError; -use ic_utils::interfaces::management_canister::{ComputeAllocation, InstallMode, MemoryAllocation}; +use ic_utils::interfaces::management_canister::attributes::{ComputeAllocation, MemoryAllocation}; +use ic_utils::interfaces::management_canister::builders::InstallMode; use slog::{info, warn}; use std::convert::TryFrom; use std::time::Duration; @@ -38,7 +39,14 @@ pub async fn deploy_canisters( info!(log, "Deploying all canisters."); } - register_canisters(env, &canister_names, &initial_canister_id_store, timeout).await?; + register_canisters( + env, + &canister_names, + &initial_canister_id_store, + timeout, + &config, + ) + .await?; build_canisters(env, &canister_names, &config)?; @@ -71,6 +79,7 @@ async fn register_canisters( canister_names: &[String], canister_id_store: &CanisterIdStore, timeout: Duration, + config: &Config, ) -> DfxResult { let canisters_to_create = canister_names .iter() @@ -82,7 +91,35 @@ async fn register_canisters( } else { info!(env.get_logger(), "Creating canisters..."); for canister_name in &canisters_to_create { - create_canister(env, &canister_name, timeout).await?; + let config_interface = config.get_config(); + let compute_allocation = + config_interface + .get_compute_allocation(canister_name)? + .map(|arg| { + ComputeAllocation::try_from(arg.parse::().unwrap()) + .expect("Compute Allocation must be a percentage.") + }); + let memory_allocation = + config_interface + .get_memory_allocation(canister_name)? + .map(|arg| { + MemoryAllocation::try_from( + u64::try_from(arg.parse::().unwrap().size()).unwrap(), + ) + .expect( + "Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.", + ) + }); + let controller = None; + create_canister( + env, + &canister_name, + timeout, + controller, + compute_allocation, + memory_allocation, + ) + .await?; } } Ok(()) @@ -126,31 +163,12 @@ async fn install_canisters( let init_type = maybe_path.and_then(|path| get_candid_init_type(&path)); let install_args = blob_from_arguments(argument, argument_type, &init_type)?; - let config_interface = config.get_config(); - let compute_allocation = - config_interface - .get_compute_allocation(canister_name)? - .map(|arg| { - ComputeAllocation::try_from(arg.parse::().unwrap()) - .expect("Compute Allocation must be a percentage.") - }); - let memory_allocation = config_interface - .get_memory_allocation(canister_name)? - .map(|arg| { - MemoryAllocation::try_from( - u64::try_from(arg.parse::().unwrap().size()).unwrap(), - ) - .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") - }); - let result = install_canister( env, &agent, &canister_info, &install_args, - compute_allocation, first_mode, - memory_allocation, timeout, ) .await; @@ -179,9 +197,7 @@ async fn install_canisters( &agent, &canister_info, &install_args, - compute_allocation, second_mode, - memory_allocation, timeout, ) .await diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index e13225fa93..0598cfc747 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -7,7 +7,7 @@ use crate::lib::waiter::waiter_with_timeout; use anyhow::Context; use ic_agent::Agent; use ic_utils::call::AsyncCall; -use ic_utils::interfaces::management_canister::*; +use ic_utils::interfaces::management_canister::builders::InstallMode; use ic_utils::interfaces::ManagementCanister; use slog::info; use std::time::Duration; @@ -18,9 +18,7 @@ pub async fn install_canister( agent: &Agent, canister_info: &CanisterInfo, args: &[u8], - compute_allocation: Option, mode: InstallMode, - memory_allocation: Option, timeout: Duration, ) -> DfxResult { let mgr = ManagementCanister::create(agent); @@ -46,17 +44,6 @@ pub async fn install_canister( .with_raw_arg(args.to_vec()) .with_mode(mode); - let install_builder = if let Some(ca) = compute_allocation { - install_builder.with_compute_allocation(ca) - } else { - install_builder - }; - let install_builder = if let Some(ma) = memory_allocation { - install_builder.with_memory_allocation(ma) - } else { - install_builder - }; - install_builder .build()? .call_and_wait(waiter_with_timeout(timeout))