From 2ef18cfde866b956c311b46936ac73fe4d5d5153 Mon Sep 17 00:00:00 2001 From: hal3e Date: Tue, 19 Nov 2024 08:55:09 +0100 Subject: [PATCH] feat: handle `Unknown` transactions, blocks and consensus parameters (#2154) ## Linked Issues/PRs https://github.com/FuelLabs/fuels-rs/issues/1477 ## Description Refactored code to handle `Unknown` transaction types, `ConsensusParameters` and `Blocks`. For transactions I have craeted a new `TransactionType` that we can `try_into` the `fuel_tx::Transaction`. For `ConsesnsuParameters` and `Block` I have used `cynic's` `fallback` attrbute and added a `Unknown` variant for all `Version` enums. I had to bump `cynic` to `3.1.0` and `reqwest` to `0.12.0` to use the `fallback` attribute on enums. BREAKING CHANGES: `graphql` endpoints for transactions use the new `TransactionType` type instead of `fuel_tx::Transaction` --- CHANGELOG.md | 6 + Cargo.lock | 515 +++++++++++++----- Cargo.toml | 4 +- crates/client/src/client.rs | 47 +- crates/client/src/client/schema/block.rs | 11 +- crates/client/src/client/schema/chain.rs | 25 + crates/client/src/client/schema/gas_price.rs | 5 +- ...ance__tests__balance_query_gql_output.snap | 4 +- ..._balances_connection_query_gql_output.snap | 4 +- ...sts__block_by_height_query_gql_output.snap | 2 +- ...__tests__block_by_id_query_gql_output.snap | 2 +- ...ests__block_mutation_query_gql_output.snap | 4 +- ...s__blocks_connection_query_gql_output.snap | 2 +- ..._chain__tests__chain_gql_query_output.snap | 2 +- ...s__tests__coin_by_id_query_gql_output.snap | 2 +- ...ts__coins_connection_query_gql_output.snap | 2 +- ...ests__contract_by_id_query_gql_output.snap | 4 +- ...sts__block_by_height_query_gql_output.snap | 2 +- ...__estimate_gas_price_query_gql_output.snap | 4 +- ...ts__latest_gas_price_query_gql_output.snap | 4 +- ...tests__owned_message_query_gql_output.snap | 4 +- ...fo__tests__node_info_query_gql_output.snap | 4 +- ...o__tests__peers_info_query_gql_output.snap | 4 +- ...ema__tx__tests__dry_run_tx_gql_output.snap | 2 +- ...ue_transaction_by_id_query_gql_output.snap | 2 +- ...hema__tx__tests__submit_tx_gql_output.snap | 4 +- ...sts__transactions_by_owner_gql_output.snap | 2 +- ...nsactions_connection_query_gql_output.snap | 2 +- ...nt_transaction_by_id_query_gql_output.snap | 2 +- crates/client/src/client/schema/tx.rs | 8 +- .../src/client/schema/tx/transparent_tx.rs | 4 +- crates/client/src/client/types.rs | 33 +- crates/client/src/client/types/block.rs | 2 + tests/tests/blocks.rs | 1 + tests/tests/tx.rs | 86 ++- tests/tests/tx/predicates.rs | 6 +- tests/tests/tx/tx_pointer.rs | 26 +- tests/tests/tx/utxo_validation.rs | 6 +- 38 files changed, 595 insertions(+), 254 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 605085fca4c..bf175fbf613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Added `Unknown` variant to `ConsensusParameters` graphql queries +- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Added `Unknown` variant to `Block` graphql queries +- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Added `TransactionType` type in `fuel-client` - [2321](https://github.com/FuelLabs/fuel-core/pull/2321): New metrics for the TxPool: - The size of transactions in the txpool (`txpool_tx_size`) - The time spent by a transaction in the txpool in seconds (`txpool_tx_time_in_txpool_seconds`) @@ -37,6 +40,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). #### Breaking - [2389](https://github.com/FuelLabs/fuel-core/pull/2258): Updated the `messageProof` GraphQL schema to return a non-nullable `MessageProof`. +#### Breaking +- [2154](https://github.com/FuelLabs/fuel-core/pull/2154): Transaction graphql endpoints use `TransactionType` instead of `fuel_tx::Transaction`. + ## [Version 0.40.0] ### Added diff --git a/Cargo.lock b/Cargo.lock index 1903c106fde..5cd13642f4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,6 +91,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "allocator-api2" version = "0.2.20" @@ -191,12 +197,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "ascii" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" - [[package]] name = "ascii-canvas" version = "3.0.0" @@ -377,7 +377,7 @@ checksum = "a94c2d176893486bd37cd1b6defadd999f7357bf5804e92f510c08bcf16c538f" dependencies = [ "Inflector", "async-graphql-parser", - "darling 0.20.10", + "darling", "proc-macro-crate", "proc-macro2", "quote", @@ -917,8 +917,8 @@ dependencies = [ "http-body 0.4.6", "http-body 1.0.1", "httparse", - "hyper", - "hyper-rustls", + "hyper 0.14.31", + "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", @@ -1006,7 +1006,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper", + "hyper 0.14.31", "itoa", "matchit", "memchr", @@ -1016,7 +1016,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "tokio", "tower", "tower-http 0.3.5", @@ -1108,6 +1108,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + [[package]] name = "bindgen" version = "0.65.1" @@ -1589,19 +1595,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" -[[package]] -name = "combine" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" -dependencies = [ - "ascii", - "byteorder", - "either", - "memchr", - "unreachable", -] - [[package]] name = "concurrent-queue" version = "2.5.0" @@ -1697,9 +1690,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" dependencies = [ "percent-encoding", "time", @@ -1708,12 +1701,13 @@ dependencies = [ [[package]] name = "cookie_store" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387461abbc748185c3a6e1673d826918b450b87ff22639429c694619a83b6cf6" +checksum = "2eac901828f88a5241ee0600950ab981148a18f2f756900ffba1b125ca6a3ef9" dependencies = [ "cookie", - "idna 0.3.0", + "document-features", + "idna 1.0.3", "log", "publicsuffix", "serde", @@ -1748,15 +1742,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "counter" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d458e66999348f56fd3ffcfbb7f7951542075ca8359687c703de6500c1ddccd" -dependencies = [ - "num-traits", -] - [[package]] name = "cpp_demangle" version = "0.4.4" @@ -2106,12 +2091,13 @@ dependencies = [ [[package]] name = "cynic" -version = "2.2.8" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1afa0591b1021e427e548a1f0f147fe6168f6c7c7f7006bace77f28856051b8" +checksum = "9a41762e03383d7bf4213b9b4e5fb15e232853400b0b738b764d1d2df9649400" dependencies = [ "cynic-proc-macros", - "reqwest", + "ref-cast", + "reqwest 0.12.9", "serde", "serde_json", "static_assertions", @@ -2120,38 +2106,42 @@ dependencies = [ [[package]] name = "cynic-codegen" -version = "2.2.8" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a1bb05cc554f46079d0fa72abe995a2d32d0737d410a41da75b31e3f7ef768" +checksum = "3b9e35b6ceec97e397c422585aa7d8c057158c63d2727f15d4ddc47563862798" dependencies = [ - "counter", - "darling 0.13.4", - "graphql-parser", + "cynic-parser", + "darling", "once_cell", + "ouroboros", "proc-macro2", "quote", "strsim 0.10.0", - "syn 1.0.109", + "syn 2.0.87", + "thiserror 1.0.69", ] [[package]] -name = "cynic-proc-macros" -version = "2.2.8" +name = "cynic-parser" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa595c4ed7a5374e0e58c5c34f9d93bd6b7d45062790963bd4b4c3c0bf520c4d" +checksum = "791001e353ca2b167bd9e3c7c10635440893a6e0fd3c75bd9da700e373c6b0d5" dependencies = [ - "cynic-codegen", - "syn 1.0.109", + "indexmap 2.6.0", + "lalrpop-util 0.22.0", + "logos", ] [[package]] -name = "darling" -version = "0.13.4" +name = "cynic-proc-macros" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +checksum = "beb9f1756c97b93a7e2faf9c5d58cc21655de6a32984dd8aa7aa076c7e246601" dependencies = [ - "darling_core 0.13.4", - "darling_macro 0.13.4", + "cynic-codegen", + "darling", + "quote", + "syn 2.0.87", ] [[package]] @@ -2160,22 +2150,8 @@ version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.10", - "darling_macro 0.20.10", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", + "darling_core", + "darling_macro", ] [[package]] @@ -2192,24 +2168,13 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core 0.13.4", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.10", + "darling_core", "quote", "syn 2.0.87", ] @@ -2449,6 +2414,15 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "document-features" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +dependencies = [ + "litrs", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -2772,7 +2746,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "syn 2.0.87", @@ -2834,7 +2808,7 @@ checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" dependencies = [ "chrono", "ethers-core", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_json", @@ -2859,7 +2833,7 @@ dependencies = [ "futures-locks", "futures-util", "instant", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "thiserror 1.0.69", @@ -2892,7 +2866,7 @@ dependencies = [ "jsonwebtoken", "once_cell", "pin-project", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "thiserror 1.0.69", @@ -3009,8 +2983,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43ddc25e1ad2cc0106d5e2d967397b4fb2068a66677ee9b0eea4600e5cfe8fb4" dependencies = [ "futures", - "hyper", - "hyper-rustls", + "hyper 0.14.31", + "hyper-rustls 0.24.2", "hyper-timeout", "log", "pin-project", @@ -3221,7 +3195,7 @@ dependencies = [ "fuel-core-upgradable-executor", "futures", "hex", - "hyper", + "hyper 0.14.31", "indicatif", "itertools 0.12.1", "mockall", @@ -3366,10 +3340,10 @@ dependencies = [ "fuel-core-types 0.40.0", "futures", "hex", - "hyper-rustls", + "hyper-rustls 0.24.2", "insta", "itertools 0.12.1", - "reqwest", + "reqwest 0.12.9", "schemafy_lib", "serde", "serde_json", @@ -3482,7 +3456,7 @@ dependencies = [ "futures", "num_enum", "parking_lot", - "reqwest", + "reqwest 0.12.9", "serde", "strum 0.25.0", "strum_macros 0.25.3", @@ -3754,7 +3728,7 @@ dependencies = [ "fuel-core-upgradable-executor", "futures", "hex", - "hyper", + "hyper 0.14.31", "insta", "itertools 0.12.1", "k256", @@ -3763,7 +3737,7 @@ dependencies = [ "primitive-types", "proptest", "rand", - "reqwest", + "reqwest 0.12.9", "rstest", "serde_json", "spki", @@ -4386,16 +4360,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "graphql-parser" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ebc8013b4426d5b81a4364c419a95ed0b404af2b82e2457de52d9348f0e474" -dependencies = [ - "combine", - "thiserror 1.0.69", -] - [[package]] name = "group" version = "0.13.0" @@ -4772,6 +4736,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -4780,13 +4763,31 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper", + "hyper 0.14.31", "log", "rustls 0.21.12", "rustls-native-certs", "tokio", - "tokio-rustls", - "webpki-roots", + "tokio-rustls 0.24.1", + "webpki-roots 0.25.4", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.5.0", + "hyper-util", + "rustls 0.23.17", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "webpki-roots 0.26.6", ] [[package]] @@ -4795,12 +4796,31 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.31", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.5.0", + "pin-project-lite", + "socket2 0.5.7", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.61" @@ -4954,16 +4974,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.4.0" @@ -5036,7 +5046,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper", + "hyper 0.14.31", "log", "rand", "tokio", @@ -5348,7 +5358,7 @@ dependencies = [ "bit-set", "ena", "itertools 0.11.0", - "lalrpop-util", + "lalrpop-util 0.20.2", "petgraph", "regex", "regex-syntax 0.8.5", @@ -5368,6 +5378,15 @@ dependencies = [ "regex-automata 0.4.9", ] +[[package]] +name = "lalrpop-util" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feee752d43abd0f4807a921958ab4131f692a44d4d599733d4419c5d586176ce" +dependencies = [ + "rustversion", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -5906,7 +5925,7 @@ dependencies = [ "thiserror 1.0.69", "tracing", "url", - "webpki-roots", + "webpki-roots 0.25.4", ] [[package]] @@ -6055,6 +6074,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "lock_api" version = "0.4.12" @@ -6074,6 +6099,39 @@ dependencies = [ "value-bag", ] +[[package]] +name = "logos" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c6b6e02facda28ca5fb8dbe4b152496ba3b1bd5a4b40bb2b1b2d8ad74e0f39b" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-codegen" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32eb6b5f26efacd015b000bfc562186472cd9b34bdba3f6b264e2a052676d10" +dependencies = [ + "beef", + "fnv", + "lazy_static", + "proc-macro2", + "quote", + "regex-syntax 0.8.5", + "syn 2.0.87", +] + +[[package]] +name = "logos-derive" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e5d0c5463c911ef55624739fc353238b4e310f0144be1f875dc42fec6bfd5ec" +dependencies = [ + "logos-codegen", +] + [[package]] name = "lru" version = "0.12.5" @@ -6671,6 +6729,31 @@ version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +[[package]] +name = "ouroboros" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944fa20996a25aded6b4795c6d63f10014a7a83f8be9828a11860b08c5fc4a67" +dependencies = [ + "aliasable", + "ouroboros_macro", + "static_assertions", +] + +[[package]] +name = "ouroboros_macro" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39b0deead1528fd0e5947a8546a9642a9777c25f6e1e26f34c97b204bbb465bd" +dependencies = [ + "heck 0.4.1", + "itertools 0.12.1", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.87", +] + [[package]] name = "outref" version = "0.5.1" @@ -7275,6 +7358,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "version_check", + "yansi 1.0.1", +] + [[package]] name = "prometheus-client" version = "0.22.3" @@ -7378,7 +7474,7 @@ dependencies = [ "log", "names", "prost", - "reqwest", + "reqwest 0.11.27", "thiserror 1.0.69", "url", "winapi", @@ -7635,6 +7731,26 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "regalloc2" version = "0.9.3" @@ -7706,16 +7822,14 @@ checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", - "cookie", - "cookie_store", "encoding_rs", "futures-core", "futures-util", "h2", "http 0.2.12", "http-body 0.4.6", - "hyper", - "hyper-rustls", + "hyper 0.14.31", + "hyper-rustls 0.24.2", "ipnet", "js-sys", "log", @@ -7724,23 +7838,67 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.12", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", + "webpki-roots 0.25.4", "winreg", ] +[[package]] +name = "reqwest" +version = "0.12.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +dependencies = [ + "base64 0.22.1", + "bytes", + "cookie", + "cookie_store", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.0", + "hyper-rustls 0.27.3", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls 0.23.17", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots 0.26.6", + "windows-registry", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -7990,7 +8148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "schannel", "security-framework", ] @@ -8004,6 +8162,15 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "rustls-pki-types" version = "1.10.0" @@ -8343,7 +8510,7 @@ version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ - "darling 0.20.10", + "darling", "proc-macro2", "quote", "syn 2.0.87", @@ -8587,7 +8754,7 @@ checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" dependencies = [ "itertools 0.11.0", "lalrpop", - "lalrpop-util", + "lalrpop-util 0.20.2", "phf", "thiserror 1.0.69", "unicode-xid", @@ -8772,7 +8939,7 @@ dependencies = [ "fs2", "hex", "once_cell", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_json", @@ -8833,6 +9000,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + [[package]] name = "synstructure" version = "0.13.1" @@ -8989,7 +9165,7 @@ dependencies = [ "futures", "itertools 0.12.1", "rand", - "reqwest", + "reqwest 0.12.9", "tempfile", "tokio", ] @@ -9236,6 +9412,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.17", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.16" @@ -9258,9 +9445,9 @@ dependencies = [ "log", "rustls 0.21.12", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tungstenite", - "webpki-roots", + "webpki-roots 0.25.4", ] [[package]] @@ -9601,15 +9788,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -10101,6 +10279,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "webpki-roots" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "widestring" version = "1.1.0" @@ -10166,6 +10353,36 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index d80bf4f5bdc..0a711e83ad3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ fuel-vm-private = { version = "0.58.2", package = "fuel-vm", default-features = # Common dependencies anyhow = "1.0" async-trait = "0.1" -cynic = { version = "2.2.1", features = ["http-reqwest"] } +cynic = { version = "3.1.0", features = ["http-reqwest"] } clap = "4.4" derivative = { version = "2" } derive_more = { version = "0.99" } @@ -119,7 +119,7 @@ serde_with = { version = "3.4", default-features = false } strum = { version = "0.25" } strum_macros = "0.25" # enable cookie store to support L7 sticky sessions -reqwest = { version = "0.11.16", default-features = false, features = [ +reqwest = { version = "0.12.0", default-features = false, features = [ "rustls-tls", "cookies", ] } diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 1743f631547..6cd9023276f 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -81,10 +81,18 @@ use schema::{ balance::BalanceArgs, blob::BlobByIdArgs, block::BlockByIdArgs, - coins::CoinByIdArgs, - contract::ContractByIdArgs, + coins::{ + CoinByIdArgs, + CoinsConnectionArgs, + }, + contract::{ + ContractBalancesConnectionArgs, + ContractByIdArgs, + }, da_compressed::DaCompressedBlockByHeightArgs, + gas_price::BlockHorizonArgs, tx::{ + TransactionsByOwnerConnectionArgs, TxArg, TxIdArgs, }, @@ -387,7 +395,10 @@ impl FuelClient { &self, block_horizon: u32, ) -> io::Result { - let query = schema::gas_price::QueryEstimateGasPrice::build(block_horizon.into()); + let args = BlockHorizonArgs { + block_horizon: Some(block_horizon.into()), + }; + let query = schema::gas_price::QueryEstimateGasPrice::build(args); self.query(query).await.map(|r| r.estimate_gas_price) } @@ -798,7 +809,8 @@ impl FuelClient { &self, request: PaginationRequest, ) -> io::Result> { - let query = schema::tx::TransactionsQuery::build(request.into()); + let args = schema::ConnectionArgs::from(request); + let query = schema::tx::TransactionsQuery::build(args); let transactions = self.query(query).await?.transactions.try_into()?; Ok(transactions) } @@ -810,7 +822,8 @@ impl FuelClient { request: PaginationRequest, ) -> io::Result> { let owner: schema::Address = (*owner).into(); - let query = schema::tx::TransactionsByOwnerQuery::build((owner, request).into()); + let args = TransactionsByOwnerConnectionArgs::from((owner, request)); + let query = schema::tx::TransactionsByOwnerQuery::build(args); let transactions = self.query(query).await?.transactions_by_owner.try_into()?; Ok(transactions) @@ -945,7 +958,8 @@ impl FuelClient { &self, request: PaginationRequest, ) -> io::Result> { - let query = schema::block::BlocksQuery::build(request.into()); + let args = schema::ConnectionArgs::from(request); + let query = schema::block::BlocksQuery::build(args); let blocks = self.query(query).await?.blocks.try_into()?; @@ -972,7 +986,8 @@ impl FuelClient { Some(asset_id) => (*asset_id).into(), None => schema::AssetId::default(), }; - let query = schema::coins::CoinsQuery::build((owner, asset_id, request).into()); + let args = CoinsConnectionArgs::from((owner, asset_id, request)); + let query = schema::coins::CoinsQuery::build(args); let coins = self.query(query).await?.coins.into(); Ok(coins) @@ -1007,9 +1022,9 @@ impl FuelClient { }, ) .map(Into::into); - let query = schema::coins::CoinsToSpendQuery::build( - (owner, spend_query, excluded_ids).into(), - ); + let args = + schema::coins::CoinsToSpendArgs::from((owner, spend_query, excluded_ids)); + let query = schema::coins::CoinsToSpendQuery::build(args); let coins_per_asset = self .query(query) @@ -1072,7 +1087,8 @@ impl FuelClient { request: PaginationRequest, ) -> io::Result> { let owner: schema::Address = (*owner).into(); - let query = schema::balance::BalancesQuery::build((owner, request).into()); + let args = schema::balance::BalancesConnectionArgs::from((owner, request)); + let query = schema::balance::BalancesQuery::build(args); let balances = self.query(query).await?.balances.into(); Ok(balances) @@ -1084,8 +1100,8 @@ impl FuelClient { request: PaginationRequest, ) -> io::Result> { let contract_id: schema::ContractId = (*contract).into(); - let query = - schema::contract::ContractBalancesQuery::build((contract_id, request).into()); + let args = ContractBalancesConnectionArgs::from((contract_id, request)); + let query = schema::contract::ContractBalancesQuery::build(args); let balances = self.query(query).await?.contract_balances.into(); @@ -1107,7 +1123,8 @@ impl FuelClient { request: PaginationRequest, ) -> io::Result> { let owner: Option = owner.map(|owner| (*owner).into()); - let query = schema::message::OwnedMessageQuery::build((owner, request).into()); + let args = schema::message::OwnedMessagesConnectionArgs::from((owner, request)); + let query = schema::message::OwnedMessageQuery::build(args); let messages = self.query(query).await?.messages.into(); @@ -1181,7 +1198,7 @@ impl FuelClient { pub async fn transparent_transaction( &self, id: &TxId, - ) -> io::Result> { + ) -> io::Result> { let query = schema::tx::TransactionQuery::build(TxIdArgs { id: (*id).into() }); let transaction = self.query(query).await?.transaction; diff --git a/crates/client/src/client/schema/block.rs b/crates/client/src/client/schema/block.rs index e159d44bc9a..b4e7d721963 100644 --- a/crates/client/src/client/schema/block.rs +++ b/crates/client/src/client/schema/block.rs @@ -2,7 +2,7 @@ use super::Bytes32; use crate::client::schema::{ schema, BlockId, - ConnectionArgs, + ConnectionArgsFields, PageInfo, Signature, Tai64Timestamp, @@ -77,6 +77,8 @@ pub struct BlockEdge { #[cynic(schema_path = "./assets/schema.sdl")] pub enum BlockVersion { V1, + #[cynic(fallback)] + Unknown, } /// Block with transaction ids @@ -123,6 +125,8 @@ pub struct BlockMutation { #[cynic(schema_path = "./assets/schema.sdl")] pub enum HeaderVersion { V1, + #[cynic(fallback)] + Unknown, } #[derive(cynic::QueryFragment, Clone, Debug)] @@ -226,12 +230,13 @@ mod tests { #[test] fn blocks_connection_query_gql_output() { use cynic::QueryBuilder; - let operation = BlocksQuery::build(ConnectionArgs { + let args = crate::client::schema::ConnectionArgs { after: None, before: None, first: None, last: None, - }); + }; + let operation = BlocksQuery::build(args); insta::assert_snapshot!(operation.query) } } diff --git a/crates/client/src/client/schema/chain.rs b/crates/client/src/client/schema/chain.rs index 7f76de69d16..31129c74491 100644 --- a/crates/client/src/client/schema/chain.rs +++ b/crates/client/src/client/schema/chain.rs @@ -30,6 +30,8 @@ pub struct ConsensusParameters { #[cynic(schema_path = "./assets/schema.sdl")] pub enum ConsensusParametersVersion { V1, + #[cynic(fallback)] + Unknown, } #[derive(cynic::QueryFragment, Clone, Debug)] @@ -48,6 +50,8 @@ pub struct TxParameters { #[cynic(schema_path = "./assets/schema.sdl")] pub enum TxParametersVersion { V1, + #[cynic(fallback)] + Unknown, } impl TryFrom for fuel_core_types::fuel_tx::TxParameters { @@ -66,6 +70,7 @@ impl TryFrom for fuel_core_types::fuel_tx::TxParameters { } .into(), ), + _ => Err(ConversionError::UnknownVariant("TxParametersVersion")), } } } @@ -84,6 +89,8 @@ pub struct PredicateParameters { #[cynic(schema_path = "./assets/schema.sdl")] pub enum PredicateParametersVersion { V1, + #[cynic(fallback)] + Unknown, } impl TryFrom for fuel_core_types::fuel_tx::PredicateParameters { @@ -100,6 +107,9 @@ impl TryFrom for fuel_core_types::fuel_tx::PredicateParamet } .into(), ), + _ => Err(ConversionError::UnknownVariant( + "PredicateParametersVersion", + )), } } } @@ -116,6 +126,8 @@ pub struct ScriptParameters { #[cynic(schema_path = "./assets/schema.sdl")] pub enum ScriptParametersVersion { V1, + #[cynic(fallback)] + Unknown, } impl TryFrom for fuel_core_types::fuel_tx::ScriptParameters { @@ -130,6 +142,7 @@ impl TryFrom for fuel_core_types::fuel_tx::ScriptParameters { } .into(), ), + _ => Err(ConversionError::UnknownVariant("ScriptParametersVersion")), } } } @@ -146,6 +159,8 @@ pub struct ContractParameters { #[cynic(schema_path = "./assets/schema.sdl")] pub enum ContractParametersVersion { V1, + #[cynic(fallback)] + Unknown, } impl TryFrom for fuel_core_types::fuel_tx::ContractParameters { @@ -160,6 +175,7 @@ impl TryFrom for fuel_core_types::fuel_tx::ContractParameter } .into(), ), + _ => Err(ConversionError::UnknownVariant("ContractParametersVersion")), } } } @@ -176,6 +192,8 @@ pub struct FeeParameters { #[cynic(schema_path = "./assets/schema.sdl")] pub enum FeeParametersVersion { V1, + #[cynic(fallback)] + Unknown, } impl TryFrom for fuel_core_types::fuel_tx::FeeParameters { @@ -190,6 +208,7 @@ impl TryFrom for fuel_core_types::fuel_tx::FeeParameters { } .into(), ), + _ => Err(ConversionError::UnknownVariant("FeeParametersVersion")), } } } @@ -321,6 +340,8 @@ pub struct GasCosts { #[cynic(schema_path = "./assets/schema.sdl")] pub enum GasCostsVersion { V1, + #[cynic(fallback)] + Unknown, } impl TryFrom for fuel_core_types::fuel_tx::GasCosts { @@ -447,6 +468,7 @@ impl TryFrom for fuel_core_types::fuel_tx::GasCosts { } .into(), )), + _ => Err(ConversionError::UnknownVariant("GasCostsVersion")), } } } @@ -497,6 +519,9 @@ impl TryFrom for fuel_core_types::fuel_tx::ConsensusParamet } .into(), ), + _ => Err(ConversionError::UnknownVariant( + "ConsensusParametersVersion", + )), } } } diff --git a/crates/client/src/client/schema/gas_price.rs b/crates/client/src/client/schema/gas_price.rs index 703df3f2801..9be2a7e6020 100644 --- a/crates/client/src/client/schema/gas_price.rs +++ b/crates/client/src/client/schema/gas_price.rs @@ -62,7 +62,10 @@ mod tests { fn estimate_gas_price_query_gql_output() { use cynic::QueryBuilder; let arbitrary_horizon = 10; - let operation = QueryEstimateGasPrice::build(arbitrary_horizon.into()); + let args = BlockHorizonArgs { + block_horizon: Some(arbitrary_horizon.into()), + }; + let operation = QueryEstimateGasPrice::build(args); insta::assert_snapshot!(operation.query) } } diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balance_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balance_query_gql_output.snap index 14d5a632868..6c2a7609657 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balance_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balance_query_gql_output.snap @@ -2,12 +2,10 @@ source: crates/client/src/client/schema/balance.rs expression: operation.query --- -query($owner: Address!, $assetId: AssetId!) { +query BalanceQuery($owner: Address!, $assetId: AssetId!) { balance(owner: $owner, assetId: $assetId) { owner amount assetId } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balances_connection_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balances_connection_query_gql_output.snap index b5043c6a2ea..20a5833cd99 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balances_connection_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__balance__tests__balances_connection_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/balance.rs expression: operation.query --- -query($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) { +query BalancesQuery($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) { balances(filter: $filter, after: $after, before: $before, first: $first, last: $last) { edges { cursor @@ -20,5 +20,3 @@ query($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int } } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap index 7f8855343cd..646548b3cbb 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/block.rs expression: operation.query --- -query($height: U32) { +query BlockByHeightQuery($height: U32) { block(height: $height) { version id diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_id_query_gql_output.snap index 0f2c57130a8..112301cfeb6 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_id_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/block.rs expression: operation.query --- -query($id: BlockId) { +query BlockByIdQuery($id: BlockId) { block(id: $id) { version id diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap index 5fbb114c456..c9427af1c28 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap @@ -2,8 +2,6 @@ source: crates/client/src/client/schema/block.rs expression: operation.query --- -mutation($startTimestamp: Tai64Timestamp, $blocksToProduce: U32!) { +mutation BlockMutation($startTimestamp: Tai64Timestamp, $blocksToProduce: U32!) { produceBlocks(blocksToProduce: $blocksToProduce, startTimestamp: $startTimestamp) } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__blocks_connection_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__blocks_connection_query_gql_output.snap index 3a0dd3d07f9..0ecbdab1de0 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__blocks_connection_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__blocks_connection_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/block.rs expression: operation.query --- -query($after: String, $before: String, $first: Int, $last: Int) { +query BlocksQuery($after: String, $before: String, $first: Int, $last: Int) { blocks(after: $after, before: $before, first: $first, last: $last) { edges { cursor diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap index 276475d619e..4b97aca83d3 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/chain.rs expression: operation.query --- -query { +query ChainQuery { chain { daHeight name diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap index ab8c41dfc93..f0465c30969 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/coins.rs expression: operation.query --- -query($utxoId: UtxoId!) { +query CoinByIdQuery($utxoId: UtxoId!) { coin(utxoId: $utxoId) { amount blockCreated diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap index a1ed7145a55..dcd3e5d5c50 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/coins.rs expression: operation.query --- -query($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) { +query CoinsQuery($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) { coins(filter: $filter, after: $after, before: $before, first: $first, last: $last) { edges { cursor diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__contract__tests__contract_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__contract__tests__contract_by_id_query_gql_output.snap index 3bbf3734c92..edc049bbfe9 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__contract__tests__contract_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__contract__tests__contract_by_id_query_gql_output.snap @@ -2,12 +2,10 @@ source: crates/client/src/client/schema/contract.rs expression: operation.query --- -query($id: ContractId!) { +query ContractByIdQuery($id: ContractId!) { contract(id: $id) { id bytecode salt } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__da_compressed__tests__block_by_height_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__da_compressed__tests__block_by_height_query_gql_output.snap index 62f797d34e8..136e3636b2e 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__da_compressed__tests__block_by_height_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__da_compressed__tests__block_by_height_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/da_compressed.rs expression: operation.query --- -query($height: U32!) { +query DaCompressedBlockByHeightQuery($height: U32!) { daCompressedBlock(height: $height) { bytes } diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__estimate_gas_price_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__estimate_gas_price_query_gql_output.snap index 854f7608efc..fe2aca12514 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__estimate_gas_price_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__estimate_gas_price_query_gql_output.snap @@ -2,10 +2,8 @@ source: crates/client/src/client/schema/gas_price.rs expression: operation.query --- -query($blockHorizon: U32) { +query QueryEstimateGasPrice($blockHorizon: U32) { estimateGasPrice(blockHorizon: $blockHorizon) { gasPrice } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__latest_gas_price_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__latest_gas_price_query_gql_output.snap index c39679de79c..fc4b33b8dc6 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__latest_gas_price_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__gas_price__tests__latest_gas_price_query_gql_output.snap @@ -2,11 +2,9 @@ source: crates/client/src/client/schema/gas_price.rs expression: operation.query --- -query { +query QueryLatestGasPrice { latestGasPrice { gasPrice blockHeight } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__message__tests__owned_message_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__message__tests__owned_message_query_gql_output.snap index 74daa16a958..af69edb1e9a 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__message__tests__owned_message_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__message__tests__owned_message_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/message.rs expression: operation.query --- -query($owner: Address, $after: String, $before: String, $first: Int, $last: Int) { +query OwnedMessageQuery($owner: Address, $after: String, $before: String, $first: Int, $last: Int) { messages(owner: $owner, after: $after, before: $before, first: $first, last: $last) { edges { cursor @@ -23,5 +23,3 @@ query($owner: Address, $after: String, $before: String, $first: Int, $last: Int) } } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__node_info_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__node_info_query_gql_output.snap index 1d538f92ad0..e89674bf28c 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__node_info_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__node_info_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/node_info.rs expression: operation.query --- -query { +query QueryNodeInfo { nodeInfo { utxoValidation vmBacktrace @@ -11,5 +11,3 @@ query { nodeVersion } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__peers_info_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__peers_info_query_gql_output.snap index 3322f6ca26b..0e760be14da 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__peers_info_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__node_info__tests__peers_info_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/node_info.rs expression: operation.query --- -query { +query QueryPeersInfo { nodeInfo { peers { id @@ -14,5 +14,3 @@ query { } } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__dry_run_tx_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__dry_run_tx_gql_output.snap index ec2c5cb373b..46918f4d7aa 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__dry_run_tx_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__dry_run_tx_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/tx.rs expression: query.query --- -mutation($txs: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) { +mutation DryRun($txs: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) { dryRun(txs: $txs, utxoValidation: $utxoValidation, gasPrice: $gasPrice) { id status { diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap index 4bd7cc1e5ed..9cdc64dce01 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__opaque_transaction_by_id_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/tx.rs expression: operation.query --- -query($id: TransactionId!) { +query TransactionQuery($id: TransactionId!) { transaction(id: $id) { rawPayload status { diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__submit_tx_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__submit_tx_gql_output.snap index 1b47a024b27..99aa42e9f1a 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__submit_tx_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__submit_tx_gql_output.snap @@ -2,10 +2,8 @@ source: crates/client/src/client/schema/tx.rs expression: query.query --- -mutation($tx: HexString!) { +mutation Submit($tx: HexString!) { submit(tx: $tx) { id } } - - diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap index 4e6edb0e54a..ca8574f17de 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_by_owner_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/tx.rs expression: operation.query --- -query($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) { +query TransactionsByOwnerQuery($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) { transactionsByOwner(owner: $owner, after: $after, before: $before, first: $first, last: $last) { edges { cursor diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap index 0b8580cbfd7..057b77f7faa 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transactions_connection_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/tx.rs expression: operation.query --- -query($after: String, $before: String, $first: Int, $last: Int) { +query TransactionsQuery($after: String, $before: String, $first: Int, $last: Int) { transactions(after: $after, before: $before, first: $first, last: $last) { edges { cursor diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap index 3795ffbdf3a..23e82b683a3 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/tx.rs expression: operation.query --- -query($id: TransactionId!) { +query TransactionQuery($id: TransactionId!) { transaction(id: $id) { scriptGasLimit id diff --git a/crates/client/src/client/schema/tx.rs b/crates/client/src/client/schema/tx.rs index 7953e768c4e..01f9184ff8d 100644 --- a/crates/client/src/client/schema/tx.rs +++ b/crates/client/src/client/schema/tx.rs @@ -3,7 +3,7 @@ use crate::client::{ schema, tx::transparent_receipt::Receipt, Address, - ConnectionArgs, + ConnectionArgsFields, ConversionError, HexString, PageInfo, @@ -526,12 +526,14 @@ pub mod tests { #[test] fn transactions_connection_query_gql_output() { use cynic::QueryBuilder; - let operation = TransactionsQuery::build(ConnectionArgs { + + let args = crate::client::schema::ConnectionArgs { after: None, before: None, first: None, last: None, - }); + }; + let operation = TransactionsQuery::build(args); insta::assert_snapshot!(operation.query) } diff --git a/crates/client/src/client/schema/tx/transparent_tx.rs b/crates/client/src/client/schema/tx/transparent_tx.rs index 4bce1dd17c8..8d5f3e7e990 100644 --- a/crates/client/src/client/schema/tx/transparent_tx.rs +++ b/crates/client/src/client/schema/tx/transparent_tx.rs @@ -2,13 +2,13 @@ use crate::client::schema::{ schema, tx::{ TransactionStatus, - TxIdArgs, + TxIdArgsFields, }, Address, AssetId, BlobId, Bytes32, - ConnectionArgs, + ConnectionArgsFields, ContractId, ConversionError, HexString, diff --git a/crates/client/src/client/types.rs b/crates/client/src/client/types.rs index 5880c4c92f5..37c5cea8ebc 100644 --- a/crates/client/src/client/types.rs +++ b/crates/client/src/client/types.rs @@ -91,7 +91,7 @@ pub mod primitives { #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct TransactionResponse { - pub transaction: Transaction, + pub transaction: TransactionType, pub status: TransactionStatus, } @@ -249,8 +249,9 @@ impl TryFrom for TransactionResponse { fn try_from(value: OpaqueTransactionWithStatus) -> Result { let bytes = value.raw_payload.0 .0; - let tx: Transaction = Transaction::from_bytes(bytes.as_slice()) - .map_err(ConversionError::TransactionFromBytesError)?; + let tx: TransactionType = Transaction::from_bytes(bytes.as_slice()) + .map(Into::into) + .unwrap_or(TransactionType::Unknown); let status = value .status .ok_or_else(|| ConversionError::MissingField("status".to_string()))? @@ -290,3 +291,29 @@ impl TryFrom for RelayedTransactionStatus { }) } } + +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[allow(clippy::large_enum_variant)] +pub enum TransactionType { + Known(Transaction), + Unknown, +} + +impl From for TransactionType { + fn from(value: Transaction) -> Self { + Self::Known(value) + } +} + +impl TryFrom for Transaction { + type Error = ConversionError; + + fn try_from(value: TransactionType) -> Result { + match value { + TransactionType::Known(tx) => Ok(tx), + TransactionType::Unknown => { + Err(ConversionError::UnknownVariant("Transaction")) + } + } + } +} diff --git a/crates/client/src/client/types/block.rs b/crates/client/src/client/types/block.rs index 3f96d34cc6e..e09e6039f32 100644 --- a/crates/client/src/client/types/block.rs +++ b/crates/client/src/client/types/block.rs @@ -95,6 +95,7 @@ impl TryFrom for Header { time: value.time.0, application_hash: value.application_hash.into(), }), + _ => Err(ConversionError::UnknownVariant("HeaderVersion")), } } } @@ -157,6 +158,7 @@ impl TryFrom for Block { block_producer, }) } + _ => Err(ConversionError::UnknownVariant("BlockVersion")), } } } diff --git a/tests/tests/blocks.rs b/tests/tests/blocks.rs index 35e40130373..923d457af93 100644 --- a/tests/tests/blocks.rs +++ b/tests/tests/blocks.rs @@ -355,6 +355,7 @@ mod full_block { schema::{ block::{ BlockByHeightArgs, + BlockByHeightArgsFields, Consensus, Header, }, diff --git a/tests/tests/tx.rs b/tests/tests/tx.rs index c405099dbc1..c760a81dbc0 100644 --- a/tests/tests/tx.rs +++ b/tests/tests/tx.rs @@ -360,12 +360,14 @@ async fn submit() { client.submit_and_await_commit(&tx).await.unwrap(); // verify that the tx returned from the api matches the submitted tx - let ret_tx = client + let ret_tx: Transaction = client .transaction(&tx.id(&ChainId::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); assert_eq!(tx.id(&ChainId::default()), ret_tx.id(&ChainId::default())); } @@ -632,8 +634,12 @@ async fn get_transactions() { .unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(transactions[0], tx1); // coinbase_tx1 @@ -669,8 +675,12 @@ async fn get_transactions() { let response = client.transactions(page_request_middle_page).await.unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); // coinbase_tx4 assert_eq!(transactions[0], tx4); @@ -684,8 +694,12 @@ async fn get_transactions() { let response = client.transactions(page_request_backwards).await.unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(transactions[0], tx3); // transactions[1] - coinbase_tx2 @@ -699,8 +713,12 @@ async fn get_transactions() { let response = client.transactions(page_request_forwards).await.unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(transactions[0], tx4); // coinbase_tx4 @@ -924,8 +942,12 @@ async fn get_transactions_from_manual_blocks() { .unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(transactions[0], txs[0].id(&ChainId::default())); assert_eq!(transactions[1], txs[1].id(&ChainId::default())); @@ -945,8 +967,12 @@ async fn get_transactions_from_manual_blocks() { .unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(transactions[0], txs[4].id(&ChainId::default())); // coinbase_tx1 @@ -967,8 +993,12 @@ async fn get_transactions_from_manual_blocks() { .unwrap(); let transactions = &response .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(transactions[0], txs[6].id(&ChainId::default())); assert_eq!(transactions[1], txs[5].id(&ChainId::default())); @@ -1003,8 +1033,12 @@ async fn get_owned_transactions() { .await .unwrap() .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); let bob_txs = client @@ -1012,8 +1046,12 @@ async fn get_owned_transactions() { .await .unwrap() .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); let charlie_txs = client @@ -1021,8 +1059,12 @@ async fn get_owned_transactions() { .await .unwrap() .results - .iter() - .map(|tx| tx.transaction.id(&ChainId::default())) + .into_iter() + .map(|tx| { + let tx: Transaction = tx.transaction.try_into().unwrap(); + + tx.id(&ChainId::default()) + }) .collect_vec(); assert_eq!(&alice_txs, &[tx1]); diff --git a/tests/tests/tx/predicates.rs b/tests/tests/tx/predicates.rs index 7dc2ab190f7..508a87b1cca 100644 --- a/tests/tests/tx/predicates.rs +++ b/tests/tests/tx/predicates.rs @@ -87,13 +87,15 @@ async fn transaction_with_valid_predicate_is_executed() { .unwrap(); // check transaction change amount to see if predicate was spent - let transaction = context + let transaction: Transaction = context .client .transaction(&predicate_tx.id(&ChainId::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); assert!( matches!(transaction.as_script().unwrap().outputs()[0], Output::Change { amount: change_amount, .. } if change_amount == amount) diff --git a/tests/tests/tx/tx_pointer.rs b/tests/tests/tx/tx_pointer.rs index 177715fc2dc..6d82b2ea6f7 100644 --- a/tests/tests/tx/tx_pointer.rs +++ b/tests/tests/tx/tx_pointer.rs @@ -17,6 +17,7 @@ use fuel_core_types::{ Input, Output, Script, + Transaction, TransactionBuilder, TxPointer, UniqueIdentifier, @@ -80,12 +81,14 @@ async fn tx_pointer_set_from_genesis_for_coin_and_contract_inputs() { client.submit_and_await_commit(&tx).await.unwrap(); // verify that the tx returned from the api has tx pointers set matching the genesis config - let ret_tx = client + let ret_tx: Transaction = client .transaction(&tx.id(&Default::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); let ret_script = ret_tx.as_script().unwrap(); let coin_input = &ret_script.inputs()[0]; @@ -136,12 +139,14 @@ async fn tx_pointer_set_from_previous_block() { let tx1 = tx1.into(); client.submit_and_await_commit(&tx1).await.unwrap(); let next_block_height_after_genesis = new_genesis_block_height + 1; - let ret_tx1 = client + let ret_tx1: Transaction = client .transaction(&tx1.id(&Default::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); let ret_tx1 = ret_tx1.as_script().unwrap(); // setup a second transaction that uses UTXOs from tx1 @@ -155,12 +160,14 @@ async fn tx_pointer_set_from_previous_block() { let tx2 = tx2.into(); client.submit_and_await_commit(&tx2).await.unwrap(); - let ret_tx2 = client + let ret_tx2: Transaction = client .transaction(&tx2.id(&Default::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); let ret_tx2 = ret_tx2.as_script().unwrap(); @@ -204,12 +211,15 @@ async fn tx_pointer_unset_when_utxo_validation_disabled() { let tx = script.into(); client.submit_and_await_commit(&tx).await.unwrap(); - let ret_tx = client + let ret_tx: Transaction = client .transaction(&tx.id(&Default::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); + let ret_tx = ret_tx.as_script().unwrap(); // verify coin input tx_pointer is null assert_eq!( diff --git a/tests/tests/tx/utxo_validation.rs b/tests/tests/tx/utxo_validation.rs index 0623ba580ef..a93c988ec32 100644 --- a/tests/tests/tx/utxo_validation.rs +++ b/tests/tests/tx/utxo_validation.rs @@ -74,12 +74,14 @@ async fn submit_utxo_verified_tx_with_min_gas_price() { let tx = tx.into(); client.submit_and_await_commit(&tx).await.unwrap(); // verify that the tx returned from the api matches the submitted tx - let ret_tx = client + let ret_tx: Transaction = client .transaction(&tx.id(&ChainId::default())) .await .unwrap() .unwrap() - .transaction; + .transaction + .try_into() + .unwrap(); let transaction_result = client .transaction_status(&ret_tx.id(&ChainId::default()))