Browse Source

Merge remote-tracking branch 'upstream/develop' into blockTests

cl-refactor
CJentzsch 10 years ago
parent
commit
3eaf7b7fe2
  1. 7
      alethzero/CMakeLists.txt
  2. 1
      eth/CMakeLists.txt
  3. 7
      libdevcore/CMakeLists.txt
  4. 22
      libdevcore/CommonIO.h
  5. 2
      libethereum/State.cpp
  6. 2
      libsolidity/CompilerContext.cpp
  7. 5
      libweb3jsonrpc/CMakeLists.txt
  8. 4
      mix/QEther.cpp
  9. 12
      mix/qml/Ether.qml
  10. 6
      mix/qml/FilesSection.qml
  11. 4
      mix/qml/NewProjectDialog.qml
  12. 4
      mix/qml/ProjectList.qml
  13. 9
      mix/qml/QHashTypeView.qml
  14. 9
      mix/qml/QIntTypeView.qml
  15. 9
      mix/qml/QStringTypeView.qml
  16. 6
      mix/qml/SourceSansProBold.qml
  17. 7
      mix/qml/SourceSansProLight.qml
  18. 8
      mix/qml/SourceSansProRegular.qml
  19. 113
      mix/qml/StateDialog.qml
  20. 17
      mix/qml/StateDialogStyle.qml
  21. 1
      mix/qml/StateListModel.qml
  22. 248
      mix/qml/TransactionDialog.qml
  23. 1
      mix/qml/qmldir
  24. 4
      mix/res.qrc
  25. 12
      test/SolidityEndToEndTest.cpp

7
alethzero/CMakeLists.txt

@ -40,9 +40,6 @@ target_link_libraries(${EXECUTABLE} evm)
target_link_libraries(${EXECUTABLE} ethcore) target_link_libraries(${EXECUTABLE} ethcore)
target_link_libraries(${EXECUTABLE} devcrypto) target_link_libraries(${EXECUTABLE} devcrypto)
target_link_libraries(${EXECUTABLE} secp256k1) target_link_libraries(${EXECUTABLE} secp256k1)
if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"))
target_link_libraries(${EXECUTABLE} serpent)
endif()
target_link_libraries(${EXECUTABLE} lll) target_link_libraries(${EXECUTABLE} lll)
target_link_libraries(${EXECUTABLE} solidity) target_link_libraries(${EXECUTABLE} solidity)
target_link_libraries(${EXECUTABLE} evmcore) target_link_libraries(${EXECUTABLE} evmcore)
@ -51,6 +48,10 @@ target_link_libraries(${EXECUTABLE} web3jsonrpc)
target_link_libraries(${EXECUTABLE} jsqrc) target_link_libraries(${EXECUTABLE} jsqrc)
target_link_libraries(${EXECUTABLE} natspec) target_link_libraries(${EXECUTABLE} natspec)
if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"))
target_link_libraries(${EXECUTABLE} serpent)
endif()
# eth_install_executable is defined in cmake/EthExecutableHelper.cmake # eth_install_executable is defined in cmake/EthExecutableHelper.cmake
eth_install_executable(${EXECUTABLE}) eth_install_executable(${EXECUTABLE})

1
eth/CMakeLists.txt

@ -16,7 +16,6 @@ add_executable(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
add_dependencies(${EXECUTABLE} BuildInfo.h) add_dependencies(${EXECUTABLE} BuildInfo.h)
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_DATE_TIME_LIBRARIES})
if (READLINE_FOUND) if (READLINE_FOUND)
target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES})

7
libdevcore/CMakeLists.txt

@ -26,9 +26,14 @@ else()
endif() endif()
target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARIES})
#target_link_libraries(${EXECUTABLE} ${Boost_DATE_TIME_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARIES})
# transitive dependencies for windows executables
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_link_libraries(${EXECUTABLE} ${Boost_CHRONO_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_DATE_TIME_LIBRARIES})
endif()
if (APPLE) if (APPLE)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})

22
libdevcore/CommonIO.h

@ -57,7 +57,7 @@ template <class S, class T> struct StreamOut { static S& bypass(S& _out, T const
template <class S> struct StreamOut<S, uint8_t> { static S& bypass(S& _out, uint8_t const& _t) { _out << (int)_t; return _out; } }; template <class S> struct StreamOut<S, uint8_t> { static S& bypass(S& _out, uint8_t const& _t) { _out << (int)_t; return _out; } };
template <class T> inline std::ostream& operator<<(std::ostream& _out, std::vector<T> const& _e); template <class T> inline std::ostream& operator<<(std::ostream& _out, std::vector<T> const& _e);
template <class T, unsigned Z> inline std::ostream& operator<<(std::ostream& _out, std::array<T, Z> const& _e); template <class T, std::size_t Z> inline std::ostream& operator<<(std::ostream& _out, std::array<T, Z> const& _e);
template <class T, class U> inline std::ostream& operator<<(std::ostream& _out, std::pair<T, U> const& _e); template <class T, class U> inline std::ostream& operator<<(std::ostream& _out, std::pair<T, U> const& _e);
template <class T> inline std::ostream& operator<<(std::ostream& _out, std::list<T> const& _e); template <class T> inline std::ostream& operator<<(std::ostream& _out, std::list<T> const& _e);
template <class T1, class T2, class T3> inline std::ostream& operator<<(std::ostream& _out, std::tuple<T1, T2, T3> const& _e); template <class T1, class T2, class T3> inline std::ostream& operator<<(std::ostream& _out, std::tuple<T1, T2, T3> const& _e);
@ -84,7 +84,7 @@ inline S& streamout(S& _out, std::vector<T> const& _e)
template <class T> inline std::ostream& operator<<(std::ostream& _out, std::vector<T> const& _e) { streamout(_out, _e); return _out; } template <class T> inline std::ostream& operator<<(std::ostream& _out, std::vector<T> const& _e) { streamout(_out, _e); return _out; }
template <class S, class T, unsigned Z> template <class S, class T, std::size_t Z>
inline S& streamout(S& _out, std::array<T, Z> const& _e) inline S& streamout(S& _out, std::array<T, Z> const& _e)
{ {
_out << "["; _out << "[";
@ -98,23 +98,7 @@ inline S& streamout(S& _out, std::array<T, Z> const& _e)
_out << "]"; _out << "]";
return _out; return _out;
} }
template <class T, unsigned Z> inline std::ostream& operator<<(std::ostream& _out, std::array<T, Z> const& _e) { streamout(_out, _e); return _out; } template <class T, std::size_t Z> inline std::ostream& operator<<(std::ostream& _out, std::array<T, Z> const& _e) { streamout(_out, _e); return _out; }
template <class S, class T, unsigned long Z>
inline S& streamout(S& _out, std::array<T, Z> const& _e)
{
_out << "[";
if (!_e.empty())
{
StreamOut<S, T>::bypass(_out, _e.front());
auto i = _e.begin();
for (++i; i != _e.end(); ++i)
StreamOut<S, T>::bypass(_out << ",", *i);
}
_out << "]";
return _out;
}
template <class T, unsigned long Z> inline std::ostream& operator<<(std::ostream& _out, std::array<T, Z> const& _e) { streamout(_out, _e); return _out; }
template <class S, class T> template <class S, class T>
inline S& streamout(S& _out, std::list<T> const& _e) inline S& streamout(S& _out, std::list<T> const& _e)

2
libethereum/State.cpp

@ -370,7 +370,7 @@ void State::resetCurrent()
m_cache.clear(); m_cache.clear();
m_currentBlock = BlockInfo(); m_currentBlock = BlockInfo();
m_currentBlock.coinbaseAddress = m_ourAddress; m_currentBlock.coinbaseAddress = m_ourAddress;
m_currentBlock.timestamp = time(0); m_currentBlock.timestamp = max(m_previousBlock.timestamp + 1, (u256)time(0));
m_currentBlock.transactionsRoot = h256(); m_currentBlock.transactionsRoot = h256();
m_currentBlock.sha3Uncles = h256(); m_currentBlock.sha3Uncles = h256();
m_currentBlock.populateFromParent(m_previousBlock); m_currentBlock.populateFromParent(m_previousBlock);

2
libsolidity/CompilerContext.cpp

@ -76,7 +76,7 @@ bytes const& CompilerContext::getCompiledContract(const ContractDefinition& _con
bool CompilerContext::isLocalVariable(Declaration const* _declaration) const bool CompilerContext::isLocalVariable(Declaration const* _declaration) const
{ {
return m_localVariables.count(_declaration); return !!m_localVariables.count(_declaration);
} }
eth::AssemblyItem CompilerContext::getFunctionEntryLabel(Declaration const& _declaration) eth::AssemblyItem CompilerContext::getFunctionEntryLabel(Declaration const& _declaration)

5
libweb3jsonrpc/CMakeLists.txt

@ -30,7 +30,10 @@ target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_SERVER_LIBRARIES})
target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} secp256k1) target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} solidity) target_link_libraries(${EXECUTABLE} solidity)
target_link_libraries(${EXECUTABLE} serpent)
if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"))
target_link_libraries(${EXECUTABLE} serpent)
endif()
if (ETH_JSON_RPC_STUB) if (ETH_JSON_RPC_STUB)
add_custom_target(jsonrpcstub) add_custom_target(jsonrpcstub)

4
mix/QEther.cpp

@ -35,7 +35,7 @@ QBigInt* QEther::toWei() const
const char* key = units.valueToKey(m_currentUnit); const char* key = units.valueToKey(m_currentUnit);
for (std::pair<dev::u256, std::string> rawUnit: dev::eth::units()) for (std::pair<dev::u256, std::string> rawUnit: dev::eth::units())
{ {
if (rawUnit.second == QString(key).toLower().toStdString()) if (QString::fromStdString(rawUnit.second).toLower() == QString(key).toLower())
return multiply(new QBigInt(rawUnit.first)); return multiply(new QBigInt(rawUnit.first));
} }
return new QBigInt(dev::u256(0)); return new QBigInt(dev::u256(0));
@ -46,7 +46,7 @@ void QEther::setUnit(QString const& _unit)
QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("EtherUnit")); QMetaEnum units = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("EtherUnit"));
for (int k = 0; k < units.keyCount(); k++) for (int k = 0; k < units.keyCount(); k++)
{ {
if (QString(units.key(k)).toLower() == _unit) if (QString(units.key(k)).toLower() == _unit.toLower())
{ {
m_currentUnit = static_cast<EtherUnit>(units.keysToValue(units.key(k))); m_currentUnit = static_cast<EtherUnit>(units.keysToValue(units.key(k)));
return; return;

12
mix/qml/Ether.qml

@ -32,6 +32,11 @@ RowLayout {
units.currentIndex = unit; units.currentIndex = unit;
} }
SourceSansProRegular
{
id: regularFont
}
TextField TextField
{ {
implicitWidth: 200 implicitWidth: 200
@ -46,6 +51,7 @@ RowLayout {
readOnly: !edit readOnly: !edit
visible: edit visible: edit
id: etherValueEdit; id: etherValueEdit;
font.family: regularFont.name
} }
ComboBox ComboBox
@ -59,6 +65,7 @@ RowLayout {
formattedValue.text = value.format(); formattedValue.text = value.format();
} }
} }
model: ListModel { model: ListModel {
id: unitsModel id: unitsModel
ListElement { text: "Uether"; } ListElement { text: "Uether"; }
@ -81,10 +88,15 @@ RowLayout {
ListElement { text: "Kwei"; } ListElement { text: "Kwei"; }
ListElement { text: "wei"; } ListElement { text: "wei"; }
} }
style: ComboBoxStyle {
font: regularFont.name
}
} }
Text Text
{ {
visible: displayFormattedValue visible: displayFormattedValue
id: formattedValue id: formattedValue
font.family: regularFont.name
} }
} }

6
mix/qml/FilesSection.qml

@ -48,16 +48,14 @@ ColumnLayout {
model.remove(i); model.remove(i);
} }
FontLoader SourceSansProRegular
{ {
id: fileNameFont id: fileNameFont
source: "qrc:/qml/fonts/SourceSansPro-Regular.ttf"
} }
FontLoader SourceSansProBold
{ {
id: boldFont id: boldFont
source: "qrc:/qml/fonts/SourceSansPro-Bold.ttf"
} }
RowLayout RowLayout

4
mix/qml/NewProjectDialog.qml

@ -5,7 +5,7 @@ import QtQuick.Window 2.0
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Window { Window {
id: newProjectWin
modality: Qt.WindowModal modality: Qt.WindowModal
width: 640 width: 640
@ -18,6 +18,8 @@ Window {
signal accepted signal accepted
function open() { function open() {
newProjectWin.setX((Screen.width - width) / 2);
newProjectWin.setY((Screen.height - height) / 2);
visible = true; visible = true;
titleField.focus = true; titleField.focus = true;
} }

4
mix/qml/ProjectList.qml

@ -12,10 +12,10 @@ Item {
anchors.fill: parent anchors.fill: parent
id: filesCol id: filesCol
spacing: 0 spacing: 0
FontLoader
SourceSansProLight
{ {
id: srcSansProLight id: srcSansProLight
source: "qrc:/qml/fonts/SourceSansPro-Light.ttf"
} }
Rectangle Rectangle

9
mix/qml/QHashTypeView.qml

@ -4,13 +4,22 @@ Item
{ {
property alias text: textinput.text property alias text: textinput.text
id: editRoot id: editRoot
SourceSansProBold
{
id: boldFont
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4
color: "#f7f7f7"
TextInput { TextInput {
id: textinput id: textinput
text: text text: text
anchors.fill: parent anchors.fill: parent
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
font.family: boldFont.name
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent

9
mix/qml/QIntTypeView.qml

@ -4,12 +4,21 @@ Item
{ {
property alias text: textinput.text property alias text: textinput.text
id: editRoot id: editRoot
SourceSansProBold
{
id: boldFont
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4
color: "#f7f7f7"
TextInput { TextInput {
id: textinput id: textinput
text: text text: text
anchors.fill: parent anchors.fill: parent
font.family: boldFont.name
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent

9
mix/qml/QStringTypeView.qml

@ -4,13 +4,22 @@ Item
{ {
property alias text: textinput.text property alias text: textinput.text
id: editRoot id: editRoot
SourceSansProBold
{
id: boldFont
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4
color: "#f7f7f7"
TextInput { TextInput {
id: textinput id: textinput
text: text text: text
anchors.fill: parent anchors.fill: parent
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
font.family: boldFont.name
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent

6
mix/qml/SourceSansProBold.qml

@ -0,0 +1,6 @@
import QtQuick 2.0
FontLoader
{
source: "qrc:/qml/fonts/SourceSansPro-Bold.ttf"
}

7
mix/qml/SourceSansProLight.qml

@ -0,0 +1,7 @@
import QtQuick 2.0
FontLoader
{
source: "qrc:/qml/fonts/SourceSansPro-Light.ttf"
}

8
mix/qml/SourceSansProRegular.qml

@ -0,0 +1,8 @@
import QtQuick 2.0
FontLoader
{
source: "qrc:/qml/fonts/SourceSansPro-Regular.ttf"
}

113
mix/qml/StateDialog.qml

@ -2,6 +2,7 @@ import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/QEtherHelper.js" as QEtherHelper import "js/QEtherHelper.js" as QEtherHelper
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
@ -11,10 +12,11 @@ Window {
id: modalStateDialog id: modalStateDialog
modality: Qt.WindowModal modality: Qt.WindowModal
width: 640 width: 450
height: 480 height: 480
title: qsTr("State Edition")
visible: false visible: false
color: StateDialogStyle.generic.backgroundColor
property alias stateTitle: titleField.text property alias stateTitle: titleField.text
property alias stateBalance: balanceField.value property alias stateBalance: balanceField.value
@ -34,6 +36,10 @@ Window {
transactionsModel.append(item.transactions[t]); transactionsModel.append(item.transactions[t]);
stateTransactions.push(item.transactions[t]); stateTransactions.push(item.transactions[t]);
} }
modalStateDialog.setX((Screen.width - width) / 2);
modalStateDialog.setY((Screen.height - height) / 2);
visible = true; visible = true;
isDefault = setDefault; isDefault = setDefault;
titleField.focus = true; titleField.focus = true;
@ -54,25 +60,38 @@ Window {
return item; return item;
} }
SourceSansProRegular
{
id: regularFont
}
Rectangle {
anchors.fill: parent
anchors.margins: 10
color: StateDialogStyle.generic.backgroundColor
GridLayout { GridLayout {
id: dialogContent id: dialogContent
columns: 2 columns: 2
anchors.fill: parent anchors.top: parent.top
anchors.margins: 10
rowSpacing: 10 rowSpacing: 10
columnSpacing: 10 columnSpacing: 10
Label { Label {
text: qsTr("Title") text: qsTr("Title")
font.family: regularFont.name
color: "#808080"
} }
TextField { TextField {
id: titleField id: titleField
focus: true focus: true
Layout.fillWidth: true Layout.fillWidth: true
font.family: regularFont.name
} }
Label { Label {
text: qsTr("Balance") text: qsTr("Balance")
font.family: regularFont.name
color: "#808080"
} }
Ether { Ether {
id: balanceField id: balanceField
@ -83,32 +102,67 @@ Window {
Label { Label {
text: qsTr("Default") text: qsTr("Default")
font.family: regularFont.name
color: "#808080"
} }
CheckBox { CheckBox {
id: defaultCheckBox id: defaultCheckBox
Layout.fillWidth: true Layout.fillWidth: true
} }
}
ColumnLayout {
anchors.top: dialogContent.bottom
anchors.topMargin: 5
spacing: 5
RowLayout
{
Label { Label {
text: qsTr("Transactions") text: qsTr("Transactions")
font.family: regularFont.name
color: "#808080"
} }
Button {
tooltip: qsTr("Create a new transaction")
onClicked: transactionsModel.addTransaction()
height: 5
width: 5
style: ButtonStyle {
label: Text {
font.family: regularFont.name
text: qsTr("+")
font.pointSize: 15
color: "#808080"
height: 5
width: 5
}
background: Rectangle {
radius: 4
border.width: 1
color: "#f7f7f7"
height: 5
implicitHeight: 5
}
}
}
}
ListView { ListView {
Layout.fillWidth: true id: trList
Layout.preferredWidth: 200
Layout.fillHeight: true Layout.fillHeight: true
Layout.minimumHeight: 20 * transactionsModel.count
model: transactionsModel model: transactionsModel
delegate: transactionRenderDelegate delegate: transactionRenderDelegate
} visible: transactionsModel.count > 0
Label {
}
Button {
text: qsTr("Add")
onClicked: transactionsModel.addTransaction()
} }
} }
RowLayout {
RowLayout
{
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right; anchors.right: parent.right;
@ -124,6 +178,7 @@ Window {
onClicked: close(); onClicked: close();
} }
} }
}
ListModel { ListModel {
id: transactionsModel id: transactionsModel
@ -161,26 +216,51 @@ Window {
text: functionId text: functionId
font.pointSize: StateStyle.general.basicFontSize //12 font.pointSize: StateStyle.general.basicFontSize //12
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
font.family: regularFont.name
} }
ToolButton { ToolButton {
text: qsTr("Edit"); text: qsTr("Edit");
visible: !stdContract visible: !stdContract
Layout.fillHeight: true Layout.fillHeight: true
onClicked: transactionsModel.editTransaction(index) onClicked: transactionsModel.editTransaction(index)
style: ButtonStyle {
label: Text {
font.family: regularFont.name
text: qsTr("Edit")
font.italic: true
font.pointSize: 9
}
background: Rectangle {
color: "transparent"
}
}
} }
ToolButton { ToolButton {
visible: index >= 0 ? !transactionsModel.get(index).executeConstructor : false visible: index >= 0 ? !transactionsModel.get(index).executeConstructor : false
text: qsTr("Delete"); text: qsTr("Delete");
Layout.fillHeight: true Layout.fillHeight: true
onClicked: transactionsModel.deleteTransaction(index) onClicked: transactionsModel.deleteTransaction(index)
style: ButtonStyle {
label: Text {
font.family: regularFont.name
text: qsTr("Delete")
font.italic: true
font.pointSize: 9
}
background: Rectangle {
color: "transparent"
}
}
} }
} }
} }
} }
TransactionDialog { TransactionDialog
{
id: transactionDialog id: transactionDialog
onAccepted: { onAccepted:
{
var item = transactionDialog.getItem(); var item = transactionDialog.getItem();
if (transactionDialog.transactionIndex < transactionsModel.count) { if (transactionDialog.transactionIndex < transactionsModel.count) {
@ -192,5 +272,4 @@ Window {
} }
} }
} }
} }

17
mix/qml/StateDialogStyle.qml

@ -0,0 +1,17 @@
pragma Singleton
import QtQuick 2.0
QtObject {
property QtObject generic: QtObject
{
property string backgroundColor: "#ededed"
}
property QtObject stateDialog: QtObject
{
}
property QtObject transactionDialog: QtObject
{
}
}

1
mix/qml/StateListModel.qml

@ -2,6 +2,7 @@ import QtQuick 2.2
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import QtQuick.Window 2.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/QEtherHelper.js" as QEtherHelper import "js/QEtherHelper.js" as QEtherHelper

248
mix/qml/TransactionDialog.qml

@ -2,16 +2,19 @@ import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0
import "js/TransactionHelper.js" as TransactionHelper import "js/TransactionHelper.js" as TransactionHelper
import "."
Window { Window {
id: modalTransactionDialog id: modalTransactionDialog
modality: Qt.WindowModal modality: Qt.WindowModal
width:640 width: 450
height:640 height: (paramsModel.count > 0 ? 550 : 300)
visible: false visible: false
color: StateDialogStyle.generic.backgroundColor
title: qsTr("Transaction Edition")
property int transactionIndex property int transactionIndex
property alias transactionParams: paramsModel; property alias transactionParams: paramsModel;
property alias gas: gasField.value; property alias gas: gasField.value;
@ -63,6 +66,9 @@ Window {
for (var p = 0; p < parameters.length; p++) for (var p = 0; p < parameters.length; p++)
loadParameter(parameters[p]); loadParameter(parameters[p]);
} }
modalTransactionDialog.setX((Screen.width - width) / 2);
modalTransactionDialog.setY((Screen.height - height) / 2);
visible = true; visible = true;
valueField.focus = true; valueField.focus = true;
} }
@ -105,6 +111,15 @@ Window {
} }
} }
function param(name)
{
for (var k = 0; k < paramsModel.count; k++)
{
if (paramsModel.get(k).name === name)
return paramsModel.get(k);
}
}
function close() function close()
{ {
visible = false; visible = false;
@ -155,12 +170,21 @@ Window {
return item; return item;
} }
ColumnLayout { SourceSansProRegular
id: dialogContent {
width: parent.width id: regularFont
}
Rectangle {
anchors.fill: parent
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 10 anchors.margins: 10
color: StateDialogStyle.generic.backgroundColor
ColumnLayout {
id: dialogContent
spacing: 30 spacing: 30
RowLayout RowLayout
{ {
@ -170,10 +194,12 @@ Window {
Label { Label {
Layout.preferredWidth: 75 Layout.preferredWidth: 75
text: qsTr("Function") text: qsTr("Function")
font.family: regularFont.name
color: "#808080"
} }
ComboBox { ComboBox {
id: functionComboBox id: functionComboBox
Layout.fillWidth: true Layout.preferredWidth: 350
currentIndex: -1 currentIndex: -1
textRole: "text" textRole: "text"
editable: false editable: false
@ -183,6 +209,9 @@ Window {
onCurrentIndexChanged: { onCurrentIndexChanged: {
loadParameters(); loadParameters();
} }
style: ComboBoxStyle {
font: regularFont.name
}
} }
} }
@ -191,162 +220,135 @@ Window {
{ {
id: rowValue id: rowValue
Layout.fillWidth: true Layout.fillWidth: true
height: 150
Label { Label {
Layout.preferredWidth: 75 Layout.preferredWidth: 75
text: qsTr("Value") text: qsTr("Value")
font.family: regularFont.name
color: "#808080"
} }
Rectangle
{
Layout.fillWidth: true
Ether { Ether {
id: valueField id: valueField
edit: true edit: true
displayFormattedValue: true displayFormattedValue: true
} }
} }
}
RowLayout RowLayout
{ {
id: rowGas id: rowGas
Layout.fillWidth: true Layout.fillWidth: true
height: 150
Label { Label {
Layout.preferredWidth: 75 Layout.preferredWidth: 75
text: qsTr("Gas") text: qsTr("Gas")
font.family: regularFont.name
color: "#808080"
} }
Rectangle
{
Layout.fillWidth: true
Ether { Ether {
id: gasField id: gasField
edit: true edit: true
displayFormattedValue: true displayFormattedValue: true
} }
} }
}
RowLayout RowLayout
{ {
id: rowGasPrice id: rowGasPrice
Layout.fillWidth: true Layout.fillWidth: true
height: 150
Label { Label {
Layout.preferredWidth: 75 Layout.preferredWidth: 75
text: qsTr("Gas Price") text: qsTr("Gas Price")
font.family: regularFont.name
color: "#808080"
} }
Rectangle
{
Layout.fillWidth: true
Ether { Ether {
id: gasPriceField id: gasPriceField
edit: true edit: true
displayFormattedValue: true displayFormattedValue: true
} }
} }
}
RowLayout
{
Layout.fillWidth: true
Label { Label {
text: qsTr("Parameters") text: qsTr("Parameters")
Layout.preferredWidth: 75 Layout.preferredWidth: 75
} font.family: regularFont.name
TableView { color: "#808080"
model: paramsModel visible: paramsModel.count > 0
Layout.preferredWidth: 120 * 2 + 240
Layout.minimumHeight: 150
Layout.preferredHeight: 400
Layout.maximumHeight: 600
TableViewColumn {
role: "name"
title: qsTr("Name")
width: 120
}
TableViewColumn {
role: "type"
title: qsTr("Type")
width: 120
}
TableViewColumn {
role: "value"
title: qsTr("Value")
width: 240
}
rowDelegate: rowDelegate
itemDelegate: editableDelegate
}
}
} }
ScrollView
{
Layout.fillWidth: true
visible: paramsModel.count > 0
ColumnLayout
{
id: paramRepeater
Layout.fillWidth: true
spacing: 10
Repeater
{
anchors.fill: parent
model: paramsModel
visible: paramsModel.count > 0
RowLayout RowLayout
{ {
anchors.bottom: parent.bottom id: row
anchors.right: parent.right; Layout.fillWidth: true
height: 150
Button { Label {
text: qsTr("OK"); id: typeLabel
onClicked: { text: type
close(); font.family: regularFont.name
accepted(); Layout.preferredWidth: 50
}
}
Button {
text: qsTr("Cancel");
onClicked: close();
}
} }
Label {
ListModel { id: nameLabel
id: paramsModel text: name
font.family: regularFont.name
Layout.preferredWidth: 50
} }
Component { Label {
id: rowDelegate id: equalLabel
Item { text: "="
height: 100 font.family: regularFont.name
Layout.preferredWidth: 15
} }
Loader
{
id: typeLoader
Layout.preferredHeight: 50
Layout.preferredWidth: 150
function getCurrent()
{
return modalTransactionDialog.param(name);
} }
Component {
id: editableDelegate
Item {
Loader {
id: loaderEditor
anchors.fill: parent
anchors.margins: 4
Connections { Connections {
target: loaderEditor.item target: typeLoader.item
onTextChanged: { onTextChanged: {
if (styleData.role === "value" && styleData.row < paramsModel.count) typeLoader.getCurrent().value = typeLoader.item.text;
loaderEditor.updateValue(styleData.row, styleData.role, loaderEditor.item.text);
} }
} }
function updateValue(row, role, value)
{
paramsModel.setProperty(styleData.row, styleData.role, value);
}
sourceComponent: sourceComponent:
{ {
if (styleData.role === "value") if (type.indexOf("int") !== -1)
{
if (paramsModel.get(styleData.row) === undefined)
return null;
if (paramsModel.get(styleData.row).type.indexOf("int") !== -1)
return intViewComp; return intViewComp;
else if (paramsModel.get(styleData.row).type.indexOf("bool") !== -1) else if (type.indexOf("bool") !== -1)
return boolViewComp; return boolViewComp;
else if (paramsModel.get(styleData.row).type.indexOf("string") !== -1) else if (type.indexOf("string") !== -1)
return stringViewComp; return stringViewComp;
else if (paramsModel.get(styleData.row).type.indexOf("hash") !== -1) else if (type.indexOf("hash") !== -1)
return hashViewComp; return hashViewComp;
}
else else
return editor; return null;
} }
Component Component
@ -354,8 +356,10 @@ Window {
id: intViewComp id: intViewComp
QIntTypeView QIntTypeView
{ {
height: 50
width: 150
id: intView id: intView
text: styleData.value text: typeLoader.getCurrent().value
} }
} }
@ -364,14 +368,14 @@ Window {
id: boolViewComp id: boolViewComp
QBoolTypeView QBoolTypeView
{ {
height: 50
width: 150
id: boolView id: boolView
defaultValue: "1" defaultValue: "1"
Component.onCompleted: Component.onCompleted:
{ {
loaderEditor.updateValue(styleData.row, styleData.role, var current = typeLoader.getCurrent().value;
(paramsModel.get(styleData.row).value === "" ? defaultValue : (current === "" ? text = defaultValue : text = current);
paramsModel.get(styleData.row).value));
text = (paramsModel.get(styleData.row).value === "" ? defaultValue : paramsModel.get(styleData.row).value);
} }
} }
} }
@ -381,38 +385,54 @@ Window {
id: stringViewComp id: stringViewComp
QStringTypeView QStringTypeView
{ {
height: 50
width: 150
id: stringView id: stringView
text: styleData.value text:
{
return typeLoader.getCurrent().value
}
} }
} }
Component Component
{ {
id: hashViewComp id: hashViewComp
QHashTypeView QHashTypeView
{ {
height: 50
width: 150
id: hashView id: hashView
text: styleData.value text: typeLoader.getCurrent().value
}
}
}
}
}
}
} }
} }
Component { RowLayout
id: editor {
TextInput { anchors.bottom: parent.bottom
id: textinput anchors.right: parent.right;
readOnly: true
color: styleData.textColor Button {
text: styleData.value text: qsTr("OK");
MouseArea { onClicked: {
id: mouseArea close();
anchors.fill: parent accepted();
hoverEnabled: true
onClicked: textinput.forceActiveFocus()
} }
} }
Button {
text: qsTr("Cancel");
onClicked: close();
} }
} }
} }
ListModel {
id: paramsModel
} }
} }

1
mix/qml/qmldir

@ -1,3 +1,4 @@
singleton StateDialogStyle 1.0 StateDialogStyle.qml
singleton ProjectFilesStyle 1.0 ProjectFilesStyle.qml singleton ProjectFilesStyle 1.0 ProjectFilesStyle.qml
singleton DebuggerPaneStyle 1.0 DebuggerPaneStyle.qml singleton DebuggerPaneStyle 1.0 DebuggerPaneStyle.qml
singleton StateStyle 1.0 StateStyle.qml singleton StateStyle 1.0 StateStyle.qml

4
mix/res.qrc

@ -81,6 +81,10 @@
<file>qml/img/closedtriangleindicator_filesproject.png</file> <file>qml/img/closedtriangleindicator_filesproject.png</file>
<file>qml/img/opentriangleindicator_filesproject.png</file> <file>qml/img/opentriangleindicator_filesproject.png</file>
<file>qml/img/projecticon.png</file> <file>qml/img/projecticon.png</file>
<file>qml/SourceSansProRegular.qml</file>
<file>qml/SourceSansProBold.qml</file>
<file>qml/SourceSansProLight.qml</file>
<file>qml/StateDialogStyle.qml</file>
<file>qml/ProjectFilesStyle.qml</file> <file>qml/ProjectFilesStyle.qml</file>
<file>qml/DebuggerPaneStyle.qml</file> <file>qml/DebuggerPaneStyle.qml</file>
<file>qml/CodeEditorStyle.qml</file> <file>qml/CodeEditorStyle.qml</file>

12
test/SolidityEndToEndTest.cpp

@ -963,7 +963,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("data()") == encodeArgs(8)); BOOST_CHECK(callContractFunction("data()") == encodeArgs(8));
BOOST_CHECK(callContractFunction("name()") == encodeArgs("Celina")); BOOST_CHECK(callContractFunction("name()") == encodeArgs("Celina"));
BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(bytes({0x7b})))); BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(bytes{0x7b})));
BOOST_CHECK(callContractFunction("an_address()") == encodeArgs(toBigEndian(u160(0x1337)))); BOOST_CHECK(callContractFunction("an_address()") == encodeArgs(toBigEndian(u160(0x1337))));
BOOST_CHECK(callContractFunction("super_secret_data()") == bytes()); BOOST_CHECK(callContractFunction("super_secret_data()") == bytes());
} }
@ -2202,8 +2202,8 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals)
BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs( BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs(
dev::sha3( dev::sha3(
toBigEndian(u256(10)) + toBigEndian(u256(10)) +
bytes({0x0, 0xc}) + bytes{0x0, 0xc} +
bytes({0x91})))); bytes{0x91})));
} }
BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals)
@ -2226,9 +2226,9 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals)
BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs( BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs(
dev::sha3( dev::sha3(
toBigEndian(u256(10)) + toBigEndian(u256(10)) +
bytes({0x0, 0xc}) + bytes{0x0, 0xc} +
bytes({0x91}) + bytes{0x91} +
bytes({0x66, 0x6f, 0x6f})))); bytes{0x66, 0x6f, 0x6f})));
} }
BOOST_AUTO_TEST_CASE(generic_call) BOOST_AUTO_TEST_CASE(generic_call)

Loading…
Cancel
Save