|
@ -256,22 +256,8 @@ void ClientModel::setupState(QVariantMap _state) |
|
|
u256 value = (qvariant_cast<QEther*>(transaction.value("value")))->toU256Wei(); |
|
|
u256 value = (qvariant_cast<QEther*>(transaction.value("value")))->toU256Wei(); |
|
|
u256 gasPrice = (qvariant_cast<QEther*>(transaction.value("gasPrice")))->toU256Wei(); |
|
|
u256 gasPrice = (qvariant_cast<QEther*>(transaction.value("gasPrice")))->toU256Wei(); |
|
|
QString sender = transaction.value("sender").toString(); |
|
|
QString sender = transaction.value("sender").toString(); |
|
|
bool isStdContract = transaction.value("stdContract").toBool(); |
|
|
|
|
|
bool isContractCreation = transaction.value("isContractCreation").toBool(); |
|
|
bool isContractCreation = transaction.value("isContractCreation").toBool(); |
|
|
bool isFunctionCall = transaction.value("isFunctionCall").toBool(); |
|
|
bool isFunctionCall = transaction.value("isFunctionCall").toBool(); |
|
|
if (isStdContract) |
|
|
|
|
|
{ |
|
|
|
|
|
if (contractId.isEmpty()) //TODO: This is to support old project files, remove later
|
|
|
|
|
|
contractId = functionId; |
|
|
|
|
|
TransactionSettings transactionSettings(contractId, transaction.value("url").toString()); |
|
|
|
|
|
transactionSettings.gasPrice = 10000000000000; |
|
|
|
|
|
transactionSettings.gasAuto = true; |
|
|
|
|
|
transactionSettings.value = 0; |
|
|
|
|
|
transactionSettings.sender = Secret(sender.toStdString()); |
|
|
|
|
|
transactionSequence.push_back(transactionSettings); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if (contractId.isEmpty() && m_codeModel->hasContract()) //TODO: This is to support old project files, remove later
|
|
|
if (contractId.isEmpty() && m_codeModel->hasContract()) //TODO: This is to support old project files, remove later
|
|
|
contractId = m_codeModel->contracts().keys()[0]; |
|
|
contractId = m_codeModel->contracts().keys()[0]; |
|
|
TransactionSettings transactionSettings(contractId, functionId, value, gas, gasAuto, gasPrice, Secret(sender.toStdString()), isContractCreation, isFunctionCall); |
|
|
TransactionSettings transactionSettings(contractId, functionId, value, gas, gasAuto, gasPrice, Secret(sender.toStdString()), isContractCreation, isFunctionCall); |
|
@ -282,7 +268,6 @@ void ClientModel::setupState(QVariantMap _state) |
|
|
|
|
|
|
|
|
transactionSequence.push_back(transactionSettings); |
|
|
transactionSequence.push_back(transactionSettings); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
m_ethAccounts->setAccounts(userAccounts); |
|
|
m_ethAccounts->setAccounts(userAccounts); |
|
|
executeSequence(transactionSequence, accounts, Secret(_state.value("miner").toMap().value("secret").toString().toStdString())); |
|
|
executeSequence(transactionSequence, accounts, Secret(_state.value("miner").toMap().value("secret").toString().toStdString())); |
|
|
} |
|
|
} |
|
@ -319,18 +304,6 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence, |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
ContractCallDataEncoder encoder; |
|
|
ContractCallDataEncoder encoder; |
|
|
if (!transaction.stdContractUrl.isEmpty()) |
|
|
|
|
|
{ |
|
|
|
|
|
//std contract
|
|
|
|
|
|
bytes const& stdContractCode = m_codeModel->getStdContractCode(transaction.contractId, transaction.stdContractUrl); |
|
|
|
|
|
TransactionSettings stdTransaction = transaction; |
|
|
|
|
|
stdTransaction.gasAuto = true; |
|
|
|
|
|
Address address = deployContract(stdContractCode, stdTransaction); |
|
|
|
|
|
m_stdContractAddresses[stdTransaction.contractId] = address; |
|
|
|
|
|
m_stdContractNames[address] = stdTransaction.contractId; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
//encode data
|
|
|
//encode data
|
|
|
CompiledContract const& compilerRes = m_codeModel->contract(ctrInstance.first); |
|
|
CompiledContract const& compilerRes = m_codeModel->contract(ctrInstance.first); |
|
|
QFunctionDefinition const* f = nullptr; |
|
|
QFunctionDefinition const* f = nullptr; |
|
@ -391,7 +364,6 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence, |
|
|
callAddress(contractAddressIter->second, encoder.encodedData(), transaction); |
|
|
callAddress(contractAddressIter->second, encoder.encodedData(), transaction); |
|
|
} |
|
|
} |
|
|
m_gasCosts.append(m_client->lastExecution().gasUsed); |
|
|
m_gasCosts.append(m_client->lastExecution().gasUsed); |
|
|
} |
|
|
|
|
|
onNewTransaction(); |
|
|
onNewTransaction(); |
|
|
} |
|
|
} |
|
|
m_running = false; |
|
|
m_running = false; |
|
@ -697,13 +669,6 @@ void ClientModel::onNewTransaction() |
|
|
if (creation) |
|
|
if (creation) |
|
|
{ |
|
|
{ |
|
|
//contract creation
|
|
|
//contract creation
|
|
|
auto const stdContractName = m_stdContractNames.find(tr.contractAddress); |
|
|
|
|
|
if (stdContractName != m_stdContractNames.end()) |
|
|
|
|
|
{ |
|
|
|
|
|
function = stdContractName->second; |
|
|
|
|
|
contract = function; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
function = QObject::tr("Constructor"); |
|
|
function = QObject::tr("Constructor"); |
|
|
address = QObject::tr("(Create contract)"); |
|
|
address = QObject::tr("(Create contract)"); |
|
|
} |
|
|
} |
|
|