Browse Source

fix for #2194 #2145

cl-refactor
yann300 10 years ago
parent
commit
0ea695c699
  1. 13
      mix/ContractCallDataEncoder.cpp
  2. 1
      mix/ContractCallDataEncoder.h
  3. 9
      mix/qml/js/ProjectModel.js

13
mix/ContractCallDataEncoder.cpp

@ -248,12 +248,15 @@ dev::bytes ContractCallDataEncoder::decodeBytes(dev::bytes const& _rawValue)
}
QString ContractCallDataEncoder::toString(dev::bytes const& _b)
{
return QString::fromStdString(dev::toJS(_b));
}
QString ContractCallDataEncoder::toChar(dev::bytes const& _b)
{
QString str;
if (asString(_b, str))
return "\"" + str + "\" " + QString::fromStdString(dev::toJS(_b));
else
return QString::fromStdString(dev::toJS(_b));
asString(_b, str);
return str;
}
@ -269,6 +272,8 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
return QVariant::fromValue(toString(decodeBool(rawParam)));
else if (type == QSolidityType::Type::Bytes || type == QSolidityType::Type::Hash)
return QVariant::fromValue(toString(decodeBytes(rawParam)));
else if (type == QSolidityType::Type::String)
return QVariant::fromValue(toChar(decodeBytes(rawParam)));
else if (type == QSolidityType::Type::Struct)
return QVariant::fromValue(QString("struct")); //TODO
else if (type == QSolidityType::Type::Address)

1
mix/ContractCallDataEncoder.h

@ -71,6 +71,7 @@ private:
bool asString(dev::bytes const& _b, QString& _str);
QList<int> extractDimension(QString const& _type);
void encodeArray(QJsonArray const& _array, QList<int> _dim, SolidityType const& _type, bytes& _content);
QString toChar(dev::bytes const& _b);
private:
bytes m_encodedData;

9
mix/qml/js/ProjectModel.js

@ -252,8 +252,10 @@ function doCreateProject(title, path) {
files: [ contractsFile, indexFile ]
};
//TODO: copy from template
fileIo.writeFile(dirPath + indexFile, htmlTemplate);
fileIo.writeFile(dirPath + contractsFile, contractTemplate);
if (!fileIo.fileExists(dirPath + indexFile))
fileIo.writeFile(dirPath + indexFile, htmlTemplate);
if (!fileIo.fileExists(dirPath + contractsFile))
fileIo.writeFile(dirPath + contractsFile, contractTemplate);
newProject(projectData);
var json = JSON.stringify(projectData, null, "\t");
fileIo.writeFile(projectFile, json);
@ -340,7 +342,8 @@ function newContract() {
function createAndAddFile(name, extension, content) {
var fileName = generateFileName(name, extension);
var filePath = projectPath + fileName;
fileIo.writeFile(filePath, content);
if (!fileIo.fileExists(filePath))
fileIo.writeFile(filePath, content);
var id = addFile(fileName);
saveProjectFile();
documentAdded(id);

Loading…
Cancel
Save