diff --git a/Cargo.lock b/Cargo.lock index 3e81fc9e8..b3f9e39d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,9 +39,9 @@ dependencies = [ "actix-rt", "actix-service", "actix-utils", - "ahash 0.8.3", - "base64 0.21.3", - "bitflags 2.4.0", + "ahash 0.8.6", + "base64 0.21.5", + "bitflags 2.4.1", "bytes", "bytestring", "derive_more", @@ -109,7 +109,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.3", + "socket2 0.5.5", "tokio", "tracing", ] @@ -150,7 +150,7 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash 0.8.3", + "ahash 0.8.6", "bytes", "bytestring", "cfg-if", @@ -169,8 +169,8 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.5.3", - "time 0.3.28", + "socket2 0.5.5", + "time 0.3.30", "url", ] @@ -214,9 +214,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -225,21 +225,22 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -288,9 +289,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "annotate-snippets" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36" +checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e" dependencies = [ "unicode-width", "yansi-term", @@ -316,9 +317,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -330,15 +331,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -354,9 +355,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -419,14 +420,14 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" dependencies = [ "async-lock", "async-task", "concurrent-queue", - "fastrand 1.9.0", + "fastrand 2.0.1", "futures-lite", "slab", ] @@ -623,9 +624,9 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.23", + "rustix 0.37.27", "slab", - "socket2 0.4.9", + "socket2 0.4.10", "waker-fn", ] @@ -688,15 +689,15 @@ dependencies = [ [[package]] name = "async-task" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", @@ -723,9 +724,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atty" @@ -784,7 +785,7 @@ dependencies = [ "async-trait", "axum-core 0.3.4", "axum-macros", - "base64 0.21.3", + "base64 0.21.5", "bitflags 1.3.2", "bytes", "futures-util", @@ -793,7 +794,7 @@ dependencies = [ "http-body", "hyper", "itoa", - "matchit 0.7.2", + "matchit 0.7.3", "memchr", "mime", "multer", @@ -915,9 +916,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -927,9 +928,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" +checksum = "2f2139706359229bfa8f19142ac1155b4b80beafb7a60471ac5dd109d4a19778" dependencies = [ "serde", ] @@ -995,9 +996,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bitmaps" @@ -1041,16 +1042,15 @@ dependencies = [ [[package]] name = "blake3" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", "constant_time_eq", - "digest 0.10.7", ] [[package]] @@ -1094,17 +1094,18 @@ dependencies = [ [[package]] name = "blocking" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" dependencies = [ "async-channel", "async-lock", "async-task", - "atomic-waker", - "fastrand 1.9.0", + "fastrand 2.0.1", + "futures-io", "futures-lite", - "log", + "piper", + "tracing", ] [[package]] @@ -1115,9 +1116,9 @@ checksum = "008b57b368e638ed60664350ea4f2f3647a0192173478df2736cc255a025a796" [[package]] name = "brotli" -version = "3.3.4" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1126,9 +1127,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1152,9 +1153,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -1192,9 +1193,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -1207,9 +1208,9 @@ dependencies = [ [[package]] name = "bytestring" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" +checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" dependencies = [ "bytes", ] @@ -1348,24 +1349,23 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.1" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", - "clap_derive 4.4.0", - "once_cell", + "clap_derive 4.4.7", ] [[package]] name = "clap_builder" -version = "4.4.1" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", - "clap_lex 0.5.1", + "clap_lex 0.6.0", "strsim", ] @@ -1384,9 +1384,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.0" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -1405,9 +1405,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cobs" @@ -1510,7 +1510,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.3", + "base64 0.21.5", "bech32 0.9.1", "bs58 0.5.0", "digest 0.10.7", @@ -1551,9 +1551,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] @@ -1596,7 +1596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ "percent-encoding", - "time 0.3.28", + "time 0.3.30", "version_check", ] @@ -1613,7 +1613,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "time 0.3.28", + "time 0.3.30", "url", ] @@ -1657,9 +1657,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -1758,9 +1758,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" @@ -1780,7 +1780,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.4.1", + "clap 4.4.7", "criterion-plot", "futures", "is-terminal", @@ -1815,16 +1815,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -1888,9 +1878,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array 0.14.7", "rand_core", @@ -2104,10 +2094,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.0", + "hashbrown 0.14.2", "lock_api", "once_cell", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.9", ] [[package]] @@ -2138,9 +2128,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] [[package]] name = "derivative" @@ -2315,9 +2308,9 @@ dependencies = [ [[package]] name = "educe" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "079044df30bb07de7d846d41a184c4b00e66ebdac93ee459253474f3a47e50ae" +checksum = "0f0042ff8246a363dbe77d2ceedb073339e85a804b9a47636c6e016a9a32c05f" dependencies = [ "enum-ordinalize", "proc-macro2", @@ -2361,7 +2354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.2", + "crypto-bigint 0.5.3", "digest 0.10.7", "ff 0.13.0", "generic-array 0.14.7", @@ -2373,6 +2366,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -2430,9 +2429,9 @@ dependencies = [ [[package]] name = "enum-ordinalize" -version = "3.1.13" +version = "3.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4f76552f53cefc9a7f64987c3701b99d982f7690606fd67de1d09712fbf52f1" +checksum = "1bf1fa3f06bbff1ea5b1a9c7b14aa992a39657db60a2759457328d7e058f49ee" dependencies = [ "num-bigint", "num-traits", @@ -2443,9 +2442,9 @@ dependencies = [ [[package]] name = "enumset" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" +checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" dependencies = [ "enumset_derive", ] @@ -2470,25 +2469,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ - "errno-dragonfly", "libc", "windows-sys 0.48.0", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "eth-keystore" version = "0.5.0" @@ -2540,9 +2528,9 @@ dependencies = [ [[package]] name = "ethnum" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8ff382b2fa527fb7fb06eeebfc5bbb3f17e3cc6b9d70b006c41daa8824adac" +checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "event-listener" @@ -2608,9 +2596,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "ff" @@ -2660,6 +2648,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + [[package]] name = "fixed-hash" version = "0.8.0" @@ -2680,9 +2674,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -2872,7 +2866,7 @@ dependencies = [ "async-graphql 4.0.16", "async-trait", "axum 0.5.17", - "clap 4.4.1", + "clap 4.4.7", "derive_more", "enum-iterator 1.4.1", "fuel-core-chain-config", @@ -2906,7 +2900,7 @@ dependencies = [ "tokio-stream", "tower-http", "tracing", - "uuid 1.4.1", + "uuid 1.5.0", ] [[package]] @@ -2942,7 +2936,7 @@ dependencies = [ "fuel-core-types", "futures", "hex", - "hyper-rustls 0.24.1", + "hyper-rustls 0.24.2", "itertools 0.10.5", "reqwest", "serde", @@ -3374,7 +3368,6 @@ dependencies = [ "http", "lazy_static", "serde", - "serde_json", "serde_yaml", "sha2 0.9.9", "strum", @@ -3407,7 +3400,8 @@ dependencies = [ "fuel-indexer-schema", "fuel-indexer-types", "fuels", - "fuels-code-gen 0.46.0", + "fuels-code-gen 0.50.1", + "inflections", "lazy_static", "proc-macro-error", "proc-macro2", @@ -3438,6 +3432,8 @@ dependencies = [ "fuel-indexer-types", "getrandom", "hex", + "proc-macro2", + "quote", "serde", "serde_json", "sha2 0.10.8", @@ -3455,7 +3451,7 @@ dependencies = [ "fuel-indexer-metrics", "sqlx", "tracing", - "uuid 1.4.1", + "uuid 1.5.0", ] [[package]] @@ -3526,7 +3522,7 @@ dependencies = [ "sqlx", "thiserror", "tokio", - "toml 0.8.0", + "toml 0.8.8", "tracing", "tracing-subscriber 0.2.25", "trybuild", @@ -3540,6 +3536,8 @@ dependencies = [ name = "fuel-indexer-types" version = "0.23.0" dependencies = [ + "async-trait", + "bincode", "bytes", "fuel-tx 0.35.4", "fuel-types 0.35.4", @@ -3898,7 +3896,7 @@ dependencies = [ "rand", "serde", "serde_json", - "serde_with 3.3.0", + "serde_with 3.4.0", "tempfile", "tokio", "which", @@ -3912,9 +3910,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -3927,9 +3925,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -3937,15 +3935,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -3965,9 +3963,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -3986,9 +3984,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -3997,21 +3995,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -4065,9 +4063,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "js-sys", @@ -4203,9 +4201,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.3.7" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" +checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" dependencies = [ "log", "pest", @@ -4230,7 +4228,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -4239,16 +4237,16 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", ] [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "allocator-api2", ] @@ -4258,7 +4256,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.14.2", ] [[package]] @@ -4267,7 +4265,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.3", + "base64 0.21.5", "bytes", "headers-core", "http", @@ -4337,9 +4335,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -4440,7 +4438,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -4481,19 +4479,19 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", "hyper", "log", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", - "webpki-roots 0.23.1", + "webpki-roots 0.25.2", ] [[package]] @@ -4523,16 +4521,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -4646,19 +4644,19 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.2", ] [[package]] name = "indicatif" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" dependencies = [ "console", "instant", @@ -4667,6 +4665,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "inflections" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" + [[package]] name = "inout" version = "0.1.3" @@ -4678,9 +4682,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.31.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0770b0a3d4c70567f0d58331f3088b0e4c4f56c9b8d764efe654b4a5d46de3a" +checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc" dependencies = [ "console", "lazy_static", @@ -4705,16 +4709,16 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -4722,8 +4726,8 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.10", + "hermit-abi 0.3.3", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -4753,18 +4757,18 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -4775,9 +4779,9 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.3", + "base64 0.21.5", "pem", - "ring", + "ring 0.16.20", "serde", "serde_json", "simple_asn1", @@ -4853,9 +4857,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -4867,6 +4871,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "librocksdb-sys" version = "0.11.0+8.1.1" @@ -4907,33 +4922,32 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "local-channel" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" dependencies = [ "futures-core", "futures-sink", - "futures-util", "local-waker", ] [[package]] name = "local-waker" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -5010,24 +5024,25 @@ checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" [[package]] name = "matchit" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed1202b2a6f884ae56f04cff409ab315c5ce26b5e58d7412e484f01fd52f52ef" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if", "digest 0.10.7", ] [[package]] name = "memchr" -version = "2.6.2" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -5038,6 +5053,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.8.0" @@ -5100,9 +5124,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", @@ -5195,9 +5219,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -5208,7 +5232,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", ] @@ -5220,9 +5244,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -5253,11 +5277,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cfg-if", "foreign-types", "libc", @@ -5285,18 +5309,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "111.27.0+1.1.1v" +version = "300.1.6+3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e8f197c82d7511c5b014030c9b1efeda40d7d5f99d23b4ceed3524a5e63f02" +checksum = "439fac53e092cd7442a3660c85dde4643ab3b5bd39040912388dcdabf6b88085" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.92" +version = "0.9.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", @@ -5317,9 +5341,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "overload" @@ -5373,9 +5397,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -5395,7 +5419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.9", ] [[package]] @@ -5414,13 +5438,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -5514,9 +5538,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -5525,9 +5549,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -5535,9 +5559,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", @@ -5548,9 +5572,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -5564,7 +5588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.1.0", ] [[package]] @@ -5663,6 +5687,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + [[package]] name = "pkcs8" version = "0.9.0" @@ -5741,9 +5776,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" [[package]] name = "portpicker" @@ -5756,15 +5791,22 @@ dependencies = [ [[package]] name = "postcard" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d534c6e61df1c7166e636ca612d9820d486fe96ddad37f7abc671517b297488e" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" dependencies = [ "cobs", + "embedded-io", "heapless", "serde", ] +[[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" @@ -5783,9 +5825,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", "syn 2.0.39", @@ -5793,18 +5835,18 @@ dependencies = [ [[package]] name = "primeorder" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2fcef82c0ec6eefcc179b978446c399b3cdf73c392c35604e399eee6df1ee3" +checksum = "c7dbe9ed3b56368bd99483eb32fe9c17fdd3730aebadc906918ce78d54c7eeb4" dependencies = [ "elliptic-curve 0.13.6", ] [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -5820,7 +5862,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit 0.19.14", + "toml_edit 0.19.15", ] [[package]] @@ -6027,9 +6069,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -6037,14 +6079,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -6065,14 +6105,23 @@ dependencies = [ "bitflags 1.3.2", ] +[[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 = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] @@ -6146,20 +6195,20 @@ dependencies = [ [[package]] name = "rend" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" dependencies = [ "bytecheck", ] [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.3", + "base64 0.21.5", "bytes", "cookie", "cookie_store", @@ -6170,7 +6219,7 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-rustls 0.24.1", + "hyper-rustls 0.24.2", "hyper-tls", "ipnet", "js-sys", @@ -6181,11 +6230,12 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -6231,11 +6281,25 @@ dependencies = [ "libc", "once_cell", "spin 0.5.2", - "untrusted", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -6260,7 +6324,7 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid 1.4.1", + "uuid 1.5.0", ] [[package]] @@ -6323,9 +6387,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.23" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", @@ -6337,14 +6401,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.10" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.11", "windows-sys 0.48.0", ] @@ -6356,7 +6420,7 @@ checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" dependencies = [ "base64 0.13.1", "log", - "ring", + "ring 0.16.20", "sct 0.6.1", "webpki 0.21.4", ] @@ -6368,21 +6432,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", - "ring", - "sct 0.7.0", - "webpki 0.22.1", + "ring 0.16.20", + "sct 0.7.1", + "webpki 0.22.4", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", - "rustls-webpki 0.101.4", - "sct 0.7.0", + "ring 0.17.5", + "rustls-webpki", + "sct 0.7.1", ] [[package]] @@ -6415,27 +6479,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.3", -] - -[[package]] -name = "rustls-webpki" -version = "0.100.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" -dependencies = [ - "ring", - "untrusted", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.101.4" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -6501,18 +6555,18 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -6619,6 +6673,12 @@ dependencies = [ "libc", ] +[[package]] +name = "self_cell" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c309e515543e67811222dbc9e3dd7e1056279b782e1dacffe4242b718734fb6" + [[package]] name = "semver" version = "1.0.20" @@ -6627,9 +6687,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] @@ -6647,9 +6707,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -6679,9 +6739,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -6710,9 +6770,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ "serde", ] @@ -6743,9 +6803,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -6800,13 +6860,23 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] +[[package]] +name = "shared-buffer" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cf61602ee61e2f83dd016b3e6387245291cf728ea071c378b35088125b4d995" +dependencies = [ + "bytes", + "memmap2 0.6.2", +] + [[package]] name = "shared_child" version = "1.0.0" @@ -6819,9 +6889,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signal-hook-registry" @@ -6860,9 +6930,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "similar" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" [[package]] name = "simple-wasm" @@ -6884,7 +6954,7 @@ dependencies = [ "num-bigint", "num-traits", "thiserror", - "time 0.3.28", + "time 0.3.30", ] [[package]] @@ -6920,9 +6990,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "snafu" @@ -6949,9 +7019,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -6959,9 +7029,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -7004,11 +7074,11 @@ dependencies = [ [[package]] name = "sqlformat" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" +checksum = "6b7b278788e7be4d0d29c0f39497a0eef3fba6bbc8e70d8bf7fde46edeaa9e85" dependencies = [ - "itertools 0.10.5", + "itertools 0.11.0", "nom", "unicode_categories", ] @@ -7038,7 +7108,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", "atoi", "base64 0.13.1", "bigdecimal", @@ -7082,7 +7152,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", - "time 0.3.28", + "time 0.3.30", "tokio-stream", "url", "webpki-roots 0.22.6", @@ -7136,10 +7206,11 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stringprep" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3737bde7edce97102e0e2b15365bf7a20bfdb5f60f4f9e8d7004258a51a8da" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" dependencies = [ + "finl_unicode", "unicode-bidi", "unicode-normalization", ] @@ -7350,6 +7421,27 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[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 = "tai64" version = "4.0.0" @@ -7378,28 +7470,28 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand 2.0.0", - "redox_syscall 0.3.5", - "rustix 0.38.10", + "fastrand 2.0.1", + "redox_syscall 0.4.1", + "rustix 0.38.21", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -7453,12 +7545,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -7466,15 +7559,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ "time-core", ] @@ -7527,7 +7620,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", ] @@ -7592,7 +7685,7 @@ checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls 0.20.9", "tokio", - "webpki 0.22.1", + "webpki 0.22.4", ] [[package]] @@ -7601,7 +7694,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.8", "tokio", ] @@ -7619,9 +7712,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", @@ -7631,9 +7724,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -7655,43 +7748,43 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.0", + "toml_edit 0.21.0", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", "toml_datetime", "winnow", ] [[package]] name = "toml_edit" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -7755,11 +7848,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -7768,9 +7860,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", @@ -7779,9 +7871,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -7801,12 +7893,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -7871,9 +7963,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.83" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df60d81823ed9c520ee897489573da4b1d79ffbe006b8134f46de1a1aa03555" +checksum = "196a58260a906cedb9bf6d8034b6379d0c11f552416960452f267402ceeddff1" dependencies = [ "basic-toml", "glob", @@ -7886,9 +7978,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ "byteorder", "bytes", @@ -7905,9 +7997,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -7944,9 +8036,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -7965,9 +8057,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -7996,6 +8088,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.1" @@ -8031,9 +8129,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ "getrandom", ] @@ -8046,9 +8144,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92ccd67fb88503048c01b59152a04effd0782d035a83a6d256ce6085f08f4a3" +checksum = "4a72e1902dde2bd6441347de2b70b7f5d59bf157c6c62f0c44572607a1d55bbe" [[package]] name = "vcpkg" @@ -8076,15 +8174,15 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "waker-fn" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -8113,9 +8211,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -8123,9 +8221,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", @@ -8161,9 +8259,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -8173,9 +8271,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -8183,9 +8281,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", @@ -8196,9 +8294,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "wasm-encoder" @@ -8224,9 +8322,9 @@ dependencies = [ [[package]] name = "wasmer" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7142dbb91ede83cc0aef2301fa75fcc7e0c9e5a7d5358e3c4f3a7249fe9ce8" +checksum = "50cb1ae2956aac1fbbcf334c543c1143cdf7d5b0a5fb6c3d23a17bf37dd1f47b" dependencies = [ "bytes", "cfg-if", @@ -8237,6 +8335,7 @@ dependencies = [ "rustc-demangle", "serde", "serde-wasm-bindgen", + "shared-buffer", "target-lexicon", "thiserror", "wasm-bindgen", @@ -8252,19 +8351,23 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b99c70711ec7631b602a9fc95577c40df21e8f3916159c9d80c3fb4f77abdc" +checksum = "12fd9aeef339095798d1e04957d5657d97490b1112f145cbf08b98f6393b4a0a" dependencies = [ "backtrace", + "bytes", "cfg-if", "enum-iterator 0.7.0", "enumset", "lazy_static", "leb128", - "memmap2", + "memmap2 0.5.10", "more-asserts", "region", + "rkyv", + "self_cell", + "shared-buffer", "smallvec", "thiserror", "wasmer-types", @@ -8275,9 +8378,9 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52aef2ef35513a04fed54de9a7dc9c469d4742a5c2e378a5f7e2a79b1327e3bd" +checksum = "344f5f1186c122756232fe7f156cc8d2e7bf333d5a658e81e25efa3415c26d07" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -8294,9 +8397,9 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bb1425c9e4dc3e2d3aacd6e82e22e27a3127379e0d09bcbdf25ff376229162" +checksum = "2ac8c1f2dc0ed3c7412a5546e468365184a461f8ce7dfe2a707b621724339f91" dependencies = [ "proc-macro-error", "proc-macro2", @@ -8306,9 +8409,9 @@ dependencies = [ [[package]] name = "wasmer-middlewares" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acfc08fb8e2e1511f1d69302d7406ace6c0ec0c90e103f8c0a5aa81ecb9fe81f" +checksum = "2dcde781a2db145acfff3873197838dc125bb2fab3e7ee3edbcf6b094eae6588" dependencies = [ "wasmer", "wasmer-types", @@ -8317,9 +8420,9 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e32ed799fa8c0d96ca9615d9ea8006857a0f0c18e7c2ed8082bd5c63a9ea70" +checksum = "5a57ecbf218c0a9348d4dfbdac0f9d42d9201ae276dffb13e61ea4ff939ecce7" dependencies = [ "bytecheck", "enum-iterator 0.7.0", @@ -8333,14 +8436,15 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "4.1.2" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0847513cb176b5d62a6f65d6ae474594935e726a10e9e3387177d9cbf8b8cda0" +checksum = "60c3513477bc0097250f6e34a640e2a903bb0ee57e6bb518c427f72c06ac7728" dependencies = [ "backtrace", "cc", "cfg-if", "corosensei", + "crossbeam-queue", "dashmap", "derivative", "enum-iterator 0.7.0", @@ -8400,9 +8504,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -8414,18 +8518,18 @@ version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] name = "webpki" -version = "0.22.1" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -8434,16 +8538,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.1", -] - -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.2", + "webpki 0.22.4", ] [[package]] @@ -8461,7 +8556,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.10", + "rustix 0.38.21", ] [[package]] @@ -8492,9 +8587,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -8506,10 +8601,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets 0.48.5", ] @@ -8691,9 +8786,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] @@ -8780,6 +8875,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 043583342..869a12273 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,6 +88,7 @@ fuel-tx = { version = "=0.35.4", default-features = false } fuel-types = { version = "=0.35.4", default-features = false, features = ["serde"] } fuel-vm = { version = "=0.35.4", default-features = false } fuels = { version = "0.50", default-features = false } +fuels-code-gen = { version = "0.50", default-features = false } serde = { version = "1.0", default-features = false, features = ["derive"] } serde_json = { version = "1.0", default-features = false } thiserror = "1.0" diff --git a/ci/Dockerfile.fuel-node b/ci/Dockerfile.fuel-node index c45ec95ad..97c51a982 100644 --- a/ci/Dockerfile.fuel-node +++ b/ci/Dockerfile.fuel-node @@ -51,5 +51,5 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -y \ COPY --from=builder /build/target/release/fuel-node . COPY --from=builder /build/target/release/fuel-node.d . COPY --from=builder /build/packages/fuel-indexer-tests/test-chain-config.json . -COPY --from=builder /build/packages/fuel-indexer-tests/contracts/fuel-indexer-test/out/debug/fuel-indexer-test.bin . -COPY --from=builder /build/examples/greetings/contracts/greeting/out/debug/greeting.bin . +COPY --from=builder /build/packages/fuel-indexer-tests/sway/fuel-indexer-test/out/debug/fuel-indexer-test.bin . +COPY --from=builder /build/examples/hello-world/contracts/greeting/out/debug/greeting.bin . diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 970c27264..14198e66e 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -25,6 +25,7 @@ - [Blocks](./indexing-fuel-types/blocks.md) - [Transactions](./indexing-fuel-types/transactions.md) - [Receipts](./indexing-fuel-types/receipts.md) + - [Predicates](./indexing-fuel-types/predicates.md) - [Indexing Custom Types](./indexing-custom-types/index.md) - [Storing Records](./storing-records/index.md) - [Querying](./querying/index.md) diff --git a/docs/src/indexing-custom-types/index.md b/docs/src/indexing-custom-types/index.md index c80c72981..126e7995e 100644 --- a/docs/src/indexing-custom-types/index.md +++ b/docs/src/indexing-custom-types/index.md @@ -178,12 +178,11 @@ Specifically, we should ensure that the `contract_abi` and `graphql_schema` fiel # as an organization identifier namespace: fuellabs -# The identifier field is used to identify the given index. +# Unique identifier for this indexer. identifier: custom_types_example -# The abi option is used to provide a link to the Sway JSON ABI that is generated when you -# build your project. -abi: path/to/custom/type/example/contract-abi.json +# A file path to the contract JSON ABI that is generated when you build your Sway contract. +contract_abi: path/to/custom/type/example/contract-abi.json # The particular start block after which you'd like your indexer to start indexing events. start_block: ~ @@ -197,11 +196,10 @@ end_block: ~ # with the `--indexer_net_config` option. fuel_client: ~ -# The contract_id specifies which particular contract you would like your index to subscribe to. +# Specifies which particular contract(s) you would like your indexer to subscribe to. contract_id: ~ -# The graphql_schema field contains the file path that points to the GraphQL schema for the -# given index. +# A file path that points to the GraphQL schema for the given indexer. graphql_schema: path/to/custom/type/example/indexer.schema.graphql # The module field contains a file path that points to code that will be run as an executor inside diff --git a/docs/src/indexing-fuel-types/index.md b/docs/src/indexing-fuel-types/index.md index c3646b0a2..b05eefd20 100644 --- a/docs/src/indexing-fuel-types/index.md +++ b/docs/src/indexing-fuel-types/index.md @@ -5,3 +5,4 @@ This document provides information about Fuel-specific types and provides exampl - [Blocks](./blocks.md) - [Transactions](./transactions.md) - [Receipts](./receipts.md) +- [Predicates](./predicates.md) diff --git a/docs/src/indexing-fuel-types/predicates.md b/docs/src/indexing-fuel-types/predicates.md new file mode 100644 index 000000000..fb085e88e --- /dev/null +++ b/docs/src/indexing-fuel-types/predicates.md @@ -0,0 +1,56 @@ +# Predicates + +## Definition + +- Immutable and ephemeral. +- Predicates are one of the most important abstractions that Fuel makes availabe. A predicate effectively has two states: a _created_ state, and a _spent_ state. A predicate has a `created` state when the predicate is...created. + + - A predicate becomes "created" when a given UTXO inclues certain parameters in its [witness data](./transactions.md). + - A predicate becomes "spent" when the aforementioned UTXO is used as an input into a subsequent [Transaction](./transactions.md), where this subsequent Transaction also includes certain parameters in its witness data. + +> TLDR: A predicate is a UTXO that includes extra information sent in the Transaction. + +```rust,ignore +/// Standardized `Witness` data format for predicates. +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct IndexerPredicate { + /// Hash of associated predicate bytecode + template_id: Bytes32, + + /// Configurable constants in predicates. + configurables: Vec, + + /// Relevant TX output indices of predicates that need to be watched. + output_index: u64, + + /// UTXO held by predicate. + coin_output: CoinOutput, + + /// ID of transaction in which predicate was created. + unspent_tx_id: Bytes32, + + /// ID of transaction in which predicate was spent. + spent_tx_id: Option, +} +``` + +## Usage + +In order to get started indexing Predicates, users will need to: + +1. Create a new Predicate project using [`forc`] +2. Build this predicate project in order to get the JSON ABI. +3. Add this predicate template hash to your indexer manifest. +4. Include the appropriate witness data in transactions you wish to flag to your indexer + +```rust,ignore +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[indexer(manifest = "indexer.manifest.yaml")] +mod indexer_mod { + fn handle_spent_predicates(predicates: Vec) { + unimplemented!() + } +} +``` diff --git a/docs/src/indexing-fuel-types/receipts.md b/docs/src/indexing-fuel-types/receipts.md index a000df9dd..083cff326 100644 --- a/docs/src/indexing-fuel-types/receipts.md +++ b/docs/src/indexing-fuel-types/receipts.md @@ -34,6 +34,9 @@ pub struct Burn { ``` ```rust, ignore +extern crate alloc; +use fuel_indexer_utils::prelude::*; + mod indexer_mod { fn handle_burn_receipt(block_data: BlockData) { let height = block_data.header.height; diff --git a/docs/src/project-components/manifest.md b/docs/src/project-components/manifest.md index 96ed9c883..81931b8a0 100644 --- a/docs/src/project-components/manifest.md +++ b/docs/src/project-components/manifest.md @@ -8,13 +8,18 @@ Below is a sample indexer manifest file namespace: fuellabs identifier: order_book_v1 fuel_client: beta-4.fuel.network:80 -abi: path/to/my/contract-abi.json -contract_id: "fuels0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051" +contract: + abi: path/to/my/contract-abi.json + subscriptions: + - fuels0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051 graphql_schema: path/to/my/schema.graphql start_block: 1564 end_block: 310000 module: wasm: path/to/my/wasm_module.wasm +predicates: + abis: ~ + templates: ~ ``` ## `namespace` @@ -35,19 +40,26 @@ _Optional._ The `fuel_client` denotes the address (host, port combination) of the running Fuel client that you would like your indexer to index events from. In order to use this per-indexer `fuel_client` option, the indexer service at which your indexer is deployed will have to run with the `--indexer_net_config` option. -## `abi` +## `contract` + +_Optional._ + +Indexer contract settings. + +### `abi` _Optional._ The `abi` option is used to provide a link to the Sway JSON application binary interface (ABI) that is generated when you build your Sway project. This generated ABI contains all types, type IDs, logged types, and message types used in your Sway contract. -## `contract_id` +### `subscriptions` _Optional._ -The `contract_id` specifies the particular contract to which you would like an indexer to subscribe. Setting this field to an empty string will index events from any contract that is currently executing on the network. This field accepts either a single string, or a list of strings. The indexer will index events from all IDs if a list is passed. +The `contract_subscriptions` specifies the particular contract to which you would like an indexer to subscribe. Setting this field to an empty string will index events from any contract that is currently executing on the network. This field accepts either a single string, or a list of strings. The indexer will index events from all IDs if a list is passed. -> Important: Contract IDs are unique to the content of a contract. If you are subscribing to a certain contract and then the contract itself is changed or updated, you will need to change the `contract_id` field of the manifest to the new ID. +> Important: Contract IDs are unique to the content of a contract. If you are subscribing to a certain contract and then the contract itself is changed or updated, you will need to change the `subscriptions` field of the manifest with the new contract ID. +> > Note: This parameter supports both Bech32 contract IDs and non-Bech32 contract IDs ## `graphql_schema` @@ -83,3 +95,21 @@ The `module` field contains a file path that points to code that will be run as _Optional._ The `resumable` field contains a boolean value and specifies whether the indexer should synchronise with the latest block if it has fallen out of sync. + +## `predicates` + +_Optional._ + +Indexer predication configuration. + +### `abis` + +_Optional._ + +List of file paths to ABIs for predicates used by this indexer. + +### `templates` + +_Optional._ + +A list of template hashes and template names used to identify each predicate used by this indexer. diff --git a/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml b/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml index 21d61ce07..e1157714c 100644 --- a/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml +++ b/examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml @@ -5,9 +5,14 @@ namespace: fuellabs # The identifier field is used to identify the given index. identifier: explorer -# The abi option is used to provide a link to the Sway JSON ABI that is generated when you -# build your project. -abi: ~ +# Indexer contract configuration. +contract: + + # File paths to the contract JSON ABIs that are generated when you build your Sway contracts. + abi: ~ + + # Specifies which particular contracts you would like your indexer to subscribe to. + subscriptions: ~ # The particular start block after which you'd like your indexer to start indexing events. start_block: ~ @@ -21,9 +26,6 @@ end_block: ~ # with the `--indexer_net_config` option. fuel_client: ~ -# The contract_id specifies which particular contract you would like your index to subscribe to. -contract_id: ~ - # The graphql_schema field contains the file path that points to the GraphQL schema for the # given index. graphql_schema: examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql @@ -37,3 +39,9 @@ module: # The resumable field contains a boolean that specifies whether or not the indexer should, synchronise # with the latest block if it has fallen out of sync. resumable: true + +# Indexer predicate configuration. +predicates: + + # Template commitments (hashes) of the bytecode of predicates used by this indexer. + templates: ~ diff --git a/examples/greetings/greetings-indexer/greetings_indexer.manifest.yaml b/examples/greetings/greetings-indexer/greetings_indexer.manifest.yaml index 2c49dbbc7..18fae66f4 100644 --- a/examples/greetings/greetings-indexer/greetings_indexer.manifest.yaml +++ b/examples/greetings/greetings-indexer/greetings_indexer.manifest.yaml @@ -5,9 +5,15 @@ namespace: fuellabs # The identifier field is used to identify the given index. identifier: greetings -# The abi option is used to provide a link to the Sway JSON ABI that is generated when you -# build your project. -abi: examples/greetings/contracts/greeting/out/debug/greeting-abi.json +# Indexer contract configuration. +contract: + + # File paths to the contract JSON ABIs that are generated when you build your Sway contracts. + abi: examples/greetings/contracts/greeting/out/debug/greeting-abi.json + + # Specifies which particular contracts you would like your indexer to subscribe to. + subscriptions: + - fuel1q6sj2srt0u40jdqg2lvvnspyuhse9rs2s2fv9nmv0hqjcrdc7sqsfpwv9x # The particular start block after which you'd like your indexer to start indexing events. start_block: ~ @@ -21,9 +27,6 @@ end_block: ~ # with the `--indexer_net_config` option. fuel_client: ~ -# The contract_id specifies which particular contract you would like your index to subscribe to. -contract_id: fuel1q6sj2srt0u40jdqg2lvvnspyuhse9rs2s2fv9nmv0hqjcrdc7sqsfpwv9x - # The graphql_schema field contains the file path that points to the GraphQL schema for the # given index. graphql_schema: examples/greetings/greetings-indexer/schema/greetings_indexer.schema.graphql @@ -36,4 +39,10 @@ module: # The resumable field contains a boolean that specifies whether or not the indexer should, synchronise # with the latest block if it has fallen out of sync. -resumable: true \ No newline at end of file +resumable: true + +# Indexer predicate configuration. +predicates: + + # Template commitments (hashes) of the bytecode of predicates used by this indexer. + templates: ~ diff --git a/examples/hello-world/hello-world/hello_world.manifest.yaml b/examples/hello-world/hello-world/hello_world.manifest.yaml index bebda374e..9ffbc92d4 100644 --- a/examples/hello-world/hello-world/hello_world.manifest.yaml +++ b/examples/hello-world/hello-world/hello_world.manifest.yaml @@ -5,9 +5,14 @@ namespace: fuellabs # The identifier field is used to identify the given index. identifier: hello_world -# The abi option is used to provide a link to the Sway JSON ABI that is generated when you -# build your project. -abi: ~ +# Indexer contract configuration. +contract: + + # File paths to the contract JSON ABIs that are generated when you build your Sway contracts. + abi: ~ + + # Specifies which particular contracts you would like your indexer to subscribe to. + subscriptions: ~ # The particular start block after which you'd like your indexer to start indexing events. start_block: ~ @@ -21,9 +26,6 @@ end_block: ~ # with the `--indexer_net_config` option. fuel_client: ~ -# The contract_id specifies which particular contract you would like your index to subscribe to. -contract_id: ~ - # The graphql_schema field contains the file path that points to the GraphQL schema for the # given index. graphql_schema: examples/hello-world/hello-world/schema/hello_world.schema.graphql @@ -36,4 +38,10 @@ module: # The resumable field contains a boolean that specifies whether or not the indexer should, synchronise # with the latest block if it has fallen out of sync. -resumable: true \ No newline at end of file +resumable: true + +# Indexer predicate configuration. +predicates: + + # Template commitments (hashes) of the bytecode of predicates used by this indexer. + templates: ~ diff --git a/packages/fuel-indexer-api-server/src/uses.rs b/packages/fuel-indexer-api-server/src/uses.rs index 747b36f3b..316d0a09c 100644 --- a/packages/fuel-indexer-api-server/src/uses.rs +++ b/packages/fuel-indexer-api-server/src/uses.rs @@ -492,7 +492,7 @@ pub(crate) async fn verify_signature( } _ => { error!("Unsupported authentication strategy."); - unimplemented!(); + unimplemented!("Unsupported authentication strategy."); } } } diff --git a/packages/fuel-indexer-benchmarks/benches/wasm/examples/fuel_explorer.rs b/packages/fuel-indexer-benchmarks/benches/wasm/examples/fuel_explorer.rs index 48caa2318..d6b9fd708 100644 --- a/packages/fuel-indexer-benchmarks/benches/wasm/examples/fuel_explorer.rs +++ b/packages/fuel-indexer-benchmarks/benches/wasm/examples/fuel_explorer.rs @@ -5,7 +5,7 @@ use fuel_indexer_lib::{config::IndexerConfig, manifest::Manifest}; fn setup_fuel_explorer_manifest() -> Manifest { let manifest_str = r#" namespace: indexer_benchmarks -abi: ~ +contract_abi: ~ identifier: fuel_explorer fuel_client: ~ graphql_schema: ../../examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql @@ -16,6 +16,8 @@ contract_id: ~ start_block: ~ end_block: ~ resumable: ~ +predicates: + templates: ~ "#; Manifest::try_from(manifest_str).unwrap() diff --git a/packages/fuel-indexer-lib/Cargo.toml b/packages/fuel-indexer-lib/Cargo.toml index b58276d79..b0d11182e 100644 --- a/packages/fuel-indexer-lib/Cargo.toml +++ b/packages/fuel-indexer-lib/Cargo.toml @@ -19,7 +19,6 @@ fuel-indexer-types = { workspace = true } http = { version = "0.2", default-features = false } lazy_static = { version = "1.4" } serde = { workspace = true } -serde_json = { workspace = true } serde_yaml = "0.8" sha2 = "0.9" strum = { version = "0.24", default-features = false, features = ["derive"] } diff --git a/packages/fuel-indexer-lib/src/constants.rs b/packages/fuel-indexer-lib/src/constants.rs index 9c296eede..480792a18 100644 --- a/packages/fuel-indexer-lib/src/constants.rs +++ b/packages/fuel-indexer-lib/src/constants.rs @@ -6,6 +6,7 @@ lazy_static! { /// Set of internal indexer entities. pub static ref INTERNAL_INDEXER_ENTITIES: HashSet<&'static str> = HashSet::from([ "IndexMetadataEntity", + "PredicateEntity", ]); /// Set of types that implement `AsRef<[u8]>`. @@ -84,28 +85,30 @@ lazy_static! { "Option", "Option", "Option", - "Option", "Option", + "Option", + "String", "UID", "Vec", - "String", ]); /// Fuel-specific receipt-related type names. pub static ref FUEL_PRIMITIVES: HashSet<&'static str> = HashSet::from([ "BlockData", + "Burn", "Call", + "IndexerPredicate", "Log", "LogData", "MessageOut", + "Mint", "Panic", + "FooPredicate", "Return", "Revert", "ScriptResult", "Transfer", "TransferOut", - "Mint", - "Burn", ]); /// Type names that are not allowed in GraphQL schema. @@ -145,6 +148,7 @@ lazy_static! { "FieldTxPointer", "GasLimit", "GasPrice", + "IndexerPredicate", "Inputs", "Log", "Log", @@ -156,6 +160,7 @@ lazy_static! { "Mint", "Outputs", "Panic", + "FooPredicate", "ReceiptsRoot", "Return", "Revert", @@ -181,17 +186,18 @@ lazy_static! { /// Generic Sway ABI types. pub static ref IGNORED_GENERIC_METADATA: HashSet<&'static str> = HashSet::from([ - "generic T", + "enum Result", + "generic D", "generic E", + "generic T", "raw untyped ptr", - "struct RawVec", - "struct RawBytes", "struct Bytes", - "enum Result" + "struct RawBytes", + "struct RawVec", ]); pub static ref GENERIC_STRUCTS: HashSet<&'static str> = HashSet::from([ + "Option", "Vec", - "Option" ]); } diff --git a/packages/fuel-indexer-lib/src/graphql/mod.rs b/packages/fuel-indexer-lib/src/graphql/mod.rs index 69bed9628..196672c8d 100644 --- a/packages/fuel-indexer-lib/src/graphql/mod.rs +++ b/packages/fuel-indexer-lib/src/graphql/mod.rs @@ -14,7 +14,7 @@ use async_graphql_parser::{ }, Pos, Positioned, }; -use fuel_indexer_types::graphql::IndexMetadata; +use fuel_indexer_types::native::{GraphQLEntity, IndexMetadata, IndexerPredicate}; use sha2::{Digest, Sha256}; use std::collections::{HashMap, HashSet}; use types::IdCol; @@ -32,11 +32,19 @@ pub fn schema_version(schema: &str) -> String { /// Inject native entities into the GraphQL schema. fn inject_native_entities_into_schema(schema: &str) -> String { + // NOTE: This is fine for now as long as the number of native entities is relatively small + // But should we continue to inject entities like this we'll need to make this a bit more + // idiomatic. + let mut schema = schema.to_string(); if !schema.contains("type IndexMetadataEntity") { - format!("{}{}", schema, IndexMetadata::schema_fragment()) - } else { - schema.to_string() + schema = format!("{}{}", schema, IndexMetadata::schema_fragment()) + } + + if !schema.contains("type PredicateEntity") { + schema = format!("{}{}", schema, IndexerPredicate::schema_fragment()) } + + schema } /// Inject internal types into the schema. In order to support popular diff --git a/packages/fuel-indexer-lib/src/manifest.rs b/packages/fuel-indexer-lib/src/manifest.rs index 24d954282..ce1cec2e0 100644 --- a/packages/fuel-indexer-lib/src/manifest.rs +++ b/packages/fuel-indexer-lib/src/manifest.rs @@ -5,7 +5,6 @@ use std::{ fs::File, io::{Read, Write}, path::{Path, PathBuf}, - str::FromStr, }; use thiserror::Error; @@ -21,6 +20,8 @@ pub enum ManifestError { NativeModuleError, #[error("File IO error: {0} {1:?}.")] FileError(String, #[source] std::io::Error), + #[error("Native execution not supported.")] + NativeExecutionNotSupported, } /// Specifies which type of module is used to create this indexer. @@ -55,6 +56,59 @@ impl AsRef for Module { } } +/// Predicates used by this indexer. +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct Predicates { + /// Predicate templates + templates: Option>, +} + +impl Predicates { + /// Get the predicate templates. + pub fn templates(&self) -> Option<&[PredicateTemplate]> { + self.templates.as_deref() + } + + /// Check if this predicate set is empty. + pub fn is_empty(&self) -> bool { + self.templates.is_none() + } +} + +/// Represents a predicate template. +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct PredicateTemplate { + /// Name of predicate. + pub name: String, + + /// Hash of predicate bytecode used to uniquely identify predicate. + pub id: String, + + /// Filepath to Sway predicate ABI. + pub abi: String, +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct Contract { + /// Filepath to Sway contract ABI. + abi: Option, + + /// Set of contract IDs this indexer should subscribe to. + subsriptions: Option>, +} + +impl Contract { + /// Get the contract ABI. + pub fn abi(&self) -> Option<&str> { + self.abi.as_deref() + } + + /// Get the contract subscriptions. + pub fn subscriptions(&self) -> Option<&[String]> { + self.subsriptions.as_deref() + } +} + /// Represents the indexer manifest file. /// /// This manifest file is a simple YAML file that is read and passed @@ -69,8 +123,8 @@ pub struct Manifest { /// Identifier of indexer. identifier: String, - /// Filepath to Sway contract ABI. - abi: Option, + /// Contract configuration. + contract: Option, /// URL to Fuel client. /// @@ -83,16 +137,6 @@ pub struct Manifest { /// Executor module. module: Module, - /// Whether or not to record metrics for this indexer. - metrics: Option, - - /// Set of contract IDs this indexer should subscribe to. - #[serde( - serialize_with = "ContractIds::serialize", - deserialize_with = "ContractIds::deserialize" - )] - contract_id: ContractIds, - /// Block at which indexer should start. start_block: Option, @@ -100,8 +144,10 @@ pub struct Manifest { end_block: Option, /// When set to true, the indexer will resume from the block height at which it last stopped. - #[serde(default)] resumable: Option, + + /// Set of predicates used by this indexer. + predicates: Option, } impl Manifest { @@ -174,16 +220,7 @@ impl Manifest { self.end_block = Some(block); } - /// Set the GraphQL schema for this indexer. - pub fn set_graphql_schema(&mut self, schema: String) { - self.graphql_schema = schema; - } - - /// Set the contract ABI for this indexer. - pub fn set_abi(&mut self, abi: String) { - self.abi = Some(abi); - } - + /// Get the indexer namespace. pub fn namespace(&self) -> &str { &self.namespace } @@ -200,34 +237,47 @@ impl Manifest { &self.identifier } + /// Get the indexer GraphQL schema. pub fn graphql_schema(&self) -> &str { &self.graphql_schema } + /// Get the indexer start block. pub fn start_block(&self) -> Option { self.start_block } - pub fn contract_id(&self) -> &ContractIds { - &self.contract_id + /// Get the indexer contract configuration. + pub fn contract_abi(&self) -> Option<&str> { + self.contract.as_ref().and_then(|c| c.abi()) } - pub fn abi(&self) -> Option<&str> { - self.abi.as_deref() + /// Get the indexer contract subscriptions. + pub fn contract_subscriptions(&self) -> Option<&[String]> { + self.contract.as_ref().and_then(|c| c.subscriptions()) } + /// Get the indexer predicates. + pub fn predicates(&self) -> Option<&Predicates> { + self.predicates.as_ref() + } + + /// Get the indexer Fuel client. pub fn fuel_client(&self) -> Option<&str> { self.fuel_client.as_deref() } + /// Get the indexer module. pub fn module(&self) -> &Module { &self.module } + /// Get the indexer end block. pub fn end_block(&self) -> Option { self.end_block } + /// Get the indexer's resumability. pub fn resumable(&self) -> Option { self.resumable } @@ -256,68 +306,3 @@ impl TryFrom<&Vec> for Manifest { Ok(manifest) } } - -/// Represents contract IDs in a `Manifest` struct. -#[derive(Debug, Deserialize, Serialize, Clone)] -#[serde(untagged)] -pub enum ContractIds { - /// Single represents a single contract ID as an `Option`. - #[serde(alias = "single")] - Single(Option), - - /// Multiple represents a vector of contracts IDs as a Vec. - #[serde(alias = "multiple")] - Multiple(Vec), -} - -impl ContractIds { - fn serialize(ids: &ContractIds, serializer: S) -> Result - where - S: serde::Serializer, - { - let s = match ids { - ContractIds::Single(Some(id)) => id.clone(), - ContractIds::Multiple(ids) => { - serde_json::to_string(ids).map_err(serde::ser::Error::custom)? - } - _ => return serializer.serialize_none(), - }; - serializer.serialize_str(&s) - } - - fn deserialize<'de, D>(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let value = serde_yaml::Value::deserialize(deserializer)?; - match value { - serde_yaml::Value::String(s) => Ok(ContractIds::Single(Some(s))), - serde_yaml::Value::Sequence(seq) => { - let ids = seq - .into_iter() - .filter_map(|val| match val { - serde_yaml::Value::String(s) => Some(s), - _ => None, - }) - .collect::>(); - Ok(ContractIds::Multiple(ids.into_iter().collect())) - } - serde_yaml::Value::Null => Ok(ContractIds::Single(None)), - _ => Err(serde::de::Error::custom("Invalid contract_id value")), - } - } -} - -impl FromStr for ContractIds { - type Err = String; - - fn from_str(s: &str) -> Result { - if s.starts_with('[') { - serde_json::from_str::>(s) - .map(ContractIds::Multiple) - .map_err(|err| err.to_string()) - } else { - Ok(ContractIds::Single(Some(s.to_string()))) - } - } -} diff --git a/packages/fuel-indexer-macros/Cargo.toml b/packages/fuel-indexer-macros/Cargo.toml index 6a193bc45..363fcbcc1 100644 --- a/packages/fuel-indexer-macros/Cargo.toml +++ b/packages/fuel-indexer-macros/Cargo.toml @@ -21,7 +21,8 @@ fuel-indexer-lib = { workspace = true, default-features = true } fuel-indexer-schema = { workspace = true, default-features = false } fuel-indexer-types = { workspace = true } fuels = { workspace = true } -fuels-code-gen = { version = "0.46", default-features = false } +fuels-code-gen = { workspace = true } +inflections = { version = "1", default-features = false } lazy_static = "1.4" proc-macro-error = "1.0" proc-macro2 = "1.0" diff --git a/packages/fuel-indexer-macros/src/decoder.rs b/packages/fuel-indexer-macros/src/decoder.rs index b756d0add..7b41e3406 100644 --- a/packages/fuel-indexer-macros/src/decoder.rs +++ b/packages/fuel-indexer-macros/src/decoder.rs @@ -44,27 +44,6 @@ pub struct ImplementationDecoder { parsed: ParsedGraphQLSchema, } -impl Default for ImplementationDecoder { - fn default() -> Self { - Self { - parameters: quote! {}, - hasher: quote! {}, - struct_fields: quote! {}, - typdef: TypeDefinition { - description: None, - extend: false, - name: Positioned::new(Name::new(String::new()), Pos::default()), - kind: TypeKind::Object(ObjectType { - implements: vec![], - fields: vec![], - }), - directives: vec![], - }, - parsed: ParsedGraphQLSchema::default(), - } - } -} - impl Decoder for ImplementationDecoder { /// Create a decoder from a GraphQL `TypeDefinition`. fn from_typedef(typ: &TypeDefinition, parsed: &ParsedGraphQLSchema) -> Self { @@ -479,20 +458,6 @@ pub struct ObjectDecoder { type_id: i64, } -impl Default for ObjectDecoder { - fn default() -> Self { - Self { - ident: format_ident!("unnamed"), - struct_fields: quote! {}, - field_extractors: quote! {}, - from_row: quote! {}, - to_row: quote! {}, - impl_decoder: ImplementationDecoder::default(), - type_id: std::i64::MAX, - } - } -} - impl Decoder for ObjectDecoder { /// Create a decoder from a GraphQL `TypeDefinition`. fn from_typedef(typ: &TypeDefinition, parsed: &ParsedGraphQLSchema) -> Self { @@ -738,13 +703,13 @@ impl From for TokenStream { impl From<#ident> for Json { fn from(value: #ident) -> Self { let s = serde_json::to_string(&value).expect("Failed to serialize Entity."); - Self(s) + Self::new(s) } } impl From for #ident { fn from(value: Json) -> Self { - let s: #ident = serde_json::from_str(&value.0).expect("Failed to deserialize Entity."); + let s: #ident = serde_json::from_str(&value.into_inner()).expect("Failed to deserialize Entity."); s } } diff --git a/packages/fuel-indexer-macros/src/helpers.rs b/packages/fuel-indexer-macros/src/helpers.rs index 050410aa4..31e24db14 100644 --- a/packages/fuel-indexer-macros/src/helpers.rs +++ b/packages/fuel-indexer-macros/src/helpers.rs @@ -1,18 +1,19 @@ -use std::collections::{HashMap, HashSet}; - use async_graphql_parser::types::{BaseType, FieldDefinition, Type as AsyncGraphQLType}; use async_graphql_value::Name; use fuel_abi_types::abi::program::{ - ABIFunction, LoggedType, ProgramABI, TypeDeclaration, + ABIFunction, Configurable, LoggedType, ProgramABI, TypeDeclaration, }; use fuel_indexer_lib::{ constants::*, graphql::{list_field_type_name, types::IdCol, ParsedGraphQLSchema}, + manifest::Manifest, }; use fuel_indexer_types::{type_id, FUEL_TYPES_NAMESPACE}; use fuels_code_gen::utils::Source; +use inflections::case::to_pascal_case; use proc_macro2::TokenStream; use quote::{format_ident, quote}; +use std::collections::{HashMap, HashSet}; use syn::{GenericArgument, Ident, PathArguments, Type, TypePath}; /// Provides a TokenStream to be used for unwrapping `Option`s for external types. @@ -46,7 +47,7 @@ pub fn get_json_abi(abi_path: Option) -> Option { Ok(src) => src, Err(e) => { proc_macro_error::abort_call_site!( - "`abi` must be a file path to valid json abi: {:?}.", + "`abi` must be a file path to valid json contract_abi:{:?}.", e ) } @@ -183,6 +184,30 @@ pub fn is_generic_type(typ: &TypeDeclaration) -> bool { matches!(gt, GenericType::Vec | GenericType::Option) } +pub fn decode_configurable_snippet( + type_tokens: &proc_macro2::TokenStream, + typ: &TypeDeclaration, +) -> proc_macro2::TokenStream { + let name = typ.decoder_field_ident(); + let ty_id = typ.type_id; + + if is_rust_primitive(type_tokens) { + quote! { + #ty_id => { + Logger::warn("Skipping primitive decoder."); + } + } + } else { + quote! { + #ty_id => { + let decoded = ABIDecoder::decode_single(&#type_tokens::param_type(), &data).expect("Failed decoding."); + let obj = #type_tokens::from_token(decoded).expect("Failed detokenizing."); + self.#name = obj; + } + } + } +} + /// Given a `TokenStream` representing this `TypeDeclaration`'s fully typed path, /// return the associated `match` arm for decoding this type in the `Decoder`. pub fn decode_snippet( @@ -296,11 +321,13 @@ impl Codegen for TypeDeclaration { "Call" => quote! { Call }, "generic T" => quote! {}, "Identity" => quote! { Identity }, + "IndexerPredicate" => quote! { IndexerPredicate }, "Log" => quote! { Log }, "LogData" => quote! { LogData }, "MessageOut" => quote! { MessageOut }, "Mint" => quote! { Mint }, "Panic" => quote! { Panic }, + "FooPredicate" => quote! { FooPredicate }, "Return" => quote! { Return }, "Revert" => quote! { Revert }, "ScriptResult" => quote! { ScriptResult }, @@ -877,13 +904,12 @@ impl From for TokenStream { /// only returns the single inner type associated with this log specific logged type pub fn derive_log_generic_inner_typedefs<'a>( typ: &'a LoggedType, - abi: &ProgramABI, + logged_types: &[LoggedType], abi_types: &'a HashMap, ) -> &'a TypeDeclaration { let result = - abi.logged_types + logged_types .iter() - .flatten() .filter_map(|log| { if log.log_id == typ.log_id && log.application.type_arguments.is_some() { let args = log @@ -1173,6 +1199,7 @@ pub fn typed_path_components( (name, tokens) } +/// Whether or not the given `TypeDeclaration` is an array-like type. pub fn is_array_type(typ: &TypeDeclaration) -> bool { typ.type_field.starts_with('[') && typ.type_field.ends_with(']') @@ -1190,3 +1217,95 @@ pub fn is_unsupported_type(type_name: &str) -> bool { _ => UNSUPPORTED_ABI_JSON_TYPES.contains(type_name), } } + +pub fn prefix_abi_and_schema_paths( + abi_path: Option<&str>, + schema: Option<&str>, +) -> (Option, Option) { + if let Some(abi_path) = abi_path { + match std::env::var("COMPILE_TEST_PREFIX") { + Ok(prefix) => { + let prefixed = std::path::Path::new(&prefix).join(abi_path); + let abi_string = prefixed + .into_os_string() + .to_str() + .expect("Could not parse prefixed ABI path.") + .to_string(); + + if let Some(schema) = schema { + let prefixed = std::path::Path::new(&prefix).join(schema); + let schema = prefixed + .into_os_string() + .to_str() + .expect("Could not parse prefixed GraphQL schema path.") + .to_string(); + + return (Some(abi_string), Some(schema)); + } + + return (Some(abi_string), None); + } + Err(_) => { + return (Some(abi_path.to_string()), schema.map(|s| s.to_string())); + } + }; + } + + (None, schema.map(|s| s.to_string())) +} + +/// Return the name of the configurable type of a given predicate's `TypeDeclaration`. +pub fn configurable_fn_type_name(configurable: &Configurable) -> Option { + let name = configurable + .name + .split_whitespace() + .next() + .unwrap() + .to_uppercase(); + if name.as_str() == "()" { + return None; + } + Some(name) +} + +pub fn derive_configurables_names_map(manifest: &Manifest) -> HashMap { + let mut output = HashMap::new(); + if let Some(predicate) = manifest.predicates() { + if predicate.is_empty() { + return output; + } + + if let Some(templates) = predicate.templates() { + for template in templates { + let abi = get_json_abi(Some(template.abi.clone())) + .expect("Could not derive predicate JSON ABI."); + let main = abi + .functions + .iter() + .find(|f| f.name == "main") + .expect("ABI missing main function."); + for input in main.inputs.iter() { + output.insert(input.type_id, input.name.clone()); + } + } + } + } + + output +} + +pub fn indexer_configurables_name(template_name: &str) -> String { + let name = to_pascal_case(template_name); + // FIXME: Rename this + format!("{}InnerConfigurables", name) +} + +pub fn sdk_configurables_name(template_name: &str) -> String { + let name = to_pascal_case(template_name); + format!("{}Configurables", name) +} + +pub fn sdk_configurables_encoder_name(template_name: &str) -> String { + let name = to_pascal_case(template_name); + format!("{}Encoder", name) +} diff --git a/packages/fuel-indexer-macros/src/indexer.rs b/packages/fuel-indexer-macros/src/indexer.rs index 2600c4989..40d3933de 100644 --- a/packages/fuel-indexer-macros/src/indexer.rs +++ b/packages/fuel-indexer-macros/src/indexer.rs @@ -1,17 +1,16 @@ use crate::{ - helpers::*, parse::IndexerConfig, schema::process_graphql_schema, + helpers::*, parse::IndexerConfig, schema::process_graphql_schema, tokens::*, wasm::handler_block_wasm, }; use fuel_abi_types::abi::program::TypeDeclaration; use fuel_indexer_lib::{ - constants::*, manifest::ContractIds, manifest::Manifest, - utils::workspace_manifest_prefix, + constants::*, manifest::Manifest, utils::workspace_manifest_prefix, }; use fuel_indexer_types::{type_id, FUEL_TYPES_NAMESPACE}; use fuels::{core::codec::resolve_fn_selector, types::param_types::ParamType}; use fuels_code_gen::{Abigen, AbigenTarget, ProgramType}; use proc_macro::TokenStream; -use quote::quote; +use quote::{format_ident, quote}; use std::collections::{HashMap, HashSet}; use std::path::{Path, PathBuf}; use syn::{parse_macro_input, FnArg, Item, ItemMod, PatType, Type}; @@ -25,9 +24,25 @@ fn additional_declarations() -> proc_macro2::TokenStream { } } +fn predicate_handler_block( + manifest: &Manifest, + block: proc_macro2::TokenStream, +) -> proc_macro2::TokenStream { + let should_run = manifest + .predicates() + .map(|p| !p.is_empty()) + .unwrap_or(false); + if should_run { + quote! { + #block + } + } else { + quote! {} + } +} + fn process_fn_items( manifest: &Manifest, - abi_path: Option, indexer_module: ItemMod, ) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) { if indexer_module.content.is_none() @@ -43,22 +58,50 @@ fn process_fn_items( ) } - let abi = get_json_abi(abi_path).unwrap_or_default(); + let (contract_abi_path, _schema_path) = prefix_abi_and_schema_paths( + manifest.contract_abi(), + Some(manifest.graphql_schema()), + ); + + let contract_abi = get_json_abi(contract_abi_path).unwrap_or_default(); let mut decoded_type_snippets = HashSet::new(); let mut decoded_log_match_arms = HashSet::new(); let mut decoded_type_fields = HashSet::new(); let mut abi_dispatchers = Vec::new(); - let funcs = abi.clone().functions; - let abi_types: Vec = abi + let funcs = contract_abi.clone().functions; + let contract_abi_types = contract_abi .clone() .types .iter() .map(|t| strip_callpath_from_type_field(t.clone())) - .collect(); - let abi_log_types = abi.clone().logged_types.unwrap_or_default(); - let abi_msg_types = abi.clone().messages_types.unwrap_or_default(); + .collect::>(); + + let configurable_abi_types = manifest + .predicates() + .map(|p| { + p.templates() + .map(|t| { + t.iter() + .map(|t| { + let ty_id = type_id(FUEL_TYPES_NAMESPACE, &t.name) as usize; + let name = indexer_configurables_name(&t.name); + TypeDeclaration { + type_id: ty_id, + type_field: name, + components: Some(Vec::default()), + type_parameters: None, + } + }) + .collect::>() + }) + .unwrap_or_default() + }) + .unwrap_or_default(); + + let contract_abi_log_types = contract_abi.clone().logged_types.unwrap_or_default(); + let contract_abi_msg_types = contract_abi.clone().messages_types.unwrap_or_default(); let fuel_types = FUEL_PRIMITIVES .iter() .map(|x| { @@ -73,7 +116,7 @@ fn process_fn_items( }) .collect::>(); - let _tuple_types_tyid = abi_types + let _tuple_types_tyid = contract_abi_types .iter() .filter_map(|typ| { if is_tuple_type(typ) { @@ -85,17 +128,38 @@ fn process_fn_items( .collect::>(); // Used to do a reverse lookup of typed path names to ABI type IDs. - let mut type_ids = RESERVED_TYPEDEF_NAMES + let mut contract_abi_type_ids = RESERVED_TYPEDEF_NAMES .iter() .map(|x| (x.to_string(), type_id(FUEL_TYPES_NAMESPACE, x) as usize)) .collect::>(); - let mut abi_types_tyid = abi_types + let configurable_abi_type_ids = configurable_abi_types + .iter() + .map(|typ| { + let name = typ.type_field.clone(); + (name, typ.type_id) + }) + .collect::>(); + + let mut contract_abi_types_tyid = contract_abi_types .iter() .map(|typ| (typ.type_id, typ.clone())) .collect::>(); - let message_types_decoders = abi_msg_types + let configurable_abi_types_tyid = configurable_abi_type_ids + .iter() + .map(|(name, ty_id)| { + let typ = TypeDeclaration { + type_id: *ty_id, + type_field: name.to_string(), + components: None, + type_parameters: None, + }; + (typ.type_id, typ) + }) + .collect::>(); + + let message_types_decoders = contract_abi_msg_types .iter() .map(|typ| { let message_type_id = typ.message_id; @@ -114,9 +178,9 @@ fn process_fn_items( }]) .collect::>(); - // Take a second pass over `abi_types` in order to update an `TypeDeclarations` that need to + // Take a second pass over `contract_abi_types` in order to update an `TypeDeclarations` that need to // be updated with more information for the codegen process. - let abi_types = abi_types + let contract_abi_types = contract_abi_types .iter() .map(|typ| { // If this is an array type we have to manually update it's type field to include its inner @@ -139,7 +203,7 @@ fn process_fn_items( .trim_end_matches(']') .parse::() .expect("Array type size could not be determined."); - let inner = abi_types_tyid + let inner = contract_abi_types_tyid .get(&inner) .expect("Array type inner not found in ABI types."); let name = format!("[{}; {}]", inner.name(), size); @@ -148,7 +212,7 @@ fn process_fn_items( ..typ.clone() }; - abi_types_tyid.insert(typ.type_id, typ.clone()); + contract_abi_types_tyid.insert(typ.type_id, typ.clone()); typ } else { typ.to_owned() @@ -156,7 +220,29 @@ fn process_fn_items( }) .collect::>(); - let abi_type_decoders = abi_types + let configurable_abi_decoders = configurable_abi_types + .iter() + .filter_map(|typ| { + if is_non_decodable_type(typ) { + return None; + } + + // NOTE: Not sure if we should handle generics and cache type IDs here (i.e., same + // as we do for standard contract TypeDeclarations. + + let type_tokens = typ.rust_tokens(); + let name = typ.decoder_field_ident(); + let ty_id = typ.type_id; + Some(quote! { + #ty_id => { + let obj = #type_tokens::try_from(data).expect("Could not deserialize configurables."); + self.#name.push(obj); + } + }) + }) + .collect::>(); + + let conract_abi_decoders = contract_abi_types .iter() .filter_map(|typ| { if is_non_decodable_type(typ) { @@ -174,11 +260,11 @@ fn process_fn_items( let gt = GenericType::from(typ); match gt { GenericType::Vec | GenericType::Option => { - let ab_types = abi_types_tyid.clone(); + let ab_types = contract_abi_types_tyid.clone(); let inner_typs = derive_generic_inner_typedefs( typ, &funcs, - &abi_log_types, + &contract_abi_log_types, &ab_types, ); @@ -189,7 +275,7 @@ fn process_fn_items( let (typ_name, type_tokens) = typed_path_components( typ, inner_typ, - &abi_types_tyid, + &contract_abi_types_tyid, ); let ty_id = type_id(FUEL_TYPES_NAMESPACE, &typ_name) as usize; @@ -204,8 +290,8 @@ fn process_fn_items( return None; } - abi_types_tyid.insert(ty_id, typ.clone()); - type_ids.insert(typ_name.clone(), ty_id); + contract_abi_types_tyid.insert(ty_id, typ.clone()); + contract_abi_type_ids.insert(typ_name.clone(), ty_id); decoded_type_snippets.insert(ty_id); @@ -217,8 +303,12 @@ fn process_fn_items( _ => unimplemented!("Unsupported decoder generic type: {:?}", gt), } } else { + if decoded_type_fields.contains(&typ.type_id) { + return None; + } + let type_tokens = typ.rust_tokens(); - type_ids.insert(type_tokens.to_string(), typ.type_id); + contract_abi_type_ids.insert(type_tokens.to_string(), typ.type_id); decoded_type_snippets.insert(typ.type_id); Some(vec![decode_snippet(&type_tokens, typ)]) } @@ -228,19 +318,47 @@ fn process_fn_items( let fuel_type_decoders = fuel_types .values() - .map(|typ| { + .filter_map(|typ| { + if decoded_type_fields.contains(&typ.type_id) { + return None; + } + let type_tokens = typ.rust_tokens(); - type_ids.insert(type_tokens.to_string(), typ.type_id); + contract_abi_type_ids.insert(type_tokens.to_string(), typ.type_id); decoded_type_snippets.insert(typ.type_id); - decode_snippet(&type_tokens, typ) + Some(decode_snippet(&type_tokens, typ)) }) .collect::>(); - let decoders = [fuel_type_decoders, abi_type_decoders].concat(); + let decoders = [ + fuel_type_decoders, + conract_abi_decoders, + configurable_abi_decoders, + ] + .concat(); - let abi_struct_fields = abi_types + let configurable_struct_fields = configurable_abi_types + .iter() + .filter_map(|typ| { + if is_non_decodable_type(typ) { + return None; + } + + // NOTE: Not sure if we should handle generics and cache type IDs here (i.e., same + // as we do for standard contract TypeDeclarations. + + let name = typ.decoder_field_ident(); + let ty = typ.rust_tokens(); + + Some(quote! { + #name: Vec<#ty> + }) + }) + .collect::>(); + + let contract_struct_fields = contract_abi_types .iter() .filter_map(|typ| { if is_non_decodable_type(typ) { @@ -258,16 +376,19 @@ fn process_fn_items( let inner_typs = derive_generic_inner_typedefs( typ, &funcs, - &abi_log_types, - &abi_types_tyid, + &contract_abi_log_types, + &contract_abi_types_tyid, ); return Some( inner_typs .iter() .filter_map(|inner_typ| { - let (typ_name, type_tokens) = - typed_path_components(typ, inner_typ, &abi_types_tyid); + let (typ_name, type_tokens) = typed_path_components( + typ, + inner_typ, + &contract_abi_types_tyid, + ); let ty_id = type_id(FUEL_TYPES_NAMESPACE, &typ_name) as usize; if decoded_type_fields.contains(&ty_id) { @@ -282,7 +403,7 @@ fn process_fn_items( let ident = typ.decoder_field_ident(); - type_ids.insert(typ_name.clone(), ty_id); + contract_abi_type_ids.insert(typ_name.clone(), ty_id); decoded_type_fields.insert(ty_id); Some(quote! { @@ -292,9 +413,13 @@ fn process_fn_items( .collect::>(), ); } else { + if decoded_type_fields.contains(&typ.type_id) { + return None; + } + let ident = typ.decoder_field_ident(); let type_tokens = typ.rust_tokens(); - type_ids.insert(typ.rust_tokens().to_string(), typ.type_id); + contract_abi_type_ids.insert(typ.rust_tokens().to_string(), typ.type_id); decoded_type_fields.insert(typ.type_id); Some(vec![quote! { @@ -312,32 +437,37 @@ fn process_fn_items( return None; } + if decoded_type_fields.contains(&typ.type_id) { + return None; + } + let name = typ.decoder_field_ident(); let ty = typ.rust_tokens(); - type_ids.insert(ty.to_string(), typ.type_id); + contract_abi_type_ids.insert(ty.to_string(), typ.type_id); decoded_type_snippets.insert(typ.type_id); - if decoded_type_fields.contains(&typ.type_id) { - return None; - } - Some(quote! { #name: Vec<#ty> }) }) .collect::>(); - let decoder_struct_fields = [abi_struct_fields, fuel_struct_fields].concat(); + let decoder_fields = [ + contract_struct_fields, + fuel_struct_fields, + configurable_struct_fields, + ] + .concat(); // Since log type decoders use `TypeDeclaration`s that were manually created specifically // for generics, we parsed log types after other ABI types. - let log_type_decoders = abi_log_types + let contract_log_type_decoders = contract_abi_log_types .iter() .filter_map(|log| { let ty_id = log.application.type_id; let log_id = log.log_id as usize; - let typ = abi_types_tyid + let typ = contract_abi_types_tyid .get(&log.application.type_id) .expect("Could not get log type reference from ABI types."); @@ -349,14 +479,20 @@ fn process_fn_items( let gt = GenericType::from(typ); match gt { GenericType::Vec | GenericType::Option => { - let inner_typ = - derive_log_generic_inner_typedefs(log, &abi, &abi_types_tyid); + let inner_typ = derive_log_generic_inner_typedefs( + log, + &contract_abi_log_types, + &contract_abi_types_tyid, + ); - let (typ_name, _) = - typed_path_components(typ, inner_typ, &abi_types_tyid); + let (typ_name, _) = typed_path_components( + typ, + inner_typ, + &contract_abi_types_tyid, + ); let ty_id = type_id(FUEL_TYPES_NAMESPACE, &typ_name) as usize; - let _typ = abi_types_tyid.get(&ty_id).expect( + let _typ = contract_abi_types_tyid.get(&ty_id).expect( "Could not get generic log type reference from ABI types.", ); @@ -382,20 +518,20 @@ fn process_fn_items( }) .collect::>(); - let abi_selectors = funcs + let contract_abi_selectors = funcs .iter() .map(|function| { let params: Vec = function .inputs .iter() .map(|x| { - ParamType::try_from_type_application(x, &abi_types_tyid) + ParamType::try_from_type_application(x, &contract_abi_types_tyid) .expect("Could not derive TypeApplication param types.") }) .collect(); let sig = resolve_fn_selector(&function.name, ¶ms[..]); let selector = u64::from_be_bytes(sig); - let ty_id = function_output_type_id(function, &abi_types_tyid); + let ty_id = function_output_type_id(function, &contract_abi_types_tyid); quote! { #selector => #ty_id, @@ -403,14 +539,14 @@ fn process_fn_items( }) .collect::>(); - let abi_selectors_to_fn_names = funcs + let contract_abi_selectors_to_fn_names = funcs .iter() .map(|function| { let params: Vec = function .inputs .iter() .map(|x| { - ParamType::try_from_type_application(x, &abi_types_tyid) + ParamType::try_from_type_application(x, &contract_abi_types_tyid) .expect("Could not derive TypeApplication param types.") }) .collect(); @@ -442,46 +578,23 @@ fn process_fn_items( None => quote! {}, }; - let subscribed_contract_ids = match &manifest.contract_id() { - ContractIds::Single(_) => quote! {}, - ContractIds::Multiple(contract_ids) => { - let contract_ids = contract_ids - .iter() - .map(|id| { - quote! { - Bech32ContractId::from_str(#id).unwrap_or_else(|_| { - let contract_id = ContractId::from_str(&#id).expect("Failed to parse manifest 'contract_id'"); - Bech32ContractId::from(contract_id) - }) - } - }) - .collect::>(); + let subscribed_contract_ids = match &manifest.contract_subscriptions() { + Some(ids) => { + let contract_ids = ids.iter().map(|id| { + quote! { + Bech32ContractId::from_str(#id).expect("Failed to parse contract ID from manifest.") + } + }).collect::>(); quote! { let contract_ids = HashSet::from([#(#contract_ids),*]); } } + None => quote! {}, }; - let check_if_subscribed_to_contract = match &manifest.contract_id() { - ContractIds::Single(contract_id) => match contract_id { - Some(contract_id) => { - quote! { - let id_bytes = <[u8; 32]>::try_from(id).expect("Could not convert contract ID into bytes"); - let bech32_id = Bech32ContractId::new("fuel", id_bytes); - let manifest_contract_id = Bech32ContractId::from_str(#contract_id).unwrap_or_else(|_| { - let contract_id = ContractId::from_str(&#contract_id).expect("Failed to parse manifest 'contract_id'"); - Bech32ContractId::from(contract_id) - }); - if bech32_id != manifest_contract_id { - debug!("Not subscribed to this contract. Will skip this receipt event. <('-'<)"); - continue; - } - } - } - None => quote! {}, - }, - ContractIds::Multiple(_) => { + let check_if_subscribed_to_contract = match &manifest.contract_subscriptions() { + Some(_) => { quote! { let id_bytes = <[u8; 32]>::try_from(id).expect("Could not convert contract ID into bytes"); let bech32_id = Bech32ContractId::new("fuel", id_bytes); @@ -492,6 +605,7 @@ fn process_fn_items( } } } + None => quote! {}, }; for item in contents { @@ -524,19 +638,37 @@ fn process_fn_items( ) } - if !type_ids.contains_key(&path_type_name) { + if !contract_abi_type_ids.contains_key(&path_type_name) + && !configurable_abi_type_ids + .contains_key(&path_type_name) + { proc_macro_error::abort_call_site!( "Type with ident '{:?}' not defined in the ABI.", path_seg.ident ); }; - let ty_id = type_ids - .get(&path_type_name) - .expect("Path type name not found in type IDs."); - let typ = match abi_types_tyid.get(ty_id) { + let ty_id = + match contract_abi_type_ids.get(&path_type_name) { + Some(ty_id) => ty_id, + None => configurable_abi_type_ids + .get(&path_type_name) + .expect("Type not found in Fuel types."), + }; + + let typ = match contract_abi_types_tyid.get(ty_id) { Some(typ) => typ, - None => fuel_types.get(ty_id).unwrap(), + None => match fuel_types.get(ty_id) { + Some(typ) => typ, + None => { + match configurable_abi_types_tyid.get(ty_id) { + Some(typ) => typ, + None => { + panic!("Type not found in ABI types.") + } + } + } + }, }; let dispatcher_name = typ.decoder_field_ident(); @@ -601,308 +733,51 @@ fn process_fn_items( } } - let decoder_struct = quote! { - #[derive(Default)] - struct Decoders { - #(#decoder_struct_fields),* - } - - impl Decoders { - fn selector_to_type_id(&self, sel: u64) -> usize { - match sel { - #(#abi_selectors)* - _ => { - debug!("Unknown selector; check ABI to make sure function outputs match to types"); - usize::MAX - } - } - } - - pub fn selector_to_fn_name(&self, sel: u64) -> String { - match sel { - #(#abi_selectors_to_fn_names)* - _ => { - debug!("Unknown selector; check ABI to make sure function outputs match to types"); - "".to_string() - } - } - } - - fn compute_message_id(&self, sender: &Address, recipient: &Address, nonce: Nonce, amount: Word, data: Option>) -> MessageId { - - let mut raw_message_id = Sha256::new() - .chain_update(sender) - .chain_update(recipient) - .chain_update(nonce) - .chain_update(amount.to_be_bytes()); - - let raw_message_id = if let Some(buffer) = data { - raw_message_id - .chain_update(&buffer[..]) - .finalize() - } else { - raw_message_id.finalize() - }; - - let message_id = <[u8; 32]>::try_from(&raw_message_id[..]).expect("Could not calculate message ID from receipt fields"); - - message_id.into() - } - - fn decode_type(&mut self, ty_id: usize, data: Vec) -> anyhow::Result<()> { - let decoder = ABIDecoder::default(); - match ty_id { - #(#decoders),* - _ => { - debug!("Unknown type ID; check ABI to make sure types are correct."); - }, - } - Ok(()) - } - - pub fn decode_block(&mut self, data: BlockData) { - self.blockdata_decoded.push(data); - } - - pub fn decode_return_type(&mut self, sel: u64, data: Vec) -> anyhow::Result<()> { - let ty_id = self.selector_to_type_id(sel); - self.decode_type(ty_id, data)?; - Ok(()) - } - - pub fn decode_logdata(&mut self, rb: usize, data: Vec) -> anyhow::Result<()> { - match rb { - #(#log_type_decoders),* - _ => debug!("Unknown logged type ID; check ABI to make sure that logged types are correct.") - } - Ok(()) - } - - pub fn decode_messagedata(&mut self, type_id: u64, data: Vec) -> anyhow::Result<()> { - match type_id { - #(#message_types_decoders),* - _ => debug!("Unknown message type ID; check ABI to make sure that message types are correct.") - } - Ok(()) - } + let configurables_match = manifest + .predicates() + .map(|p| { + p.templates() + .map(|t| { + t.iter() + .map(|t| { + let template_id = &t.id.to_string(); + let name = indexer_configurables_name(&t.name); + let ident = format_ident! { "{}", name }; + + quote! { + #template_id => { + let obj = #ident::try_from(predicate_data).expect("Failed to decode configurable"); + ConfigurablesContainer::#ident(obj) + }, + } + }) + .collect::>() + }) + .unwrap_or_default() + }) + .unwrap_or_default(); + + let predicate_tokens = transaction_predicate_tokens(manifest, configurables_match); + let predicate_block = predicate_handler_block(manifest, predicate_tokens); + + let decoder_struct = decoder_struct_tokens( + decoder_fields, + contract_abi_selectors, + contract_abi_selectors_to_fn_names, + decoders, + contract_log_type_decoders, + message_types_decoders, + abi_dispatchers, + ); - pub fn dispatch(&self) -> anyhow::Result<()> { - #(#abi_dispatchers)* + let process_transaction = + process_transaction_tokens(check_if_subscribed_to_contract, predicate_block); - unsafe { - if !ERROR_MESSAGE.is_empty() { - anyhow::bail!(ERROR_MESSAGE.clone()); - } else { - Ok(()) - } - } - } - } - }; ( quote! { #subscribed_contract_ids - use anyhow::Context; - use fuel::TransactionData; - - let mut process_transaction = |decoder: &mut Decoders, tx: TransactionData| -> anyhow::Result<()> { - let mut return_types = Vec::new(); - let mut callees = HashSet::new(); - - for receipt in tx.receipts { - match receipt { - fuel::Receipt::Call { id: contract_id, amount, asset_id, gas, param1, to: id, .. } => { - #check_if_subscribed_to_contract - - let fn_name = decoder.selector_to_fn_name(param1); - return_types.push(param1); - callees.insert(id); - - let data = serialize( - &Call { - contract_id: ContractId::from(<[u8; 32]>::from(contract_id)), - to: ContractId::from(<[u8; 32]>::from(id)), - amount, - asset_id: AssetId::from(<[u8; 32]>::from(asset_id)), - gas, - fn_name - } - ); - let ty_id = Call::type_id(); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::Log { id, ra, rb, .. } => { - #check_if_subscribed_to_contract - let ty_id = Log::type_id(); - let data = serialize( - &Log { - contract_id: ContractId::from(<[u8; 32]>::from(id)), - ra, - rb - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::LogData { rb, data, ptr, len, id, .. } => { - #check_if_subscribed_to_contract - decoder.decode_logdata(rb as usize, data.unwrap_or(Vec::::new()))?; - } - fuel::Receipt::Return { id, val, pc, is } => { - #check_if_subscribed_to_contract - if callees.contains(&id) { - let ty_id = Return::type_id(); - let data = serialize( - &Return { - contract_id: ContractId::from(<[u8; 32]>::from(id)), - val, - pc, - is - } - ); - decoder.decode_type(ty_id, data)?; - } - } - fuel::Receipt::ReturnData { data, id, .. } => { - #check_if_subscribed_to_contract - if callees.contains(&id) { - let selector = return_types.pop().expect("No return type available. <('-'<)"); - decoder.decode_return_type(selector, data.unwrap_or(Vec::::new()))?; - } - } - fuel::Receipt::MessageOut { sender, recipient, amount, nonce, len, digest, data, .. } => { - let sender = Address::from(<[u8; 32]>::from(sender)); - let recipient = Address::from(<[u8; 32]>::from(recipient)); - let message_id = decoder.compute_message_id(&sender, &recipient, nonce, amount, data.clone()); - - // It's possible that the data field was generated from an empty Sway `Bytes` array - // in the send_message() instruction in which case the data field in the receipt will - // have no type information or data to decode. Thus, we check for a None value or - // an empty byte vector; if either condition is present, then we decode to a unit struct instead. - let (type_id, data) = data - .map_or((u64::MAX, Vec::::new()), |buffer| { - if buffer.is_empty() { - (u64::MAX, Vec::::new()) - } else { - let (type_id_bytes, data_bytes) = buffer.split_at(8); - let type_id = u64::from_be_bytes( - <[u8; 8]>::try_from(type_id_bytes) - .expect("Could not get type ID for data in MessageOut receipt") - ); - let data = data_bytes.to_vec(); - (type_id, data) - } - }); - - - decoder.decode_messagedata(type_id, data.clone())?; - - let ty_id = MessageOut::type_id(); - let data = serialize( - &MessageOut { - message_id, - sender, - recipient, - amount, - nonce, - len, - digest, - data - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::ScriptResult { result, gas_used } => { - let ty_id = ScriptResult::type_id(); - let data = serialize(&ScriptResult{ result: u64::from(result), gas_used }); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::Transfer { id, to, asset_id, amount, pc, is, .. } => { - #check_if_subscribed_to_contract - let ty_id = Transfer::type_id(); - let data = serialize( - &Transfer { - contract_id: ContractId::from(<[u8; 32]>::from(id)), - to: ContractId::from(<[u8; 32]>::from(to)), - asset_id: AssetId::from(<[u8; 32]>::from(asset_id)), - amount, - pc, - is - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::TransferOut { id, to, asset_id, amount, pc, is, .. } => { - #check_if_subscribed_to_contract - let ty_id = TransferOut::type_id(); - let data = serialize( - &TransferOut { - contract_id: ContractId::from(<[u8; 32]>::from(id)), - to: Address::from(<[u8; 32]>::from(to)), - asset_id: AssetId::from(<[u8; 32]>::from(asset_id)), - amount, - pc, - is - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::Panic { id, reason, .. } => { - #check_if_subscribed_to_contract - let ty_id = Panic::type_id(); - let data = serialize( - &Panic { - contract_id: ContractId::from(<[u8; 32]>::from(id)), - reason: *reason.reason() as u32 - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::Revert { id, ra, .. } => { - #check_if_subscribed_to_contract - let ty_id = Revert::type_id(); - let data = serialize( - &Revert { - contract_id: ContractId::from(<[u8; 32]>::from(id)), - error_val: u64::from(ra & 0xF) - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::Mint { sub_id, contract_id, val, pc, is } => { - let ty_id = Mint::type_id(); - let data = serialize( - &Mint { - sub_id: AssetId::from(<[u8; 32]>::from(sub_id)), - contract_id: ContractId::from(<[u8; 32]>::from(contract_id)), - val, - pc, - is - } - ); - decoder.decode_type(ty_id, data)?; - } - fuel::Receipt::Burn { sub_id, contract_id, val, pc, is } => { - let ty_id = Burn::type_id(); - let data = serialize( - &Burn { - sub_id: AssetId::from(<[u8; 32]>::from(sub_id)), - contract_id: ContractId::from(<[u8; 32]>::from(contract_id)), - val, - pc, - is - } - ); - decoder.decode_type(ty_id, data)?; - } - _ => { - info!("This type is not handled yet. (>'.')>"); - } - } - } - - Ok(()) - }; + #process_transaction let mut process_block = |block: BlockData| -> anyhow::Result<()> { #start_block @@ -931,6 +806,7 @@ fn process_fn_items( } }, quote! { + #decoder_struct #(#handler_fns)* @@ -938,56 +814,6 @@ fn process_fn_items( ) } -pub fn prefix_abi_and_schema_paths( - abi: Option<&str>, - schema: &str, -) -> (Option, String) { - if let Some(abi) = abi { - match std::env::var("COMPILE_TEST_PREFIX") { - Ok(prefix) => { - let prefixed = std::path::Path::new(&prefix).join(abi); - let abi_string = prefixed - .into_os_string() - .to_str() - .expect("Could not parse prefixed ABI path.") - .to_string(); - let prefixed = std::path::Path::new(&prefix).join(schema); - let schema = prefixed - .into_os_string() - .to_str() - .expect("Could not parse prefixed GraphQL schema path.") - .to_string(); - - return (Some(abi_string), schema); - } - Err(_) => { - return (Some(abi.into()), schema.to_string()); - } - }; - } - - (None, schema.to_string()) -} - -pub fn get_abi_tokens(namespace: &str, abi: &str) -> proc_macro2::TokenStream { - match Abigen::generate( - vec![AbigenTarget { - name: namespace.to_string(), - abi: abi.to_owned(), - program_type: ProgramType::Contract, - }], - true, - ) { - Ok(tokens) => tokens, - Err(e) => { - proc_macro_error::abort_call_site!( - "Could not generate tokens for abi: {:?}.", - e - ) - } - } -} - pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStream { let config = parse_macro_input!(attrs as IndexerConfig); @@ -1001,24 +827,74 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr let indexer_module = parse_macro_input!(item as ItemMod); - let (abi, schema_string) = - prefix_abi_and_schema_paths(manifest.abi(), manifest.graphql_schema()); + let predicate_abi_info = manifest + .predicates() + .map(|p| { + p.templates() + .map(|t| { + t.iter() + .filter_map(|t| { + let (predicate_abi, _) = prefix_abi_and_schema_paths( + Some(&t.abi), + Some(manifest.graphql_schema()), + ); + + if let Some(predicate_abi) = predicate_abi { + return Some((predicate_abi, t.name.to_string())); + } + None + }) + .collect::>() + }) + .unwrap_or_default() + }) + .unwrap_or_default(); + + let mut targets = Vec::new(); - let abi_tokens = match abi { - Some(ref abi_path) => get_abi_tokens(manifest.namespace(), abi_path), - None => proc_macro2::TokenStream::new(), + if let Some(ref abi) = manifest.contract_abi() { + targets.push(AbigenTarget { + // FIXME: We should be using the name of the contract here + name: manifest.namespace().to_string(), + abi: abi.to_string(), + program_type: ProgramType::Contract, + }); + } + + predicate_abi_info + .iter() + .for_each(|(abi_path, template_name)| { + targets.push(AbigenTarget { + name: template_name.to_string(), + abi: abi_path.to_string(), + program_type: ProgramType::Predicate, + }); + }); + + let abi_tokens = match Abigen::generate(targets, true) { + Ok(tokens) => tokens, + Err(e) => { + proc_macro_error::abort_call_site!( + "Could not generate tokens for ABI: {:?}.", + e + ) + } }; // NOTE: https://nickb.dev/blog/cargo-workspace-and-the-feature-unification-pitfall/ let graphql_tokens = process_graphql_schema( manifest.namespace(), manifest.identifier(), - &schema_string, + manifest.graphql_schema(), ); let decl_tokens = additional_declarations(); - let (handler_block, fn_items) = process_fn_items(&manifest, abi, indexer_module); + let predicate_impl_tokens = predicate_tokens(); + + let indexer_configurables_tokens = indexer_configurables_tokens(&manifest); + + let (handler_block, fn_items) = process_fn_items(&manifest, indexer_module); let handler_block = handler_block_wasm(handler_block); let output = quote! { @@ -1028,6 +904,10 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr #graphql_tokens + #indexer_configurables_tokens + + #predicate_impl_tokens + #handler_block #fn_items diff --git a/packages/fuel-indexer-macros/src/lib.rs b/packages/fuel-indexer-macros/src/lib.rs index d7f941b3e..82d1b282e 100644 --- a/packages/fuel-indexer-macros/src/lib.rs +++ b/packages/fuel-indexer-macros/src/lib.rs @@ -5,10 +5,13 @@ pub(crate) mod decoder; pub(crate) mod helpers; pub(crate) mod indexer; pub(crate) mod parse; +pub(crate) mod predicate; pub(crate) mod schema; +pub(crate) mod tokens; pub(crate) mod wasm; use indexer::process_indexer_module; +use predicate::process_predicate_handler; use proc_macro::TokenStream; #[proc_macro_error::proc_macro_error] @@ -16,3 +19,9 @@ use proc_macro::TokenStream; pub fn indexer(attrs: TokenStream, item: TokenStream) -> TokenStream { process_indexer_module(attrs, item) } + +#[proc_macro_error::proc_macro_error] +#[proc_macro_attribute] +pub fn predicate(attrs: TokenStream, item: TokenStream) -> TokenStream { + process_predicate_handler(attrs, item) +} diff --git a/packages/fuel-indexer-macros/src/predicate.rs b/packages/fuel-indexer-macros/src/predicate.rs new file mode 100644 index 000000000..f799cd8ac --- /dev/null +++ b/packages/fuel-indexer-macros/src/predicate.rs @@ -0,0 +1,45 @@ +#![allow(unused)] +use proc_macro::TokenStream; +use proc_macro_error::proc_macro_error; +use quote::quote; +use syn::{parse_macro_input, ItemFn}; + +// TODO: I don't think we need this macro but leaving it here for now. + +pub fn process_predicate_handler(_attrs: TokenStream, item: TokenStream) -> TokenStream { + let ast = parse_macro_input!(item as ItemFn); + let fn_name = &ast.sig.ident; + let label = fn_name.to_string(); + let fn_inputs = &ast.sig.inputs; + let fn_output = &ast.sig.output; + let fn_vis = &ast.vis; + let block = &ast.block; + + let (asyncness, awaitness) = if ast.sig.asyncness.is_none() { + (quote! {}, quote! {}) + } else { + (quote! {async}, quote! {.await}) + }; + + let input_idents = fn_inputs + .iter() + .map(|input| match input { + syn::FnArg::Typed(typed) => typed.pat.clone(), + syn::FnArg::Receiver(_) => panic!("`self` arguments are not supported"), + }) + .collect::>(); + + let gen = quote! { + + #fn_vis #asyncness fn #fn_name(#fn_inputs) #fn_output { + let result = { + #asyncness fn inner(#fn_inputs) #fn_output #block + let result = inner(#(#input_idents),*)#awaitness; + result + }; + result + } + }; + + gen.into() +} diff --git a/packages/fuel-indexer-macros/src/tokens.rs b/packages/fuel-indexer-macros/src/tokens.rs new file mode 100644 index 000000000..d0f7b43eb --- /dev/null +++ b/packages/fuel-indexer-macros/src/tokens.rs @@ -0,0 +1,712 @@ +/// Various functions that generate TokenStreams used to augment the indexer ASTs. +use crate::helpers::*; +use fuel_abi_types::abi::program::{Configurable, TypeDeclaration}; +use fuel_indexer_lib::manifest::Manifest; +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use std::collections::HashMap; + +/// `TokenStream` that represents the `Decoder` from which all data is decoded, and all +/// functions are dispatched. +#[allow(clippy::too_many_arguments)] +pub fn decoder_struct_tokens( + decoder_fields: Vec, + abi_selectors: Vec, + abi_selectors_to_fn_names: Vec, + decoders: Vec, + contract_log_decoders: Vec, + message_decoders: Vec, + abi_dispatchers: Vec, +) -> TokenStream { + quote! { + #[derive(Default)] + struct Decoders { + #(#decoder_fields),* + } + + impl Decoders { + fn selector_to_type_id(&self, sel: u64) -> usize { + match sel { + #(#abi_selectors)* + _ => { + debug!("Unknown selector; check ABI to make sure function outputs match to types"); + usize::MAX + } + } + } + + pub fn selector_to_fn_name(&self, sel: u64) -> String { + match sel { + #(#abi_selectors_to_fn_names)* + _ => { + debug!("Unknown selector; check ABI to make sure function outputs match to types"); + "".to_string() + } + } + } + + fn compute_message_id(&self, sender: &Address, recipient: &Address, nonce: Nonce, amount: Word, data: Option>) -> MessageId { + + let mut raw_message_id = Sha256::new() + .chain_update(sender) + .chain_update(recipient) + .chain_update(nonce) + .chain_update(amount.to_be_bytes()); + + let raw_message_id = if let Some(buffer) = data { + raw_message_id + .chain_update(&buffer[..]) + .finalize() + } else { + raw_message_id.finalize() + }; + + let message_id = <[u8; 32]>::try_from(&raw_message_id[..]).expect("Could not calculate message ID from receipt fields"); + + message_id.into() + } + + fn decode_type(&mut self, ty_id: usize, data: Vec) -> anyhow::Result<()> { + let decoder = ABIDecoder::default(); + match ty_id { + #(#decoders),* + _ => { + debug!("Unknown type ID; check ABI to make sure types are correct."); + }, + } + Ok(()) + } + + pub fn decode_block(&mut self, data: BlockData) { + self.blockdata_decoded.push(data); + } + + pub fn decode_return_type(&mut self, sel: u64, data: Vec) -> anyhow::Result<()> { + let ty_id = self.selector_to_type_id(sel); + self.decode_type(ty_id, data)?; + Ok(()) + } + + // FIXME: Until SDK's Predicate is serializable, we can't use decode_type + pub fn decoder_predicate_type(&mut self, predicate: FooPredicate) { + self.foopredicate_decoded.push(predicate); + } + + pub fn decode_logdata(&mut self, rb: usize, data: Vec) -> anyhow::Result<()> { + match rb { + #(#contract_log_decoders),* + _ => debug!("Unknown logged type ID; check ABI to make sure that logged types are correct.") + } + Ok(()) + } + + pub fn decode_messagedata(&mut self, type_id: u64, data: Vec) -> anyhow::Result<()> { + match type_id { + #(#message_decoders),* + _ => debug!("Unknown message type ID; check ABI to make sure that message types are correct.") + } + Ok(()) + } + + pub fn dispatch(&self) -> anyhow::Result<()> { + #(#abi_dispatchers)* + + unsafe { + if !ERROR_MESSAGE.is_empty() { + anyhow::bail!(ERROR_MESSAGE.clone()); + } else { + Ok(()) + } + } + } + } + } +} + +/// `TokenStream` used to build the transaction handler. +pub fn process_transaction_tokens( + contract_subscription: TokenStream, + predicate_block: TokenStream, +) -> TokenStream { + quote! { + let mut process_transaction = |decoder: &mut Decoders, tx: fuel::TransactionData| -> anyhow::Result<()> { + let tx_id = tx.id; + + #predicate_block + + let mut return_types = Vec::new(); + let mut callees = HashSet::new(); + + for receipt in tx.receipts { + match receipt { + fuel::Receipt::Call { id: contract_id, amount, asset_id, gas, param1, to: id, .. } => { + #contract_subscription + + let fn_name = decoder.selector_to_fn_name(param1); + return_types.push(param1); + callees.insert(id); + + let data = serialize( + &Call { + contract_id: ContractId::from(<[u8; 32]>::from(contract_id)), + to: ContractId::from(<[u8; 32]>::from(id)), + amount, + asset_id: AssetId::from(<[u8; 32]>::from(asset_id)), + gas, + fn_name + } + ); + let ty_id = Call::type_id(); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::Log { id, ra, rb, .. } => { + #contract_subscription + let ty_id = Log::type_id(); + let data = serialize( + &Log { + contract_id: ContractId::from(<[u8; 32]>::from(id)), + ra, + rb + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::LogData { rb, data, ptr, len, id, .. } => { + #contract_subscription + decoder.decode_logdata(rb as usize, data.unwrap_or(Vec::::new()))?; + } + fuel::Receipt::Return { id, val, pc, is } => { + #contract_subscription + if callees.contains(&id) { + let ty_id = Return::type_id(); + let data = serialize( + &Return { + contract_id: ContractId::from(<[u8; 32]>::from(id)), + val, + pc, + is + } + ); + decoder.decode_type(ty_id, data)?; + } + } + fuel::Receipt::ReturnData { data, id, .. } => { + #contract_subscription + if callees.contains(&id) { + let selector = return_types.pop().expect("No return type available. <('-'<)"); + decoder.decode_return_type(selector, data.unwrap_or(Vec::::new()))?; + } + } + fuel::Receipt::MessageOut { sender, recipient, amount, nonce, len, digest, data, .. } => { + let sender = Address::from(<[u8; 32]>::from(sender)); + let recipient = Address::from(<[u8; 32]>::from(recipient)); + let message_id = decoder.compute_message_id(&sender, &recipient, nonce, amount, data.clone()); + + // It's possible that the data field was generated from an empty Sway `Bytes` array + // in the send_message() instruction in which case the data field in the receipt will + // have no type information or data to decode. Thus, we check for a None value or + // an empty byte vector; if either condition is present, then we decode to a unit struct instead. + let (type_id, data) = data + .map_or((u64::MAX, Vec::::new()), |buffer| { + if buffer.is_empty() { + (u64::MAX, Vec::::new()) + } else { + let (type_id_bytes, data_bytes) = buffer.split_at(8); + let type_id = u64::from_be_bytes( + <[u8; 8]>::try_from(type_id_bytes) + .expect("Could not get type ID for data in MessageOut receipt") + ); + let data = data_bytes.to_vec(); + (type_id, data) + } + }); + + + decoder.decode_messagedata(type_id, data.clone())?; + + let ty_id = MessageOut::type_id(); + let data = serialize( + &MessageOut { + message_id, + sender, + recipient, + amount, + nonce, + len, + digest, + data + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::ScriptResult { result, gas_used } => { + let ty_id = ScriptResult::type_id(); + let data = serialize(&ScriptResult{ result: u64::from(result), gas_used }); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::Transfer { id, to, asset_id, amount, pc, is, .. } => { + #contract_subscription + let ty_id = Transfer::type_id(); + let data = serialize( + &Transfer { + contract_id: ContractId::from(<[u8; 32]>::from(id)), + to: ContractId::from(<[u8; 32]>::from(to)), + asset_id: AssetId::from(<[u8; 32]>::from(asset_id)), + amount, + pc, + is + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::TransferOut { id, to, asset_id, amount, pc, is, .. } => { + #contract_subscription + let ty_id = TransferOut::type_id(); + let data = serialize( + &TransferOut { + contract_id: ContractId::from(<[u8; 32]>::from(id)), + to: Address::from(<[u8; 32]>::from(to)), + asset_id: AssetId::from(<[u8; 32]>::from(asset_id)), + amount, + pc, + is + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::Panic { id, reason, .. } => { + #contract_subscription + let ty_id = Panic::type_id(); + let data = serialize( + &Panic { + contract_id: ContractId::from(<[u8; 32]>::from(id)), + reason: *reason.reason() as u32 + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::Revert { id, ra, .. } => { + #contract_subscription + let ty_id = Revert::type_id(); + let data = serialize( + &Revert { + contract_id: ContractId::from(<[u8; 32]>::from(id)), + error_val: u64::from(ra & 0xF) + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::Mint { sub_id, contract_id, val, pc, is } => { + let ty_id = Mint::type_id(); + let data = serialize( + &Mint { + sub_id: AssetId::from(<[u8; 32]>::from(sub_id)), + contract_id: ContractId::from(<[u8; 32]>::from(contract_id)), + val, + pc, + is + } + ); + decoder.decode_type(ty_id, data)?; + } + fuel::Receipt::Burn { sub_id, contract_id, val, pc, is } => { + let ty_id = Burn::type_id(); + let data = serialize( + &Burn { + sub_id: AssetId::from(<[u8; 32]>::from(sub_id)), + contract_id: ContractId::from(<[u8; 32]>::from(contract_id)), + val, + pc, + is + } + ); + decoder.decode_type(ty_id, data)?; + } + _ => { + info!("This type is not handled yet. (>'.')>"); + } + } + } + + Ok(()) + }; + } +} + +/// `TokenStream` used to augment the `process_transaction_tokens` `TokenStream` with logic +/// specific to the handling of predicates. +pub fn transaction_predicate_tokens( + manifest: &Manifest, + configurables_match: Vec, +) -> TokenStream { + let verification_tokens = predicate_verification_tokens(manifest); + quote! { + match &tx.transaction { + fuel::Transaction::Script(script) => { + let fuel::Script { + inputs, + outputs, + witnesses, + .. + } = script; + + let signaled_predicates = witnesses + .iter() + .map(|w| PredicateWitnessData::try_from(w.to_owned())) + .filter_map(Result::ok) + .map(|data| { + IndexerPredicate::from_signaled_witness_data( + data.to_owned(), + tx_id, + outputs[data.output_index() as usize].to_owned(), + ) + }) + .collect::>(); + + // Cache signaled predicates + signaled_predicates.iter().for_each(|p| { + let _p = PredicateEntity::from(p.to_owned()).get_or_create(); + }); + + let results = inputs.iter().map(|i| { + match i { + fuel::Input::Coin(coin) => { + let fuel::InputCoin { + utxo_id, + owner, + amount, + asset_id, + predicate: predicate_code, + predicate_data, + .. + } = coin; + + // This could potentially be an InputCoin with no predicate data + if predicate_code.is_empty() || predicate_data.is_empty() { + return None; + } + + // FIXME: hard-coding chain ID for now + let chain_id = 0; + + // FIXME: After https://github.com/FuelLabs/fuel-indexer/pull/1446 is merged, use the new .find() + // functionality to look in the DB for the predicate + let pred = signaled_predicates.iter().find(|p| { + let utxo = p.coin_output(); + utxo.to == *owner + }); + + + match pred { + Some(pred) => { + let template_id = pred.template_id().to_string(); + let predicate_data = pred.configurables().to_owned(); + let configurable = match template_id.as_str() { + #(#configurables_match)* + _ => panic!("Unknown predicate template ID; check ABI to make sure that predicate IDs are correct.") + }; + + match configurable { + #(#verification_tokens)* + _ => panic!("Unrecognized configurable type."), + } + + None + } + None => None, + } + } + _ => { + debug!("Input type ignored for predicates."); + None + } + } + }).collect::>>(); + } + _ => { + debug!("Transaction type ignored for predicates."); + } + } + } +} + +/// `TokenStream` used to verify a set of predicates. +pub fn predicate_verification_tokens(manifest: &Manifest) -> Vec { + let mut output = Vec::new(); + + if let Some(predicates) = manifest.predicates() { + if predicates.is_empty() { + return output; + } + + let configurables_namings = derive_configurables_names_map(manifest); + + if let Some(templates) = predicates.templates() { + for template in templates { + let indexer_variant_name = + format_ident! { "{}", indexer_configurables_name(&template.name) }; + let sdk_variant_name = + format_ident! { "{}", sdk_configurables_name(&template.name) }; + + let encoder_name = format_ident! { "{}", sdk_configurables_encoder_name(&template.name) }; + + let abi = get_json_abi(Some(template.abi.clone())) + .expect("Could not derive predicate JSON ABI."); + + let main = abi + .functions + .iter() + .find(|f| f.name == "main") + .expect("Could not find main function in predicate ABI."); + + let input_fields = main + .inputs + .iter() + .map(|i| { + let ty_id = i.type_id; + let name = configurables_namings + .get(&ty_id) + .expect("Could not find configurable naming."); + format_ident! {"{}", name } + }) + .collect::>(); + + let chained_functions = + abi.configurables.iter().flat_map(|configurables| { + configurables.iter().map(|c| { + let ty_name = configurable_fn_type_name(c) + .expect("Cannot use unit types '()' in configurables."); + let arg = configurables_namings + .get(&c.application.type_id) + .expect("Could not find configurable naming."); + let arg = format_ident! {"{}", arg }; + let fn_name = format_ident! { "with_{}", ty_name }; + quote! { + .#fn_name(#arg) + } + }) + }); + + output.push(quote! { + ConfigurablesContainer::#indexer_variant_name(#indexer_variant_name { #(#input_fields),*, .. }) => { + let configurables = #sdk_variant_name::new()#(#chained_functions)*; + let predicate_data = #encoder_name::encode_data(#(#input_fields),*); + + let mut predicate: Predicate = Predicate::from_code(predicate_code.clone(), chain_id) + .with_data(predicate_data) + .with_configurables(configurables); + + let predicate = FooPredicate::from(predicate); + + if *predicate.address() == pred.coin_output().to.into() { + decoder.decoder_predicate_type(predicate); + return None; + } + + // logger.debug!("Could not verify predicate."); + // None + } + }); + } + } + } + + output +} + +/// `TokenStream` used to generate a set of indexer-specific configurables (not to be confused +/// with `fuels-rs` configurables). +pub fn indexer_configurables_tokens(manifest: &Manifest) -> TokenStream { + let predicates = manifest.predicates(); + + let mut output = quote! { + trait ConfigurableDecoder { + fn decode_type(&self, ty_id: usize, data: Vec); + } + }; + + if let Some(p) = predicates { + if p.is_empty() { + return output; + } + + let configurable_namings = derive_configurables_names_map(manifest); + + let mut configurable_variants = Vec::new(); + + let names = p + .templates() + .map(|t| t.iter().map(|t| t.name.clone()).collect::>()) + .unwrap_or_default(); + let paths = p + .templates() + .map(|t| t.iter().map(|t| t.abi.clone()).collect::>()) + .unwrap_or_default(); + + names.into_iter().zip(paths).for_each(|(name, abi_path)| { + let abi = get_json_abi(Some(abi_path)) + .expect("Could not derive predicate JSON ABI."); + let main = abi + .functions + .iter() + .find(|f| f.name == "main") + .expect("Could not find main function in predicate ABI."); + + let configurable_types = abi + .configurables + .iter() + .flat_map(|configurables| { + configurables + .iter() + .map(|c| (c.application.type_id, c.clone())) + }) + .collect::>(); + + let predicate_types = abi + .types + .iter() + .map(|typ| (typ.type_id, typ.clone())) + .collect::>(); + + let predicate_input_fields = main + .inputs + .iter() + .map(|i| { + let typ = predicate_types + .get(&i.type_id) + .expect("Predicate configurable type not found in the ABI."); + let name = configurable_namings + .get(&i.type_id) + .expect("Could not find configurable naming."); + let ty = typ.rust_tokens(); + let name = format_ident! { "{}", name }; + + quote! { + pub #name: #ty + } + }) + .collect::>(); + + let config_set_decoders = configurable_types + .keys() + .map(|ty_id| { + let typ = predicate_types.get(ty_id).expect( + "Could not get configurable type reference from ABI types.", + ); + let type_tokens = typ.rust_tokens(); + decode_configurable_snippet(&type_tokens, typ) + }) + .collect::>(); + + let name = indexer_configurables_name(&name); + let ident = format_ident! { "{}", name }; + configurable_variants.push(ident.clone()); + + output = quote! { + #output + + #[derive(Debug, Clone)] + pub struct #ident { + pub id: String, + #(#predicate_input_fields),* + } + + impl ConfigurableDecoder for #ident { + fn decode_type(&self, ty_id: usize, data: Vec) { + match ty_id { + #(#config_set_decoders)* + _ => { + panic!("Could not find type with ID: {}", ty_id); + } + } + } + } + + impl TypeId for #ident { + fn type_id() -> usize { + type_id(FUEL_TYPES_NAMESPACE, #name) as usize + } + } + + impl TryFrom> for #ident { + type Error = bincode::Error; + fn try_from(bytes: Vec) -> Result { + // let obj = Self::default(); + // let mut left = 0; + // let right = bytes.len(); + // while left < right { + // let ty_id = u32::from_le_bytes(bytes[0..4].try_into().unwrap()); + // let len = u32::from_le_bytes(bytes[4..8].try_into().unwrap()); + // let arr = bytes[8 .. len as usize].to_vec(); + // obj.decode_type(ty_id as usize, arr); + // left = 8 + len as usize; + // } + // Ok(obj) + todo!() + } + } + } + }); + + output = quote! { + #output + + enum ConfigurablesContainer { + #(#configurable_variants(#configurable_variants)),* + } + }; + }; + + output +} + +/// Generate a set of tokens for converting predicate types between their ABI-like type +/// (e.g., `IndexerPredicate`) and their Entity-like type (e.g., `PredicateEntity`). +pub fn predicate_tokens() -> TokenStream { + quote! { + impl From for PredicateEntity { + fn from(p: IndexerPredicate) -> Self { + let coin_output = p.coin_output(); + let spent_tx_id = p.spent_tx_id(); + let unspent_tx_id = p.unspent_tx_id(); + let configurables = p.configurables(); + let template_id = p.template_id(); + let output_index = p.output_index(); + + let coin_output = bincode::serialize(&coin_output).expect("Could not serialize CoinOutput."); + + Self::new( + configurables.to_owned(), + template_id.to_owned(), + output_index.to_owned(), + coin_output, + unspent_tx_id.to_owned(), + spent_tx_id.to_owned(), + ) + } + } + + impl From for IndexerPredicate { + fn from(entity: PredicateEntity) -> Self { + let PredicateEntity { + configurables, + unspent_tx_id, + spent_tx_id, + coin_output, + template_id, + output_index, + .. + } = entity; + + Self::from_entity( + output_index, + configurables.to_vec(), + template_id, + coin_output, + unspent_tx_id, + spent_tx_id, + ) + } + } + } +} diff --git a/packages/fuel-indexer-macros/src/wasm.rs b/packages/fuel-indexer-macros/src/wasm.rs index 67a3dff78..447e126df 100644 --- a/packages/fuel-indexer-macros/src/wasm.rs +++ b/packages/fuel-indexer-macros/src/wasm.rs @@ -100,8 +100,10 @@ fn wasm_prelude() -> proc_macro2::TokenStream { use fuel_indexer_utils::plugin::{serde_json, serialize, deserialize, bincode}; use fuel_indexer_utils::plugin::serde::{Deserialize, Serialize}; use fuels::{ + accounts::predicate::Predicate, core::{codec::{ABIDecoder}, Configurables, traits::{Parameterize, Tokenizable}}, types::{param_types::ParamType}, + prelude::abigen, }; } } diff --git a/packages/fuel-indexer-plugin/Cargo.toml b/packages/fuel-indexer-plugin/Cargo.toml index 8b1e29f41..a474343f0 100644 --- a/packages/fuel-indexer-plugin/Cargo.toml +++ b/packages/fuel-indexer-plugin/Cargo.toml @@ -20,6 +20,8 @@ fuel-indexer-schema = { workspace = true, default-features = false } fuel-indexer-types = { workspace = true } getrandom = { version = "0.2", features = ["js"] } hex = "0.4" +proc-macro2 = "1.0" +quote = "1.0" serde = { workspace = true } serde_json = { workspace = true } sha2 = { version = "0.10" } diff --git a/packages/fuel-indexer-schema/src/lib.rs b/packages/fuel-indexer-schema/src/lib.rs index 6ccf24b93..89ae4c4bd 100644 --- a/packages/fuel-indexer-schema/src/lib.rs +++ b/packages/fuel-indexer-schema/src/lib.rs @@ -156,7 +156,7 @@ impl FtColumn { }, FtColumn::Json(value) => match value { Some(val) => { - let x = &val.0; + let x: &str = val.as_ref(); format!("'{x}'") } None => String::from(NULL_VALUE), @@ -270,7 +270,7 @@ mod tests { let int4 = FtColumn::I32(Some(i32::from_le_bytes([0x78; 4]))); let int64 = FtColumn::I64(Some(i64::from_le_bytes([0x78; 8]))); let int8 = FtColumn::I64(Some(i64::from_le_bytes([0x78; 8]))); - let json = FtColumn::Json(Some(Json(r#"{"hello":"world"}"#.to_string()))); + let json = FtColumn::Json(Some(Json::new(r#"{"hello":"world"}"#.to_string()))); let r#bool = FtColumn::Boolean(Some(true)); let r#enum = FtColumn::Enum(Some(String::from("hello"))); let uint1 = FtColumn::U8(Some(u8::from_le_bytes([0x78; 1]))); diff --git a/packages/fuel-indexer-tests/components/fuel-node/src/main.rs b/packages/fuel-indexer-tests/components/fuel-node/src/main.rs index 2f83adb36..ce10bac49 100644 --- a/packages/fuel-indexer-tests/components/fuel-node/src/main.rs +++ b/packages/fuel-indexer-tests/components/fuel-node/src/main.rs @@ -4,8 +4,8 @@ use fuels::macros::abigen; use std::path::{Path, PathBuf}; abigen!(Contract( - name = "FuelIndexerTest", - abi = "packages/fuel-indexer-tests/contracts/fuel-indexer-test/out/debug/fuel-indexer-test-abi.json" + name = "FuelIndexer", + abi = "packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json" )); #[derive(Debug, Parser, Clone)] @@ -38,11 +38,11 @@ async fn main() -> Result<(), Box> { Path::new(&manifest_dir) .join("..") .join("..") - .join("contracts") - .join("fuel-indexer-test") + .join("sway") + .join("test-contract1") .join("out") .join("debug") - .join("fuel-indexer-test.bin") + .join("test-contract1.bin") }); let host = opts diff --git a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml index 0c99411d8..13a6a711f 100644 --- a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml +++ b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/fuel_indexer_test.yaml @@ -1,11 +1,21 @@ namespace: fuel_indexer_test fuel_client: ~ graphql_schema: packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fuel_indexer_test.graphql -abi: packages/fuel-indexer-tests/contracts/fuel-indexer-test/out/debug/fuel-indexer-test-abi.json start_block: ~ end_block: ~ -contract_id: fuel1jjrj8zjyjc3s4qkw345mt57mwn56lnc9zwqnt5krrx9umwxacrvs2c3jyg +contract: + abi: packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json + subscriptions: + - fuel1jjrj8zjyjc3s4qkw345mt57mwn56lnc9zwqnt5krrx9umwxacrvs2c3jyg identifier: index1 module: wasm: target/wasm32-unknown-unknown/release/fuel_indexer_test.wasm -resumable: true \ No newline at end of file +resumable: true +predicates: + templates: + - name: TestPredicate1 + abi: packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-abi.json + id: 0xcfd60aa414972babde16215e0cb5a2739628831405a7ae81a9fc1d2ebce87145 + - name: TestPredicate2 + id: 0x1c83e1f094b47f14943066f6b6ca41ce5c3ae4e387c973e924564dac0227a896 + abi: packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-abi.json \ No newline at end of file diff --git a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs index b3658f8bd..c8f65f403 100644 --- a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs +++ b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs @@ -1,5 +1,4 @@ extern crate alloc; - use fuel_indexer_utils::prelude::*; #[indexer( @@ -13,8 +12,12 @@ mod fuel_indexer_test { let input_data = r#"{"foo":"bar"}"#.to_string(); for _tx in block_data.transactions.iter() { - TxEntity::new(block.id.clone(), Json(input_data.clone()), block_data.time) - .get_or_create(); + TxEntity::new( + block.id.clone(), + Json::new(input_data.clone()), + block_data.time, + ) + .get_or_create(); } } @@ -146,7 +149,7 @@ mod fuel_indexer_test { block_data: BlockData, ) { info!( - "fuel_indexer_test_multiargs handling Pung, Pong, Ping, and BlockData events." + "fuel_indexer_test_multiargs handling Pung, Pong, Ping, and BlockData events.." ); BlockEntity::new(block_data.height, block_data.time).get_or_create(); @@ -579,4 +582,11 @@ mod fuel_indexer_test { ping.save(); } + + fn fuel_indexer_test_predicates( + _predicate: FooPredicate, + _configurables: TestPredicate1InnerConfigurables, + ) { + info!("fuel_indexer_test_predicates handling trigger_predicates event"); + } } diff --git a/packages/fuel-indexer-tests/indexers/simple-wasm/simple_wasm.yaml b/packages/fuel-indexer-tests/indexers/simple-wasm/simple_wasm.yaml index ab4c5a140..64ae79998 100644 --- a/packages/fuel-indexer-tests/indexers/simple-wasm/simple_wasm.yaml +++ b/packages/fuel-indexer-tests/indexers/simple-wasm/simple_wasm.yaml @@ -1,7 +1,11 @@ namespace: test_namespace identifier: simple_wasm_executor -abi: packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi.json +contract: + abi: packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-abi.json + subscriptions: ~ graphql_schema: packages/fuel-indexer-tests/indexers/simple-wasm/schema/simple_wasm.graphql -contract_id: ~ module: wasm: target/wasm32-unknown-unknown/release/simple_wasm.wasm +predicates: + abis: ~ + templates: ~ diff --git a/packages/fuel-indexer-tests/src/fixtures.rs b/packages/fuel-indexer-tests/src/fixtures.rs index c00a39cb3..9710c83e4 100644 --- a/packages/fuel-indexer-tests/src/fixtures.rs +++ b/packages/fuel-indexer-tests/src/fixtures.rs @@ -1,6 +1,4 @@ -use crate::{ - assets, defaults, utils::update_test_manifest_asset_paths, TestError, WORKSPACE_ROOT, -}; +use crate::{assets, defaults, TestError, WORKSPACE_ROOT}; use actix_service::Service; use actix_web::test; use axum::routing::Router; @@ -40,8 +38,8 @@ use tokio::{ use tracing_subscriber::filter::EnvFilter; abigen!(Contract( - name = "FuelIndexerTest", - abi = "packages/fuel-indexer-tests/contracts/fuel-indexer-test/out/debug/fuel-indexer-test-abi.json" + name = "FuelIndexer", + abi = "packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json" )); pub struct TestPostgresDb { @@ -93,8 +91,7 @@ pub async fn setup_indexing_test_components( let db = TestPostgresDb::new().await.unwrap(); let mut service = indexer_service_postgres(Some(&db.url), config).await; - let mut manifest = Manifest::try_from(assets::FUEL_INDEXER_TEST_MANIFEST).unwrap(); - update_test_manifest_asset_paths(&mut manifest); + let manifest = assets::test_indexer_updated_manifest(); service .register_indexer_from_manifest( @@ -119,8 +116,7 @@ pub async fn setup_web_test_components( let db = TestPostgresDb::new().await.unwrap(); let mut service = indexer_service_postgres(Some(&db.url), config.clone()).await; - let mut manifest = Manifest::try_from(assets::FUEL_INDEXER_TEST_MANIFEST).unwrap(); - update_test_manifest_asset_paths(&mut manifest); + let manifest = assets::test_indexer_updated_manifest(); service .register_indexer_from_manifest( @@ -346,22 +342,22 @@ pub async fn setup_example_test_fuel_node() -> Result<(), ()> { let wallet_path = Path::new(WORKSPACE_ROOT).join("test-chain-config.json"); let contract_bin_path = Path::new(WORKSPACE_ROOT) - .join("contracts") - .join("fuel-indexer-test") + .join("sway") + .join("test-contract1") .join("out") .join("debug") - .join("fuel-indexer-test.bin"); + .join("test-contract1.bin"); setup_test_fuel_node(wallet_path, Some(contract_bin_path), None).await } pub fn get_test_contract_id() -> Bech32ContractId { let contract_bin_path = Path::new(WORKSPACE_ROOT) - .join("contracts") - .join("fuel-indexer-test") + .join("sway") + .join("test-contract1") .join("out") .join("debug") - .join("fuel-indexer-test.bin"); + .join("test-contract1.bin"); let loaded_contract = Contract::load_from( contract_bin_path.as_os_str().to_str().unwrap(), @@ -413,7 +409,7 @@ pub async fn indexer_service_postgres( } pub async fn connect_to_deployed_contract( -) -> Result, Box> { +) -> Result, Box> { let wallet_path = Path::new(WORKSPACE_ROOT).join("test-chain-config.json"); let wallet_path_str = wallet_path.as_os_str().to_str().unwrap(); let mut wallet = @@ -433,7 +429,7 @@ pub async fn connect_to_deployed_contract( let contract_id: Bech32ContractId = Bech32ContractId::from(fuels::types::ContractId::from(get_test_contract_id())); - let contract = FuelIndexerTest::new(contract_id.clone(), wallet); + let contract = FuelIndexer::new(contract_id.clone(), wallet); println!("Using contract at {contract_id}"); @@ -454,7 +450,7 @@ pub mod test_web { use fuels::types::bech32::Bech32ContractId; use std::path::Path; - use super::{tx_params, FuelIndexerTest}; + use super::{tx_params, FuelIndexer}; async fn fuel_indexer_test_blocks(state: web::Data>) -> impl Responder { let _ = state @@ -825,11 +821,11 @@ pub mod test_web { } pub struct AppState { - pub contract: FuelIndexerTest, + pub contract: FuelIndexer, } pub fn app( - contract: FuelIndexerTest, + contract: FuelIndexer, ) -> App< impl ServiceFactory< ServiceRequest, @@ -928,7 +924,7 @@ pub mod test_web { println!("Starting server at {}", defaults::WEB_API_ADDR); let _ = HttpServer::new(move || { - app(FuelIndexerTest::new(contract_id.clone(), wallet.clone())) + app(FuelIndexer::new(contract_id.clone(), wallet.clone())) }) .bind(defaults::WEB_API_ADDR) .unwrap() diff --git a/packages/fuel-indexer-tests/src/lib.rs b/packages/fuel-indexer-tests/src/lib.rs index 667f90b74..c500bf98b 100644 --- a/packages/fuel-indexer-tests/src/lib.rs +++ b/packages/fuel-indexer-tests/src/lib.rs @@ -1,11 +1,11 @@ #[cfg(not(feature = "trybuild"))] pub mod fixtures; -pub const WORKSPACE_ROOT: &str = env!("CARGO_MANIFEST_DIR"); - use fuel_indexer_lib::config::IndexerConfigError; use thiserror::Error; +pub const WORKSPACE_ROOT: &str = env!("CARGO_MANIFEST_DIR"); + #[derive(Error, Debug)] pub enum TestError { #[error("Database error: {0:?}")] @@ -23,6 +23,9 @@ pub enum TestError { } pub mod assets { + use duct::cmd; + use fuel_indexer_lib::manifest::Manifest; + pub const FUEL_INDEXER_TEST_MANIFEST: &str = include_str!("./../indexers/fuel-indexer-test/fuel_indexer_test.yaml"); @@ -34,6 +37,53 @@ pub mod assets { pub const SIMPLE_WASM_WASM: &[u8] = include_bytes!("../../../target/wasm32-unknown-unknown/release/simple_wasm.wasm"); + + // NOTE: This is a hack to update the `manifest` with the proper absolute paths. + // This is already done in the #[indexer] attribute, but since these tests test + // modules that have already been compiled, we need to do this manually here. + // + // Doing this allows us to use the relative root of the the fuel-indexer/ + // repo for all test asset paths (i.e., we can simply reference all asset paths in + // in manifest files relative from 'fuel-indexer') + pub fn test_indexer_updated_manifest() -> Manifest { + // TODO: Write a CI check for this + let workspace_root = cmd!("cargo", "metadata", "--format-version=1") + .pipe(cmd!("json_pp")) + .pipe(cmd!("jq", ".workspace_root")) + .read() + .unwrap(); + let mut chars = workspace_root.chars(); + chars.next(); + chars.next_back(); + let workspace_root = chars.as_str().to_string(); + // Should mirror packages::fuel_indexer_tests::indexers::fuel_indexer_test::fuel_indexer_test.yaml + let content = format!( + r#" +namespace: fuel_indexer_test +fuel_client: ~ +graphql_schema: {workspace_root}/packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fuel_indexer_test.graphql +start_block: ~ +end_block: ~ +contract: + abi: {workspace_root}/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json + subscriptions: + - fuel1jjrj8zjyjc3s4qkw345mt57mwn56lnc9zwqnt5krrx9umwxacrvs2c3jyg +identifier: index1 +module: + wasm: {workspace_root}/target/wasm32-unknown-unknown/release/fuel_indexer_test.wasm +resumable: true +predicates: + templates: + - name: TestPredicate1 + abi: {workspace_root}/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-abi.json + id: 0xcfd60aa414972babde16215e0cb5a2739628831405a7ae81a9fc1d2ebce87145 + - name: TestPredicate2 + id: 0x1c83e1f094b47f14943066f6b6ca41ce5c3ae4e387c973e924564dac0227a896 + abi: {workspace_root}/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-abi.json +"# + ); + Manifest::try_from(content.as_str()).unwrap() + } } pub mod defaults { @@ -54,61 +104,3 @@ pub mod defaults { pub const MAX_BODY_SIZE: usize = 5242880; // 5MB in bytes pub const POSTGRES_URL: &str = "postgres://postgres:my-secret@localhost:5432"; } - -pub mod utils { - - use super::WORKSPACE_ROOT; - use fuel_indexer_lib::manifest::{Manifest, Module}; - use std::path::Path; - - // NOTE: This is a hack to update the `manifest` with the proper absolute paths. - // This is already done in the #[indexer] attribute, but since these tests test - // modules that have already been compiled, we need to do this manually here. - // - // Doing this allows us to use the relative root of the the fuel-indexer/ - // repo for all test asset paths (i.e., we can simply reference all asset paths in - // in manifest files relative from 'fuel-indexer') - pub fn update_test_manifest_asset_paths(manifest: &mut Manifest) { - let manifest_dir = Path::new(WORKSPACE_ROOT); - let graphql_schema = manifest_dir - .parent() - .unwrap() - .parent() - .unwrap() - .join(manifest.graphql_schema()) - .into_os_string() - .to_str() - .unwrap() - .to_string(); - - manifest.set_graphql_schema(graphql_schema); - - let abi = manifest_dir - .parent() - .unwrap() - .parent() - .unwrap() - .join(manifest.abi().unwrap()) - .into_os_string() - .to_str() - .unwrap() - .to_string(); - - manifest.set_abi(abi); - - let module = Module::Wasm( - manifest_dir - .parent() - .unwrap() - .parent() - .unwrap() - .join(manifest.module().to_string()) - .into_os_string() - .to_str() - .unwrap() - .to_string(), - ); - - manifest.set_module(module); - } -} diff --git a/packages/fuel-indexer-tests/contracts/README.md b/packages/fuel-indexer-tests/sway/README.md similarity index 100% rename from packages/fuel-indexer-tests/contracts/README.md rename to packages/fuel-indexer-tests/sway/README.md diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/.gitignore b/packages/fuel-indexer-tests/sway/simple-wasm/.gitignore similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/.gitignore rename to packages/fuel-indexer-tests/sway/simple-wasm/.gitignore diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/Forc.lock b/packages/fuel-indexer-tests/sway/simple-wasm/Forc.lock similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/Forc.lock rename to packages/fuel-indexer-tests/sway/simple-wasm/Forc.lock diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/Forc.toml b/packages/fuel-indexer-tests/sway/simple-wasm/Forc.toml similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/Forc.toml rename to packages/fuel-indexer-tests/sway/simple-wasm/Forc.toml diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi.json b/packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-abi.json similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi.json rename to packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-abi.json diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-flat-abi.json b/packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-flat-abi.json similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-flat-abi.json rename to packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-flat-abi.json diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-storage_slots.json b/packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-storage_slots.json similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-storage_slots.json rename to packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-storage_slots.json diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts.bin b/packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts.bin similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts.bin rename to packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts.bin diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/src/main.sw b/packages/fuel-indexer-tests/sway/simple-wasm/src/main.sw similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/src/main.sw rename to packages/fuel-indexer-tests/sway/simple-wasm/src/main.sw diff --git a/packages/fuel-indexer-tests/sway/test-contract1/.gitignore b/packages/fuel-indexer-tests/sway/test-contract1/.gitignore new file mode 100644 index 000000000..77d3844f5 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-contract1/.gitignore @@ -0,0 +1,2 @@ +out +target diff --git a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/Forc.lock b/packages/fuel-indexer-tests/sway/test-contract1/Forc.lock similarity index 91% rename from packages/fuel-indexer-tests/contracts/fuel-indexer-test/Forc.lock rename to packages/fuel-indexer-tests/sway/test-contract1/Forc.lock index d643155c4..e9a883c35 100644 --- a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/Forc.lock +++ b/packages/fuel-indexer-tests/sway/test-contract1/Forc.lock @@ -2,12 +2,12 @@ name = 'core' source = 'path+from-root-63B5D95B29B128A3' -[[package]] -name = 'fuel-indexer-test' -source = 'member' -dependencies = ['std'] - [[package]] name = 'std' source = 'git+https://github.com/fuellabs/sway?tag=v0.45.0#92dc9f361a9508a940c0d0708130f26fa044f6b3' dependencies = ['core'] + +[[package]] +name = 'test-contract1' +source = 'member' +dependencies = ['std'] diff --git a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/Forc.toml b/packages/fuel-indexer-tests/sway/test-contract1/Forc.toml similarity index 77% rename from packages/fuel-indexer-tests/contracts/fuel-indexer-test/Forc.toml rename to packages/fuel-indexer-tests/sway/test-contract1/Forc.toml index 39acf3d45..6517dfbf4 100644 --- a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/Forc.toml +++ b/packages/fuel-indexer-tests/sway/test-contract1/Forc.toml @@ -2,6 +2,6 @@ authors = ["Rashad Alston"] entry = "main.sw" license = "Apache-2.0" -name = "fuel-indexer-test" +name = "test-contract1" [dependencies] diff --git a/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json b/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json new file mode 100644 index 000000000..7e50dcb21 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-abi.json @@ -0,0 +1,907 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "(_, _)", + "components": [ + { + "name": "__tuple_element", + "type": 18, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 31, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 2, + "type": "(_, _)", + "components": [ + { + "name": "__tuple_element", + "type": 33, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 3, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "(_, _, _)", + "components": [ + { + "name": "__tuple_element", + "type": 34, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 7, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "(_, _, _)", + "components": [ + { + "name": "__tuple_element", + "type": 33, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 34, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 16, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "[_; 3]", + "components": [ + { + "name": "__array_element", + "type": 35, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 7, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 8, + "type": "enum AnotherSimpleEnum", + "components": [ + { + "name": "Ping", + "type": 25, + "typeArguments": null + }, + { + "name": "Pung", + "type": 27, + "typeArguments": null + }, + { + "name": "Call", + "type": 12, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 20, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 22, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "enum NestedEnum", + "components": [ + { + "name": "Inner", + "type": 8, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 14, + "typeArguments": null + } + ], + "typeParameters": [ + 14 + ] + }, + { + "typeId": 12, + "type": "enum SimpleEnum", + "components": [ + { + "name": "One", + "type": 0, + "typeArguments": null + }, + { + "name": "Two", + "type": 0, + "typeArguments": null + }, + { + "name": "Three", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "enum UserError", + "components": [ + { + "name": "Unauthorized", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 15, + "type": "raw untyped ptr", + "components": null, + "typeParameters": null + }, + { + "typeId": 16, + "type": "str[12]", + "components": null, + "typeParameters": null + }, + { + "typeId": 17, + "type": "str[32]", + "components": null, + "typeParameters": null + }, + { + "typeId": 18, + "type": "str[5]", + "components": null, + "typeParameters": null + }, + { + "typeId": 19, + "type": "str[78]", + "components": null, + "typeParameters": null + }, + { + "typeId": 20, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 6, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 21, + "type": "struct ComplexTupleStruct", + "components": [ + { + "name": "data", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 22, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 6, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 23, + "type": "struct ExampleMessageStruct", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + }, + { + "name": "message", + "type": 17, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 24, + "type": "struct ExplicitQueryStruct", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 25, + "type": "struct Ping", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + }, + { + "name": "value", + "type": 34, + "typeArguments": null + }, + { + "name": "message", + "type": 17, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 26, + "type": "struct Pong", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + }, + { + "name": "value", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 27, + "type": "struct Pung", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + }, + { + "name": "value", + "type": 34, + "typeArguments": null + }, + { + "name": "is_pung", + "type": 7, + "typeArguments": null + }, + { + "name": "pung_from", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 28, + "type": "struct RawVec", + "components": [ + { + "name": "ptr", + "type": 15, + "typeArguments": null + }, + { + "name": "cap", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": [ + 14 + ] + }, + { + "typeId": 29, + "type": "struct SimpleQueryStruct", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 30, + "type": "struct SimpleTupleStruct", + "components": [ + { + "name": "data", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 31, + "type": "struct TupleStructItem", + "components": [ + { + "name": "id", + "type": 34, + "typeArguments": null + }, + { + "name": "arr", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 32, + "type": "struct Vec", + "components": [ + { + "name": "buf", + "type": 28, + "typeArguments": [ + { + "name": "", + "type": 14, + "typeArguments": null + } + ] + }, + { + "name": "len", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": [ + 14 + ] + }, + { + "typeId": 33, + "type": "u32", + "components": null, + "typeParameters": null + }, + { + "typeId": 34, + "type": "u64", + "components": null, + "typeParameters": null + }, + { + "typeId": 35, + "type": "u8", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [], + "name": "trigger_burn", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [], + "name": "trigger_callreturn", + "output": { + "name": "", + "type": 27, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_deeply_nested", + "output": { + "name": "", + "type": 29, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_enum", + "output": { + "name": "", + "type": 8, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [ + { + "name": "num", + "type": 34, + "typeArguments": null + } + ], + "name": "trigger_enum_error", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_explicit", + "output": { + "name": "", + "type": 24, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_generics", + "output": { + "name": "", + "type": 11, + "typeArguments": [ + { + "name": "", + "type": 25, + "typeArguments": null + } + ] + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_log", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_logdata", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_messageout", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [], + "name": "trigger_mint", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_multiargs", + "output": { + "name": "", + "type": 25, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_panic", + "output": { + "name": "", + "type": 34, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_ping", + "output": { + "name": "", + "type": 25, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_ping_for_optional", + "output": { + "name": "", + "type": 25, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_pong", + "output": { + "name": "", + "type": 26, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_pure_function", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_revert", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_scriptresult", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_transfer", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [], + "name": "trigger_transferout", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [], + "name": "trigger_tuple", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [ + { + "name": "v", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 35, + "typeArguments": null + } + ] + } + ], + "name": "trigger_vec_pong_calldata", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "trigger_vec_pong_logdata", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": null + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 13, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [ + { + "name": "", + "type": 25, + "typeArguments": [] + } + ] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 25, + "typeArguments": [] + } + ] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 34, + "typeArguments": null + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 27, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 27, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 26, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 34, + "typeArguments": null + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 30, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 19, + "typeArguments": null + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 26, + "typeArguments": [] + } + ] + } + } + ], + "messagesTypes": [ + { + "messageId": 0, + "messageType": { + "name": "", + "type": 23, + "typeArguments": [] + } + } + ], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/out/debug/fuel-indexer-test-storage_slots.json b/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-storage_slots.json similarity index 100% rename from packages/fuel-indexer-tests/contracts/fuel-indexer-test/out/debug/fuel-indexer-test-storage_slots.json rename to packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1-storage_slots.json diff --git a/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1.bin b/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1.bin new file mode 100644 index 000000000..fca1fe78f Binary files /dev/null and b/packages/fuel-indexer-tests/sway/test-contract1/out/debug/test-contract1.bin differ diff --git a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw b/packages/fuel-indexer-tests/sway/test-contract1/src/main.sw similarity index 98% rename from packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw rename to packages/fuel-indexer-tests/sway/test-contract1/src/main.sw index f082a8402..4a2216fb1 100644 --- a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw +++ b/packages/fuel-indexer-tests/sway/test-contract1/src/main.sw @@ -21,7 +21,6 @@ pub struct Pong { value: u64, } - pub struct Ping { id: u64, value: u64, @@ -119,7 +118,6 @@ impl FuelIndexer for Contract { log(Pong { id: 45678, value: 45678 }); - Ping { id: 12345, value: 12345, message: "a multiarg ping entity " } } @@ -225,7 +223,7 @@ impl FuelIndexer for Contract { v.push(Pong{ id: 7777, value: 7777 }); v.push(Pong{ id: 8888, value: 8888 }); v.push(Pong{ id: 9999, value: 9999 }); - + log(v); } @@ -237,7 +235,7 @@ impl FuelIndexer for Contract { let r0: u64 = 18_446_744_073_709_551_615u64; // add r0 & r0 (which is the maximum u64 value) and put the result in r1 asm(r0: r0, r1) { - add r1 r0 r0; + add r1 r0 r0; r1: u64 } } @@ -261,8 +259,8 @@ impl FuelIndexer for Contract { log(NestedEnum::Inner(AnotherSimpleEnum::Call(SimpleEnum::Three))); AnotherSimpleEnum::Ping(Ping { - id: 7777, - value: 7775, + id: 7777, + value: 7775, message: "hello world! I am, a log event!!" }) } diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/.gitignore b/packages/fuel-indexer-tests/sway/test-predicate1/.gitignore new file mode 100644 index 000000000..77d3844f5 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate1/.gitignore @@ -0,0 +1,2 @@ +out +target diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/Forc.lock b/packages/fuel-indexer-tests/sway/test-predicate1/Forc.lock new file mode 100644 index 000000000..23d9e0140 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate1/Forc.lock @@ -0,0 +1,13 @@ +[[package]] +name = "core" +source = "path+from-root-BD9159206068AEC6" + +[[package]] +name = "std" +source = "git+https://github.com/fuellabs/sway?tag=v0.46.1#512a3386f8961185188302f391ccc96553d23a7a" +dependencies = ["core"] + +[[package]] +name = "test-predicate1" +source = "member" +dependencies = ["std"] diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/Forc.toml b/packages/fuel-indexer-tests/sway/test-predicate1/Forc.toml new file mode 100644 index 000000000..9e9e77f5e --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate1/Forc.toml @@ -0,0 +1,7 @@ +[project] +authors = ["Rashad Alston"] +entry = "main.sw" +license = "Apache-2.0" +name = "test-predicate1" + +[dependencies] diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-abi.json b/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-abi.json new file mode 100644 index 000000000..dd932f35d --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-abi.json @@ -0,0 +1,117 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "enum Predicate1SimpleEnum", + "components": [ + { + "name": "VariantOne", + "type": 0, + "typeArguments": null + }, + { + "name": "VariantTwo", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "struct Predicate1SimpleStruct", + "components": [ + { + "name": "field_1", + "type": 5, + "typeArguments": null + }, + { + "name": "field_2", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "u64", + "components": null, + "typeParameters": null + }, + { + "typeId": 5, + "type": "u8", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "u_8", + "type": 5, + "typeArguments": null + }, + { + "name": "switch", + "type": 1, + "typeArguments": null + }, + { + "name": "some_struct", + "type": 3, + "typeArguments": null + }, + { + "name": "some_enum", + "type": 2, + "typeArguments": null + } + ], + "name": "main", + "output": { + "name": "", + "type": 1, + "typeArguments": null + }, + "attributes": null + } + ], + "loggedTypes": [], + "messagesTypes": [], + "configurables": [ + { + "name": "U8", + "configurableType": { + "name": "", + "type": 5, + "typeArguments": null + }, + "offset": 124 + }, + { + "name": "BOOL", + "configurableType": { + "name": "", + "type": 1, + "typeArguments": null + }, + "offset": 132 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-bin-root b/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-bin-root new file mode 100644 index 000000000..41ae03b7b --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1-bin-root @@ -0,0 +1 @@ +0x048029a18e3254862e2d4108fc9a9dcdcd2f71e0c6e37dad8f1b513845c8e685 \ No newline at end of file diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1.bin b/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1.bin new file mode 100644 index 000000000..588bcfa96 Binary files /dev/null and b/packages/fuel-indexer-tests/sway/test-predicate1/out/debug/test-predicate1.bin differ diff --git a/packages/fuel-indexer-tests/sway/test-predicate1/src/main.sw b/packages/fuel-indexer-tests/sway/test-predicate1/src/main.sw new file mode 100644 index 000000000..5e268293e --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate1/src/main.sw @@ -0,0 +1,31 @@ +predicate; + +#[allow(dead_code)] +enum Predicate1SimpleEnum { + VariantOne : (), + VariantTwo : (), +} + +struct Predicate1SimpleStruct { + field_1: u8, + field_2: u64, +} + +configurable { + U8: u8 = 8u8, + BOOL: bool = true, + STRUCT: Predicate1SimpleStruct = Predicate1SimpleStruct { +field_1: 8, +field_2: 16, + }, + ENUM: Predicate1SimpleEnum = Predicate1SimpleEnum::VariantOne, +} + +fn main( + u_8: u8, + switch: bool, + some_struct: Predicate1SimpleStruct, + some_enum: Predicate1SimpleEnum, +) -> bool { + u_8 == U8 && switch == BOOL +} diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/.gitignore b/packages/fuel-indexer-tests/sway/test-predicate2/.gitignore new file mode 100644 index 000000000..77d3844f5 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate2/.gitignore @@ -0,0 +1,2 @@ +out +target diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/Forc.lock b/packages/fuel-indexer-tests/sway/test-predicate2/Forc.lock new file mode 100644 index 000000000..db0afd428 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate2/Forc.lock @@ -0,0 +1,13 @@ +[[package]] +name = "core" +source = "path+from-root-BD9159206068AEC6" + +[[package]] +name = "std" +source = "git+https://github.com/fuellabs/sway?tag=v0.46.1#512a3386f8961185188302f391ccc96553d23a7a" +dependencies = ["core"] + +[[package]] +name = "test-predicate2" +source = "member" +dependencies = ["std"] diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/Forc.toml b/packages/fuel-indexer-tests/sway/test-predicate2/Forc.toml new file mode 100644 index 000000000..abfb6800e --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate2/Forc.toml @@ -0,0 +1,7 @@ +[project] +authors = ["Rashad Alston"] +entry = "main.sw" +license = "Apache-2.0" +name = "test-predicate2" + +[dependencies] diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-abi.json b/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-abi.json new file mode 100644 index 000000000..03272ec7b --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-abi.json @@ -0,0 +1,117 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "enum Predicate2SimpleEnum", + "components": [ + { + "name": "VariantOne", + "type": 0, + "typeArguments": null + }, + { + "name": "VariantTwo", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "struct Predicate2SimpleStruct", + "components": [ + { + "name": "field_1", + "type": 5, + "typeArguments": null + }, + { + "name": "field_2", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "u64", + "components": null, + "typeParameters": null + }, + { + "typeId": 5, + "type": "u8", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "u_8", + "type": 5, + "typeArguments": null + }, + { + "name": "switch", + "type": 1, + "typeArguments": null + }, + { + "name": "some_struct", + "type": 3, + "typeArguments": null + }, + { + "name": "some_enum", + "type": 2, + "typeArguments": null + } + ], + "name": "main", + "output": { + "name": "", + "type": 1, + "typeArguments": null + }, + "attributes": null + } + ], + "loggedTypes": [], + "messagesTypes": [], + "configurables": [ + { + "name": "U8", + "configurableType": { + "name": "", + "type": 5, + "typeArguments": null + }, + "offset": 124 + }, + { + "name": "BOOL", + "configurableType": { + "name": "", + "type": 1, + "typeArguments": null + }, + "offset": 132 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-bin-root b/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-bin-root new file mode 100644 index 000000000..41ae03b7b --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2-bin-root @@ -0,0 +1 @@ +0x048029a18e3254862e2d4108fc9a9dcdcd2f71e0c6e37dad8f1b513845c8e685 \ No newline at end of file diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2.bin b/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2.bin new file mode 100644 index 000000000..588bcfa96 Binary files /dev/null and b/packages/fuel-indexer-tests/sway/test-predicate2/out/debug/test-predicate2.bin differ diff --git a/packages/fuel-indexer-tests/sway/test-predicate2/src/main.sw b/packages/fuel-indexer-tests/sway/test-predicate2/src/main.sw new file mode 100644 index 000000000..11040f327 --- /dev/null +++ b/packages/fuel-indexer-tests/sway/test-predicate2/src/main.sw @@ -0,0 +1,31 @@ +predicate; + +#[allow(dead_code)] +enum Predicate2SimpleEnum { + VariantOne : (), + VariantTwo : (), +} + +struct Predicate2SimpleStruct { + field_1: u8, + field_2: u64, +} + +configurable { + U8: u8 = 8u8, + BOOL: bool = true, + STRUCT: Predicate2SimpleStruct = Predicate2SimpleStruct { +field_1: 8, +field_2: 16, + }, + ENUM: Predicate2SimpleEnum = Predicate2SimpleEnum::VariantOne, +} + +fn main( + u_8: u8, + switch: bool, + some_struct: Predicate2SimpleStruct, + some_enum: Predicate2SimpleEnum, +) -> bool { + u_8 == U8 && switch == BOOL +} diff --git a/packages/fuel-indexer-tests/tests/indexing.rs b/packages/fuel-indexer-tests/tests/indexing.rs index e506a5a07..64bf90b13 100644 --- a/packages/fuel-indexer-tests/tests/indexing.rs +++ b/packages/fuel-indexer-tests/tests/indexing.rs @@ -10,7 +10,7 @@ use std::{collections::HashSet, str::FromStr}; const REVERT_VM_CODE: u64 = 0x0004; const EXPECTED_CONTRACT_ID: &str = - "9487238a4496230a82ce8d69b5d3db74e9afcf05138135d2c3198bcdb8ddc0d9"; + "c34d5389809280d8fd182f96fbd5f9cafad81eb95bc239e46af274a1c69cd37f"; const TRANSFER_BASE_ASSET_ID: &str = "0000000000000000000000000000000000000000000000000000000000000000"; diff --git a/packages/fuel-indexer-tests/tests/trybuild.rs b/packages/fuel-indexer-tests/tests/trybuild.rs index b4de3484b..26517aa79 100644 --- a/packages/fuel-indexer-tests/tests/trybuild.rs +++ b/packages/fuel-indexer-tests/tests/trybuild.rs @@ -53,7 +53,7 @@ fn test_success_and_failure_macros() { r#" namespace: test_namespace identifier: simple_wasm_executor -abi: {tests_root_str}/contracts/simple-wasm/out/debug/contracts-abi.json +contract_abi: {tests_root_str}/sway/simple-wasm/out/debug/contracts-abi.json graphql_schema: {tests_root_str}/indexers/simple-wasm/schema/simple_wasm.graphql contract_id: ~ module: @@ -73,14 +73,14 @@ module: TestKind::Fail, format!( r#" - namespace: test_namespace - identifier: simple_wasm_executor - abi: {tests_root_str}/contracts/simple-wasm/out/debug/contracts-abi.json - # This schema file doesn't actually exist - graphql_schema: schema.graphql - contract_id: ~ - module: - wasm: {project_root_str}/target/wasm32-unknown-unknown/release/simple_wasm.wasm"# +namespace: test_namespace +identifier: simple_wasm_executor +contract_abi: {tests_root_str}/sway/simple-wasm/out/debug/contracts-abi.json +# This schema file doesn't actually exist +graphql_schema: schema.graphql +contract_id: ~ +module: + wasm: {project_root_str}/target/wasm32-unknown-unknown/release/simple_wasm.wasm"# ), ), ( diff --git a/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml b/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml index 767984310..155db2bd3 100644 --- a/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml +++ b/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml @@ -3,6 +3,6 @@ namespace: test_namespace identifier: simple_wasm_executor abi: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/trybuild/abi/contracts-abi-reserved-name.json graphql_schema: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/indexers/simple-wasm/schema/simple_wasm.graphql -contract_id: ~ +contract_subscriptions: ~ module: wasm: /Users/rashad/dev/repos/fuel-indexer/target/wasm32-unknown-unknown/release/simple_wasm.wasm \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/invalid_schema_simple_wasm.yaml b/packages/fuel-indexer-tests/trybuild/invalid_schema_simple_wasm.yaml index 93680770e..336e9e806 100644 --- a/packages/fuel-indexer-tests/trybuild/invalid_schema_simple_wasm.yaml +++ b/packages/fuel-indexer-tests/trybuild/invalid_schema_simple_wasm.yaml @@ -4,6 +4,6 @@ abi: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi.json # This schema file doesn't actually exist graphql_schema: schema.graphql - contract_id: ~ + contract_subscriptions: ~ module: wasm: /Users/rashad/dev/repos/fuel-indexer/target/wasm32-unknown-unknown/release/simple_wasm.wasm \ No newline at end of file diff --git a/packages/fuel-indexer-types/Cargo.toml b/packages/fuel-indexer-types/Cargo.toml index 4a4eabe8e..ded6d4623 100644 --- a/packages/fuel-indexer-types/Cargo.toml +++ b/packages/fuel-indexer-types/Cargo.toml @@ -10,6 +10,8 @@ rust-version = { workspace = true } description = "Fuel Indexer Types" [dependencies] +async-trait = { version = "0.1" } +bincode = { workspace = true } bytes = { version = "1.4", features = ["serde"] } fuel-tx = { workspace = true, features = ["serde"] } fuel-types = { workspace = true } diff --git a/packages/fuel-indexer-types/src/fuel.rs b/packages/fuel-indexer-types/src/fuel.rs index fb4738371..1921f4667 100644 --- a/packages/fuel-indexer-types/src/fuel.rs +++ b/packages/fuel-indexer-types/src/fuel.rs @@ -71,14 +71,14 @@ impl From for Json { fn from(metadata: CommonMetadata) -> Self { let s = serde_json::to_string(&metadata) .expect("Failed to serialize CommonMetadata."); - Self(s) + Self::new(s) } } impl From for CommonMetadata { fn from(json: Json) -> Self { - let metadata: CommonMetadata = - serde_json::from_str(&json.0).expect("Failed to deserialize CommonMetadata."); + let metadata: CommonMetadata = serde_json::from_str(&json.into_inner()) + .expect("Failed to deserialize CommonMetadata."); metadata } } @@ -107,14 +107,14 @@ impl From for Json { fn from(metadata: ScriptMetadata) -> Self { let s = serde_json::to_string(&metadata) .expect("Failed to deserialize MintMetadata."); - Self(s) + Self::new(s) } } impl From for ScriptMetadata { fn from(json: Json) -> Self { - let metadata: ScriptMetadata = - serde_json::from_str(&json.0).expect("Failed to deserialize ScriptMetadata."); + let metadata: ScriptMetadata = serde_json::from_str(&json.into_inner()) + .expect("Failed to deserialize ScriptMetadata."); metadata } } @@ -137,14 +137,14 @@ impl From for Json { fn from(metadata: MintMetadata) -> Self { let s = serde_json::to_string(&metadata).expect("Failed to serialize MintMetadata."); - Self(s) + Self::new(s) } } impl From for MintMetadata { fn from(json: Json) -> Self { - let metadata: MintMetadata = - serde_json::from_str(&json.0).expect("Failed to deserialize MintMetadata."); + let metadata: MintMetadata = serde_json::from_str(&json.into_inner()) + .expect("Failed to deserialize MintMetadata."); metadata } } @@ -215,8 +215,8 @@ impl From for Input { nonce: message_signed.nonce, witness_index: message_signed.witness_index, data: message_signed.data, - predicate: "".into(), - predicate_data: "".into(), + predicate: Bytes::new(), + predicate_data: Bytes::new(), }) } ClientInput::MessageDataPredicate(message_predicate) => { @@ -241,8 +241,8 @@ impl From for Input { tx_pointer: coin_signed.tx_pointer.into(), witness_index: coin_signed.witness_index, maturity: coin_signed.maturity, - predicate: "".into(), - predicate_data: "".into(), + predicate: Bytes::new(), + predicate_data: Bytes::new(), }), ClientInput::CoinPredicate(coin_predicate) => Input::Coin(InputCoin { utxo_id: coin_predicate.utxo_id, @@ -269,9 +269,9 @@ impl From for Input { amount: message_coin.amount, nonce: message_coin.nonce, witness_index: message_coin.witness_index, - data: "".into(), - predicate: "".into(), - predicate_data: "".into(), + data: Bytes::new(), + predicate: Bytes::new(), + predicate_data: Bytes::new(), }) } ClientInput::MessageCoinPredicate(message_coin) => { @@ -281,7 +281,7 @@ impl From for Input { amount: message_coin.amount, nonce: message_coin.nonce, witness_index: 0, - data: "".into(), + data: Bytes::new(), predicate: message_coin.predicate, predicate_data: message_coin.predicate_data, }) @@ -530,14 +530,14 @@ pub struct ProgramState { impl From for Json { fn from(state: ProgramState) -> Self { let s = serde_json::to_string(&state).expect("Failed to serialize ProgramState."); - Self(s) + Self::new(s) } } impl From for ProgramState { fn from(json: Json) -> Self { - let state: ProgramState = - serde_json::from_str(&json.0).expect("Failed to deserialize ProgramState."); + let state: ProgramState = serde_json::from_str(&json.into_inner()) + .expect("Failed to deserialize ProgramState."); state } } diff --git a/packages/fuel-indexer-types/src/graphql.rs b/packages/fuel-indexer-types/src/graphql.rs deleted file mode 100644 index 86b852ecd..000000000 --- a/packages/fuel-indexer-types/src/graphql.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::scalar::ID; -use serde::{Deserialize, Serialize}; - -/// Native GraphQL `TypeDefinition` used to keep track of chain metadata. -#[derive(Serialize, Deserialize, Clone, Debug)] -pub struct IndexMetadata { - /// Metadata identifier. - pub id: ID, - - /// Time of metadata. - pub time: u64, - - /// Block height of metadata. - pub block_height: u32, - - /// Block ID of metadata. - pub block_id: String, -} - -impl IndexMetadata { - /// Return the GraphQL schema fragment for the `IndexMetadata` type. - /// - /// The structure of this fragment should always match `fuel_indexer_types::IndexMetadata`. - pub fn schema_fragment() -> &'static str { - r#" - -type IndexMetadataEntity @entity { - id: ID! - time: U64! - block_height: U32! - block_id: Bytes32! -} -"# - } -} diff --git a/packages/fuel-indexer-types/src/lib.rs b/packages/fuel-indexer-types/src/lib.rs index eb4c6a491..21bb72e2d 100644 --- a/packages/fuel-indexer-types/src/lib.rs +++ b/packages/fuel-indexer-types/src/lib.rs @@ -1,6 +1,6 @@ pub mod ffi; pub mod fuel; -pub mod graphql; +pub mod native; pub mod receipt; pub mod scalar; @@ -23,7 +23,7 @@ pub trait TypeId { pub mod prelude { pub use crate::ffi::*; pub use crate::fuel; - pub use crate::graphql::*; + pub use crate::native::*; pub use crate::receipt::*; pub use crate::scalar::*; pub use crate::{ diff --git a/packages/fuel-indexer-types/src/native.rs b/packages/fuel-indexer-types/src/native.rs new file mode 100644 index 000000000..417e699b3 --- /dev/null +++ b/packages/fuel-indexer-types/src/native.rs @@ -0,0 +1,247 @@ +use crate::{ + fuel::{CoinOutput, Output, Witness}, + scalar::{Address, Bytes32, ID}, + type_id, TypeId, FUEL_TYPES_NAMESPACE, +}; +use fuels::accounts::predicate::Predicate; +use serde::{Deserialize, Serialize}; + +pub trait GraphQLEntity { + /// Return the GraphQL schema fragment for the entity. + fn schema_fragment() -> &'static str; +} + +/// Native GraphQL `TypeDefinition` used to keep track of chain metadata. +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct IndexMetadata { + /// Metadata identifier. + pub id: ID, + + /// Time of metadata. + pub time: u64, + + /// Block height of metadata. + pub block_height: u32, + + /// Block ID of metadata. + pub block_id: String, +} + +impl GraphQLEntity for IndexMetadata { + /// Return the GraphQL schema fragment for the `IndexMetadata` type. + /// + /// The structure of this fragment should always match `fuel_indexer_types::IndexMetadata`. + fn schema_fragment() -> &'static str { + r#" + +type IndexMetadataEntity @entity { + id: ID! + time: U64! + block_height: U32! + block_id: Bytes32! +} +"# + } +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct PredicateWitnessData { + /// Hash of associated predicate bytecode + template_id: Bytes32, + + /// Configurable constants in predicates. + output_index: u64, + + /// Configurables passed to predicate. + configurables: Vec, +} + +impl PredicateWitnessData { + pub fn template_id(&self) -> &Bytes32 { + &self.template_id + } + + pub fn output_index(&self) -> u64 { + self.output_index + } + + pub fn configurables(&self) -> &Vec { + &self.configurables + } +} +impl TryFrom for PredicateWitnessData { + type Error = bincode::Error; + /// Convert from `Witness` to `PredicateWitnessData`. + fn try_from(witness: Witness) -> Result { + let data: Vec = witness.into_inner(); + bincode::deserialize(&data) + } +} + +/// Standardized `Witness` data format for predicates. +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct IndexerPredicate { + /// Hash of associated predicate bytecode + template_id: Bytes32, + + /// Configurable constants in predicates. + configurables: Vec, + + /// Relevant TX output indices of predicates that need to be watched. + output_index: u64, + + /// UTXO held by predicate. + coin_output: CoinOutput, + + /// ID of transaction in which predicate was created. + unspent_tx_id: Bytes32, + + /// ID of transaction in which predicate was spent. + spent_tx_id: Option, +} + +impl IndexerPredicate { + /// Create a new `IndexerPredicate`. + pub fn from_entity( + output_index: u64, + configurables: Vec, + template_id: Bytes32, + coin_output: Vec, + unspent_tx_id: Bytes32, + spent_tx_id: Option, + ) -> Self { + let coin_output: CoinOutput = bincode::deserialize(&coin_output) + .expect("Could not deserialize coin output."); + Self { + template_id, + configurables, + output_index, + coin_output, + unspent_tx_id, + spent_tx_id, + } + } + + /// Get the predicate bytecode hash. + pub fn template_id(&self) -> &Bytes32 { + &self.template_id + } + + /// Get the configuration schema of the predicate. + pub fn configurables(&self) -> &Vec { + &self.configurables + } + + /// Get the predicate data output index. + pub fn output_index(&self) -> u64 { + self.output_index + } + + /// Get the UTXO held by the predicate. + pub fn coin_output(&self) -> &CoinOutput { + &self.coin_output + } + + /// Get the output transaction ID of the predicate. + pub fn unspent_tx_id(&self) -> &Bytes32 { + &self.unspent_tx_id + } + + /// Get the output transaction ID of the predicate. + pub fn spent_tx_id(&self) -> &Option { + &self.spent_tx_id + } + + pub fn from_signaled_witness_data( + data: PredicateWitnessData, + tx_id: Bytes32, + output: Output, + ) -> Self { + let coin_output = match output { + Output::CoinOutput(coin_output) => coin_output, + _ => todo!(), + }; + + let PredicateWitnessData { + template_id, + output_index, + configurables, + } = data; + + Self { + template_id, + configurables, + output_index, + coin_output, + unspent_tx_id: tx_id, + spent_tx_id: None, + } + } +} + +impl TypeId for IndexerPredicate { + /// Return the type ID for `IndexerPredicate`. + fn type_id() -> usize { + type_id(FUEL_TYPES_NAMESPACE, "IndexerPredicate") as usize + } +} + +impl GraphQLEntity for IndexerPredicate { + /// Return the GraphQL schema fragment for the `IndexerPredicate` type. + /// + /// The structure of this fragment should always match `fuel_indexer_types::Predicate`. + fn schema_fragment() -> &'static str { + r#" + type PredicateEntity @entity { + id: ID! + configurables: Bytes! + template_id: Bytes32! + output_index: U64! + coin_output: Bytes! + unspent_tx_id: Bytes32! + spent_tx_id: Bytes32 + } + "# + } +} + +// Copied over from the SDK +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct FooPredicate { + // Using simple `Address` because `Bech32Address` is not serializable + address: Address, + code: Vec, + // Using simple `Vec because `UnresolvedBytes` is not serializable + data: Vec, + chain_id: u64, +} + +impl From for FooPredicate { + fn from(predicate: Predicate) -> Self { + Self { + address: predicate.address().into(), + code: predicate.code().to_vec(), + data: predicate.data().clone().resolve(0), + // FIXME: Hardcoding beta-4 until SDK fix is out + chain_id: 0, + } + } +} + +impl FooPredicate { + pub fn address(&self) -> &Address { + &self.address + } + + pub fn code(&self) -> &[u8] { + &self.code + } + + pub fn data(&self) -> &[u8] { + &self.data + } + + pub fn chain_id(&self) -> u64 { + self.chain_id + } +} diff --git a/packages/fuel-indexer-types/src/scalar.rs b/packages/fuel-indexer-types/src/scalar.rs index 5e8bf7fc0..91bcca9b4 100644 --- a/packages/fuel-indexer-types/src/scalar.rs +++ b/packages/fuel-indexer-types/src/scalar.rs @@ -46,7 +46,23 @@ pub type Bytes = Vec; /// JSON type used to store arbitrary object payloads. #[derive(Deserialize, Serialize, Clone, Eq, PartialEq, Debug, Hash)] -pub struct Json(pub String); +pub struct Json(String); + +impl Json { + pub fn into_inner(self) -> String { + self.0 + } + + pub fn new(s: String) -> Self { + Json(s) + } +} + +impl AsRef for Json { + fn as_ref(&self) -> &str { + self.0.as_ref() + } +} impl Default for Json { fn default() -> Self { diff --git a/packages/fuel-indexer-utils/src/lib.rs b/packages/fuel-indexer-utils/src/lib.rs index e71bab145..3e28bc4d3 100644 --- a/packages/fuel-indexer-utils/src/lib.rs +++ b/packages/fuel-indexer-utils/src/lib.rs @@ -17,7 +17,7 @@ pub use utilities::*; /// Prelude for Fuel indexers. pub mod prelude { pub use crate::utilities::*; - pub use fuel_indexer_macros::indexer; + pub use fuel_indexer_macros::{indexer, predicate}; pub use fuel_indexer_plugin::prelude::*; } diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index 7807e2277..1160df36f 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -58,12 +58,17 @@ pub fn default_indexer_manifest( # as an organization identifier namespace: {namespace} -# The identifier field is used to identify the given index. +# Unique identifier for this indexer. identifier: {indexer_name} -# The abi option is used to provide a link to the Sway JSON ABI that is generated when you -# build your project. -abi: ~ +# Indexer contract configuration. +contract: ~ + + # File paths to the contract JSON ABIs that are generated when you build your Sway contracts. + abis: ~ + + # Specifies which particular contracts you would like your indexer to subscribe to. + subscriptions: ~ # The particular start block after which you'd like your indexer to start indexing events. start_block: ~ @@ -77,11 +82,7 @@ end_block: ~ # with the `--indexer_net_config` option. fuel_client: ~ -# The contract_id specifies which particular contract you would like your index to subscribe to. -contract_id: ~ - -# The graphql_schema field contains the file path that points to the GraphQL schema for the -# given index. +# A file path that points to the GraphQL schema for the given indexer. graphql_schema: {schema_path} # The module field contains a file path that points to code that will be run as an executor inside @@ -92,6 +93,12 @@ module: # The resumable field contains a boolean that specifies whether or not the indexer should, synchronise # with the latest block if it has fallen out of sync. resumable: true + +# Indexer predicate configuration. +predicates: + + # Template commitments (hashes) of the bytecode of predicates used by this indexer. + templates: ~ "# ) } diff --git a/plugins/forc-postgres/src/pg.rs b/plugins/forc-postgres/src/pg.rs index 8f0e4f384..8ea502775 100644 --- a/plugins/forc-postgres/src/pg.rs +++ b/plugins/forc-postgres/src/pg.rs @@ -130,7 +130,7 @@ impl PostgresVersion { "v11" => Self::V11, "v10" => Self::V10, "v9" => Self::V9, - _ => unimplemented!(), + _ => unimplemented!("Postgres version unimplemented."), } } } diff --git a/scripts/utils/README.md b/scripts/utils/README.md deleted file mode 100644 index a664edf96..000000000 --- a/scripts/utils/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# scripts/utils - -General utilty scripts used to improve devx - -```text -. -├── README.md -├── build_test_wasm_module.bash -├── kill_test_components.bash -├── refresh_test_db.bash -└── start_test_components.bash - -0 directories, 5 files -``` - -- build_test_wasm_module - - Build the default `fuel-indexer-test` WASM module and add it to `fuel-indexer-tests/assets` -- kill_test_components - - Kill all processes for test components (Fuel node, Web API) -- refresh_test_db - - Drop the default testing database, recreate it, and run migrations -- start_test_components - - Start all testing components (Fuel node, Web API)