diff --git a/Cargo.lock b/Cargo.lock index 113d639815..d258726874 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,7 +152,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "syn-solidity", "tiny-keccak", ] @@ -225,9 +225,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "approx" @@ -249,7 +249,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -794,7 +794,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -817,7 +817,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1422,7 +1422,7 @@ dependencies = [ "semver 1.0.22", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -1549,7 +1549,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2067,7 +2067,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2299,7 +2299,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2326,7 +2326,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2343,7 +2343,7 @@ checksum = "98532a60dedaebc4848cb2cba5023337cc9ea3af16a5b062633fabfd9f18fb60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2367,7 +2367,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2378,7 +2378,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2419,7 +2419,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2430,7 +2430,7 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2463,7 +2463,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "unicode-xid", ] @@ -2536,7 +2536,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.77", + "syn 2.0.87", "termcolor", "toml 0.8.12", "walkdir", @@ -2684,7 +2684,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2695,7 +2695,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2827,7 +2827,7 @@ dependencies = [ "prettier-please", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -3008,7 +3008,7 @@ checksum = "02d3379df61ff3dd871e2dde7d1bcdc0263e613c21c7579b149fd4f0ad9b1dc2" dependencies = [ "frame-metadata 17.0.0", "parity-scale-codec", - "scale-decode", + "scale-decode 0.14.0", "scale-info", "scale-type-resolver", "sp-crypto-hashing", @@ -3023,7 +3023,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -3162,7 +3162,7 @@ dependencies = [ "proc-macro2", "quote", "sp-crypto-hashing", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -3175,7 +3175,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -3186,7 +3186,7 @@ checksum = "ed971c6435503a099bdac99fe4c5bea08981709e5b5a0a8535a1856f48561191" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -3333,7 +3333,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -3486,7 +3486,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -3979,7 +3979,7 @@ dependencies = [ "subxt-metadata", "subxt-signer", "subxt-test-macro", - "syn 2.0.77", + "syn 2.0.87", "test-runtime", "tokio", "tracing", @@ -4052,7 +4052,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.64", "walkdir", ] @@ -4113,7 +4113,7 @@ dependencies = [ "rustls-pki-types", "rustls-platform-verifier", "soketto", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-rustls", "tokio-util", @@ -4141,7 +4141,7 @@ dependencies = [ "rustc-hash 2.0.0", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-stream", "tracing", @@ -4166,7 +4166,7 @@ dependencies = [ "rustls-platform-verifier", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tokio", "tower", "tracing", @@ -4192,7 +4192,7 @@ dependencies = [ "serde", "serde_json", "soketto", - "thiserror", + "thiserror 1.0.64", "tokio", "tokio-stream", "tokio-util", @@ -4209,7 +4209,7 @@ dependencies = [ "http", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -4427,7 +4427,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4441,7 +4441,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4452,7 +4452,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4463,7 +4463,7 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4587,7 +4587,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -4656,7 +4656,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -5356,7 +5356,7 @@ checksum = "94226cbd48516b7c310eb5dae8d50798c1ce73a7421dc0977c55b7fc2237a283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -6162,7 +6162,7 @@ checksum = "0cc16d1f7cee6a1ee6e8cd710e16230d59fb4935316c1704cf770e4d2335f8d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -6934,7 +6934,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.64", "ucd-trie", ] @@ -6955,7 +6955,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7587,7 +7587,7 @@ dependencies = [ "polkavm-common 0.9.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7599,7 +7599,7 @@ dependencies = [ "polkavm-common 0.10.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7609,7 +7609,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ "polkavm-derive-impl 0.9.0", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7619,7 +7619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9324fe036de37c17829af233b46ef6b5562d4a0c09bb7fdb9f8378856dee30cf" dependencies = [ "polkavm-derive-impl 0.10.0", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7721,7 +7721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22020dfcf177fcc7bf5deaf7440af371400c67c0de14c399938d8ed4fb4645d3" dependencies = [ "proc-macro2", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7813,7 +7813,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -7824,14 +7824,14 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -7977,7 +7977,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -7997,7 +7997,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -8405,7 +8405,7 @@ dependencies = [ "log", "sp-core", "sp-wasm-interface", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -8442,7 +8442,7 @@ dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface", - "thiserror", + "thiserror 1.0.64", "wasm-instrument", ] @@ -8482,6 +8482,16 @@ name = "scale-bits" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e57b1e7f6b65ed1f04e79a85a57d755ad56d76fdf1e9bddcc9ae14f71fcdcf54" +dependencies = [ + "parity-scale-codec", + "scale-type-resolver", +] + +[[package]] +name = "scale-bits" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27243ab0d2d6235072b017839c5f0cd1a3b1ce45c0f7a715363b0c7d36c76c94" dependencies = [ "parity-scale-codec", "scale-info", @@ -8496,59 +8506,72 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ae9cc099ae85ff28820210732b00f019546f36f33225f509fe25d5816864a0" dependencies = [ "derive_more 1.0.0", + "parity-scale-codec", + "scale-bits 0.6.0", + "scale-type-resolver", + "smallvec", +] + +[[package]] +name = "scale-decode" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d78196772d25b90a98046794ce0fe2588b39ebdfbdc1e45b4c6c85dd43bebad" +dependencies = [ "parity-scale-codec", "primitive-types 0.13.1", - "scale-bits", + "scale-bits 0.7.0", "scale-decode-derive", "scale-type-resolver", "smallvec", + "thiserror 2.0.0", ] [[package]] name = "scale-decode-derive" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed9401effa946b493f9f84dc03714cca98119b230497df6f3df6b84a2b03648" +checksum = "2f4b54a1211260718b92832b661025d1f1a4b6930fbadd6908e00edd265fa5f7" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "scale-encode" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9271284d05d0749c40771c46180ce89905fd95aa72a2a2fddb4b7c0aa424db" +checksum = "64901733157f9d25ef86843bd783eda439fac7efb0ad5a615d12d2cf3a29464b" dependencies = [ - "derive_more 1.0.0", "parity-scale-codec", "primitive-types 0.13.1", - "scale-bits", + "scale-bits 0.7.0", "scale-encode-derive", "scale-type-resolver", "smallvec", + "thiserror 2.0.0", ] [[package]] name = "scale-encode-derive" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "102fbc6236de6c53906c0b262f12c7aa69c2bdc604862c12728f5f4d370bc137" +checksum = "78a3993a13b4eafa89350604672c8757b7ea84c7c5947d4b3691e3169c96379b" dependencies = [ "darling", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "scale-info" -version = "2.11.4" +version = "2.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22760a375f81a31817aeaf6f5081e9ccb7ffd7f2da1809a6e3fc82b6656f10d5" +checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" dependencies = [ "bitvec", "cfg-if", @@ -8560,14 +8583,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.4" +version = "2.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc61ebe25a5c410c0e245028fc9934bf8fa4817199ef5a24a68092edfd34614" +checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] @@ -8582,22 +8605,22 @@ dependencies = [ [[package]] name = "scale-typegen" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc4c70c7fea2eef1740f0081d3fe385d8bee1eef11e9272d3bec7dc8e5438e0" +checksum = "dc3173be608895eb117cf397ab4f31f00e2ed2c7af1c6e0b8f5d51d0a0967053" dependencies = [ "proc-macro2", "quote", "scale-info", - "syn 2.0.77", - "thiserror", + "syn 2.0.87", + "thiserror 2.0.0", ] [[package]] name = "scale-typegen-description" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916c0acaebbf59523ac8beaa55017561da372f2e9fdcc90429f5e364feec378b" +checksum = "bac04b5165c69d87ec4f89e35f47cf98afe3c3bc1b91fa50770cb09e6383af7f" dependencies = [ "anyhow", "peekmore", @@ -8613,21 +8636,20 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e0ef2a0ee1e02a69ada37feb87ea1616ce9808aca072befe2d3131bf28576e" +checksum = "8ca8b26b451ecb7fd7b62b259fa28add63d12ec49bbcac0e01fcb4b5ae0c09aa" dependencies = [ "base58", "blake2", - "derive_more 1.0.0", "either", "parity-scale-codec", - "scale-bits", - "scale-decode", + "scale-bits 0.7.0", + "scale-decode 0.16.0", "scale-encode", - "scale-info", "scale-type-resolver", "serde", + "thiserror 2.0.0", "yap", ] @@ -8887,7 +8909,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -9529,7 +9551,7 @@ dependencies = [ "sp-state-machine", "sp-trie", "sp-version", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -9544,7 +9566,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -9741,7 +9763,7 @@ dependencies = [ "sp-storage", "ss58-registry", "substrate-bip39", - "thiserror", + "thiserror 1.0.64", "tracing", "w3f-bls", "zeroize", @@ -9799,7 +9821,7 @@ checksum = "b85d0f1f1e44bd8617eb2a48203ee854981229e3e79e6f468c7175d5fd37489b" dependencies = [ "quote", "sp-crypto-hashing", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -9810,7 +9832,7 @@ checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -9848,7 +9870,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -9907,7 +9929,7 @@ version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0c768c11afbe698a090386876911da4236af199cd38a5866748df4d8628aeff" dependencies = [ - "thiserror", + "thiserror 1.0.64", "zstd 0.12.4", ] @@ -9949,7 +9971,7 @@ dependencies = [ "sp-core", "sp-debug-derive", "sp-runtime", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -10046,7 +10068,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -10108,7 +10130,7 @@ dependencies = [ "sp-externalities", "sp-panic-handler", "sp-trie", - "thiserror", + "thiserror 1.0.64", "tracing", "trie-db", ] @@ -10134,7 +10156,7 @@ dependencies = [ "sp-externalities", "sp-runtime", "sp-runtime-interface", - "thiserror", + "thiserror 1.0.64", "x25519-dalek", ] @@ -10167,7 +10189,7 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -10225,7 +10247,7 @@ dependencies = [ "schnellru", "sp-core", "sp-externalities", - "thiserror", + "thiserror 1.0.64", "tracing", "trie-db", "trie-root", @@ -10246,7 +10268,7 @@ dependencies = [ "sp-runtime", "sp-std", "sp-version-proc-macro", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -10258,7 +10280,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -10497,7 +10519,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -10565,8 +10587,8 @@ dependencies = [ "parity-scale-codec", "polkadot-sdk", "primitive-types 0.13.1", - "scale-bits", - "scale-decode", + "scale-bits 0.7.0", + "scale-decode 0.16.0", "scale-encode", "scale-info", "scale-value", @@ -10577,7 +10599,7 @@ dependencies = [ "subxt-macro", "subxt-metadata", "subxt-signer", - "thiserror", + "thiserror 2.0.0", "tokio", "tokio-util", "tower", @@ -10613,8 +10635,8 @@ dependencies = [ "subxt-codegen", "subxt-metadata", "subxt-utils-fetchmetadata", - "syn 2.0.77", - "thiserror", + "syn 2.0.87", + "thiserror 2.0.0", "tokio", ] @@ -10631,8 +10653,8 @@ dependencies = [ "scale-info", "scale-typegen", "subxt-metadata", - "syn 2.0.77", - "thiserror", + "syn 2.0.87", + "thiserror 2.0.0", ] [[package]] @@ -10653,8 +10675,8 @@ dependencies = [ "parity-scale-codec", "polkadot-sdk", "primitive-types 0.13.1", - "scale-bits", - "scale-decode", + "scale-bits 0.7.0", + "scale-decode 0.16.0", "scale-encode", "scale-info", "scale-value", @@ -10663,6 +10685,7 @@ dependencies = [ "subxt-macro", "subxt-metadata", "subxt-signer", + "thiserror 2.0.0", "tracing", ] @@ -10681,7 +10704,7 @@ dependencies = [ "serde_json", "smoldot", "smoldot-light", - "thiserror", + "thiserror 2.0.0", "tokio", "tokio-stream", "tracing", @@ -10703,7 +10726,7 @@ dependencies = [ "scale-typegen", "subxt-codegen", "subxt-utils-fetchmetadata", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -10718,6 +10741,7 @@ dependencies = [ "parity-scale-codec", "polkadot-sdk", "scale-info", + "thiserror 2.0.0", ] [[package]] @@ -10747,6 +10771,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "subxt-core", + "thiserror 2.0.0", "zeroize", ] @@ -10755,7 +10780,7 @@ name = "subxt-test-macro" version = "0.38.0" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -10766,7 +10791,7 @@ dependencies = [ "hex", "jsonrpsee", "parity-scale-codec", - "thiserror", + "thiserror 2.0.0", "tokio", "url", ] @@ -10784,9 +10809,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -10802,7 +10827,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -10888,7 +10913,16 @@ version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.64", +] + +[[package]] +name = "thiserror" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15291287e9bff1bc6f9ff3409ed9af665bec7a5fc8ac079ea96be07bca0e2668" +dependencies = [ + "thiserror-impl 2.0.0", ] [[package]] @@ -10899,7 +10933,18 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22efd00f33f93fa62848a7cab956c3d38c8d43095efda1decfc2b3a5dc0b8972" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -11001,7 +11046,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -11143,7 +11188,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -11435,7 +11480,7 @@ dependencies = [ "rand_core", "sha2 0.10.8", "sha3", - "thiserror", + "thiserror 1.0.64", "zeroize", ] @@ -11518,7 +11563,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "wasm-bindgen-shared", ] @@ -11552,7 +11597,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -11583,7 +11628,7 @@ dependencies = [ "strum 0.24.1", "strum_macros 0.24.3", "tempfile", - "thiserror", + "thiserror 1.0.64", "wasm-opt-cxx-sys", "wasm-opt-sys", ] @@ -11744,7 +11789,7 @@ dependencies = [ "log", "object 0.30.4", "target-lexicon", - "thiserror", + "thiserror 1.0.64", "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", @@ -11779,7 +11824,7 @@ dependencies = [ "object 0.30.4", "serde", "target-lexicon", - "thiserror", + "thiserror 1.0.64", "wasmparser", "wasmtime-types", ] @@ -11862,7 +11907,7 @@ checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", - "thiserror", + "thiserror 1.0.64", "wasmparser", ] @@ -12224,7 +12269,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -12273,9 +12318,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yap" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4524214bc4629eba08d78ceb1d6507070cc0bcbbed23af74e19e6e924a24cf" +checksum = "bfe269e7b803a5e8e20cbd97860e136529cd83bf2c9c6d37b142467e7e1f051f" [[package]] name = "zerocopy" @@ -12294,7 +12339,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -12314,7 +12359,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7180e2a7e4..03f862c6ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ resolver = "2" authors = ["Parity Technologies "] edition = "2021" version = "0.38.0" -rust-version = "1.74.0" +rust-version = "1.81.0" license = "Apache-2.0 OR GPL-3.0" repository = "https://github.com/paritytech/subxt" documentation = "https://docs.rs/subxt" @@ -94,16 +94,16 @@ proc-macro2 = "1.0.86" quote = "1.0.37" regex = { version = "1.11.0", default-features = false } scale-info = { version = "2.11.4", default-features = false } -scale-value = { version = "0.17.0", default-features = false } -scale-bits = { version = "0.6.0", default-features = false } -scale-decode = { version = "0.14.0", default-features = false } -scale-encode = { version = "0.8.0", default-features = false } -scale-typegen = "0.9.0" -scale-typegen-description = "0.9.0" +scale-value = { version = "0.18.0", default-features = false } +scale-bits = { version = "0.7.0", default-features = false } +scale-decode = { version = "0.16.0", default-features = false } +scale-encode = { version = "0.10.0", default-features = false } +scale-typegen = "0.10.0" +scale-typegen-description = "0.10.0" serde = { version = "1.0.210", default-features = false, features = ["derive"] } serde_json = { version = "1.0.128", default-features = false } syn = { version = "2.0.77", features = ["full", "extra-traits"] } -thiserror = "1.0.64" +thiserror = { version = "2.0.0", default-features = false } tokio = { version = "1.40", default-features = false } tracing = { version = "0.1.40", default-features = false } tracing-wasm = "0.2.1" diff --git a/core/Cargo.toml b/core/Cargo.toml index 17c73a89e5..19c70e2486 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,10 +19,6 @@ default = ["std"] std = [ "codec/std", "scale-info/std", - "scale-value/std", - "scale-bits/std", - "scale-decode/std", - "scale-encode/std", "frame-metadata/std", "subxt-metadata/std", "hex/std", @@ -49,6 +45,8 @@ hex = { workspace = true, default-features = false, features = ["alloc"] } serde = { workspace = true, default-features = false, features = ["derive"] } serde_json = { workspace = true, default-features = false, features = ["raw_value", "alloc"] } hashbrown = { workspace = true } +thiserror = { workspace = true, default-features = false } + # For ss58 encoding AccountId32 to serialize them properly: base58 = { workspace = true } @@ -82,4 +80,4 @@ rustdoc-args = ["--cfg", "docsrs"] default-features = true [lints] -workspace = true \ No newline at end of file +workspace = true diff --git a/core/src/error.rs b/core/src/error.rs index 000a3019cc..86362125e7 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -4,61 +4,56 @@ //! The errors that can be emitted in this crate. -use core::fmt::Display; - use alloc::boxed::Box; use alloc::string::String; use subxt_metadata::StorageHasher; +use thiserror::Error as DeriveError; /// The error emitted when something goes wrong. -#[derive(Debug)] +#[derive(Debug, DeriveError)] pub enum Error { /// Codec error. + #[error("Codec error: {0}")] Codec(codec::Error), /// Metadata error. - Metadata(MetadataError), + #[error(transparent)] + Metadata(#[from] MetadataError), /// Storage address error. - StorageAddress(StorageAddressError), + #[error(transparent)] + StorageAddress(#[from] StorageAddressError), /// Error decoding to a [`crate::dynamic::Value`]. - Decode(scale_decode::Error), + #[error("Error decoding into dynamic value: {0}")] + Decode(#[from] scale_decode::Error), /// Error encoding from a [`crate::dynamic::Value`]. - Encode(scale_encode::Error), + #[error("Error encoding from dynamic value: {0}")] + Encode(#[from] scale_encode::Error), /// Error constructing the appropriate extrinsic params. - ExtrinsicParams(ExtrinsicParamsError), + #[error(transparent)] + ExtrinsicParams(#[from] ExtrinsicParamsError), /// Block body error. - Block(BlockError), + #[error("Error working with block_body: {0}")] + Block(#[from] BlockError), } -impl core::fmt::Display for Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Error::Codec(e) => write!(f, "Scale codec error: {e}"), - Error::Metadata(e) => write!(f, "Metadata Error: {e}"), - Error::StorageAddress(e) => write!(f, "Storage Error: {e}"), - Error::Decode(e) => write!(f, "Error decoding into dynamic value: {e}"), - Error::Encode(e) => write!(f, "Error encoding from dynamic value: {e}"), - Error::ExtrinsicParams(e) => write!(f, "Extrinsic params error: {e}"), - Error::Block(e) => write!(f, "Error working with block_body: {}", e), - } +impl From for Error { + fn from(err: scale_decode::visitor::DecodeError) -> Error { + Error::Decode(err.into()) } } -#[cfg(feature = "std")] -impl std::error::Error for Error {} - -impl_from!(ExtrinsicParamsError => Error::ExtrinsicParams); -impl_from!(BlockError => Error::Block); -impl_from!(MetadataError => Error::Metadata); -impl_from!(scale_decode::Error => Error::Decode); -impl_from!(scale_decode::visitor::DecodeError => Error::Decode); -impl_from!(scale_encode::Error => Error::Encode); -impl_from!(StorageAddressError => Error::StorageAddress); -impl_from!(codec::Error => Error::Codec); +// TODO: when `codec::Error` implements `core::Error` +// remove this impl and replace it by thiserror #[from] +impl From for Error { + fn from(err: codec::Error) -> Error { + Error::Codec(err) + } +} /// Block error -#[derive(Debug)] +#[derive(Debug, DeriveError)] pub enum BlockError { /// Leftover bytes found after decoding the extrinsic. + #[error("After decoding the extrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed")] LeftoverBytes { /// Index of the extrinsic that failed to decode. extrinsic_index: usize, @@ -66,6 +61,7 @@ pub enum BlockError { num_leftover_bytes: usize, }, /// Something went wrong decoding the extrinsic. + #[error("Failed to decode extrinsic at index {extrinsic_index}: {error}")] ExtrinsicDecodeError { /// Index of the extrinsic that failed to decode. extrinsic_index: usize, @@ -73,121 +69,74 @@ pub enum BlockError { error: ExtrinsicDecodeError, }, } -impl Display for BlockError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - BlockError::LeftoverBytes { - extrinsic_index, - num_leftover_bytes, - } => { - write!( - f, - "After decoding the extrinsic at index {extrinsic_index}, {num_leftover_bytes} bytes were left, suggesting that decoding may have failed" - ) - } - BlockError::ExtrinsicDecodeError { - extrinsic_index, - error, - } => { - write!( - f, - "Failed to decode extrinsic at index {extrinsic_index}: {error}" - ) - } - } - } -} /// An alias for [`frame_decode::extrinsics::ExtrinsicDecodeError`]. /// pub type ExtrinsicDecodeError = frame_decode::extrinsics::ExtrinsicDecodeError; /// Something went wrong trying to access details in the metadata. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, DeriveError)] #[non_exhaustive] pub enum MetadataError { /// The DispatchError type isn't available in the metadata + #[error("The DispatchError type isn't available")] DispatchErrorNotFound, /// Type not found in metadata. + #[error("Type with ID {0} not found")] TypeNotFound(u32), /// Pallet not found (index). + #[error("Pallet with index {0} not found")] PalletIndexNotFound(u8), /// Pallet not found (name). + #[error("Pallet with name {0} not found")] PalletNameNotFound(String), /// Variant not found. + #[error("Variant with index {0} not found")] VariantIndexNotFound(u8), /// Constant not found. + #[error("Constant with name {0} not found")] ConstantNameNotFound(String), /// Call not found. + #[error("Call with name {0} not found")] CallNameNotFound(String), /// Runtime trait not found. + #[error("Runtime trait with name {0} not found")] RuntimeTraitNotFound(String), /// Runtime method not found. + #[error("Runtime method with name {0} not found")] RuntimeMethodNotFound(String), /// Call type not found in metadata. + #[error("Call type not found in pallet with index {0}")] CallTypeNotFoundInPallet(u8), /// Event type not found in metadata. + #[error("Event type not found in pallet with index {0}")] EventTypeNotFoundInPallet(u8), /// Storage details not found in metadata. + #[error("Storage details not found in pallet with name {0}")] StorageNotFoundInPallet(String), /// Storage entry not found. + #[error("Storage entry {0} not found")] StorageEntryNotFound(String), /// The generated interface used is not compatible with the node. + #[error("The generated code is not compatible with the node")] IncompatibleCodegen, /// Custom value not found. + #[error("Custom value with name {0} not found")] CustomValueNameNotFound(String), } -impl Display for MetadataError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - MetadataError::DispatchErrorNotFound => { - write!(f, "The DispatchError type isn't available") - } - MetadataError::TypeNotFound(e) => write!(f, "Type with ID {e} not found"), - MetadataError::PalletIndexNotFound(e) => write!(f, "Pallet with index {e} not found"), - MetadataError::PalletNameNotFound(e) => write!(f, "Pallet with name {e} not found"), - MetadataError::VariantIndexNotFound(e) => write!(f, "Variant with index {e} not found"), - MetadataError::ConstantNameNotFound(e) => write!(f, "Constant with name {e} not found"), - MetadataError::CallNameNotFound(e) => write!(f, "Call with name {e} not found"), - MetadataError::RuntimeTraitNotFound(e) => { - write!(f, "Runtime trait with name {e} not found") - } - MetadataError::RuntimeMethodNotFound(e) => { - write!(f, "Runtime method with name {e} not found") - } - MetadataError::CallTypeNotFoundInPallet(e) => { - write!(f, "Call type not found in pallet with index {e}") - } - MetadataError::EventTypeNotFoundInPallet(e) => { - write!(f, "Event type not found in pallet with index {e}") - } - MetadataError::StorageNotFoundInPallet(e) => { - write!(f, "Storage details not found in pallet with name {e}") - } - MetadataError::StorageEntryNotFound(e) => write!(f, "Storage entry {e} not found"), - MetadataError::IncompatibleCodegen => { - write!(f, "The generated code is not compatible with the node") - } - MetadataError::CustomValueNameNotFound(e) => { - write!(f, "Custom value with name {e} not found") - } - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for MetadataError {} /// Something went wrong trying to encode or decode a storage address. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, DeriveError)] #[non_exhaustive] pub enum StorageAddressError { /// Storage lookup does not have the expected number of keys. + #[error("Storage lookup requires {expected} keys but more keys have been provided.")] TooManyKeys { /// The number of keys provided in the storage address. expected: usize, }, /// This storage entry in the metadata does not have the correct number of hashers to fields. + #[error("Storage entry in metadata does not have the correct number of hashers to fields")] WrongNumberOfHashers { /// The number of hashers in the metadata for this storage entry. hashers: usize, @@ -195,12 +144,16 @@ pub enum StorageAddressError { fields: usize, }, /// We weren't given enough bytes to decode the storage address/key. + #[error("Not enough remaining bytes to decode the storage address/key")] NotEnoughBytes, /// We have leftover bytes after decoding the storage address. + #[error("We have leftover bytes after decoding the storage address")] TooManyBytes, /// The bytes of a storage address are not the expected address for decoding the storage keys of the address. + #[error("Storage address bytes are not the expected format. Addresses need to be at least 16 bytes (pallet ++ entry) and follow a structure given by the hashers defined in the metadata")] UnexpectedAddressBytes, /// An invalid hasher was used to reconstruct a value from a chunk of bytes that is part of a storage address. Hashers where the hash does not contain the original value are invalid for this purpose. + #[error("An invalid hasher was used to reconstruct a value with type ID {ty_id} from a hash formed by a {hasher:?} hasher. This is only possible for concat-style hashers or the identity hasher")] HasherCannotReconstructKey { /// Type id of the key's type. ty_id: u32, @@ -209,47 +162,14 @@ pub enum StorageAddressError { }, } -impl Display for StorageAddressError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - StorageAddressError::TooManyKeys { expected } => write!( - f, - "Storage lookup requires {expected} keys but more keys have been provided." - ), - StorageAddressError::WrongNumberOfHashers { .. } => write!( - f, - "Storage entry in metadata does not have the correct number of hashers to fields" - ), - StorageAddressError::NotEnoughBytes => write!( - f, - "Not enough remaining bytes to decode the storage address/key" - ), - StorageAddressError::TooManyBytes => write!( - f, - "We have leftover bytes after decoding the storage address" - ), - StorageAddressError::UnexpectedAddressBytes => write!( - f, - "Storage address bytes are not the expected format. Addresses need to be at least 16 bytes (pallet ++ entry) and follow a structure given by the hashers defined in the metadata" - ), - StorageAddressError::HasherCannotReconstructKey { ty_id, hasher } => write!( - f, - "An invalid hasher was used to reconstruct a value with type ID {ty_id} from a hash formed by a {hasher:?} hasher. This is only possible for concat-style hashers or the identity hasher" - ), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for StorageAddressError {} - /// An error that can be emitted when trying to construct an instance of [`crate::config::ExtrinsicParams`], /// encode data from the instance, or match on signed extensions. -#[derive(Debug)] +#[derive(Debug, DeriveError)] #[non_exhaustive] pub enum ExtrinsicParamsError { /// Cannot find a type id in the metadata. The context provides some additional /// information about the source of the error (eg the signed extension name). + #[error("Cannot find type id '{type_id} in the metadata (context: {context})")] MissingTypeId { /// Type ID. type_id: u32, @@ -257,29 +177,13 @@ pub enum ExtrinsicParamsError { context: &'static str, }, /// A signed extension in use on some chain was not provided. + #[error("The chain expects a signed extension with the name {0}, but we did not provide one")] UnknownSignedExtension(String), /// Some custom error. + #[error("Error constructing extrinsic parameters: {0}")] Custom(Box), } -impl Display for ExtrinsicParamsError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - ExtrinsicParamsError::MissingTypeId { type_id, context } => write!( - f, - "Cannot find type id '{type_id} in the metadata (context: {context})" - ), - ExtrinsicParamsError::UnknownSignedExtension(e) => write!( - f, - "The chain expects a signed extension with the name {e}, but we did not provide one" - ), - ExtrinsicParamsError::Custom(e) => { - write!(f, "Error constructing extrinsic parameters: {e}") - } - } - } -} - /// Anything implementing this trait can be used in [`ExtrinsicParamsError::Custom`]. #[cfg(feature = "std")] pub trait CustomError: std::error::Error + Send + Sync + 'static {} @@ -292,9 +196,6 @@ pub trait CustomError: core::fmt::Debug + core::fmt::Display + Send + Sync + 'st #[cfg(not(feature = "std"))] impl CustomError for T {} -#[cfg(feature = "std")] -impl std::error::Error for ExtrinsicParamsError {} - impl From for ExtrinsicParamsError { fn from(value: core::convert::Infallible) -> Self { match value {} diff --git a/core/src/macros.rs b/core/src/macros.rs index 7b0117c959..8e25742c88 100644 --- a/core/src/macros.rs +++ b/core/src/macros.rs @@ -18,14 +18,4 @@ macro_rules! cfg_substrate_compat { }; } -macro_rules! impl_from { - ($module_path:path => $delegate_ty:ident :: $variant:ident) => { - impl From<$module_path> for $delegate_ty { - fn from(val: $module_path) -> Self { - $delegate_ty::$variant(val.into()) - } - } - }; -} - pub(crate) use {cfg_feature, cfg_substrate_compat}; diff --git a/core/src/storage/storage_key.rs b/core/src/storage/storage_key.rs index 6ecd20180b..1fb128b08a 100644 --- a/core/src/storage/storage_key.rs +++ b/core/src/storage/storage_key.rs @@ -265,6 +265,7 @@ impl StorageKey for Vec { Some(value_bytes) => { let value = scale_value::scale::decode_as_type(&mut &*value_bytes, ty_id, types)?; + result.push(value.remove_context()); } None => { diff --git a/core/src/utils/account_id.rs b/core/src/utils/account_id.rs index 714ccf2705..40fd68c42c 100644 --- a/core/src/utils/account_id.rs +++ b/core/src/utils/account_id.rs @@ -6,14 +6,13 @@ //! This doesn't contain much functionality itself, but is easy to convert to/from an `sp_core::AccountId32` //! for instance, to gain functionality without forcing a dependency on Substrate crates here. -use core::fmt::Display; - use alloc::format; use alloc::string::String; use alloc::vec; use alloc::vec::Vec; use codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; +use thiserror::Error as DeriveError; /// A 32-byte cryptographic identifier. This is a simplified version of Substrate's /// `sp_core::crypto::AccountId32`. To obtain more functionality, convert this into @@ -106,29 +105,19 @@ impl AccountId32 { } /// An error obtained from trying to interpret an SS58 encoded string into an AccountId32 -#[derive(Clone, Copy, Eq, PartialEq, Debug)] +#[derive(Clone, Copy, Eq, PartialEq, Debug, DeriveError)] #[allow(missing_docs)] pub enum FromSs58Error { + #[error("Base 58 requirement is violated")] BadBase58, + #[error("Length is bad")] BadLength, + #[error("Invalid checksum")] InvalidChecksum, + #[error("Invalid SS58 prefix byte.")] InvalidPrefix, } -impl Display for FromSs58Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - FromSs58Error::BadBase58 => write!(f, "Base 58 requirement is violated"), - FromSs58Error::BadLength => write!(f, "Length is bad"), - FromSs58Error::InvalidChecksum => write!(f, "Invalid checksum"), - FromSs58Error::InvalidPrefix => write!(f, "Invalid SS58 prefix byte."), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for FromSs58Error {} - // We do this just to get a checksum to help verify the validity of the address in to_ss58check fn ss58hash(data: &[u8]) -> Vec { use blake2::{Blake2b512, Digest}; diff --git a/core/src/utils/account_id20.rs b/core/src/utils/account_id20.rs index 48f9306349..4d32796fa9 100644 --- a/core/src/utils/account_id20.rs +++ b/core/src/utils/account_id20.rs @@ -4,13 +4,12 @@ //! `AccountId20` is a representation of Ethereum address derived from hashing the public key. -use core::fmt::Display; - use alloc::format; use alloc::string::String; use codec::{Decode, Encode}; use keccak_hash::keccak; use serde::{Deserialize, Serialize}; +use thiserror::Error as DeriveError; #[derive( Copy, @@ -72,27 +71,17 @@ impl AccountId20 { } /// An error obtained from trying to interpret a hex encoded string into an AccountId20 -#[derive(Clone, Copy, Eq, PartialEq, Debug)] +#[derive(Clone, Copy, Eq, PartialEq, Debug, DeriveError)] #[allow(missing_docs)] pub enum FromChecksumError { + #[error("Length is bad")] BadLength, + #[error("Invalid checksum")] InvalidChecksum, + #[error("Invalid checksum prefix byte.")] InvalidPrefix, } -impl Display for FromChecksumError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - FromChecksumError::BadLength => write!(f, "Length is bad"), - FromChecksumError::InvalidChecksum => write!(f, "Invalid checksum"), - FromChecksumError::InvalidPrefix => write!(f, "Invalid checksum prefix byte."), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for FromChecksumError {} - impl Serialize for AccountId20 { fn serialize(&self, serializer: S) -> Result where diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml index fb34cfa2fd..73406a43da 100644 --- a/metadata/Cargo.toml +++ b/metadata/Cargo.toml @@ -24,6 +24,7 @@ frame-metadata = { workspace = true, default-features = false, features = ["curr codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] } polkadot-sdk = { workspace = true, features = ["sp-crypto-hashing"] } hashbrown = { workspace = true } +thiserror = { workspace = true, default-features = false } [dev-dependencies] bitvec = { workspace = true, features = ["alloc"] } diff --git a/metadata/src/from_into/mod.rs b/metadata/src/from_into/mod.rs index 0c34afe375..bbb5d8c0b6 100644 --- a/metadata/src/from_into/mod.rs +++ b/metadata/src/from_into/mod.rs @@ -2,56 +2,33 @@ // This file is dual-licensed as Apache-2.0 or GPL-3.0. // see LICENSE for license details. -use core::fmt::Display; - use alloc::string::String; - +use thiserror::Error as DeriveError; mod v14; mod v15; /// An error emitted if something goes wrong converting [`frame_metadata`] /// types into [`crate::Metadata`]. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, DeriveError)] #[non_exhaustive] pub enum TryFromError { /// Type missing from type registry + #[error("Type id {0} is expected but not found in the type registry")] TypeNotFound(u32), /// Type was not a variant/enum type + #[error("Type {0} was not a variant/enum type, but is expected to be one")] VariantExpected(u32), /// An unsupported metadata version was provided. + #[error("Cannot convert v{0} metadata into Metadata type")] UnsupportedMetadataVersion(u32), /// Type name missing from type registry + #[error("Type name {0} is expected but not found in the type registry")] TypeNameNotFound(String), /// Invalid type path. + #[error("Type has an invalid path {0}")] InvalidTypePath(String), } -impl Display for TryFromError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - TryFromError::TypeNotFound(e) => write!( - f, - "Type id {e} is expected but not found in the type registry" - ), - TryFromError::VariantExpected(e) => write!( - f, - "Type {e} was not a variant/enum type, but is expected to be one" - ), - TryFromError::UnsupportedMetadataVersion(e) => { - write!(f, "Cannot convert v{e} metadata into Metadata type") - } - TryFromError::TypeNameNotFound(e) => write!( - f, - "Type name {e} is expected but not found in the type registry" - ), - TryFromError::InvalidTypePath(e) => write!(f, "Type has an invalid path {e}"), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for TryFromError {} - impl From for frame_metadata::RuntimeMetadataPrefixed { fn from(value: crate::Metadata) -> Self { let m: frame_metadata::v15::RuntimeMetadataV15 = value.into(); diff --git a/signer/Cargo.toml b/signer/Cargo.toml index fc2f5d10f6..acc6e66890 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -72,6 +72,7 @@ secp256k1 = { workspace = true, optional = true, features = [ "recovery", ] } keccak-hash = { workspace = true, optional = true } +thiserror = { workspace = true, default-features = false } # These are used if the polkadot-js-compat feature is enabled serde = { workspace = true, optional = true } diff --git a/signer/src/crypto/secret_uri.rs b/signer/src/crypto/secret_uri.rs index 0d93db202e..b30e61d881 100644 --- a/signer/src/crypto/secret_uri.rs +++ b/signer/src/crypto/secret_uri.rs @@ -2,13 +2,13 @@ // This file is dual-licensed as Apache-2.0 or GPL-3.0. // see LICENSE for license details. -use core::fmt::Display; - use super::DeriveJunction; use alloc::{string::ToString, vec::Vec}; use regex::Regex; use secrecy::SecretString; +use thiserror::Error as DeriveError; + // This code is taken from sp_core::crypto::DeriveJunction. The logic should be identical, // though the code is tweaked a touch! @@ -116,23 +116,13 @@ impl core::str::FromStr for SecretUri { } /// This is returned if `FromStr` cannot parse a string into a `SecretUri`. -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, DeriveError)] pub enum SecretUriError { /// Parsing the secret URI from a string failed; wrong format. + #[error("Invalid secret phrase format")] InvalidFormat, } -impl Display for SecretUriError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - SecretUriError::InvalidFormat => write!(f, "Invalid secret phrase format"), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for SecretUriError {} - once_static_cloned! { /// Interpret a phrase like: /// diff --git a/signer/src/ecdsa.rs b/signer/src/ecdsa.rs index 69bda852e7..b316485319 100644 --- a/signer/src/ecdsa.rs +++ b/signer/src/ecdsa.rs @@ -7,11 +7,13 @@ use codec::Encode; use polkadot_sdk::sp_crypto_hashing; use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri}; -use core::{fmt::Display, str::FromStr}; +use core::str::FromStr; use hex::FromHex; use secp256k1::{ecdsa::RecoverableSignature, Message, Secp256k1, SecretKey}; use secrecy::ExposeSecret; +use thiserror::Error as DeriveError; + const SECRET_KEY_LENGTH: usize = 32; /// Seed bytes used to generate a key pair. @@ -222,33 +224,33 @@ pub(crate) mod internal { } /// An error handed back if creating a keypair fails. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, DeriveError)] pub enum Error { /// Invalid seed. + #[error("Invalid seed (was it the wrong length?)")] InvalidSeed, /// Invalid seed. + #[error("Invalid seed for ECDSA, contained soft junction")] SoftJunction, /// Invalid phrase. + #[error("Cannot parse phrase: {0}")] Phrase(bip39::Error), /// Invalid hex. + #[error("Cannot parse hex string: {0}")] Hex(hex::FromHexError), } -impl Display for Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Error::InvalidSeed => write!(f, "Invalid seed (was it the wrong length?)"), - Error::SoftJunction => write!(f, "Invalid seed for ECDSA, contained soft junction"), - Error::Phrase(e) => write!(f, "Cannot parse phrase: {e}"), - Error::Hex(e) => write!(f, "Cannot parse hex string: {e}"), - } + +impl From for Error { + fn from(err: hex::FromHexError) -> Self { + Error::Hex(err) } } -impl_from!(bip39::Error => Error::Phrase); -impl_from!(hex::FromHexError => Error::Hex); - -#[cfg(feature = "std")] -impl std::error::Error for Error {} +impl From for Error { + fn from(err: bip39::Error) -> Self { + Error::Phrase(err) + } +} /// Dev accounts, helpful for testing but not to be used in production, /// since the secret keys are known. diff --git a/signer/src/eth.rs b/signer/src/eth.rs index bc92d51029..8a4a91158b 100644 --- a/signer/src/eth.rs +++ b/signer/src/eth.rs @@ -6,11 +6,12 @@ use crate::ecdsa; use alloc::format; -use core::fmt::{Display, Formatter}; use core::str::FromStr; use keccak_hash::keccak; use secp256k1::Message; +use thiserror::Error as DeriveError; + const SECRET_KEY_LENGTH: usize = 32; /// Bytes representing a private key. @@ -201,29 +202,16 @@ pub fn verify>(sig: &Signature, message: M, pubkey: &PublicKey) - } /// An error handed back if creating a keypair fails. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, DeriveError)] pub enum Error { /// Invalid seed. + #[error("Invalid seed (was it the wrong length?)")] InvalidSeed, /// Invalid derivation path. + #[error("Could not derive from path; some values in the path may have been >= 2^31?")] DeriveFromPath, } -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { - match self { - Error::InvalidSeed => write!(f, "Invalid seed (was it the wrong length?)"), - Error::DeriveFromPath => write!( - f, - "Could not derive from path; some values in the path may have been >= 2^31?" - ), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} - /// Dev accounts, helpful for testing but not to be used in production, /// since the secret keys are known. pub mod dev { diff --git a/signer/src/polkadot_js_compat.rs b/signer/src/polkadot_js_compat.rs index b90f87efa6..5aa155fe59 100644 --- a/signer/src/polkadot_js_compat.rs +++ b/signer/src/polkadot_js_compat.rs @@ -5,7 +5,6 @@ //! A Polkadot-JS account loader. use base64::Engine; -use core::fmt::Display; use crypto_secretbox::{ aead::{Aead, KeyInit}, Key, Nonce, XSalsa20Poly1305, @@ -13,6 +12,8 @@ use crypto_secretbox::{ use serde::Deserialize; use subxt_core::utils::AccountId32; +use thiserror::Error as DeriveError; + use crate::sr25519; /// Given a JSON keypair as exported from Polkadot-JS, this returns an [`sr25519::Keypair`] @@ -22,15 +23,19 @@ pub fn decrypt_json(json: &str, password: &str) -> Result Error::Json); -impl_from!(base64::DecodeError => Error::Base64); -impl_from!(crypto_secretbox::Error => Error::Secretbox); -impl_from!(sr25519::Error => Error::Sr25519); - -impl Display for Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Error::Json(e) => write!(f, "Invalid JSON: {e}"), - Error::UnsupportedEncoding => write!(f, "Unsupported encoding."), - Error::Base64(e) => write!(f, "Base64 decoding error: {e}"), - Error::UnsupportedScryptParameters { n, p, r } => { - write!(f, "Unsupported Scrypt parameters: N: {n}, p: {p}, r: {r}") - } - Error::Secretbox(e) => write!(f, "Decryption error: {e}"), - Error::Sr25519(e) => write!(f, "{e}"), - Error::InvalidKeys => write!(f, "The decrypted keys are not valid."), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} - #[derive(Deserialize)] struct EncryptionMetadata { /// Descriptor for the content diff --git a/signer/src/sr25519.rs b/signer/src/sr25519.rs index c566753f84..251aa92ab2 100644 --- a/signer/src/sr25519.rs +++ b/signer/src/sr25519.rs @@ -4,7 +4,7 @@ //! An sr25519 keypair implementation. -use core::{fmt::Display, str::FromStr}; +use core::str::FromStr; use crate::crypto::{seed_from_entropy, DeriveJunction, SecretUri}; @@ -15,6 +15,8 @@ use schnorrkel::{ }; use secrecy::ExposeSecret; +use thiserror::Error as DeriveError; + const SECRET_KEY_LENGTH: usize = schnorrkel::keys::MINI_SECRET_KEY_LENGTH; const SIGNING_CTX: &[u8] = b"substrate"; @@ -203,35 +205,39 @@ pub fn verify>(sig: &Signature, message: M, pubkey: &PublicKey) - } /// An error handed back if creating a keypair fails. -#[derive(Debug)] +#[derive(Debug, DeriveError)] pub enum Error { /// Invalid seed. + #[error("Invalid seed (was it the wrong length?)")] InvalidSeed, /// Invalid phrase. + #[error("Cannot parse phrase: {0}")] Phrase(bip39::Error), /// Invalid hex. + #[error("Cannot parse hex string: {0}")] Hex(hex::FromHexError), /// Signature error. + #[error("Signature error: {0}")] Signature(schnorrkel::SignatureError), } -impl_from!(bip39::Error => Error::Phrase); -impl_from!(hex::FromHexError => Error::Hex); -impl_from!(schnorrkel::SignatureError => Error::Signature); - -impl Display for Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Error::InvalidSeed => write!(f, "Invalid seed (was it the wrong length?)"), - Error::Phrase(e) => write!(f, "Cannot parse phrase: {e}"), - Error::Hex(e) => write!(f, "Cannot parse hex string: {e}"), - Error::Signature(e) => write!(f, "Signature error: {e}"), - } +impl From for Error { + fn from(value: schnorrkel::SignatureError) -> Self { + Error::Signature(value) } } -#[cfg(feature = "std")] -impl std::error::Error for Error {} +impl From for Error { + fn from(err: hex::FromHexError) -> Self { + Error::Hex(err) + } +} + +impl From for Error { + fn from(err: bip39::Error) -> Self { + Error::Phrase(err) + } +} /// Dev accounts, helpful for testing but not to be used in production, /// since the secret keys are known. diff --git a/signer/src/utils.rs b/signer/src/utils.rs index 72b6e14fa7..64358cee42 100644 --- a/signer/src/utils.rs +++ b/signer/src/utils.rs @@ -35,13 +35,3 @@ macro_rules! once_static_cloned { )+ }; } - -macro_rules! impl_from { - ($module_path:path => $delegate_ty:ident :: $variant:ident) => { - impl From<$module_path> for $delegate_ty { - fn from(val: $module_path) -> Self { - $delegate_ty::$variant(val.into()) - } - } - }; -}