From c020c05ea07e194ecef5bebdcbc0ebaa69a7b459 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 1 Aug 2023 13:03:06 +0200 Subject: [PATCH] Add docs to ConvertTransaction and NoTransactionConverter (#977) * Add docs to ConvertTransaction and NoTransactionConverter * Update lib.rs --- primitives/rpc/src/lib.rs | 5 ++++- shell.nix | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs index 045402fdf5..57895c46b0 100644 --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -252,10 +252,13 @@ sp_api::decl_runtime_apis! { } } +/// Fallback transaction converter when the `ConvertTransactionRuntimeApi` is not available. For almost all +/// non-legacy cases, you can instantiate this type as `NoTransactionConverter`. pub trait ConvertTransaction { fn convert_transaction(&self, transaction: ethereum::TransactionV2) -> E; } +/// No fallback transaction converter is available. // `NoTransactionConverter` is a non-instantiable type (an enum with no variants), // so we are guaranteed at compile time that `NoTransactionConverter` can never be instantiated. pub enum NoTransactionConverter {} @@ -263,6 +266,6 @@ impl ConvertTransaction for NoTransactionConverter { // `convert_transaction` is a method taking `&self` as a parameter, so it can only be called via an instance of type Self, // so we are guaranteed at compile time that this method can never be called. fn convert_transaction(&self, _transaction: ethereum::TransactionV2) -> E { - unreachable!() + match *self {} } } diff --git a/shell.nix b/shell.nix index 5e2c4423f6..e752b5b933 100644 --- a/shell.nix +++ b/shell.nix @@ -5,7 +5,7 @@ let rev = "78e723925daf5c9e8d0a1837ec27059e61649cb6"; }); nixpkgs = import { overlays = [ mozillaOverlay ]; }; - rust-nightly = with nixpkgs; ((rustChannelOf { date = "2022-11-15"; channel = "nightly"; }).rust.override { + rust-nightly = with nixpkgs; ((rustChannelOf { date = "2023-07-23"; channel = "nightly"; }).rust.override { extensions = [ "rust-src" ]; targets = [ "wasm32-unknown-unknown" ]; });