Browse Source

Merge pull request #2463 from arkpar/az-fix

Allow 0x prefix for address entry in AZ
cl-refactor
Gav Wood 10 years ago
parent
commit
1029517cce
  1. 12
      alethzero/MainWin.cpp
  2. 2
      test/TestHelper.cpp

12
alethzero/MainWin.cpp

@ -638,18 +638,22 @@ pair<Address, bytes> Main::fromString(std::string const& _n) const
if (_n == "(Create Contract)") if (_n == "(Create Contract)")
return make_pair(Address(), bytes()); return make_pair(Address(), bytes());
std::string n = _n;
if (n.find("0x") == 0)
n.erase(0, 2);
auto g_newNameReg = getNameReg(); auto g_newNameReg = getNameReg();
if (g_newNameReg) if (g_newNameReg)
{ {
Address a = abiOut<Address>(ethereum()->call(g_newNameReg, abiIn("addr(bytes32)", ::toString32(_n))).output); Address a = abiOut<Address>(ethereum()->call(g_newNameReg, abiIn("addr(bytes32)", ::toString32(n))).output);
if (a) if (a)
return make_pair(a, bytes()); return make_pair(a, bytes());
} }
if (_n.size() == 40) if (n.size() == 40)
{ {
try try
{ {
return make_pair(Address(fromHex(_n, WhenError::Throw)), bytes()); return make_pair(Address(fromHex(n, WhenError::Throw)), bytes());
} }
catch (BadHexCharacter& _e) catch (BadHexCharacter& _e)
{ {
@ -665,7 +669,7 @@ pair<Address, bytes> Main::fromString(std::string const& _n) const
} }
else else
try { try {
return ICAP::decoded(_n).address([&](Address const& a, bytes const& b) -> bytes return ICAP::decoded(n).address([&](Address const& a, bytes const& b) -> bytes
{ {
return ethereum()->call(a, b).output; return ethereum()->call(a, b).output;
}, g_newNameReg); }, g_newNameReg);

2
test/TestHelper.cpp

@ -479,7 +479,7 @@ bytes importCode(json_spirit::mObject& _o)
{ {
bytes code; bytes code;
if (_o["code"].type() == json_spirit::str_type) if (_o["code"].type() == json_spirit::str_type)
if (_o["code"].get_str().find_first_of("0x") != 0) if (_o["code"].get_str().find("0x") != 0)
code = compileLLL(_o["code"].get_str(), false); code = compileLLL(_o["code"].get_str(), false);
else else
code = fromHex(_o["code"].get_str().substr(2)); code = fromHex(_o["code"].get_str().substr(2));

Loading…
Cancel
Save