Browse Source

bugfix: contract type as param.

cl-refactor
yann300 10 years ago
parent
commit
e33ae2e946
  1. 16
      mix/ClientModel.cpp
  2. 1
      mix/ClientModel.h
  3. 5
      mix/qml/Debugger.qml
  4. 13
      mix/qml/QAddressView.qml
  5. 14
      mix/qml/StateDialog.qml
  6. 11
      mix/qml/StructView.qml

16
mix/ClientModel.cpp

@ -237,7 +237,7 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence,
{ {
try try
{ {
map<Address, QString> deployedContracts; vector<Address> deployedContracts;
onStateReset(); onStateReset();
for (TransactionSettings const& transaction: _sequence) for (TransactionSettings const& transaction: _sequence)
{ {
@ -249,7 +249,7 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence,
TransactionSettings stdTransaction = transaction; TransactionSettings stdTransaction = transaction;
stdTransaction.gasAuto = true; stdTransaction.gasAuto = true;
Address address = deployContract(stdContractCode, stdTransaction); Address address = deployContract(stdContractCode, stdTransaction);
deployedContracts.insert(make_pair(address, transaction.contractId)); deployedContracts.push_back(address);
m_stdContractAddresses[stdTransaction.contractId] = address; m_stdContractAddresses[stdTransaction.contractId] = address;
m_stdContractNames[address] = stdTransaction.contractId; m_stdContractNames[address] = stdTransaction.contractId;
} }
@ -284,13 +284,9 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence,
QVariant value = transaction.parameterValues.value(p->name()); QVariant value = transaction.parameterValues.value(p->name());
if (type->type().type == SolidityType::Type::Address && value.toString().startsWith("<")) if (type->type().type == SolidityType::Type::Address && value.toString().startsWith("<"))
{ {
for (auto it = deployedContracts.begin(); it != deployedContracts.end(); ++it) value = value.toString().remove("<").remove(">");
{ QStringList nb = value.toString().split(" - ");
if (value.toString().remove("<").remove(">") == it->second) value = QVariant(QString::fromStdString("0x" + toHex(deployedContracts.at(nb.back().toInt()).ref())));
{
value = QVariant(QString::fromStdString(toHex(it->first.ref())));
}
}
} }
encoder.encode(value, type->type()); encoder.encode(value, type->type());
} }
@ -300,7 +296,7 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence,
bytes param = encoder.encodedData(); bytes param = encoder.encodedData();
contractCode.insert(contractCode.end(), param.begin(), param.end()); contractCode.insert(contractCode.end(), param.begin(), param.end());
Address newAddress = deployContract(contractCode, transaction); Address newAddress = deployContract(contractCode, transaction);
deployedContracts.insert(make_pair(newAddress, transaction.contractId)); deployedContracts.push_back(newAddress);
auto contractAddressIter = m_contractAddresses.find(transaction.contractId); auto contractAddressIter = m_contractAddresses.find(transaction.contractId);
if (contractAddressIter == m_contractAddresses.end() || newAddress != contractAddressIter->second) if (contractAddressIter == m_contractAddresses.end() || newAddress != contractAddressIter->second)
{ {

1
mix/ClientModel.h

@ -71,6 +71,7 @@ struct TransactionSettings
QString stdContractUrl; QString stdContractUrl;
/// Sender /// Sender
Secret sender; Secret sender;
}; };

5
mix/qml/Debugger.qml

@ -211,7 +211,7 @@ Rectangle {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 15 anchors.topMargin: 15
anchors.left: parent.left; anchors.left: parent.left;
anchors.leftMargin: machineStates.sideMargin anchors.leftMargin: machineStates.sideMargin
width: debugScrollArea.width - machineStates.sideMargin * 2 - 20 ; width: debugScrollArea.width - machineStates.sideMargin * 2 - 20 ;
spacing: machineStates.sideMargin spacing: machineStates.sideMargin
@ -641,9 +641,6 @@ Rectangle {
} }
} }
Rectangle Rectangle
{ {
id: storageRect id: storageRect

13
mix/qml/QAddressView.qml

@ -1,12 +1,13 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.3 import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3
Item Item
{ {
property alias value: textinput.text property alias value: textinput.text
property alias contractCreationTr: ctrModel property alias contractCreationTr: ctrModel
id: editRoot id: editRoot
height: 30 height: 20
width: 200 width: 200
SourceSansProBold SourceSansProBold
@ -16,6 +17,7 @@ Item
function init() function init()
{ {
trCombobox.visible = ctrModel.count > 1; //index 0 is a blank value.
if (value.indexOf("<") === 0) if (value.indexOf("<") === 0)
{ {
for (var k = 0; k < ctrModel.count; k++) for (var k = 0; k < ctrModel.count; k++)
@ -34,11 +36,13 @@ Item
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
radius: 4 radius: 4
anchors.verticalCenter: parent.verticalCenter
height: 20
TextInput { TextInput {
id: textinput id: textinput
text: value text: value
width: parent.width width: parent.width
height: 30 height: parent.width
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
clip: true clip: true
font.family: boldFont.name font.family: boldFont.name
@ -70,9 +74,12 @@ Item
id: trCombobox id: trCombobox
model: ctrModel model: ctrModel
textRole: "functionId" textRole: "functionId"
height: 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: textinput.parent.right anchors.left: textinput.parent.right
anchors.leftMargin: 3
onCurrentIndexChanged: { onCurrentIndexChanged: {
trCombobox.selected = false;
if (currentText === "") if (currentText === "")
return; return;
else if (currentText !== " - ") else if (currentText !== " - ")
@ -81,7 +88,9 @@ Item
trCombobox.selected = true; trCombobox.selected = true;
} }
else if (textinput.text.indexOf("<") === 0) else if (textinput.text.indexOf("<") === 0)
{
textinput.text = ""; textinput.text = "";
}
} }
} }
} }

14
mix/qml/StateDialog.qml

@ -366,7 +366,17 @@ Dialog {
DefaultLabel { DefaultLabel {
Layout.preferredWidth: 150 Layout.preferredWidth: 150
text: styleData.row >= 0 ? transactionsModel.get(styleData.row).functionId : "" text: {
if (styleData.row >= 0)
{
if (transactionsModel.get(styleData.row).label !== undefined)
return transactionsModel.get(styleData.row).label;
else if (transactionsModel.get(styleData.row).functionId !== undefined)
return transactionsModel.get(styleData.row).functionId;
}
else
return "";
}
} }
} }
} }
@ -378,7 +388,6 @@ Dialog {
} }
} }
} }
} }
RowLayout RowLayout
@ -456,7 +465,6 @@ Dialog {
onAccepted: onAccepted:
{ {
var item = transactionDialog.getItem(); var item = transactionDialog.getItem();
if (transactionDialog.transactionIndex < transactionsModel.count) { if (transactionDialog.transactionIndex < transactionsModel.count) {
transactionsModel.set(transactionDialog.transactionIndex, item); transactionsModel.set(transactionDialog.transactionIndex, item);
stateTransactions[transactionDialog.transactionIndex] = item; stateTransactions[transactionDialog.transactionIndex] = item;

11
mix/qml/StructView.qml

@ -20,7 +20,7 @@ Column
RowLayout RowLayout
{ {
id: row id: row
height: 20 + (members[index].type.category === QSolidityType.Struct ? (20 * members[index].type.members.length) : 0) height: 30 + (members[index].type.category === QSolidityType.Struct ? (20 * members[index].type.members.length) : 0)
Layout.fillWidth: true Layout.fillWidth: true
DefaultLabel { DefaultLabel {
height: 20 height: 20
@ -70,13 +70,18 @@ Column
if (ptype.category === QSolidityType.Address) if (ptype.category === QSolidityType.Address)
{ {
item.contractCreationTr.append({"functionId": " - "}); item.contractCreationTr.append({"functionId": " - "});
var trCr = -1;
for (var k = 0; k < transactionsModel.count; k++) for (var k = 0; k < transactionsModel.count; k++)
{ {
if (k >= transactionIndex) if (k >= transactionIndex)
break; break;
var tr = transactionsModel.get(k); var tr = transactionsModel.get(k);
if (tr.functionId === tr.contractId && modelData.type.name === qsTr("contract") + " " + tr.contractId) if (tr.functionId === tr.contractId)
item.contractCreationTr.append(tr); {
trCr++;
if (modelData.type.name === qsTr("contract") + " " + tr.contractId)
item.contractCreationTr.append({ "functionId": tr.contractId + " - " + trCr });
}
} }
item.value = getValue(); item.value = getValue();
item.init(); item.init();

Loading…
Cancel
Save