Browse Source

- If param is address type, allow to easily fill in param width used

accounts
cl-refactor
yann300 10 years ago
parent
commit
962d0eaaf2
  1. 4
      mix/ContractCallDataEncoder.cpp
  2. 21
      mix/qml/QAddressView.qml
  3. 2
      mix/qml/StateListModel.qml
  4. 33
      mix/qml/StructView.qml
  5. 4
      mix/qml/TransactionDialog.qml
  6. 2
      mix/qml/VariablesView.qml

4
mix/ContractCallDataEncoder.cpp

@ -195,7 +195,7 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
bytes rawParam(32); bytes rawParam(32);
value.populate(&rawParam); value.populate(&rawParam);
QSolidityType::Type type = _type.type; QSolidityType::Type type = _type.type;
if (type == QSolidityType::Type::SignedInteger || type == QSolidityType::Type::UnsignedInteger || type == QSolidityType::Type::Address) if (type == QSolidityType::Type::SignedInteger || type == QSolidityType::Type::UnsignedInteger)
return QVariant::fromValue(toString(decodeInt(rawParam))); return QVariant::fromValue(toString(decodeInt(rawParam)));
else if (type == QSolidityType::Type::Bool) else if (type == QSolidityType::Type::Bool)
return QVariant::fromValue(toString(decodeBool(rawParam))); return QVariant::fromValue(toString(decodeBool(rawParam)));
@ -203,6 +203,8 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
return QVariant::fromValue(toString(decodeBytes(rawParam))); return QVariant::fromValue(toString(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)
return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam))));
else else
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found")); BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found"));
} }

21
mix/qml/QAddressView.qml

@ -5,10 +5,12 @@ import QtQuick.Controls.Styles 1.3
Item Item
{ {
property alias value: textinput.text property alias value: textinput.text
property alias contractCreationTr: ctrModel property alias accountRef: ctrModel
property string subType
property bool readOnly
id: editRoot id: editRoot
height: 20 height: 20
width: 200 width: 320
SourceSansProBold SourceSansProBold
{ {
@ -17,19 +19,19 @@ Item
function init() function init()
{ {
trCombobox.visible = ctrModel.count > 1; //index 0 is a blank value. trCombobox.visible = !readOnly
if (value.indexOf("<") === 0) textinput.readOnly = readOnly
if (!readOnly)
{ {
for (var k = 0; k < ctrModel.count; k++) for (var k = 0; k < ctrModel.count; k++)
{ {
if ("<" + ctrModel.get(k).functionId + ">" === value) if (ctrModel.get(k).value === value)
{ {
trCombobox.currentIndex = k; trCombobox.currentIndex = k;
return; return;
} }
} }
trCombobox.currentIndex = 0; trCombobox.currentIndex = 0;
value = "";
} }
} }
@ -43,7 +45,7 @@ Item
text: value text: value
width: parent.width width: parent.width
height: parent.width height: parent.width
wrapMode: Text.WrapAnywhere wrapMode: Text.WordWrap
clip: true clip: true
font.family: boldFont.name font.family: boldFont.name
MouseArea { MouseArea {
@ -73,7 +75,7 @@ Item
property bool selected: false property bool selected: false
id: trCombobox id: trCombobox
model: ctrModel model: ctrModel
textRole: "functionId" textRole: "itemid"
height: 20 height: 20
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: textinput.parent.right anchors.left: textinput.parent.right
@ -84,7 +86,10 @@ Item
return; return;
else if (currentText !== " - ") else if (currentText !== " - ")
{ {
if (model.get(currentIndex).type === "contract")
textinput.text = "<" + currentText + ">"; textinput.text = "<" + currentText + ">";
else
textinput.text = model.get(currentIndex).value; //address
trCombobox.selected = true; trCombobox.selected = true;
} }
else if (textinput.text.indexOf("<") === 0) else if (textinput.text.indexOf("<") === 0)

2
mix/qml/StateListModel.qml

@ -183,7 +183,7 @@ Item {
_secret = clientModel.newSecret(); _secret = clientModel.newSecret();
var address = clientModel.address(_secret); var address = clientModel.address(_secret);
var name = qsTr("Account") + "-" + address.substring(0, 4); var name = qsTr("Account") + "-" + address.substring(0, 4);
return { name: name, secret: _secret, balance: QEtherHelper.createEther(_balance, _unit) }; return { name: name, secret: _secret, balance: QEtherHelper.createEther(_balance, _unit), address: address };
} }
function createDefaultState() { function createDefaultState() {

33
mix/qml/StructView.qml

@ -7,8 +7,10 @@ Column
{ {
id: root id: root
property alias members: repeater.model //js array property alias members: repeater.model //js array
property variant accounts
property var value: ({}) property var value: ({})
property int transactionIndex property int transactionIndex
property string context
Layout.fillWidth: true Layout.fillWidth: true
spacing: 10 spacing: 10
Repeater Repeater
@ -69,21 +71,40 @@ Column
var vals = value; var vals = value;
if (ptype.category === QSolidityType.Address) if (ptype.category === QSolidityType.Address)
{ {
item.contractCreationTr.append({"functionId": " - "}); item.value = getValue();
var trCr = -1; item.readOnly = context === "variable";
if (context === "parameter")
{
var dec = modelData.type.name.split(" ");
item.subType = dec[0];
item.accountRef.append({"itemid": " - "});
if (item.subType === "contract" || item.subType === "address")
{
var trCr = 0;
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) if (tr.functionId === tr.contractId && (dec[1] === tr.contractId || item.subType === "address"))
{ {
item.accountRef.append({ "itemid": tr.contractId + " - " + trCr, "value": "<" + tr.contractId + " - " + trCr + ">", "type": "contract" });
trCr++; trCr++;
if (modelData.type.name === qsTr("contract") + " " + tr.contractId)
item.contractCreationTr.append({ "functionId": tr.contractId + " - " + trCr });
} }
} }
item.value = getValue(); }
if (item.subType === "address")
{
for (k = 0; k < accounts.length; k++)
{
if (accounts[k].address === undefined)
accounts[k].address = clientModel.address(accounts[k].secret);
item.accountRef.append({ "itemid": accounts[k].name, "value": "0x" + accounts[k].address, "type": "address" });
}
}
}
item.init(); item.init();
} }
else if (ptype.category === QSolidityType.Struct && !item.members) else if (ptype.category === QSolidityType.Struct && !item.members)

4
mix/qml/TransactionDialog.qml

@ -11,7 +11,7 @@ import "."
Dialog { Dialog {
id: modalTransactionDialog id: modalTransactionDialog
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
width: 520 width: 570
height: 500 height: 500
visible: false visible: false
title: qsTr("Edit Transaction") title: qsTr("Edit Transaction")
@ -387,6 +387,8 @@ Dialog {
id: typeLoader id: typeLoader
Layout.preferredWidth: 150 Layout.preferredWidth: 150
members: paramsModel; members: paramsModel;
accounts: senderComboBox.model
context: "parameter"
} }
} }

2
mix/qml/VariablesView.qml

@ -24,6 +24,8 @@ DebugInfoList
members: [] members: []
value: {} value: {}
Layout.preferredWidth: parent.width Layout.preferredWidth: parent.width
context: "variable"
width: parent.width
} }
} }
} }

Loading…
Cancel
Save