Browse Source

Cleaning

cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
eab72b22b3
  1. 6
      libdevcore/CommonJS.h
  2. 2
      mix/ClientModel.cpp
  3. 4
      mix/ContractCallDataEncoder.cpp
  4. 6
      mix/ContractCallDataEncoder.h

6
libdevcore/CommonJS.h

@ -48,15 +48,15 @@ inline std::string toJS(dev::bytes const& _n)
/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. /// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex.
bytes jsToBytes(std::string const& _s); bytes jsToBytes(std::string const& _s);
/// Add '0' on the head of _b until _l. /// Add '0' on the head of @a _b until @a _l.
bytes padded(bytes _b, unsigned _l); bytes padded(bytes _b, unsigned _l);
/// Add '0' on the queue of _b until _l. /// Add '0' on the queue of @a _b until @a _l.
bytes paddedRight(bytes _b, unsigned _l); bytes paddedRight(bytes _b, unsigned _l);
/// Remove all trailing '0' /// Remove all trailing '0'
std::string unpadRight(std::string _b); std::string unpadRight(std::string _b);
/// Removing all trailing '0'. Returns empty array if input contains only '0' char. /// Removing all trailing '0'. Returns empty array if input contains only '0' char.
bytes unpadded(bytes _s); bytes unpadded(bytes _s);
/// Remove all '0' on the head of _s. Returns 0 if _s contains only '0'. /// Remove all '0' on the head of @a _s. Returns 0 if @a _s contains only '0'.
std::string unpadLeft(std::string _s); std::string unpadLeft(std::string _s);
/// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256.
std::string prettyU256(u256 _n); std::string prettyU256(u256 _n);

2
mix/ClientModel.cpp

@ -171,7 +171,7 @@ void ClientModel::executeSequence(std::vector<TransactionSettings> const& _seque
throw std::runtime_error("function " + t.functionId.toStdString() + " not found"); throw std::runtime_error("function " + t.functionId.toStdString() + " not found");
c.encode(f); c.encode(f);
for (unsigned int p = 0; p < t.parameterValues.size(); p++) for (int p = 0; p < t.parameterValues.size(); p++)
c.push(t.parameterValues.at(p)->encodeValue()); c.push(t.parameterValues.at(p)->encodeValue());
transactonData.emplace_back(c.encodedData()); transactonData.emplace_back(c.encodedData());
} }

4
mix/ContractCallDataEncoder.cpp

@ -44,12 +44,12 @@ void ContractCallDataEncoder::encode(QFunctionDefinition const* _function)
m_encodedData.insert(m_encodedData.end(), hash.begin(), hash.end()); m_encodedData.insert(m_encodedData.end(), hash.begin(), hash.end());
} }
void ContractCallDataEncoder::push(bytes _b) void ContractCallDataEncoder::push(bytes const& _b)
{ {
m_encodedData.insert(m_encodedData.end(), _b.begin(), _b.end()); m_encodedData.insert(m_encodedData.end(), _b.begin(), _b.end());
} }
QList<QVariableDefinition*> ContractCallDataEncoder::decode(QList<QVariableDeclaration*> _returnParameters, bytes _value) QList<QVariableDefinition*> ContractCallDataEncoder::decode(QList<QVariableDeclaration*> const& _returnParameters, bytes const& _value)
{ {
QList<QVariableDefinition*> r; QList<QVariableDefinition*> r;
std::string returnValue = toJS(_value); std::string returnValue = toJS(_value);

6
mix/ContractCallDataEncoder.h

@ -44,11 +44,11 @@ public:
/// Encode hash of the function to call. /// Encode hash of the function to call.
void encode(QFunctionDefinition const* _function); void encode(QFunctionDefinition const* _function);
/// Decode variable in order to be sent to QML view. /// Decode variable in order to be sent to QML view.
QList<QVariableDefinition*> decode(QList<QVariableDeclaration*> _dec, bytes _value); QList<QVariableDefinition*> decode(QList<QVariableDeclaration*> const& _dec, bytes const& _value);
/// Get all encoded data encoded by encode function. /// Get all encoded data encoded by encode function.
bytes encodedData(); bytes encodedData();
/// Push the given @ _b to the current param context. /// Push the given @a _b to the current param context.
void push(bytes _b); void push(bytes const& _b);
private: private:
bytes m_encodedData; bytes m_encodedData;

Loading…
Cancel
Save