1- // This file was taken from subxt (Parity Technologies (UK))
2- // https://github.com/paritytech/subxt/
3- // And was adapted by Supercomputing Systems AG and Integritee AG.
4- //
5- // Copyright 2019-2022 Parity Technologies (UK) Ltd, Supercomputing Systems AG and Integritee AG.
6- // This file is licensed as Apache-2.0
7- // see LICENSE for license details.
1+ /*
2+ Copyright 2021 Integritee AG and Supercomputing Systems AG
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+ http://www.apache.org/licenses/LICENSE-2.0
7+ Unless required by applicable law or agreed to in writing, software
8+ distributed under the License is distributed on an "AS IS" BASIS,
9+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+ See the License for the specific language governing permissions and
11+ limitations under the License.
12+ */
813
9- //! General node-api Error and Substrate DispatchError implementation.
10-
11- use crate :: {
12- alloc:: {
13- borrow:: Cow ,
14- format,
15- string:: { String , ToString } ,
16- vec:: Vec ,
17- } ,
18- metadata:: Metadata ,
14+ use crate :: metadata:: Metadata ;
15+ use alloc:: {
16+ borrow:: Cow ,
17+ string:: { String , ToString } ,
18+ vec:: Vec ,
1919} ;
20-
2120use codec:: { Decode , Encode } ;
2221use core:: fmt:: Debug ;
2322use derive_more:: From ;
@@ -32,45 +31,6 @@ pub use crate::{
3231pub use sp_core:: crypto:: SecretStringError ;
3332pub use sp_runtime:: transaction_validity:: TransactionValidityError ;
3433
35- /// The underlying error enum, generic over the type held by the `Runtime`
36- /// variant. Prefer to use the [`Error<E>`] and [`Error`] aliases over
37- /// using this type directly.
38- #[ derive( Debug , From ) ]
39- pub enum Error {
40- /// Codec error.
41- Codec ( codec:: Error ) ,
42- /// Serde serialization error
43- Serialization ( serde_json:: error:: Error ) ,
44- /// Secret string error.
45- SecretString ( SecretStringError ) ,
46- /// Extrinsic validity error
47- Invalid ( TransactionValidityError ) ,
48- /// Invalid metadata error
49- InvalidMetadata ( InvalidMetadataError ) ,
50- /// Invalid metadata error
51- Metadata ( MetadataError ) ,
52- /// Runtime error.
53- Runtime ( DispatchError ) ,
54- /// Error decoding to a [`crate::dynamic::Value`].
55- DecodeValue ( DecodeError ) ,
56- /// Error encoding from a [`crate::dynamic::Value`].
57- EncodeValue ( EncodeError ) ,
58- /// Transaction progress error.
59- Transaction ( TransactionError ) ,
60- /// Block related error.
61- Block ( BlockError ) ,
62- /// An error encoding a storage address.
63- StorageAddress ( StorageAddressError ) ,
64- /// Other error.
65- Other ( String ) ,
66- }
67-
68- impl From < & str > for Error {
69- fn from ( error : & str ) -> Self {
70- Error :: Other ( error. into ( ) )
71- }
72- }
73-
7434/// An error dispatching a transaction. See Substrate DispatchError
7535//https://github.com/paritytech/substrate/blob/890451221db37176e13cb1a306246f02de80590a/primitives/runtime/src/lib.rs#L524
7636#[ derive( Debug , From ) ]
@@ -295,32 +255,6 @@ pub enum TransactionalError {
295255 NoLayer ,
296256}
297257
298- /// Block error
299- #[ derive( Clone , Debug , Eq , PartialEq ) ]
300- pub enum BlockError {
301- /// The block
302- BlockHashNotFound ( String ) ,
303- }
304-
305- impl BlockError {
306- /// Produce an error that a block with the given hash cannot be found.
307- pub fn block_hash_not_found ( hash : impl AsRef < [ u8 ] > ) -> BlockError {
308- let hash = format ! ( "0x{}" , hex:: encode( hash) ) ;
309- BlockError :: BlockHashNotFound ( hash)
310- }
311- }
312-
313- /// Transaction error.
314- #[ derive( Clone , Debug , Eq , PartialEq ) ]
315- pub enum TransactionError {
316- /// The finality subscription expired (after ~512 blocks we give up if the
317- /// block hasn't yet been finalized).
318- FinalitySubscriptionTimeout ,
319- /// The block hash that the transaction was added to could not be found.
320- /// This is probably because the block was retracted before being finalized.
321- BlockHashNotFound ,
322- }
323-
324258/// Details about a module error that has occurred.
325259#[ derive( Clone , Debug ) ]
326260pub struct ModuleError {
@@ -352,26 +286,3 @@ impl ModuleErrorData {
352286 self . error [ 0 ]
353287 }
354288}
355-
356- /// Something went wrong trying to encode a storage address.
357- #[ derive( Clone , Debug ) ]
358- pub enum StorageAddressError {
359- /// Storage map type must be a composite type.
360- MapTypeMustBeTuple ,
361- /// Storage lookup does not have the expected number of keys.
362- WrongNumberOfKeys {
363- /// The actual number of keys needed, based on the metadata.
364- actual : usize ,
365- /// The number of keys provided in the storage address.
366- expected : usize ,
367- } ,
368- /// Storage lookup requires a type that wasn't found in the metadata.
369- TypeNotFound ( u32 ) ,
370- /// This storage entry in the metadata does not have the correct number of hashers to fields.
371- WrongNumberOfHashers {
372- /// The number of hashers in the metadata for this storage entry.
373- hashers : usize ,
374- /// The number of fields in the metadata for this storage entry.
375- fields : usize ,
376- } ,
377- }
0 commit comments