Kagome
Polkadot Runtime Engine in C++17
token_error.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_PRIMITIVES_TOKEN_ERROR_HPP
7 #define KAGOME_CORE_PRIMITIVES_TOKEN_ERROR_HPP
8 
9 #include <cstdint>
10 
11 #include "outcome/outcome.hpp"
12 
13 namespace kagome::primitives {
14 
15  enum class TokenError : uint8_t {
17  NoFunds = 1,
19  WouldDie,
27  Frozen,
30  };
31 
32  template <class Stream,
33  typename = std::enable_if_t<Stream::is_encoder_stream>>
35  // index shift is required for compatibility with rust implementation.
36  // std::error_code policy preserves 0 index for success cases.
37  return s << static_cast<uint8_t>(v) - 1;
38  }
39 
40  template <class Stream,
41  typename = std::enable_if_t<Stream::is_decoder_stream>>
42  Stream &operator>>(Stream &s, TokenError &v) {
43  uint8_t value = 0u;
44  s >> value;
45  // index shift is required for compatibility with rust implementation.
46  // std::error_code policy preserves 0 index for success cases.
47  ++value;
48  v = static_cast<TokenError>(value);
49  return s;
50  }
51 
52 } // namespace kagome::primitives
53 
55 
56 #endif // KAGOME_CORE_PRIMITIVES_TOKEN_ERROR_HPP
Funds exist but are frozen.
Account that must exist would die.
OUTCOME_HPP_DECLARE_ERROR(kagome::primitives, TokenError)
Stream & operator>>(Stream &s, ArithmeticError &v)
The asset in question is unknown.
Operation is not supported by the asset.
Stream & operator<<(Stream &s, const ArithmeticError &v)
Account cannot exist with the funds that would be given.
libp2p::connection::Stream Stream