Skip to content

Commit

Permalink
Merge pull request LedgerHQ#32 from KhalilBellakrid/master
Browse files Browse the repository at this point in the history
Prepare bump of libcore to 2.7.0
  • Loading branch information
gre authored Mar 22, 2019
2 parents b16ecc4 + c8e1897 commit 8835d96
Show file tree
Hide file tree
Showing 75 changed files with 4,474 additions and 46 deletions.
22 changes: 20 additions & 2 deletions include/BitcoinLikeAddress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,38 @@ class LIBCORE_EXPORT BitcoinLikeAddress {
*/
virtual std::string toBase58() = 0;

/**
* Get the Bech32 encoded address (with respect to BIP173)
* @return The Bech32 encoded address
*/
virtual std::string toBech32() = 0;

/**
* Serializes the hash160 to a payment uri (i.e bitcoin:16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM)
* @return A payment uri to this address
* toPaymentUri(): string;
* Checks if the given address is a P2SH address
* @return True if the version byte matches the P2SH byte version of the address network parameters
* @return True if the keychain engine is P2SH
*/
virtual bool isP2SH() = 0;

/**
* Checks if the given address is a P2PKH address
* @return True if the version byte matches the P2PKH byte version of the address network parameters
* @return if the keychain engine is P2PKH
*/
virtual bool isP2PKH() = 0;

/**
* Checks if the given address is a P2WSH address
* @return True if the keychain engine is P2WSH
*/
virtual bool isP2WSH() = 0;

/**
* Checks if the given address is a P2WPKH address
* @return True if the keychain engine is P2WPKH
*/
virtual bool isP2WPKH() = 0;
};

} } } // namespace ledger::core::api
Expand Down
4 changes: 4 additions & 0 deletions include/BlockchainExplorerEngines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ namespace ledger { namespace core { namespace api {

std::string const BlockchainExplorerEngines::LEDGER_API = {"LEDGER_API"};

std::string const BlockchainExplorerEngines::RIPPLE_API = {"RIPPLE_API"};

std::string const BlockchainExplorerEngines::RIPPLE_NODE = {"RIPPLE_NODE"};

} } } // namespace ledger::core::api
4 changes: 4 additions & 0 deletions include/BlockchainExplorerEngines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class LIBCORE_EXPORT BlockchainExplorerEngines {
virtual ~BlockchainExplorerEngines() {}

static std::string const LEDGER_API;

static std::string const RIPPLE_API;

static std::string const RIPPLE_NODE;
};

} } } // namespace ledger::core::api
Expand Down
2 changes: 2 additions & 0 deletions include/BlockchainObserverEngines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ namespace ledger { namespace core { namespace api {

std::string const BlockchainObserverEngines::LEDGER_API = {"LEDGER_API"};

std::string const BlockchainObserverEngines::RIPPLE_NODE = {"RIPPLE_NODE"};

} } } // namespace ledger::core::api
2 changes: 2 additions & 0 deletions include/BlockchainObserverEngines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class LIBCORE_EXPORT BlockchainObserverEngines {
virtual ~BlockchainObserverEngines() {}

static std::string const LEDGER_API;

static std::string const RIPPLE_NODE;
};

} } } // namespace ledger::core::api
Expand Down
2 changes: 2 additions & 0 deletions include/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ std::string const Configuration::BLOCKCHAIN_EXPLORER_API_ENDPOINT = {"BLOCKCHAIN

std::string const Configuration::BLOCKCHAIN_EXPLORER_VERSION = {"BLOCKCHAIN_EXPLORER_VERSION"};

std::string const Configuration::BLOCKCHAIN_EXPLORER_PORT = {"BLOCKCHAIN_EXPLORER_PORT"};

std::string const Configuration::BLOCKCHAIN_OBSERVER_ENGINE = {"BLOCKCHAIN_OBSERVER_ENGINE"};

std::string const Configuration::BLOCKCHAIN_OBSERVER_WS_ENDPOINT = {"BLOCKCHAIN_OBSERVER_WS_ENDPOINT"};
Expand Down
5 changes: 4 additions & 1 deletion include/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class LIBCORE_EXPORT Configuration {
/** Sets the API version. */
static std::string const BLOCKCHAIN_EXPLORER_VERSION;

/** Selects the blockchain observer engine (Ledger's API). */
/** Sets the API port (e.g. for XRP it is 51234) */
static std::string const BLOCKCHAIN_EXPLORER_PORT;

/** Selects the blockchain observer engine (Ledger's API) */
static std::string const BLOCKCHAIN_OBSERVER_ENGINE;

/** Selects the blockchain observer engine (Ledger's API; Websocket version). */
Expand Down
13 changes: 10 additions & 3 deletions include/Currency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "BitcoinLikeNetworkParameters.hpp"
#include "CurrencyUnit.hpp"
#include "EthereumLikeNetworkParameters.hpp"
#include "RippleLikeNetworkParameters.hpp"
#include "WalletType.hpp"
#include <cstdint>
#include <iostream>
Expand Down Expand Up @@ -39,21 +40,25 @@ struct Currency final {
std::experimental::optional<BitcoinLikeNetworkParameters> bitcoinLikeNetworkParameters;
/** Optional EthereumLikeNetworkParameters, for more details refer to EthereumLikeNetworkParameters doc */
std::experimental::optional<EthereumLikeNetworkParameters> ethereumLikeNetworkParameters;
/**Optional EthereumLikeNetworkParameters, for more details refer to EthereumLikeNetworkParameters doc */
std::experimental::optional<RippleLikeNetworkParameters> rippleLikeNetworkParameters;

Currency(WalletType walletType_,
std::string name_,
int32_t bip44CoinType_,
std::string paymentUriScheme_,
std::vector<CurrencyUnit> units_,
std::experimental::optional<BitcoinLikeNetworkParameters> bitcoinLikeNetworkParameters_,
std::experimental::optional<EthereumLikeNetworkParameters> ethereumLikeNetworkParameters_)
std::experimental::optional<EthereumLikeNetworkParameters> ethereumLikeNetworkParameters_,
std::experimental::optional<RippleLikeNetworkParameters> rippleLikeNetworkParameters_)
: walletType(std::move(walletType_))
, name(std::move(name_))
, bip44CoinType(std::move(bip44CoinType_))
, paymentUriScheme(std::move(paymentUriScheme_))
, units(std::move(units_))
, bitcoinLikeNetworkParameters(std::move(bitcoinLikeNetworkParameters_))
, ethereumLikeNetworkParameters(std::move(ethereumLikeNetworkParameters_))
, rippleLikeNetworkParameters(std::move(rippleLikeNetworkParameters_))
{}

Currency(const Currency& cpy) {
Expand All @@ -64,6 +69,7 @@ struct Currency final {
this->units = cpy.units;
this->bitcoinLikeNetworkParameters = cpy.bitcoinLikeNetworkParameters;
this->ethereumLikeNetworkParameters = cpy.ethereumLikeNetworkParameters;
this->rippleLikeNetworkParameters = cpy.rippleLikeNetworkParameters;
}

Currency() = default;
Expand All @@ -77,17 +83,18 @@ struct Currency final {
this->units = cpy.units;
this->bitcoinLikeNetworkParameters = cpy.bitcoinLikeNetworkParameters;
this->ethereumLikeNetworkParameters = cpy.ethereumLikeNetworkParameters;
this->rippleLikeNetworkParameters = cpy.rippleLikeNetworkParameters;
return *this;
}

template <class Archive>
void load(Archive& archive) {
archive(walletType, name, bip44CoinType, paymentUriScheme, units, bitcoinLikeNetworkParameters, ethereumLikeNetworkParameters);
archive(walletType, name, bip44CoinType, paymentUriScheme, units, bitcoinLikeNetworkParameters, ethereumLikeNetworkParameters, rippleLikeNetworkParameters);
}

template <class Archive>
void save(Archive& archive) const {
archive(walletType, name, bip44CoinType, paymentUriScheme, units, bitcoinLikeNetworkParameters, ethereumLikeNetworkParameters);
archive(walletType, name, bip44CoinType, paymentUriScheme, units, bitcoinLikeNetworkParameters, ethereumLikeNetworkParameters, rippleLikeNetworkParameters);
}
};

Expand Down
8 changes: 8 additions & 0 deletions include/ERC20LikeAccount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef DJINNI_GENERATED_ERC20LIKEACCOUNT_HPP
#define DJINNI_GENERATED_ERC20LIKEACCOUNT_HPP

#include <chrono>
#include <cstdint>
#include <memory>
#include <string>
Expand All @@ -21,6 +22,7 @@ namespace ledger { namespace core { namespace api {
class BigInt;
class ERC20LikeOperation;
class OperationQuery;
enum class TimePeriod;
struct ERC20Token;

/** ERC20-like accounts class. */
Expand All @@ -37,6 +39,12 @@ class LIBCORE_EXPORT ERC20LikeAccount {
/** Get the current balance of this ERC20 account. */
virtual std::shared_ptr<BigInt> getBalance() = 0;

/**
* Get the balance history of this ERC20 account from a starting date (included) to an ending
* date (included).
*/
virtual std::vector<std::shared_ptr<BigInt>> getBalanceHistoryFor(const std::chrono::system_clock::time_point & start, const std::chrono::system_clock::time_point & end, TimePeriod period) = 0;

/** Get the list of operations performed on this ERC20 account. */
virtual std::vector<std::shared_ptr<ERC20LikeOperation>> getOperations() = 0;

Expand Down
5 changes: 4 additions & 1 deletion include/ErrorCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ std::string to_string(const ErrorCode& errorCode) {
case ErrorCode::NOT_ENOUGH_FUNDS: return "NOT_ENOUGH_FUNDS";
case ErrorCode::BAD_CAST: return "BAD_CAST";
case ErrorCode::LINK_NON_TAIL_FILTER: return "LINK_NON_TAIL_FILTER";
case ErrorCode::INVALID_BECH32_FORMAT: return "INVALID_BECH32_FORMAT";
};
};
template <>
Expand Down Expand Up @@ -125,7 +126,8 @@ ErrorCode from_string(const std::string& errorCode) {
else if (errorCode == "DATABASE_EXCEPTION") return ErrorCode::DATABASE_EXCEPTION;
else if (errorCode == "NOT_ENOUGH_FUNDS") return ErrorCode::NOT_ENOUGH_FUNDS;
else if (errorCode == "BAD_CAST") return ErrorCode::BAD_CAST;
else return ErrorCode::LINK_NON_TAIL_FILTER;
else if (errorCode == "LINK_NON_TAIL_FILTER") return ErrorCode::LINK_NON_TAIL_FILTER;
else return ErrorCode::INVALID_BECH32_FORMAT;
};

std::ostream &operator<<(std::ostream &os, const ErrorCode &o)
Expand Down Expand Up @@ -188,6 +190,7 @@ std::ostream &operator<<(std::ostream &os, const ErrorCode &o)
case ErrorCode::NOT_ENOUGH_FUNDS: return os << "NOT_ENOUGH_FUNDS";
case ErrorCode::BAD_CAST: return os << "BAD_CAST";
case ErrorCode::LINK_NON_TAIL_FILTER: return os << "LINK_NON_TAIL_FILTER";
case ErrorCode::INVALID_BECH32_FORMAT: return os << "INVALID_BECH32_FORMAT";
}
}

Expand Down
2 changes: 2 additions & 0 deletions include/ErrorCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ enum class ErrorCode : int {
BAD_CAST,
/** Query build */
LINK_NON_TAIL_FILTER,
/** Invalid bech32 format */
INVALID_BECH32_FORMAT,
};
LIBCORE_EXPORT std::string to_string(const ErrorCode& errorCode);
LIBCORE_EXPORT std::ostream &operator<<(std::ostream &os, const ErrorCode &o);
Expand Down
3 changes: 3 additions & 0 deletions include/EthereumLikeTransaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class LIBCORE_EXPORT EthereumLikeTransaction {
/** Get binary data payload. */
virtual std::experimental::optional<std::vector<uint8_t>> getData() = 0;

/** Get status of transaction: equals to 1 if succeeded, 0 otherwise */
virtual int32_t getStatus() = 0;

/** Serialize the transaction to its raw format. */
virtual std::vector<uint8_t> serialize() = 0;

Expand Down
4 changes: 4 additions & 0 deletions include/KeychainEngines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ std::string const KeychainEngines::BIP32_P2PKH = {"BIP32_P2PKH"};

std::string const KeychainEngines::BIP49_P2SH = {"BIP49_P2SH"};

std::string const KeychainEngines::BIP173_P2WPKH = {"BIP173_P2WPKH"};

std::string const KeychainEngines::BIP173_P2WSH = {"BIP173_P2WSH"};

} } } // namespace ledger::core::api
4 changes: 4 additions & 0 deletions include/KeychainEngines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class LIBCORE_EXPORT KeychainEngines {
static std::string const BIP32_P2PKH;

static std::string const BIP49_P2SH;

static std::string const BIP173_P2WPKH;

static std::string const BIP173_P2WSH;
};

} } } // namespace ledger::core::api
Expand Down
4 changes: 4 additions & 0 deletions include/Networks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace ledger { namespace core { namespace api {

struct BitcoinLikeNetworkParameters;
struct EthereumLikeNetworkParameters;
struct RippleLikeNetworkParameters;

/** All available blockchain networks parameters. */
class LIBCORE_EXPORT Networks {
Expand All @@ -26,6 +27,9 @@ class LIBCORE_EXPORT Networks {

/** The Ethereum network parameters. */
static EthereumLikeNetworkParameters ethereum();

/** The Ripple network parameters. */
static RippleLikeNetworkParameters ripple();
};

} } } // namespace ledger::core::api
Expand Down
8 changes: 7 additions & 1 deletion include/Operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Amount;
class BitcoinLikeOperation;
class EthereumLikeOperation;
class Preferences;
class RippleLikeOperation;
class TrustIndicator;
enum class OperationType;
enum class WalletType;
Expand Down Expand Up @@ -112,7 +113,12 @@ class LIBCORE_EXPORT Operation {
*/
virtual std::shared_ptr<EthereumLikeOperation> asEthereumLikeOperation() = 0;

/** Is this an instance of a Bitcoin-like operation? */
/**
*Convert operation as Ripple operation
*@return RippleLikeOperation object
*/
virtual std::shared_ptr<RippleLikeOperation> asRippleLikeOperation() = 0;

virtual bool isInstanceOfBitcoinLikeOperation() = 0;

/** Same as isInstanceOfBitcoinLikeOperation for ethereum. */
Expand Down
20 changes: 20 additions & 0 deletions include/RippleConfigurationDefaults.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from ripple_like_wallet.djinni

#include "RippleConfigurationDefaults.hpp" // my header

namespace ledger { namespace core { namespace api {

std::string const RippleConfigurationDefaults::RIPPLE_DEFAULT_API_ENDPOINT = {"https://data.ripple.com"};

std::string const RippleConfigurationDefaults::RIPPLE_OBSERVER_NODE_ENDPOINT_S2 = {"https://s2.ripple.com"};

std::string const RippleConfigurationDefaults::RIPPLE_OBSERVER_NODE_ENDPOINT_S3 = {"https://s3.ripple.com"};

std::string const RippleConfigurationDefaults::RIPPLE_OBSERVER_WS_ENDPOINT_S2 = {"wss://s2.ripple.com"};

std::string const RippleConfigurationDefaults::RIPPLE_OBSERVER_WS_ENDPOINT_S3 = {"wss://s3.ripple.com"};

std::string const RippleConfigurationDefaults::RIPPLE_DEFAULT_PORT = {"51234"};

} } } // namespace ledger::core::api
36 changes: 36 additions & 0 deletions include/RippleConfigurationDefaults.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from ripple_like_wallet.djinni

#ifndef DJINNI_GENERATED_RIPPLECONFIGURATIONDEFAULTS_HPP
#define DJINNI_GENERATED_RIPPLECONFIGURATIONDEFAULTS_HPP

#include <string>
#ifndef LIBCORE_EXPORT
#if defined(_MSC_VER)
#include <libcore_export.h>
#else
#define LIBCORE_EXPORT
#endif
#endif

namespace ledger { namespace core { namespace api {

class LIBCORE_EXPORT RippleConfigurationDefaults {
public:
virtual ~RippleConfigurationDefaults() {}

static std::string const RIPPLE_DEFAULT_API_ENDPOINT;

static std::string const RIPPLE_OBSERVER_NODE_ENDPOINT_S2;

static std::string const RIPPLE_OBSERVER_NODE_ENDPOINT_S3;

static std::string const RIPPLE_OBSERVER_WS_ENDPOINT_S2;

static std::string const RIPPLE_OBSERVER_WS_ENDPOINT_S3;

static std::string const RIPPLE_DEFAULT_PORT;
};

} } } // namespace ledger::core::api
#endif //DJINNI_GENERATED_RIPPLECONFIGURATIONDEFAULTS_HPP
37 changes: 37 additions & 0 deletions include/RippleLikeAccount.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from ripple_like_wallet.djinni

#ifndef DJINNI_GENERATED_RIPPLELIKEACCOUNT_HPP
#define DJINNI_GENERATED_RIPPLELIKEACCOUNT_HPP

#include <cstdint>
#include <memory>
#include <vector>
#ifndef LIBCORE_EXPORT
#if defined(_MSC_VER)
#include <libcore_export.h>
#else
#define LIBCORE_EXPORT
#endif
#endif

namespace ledger { namespace core { namespace api {

class RippleLikeTransaction;
class RippleLikeTransactionBuilder;
class StringCallback;

/**Class representing a Ripple account */
class LIBCORE_EXPORT RippleLikeAccount {
public:
virtual ~RippleLikeAccount() {}

virtual void broadcastRawTransaction(const std::vector<uint8_t> & transaction, const std::shared_ptr<StringCallback> & callback) = 0;

virtual void broadcastTransaction(const std::shared_ptr<RippleLikeTransaction> & transaction, const std::shared_ptr<StringCallback> & callback) = 0;

virtual std::shared_ptr<RippleLikeTransactionBuilder> buildTransaction() = 0;
};

} } } // namespace ledger::core::api
#endif //DJINNI_GENERATED_RIPPLELIKEACCOUNT_HPP
Loading

0 comments on commit 8835d96

Please sign in to comment.