Browse Source

enum as input parameter

cl-refactor
DEV Mac Mini 10 years ago
parent
commit
e18f42fefb
  1. 6
      mix/ContractCallDataEncoder.cpp
  2. 2
      mix/ContractCallDataEncoder.h
  3. 2
      mix/qml/StructView.qml
  4. 2
      mix/qml/js/InputValidator.js

6
mix/ContractCallDataEncoder.cpp

@ -298,10 +298,16 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
return QVariant::fromValue(QString("struct")); //TODO return QVariant::fromValue(QString("struct")); //TODO
else if (type == QSolidityType::Type::Address) else if (type == QSolidityType::Type::Address)
return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam)))); return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam))));
else if (type == QSolidityType::Type::Enum)
return QVariant::fromValue(decodeEnum(rawParam));
else else
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found")); 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) QString ContractCallDataEncoder::decode(QVariableDeclaration* const& _param, bytes _value)
{ {
SolidityType const& type = _param->type()->type(); SolidityType const& type = _param->type()->type();

2
mix/ContractCallDataEncoder.h

@ -64,6 +64,8 @@ public:
QJsonArray decodeArray(SolidityType const& _type, bytes const& _value, int& pos); QJsonArray decodeArray(SolidityType const& _type, bytes const& _value, int& pos);
/// Decode array items /// Decode array items
QJsonValue decodeArrayContent(SolidityType const& _type, bytes const& _value, int& pos); QJsonValue decodeArrayContent(SolidityType const& _type, bytes const& _value, int& pos);
/// Decode enum
QString decodeEnum(bytes _value);
private: private:
unsigned encodeSingleItem(QString const& _data, SolidityType const& _type, bytes& _dest); unsigned encodeSingleItem(QString const& _data, SolidityType const& _type, bytes& _dest);

2
mix/qml/StructView.qml

@ -60,6 +60,8 @@ Column
return Qt.createComponent("qrc:/qml/QHashTypeView.qml"); return Qt.createComponent("qrc:/qml/QHashTypeView.qml");
else if (t === QSolidityType.Struct) else if (t === QSolidityType.Struct)
return Qt.createComponent("qrc:/qml/StructView.qml"); return Qt.createComponent("qrc:/qml/StructView.qml");
else if (t === QSolidityType.Enum)
return Qt.createComponent("qrc:/qml/QStringTypeView.qml");
else if (t === QSolidityType.Address) else if (t === QSolidityType.Address)
return Qt.createComponent("qrc:/qml/QAddressView.qml"); return Qt.createComponent("qrc:/qml/QAddressView.qml");
else else

2
mix/qml/js/InputValidator.js

@ -38,6 +38,8 @@ function check(type, value)
res = validateArray(type, value); res = validateArray(type, value);
else if (type.indexOf("int") !== -1) else if (type.indexOf("int") !== -1)
res = validateInt(type, value); res = validateInt(type, value);
else if (type.indexOf("enum") !== -1)
res = validateInt(type, value);
else if (type.indexOf("bytes") !== -1) else if (type.indexOf("bytes") !== -1)
res = validateBytes(type, value); res = validateBytes(type, value);
else if (type.indexOf("bool") !== -1) else if (type.indexOf("bool") !== -1)

Loading…
Cancel
Save