diff --git a/mix/ContractCallDataEncoder.cpp b/mix/ContractCallDataEncoder.cpp index ff858efbf..264b66359 100644 --- a/mix/ContractCallDataEncoder.cpp +++ b/mix/ContractCallDataEncoder.cpp @@ -298,10 +298,16 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const& return QVariant::fromValue(QString("struct")); //TODO else if (type == QSolidityType::Type::Address) return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam)))); + else if (type == QSolidityType::Type::Enum) + return QVariant::fromValue(decodeEnum(rawParam)); else BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found")); } +QString ContractCallDataEncoder::decodeEnum(bytes _value){ + return toChar(decodeBytes(_value)); +} + QString ContractCallDataEncoder::decode(QVariableDeclaration* const& _param, bytes _value) { SolidityType const& type = _param->type()->type(); diff --git a/mix/ContractCallDataEncoder.h b/mix/ContractCallDataEncoder.h index 8eb1569e4..d62b65187 100644 --- a/mix/ContractCallDataEncoder.h +++ b/mix/ContractCallDataEncoder.h @@ -64,6 +64,8 @@ public: QJsonArray decodeArray(SolidityType const& _type, bytes const& _value, int& pos); /// Decode array items QJsonValue decodeArrayContent(SolidityType const& _type, bytes const& _value, int& pos); + /// Decode enum + QString decodeEnum(bytes _value); private: unsigned encodeSingleItem(QString const& _data, SolidityType const& _type, bytes& _dest); diff --git a/mix/qml/StructView.qml b/mix/qml/StructView.qml index bd2cbf598..95ae3705b 100644 --- a/mix/qml/StructView.qml +++ b/mix/qml/StructView.qml @@ -60,6 +60,8 @@ Column return Qt.createComponent("qrc:/qml/QHashTypeView.qml"); else if (t === QSolidityType.Struct) return Qt.createComponent("qrc:/qml/StructView.qml"); + else if (t === QSolidityType.Enum) + return Qt.createComponent("qrc:/qml/QStringTypeView.qml"); else if (t === QSolidityType.Address) return Qt.createComponent("qrc:/qml/QAddressView.qml"); else diff --git a/mix/qml/js/InputValidator.js b/mix/qml/js/InputValidator.js index 7190ae291..c0626e0f1 100644 --- a/mix/qml/js/InputValidator.js +++ b/mix/qml/js/InputValidator.js @@ -38,6 +38,8 @@ function check(type, value) res = validateArray(type, value); else if (type.indexOf("int") !== -1) res = validateInt(type, value); + else if (type.indexOf("enum") !== -1) + res = validateInt(type, value); else if (type.indexOf("bytes") !== -1) res = validateBytes(type, value); else if (type.indexOf("bool") !== -1)