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. 23
      mix/qml/QAddressView.qml
  3. 2
      mix/qml/StateListModel.qml
  4. 43
      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);
value.populate(&rawParam);
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)));
else if (type == QSolidityType::Type::Bool)
return QVariant::fromValue(toString(decodeBool(rawParam)));
@ -203,6 +203,8 @@ QVariant ContractCallDataEncoder::decode(SolidityType const& _type, bytes const&
return QVariant::fromValue(toString(decodeBytes(rawParam)));
else if (type == QSolidityType::Type::Struct)
return QVariant::fromValue(QString("struct")); //TODO
else if (type == QSolidityType::Type::Address)
return QVariant::fromValue(toString(decodeBytes(unpadLeft(rawParam))));
else
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Parameter declaration not found"));
}

23
mix/qml/QAddressView.qml

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

2
mix/qml/StateListModel.qml

@ -183,7 +183,7 @@ Item {
_secret = clientModel.newSecret();
var address = clientModel.address(_secret);
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() {

43
mix/qml/StructView.qml

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

4
mix/qml/TransactionDialog.qml

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

2
mix/qml/VariablesView.qml

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

Loading…
Cancel
Save