diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index eae3f8834..23f68996c 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -674,8 +674,8 @@ void ClientModel::debugRecord(unsigned _index) Address ClientModel::deployContract(bytes const& _code, TransactionSettings const& _ctrTransaction) { - Address newAddress = m_client->submitTransaction(_ctrTransaction.sender, _ctrTransaction.value, _code, _ctrTransaction.gas, _ctrTransaction.gasPrice, _ctrTransaction.gasAuto); - return newAddress; + m_client->submitTransaction(_ctrTransaction.sender, _ctrTransaction.value, _code, _ctrTransaction.gas, _ctrTransaction.gasPrice, _ctrTransaction.gasAuto); + return m_client->lastCreatedContractAddr(); } void ClientModel::callAddress(Address const& _contract, bytes const& _data, TransactionSettings const& _tr) diff --git a/mix/ClientModel.h b/mix/ClientModel.h index 92f06b48b..ca8c36b79 100644 --- a/mix/ClientModel.h +++ b/mix/ClientModel.h @@ -252,7 +252,7 @@ private: QVariantMap contractAddresses() const; QVariantList gasCosts() const; void executeSequence(std::vector const& _sequence); - dev::Address deployContract(bytes const& _code, TransactionSettings const& _tr = TransactionSettings()); + Address deployContract(bytes const& _code, TransactionSettings const& _tr = TransactionSettings()); void callAddress(Address const& _contract, bytes const& _data, TransactionSettings const& _tr); void onNewTransaction(); void onStateReset(); diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index 7978ff1ac..c41661046 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -313,6 +313,12 @@ h256 MixClient::submitTransaction(eth::TransactionSkeleton const& _ts, Secret co return t.sha3(); } +Address MixClient::lastCreatedContractAddr() const +{ + Transaction tr = m_state.pending().back(); + return tr.isCreation() ? right160(sha3(rlpList(tr.sender(), tr.nonce()))) : Address(); +} + dev::eth::ExecutionResult MixClient::call(Address const& _from, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, bool _gasAuto, FudgeFactor _ff) { (void)_blockNumber; diff --git a/mix/MixClient.h b/mix/MixClient.h index e4ad9c133..5b1b155a1 100644 --- a/mix/MixClient.h +++ b/mix/MixClient.h @@ -76,6 +76,9 @@ public: using Interface::blockInfo; // to remove warning about hiding virtual function eth::BlockInfo blockInfo() const; + /// return the new address generated by the last tr (if creation). returns empty address if other cases. + Address lastCreatedContractAddr() const; + protected: /// ClientBase methods using ClientBase::asOf;