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

1
mix/ContractCallDataEncoder.h

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

9
mix/qml/js/ProjectModel.js

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

Loading…
Cancel
Save