diff --git a/api/Cargo.lock b/api/Cargo.lock index 0b9c02b..19faa0d 100644 --- a/api/Cargo.lock +++ b/api/Cargo.lock @@ -56,10 +56,13 @@ dependencies = [ "crossbeam-queue", "crossbeam-skiplist", "fmt", + "lazy_static", "prometheus", + "reqwest", "rocket", "serde", "thiserror", + "tokio", "tracing", "tracing-appender", "tracing-log 0.1.4", @@ -136,12 +139,24 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "binascii" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.6.0" @@ -212,6 +227,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -296,13 +321,24 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35b50dba0afdca80b187392b24f2499a88c336d5a8493e4b4ccfb608708be56a" dependencies = [ - "bitflags", + "bitflags 2.6.0", "proc-macro2", "proc-macro2-diagnostics", "quote", "syn", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "either" version = "1.13.0" @@ -366,6 +402,30 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.30" @@ -573,6 +633,19 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -596,6 +669,145 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indexmap" version = "2.4.0" @@ -613,6 +825,12 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + [[package]] name = "is-terminal" version = "0.4.13" @@ -657,6 +875,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "lock_api" version = "0.4.12" @@ -749,6 +973,23 @@ dependencies = [ "version_check", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -799,6 +1040,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "overload" version = "0.1.1" @@ -869,6 +1154,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -972,7 +1263,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] @@ -1039,6 +1330,46 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "rocket" version = "0.5.1" @@ -1133,13 +1464,22 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", "windows-sys 0.52.0", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + [[package]] name = "rustversion" version = "1.0.17" @@ -1152,6 +1492,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -1164,6 +1513,29 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.208" @@ -1205,6 +1577,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -1269,6 +1653,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "state" version = "0.6.0" @@ -1289,6 +1679,44 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.12.0" @@ -1363,6 +1791,16 @@ dependencies = [ "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tokio" version = "1.39.3" @@ -1373,6 +1811,7 @@ dependencies = [ "bytes", "libc", "mio", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -1391,6 +1830,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.15" @@ -1589,6 +2038,29 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "uuid" version = "1.10.0" @@ -1605,6 +2077,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" @@ -1652,6 +2130,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.93" @@ -1681,6 +2171,16 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "web-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1721,6 +2221,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -1869,6 +2378,28 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "yansi" version = "1.0.1" @@ -1878,6 +2409,30 @@ dependencies = [ "is-terminal", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -1898,3 +2453,46 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/api/Cargo.toml b/api/Cargo.toml index a97a76f..be47da8 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -19,4 +19,7 @@ crossbeam-skiplist = "0.1.1" fmt = "0.1.0" thiserror = "1.0.50" chrono = "0.4.31" -prometheus = "0.13.4" \ No newline at end of file +prometheus = "0.13.4" +reqwest = { version = "0.11", features = ["json"] } +lazy_static = "1.4.0" +tokio = { version = "1.0", features = ["full"] } \ No newline at end of file diff --git a/api/src/handlers/mod.rs b/api/src/handlers/mod.rs index 6569849..1f5c357 100644 --- a/api/src/handlers/mod.rs +++ b/api/src/handlers/mod.rs @@ -4,6 +4,7 @@ pub mod scarb_test; pub mod scarb_version; pub mod types; pub mod utils; +pub mod allowed_versions; use tracing::info; use tracing::instrument; diff --git a/api/src/handlers/types.rs b/api/src/handlers/types.rs index 7b83844..b75c425 100644 --- a/api/src/handlers/types.rs +++ b/api/src/handlers/types.rs @@ -52,7 +52,9 @@ pub struct CompilationRequest { impl CompilationRequest { pub fn has_scarb_toml(&self) -> bool { - self.files.iter().any(|f| &f.file_name == "Scarb.toml") + self.files + .iter() + .any(|f| f.file_name.ends_with("Scarb.toml")) } pub fn file_names(&self) -> Vec { diff --git a/api/src/main.rs b/api/src/main.rs index ea6ecaa..5c8cb33 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -16,6 +16,7 @@ use handlers::process::get_process_status; use handlers::scarb_test::{get_scarb_test_result, scarb_test_async}; use handlers::scarb_version::{get_scarb_version_result, scarb_version_async}; use handlers::utils::on_plugin_launched; +use handlers::allowed_versions::{get_allowed_versions, start_version_updater}; use handlers::{health, who_is_this}; use prometheus::Registry; use rocket::{Build, Config, Rocket}; @@ -86,6 +87,7 @@ fn create_app(metrics: Metrics) -> Rocket { get_scarb_test_result, scarb_test_async, on_plugin_launched, + get_allowed_versions, ], ) } @@ -94,6 +96,9 @@ fn create_app(metrics: Metrics) -> Rocket { async fn main() -> anyhow::Result<()> { init_logger().context("Failed to initialize logger")?; + // Start the version updater + start_version_updater().await; + let registry = Registry::new(); let metrics = initialize_metrics(registry.clone()).context("Failed to initialize metrics")?; diff --git a/plugin/src/atoms/cairoVersion.ts b/plugin/src/atoms/cairoVersion.ts index e78d36a..2a351ed 100644 --- a/plugin/src/atoms/cairoVersion.ts +++ b/plugin/src/atoms/cairoVersion.ts @@ -1,6 +1,6 @@ import { atom } from "jotai"; -const cairoVersionAtom = atom("v2.8.4"); +const cairoVersionAtom = atom(null); const versionsAtom = atom([]); diff --git a/plugin/src/atoms/compilation.ts b/plugin/src/atoms/compilation.ts index ae3e707..23901f0 100644 --- a/plugin/src/atoms/compilation.ts +++ b/plugin/src/atoms/compilation.ts @@ -6,10 +6,11 @@ import { atom } from "jotai"; enum CompilationStatus { Compiling = "Compiling...", Success = "Success", - Error = "Error" + Error = "Error", + Idle = "Idle" } -const statusAtom = atom(CompilationStatus.Compiling); +const statusAtom = atom(CompilationStatus.Idle); const currentFilenameAtom = atom(""); diff --git a/plugin/src/components/LoadingDots/index.tsx b/plugin/src/components/LoadingDots/index.tsx new file mode 100644 index 0000000..ce9ce0b --- /dev/null +++ b/plugin/src/components/LoadingDots/index.tsx @@ -0,0 +1,25 @@ +import React, { useEffect, useState } from "react"; + +const LoadingDots: React.FC<{ message: string }> = ({ message }) => { + const [dots, setDots] = useState(""); + + useEffect(() => { + const interval = setInterval(() => { + setDots((prev) => { + return prev.length >= 3 ? "" : prev + "."; + }); + }, 500); + + return () => { + clearInterval(interval); + }; + }, []); + + return ( + + {message}{dots} + + ); +}; + +export default LoadingDots; diff --git a/plugin/src/components/Settings/index.tsx b/plugin/src/components/Settings/index.tsx index e76ac11..d56d826 100644 --- a/plugin/src/components/Settings/index.tsx +++ b/plugin/src/components/Settings/index.tsx @@ -5,6 +5,7 @@ import { useAtom, useAtomValue } from "jotai"; import { cairoVersionAtom, versionsAtom } from "../../atoms/cairoVersion"; import ExplorerSelector, { useCurrentExplorer } from "../ExplorerSelector"; import * as Select from "../ui_components/Select"; +import LoadingDots from "../LoadingDots"; export const Settings: React.FC = () => { const [cairoVersion, setCairoVersion] = useAtom(cairoVersionAtom); @@ -18,29 +19,37 @@ export const Settings: React.FC = () => {
Cairo Version
- - - -
-

{cairoVersion}

-
-
- - - -
- - - - {getVersions.map((v, i) => ( - - {v} - - ))} - - - -
+ {cairoVersion !== null + ? ( + + + +
+

{cairoVersion}

+
+
+ + + +
+ + + + {getVersions.map((v, i) => ( + + {v} + + ))} + + + +
+ ) + : ( +
+ +
+ )}
diff --git a/plugin/src/features/Compilation/index.tsx b/plugin/src/features/Compilation/index.tsx index 508851b..5c652e5 100644 --- a/plugin/src/features/Compilation/index.tsx +++ b/plugin/src/features/Compilation/index.tsx @@ -6,7 +6,7 @@ import Container from "../../components/ui_components/Container"; import { type AccordianTabs } from "../Plugin"; import * as D from "../../components/ui_components/Dropdown"; import { BsChevronDown } from "react-icons/bs"; -import { useAtomValue, useSetAtom, useAtom } from "jotai"; +import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { hash } from "starknet"; // Imported Atoms @@ -20,7 +20,12 @@ import { } from "../../atoms/compilation"; import useRemixClient from "../../hooks/useRemixClient"; import { useIcon } from "../../hooks/useIcons"; -import { type CompilationResult, type Contract, type CompilationRequest } from "../../utils/types/contracts"; +import { + type CompilationRequest, + type CompilationResult, + type Contract, + type ContractFile +} from "../../utils/types/contracts"; import { asyncFetch } from "../../utils/async_fetch"; import { compiledContractsAtom } from "../../atoms/compiledContracts"; @@ -177,7 +182,6 @@ const Compilation: React.FC = ({ setAccordian }) => { const { remixClient } = useRemixClient(); const [contracts, setContracts] = useAtom(compiledContractsAtom); - // const [selectedContract, setSelectedContract] = useAtom(selectedCompiledContractAtom); const currentFilename = useAtomValue(currentFilenameAtom); const tomlPaths = useAtomValue(tomlPathsAtom); @@ -253,31 +257,31 @@ const Compilation: React.FC = ({ setAccordian }) => { return resTomlPaths; } - // const getFolderFilemapRecursive = async ( - // workspacePath: string, - // dirPath = "" - // ): Promise => { - // const files = [] as ContractFile[]; - // const pathFiles = await remixClient.fileManager.readdir(`${workspacePath}/${dirPath}`); - // for (const [path, entry] of Object.entries(pathFiles)) { - // if (entry.isDirectory === true) { - // const deps = await getFolderFilemapRecursive(workspacePath, path); - // for (const dep of deps) files.push(dep); - // continue; - // } - - // const content = await remixClient.fileManager.readFile(path); - - // if (!path.endsWith(".cairo") && !path.endsWith("Scarb.toml")) continue; - - // files.push({ - // file_name: path, - // real_path: path, - // file_content: content - // }); - // } - // return files; - // }; + const getFolderFilemapRecursive = async ( + workspacePath: string, + dirPath = "" + ): Promise => { + const files = [] as ContractFile[]; + const pathFiles = await remixClient.fileManager.readdir(`${workspacePath}/${dirPath}`); + for (const [path, entry] of Object.entries(pathFiles)) { + if (entry.isDirectory === true) { + const deps = await getFolderFilemapRecursive(workspacePath, path); + for (const dep of deps) files.push(dep); + continue; + } + + const content = await remixClient.fileManager.readFile(path); + + if (!path.endsWith(".cairo") && !path.endsWith("Scarb.toml")) continue; + + files.push({ + file_name: path, + real_path: path, + file_content: content + }); + } + return files; + }; const updateTomlPaths = (): void => { // eslint-disable-next-line @typescript-eslint/no-misused-promises @@ -354,10 +358,12 @@ const Compilation: React.FC = ({ setAccordian }) => { setStatus(CompilationStatus.Compiling); try { - const result = await asyncFetch("/compile-async", "compile-result", compilationRequest); + const result = await asyncFetch("compile-async", "compile-result", compilationRequest); const resultJson = JSON.parse(result) as CompilationResult; + console.log("compile result: ", resultJson); + if (resultJson.status !== "Success") { await remixClient.call( "notification" as any, @@ -406,6 +412,8 @@ const Compilation: React.FC = ({ setAccordian }) => { } > = {}; + console.log(compileResult); + // First pass to collect artifacts for (const file of compileResult.artifacts) { if (!file.file_name.endsWith(".compiled_contract_class.json") && !file.file_name.endsWith(".contract_class.json")) continue; @@ -413,7 +421,10 @@ const Compilation: React.FC = ({ setAccordian }) => { const basePath = file.file_name.replace(".compiled_contract_class.json", "").replace(".contract_class.json", "").replace("___testsingle_", ""); if (!(basePath in contractToArtifacts)) { - contractToArtifacts[basePath] = { casm: "", sierra: "" }; + contractToArtifacts[basePath] = { + casm: "", + sierra: "" + }; } if (file.file_name.endsWith(".contract_class.json")) { @@ -510,172 +521,41 @@ const Compilation: React.FC = ({ setAccordian }) => { } async function compileScarb (workspacePath: string, scarbPath: string): Promise { - // try { - // setStatus("Saving scarb workspace..."); - // - // let result: string; - // try { - // // result = await asyncFetch( - // // `compile-scarb-async/${hashDir}/${workspacePath.replace(".", "")}/${scarbPath}`, - // // "compile-scarb-result" - // // ); - // } catch (e) { - // await remixClient.call( - // "notification" as any, - // "toast", - // "Could not reach cairo compilation server" - // ); - // throw new Error("Cairo Compilation Request Failed"); - // } - // const scarbCompile: ScarbCompileResponse = JSON.parse(result); - // if (scarbCompile.status !== "Success") { - // await remixClient.call("notification" as any, "alert", { - // id: "starknetRemixPluginAlert", - // title: "Scarb compilation failed!", - // message: "Scarb compilation failed!, you can read logs in the terminal console" - // }); - // remixClient.emit("statusChanged", { - // key: "failed", - // type: "error", - // title: "Scarb compilation failed!" - // }); - // await remixClient.terminal.log({ - // type: "error", - // value: scarbCompile.message - // }); - // throw new Error("Cairo Compilation Request Failed"); - // } - // - // remixClient.emit("statusChanged", { - // key: "succeed", - // type: "success", - // title: "Scarb compilation successful" - // }); - // - // setStatus("Analyzing contracts..."); - // - // let notifyCasmInclusion = false; - // - // const contractsToStore: Contract[] = []; - // - // for (const file of scarbCompile.file_content_map_array) { - // if (file.file_name?.endsWith(".contract_class.json")) { - // const contractName: string = file.file_name.replace(".contract_class.json", ""); - // const sierra = JSON.parse(file.file_content); - // if ( - // scarbCompile.file_content_map_array?.find( - // (file: { file_name: string }) => - // file.file_name === contractName + ".compiled_contract_class.json" - // ) == null - // ) { - // notifyCasmInclusion = true; - // continue; - // } - // const casm = JSON.parse( - // scarbCompile.file_content_map_array.find( - // (file: { file_name: string }) => - // file.file_name === contractName + ".compiled_contract_class.json" - // )?.file_content ?? "" - // ); - // const genContract = await genContractData( - // contractName, - // file.file_name, - // JSON.stringify(sierra), - // JSON.stringify(casm) - // ); - // if (genContract != null) contractsToStore.push(genContract); - // } - // } - // - // if (contractsToStore.length >= 1) { - // setSelectedContract(contractsToStore[0]); - // setContracts([...contractsToStore, ...contracts]); - // } else { - // if (selectedContract == null) setSelectedContract(contracts[0]); - // } - // if (notifyCasmInclusion) { - // await remixClient.call( - // "notification" as any, - // "toast", - // "Please include 'casm=true' in the Scarb.toml to deploy cairo contracts" - // ); - // } - // - // setStatus("Saving compilation output files..."); - // try { - // for (const file of scarbCompile.file_content_map_array) { - // // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - // const filePath = `${scarbPath}/target/dev/${file.file_name}`; - // await remixClient.call( - // "fileManager", - // "writeFile", - // filePath, - // JSON.stringify(JSON.parse(file.file_content)) - // ); - // } - // await remixClient.call( - // "notification" as any, - // "toast", - // `Compilation resultant files are written to ${scarbPath}/target/dev directory` - // ); - // } catch (e) { - // if (e instanceof Error) { - // await remixClient.call( - // "notification" as any, - // "toast", - // e.message + " try deleting the dir: " + scarbPath + "target/dev" - // ); - // } - // remixClient.emit("statusChanged", { - // key: "succeed", - // type: "warning", - // title: "Failed to save artifacts" - // }); - // } - // setStatus("done"); - // setAccordian("deploy"); - // } catch (e) { - // setStatus("failed"); - // console.log("error: ", e); - // } - } + console.log(workspacePath, scarbPath); + + try { + const compilationRequest: CompilationRequest = { + files: await getFolderFilemapRecursive(workspacePath, scarbPath) + }; - // async function genContractData ( - // contractName: string, - // path: string, - // sierraFile: string, - // casmFile: string - // ): Promise { - // const sierra = await JSON.parse(sierraFile); - // const casm = await JSON.parse(casmFile); - // const compiledClassHash = hash.computeCompiledClassHash(casm); - // const classHash = hash.computeContractClassHash(sierraFile); - // const sierraClassHash = hash.computeSierraContractClassHash(sierra); - // if ( - // contracts.find( - // (contract: Contract) => - // contract.classHash === classHash && - // contract.compiledClassHash === compiledClassHash - // ) != null - // ) { - // return null; - // } - // const contract = { - // name: contractName, - // abi: sierra.abi, - // compiledClassHash, - // classHash, - // sierraClassHash, - // sierra: sierraFile, - // casm, - // path, - // deployedInfo: [], - // address: "", - // declaredInfo: [] - // }; - - // return contract; - // } + // format request, remove scarbPath from file names + compilationRequest.files = compilationRequest.files.map((file) => { + file.file_name = file.file_name.replace(scarbPath + "/", ""); + return file; + }); + + console.log(compilationRequest); + + const result = await compile(compilationRequest); + + console.log(result); + + if (result != null) { + setStatus("done"); + setAccordian("deploy"); + } + } catch (e) { + setStatus("failed"); + if (e instanceof Error) { + await remixClient.call("notification" as any, "alert", { + id: "starknetRemixPluginAlert", + title: "Cairo Compilation Failed", + message: e.message + }); + } + console.error(e); + } + } return (
diff --git a/plugin/src/features/Footer/index.tsx b/plugin/src/features/Footer/index.tsx index b2904fc..bfc011b 100644 --- a/plugin/src/features/Footer/index.tsx +++ b/plugin/src/features/Footer/index.tsx @@ -3,6 +3,7 @@ import Nethermind from "../../components/NM"; import "./style.css"; import { useAtomValue } from "jotai"; import { cairoVersionAtom } from "../../atoms/cairoVersion"; +import LoadingDots from "../../components/LoadingDots"; const Footer: React.FC = () => { const version = useAtomValue(cairoVersionAtom); @@ -12,7 +13,7 @@ const Footer: React.FC = () => {
diff --git a/plugin/src/features/Plugin/index.tsx b/plugin/src/features/Plugin/index.tsx index 5932477..67bd183 100644 --- a/plugin/src/features/Plugin/index.tsx +++ b/plugin/src/features/Plugin/index.tsx @@ -22,7 +22,6 @@ import { cairoVersionAtom, versionsAtom } from "../../atoms/cairoVersion"; import { apiUrl } from "../../utils/network"; import { StarknetProvider } from "../../components/starknet/starknet-provider"; import { CompilationStatus, statusAtom } from "../../atoms/compilation"; -import { asyncFetch } from "../../utils/async_fetch"; export type AccordianTabs = "compile" | "deploy" | "interaction" | "transactions" | ""; @@ -65,8 +64,11 @@ const Plugin: React.FC = () => { const fetchCairoVersions = async (): Promise => { try { if (apiUrl !== undefined) { - const versions = await asyncFetch("scarb-version-async", "scarb-version-result"); - setVersions(versions.split("\n")); + const versions = await fetch(`${apiUrl}/allowed-versions`); + + const versionsData = await versions.json(); + + setVersions(versionsData); } } catch (e) { await remixClient.call( @@ -88,7 +90,7 @@ const Plugin: React.FC = () => { await fetchCairoVersions(); if (getVersions.length > 0) { - setCairoVersion(getVersions[getVersions.length - 1]); + setCairoVersion(getVersions[0]); } }; fetchCairo().catch((e) => { @@ -99,7 +101,7 @@ const Plugin: React.FC = () => { useEffect(() => { if (getVersions.length > 0) { - setCairoVersion(getVersions[getVersions.length - 1]); + setCairoVersion(getVersions[0]); } }, [remixClient, getVersions]);