From fd962e21e1e155252f66ce58af0da3d28e623905 Mon Sep 17 00:00:00 2001 From: Peter White Date: Mon, 9 Dec 2024 16:38:36 -0700 Subject: [PATCH] feat(wallet-integration): server and API (#362) * feat(wallet-integration): implement server and API * feat(wallet-integration): add a few tests to server. Needs more * refactor(wallet-integration): just use call_data, remove data types * feat(wallet-integration): add frontend type for flexible serving * feat(wallet-integration): StateHandler in WalletIntegrationManager. Add terminate method * refactor(wallet-integration): move to module with pop-cli crate * feat(wallet-integration): server-side error handling, update port to 9090 * refactor(wallet-integration): restructure server for easier use in thread * fix(wallet-integration): remove invalid fn `finish` * docs(wallet-integration): inline comments * test(wallet-integration): unit tests for wallet-integration server. Add new frontend type * feat(wallet-integration): two new routes: error and terminate * refactor(wallet-integration): consistent comments, remove unnecessary code in tests * feat: add TransactionData::new * refactor(wallet-integration: shutdown channel error handling, terminate helper, take_error and TranscationData::new tests * chore: clippy warning --- Cargo.lock | 1020 +++++----------------- Cargo.toml | 4 + crates/pop-cli/Cargo.toml | 5 + crates/pop-cli/src/main.rs | 1 + crates/pop-cli/src/wallet_integration.rs | 537 ++++++++++++ 5 files changed, 768 insertions(+), 799 deletions(-) create mode 100644 crates/pop-cli/src/wallet_integration.rs diff --git a/Cargo.lock b/Cargo.lock index 74d393d5d..901e0e10f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -817,7 +817,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 5.3.1", + "event-listener", "event-listener-strategy", "pin-project-lite", ] @@ -846,7 +846,7 @@ dependencies = [ "async-task", "blocking", "cfg-if", - "event-listener 5.3.1", + "event-listener", "futures-lite", "rustix 0.38.42", "tracing", @@ -938,6 +938,61 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.1", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tower 0.5.1", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "backoff" version = "0.4.0" @@ -1015,15 +1070,6 @@ dependencies = [ "serde", ] -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde", -] - [[package]] name = "binary-merkle-tree" version = "15.0.1" @@ -2022,8 +2068,8 @@ dependencies = [ "serde_json", "sp-core 32.0.0", "sp-runtime 35.0.0", - "sp-weights 31.0.0", - "subxt 0.38.0", + "sp-weights", + "subxt", "tokio", "tracing", "url", @@ -3354,16 +3400,6 @@ dependencies = [ "uint 0.9.5", ] -[[package]] -name = "event-listener" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" -dependencies = [ - "concurrent-queue", - "pin-project-lite", -] - [[package]] name = "event-listener" version = "5.3.1" @@ -3381,7 +3417,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ - "event-listener 5.3.1", + "event-listener", "pin-project-lite", ] @@ -3493,16 +3529,6 @@ dependencies = [ "scale-info", ] -[[package]] -name = "finito" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2384245d85162258a14b43567a9ee3598f5ae746a1581fb5d3d2cb780f0dbf95" -dependencies = [ - "futures-timer", - "pin-project", -] - [[package]] name = "fixed-hash" version = "0.8.0" @@ -3647,7 +3673,7 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-npos-elections", "sp-runtime 39.0.2", @@ -3672,17 +3698,6 @@ dependencies = [ "sp-tracing 17.0.1", ] -[[package]] -name = "frame-metadata" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" -dependencies = [ - "cfg-if", - "parity-scale-codec", - "scale-info", -] - [[package]] name = "frame-metadata" version = "16.0.0" @@ -3747,7 +3762,7 @@ dependencies = [ "serde_json", "smallvec", "sp-api", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-crypto-hashing-proc-macro", "sp-debug-derive", @@ -3760,7 +3775,7 @@ dependencies = [ "sp-state-machine 0.43.0", "sp-std", "sp-tracing 17.0.1", - "sp-weights 31.0.0", + "sp-weights", "static_assertions", "tt-call", ] @@ -3827,7 +3842,7 @@ dependencies = [ "sp-runtime 39.0.2", "sp-std", "sp-version", - "sp-weights 31.0.0", + "sp-weights", ] [[package]] @@ -4376,6 +4391,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +[[package]] +name = "http-range-header" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" + [[package]] name = "httparse" version = "1.9.5" @@ -5050,15 +5071,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -5143,83 +5155,16 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "jsonrpsee" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdb12a2381ea5b2e68c3469ec604a007b367778cdb14d09612c8069ebd616ad" -dependencies = [ - "jsonrpsee-client-transport 0.22.5", - "jsonrpsee-core 0.22.5", - "jsonrpsee-http-client", - "jsonrpsee-types 0.22.5", -] - -[[package]] -name = "jsonrpsee" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b089779ad7f80768693755a031cc14a7766aba707cbe886674e3f79e9b7e47" -dependencies = [ - "jsonrpsee-core 0.23.2", - "jsonrpsee-types 0.23.2", - "jsonrpsee-ws-client 0.23.2", -] - [[package]] name = "jsonrpsee" version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5c71d8c1a731cc4227c2f698d377e7848ca12c8a48866fc5e6951c43a4db843" dependencies = [ - "jsonrpsee-client-transport 0.24.7", - "jsonrpsee-core 0.24.7", - "jsonrpsee-types 0.24.7", - "jsonrpsee-ws-client 0.24.7", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" -dependencies = [ - "futures-util", - "http 0.2.12", - "jsonrpsee-core 0.22.5", - "pin-project", - "rustls-native-certs 0.7.3", - "rustls-pki-types", - "soketto 0.7.1", - "thiserror 1.0.69", - "tokio", - "tokio-rustls 0.25.0", - "tokio-util", - "tracing", - "url", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08163edd8bcc466c33d79e10f695cdc98c00d1e6ddfb95cec41b6b0279dd5432" -dependencies = [ - "base64 0.22.1", - "futures-util", - "http 1.2.0", - "jsonrpsee-core 0.23.2", - "pin-project", - "rustls 0.23.19", - "rustls-pki-types", - "rustls-platform-verifier", - "soketto 0.8.1", - "thiserror 1.0.69", - "tokio", - "tokio-rustls 0.26.1", - "tokio-util", - "tracing", - "url", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", + "jsonrpsee-ws-client", ] [[package]] @@ -5231,12 +5176,12 @@ dependencies = [ "base64 0.22.1", "futures-util", "http 1.2.0", - "jsonrpsee-core 0.24.7", + "jsonrpsee-core", "pin-project", "rustls 0.23.19", "rustls-pki-types", "rustls-platform-verifier", - "soketto 0.8.1", + "soketto", "thiserror 1.0.69", "tokio", "tokio-rustls 0.26.1", @@ -5245,51 +5190,6 @@ dependencies = [ "url", ] -[[package]] -name = "jsonrpsee-core" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" -dependencies = [ - "anyhow", - "async-trait", - "beef", - "futures-timer", - "futures-util", - "hyper 0.14.31", - "jsonrpsee-types 0.22.5", - "pin-project", - "rustc-hash 1.1.0", - "serde", - "serde_json", - "thiserror 1.0.69", - "tokio", - "tokio-stream", - "tracing", -] - -[[package]] -name = "jsonrpsee-core" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79712302e737d23ca0daa178e752c9334846b08321d439fd89af9a384f8c830b" -dependencies = [ - "anyhow", - "async-trait", - "beef", - "futures-timer", - "futures-util", - "jsonrpsee-types 0.23.2", - "pin-project", - "rustc-hash 1.1.0", - "serde", - "serde_json", - "thiserror 1.0.69", - "tokio", - "tokio-stream", - "tracing", -] - [[package]] name = "jsonrpsee-core" version = "0.24.7" @@ -5299,7 +5199,7 @@ dependencies = [ "async-trait", "futures-timer", "futures-util", - "jsonrpsee-types 0.24.7", + "jsonrpsee-types", "pin-project", "rustc-hash 2.1.0", "serde", @@ -5310,52 +5210,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-http-client" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" -dependencies = [ - "async-trait", - "hyper 0.14.31", - "hyper-rustls 0.24.2", - "jsonrpsee-core 0.22.5", - "jsonrpsee-types 0.22.5", - "serde", - "serde_json", - "thiserror 1.0.69", - "tokio", - "tower", - "tracing", - "url", -] - -[[package]] -name = "jsonrpsee-types" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150d6168405890a7a3231a3c74843f58b8959471f6df76078db2619ddee1d07d" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror 1.0.69", -] - -[[package]] -name = "jsonrpsee-types" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c465fbe385238e861fdc4d1c85e04ada6c1fd246161d26385c1b311724d2af" -dependencies = [ - "beef", - "http 1.2.0", - "serde", - "serde_json", - "thiserror 1.0.69", -] - [[package]] name = "jsonrpsee-types" version = "0.24.7" @@ -5368,19 +5222,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "jsonrpsee-ws-client" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c28759775f5cb2f1ea9667672d3fe2b0e701d1f4b7b67954e60afe7fd058b5e" -dependencies = [ - "http 1.2.0", - "jsonrpsee-client-transport 0.23.2", - "jsonrpsee-core 0.23.2", - "jsonrpsee-types 0.23.2", - "url", -] - [[package]] name = "jsonrpsee-ws-client" version = "0.24.7" @@ -5388,9 +5229,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fe322e0896d0955a3ebdd5bf813571c53fea29edd713bc315b76620b327e86d" dependencies = [ "http 1.2.0", - "jsonrpsee-client-transport 0.24.7", - "jsonrpsee-core 0.24.7", - "jsonrpsee-types 0.24.7", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", "url", ] @@ -5486,8 +5327,8 @@ dependencies = [ "tokio", "tokio-tungstenite", "tokio-util", - "tower", - "tower-http", + "tower 0.4.13", + "tower-http 0.4.4", "tracing", ] @@ -5936,6 +5777,12 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "matrixmultiply" version = "0.3.9" @@ -6161,12 +6008,6 @@ dependencies = [ "libc", ] -[[package]] -name = "no-std-net" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" - [[package]] name = "nodrop" version = "0.1.14" @@ -6480,7 +6321,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -6499,7 +6340,7 @@ dependencies = [ "pallet-asset-conversion", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -6855,7 +6696,7 @@ dependencies = [ "pallet-transaction-payment", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-runtime 39.0.2", "sp-std", ] @@ -6874,7 +6715,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-runtime 39.0.2", ] @@ -6980,7 +6821,7 @@ dependencies = [ "staging-xcm 14.2.0", "staging-xcm-builder", "wasm-instrument", - "wasmi 0.32.3", + "wasmi", ] [[package]] @@ -7097,7 +6938,7 @@ dependencies = [ "pallet-ranked-collective", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -7168,7 +7009,7 @@ dependencies = [ "parity-scale-codec", "rand", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-npos-elections", @@ -7382,11 +7223,11 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", ] [[package]] @@ -7421,7 +7262,7 @@ dependencies = [ "scale-info", "serde", "sp-application-crypto 38.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-io 38.0.0", "sp-mixnet", "sp-runtime 39.0.2", @@ -7518,7 +7359,7 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-runtime 39.0.2", ] @@ -7712,7 +7553,7 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -7746,7 +7587,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-io 38.0.0", "sp-runtime 39.0.2", ] @@ -7919,7 +7760,7 @@ dependencies = [ "pallet-utility", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-runtime 39.0.2", ] @@ -7936,7 +7777,7 @@ dependencies = [ "pallet-ranked-collective", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -7957,7 +7798,7 @@ dependencies = [ "scale-info", "sp-io 38.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", ] [[package]] @@ -8039,7 +7880,7 @@ dependencies = [ "parity-scale-codec", "rand_chacha", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-io 38.0.0", "sp-runtime 39.0.2", ] @@ -8073,7 +7914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "988a7ebeacc84d4bdb0b12409681e956ffe35438447d8f8bc78db547cffb6ebc" dependencies = [ "log", - "sp-arithmetic 26.0.0", + "sp-arithmetic", ] [[package]] @@ -8203,7 +8044,7 @@ dependencies = [ "parity-scale-codec", "sp-api", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", ] [[package]] @@ -8767,7 +8608,7 @@ dependencies = [ "serde", "sp-core 34.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", ] [[package]] @@ -8786,7 +8627,7 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto 38.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-authority-discovery", "sp-consensus-slots", "sp-core 34.0.0", @@ -8813,7 +8654,7 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto 38.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-authority-discovery", "sp-consensus-slots", "sp-core 34.0.0", @@ -8923,7 +8764,7 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto 38.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-inherents", "sp-io 38.0.0", @@ -9118,7 +8959,7 @@ dependencies = [ "sp-api", "sp-api-proc-macro", "sp-application-crypto 38.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-authority-discovery", "sp-block-builder", "sp-consensus-aura", @@ -9158,7 +8999,7 @@ dependencies = [ "sp-trie 37.0.0", "sp-version", "sp-wasm-interface 21.0.1", - "sp-weights 31.0.0", + "sp-weights", "staging-parachain-info", "staging-xcm 14.2.0", "staging-xcm-builder", @@ -9186,7 +9027,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-block-builder", "sp-consensus-aura", "sp-consensus-grandpa", @@ -9477,6 +9318,7 @@ version = "0.5.0" dependencies = [ "anyhow", "assert_cmd", + "axum", "clap", "cliclack", "console", @@ -9491,13 +9333,15 @@ dependencies = [ "pop-telemetry", "predicates", "reqwest 0.12.9", + "serde", "serde_json", - "sp-core 31.0.0", - "sp-weights 30.0.0", + "sp-core 32.0.0", + "sp-weights", "strum 0.26.3", "strum_macros 0.26.4", "tempfile", "tokio", + "tower-http 0.6.2", "url", ] @@ -9522,8 +9366,8 @@ dependencies = [ "serde_json", "strum 0.26.3", "strum_macros 0.26.4", - "subxt 0.37.0", - "subxt-signer 0.37.0", + "subxt", + "subxt-signer", "tar", "tempfile", "thiserror 1.0.69", @@ -9550,8 +9394,8 @@ dependencies = [ "pop-common", "reqwest 0.12.9", "scale-info", - "sp-core 31.0.0", - "sp-weights 30.0.0", + "sp-core 32.0.0", + "sp-weights", "strum 0.26.3", "strum_macros 0.26.4", "tar", @@ -9578,11 +9422,11 @@ dependencies = [ "pop-common", "reqwest 0.12.9", "scale-info", - "scale-value 0.16.3", + "scale-value", "serde_json", "strum 0.26.3", "strum_macros 0.26.4", - "subxt 0.37.0", + "subxt", "symlink", "tar", "tempfile", @@ -9934,22 +9778,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "reconnecting-jsonrpsee-ws-client" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06fa4f17e09edfc3131636082faaec633c7baa269396b4004040bc6c52f49f65" -dependencies = [ - "cfg_aliases", - "finito", - "futures", - "jsonrpsee 0.23.2", - "serde_json", - "thiserror 1.0.69", - "tokio", - "tracing", -] - [[package]] name = "redox_syscall" version = "0.5.7" @@ -10233,7 +10061,7 @@ dependencies = [ "smallvec", "sp-core 34.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", "staging-xcm 14.2.0", "staging-xcm-builder", ] @@ -10374,20 +10202,6 @@ dependencies = [ "sct", ] -[[package]] -name = "rustls" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" -dependencies = [ - "log", - "ring", - "rustls-pki-types", - "rustls-webpki 0.102.8", - "subtle", - "zeroize", -] - [[package]] name = "rustls" version = "0.23.19" @@ -10518,17 +10332,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "ruzstd" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d" -dependencies = [ - "byteorder", - "derive_more 0.99.18", - "twox-hash", -] - [[package]] name = "ruzstd" version = "0.6.0" @@ -10709,21 +10512,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "scale-decode" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" -dependencies = [ - "derive_more 0.99.18", - "parity-scale-codec", - "primitive-types 0.12.2", - "scale-bits 0.6.0", - "scale-decode-derive 0.13.1", - "scale-type-resolver 0.2.0", - "smallvec", -] - [[package]] name = "scale-decode" version = "0.14.0" @@ -10751,18 +10539,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "scale-decode-derive" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb22f574168103cdd3133b19281639ca65ad985e24612728f727339dcaf4021" -dependencies = [ - "darling 0.14.4", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "scale-decode-derive" version = "0.14.0" @@ -10788,21 +10564,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "scale-encode" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528464e6ae6c8f98e2b79633bf79ef939552e795e316579dab09c61670d56602" -dependencies = [ - "derive_more 0.99.18", - "parity-scale-codec", - "primitive-types 0.12.2", - "scale-bits 0.6.0", - "scale-encode-derive 0.7.2", - "scale-type-resolver 0.2.0", - "smallvec", -] - [[package]] name = "scale-encode" version = "0.8.0" @@ -10831,19 +10592,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "scale-encode-derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef2618f123c88da9cd8853b69d766068f1eddc7692146d7dfe9b89e25ce2efd" -dependencies = [ - "darling 0.20.10", - "proc-macro-crate 3.2.0", - "proc-macro2", - "quote", - "syn 2.0.90", -] - [[package]] name = "scale-encode-derive" version = "0.8.0" @@ -10903,19 +10651,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "scale-typegen" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498d1aecf2ea61325d4511787c115791639c0fd21ef4f8e11e49dd09eff2bbac" -dependencies = [ - "proc-macro2", - "quote", - "scale-info", - "syn 2.0.90", - "thiserror 1.0.69", -] - [[package]] name = "scale-typegen" version = "0.9.0" @@ -10929,27 +10664,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "scale-value" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6ab090d823e75cfdb258aad5fe92e13f2af7d04b43a55d607d25fcc38c811" -dependencies = [ - "base58", - "blake2", - "derive_more 0.99.18", - "either", - "frame-metadata 15.1.0", - "parity-scale-codec", - "scale-bits 0.6.0", - "scale-decode 0.13.1", - "scale-encode 0.7.2", - "scale-info", - "scale-type-resolver 0.2.0", - "serde", - "yap", -] - [[package]] name = "scale-value" version = "0.17.0" @@ -11292,6 +11006,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_repr" version = "0.1.19" @@ -11364,19 +11088,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha1" version = "0.10.6" @@ -11586,61 +11297,6 @@ dependencies = [ "futures-lite", ] -[[package]] -name = "smoldot" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d1eaa97d77be4d026a1e7ffad1bb3b78448763b357ea6f8188d3e6f736a9b9" -dependencies = [ - "arrayvec 0.7.6", - "async-lock", - "atomic-take", - "base64 0.21.7", - "bip39", - "blake2-rfc", - "bs58", - "chacha20", - "crossbeam-queue", - "derive_more 0.99.18", - "ed25519-zebra 4.0.3", - "either", - "event-listener 4.0.3", - "fnv", - "futures-lite", - "futures-util", - "hashbrown 0.14.5", - "hex", - "hmac 0.12.1", - "itertools 0.12.1", - "libm", - "libsecp256k1", - "merlin", - "no-std-net", - "nom", - "num-bigint", - "num-rational", - "num-traits", - "pbkdf2", - "pin-project", - "poly1305", - "rand", - "rand_chacha", - "ruzstd 0.5.0", - "schnorrkel", - "serde", - "serde_json", - "sha2 0.10.8", - "sha3", - "siphasher", - "slab", - "smallvec", - "soketto 0.7.1", - "twox-hash", - "wasmi 0.31.2", - "x25519-dalek", - "zeroize", -] - [[package]] name = "smoldot" version = "0.18.0" @@ -11659,7 +11315,7 @@ dependencies = [ "derive_more 0.99.18", "ed25519-zebra 4.0.3", "either", - "event-listener 5.3.1", + "event-listener", "fnv", "futures-lite", "futures-util", @@ -11679,7 +11335,7 @@ dependencies = [ "poly1305", "rand", "rand_chacha", - "ruzstd 0.6.0", + "ruzstd", "schnorrkel", "serde", "serde_json", @@ -11688,49 +11344,13 @@ dependencies = [ "siphasher", "slab", "smallvec", - "soketto 0.8.1", + "soketto", "twox-hash", - "wasmi 0.32.3", + "wasmi", "x25519-dalek", "zeroize", ] -[[package]] -name = "smoldot-light" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5496f2d116b7019a526b1039ec2247dd172b8670633b1a64a614c9ea12c9d8c7" -dependencies = [ - "async-channel", - "async-lock", - "base64 0.21.7", - "blake2-rfc", - "derive_more 0.99.18", - "either", - "event-listener 4.0.3", - "fnv", - "futures-channel", - "futures-lite", - "futures-util", - "hashbrown 0.14.5", - "hex", - "itertools 0.12.1", - "log", - "lru 0.12.5", - "no-std-net", - "parking_lot", - "pin-project", - "rand", - "rand_chacha", - "serde", - "serde_json", - "siphasher", - "slab", - "smol", - "smoldot 0.16.0", - "zeroize", -] - [[package]] name = "smoldot-light" version = "0.16.2" @@ -11744,7 +11364,7 @@ dependencies = [ "bs58", "derive_more 0.99.18", "either", - "event-listener 5.3.1", + "event-listener", "fnv", "futures-channel", "futures-lite", @@ -11763,7 +11383,7 @@ dependencies = [ "siphasher", "slab", "smol", - "smoldot 0.18.0", + "smoldot", "zeroize", ] @@ -11815,7 +11435,7 @@ dependencies = [ "scale-info", "serde", "snowbridge-beacon-primitives", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -11981,7 +11601,7 @@ dependencies = [ "serde", "snowbridge-core", "snowbridge-outbound-queue-merkle-tree", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", @@ -12039,7 +11659,7 @@ dependencies = [ "log", "parity-scale-codec", "snowbridge-core", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-std", "staging-xcm 14.2.0", "staging-xcm-builder", @@ -12101,21 +11721,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "soketto" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" -dependencies = [ - "base64 0.13.1", - "bytes", - "futures", - "httparse", - "log", - "rand", - "sha-1", -] - [[package]] name = "soketto" version = "0.8.1" @@ -12196,21 +11801,6 @@ dependencies = [ "sp-io 38.0.0", ] -[[package]] -name = "sp-arithmetic" -version = "25.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910c07fa263b20bf7271fdd4adcb5d3217dfdac14270592e0780223542e7e114" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "scale-info", - "serde", - "sp-std", - "static_assertions", -] - [[package]] name = "sp-arithmetic" version = "26.0.0" @@ -12305,7 +11895,7 @@ dependencies = [ "sp-keystore 0.40.0", "sp-mmr-primitives", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", "strum 0.26.3", ] @@ -12768,7 +12358,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-runtime 39.0.2", ] @@ -12813,11 +12403,11 @@ dependencies = [ "serde", "simple-mermaid", "sp-application-crypto 34.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 32.0.0", "sp-io 34.0.0", "sp-std", - "sp-weights 31.0.0", + "sp-weights", ] [[package]] @@ -12839,11 +12429,11 @@ dependencies = [ "serde", "simple-mermaid", "sp-application-crypto 38.0.0", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-std", - "sp-weights 31.0.0", + "sp-weights", "tracing", ] @@ -13232,22 +12822,6 @@ dependencies = [ "wasmtime", ] -[[package]] -name = "sp-weights" -version = "30.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9af6c661fe3066b29f9e1d258000f402ff5cc2529a9191972d214e5871d0ba87" -dependencies = [ - "bounded-collections", - "parity-scale-codec", - "scale-info", - "serde", - "smallvec", - "sp-arithmetic 25.0.0", - "sp-debug-derive", - "sp-std", -] - [[package]] name = "sp-weights" version = "31.0.0" @@ -13259,7 +12833,7 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-debug-derive", ] @@ -13352,7 +12926,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-weights 31.0.0", + "sp-weights", "xcm-procedural 8.0.0", ] @@ -13372,7 +12946,7 @@ dependencies = [ "scale-info", "serde", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", "xcm-procedural 10.1.0", ] @@ -13391,10 +12965,10 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-io 38.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", "staging-xcm 14.2.0", "staging-xcm-executor", ] @@ -13411,11 +12985,11 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-arithmetic 26.0.0", + "sp-arithmetic", "sp-core 34.0.0", "sp-io 38.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", "staging-xcm 14.2.0", "tracing", ] @@ -13543,42 +13117,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "subxt" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a160cba1edbf3ec4fbbeaea3f1a185f70448116a6bccc8276bb39adb3b3053bd" -dependencies = [ - "async-trait", - "derive-where", - "either", - "frame-metadata 16.0.0", - "futures", - "hex", - "impl-serde 0.4.0", - "instant", - "jsonrpsee 0.22.5", - "parity-scale-codec", - "primitive-types 0.12.2", - "reconnecting-jsonrpsee-ws-client", - "scale-bits 0.6.0", - "scale-decode 0.13.1", - "scale-encode 0.7.2", - "scale-info", - "scale-value 0.16.3", - "serde", - "serde_json", - "sp-crypto-hashing", - "subxt-core 0.37.1", - "subxt-lightclient 0.37.0", - "subxt-macro 0.37.0", - "subxt-metadata 0.37.0", - "thiserror 1.0.69", - "tokio-util", - "tracing", - "url", -] - [[package]] name = "subxt" version = "0.38.0" @@ -13592,7 +13130,7 @@ dependencies = [ "futures", "hex", "impl-serde 0.5.0", - "jsonrpsee 0.24.7", + "jsonrpsee", "parity-scale-codec", "polkadot-sdk", "primitive-types 0.13.1", @@ -13600,13 +13138,13 @@ dependencies = [ "scale-decode 0.14.0", "scale-encode 0.8.0", "scale-info", - "scale-value 0.17.0", + "scale-value", "serde", "serde_json", - "subxt-core 0.38.0", - "subxt-lightclient 0.38.0", - "subxt-macro 0.38.0", - "subxt-metadata 0.38.0", + "subxt-core", + "subxt-lightclient", + "subxt-macro", + "subxt-metadata", "thiserror 1.0.69", "tokio", "tokio-util", @@ -13616,27 +13154,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "subxt-codegen" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d703dca0905cc5272d7cc27a4ac5f37dcaae7671acc7fef0200057cc8c317786" -dependencies = [ - "frame-metadata 16.0.0", - "heck 0.5.0", - "hex", - "jsonrpsee 0.22.5", - "parity-scale-codec", - "proc-macro2", - "quote", - "scale-info", - "scale-typegen 0.8.0", - "subxt-metadata 0.37.0", - "syn 2.0.90", - "thiserror 1.0.69", - "tokio", -] - [[package]] name = "subxt-codegen" version = "0.38.0" @@ -13648,39 +13165,12 @@ dependencies = [ "proc-macro2", "quote", "scale-info", - "scale-typegen 0.9.0", - "subxt-metadata 0.38.0", + "scale-typegen", + "subxt-metadata", "syn 2.0.90", "thiserror 1.0.69", ] -[[package]] -name = "subxt-core" -version = "0.37.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3af3b36405538a36b424d229dc908d1396ceb0994c90825ce928709eac1a159a" -dependencies = [ - "base58", - "blake2", - "derive-where", - "frame-metadata 16.0.0", - "hashbrown 0.14.5", - "hex", - "impl-serde 0.4.0", - "parity-scale-codec", - "primitive-types 0.12.2", - "scale-bits 0.6.0", - "scale-decode 0.13.1", - "scale-encode 0.7.2", - "scale-info", - "scale-value 0.16.3", - "serde", - "serde_json", - "sp-crypto-hashing", - "subxt-metadata 0.37.0", - "tracing", -] - [[package]] name = "subxt-core" version = "0.38.0" @@ -13703,27 +13193,10 @@ dependencies = [ "scale-decode 0.14.0", "scale-encode 0.8.0", "scale-info", - "scale-value 0.17.0", + "scale-value", "serde", "serde_json", - "subxt-metadata 0.38.0", - "tracing", -] - -[[package]] -name = "subxt-lightclient" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9406fbdb9548c110803cb8afa750f8b911d51eefdf95474b11319591d225d9" -dependencies = [ - "futures", - "futures-util", - "serde", - "serde_json", - "smoldot-light 0.14.0", - "thiserror 1.0.69", - "tokio", - "tokio-stream", + "subxt-metadata", "tracing", ] @@ -13737,28 +13210,13 @@ dependencies = [ "futures-util", "serde", "serde_json", - "smoldot-light 0.16.2", + "smoldot-light", "thiserror 1.0.69", "tokio", "tokio-stream", "tracing", ] -[[package]] -name = "subxt-macro" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c195f803d70687e409aba9be6c87115b5da8952cd83c4d13f2e043239818fcd" -dependencies = [ - "darling 0.20.10", - "parity-scale-codec", - "proc-macro-error", - "quote", - "scale-typegen 0.8.0", - "subxt-codegen 0.37.0", - "syn 2.0.90", -] - [[package]] name = "subxt-macro" version = "0.38.0" @@ -13769,25 +13227,12 @@ dependencies = [ "parity-scale-codec", "proc-macro-error2", "quote", - "scale-typegen 0.9.0", - "subxt-codegen 0.38.0", + "scale-typegen", + "subxt-codegen", "subxt-utils-fetchmetadata", "syn 2.0.90", ] -[[package]] -name = "subxt-metadata" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738be5890fdeff899bbffff4d9c0f244fe2a952fb861301b937e3aa40ebb55da" -dependencies = [ - "frame-metadata 16.0.0", - "hashbrown 0.14.5", - "parity-scale-codec", - "scale-info", - "sp-crypto-hashing", -] - [[package]] name = "subxt-metadata" version = "0.38.0" @@ -13802,28 +13247,6 @@ dependencies = [ "scale-info", ] -[[package]] -name = "subxt-signer" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49888ae6ae90fe01b471193528eea5bd4ed52d8eecd2d13f4a2333b87388850" -dependencies = [ - "bip39", - "cfg-if", - "hex", - "hmac 0.12.1", - "parity-scale-codec", - "pbkdf2", - "regex", - "schnorrkel", - "secp256k1 0.28.2", - "secrecy 0.8.0", - "sha2 0.10.8", - "sp-crypto-hashing", - "subxt-core 0.37.1", - "zeroize", -] - [[package]] name = "subxt-signer" version = "0.38.0" @@ -13847,7 +13270,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "subxt-core 0.38.0", + "subxt-core", "zeroize", ] @@ -14244,17 +13667,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" -dependencies = [ - "rustls 0.22.4", - "rustls-pki-types", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.1" @@ -14401,6 +13813,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower-http" version = "0.4.4" @@ -14414,7 +13842,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "http-range-header", + "http-range-header 0.3.1", "mime", "pin-project-lite", "tower-layer", @@ -14422,6 +13850,31 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower-http" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" +dependencies = [ + "bitflags 2.6.0", + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "http-range-header 0.4.2", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -15007,19 +14460,6 @@ dependencies = [ "cxx-build", ] -[[package]] -name = "wasmi" -version = "0.31.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8281d1d660cdf54c76a3efa9ddd0c270cada1383a995db3ccb43d166456c7" -dependencies = [ - "smallvec", - "spin", - "wasmi_arena", - "wasmi_core 0.13.0", - "wasmparser-nostd", -] - [[package]] name = "wasmi" version = "0.32.3" @@ -15033,16 +14473,10 @@ dependencies = [ "smallvec", "spin", "wasmi_collections", - "wasmi_core 0.32.3", + "wasmi_core", "wasmparser-nostd", ] -[[package]] -name = "wasmi_arena" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073" - [[package]] name = "wasmi_collections" version = "0.32.3" @@ -15054,18 +14488,6 @@ dependencies = [ "string-interner", ] -[[package]] -name = "wasmi_core" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" -dependencies = [ - "downcast-rs", - "libm", - "num-traits", - "paste", -] - [[package]] name = "wasmi_core" version = "0.32.3" @@ -15347,7 +14769,7 @@ dependencies = [ "smallvec", "sp-core 34.0.0", "sp-runtime 39.0.2", - "sp-weights 31.0.0", + "sp-weights", "staging-xcm 14.2.0", "staging-xcm-builder", ] @@ -15770,7 +15192,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-weights 31.0.0", + "sp-weights", "staging-xcm 14.2.0", "staging-xcm-executor", ] @@ -15974,8 +15396,8 @@ dependencies = [ "serde_json", "sha2 0.10.8", "sp-core 31.0.0", - "subxt 0.38.0", - "subxt-signer 0.38.0", + "subxt", + "subxt-signer", "thiserror 1.0.69", "tokio", "tracing", @@ -16037,8 +15459,8 @@ dependencies = [ "async-trait", "futures", "lazy_static", - "subxt 0.38.0", - "subxt-signer 0.38.0", + "subxt", + "subxt-signer", "tokio", "zombienet-configuration", "zombienet-orchestrator", diff --git a/Cargo.toml b/Cargo.toml index c31416f12..c84ce914d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,3 +76,7 @@ console = "0.15" os_info = { version = "3", default-features = false } strum = "0.26" strum_macros = "0.26" + +# wallet-integration +axum = "0.7.9" +tower-http = "0.6.2" diff --git a/crates/pop-cli/Cargo.toml b/crates/pop-cli/Cargo.toml index c9761b642..4f3ab59ab 100644 --- a/crates/pop-cli/Cargo.toml +++ b/crates/pop-cli/Cargo.toml @@ -18,6 +18,7 @@ duct.workspace = true env_logger.workspace = true os_info.workspace = true reqwest.workspace = true +serde = { workspace = true, version = "1.0", features = ["derive"] } serde_json.workspace = true tempfile.workspace = true tokio.workspace = true @@ -46,6 +47,10 @@ pop-telemetry = { path = "../pop-telemetry", version = "0.5.0", optional = true # common pop-common = { path = "../pop-common", version = "0.5.0" } +# wallet-integration +axum.workspace = true +tower-http = { workspace = true, features = ["fs"] } + [dev-dependencies] assert_cmd.workspace = true predicates.workspace = true diff --git a/crates/pop-cli/src/main.rs b/crates/pop-cli/src/main.rs index 9a41fd7c1..f8e3504e5 100644 --- a/crates/pop-cli/src/main.rs +++ b/crates/pop-cli/src/main.rs @@ -19,6 +19,7 @@ mod cli; mod commands; mod common; mod style; +mod wallet_integration; #[tokio::main] async fn main() -> Result<()> { diff --git a/crates/pop-cli/src/wallet_integration.rs b/crates/pop-cli/src/wallet_integration.rs new file mode 100644 index 000000000..2d7c4cdf4 --- /dev/null +++ b/crates/pop-cli/src/wallet_integration.rs @@ -0,0 +1,537 @@ +use axum::{ + response::Html, + routing::{get, post}, + Router, +}; +use serde::Serialize; +use std::{path::PathBuf, sync::Arc}; +use tokio::{ + sync::{oneshot, Mutex}, + task::JoinHandle, +}; +use tower_http::services::ServeDir; + +/// Make frontend sourcing more flexible by allowing a custom route +/// to be defined. +pub trait Frontend { + fn serve_content(&self) -> Router; +} + +/// Transaction payload to be sent to frontend for signing. +#[derive(Serialize, Debug)] +#[cfg_attr(test, derive(serde::Deserialize, Clone))] +pub struct TransactionData { + chain_rpc: String, + call_data: Vec, +} + +impl TransactionData { + pub fn new(chain_rpc: String, call_data: Vec) -> Self { + Self { chain_rpc, call_data } + } +} + +/// Shared state between routes. Serves two purposes: +/// - Maintains a channel to signal shutdown to the main app. +/// - Stores the signed payload received from the wallet. +#[derive(Default)] +pub struct StateHandler { + /// Channel to signal shutdown to the main app. + shutdown_tx: Option>, + /// Received from UI. + pub signed_payload: Option, + /// Holds a single error message. + /// Only method for consuming error removes (takes) it from state. + error: Option, +} + +/// Manages the wallet integration for secure signing of transactions. +pub struct WalletIntegrationManager { + /// Shared state between routes. + pub state: Arc>, + /// Node rpc address. + pub rpc_url: String, + /// Web server task handle. + pub task_handle: JoinHandle>, +} + +impl WalletIntegrationManager { + /// Launches a server for hosting the wallet integration. Server launched in separate task. + /// Uses default address of 127.0.0.1:9090. + /// # Arguments + /// * `frontend`: A frontend with custom route to serve content. + /// * `payload`: Payload to be sent to the frontend for signing. + /// + /// # Returns + /// A `WalletIntegrationManager` instance, with access to the state and task handle for the + /// server. + pub fn new(frontend: F, payload: TransactionData) -> Self { + Self::new_with_address(frontend, payload, "127.0.0.1:9090") + } + + /// Same as `new`, but allows specifying the address to bind to. + pub fn new_with_address(frontend: F, payload: TransactionData, rpc: &str) -> Self { + // Channel to signal shutdown. + let (tx, rx) = oneshot::channel(); + + let state = Arc::new(Mutex::new(StateHandler { + shutdown_tx: Some(tx), + signed_payload: None, + error: None, + })); + + let payload = Arc::new(payload); + + let app = Router::new() + .route("/payload", get(routes::get_payload_handler).with_state(payload)) + .route("/submit", post(routes::submit_handler).with_state(state.clone())) + .route("/error", post(routes::error_handler).with_state(state.clone())) + .route("/terminate", post(routes::terminate_handler).with_state(state.clone())) + .merge(frontend.serve_content()); // Custom route for serving frontend. + + let rpc_owned = rpc.to_string(); + + // Will shut down when the signed payload is received. + let task_handle = tokio::spawn(async move { + let listener = tokio::net::TcpListener::bind(&rpc_owned) + .await + .map_err(|e| anyhow::anyhow!("Failed to bind to {}: {}", rpc_owned, e))?; + + axum::serve(listener, app) + .with_graceful_shutdown(async move { + let _ = rx.await.ok(); + }) + .await + .map_err(|e| anyhow::anyhow!("Server encountered an error: {}", e))?; + Ok(()) + }); + + Self { state, rpc_url: rpc.to_string(), task_handle } + } + + /// Signals the wallet integration server to shut down. + pub async fn terminate(&mut self) -> anyhow::Result<()> { + terminate_helper(&self.state).await + } + + /// Checks if the server task is still running. + pub fn is_running(&self) -> bool { + !self.task_handle.is_finished() + } + + /// Takes the error from the state if it exists. + pub async fn take_error(&mut self) -> Option { + self.state.lock().await.error.take() + } +} + +mod routes { + use super::{terminate_helper, Arc, Mutex, StateHandler, TransactionData}; + use anyhow::Error; + use axum::{ + extract::State, + http::StatusCode, + response::{IntoResponse, Response}, + Json, + }; + use serde_json::json; + + pub(super) struct ApiError(Error); + + impl From for ApiError { + fn from(err: Error) -> Self { + ApiError(err) + } + } + + // Implementing IntoResponse for ApiError allows us to return it directly from a route handler. + impl IntoResponse for ApiError { + fn into_response(self) -> Response { + let body = json!({ + "error": self.0.to_string(), + }); + (StatusCode::INTERNAL_SERVER_ERROR, Json(body)).into_response() + } + } + + /// Responds with the serialized JSON data for signing. + pub(super) async fn get_payload_handler( + State(payload): State>, + ) -> Result, ApiError> { + // Error should never occur. + let json_payload = serde_json::to_value(&*payload) + .map_err(|e| anyhow::anyhow!("Failed to serialize payload: {}", e))?; + Ok(Json(json_payload)) + } + + /// Receives the signed payload from the wallet. + /// Will signal for shutdown on success. + pub(super) async fn submit_handler( + State(state): State>>, + Json(payload): Json, + ) -> Result, ApiError> { + // Signal shutdown. + let res = terminate_helper(&state).await; + + let mut state_locked = state.lock().await; + state_locked.signed_payload = Some(payload); + + res?; + + // Graceful shutdown ensures response is sent before shutdown. + Ok(Json(json!({"status": "success"}))) + } + + /// Receives an error message from the wallet. + pub(super) async fn error_handler( + State(state): State>>, + Json(error): Json, + ) { + let mut state = state.lock().await; + state.error = Some(error); + } + + /// Allows the server to be terminated from the frontend. + pub(super) async fn terminate_handler( + State(state): State>>, + ) -> Result<(), ApiError> { + Ok(terminate_helper(&state).await?) + } +} + +async fn terminate_helper(handle: &Arc>) -> anyhow::Result<()> { + if let Some(shutdown_tx) = handle.lock().await.shutdown_tx.take() { + shutdown_tx + .send(()) + .map_err(|_| anyhow::anyhow!("Failed to send shutdown signal"))?; + } + Ok(()) +} + +/// Serves static files from a directory. +pub struct FrontendFromDir { + content: PathBuf, +} +impl FrontendFromDir { + pub fn new(content: PathBuf) -> Self { + Self { content } + } +} + +impl Frontend for FrontendFromDir { + fn serve_content(&self) -> Router { + Router::new().nest_service("/", ServeDir::new(self.content.clone())) + } +} + +/// Serves a hard-coded HTML string as the frontend. +pub struct FrontendFromString { + content: String, +} + +impl FrontendFromString { + pub fn new(content: String) -> Self { + Self { content } + } +} + +impl Frontend for FrontendFromString { + fn serve_content(&self) -> Router { + let content = self.content.clone(); + Router::new().route("/", get(move || async { Html(content) })) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + const TEST_HTML: &str = "Hello, world!"; + + // Wait for server to launch. + async fn wait() { + tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; + } + + fn default_payload() -> TransactionData { + TransactionData { chain_rpc: "localhost:9944".to_string(), call_data: vec![1, 2, 3] } + } + + #[tokio::test] + async fn new_works() { + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + let mut wim = WalletIntegrationManager::new(frontend, default_payload()); + + assert_eq!(wim.rpc_url, "127.0.0.1:9090"); + assert_eq!(wim.is_running(), true); + assert!(wim.state.lock().await.shutdown_tx.is_some()); + assert!(wim.state.lock().await.signed_payload.is_none()); + + // Terminate the server and make sure result is ok. + wim.terminate().await.expect("Termination should not fail."); + assert!(wim.task_handle.await.is_ok()); + } + + #[test] + fn new_transaction_data_works() { + let chain_rpc = "localhost:9944".to_string(); + let call_data = vec![1, 2, 3]; + let transaction_data = TransactionData::new(chain_rpc.clone(), call_data.clone()); + + assert_eq!(transaction_data.chain_rpc, chain_rpc); + assert_eq!(transaction_data.call_data, call_data); + } + + #[tokio::test] + async fn take_error_works() { + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + let mut wim = WalletIntegrationManager::new(frontend, default_payload()); + + assert_eq!(wim.take_error().await, None); + + let error = "An error occurred".to_string(); + wim.state.lock().await.error = Some(error.clone()); + + let taken_error = wim.take_error().await; + assert_eq!(taken_error, Some(error)); + } + + #[tokio::test] + async fn payload_handler_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9091"; + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + + let expected_payload = + TransactionData { chain_rpc: "localhost:9944".to_string(), call_data: vec![1, 2, 3] }; + let mut wim = + WalletIntegrationManager::new_with_address(frontend, expected_payload.clone(), addr); + wait().await; + + let addr = format!("http://{}", wim.rpc_url); + let actual_payload = reqwest::get(&format!("{}/payload", addr)) + .await + .expect("Failed to get payload") + .json::() + .await + .expect("Failed to parse payload"); + + assert_eq!(actual_payload.chain_rpc, expected_payload.chain_rpc); + assert_eq!(actual_payload.call_data, expected_payload.call_data); + + wim.terminate().await.expect("Termination should not fail"); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn submit_handler_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9092"; + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + + let mut wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + let addr = format!("http://{}", wim.rpc_url); + let response = reqwest::Client::new() + .post(&format!("{}/submit", addr)) + .json(&"0xDEADBEEF") + .send() + .await + .expect("Failed to submit payload") + .json::() + .await + .expect("Failed to parse JSON response"); + + assert_eq!(response, json!({"status": "success"})); + assert_eq!(wim.state.lock().await.signed_payload, Some("0xDEADBEEF".to_string())); + assert_eq!(wim.is_running(), false); + + wim.terminate().await.expect("Termination should not fail"); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn error_handler_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9093"; + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + + let mut wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + let addr = format!("http://{}", wim.rpc_url); + let response = reqwest::Client::new() + .post(&format!("{}/error", addr)) + .json(&"an error occurred") + .send() + .await + .expect("Failed to submit error") + .text() + .await + .expect("Failed to parse response"); + + // no response expected + assert_eq!(response.len(), 0); + assert_eq!(wim.state.lock().await.error, Some("an error occurred".to_string())); + assert_eq!(wim.is_running(), true); + + wim.terminate().await.expect("Termination should not fail"); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn terminate_handler_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9094"; + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + + let wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + let addr = format!("http://{}", wim.rpc_url); + let response = reqwest::Client::new() + .post(&format!("{}/terminate", addr)) + .send() + .await + .expect("Failed to terminate") + .text() + .await + .expect("Failed to parse response"); + + // No response expected. + assert_eq!(response.len(), 0); + assert_eq!(wim.is_running(), false); + + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn wallet_terminate_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9095"; + + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + + let mut wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + + assert_eq!(wim.is_running(), true); + wim.terminate().await.expect("Termination should not fail"); + wait().await; + assert_eq!(wim.is_running(), false); + + wim.terminate().await.expect("Termination should not fail"); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn frontend_from_string_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9096"; + + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + let mut wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + let actual_content = reqwest::get(&format!("http://{}", addr)) + .await + .expect("Failed to get web page") + .text() + .await + .expect("Failed to parse page"); + + assert_eq!(actual_content, TEST_HTML); + + wim.terminate().await.expect("Termination should not fail"); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn frontend_from_dir_works() { + use std::fs; + use tempfile::tempdir; + + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9097"; + + let temp_dir = tempdir().expect("Failed to create temp directory"); + let index_file_path = temp_dir.path().join("index.html"); + + let test_html = "Hello, world from Directory!"; + fs::write(&index_file_path, test_html).expect("Failed to write index.html"); + + let frontend = FrontendFromDir::new(temp_dir.path().to_path_buf()); + let mut wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + let actual_content = reqwest::get(&format!("http://{}", addr)) + .await + .expect("Failed to get web page") + .text() + .await + .expect("Failed to parse page"); + + assert_eq!(actual_content, test_html); + + wim.terminate().await.expect("Termination should not fail"); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn large_payload_works() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9098"; + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + + let call_data_5mb = vec![99u8; 5 * 1024 * 1024]; + + let expected_payload = TransactionData { + chain_rpc: "localhost:9944".to_string(), + call_data: call_data_5mb.clone(), + }; + let mut wim = + WalletIntegrationManager::new_with_address(frontend, expected_payload.clone(), addr); + wait().await; + + let addr = format!("http://{}", wim.rpc_url); + let actual_payload = reqwest::get(&format!("{}/payload", addr)) + .await + .expect("Failed to get payload") + .json::() + .await + .expect("Failed to parse payload"); + + assert_eq!(actual_payload.chain_rpc, expected_payload.chain_rpc); + assert_eq!(actual_payload.call_data, call_data_5mb); + + wim.terminate().await.expect("Termination should not fail."); + assert!(wim.task_handle.await.is_ok()); + } + + #[tokio::test] + async fn new_with_conflicting_address_fails() { + // offset port per test to avoid conflicts + let addr = "127.0.0.1:9099"; + + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + let wim = WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + assert_eq!(wim.is_running(), true); + + let frontend = FrontendFromString::new(TEST_HTML.to_string()); + let wim_conflict = + WalletIntegrationManager::new_with_address(frontend, default_payload(), addr); + wait().await; + + assert_eq!(wim_conflict.is_running(), false); + let task_result = wim_conflict.task_handle.await.unwrap(); + match task_result { + Err(e) => assert!(e + .to_string() + .starts_with(&format!("Failed to bind to {}: Address already in use", addr))), + Ok(_) => panic!("Expected error, but task succeeded"), + } + } +}