Ethereum  PoC-8
The C++ Implementation of Ethereum
CommonJS.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
24 #pragma once
25 
26 #include <string>
27 #include <libdevcore/CommonJS.h>
28 #include <libdevcrypto/Common.h>
29 #include "Common.h"
30 
31 // devcrypto
32 
33 namespace dev
34 {
35 
37 inline Public jsToPublic(std::string const& _s) { return jsToFixed<sizeof(dev::Public)>(_s); }
38 
40 inline Secret jsToSecret(std::string const& _s) { h256 d = jsToFixed<sizeof(dev::Secret)>(_s); Secret ret(d); d.ref().cleanse(); return ret; }
41 
43 inline Address jsToAddress(std::string const& _s) { return eth::toAddress(_s); }
44 
46 std::string prettyU256(u256 _n, bool _abridged = true);
47 
48 }
49 
50 
51 // ethcore
52 namespace dev
53 {
54 namespace eth
55 {
56 
58 BlockNumber jsToBlockNumber(std::string const& _js);
59 
60 }
61 }
dev::jsToPublic
Public jsToPublic(std::string const &_s)
Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length.
Definition: CommonJS.h:37
dev::prettyU256
std::string prettyU256(u256 _n, bool _abridged)
Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHa...
Definition: CommonJS.cpp:29
dev::SecureFixedHash< 32 >
dev::FixedHash::ref
bytesRef ref()
Definition: FixedHash.h:132
Common.h
CommonJS.h
dev::FixedHash< 64 >
Common.h
dev::eth::toAddress
Address toAddress(std::string const &_s)
Convert the given string into an address.
Definition: Common.cpp:56
dev::jsToAddress
Address jsToAddress(std::string const &_s)
Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length.
Definition: CommonJS.h:43
dev::eth::jsToBlockNumber
BlockNumber jsToBlockNumber(std::string const &_js)
Convert to a block number, a bit like jsToInt, except that it correctly recognises "pending" and "lat...
Definition: CommonJS.cpp:62
dev::jsToSecret
Secret jsToSecret(std::string const &_s)
Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length.
Definition: CommonJS.h:40
dev::eth::BlockNumber
unsigned BlockNumber
Definition: Common.h:64
dev::u256
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
Definition: Common.h:121
dev
Definition: Address.cpp:21
dev::vector_ref::cleanse
void cleanse()
Definition: vector_ref.h:72