Skip to content

Commit

Permalink
Fix codacy issues:
Browse files Browse the repository at this point in the history
- Mark ModelBuilder and UnsignedWrapper constructors as explicit
- Rename (finally!) Simple_ classes to Model_

Signed-off-by: luckychess <[email protected]>
  • Loading branch information
luckychess authored and lebdron committed Dec 19, 2017
1 parent 6754267 commit fef726b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 32 deletions.
20 changes: 7 additions & 13 deletions shared_model/bindings/model_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,23 @@

namespace shared_model {
namespace bindings {
SimpleBuilder::SimpleBuilder(
const proto::TemplateTransactionBuilder<
(1 << shared_model::proto::TemplateTransactionBuilder<>::total) - 1>
&o)
: builder_(o) {}

SimpleBuilder SimpleBuilder::creatorAccountId(
ModelBuilder ModelBuilder::creatorAccountId(
const interface::types::AccountIdType &account_id) {
return builder_.creatorAccountId(account_id);
return ModelBuilder(builder_.creatorAccountId(account_id));
}

SimpleBuilder SimpleBuilder::txCounter(uint64_t tx_counter) {
return builder_.txCounter(tx_counter);
ModelBuilder ModelBuilder::txCounter(uint64_t tx_counter) {
return ModelBuilder(builder_.txCounter(tx_counter));
}

SimpleBuilder SimpleBuilder::addAssetQuantity(
ModelBuilder ModelBuilder::addAssetQuantity(
const interface::types::AccountIdType &account_id,
const interface::types::AssetIdType &asset_id,
const std::string &amount) {
return builder_.assetQuantity(account_id, asset_id, amount);
return ModelBuilder(builder_.assetQuantity(account_id, asset_id, amount));
}

proto::UnsignedWrapper<proto::Transaction> SimpleBuilder::build() {
proto::UnsignedWrapper<proto::Transaction> ModelBuilder::build() {
return builder_.build();
}
} // namespace bindings
Expand Down
24 changes: 10 additions & 14 deletions shared_model/bindings/model_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,29 @@ namespace shared_model {
* Wrapper class for transaction builder. Designed only for SWIG bindings,
* don't use in other cases.
*/
class SimpleBuilder {
public:
SimpleBuilder() = default;
class ModelBuilder {
private:
template <int Sp>
explicit ModelBuilder(const proto::TemplateTransactionBuilder<Sp> &o)
: builder_(o) {}

/**
* Creates new SimpleBuilder
* @param o - TemplateTransactionBuilder<> instance
*/
SimpleBuilder(
const proto::TemplateTransactionBuilder<
(1 << shared_model::proto::TemplateTransactionBuilder<>::total)
- 1> &o);
public:
ModelBuilder() = default;

/**
* Sets id of account creator
* @param account_id - account id
* @return builder with account_id field appended
*/
SimpleBuilder creatorAccountId(
ModelBuilder creatorAccountId(
const interface::types::AccountIdType &account_id);

/**
* Sets transaction counter field
* @param tx_counter - transaction counter
* @return builder with tx_counter field appended
*/
SimpleBuilder txCounter(uint64_t tx_counter);
ModelBuilder txCounter(uint64_t tx_counter);

/**
* Adds given quantity of given asset to account
Expand All @@ -62,7 +58,7 @@ namespace shared_model {
* @param amount - amount of asset to add
* @return builder with added given quantity of given asset for account
*/
SimpleBuilder addAssetQuantity(
ModelBuilder addAssetQuantity(
const interface::types::AccountIdType &account_id,
const interface::types::AssetIdType &asset_id,
const std::string &amount);
Expand Down
2 changes: 1 addition & 1 deletion shared_model/bindings/model_crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace shared_model {
namespace bindings {
crypto::Keypair SimpleCrypto::generateKeypair() {
crypto::Keypair ModelCrypto::generateKeypair() {
return crypto::CryptoProviderEd25519Sha3::generateKeypair();
}
} // namespace bindings
Expand Down
2 changes: 1 addition & 1 deletion shared_model/bindings/model_crypto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace shared_model {
/**
* Class for crypto operations for SWIG
*/
class SimpleCrypto {
class ModelCrypto {
public:
/**
* Generates new keypair (ed25519)
Expand Down
2 changes: 1 addition & 1 deletion shared_model/bindings/model_transaction_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace shared_model {
namespace bindings {
crypto::Blob SimpleTransactionProto::signAndAddSignature(
crypto::Blob ModelTransactionProto::signAndAddSignature(
proto::UnsignedWrapper<proto::Transaction> &tx,
const crypto::Keypair &keypair) {
return tx.signAndAddSignature(keypair).blob();
Expand Down
2 changes: 1 addition & 1 deletion shared_model/bindings/model_transaction_proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace shared_model {
/**
* Class for proto operations for SWIG
*/
class SimpleTransactionProto {
class ModelTransactionProto {
public:
/**
* Signs unsigned transaction and adds signature to its internal proto
Expand Down
2 changes: 1 addition & 1 deletion shared_model/builders/protobuf/unsigned_proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace shared_model {
* Constructs new unsigned object instance
* @param o - object received from builder
*/
UnsignedWrapper(const T &o) : unsigned_(o) {}
explicit UnsignedWrapper(const T &o) : unsigned_(o) {}

/**
* Add signature and retrieve signed result
Expand Down

0 comments on commit fef726b

Please sign in to comment.