diff --git a/.eslintrc.json b/.eslintrc.json index 0e8f13b..de6adb5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,9 +12,10 @@ "plugins": ["@typescript-eslint", "unused-imports"], "ignorePatterns": ["dist/", "tailwind.config.js"], "rules": { - "@typescript-eslint/no-explicit-any": ["off"], - "no-unused-vars": "off", - "unused-imports/no-unused-imports": "error", + "@typescript-eslint/no-explicit-any": ["warn"], + "no-unused-vars": "warn", + "@typescript-eslint/no-unused-vars": "warn", + "unused-imports/no-unused-imports": "warn", "unused-imports/no-unused-vars": [ "warn", { diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e296879..f04c363 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,6 +35,11 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 + - name: Test the WASM module with Node's WASM executer + run: | + cd ./codegen + wasm-pack test --node --no-default-features --features web + - name: Install dependencies uses: bahmutov/npm-install@v1 diff --git a/codegen/Cargo.lock b/codegen/Cargo.lock index 6b84fc1..4267092 100644 --- a/codegen/Cargo.lock +++ b/codegen/Cargo.lock @@ -19,64 +19,46 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", - "opaque-debug", -] - -[[package]] -name = "aes-gcm" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - [[package]] name = "ahash" -version = "0.7.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ - "getrandom", + "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "arrayref" @@ -101,22 +83,24 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-channel" -version = "1.9.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 4.0.3", + "event-listener-strategy", "futures-core", + "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.5.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock", + "async-lock 3.3.0", "async-task", "concurrent-queue", "fastrand", @@ -126,34 +110,32 @@ dependencies = [ [[package]] name = "async-fs" -version = "1.6.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +checksum = "dd1f344136bad34df1f83a47f3fd7f2ab85d75cb8a940af4ccf6d482a84ea01b" dependencies = [ - "async-lock", - "autocfg", + "async-lock 3.3.0", "blocking", "futures-lite", ] [[package]] name = "async-io" -version = "1.13.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +checksum = "fb41eb19024a91746eba0773aa5e16036045bbf45733766661099e182ea6a744" dependencies = [ - "async-lock", - "autocfg", + "async-lock 3.3.0", "cfg-if", "concurrent-queue", + "futures-io", "futures-lite", - "log", "parking", "polling", "rustix", "slab", - "socket2 0.4.9", - "waker-fn", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -162,67 +144,95 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +dependencies = [ + "event-listener 4.0.3", + "event-listener-strategy", + "pin-project-lite", ] [[package]] name = "async-net" -version = "1.7.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4051e67316bc7eff608fe723df5d32ed639946adcd69e07df41fd42a7b411f1f" +checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" dependencies = [ "async-io", - "autocfg", "blocking", "futures-lite", ] [[package]] name = "async-process" -version = "1.7.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" +checksum = "15c1cd5d253ecac3d3cf15e390fd96bd92a13b1d14497d81abf077304794fb04" dependencies = [ + "async-channel", "async-io", - "async-lock", - "autocfg", + "async-lock 3.3.0", + "async-signal", "blocking", "cfg-if", - "event-listener", + "event-listener 4.0.3", "futures-lite", "rustix", - "signal-hook", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-signal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +dependencies = [ + "async-io", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", ] [[package]] name = "async-task" -version = "4.4.0" +version = "4.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] -name = "atomic" -version = "0.5.3" +name = "atomic-take" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" [[package]] name = "atomic-waker" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" @@ -259,9 +269,18 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "basic-toml" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" +dependencies = [ + "serde", +] [[package]] name = "beef" @@ -279,8 +298,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "serde", - "unicode-normalization", ] [[package]] @@ -295,6 +312,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "bitvec" version = "1.0.1" @@ -357,17 +380,18 @@ dependencies = [ [[package]] name = "blocking" -version = "1.3.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel", - "async-lock", + "async-lock 3.3.0", "async-task", - "atomic-waker", "fastrand", + "futures-io", "futures-lite", - "log", + "piper", + "tracing", ] [[package]] @@ -393,9 +417,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -420,43 +444,30 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "zeroize", -] - -[[package]] -name = "chacha20poly1305" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" -dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", - "zeroize", ] [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", ] [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ "crossbeam-utils", ] @@ -491,9 +502,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -501,37 +512,33 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crunchy" @@ -546,6 +553,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core", "typenum", ] @@ -559,37 +567,16 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctr" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" -dependencies = [ - "cipher", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - [[package]] name = "curve25519-dalek" -version = "4.1.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622178105f911d937a42cdb140730ba4a3ed2becd8ae6ce39c7d28b5d75d4588" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", "platforms", "rustc_version", @@ -599,26 +586,13 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", -] - -[[package]] -name = "curve25519-dalek-ng" -version = "4.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.6.4", - "subtle-ng", - "zeroize", + "syn 2.0.48", ] [[package]] @@ -666,7 +640,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] @@ -688,7 +662,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] @@ -741,17 +715,27 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + [[package]] name = "ed25519-zebra" -version = "3.1.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", + "curve25519-dalek", + "ed25519", + "hashbrown", "hex", - "rand_core 0.6.4", - "sha2 0.9.9", + "rand_core", + "sha2 0.10.8", "zeroize", ] @@ -769,45 +753,52 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "event-listener" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "2.5.3" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] [[package]] -name = "fastrand" -version = "1.9.0" +name = "event-listener-strategy" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "instant", + "event-listener 4.0.3", + "pin-project-lite", ] +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "fixed-hash" @@ -829,9 +820,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -867,9 +858,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -881,9 +872,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -891,53 +882,51 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "1.13.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" dependencies = [ "fastrand", "futures-core", "futures-io", - "memchr", "parking", "pin-project-lite", - "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -951,9 +940,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -979,9 +968,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", @@ -991,26 +980,31 @@ dependencies = [ ] [[package]] -name = "ghash" -version = "0.4.4" +name = "getrandom_or_panic" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" dependencies = [ - "opaque-debug", - "polyval", + "rand_core", ] [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "glob" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "gloo-net" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" +checksum = "43aaa242d1239a8822c15c645f02166398da4f8b5c4bae795c1f5b44e9eee173" dependencies = [ "futures-channel", "futures-core", @@ -1073,19 +1067,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" -dependencies = [ + "allocator-api2", "serde", ] @@ -1097,9 +1084,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -1139,9 +1126,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1150,9 +1137,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1173,9 +1160,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1188,7 +1175,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", @@ -1197,18 +1184,18 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", "hyper", "log", - "rustls", - "rustls-native-certs", + "rustls 0.21.10", + "rustls-native-certs 0.6.3", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", ] [[package]] @@ -1219,9 +1206,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1258,12 +1245,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown", ] [[package]] @@ -1272,6 +1259,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -1284,52 +1280,35 @@ dependencies = [ "web-sys", ] -[[package]] -name = "intx" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f38a50a899dc47a6d0ed5508e7f601a2e34c3a85303514b5d137f3c10a0c75" - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - [[package]] name = "itertools" -version = "0.10.5" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad9b31183a8bcbe843e32ca8554ad2936633548d95a7bb6a8e14c767dea6b05" +checksum = "9579d0ca9fb30da026bac2f0f7d9576ec93489aeb7cd4971dd5b4617d82c79b2" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -1339,9 +1318,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97f2743cad51cc86b0dbfe316309eeb87a9d96a3d7f4dd7a99767c4b5f065335" +checksum = "3f9f9ed46590a8d5681975f126e22531698211b926129a40a2db47cbca429220" dependencies = [ "futures-channel", "futures-util", @@ -1349,11 +1328,12 @@ dependencies = [ "http", "jsonrpsee-core", "pin-project", - "rustls-native-certs", + "rustls-native-certs 0.7.0", + "rustls-pki-types", "soketto", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tokio-util", "tracing", "url", @@ -1361,32 +1341,34 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35dc957af59ce98373bcdde0c1698060ca6c2d2e9ae357b459c7158b6df33330" +checksum = "776d009e2f591b78c038e0d053a796f94575d66ca4e77dd84bfc5e81419e436c" dependencies = [ "anyhow", - "async-lock", + "async-lock 3.3.0", "async-trait", "beef", "futures-timer", "futures-util", "hyper", "jsonrpsee-types", + "pin-project", "rustc-hash", "serde", "serde_json", "thiserror", "tokio", + "tokio-stream", "tracing", "wasm-bindgen-futures", ] [[package]] name = "jsonrpsee-http-client" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd865d0072764cb937b0110a92b5f53e995f7101cb346beca03d93a2dea79de" +checksum = "78b7de9f3219d95985eb77fd03194d7c1b56c19bce1abfcc9d07462574b15572" dependencies = [ "async-trait", "hyper", @@ -1404,38 +1386,37 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa9e25aec855b2a7d3ed90fded6c41e8c3fb72b63f071e1be3f0004eba19b625" +checksum = "3266dfb045c9174b24c77c2dfe0084914bb23a6b2597d70c9dc6018392e1cd1b" dependencies = [ "anyhow", "beef", "serde", "serde_json", "thiserror", - "tracing", ] [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] [[package]] name = "libc" -version = "0.2.148" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsecp256k1" @@ -1487,15 +1468,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1509,15 +1490,18 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.10.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" +dependencies = [ + "hashbrown", +] [[package]] name = "memchr" -version = "2.6.3" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "merlin" @@ -1527,7 +1511,7 @@ checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ "byteorder", "keccak", - "rand_core 0.6.4", + "rand_core", "zeroize", ] @@ -1548,13 +1532,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1614,9 +1598,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1633,18 +1617,18 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -1660,9 +1644,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -1674,11 +1658,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", "syn 1.0.109", @@ -1686,9 +1670,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -1702,15 +1686,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1736,9 +1720,9 @@ checksum = "9163e1259760e83d528d1b3171e5100c1767f10c52e1c4d6afad26e63d47d758" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -1757,7 +1741,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] @@ -1772,26 +1756,35 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + [[package]] name = "platforms" -version = "3.1.2" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" [[package]] name = "polling" -version = "2.8.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" dependencies = [ - "autocfg", - "bitflags", "cfg-if", "concurrent-queue", - "libc", - "log", "pin-project-lite", - "windows-sys", + "rustix", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -1802,9 +1795,9 @@ checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug", @@ -1812,38 +1805,26 @@ dependencies = [ ] [[package]] -name = "polyval" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug", - "universal-hash", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "ppv-lite86" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -1859,7 +1840,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit 0.20.2", ] [[package]] @@ -1888,18 +1879,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1918,7 +1909,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1928,15 +1919,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - [[package]] name = "rand_core" version = "0.6.4" @@ -1948,18 +1933,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", @@ -1969,9 +1954,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ "aho-corasick", "memchr", @@ -1986,17 +1971,16 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" -version = "0.16.20" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", + "getrandom", "libc", - "once_cell", - "spin 0.5.2", + "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -2028,30 +2012,43 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.25" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags", + "bitflags 2.4.2", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.1", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -2059,46 +2056,86 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.0.0", + "rustls-pki-types", "schannel", "security-framework", ] [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.4", + "base64 0.21.7", +] + +[[package]] +name = "rustls-pemfile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +dependencies = [ + "base64 0.21.7", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9d979b3ce68192e42760c7810125eb6cf2ea10efae545a156063e61f314e2a" + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", ] [[package]] name = "rustls-webpki" -version = "0.101.5" +version = "0.102.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" +checksum = "ef4ca26037c909dedb327b48c3327d0ba91d3dd3c4e05dad328f210ffb68e95b" dependencies = [ "ring", + "rustls-pki-types", "untrusted", ] [[package]] name = "ruzstd" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3ffab8f9715a0d455df4bbb9d21e91135aab3cd3ca187af0cd0c3c3f868fdc" +checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d" dependencies = [ "byteorder", - "thiserror-core", + "derive_more", "twox-hash", ] [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "scale-bits" @@ -2121,7 +2158,22 @@ dependencies = [ "parity-scale-codec", "primitive-types", "scale-bits", - "scale-decode-derive", + "scale-decode-derive 0.9.0", + "scale-info", + "smallvec", +] + +[[package]] +name = "scale-decode" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7caaf753f8ed1ab4752c6afb20174f03598c664724e0e32628e161c21000ff76" +dependencies = [ + "derive_more", + "parity-scale-codec", + "primitive-types", + "scale-bits", + "scale-decode-derive 0.10.0", "scale-info", "smallvec", ] @@ -2133,7 +2185,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27873eb6005868f8cc72dcfe109fae664cf51223d35387bc2f28be4c28d94c47" dependencies = [ "darling 0.14.4", - "proc-macro-crate", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "scale-decode-derive" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3475108a1b62c7efd1b5c65974f30109a598b2f45f23c9ae030acb9686966db" +dependencies = [ + "darling 0.14.4", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2161,7 +2226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "995491f110efdc6bea96d6a746140e32bfceb4ea47510750a5467295a4707a25" dependencies = [ "darling 0.14.4", - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2169,9 +2234,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -2183,16 +2248,47 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "scale-typegen" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00860983481ac590ac87972062909bef0d6a658013b592ccc0f2feb272feab11" +dependencies = [ + "proc-macro2", + "quote", + "scale-info", + "syn 2.0.48", + "thiserror", +] + +[[package]] +name = "scale-typegen-description" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae69c1dfd81e9859a5fb42c1b560369e6ed82d2c5b5cb4cac3bba1962a73f017" +dependencies = [ + "anyhow", + "peekmore", + "proc-macro2", + "quote", + "rand", + "rand_chacha", + "scale-info", + "scale-typegen", + "scale-value 0.13.0", + "smallvec", +] + [[package]] name = "scale-value" version = "0.12.0" @@ -2206,7 +2302,27 @@ dependencies = [ "frame-metadata 15.1.0", "parity-scale-codec", "scale-bits", - "scale-decode", + "scale-decode 0.9.0", + "scale-encode", + "scale-info", + "serde", + "yap", +] + +[[package]] +name = "scale-value" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58223c7691bf0bd46b43c9aea6f0472d1067f378d574180232358d7c6e0a8089" +dependencies = [ + "base58", + "blake2", + "derive_more", + "either", + "frame-metadata 15.1.0", + "parity-scale-codec", + "scale-bits", + "scale-decode 0.10.0", "scale-encode", "scale-info", "serde", @@ -2215,30 +2331,38 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "schnorrkel" -version = "0.10.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "844b7645371e6ecdf61ff246ba1958c29e802881a749ae3fb1993675d210d28d" +checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" dependencies = [ + "aead", "arrayref", "arrayvec 0.7.4", - "curve25519-dalek-ng", + "curve25519-dalek", + "getrandom_or_panic", "merlin", - "rand_core 0.6.4", + "rand_core", "serde_bytes", - "sha2 0.9.9", - "subtle-ng", + "sha2 0.10.8", + "subtle", "zeroize", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -2247,48 +2371,21 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", ] -[[package]] -name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", -] - -[[package]] -name = "secrecy" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" -dependencies = [ - "zeroize", -] - [[package]] name = "security-framework" version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -2307,9 +2404,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "send_wrapper" @@ -2325,9 +2422,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -2345,29 +2442,29 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.12" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -2402,9 +2499,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -2421,16 +2518,6 @@ dependencies = [ "keccak", ] -[[package]] -name = "signal-hook" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -2440,11 +2527,17 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" + [[package]] name = "siphasher" -version = "0.3.11" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "54ac45299ccbd390721be55b412d41931911f654fa99e2cb8bfb57184b2061fe" [[package]] name = "slab" @@ -2457,21 +2550,21 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "smol" -version = "1.3.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13f2b548cd8447f8de0fdf1c592929f70f4fc7039a05e47404b0d096ec6987a1" +checksum = "e635339259e51ef85ac7aa29a1cd991b957047507288697a690e80ab97d07cad" dependencies = [ "async-channel", "async-executor", "async-fs", "async-io", - "async-lock", + "async-lock 3.3.0", "async-net", "async-process", "blocking", @@ -2480,29 +2573,31 @@ dependencies = [ [[package]] name = "smoldot" -version = "0.8.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cce5e2881b30bad7ef89f383a816ad0b22c45915911f28499026de4a76d20ee" +checksum = "e6d1eaa97d77be4d026a1e7ffad1bb3b78448763b357ea6f8188d3e6f736a9b9" dependencies = [ "arrayvec 0.7.4", - "async-lock", - "atomic", - "base64 0.21.4", + "async-lock 3.3.0", + "atomic-take", + "base64 0.21.7", "bip39", "blake2-rfc", "bs58", + "chacha20", "crossbeam-queue", "derive_more", "ed25519-zebra", "either", - "event-listener", + "event-listener 4.0.3", "fnv", - "futures-channel", + "futures-lite", "futures-util", - "hashbrown 0.14.0", + "hashbrown", "hex", "hmac 0.12.1", "itertools", + "libm", "libsecp256k1", "merlin", "no-std-net", @@ -2512,87 +2607,69 @@ dependencies = [ "num-traits", "pbkdf2", "pin-project", + "poly1305", "rand", "rand_chacha", "ruzstd", "schnorrkel", "serde", "serde_json", - "sha2 0.10.7", + "sha2 0.10.8", + "sha3", "siphasher", "slab", "smallvec", - "smol", - "snow", "soketto", - "tiny-keccak", "twox-hash", "wasmi", + "x25519-dalek", + "zeroize", ] [[package]] name = "smoldot-light" -version = "0.6.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2f7b4687b83ff244ef6137735ed5716ad37dcdf3ee16c4eb1a32fb9808fa47" +checksum = "5496f2d116b7019a526b1039ec2247dd172b8670633b1a64a614c9ea12c9d8c7" dependencies = [ - "async-lock", + "async-channel", + "async-lock 3.3.0", + "base64 0.21.7", "blake2-rfc", "derive_more", "either", - "event-listener", + "event-listener 4.0.3", "fnv", "futures-channel", + "futures-lite", "futures-util", - "hashbrown 0.14.0", + "hashbrown", "hex", "itertools", "log", "lru", + "no-std-net", "parking_lot", + "pin-project", "rand", + "rand_chacha", "serde", "serde_json", "siphasher", "slab", "smol", "smoldot", -] - -[[package]] -name = "snow" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" -dependencies = [ - "aes-gcm", - "blake2", - "chacha20poly1305", - "curve25519-dalek 4.1.0", - "rand_core 0.6.4", - "rustc_version", - "sha2 0.10.7", - "subtle", -] - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", + "zeroize", ] [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2612,31 +2689,18 @@ dependencies = [ [[package]] name = "sp-core-hashing" -version = "9.0.0" +version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee599a8399448e65197f9a6cee338ad192e9023e35e31f22382964c3c174c68" +checksum = "1e0f4990add7b2cefdeca883c0efa99bb4d912cb2196120e1500c0cc099553b0" dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.7", + "sha2 0.10.8", "sha3", - "sp-std", "twox-hash", ] -[[package]] -name = "sp-std" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53458e3c57df53698b3401ec0934bea8e8cfce034816873c0b0abbd83d7bac0d" - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -2661,17 +2725,11 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "subtle-ng" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" - [[package]] name = "subxt" -version = "0.32.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "588b8ce92699eeb06290f4fb02dad4f7e426c4e6db4d53889c6bcbc808cf24ac" +checksum = "b3323d5c27898b139d043dc1ee971f602f937b99354ee33ee933bd90e0009fbd" dependencies = [ "async-trait", "base58", @@ -2683,14 +2741,15 @@ dependencies = [ "getrandom", "hex", "impl-serde", + "instant", "jsonrpsee", "parity-scale-codec", "primitive-types", "scale-bits", - "scale-decode", + "scale-decode 0.10.0", "scale-encode", "scale-info", - "scale-value", + "scale-value 0.13.0", "serde", "serde_json", "sp-core-hashing", @@ -2699,14 +2758,16 @@ dependencies = [ "subxt-metadata", "thiserror", "tokio-stream", + "tokio-util", "tracing", + "url", ] [[package]] name = "subxt-codegen" -version = "0.32.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98f5a534c8d475919e9c845d51fc2316da4fcadd04fe17552d932d2106de930e" +checksum = "2d0e58c3f88651cff26aa52bae0a0a85f806a2e923a20eb438c16474990743ea" dependencies = [ "frame-metadata 16.0.0", "getrandom", @@ -2717,17 +2778,18 @@ dependencies = [ "proc-macro2", "quote", "scale-info", + "scale-typegen", "subxt-metadata", - "syn 2.0.37", + "syn 2.0.48", "thiserror", "tokio", ] [[package]] name = "subxt-lightclient" -version = "0.32.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10fd0ac9b091211f962b6ae19e26cd08e0b86efa064dfb7fac69c8f79f122329" +checksum = "ecec7066ba7bc0c3608fcd1d0c7d9584390990cd06095b6ae4f114f74c4b8550" dependencies = [ "futures", "futures-timer", @@ -2735,6 +2797,7 @@ dependencies = [ "getrandom", "instant", "js-sys", + "pin-project", "send_wrapper 0.6.0", "serde", "serde_json", @@ -2751,21 +2814,24 @@ dependencies = [ [[package]] name = "subxt-macro" -version = "0.32.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e8be9ab6fe88b8c13edbe15911e148482cfb905a8b8d5b8d766a64c54be0bd" +checksum = "365251668613323064803427af8c7c7bc366cd8b28e33639640757669dafebd5" dependencies = [ "darling 0.20.3", + "parity-scale-codec", "proc-macro-error", + "quote", + "scale-typegen", "subxt-codegen", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] name = "subxt-metadata" -version = "0.32.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6898275765d36a37e5ef564358e0341cf41b5f3a91683d7d8b859381b65ac8a" +checksum = "c02aca8d39a1f6c55fff3a8fd81557d30a610fedc1cef03f889a81bc0f8f0b52" dependencies = [ "frame-metadata 16.0.0", "parity-scale-codec", @@ -2774,28 +2840,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "subxt-signer" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82e5abb896d5f5a6581d5b86a5e7f015e318122498d8163211e8f61f83b54d2" -dependencies = [ - "bip39", - "hex", - "hmac 0.12.1", - "parity-scale-codec", - "pbkdf2", - "regex", - "schnorrkel", - "secp256k1", - "secrecy", - "sha2 0.10.7", - "sp-core-hashing", - "subxt", - "thiserror", - "zeroize", -] - [[package]] name = "subxt_example_codegen" version = "0.1.0" @@ -2806,23 +2850,28 @@ dependencies = [ "console_error_panic_hook", "heck", "js-sys", + "parity-scale-codec", "peekmore", "pollster", "prettyplease", "proc-macro2", "quote", "regex", + "scale-decode 0.9.0", "scale-info", + "scale-typegen-description", + "scale-value 0.12.0", "serde", "serde-wasm-bindgen", "smallvec", "subxt", "subxt-codegen", "subxt-metadata", - "subxt-signer", - "syn 2.0.37", + "syn 2.0.48", + "trybuild", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-bindgen-test", ] [[package]] @@ -2838,9 +2887,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -2854,52 +2903,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] -name = "thiserror" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-core" -version = "1.0.38" +name = "termcolor" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ - "thiserror-core-impl", + "winapi-util", ] [[package]] -name = "thiserror-core-impl" -version = "1.0.38" +name = "thiserror" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", + "syn 2.0.48", ] [[package]] @@ -2919,9 +2948,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -2929,20 +2958,20 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.4", + "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] @@ -2951,7 +2980,18 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", + "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.2", + "rustls-pki-types", "tokio", ] @@ -2968,9 +3008,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -2998,6 +3038,17 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -3027,11 +3078,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -3040,29 +3090,44 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "trybuild" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a9d3ba662913483d6722303f619e75ea10b7855b0f8e0d72799cf8621bb488f" +dependencies = [ + "basic-toml", + "glob", + "once_cell", + "serde", + "serde_derive", + "serde_json", + "termcolor", +] [[package]] name = "twox-hash" @@ -3095,9 +3160,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3116,25 +3181,25 @@ dependencies = [ [[package]] name = "universal-hash" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3147,12 +3212,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "want" version = "0.3.1" @@ -3170,9 +3229,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3180,24 +3239,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -3207,9 +3266,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3217,32 +3276,56 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139bd73305d50e1c1c4333210c0db43d989395b64a237bd35c10ef3832a7f70c" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70072aebfe5da66d2716002c729a14e4aec4da0e23cc2ea66323dac541c93928" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] [[package]] name = "wasmi" -version = "0.30.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51fb5c61993e71158abf5bb863df2674ca3ec39ed6471c64f07aeaf751d67b4" +checksum = "acfc1e384a36ca532d070a315925887247f3c7e23567e23e0ac9b1c5d6b8bf76" dependencies = [ - "intx", "smallvec", - "spin 0.9.8", + "spin", "wasmi_arena", "wasmi_core", "wasmparser-nostd", @@ -3250,15 +3333,15 @@ dependencies = [ [[package]] name = "wasmi_arena" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" +checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073" [[package]] name = "wasmi_core" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" +checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" dependencies = [ "downcast-rs", "libm", @@ -3277,9 +3360,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -3301,6 +3384,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -3313,7 +3405,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -3322,13 +3423,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -3337,47 +3453,89 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" dependencies = [ "memchr", ] @@ -3391,17 +3549,49 @@ dependencies = [ "tap", ] +[[package]] +name = "x25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" +dependencies = [ + "curve25519-dalek", + "rand_core", + "serde", + "zeroize", +] + [[package]] name = "yap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff4524214bc4629eba08d78ceb1d6507070cc0bcbbed23af74e19e6e924a24cf" +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -3414,5 +3604,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.48", ] diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index bdad4ab..7d40dd8 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -2,9 +2,7 @@ name = "subxt_example_codegen" version = "0.1.0" edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - +resolver = "2" [features] default = ["web"] @@ -12,23 +10,19 @@ default = ["web"] native = ["subxt/native"] web = [ - "subxt/web", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "serde-wasm-bindgen", - "console_error_panic_hook", + "subxt/web", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "serde-wasm-bindgen", + "console_error_panic_hook" ] [dependencies] - -subxt = { version = "0.32.1", default-features = false, features = [ - "jsonrpsee", - "unstable-light-client", -], target_arch = "wasm32" } -subxt-metadata = { version = "0.32.1" } -subxt-codegen = { version = "0.32.1", default-features = false } -subxt-signer = { version = "0.32.1", features = ["subxt"] } +subxt = { version = "0.34.0", default-features = false, features = ["jsonrpsee", "unstable-light-client"], target_arch = "wasm32" } +subxt-metadata = { version = "0.34.0" } +subxt-codegen = { version = "0.34.0", default-features = false, features = ["web"] } +scale-typegen-description = { version = "0.1.0" } syn = "2.0.29" quote = "1.0.33" @@ -36,19 +30,12 @@ anyhow = "1.0.75" proc-macro2 = "1.0.66" heck = "0.4.1" prettyplease = "0.2.12" -scale-info = "2.9.0" +scale-info = "2.10.0" bitvec = "1.0.1" -# trybuild = "1.0.83" pollster = "0.3.0" regex = "1.5" -# scale-value = "0.12.0" -# scale-decode = "0.9.0" -# parity-scale-codec = "*" - serde = { version = "1.0.188", features = ["derive"] } - - js-sys = { version = "0.3.64", optional = true } wasm-bindgen = { version = "0.2.87", optional = true } wasm-bindgen-futures = { version = "0.4.37", optional = true } @@ -65,3 +52,10 @@ crate-type = ["cdylib", "rlib"] [package.metadata.wasm-pack.profile.dev] wasm-opt = false + +[dev-dependencies] +trybuild = "1.0.83" +scale-value = "0.12.0" +scale-decode = "0.9.0" +parity-scale-codec = "*" +wasm-bindgen-test = "0.3.17" diff --git a/codegen/polkadot.scale b/codegen/artifacts/polkadot.scale similarity index 100% rename from codegen/polkadot.scale rename to codegen/artifacts/polkadot.scale diff --git a/codegen/examples/polkadot.rs b/codegen/examples/polkadot.rs new file mode 100644 index 0000000..1ea01f4 --- /dev/null +++ b/codegen/examples/polkadot.rs @@ -0,0 +1,13 @@ +//! This example shows how to generate all call, storage, constant and runtime api example from the `polkadot.scale` metadata file found in the artifacts directory. + +use std::fs; +use subxt_example_codegen::ExampleGenerator; + +fn main() -> anyhow::Result<()> { + let example_gen = ExampleGenerator::new_from_metadata_file("artifacts/polkadot.scale")?; + let tokens = example_gen.all_examples_wrapped()?; + let syn_tree = syn::parse_file(&tokens.to_string()).unwrap(); + let pretty = prettyplease::unparse(&syn_tree); + fs::write("artifacts/polkadot.rs", pretty)?; + Ok(()) +} diff --git a/codegen/src/context.rs b/codegen/src/context.rs index 1a44240..c2a794c 100644 --- a/codegen/src/context.rs +++ b/codegen/src/context.rs @@ -1,10 +1,12 @@ use quote::format_ident; +use scale_typegen_description::scale_typegen::TypeGeneratorSettings; #[derive(Debug, Clone)] pub struct ExampleContext { pub dynamic: bool, pub inter_face_ident: syn::Ident, pub file_or_url: FileOrUrl, + pub typegen_settings: TypeGeneratorSettings, } impl ExampleContext { @@ -13,6 +15,7 @@ impl ExampleContext { dynamic, inter_face_ident: format_ident!("runtime"), file_or_url: FileOrUrl::File(file_path.into()), + typegen_settings: subxt_codegen::default_subxt_type_gen_settings(), } } @@ -21,6 +24,7 @@ impl ExampleContext { dynamic, inter_face_ident: format_ident!("runtime"), file_or_url: FileOrUrl::Url(url.into()), + typegen_settings: subxt_codegen::default_subxt_type_gen_settings(), } } } diff --git a/codegen/src/descriptions/formatting.rs b/codegen/src/descriptions/formatting.rs deleted file mode 100644 index 753fa99..0000000 --- a/codegen/src/descriptions/formatting.rs +++ /dev/null @@ -1,124 +0,0 @@ -use std::str::Chars; - -use peekmore::{PeekMore, PeekMoreIterator}; -use smallvec::SmallVec; - -pub fn format_type_description(input: &str) -> String { - #[derive(Debug, Clone, PartialEq)] - enum Scope { - Big, - Small, - } - - const SMALL_SCOPE_MAX_TOKENS: usize = 10; - /// should be called on the chars iterator shortly after open_token was encountered. - fn scope_is_small( - chars: &mut PeekMoreIterator, - open_token: char, - close_token: char, - ) -> bool { - // 1 because starting assuming bracket is open - let mut open_close_balance = 1; - for ch in chars.peek_amount(SMALL_SCOPE_MAX_TOKENS) { - let Some(ch) = ch else { - break; - }; - if *ch == open_token { - open_close_balance += 1; - } - if *ch == close_token { - open_close_balance -= 1; - if open_close_balance == 0 { - return true; - } - } - } - false - } - - fn add_indentation(output: &mut String, indent_level: i32) { - for _ in 0..indent_level { - output.push_str(" "); - } - } - - let mut output = String::new(); - let mut indent_level: i32 = 0; - - let mut tuple_level: SmallVec<[Scope; 8]> = SmallVec::new(); - let mut angle_level: SmallVec<[Scope; 8]> = SmallVec::new(); - - let mut chars_peekable = input.chars().peekmore(); - - while let Some(ch) = chars_peekable.next() { - match ch { - '{' => { - indent_level += 1; - output.push(' '); - output.push(ch); - output.push('\n'); - add_indentation(&mut output, indent_level); - } - '}' => { - indent_level -= 1; - output.push('\n'); - add_indentation(&mut output, indent_level); - output.push(ch); - } - ',' => { - output.push(ch); - - if tuple_level.last() == Some(&Scope::Small) { - output.push(' '); - } else { - output.push('\n'); - add_indentation(&mut output, indent_level); - } - } - '(' => { - output.push(ch); - - if scope_is_small(&mut chars_peekable, '(', ')') { - tuple_level.push(Scope::Small) - } else { - tuple_level.push(Scope::Big); - indent_level += 1; - output.push('\n'); - add_indentation(&mut output, indent_level); - } - } - ')' => { - if let Some(Scope::Big) = tuple_level.pop() { - indent_level -= 1; - output.push('\n'); - add_indentation(&mut output, indent_level); - } - output.push(ch); - } - '<' => { - output.push(ch); - if scope_is_small(&mut chars_peekable, '<', '>') { - angle_level.push(Scope::Small) - } else { - angle_level.push(Scope::Big); - indent_level += 1; - output.push('\n'); - add_indentation(&mut output, indent_level); - } - } - '>' => { - if let Some(Scope::Big) = angle_level.pop() { - indent_level -= 1; - output.push('\n'); - add_indentation(&mut output, indent_level); - } - - output.push(ch); - } - _ => { - output.push(ch); - } - } - } - output -} diff --git a/codegen/src/descriptions/mod.rs b/codegen/src/descriptions/mod.rs deleted file mode 100644 index 2d25033..0000000 --- a/codegen/src/descriptions/mod.rs +++ /dev/null @@ -1,257 +0,0 @@ -use std::collections::HashMap; - -use scale_info::{ - form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefArray, TypeDefBitSequence, - TypeDefCompact, TypeDefPrimitive, TypeDefSequence, TypeDefTuple, TypeDefVariant, Variant, -}; - -use self::formatting::format_type_description; - -pub mod formatting; - -pub fn type_description_formatted( - type_id: u32, - metadata: &subxt_metadata::Metadata, -) -> anyhow::Result { - let mut cache = HashMap::::new(); - let type_description = type_description(type_id, metadata.types(), &mut cache)?; - let type_description = format_type_description(&type_description); - Ok(type_description) -} - -#[derive(Clone, Debug)] -enum CachedDescription { - /// not known yet, but computation has already started - Recursive, - /// computation was finished - Description(String), -} - -fn type_description( - type_id: u32, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - match cache.get(&type_id) { - Some(CachedDescription::Recursive) => return Ok("Recursive".into()), - Some(CachedDescription::Description(description)) => return Ok(description.clone()), - _ => {} - }; - cache.insert(type_id, CachedDescription::Recursive); - let ty = registry.resolve(type_id).ok_or(anyhow::anyhow!( - "Type with id {} not found in registry", - type_id - ))?; - let ident = ty.path.ident(); - let prefix = type_def_prefix(&ty.type_def); - let mut type_def_description = type_def_type_description(&ty.type_def, registry, cache)?; - if let Some(ident) = ident { - type_def_description = format!("{}{}{}", prefix, ident, type_def_description); - cache.insert( - type_id, - CachedDescription::Description(format!("{prefix}{ident}")), - ); - } else { - cache.insert( - type_id, - CachedDescription::Description(type_def_description.clone()), - ); - type_def_description = format!("{}{}", prefix, type_def_description); - } - - // cannot avoid the clone here sadly: - - Ok(type_def_description) -} - -/// todo: clean this up -fn type_def_prefix(type_def: &TypeDef) -> &str { - match type_def { - TypeDef::Variant(_) => "enum ", - _ => "", - } -} - -fn type_def_type_description( - type_def: &TypeDef, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - match type_def { - TypeDef::Composite(composite) => { - fields_type_description(&composite.fields, registry, cache) - } - - TypeDef::Variant(variant) => variant_type_def_type_description(variant, registry, cache), - TypeDef::Sequence(sequence) => sequence_type_description(sequence, registry, cache), - TypeDef::Array(array) => array_type_description(array, registry, cache), - TypeDef::Tuple(tuple) => tuple_type_description(tuple, registry, cache), - TypeDef::Primitive(primitive) => primitive_type_description(primitive), - TypeDef::Compact(compact) => compact_type_description(compact, registry, cache), - TypeDef::BitSequence(bit_sequence) => { - bit_sequence_type_description(bit_sequence, registry, cache) - } - } -} - -fn tuple_type_description( - tuple: &TypeDefTuple, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let mut output = "(".to_string(); - let mut iter = tuple.fields.iter().peekable(); - while let Some(ty) = iter.next() { - let type_description = type_description(ty.id, registry, cache)?; - output.push_str(&type_description); - if iter.peek().is_some() { - output.push(',') - } - } - output.push(')'); - Ok(output) -} - -fn bit_sequence_type_description( - bit_sequence: &TypeDefBitSequence, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let bit_order_type = type_description(bit_sequence.bit_order_type.id, registry, cache)?; - let bit_store_type = type_description(bit_sequence.bit_store_type.id, registry, cache)?; - Ok(format!("BitSequence({bit_order_type}, {bit_store_type})")) -} - -fn sequence_type_description( - sequence: &TypeDefSequence, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let type_description = type_description(sequence.type_param.id, registry, cache)?; - Ok(format!("Vec<{type_description}>")) -} - -fn compact_type_description( - compact: &TypeDefCompact, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let type_description = type_description(compact.type_param.id, registry, cache)?; - Ok(format!("Compact({type_description})")) -} - -fn array_type_description( - array: &TypeDefArray, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let type_description = type_description(array.type_param.id, registry, cache)?; - Ok(format!("[{type_description}; {}]", array.len)) -} - -fn primitive_type_description(primitive: &TypeDefPrimitive) -> anyhow::Result { - Ok(match &primitive { - TypeDefPrimitive::Bool => "bool", - TypeDefPrimitive::Char => "char", - TypeDefPrimitive::Str => "String", - TypeDefPrimitive::U8 => "u8", - TypeDefPrimitive::U16 => "u16", - TypeDefPrimitive::U32 => "u32", - TypeDefPrimitive::U64 => "u64", - TypeDefPrimitive::U128 => "u128", - TypeDefPrimitive::U256 => "u256", - TypeDefPrimitive::I8 => "i8", - TypeDefPrimitive::I16 => "i16", - TypeDefPrimitive::I32 => "i32", - TypeDefPrimitive::I64 => "i64", - TypeDefPrimitive::I128 => "i128", - TypeDefPrimitive::I256 => "i256", - } - .into()) -} - -fn variant_type_def_type_description( - variant_type_def: &TypeDefVariant, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let mut variants_string = String::new(); - variants_string.push('{'); - let mut iter = variant_type_def.variants.iter().peekable(); - while let Some(variant) = iter.next() { - let variant_string = variant_type_description(variant, registry, cache)?; - variants_string.push_str(&variant_string); - - if iter.peek().is_some() { - variants_string.push(','); - } - } - variants_string.push('}'); - Ok(variants_string) -} - -fn variant_type_description( - variant: &Variant, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let fields_string = fields_type_description(&variant.fields, registry, cache)?; - let output = if fields_string == "()" { - variant.name.to_string() - } else if fields_string.starts_with('(') { - format!("{}{}", &variant.name, fields_string) - } else { - format!("{} {}", &variant.name, fields_string) - }; - Ok(output) -} - -fn fields_type_description( - fields: &[Field], - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - if fields.is_empty() { - return Ok("()".to_string()); - } - - let all_fields_named = fields.iter().all(|f| f.name.is_some()); - let all_fields_unnamed = fields.iter().all(|f| f.name.is_none()); - let brackets = match (all_fields_named, all_fields_unnamed) { - (true, false) => ('{', '}'), - (false, true) => ('(', ')'), - _ => { - return Err(anyhow::anyhow!( - "combination of named and unnamed fields in compound type" - )); - } - }; - - let mut fields_string = String::new(); - fields_string.push(brackets.0); - let mut iter = fields.iter().peekable(); - while let Some(field) = iter.next() { - let field_description = field_type_description(field, registry, cache)?; - fields_string.push_str(&field_description); - - if iter.peek().is_some() { - fields_string.push(',') - } - } - fields_string.push(brackets.1); - Ok(fields_string) -} - -fn field_type_description( - field: &Field, - registry: &PortableRegistry, - cache: &mut HashMap, -) -> anyhow::Result { - let type_description = type_description(field.ty.id, registry, cache)?; - let type_description_maybe_named = if let Some(name) = &field.name { - format!("{}: {}", name, type_description) - } else { - type_description - }; - Ok(type_description_maybe_named) -} diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 1c17833..99fb1b8 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -1,4 +1,5 @@ #![feature(try_trait_v2)] +#![feature(try_blocks)] //! This crate exposes a struct [ExampleGenerator] that is capable of generating code examples for calls, constants and storage entries from static metadata. //! The generated code can look like this: @@ -34,21 +35,19 @@ use heck::ToSnakeCase; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote, ToTokens}; use scale_info::{form::PortableForm, TypeDef, Variant}; +use scale_typegen_description::scale_typegen::TypeGenerator; use subxt::ext::codec::Decode; -use subxt_codegen::{DerivesRegistry, TypeGenerator, TypeSubstitutes}; use subxt_metadata::{ PalletMetadata, RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata, StorageEntryType, }; pub mod context; -pub mod descriptions; -/// empty mod, copy paste stuff in here to validate code quickly -mod generated; -pub mod values; +mod utils; #[cfg(feature = "web")] pub mod wasm_interface; +use utils::{rust_value_type_example, scale_value_type_example}; #[cfg(feature = "web")] pub use wasm_interface::*; @@ -180,10 +179,10 @@ impl<'a> ExampleGenerator<'a> { pub fn runtime_api_example_wrapped( &self, - runtime_api_trait_name: &str, + api_name: &str, method_name: &str, ) -> anyhow::Result { - let runtime_api_example = self.runtime_api_example(runtime_api_trait_name, method_name)?; + let runtime_api_example = self.runtime_api_example(api_name, method_name)?; let wrapped = self.wrap_in_main(runtime_api_example); Ok(wrapped) } @@ -242,7 +241,10 @@ impl<'a> ExampleGenerator<'a> { quote!(DecodedValueThunk) } else { let value_type = entry.entry_type().value_ty(); - let value_type_path = type_gen.resolve_type_path(value_type).prune(); + let value_type_path = type_gen + .resolve_type_path(value_type) + .map_err(|e| anyhow!("{e}"))? + .prune(); quote!(#value_type_path) }; @@ -286,7 +288,10 @@ impl<'a> ExampleGenerator<'a> { } else { let pallet_name = format_ident!("{}", pallet.name().to_snake_case()); let constant_name = format_ident!("{}", constant.name().to_snake_case()); - let constant_type_path = type_gen.resolve_type_path(constant.ty()).prune(); + let constant_type_path = type_gen + .resolve_type_path(constant.ty()) + .map_err(|e| anyhow!("{e}"))? + .prune(); quote!( let constant_query = runtime::constants().#pallet_name().#constant_name(); let api = OnlineClient::::new().await?; @@ -304,7 +309,10 @@ impl<'a> ExampleGenerator<'a> { .get(name) .ok_or_else(|| anyhow!("custom value {name} not found."))?; - let custom_value_type = type_gen.resolve_type_path(custom_value.type_id()).prune(); + let custom_value_type = type_gen + .resolve_type_path(custom_value.type_id()) + .map_err(|e| anyhow!("{e}"))? + .prune(); let interface_name = &self.context.inter_face_ident; let address_expr = if self.context.dynamic { @@ -327,14 +335,16 @@ impl<'a> ExampleGenerator<'a> { fn runtime_api_example( &self, - runtime_api_trait_name: &str, + api_name: &str, method_name: &str, ) -> anyhow::Result { let type_gen = self.type_gen(); - let runtime_api_trait = self - .metadata - .runtime_api_trait_by_name_err(runtime_api_trait_name)?; - let method = runtime_api_trait.method_by_name(method_name).ok_or_else(|| anyhow!("Method {method_name} not found for runtime API trait {runtime_api_trait_name}."))?; + let runtime_api_trait = self.metadata.runtime_api_trait_by_name_err(api_name)?; + let method = runtime_api_trait + .method_by_name(method_name) + .ok_or_else(|| { + anyhow!("Method {method_name} not found for runtime API trait {api_name}.") + })?; // defines: `let runtime_api_call = ...` let runtime_api_call_code = @@ -343,7 +353,10 @@ impl<'a> ExampleGenerator<'a> { let output_type_path = if self.context.dynamic { quote!(DecodedValueThunk) } else { - let value_type_path = type_gen.resolve_type_path(method.output_ty()).prune(); + let value_type_path = type_gen + .resolve_type_path(method.output_ty()) + .map_err(|e| anyhow!("{e}"))? + .prune(); quote!(#value_type_path) }; @@ -383,6 +396,7 @@ impl<'a> ExampleGenerator<'a> { .expect("only named fields should be call arguments"); let type_path = type_gen .resolve_field_type_path(field.ty.id, &[], field.type_name.as_deref()) + .expect("type not found") .prune(); (name, field.ty.id, type_path) }); @@ -420,16 +434,21 @@ impl<'a> ExampleGenerator<'a> { pallet: &PalletMetadata, entry: &StorageEntryMetadata, ) -> anyhow::Result { - let variables_iter = storage_entry_key_ty_ids(type_gen, entry) + let mut variables: Vec<(String, u32, TokenStream)> = vec![]; + for (i, type_id) in storage_entry_key_ty_ids(type_gen, entry) .into_iter() .enumerate() - .map(|(i, type_id)| { - let variable_name = format!("key_{i}"); - let type_path = type_gen.resolve_type_path(type_id).prune(); - (variable_name, type_id, type_path) - }); + { + let variable_name = format!("key_{i}"); + let type_path = type_gen + .resolve_type_path(type_id) + .map_err(|e| anyhow!("{e}"))? + .prune(); + variables.push((variable_name, type_id, type_path)); + } + let (variable_names, variable_declarations) = - variable_names_and_declarations(type_gen, variables_iter, &self.context)?; + variable_names_and_declarations(type_gen, variables.into_iter(), &self.context)?; let query_expr = if self.context.dynamic { let pallet_name = pallet.name(); @@ -464,22 +483,24 @@ impl<'a> ExampleGenerator<'a> { method: &RuntimeApiMethodMetadata, ) -> anyhow::Result { let variable_iter = method.inputs().map(|param| { - let type_path = type_gen.resolve_type_path(param.ty).prune(); + let type_path = type_gen + .resolve_type_path(param.ty) + .expect("type not found") + .prune(); (param.name.as_str(), param.ty, type_path) }); let (variable_names, variable_declarations) = variable_names_and_declarations(type_gen, variable_iter, &self.context)?; let call_expr = if self.context.dynamic { - let runtime_api_trait_name = runtime_api_trait.name(); + let api_name = runtime_api_trait.name(); let method_name = method.name(); let key_vec = variable_names_to_scale_value_vec(variable_names); - quote!(subxt::dynamic::runtime_api_call(#runtime_api_trait_name, #method_name, #key_vec)) + quote!(subxt::dynamic::runtime_api_call(#api_name, #method_name, #key_vec)) } else { - let runtime_api_trait_name = - format_ident!("{}", runtime_api_trait.name().to_snake_case()); + let api_name = format_ident!("{}", runtime_api_trait.name().to_snake_case()); let method_name = format_ident!("{}", method.name().to_snake_case()); - quote!(runtime::apis().#runtime_api_trait_name().#method_name( #(#variable_names),*)) + quote!(runtime::apis().#api_name().#method_name( #(#variable_names),*)) }; let code = quote!( @@ -495,14 +516,7 @@ impl<'a> ExampleGenerator<'a> { ////////////////////////////////////////////// fn type_gen(&self) -> TypeGenerator { - TypeGenerator::new( - self.metadata.types(), - "runtime_types", - TypeSubstitutes::with_default_substitutes(&Default::default()), - DerivesRegistry::with_default_derives(&Default::default()), - Default::default(), - true, - ) + TypeGenerator::new(self.metadata.types(), &self.context.typegen_settings) } fn wrap_in_wrapper_fn(&self, code: TokenStream) -> TokenStream { @@ -590,7 +604,11 @@ pub fn storage_entry_key_ty_ids( match entry.entry_type() { StorageEntryType::Plain(_) => vec![], StorageEntryType::Map { key_ty, .. } => { - match &type_gen.resolve_type(*key_ty).type_def { + match &type_gen + .resolve_type(*key_ty) + .expect("type not found") + .type_def + { // An N-map; return each of the keys separately. TypeDef::Tuple(tuple) => tuple.fields.iter().map(|ty| ty.id).collect::>(), // A map with a single key; return the single key. @@ -608,13 +626,12 @@ fn variable_names_and_declarations( ) -> anyhow::Result<(Vec, Vec)> { let mut variable_names: Vec = vec![]; let mut variable_declarations: Vec = vec![]; - for (variable_name, type_id, type_path) in variables { let variable_name = format_ident!("{variable_name}"); let type_example = if context.dynamic { - values::dynamic_values::type_example(type_id, type_gen.types())? + scale_value_type_example(type_id, type_gen.types())? } else { - values::static_values::type_example(type_id, type_gen)? + rust_value_type_example(type_id, type_gen)? }; let type_path = if context.dynamic { @@ -638,8 +655,6 @@ pub trait PruneTypePath { impl PruneTypePath for T { fn prune(&self) -> TokenStream { - let _e: subxt::utils::AccountId32 = subxt_signer::ecdsa::dev::bob().public_key().into(); - // // WARNING: HACKY CUSTOM LOGIC // diff --git a/codegen/src/main.rs b/codegen/src/main.rs deleted file mode 100644 index 3c3fd43..0000000 --- a/codegen/src/main.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::fs; - -use subxt_example_codegen::ExampleGenerator; - -/// Make sure you have a `polkadot.scale` file at the root of this project. -/// -/// Use `cargo run` to just generate a file with all examples for `polkadot.scale` under `gen/generated.rs`. -/// You can copy this file into the empty `src/generated.rs` to have it included in the module tree and checked by rust analyzer. -fn main() -> anyhow::Result<()> { - let example_gen = ExampleGenerator::new_from_metadata_file("polkadot.scale")?; - let tokens = example_gen.all_examples_wrapped()?; - let syn_tree = syn::parse_file(&tokens.to_string()).unwrap(); - let pretty = prettyplease::unparse(&syn_tree); - fs::write("gen/generated.rs", pretty)?; - Ok(()) -} diff --git a/codegen/src/utils.rs b/codegen/src/utils.rs new file mode 100644 index 0000000..86f6dfc --- /dev/null +++ b/codegen/src/utils.rs @@ -0,0 +1,130 @@ +use anyhow::anyhow; +use proc_macro2::TokenStream; +use quote::quote; +use regex::{Captures, Regex}; +use scale_info::{form::PortableForm, PortableRegistry, Type}; +use scale_typegen_description::{ + rust_value_from_seed, scale_typegen::TypeGenerator, type_example::rust_value::TyMiddleware, +}; + +pub fn scale_value_type_example(id: u32, types: &PortableRegistry) -> anyhow::Result { + let value = scale_typegen_description::scale_value(id, types)?; + // A scale value that is made into a string should fit the schema the value! macro expects. + let value_string = value.to_string(); + // However there is one caveat: BitSequences. Bitsequences in the string are represented as e.g. <0110>. + // The scale value macro does not support these. But we can use the bits! macro from scale_bits e.g. bits![0,1,1,0] + let value_string = replace_bits_with_bit_macros(&value_string); + + let mut value_macro_string = format!("value!{{{value_string}}}"); + + if value_macro_string.len() > 500 { + value_macro_string = + r#"todo!("Value string is very long and will likely exceed recursion limit.")"#.into(); + } + let token_stream: TokenStream = value_macro_string + .parse() + .map_err(|_| anyhow!("Cannot convert {value_macro_string} into TokenStream."))?; + Ok(token_stream) +} + +/// replaces all occurances of bits from this: `<01011>` to this: `bits![0,1,0,1,1]` +fn replace_bits_with_bit_macros(input: &str) -> String { + let re = Regex::new(r"<([01]*)>").unwrap(); + let replacement_fn = |caps: &Captures| -> String { + let cap = caps + .get(1) + .expect("should be there because capture group specified in regex above."); + let mut bits_string: String = "bits![".into(); + for (i, bin_digit) in caps[1].chars().enumerate() { + bits_string.push(bin_digit); + if i != cap.len() - 1 { + bits_string.push(',') + } + } + bits_string.push(']'); + bits_string + }; + re.replace_all(input, replacement_fn).into_owned() +} + +pub fn rust_value_type_example( + type_id: u32, + type_gen: &TypeGenerator, +) -> anyhow::Result { + let ty_middleware: TyMiddleware = Box::new(|ty: &Type, transformer| { + fn ty_name_is(ty: &Type, str: &str) -> bool { + ty.path.ident().as_ref().map(|e| e == str).unwrap_or(false) + } + + if ty_name_is(ty, "UncheckedExtrinsic") { + let expr = quote!(subxt::utils::UncheckedExtrinsic::new(vec![1, 2, 3, 4])); + Some(Ok(expr)) + } else if ty_name_is(ty, "AccountId32") { + let expr = quote!(dev::bob().public_key().into()); + Some(Ok(expr)) + } else if ty_name_is(ty, "BTreeMap") { + let expr_or_err = try { + let key_ty = ty + .type_params + .first() + .ok_or_else(|| anyhow!("type name is BTreeMap, we expect 2 type paramters."))? + .ty + .ok_or_else(|| anyhow!("key_ty of BTreeMap has invalid type"))?; + let key_example = transformer.resolve(key_ty.id)?; + + let value_ty = ty + .type_params + .get(1) + .ok_or_else(|| anyhow!("type name is BTreeMap, we expect 2 type paramters."))? + .ty + .ok_or_else(|| anyhow!("value_ty of BTreeMap has invalid type"))?; + + let value_example = transformer.resolve(value_ty.id)?; + quote!(vec![(#key_example, #value_example)]) + }; + + Some(expr_or_err) + } else { + None + } + }); + + let ty_path_middleware: Box TokenStream> = Box::new(|tokens| { + const PATH_SEGMENTS_REPLACEMENTS: &[(&str, &str)] = &[ + ("::subxt::utils::", ""), + ("::subxt", "subxt"), + ("::std::vec::Vec", "Vec"), + ("::core::option::Option", "Option"), + ("::core::primitive::", ""), + ]; + let mut s = tokens.to_string(); + s = s.replace(' ', ""); + for (from, to) in PATH_SEGMENTS_REPLACEMENTS { + s = s.replace(from, to); + } + s.parse() + .expect("the replacement above should result in valid paths, qed.") + }); + + let result = rust_value_from_seed( + type_id, + type_gen.types(), + type_gen.settings(), + 42, + Some(ty_middleware), + Some(ty_path_middleware), + )?; + Ok(result) +} + +#[cfg(test)] +mod test { + use super::replace_bits_with_bit_macros; + use wasm_bindgen_test::*; + #[wasm_bindgen_test] + fn replace_bits() { + let input = "<01011>"; + let output = replace_bits_with_bit_macros(input); + assert_eq!(output, "bits![0,1,0,1,1]"); + } +} diff --git a/codegen/src/values/dynamic_values.rs b/codegen/src/values/dynamic_values.rs deleted file mode 100644 index bac9608..0000000 --- a/codegen/src/values/dynamic_values.rs +++ /dev/null @@ -1,160 +0,0 @@ -use anyhow::{anyhow, Ok}; -use proc_macro2::TokenStream; -use scale_info::{form::PortableForm, PortableRegistry, TypeDef, TypeDefPrimitive}; -use subxt::ext::scale_value::{BitSequence, Composite, Primitive, Value, ValueDef, Variant}; -// use scale_value::Value; -use regex::{Captures, Regex}; -// use scale_value::{BitSequence, Composite, Primitive, Value, ValueDef, Variant}; -pub fn type_example(id: u32, types: &PortableRegistry) -> anyhow::Result { - let value: Value = type_id_example(id, types)?; - // A scale value that is made into a string should fit the schema the value! macro expects. - let value_string = value.to_string(); - // However there is one caveat: BitSequences. Bitsequences in the string are represented as e.g. <0110>. - // The scale value macro does not support these. But we can use the bits! macro from scale_bits e.g. bits![0,1,1,0] - let value_string = replace_bits_with_bit_macros(&value_string); - - let mut value_macro_string = format!("value!{{{value_string}}}"); - - if value_macro_string.len() > 500 { - value_macro_string = - r#"todo!("Value string is very long and will likely exceed recursion limit.")"#.into(); - } - let token_stream: TokenStream = value_macro_string - .parse() - .map_err(|_| anyhow!("Cannot convert {value_macro_string} into TokenStream."))?; - Ok(token_stream) -} - -pub fn type_id_example(id: u32, types: &PortableRegistry) -> anyhow::Result { - let ty = types - .resolve(id) - .ok_or(anyhow!("Type with id {id} not found in registry"))?; - type_def_example(&ty.type_def, types) -} - -fn type_def_example( - type_def: &TypeDef, - types: &PortableRegistry, -) -> anyhow::Result { - match type_def { - TypeDef::Composite(composite) => { - let fields = composite.fields.iter().map(|e| (e.name.as_ref(), e.ty.id)); - let composite = fields_type_example(fields, types)?; - Ok(Value { - value: ValueDef::Composite(composite), - context: (), - }) - } - TypeDef::Variant(variant) => { - let first = variant - .variants - .first() - .ok_or_else(|| anyhow!("Variant type should have at least one variant"))?; - let fields = first.fields.iter().map(|e| (e.name.as_ref(), e.ty.id)); - let composite = fields_type_example(fields, types)?; - Ok(Value { - value: ValueDef::Variant(Variant { - name: first.name.clone(), - values: composite, - }), - context: (), - }) - } - TypeDef::Sequence(sequence) => { - let example = type_id_example(sequence.type_param.id, types)?; - Ok(Value::unnamed_composite([ - example.clone(), - example.clone(), - example, - ])) - } - TypeDef::Array(array) => { - let example = type_id_example(array.type_param.id, types)?; - let elements: Vec<_> = (0..array.len).map(|_| example.clone()).collect(); - Ok(Value::unnamed_composite(elements)) - } - TypeDef::Tuple(tuple) => { - let fields = tuple.fields.iter().map(|e| (None::<&str>, e.id)); - let composite = fields_type_example(fields, types)?; - Ok(Value { - value: ValueDef::Composite(composite), - context: (), - }) - } - TypeDef::Primitive(primitive) => Ok(primitive_type_def_example(primitive)), - TypeDef::Compact(compact) => type_id_example(compact.type_param.id, types), - TypeDef::BitSequence(_) => Ok(Value::bit_sequence(BitSequence::new())), - } -} - -fn primitive_type_def_example(primitive: &TypeDefPrimitive) -> Value { - let primitive: Primitive = match primitive { - TypeDefPrimitive::Bool => Primitive::Bool(true), - TypeDefPrimitive::Char => Primitive::Char('a'), - TypeDefPrimitive::Str => Primitive::String("Hello".into()), - TypeDefPrimitive::U8 => Primitive::U128(8), - TypeDefPrimitive::U16 => Primitive::U128(16), - TypeDefPrimitive::U32 => Primitive::U128(32), - TypeDefPrimitive::U64 => Primitive::U128(64), - TypeDefPrimitive::U128 => Primitive::U128(128), - TypeDefPrimitive::U256 => Primitive::U256(Default::default()), - TypeDefPrimitive::I8 => Primitive::I128(8), - TypeDefPrimitive::I16 => Primitive::I128(16), - TypeDefPrimitive::I32 => Primitive::I128(32), - TypeDefPrimitive::I64 => Primitive::I128(64), - TypeDefPrimitive::I128 => Primitive::I128(128), - TypeDefPrimitive::I256 => Primitive::I256(Default::default()), - }; - Value::primitive(primitive) -} - -fn fields_type_example( - fields: impl Iterator>, u32)> + Clone, - types: &PortableRegistry, -) -> anyhow::Result> { - let all_fields_named = fields.clone().all(|e| e.0.is_some()); - let all_fields_unnamed = fields.clone().all(|e| e.0.is_none()); - match (all_fields_named, all_fields_unnamed) { - (true, true) => Ok(Composite::Unnamed(vec![])), - (true, false) => { - let mut elements: Vec<(String, Value)> = vec![]; - for (name, id) in fields { - let field_value = type_id_example(id, types)?; - let name = name.unwrap().as_ref().into(); - elements.push((name, field_value)); - } - Ok(Composite::named(elements)) - } - (false, true) => { - let mut elements = vec![]; - for (_, id) in fields { - let field_value = type_id_example(id, types)?; - elements.push(field_value); - } - Ok(Composite::unnamed(elements)) - } - (false, false) => Err(anyhow!( - "Composite should not have unnamed and named fields" - )), - } -} - -/// replaces all occurances of bits from this: `<01011>` to this: `bits![0,1,0,1,1]` -pub fn replace_bits_with_bit_macros(input: &str) -> String { - let re = Regex::new(r"<([01]*)>").unwrap(); - let replacement_fn = |caps: &Captures| -> String { - let cap = caps - .get(1) - .expect("should be there because capture group specified in regex above."); - let mut bits_string: String = "bits![".into(); - for (i, bin_digit) in caps[1].chars().enumerate() { - bits_string.push(bin_digit); - if i != cap.len() - 1 { - bits_string.push(',') - } - } - bits_string.push(']'); - bits_string - }; - re.replace_all(input, replacement_fn).into_owned() -} diff --git a/codegen/src/values/mod.rs b/codegen/src/values/mod.rs deleted file mode 100644 index a06a4bf..0000000 --- a/codegen/src/values/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod dynamic_values; -pub mod static_values; diff --git a/codegen/src/values/static_values.rs b/codegen/src/values/static_values.rs deleted file mode 100644 index 37c634e..0000000 --- a/codegen/src/values/static_values.rs +++ /dev/null @@ -1,289 +0,0 @@ -use anyhow::{anyhow, Ok}; - -use proc_macro2::{TokenStream, TokenTree}; -use quote::{format_ident, quote, ToTokens}; -use scale_info::{form::PortableForm, Field, Type, TypeDef, TypeDefPrimitive}; -use subxt_codegen::{CratePath, TypeDefGen, TypeGenerator}; - -use crate::PruneTypePath; - -pub enum CompactMode { - // explicitely stating Compact(u32) - Expl, - // compact encoded via attribute #[codec(compact)] - Attr, -} - -pub fn type_example(id: u32, type_gen: &TypeGenerator) -> anyhow::Result { - type_example_internal(id, type_gen, CompactMode::Attr) -} - -pub fn type_example_internal( - id: u32, - type_gen: &TypeGenerator, - compact_mode: CompactMode, -) -> anyhow::Result { - let ty = type_gen.resolve_type(id); - type_def_example(type_gen, id, &ty, compact_mode) -} - -fn type_def_example( - type_gen: &TypeGenerator, - id: u32, - ty: &Type, - compact_mode: CompactMode, -) -> anyhow::Result { - fn last_path_segment(ty: &Type, s: &str) -> bool { - ty.path.segments.last().map_or(false, |e| e == s) - } - - // - // WARNING: HACKY CUSTOM LOGIC - // - // cannot use normal construction for `subxt::utils::UncheckedExtrinsic`, because phantom data is private. - if last_path_segment(ty, "UncheckedExtrinsic") { - return Ok(quote!(subxt::utils::UncheckedExtrinsic::new(vec![ - 1, 2, 3, 4 - ]))); - } - - // - // WARNING: HACKY CUSTOM LOGIC - // - // BtreeMaps are replaced by KeyedVec = Vec, causes problems because the type alias is seen as a 1 element typle struct -> wrong example generation - if last_path_segment(ty, "BTreeMap") { - let key_ty = ty - .type_params - .get(0) - .ok_or_else(|| anyhow!("type name is BTreeMap, we expect 2 type paramters."))? - .ty - .ok_or_else(|| anyhow!("key has no known type"))?; - let value_ty = ty - .type_params - .get(1) - .ok_or_else(|| anyhow!("type name is BTreeMap, we expect 2 type paramters."))? - .ty - .ok_or_else(|| anyhow!("key has no known type"))?; - - let key_example = type_example(key_ty.id, type_gen)?; - let value_example = type_example(value_ty.id, type_gen)?; - return Ok(quote!(vec![(#key_example, #value_example)])); - } - - // - // WARNING: HACKY CUSTOM LOGIC - // - // just makes it nicer to see AccountId examples in the generated code - if last_path_segment(ty, "AccountId32") { - return Ok(quote!(dev::bob().public_key().into())); - } - - // general handling of type definitions - match &ty.type_def { - scale_info::TypeDef::Composite(def) => { - let struct_path = resolve_type_path_omit_generics(type_gen, id); - let gen_for_unsused_params = - TypeDefGen::from_type(ty, type_gen, &CratePath::default(), false) - .expect("should work"); - let fields: TokenStream = fields_example( - type_gen, - &def.fields, - gen_for_unsused_params.has_unused_type_params(), - )?; - Ok(quote!(#struct_path #fields)) - } - scale_info::TypeDef::Variant(def) => { - // just take first variant: - let enum_path = resolve_type_path_omit_generics(type_gen, id); - let first_variant = def - .variants - .first() - .ok_or(anyhow!("variant type should have at least one variant"))?; - let variant_ident = format_ident!("{}", &first_variant.name); - // Technically we also need for phantom types here, but that is quite difficult at the moment, because we only want to check for a single variant, and TypeDefGen does not support that right now - // So for now, we set it to false. - let fields = fields_example(type_gen, &first_variant.fields, false)?; - let mut example = quote!(#enum_path::#variant_ident #fields); - - // - // WARNING: HACKY CUSTOM LOGIC - // - // Note: this makes it such that Option::None is just shown as None. - if example.to_string() == "Option :: None" { - example = quote!(None); - }; - Ok(example) - } - scale_info::TypeDef::Sequence(def) => { - // return a Vec with 2 elements: - let inner_ty = type_gen.resolve_type(def.type_param.id); - let item_code = - type_def_example(type_gen, def.type_param.id, &inner_ty, CompactMode::Expl)?; - let vec_code = quote!(vec![#item_code, #item_code, #item_code]); - Ok(vec_code) - } - scale_info::TypeDef::Array(def) => { - let inner_ty = type_gen.resolve_type(def.type_param.id); - let item_code = - type_def_example(type_gen, def.type_param.id, &inner_ty, CompactMode::Expl)?; - let inner_is_copy = type_def_is_copy(type_gen, &inner_ty.type_def); - let len = def.len as usize; - let arr_code = if inner_is_copy { - // if the item_code is an expression that is `Copy` we can use short init syntax: - quote!([#item_code;#len]) - } else { - // otherwise we need to duplicate the item_code `len` times: - let item_iter = (0..len).map(|_| &item_code); - quote!([#(#item_iter),*]) - }; - Ok(arr_code) - } - scale_info::TypeDef::Tuple(def) => { - let mut fields: Vec = vec![]; - for f in &def.fields { - let value = type_example_internal(f.id, type_gen, CompactMode::Expl)?; - fields.push(value) - } - Ok(quote!(( #(#fields),* ))) - } - scale_info::TypeDef::Primitive(def) => Ok(primitive_example(def)), - scale_info::TypeDef::Compact(def) => { - // there are actually two possibilities here: - // 1. the value is not actually compact but just tagged with { #[codec(compact)] number: u8 } in the type definition. - // --> give a normal primitive as a type example, e.g. 8 - // 2. the value is actually like (Compact, String) in the type definition. - // --> give compact type example, e.g. Compact(8) - - // How to find out? In structs, we are gonna be in case 1, otherwise (inside a tuple, array or vec) where the #[codec(compact)] is not possible, we are in case 2. - // `explicit_compact` flag is used to indicate we are in case 2. - - let inner_code = type_example_internal(def.type_param.id, type_gen, CompactMode::Expl)?; - // I used this originally, but it turns out the compact part should be omitted: - - let code = match compact_mode { - CompactMode::Expl => { - let compact_path = resolve_type_path_omit_generics(type_gen, id); - quote!(#compact_path(#inner_code)) - } - CompactMode::Attr => inner_code, - }; - - Ok(code) - } - scale_info::TypeDef::BitSequence(_def) => { - Ok(quote!(subxt::utils::bits::DecodedBits::from_iter([ - true, false, false - ]))) - } - } -} - -fn fields_example( - type_gen: &TypeGenerator, - fields: &[Field], - has_unused_type_params: bool, -) -> anyhow::Result { - let all_named = fields.iter().all(|f| f.name.is_some()); - let all_unnamed = fields.iter().all(|f| f.name.is_none()); - match (all_named, all_unnamed) { - (true, false) => { - // all fields named - let mut field_idents_and_values: Vec = vec![]; - for f in fields { - let name = f.name.as_ref().expect("safe because of check above; qed"); - let ident = format_ident!("{name}"); - let value_code = type_example_internal(f.ty.id, type_gen, CompactMode::Attr)?; - field_idents_and_values.push(quote!(#ident : #value_code)); - } - // maybe add phantom data to struct / named composite enum - let maybe_phantom = if has_unused_type_params { - quote!( __subxt_unused_type_params: ::core::marker::PhantomData ) - } else { - quote!() - }; - Ok(quote!({ #(#field_idents_and_values ,)* #maybe_phantom })) - } - (false, true) => { - // all fields unnamed - let mut field_values: Vec = vec![]; - for f in fields { - let value_code = type_example_internal(f.ty.id, type_gen, CompactMode::Attr)?; - field_values.push(value_code); - } - // maybe add phantom data to struct / named composite enum - let maybe_phantom = if has_unused_type_params { - quote!(::core::marker::PhantomData) - } else { - quote!() - }; - Ok(quote!(( #(#field_values ,)* #maybe_phantom ))) - } - (true, true) => { - // no fields - Ok(quote!()) - } - (false, false) => { - // mixed fields - Err(anyhow!("mixed fields in struct def")) - } - } -} - -fn primitive_example(def: &TypeDefPrimitive) -> TokenStream { - match def { - TypeDefPrimitive::Bool => quote!(false), - TypeDefPrimitive::Char => quote!('c'), - TypeDefPrimitive::Str => quote!("Hello".into()), - TypeDefPrimitive::U8 => quote!(8), - TypeDefPrimitive::U16 => quote!(16), - TypeDefPrimitive::U32 => quote!(32), - TypeDefPrimitive::U64 => quote!(64), - TypeDefPrimitive::U128 => quote!(128), - TypeDefPrimitive::U256 => quote!(256), - TypeDefPrimitive::I8 => quote!(-8), - TypeDefPrimitive::I16 => quote!(-16), - TypeDefPrimitive::I32 => quote!(-32), - TypeDefPrimitive::I64 => quote!(-64), - TypeDefPrimitive::I128 => quote!(-128), - TypeDefPrimitive::I256 => quote!(-256), - } -} - -/// Simple Heuristics. Just makes array initialization shorter if is `Copy`. -fn type_def_is_copy(type_gen: &TypeGenerator, ty: &TypeDef) -> bool { - match ty { - TypeDef::Primitive(def) => !matches!(def, TypeDefPrimitive::Str), - scale_info::TypeDef::Array(def) => { - let item_type = type_gen.resolve_type(def.type_param.id); - def.len <= 32 && type_def_is_copy(type_gen, &item_type.type_def) - } - scale_info::TypeDef::Tuple(def) => def.fields.iter().all(|f| { - let ty = type_gen.resolve_type(f.id); - type_def_is_copy(type_gen, &ty.type_def) - }), - - scale_info::TypeDef::Compact(def) => { - let ty = type_gen.resolve_type(def.type_param.id); - type_def_is_copy(type_gen, &ty.type_def) - } - _ => false, - } -} - -/// Converts e.g. HashMap => HashMap -/// -/// This is a workaround, should probably be handled with syn::Expr somehow -fn resolve_type_path_omit_generics(type_gen: &TypeGenerator, id: u32) -> TokenStream { - let path = type_gen.resolve_type_path(id).prune(); - - let path: TokenStream = path - .to_token_stream() - .into_iter() - .take_while(|t| match t { - TokenTree::Punct(p) => p.as_char() != '<', - _ => true, - }) - .collect(); - - path -} diff --git a/codegen/src/wasm_interface.rs b/codegen/src/wasm_interface.rs index 192e277..fa28935 100644 --- a/codegen/src/wasm_interface.rs +++ b/codegen/src/wasm_interface.rs @@ -6,20 +6,20 @@ use anyhow::anyhow; mod client_object; +use scale_typegen_description::type_description; use serde::Serialize; use subxt::{ - client::{LightClient, LightClientBuilder, OfflineClientT, OnlineClientT}, - ext::{codec::Decode, scale_value}, - OfflineClient, OnlineClient, PolkadotConfig, SubstrateConfig, + client::{LightClient, LightClientBuilder}, + ext::codec::Decode, + OfflineClient, OnlineClient, PolkadotConfig, }; use subxt_metadata::{Metadata, PalletMetadata, RuntimeApiMetadata}; -use syn::Meta; + use wasm_bindgen::{convert::IntoWasmAbi, prelude::*}; use crate::{ - context::ExampleContext, descriptions::type_description_formatted, format_code, - format_scale_value_string, format_type, storage_entry_key_ty_ids, ExampleGenerator, - PruneTypePath, + context::ExampleContext, format_code, format_scale_value_string, format_type, + storage_entry_key_ty_ids, ExampleGenerator, PruneTypePath, }; use self::client_object::{OfflineClientObject, OnlineClientObject}; @@ -44,14 +44,13 @@ type ConfigUsed = PolkadotConfig; #[wasm_bindgen] pub struct Client { - kind: ClientKind, offline_client: Arc>, online_client: Option>>, example_gen_dynamic: ExampleGenerator<'static>, example_gen_static: ExampleGenerator<'static>, } -pub enum ClientKind { +pub enum ClientConfig { Offline { metadata_file_name: String, client: OfflineClient, @@ -66,35 +65,35 @@ pub enum ClientKind { }, } -impl ClientKind { +impl ClientConfig { fn example_context(&self, dynamic: bool) -> ExampleContext { match &self { - ClientKind::Offline { + ClientConfig::Offline { metadata_file_name, .. } => ExampleContext::from_file(metadata_file_name, dynamic), - ClientKind::Online { url, .. } => ExampleContext::from_url(url, dynamic), - ClientKind::LightClient { .. } => ExampleContext::from_file("metadata.scale", dynamic), + ClientConfig::Online { url, .. } => ExampleContext::from_url(url, dynamic), + ClientConfig::LightClient { .. } => { + ExampleContext::from_file("metadata.scale", dynamic) + } } } } impl Client { - // dynamic lookup of constant value - - fn new(kind: ClientKind) -> Self { + fn new(config: ClientConfig) -> Self { let offline_client: Arc>; let online_client: Option>>; - (offline_client, online_client) = match &kind { - ClientKind::Offline { client, .. } => ( + (offline_client, online_client) = match &config { + ClientConfig::Offline { client, .. } => ( Arc::new(client.clone()) as Arc>, None, ), - ClientKind::Online { client, .. } => ( + ClientConfig::Online { client, .. } => ( Arc::new(client.clone()) as Arc>, Some(Arc::new(client.clone()) as Arc>), ), - ClientKind::LightClient { client, .. } => ( + ClientConfig::LightClient { client, .. } => ( Arc::new(client.clone()) as Arc>, Some(Arc::new(client.clone()) as Arc>), ), @@ -102,11 +101,10 @@ impl Client { let metadata = offline_client.metadata(); let example_gen_dynamic = - ExampleGenerator::new(metadata.clone(), Cow::Owned(kind.example_context(true))); + ExampleGenerator::new(metadata.clone(), Cow::Owned(config.example_context(true))); let example_gen_static = - ExampleGenerator::new(metadata, Cow::Owned(kind.example_context(false))); + ExampleGenerator::new(metadata, Cow::Owned(config.example_context(false))); Self { - kind, offline_client, online_client, example_gen_dynamic, @@ -121,8 +119,11 @@ impl Client { /// resolves the provided type id and returns the type path as a string. fn resolve_type_path(&self, type_id: u32) -> Option { let type_gen = self.example_gen_static.type_gen(); - type_gen.types().resolve(type_id)?; - let type_path_string = type_gen.resolve_type_path(type_id).prune().to_string(); + let type_path_string = type_gen + .resolve_type_path(type_id) + .expect("typed should be present") + .prune() + .to_string(); let type_path_string = format_type(&type_path_string); Some(type_path_string) } @@ -131,7 +132,7 @@ impl Client { let type_path = self .resolve_type_path(type_id) .ok_or_else(|| anyhow!("type with id {type_id} not found."))?; - let type_structure = type_description_formatted(type_id, &self.metadata())?; + let type_structure = type_description(type_id, self.metadata().types(), true)?; Ok(TypeDescription { type_path, @@ -166,7 +167,7 @@ impl Client { metadata, ); - Ok(Client::new(ClientKind::Offline { + Ok(Client::new(ClientConfig::Offline { metadata_file_name: metadata_file_name.into(), client, })) @@ -180,7 +181,7 @@ impl Client { let client = subxt::OnlineClient::::from_url(url) .await .map_err(|e| e.to_string())?; - Ok(Client::new(ClientKind::Online { + Ok(Client::new(ClientConfig::Online { url: url.into(), client, })) @@ -198,7 +199,10 @@ impl Client { .await .map_err(|e| e.to_string())?; console_log!("light client creation successful"); - Ok(Client::new(ClientKind::LightClient { chain_spec, client })) + Ok(Client::new(ClientConfig::LightClient { + chain_spec, + client, + })) } #[wasm_bindgen(js_name = "metadataContent")] @@ -244,7 +248,7 @@ impl Client { let type_description = self.type_description(field.ty.id)?; Ok(NameAndType { - name: Cow::Borrowed(&name), + name: Cow::Borrowed(name), type_description, }) }) @@ -385,18 +389,18 @@ impl Client { } #[wasm_bindgen(js_name = "runtimeApiTraitDocs")] - pub fn runtime_api_trait_docs(&self, runtime_api_trait_name: &str) -> MyJsValue { + pub fn runtime_api_trait_docs(&self, api_name: &str) -> MyJsValue { let metadata = self.metadata(); - let runtime_api = metadata.runtime_api_trait_by_name(runtime_api_trait_name)?; + let runtime_api = metadata.runtime_api_trait_by_name(api_name)?; serde_wasm_bindgen::to_value(runtime_api.docs()) .expect("should always work") .into() } #[wasm_bindgen(js_name = "runtimeApiTraitContent")] - pub fn runtime_api_trait_content(&self, runtime_api_trait_name: &str) -> MyJsValue { + pub fn runtime_api_trait_content(&self, api_name: &str) -> MyJsValue { let metadata = self.metadata(); - let runtime_api = metadata.runtime_api_trait_by_name(runtime_api_trait_name)?; + let runtime_api = metadata.runtime_api_trait_by_name(api_name)?; let content = RuntimeApiTraitContent::from_metadata(runtime_api); serde_wasm_bindgen::to_value(&content) @@ -405,13 +409,9 @@ impl Client { } #[wasm_bindgen(js_name = "runtimeApiMethodContent")] - pub fn runtime_api_method_content( - &self, - runtime_api_trait_name: &str, - method_name: &str, - ) -> MyJsValue { + pub fn runtime_api_method_content(&self, api_name: &str, method_name: &str) -> MyJsValue { let metadata = self.metadata(); - let runtime_api = metadata.runtime_api_trait_by_name(runtime_api_trait_name)?; + let runtime_api = metadata.runtime_api_trait_by_name(api_name)?; let method = runtime_api.method_by_name(method_name)?; let input_types = method @@ -430,15 +430,15 @@ impl Client { // static code example let code_example_static = self .example_gen_static - .runtime_api_example_wrapped(runtime_api_trait_name, method_name)?; + .runtime_api_example_wrapped(api_name, method_name)?; // dynamic code example let code_example_dynamic = self .example_gen_dynamic - .runtime_api_example_wrapped(runtime_api_trait_name, method_name)?; + .runtime_api_example_wrapped(api_name, method_name)?; let content = RuntimeApiMethodContent { - runtime_api_trait_name, + api_name, method_name, docs: method.docs(), code_example_static: &format_code(&code_example_static.to_string()), @@ -470,11 +470,35 @@ impl Client { return JsValue::UNDEFINED.into(); } let value = online_client - .key_less_storage_at(pallet_name, entry_name) + .keyless_storage_at(pallet_name, entry_name) .await?; let value_str = format_scale_value_string(&value.to_string()); JsValue::from_str(&value_str).into() } + + /// Dynamically fetches the value of a keyless storage entry. + /// Only works if this is an online client. + #[wasm_bindgen(js_name = "fetchKeylessRuntimeApiValue")] + pub async fn fetch_keyless_runtime_api_value( + &self, + api_name: &str, + method_name: &str, + ) -> MyJsValue { + let online_client = self.online_client.as_ref()?; + let metadata = online_client.metadata(); + let api_metadata = metadata.runtime_api_trait_by_name_err(api_name)?; + let method = api_metadata.method_by_name(method_name)?; + + if method.inputs().len() != 0 { + return JsValue::UNDEFINED.into(); + } + let value = online_client + .call_inputless_runtime_api_method(api_name, method_name) + .await?; + + let value_str = format_scale_value_string(&value.to_string()); + JsValue::from_str(&value_str).into() + } } /// New-Type struct to implement short circuiting with `FromResidual` trait. @@ -535,7 +559,7 @@ impl<'a> MetadataContent<'a> { .collect(); // sort all pallets by name, not by index - pallets.sort_by(|a, b| a.name.cmp(&b.name)); + pallets.sort_by(|a, b| a.name.cmp(b.name)); let runtime_apis: Vec = metadata .runtime_api_traits() @@ -658,7 +682,7 @@ pub struct EventContent<'a> { #[derive(Serialize)] pub struct RuntimeApiMethodContent<'a> { - pub runtime_api_trait_name: &'a str, + pub api_name: &'a str, pub method_name: &'a str, pub docs: &'a [String], pub code_example_static: &'a str, diff --git a/codegen/src/wasm_interface/client_object.rs b/codegen/src/wasm_interface/client_object.rs index 76c8053..8e5f7af 100644 --- a/codegen/src/wasm_interface/client_object.rs +++ b/codegen/src/wasm_interface/client_object.rs @@ -72,16 +72,22 @@ impl OfflineClientObject for LightClient { #[async_trait] pub trait OnlineClientObject: OfflineClientObject { - async fn key_less_storage_at( + async fn keyless_storage_at( &self, pallet_name: &str, entry_name: &str, ) -> anyhow::Result>; + + async fn call_inputless_runtime_api_method( + &self, + api_name: &str, + method_name: &str, + ) -> anyhow::Result>; } #[async_trait] impl OnlineClientObject for OnlineClient { - async fn key_less_storage_at( + async fn keyless_storage_at( &self, pallet_name: &str, entry_name: &str, @@ -95,11 +101,29 @@ impl OnlineClientObject for OnlineClient { .to_value()?; Ok(value) } + + async fn call_inputless_runtime_api_method( + &self, + api_name: &str, + method_name: &str, + ) -> anyhow::Result> { + let api_client = self.runtime_api().at_latest().await?; + let value = api_client + .call(subxt::runtime_api::dynamic( + api_name, + method_name, + scale_value::Composite::Unnamed(vec![]), + )) + .await + .map_err(|_| anyhow!("Runtime Api Call failed"))? + .to_value()?; + Ok(value) + } } #[async_trait] impl OnlineClientObject for LightClient { - async fn key_less_storage_at( + async fn keyless_storage_at( &self, pallet_name: &str, entry_name: &str, @@ -113,4 +137,22 @@ impl OnlineClientObject for LightClient { .to_value()?; Ok(value) } + + async fn call_inputless_runtime_api_method( + &self, + api_name: &str, + method_name: &str, + ) -> anyhow::Result> { + let api_client = self.runtime_api().at_latest().await?; + let value = api_client + .call(subxt::runtime_api::dynamic( + api_name, + method_name, + scale_value::Composite::Unnamed(vec![]), + )) + .await + .map_err(|_| anyhow!("Runtime Api Call failed"))? + .to_value()?; + Ok(value) + } } diff --git a/src/components/FetchableValue.tsx b/src/components/FetchableValue.tsx new file mode 100644 index 0000000..3ae88c3 --- /dev/null +++ b/src/components/FetchableValue.tsx @@ -0,0 +1,78 @@ +import { Show, createSignal } from "solid-js"; +import { sectionHeading } from "./KeyValueTypesLayout"; + +export type Props = { + title: string; + fetch: () => Promise; + fetch_on_init: boolean; +}; + +type Loading = { + tag: "loading"; +}; +export type FetchError = { + tag: "error"; + error: string; +}; +export type ValueFetched = { + tag: "value"; + value: string; +}; + +type FetchState = Loading | FetchError | ValueFetched; + +export const FetchableValue = (props: Props) => { + const [state, setState] = createSignal({ + tag: "loading", + }); + + const fetchState = async () => { + setState({ tag: "loading" }); + const res = await props.fetch(); + setState(res); + }; + + if (props.fetch_on_init) { + fetchState(); + } + + return ( + <> +
+ {sectionHeading(props.title)} + +
+ + + + + + + +
+
+ + Loading... + + +
+ + An Error Occurred: {(state() as FetchError).error} + +
+
+ +
+ {(state() as ValueFetched).value} +
+
+
+
+ + ); +}; diff --git a/src/components/KeyValueTypesLayout.tsx b/src/components/KeyValueTypesLayout.tsx index 94b2bfe..6795e36 100644 --- a/src/components/KeyValueTypesLayout.tsx +++ b/src/components/KeyValueTypesLayout.tsx @@ -54,7 +54,7 @@ export const KeyValueTypesLayout: Component = (props: Props) => { {props.valueType && ( { const props = () => { @@ -28,12 +33,31 @@ export const RuntimeApiMethodsPage = () => { {props().docs && } There are {props().methods!.length} methods available on the{" "} {props().runtimeApi} Runtime API. - {props().methods!.map((method) => methodContent(method))} + {props().methods!.map((method) => methodContent(client()!, method))} ); }; -function methodContent(method: RuntimeApiMethodContent): JSX.Element { +function methodContent( + client: Client, + method: RuntimeApiMethodContent +): JSX.Element { + // Note: can currently only fetch keyless storage values. + async function callRuntimeApiMethod(): Promise { + const value = await client.fetchKeylessRuntimeApiValue( + method.api_name, + method.method_name + ); + if (value !== undefined) { + return { tag: "value", value }; + } else { + return { tag: "error", error: "Error executing the Runtime API Call" }; + } + } + + const shouldFetchValue = + method.input_types.length === 0 && client.hasOnlineCapabilities(); + return ( <> @@ -51,10 +75,17 @@ function methodContent(method: RuntimeApiMethodContent): JSX.Element { : undefined } valueType={{ - title: "API Call Return Type", + title: "Return Type", type_description: method.value_type, }} > + + +
{ const props = () => { @@ -34,35 +36,24 @@ export const StoragePage = () => { } }; -// undefined for storage entries that require keys to be fetched. -type StorageValueState = - | undefined - | { tag: "loading" } - | { tag: "error" } - | { tag: "value"; value: string }; - function storageEntryContent( - state: Client, + client: Client, entry: StorageEntryContent ): JSX.Element { - const [storageValue, setStorageValue] = createSignal(); - - async function fetchStorageValue() { - setStorageValue({ tag: "loading" }); - const result = await state.fetchKeylessStorageValue( + async function fetchStorageValue(): Promise { + const value = await client.fetchKeylessStorageValue( entry.pallet_name, entry.name ); - if (result !== undefined) { - setStorageValue({ tag: "value", value: result }); + if (value !== undefined) { + return { tag: "value", value }; } else { - setStorageValue({ tag: "error" }); + return { tag: "error", error: "Error fetching storage value" }; } } // fetch the value in storage when the component is loaded - if (entry.key_types.length === 0 && client()?.hasOnlineCapabilities()) { - fetchStorageValue(); - } + const shouldFetchValue = + entry.key_types.length === 0 && client.hasOnlineCapabilities(); return ( <> @@ -87,49 +78,12 @@ function storageEntryContent( type_description: entry.value_type, }} > - -
- {sectionHeading("Value")} - -
- - - - - - - -
-
- - Loading... - - -
- None -
-
- -
- - { - (storageValue() as { tag: "value"; value: string }) - .value - } - -
-
-
-
+ +
diff --git a/src/state/client.ts b/src/state/client.ts index 33e0e6b..e7df9d4 100644 --- a/src/state/client.ts +++ b/src/state/client.ts @@ -264,6 +264,22 @@ export class Client { ); return valueString as string | undefined; } + + /** + * Returns the scale value string of a storage entry + * @param apiName + * @param apiMethodName + */ + async fetchKeylessRuntimeApiValue( + apiName: string, + apiMethodName: string + ): Promise { + const valueString = await this.client.fetchKeylessRuntimeApiValue( + apiName, + apiMethodName + ); + return valueString as string | undefined; + } } export async function createClient( @@ -327,7 +343,7 @@ export interface PalletItemConent { } export interface RuntimeApiMethodContent { - runtime_api_trait_name: string; + api_name: string; method_name: string; docs: string[]; code_example_static: string;