Kagome
Polkadot Runtime Engine in C++17
ss58_codec.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_SS58_CODEC_HPP
7 #define KAGOME_SS58_CODEC_HPP
8 
9 #include <gsl/span>
10 
11 #include "outcome/outcome.hpp"
12 #include "primitives/account.hpp"
13 
14 namespace kagome::crypto {
15  class Hasher;
16 }
17 
18 namespace kagome::primitives {
19 
21 
22  constexpr size_t kSs58ChecksumLength = 2;
23  constexpr size_t kSs58Length = AccountId::size() + kSs58ChecksumLength
24  + 1; // 1 byte address type, 2 bytes checksum
25 
30  outcome::result<AccountId> decodeSs58(std::string_view account_address,
31  const crypto::Hasher &hasher) noexcept;
32 
33  std::string encodeSs58(uint8_t account_type,
34  const AccountId &id,
35  const crypto::Hasher &hasher) noexcept;
36 
37 } // namespace kagome::primitives
38 
40 
41 #endif // KAGOME_SS58_CODEC_HPP
OUTCOME_HPP_DECLARE_ERROR(kagome::primitives, Ss58Error)
constexpr size_t kSs58Length
Definition: ss58_codec.hpp:23
outcome::result< AccountId > decodeSs58(std::string_view account_address, const crypto::Hasher &hasher) noexcept
Definition: ss58_codec.cpp:37
crypto::Sr25519PublicKey AccountId
Definition: account.hpp:13
std::string encodeSs58(uint8_t account_type, const AccountId &id, const crypto::Hasher &hasher) noexcept
Definition: ss58_codec.cpp:67
constexpr size_t kSs58ChecksumLength
Definition: ss58_codec.hpp:22