From d9cf65855dd43dd6220b3ada82412618f19e3bf0 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Tue, 22 Oct 2024 21:49:11 +0100 Subject: [PATCH] cleanup --- .env.example | 3 +- Cargo.lock | 400 ++++++++++-------------------- Cargo.toml | 25 +- src/config.rs | 5 - src/main.rs | 10 +- src/routes/api/v1/ens_gateway.rs | 4 +- src/routes/api/v1/mod.rs | 2 +- src/routes/api/v1/query_single.rs | 8 +- src/types/error.rs | 2 +- src/types/mod.rs | 2 +- src/verify.rs | 3 +- 11 files changed, 166 insertions(+), 298 deletions(-) diff --git a/.env.example b/.env.example index 55e91d3..45158fc 100644 --- a/.env.example +++ b/.env.example @@ -1,9 +1,8 @@ ENS_DOMAIN= WLD_APP_ID= PRIVATE_KEY= -ENS_CHAIN_ID= RESERVED_USERNAMES= RUST_LOG="wld_usernames=debug" BLOCKED_SUBSTRINGS="world,support,admin" DATABASE_URL=postgres://postgres@localhost/postgres -DEVELOPER_PORTAL_ENDPOINT= \ No newline at end of file +DEVELOPER_PORTAL_ENDPOINT= diff --git a/Cargo.lock b/Cargo.lock index c6f79e0..2d54f59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,7 +77,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -336,7 +336,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -354,7 +354,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tracing", "url", ] @@ -481,7 +481,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -492,12 +492,12 @@ checksum = "71c4d842beb7a6686d04125603bc57614d5ed78bf95e4753274db3db4ba95214" dependencies = [ "alloy-sol-macro-input", "const-hex", - "heck 0.5.0", + "heck", "indexmap 2.4.0", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", "syn-solidity", "tiny-keccak", ] @@ -510,10 +510,10 @@ checksum = "1306e8d3c9e6e6ecf7a39ffaf7291e73a5f655a2defd366ee92c2efebcdf7fee" dependencies = [ "const-hex", "dunce", - "heck 0.5.0", + "heck", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", "syn-solidity", ] @@ -553,7 +553,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower", + "tower 0.4.13", "tracing", "url", ] @@ -567,7 +567,7 @@ dependencies = [ "alloy-transport", "reqwest", "serde_json", - "tower", + "tower 0.4.13", "tracing", "url", ] @@ -589,9 +589,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "ark-ff" @@ -755,7 +755,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -766,7 +766,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -792,7 +792,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -1001,9 +1001,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" dependencies = [ "async-trait", "axum-core", @@ -1027,7 +1027,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -1035,9 +1035,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", @@ -1048,7 +1048,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -1444,7 +1444,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -1455,7 +1455,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -1513,7 +1513,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -1634,12 +1634,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "event-listener" version = "5.3.1" @@ -1834,7 +1828,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -1894,7 +1888,7 @@ dependencies = [ "serde_json", "tokio", "tonic", - "tower", + "tower 0.4.13", "tower-layer", "tower-util", "tracing", @@ -1983,15 +1977,6 @@ dependencies = [ "allocator-api2", ] -[[package]] -name = "hashlink" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" -dependencies = [ - "hashbrown 0.14.5", -] - [[package]] name = "hashlink" version = "0.9.1" @@ -2001,15 +1986,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.5.0" @@ -2176,7 +2152,7 @@ dependencies = [ "hyper", "hyper-util", "rustls", - "rustls-native-certs", + "rustls-native-certs 0.7.2", "rustls-pki-types", "tokio", "tokio-rustls", @@ -2227,7 +2203,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", + "tower 0.4.13", "tower-service", "tracing", ] @@ -2802,7 +2778,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -2843,7 +2819,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -3010,7 +2986,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -3134,7 +3110,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -3160,7 +3136,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -3300,14 +3276,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -3321,13 +3297,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -3344,15 +3320,15 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "async-compression", "base64 0.22.1", @@ -3379,7 +3355,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", - "rustls-native-certs", + "rustls-native-certs 0.8.0", "rustls-pemfile", "rustls-pki-types", "serde", @@ -3572,6 +3548,19 @@ dependencies = [ "security-framework", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "2.1.3" @@ -3656,7 +3645,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -3741,22 +3730,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.209" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -3767,14 +3756,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -3954,72 +3943,22 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" -dependencies = [ - "sqlx-core 0.7.4", - "sqlx-macros 0.7.4", - "sqlx-postgres 0.7.4", -] - -[[package]] -name = "sqlx" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcfa89bea9500db4a0d038513d7a060566bfc51d46d1c014847049a45cce85e8" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" dependencies = [ - "sqlx-core 0.8.1", - "sqlx-macros 0.8.1", + "sqlx-core", + "sqlx-macros", "sqlx-mysql", - "sqlx-postgres 0.8.1", + "sqlx-postgres", "sqlx-sqlite", ] [[package]] name = "sqlx-core" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" -dependencies = [ - "ahash", - "atoi", - "byteorder", - "bytes", - "crc", - "crossbeam-queue", - "either", - "event-listener 2.5.3", - "futures-channel", - "futures-core", - "futures-intrusive", - "futures-io", - "futures-util", - "hashlink 0.8.4", - "hex", - "indexmap 2.4.0", - "log", - "memchr", - "once_cell", - "paste", - "percent-encoding", - "serde", - "serde_json", - "sha2", - "smallvec", - "sqlformat", - "thiserror", - "tokio", - "tokio-stream", - "tracing", - "url", -] - -[[package]] -name = "sqlx-core" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06e2f2bd861719b1f3f0c7dbe1d80c30bf59e76cf019f07d9014ed7eefb8e08" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" dependencies = [ "atoi", "byteorder", @@ -4028,14 +3967,14 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 5.3.1", + "event-listener", "futures-channel", "futures-core", "futures-intrusive", "futures-io", "futures-util", "hashbrown 0.14.5", - "hashlink 0.9.1", + "hashlink", "hex", "indexmap 2.4.0", "log", @@ -4060,63 +3999,26 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" -dependencies = [ - "proc-macro2", - "quote", - "sqlx-core 0.7.4", - "sqlx-macros-core 0.7.4", - "syn 1.0.109", -] - -[[package]] -name = "sqlx-macros" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f998a9defdbd48ed005a89362bd40dd2117502f15294f61c8d47034107dbbdc" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" dependencies = [ "proc-macro2", "quote", - "sqlx-core 0.8.1", - "sqlx-macros-core 0.8.1", - "syn 2.0.76", -] - -[[package]] -name = "sqlx-macros-core" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" -dependencies = [ - "dotenvy", - "either", - "heck 0.4.1", - "hex", - "once_cell", - "proc-macro2", - "quote", - "serde", - "serde_json", - "sha2", - "sqlx-core 0.7.4", - "sqlx-postgres 0.7.4", - "syn 1.0.109", - "tempfile", - "tokio", - "url", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.82", ] [[package]] name = "sqlx-macros-core" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d100558134176a2629d46cec0c8891ba0be8910f7896abfdb75ef4ab6f4e7ce" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" dependencies = [ "dotenvy", "either", - "heck 0.5.0", + "heck", "hex", "once_cell", "proc-macro2", @@ -4124,11 +4026,11 @@ dependencies = [ "serde", "serde_json", "sha2", - "sqlx-core 0.8.1", + "sqlx-core", "sqlx-mysql", - "sqlx-postgres 0.8.1", + "sqlx-postgres", "sqlx-sqlite", - "syn 2.0.76", + "syn 2.0.82", "tempfile", "tokio", "url", @@ -4136,9 +4038,9 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cac0ab331b14cb3921c62156d913e4c15b74fb6ec0f3146bd4ef6e4fb3c12" +checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" dependencies = [ "atoi", "base64 0.22.1", @@ -4170,45 +4072,7 @@ dependencies = [ "sha1", "sha2", "smallvec", - "sqlx-core 0.8.1", - "stringprep", - "thiserror", - "tracing", - "whoami", -] - -[[package]] -name = "sqlx-postgres" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" -dependencies = [ - "atoi", - "base64 0.21.7", - "bitflags 2.6.0", - "byteorder", - "crc", - "dotenvy", - "etcetera", - "futures-channel", - "futures-core", - "futures-io", - "futures-util", - "hex", - "hkdf", - "hmac", - "home", - "itoa", - "log", - "md-5", - "memchr", - "once_cell", - "rand", - "serde", - "serde_json", - "sha2", - "smallvec", - "sqlx-core 0.7.4", + "sqlx-core", "stringprep", "thiserror", "tracing", @@ -4217,9 +4081,9 @@ dependencies = [ [[package]] name = "sqlx-postgres" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9734dbce698c67ecf67c442f768a5e90a49b2a4d61a9f1d59f73874bd4cf0710" +checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" dependencies = [ "atoi", "base64 0.22.1", @@ -4247,7 +4111,7 @@ dependencies = [ "serde_json", "sha2", "smallvec", - "sqlx-core 0.8.1", + "sqlx-core", "stringprep", "thiserror", "tracing", @@ -4256,9 +4120,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75b419c3c1b1697833dd927bdc4c6545a620bc1bbafabd44e1efbe9afcd337e" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" dependencies = [ "atoi", "chrono", @@ -4273,21 +4137,21 @@ dependencies = [ "percent-encoding", "serde", "serde_urlencoded", - "sqlx-core 0.8.1", + "sqlx-core", "tracing", "url", ] [[package]] name = "sqlxinsert" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70fabc5ed12c498984de1e89b7d343f0a24200586c3e245dd621381fc1680a2b" +checksum = "371a2005ee00d00cfa98691eddbd670131ba4033c0403008605ed592f480d76f" dependencies = [ "async-trait", "quote", - "sqlx 0.7.4", - "syn 2.0.76", + "sqlx", + "syn 2.0.82", ] [[package]] @@ -4328,11 +4192,11 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -4354,9 +4218,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -4372,7 +4236,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -4432,22 +4296,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -4526,9 +4390,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -4550,7 +4414,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -4637,13 +4501,13 @@ dependencies = [ "percent-encoding", "pin-project 1.1.5", "prost", - "rustls-native-certs", + "rustls-native-certs 0.7.2", "rustls-pemfile", "socket2", "tokio", "tokio-rustls", "tokio-stream", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -4669,6 +4533,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower-http" version = "0.6.1" @@ -4727,7 +4607,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -4854,12 +4734,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" -[[package]] -name = "unicode-segmentation" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" - [[package]] name = "unicode_categories" version = "0.1.1" @@ -4976,7 +4850,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", "wasm-bindgen-shared", ] @@ -5010,7 +4884,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5302,7 +5176,7 @@ dependencies = [ "schemars", "serde", "serde_json", - "sqlx 0.8.1", + "sqlx", "sqlxinsert", "thiserror", "tokio", @@ -5339,7 +5213,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] [[package]] @@ -5359,5 +5233,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.82", ] diff --git a/Cargo.toml b/Cargo.toml index e0bb3d1..3bd5b84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,26 +2,30 @@ license = "MIT" edition = "2021" version = "0.1.0" +readme = "README.md" name = "wld-usernames" authors = ["Miguel Piedrafita "] +repository = "https://github.com/worldcoin/wld-usernames" +description = "Backend powering World App username registration and querying." [dependencies] -axum = "0.7.5" +axum = "0.7.7" hex = "0.4.3" http = "1.1.0" idkit = "0.1.2" -regex = "1.10.6" -anyhow = "1.0.86" +regex = "1.11.0" +anyhow = "1.0.91" tracing = "0.1.40" dotenvy = "0.15.7" -thiserror = "1.0.63" +thiserror = "1.0.65" num-traits = "0.2.19" -serde_json = "1.0.127" +serde_json = "1.0.132" url = { version = "2.5.2", features = ["serde"] } -tokio = { version = "1.39.3", features = ["full"] } +tokio = { version = "1.41.0", features = ["full"] } chrono = { version = "0.4.38", features = ["serde"] } -reqwest = { version = "0.12.7", features = ["json"] } -serde = { version = "1.0.209", features = ["derive"] } +reqwest = { version = "0.12.8", features = ["json"] } +serde = { version = "1.0.213", features = ["derive"] } +tower-http = { version = "0.6.1", features = ["cors"] } axum-jsonschema = { version = "0.8.0", features = ["aide"] } schemars = { version = "0.8.21", features = ["chrono", "url"] } aide = { version = "0.13.4", features = ["axum", "macros", "scalar"] } @@ -29,7 +33,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } ruint = { version = "1.12.3", default-features = false, features = [ "num-traits", ] } -sqlxinsert = { version = "0.10.0", default-features = false, features = [ +sqlxinsert = { version = "0.11.0", default-features = false, features = [ "postgres", ] } alloy = { git = "https://github.com/alloy-rs/alloy.git", features = [ @@ -37,7 +41,7 @@ alloy = { git = "https://github.com/alloy-rs/alloy.git", features = [ "sol-types", "signer-local", ] } -sqlx = { version = "0.8.1", features = [ +sqlx = { version = "0.8.2", features = [ "chrono", "macros", "migrate", @@ -45,7 +49,6 @@ sqlx = { version = "0.8.1", features = [ "tls-rustls", "runtime-tokio", ], default-features = false } -tower-http = { version="0.6.1", features= ["cors"]} [build-dependencies] diff --git a/src/config.rs b/src/config.rs index 3524a21..23616ad 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,7 +23,6 @@ pub static DEVICE_USERNAME_REGEX: LazyLock = #[derive(Debug)] pub struct Config { pub wld_app_id: AppId, - pub ens_chain_id: u64, pub ens_domain: String, pub private_key: String, pub developer_portal_url: String, @@ -66,10 +65,6 @@ impl Config { .context("ENS_DOMAIN environment variable not set")?, private_key: env::var("PRIVATE_KEY") .context("PRIVATE_KEY environment variable not set")?, - ens_chain_id: env::var("ENS_CHAIN_ID") - .context("ENS_CHAIN_ID environment variable not set")? - .parse() - .context("ENS_CHAIN_ID could not be parsed as a number")?, wld_app_id: unsafe { AppId::new_unchecked( env::var("WLD_APP_ID").context("WLD_APP_ID environment variable not set")?, diff --git a/src/main.rs b/src/main.rs index 0dc5fb8..7a8a9e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,5 @@ #![warn(clippy::all, clippy::pedantic, clippy::nursery)] -use anyhow::Result; -use config::Config; -use dotenvy::dotenv; - mod blocklist; mod config; mod routes; @@ -13,8 +9,8 @@ mod utils; mod verify; #[tokio::main] -async fn main() -> Result<()> { - dotenv().ok(); +async fn main() -> anyhow::Result<()> { + dotenvy::dotenv().ok(); tracing_subscriber::fmt() .json() @@ -24,7 +20,7 @@ async fn main() -> Result<()> { tracing::info!("👩 Server started"); - let config = Config::from_env().await?; + let config = config::Config::from_env().await?; config.migrate_database().await?; tracing::info!("👩‍🌾 Migrations run"); diff --git a/src/routes/api/v1/ens_gateway.rs b/src/routes/api/v1/ens_gateway.rs index 696bc1a..d9afb43 100644 --- a/src/routes/api/v1/ens_gateway.rs +++ b/src/routes/api/v1/ens_gateway.rs @@ -1,9 +1,9 @@ use alloy::{ - primitives::{keccak256, Address, U256, U64}, + primitives::{keccak256, Address, U64}, signers::{local::PrivateKeySigner, Signature, Signer}, sol_types::{SolCall, SolValue}, }; -use axum::{body::Bytes, extract::Extension, http::StatusCode, response::IntoResponse}; +use axum::{body::Bytes, extract::Extension}; use axum_jsonschema::Json; use chrono::{TimeDelta, Utc}; use serde_json::from_slice; diff --git a/src/routes/api/v1/mod.rs b/src/routes/api/v1/mod.rs index df0f6e5..c2e2c65 100644 --- a/src/routes/api/v1/mod.rs +++ b/src/routes/api/v1/mod.rs @@ -29,7 +29,7 @@ pub fn handler() -> ApiRouter { .api_route("/ens", post_with(ens_gateway, ens_gateway_docs)) .layer(cors.clone()) .api_route("/query", post_with(query_multiple, query_multiple_docs)) - .layer(cors.clone()) + .layer(cors) .api_route("/rename", post_with(rename, rename_docs)) .api_route( "/register", diff --git a/src/routes/api/v1/query_single.rs b/src/routes/api/v1/query_single.rs index 52a3147..96d8927 100644 --- a/src/routes/api/v1/query_single.rs +++ b/src/routes/api/v1/query_single.rs @@ -52,8 +52,8 @@ pub fn docs(op: aide::transform::TransformOperation) -> aide::transform::Transfo } pub fn validate_address(name_or_address: &str) -> String { - match Address::from_str(name_or_address) { - Ok(address) => address.to_checksum(None), - Err(_) => name_or_address.to_string(), - } + Address::from_str(name_or_address).map_or_else( + |_| name_or_address.to_string(), + |address| address.to_checksum(None), + ) } diff --git a/src/types/error.rs b/src/types/error.rs index 4f5e955..8774095 100644 --- a/src/types/error.rs +++ b/src/types/error.rs @@ -52,7 +52,7 @@ impl ErrorResponse { } impl From for ErrorResponse { - fn from(err: E) -> Self { + fn from(_: E) -> Self { Self::server_error("Internal Server Error".to_string()) } } diff --git a/src/types/mod.rs b/src/types/mod.rs index 23d8b39..716621c 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -6,7 +6,7 @@ mod response; mod wrappers; pub use database::{MovedRecord, Name}; -pub use ens::{resolveCall as ResolveRequest, GatewayResponse, Method}; +pub use ens::{resolveCall as ResolveRequest, Method}; pub use error::{ENSErrorResponse, ErrorResponse}; pub use request::{ ENSQueryPayload, QueryAddressesPayload, RegisterUsernamePayload, RenamePayload, diff --git a/src/verify.rs b/src/verify.rs index 18e1968..c519297 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -16,6 +16,7 @@ pub enum Error { } #[derive(Debug, serde::Deserialize)] +#[allow(dead_code, reason = "Fields are used on the HTTP response.")] pub struct ErrorResponse { pub code: String, pub detail: String, @@ -48,7 +49,7 @@ pub async fn dev_portal_verify_proof( let signal = signal.abi_encode_packed(); let response = reqwest::Client::new() - .post(format!("{}/api/v2/verify/{}", developer_portal_url, app_id)) + .post(format!("{developer_portal_url}/api/v2/verify/{app_id}")) .header(header::USER_AGENT, "idkit-rs") .json(&VerificationRequest { proof: proof.proof,