Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- added Delegate Resignation Builder ([#208])

### Changed
- improved transaction builder ([#217])

## [1.0.0-arduino] - 2020-02-13

### Added
- added AIP-11 support for Core v.2.6 Transactions ([#198])

### Changed
- removed use of monolithic `arkCrypto.h` header ([#190])
- break up unit tests to support platforms with limited RAM ([#172])

### Added
- added AIP-11 support for Core v.2.6 Transactions ([#198])

### Fixed
- fixed `transaction::to_json` tests on ESP8266 ([#180])
- fixed `transaction::to_array` tests on ESP8266 ([#178])
Expand Down Expand Up @@ -112,4 +115,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
[1.0.0-arduino]: https://github.com/ArkEcosystem/cpp-crypto/compare/0.7.0-arduino...1.0.0-arduino
[1.0.0]: https://github.com/ArkEcosystem/cpp-crypto/compare/0.7.0-arduino...1.0.0
[#208]: https://github.com/ArkEcosystem/cpp-crypto/pull/208
[#217]: https://github.com/ArkEcosystem/cpp-crypto/pull/217
[unreleased]: https://github.com/ArkEcosystem/cpp-crypto/compare/1.0.0-arduino...develop
4 changes: 2 additions & 2 deletions examples/ESP32/ESP32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ void createBridgechainTransaction() {
const Configuration cfg(BridgechainNetwork);

// Use the Transaction Builder to make a transaction.
const auto bridgechainTransaction = builder::Transfer()
const auto bridgechainTransaction = builder::Transfer(cfg)
.recipientId("D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib")
.vendorField("this is a custom bridgechain transaction")
.sign(Passphrase)
.secondSign(SecondPassphrase)
.build(cfg);
.build();

// Create and Print the Json representation of the Transaction.
const auto transactionJson = bridgechainTransaction.toJson();
Expand Down
4 changes: 2 additions & 2 deletions examples/ESP8266/ESP8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ void createBridgechainTransaction() {
const Configuration cfg(BridgechainNetwork);

// Use the Transaction Builder to make a transaction.
const auto bridgechainTransaction = builder::Transfer()
const auto bridgechainTransaction = builder::Transfer(cfg)
.recipientId("D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib")
.vendorField("this is a custom bridgechain transaction")
.sign(Passphrase)
.build(cfg);
.build();

// Create and Print the Json representation of the Transaction.
const auto transactionJson = bridgechainTransaction.toJson();
Expand Down
4 changes: 2 additions & 2 deletions src/common/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Configuration : public managers::NetworkManager,
////////////////////////////////////////////////////////////////////////////
// Default initialization: ARK Devnet w/StaticFees
Configuration() = default;
explicit Configuration(const Network &network);
explicit Configuration(const FeePolicy &policy);
Configuration(const Network &network);
Configuration(const FeePolicy &policy);
Configuration(const Network &network, const FeePolicy &policy);

////////////////////////////////////////////////////////////////////////////
Expand Down
27 changes: 9 additions & 18 deletions src/transactions/builders/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,19 @@ template<class T> class Common {
}

////////////////////////////////////////////////////////////////////////////
// Build
//
// If calling 'builder::sign()' before calling 'build()',
// ensure the Fees and Network are properly configured first.
//
// ---
Transaction &build(const Configuration &config = {}) {
// if the transaction fee is the default of '0', use the config fees.
if (this->transaction.data.fee == 0ULL) {
this->transaction.data.fee = config.getFee(this->transaction.data.type);
}

// Use the configuration network version if it's different.
if (this->transaction.data.network == Devnet.version &&
config.getNetwork().version != Devnet.version) {
this->transaction.data.network = config.getNetwork().version;
}

// Finish the build pattern
// !! should always be the last call !!
Transaction &build() {
return this->transaction;
}

protected:
////////////////////////////////////////////////////////////////////////////
void configure(const Configuration &config) {
this->transaction.data.fee = config.getFee(this->transaction.data.type);
this->transaction.data.network = config.getNetwork().version;
}

////////////////////////////////////////////////////////////////////////////
Transaction transaction;
};
Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/delegate_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class DelegateRegistration : public Common<DelegateRegistration> {
}

////////////////////////////////////////////////////////////////////////////
DelegateRegistration() {
DelegateRegistration(const Configuration &config = {}) {
this->transaction.data.type = DELEGATE_REGISTRATION_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/delegate_resignation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class DelegateResignation;
////////////////////////////////////////////////////////////////////////////////
class DelegateResignation : public Common<DelegateResignation> {
public:
DelegateResignation() {
DelegateResignation(const Configuration &config = {}) {
this->transaction.data.type = DELEGATE_RESIGNATION_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/htlc_claim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class HtlcClaim : public Common<HtlcClaim> {
}

////////////////////////////////////////////////////////////////////////////
HtlcClaim() {
HtlcClaim(const Configuration &config = {}) {
this->transaction.data.type = HTLC_CLAIM_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/htlc_lock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ class HtlcLock : public Common<HtlcLock> {
}

////////////////////////////////////////////////////////////////////////////
HtlcLock() {
HtlcLock(const Configuration &config = {}) {
this->transaction.data.type = HTLC_LOCK_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/htlc_refund.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class HtlcRefund : public Common<HtlcRefund> {
}

////////////////////////////////////////////////////////////////////////////
HtlcRefund() {
HtlcRefund(const Configuration &config = {}) {
this->transaction.data.type = HTLC_REFUND_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/ipfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class Ipfs : public Common<Ipfs> {
}

////////////////////////////////////////////////////////////////////////////
Ipfs() {
Ipfs(const Configuration &config = {}) {
this->transaction.data.type = IPFS_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/multi_payment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class MultiPayment : public Common<MultiPayment> {
}

////////////////////////////////////////////////////////////////////////////
MultiPayment() {
MultiPayment(const Configuration &config = {}) {
this->transaction.data.type = MULTI_PAYMENT_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/second_signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class SecondSignature : public Common<SecondSignature> {
}

////////////////////////////////////////////////////////////////////////////
SecondSignature() {
SecondSignature(const Configuration &config = {}) {
this->transaction.data.type = SECOND_SIGNATURE_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/transfer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ class Transfer : public Common<Transfer> {
}

////////////////////////////////////////////////////////////////////////////
Transfer() {
Transfer(const Configuration &config = {}) {
this->transaction.data.type = TRANSFER_TYPE;
this->configure(config);
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/transactions/builders/vote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class Vote : public Common<Vote> {
}

////////////////////////////////////////////////////////////////////////////
Vote() {
Vote(const Configuration &config = {}) {
this->transaction.data.type = VOTE_TYPE;
this->configure(config);
}
};

Expand Down