diff --git a/Cargo.lock b/Cargo.lock index 56253cd..060b678 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,19 +3,36 @@ version = 3 [[package]] -name = "aho-corasick" -version = "1.1.2" +name = "addr2line" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "memchr", + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy.git?rev=6f8ebb4#6f8ebb45afca1a201a11d421ec46db0f7a1d8d08" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", ] [[package]] name = "alloy-primitives" -version = "0.5.4" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c234f92024707f224510ff82419b2be0e1d8e1fd911defcac5a085cd7f83898" +checksum = "ef197eb250c64962003cb08b90b17f0882c192f4a6f2f544809d424fd7cb0e7d" dependencies = [ "alloy-rlp", "bytes", @@ -24,6 +41,7 @@ dependencies = [ "derive_more", "hex-literal", "itoa", + "k256", "keccak-asm", "proptest", "rand", @@ -51,44 +69,44 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git?rev=3b1c310#3b1c3108ccd33c78abd7da8191e3744b4ae9a735" +source = "git+https://github.com/alloy-rs/alloy.git?rev=6f8ebb4#6f8ebb45afca1a201a11d421ec46db0f7a1d8d08" dependencies = [ "alloy-primitives", "alloy-rlp", - "itertools 0.12.0", - "jsonrpsee-types", + "itertools 0.12.1", "serde", "serde_json", - "serde_with", "thiserror", ] [[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +name = "alloy-transport" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy.git?rev=6f8ebb4#6f8ebb45afca1a201a11d421ec46db0f7a1d8d08" dependencies = [ - "libc", + "alloy-json-rpc", + "base64", + "futures-util", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "url", + "wasm-bindgen-futures", ] [[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 = "ark-ff" @@ -222,14 +240,13 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "auto_impl" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -238,6 +255,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base16ct" version = "0.2.0" @@ -256,15 +288,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde", -] - [[package]] name = "bincode" version = "1.3.3" @@ -291,15 +314,9 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bitvec" @@ -364,19 +381,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "windows-targets 0.48.5", -] - [[package]] name = "const-hex" version = "1.10.0" @@ -402,17 +406,11 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -445,41 +443,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "darling" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.38", -] - -[[package]] -name = "darling_macro" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.38", -] - [[package]] name = "der" version = "0.7.8" @@ -490,16 +453,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", - "serde", -] - [[package]] name = "derivative" version = "2.2.0" @@ -597,82 +550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-core" -version = "2.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f03e0bdc216eeb9e355b90cf610ef6c5bb8aca631f97b5ae9980ce34ea7878d" -dependencies = [ - "arrayvec", - "bytes", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", + "windows-sys", ] [[package]] @@ -722,9 +600,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", ] @@ -735,6 +613,43 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -748,15 +663,21 @@ 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", "libc", "wasi", ] +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + [[package]] name = "group" version = "0.13.0" @@ -770,15 +691,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -824,46 +739,17 @@ dependencies = [ "itoa", ] -[[package]] -name = "iana-time-zone" -version = "0.1.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "id-arena" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" -version = "0.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", @@ -878,24 +764,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -909,23 +777,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.1.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown", "serde", ] @@ -940,18 +797,18 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" 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" @@ -962,40 +819,18 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonrpsee-types" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "k256" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", "once_cell", "sha2", -] - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", + "signature", ] [[package]] @@ -1012,10 +847,12 @@ dependencies = [ name = "kinode_process_lib" version = "0.6.0" dependencies = [ + "alloy-json-rpc", + "alloy-primitives", "alloy-rpc-types", + "alloy-transport", "anyhow", "bincode", - "ethers-core", "http", "mime_guess", "rand", @@ -1040,9 +877,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libm" @@ -1052,9 +889,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" @@ -1064,9 +901,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mime" @@ -1084,6 +921,15 @@ dependencies = [ "unicase", ] +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -1116,24 +962,12 @@ dependencies = [ ] [[package]] -name = "num_enum" -version = "0.7.1" +name = "object" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" -dependencies = [ - "proc-macro-crate 2.0.1", - "proc-macro2", - "quote", - "syn 2.0.38", + "memchr", ] [[package]] @@ -1142,36 +976,11 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[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", "bitvec", @@ -1183,11 +992,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 1.3.1", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -1201,27 +1010,53 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[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 = "pest" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", "ucd-trie", ] +[[package]] +name = "pin-project" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkcs8" version = "0.10.2" @@ -1232,12 +1067,6 @@ dependencies = [ "spki", ] -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1252,61 +1081,24 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", "uint", ] [[package]] name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" dependencies = [ "toml_datetime", - "toml_edit 0.20.2", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", + "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -1319,7 +1111,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.1", + "bitflags", "lazy_static", "num-traits", "rand", @@ -1339,9 +1131,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[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", ] @@ -1391,38 +1183,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - [[package]] name = "regex-syntax" version = "0.8.2" @@ -1446,21 +1206,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "ruint" version = "1.11.1" @@ -1491,6 +1239,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e666a5496a0b2186dbcd0ff6106e29e093c15591bde62c20d3842007c6978a09" +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -1512,28 +1266,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.20", + "semver 1.0.21", ] [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "rusty-fork" version = "0.3.0" @@ -1548,33 +1296,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "scale-info" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "sec1" @@ -1601,9 +1325,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "semver-parser" @@ -1616,64 +1340,35 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.190" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", "serde", ] -[[package]] -name = "serde_with" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" -dependencies = [ - "base64", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.1.0", - "serde", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "sha2" version = "0.10.8" @@ -1685,16 +1380,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest 0.10.7", - "keccak", -] - [[package]] name = "sha3-asm" version = "0.1.0" @@ -1715,17 +1400,26 @@ dependencies = [ "rand_core", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[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 = "spdx" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19b32ed6d899ab23174302ff105c1577e45a06b08d4fe0a9dd13ce804bbbf71" +checksum = "62bde1398b09b9f93fc2fc9b9da86e362693e999d3a54a8ac47a99a5a73f638b" dependencies = [ "smallvec", ] @@ -1746,34 +1440,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.38", -] - [[package]] name = "subtle" version = "2.5.0" @@ -1793,9 +1459,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -1810,64 +1476,34 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", -] - -[[package]] -name = "time" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" -dependencies = [ - "deranged", - "itoa", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" -dependencies = [ - "time-core", + "syn 2.0.48", ] [[package]] @@ -1894,6 +1530,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +dependencies = [ + "backtrace", + "pin-project-lite", +] + [[package]] name = "toml_datetime" version = "0.6.3" @@ -1902,32 +1548,49 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.1.0", + "indexmap", "toml_datetime", "winnow", ] [[package]] -name = "toml_edit" -version = "0.20.2" +name = "tower" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ - "indexmap 2.1.0", - "toml_datetime", - "winnow", + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", ] +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-core", ] @@ -1937,6 +1600,9 @@ name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] [[package]] name = "typenum" @@ -1979,9 +1645,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" @@ -2012,9 +1678,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[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", @@ -2069,10 +1735,22 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.90" @@ -2091,7 +1769,7 @@ checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2104,21 +1782,21 @@ checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "wasm-encoder" -version = "0.38.1" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" +checksum = "e09bca7d6388637d27fb5edbeab11f56bfabcef8743c55ae34370e1e5030a071" dependencies = [ "leb128", ] [[package]] name = "wasm-metadata" -version = "0.10.14" +version = "0.10.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d835d67708f6374937c550ad8dd1d17c616ae009e3f00d7a0ac9f7825e78c36a" +checksum = "c853d3809fc9fccf3bc0ad63f4f51d8eefad0bacf88f957aa991c1d9b88b016e" dependencies = [ "anyhow", - "indexmap 2.1.0", + "indexmap", "serde", "serde_derive", "serde_json", @@ -2129,30 +1807,23 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.118.1" +version = "0.121.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" +checksum = "953cf6a7606ab31382cb1caa5ae403e77ba70c7f8e12eeda167e7040d42bfda8" dependencies = [ - "indexmap 2.1.0", - "semver 1.0.20", + "bitflags", + "indexmap", + "semver 1.0.21", ] [[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" +name = "web-sys" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ - "windows-targets 0.48.5", + "js-sys", + "wasm-bindgen", ] [[package]] @@ -2161,22 +1832,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "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", + "windows-targets", ] [[package]] @@ -2185,93 +1841,51 @@ 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", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -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" @@ -2280,26 +1894,26 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.31" +version = "0.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" +checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" dependencies = [ "memchr", ] [[package]] name = "wit-bindgen" -version = "0.16.0" -source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=efcc759#efcc7592cf3277bcb9be1034e48569c6d822b322" +version = "0.17.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=21a46c7#21a46c774532da99384f7a1877c1fcfb7a4c72d3" dependencies = [ - "bitflags 2.4.1", + "bitflags", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.16.0" -source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=efcc759#efcc7592cf3277bcb9be1034e48569c6d822b322" +version = "0.17.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=21a46c7#21a46c774532da99384f7a1877c1fcfb7a4c72d3" dependencies = [ "anyhow", "wit-component", @@ -2308,8 +1922,8 @@ dependencies = [ [[package]] name = "wit-bindgen-rust" -version = "0.16.0" -source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=efcc759#efcc7592cf3277bcb9be1034e48569c6d822b322" +version = "0.17.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=21a46c7#21a46c774532da99384f7a1877c1fcfb7a4c72d3" dependencies = [ "anyhow", "heck", @@ -2320,13 +1934,13 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.16.0" -source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=efcc759#efcc7592cf3277bcb9be1034e48569c6d822b322" +version = "0.17.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=21a46c7#21a46c774532da99384f7a1877c1fcfb7a4c72d3" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", "wit-bindgen-core", "wit-bindgen-rust", "wit-component", @@ -2334,13 +1948,13 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.18.2" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a35a2a9992898c9d27f1664001860595a4bc99d32dd3599d547412e17d7e2" +checksum = "331de496d439010797c17637d8002712b9b69110f1669164c09dfa226ad277bb" dependencies = [ "anyhow", - "bitflags 2.4.1", - "indexmap 2.1.0", + "bitflags", + "indexmap", "log", "serde", "serde_derive", @@ -2353,15 +1967,15 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15df6b7b28ce94b8be39d8df5cb21a08a4f3b9f33b631aedb4aa5776f785ead3" +checksum = "df4913a2219096373fd6512adead1fb77ecdaa59d7fc517972a7d30b12f625be" dependencies = [ "anyhow", "id-arena", - "indexmap 2.1.0", + "indexmap", "log", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_derive", "serde_json", @@ -2394,5 +2008,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.48", ] diff --git a/Cargo.toml b/Cargo.toml index d72bafb..ed4c7e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,14 +7,13 @@ license-file = "LICENSE" homepage = "https://kinode.org" repository = "https://github.com/kinode-dao/process_lib" -[features] -eth = ["ethers-core", "alloy-rpc-types"] - [dependencies] -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy.git", rev = "3b1c310", optional = true } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "6f8ebb4" } +alloy-primitives = "0.6.3" +alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "6f8ebb4" } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy.git", rev = "6f8ebb4" } anyhow = "1.0" bincode = "1.3.3" -ethers-core = { version = "2.0.11", optional = true } http = "1.0.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -22,4 +21,4 @@ rand = "0.8" thiserror = "1.0" url = "2.4.1" mime_guess = "2.0" -wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" } +wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "21a46c7" } diff --git a/kinode-wit b/kinode-wit index 373542a..aa2c8b1 160000 --- a/kinode-wit +++ b/kinode-wit @@ -1 +1 @@ -Subproject commit 373542a9a94ae61a7d216159f9f7bdf9266cd935 +Subproject commit aa2c8b11c9171b949d1991c32f58591c0e881f85 diff --git a/src/eth.rs b/src/eth.rs index 9b2426d..8dfd266 100644 --- a/src/eth.rs +++ b/src/eth.rs @@ -1,235 +1,640 @@ -use crate::*; -use crate::{Address as KiAddress, Request as KiRequest}; -use alloy_rpc_types::Log; -pub use ethers_core::types::{ - Address as EthAddress, BlockNumber, Filter, FilterBlockOption, Topic, ValueOrArray, H256, U64, +use crate::{Message, Request as KiRequest}; +pub use alloy_primitives::{Address, BlockHash, BlockNumber, Bytes, TxHash, U128, U256, U64, U8}; +pub use alloy_rpc_types::pubsub::{Params, SubscriptionKind, SubscriptionResult}; +pub use alloy_rpc_types::{ + request::{TransactionInput, TransactionRequest}, + Block, BlockId, BlockNumberOrTag, FeeHistory, Filter, FilterBlockOption, Log, Transaction, + TransactionReceipt, }; use serde::{Deserialize, Serialize}; +use std::collections::{HashMap, HashSet}; -/// The Request type that can be made to eth:distro:sys. Currently primitive, this -/// enum will expand to support more actions in the future. +// +// types mirrored from runtime module +// + +/// The Action and Request type that can be made to eth:distro:sys. Any process with messaging +/// capabilities can send this action to the eth provider. /// /// Will be serialized and deserialized using `serde_json::to_vec` and `serde_json::from_slice`. -#[derive(Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub enum EthAction { /// Subscribe to logs with a custom filter. ID is to be used to unsubscribe. - SubscribeLogs { sub_id: u64, filter: Filter }, + /// Logs come in as alloy_rpc_types::pubsub::SubscriptionResults + SubscribeLogs { + sub_id: u64, + chain_id: u64, + kind: SubscriptionKind, + params: Params, + }, /// Kill a SubscribeLogs subscription of a given ID, to stop getting updates. UnsubscribeLogs(u64), + /// Raw request. Used by kinode_process_lib. + Request { + chain_id: u64, + method: String, + params: serde_json::Value, + }, +} + +/// Incoming `Request` containing subscription updates or errors that processes will receive. +/// Can deserialize all incoming requests from eth:distro:sys to this type. +/// +/// Will be serialized and deserialized using `serde_json::to_vec` and `serde_json::from_slice`. +pub type EthSubResult = Result; + +/// Incoming type for successful subscription updates. +#[derive(Debug, Serialize, Deserialize)] +pub struct EthSub { + pub id: u64, + pub result: SubscriptionResult, +} + +/// If your subscription is closed unexpectedly, you will receive this. +#[derive(Debug, Serialize, Deserialize)] +pub struct EthSubError { + pub id: u64, + pub error: String, } /// The Response type which a process will get from requesting with an [`EthAction`] will be -/// of the form `Result<(), EthError>`, serialized and deserialized using `serde_json::to_vec` +/// of this type, serialized and deserialized using `serde_json::to_vec` /// and `serde_json::from_slice`. +/// +/// In the case of an [`EthAction::SubscribeLogs`] request, the response will indicate if +/// the subscription was successfully created or not. #[derive(Debug, Serialize, Deserialize)] +pub enum EthResponse { + Ok, + Response { value: serde_json::Value }, + Err(EthError), +} + +#[derive(Debug, Serialize, Deserialize, PartialEq)] pub enum EthError { - /// The subscription ID already existed - SubscriptionIdCollision, - /// The ethers provider threw an error when trying to subscribe - /// (contains ProviderError serialized to debug string) - ProviderError(String), - SubscriptionClosed, - /// The subscription ID was not found, so we couldn't unsubscribe. - SubscriptionNotFound, + /// provider module cannot parse message + MalformedRequest, + /// No RPC provider for the chain + NoRpcForChain, + /// Subscription closed + SubscriptionClosed(u64), + /// Invalid method + InvalidMethod(String), + /// Invalid parameters + InvalidParams, + /// Permission denied + PermissionDenied, + /// RPC timed out + RpcTimeout, + /// RPC gave garbage back + RpcMalformedResponse, } -/// The Request type which a process will get from using SubscribeLogs to subscribe -/// to a log. +/// The action type used for configuring eth:distro:sys. Only processes which have the "root" +/// capability from eth:distro:sys can successfully send this action. /// -/// Will be serialized and deserialized using `serde_json::to_vec` and `serde_json::from_slice`. +/// NOTE: changes to config will not be persisted between boots, they must be saved in .env +/// to be reflected between boots. TODO: can change this #[derive(Debug, Serialize, Deserialize)] -pub enum EthSubEvent { - Log(Log), +pub enum EthConfigAction { + /// Add a new provider to the list of providers. + AddProvider(ProviderConfig), + /// Remove a provider from the list of providers. + /// The tuple is (chain_id, node_id/rpc_url). + RemoveProvider((u64, String)), + /// make our provider public + SetPublic, + /// make our provider not-public + SetPrivate, + /// add node to whitelist on a provider + AllowNode(String), + /// remove node from whitelist on a provider + UnallowNode(String), + /// add node to blacklist on a provider + DenyNode(String), + /// remove node from blacklist on a provider + UndenyNode(String), + /// Set the list of providers to a new list. + /// Replaces all existing saved provider configs. + SetProviders(SavedConfigs), + /// Get the list of current providers as a [`SavedConfigs`] object. + GetProviders, + /// Get the current access settings. + GetAccessSettings, + /// Get the state of calls and subscriptions. Used for debugging. + GetState, } -#[derive(Debug)] -pub struct SubscribeLogsRequest { - pub request: KiRequest, - pub id: u64, - pub filter: Filter, +/// Response type from an [`EthConfigAction`] request. +#[derive(Debug, Serialize, Deserialize)] +pub enum EthConfigResponse { + Ok, + /// Response from a GetProviders request. + /// Note the [`crate::kernel_types::KnsUpdate`] will only have the correct `name` field. + /// The rest of the Update is not saved in this module. + Providers(SavedConfigs), + /// Response from a GetAccessSettings request. + AccessSettings(AccessSettings), + /// Permission denied due to missing capability + PermissionDenied, + /// Response from a GetState request + State { + active_subscriptions: HashMap>>, // None if local, Some(node_provider_name) if remote + outstanding_requests: HashSet, + }, +} + +/// Settings for our ETH provider +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct AccessSettings { + pub public: bool, // whether or not other nodes can access through us + pub allow: HashSet, // whitelist for access (only used if public == false) + pub deny: HashSet, // blacklist for access (always used) +} + +pub type SavedConfigs = Vec; + +/// Provider config. Can currently be a node or a ws provider instance. +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct ProviderConfig { + pub chain_id: u64, + pub trusted: bool, + pub provider: NodeOrRpcUrl, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum NodeOrRpcUrl { + Node { + kns_update: crate::kernel_types::KnsUpdate, + use_as_provider: bool, // for routers inside saved config + }, + RpcUrl(String), } -impl SubscribeLogsRequest { - /// Start building a new `SubscribeLogsRequest`. - pub fn new(id: u64) -> Self { - let request = KiRequest::new().target(KiAddress::new( - "our", - ProcessId::new(Some("eth"), "distro", "sys"), - )); - - SubscribeLogsRequest { - request, - id, - filter: Filter::new(), +impl std::cmp::PartialEq for NodeOrRpcUrl { + fn eq(&self, other: &str) -> bool { + match self { + NodeOrRpcUrl::Node { kns_update, .. } => kns_update.name == other, + NodeOrRpcUrl::RpcUrl(url) => url == other, } } +} + +/// An EVM chain provider. Create this object to start making RPC calls. +/// Set the chain_id to determine which chain to call: requests will fail +/// unless the node this process is running on has access to a provider +/// for that chain. +pub struct Provider { + chain_id: u64, + request_timeout: u64, +} + +impl Provider { + /// Instantiate a new provider. + pub fn new(chain_id: u64, request_timeout: u64) -> Self { + Self { + chain_id, + request_timeout, + } + } + /// Sends a request based on the specified `EthAction` and parses the response. + /// + /// This function constructs a request targeting the Ethereum distribution system, serializes the provided `EthAction`, + /// and sends it. It awaits a response with a specified timeout, then attempts to parse the response into the expected + /// type `T`. This method is generic and can be used for various Ethereum actions by specifying the appropriate `EthAction` + /// and return type `T`. + pub fn send_request_and_parse_response( + &self, + action: EthAction, + ) -> Result { + let resp = KiRequest::new() + .target(("our", "eth", "distro", "sys")) + .body(serde_json::to_vec(&action).unwrap()) + .send_and_await_response(self.request_timeout) + .unwrap() + .map_err(|_| EthError::RpcTimeout)?; - /// Attempt to send the request. - pub fn send(self) -> anyhow::Result<()> { - self.request - .body(serde_json::to_vec(&EthAction::SubscribeLogs { - sub_id: self.id, - filter: self.filter, - })?) - .send() + match resp { + Message::Response { body, .. } => match serde_json::from_slice::(&body) { + Ok(EthResponse::Response { value }) => { + serde_json::from_value::(value).map_err(|_| EthError::RpcMalformedResponse) + } + Ok(EthResponse::Err(e)) => Err(e), + _ => Err(EthError::RpcMalformedResponse), + }, + _ => Err(EthError::RpcMalformedResponse), + } } - /// Sets the inner filter object + /// Retrieves the current block number. /// - /// *NOTE:* ranges are always inclusive + /// # Returns + /// A `Result` representing the current block number. + pub fn get_block_number(&self) -> Result { + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_blockNumber".to_string(), + params: ().into(), + }; + + let res = self.send_request_and_parse_response::(action)?; + Ok(res.to::()) + } + + /// Retrieves the balance of the given address at the specified block. /// - /// # Examples + /// # Parameters + /// - `address`: The address to query the balance for. + /// - `tag`: Optional block ID to specify the block at which the balance is queried. /// - /// Match only a specific block + /// # Returns + /// A `Result` representing the balance of the address. + pub fn get_balance(&self, address: Address, tag: Option) -> Result { + let params = serde_json::to_value(( + address, + tag.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)), + )) + .unwrap(); + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getBalance".to_string(), + params, + }; + + self.send_request_and_parse_response::(action) + } + + /// Retrieves logs based on a filter. /// - /// ```rust - /// # use process_lib::eth::SubscribeLogsRequest; - /// # fn main() { - /// let request = SubscribeLogsRequest::new().select(69u64); - /// # } - /// ``` - /// This is the same as `SubscribeLogsRequest::new().from_block(1337u64).to_block(1337u64)` + /// # Parameters + /// - `filter`: The filter criteria for the logs. /// - /// Match the latest block only + /// # Returns + /// A `Result, EthError>` containing the logs that match the filter. + pub fn get_logs(&self, filter: &Filter) -> Result, EthError> { + // NOTE: filter must be encased by a tuple to be serialized correctly + let Ok(params) = serde_json::to_value((filter,)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getLogs".to_string(), + params, + }; + + self.send_request_and_parse_response::>(action) + } + + /// Retrieves the current gas price. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, BlockNumber}; - /// # fn main() { - /// let request = SubscribeLogsRequest::new().select(BlockNumber::Latest); - /// # } - /// ``` + /// # Returns + /// A `Result` representing the current gas price. + pub fn get_gas_price(&self) -> Result { + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_gasPrice".to_string(), + params: ().into(), + }; + + self.send_request_and_parse_response::(action) + } + + /// Retrieves the number of transactions sent from the given address. /// - /// Match a block by its hash + /// # Parameters + /// - `address`: The address to query the transaction count for. + /// - `tag`: Optional block ID to specify the block at which the count is queried. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, H256}; - /// # fn main() { - /// let request = SubscribeLogsRequest::new().select(H256::zero()); - /// # } - /// ``` - /// This is the same as `at_block_hash` + /// # Returns + /// A `Result` representing the number of transactions sent from the address. + pub fn get_transaction_count( + &self, + address: Address, + tag: Option, + ) -> Result { + let Ok(params) = serde_json::to_value((address, tag.unwrap_or_default())) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getTransactionCount".to_string(), + params, + }; + + self.send_request_and_parse_response::(action) + } + + /// Retrieves a block by its hash. /// - /// Match a range of blocks + /// # Parameters + /// - `hash`: The hash of the block to retrieve. + /// - `full_tx`: Whether to return full transaction objects or just their hashes. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, H256}; - /// # fn main() { - /// let request = SubscribeLogsRequest::new().select(0u64..100u64); - /// # } - /// ``` + /// # Returns + /// A `Result, EthError>` representing the block, if found. + pub fn get_block_by_hash( + &self, + hash: BlockHash, + full_tx: bool, + ) -> Result, EthError> { + let Ok(params) = serde_json::to_value((hash, full_tx)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getBlockByHash".to_string(), + params, + }; + + self.send_request_and_parse_response::>(action) + } + /// Retrieves a block by its number or tag. /// - /// Match all blocks in range `(1337..BlockNumber::Latest)` + /// # Parameters + /// - `number`: The number or tag of the block to retrieve. + /// - `full_tx`: Whether to return full transaction objects or just their hashes. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, H256}; - /// # fn main() { - /// let request = SubscribeLogsRequest::new().select(1337u64..); - /// # } - /// ``` + /// # Returns + /// A `Result, EthError>` representing the block, if found. + pub fn get_block_by_number( + &self, + number: BlockNumberOrTag, + full_tx: bool, + ) -> Result, EthError> { + let Ok(params) = serde_json::to_value((number, full_tx)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getBlockByNumber".to_string(), + params, + }; + + self.send_request_and_parse_response::>(action) + } + + /// Retrieves the storage at a given address and key. /// - /// Match all blocks in range `(BlockNumber::Earliest..1337)` + /// # Parameters + /// - `address`: The address of the storage to query. + /// - `key`: The key of the storage slot to retrieve. + /// - `tag`: Optional block ID to specify the block at which the storage is queried. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, H256}; - /// # fn main() { - /// let request = SubscribeLogsRequest::new().select(..1337u64); - /// # } - /// ``` - pub fn select(mut self, filter: impl Into) -> Self { - self.filter = self.filter.select(filter); - self - } + /// # Returns + /// A `Result` representing the data stored at the given address and key. + pub fn get_storage_at( + &self, + address: Address, + key: U256, + tag: Option, + ) -> Result { + let Ok(params) = serde_json::to_value((address, key, tag.unwrap_or_default())) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getStorageAt".to_string(), + params, + }; - /// Matches starting from a specific block - pub fn from_block>(mut self, block: T) -> Self { - self.filter = self.filter.from_block(block); - self + self.send_request_and_parse_response::(action) } - /// Matches up until a specific block - pub fn to_block>(mut self, block: T) -> Self { - self.filter = self.filter.to_block(block); - self - } + /// Retrieves the code at a given address. + /// + /// # Parameters + /// - `address`: The address of the code to query. + /// - `tag`: The block ID to specify the block at which the code is queried. + /// + /// # Returns + /// A `Result` representing the code stored at the given address. + pub fn get_code_at(&self, address: Address, tag: BlockId) -> Result { + let Ok(params) = serde_json::to_value((address, tag)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getCode".to_string(), + params, + }; - /// Matches a for a specific block hash - pub fn at_block_hash>(mut self, hash: T) -> Self { - self.filter = self.filter.at_block_hash(hash); - self + self.send_request_and_parse_response::(action) } - /// Sets the SubscribeLogs filter object + /// Retrieves a transaction by its hash. /// - /// *NOTE:* ranges are always inclusive + /// # Parameters + /// - `hash`: The hash of the transaction to retrieve. /// - /// # Examples + /// # Returns + /// A `Result, EthError>` representing the transaction, if found. + pub fn get_transaction_by_hash(&self, hash: TxHash) -> Result, EthError> { + // NOTE: hash must be encased by a tuple to be serialized correctly + let Ok(params) = serde_json::to_value((hash,)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getTransactionByHash".to_string(), + params, + }; + + self.send_request_and_parse_response::>(action) + } + + /// Retrieves the receipt of a transaction by its hash. /// - /// Match only a specific address `("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF")` + /// # Parameters + /// - `hash`: The hash of the transaction for which the receipt is requested. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, Address}; - /// # fn main() { - /// let filter = SubscribeLogsRequest::new().address("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::().unwrap()); - /// # } - /// ``` + /// # Returns + /// A `Result, EthError>` representing the transaction receipt, if found. + pub fn get_transaction_receipt( + &self, + hash: TxHash, + ) -> Result, EthError> { + // NOTE: hash must be encased by a tuple to be serialized correctly + let Ok(params) = serde_json::to_value((hash,)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_getTransactionReceipt".to_string(), + params, + }; + + self.send_request_and_parse_response::>(action) + } + + /// Estimates the amount of gas that a transaction will consume. /// - /// Match all addresses in array `(vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF", - /// "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"])` + /// # Parameters + /// - `tx`: The transaction request object containing the details of the transaction to estimate gas for. + /// - `block`: Optional block ID to specify the block at which the gas estimate should be made. /// - /// ```rust - /// # use process_lib::eth::{SubscribeLogsRequest, EthAddress, ValueOrArray}; - /// # fn main() { - /// let addresses = vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::().unwrap(),"0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8".parse::().unwrap()]; - /// let filter = SubscribeLogsRequest::new().address(addresses); - /// # } - /// ``` - pub fn address>>(mut self, address: T) -> Self { - self.filter = self.filter.address(address); - self - } + /// # Returns + /// A `Result` representing the estimated gas amount. + pub fn estimate_gas( + &self, + tx: TransactionRequest, + block: Option, + ) -> Result { + let Ok(params) = serde_json::to_value((tx, block.unwrap_or_default())) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_estimateGas".to_string(), + params, + }; - /// Given the event signature in string form, it hashes it and adds it to the topics to monitor - pub fn event(mut self, event_name: &str) -> Self { - self.filter = self.filter.event(event_name); - self + self.send_request_and_parse_response::(action) } - /// Hashes all event signatures and sets them as array to topic0 - pub fn events(mut self, events: impl IntoIterator>) -> Self { - self.filter = self.filter.events(events); - self - } + /// Retrieves the list of accounts controlled by the node. + /// + /// # Returns + /// A `Result, EthError>` representing the list of accounts. + /// Note: This function may return an empty list depending on the node's configuration and capabilities. + pub fn get_accounts(&self) -> Result, EthError> { + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_accounts".to_string(), + params: serde_json::Value::Array(vec![]), + }; - /// Sets topic0 (the event name for non-anonymous events) - pub fn topic0>(mut self, topic: T) -> Self { - self.filter = self.filter.topic0(topic); - self + self.send_request_and_parse_response::>(action) } - /// Sets the 1st indexed topic - pub fn topic1>(mut self, topic: T) -> Self { - self.filter = self.filter.topic1(topic); - self + /// Retrieves the fee history for a given range of blocks. + /// + /// # Parameters + /// - `block_count`: The number of blocks to include in the history. + /// - `last_block`: The ending block number or tag for the history range. + /// - `reward_percentiles`: A list of percentiles to report fee rewards for. + /// + /// # Returns + /// A `Result` representing the fee history for the specified range. + pub fn get_fee_history( + &self, + block_count: U256, + last_block: BlockNumberOrTag, + reward_percentiles: Vec, + ) -> Result { + let Ok(params) = serde_json::to_value((block_count, last_block, reward_percentiles)) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_feeHistory".to_string(), + params, + }; + + self.send_request_and_parse_response::(action) } - /// Sets the 2nd indexed topic - pub fn topic2>(mut self, topic: T) -> Self { - self.filter = self.filter.topic2(topic); - self + /// Executes a call transaction, which is directly executed in the VM of the node, but never mined into the blockchain. + /// + /// # Parameters + /// - `tx`: The transaction request object containing the details of the call. + /// - `block`: Optional block ID to specify the block at which the call should be made. + /// + /// # Returns + /// A `Result` representing the result of the call. + pub fn call(&self, tx: TransactionRequest, block: Option) -> Result { + let Ok(params) = serde_json::to_value((tx, block.unwrap_or_default())) else { + return Err(EthError::InvalidParams); + }; + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_call".to_string(), + params, + }; + + self.send_request_and_parse_response::(action) } - /// Sets the 3rd indexed topic - pub fn topic3>(mut self, topic: T) -> Self { - self.filter = self.filter.topic3(topic); - self + /// Sends a raw transaction to the network. + /// + /// # Parameters + /// - `tx`: The raw transaction data. + /// + /// # Returns + /// A `Result` representing the hash of the transaction once it has been sent. + pub fn send_raw_transaction(&self, tx: Bytes) -> Result { + let action = EthAction::Request { + chain_id: self.chain_id, + method: "eth_sendRawTransaction".to_string(), + // NOTE: tx must be encased by a tuple to be serialized correctly + params: serde_json::to_value((tx,)).unwrap(), + }; + + self.send_request_and_parse_response::(action) } - pub fn is_paginatable(&self) -> bool { - self.filter.is_paginatable() + /// Subscribes to logs without waiting for a confirmation. + /// + /// # Parameters + /// - `sub_id`: The subscription ID to be used for unsubscribing. + /// - `filter`: The filter criteria for the logs. + /// + /// # Returns + /// A `Result<(), EthError>` indicating whether the subscription was created. + pub fn subscribe(&self, sub_id: u64, filter: Filter) -> Result<(), EthError> { + let action = EthAction::SubscribeLogs { + sub_id, + chain_id: self.chain_id, + kind: SubscriptionKind::Logs, + params: Params::Logs(Box::new(filter)), + }; + + let Ok(body) = serde_json::to_vec(&action) else { + return Err(EthError::InvalidParams); + }; + + let resp = KiRequest::new() + .target(("our", "eth", "distro", "sys")) + .body(body) + .send_and_await_response(self.request_timeout) + .unwrap() + .map_err(|_| EthError::RpcTimeout)?; + + match resp { + Message::Response { body, .. } => { + let response = serde_json::from_slice::(&body); + match response { + Ok(EthResponse::Ok) => Ok(()), + Ok(EthResponse::Err(e)) => Err(e), + _ => Err(EthError::RpcMalformedResponse), + } + } + _ => Err(EthError::RpcMalformedResponse), + } } - /// Returns the numeric value of the `toBlock` field - pub fn get_to_block(&self) -> Option { - self.filter.get_to_block() + /// Unsubscribes from a previously created subscription. + /// + /// # Parameters + /// - `sub_id`: The subscription ID to unsubscribe from. + /// + /// # Returns + /// A `Result<(), EthError>` indicating whether the subscription was cancelled. + pub fn unsubscribe(&self, sub_id: u64) -> Result<(), EthError> { + let action = EthAction::UnsubscribeLogs(sub_id); + + let resp = KiRequest::new() + .target(("our", "eth", "distro", "sys")) + .body(serde_json::to_vec(&action).map_err(|_| EthError::MalformedRequest)?) + .send_and_await_response(self.request_timeout) + .unwrap() + .map_err(|_| EthError::RpcTimeout)?; + + match resp { + Message::Response { body, .. } => match serde_json::from_slice::(&body) { + Ok(EthResponse::Ok) => Ok(()), + _ => Err(EthError::RpcMalformedResponse), + }, + _ => Err(EthError::RpcMalformedResponse), + } } } diff --git a/src/http.rs b/src/http.rs index d557d06..aeead28 100644 --- a/src/http.rs +++ b/src/http.rs @@ -44,7 +44,9 @@ pub struct IncomingHttpRequest { source_socket_addr: Option, // will parse to SocketAddr method: String, // will parse to http::Method url: String, // will parse to url::Url + bound_path: String, // the matching path that was bound headers: HashMap, // will parse to http::HeaderMap + url_params: HashMap, query_params: HashMap, // BODY is stored in the lazy_load_blob, as bytes } @@ -94,6 +96,8 @@ pub enum HttpServerAction { /// lazy_load_blob bytes and serve them as the response to any request to this path. cache: bool, }, + /// Unbind a previously-bound HTTP path + Unbind { path: String }, /// Bind a path to receive incoming WebSocket connections. /// Doesn't need a cache since does not serve assets. WebSocketBind { @@ -111,6 +115,8 @@ pub enum HttpServerAction { encrypted: bool, extension: bool, }, + /// Unbind a previously-bound WebSocket path + WebSocketUnbind { path: String }, /// Processes will RECEIVE this kind of request when a client connects to them. /// If a process does not want this websocket open, they should issue a *request* /// containing a [`type@HttpServerAction::WebSocketClose`] message and this channel ID. @@ -233,6 +239,18 @@ impl IncomingHttpRequest { } } + /// Returns the path that was originally bound, with an optional prefix stripped. + /// The prefix would normally be the process ID as a &str, but it could be anything. + pub fn bound_path(&self, process_id_to_strip: Option<&str>) -> &str { + match process_id_to_strip { + Some(process_id) => self + .bound_path + .strip_prefix(&format!("/{}", process_id)) + .unwrap_or(&self.bound_path), + None => &self.bound_path, + } + } + pub fn path(&self) -> anyhow::Result { let url = url::Url::parse(&self.url)?; // skip the first path segment, which is the process ID. @@ -260,6 +278,10 @@ impl IncomingHttpRequest { header_map } + pub fn url_params(&self) -> &HashMap { + &self.url_params + } + pub fn query_params(&self) -> &HashMap { &self.query_params } @@ -416,6 +438,27 @@ where resp } +pub fn unbind_http_path(path: T) -> std::result::Result<(), HttpServerError> +where + T: Into, +{ + let res = KiRequest::to(("our", "http_server", "distro", "sys")) + .body(serde_json::to_vec(&HttpServerAction::Unbind { path: path.into() }).unwrap()) + .send_and_await_response(5) + .unwrap(); + let Ok(Message::Response { body, .. }) = res else { + return Err(HttpServerError::PathBindError { + error: "http_server timed out".to_string(), + }); + }; + let Ok(resp) = serde_json::from_slice::>(&body) else { + return Err(HttpServerError::PathBindError { + error: "http_server gave unexpected response".to_string(), + }); + }; + resp +} + /// Register a WebSockets path with the HTTP server. Your app must do this /// in order to receive incoming WebSocket connections. pub fn bind_ws_path( @@ -483,6 +526,27 @@ where resp } +pub fn unbind_ws_path(path: T) -> std::result::Result<(), HttpServerError> +where + T: Into, +{ + let res = KiRequest::to(("our", "http_server", "distro", "sys")) + .body(serde_json::to_vec(&HttpServerAction::WebSocketUnbind { path: path.into() }).unwrap()) + .send_and_await_response(5) + .unwrap(); + let Ok(Message::Response { body, .. }) = res else { + return Err(HttpServerError::PathBindError { + error: "http_server timed out".to_string(), + }); + }; + let Ok(resp) = serde_json::from_slice::>(&body) else { + return Err(HttpServerError::PathBindError { + error: "http_server gave unexpected response".to_string(), + }); + }; + resp +} + /// Send an HTTP response to the incoming HTTP request. pub fn send_response(status: StatusCode, headers: Option>, body: Vec) { KiResponse::new() diff --git a/src/kernel_types.rs b/src/kernel_types.rs index 1d73be8..258e9f0 100644 --- a/src/kernel_types.rs +++ b/src/kernel_types.rs @@ -1,7 +1,7 @@ use crate::kinode::process::standard as wit; use crate::{Address, ProcessId}; use serde::{Deserialize, Serialize}; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; // // process-facing kernel types, used for process @@ -198,17 +198,47 @@ impl StateError { // package types // -pub type PackageVersion = (u32, u32, u32); - -/// the type that gets deserialized from `metadata.json` in a package -#[derive(Debug, Serialize, Deserialize)] -pub struct PackageMetadata { - pub package: String, +/// Represents the metadata associated with a kinode package, which is an ERC721 compatible token. +/// This is deserialized from the `metadata.json` file in a package. +/// Fields: +/// - `name`: An optional field representing the display name of the package. This does not have to be unique, and is not used for identification purposes. +/// - `description`: An optional field providing a description of the package. +/// - `image`: An optional field containing a URL to an image representing the package. +/// - `external_url`: An optional field containing a URL for more information about the package. For example, a link to the github repository. +/// - `animation_url`: An optional field containing a URL to an animation or video representing the package. +/// - `properties`: A requried field containing important information about the package. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Erc721Metadata { + pub name: Option, + pub description: Option, + pub image: Option, + pub external_url: Option, + pub animation_url: Option, + pub properties: Erc721Properties, +} + +/// Represents critical fields of a kinode package in an ERC721 compatible format. +/// This follows the [ERC1155](https://github.com/ethereum/ercs/blob/master/ERCS/erc-1155.md#erc-1155-metadata-uri-json-schema) metadata standard. +/// +/// Fields: +/// - `package_name`: The unique name of the package, used in the `PackageId`, e.g. `package_name:publisher`. +/// - `publisher`: The KNS identity of the package publisher used in the `PackageId`, e.g. `package_name:publisher` +/// - `current_version`: A string representing the current version of the package, e.g. `1.0.0`. +/// - `mirrors`: A list of NodeIds where the package can be found, providing redundancy. +/// - `code_hashes`: A map from version names to their respective SHA-256 hashes. +/// - `license`: An optional field containing the license of the package. +/// - `screenshots`: An optional field containing a list of URLs to screenshots of the package. +/// - `wit_version`: An optional field containing the version of the WIT standard that the package adheres to. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Erc721Properties { + pub package_name: String, pub publisher: String, - pub version: PackageVersion, + pub current_version: String, + pub mirrors: Vec, + pub code_hashes: HashMap, + pub license: Option, + pub screenshots: Option>, pub wit_version: Option<(u32, u32, u32)>, - pub description: Option, - pub website: Option, } /// the type that gets deserialized from each entry in the array in `manifest.json` @@ -402,3 +432,14 @@ pub enum MessageType { Request, Response, } + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct KnsUpdate { + pub name: String, // actual username / domain name + pub owner: String, + pub node: String, // hex namehash of node + pub public_key: String, + pub ip: String, + pub port: u16, + pub routers: Vec, +} diff --git a/src/kv.rs b/src/kv.rs index 1ad3680..0aa309a 100644 --- a/src/kv.rs +++ b/src/kv.rs @@ -1,5 +1,6 @@ use crate::{get_blob, Message, PackageId, Request}; -use serde::{Deserialize, Serialize}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use std::marker::PhantomData; use thiserror::Error; /// Actions are sent to a specific key value database, "db" is the name, @@ -54,14 +55,21 @@ pub enum KvError { /// Opening or creating a kv will give you a Result. /// You can call it's impl functions to interact with it. #[derive(Debug, Serialize, Deserialize)] -pub struct Kv { +pub struct Kv { pub package_id: PackageId, pub db: String, + pub timeout: u64, + _marker: PhantomData<(K, V)>, } -impl Kv { +impl Kv +where + K: Serialize + DeserializeOwned, + V: Serialize + DeserializeOwned, +{ /// Get a value. - pub fn get(&self, key: Vec) -> anyhow::Result> { + pub fn get(&self, key: &K) -> anyhow::Result { + let key = serde_json::to_vec(key)?; let res = Request::new() .target(("our", "kv", "distro", "sys")) .body(serde_json::to_vec(&KvRequest { @@ -69,7 +77,7 @@ impl Kv { db: self.db.clone(), action: KvAction::Get { key }, })?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -81,7 +89,9 @@ impl Kv { Some(bytes) => bytes.bytes, None => return Err(anyhow::anyhow!("kv: no blob")), }; - Ok(bytes) + let value = serde_json::from_slice::(&bytes) + .map_err(|e| anyhow::anyhow!("Failed to deserialize value: {}", e))?; + Ok(value) } KvResponse::Err { error } => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), @@ -92,7 +102,10 @@ impl Kv { } /// Set a value, optionally in a transaction. - pub fn set(&self, key: Vec, value: Vec, tx_id: Option) -> anyhow::Result<()> { + pub fn set(&self, key: &K, value: &V, tx_id: Option) -> anyhow::Result<()> { + let key = serde_json::to_vec(key)?; + let value = serde_json::to_vec(value)?; + let res = Request::new() .target(("our", "kv", "distro", "sys")) .body(serde_json::to_vec(&KvRequest { @@ -101,7 +114,7 @@ impl Kv { action: KvAction::Set { key, tx_id }, })?) .blob_bytes(value) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -118,7 +131,8 @@ impl Kv { } /// Delete a value, optionally in a transaction. - pub fn delete(&self, key: Vec, tx_id: Option) -> anyhow::Result<()> { + pub fn delete(&self, key: &K, tx_id: Option) -> anyhow::Result<()> { + let key = serde_json::to_vec(key)?; let res = Request::new() .target(("our", "kv", "distro", "sys")) .body(serde_json::to_vec(&KvRequest { @@ -126,7 +140,7 @@ impl Kv { db: self.db.clone(), action: KvAction::Delete { key, tx_id }, })?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -151,7 +165,7 @@ impl Kv { db: self.db.clone(), action: KvAction::BeginTx, })?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -176,7 +190,7 @@ impl Kv { db: self.db.clone(), action: KvAction::Commit { tx_id }, })?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -194,7 +208,13 @@ impl Kv { } /// Opens or creates a kv db. -pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { +pub fn open(package_id: PackageId, db: &str, timeout: Option) -> anyhow::Result> +where + K: Serialize + DeserializeOwned, + V: Serialize + DeserializeOwned, +{ + let timeout = timeout.unwrap_or(5); + let res = Request::new() .target(("our", "kv", "distro", "sys")) .body(serde_json::to_vec(&KvRequest { @@ -202,7 +222,7 @@ pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { db: db.to_string(), action: KvAction::Open, })?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -212,6 +232,8 @@ pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { KvResponse::Ok => Ok(Kv { package_id, db: db.to_string(), + timeout, + _marker: PhantomData, }), KvResponse::Err { error } => Err(error.into()), _ => Err(anyhow::anyhow!("kv: unexpected response {:?}", response)), @@ -222,7 +244,9 @@ pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { } /// Removes and deletes a kv db. -pub fn remove_db(package_id: PackageId, db: &str) -> anyhow::Result<()> { +pub fn remove_db(package_id: PackageId, db: &str, timeout: Option) -> anyhow::Result<()> { + let timeout = timeout.unwrap_or(5); + let res = Request::new() .target(("our", "kv", "distro", "sys")) .body(serde_json::to_vec(&KvRequest { @@ -230,7 +254,7 @@ pub fn remove_db(package_id: PackageId, db: &str) -> anyhow::Result<()> { db: db.to_string(), action: KvAction::RemoveDb, })?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match res { Ok(Message::Response { body, .. }) => { diff --git a/src/lib.rs b/src/lib.rs index 9e351c4..322a83c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,6 @@ wit_bindgen::generate!({ }); /// Interact with the eth provider module. -#[cfg(feature = "eth")] pub mod eth; /// Interact with the HTTP server and client modules. /// Contains types from the `http` crate to use as well. diff --git a/src/sqlite.rs b/src/sqlite.rs index 6bd1374..f87e120 100644 --- a/src/sqlite.rs +++ b/src/sqlite.rs @@ -79,6 +79,7 @@ pub enum SqliteError { pub struct Sqlite { pub package_id: PackageId, pub db: String, + pub timeout: u64, } impl Sqlite { @@ -96,7 +97,7 @@ impl Sqlite { action: SqliteAction::Read { query }, })?) .blob_bytes(serde_json::to_vec(¶ms)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -141,7 +142,7 @@ impl Sqlite { action: SqliteAction::Write { statement, tx_id }, })?) .blob_bytes(serde_json::to_vec(¶ms)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -169,7 +170,7 @@ impl Sqlite { db: self.db.clone(), action: SqliteAction::BeginTx, })?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -197,7 +198,7 @@ impl Sqlite { db: self.db.clone(), action: SqliteAction::Commit { tx_id }, })?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -218,7 +219,9 @@ impl Sqlite { } /// Open or create sqlite database. -pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { +pub fn open(package_id: PackageId, db: &str, timeout: Option) -> anyhow::Result { + let timeout = timeout.unwrap_or(5); + let res = Request::new() .target(("our", "sqlite", "distro", "sys")) .body(serde_json::to_vec(&SqliteRequest { @@ -226,7 +229,7 @@ pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { db: db.to_string(), action: SqliteAction::Open, })?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match res { Ok(Message::Response { body, .. }) => { @@ -236,6 +239,7 @@ pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { SqliteResponse::Ok => Ok(Sqlite { package_id, db: db.to_string(), + timeout, }), SqliteResponse::Err { error } => Err(error.into()), _ => Err(anyhow::anyhow!( @@ -249,7 +253,9 @@ pub fn open(package_id: PackageId, db: &str) -> anyhow::Result { } /// Remove and delete sqlite database. -pub fn remove_db(package_id: PackageId, db: &str) -> anyhow::Result<()> { +pub fn remove_db(package_id: PackageId, db: &str, timeout: Option) -> anyhow::Result<()> { + let timeout = timeout.unwrap_or(5); + let res = Request::new() .target(("our", "sqlite", "distro", "sys")) .body(serde_json::to_vec(&SqliteRequest { @@ -257,7 +263,7 @@ pub fn remove_db(package_id: PackageId, db: &str) -> anyhow::Result<()> { db: db.to_string(), action: SqliteAction::RemoveDb, })?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match res { Ok(Message::Response { body, .. }) => { diff --git a/src/vfs/directory.rs b/src/vfs/directory.rs index 31fb296..6cc8154 100644 --- a/src/vfs/directory.rs +++ b/src/vfs/directory.rs @@ -6,6 +6,7 @@ use crate::{Message, Request}; /// You can call it's impl functions to interact with it. pub struct Directory { pub path: String, + pub timeout: u64, } impl Directory { @@ -19,7 +20,7 @@ impl Directory { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -37,10 +38,12 @@ impl Directory { /// Opens or creates a directory at path. /// If trying to create an existing directory, will just give you the path. -pub fn open_dir(path: &str, create: bool) -> anyhow::Result { +pub fn open_dir(path: &str, create: bool, timeout: Option) -> anyhow::Result { + let timeout = timeout.unwrap_or(5); if !create { return Ok(Directory { path: path.to_string(), + timeout, }); } let request = VfsRequest { @@ -51,7 +54,7 @@ pub fn open_dir(path: &str, create: bool) -> anyhow::Result { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -59,6 +62,7 @@ pub fn open_dir(path: &str, create: bool) -> anyhow::Result { match response { VfsResponse::Ok => Ok(Directory { path: path.to_string(), + timeout, }), VfsResponse::Err(e) => Err(e.into()), _ => Err(anyhow::anyhow!("vfs: unexpected response: {:?}", response)), @@ -69,7 +73,9 @@ pub fn open_dir(path: &str, create: bool) -> anyhow::Result { } /// Removes a dir at path, errors if path not found or path is not a directory. -pub fn remove_dir(path: &str) -> anyhow::Result<()> { +pub fn remove_dir(path: &str, timeout: Option) -> anyhow::Result<()> { + let timeout = timeout.unwrap_or(5); + let request = VfsRequest { path: path.to_string(), action: VfsAction::RemoveDir, @@ -78,7 +84,7 @@ pub fn remove_dir(path: &str) -> anyhow::Result<()> { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match message { Ok(Message::Response { body, .. }) => { diff --git a/src/vfs/file.rs b/src/vfs/file.rs index ef46345..6d38e82 100644 --- a/src/vfs/file.rs +++ b/src/vfs/file.rs @@ -6,6 +6,7 @@ use crate::{get_blob, Message, PackageId, Request}; /// You can call it's impl functions to interact with it. pub struct File { pub path: String, + pub timeout: u64, } impl File { @@ -19,7 +20,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -50,7 +51,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -84,7 +85,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -117,7 +118,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -149,7 +150,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -176,7 +177,7 @@ impl File { .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) .blob_bytes(buffer) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -201,7 +202,7 @@ impl File { .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) .blob_bytes(buffer) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -226,7 +227,7 @@ impl File { .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) .blob_bytes(buffer) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -251,7 +252,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -286,6 +287,7 @@ impl File { match response { VfsResponse::Ok => Ok(File { path: path.to_string(), + timeout: self.timeout, }), VfsResponse::Err(e) => Err(e.into()), _ => Err(anyhow::anyhow!("vfs: unexpected response: {:?}", response)), @@ -304,7 +306,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -328,7 +330,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -352,7 +354,7 @@ impl File { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(self.timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -371,7 +373,13 @@ impl File { /// Creates a drive with path "/package_id/drive", gives you read and write caps. /// Will only work on the same package_id as you're calling it from, unless you /// have root capabilities. -pub fn create_drive(package_id: PackageId, drive: &str) -> anyhow::Result { +pub fn create_drive( + package_id: PackageId, + drive: &str, + timeout: Option, +) -> anyhow::Result { + let timeout = timeout.unwrap_or(5); + let path = format!("/{}/{}", package_id, drive); let res = Request::new() .target(("our", "vfs", "distro", "sys")) @@ -379,7 +387,7 @@ pub fn create_drive(package_id: PackageId, drive: &str) -> anyhow::Result { @@ -395,7 +403,9 @@ pub fn create_drive(package_id: PackageId, drive: &str) -> anyhow::Result anyhow::Result { +pub fn open_file(path: &str, create: bool, timeout: Option) -> anyhow::Result { + let timeout = timeout.unwrap_or(5); + let request = VfsRequest { path: path.to_string(), action: VfsAction::OpenFile { create }, @@ -404,7 +414,7 @@ pub fn open_file(path: &str, create: bool) -> anyhow::Result { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -412,6 +422,7 @@ pub fn open_file(path: &str, create: bool) -> anyhow::Result { match response { VfsResponse::Ok => Ok(File { path: path.to_string(), + timeout, }), VfsResponse::Err(e) => Err(e.into()), _ => Err(anyhow::anyhow!("vfs: unexpected response: {:?}", response)), @@ -422,7 +433,8 @@ pub fn open_file(path: &str, create: bool) -> anyhow::Result { } /// Creates a file at path, if file found at path, truncates it to 0. -pub fn create_file(path: &str) -> anyhow::Result { +pub fn create_file(path: &str, timeout: Option) -> anyhow::Result { + let timeout = timeout.unwrap_or(5); let request = VfsRequest { path: path.to_string(), action: VfsAction::CreateFile, @@ -431,7 +443,7 @@ pub fn create_file(path: &str) -> anyhow::Result { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -439,6 +451,7 @@ pub fn create_file(path: &str) -> anyhow::Result { match response { VfsResponse::Ok => Ok(File { path: path.to_string(), + timeout, }), VfsResponse::Err(e) => Err(e.into()), _ => Err(anyhow::anyhow!("vfs: unexpected response: {:?}", response)), @@ -449,7 +462,9 @@ pub fn create_file(path: &str) -> anyhow::Result { } /// Removes a file at path, errors if path not found or path is not a file. -pub fn remove_file(path: &str) -> anyhow::Result<()> { +pub fn remove_file(path: &str, timeout: Option) -> anyhow::Result<()> { + let timeout = timeout.unwrap_or(5); + let request = VfsRequest { path: path.to_string(), action: VfsAction::RemoveFile, @@ -458,7 +473,7 @@ pub fn remove_file(path: &str) -> anyhow::Result<()> { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match message { Ok(Message::Response { body, .. }) => { diff --git a/src/vfs/mod.rs b/src/vfs/mod.rs index cefbdbe..5f0aa5f 100644 --- a/src/vfs/mod.rs +++ b/src/vfs/mod.rs @@ -127,7 +127,9 @@ impl VfsError { } /// Metadata of a path, returns file type and length. -pub fn metadata(path: &str) -> anyhow::Result { +pub fn metadata(path: &str, timeout: Option) -> anyhow::Result { + let timeout = timeout.unwrap_or(5); + let request = VfsRequest { path: path.to_string(), action: VfsAction::Metadata, @@ -135,7 +137,7 @@ pub fn metadata(path: &str) -> anyhow::Result { let message = Request::new() .target(("our", "vfs", "distro", "sys")) .body(serde_json::to_vec(&request)?) - .send_and_await_response(5)?; + .send_and_await_response(timeout)?; match message { Ok(Message::Response { body, .. }) => { @@ -151,11 +153,11 @@ pub fn metadata(path: &str) -> anyhow::Result { } /// Removes a path, if it's either a directory or a file. -pub fn remove_path(path: &str) -> anyhow::Result<()> { - let meta = metadata(path)?; +pub fn remove_path(path: &str, timeout: Option) -> anyhow::Result<()> { + let meta = metadata(path, timeout)?; match meta.file_type { - FileType::Directory => remove_dir(path), - FileType::File => remove_file(path), + FileType::Directory => remove_dir(path, timeout), + FileType::File => remove_file(path, timeout), _ => Err(anyhow::anyhow!( "vfs: path is not a file or directory: {}", path