Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LianaHus committed Feb 19, 2016
1 parent bdc155d commit e2f1a8a
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 26 deletions.
82 changes: 74 additions & 8 deletions src/ClientModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,34 @@ struct SolidityType;
struct TransactionSettings
{
TransactionSettings() {}
TransactionSettings(QString const& _contractId, QString const& _functionId, u256 _value, u256 _gas, bool _gasAuto, u256 _gasPrice, Secret const& _sender, bool _isContractCreation, bool _isFunctionCall):
contractId(_contractId), functionId(_functionId), value(_value), gas(_gas), gasAuto(_gasAuto), gasPrice(_gasPrice), sender(_sender), isContractCreation(_isContractCreation), isFunctionCall(_isFunctionCall) {}
TransactionSettings(
QString const& _contractId,
QString const& _functionId,
u256 _value,
u256 _gas,
bool _gasAuto,
u256 _gasPrice,
Secret const& _sender,
bool _isContractCreation,
bool _isFunctionCall
):
contractId(_contractId),
functionId(_functionId),
value(_value),
gas(_gas),
gasAuto(_gasAuto),
gasPrice(_gasPrice),
sender(_sender),
isContractCreation(_isContractCreation),
isFunctionCall(_isFunctionCall)
{}
TransactionSettings(QString const& _stdContractName, QString const& _stdContractUrl):
contractId(_stdContractName), gasAuto(true), stdContractUrl(_stdContractUrl), isContractCreation(true), isFunctionCall(true) {}
contractId(_stdContractName),
gasAuto(true),
stdContractUrl(_stdContractUrl),
isContractCreation(true),
isFunctionCall(true)
{}

/// Contract name
QString contractId;
Expand Down Expand Up @@ -174,10 +198,46 @@ class RecordLogEntry: public QObject

RecordLogEntry():
m_recordIndex(0), m_call(false), m_type(RecordType::Transaction) {}
RecordLogEntry(unsigned _recordIndex, QString _transactionIndex, QString _contract, QString _function, QString _value, QString _address, QString _returned, bool _call, RecordType _type, QString _gasUsed,
QString _gasRequired, QString _gasRefunded, QString _sender, QString _label, QVariantMap _inputParameters, QVariantMap _returnParameters, QVariantList _logs, TxSource _source, TransactionException _exception):
m_recordIndex(_recordIndex), m_transactionIndex(_transactionIndex), m_contract(_contract), m_function(_function), m_value(_value), m_address(_address), m_returned(_returned), m_call(_call), m_type(_type), m_gasUsed(_gasUsed),
m_gasRequired(_gasRequired), m_gasRefunded(_gasRefunded), m_sender(_sender), m_label(_label), m_inputParameters(_inputParameters), m_returnParameters(_returnParameters), m_logs(_logs), m_source(_source), m_exception(_exception)
RecordLogEntry(
unsigned _recordIndex,
QString _transactionIndex,
QString _contract,
QString _function,
QString _value,
QString _address,
QString _returned,
bool _call,
RecordType _type,
QString _gasUsed,
QString _gasRequired,
QString _gasRefunded,
QString _sender,
QString _label,
QVariantMap _inputParameters,
QVariantMap _returnParameters,
QVariantList _logs,
TxSource _source,
TransactionException _exception
):
m_recordIndex(_recordIndex),
m_transactionIndex(_transactionIndex),
m_contract(_contract),
m_function(_function),
m_value(_value),
m_address(_address),
m_returned(_returned),
m_call(_call),
m_type(_type),
m_gasUsed(_gasUsed),
m_gasRequired(_gasRequired),
m_gasRefunded(_gasRefunded),
m_sender(_sender),
m_label(_label),
m_inputParameters(_inputParameters),
m_returnParameters(_returnParameters),
m_logs(_logs),
m_source(_source),
m_exception(_exception)
{
QMetaEnum ex = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("TransactionException"));
m_strException = QString(ex.valueToKey(m_exception));
Expand Down Expand Up @@ -341,7 +401,13 @@ private slots:
std::pair<QString, int> retrieveToken(QString const& _value);
std::pair<QString, int> resolvePair(QString const& _contractId);
QString serializeToken(std::pair<QString, int> const& _value) const;
QVariant formatStorageValue(SolidityType const& _type, std::unordered_map<dev::u256, dev::u256> const& _storage, unsigned const& _offset, dev::u256 const& _slot);
QVariant formatStorageValue(
SolidityType const& _type,
std::unordered_map<dev::u256,
dev::u256> const& _storage,
unsigned const& _offset,
dev::u256 const& _slot
);
QVariant formatMemoryValue(SolidityType const& _type, bytes const& _value, u256& _offset);
void processNextTransactions();
void finalizeBlock();
Expand Down
32 changes: 29 additions & 3 deletions src/CodeModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,25 @@ class GasMap: public QObject
Constructor
};

GasMap(int _start, int _end, QString _gas, bool _isInfinite, type _type, QString _contractName, QString _functionName, QObject* _parent): QObject(_parent),
m_start(_start), m_end(_end), m_gas(_gas), m_isInfinite(_isInfinite), m_type(_type), m_contractName(_contractName), m_functionName(_functionName) {}
GasMap(
int _start,
int _end,
QString _gas,
bool _isInfinite,
type _type,
QString _contractName,
QString _functionName,
QObject* _parent
):
QObject(_parent),
m_start(_start),
m_end(_end),
m_gas(_gas),
m_isInfinite(_isInfinite),
m_type(_type),
m_contractName(_contractName),
m_functionName(_functionName)
{}
QString contractName() { return m_contractName; }
QString functionName() { return m_functionName; }

Expand Down Expand Up @@ -193,7 +210,16 @@ class GasMapWrapper: public QObject
public:
GasMapWrapper(QObject* _parent = nullptr): QObject(_parent){}
~GasMapWrapper(){ m_gasMaps.clear(); }
void push(QString _source, int _start, int _end, QString _value, bool _isInfinite, GasMap::type _type, QString _contractName = "", QString _functionName = "");
void push(
QString _source,
int _start,
int _end,
QString _value,
bool _isInfinite,
GasMap::type _type,
QString _contractName = "",
QString _functionName = ""
);
bool contains(QString _key);
void insert(QString _source, QVariantList _variantList);
QVariantList gasCostsByDocId(QString _source);
Expand Down
23 changes: 20 additions & 3 deletions src/DebuggingStateWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,22 @@ class QSolState: public QObject
Q_PROPERTY(QString sourceName MEMBER m_sourceName CONSTANT)

public:
QSolState(QObject* _parent, QVariantMap&& _storage, QVariantList&& _callStack, QVariantMap&& _locals, int _start, int _end, QString _sourceName):
QObject(_parent), m_storage(_storage), m_callStack(_callStack), m_locals(_locals), m_start(_start), m_end(_end), m_sourceName(_sourceName)
QSolState(
QObject* _parent,
QVariantMap&& _storage,
QVariantList&& _callStack,
QVariantMap&& _locals,
int _start,
int _end,
QString _sourceName
):
QObject(_parent),
m_storage(_storage),
m_callStack(_callStack),
m_locals(_locals),
m_start(_start),
m_end(_end),
m_sourceName(_sourceName)
{ }

private:
Expand All @@ -91,7 +105,10 @@ class QCode: public QObject
Q_PROPERTY(QString documentId MEMBER m_document CONSTANT)

public:
QCode(QObject* _owner, QString const& _address, QVariantList&& _instrunctions): QObject(_owner), m_instructions(std::move(_instrunctions)), m_address(_address) {}
QCode(QObject* _owner, QString const& _address, QVariantList&& _instrunctions):
QObject(_owner),
m_instructions(std::move(_instrunctions)), m_address(_address)
{}
void setDocument(QString const& _documentId) { m_document = _documentId; }

private:
Expand Down
5 changes: 5 additions & 0 deletions src/MixClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ dev::eth::ExecutionResult MixClient::create(
return lastExecution().result;
}

pair<h256, Address> MixClient::submitTransaction(const TransactionSkeleton& _ts, const Secret& _secret)
{
return submitTransaction(_ts, _secret, false);
}

eth::BlockHeader MixClient::blockInfo() const
{
ReadGuard l(x_state);
Expand Down
34 changes: 30 additions & 4 deletions src/MixClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,39 @@ class MixClient: public dev::eth::ClientBase
ExecutionResult lastExecution() const;
ExecutionResult execution(unsigned _index) const;

dev::eth::ExecutionResult call(Address const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, eth::BlockNumber _blockNumber = eth::PendingBlock, eth::FudgeFactor _ff = eth::FudgeFactor::Strict) override;
dev::eth::ExecutionResult create(Address const& _secret, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * eth::szabo, eth::BlockNumber _blockNumber = eth::PendingBlock, eth::FudgeFactor _ff = eth::FudgeFactor::Strict) override;
dev::eth::ExecutionResult call(
Address const& _secret,
u256 _value,
Address _dest,
bytes const& _data,
u256 _gas, u256 _gasPrice,
eth::BlockNumber _blockNumber = eth::PendingBlock,
eth::FudgeFactor _ff = eth::FudgeFactor::Strict
) override;
dev::eth::ExecutionResult create(
Address const& _secret,
u256 _value,
bytes const& _data = bytes(),
u256 _gas = 10000,
u256 _gasPrice = 10 * eth::szabo,
eth::BlockNumber _blockNumber = eth::PendingBlock,
eth::FudgeFactor _ff = eth::FudgeFactor::Strict
) override;

using ClientBase::submitTransaction;
virtual std::pair<h256, Address> submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret) override { return submitTransaction(_ts, _secret, false); }
virtual std::pair<h256, Address> submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret) override;
std::pair<h256, Address> submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret, bool _gasAuto);
dev::eth::ExecutionResult call(Address const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, eth::BlockNumber _blockNumber, bool _gasAuto, eth::FudgeFactor _ff = eth::FudgeFactor::Strict);
dev::eth::ExecutionResult call(
Address const& _secret,
u256 _value,
Address _dest,
bytes const& _data,
u256 _gas,
u256 _gasPrice,
eth::BlockNumber _blockNumber,
bool _gasAuto,
eth::FudgeFactor _ff = eth::FudgeFactor::Strict
);
ExecutionResult debugTransaction(dev::eth::Transaction const& _t, eth:: State const& _state, eth::EnvInfo const& _envInfo, bool _call);
void setAuthor(Address const& _us) override;
void startSealing() override {}
Expand Down
33 changes: 28 additions & 5 deletions src/QBigInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,34 @@ class QBigInt: public QObject
Q_OBJECT

public:
QBigInt(QObject* _parent = 0): QObject(_parent), m_internalValue(dev::u256(0)) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::u256 const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::bigint const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(BigIntVariant const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value){ QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::s256 const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(QObject* _parent = 0): QObject(_parent), m_internalValue(dev::u256(0))
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
QBigInt(dev::u256 const& _value, QObject* _parent = 0):
QObject(_parent),
m_internalValue(_value)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
QBigInt(dev::bigint const& _value, QObject* _parent = 0):
QObject(_parent),
m_internalValue(_value)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
QBigInt(BigIntVariant const& _value, QObject* _parent = 0):
QObject(_parent),
m_internalValue(_value)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
QBigInt(dev::s256 const& _value, QObject* _parent = 0):
QObject(_parent),
m_internalValue(_value)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
}
~QBigInt() {}

/// @returns the current used big integer.
Expand Down
14 changes: 12 additions & 2 deletions src/QContractDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,25 @@ class QContractDefinition: public QBasicNodeDefinition
public:
QContractDefinition(QObject* _parent, solidity::ContractDefinition const* _contract);
/// Get all the functions of the contract.
QQmlListProperty<QFunctionDefinition> functions() const { return QQmlListProperty<QFunctionDefinition>(const_cast<QContractDefinition*>(this), const_cast<QContractDefinition*>(this)->m_functions); }
QQmlListProperty<QFunctionDefinition> functions() const {
return QQmlListProperty<QFunctionDefinition>(
const_cast<QContractDefinition*>(this),
const_cast<QContractDefinition*>(this)->m_functions
);
}
/// Get the constructor of the contract.
QFunctionDefinition* constructor() const { return m_constructor; }
/// Get all the functions of the contract.
QList<QFunctionDefinition*> const& functionsList() const { return m_functions; }
/// Find function by hash, returns nullptr if not found
QFunctionDefinition const* getFunction(dev::FixedHash<4> _hash) const;
/// Get events
QQmlListProperty<QFunctionDefinition> events() const { return QQmlListProperty<QFunctionDefinition>(const_cast<QContractDefinition*>(this), const_cast<QContractDefinition*>(this)->m_events); }
QQmlListProperty<QFunctionDefinition> events() const {
return QQmlListProperty<QFunctionDefinition>(
const_cast<QContractDefinition*>(this),
const_cast<QContractDefinition*>(this)->m_events
);
}
/// Get events
QList<QFunctionDefinition*> const& eventsList() const { return m_events; }
/// Is Library
Expand Down
7 changes: 6 additions & 1 deletion src/QFunctionDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ class QFunctionDefinition: public QBasicNodeDefinition
/// Get all input parameters of this function.
QList<QVariableDeclaration*> const& parametersList() const { return m_parameters; }
/// Get all input parameters of this function as QML property.
QQmlListProperty<QVariableDeclaration> parameters() const { return QQmlListProperty<QVariableDeclaration>(const_cast<QFunctionDefinition*>(this), const_cast<QFunctionDefinition*>(this)->m_parameters); }
QQmlListProperty<QVariableDeclaration> parameters() const {
return QQmlListProperty<QVariableDeclaration>(
const_cast<QFunctionDefinition*>(this),
const_cast<QFunctionDefinition*>(this)->m_parameters
);
}
/// Get all return parameters of this function.
QList<QVariableDeclaration*> returnParameters() const { return m_returnParameters; }
/// Get the hash of this function declaration on the contract ABI.
Expand Down

0 comments on commit e2f1a8a

Please sign in to comment.