From 8a6692b2cfb7cf53db6731acd6a9908bd36b5475 Mon Sep 17 00:00:00 2001 From: wadeAlexC Date: Thu, 5 Oct 2017 09:28:25 -0400 Subject: Improves address literal checksum error message --- libsolidity/ast/AST.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libsolidity/ast/AST.cpp') diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 1048b610..4911f161 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -583,3 +583,9 @@ bool Literal::passesAddressChecksum() const solAssert(isHexNumber(), "Expected hex number"); return dev::passesAddressChecksum(value(), true); } + +std::string Literal::getChecksummedAddress() const +{ + solAssert(isHexNumber(), "Expected hex number"); + return dev::getChecksummedAddress(value()); +} -- cgit v1.2.3 From 1d5dd909b4ed8625330e9ec859e02dfd067f4006 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 24 Oct 2017 10:54:51 +0100 Subject: Do not try to display checksummed address for too-short/long address literals --- libsolidity/ast/AST.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libsolidity/ast/AST.cpp') diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 4911f161..62507093 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -587,5 +587,7 @@ bool Literal::passesAddressChecksum() const std::string Literal::getChecksummedAddress() const { solAssert(isHexNumber(), "Expected hex number"); + if (value().length != 42) + return string(); return dev::getChecksummedAddress(value()); } -- cgit v1.2.3 From 8d26894841d7b5897b7c6f126f6ea1b8293ab5a2 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 24 Oct 2017 11:01:56 +0100 Subject: Show checksummed address always (prepend with 0) --- libsolidity/ast/AST.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libsolidity/ast/AST.cpp') diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 62507093..8da6964e 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -587,7 +587,10 @@ bool Literal::passesAddressChecksum() const std::string Literal::getChecksummedAddress() const { solAssert(isHexNumber(), "Expected hex number"); - if (value().length != 42) + /// Pad literal to be a proper hex address. + string address = value().substr(2); + if (address.length() > 40) return string(); - return dev::getChecksummedAddress(value()); + address.insert(address.begin(), 40 - address.size(), '0'); + return dev::getChecksummedAddress(address); } -- cgit v1.2.3