From aabae157723c00792b530c8c4bead5a5c4ac9984 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Sun, 13 Oct 2024 10:25:32 +0200 Subject: [PATCH 01/12] feat: make ic-repl work against PocketIC --- .github/workflows/ci.yml | 11 +- Cargo.lock | 550 ++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 + src/exp.rs | 6 +- src/helper.rs | 31 +++ src/utils.rs | 8 +- 6 files changed, 593 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3e578a..65163bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest env: - DFX_VERSION: 0.24.0 + DFX_VERSION: 0.24.1-beta.1 steps: - uses: actions/checkout@v4 - name: Install stable Rust toolchain @@ -38,12 +38,17 @@ jobs: uses: dfinity/setup-dfx@main with: dfx-version: "${{ env.DFX_VERSION }}" - - name: Start replica using dfx + - name: Run e2e tests against replica run: | echo '{}' > dfx.json dfx start --background - - name: e2e tests + set -ex + target/debug/ic-repl examples/install.sh + target/debug/ic-repl examples/func.sh + - name: Run e2e tests against PocketIC run: | + echo '{}' > dfx.json + dfx start --background --pocketic set -ex target/debug/ic-repl examples/install.sh target/debug/ic-repl examples/func.sh diff --git a/Cargo.lock b/Cargo.lock index dd41f70..9280f2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,6 +155,12 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.4.0" @@ -193,6 +199,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.7" @@ -521,6 +533,22 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "core2" version = "0.4.0" @@ -747,6 +775,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ecdsa" version = "0.16.9" @@ -817,6 +851,15 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "endian-type" version = "0.1.2" @@ -829,6 +872,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + [[package]] name = "errno" version = "0.3.9" @@ -940,6 +992,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1088,6 +1155,25 @@ dependencies = [ "subtle", ] +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.6.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "1.8.3" @@ -1225,6 +1311,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2", "http", "http-body", "httparse", @@ -1246,6 +1333,7 @@ dependencies = [ "hyper", "hyper-util", "rustls", + "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -1253,6 +1341,22 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.9" @@ -1314,6 +1418,33 @@ dependencies = [ "url", ] +[[package]] +name = "ic-cdk" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1da6a25b045f9da3c9459c0cb2b0700ac368ee16382975a17185a23b9c18ab" +dependencies = [ + "candid", + "ic-cdk-macros", + "ic0", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-cdk-macros" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45800053d80a6df839a71aaea5797e723188c0b992618208ca3b941350c7355" +dependencies = [ + "candid", + "proc-macro2", + "quote", + "serde", + "serde_tokenstream", + "syn 1.0.109", +] + [[package]] name = "ic-certification" version = "2.6.0" @@ -1364,10 +1495,12 @@ dependencies = [ "libflate", "logos", "pem", + "pocket-ic", "pretty", "pretty_assertions", "qrcode", "rand", + "reqwest", "ring", "rpassword", "rustyline", @@ -1424,6 +1557,12 @@ dependencies = [ "walrus", ] +[[package]] +name = "ic0" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" + [[package]] name = "ic_bls12_381" version = "0.10.0" @@ -1607,7 +1746,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax", + "regex-syntax 0.8.5", "string_cache", "term", "tiny-keccak", @@ -1621,7 +1760,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata", + "regex-automata 0.4.8", ] [[package]] @@ -1728,7 +1867,7 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "regex-syntax", + "regex-syntax 0.8.5", "syn 2.0.79", ] @@ -1741,6 +1880,15 @@ dependencies = [ "logos-codegen", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1753,6 +1901,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -1775,6 +1933,23 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -1814,6 +1989,16 @@ dependencies = [ "libc", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.2.6" @@ -1894,12 +2079,62 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "p256" version = "0.13.2" @@ -2083,6 +2318,12 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "png" version = "0.17.14" @@ -2096,6 +2337,29 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "pocket-ic" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beff607d4dbebff8d003453ced669d2645e905de496ca93713f3d47633357e6c" +dependencies = [ + "base64 0.13.1", + "candid", + "hex", + "ic-cdk", + "reqwest", + "schemars", + "serde", + "serde_bytes", + "serde_json", + "sha2 0.10.8", + "slog", + "tokio", + "tracing", + "tracing-appender", + "tracing-subscriber", +] + [[package]] name = "portable-atomic" version = "1.9.0" @@ -2320,8 +2584,17 @@ checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -2332,9 +2605,15 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -2349,32 +2628,41 @@ checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", + "encoding_rs", "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", + "mime_guess", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", "quinn", "rustls", + "rustls-native-certs", "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls", + "tokio-socks", "tokio-util", "tower-service", "url", @@ -2486,6 +2774,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -2566,6 +2867,39 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.79", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -2586,6 +2920,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.23" @@ -2631,6 +2988,17 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "serde_json" version = "1.0.128" @@ -2663,6 +3031,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_tokenstream" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "797ba1d80299b264f3aac68ab5d12e5825a561749db4df7cd7c8083900c5d4e9" +dependencies = [ + "proc-macro2", + "serde", + "syn 1.0.109", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2699,6 +3078,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shell-words" version = "1.1.0" @@ -2772,6 +3160,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slog" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" +dependencies = [ + "erased-serde", +] + [[package]] name = "smallvec" version = "1.13.2" @@ -2891,6 +3288,27 @@ dependencies = [ "futures-core", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.13.0" @@ -2944,6 +3362,16 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.36" @@ -3028,6 +3456,16 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -3039,6 +3477,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-socks" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -3099,9 +3549,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -3109,6 +3583,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", ] [[package]] @@ -3135,6 +3652,15 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.17" @@ -3197,6 +3723,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" diff --git a/Cargo.toml b/Cargo.toml index 00c4adc..7c75c85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,8 @@ image = { version = "0.24", default-features = false, features = ["png"] } libflate = "2.0" base64 = "0.21" futures = "0.3.30" +pocket-ic = "5.0.0" +reqwest = "0.12.8" [patch.crates-io] ic-agent = { git = "https://github.com/dfinity/agent-rs.git", rev = "a56ccd471d7ca3c9ef5d63b57cc3c05afdcf89da" } diff --git a/src/exp.rs b/src/exp.rs index 8440985..175ddcb 100644 --- a/src/exp.rs +++ b/src/exp.rs @@ -594,7 +594,8 @@ impl Exp { args.to_bytes()? }; let method = &call.method.method; - let effective_id = get_effective_canister_id(info.canister_id, method, &bytes)?; + let effective_id = get_effective_canister_id(info.canister_id, method, &bytes)? + .unwrap_or(helper.default_effective_canister_id); let mut builder = helper.agent.update(&info.canister_id, method); builder = builder .with_arg(bytes) @@ -931,7 +932,8 @@ async fn call( ) -> anyhow::Result { use crate::offline::*; let agent = &helper.agent; - let effective_id = get_effective_canister_id(*canister_id, method, args)?; + let effective_id = get_effective_canister_id(*canister_id, method, args)? + .unwrap_or(helper.default_effective_canister_id); let is_query = opt_func .as_ref() .map(|(_, f)| f.is_query()) diff --git a/src/helper.rs b/src/helper.rs index e524622..28c24d9 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -91,6 +91,7 @@ pub struct MyHelper { pub base_path: std::path::PathBuf, pub messages: RefCell>, pub verbose: bool, + pub default_effective_canister_id: Principal, } impl MyHelper { @@ -113,6 +114,7 @@ impl MyHelper { offline: self.offline.clone(), messages: self.messages.clone(), verbose: self.verbose, + default_effective_canister_id: self.default_effective_canister_id, } } pub fn new( @@ -121,6 +123,34 @@ impl MyHelper { offline: Option, verbose: bool, ) -> Self { + let runtime = Runtime::new().expect("Unable to create a runtime"); + let default_effective_canister_id = runtime + .block_on(async { + let client = reqwest::Client::new(); + let topology: pocket_ic::common::rest::Topology = client + .get(format!( + "{}{}", + agent_url.trim_end_matches('/'), + "/_/topology" + )) + .send() + .await? + .json() + .await?; + let subnet = topology.get_app_subnets().into_iter().next().unwrap_or( + topology + .get_verified_app_subnets() + .into_iter() + .next() + .unwrap_or(topology.get_system_subnets().into_iter().next().unwrap_or_else(|| panic!("PocketIC topology contains no application, verified application, and system subnet."))), + ); + Ok::<_, reqwest::Error>(Principal::from_slice( + &topology.0.get(&subnet).unwrap().canister_ranges[0] + .start + .canister_id, + )) + }) + .unwrap_or(Principal::management_canister()); let mut res = MyHelper { completer: FilenameCompleter::new(), highlighter: MatchingBracketHighlighter::new(), @@ -139,6 +169,7 @@ impl MyHelper { agent_url, offline, verbose, + default_effective_canister_id, }; res.fetch_root_key_if_needed().unwrap(); res.load_prelude().unwrap(); diff --git a/src/utils.rs b/src/utils.rs index f7b6bf7..5bf41b8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -162,7 +162,7 @@ pub fn get_effective_canister_id( canister_id: Principal, method: &str, args: &[u8], -) -> anyhow::Result { +) -> anyhow::Result> { use candid::{CandidType, Decode, Deserialize}; if canister_id == Principal::management_canister() { match method { @@ -170,7 +170,7 @@ pub fn get_effective_canister_id( "{} can only be called via inter-canister call.", method )), - "provisional_create_canister_with_cycles" => Ok(canister_id), + "provisional_create_canister_with_cycles" => Ok(None), _ => { #[derive(CandidType, Deserialize)] struct Arg { @@ -179,11 +179,11 @@ pub fn get_effective_canister_id( let args = Decode!(args, Arg).map_err(|_| { anyhow!("{} can only be called via inter-canister call.", method) })?; - Ok(args.canister_id) + Ok(Some(args.canister_id)) } } } else { - Ok(canister_id) + Ok(Some(canister_id)) } } From bb97ed7a3b71a5ee67be4c3160955340697166fc Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Sun, 13 Oct 2024 10:32:39 +0200 Subject: [PATCH 02/12] lazy --- src/helper.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helper.rs b/src/helper.rs index 28c24d9..acbd812 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -137,12 +137,12 @@ impl MyHelper { .await? .json() .await?; - let subnet = topology.get_app_subnets().into_iter().next().unwrap_or( + let subnet = topology.get_app_subnets().into_iter().next().unwrap_or_else(|| topology .get_verified_app_subnets() .into_iter() .next() - .unwrap_or(topology.get_system_subnets().into_iter().next().unwrap_or_else(|| panic!("PocketIC topology contains no application, verified application, and system subnet."))), + .unwrap_or_else(|| topology.get_system_subnets().into_iter().next().unwrap_or_else(|| panic!("PocketIC topology contains no application, verified application, and system subnet."))), ); Ok::<_, reqwest::Error>(Principal::from_slice( &topology.0.get(&subnet).unwrap().canister_ranges[0] From 3c1e200197eedc6b48af81b42976a90fd3f8317c Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Sun, 13 Oct 2024 10:40:32 +0200 Subject: [PATCH 03/12] dfx stop --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65163bf..cfabc27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: set -ex target/debug/ic-repl examples/install.sh target/debug/ic-repl examples/func.sh + dfx stop - name: Run e2e tests against PocketIC run: | echo '{}' > dfx.json @@ -52,3 +53,4 @@ jobs: set -ex target/debug/ic-repl examples/install.sh target/debug/ic-repl examples/func.sh + dfx stop From fefd8a960225375d0b765878c4fbdab29065a9c6 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Sun, 13 Oct 2024 10:45:14 +0200 Subject: [PATCH 04/12] clean --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfabc27..a0d88cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Run e2e tests against replica run: | echo '{}' > dfx.json - dfx start --background + dfx start --background --clean set -ex target/debug/ic-repl examples/install.sh target/debug/ic-repl examples/func.sh @@ -49,7 +49,7 @@ jobs: - name: Run e2e tests against PocketIC run: | echo '{}' > dfx.json - dfx start --background --pocketic + dfx start --background --clean --pocketic set -ex target/debug/ic-repl examples/install.sh target/debug/ic-repl examples/func.sh From 0b06a102155564fcea80f31b61388a5a35fb6817 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Mon, 14 Oct 2024 11:32:54 +0200 Subject: [PATCH 05/12] use fn get_default_effective_canister_id --- Cargo.lock | 129 +++++++++++++++++++++++++++++++++++++++++++------- Cargo.toml | 2 +- src/helper.rs | 28 ++--------- 3 files changed, 117 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9280f2f..08af949 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1283,6 +1283,17 @@ dependencies = [ "http", ] +[[package]] +name = "http-body-to-bytes" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17a08236c6f51c2ee95d840f45acf8fa9e339390e00b4ef640857b2f2a534d70" +dependencies = [ + "bytes", + "http-body", + "http-body-util", +] + [[package]] name = "http-body-util" version = "0.1.2" @@ -1376,6 +1387,53 @@ dependencies = [ "tracing", ] +[[package]] +name = "ic-agent" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd3fdf5e5c4f4a9fe5ca612f0febd22dcb161d2f2b75b0142326732be5e4978" +dependencies = [ + "async-lock", + "backoff", + "cached", + "candid", + "ed25519-consensus", + "futures-util", + "hex", + "http", + "http-body", + "http-body-to-bytes", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "ic-certification", + "ic-transport-types 0.37.1", + "ic-verify-bls-signature", + "k256", + "leb128", + "p256", + "pem", + "pkcs8", + "rand", + "rangemap", + "reqwest", + "ring", + "rustls-webpki", + "sec1", + "serde", + "serde_bytes", + "serde_cbor", + "serde_repr", + "sha2 0.10.8", + "simple_asn1", + "thiserror", + "time", + "tokio", + "tower", + "url", +] + [[package]] name = "ic-agent" version = "0.38.2" @@ -1392,7 +1450,7 @@ dependencies = [ "http", "http-body", "ic-certification", - "ic-transport-types", + "ic-transport-types 0.38.2", "ic-verify-bls-signature", "k256", "leb128", @@ -1420,9 +1478,9 @@ dependencies = [ [[package]] name = "ic-cdk" -version = "0.13.5" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1da6a25b045f9da3c9459c0cb2b0700ac368ee16382975a17185a23b9c18ab" +checksum = "dd8ecacd682fa05a985253592963306cb9799622d7b1cce4b1edb89c6ec85be1" dependencies = [ "candid", "ic-cdk-macros", @@ -1433,16 +1491,16 @@ dependencies = [ [[package]] name = "ic-cdk-macros" -version = "0.13.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45800053d80a6df839a71aaea5797e723188c0b992618208ca3b941350c7355" +checksum = "0d4d857135deef20cc7ea8f3869a30cd9cfeb1392b3a81043790b2cd82adc3e0" dependencies = [ "candid", "proc-macro2", "quote", "serde", "serde_tokenstream", - "syn 1.0.109", + "syn 2.0.79", ] [[package]] @@ -1463,7 +1521,7 @@ version = "0.38.2" source = "git+https://github.com/dfinity/agent-rs.git?rev=a56ccd471d7ca3c9ef5d63b57cc3c05afdcf89da#a56ccd471d7ca3c9ef5d63b57cc3c05afdcf89da" dependencies = [ "hex", - "ic-agent", + "ic-agent 0.38.2", "pkcs11", "sha2 0.10.8", "simple_asn1", @@ -1484,9 +1542,9 @@ dependencies = [ "crc32fast", "futures", "hex", - "ic-agent", + "ic-agent 0.38.2", "ic-identity-hsm", - "ic-transport-types", + "ic-transport-types 0.38.2", "ic-wasm", "image", "inferno", @@ -1513,6 +1571,23 @@ dependencies = [ "tokio", ] +[[package]] +name = "ic-transport-types" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875dc4704780383112e8e8b5063a1b98de114321d0c7d3e7f635dcf360a57fba" +dependencies = [ + "candid", + "hex", + "ic-certification", + "leb128", + "serde", + "serde_bytes", + "serde_repr", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "ic-transport-types" version = "0.38.2" @@ -1559,9 +1634,9 @@ dependencies = [ [[package]] name = "ic0" -version = "0.21.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" +checksum = "8de254dd67bbd58073e23dc1c8553ba12fa1dc610a19de94ad2bbcd0460c067f" [[package]] name = "ic_bls12_381" @@ -2340,20 +2415,23 @@ dependencies = [ [[package]] name = "pocket-ic" version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beff607d4dbebff8d003453ced669d2645e905de496ca93713f3d47633357e6c" +source = "git+https://github.com/dfinity/ic.git?rev=71161800e87f1659998f2b3d480e12532f7580cc#71161800e87f1659998f2b3d480e12532f7580cc" dependencies = [ "base64 0.13.1", "candid", "hex", + "ic-agent 0.37.1", "ic-cdk", + "ic-transport-types 0.37.1", "reqwest", "schemars", "serde", "serde_bytes", + "serde_cbor", "serde_json", "sha2 0.10.8", "slog", + "thiserror", "tokio", "tracing", "tracing-appender", @@ -3033,13 +3111,14 @@ dependencies = [ [[package]] name = "serde_tokenstream" -version = "0.1.7" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "797ba1d80299b264f3aac68ab5d12e5825a561749db4df7cd7c8083900c5d4e9" +checksum = "64060d864397305347a78851c51588fd283767e7e7589829e8121d65512340f1" dependencies = [ "proc-macro2", + "quote", "serde", - "syn 1.0.109", + "syn 2.0.79", ] [[package]] @@ -3536,6 +3615,23 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.3" @@ -3548,6 +3644,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", diff --git a/Cargo.toml b/Cargo.toml index 7c75c85..324b0b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ image = { version = "0.24", default-features = false, features = ["png"] } libflate = "2.0" base64 = "0.21" futures = "0.3.30" -pocket-ic = "5.0.0" +pocket-ic = { git = "https://github.com/dfinity/ic.git", rev = "71161800e87f1659998f2b3d480e12532f7580cc" } reqwest = "0.12.8" [patch.crates-io] diff --git a/src/helper.rs b/src/helper.rs index acbd812..2b4c279 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -125,31 +125,9 @@ impl MyHelper { ) -> Self { let runtime = Runtime::new().expect("Unable to create a runtime"); let default_effective_canister_id = runtime - .block_on(async { - let client = reqwest::Client::new(); - let topology: pocket_ic::common::rest::Topology = client - .get(format!( - "{}{}", - agent_url.trim_end_matches('/'), - "/_/topology" - )) - .send() - .await? - .json() - .await?; - let subnet = topology.get_app_subnets().into_iter().next().unwrap_or_else(|| - topology - .get_verified_app_subnets() - .into_iter() - .next() - .unwrap_or_else(|| topology.get_system_subnets().into_iter().next().unwrap_or_else(|| panic!("PocketIC topology contains no application, verified application, and system subnet."))), - ); - Ok::<_, reqwest::Error>(Principal::from_slice( - &topology.0.get(&subnet).unwrap().canister_ranges[0] - .start - .canister_id, - )) - }) + .block_on(pocket_ic::nonblocking::get_default_effective_canister_id( + agent_url.clone(), + )) .unwrap_or(Principal::management_canister()); let mut res = MyHelper { completer: FilenameCompleter::new(), From d093cd578be32fc9bb2f867455dcc9b9eedf4317 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Mon, 14 Oct 2024 11:33:50 +0200 Subject: [PATCH 06/12] simplify deps --- Cargo.lock | 144 ----------------------------------------------------- Cargo.toml | 1 - 2 files changed, 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08af949..e63945c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -851,15 +851,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "endian-type" version = "0.1.2" @@ -992,21 +983,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1352,22 +1328,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.9" @@ -1558,7 +1518,6 @@ dependencies = [ "pretty_assertions", "qrcode", "rand", - "reqwest", "ring", "rpassword", "rustyline", @@ -2008,23 +1967,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "native-tls" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -2154,50 +2096,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "openssl" -version = "0.10.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.79", -] - [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-sys" -version = "0.9.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -2393,12 +2297,6 @@ dependencies = [ "spki", ] -[[package]] -name = "pkg-config" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" - [[package]] name = "png" version = "0.17.14" @@ -2706,7 +2604,6 @@ checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", - "encoding_rs", "futures-channel", "futures-core", "futures-util", @@ -2716,14 +2613,12 @@ dependencies = [ "http-body-util", "hyper", "hyper-rustls", - "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", "mime_guess", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -2736,9 +2631,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls", "tokio-socks", "tokio-util", @@ -3367,27 +3260,6 @@ dependencies = [ "futures-core", ] -[[package]] -name = "system-configuration" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" -dependencies = [ - "bitflags 2.6.0", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tempfile" version = "3.13.0" @@ -3535,16 +3407,6 @@ dependencies = [ "syn 2.0.79", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.0" @@ -3826,12 +3688,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.5" diff --git a/Cargo.toml b/Cargo.toml index 324b0b5..787d86d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,6 @@ libflate = "2.0" base64 = "0.21" futures = "0.3.30" pocket-ic = { git = "https://github.com/dfinity/ic.git", rev = "71161800e87f1659998f2b3d480e12532f7580cc" } -reqwest = "0.12.8" [patch.crates-io] ic-agent = { git = "https://github.com/dfinity/agent-rs.git", rev = "a56ccd471d7ca3c9ef5d63b57cc3c05afdcf89da" } From d6965f65a1d3db95d7a6838d71ed6298d92aa7b7 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Fri, 25 Oct 2024 20:43:34 +0200 Subject: [PATCH 07/12] bump dfx --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0d88cf..19b9d9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest env: - DFX_VERSION: 0.24.1-beta.1 + DFX_VERSION: 0.24.2-beta.0 steps: - uses: actions/checkout@v4 - name: Install stable Rust toolchain From ab157dd89ffb36d28378b0f76067ea3a65cabed2 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 19:37:59 +0100 Subject: [PATCH 08/12] dfx version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19b9d9f..a38495a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest env: - DFX_VERSION: 0.24.2-beta.0 + DFX_VERSION: 0.24.1 steps: - uses: actions/checkout@v4 - name: Install stable Rust toolchain From 8692c372e05cb7bf9862bc97a5e4c15b9eddffc0 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 19:42:53 +0100 Subject: [PATCH 09/12] Revert "dfx version" This reverts commit ab157dd89ffb36d28378b0f76067ea3a65cabed2. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a38495a..19b9d9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest env: - DFX_VERSION: 0.24.1 + DFX_VERSION: 0.24.2-beta.0 steps: - uses: actions/checkout@v4 - name: Install stable Rust toolchain From 635041c33541603d3d30165d0a6e92ef5d55f89a Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Fri, 15 Nov 2024 16:18:33 +0100 Subject: [PATCH 10/12] deps --- .github/workflows/ci.yml | 2 +- Cargo.lock | 172 ++++++++++----------------------------- Cargo.toml | 3 +- 3 files changed, 43 insertions(+), 134 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19b9d9f..a38495a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest env: - DFX_VERSION: 0.24.2-beta.0 + DFX_VERSION: 0.24.1 steps: - uses: actions/checkout@v4 - name: Install stable Rust toolchain diff --git a/Cargo.lock b/Cargo.lock index 1c02fbd..beffc42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1259,17 +1259,6 @@ dependencies = [ "http", ] -[[package]] -name = "http-body-to-bytes" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17a08236c6f51c2ee95d840f45acf8fa9e339390e00b4ef640857b2f2a534d70" -dependencies = [ - "bytes", - "http-body", - "http-body-util", -] - [[package]] name = "http-body-util" version = "0.1.2" @@ -1347,53 +1336,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "ic-agent" -version = "0.37.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd3fdf5e5c4f4a9fe5ca612f0febd22dcb161d2f2b75b0142326732be5e4978" -dependencies = [ - "async-lock", - "backoff", - "cached", - "candid", - "ed25519-consensus", - "futures-util", - "hex", - "http", - "http-body", - "http-body-to-bytes", - "http-body-util", - "hyper", - "hyper-rustls", - "hyper-util", - "ic-certification", - "ic-transport-types 0.37.1", - "ic-verify-bls-signature", - "k256", - "leb128", - "p256", - "pem", - "pkcs8", - "rand", - "rangemap", - "reqwest", - "ring", - "rustls-webpki", - "sec1", - "serde", - "serde_bytes", - "serde_cbor", - "serde_repr", - "sha2 0.10.8", - "simple_asn1", - "thiserror", - "time", - "tokio", - "tower", - "url", -] - [[package]] name = "ic-agent" version = "0.39.1" @@ -1438,33 +1380,6 @@ dependencies = [ "url", ] -[[package]] -name = "ic-cdk" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8ecacd682fa05a985253592963306cb9799622d7b1cce4b1edb89c6ec85be1" -dependencies = [ - "candid", - "ic-cdk-macros", - "ic0", - "serde", - "serde_bytes", -] - -[[package]] -name = "ic-cdk-macros" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4d857135deef20cc7ea8f3869a30cd9cfeb1392b3a81043790b2cd82adc3e0" -dependencies = [ - "candid", - "proc-macro2", - "quote", - "serde", - "serde_tokenstream", - "syn 2.0.85", -] - [[package]] name = "ic-certification" version = "2.6.0" @@ -1484,7 +1399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8722411845f0a4b2c526b906049d45f87c62c78ddf1c38ecdc03ecbd34ffc1d6" dependencies = [ "hex", - "ic-agent 0.39.1", + "ic-agent", "pkcs11", "sha2 0.10.8", "simple_asn1", @@ -1506,7 +1421,7 @@ dependencies = [ "ed25519-consensus", "futures", "hex", - "ic-agent 0.39.1", + "ic-agent", "ic-identity-hsm", "ic-transport-types 0.39.1", "ic-wasm", @@ -1595,12 +1510,6 @@ dependencies = [ "walrus", ] -[[package]] -name = "ic0" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de254dd67bbd58073e23dc1c8553ba12fa1dc610a19de94ad2bbcd0460c067f" - [[package]] name = "ic_bls12_381" version = "0.10.0" @@ -2313,14 +2222,14 @@ dependencies = [ [[package]] name = "pocket-ic" -version = "5.0.0" -source = "git+https://github.com/dfinity/ic.git?rev=3c76b9142f67da01393d9280c705f88b6e522a93#3c76b9142f67da01393d9280c705f88b6e522a93" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "124a2380ca6f557adf8b02517cbfd2f564113230e14cda6f6aadd3dfe156293c" dependencies = [ "base64 0.13.1", "candid", "hex", - "ic-agent 0.37.1", - "ic-cdk", + "ic-certification", "ic-transport-types 0.37.1", "reqwest", "schemars", @@ -2330,11 +2239,14 @@ dependencies = [ "serde_json", "sha2 0.10.8", "slog", + "strum", + "strum_macros", "thiserror", "tokio", "tracing", "tracing-appender", "tracing-subscriber", + "wslpath", ] [[package]] @@ -2901,9 +2813,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -2997,18 +2909,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_tokenstream" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64060d864397305347a78851c51588fd283767e7e7589829e8121d65512340f1" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "syn 2.0.85", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3212,6 +3112,28 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.85", +] + [[package]] name = "subtle" version = "2.6.1" @@ -3375,9 +3297,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -3472,23 +3394,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -3501,7 +3406,6 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4079,6 +3983,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "wslpath" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04a2ecdf2cc4d33a6a93d71bcfbc00bb1f635cdb8029a2cc0709204a045ec7a3" + [[package]] name = "yansi" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index f308742..14b749f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,5 +48,4 @@ image = { version = "0.24", default-features = false, features = ["png"] } libflate = "2.0" base64 = "0.21" futures = "0.3.30" -pocket-ic = { git = "https://github.com/dfinity/ic.git", rev = "3c76b9142f67da01393d9280c705f88b6e522a93" } - +pocket-ic = "6.0.0" From bab1095f057d8ca0240f81174fd6b3a0f9ff6e18 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Fri, 15 Nov 2024 16:25:23 +0100 Subject: [PATCH 11/12] dfx --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a38495a..72df0a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest env: - DFX_VERSION: 0.24.1 + DFX_VERSION: 0.24.2 steps: - uses: actions/checkout@v4 - name: Install stable Rust toolchain From 40d84336a13216f2b981170bfac1f7e1978abcfe Mon Sep 17 00:00:00 2001 From: mraszyk <31483726+mraszyk@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:19:38 +0100 Subject: [PATCH 12/12] avoid pocket-ic crate (#101) * avoid pocket-ic crate * . * trim_end_matches --- Cargo.lock | 611 +++++++++++++++++++++++--------------------------- Cargo.toml | 3 +- src/helper.rs | 26 ++- 3 files changed, 311 insertions(+), 329 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index beffc42..7b38eac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,6 +51,21 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.6.17" @@ -199,12 +214,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -425,6 +434,19 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.6", +] + [[package]] name = "clap" version = "4.5.20" @@ -642,6 +664,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.85", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.85", +] + [[package]] name = "dary_heap" version = "0.3.7" @@ -686,6 +743,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -775,12 +833,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dyn-clone" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" - [[package]] name = "ecdsa" version = "0.16.9" @@ -851,6 +903,15 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "endian-type" version = "0.1.2" @@ -863,15 +924,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "erased-serde" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" -dependencies = [ - "serde", -] - [[package]] name = "errno" version = "0.3.9" @@ -983,6 +1035,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1309,7 +1376,6 @@ dependencies = [ "hyper", "hyper-util", "rustls", - "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -1317,6 +1383,22 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.9" @@ -1336,6 +1418,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "ic-agent" version = "0.39.1" @@ -1356,7 +1461,7 @@ dependencies = [ "http", "http-body", "ic-certification", - "ic-transport-types 0.39.1", + "ic-transport-types", "ic-verify-bls-signature", "k256", "leb128", @@ -1423,7 +1528,7 @@ dependencies = [ "hex", "ic-agent", "ic-identity-hsm", - "ic-transport-types 0.39.1", + "ic-transport-types", "ic-wasm", "image", "inferno", @@ -1432,39 +1537,23 @@ dependencies = [ "libflate", "logos", "pem", - "pocket-ic", "pretty", "pretty_assertions", "qrcode", "rand", + "reqwest", "rpassword", "rustyline", "rustyline-derive", "serde", "serde_cbor", "serde_json", + "serde_with", "sha2 0.10.8", "shellexpand", "tokio", ] -[[package]] -name = "ic-transport-types" -version = "0.37.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875dc4704780383112e8e8b5063a1b98de114321d0c7d3e7f635dcf360a57fba" -dependencies = [ - "candid", - "hex", - "ic-certification", - "leb128", - "serde", - "serde_bytes", - "serde_repr", - "sha2 0.10.8", - "thiserror", -] - [[package]] name = "ic-transport-types" version = "0.39.1" @@ -1544,6 +1633,12 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -1575,6 +1670,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", + "serde", ] [[package]] @@ -1693,7 +1789,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax 0.8.5", + "regex-syntax", "string_cache", "term", "tiny-keccak", @@ -1707,7 +1803,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.8", + "regex-automata", ] [[package]] @@ -1814,7 +1910,7 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "regex-syntax 0.8.5", + "regex-syntax", "syn 2.0.85", ] @@ -1827,15 +1923,6 @@ dependencies = [ "logos-codegen", ] -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - [[package]] name = "memchr" version = "2.7.4" @@ -1848,16 +1935,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -1880,6 +1957,23 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -1919,16 +2013,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-bigint" version = "0.2.6" @@ -2006,6 +2090,32 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "openssl-probe" version = "0.1.5" @@ -2013,16 +2123,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] -name = "option-ext" -version = "0.2.0" +name = "openssl-sys" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] [[package]] -name = "overload" -version = "0.1.1" +name = "option-ext" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "p256" @@ -2207,6 +2323,12 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "png" version = "0.17.14" @@ -2220,35 +2342,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "pocket-ic" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "124a2380ca6f557adf8b02517cbfd2f564113230e14cda6f6aadd3dfe156293c" -dependencies = [ - "base64 0.13.1", - "candid", - "hex", - "ic-certification", - "ic-transport-types 0.37.1", - "reqwest", - "schemars", - "serde", - "serde_bytes", - "serde_cbor", - "serde_json", - "sha2 0.10.8", - "slog", - "strum", - "strum_macros", - "thiserror", - "tokio", - "tracing", - "tracing-appender", - "tracing-subscriber", - "wslpath", -] - [[package]] name = "powerfmt" version = "0.2.0" @@ -2467,17 +2560,8 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", - "regex-syntax 0.8.5", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] @@ -2488,15 +2572,9 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.8.5" @@ -2505,12 +2583,13 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", + "encoding_rs", "futures-channel", "futures-core", "futures-util", @@ -2520,27 +2599,28 @@ dependencies = [ "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", - "mime_guess", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", "quinn", "rustls", - "rustls-native-certs", "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls", - "tokio-socks", "tokio-util", "tower-service", "url", @@ -2652,19 +2732,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "rustls-pki-types", - "schannel", - "security-framework", -] - [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -2754,30 +2821,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "schemars" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn 2.0.85", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -2866,17 +2909,6 @@ dependencies = [ "syn 2.0.85", ] -[[package]] -name = "serde_derive_internals" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.85", -] - [[package]] name = "serde_json" version = "1.0.132" @@ -2921,6 +2953,36 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.6.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "sha2" version = "0.9.9" @@ -2945,15 +3007,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "shell-words" version = "1.1.0" @@ -3027,15 +3080,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slog" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" -dependencies = [ - "erased-serde", -] - [[package]] name = "smallvec" version = "1.13.2" @@ -3112,28 +3156,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.85", -] - [[package]] name = "subtle" version = "2.6.1" @@ -3177,6 +3199,27 @@ dependencies = [ "futures-core", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.13.0" @@ -3230,16 +3273,6 @@ dependencies = [ "syn 2.0.85", ] -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "time" version = "0.3.36" @@ -3297,9 +3330,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -3325,25 +3358,23 @@ dependencies = [ ] [[package]] -name = "tokio-rustls" -version = "0.26.0" +name = "tokio-native-tls" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ - "rustls", - "rustls-pki-types", + "native-tls", "tokio", ] [[package]] -name = "tokio-socks" -version = "0.5.2" +name = "tokio-rustls" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "either", - "futures-util", - "thiserror", + "rustls", + "rustls-pki-types", "tokio", ] @@ -3407,33 +3438,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-appender" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" -dependencies = [ - "crossbeam-channel", - "thiserror", - "time", - "tracing-subscriber", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.85", -] - [[package]] name = "tracing-core" version = "0.1.32" @@ -3441,49 +3448,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", - "tracing-serde", ] [[package]] @@ -3510,12 +3474,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" -[[package]] -name = "unicase" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" - [[package]] name = "unicode-bidi" version = "0.3.17" @@ -3579,10 +3537,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] -name = "valuable" -version = "0.1.0" +name = "vcpkg" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" @@ -3796,6 +3754,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-registry" version = "0.2.0" @@ -3983,12 +3950,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wslpath" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04a2ecdf2cc4d33a6a93d71bcfbc00bb1f635cdb8029a2cc0709204a045ec7a3" - [[package]] name = "yansi" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 14b749f..fd2537b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,4 +48,5 @@ image = { version = "0.24", default-features = false, features = ["png"] } libflate = "2.0" base64 = "0.21" futures = "0.3.30" -pocket-ic = "6.0.0" +reqwest = "0.12.9" +serde_with = { version = "3.11.0", features = ["base64"] } diff --git a/src/helper.rs b/src/helper.rs index 2b4c279..a21486d 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -125,9 +125,29 @@ impl MyHelper { ) -> Self { let runtime = Runtime::new().expect("Unable to create a runtime"); let default_effective_canister_id = runtime - .block_on(pocket_ic::nonblocking::get_default_effective_canister_id( - agent_url.clone(), - )) + .block_on(async { + use serde_with::base64::Base64; + #[serde_with::serde_as] + #[derive(serde::Deserialize)] + pub struct RawCanisterId { + #[serde_as(as = "Base64")] + pub canister_id: Vec, + } + #[derive(serde::Deserialize)] + struct Topology { + pub default_effective_canister_id: RawCanisterId, + } + let resp = reqwest::get(format!("{}/_/topology", agent_url.trim_end_matches('/'))) + .await + .ok()?; + if resp.status().is_success() { + resp.json::().await.ok().map(|topology| { + Principal::from_slice(&topology.default_effective_canister_id.canister_id) + }) + } else { + None + } + }) .unwrap_or(Principal::management_canister()); let mut res = MyHelper { completer: FilenameCompleter::new(),