Tidy and conformalise the toHex API.

This commit is contained in:
Gav Wood 2015-04-27 23:30:28 +02:00
parent 5e0eb4bae1
commit 50644d2e10

View File

@ -137,7 +137,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
str = value.get_str(); str = value.get_str();
else continue; else continue;
_o[key] = (str.substr(0, 2) == "0x") ? str : toCompactHex(toInt(str), HexPrefix::Add); _o[key] = (str.substr(0, 2) == "0x") ? str : toCompactHex(toInt(str), HexPrefix::Add, 1);
} }
return _o; return _o;
} }
@ -355,15 +355,15 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost)
json_spirit::mObject fillJsonWithTransaction(Transaction _txn) json_spirit::mObject fillJsonWithTransaction(Transaction _txn)
{ {
json_spirit::mObject txObject; json_spirit::mObject txObject;
txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add); txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add, 1);
txObject["data"] = toHex(_txn.data(), 2, HexPrefix::Add); txObject["data"] = toHex(_txn.data(), 2, HexPrefix::Add);
txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add); txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add, 1);
txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add); txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add, 1);
txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add); txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add, 1);
txObject["s"] = toCompactHex(_txn.signature().s, HexPrefix::Add); txObject["s"] = toCompactHex(_txn.signature().s, HexPrefix::Add, 1);
txObject["v"] = toCompactHex(_txn.signature().v + 27, HexPrefix::Add); txObject["v"] = toCompactHex(_txn.signature().v + 27, HexPrefix::Add, 1);
txObject["to"] = _txn.isCreation() ? "" : toString(_txn.receiveAddress()); txObject["to"] = _txn.isCreation() ? "" : toString(_txn.receiveAddress());
txObject["value"] = toCompactHex(_txn.value(), HexPrefix::Add); txObject["value"] = toCompactHex(_txn.value(), HexPrefix::Add, 1);
return txObject; return txObject;
} }
@ -373,12 +373,12 @@ json_spirit::mObject fillJsonWithState(State _state)
for (auto const& a: _state.addresses()) for (auto const& a: _state.addresses())
{ {
json_spirit::mObject o; json_spirit::mObject o;
o["balance"] = toCompactHex(_state.balance(a.first), HexPrefix::Add); o["balance"] = toCompactHex(_state.balance(a.first), HexPrefix::Add, 1);
o["nonce"] = toCompactHex(_state.transactionsFrom(a.first), HexPrefix::Add); o["nonce"] = toCompactHex(_state.transactionsFrom(a.first), HexPrefix::Add, 1);
{ {
json_spirit::mObject store; json_spirit::mObject store;
for (auto const& s: _state.storage(a.first)) for (auto const& s: _state.storage(a.first))
store[toCompactHex(s.first, HexPrefix::Add)] = toCompactHex(s.second, HexPrefix::Add); store[toCompactHex(s.first, HexPrefix::Add, 1)] = toCompactHex(s.second, HexPrefix::Add, 1);
o["storage"] = store; o["storage"] = store;
} }
o["code"] = toHex(_state.code(a.first), 2, HexPrefix::Add); o["code"] = toHex(_state.code(a.first), 2, HexPrefix::Add);