Browse Source

bug fix. issue while getting the created contract address.

cl-refactor
yann300 10 years ago
parent
commit
0236886d3e
  1. 8
      mix/ClientModel.cpp
  2. 2
      mix/ClientModel.h
  3. 6
      mix/MixClient.cpp
  4. 3
      mix/MixClient.h

8
mix/ClientModel.cpp

@ -390,7 +390,8 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence)
{
bytes param = encoder.encodedData();
contractCode.insert(contractCode.end(), param.begin(), param.end());
Address newAddress = deployContract(contractCode, transaction);
deployContract(contractCode, transaction);
Address newAddress = m_client->lastCreatedContractAddr();
std::pair<QString, int> contractToken = retrieveToken(transaction.contractId);
m_contractAddresses[contractToken] = newAddress;
m_contractNames[newAddress] = contractToken.first;
@ -672,10 +673,9 @@ void ClientModel::debugRecord(unsigned _index)
showDebuggerForTransaction(e);
}
Address ClientModel::deployContract(bytes const& _code, TransactionSettings const& _ctrTransaction)
void 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);
}
void ClientModel::callAddress(Address const& _contract, bytes const& _data, TransactionSettings const& _tr)

2
mix/ClientModel.h

@ -252,7 +252,7 @@ private:
QVariantMap contractAddresses() const;
QVariantList gasCosts() const;
void executeSequence(std::vector<TransactionSettings> const& _sequence);
dev::Address deployContract(bytes const& _code, TransactionSettings const& _tr = TransactionSettings());
void deployContract(bytes const& _code, TransactionSettings const& _tr = TransactionSettings());
void callAddress(Address const& _contract, bytes const& _data, TransactionSettings const& _tr);
void onNewTransaction();
void onStateReset();

6
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;

3
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;

Loading…
Cancel
Save