diff --git a/mix/ContractCallDataEncoder.cpp b/mix/ContractCallDataEncoder.cpp index 08e764955..bc3322145 100644 --- a/mix/ContractCallDataEncoder.cpp +++ b/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) diff --git a/mix/ContractCallDataEncoder.h b/mix/ContractCallDataEncoder.h index 629e46b0d..bec048c50 100644 --- a/mix/ContractCallDataEncoder.h +++ b/mix/ContractCallDataEncoder.h @@ -71,6 +71,7 @@ private: bool asString(dev::bytes const& _b, QString& _str); QList extractDimension(QString const& _type); void encodeArray(QJsonArray const& _array, QList _dim, SolidityType const& _type, bytes& _content); + QString toChar(dev::bytes const& _b); private: bytes m_encodedData; diff --git a/mix/qml/js/ProjectModel.js b/mix/qml/js/ProjectModel.js index 6fce7686d..f9c7a611c 100644 --- a/mix/qml/js/ProjectModel.js +++ b/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);