From 09ab634253495aa39b3f479d90d162df27ef1329 Mon Sep 17 00:00:00 2001 From: Bertrand Darbon Date: Mon, 28 Nov 2022 15:27:33 +0100 Subject: [PATCH] Update clang format rule For better readability --- .clang-format | 2 +- core/src/bytes/zarith/zarith.h | 4 +- core/src/common/AbstractExtendedPublicKey.h | 8 +- core/src/cosmos/CosmosLikeAddress.cpp | 2 +- core/src/crypto/AESCipher.cpp | 20 +- core/src/crypto/DER.cpp | 2 +- core/src/database/DatabaseBackend.hpp | 2 +- core/src/math/BaseConverter.hpp | 8 +- core/src/math/BigInt.cpp | 2 +- core/src/math/bech32/Bech32.cpp | 2 +- core/src/math/bech32/Bech32.h | 2 +- core/src/net/HttpClient.hpp | 2 +- core/src/tezos/TezosKey.h | 8 +- core/src/utils/Concurrency.hpp | 6 +- core/src/utils/DerivationPath.cpp | 4 +- core/src/utils/json.hpp | 76 ++-- core/src/utils/optional.hpp | 2 +- core/src/wallet/algorand/AlgorandAccount.cpp | 6 +- .../algorand/AlgorandAccountSynchronizer.cpp | 2 +- .../algorand/AlgorandBlockchainExplorer.cpp | 8 +- .../algorand/AlgorandExplorerConstants.hpp | 134 +++---- .../wallet/algorand/AlgorandJsonParser.hpp | 34 +- .../wallet/algorand/AlgorandWalletFactory.cpp | 2 +- .../AlgorandTransactionDatabaseHelper.cpp | 34 +- .../AlgorandTransactionDatabaseHelper.hpp | 90 ++--- .../transactions/util/TransactionAdaptor.hpp | 76 ++-- .../src/wallet/bitcoin/BitcoinLikeAccount.cpp | 2 +- .../api_impl/BitcoinLikeTransactionApi.cpp | 32 +- .../BitcoinLikeTransactionDatabaseHelper.cpp | 2 +- .../database/BitcoinLikeUTXODatabaseHelper.h | 2 +- .../factories/BitcoinLikeWalletFactory.cpp | 8 +- .../bitcoin/keychains/BitcoinLikeKeychain.hpp | 12 +- .../bitcoin/scripts/BitcoinLikeScript.cpp | 2 +- core/src/wallet/bitcoin/scripts/operators.h | 202 +++++----- .../BlockchainExplorerAccountSynchronizer.cpp | 34 +- .../BitcoinLikeStrategyUtxoPicker.cpp | 46 +-- .../BitcoinLikeTransactionBuilder.cpp | 4 +- .../BitcoinLikeUtxoPicker.cpp | 16 +- core/src/wallet/common/Operation.h | 6 +- core/src/wallet/common/OperationQuery.cpp | 2 +- .../database/OperationDatabaseHelper.cpp | 2 +- ...actBlockchainExplorerAccountSynchronizer.h | 26 +- core/src/wallet/cosmos/CosmosLikeAccount.cpp | 8 +- .../src/wallet/cosmos/CosmosLikeConstants.hpp | 372 +++++++++--------- core/src/wallet/cosmos/CosmosLikeMessage.cpp | 2 +- core/src/wallet/cosmos/cosmos.hpp | 50 +-- .../CosmosLikeAccountDatabaseHelper.cpp | 20 +- .../CosmosLikeOperationDatabaseHelper.hpp | 2 +- .../CosmosLikeTransactionDatabaseHelper.cpp | 6 +- .../cosmos/database/SociCosmosAmount.hpp | 6 +- .../CosmosLikeBlockchainExplorer.hpp | 14 +- .../GaiaCosmosLikeBlockchainExplorer.cpp | 34 +- .../factories/CosmosLikeWalletFactory.cpp | 2 +- .../CosmosLikeAccountSynchronizer.cpp | 20 +- .../CosmosLikeTransactionBuilder.cpp | 20 +- .../wallet/ethereum/EthereumLikeAccount.cpp | 24 +- .../wallet/ethereum/EthereumLikeWallet.cpp | 2 +- .../api_impl/EthereumLikeTransactionApi.cpp | 22 +- .../EthereumLikeTransactionDatabaseHelper.cpp | 24 +- ...edgerApiEthereumLikeBlockchainExplorer.cpp | 4 +- .../api/EthereumLikeTransactionParser.cpp | 2 +- .../keychains/EthereumLikeKeychain.cpp | 6 +- .../EthereumLikeTransactionBuilder.cpp | 4 +- core/src/wallet/pool/WalletPool.cpp | 16 +- .../database/CurrenciesDatabaseHelper.cpp | 6 +- core/src/wallet/ripple/RippleLikeAccount.cpp | 6 +- .../api_impl/RippleLikeTransactionApi.cpp | 6 +- .../RippleLikeTransactionDatabaseHelper.cpp | 2 +- .../NodeRippleLikeBlockchainExplorer.h | 6 +- .../explorers/api/RippleLikeBlockParser.h | 2 +- .../api/RippleLikeTransactionParser.cpp | 4 +- .../ripple/keychains/RippleLikeKeychain.cpp | 8 +- .../RippleLikeAccountSynchronizer.cpp | 10 +- .../RippleLikeTransactionBuilder.cpp | 4 +- .../src/wallet/stellar/StellarLikeAccount.cpp | 8 +- .../wallet/stellar/StellarLikeOperation.cpp | 2 +- .../factories/StellarLikeWalletFactory.cpp | 4 +- ...eBlockchainExplorerAccountSynchronizer.hpp | 2 +- .../StellarLikeTransactionBuilder.cpp | 10 +- core/src/wallet/stellar/xdr/models.hpp | 16 +- core/src/wallet/tezos/TezosLikeAccount.cpp | 10 +- core/src/wallet/tezos/TezosLikeAccount2.cpp | 10 +- .../api_impl/TezosLikeTransactionApi.cpp | 20 +- .../TezosLikeAccountDatabaseHelper.cpp | 2 +- .../TezosLikeTransactionDatabaseHelper.cpp | 4 +- .../BakingBadTezosLikeBlockchainExplorer.cpp | 10 +- .../ExternalTezosLikeBlockchainExplorer.cpp | 6 +- .../NodeTezosLikeBlockchainExplorer.cpp | 4 +- .../explorers/TezosLikeBlockchainExplorer.cpp | 2 +- .../explorers/TezosLikeBlockchainExplorer.h | 6 +- .../TezosLikeAccountSynchronizer.cpp | 12 +- .../TezosLikeTransactionBuilder.cpp | 22 +- core/test/algorand/AlgorandAccountTests.cpp | 20 +- core/test/algorand/AlgorandDatabaseTests.cpp | 8 +- core/test/algorand/AlgorandExplorerTests.cpp | 4 +- .../algorand/AlgorandSynchronizationTests.cpp | 6 +- core/test/algorand/AlgorandTestFixtures.hpp | 20 +- core/test/bitcoin/address_test.cpp | 8 +- .../bitcoin/bitcoin_utxo_picket_tests.cpp | 6 +- .../stellar/synchronization_tests.cpp | 2 +- .../stellar/transaction_tests.cpp | 4 +- .../coin-integration/stellar/xdr_tests.cpp | 8 +- core/test/common/balance_history.cpp | 16 +- core/test/cosmos/address_test.cpp | 10 +- core/test/cosmos/db_test.cpp | 40 +- core/test/cosmos/parsers_test.cpp | 2 +- core/test/cosmos/transactions_test.cpp | 180 ++++----- core/test/crypto/encryption_test.cpp | 2 +- core/test/database/pool_tests.cpp | 16 +- core/test/events/events_test.cpp | 4 +- core/test/integration/BaseFixture.cpp | 8 +- core/test/integration/account_info_test.cpp | 2 +- .../common_bitcoin_keychain_test.cpp | 2 +- .../keychains/ethereum_keychain_test.cpp | 4 +- .../keychains/p2wsh_keychain_test.cpp | 2 +- .../keychains/ripple_keychain_test.cpp | 2 +- .../cosmos_synchronization.cpp | 52 +-- .../cosmos_synchronization_benchmarks.cpp | 4 +- .../ethereum_synchronization.cpp | 62 +-- .../ripple_synchronization.cpp | 12 +- .../synchronization_P2SH_tests.cpp | 20 +- .../synchronization_btc_rbf_tests.cpp | 10 +- .../synchronization/synchronization_tests.cpp | 40 +- .../synchronization/tezos_synchronization.cpp | 18 +- .../bitcoin_P2PKH_transaction_tests.cpp | 2 +- .../bitcoin_P2WSH_transaction_tests.cpp | 4 +- .../transactions/coin_selection_P2PKH.cpp | 4 +- .../ethereum_transaction_tests.cpp | 2 +- .../optimisticupdate_xrp_tests.cpp | 2 +- .../transactions/ripple_transaction_tests.cpp | 10 +- .../transactions/tezos_transaction_tests.cpp | 8 +- .../transactions/transaction_test_helper.cpp | 4 +- .../integration/wallet_database_tests.cpp | 6 +- core/test/math/base58_test.cpp | 22 +- core/test/tezos/ED25519_transaction_test.cpp | 18 +- core/test/tezos/P256_transaction_test.cpp | 18 +- .../test/tezos/SECP256K1_transaction_test.cpp | 36 +- core/test/tezos/address_test.cpp | 2 +- 138 files changed, 1266 insertions(+), 1266 deletions(-) diff --git a/.clang-format b/.clang-format index adcfb4c380..31172c1af6 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,7 @@ Language: Cpp AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignConsecutiveMacros: false -AlignConsecutiveAssignments: AcrossEmptyLinesAndComments +AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: false AlignEscapedNewlines: Right AlignOperands: true diff --git a/core/src/bytes/zarith/zarith.h b/core/src/bytes/zarith/zarith.h index b2d90102de..9975b65d43 100644 --- a/core/src/bytes/zarith/zarith.h +++ b/core/src/bytes/zarith/zarith.h @@ -118,8 +118,8 @@ namespace ledger { size_t id = 0, delay = 0; uint8_t offset = 0; while (id + delay < data.size()) { - auto byte = data[id + delay]; - auto isLast = id + delay == data.size() - 1; + auto byte = data[id + delay]; + auto isLast = id + delay == data.size() - 1; // We should stop reading if most significant bit is null auto shouldStop = !(byte & 0x80); diff --git a/core/src/common/AbstractExtendedPublicKey.h b/core/src/common/AbstractExtendedPublicKey.h index 295212018b..841cc046ee 100644 --- a/core/src/common/AbstractExtendedPublicKey.h +++ b/core/src/common/AbstractExtendedPublicKey.h @@ -106,15 +106,15 @@ namespace ledger { throw Exception(api::ErrorCode::INVALID_NETWORK_ADDRESS_VERSION, "Provided network parameters and address version do not match."); } // 1 byte of depth - auto depth = reader.readNextByte(); + auto depth = reader.readNextByte(); // 4 bytes of fingerprint auto fingerprint = reader.readNextBeUint(); // 4 bytes of child's index - auto childNum = reader.readNextBeUint(); + auto childNum = reader.readNextBeUint(); // 32 bytes of chaincode - auto chainCode = reader.read(32); + auto chainCode = reader.read(32); // 33 bytes of publicKey - auto publicKey = reader.readUntilEnd(); + auto publicKey = reader.readUntilEnd(); return DeterministicPublicKey(publicKey, chainCode, childNum, depth, fingerprint, params.Identifier); } diff --git a/core/src/cosmos/CosmosLikeAddress.cpp b/core/src/cosmos/CosmosLikeAddress.cpp index a828780fa2..d97c7706c0 100644 --- a/core/src/cosmos/CosmosLikeAddress.cpp +++ b/core/src/cosmos/CosmosLikeAddress.cpp @@ -97,7 +97,7 @@ namespace ledger { const Option &derivationPath) { auto const ¶ms = currency.cosmosLikeNetworkParameters.value(); - auto const type = [](auto const &address) { + auto const type = [](auto const &address) { if (address.find(cosmos::getBech32Params(api::CosmosBech32Type::ADDRESS_VAL).hrp) != std::string::npos) { return api::CosmosBech32Type::ADDRESS_VAL; diff --git a/core/src/crypto/AESCipher.cpp b/core/src/crypto/AESCipher.cpp index 948948f8b3..fd1d48c92f 100644 --- a/core/src/crypto/AESCipher.cpp +++ b/core/src/crypto/AESCipher.cpp @@ -57,11 +57,11 @@ namespace ledger { uint32_t read = input->gcount(); // Create an IVt - auto IV = _rng->getRandomBytes(AES256::BLOCK_SIZE); + auto IV = _rng->getRandomBytes(AES256::BLOCK_SIZE); assert(IV.size() == AES256::BLOCK_SIZE); // Encrypt - auto encrypted = AES256::encrypt(IV, _key, std::vector(buffer, buffer + read)); + auto encrypted = AES256::encrypt(IV, _key, std::vector(buffer, buffer + read)); // Store number of blocks uint8_t blocksCount = (encrypted.size() / AES256::BLOCK_SIZE); (*output) << blocksCount; @@ -107,11 +107,11 @@ namespace ledger { std::vector dataToEncrypt = input.read(minEncryptedRead); uint32_t read = dataToEncrypt.size(); // Create an IVt - auto IV = _rng->getRandomBytes(AES256::BLOCK_SIZE); + auto IV = _rng->getRandomBytes(AES256::BLOCK_SIZE); // Encrypt - auto encrypted = AES256::encrypt(IV, _key, dataToEncrypt); + auto encrypted = AES256::encrypt(IV, _key, dataToEncrypt); // Store number of blocks - uint8_t blocksCount = (encrypted.size() / AES256::BLOCK_SIZE); + uint8_t blocksCount = (encrypted.size() / AES256::BLOCK_SIZE); // Number of blocks of size AES256::BLOCK_SIZE in enrypted data output.writeByte(blocksCount); // Limit of reading (padding or string terminating before maxRead) @@ -127,15 +127,15 @@ namespace ledger { uint32_t maxRead = 255 * AES256::BLOCK_SIZE; do { // Get number of blocks in encrypted data - uint8_t blocksCount = input.readNextByte(); + uint8_t blocksCount = input.readNextByte(); // Size of encrypted (chunk of) data uint32_t encryptedDataSize = blocksCount * AES256::BLOCK_SIZE; // Get data that we read - uint32_t dataSize = input.readNextVarInt(); + uint32_t dataSize = input.readNextVarInt(); // Read IV - std::vector IV = input.read(AES256::BLOCK_SIZE); + std::vector IV = input.read(AES256::BLOCK_SIZE); // Get number of bytes to read - uint32_t available = input.available(); + uint32_t available = input.available(); if (available < encryptedDataSize) { // Should not read than more available data break; @@ -143,7 +143,7 @@ namespace ledger { // Read encrypted data std::vector encryptedData = input.read(encryptedDataSize); // Decrypt - auto decrypted = AES256::decrypt(IV, _key, encryptedData); + auto decrypted = AES256::decrypt(IV, _key, encryptedData); // Truncate if needed to size of encrypted data that we stored in dataSize bytes if (dataSize < decrypted.size()) { decrypted.resize(dataSize); diff --git a/core/src/crypto/DER.cpp b/core/src/crypto/DER.cpp index a479a2b040..7976482d8a 100644 --- a/core/src/crypto/DER.cpp +++ b/core/src/crypto/DER.cpp @@ -112,7 +112,7 @@ namespace ledger { // Ensure DER encoded size match read bytes // Length = len(rType + rSize + rSig + sType + sSize + sSig) - auto readSize = 2 /* rType + rSize */ + rSize + 2 /* rType + rSize */ + sSize; + auto readSize = 2 /* rType + rSize */ + rSize + 2 /* rType + rSize */ + sSize; if (length != readSize) { throw make_exception(api::ErrorCode::INVALID_ARGUMENT, "Read size mismatch DER announced size"); diff --git a/core/src/database/DatabaseBackend.hpp b/core/src/database/DatabaseBackend.hpp index 8ca269e630..037c623d87 100644 --- a/core/src/database/DatabaseBackend.hpp +++ b/core/src/database/DatabaseBackend.hpp @@ -48,7 +48,7 @@ namespace ledger { const std::shared_ptr &resolver, const std::string &dbName, const std::string &password, - soci::session &session) = 0; + soci::session &session) = 0; virtual void setPassword(const std::string &password, soci::session &session) = 0; diff --git a/core/src/math/BaseConverter.hpp b/core/src/math/BaseConverter.hpp index 0f88be9fae..ea6c2fb917 100644 --- a/core/src/math/BaseConverter.hpp +++ b/core/src/math/BaseConverter.hpp @@ -53,7 +53,7 @@ namespace ledger { /** * A function taking the number of missing bytes in a block and returning the padding to append to the encoding result. */ - using PaddingPolicy = std::function; + using PaddingPolicy = std::function; /** * Parameters used by the algorithm to encode or decode a byte array @@ -144,7 +144,7 @@ namespace ledger { auto remainingBits = bufferSize - ValueBitSize; if (remainingBits < 0) { // For the sake of understanding what we are doing, we set remainingBits to a positive value - remainingBits = -remainingBits; + remainingBits = -remainingBits; // Move the bits from the buffer to the index auto bufferMask = (1 << bufferSize) - 1; index = (block[offset] & bufferMask) << remainingBits; @@ -174,8 +174,8 @@ namespace ledger { template static void decodeBlock(const char *str, int size, const Params ¶ms, std::vector &out) { - int buffer = 0; - int bufferSize = 0; + int buffer = 0; + int bufferSize = 0; // Compute extraction mask for a ValueBitSize of 5: // (1 << 5) = 00100000 // (1 << 5) -1 = 00011111 (i.e if we mask a byte with it, it will only give the 5 last bit values) diff --git a/core/src/math/BigInt.cpp b/core/src/math/BigInt.cpp index ce2f4f40df..cb40a8c8bf 100644 --- a/core/src/math/BigInt.cpp +++ b/core/src/math/BigInt.cpp @@ -423,7 +423,7 @@ namespace ledger { mp::cpp_dec_float_50 scale = mp::pow(mp::cpp_dec_float_50(10), (float)scaleFactor); f = f * scale; - bool isNegative = f < 0; + bool isNegative = f < 0; if (isNegative) f = f * -1; diff --git a/core/src/math/bech32/Bech32.cpp b/core/src/math/bech32/Bech32.cpp index 0ba4c35adc..acb7fca068 100644 --- a/core/src/math/bech32/Bech32.cpp +++ b/core/src/math/bech32/Bech32.cpp @@ -36,7 +36,7 @@ namespace ledger { namespace core { // The Bech32 character set for encoding. - const char *charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; + const char *charset = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; // The Bech32 character set for decoding. const int8_t charsetRev[128] = { diff --git a/core/src/math/bech32/Bech32.h b/core/src/math/bech32/Bech32.h index 52792b8693..1e7d732a76 100644 --- a/core/src/math/bech32/Bech32.h +++ b/core/src/math/bech32/Bech32.h @@ -70,7 +70,7 @@ namespace ledger { std::pair> decodeBech32Raw(const std::string &str) const; // Find the polynomial with value coefficients mod the generator as 64-bit. - virtual uint64_t polymod(const std::vector &values) const = 0; + virtual uint64_t polymod(const std::vector &values) const = 0; // Expand a HRP for use in checksum computation. virtual std::vector expandHrp(const std::string &hrp) const = 0; diff --git a/core/src/net/HttpClient.hpp b/core/src/net/HttpClient.hpp index 36539494a5..c9eeb8cd0b 100644 --- a/core/src/net/HttpClient.hpp +++ b/core/src/net/HttpClient.hpp @@ -114,7 +114,7 @@ namespace ledger { const std::vector &buffer = result.data.value(); std::stringstream ss; std::copy(buffer.begin(), buffer.end(), std::ostream_iterator(ss, "")); - const std::string str = ss.str(); + const std::string str = ss.str(); const int32_t statusCode = c->getStatusCode(); bool isFailure = statusCode < 200 || statusCode >= 400; diff --git a/core/src/tezos/TezosKey.h b/core/src/tezos/TezosKey.h index 37893a40a2..e998e7ac4e 100644 --- a/core/src/tezos/TezosKey.h +++ b/core/src/tezos/TezosKey.h @@ -81,15 +81,15 @@ namespace ledger { const Encoding P2SIG{"p2sig", {54, 240, 44, 52}, api::TezosCurve::P256, 64, 99, "p256 signature"}; - const std::vector ALL = {EDPK, SPPK, P2PK, XPUB, TZ1, TZ2, TZ3, KT1}; + const std::vector ALL = {EDPK, SPPK, P2PK, XPUB, TZ1, TZ2, TZ3, KT1}; - const std::vector PUBKEYS = {EDPK, SPPK, P2PK}; + const std::vector PUBKEYS = {EDPK, SPPK, P2PK}; const std::vector LEGACY_PUBKEYS = {EDPK, SPPK, P2PK, XPUB}; - const std::vector ADDRESSES = {TZ1, TZ2, TZ3, KT1}; + const std::vector ADDRESSES = {TZ1, TZ2, TZ3, KT1}; - const std::vector SIGNATURES = {EDSIG, SPSIG, P2SIG, SIG}; + const std::vector SIGNATURES = {EDSIG, SPSIG, P2SIG, SIG}; /** * Get the key encoding definition for a given version diff --git a/core/src/utils/Concurrency.hpp b/core/src/utils/Concurrency.hpp index 8dd25d9dc3..fa0e49b295 100644 --- a/core/src/utils/Concurrency.hpp +++ b/core/src/utils/Concurrency.hpp @@ -40,10 +40,10 @@ namespace ledger { public: template static void parallel_for_each(InputIter first, InputIter last, UnaryFunction f) { - auto range = std::distance(first, last); - size_t approxNumThreads = std::thread::hardware_concurrency(); + auto range = std::distance(first, last); + size_t approxNumThreads = std::thread::hardware_concurrency(); // number of elements for one thread - size_t jobsForThread = range / approxNumThreads; + size_t jobsForThread = range / approxNumThreads; // number of elements for one thread + remainder size_t jobsForMainThread = range % approxNumThreads + jobsForThread; // minus main thread diff --git a/core/src/utils/DerivationPath.cpp b/core/src/utils/DerivationPath.cpp index 804ff27e79..8f9f53f8d2 100644 --- a/core/src/utils/DerivationPath.cpp +++ b/core/src/utils/DerivationPath.cpp @@ -56,8 +56,8 @@ namespace ledger { bool lastCharWasZero = false; bool nextIntIsInHex = false; std::vector result; - int sepCount = 0; - int index = 0; + int sepCount = 0; + int index = 0; auto pushSegment = [&]() { if (currentNode.size() == 0 && sepCount > 0) { diff --git a/core/src/utils/json.hpp b/core/src/utils/json.hpp index f2ee8e99b8..fb3b5b2d9e 100644 --- a/core/src/utils/json.hpp +++ b/core/src/utils/json.hpp @@ -245,32 +245,32 @@ Format](http://rfc7159.net/rfc7159) /// @{ /// the type of elements in a basic_json container - using value_type = basic_json; + using value_type = basic_json; /// the type of an element reference - using reference = value_type &; + using reference = value_type &; /// the type of an element const reference using const_reference = const value_type &; /// a type to represent differences between iterators using difference_type = std::ptrdiff_t; /// a type to represent container sizes - using size_type = std::size_t; + using size_type = std::size_t; /// the allocator type - using allocator_type = AllocatorType; + using allocator_type = AllocatorType; /// the type of an element pointer - using pointer = typename std::allocator_traits::pointer; + using pointer = typename std::allocator_traits::pointer; /// the type of an element const pointer - using const_pointer = typename std::allocator_traits::const_pointer; + using const_pointer = typename std::allocator_traits::const_pointer; /// an iterator for a basic_json container class iterator; /// a const iterator for a basic_json container class const_iterator; /// a reverse iterator for a basic_json container - using reverse_iterator = json_reverse_iterator; + using reverse_iterator = json_reverse_iterator; /// a const reverse iterator for a basic_json container using const_reverse_iterator = json_reverse_iterator; @@ -375,7 +375,7 @@ Format](http://rfc7159.net/rfc7159) 7159](http://rfc7159.net/rfc7159), because any order implements the specified "unordered" nature of JSON objects. */ - using object_t = ObjectType, AllocatorType>; + using array_t = ArrayType>; /*! @brief a type for a string @@ -472,7 +472,7 @@ Format](http://rfc7159.net/rfc7159) @since version 1.0.0 */ - using string_t = StringType; + using string_t = StringType; /*! @brief a type for a boolean @@ -498,7 +498,7 @@ Format](http://rfc7159.net/rfc7159) @since version 1.0.0 */ - using boolean_t = BooleanType; + using boolean_t = BooleanType; /*! @brief a type for a number (integer) @@ -570,7 +570,7 @@ Format](http://rfc7159.net/rfc7159) @since version 1.0.0 */ - using number_integer_t = NumberIntegerType; + using number_integer_t = NumberIntegerType; /*! @brief a type for a number (unsigned) @@ -709,7 +709,7 @@ Format](http://rfc7159.net/rfc7159) @since version 1.0.0 */ - using number_float_t = NumberFloatType; + using number_float_t = NumberFloatType; /// @} @@ -2634,7 +2634,7 @@ Format](http://rfc7159.net/rfc7159) using PointerType = typename std::add_pointer::type; // delegate the call to get_ptr<>() - auto ptr = obj.template get_ptr(); + auto ptr = obj.template get_ptr(); if (ptr != nullptr) { return *ptr; @@ -5304,7 +5304,7 @@ Format](http://rfc7159.net/rfc7159) o.width(0); // fix locale problems - const auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator)); + const auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator)); // set precision // 6, 15 or 16 digits of precision allows round-trip IEEE 754 @@ -5906,7 +5906,7 @@ Format](http://rfc7159.net/rfc7159) ////////////////////// /// the type of the current element - value_t m_type = value_t::null; + value_t m_type = value_t::null; /// the value of the current element json_value m_value = {}; @@ -5962,7 +5962,7 @@ Format](http://rfc7159.net/rfc7159) static constexpr difference_type end_value = begin_value + 1; /// iterator as signed integer type - difference_type m_it = std::numeric_limits::denorm_min(); + difference_type m_it = std::numeric_limits::denorm_min(); }; /*! @@ -6092,18 +6092,18 @@ Format](http://rfc7159.net/rfc7159) public: /// the type of the values when the iterator is dereferenced - using value_type = typename basic_json::value_type; + using value_type = typename basic_json::value_type; /// a type to represent differences between iterators - using difference_type = typename basic_json::difference_type; + using difference_type = typename basic_json::difference_type; /// defines a pointer to the type iterated over (value_type) - using pointer = typename basic_json::const_pointer; + using pointer = typename basic_json::const_pointer; /// defines a reference to the type iterated over (value_type) - using reference = typename basic_json::const_reference; + using reference = typename basic_json::const_reference; /// the category of the iterator using iterator_category = std::bidirectional_iterator_tag; /// default constructor - const_iterator() = default; + const_iterator() = default; /*! @brief constructor for a given JSON instance @@ -6591,7 +6591,7 @@ Format](http://rfc7159.net/rfc7159) private: /// associated JSON instance - pointer m_object = nullptr; + pointer m_object = nullptr; /// the actual iterator of the associated instance internal_iterator m_it = internal_iterator(); }; @@ -6615,7 +6615,7 @@ Format](http://rfc7159.net/rfc7159) using reference = typename basic_json::reference; /// default constructor - iterator() = default; + iterator() = default; /// constructor for a given JSON instance explicit iterator(pointer object) noexcept @@ -6736,7 +6736,7 @@ Format](http://rfc7159.net/rfc7159) /// shortcut to the reverse iterator adaptor using base_iterator = std::reverse_iterator; /// the reference type for the pointed-to element - using reference = typename Base::reference; + using reference = typename Base::reference; /// create reverse iterator from iterator json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept @@ -7004,7 +7004,7 @@ Format](http://rfc7159.net/rfc7159) m_marker = nullptr; // remember the begin of the token - m_start = m_cursor; + m_start = m_cursor; assert(m_start != nullptr); { @@ -7868,7 +7868,7 @@ Format](http://rfc7159.net/rfc7159) */ void fill_line_buffer() { // number of processed characters (p) - const auto offset_start = m_start - m_content; + const auto offset_start = m_start - m_content; // offset for m_marker wrt. to m_start const auto offset_marker = (m_marker == nullptr) ? 0 : m_marker - m_start; // number of unprocessed characters (u) @@ -8140,7 +8140,7 @@ Format](http://rfc7159.net/rfc7159) const lexer::lexer_char_t *curptr = m_start; // accumulate the integer conversion result (unsigned for now) - number_unsigned_t value = 0; + number_unsigned_t value = 0; // maximum absolute value of the relevant integer type number_unsigned_t max; @@ -8211,15 +8211,15 @@ Format](http://rfc7159.net/rfc7159) /// the buffer pointer const lexer_char_t *m_content = nullptr; /// pointer to the beginning of the current symbol - const lexer_char_t *m_start = nullptr; + const lexer_char_t *m_start = nullptr; /// pointer for backtracking information - const lexer_char_t *m_marker = nullptr; + const lexer_char_t *m_marker = nullptr; /// pointer to the current symbol - const lexer_char_t *m_cursor = nullptr; + const lexer_char_t *m_cursor = nullptr; /// pointer to the end of the buffer - const lexer_char_t *m_limit = nullptr; + const lexer_char_t *m_limit = nullptr; /// the last token type - token_type last_token_type = token_type::end_of_input; + token_type last_token_type = token_type::end_of_input; }; /*! @@ -8299,7 +8299,7 @@ Format](http://rfc7159.net/rfc7159) expect(lexer::token_type::value_string); const auto key = m_lexer.get_string(); - bool keep_tag = false; + bool keep_tag = false; if (keep) { if (callback) { basic_json k(key); @@ -8451,9 +8451,9 @@ Format](http://rfc7159.net/rfc7159) private: /// current level of recursion - int depth = 0; + int depth = 0; /// callback function - const parser_callback_t callback = nullptr; + const parser_callback_t callback = nullptr; /// the type of the last read token typename lexer::token_type last_token = lexer::token_type::uninitialized; /// the lexer @@ -8792,7 +8792,7 @@ Format](http://rfc7159.net/rfc7159) // search for the first slash after the first character size_t slash = reference_string.find_first_of("/", 1), // set the beginning of the first reference token - start = 1; + start = 1; // we can stop if start == string::npos+1 = 0 start != 0; // set the beginning of the next reference token @@ -9293,7 +9293,7 @@ Format](http://rfc7159.net/rfc7159) const std::string &member, bool string_type) -> basic_json & { // find value - auto it = val.m_value.object->find(member); + auto it = val.m_value.object->find(member); // context-sensitive error message const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; diff --git a/core/src/utils/optional.hpp b/core/src/utils/optional.hpp index 9fb4b1fdb2..c8c6894fe4 100644 --- a/core/src/utils/optional.hpp +++ b/core/src/utils/optional.hpp @@ -594,7 +594,7 @@ namespace std { explicit optional(in_place_t, T &&) = delete; - ~optional() = default; + ~optional() = default; // 20.5.5.2, mutation optional &operator=(nullopt_t) noexcept { diff --git a/core/src/wallet/algorand/AlgorandAccount.cpp b/core/src/wallet/algorand/AlgorandAccount.cpp index 917c101a43..d78c88022c 100644 --- a/core/src/wallet/algorand/AlgorandAccount.cpp +++ b/core/src/wallet/algorand/AlgorandAccount.cpp @@ -210,7 +210,7 @@ namespace ledger { auto lowerDate = startDate; auto upperDate = DateUtils::incrementDate(startDate, period); - const auto id = std::stoull(assetId); + const auto id = std::stoull(assetId); const auto transactions = TransactionDatabaseHelper::queryAssetTransferTransactionsInvolving( sql, id, _address.toString()); @@ -438,7 +438,7 @@ namespace ledger { auto eventPublisher = std::make_shared(getContext()); _currentSyncEventBus = eventPublisher->getEventBus(); - auto startTime = DateUtils::now(); + auto startTime = DateUtils::now(); eventPublisher->postSticky( std::make_shared(api::EventCode::SYNCHRONIZATION_STARTED, api::DynamicObject::newInstance()), 0); @@ -573,7 +573,7 @@ namespace ledger { Future Account::eraseDataSince(const std::chrono::system_clock::time_point &date) { auto accountUid = getAccountUid(); - auto log = logger(); + auto log = logger(); log->debug(" Start erasing data of account : {}", accountUid); std::lock_guard lock(_synchronizationLock); diff --git a/core/src/wallet/algorand/AlgorandAccountSynchronizer.cpp b/core/src/wallet/algorand/AlgorandAccountSynchronizer.cpp index 6d5443f33c..2f76f943e7 100644 --- a/core/src/wallet/algorand/AlgorandAccountSynchronizer.cpp +++ b/core/src/wallet/algorand/AlgorandAccountSynchronizer.cpp @@ -117,7 +117,7 @@ namespace ledger { account->interpretTransaction(tx, operations); // Record the lowest round in this batch, to continue fetching txs below it if needed - lowestBatchRound = std::min(lowestBatchRound, tx.header.round.getValueOr(lowestBatchRound)); + lowestBatchRound = std::min(lowestBatchRound, tx.header.round.getValueOr(lowestBatchRound)); // Record the highest round ever seen, to update the cache for next incremental sychronization savedState->round = std::max(savedState->round, tx.header.round.getValueOr(0)); diff --git a/core/src/wallet/algorand/AlgorandBlockchainExplorer.cpp b/core/src/wallet/algorand/AlgorandBlockchainExplorer.cpp index 77499393d4..766fae5c7a 100644 --- a/core/src/wallet/algorand/AlgorandBlockchainExplorer.cpp +++ b/core/src/wallet/algorand/AlgorandBlockchainExplorer.cpp @@ -41,7 +41,7 @@ namespace ledger { namespace constants { - const std::string purestakeTokenHeader = "x-api-key"; + const std::string purestakeTokenHeader = "x-api-key"; // Explorer endpoints const std::string purestakeStatusEndpoint = "/ps2/v2/status"; @@ -54,9 +54,9 @@ namespace ledger { const std::string purestakeAssetEndpoint = "/idx2/v2/assets/{}"; // Query parameters - const std::string limitQueryParam = "{}?limit={}"; - const std::string minRoundQueryParam = "{}&min-round={}"; - const std::string maxRoundQueryParam = "{}&max-round={}"; + const std::string limitQueryParam = "{}?limit={}"; + const std::string minRoundQueryParam = "{}&min-round={}"; + const std::string maxRoundQueryParam = "{}&max-round={}"; } // namespace constants diff --git a/core/src/wallet/algorand/AlgorandExplorerConstants.hpp b/core/src/wallet/algorand/AlgorandExplorerConstants.hpp index b8d31c7ae1..6afc5f16b8 100644 --- a/core/src/wallet/algorand/AlgorandExplorerConstants.hpp +++ b/core/src/wallet/algorand/AlgorandExplorerConstants.hpp @@ -37,33 +37,33 @@ namespace ledger { namespace algorand { namespace constants { - static constexpr uint32_t EXPLORER_QUERY_LIMIT = 100; // Max nb of objects returned by queries - defined by Algorand + static constexpr uint32_t EXPLORER_QUERY_LIMIT = 100; // Max nb of objects returned by queries - defined by Algorand // Block /// The block hash is not returned by algod v2 anymore // static const std::string xHash = "hash"; - static const std::string xBlock = "block"; - static const std::string xRnd = "rnd"; - static const std::string xTs = "ts"; + static const std::string xBlock = "block"; + static const std::string xRnd = "rnd"; + static const std::string xTs = "ts"; // AssetParam - static const std::string xClawbackAddr = "clawback"; - static const std::string xCreator = "creator"; - static const std::string xDecimal = "decimals"; - static const std::string xDefaultFrozen = "default-frozen"; - static const std::string xFreezeAddr = "freeze"; - static const std::string xManagerKey = "manager"; - static const std::string xMetadataHash = "metadata-hash"; - static const std::string xAssetName = "name"; - static const std::string xReserveAddr = "reserve"; - static const std::string xTotal = "total"; - static const std::string xUnitName = "unit-name"; - static const std::string xUrl = "url"; - static const std::string xAsset = "asset"; + static const std::string xClawbackAddr = "clawback"; + static const std::string xCreator = "creator"; + static const std::string xDecimal = "decimals"; + static const std::string xDefaultFrozen = "default-frozen"; + static const std::string xFreezeAddr = "freeze"; + static const std::string xManagerKey = "manager"; + static const std::string xMetadataHash = "metadata-hash"; + static const std::string xAssetName = "name"; + static const std::string xReserveAddr = "reserve"; + static const std::string xTotal = "total"; + static const std::string xUnitName = "unit-name"; + static const std::string xUrl = "url"; + static const std::string xAsset = "asset"; // AssetAmount - static const std::string xAmount = "amount"; - static const std::string xFrozen = "is-frozen"; + static const std::string xAmount = "amount"; + static const std::string xFrozen = "is-frozen"; // Account static const std::string xAddress = "address"; @@ -77,62 +77,62 @@ namespace ledger { static const std::string xParticipation = "participation"; // Header txn - static const std::string xConfirmedRound = "confirmed-round"; - static const std::string xRoundTime = "round-time"; - static const std::string xTxType = "tx-type"; - static const std::string xId = "id"; - static const std::string xSender = "sender"; - static const std::string xFee = "fee"; - static const std::string xFirstValid = "first-valid"; - static const std::string xLastValid = "last-valid"; - static const std::string xNote = "note"; - static const std::string xGenesisId = "genesis-id"; - static const std::string xGenesisHash = "genesis-hash"; - static const std::string xGroup = "group"; - static const std::string xLease = "lease"; + static const std::string xConfirmedRound = "confirmed-round"; + static const std::string xRoundTime = "round-time"; + static const std::string xTxType = "tx-type"; + static const std::string xId = "id"; + static const std::string xSender = "sender"; + static const std::string xFee = "fee"; + static const std::string xFirstValid = "first-valid"; + static const std::string xLastValid = "last-valid"; + static const std::string xNote = "note"; + static const std::string xGenesisId = "genesis-id"; + static const std::string xGenesisHash = "genesis-hash"; + static const std::string xGroup = "group"; + static const std::string xLease = "lease"; // Payment txn - static const std::string xReceiver = "receiver"; - static const std::string xReceiverRewards = "receiver-rewards"; - static const std::string xCloseAmount = "close-amount"; - static const std::string xCloseRewards = "close-rewards"; - static const std::string xSenderRewards = "sender-rewards"; - static const std::string xCloseTo = "close-to"; - static const std::string xCloseRemainderTo = "close-remainder-to"; + static const std::string xReceiver = "receiver"; + static const std::string xReceiverRewards = "receiver-rewards"; + static const std::string xCloseAmount = "close-amount"; + static const std::string xCloseRewards = "close-rewards"; + static const std::string xSenderRewards = "sender-rewards"; + static const std::string xCloseTo = "close-to"; + static const std::string xCloseRemainderTo = "close-remainder-to"; // Keyreg txn - static const std::string xNonParticipation = "non-participation"; - static const std::string xSelkey = "selection-participation-key"; - static const std::string xVotefst = "vote-first-valid"; - static const std::string xVotekd = "vote-key-dilution"; - static const std::string xVotekey = "vote-participation-key"; - static const std::string xVotelst = "vote-last-valid"; + static const std::string xNonParticipation = "non-participation"; + static const std::string xSelkey = "selection-participation-key"; + static const std::string xVotefst = "vote-first-valid"; + static const std::string xVotekd = "vote-key-dilution"; + static const std::string xVotekey = "vote-participation-key"; + static const std::string xVotelst = "vote-last-valid"; // AssetConfig txn - static const std::string xAssetId = "asset-id"; - static const std::string xParams = "params"; - static const std::string xIndex = "index"; + static const std::string xAssetId = "asset-id"; + static const std::string xParams = "params"; + static const std::string xIndex = "index"; // AssetFreeze txn - static const std::string xNewFreezeStatus = "new-freeze-status"; - - static const std::string xPay = "pay"; - static const std::string xKeyregs = "keyreg"; - static const std::string xAcfg = "acfg"; - static const std::string xAxfer = "axfer"; - static const std::string xAfreeze = "afrz"; - - static const std::string xPayment = "payment-transaction"; - static const std::string xKeyreg = "keyreg-transaction"; - static const std::string xCurcfg = "asset-config-transaction"; - static const std::string xCurxfer = "asset-transfer-transaction"; - static const std::string xCurfrz = "asset-freeze-transaction"; - - static const std::string xTransactions = "transactions"; - static const std::string xTxId = "txId"; - static const std::string xMinFee = "min-fee"; - static const std::string xConsensusVersion = "consensus-version"; - static const std::string xLastRoundParam = "last-round"; + static const std::string xNewFreezeStatus = "new-freeze-status"; + + static const std::string xPay = "pay"; + static const std::string xKeyregs = "keyreg"; + static const std::string xAcfg = "acfg"; + static const std::string xAxfer = "axfer"; + static const std::string xAfreeze = "afrz"; + + static const std::string xPayment = "payment-transaction"; + static const std::string xKeyreg = "keyreg-transaction"; + static const std::string xCurcfg = "asset-config-transaction"; + static const std::string xCurxfer = "asset-transfer-transaction"; + static const std::string xCurfrz = "asset-freeze-transaction"; + + static const std::string xTransactions = "transactions"; + static const std::string xTxId = "txId"; + static const std::string xMinFee = "min-fee"; + static const std::string xConsensusVersion = "consensus-version"; + static const std::string xLastRoundParam = "last-round"; } // namespace constants } // namespace algorand diff --git a/core/src/wallet/algorand/AlgorandJsonParser.hpp b/core/src/wallet/algorand/AlgorandJsonParser.hpp index 5805175479..cc6fd23e7a 100644 --- a/core/src/wallet/algorand/AlgorandJsonParser.hpp +++ b/core/src/wallet/algorand/AlgorandJsonParser.hpp @@ -66,7 +66,7 @@ namespace ledger { if (blockHeight > static_cast(std::numeric_limits::max())) { throw make_exception(api::ErrorCode::OUT_OF_RANGE, "Block height exceeds maximum value"); } - block.height = static_cast(blockHeight); + block.height = static_cast(blockHeight); /// In Algorand implementation, we use the block height (aka round) as block hash block.blockHash = std::to_string(block.height); @@ -94,7 +94,7 @@ namespace ledger { assetParams.creatorAddr = getMandatoryAddressField(node, constants::xCreator); assetParams.total = getMandatoryUint64Field(node, constants::xTotal); assert(node.HasMember(constants::xDecimal.c_str())); - assetParams.decimals = node[constants::xDecimal.c_str()].GetUint(); + assetParams.decimals = node[constants::xDecimal.c_str()].GetUint(); assetParams.defaultFrozen = getOptionalBoolField(node, constants::xDefaultFrozen); assetParams.unitName = getOptionalStringField(node, constants::xUnitName); @@ -128,11 +128,11 @@ namespace ledger { // WARNING This has not been tested template static void parseParticipationInfo(const T &node, model::KeyRegTxnFields &details) { - details.selectionPk = getMandatoryStringField(node, constants::xVotekey); - details.votePk = getMandatoryStringField(node, constants::xSelkey); - details.voteKeyDilution = getMandatoryUint64Field(node, constants::xVotekd); - details.voteFirst = getMandatoryUint64Field(node, constants::xVotefst); - details.voteLast = getMandatoryUint64Field(node, constants::xVotelst); + details.selectionPk = getMandatoryStringField(node, constants::xVotekey); + details.votePk = getMandatoryStringField(node, constants::xSelkey); + details.voteKeyDilution = getMandatoryUint64Field(node, constants::xVotekd); + details.voteFirst = getMandatoryUint64Field(node, constants::xVotefst); + details.voteLast = getMandatoryUint64Field(node, constants::xVotelst); details.nonParticipation = getOptionalBoolField(node, constants::xNonParticipation); } @@ -152,9 +152,9 @@ namespace ledger { details.assetReceiver = getMandatoryAddressField(node, constants::xReceiver); details.assetAmount = getMandatoryUint64Field(node, constants::xAmount); - details.assetCloseTo = getOptionalAddressField(node, constants::xCloseTo); - details.closeAmount = getOptionalUint64Field(node, constants::xCloseAmount); - details.assetSender = getOptionalAddressField(node, constants::xSender); + details.assetCloseTo = getOptionalAddressField(node, constants::xCloseTo); + details.closeAmount = getOptionalUint64Field(node, constants::xCloseAmount); + details.assetSender = getOptionalAddressField(node, constants::xSender); } // WARNING This has not been tested @@ -167,13 +167,13 @@ namespace ledger { template static void parseTransaction(const T &node, model::Transaction &tx) { - tx.header.type = getMandatoryStringField(node, constants::xTxType); - tx.header.id = getMandatoryStringField(node, constants::xId); - tx.header.sender = getMandatoryAddressField(node, constants::xSender); - tx.header.firstValid = getMandatoryUint64Field(node, constants::xFirstValid); - tx.header.lastValid = getMandatoryUint64Field(node, constants::xLastValid); - tx.header.fee = getMandatoryUint64Field(node, constants::xFee); - tx.header.genesisHash = getMandatoryB64StringField(node, constants::xGenesisHash); + tx.header.type = getMandatoryStringField(node, constants::xTxType); + tx.header.id = getMandatoryStringField(node, constants::xId); + tx.header.sender = getMandatoryAddressField(node, constants::xSender); + tx.header.firstValid = getMandatoryUint64Field(node, constants::xFirstValid); + tx.header.lastValid = getMandatoryUint64Field(node, constants::xLastValid); + tx.header.fee = getMandatoryUint64Field(node, constants::xFee); + tx.header.genesisHash = getMandatoryB64StringField(node, constants::xGenesisHash); tx.header.round = getOptionalUint64Field(node, constants::xConfirmedRound); tx.header.timestamp = getOptionalUint64Field(node, constants::xRoundTime); diff --git a/core/src/wallet/algorand/AlgorandWalletFactory.cpp b/core/src/wallet/algorand/AlgorandWalletFactory.cpp index ba584c1a1f..ffc90c8f9e 100644 --- a/core/src/wallet/algorand/AlgorandWalletFactory.cpp +++ b/core/src/wallet/algorand/AlgorandWalletFactory.cpp @@ -127,7 +127,7 @@ namespace ledger { std::shared_ptr explorer = nullptr; - auto engine = configuration->getString(api::Configuration::BLOCKCHAIN_EXPLORER_ENGINE).value_or(ALGORAND_NODE_EXPLORER); + auto engine = configuration->getString(api::Configuration::BLOCKCHAIN_EXPLORER_ENGINE).value_or(ALGORAND_NODE_EXPLORER); if (engine == ALGORAND_NODE_EXPLORER) { auto &networkParams = networks::getAlgorandNetworkParameters(getCurrency().name); auto pool = getPool(); diff --git a/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.cpp b/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.cpp index e837199837..d9288fdd6a 100644 --- a/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.cpp +++ b/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.cpp @@ -46,7 +46,7 @@ namespace ledger { namespace algorand { static void putPaymentTransaction(soci::session &sql, const std::string &txUid, const model::Transaction &tx) { - auto &payment = boost::get(tx.details); + auto &payment = boost::get(tx.details); auto headerId = optionalValue(tx.header.id); auto headerGenesisId = optionalValue(tx.header.genesisId); @@ -325,7 +325,7 @@ namespace ledger { paymentDetails.closeAddr = getOptionalStringWithTransform
(row, COL_TX_PAY_CLOSE_ADDRESS, stringToAddr); paymentDetails.closeAmount = getOptionalNumber(row, COL_TX_PAY_CLOSE_AMOUNT); - tx.details = paymentDetails; + tx.details = paymentDetails; } else if (tx.header.type == constants::xKeyregs) { // NOTE This has not been tested @@ -339,7 +339,7 @@ namespace ledger { keyregDetails.voteFirst = getNumber(row, COL_TX_KEYREG_VOTE_FIRST); keyregDetails.voteLast = getNumber(row, COL_TX_KEYREG_VOTE_LAST); - tx.details = keyregDetails; + tx.details = keyregDetails; } else if (tx.header.type == constants::xAcfg) { model::AssetConfigTxnFields assetConfigDetails; @@ -348,18 +348,18 @@ namespace ledger { if (row.get_indicator(COL_TX_ACFG_TOTAL) != soci::i_null) { model::AssetParams assetParams; - assetParams.assetName = getOptionalString(row, COL_TX_ACFG_ASSET_NAME); - assetParams.unitName = getOptionalString(row, COL_TX_ACFG_UNIT_NAME); - assetParams.total = getOptionalNumber(row, COL_TX_ACFG_TOTAL); - assetParams.decimals = row.get_indicator(COL_TX_ACFG_DECIMALS) != soci::i_null ? Option(soci::get_number(row, COL_TX_ACFG_DECIMALS)) : Option::NONE; - assetParams.defaultFrozen = getOptionalNumberWithTransform(row, COL_TX_ACFG_DEFAULT_FROZEN, numToBool); - assetParams.creatorAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_CREATOR_ADDRESS, stringToAddr); - assetParams.managerAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_MANAGER_ADDRESS, stringToAddr); - assetParams.reserveAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_RESERVE_ADDRESS, stringToAddr); - assetParams.freezeAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_FREEZE_ADDRESS, stringToAddr); - assetParams.clawbackAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_CLAWBACK_ADDRESS, stringToAddr); - assetParams.url = getOptionalString(row, COL_TX_ACFG_URL); - assetParams.metaDataHash = getOptionalStringWithTransform>(row, COL_TX_ACFG_METADATA_HASH, b64toBytes); + assetParams.assetName = getOptionalString(row, COL_TX_ACFG_ASSET_NAME); + assetParams.unitName = getOptionalString(row, COL_TX_ACFG_UNIT_NAME); + assetParams.total = getOptionalNumber(row, COL_TX_ACFG_TOTAL); + assetParams.decimals = row.get_indicator(COL_TX_ACFG_DECIMALS) != soci::i_null ? Option(soci::get_number(row, COL_TX_ACFG_DECIMALS)) : Option::NONE; + assetParams.defaultFrozen = getOptionalNumberWithTransform(row, COL_TX_ACFG_DEFAULT_FROZEN, numToBool); + assetParams.creatorAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_CREATOR_ADDRESS, stringToAddr); + assetParams.managerAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_MANAGER_ADDRESS, stringToAddr); + assetParams.reserveAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_RESERVE_ADDRESS, stringToAddr); + assetParams.freezeAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_FREEZE_ADDRESS, stringToAddr); + assetParams.clawbackAddr = getOptionalStringWithTransform
(row, COL_TX_ACFG_CLAWBACK_ADDRESS, stringToAddr); + assetParams.url = getOptionalString(row, COL_TX_ACFG_URL); + assetParams.metaDataHash = getOptionalStringWithTransform>(row, COL_TX_ACFG_METADATA_HASH, b64toBytes); assetConfigDetails.assetParams = assetParams; } @@ -376,7 +376,7 @@ namespace ledger { assetTransferDetails.closeAmount = getOptionalNumber(row, COL_TX_AXFER_CLOSE_AMOUNT); assetTransferDetails.assetSender = getOptionalStringWithTransform
(row, COL_TX_AXFER_SENDER_ADDRESS, stringToAddr); - tx.details = assetTransferDetails; + tx.details = assetTransferDetails; } else if (tx.header.type == constants::xAfreeze) { // NOTE This has not been tested @@ -387,7 +387,7 @@ namespace ledger { assetFreezeDetails.assetFrozen = !!getNumber(row, COL_TX_AFRZ_FROZEN); assetFreezeDetails.frozenAddress = Address(getString(row, COL_TX_AFRZ_FROZEN_ADDRESS)); - tx.details = assetFreezeDetails; + tx.details = assetFreezeDetails; } } diff --git a/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.hpp b/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.hpp index d163856586..9ecffbdfeb 100644 --- a/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.hpp +++ b/core/src/wallet/algorand/database/AlgorandTransactionDatabaseHelper.hpp @@ -41,27 +41,27 @@ namespace ledger { namespace core { namespace algorand { - static constexpr auto COL_TX_HASH = 1; - static constexpr auto COL_TX_TYPE = 2; - static constexpr auto COL_TX_ROUND = 3; - static constexpr auto COL_TX_TIMESTAMP = 4; - static constexpr auto COL_TX_FIRST_VALID = 5; - static constexpr auto COL_TX_LAST_VALID = 6; - static constexpr auto COL_TX_GENESIS_ID = 7; - static constexpr auto COL_TX_GENESIS_HASH = 8; - static constexpr auto COL_TX_SENDER = 9; - static constexpr auto COL_TX_FEE = 10; - static constexpr auto COL_TX_NOTE = 11; - static constexpr auto COL_TX_GROUP = 12; - static constexpr auto COL_TX_LEASE = 13; - static constexpr auto COL_TX_SENDER_REWARDS = 14; - static constexpr auto COL_TX_RECEIVER_REWARDS = 15; - static constexpr auto COL_TX_CLOSE_REWARDS = 16; - - static constexpr auto COL_TX_PAY_AMOUNT = 17; - static constexpr auto COL_TX_PAY_RECEIVER_ADDRESS = 18; - static constexpr auto COL_TX_PAY_CLOSE_ADDRESS = 19; - static constexpr auto COL_TX_PAY_CLOSE_AMOUNT = 20; + static constexpr auto COL_TX_HASH = 1; + static constexpr auto COL_TX_TYPE = 2; + static constexpr auto COL_TX_ROUND = 3; + static constexpr auto COL_TX_TIMESTAMP = 4; + static constexpr auto COL_TX_FIRST_VALID = 5; + static constexpr auto COL_TX_LAST_VALID = 6; + static constexpr auto COL_TX_GENESIS_ID = 7; + static constexpr auto COL_TX_GENESIS_HASH = 8; + static constexpr auto COL_TX_SENDER = 9; + static constexpr auto COL_TX_FEE = 10; + static constexpr auto COL_TX_NOTE = 11; + static constexpr auto COL_TX_GROUP = 12; + static constexpr auto COL_TX_LEASE = 13; + static constexpr auto COL_TX_SENDER_REWARDS = 14; + static constexpr auto COL_TX_RECEIVER_REWARDS = 15; + static constexpr auto COL_TX_CLOSE_REWARDS = 16; + + static constexpr auto COL_TX_PAY_AMOUNT = 17; + static constexpr auto COL_TX_PAY_RECEIVER_ADDRESS = 18; + static constexpr auto COL_TX_PAY_CLOSE_ADDRESS = 19; + static constexpr auto COL_TX_PAY_CLOSE_AMOUNT = 20; static constexpr auto COL_TX_KEYREG_NONPART = 21; static constexpr auto COL_TX_KEYREG_SELECTION_PK = 22; @@ -70,30 +70,30 @@ namespace ledger { static constexpr auto COL_TX_KEYREG_VOTE_FIRST = 25; static constexpr auto COL_TX_KEYREG_VOTE_LAST = 26; - static constexpr auto COL_TX_ACFG_ASSET_ID = 27; - static constexpr auto COL_TX_ACFG_ASSET_NAME = 28; - static constexpr auto COL_TX_ACFG_UNIT_NAME = 29; - static constexpr auto COL_TX_ACFG_TOTAL = 30; - static constexpr auto COL_TX_ACFG_DECIMALS = 31; - static constexpr auto COL_TX_ACFG_DEFAULT_FROZEN = 32; - static constexpr auto COL_TX_ACFG_CREATOR_ADDRESS = 33; - static constexpr auto COL_TX_ACFG_MANAGER_ADDRESS = 34; - static constexpr auto COL_TX_ACFG_RESERVE_ADDRESS = 35; - static constexpr auto COL_TX_ACFG_FREEZE_ADDRESS = 36; - static constexpr auto COL_TX_ACFG_CLAWBACK_ADDRESS = 37; - static constexpr auto COL_TX_ACFG_METADATA_HASH = 38; - static constexpr auto COL_TX_ACFG_URL = 39; - - static constexpr auto COL_TX_AXFER_ASSET_ID = 40; - static constexpr auto COL_TX_AXFER_ASSET_AMOUNT = 41; - static constexpr auto COL_TX_AXFER_RECEIVER_ADDRESS = 42; - static constexpr auto COL_TX_AXFER_CLOSE_ADDRESS = 43; - static constexpr auto COL_TX_AXFER_CLOSE_AMOUNT = 44; - static constexpr auto COL_TX_AXFER_SENDER_ADDRESS = 45; - - static constexpr auto COL_TX_AFRZ_ASSET_ID = 46; - static constexpr auto COL_TX_AFRZ_FROZEN = 47; - static constexpr auto COL_TX_AFRZ_FROZEN_ADDRESS = 48; + static constexpr auto COL_TX_ACFG_ASSET_ID = 27; + static constexpr auto COL_TX_ACFG_ASSET_NAME = 28; + static constexpr auto COL_TX_ACFG_UNIT_NAME = 29; + static constexpr auto COL_TX_ACFG_TOTAL = 30; + static constexpr auto COL_TX_ACFG_DECIMALS = 31; + static constexpr auto COL_TX_ACFG_DEFAULT_FROZEN = 32; + static constexpr auto COL_TX_ACFG_CREATOR_ADDRESS = 33; + static constexpr auto COL_TX_ACFG_MANAGER_ADDRESS = 34; + static constexpr auto COL_TX_ACFG_RESERVE_ADDRESS = 35; + static constexpr auto COL_TX_ACFG_FREEZE_ADDRESS = 36; + static constexpr auto COL_TX_ACFG_CLAWBACK_ADDRESS = 37; + static constexpr auto COL_TX_ACFG_METADATA_HASH = 38; + static constexpr auto COL_TX_ACFG_URL = 39; + + static constexpr auto COL_TX_AXFER_ASSET_ID = 40; + static constexpr auto COL_TX_AXFER_ASSET_AMOUNT = 41; + static constexpr auto COL_TX_AXFER_RECEIVER_ADDRESS = 42; + static constexpr auto COL_TX_AXFER_CLOSE_ADDRESS = 43; + static constexpr auto COL_TX_AXFER_CLOSE_AMOUNT = 44; + static constexpr auto COL_TX_AXFER_SENDER_ADDRESS = 45; + + static constexpr auto COL_TX_AFRZ_ASSET_ID = 46; + static constexpr auto COL_TX_AFRZ_FROZEN = 47; + static constexpr auto COL_TX_AFRZ_FROZEN_ADDRESS = 48; // Helpers to deal with Option<> types, // because SOCI only understands boost::optional<>... diff --git a/core/src/wallet/algorand/transactions/util/TransactionAdaptor.hpp b/core/src/wallet/algorand/transactions/util/TransactionAdaptor.hpp index 54d77b08ba..f829dd103e 100644 --- a/core/src/wallet/algorand/transactions/util/TransactionAdaptor.hpp +++ b/core/src/wallet/algorand/transactions/util/TransactionAdaptor.hpp @@ -53,16 +53,16 @@ namespace ledger { namespace constants { // Header - static constexpr const char *fee = "fee"; - static constexpr const char *fv = "fv"; - static constexpr const char *gen = "gen"; - static constexpr const char *gh = "gh"; - static constexpr const char *grp = "grp"; - static constexpr const char *lv = "lv"; - static constexpr const char *lx = "lx"; - static constexpr const char *note = "note"; - static constexpr const char *snd = "snd"; - static constexpr const char *type = "type"; + static constexpr const char *fee = "fee"; + static constexpr const char *fv = "fv"; + static constexpr const char *gen = "gen"; + static constexpr const char *gh = "gh"; + static constexpr const char *grp = "grp"; + static constexpr const char *lv = "lv"; + static constexpr const char *lx = "lx"; + static constexpr const char *note = "note"; + static constexpr const char *snd = "snd"; + static constexpr const char *type = "type"; // Key Registration Transaction static constexpr const char *nonpart = "nonpart"; @@ -73,43 +73,43 @@ namespace ledger { static constexpr const char *votelst = "votelst"; // Payment Transaction - static constexpr const char *amt = "amt"; - static constexpr const char *close = "close"; - static constexpr const char *rcv = "rcv"; + static constexpr const char *amt = "amt"; + static constexpr const char *close = "close"; + static constexpr const char *rcv = "rcv"; // Asset configuration Transaction - static constexpr const char *apar = "apar"; - static constexpr const char *caid = "caid"; + static constexpr const char *apar = "apar"; + static constexpr const char *caid = "caid"; // Asset parameters - static constexpr const char *am = "am"; - static constexpr const char *an = "an"; - static constexpr const char *au = "au"; - static constexpr const char *c = "c"; - static constexpr const char *dc = "dc"; - static constexpr const char *df = "df"; - static constexpr const char *f = "f"; - static constexpr const char *m = "m"; - static constexpr const char *r = "r"; - static constexpr const char *t = "t"; - static constexpr const char *un = "un"; + static constexpr const char *am = "am"; + static constexpr const char *an = "an"; + static constexpr const char *au = "au"; + static constexpr const char *c = "c"; + static constexpr const char *dc = "dc"; + static constexpr const char *df = "df"; + static constexpr const char *f = "f"; + static constexpr const char *m = "m"; + static constexpr const char *r = "r"; + static constexpr const char *t = "t"; + static constexpr const char *un = "un"; // Asset Transfer Transaction - static constexpr const char *aamt = "aamt"; - static constexpr const char *aclose = "aclose"; - static constexpr const char *arcv = "arcv"; - static constexpr const char *asnd = "asnd"; - static constexpr const char *xaid = "xaid"; + static constexpr const char *aamt = "aamt"; + static constexpr const char *aclose = "aclose"; + static constexpr const char *arcv = "arcv"; + static constexpr const char *asnd = "asnd"; + static constexpr const char *xaid = "xaid"; // Asset Freeze Transaction - static constexpr const char *afrz = "afrz"; - static constexpr const char *fadd = "fadd"; - static constexpr const char *faid = "faid"; + static constexpr const char *afrz = "afrz"; + static constexpr const char *fadd = "fadd"; + static constexpr const char *faid = "faid"; // Signed Transaction - static constexpr const char *lsig = "lsig"; - static constexpr const char *msig = "msig"; - static constexpr const char *sig = "sig"; - static constexpr const char *txn = "txn"; + static constexpr const char *lsig = "lsig"; + static constexpr const char *msig = "msig"; + static constexpr const char *sig = "sig"; + static constexpr const char *txn = "txn"; } // namespace constants } // namespace algorand diff --git a/core/src/wallet/bitcoin/BitcoinLikeAccount.cpp b/core/src/wallet/bitcoin/BitcoinLikeAccount.cpp index 303310a6e9..0d29955982 100644 --- a/core/src/wallet/bitcoin/BitcoinLikeAccount.cpp +++ b/core/src/wallet/bitcoin/BitcoinLikeAccount.cpp @@ -597,7 +597,7 @@ namespace ledger { return FuturePtr::async(getWallet()->getPool()->getThreadPoolExecutionContext(), [=]() -> std::shared_ptr { const auto &uid = self->getAccountUid(); soci::session sql(self->getWallet()->getDatabase()->getReadonlyPool()); - auto keychain = self->getKeychain(); + auto keychain = self->getKeychain(); // make sure ALL UTXOs are contained within the balance - although no transaction will be crafted with those constexpr auto worthlessUtxoAmount = 0; const auto sum = BitcoinLikeUTXODatabaseHelper::sumUTXO(sql, uid, worthlessUtxoAmount); diff --git a/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp b/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp index c6863372d4..c888c976c9 100644 --- a/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp +++ b/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp @@ -241,7 +241,7 @@ namespace ledger { std::size_t fixedSize = 0; // Fixed size computation - fixedSize = 4; // Transaction version + fixedSize = 4; // Transaction version if (currency.bitcoinLikeNetworkParameters.value().UsesTimestampedTransaction) fixedSize += 4; // Timestamp fixedSize += BytesWriter().writeVarInt(inputCount).toByteArray().size(); // Number of inputs @@ -264,16 +264,16 @@ namespace ledger { if (isSegwit) { // Native Segwit: 32 PrevTxHash + 4 Index + 1 null byte + 4 sequence // P2SH: 32 PrevTxHash + 4 Index + 23 scriptPubKey + 4 sequence - const auto isNativeSegwit = BitcoinLikeKeychain::isNativeSegwit(keychainEngine); - const std::size_t inputSize = isNativeSegwit ? 41 : 63; - const std::size_t noWitness = fixedSize + inputSize * inputCount + maxOutputsSize; + const auto isNativeSegwit = BitcoinLikeKeychain::isNativeSegwit(keychainEngine); + const std::size_t inputSize = isNativeSegwit ? 41 : 63; + const std::size_t noWitness = fixedSize + inputSize * inputCount + maxOutputsSize; // Include flag and marker size (one byte each) const std::size_t minWitness = noWitness + (106 * inputCount) + 2; const std::size_t maxWitness = noWitness + (108 * inputCount) + 2; - minSize = (noWitness * 3 + minWitness) / 4; - maxSize = (noWitness * 3 + maxWitness) / 4; + minSize = (noWitness * 3 + minWitness) / 4; + maxSize = (noWitness * 3 + maxWitness) / 4; } else { minSize = fixedSize + 146 * inputCount + minOutputsSize; maxSize = fixedSize + 148 * inputCount + maxOutputsSize; @@ -298,7 +298,7 @@ namespace ledger { const std::string &keychainEngine) { const std::size_t fixedSize = estimateFixedTxSize(inputCount, outputs.size(), currency); - std::size_t outputsSize = (8 + 1) * outputs.size(); // amount (8 bytes) + script length (1 byte) + std::size_t outputsSize = (8 + 1) * outputs.size(); // amount (8 bytes) + script length (1 byte) for (const auto &out : outputs) { outputsSize += out->getScript().size(); } @@ -313,7 +313,7 @@ namespace ledger { const std::string &keychainEngine) { const std::size_t fixedSize = estimateFixedTxSize(inputCount, outputs.size(), currency); - std::size_t outputsSize = (8 + 1) * outputs.size(); // amount (8 bytes) + script length (1 byte) + std::size_t outputsSize = (8 + 1) * outputs.size(); // amount (8 bytes) + script length (1 byte) for (const auto &out : outputs) { outputsSize += std::dynamic_pointer_cast(std::get<1>(out))->getScript().serialize().size(); } @@ -323,10 +323,10 @@ namespace ledger { int32_t BitcoinLikeTransactionApi::computeWorthlessUtxoValue(const api::Currency ¤cy, const std::string &keychainEngine, const std::vector> &fees) { // Size of empty transaction (0 input 0 output) - auto const fixedSize = BitcoinLikeTransactionApi::estimateSize(0, - 0, - currency, - keychainEngine); + auto const fixedSize = BitcoinLikeTransactionApi::estimateSize(0, + 0, + currency, + keychainEngine); // Size 1 signed UTXO (signed input) const int32_t signedUTXOSize = BitcoinLikeTransactionApi::estimateSize(1, @@ -361,7 +361,7 @@ namespace ledger { BitcoinLikeTransactionApi &BitcoinLikeTransactionApi::setVersion(uint32_t version) { _version = version; // Update params - _params = networks::getNetworkParameters(_currency.name, _version); + _params = networks::getNetworkParameters(_currency.name, _version); return *this; } @@ -396,7 +396,7 @@ namespace ledger { // 4 value representing both stack size and length of R and S - sighash is excluded auto const sAndRLengthInt = 4 + signatures[i].r.size() + signatures[i].s.size(); // DER Signature = Total Size | DER prefix | Size(S+R) | R StackSize | R Length | R | S StackSize | S Length | S | SIGHASH - auto const totalSigInt = 2 + sAndRLengthInt; + auto const totalSigInt = 2 + sAndRLengthInt; writer.writeByte(totalSigInt); // DER prefix writer.writeByte(0x30); @@ -806,12 +806,12 @@ namespace ledger { // For BIP32_P2PKH it is recovered from scriptPubKey (see above) // For BIP49_P2SH it is recovered from redeemScript (see above) // Note: Decred does not support segwit - auto outAddress = preparedInputs[index].address; + auto outAddress = preparedInputs[index].address; if (isSegwit && preparedInputs[index].address.empty()) { // Get keychain engine // BIP173_P2WPKH script : (with .size() == 33) // BIP173_P2WSH script : - auto keychain = pubKey.size() == 33 ? api::KeychainEngines::BIP173_P2WPKH : api::KeychainEngines::BIP173_P2WSH; + auto keychain = pubKey.size() == 33 ? api::KeychainEngines::BIP173_P2WPKH : api::KeychainEngines::BIP173_P2WSH; // Get hash160 to construct address auto hash160 = BitcoinLikeAddress::fromPublicKeyToHash160(pubKey, currency, keychain); preparedInputs[index].address = BitcoinLikeAddress(currency, hash160, keychain).toString(); diff --git a/core/src/wallet/bitcoin/database/BitcoinLikeTransactionDatabaseHelper.cpp b/core/src/wallet/bitcoin/database/BitcoinLikeTransactionDatabaseHelper.cpp index 13bd75a75e..fcfde69933 100644 --- a/core/src/wallet/bitcoin/database/BitcoinLikeTransactionDatabaseHelper.cpp +++ b/core/src/wallet/bitcoin/database/BitcoinLikeTransactionDatabaseHelper.cpp @@ -95,7 +95,7 @@ namespace ledger { out.block = block; } - auto btcTxUid = BitcoinLikeTransactionDatabaseHelper::createBitcoinTransactionUid(accountUid, out.hash); + auto btcTxUid = BitcoinLikeTransactionDatabaseHelper::createBitcoinTransactionUid(accountUid, out.hash); // Fetch inputs rowset inputRows = (sql.prepare << "SELECT ti.input_idx, i.previous_output_idx, i.previous_tx_hash, i.amount, i.address, i.coinbase," diff --git a/core/src/wallet/bitcoin/database/BitcoinLikeUTXODatabaseHelper.h b/core/src/wallet/bitcoin/database/BitcoinLikeUTXODatabaseHelper.h index 065acf1d5c..13f598f77d 100644 --- a/core/src/wallet/bitcoin/database/BitcoinLikeUTXODatabaseHelper.h +++ b/core/src/wallet/bitcoin/database/BitcoinLikeUTXODatabaseHelper.h @@ -39,7 +39,7 @@ namespace ledger { namespace core { class BitcoinLikeUTXODatabaseHelper { - BitcoinLikeUTXODatabaseHelper() = delete; + BitcoinLikeUTXODatabaseHelper() = delete; ~BitcoinLikeUTXODatabaseHelper() = delete; diff --git a/core/src/wallet/bitcoin/factories/BitcoinLikeWalletFactory.cpp b/core/src/wallet/bitcoin/factories/BitcoinLikeWalletFactory.cpp index cf84853ced..9e8463a88b 100644 --- a/core/src/wallet/bitcoin/factories/BitcoinLikeWalletFactory.cpp +++ b/core/src/wallet/bitcoin/factories/BitcoinLikeWalletFactory.cpp @@ -149,10 +149,10 @@ namespace ledger { .value_or(api::ConfigurationDefaults::BLOCKCHAIN_DEFAULT_API_ENDPOINT)); auto &networkParams = getCurrency().bitcoinLikeNetworkParameters.value(); - auto context = pool->getDispatcher()->getThreadPoolExecutionContext( - fmt::format("{}-{}-explorer", - api::BlockchainExplorerEngines::LEDGER_API, - networkParams.Identifier)); + auto context = pool->getDispatcher()->getThreadPoolExecutionContext( + fmt::format("{}-{}-explorer", + api::BlockchainExplorerEngines::LEDGER_API, + networkParams.Identifier)); explorer = std::make_shared(context, http, networkParams, configuration); } diff --git a/core/src/wallet/bitcoin/keychains/BitcoinLikeKeychain.hpp b/core/src/wallet/bitcoin/keychains/BitcoinLikeKeychain.hpp index 76684d7efe..18978d48d1 100644 --- a/core/src/wallet/bitcoin/keychains/BitcoinLikeKeychain.hpp +++ b/core/src/wallet/bitcoin/keychains/BitcoinLikeKeychain.hpp @@ -67,18 +67,18 @@ namespace ledger { virtual bool markAsUsed(const std::vector &addresses); virtual bool markAsUsed(const std::string &address, bool needExtendKeychain = true); - virtual bool markPathAsUsed(const DerivationPath &path, bool needExtendKeychain = true) = 0; + virtual bool markPathAsUsed(const DerivationPath &path, bool needExtendKeychain = true) = 0; virtual std::vector
getAllObservableAddresses(uint32_t from, uint32_t to) = 0; virtual std::vector getAllObservableAddressString(uint32_t from, uint32_t to) = 0; virtual std::vector
getAllObservableAddresses(KeyPurpose purpose, uint32_t from, uint32_t to) = 0; - virtual Address getFreshAddress(KeyPurpose purpose) = 0; - virtual std::vector
getFreshAddresses(KeyPurpose purpose, size_t n) = 0; + virtual Address getFreshAddress(KeyPurpose purpose) = 0; + virtual std::vector
getFreshAddresses(KeyPurpose purpose, size_t n) = 0; - virtual Option getAddressPurpose(const std::string &address) const = 0; - virtual Option getAddressDerivationPath(const std::string &address) const = 0; - virtual bool isEmpty() const = 0; + virtual Option getAddressPurpose(const std::string &address) const = 0; + virtual Option getAddressDerivationPath(const std::string &address) const = 0; + virtual bool isEmpty() const = 0; int getAccountIndex() const; const api::BitcoinLikeNetworkParameters &getNetworkParameters() const; diff --git a/core/src/wallet/bitcoin/scripts/BitcoinLikeScript.cpp b/core/src/wallet/bitcoin/scripts/BitcoinLikeScript.cpp index 3ed6ba1995..5544d78b92 100644 --- a/core/src/wallet/bitcoin/scripts/BitcoinLikeScript.cpp +++ b/core/src/wallet/bitcoin/scripts/BitcoinLikeScript.cpp @@ -203,7 +203,7 @@ namespace ledger { if (_configuration.isSigned) { std::vector script = {0x00, 0x14}; // Hash160 of public key - auto publicKeyHash160 = HASH160::hash((*this)[1].getBytes(), hashAlgorithm); + auto publicKeyHash160 = HASH160::hash((*this)[1].getBytes(), hashAlgorithm); script.insert(script.end(), publicKeyHash160.begin(), publicKeyHash160.end()); return Option( BitcoinLikeAddress(currency, diff --git a/core/src/wallet/bitcoin/scripts/operators.h b/core/src/wallet/bitcoin/scripts/operators.h index f95795b1ae..d670bb639a 100644 --- a/core/src/wallet/bitcoin/scripts/operators.h +++ b/core/src/wallet/bitcoin/scripts/operators.h @@ -42,112 +42,112 @@ namespace ledger { /** Script opcodes */ enum opcodetype { // push value - OP_0 = 0x00, - OP_FALSE = OP_0, - OP_PUSHDATA1 = 0x4c, - OP_PUSHDATA2 = 0x4d, - OP_PUSHDATA4 = 0x4e, - OP_1NEGATE = 0x4f, - OP_RESERVED = 0x50, - OP_1 = 0x51, - OP_TRUE = OP_1, - OP_2 = 0x52, - OP_3 = 0x53, - OP_4 = 0x54, - OP_5 = 0x55, - OP_6 = 0x56, - OP_7 = 0x57, - OP_8 = 0x58, - OP_9 = 0x59, - OP_10 = 0x5a, - OP_11 = 0x5b, - OP_12 = 0x5c, - OP_13 = 0x5d, - OP_14 = 0x5e, - OP_15 = 0x5f, - OP_16 = 0x60, + OP_0 = 0x00, + OP_FALSE = OP_0, + OP_PUSHDATA1 = 0x4c, + OP_PUSHDATA2 = 0x4d, + OP_PUSHDATA4 = 0x4e, + OP_1NEGATE = 0x4f, + OP_RESERVED = 0x50, + OP_1 = 0x51, + OP_TRUE = OP_1, + OP_2 = 0x52, + OP_3 = 0x53, + OP_4 = 0x54, + OP_5 = 0x55, + OP_6 = 0x56, + OP_7 = 0x57, + OP_8 = 0x58, + OP_9 = 0x59, + OP_10 = 0x5a, + OP_11 = 0x5b, + OP_12 = 0x5c, + OP_13 = 0x5d, + OP_14 = 0x5e, + OP_15 = 0x5f, + OP_16 = 0x60, // control - OP_NOP = 0x61, - OP_VER = 0x62, - OP_IF = 0x63, - OP_NOTIF = 0x64, - OP_VERIF = 0x65, - OP_VERNOTIF = 0x66, - OP_ELSE = 0x67, - OP_ENDIF = 0x68, - OP_VERIFY = 0x69, - OP_RETURN = 0x6a, + OP_NOP = 0x61, + OP_VER = 0x62, + OP_IF = 0x63, + OP_NOTIF = 0x64, + OP_VERIF = 0x65, + OP_VERNOTIF = 0x66, + OP_ELSE = 0x67, + OP_ENDIF = 0x68, + OP_VERIFY = 0x69, + OP_RETURN = 0x6a, // stack ops - OP_TOALTSTACK = 0x6b, - OP_FROMALTSTACK = 0x6c, - OP_2DROP = 0x6d, - OP_2DUP = 0x6e, - OP_3DUP = 0x6f, - OP_2OVER = 0x70, - OP_2ROT = 0x71, - OP_2SWAP = 0x72, - OP_IFDUP = 0x73, - OP_DEPTH = 0x74, - OP_DROP = 0x75, - OP_DUP = 0x76, - OP_NIP = 0x77, - OP_OVER = 0x78, - OP_PICK = 0x79, - OP_ROLL = 0x7a, - OP_ROT = 0x7b, - OP_SWAP = 0x7c, - OP_TUCK = 0x7d, + OP_TOALTSTACK = 0x6b, + OP_FROMALTSTACK = 0x6c, + OP_2DROP = 0x6d, + OP_2DUP = 0x6e, + OP_3DUP = 0x6f, + OP_2OVER = 0x70, + OP_2ROT = 0x71, + OP_2SWAP = 0x72, + OP_IFDUP = 0x73, + OP_DEPTH = 0x74, + OP_DROP = 0x75, + OP_DUP = 0x76, + OP_NIP = 0x77, + OP_OVER = 0x78, + OP_PICK = 0x79, + OP_ROLL = 0x7a, + OP_ROT = 0x7b, + OP_SWAP = 0x7c, + OP_TUCK = 0x7d, // splice ops - OP_CAT = 0x7e, - OP_SUBSTR = 0x7f, - OP_LEFT = 0x80, - OP_RIGHT = 0x81, - OP_SIZE = 0x82, + OP_CAT = 0x7e, + OP_SUBSTR = 0x7f, + OP_LEFT = 0x80, + OP_RIGHT = 0x81, + OP_SIZE = 0x82, // bit logic - OP_INVERT = 0x83, - OP_AND = 0x84, - OP_OR = 0x85, - OP_XOR = 0x86, - OP_EQUAL = 0x87, - OP_EQUALVERIFY = 0x88, - OP_RESERVED1 = 0x89, - OP_RESERVED2 = 0x8a, + OP_INVERT = 0x83, + OP_AND = 0x84, + OP_OR = 0x85, + OP_XOR = 0x86, + OP_EQUAL = 0x87, + OP_EQUALVERIFY = 0x88, + OP_RESERVED1 = 0x89, + OP_RESERVED2 = 0x8a, // numeric - OP_1ADD = 0x8b, - OP_1SUB = 0x8c, - OP_2MUL = 0x8d, - OP_2DIV = 0x8e, - OP_NEGATE = 0x8f, - OP_ABS = 0x90, - OP_NOT = 0x91, - OP_0NOTEQUAL = 0x92, - - OP_ADD = 0x93, - OP_SUB = 0x94, - OP_MUL = 0x95, - OP_DIV = 0x96, - OP_MOD = 0x97, - OP_LSHIFT = 0x98, - OP_RSHIFT = 0x99, - - OP_BOOLAND = 0x9a, - OP_BOOLOR = 0x9b, - OP_NUMEQUAL = 0x9c, - OP_NUMEQUALVERIFY = 0x9d, - OP_NUMNOTEQUAL = 0x9e, - OP_LESSTHAN = 0x9f, - OP_GREATERTHAN = 0xa0, - OP_LESSTHANOREQUAL = 0xa1, - OP_GREATERTHANOREQUAL = 0xa2, - OP_MIN = 0xa3, - OP_MAX = 0xa4, - - OP_WITHIN = 0xa5, + OP_1ADD = 0x8b, + OP_1SUB = 0x8c, + OP_2MUL = 0x8d, + OP_2DIV = 0x8e, + OP_NEGATE = 0x8f, + OP_ABS = 0x90, + OP_NOT = 0x91, + OP_0NOTEQUAL = 0x92, + + OP_ADD = 0x93, + OP_SUB = 0x94, + OP_MUL = 0x95, + OP_DIV = 0x96, + OP_MOD = 0x97, + OP_LSHIFT = 0x98, + OP_RSHIFT = 0x99, + + OP_BOOLAND = 0x9a, + OP_BOOLOR = 0x9b, + OP_NUMEQUAL = 0x9c, + OP_NUMEQUALVERIFY = 0x9d, + OP_NUMNOTEQUAL = 0x9e, + OP_LESSTHAN = 0x9f, + OP_GREATERTHAN = 0xa0, + OP_LESSTHANOREQUAL = 0xa1, + OP_GREATERTHANOREQUAL = 0xa2, + OP_MIN = 0xa3, + OP_MAX = 0xa4, + + OP_WITHIN = 0xa5, // crypto OP_RIPEMD160 = 0xa6, @@ -176,12 +176,12 @@ namespace ledger { OP_NOP10 = 0xb9, // template matching params - OP_SMALLINTEGER = 0xfa, - OP_PUBKEYS = 0xfb, - OP_PUBKEYHASH = 0xfd, - OP_PUBKEY = 0xfe, + OP_SMALLINTEGER = 0xfa, + OP_PUBKEYS = 0xfb, + OP_PUBKEYHASH = 0xfd, + OP_PUBKEY = 0xfe, - OP_INVALIDOPCODE = 0xff, + OP_INVALIDOPCODE = 0xff, }; const char *GetOpName(opcodetype opcode); diff --git a/core/src/wallet/bitcoin/synchronizers/BlockchainExplorerAccountSynchronizer.cpp b/core/src/wallet/bitcoin/synchronizers/BlockchainExplorerAccountSynchronizer.cpp index 585b5fd4b1..0258694ed5 100644 --- a/core/src/wallet/bitcoin/synchronizers/BlockchainExplorerAccountSynchronizer.cpp +++ b/core/src/wallet/bitcoin/synchronizers/BlockchainExplorerAccountSynchronizer.cpp @@ -43,10 +43,10 @@ namespace ledger { constexpr auto ADDRESS_BATCH_SIZE = 10; - using Transaction = BitcoinLikeBlockchainExplorerTransaction; - using Input = BitcoinLikeBlockchainExplorerInput; - using CommonBuddy = BlockchainExplorerAccountSynchronizer::SynchronizationBuddy; - using TransactionMap = std::unordered_map>; + using Transaction = BitcoinLikeBlockchainExplorerTransaction; + using Input = BitcoinLikeBlockchainExplorerInput; + using CommonBuddy = BlockchainExplorerAccountSynchronizer::SynchronizationBuddy; + using TransactionMap = std::unordered_map>; struct BitcoinSynchronizationBuddy : public CommonBuddy { std::vector mempoolTransaction; @@ -63,7 +63,7 @@ namespace ledger { void BlockchainExplorerAccountSynchronizer::updateTransactionsToDrop(soci::session &sql, std::shared_ptr &buddy, const std::string &accountUid) { - auto span = _currentAccount->getTracer()->startSpan("BlockchainExplorerAccountSynchronizer::updateTransactionsToDrop"); + auto span = _currentAccount->getTracer()->startSpan("BlockchainExplorerAccountSynchronizer::updateTransactionsToDrop"); // Get all transactions in DB that may be dropped (txs without block_uid) soci::rowset rows = (sql.prepare << "SELECT op.uid, op.date, btc_op.transaction_hash FROM operations AS op " "LEFT OUTER JOIN bitcoin_operations AS btc_op ON btc_op.uid = op.uid " @@ -74,8 +74,8 @@ namespace ledger { const auto TX_HASH_COL = 2; // Create predicate function that returns true if the transaction should be saved from `transactionsToDrop` pruning - auto gracePeriod = buddy->account->getWallet()->getMempoolGracePeriod(); - auto isGraced = [gracePeriod, buddy](const auto &row, int date_col_index) -> bool { + auto gracePeriod = buddy->account->getWallet()->getMempoolGracePeriod(); + auto isGraced = [gracePeriod, buddy](const auto &row, int date_col_index) -> bool { if (row.get_indicator(date_col_index) == soci::i_null) { const auto txHash = row.template get(date_col_index); buddy->logger->warn("Mempool transaction (or optimistic update) is missing a date : {}, it won't be graced.", txHash); @@ -440,8 +440,8 @@ namespace ledger { return lhs.blockHeight < rhs.blockHeight; }); - auto currencyName = buddy->wallet->getCurrency().name; - size_t index = 0; + auto currencyName = buddy->wallet->getCurrency().name; + size_t index = 0; // Reorg can't happen until genesis block, safely initialize with 0 uint64_t deepestFailedBlockHeight = 0; while (index < sortedBatches.size() && !BlockDatabaseHelper::blockExists(sql, sortedBatches[index].blockHash, currencyName)) { @@ -508,10 +508,10 @@ namespace ledger { // get the last block height treated during the synchronization // std::max_element returns an iterator hence the indirection here // We use an constant iterator variable for readability purpose - auto const batchIt = std::max_element( - std::cbegin(batches), - std::cend(batches), - [](auto const &lhs, auto const &rhs) { + auto const batchIt = std::max_element( + std::cbegin(batches), + std::cend(batches), + [](auto const &lhs, auto const &rhs) { return lhs.blockHeight < rhs.blockHeight; }); soci::session sql(buddy->wallet->getDatabase()->getPool()); @@ -629,8 +629,8 @@ namespace ledger { AccountDatabaseHelper::removeBlockOperation(sql, buddy->account->getAccountUid(), blockToDelete); // Get last block not part from reorg - auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, - buddy->wallet->getCurrency().name); + auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, + buddy->wallet->getCurrency().name); // Resync from the "beginning" if no last block in DB int64_t lastBlockHeight = 0; @@ -723,9 +723,9 @@ namespace ledger { self->_explorerBenchmark->stop(); auto interpretBenchmark = NEW_BENCHMARK("interpret_operations"); - auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; + auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; buddy->logger->info("Got {} txs for account {}", bulk->transactions.size(), buddy->account->getAccountUid()); - auto count = 0; + auto count = 0; Option lastBlock = Option::NONE; std::vector operations; diff --git a/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeStrategyUtxoPicker.cpp b/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeStrategyUtxoPicker.cpp index 277c4ffee7..7f6199de5d 100644 --- a/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeStrategyUtxoPicker.cpp +++ b/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeStrategyUtxoPicker.cpp @@ -192,16 +192,16 @@ namespace ledger { */ // Compute long term fees - uint32_t confirmTarget = 1008; + uint32_t confirmTarget = 1008; // TODO: we will have a call to estimateSmartFees (bitcoin core/ explorer side) to estimate long term fees // int64_t longTermFees = estimateSmartFees(confirmTarget); - int64_t longTermFees = DEFAULT_FALLBACK_FEE; + int64_t longTermFees = DEFAULT_FALLBACK_FEE; // Compute cost of change - auto const fixedSize = BitcoinLikeTransactionApi::estimateSize(0, - 0, - currency, - buddy->keychain->getKeychainEngine()); + auto const fixedSize = BitcoinLikeTransactionApi::estimateSize(0, + 0, + currency, + buddy->keychain->getKeychainEngine()); // Size of only 1 output (without fixed size) const int64_t oneOutputSize = BitcoinLikeTransactionApi::estimateSize(0, 1, @@ -218,15 +218,15 @@ namespace ledger { fixedSize.Max; // Size of unsigned change - const int64_t changeSize = oneOutputSize; + const int64_t changeSize = oneOutputSize; // Size of signed change const int64_t signedChangeSize = signedUTXOSize; - const int64_t effectiveFees = buddy->request.feePerByte->toInt64(); + const int64_t effectiveFees = buddy->request.feePerByte->toInt64(); // Here signedChangeSize should be multiplied by discard fees // but since we don't have access to estimateSmartFees, we assume // that discard fees are equal to effectiveFees - const int64_t costOfChange = effectiveFees * (signedChangeSize + changeSize); + const int64_t costOfChange = effectiveFees * (signedChangeSize + changeSize); buddy->logger->debug("Cost of change {}, signedChangeSize {}, changeSize {}", costOfChange, signedChangeSize, changeSize); @@ -368,7 +368,7 @@ namespace ledger { std::vector includedUTXOs; bestValues.assign(vUTXOs.size(), true); - bestValue = totalLower; + bestValue = totalLower; auto insecureRand = []() -> bool { auto seed = std::chrono::system_clock::now().time_since_epoch().count(); @@ -413,10 +413,10 @@ namespace ledger { const BigInt &aggregatedAmount, const api::Currency ¤cy) { // Tx fixed size - auto const fixedSize = BitcoinLikeTransactionApi::estimateSize(0, - 0, - currency, - buddy->keychain->getKeychainEngine()); + auto const fixedSize = BitcoinLikeTransactionApi::estimateSize(0, + 0, + currency, + buddy->keychain->getKeychainEngine()); // Size of one output (without fixed size) const int64_t oneOutputSize = BitcoinLikeTransactionApi::estimateSize(0, 1, @@ -432,10 +432,10 @@ namespace ledger { .Max - fixedSize.Max; - const int64_t signedUTXOCost = signedUTXOSize * buddy->request.feePerByte->toInt64(); + const int64_t signedUTXOCost = signedUTXOSize * buddy->request.feePerByte->toInt64(); // Amount + fixed size fees + outputs fees - const int64_t amountWithFixedFees = buddy->request.feePerByte->toInt64() * (fixedSize.Max + (buddy->request.outputs.size() * oneOutputSize)) + buddy->outputAmount.toInt64(); + const int64_t amountWithFixedFees = buddy->request.feePerByte->toInt64() * (fixedSize.Max + (buddy->request.outputs.size() * oneOutputSize)) + buddy->outputAmount.toInt64(); // Minimum amount from which we are willing to create a change for it // We take the dust as a reference plus the cost of spending this change @@ -443,13 +443,13 @@ namespace ledger { const int64_t dustAmount_fixedAndOutputPart = BitcoinLikeTransactionApi::computeDustAmount(currency, (fixedSize.Max + (buddy->request.outputs.size() * oneOutputSize))); - const int64_t dustAmount_OneInputPart = BitcoinLikeTransactionApi::computeDustAmount(currency, - signedUTXOSize); + const int64_t dustAmount_OneInputPart = BitcoinLikeTransactionApi::computeDustAmount(currency, + signedUTXOSize); - const int64_t dustAmountWithOneInput = BitcoinLikeTransactionApi::computeDustAmount(currency, - fixedSize.Max + oneOutputSize + signedUTXOSize + signedUTXOSize); + const int64_t dustAmountWithOneInput = BitcoinLikeTransactionApi::computeDustAmount(currency, + fixedSize.Max + oneOutputSize + signedUTXOSize + signedUTXOSize); - const int64_t minimumChangeWithOneInput = dustAmountWithOneInput + signedUTXOCost; + const int64_t minimumChangeWithOneInput = dustAmountWithOneInput + signedUTXOCost; // const int64_t minimumChange = dustAmount + signedUTXOCost; buddy->logger->debug("Dust {}, Identifier {}, dustAmountWithOneInput {}", currency.bitcoinLikeNetworkParameters->Dust, currency.bitcoinLikeNetworkParameters->Identifier, dustAmountWithOneInput); @@ -470,7 +470,7 @@ namespace ledger { // Add fees for a signed input to amount for (auto index : indexes) { - auto &utxo = utxos[index]; + auto &utxo = utxos[index]; const int64_t currentAmount = utxo.value.toLong(); const int64_t currentAmountWithDeductedCost = currentAmount - signedUTXOCost; @@ -558,7 +558,7 @@ namespace ledger { buddy->changeAmount = BigInt(coinLowestLarger.getValue().value.toLong() - signedUTXOCost - (int64_t)(amountWithFixedFees + oneOutputSize * buddy->request.feePerByte->toInt64())); } else { // Pick bestValues buddy->logger->debug("Push all vUTXOs"); - out = tmpOut; + out = tmpOut; // Set amount of change // Change amount = amountWithFixedFees + fees for 1 additional output (change) buddy->changeAmount = BigInt(bestValue - (int64_t)(amountWithFixedFees + oneOutputSize * buddy->request.feePerByte->toInt64())); diff --git a/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeTransactionBuilder.cpp b/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeTransactionBuilder.cpp index dfe4dfe3b9..2f11122b0e 100644 --- a/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeTransactionBuilder.cpp +++ b/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeTransactionBuilder.cpp @@ -121,8 +121,8 @@ namespace ledger { // Wipe mode _request.wipe = true; // We don't have the amount yet, will be set when we fill outputs in BitcoinLikeUtxoPicker - auto a = std::shared_ptr(); - auto script = createSendScript(address); + auto a = std::shared_ptr(); + auto script = createSendScript(address); _request.outputs.push_back(std::tuple, std::shared_ptr>(a, script)); return shared_from_this(); } diff --git a/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeUtxoPicker.cpp b/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeUtxoPicker.cpp index b9fe592f36..83d03099e1 100644 --- a/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeUtxoPicker.cpp +++ b/core/src/wallet/bitcoin/transaction_builders/BitcoinLikeUtxoPicker.cpp @@ -119,10 +119,10 @@ namespace ledger { } // Fill change outputs - auto sizeWithChange = BitcoinLikeTransactionApi::estimateSize(buddy->transaction->getInputs().size(), - buddy->transaction->getOutputs(), - getCurrency(), - buddy->keychain->getKeychainEngine()); + auto sizeWithChange = BitcoinLikeTransactionApi::estimateSize(buddy->transaction->getInputs().size(), + buddy->transaction->getOutputs(), + getCurrency(), + buddy->keychain->getKeychainEngine()); const std::size_t changeOutputSize = BitcoinLikeTransactionApi::estimateOutputSize(buddy->keychain->getKeychainEngine()); sizeWithChange.Min += narrowing_cast(changeOutputSize); @@ -134,8 +134,8 @@ namespace ledger { // TODO implement use specific change address auto changeAddress = buddy->keychain->getFreshAddress(BitcoinLikeKeychain::CHANGE)->toString(); - auto amount = buddy->changeAmount; - auto script = BitcoinLikeScript::fromAddress(changeAddress, _currency); + auto amount = buddy->changeAmount; + auto script = BitcoinLikeScript::fromAddress(changeAddress, _currency); BitcoinLikeBlockchainExplorerOutput out; out.index = static_cast(buddy->transaction->getOutputs().size()); out.value = amount; @@ -172,7 +172,7 @@ namespace ledger { Future BitcoinLikeUtxoPicker::fillInputs(const std::shared_ptr &buddy) { buddy->logger->info("Filling inputs"); - auto self = shared_from_this(); + auto self = shared_from_this(); auto performFill = [self, buddy](auto performFill, auto index) { if (index >= buddy->request.inputs.size()) { @@ -259,7 +259,7 @@ namespace ledger { return keychain->contains(addr); })); - auto const isNotExcluded = [&keychainContains, &request](auto const ¤tUtxo) { + auto const isNotExcluded = [&keychainContains, &request](auto const ¤tUtxo) { return !(currentUtxo.address.isEmpty() || !keychainContains(currentUtxo.address.getValue()) || request.excludedUtxos.count(BitcoinLikeTransactionUtxoDescriptor{currentUtxo.transactionHash, currentUtxo.index}) > 0); }; diff --git a/core/src/wallet/common/Operation.h b/core/src/wallet/common/Operation.h index d3049471ad..35a930ce9f 100644 --- a/core/src/wallet/common/Operation.h +++ b/core/src/wallet/common/Operation.h @@ -82,10 +82,10 @@ namespace ledger { void refreshUid(const std::string &additional = ""); - Operation() = default; - Operation(Operation const &) = default; + Operation() = default; + Operation(Operation const &) = default; - Operation(Operation &&) = default; + Operation(Operation &&) = default; Operation &operator=(Operation const &) = default; Operation &operator=(Operation &&) = default; diff --git a/core/src/wallet/common/OperationQuery.cpp b/core/src/wallet/common/OperationQuery.cpp index fcb952ffe3..6cf633a070 100644 --- a/core/src/wallet/common/OperationQuery.cpp +++ b/core/src/wallet/common/OperationQuery.cpp @@ -193,7 +193,7 @@ namespace ledger { operationApi = std::make_shared(account->second); } - auto &operation = operationApi->getBackend(); + auto &operation = operationApi->getBackend(); // Inflate abstract operation diff --git a/core/src/wallet/common/database/OperationDatabaseHelper.cpp b/core/src/wallet/common/database/OperationDatabaseHelper.cpp index 2828585263..3eca4ef834 100644 --- a/core/src/wallet/common/database/OperationDatabaseHelper.cpp +++ b/core/src/wallet/common/database/OperationDatabaseHelper.cpp @@ -79,7 +79,7 @@ namespace ledger { " WHERE op.account_uid = :uid ORDER BY op.date", use(accountUid)); - auto filterList = [&](const std::vector &list) -> bool { + auto filterList = [&](const std::vector &list) -> bool { for (auto &elem : list) { if (filter(elem)) { return true; diff --git a/core/src/wallet/common/synchronizers/AbstractBlockchainExplorerAccountSynchronizer.h b/core/src/wallet/common/synchronizers/AbstractBlockchainExplorerAccountSynchronizer.h index bc252816e3..623d6d6dad 100644 --- a/core/src/wallet/common/synchronizers/AbstractBlockchainExplorerAccountSynchronizer.h +++ b/core/src/wallet/common/synchronizers/AbstractBlockchainExplorerAccountSynchronizer.h @@ -222,8 +222,8 @@ namespace ledger { return lhs.blockHeight < rhs.blockHeight; }); - auto currencyName = buddy->wallet->getCurrency().name; - size_t index = 0; + auto currencyName = buddy->wallet->getCurrency().name; + size_t index = 0; // Reorg can't happen until genesis block, safely initialize with 0 uint64_t deepestFailedBlockHeight = 0; while (index < sortedBatches.size() && !BlockDatabaseHelper::blockExists(sql, sortedBatches[index].blockHash, currencyName)) { @@ -265,10 +265,10 @@ namespace ledger { // get the last block height treated during the synchronization // std::max_element returns an iterator hence the indirection here // We use an constant iterator variable for readability purpose - auto const batchIt = std::max_element( - std::cbegin(batches), - std::cend(batches), - [](auto const &lhs, auto const &rhs) { + auto const batchIt = std::max_element( + std::cbegin(batches), + std::cend(batches), + [](auto const &lhs, auto const &rhs) { return lhs.blockHeight < rhs.blockHeight; }); soci::session sql(buddy->wallet->getDatabase()->getPool()); @@ -311,7 +311,7 @@ namespace ledger { auto self = getSharedFromThis(); auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; - auto benchmark = NEW_BENCHMARK("full_batch"); + auto benchmark = NEW_BENCHMARK("full_batch"); benchmark->start(); return synchronizeBatch(currentBatchIndex, buddy).template flatMap(buddy->account->getContext(), [=](const bool &hadTransactions) -> Future { benchmark->stop(); @@ -364,8 +364,8 @@ namespace ledger { AccountDatabaseHelper::removeBlockOperation(sql, buddy->account->getAccountUid(), blockToDelete); // Get last block not part from reorg - auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, - buddy->wallet->getCurrency().name); + auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, + buddy->wallet->getCurrency().name); // Resync from the "beginning" if no last block in DB int64_t lastBlockHeight = 0; @@ -464,10 +464,10 @@ namespace ledger { auto interpretBenchmark = NEW_BENCHMARK("interpret_operations"); - auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; + auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; // self->transactions.insert(self->transactions.end(), bulk->transactions.begin(), bulk->transactions.end()); buddy->logger->info("Got {} txs for account {}", bulk->transactions.size(), buddy->account->getAccountUid()); - auto count = 0; + auto count = 0; // NEW CODE Option lastBlock = Option::NONE; @@ -558,10 +558,10 @@ namespace ledger { virtual void interpretTransaction(const Transaction &transaction, const std::shared_ptr &buddy, std::vector &out) = 0; virtual void updateCurrentBlock(std::shared_ptr &buddy, - const std::shared_ptr &context) = 0; + const std::shared_ptr &context) = 0; virtual void updateTransactionsToDrop(soci::session &sql, std::shared_ptr &buddy, - const std::string &accountUid) = 0; + const std::string &accountUid) = 0; std::shared_ptr _explorer; std::shared_ptr> _notifier; diff --git a/core/src/wallet/cosmos/CosmosLikeAccount.cpp b/core/src/wallet/cosmos/CosmosLikeAccount.cpp index a82738279c..9477c415bd 100644 --- a/core/src/wallet/cosmos/CosmosLikeAccount.cpp +++ b/core/src/wallet/cosmos/CosmosLikeAccount.cpp @@ -145,7 +145,7 @@ namespace ledger { void CosmosLikeAccount::fillOperationTypeAmountFromMultiSend( CosmosLikeOperation &out, const cosmos::MsgMultiSend &innerMultiSendMsg) const { - const auto address = getAddress(); + const auto address = getAddress(); // Check if the user has more inputs or outputs in the message const auto &inputs = innerMultiSendMsg.inputs; @@ -359,8 +359,8 @@ namespace ledger { // AbstractBlockchainObserver::putTransaction) it makes it impossible to manage uids of nested // objects (eg. cosmos::Message). Writable copy of tx to allow to add uids. - auto tx = transaction; - tx.uid = CosmosLikeTransactionDatabaseHelper::createCosmosTransactionUid(getAccountUid(), tx.hash); + auto tx = transaction; + tx.uid = CosmosLikeTransactionDatabaseHelper::createCosmosTransactionUid(getAccountUid(), tx.hash); auto wallet = getWallet(); if (wallet == nullptr) { @@ -577,7 +577,7 @@ namespace ledger { std::lock_guard lock(_synchronizationLock); if (_currentSyncEventBus) return _currentSyncEventBus; - auto eventPublisher = std::make_shared(getContext()); + auto eventPublisher = std::make_shared(getContext()); _currentSyncEventBus = eventPublisher->getEventBus(); auto future = diff --git a/core/src/wallet/cosmos/CosmosLikeConstants.hpp b/core/src/wallet/cosmos/CosmosLikeConstants.hpp index e93d49c722..e4f31072ae 100644 --- a/core/src/wallet/cosmos/CosmosLikeConstants.hpp +++ b/core/src/wallet/cosmos/CosmosLikeConstants.hpp @@ -55,223 +55,223 @@ namespace ledger { constexpr char kGaiaWithdrawAddressEndpoint[] = "/distribution/delegators/{}/withdraw_address"; // use raw char array here to be compliant with rapidjson - constexpr char kMsgBeginRedelegate[] = "cosmos-sdk/MsgBeginRedelegate"; - constexpr char kMsgDelegate[] = "cosmos-sdk/MsgDelegate"; - constexpr char kMsgDeposit[] = "cosmos-sdk/MsgDeposit"; - constexpr char kMsgSend[] = "cosmos-sdk/MsgSend"; - constexpr char kMsgSubmitProposal[] = "cosmos-sdk/MsgSubmitProposal"; - constexpr char kMsgUndelegate[] = "cosmos-sdk/MsgUndelegate"; - constexpr char kMsgVote[] = "cosmos-sdk/MsgVote"; - constexpr char kMsgWithdrawDelegationReward[] = "cosmos-sdk/MsgWithdrawDelegationReward"; - constexpr char kMsgMultiSend[] = "cosmos-sdk/MsgMultiSend"; - constexpr char kMsgCreateValidator[] = "cosmos-sdk/MsgCreateValidator"; - constexpr char kMsgEditValidator[] = "cosmos-sdk/MsgEditValidator"; - constexpr char kMsgSetWithdrawAddress[] = "cosmos-sdk/MsgSetWithdrawAddress"; - constexpr char kMsgWithdrawDelegatorReward[] = "cosmos-sdk/MsgWithdrawDelegatorReward"; - constexpr char kMsgWithdrawValidatorCommission[] = "cosmos-sdk/MsgWithdrawValidatorCommission"; - constexpr char kMsgUnjail[] = "cosmos-sdk/MsgUnjail"; - constexpr char kMsgFees[] = "internal/MsgFees"; - - constexpr char kAccountNumber[] = "account_number"; - constexpr char kAddress[] = "address"; - constexpr char kAmount[] = "amount"; - constexpr char kBalance[] = "balance"; - constexpr char kBaseReq[] = "base_req"; - constexpr char kChainId[] = "chain_id"; - constexpr char kCoins[] = "coins"; - constexpr char kCommission[] = "commission"; - constexpr char kCommissionRate[] = "rate"; - constexpr char kCommissionRates[] = "commission_rates"; - constexpr char kCommissionMaxRate[] = "max_rate"; - constexpr char kCommissionMaxChangeRate[] = "max_change_rate"; - constexpr char kCompletionTime[] = "completion_time"; - constexpr char kConsensusPubkey[] = "consensus_pubkey"; - constexpr char kContent[] = "content"; - constexpr char kCount[] = "count"; - constexpr char kCreationHeight[] = "creation_height"; - constexpr char kDelegatorAddress[] = "delegator_address"; - constexpr char kDenom[] = "denom"; - constexpr char kDepositor[] = "depositor"; - constexpr char kDescription[] = "description"; - constexpr char kDetails[] = "details"; - constexpr char kEditValCommissionRate[] = "commission_rate"; - constexpr char kEntries[] = "entries"; - constexpr char kFee[] = "fee"; - constexpr char kFees[] = "fees"; - constexpr char kFrom[] = "from"; - constexpr char kFromAddress[] = "from_address"; - constexpr char kGas[] = "gas"; - constexpr char kGasAdjustment[] = "gas_adjustment"; - constexpr char kGasEstimate[] = "gas_estimate"; - constexpr char kGasUsed[] = "gas_used"; - constexpr char kHeight[] = "height"; - constexpr char kIdentity[] = "identity"; - constexpr char kIndexOffset[] = "index_offset"; - constexpr char kInitialBalance[] = "initial_balance"; - constexpr char kInitialDeposit[] = "initial_deposit"; - constexpr char kInputs[] = "inputs"; - constexpr char kJailed[] = "jailed"; - constexpr char kJailedUntil[] = "jailed_until"; - constexpr char kLog[] = "log"; - constexpr char kLogs[] = "logs"; - constexpr char kMaxHeight[] = "maxheight"; - constexpr char kMemo[] = "memo"; - constexpr char kMessage[] = "msg"; - constexpr char kMessages[] = "msgs"; - constexpr char kMinHeight[] = "minheight"; - constexpr char kMinSelfDelegation[] = "min_self_delegation"; - constexpr char kMissedBlocksCounter[] = "missed_blocks_counter"; - constexpr char kMoniker[] = "moniker"; - constexpr char kMsgIndex[] = "msg_index"; - constexpr char kOperatorAddress[] = "operator_address"; - constexpr char kOption[] = "option"; - constexpr char kOutputs[] = "outputs"; - constexpr char kProposalId[] = "proposal_id"; - constexpr char kProposer[] = "proposer"; - constexpr char kPubKey[] = "pub_key"; - constexpr char kResult[] = "result"; - constexpr char kReward[] = "reward"; - constexpr char kRewards[] = "rewards"; - constexpr char kSelfBondRewards[] = "self_bond_rewards"; - constexpr char kSequence[] = "sequence"; - constexpr char kSignature[] = "signature"; - constexpr char kSimulate[] = "simulate"; - constexpr char kSignatures[] = "signatures"; - constexpr char kStartHeight[] = "start_height"; - constexpr char kStatus[] = "status"; - constexpr char kSuccess[] = "success"; - constexpr char kTimestamp[] = "timestamp"; - constexpr char kTitle[] = "title"; - constexpr char kToAddress[] = "to_address"; - constexpr char kTokens[] = "tokens"; - constexpr char kTombstoned[] = "tombstoned"; - constexpr char kTotal[] = "total"; - constexpr char kTotalCount[] = "total_count"; - constexpr char kTxArray[] = "txs"; - constexpr char kTxHash[] = "txhash"; - constexpr char kTx[] = "tx"; - constexpr char kType[] = "type"; - constexpr char kUnbondingHeight[] = "unbonding_height"; - constexpr char kUnbondingTime[] = "unbonding_time"; - constexpr char kUpdateTime[] = "update_time"; - constexpr char kValCommission[] = "val_commission"; - constexpr char kValidatorAddress[] = "validator_address"; - constexpr char kValidatorDstAddress[] = "validator_dst_address"; - constexpr char kValidatorSrcAddress[] = "validator_src_address"; - constexpr char kValue[] = "value"; - constexpr char kVoter[] = "voter"; - constexpr char kWebsite[] = "website"; - constexpr char kWithdrawAddress[] = "withdraw_address"; + constexpr char kMsgBeginRedelegate[] = "cosmos-sdk/MsgBeginRedelegate"; + constexpr char kMsgDelegate[] = "cosmos-sdk/MsgDelegate"; + constexpr char kMsgDeposit[] = "cosmos-sdk/MsgDeposit"; + constexpr char kMsgSend[] = "cosmos-sdk/MsgSend"; + constexpr char kMsgSubmitProposal[] = "cosmos-sdk/MsgSubmitProposal"; + constexpr char kMsgUndelegate[] = "cosmos-sdk/MsgUndelegate"; + constexpr char kMsgVote[] = "cosmos-sdk/MsgVote"; + constexpr char kMsgWithdrawDelegationReward[] = "cosmos-sdk/MsgWithdrawDelegationReward"; + constexpr char kMsgMultiSend[] = "cosmos-sdk/MsgMultiSend"; + constexpr char kMsgCreateValidator[] = "cosmos-sdk/MsgCreateValidator"; + constexpr char kMsgEditValidator[] = "cosmos-sdk/MsgEditValidator"; + constexpr char kMsgSetWithdrawAddress[] = "cosmos-sdk/MsgSetWithdrawAddress"; + constexpr char kMsgWithdrawDelegatorReward[] = "cosmos-sdk/MsgWithdrawDelegatorReward"; + constexpr char kMsgWithdrawValidatorCommission[] = "cosmos-sdk/MsgWithdrawValidatorCommission"; + constexpr char kMsgUnjail[] = "cosmos-sdk/MsgUnjail"; + constexpr char kMsgFees[] = "internal/MsgFees"; + + constexpr char kAccountNumber[] = "account_number"; + constexpr char kAddress[] = "address"; + constexpr char kAmount[] = "amount"; + constexpr char kBalance[] = "balance"; + constexpr char kBaseReq[] = "base_req"; + constexpr char kChainId[] = "chain_id"; + constexpr char kCoins[] = "coins"; + constexpr char kCommission[] = "commission"; + constexpr char kCommissionRate[] = "rate"; + constexpr char kCommissionRates[] = "commission_rates"; + constexpr char kCommissionMaxRate[] = "max_rate"; + constexpr char kCommissionMaxChangeRate[] = "max_change_rate"; + constexpr char kCompletionTime[] = "completion_time"; + constexpr char kConsensusPubkey[] = "consensus_pubkey"; + constexpr char kContent[] = "content"; + constexpr char kCount[] = "count"; + constexpr char kCreationHeight[] = "creation_height"; + constexpr char kDelegatorAddress[] = "delegator_address"; + constexpr char kDenom[] = "denom"; + constexpr char kDepositor[] = "depositor"; + constexpr char kDescription[] = "description"; + constexpr char kDetails[] = "details"; + constexpr char kEditValCommissionRate[] = "commission_rate"; + constexpr char kEntries[] = "entries"; + constexpr char kFee[] = "fee"; + constexpr char kFees[] = "fees"; + constexpr char kFrom[] = "from"; + constexpr char kFromAddress[] = "from_address"; + constexpr char kGas[] = "gas"; + constexpr char kGasAdjustment[] = "gas_adjustment"; + constexpr char kGasEstimate[] = "gas_estimate"; + constexpr char kGasUsed[] = "gas_used"; + constexpr char kHeight[] = "height"; + constexpr char kIdentity[] = "identity"; + constexpr char kIndexOffset[] = "index_offset"; + constexpr char kInitialBalance[] = "initial_balance"; + constexpr char kInitialDeposit[] = "initial_deposit"; + constexpr char kInputs[] = "inputs"; + constexpr char kJailed[] = "jailed"; + constexpr char kJailedUntil[] = "jailed_until"; + constexpr char kLog[] = "log"; + constexpr char kLogs[] = "logs"; + constexpr char kMaxHeight[] = "maxheight"; + constexpr char kMemo[] = "memo"; + constexpr char kMessage[] = "msg"; + constexpr char kMessages[] = "msgs"; + constexpr char kMinHeight[] = "minheight"; + constexpr char kMinSelfDelegation[] = "min_self_delegation"; + constexpr char kMissedBlocksCounter[] = "missed_blocks_counter"; + constexpr char kMoniker[] = "moniker"; + constexpr char kMsgIndex[] = "msg_index"; + constexpr char kOperatorAddress[] = "operator_address"; + constexpr char kOption[] = "option"; + constexpr char kOutputs[] = "outputs"; + constexpr char kProposalId[] = "proposal_id"; + constexpr char kProposer[] = "proposer"; + constexpr char kPubKey[] = "pub_key"; + constexpr char kResult[] = "result"; + constexpr char kReward[] = "reward"; + constexpr char kRewards[] = "rewards"; + constexpr char kSelfBondRewards[] = "self_bond_rewards"; + constexpr char kSequence[] = "sequence"; + constexpr char kSignature[] = "signature"; + constexpr char kSimulate[] = "simulate"; + constexpr char kSignatures[] = "signatures"; + constexpr char kStartHeight[] = "start_height"; + constexpr char kStatus[] = "status"; + constexpr char kSuccess[] = "success"; + constexpr char kTimestamp[] = "timestamp"; + constexpr char kTitle[] = "title"; + constexpr char kToAddress[] = "to_address"; + constexpr char kTokens[] = "tokens"; + constexpr char kTombstoned[] = "tombstoned"; + constexpr char kTotal[] = "total"; + constexpr char kTotalCount[] = "total_count"; + constexpr char kTxArray[] = "txs"; + constexpr char kTxHash[] = "txhash"; + constexpr char kTx[] = "tx"; + constexpr char kType[] = "type"; + constexpr char kUnbondingHeight[] = "unbonding_height"; + constexpr char kUnbondingTime[] = "unbonding_time"; + constexpr char kUpdateTime[] = "update_time"; + constexpr char kValCommission[] = "val_commission"; + constexpr char kValidatorAddress[] = "validator_address"; + constexpr char kValidatorDstAddress[] = "validator_dst_address"; + constexpr char kValidatorSrcAddress[] = "validator_src_address"; + constexpr char kValue[] = "value"; + constexpr char kVoter[] = "voter"; + constexpr char kWebsite[] = "website"; + constexpr char kWithdrawAddress[] = "withdraw_address"; // Explorer specific constants - constexpr char kBlockMeta[] = "block_meta"; - constexpr char kBlockId[] = "block_id"; - constexpr char kHash[] = "hash"; - constexpr char kHeader[] = "header"; - constexpr char kTime[] = "time"; - constexpr char kMode[] = "mode"; + constexpr char kBlockMeta[] = "block_meta"; + constexpr char kBlockId[] = "block_id"; + constexpr char kHash[] = "hash"; + constexpr char kHeader[] = "header"; + constexpr char kTime[] = "time"; + constexpr char kMode[] = "mode"; // cosmos/cosmos-sdk Event / Attribute types as of // https://github.com/cosmos/cosmos-sdk/tree/43137ee893cefbdb2aacd25ef4ec39eacf6ae70c // Common in all messages - constexpr char kEventTypeMessage[] = "message"; + constexpr char kEventTypeMessage[] = "message"; - constexpr char kAttributeKeyAction[] = "action"; - constexpr char kAttributeKeyModule[] = "module"; - constexpr char kAttributeKeySender[] = "sender"; - constexpr char kAttributeKeyAmount[] = "amount"; - constexpr char kAttributeWithdrawDelegationReward[] = "withdraw_delegator_reward"; + constexpr char kAttributeKeyAction[] = "action"; + constexpr char kAttributeKeyModule[] = "module"; + constexpr char kAttributeKeySender[] = "sender"; + constexpr char kAttributeKeyAmount[] = "amount"; + constexpr char kAttributeWithdrawDelegationReward[] = "withdraw_delegator_reward"; - constexpr char kPubKeySecp256k1[] = "tendermint/PubKeySecp256k1"; + constexpr char kPubKeySecp256k1[] = "tendermint/PubKeySecp256k1"; // Staking - constexpr char kEventTypeCompleteUnbonding[] = "complete_unbonding"; - constexpr char kEventTypeCompleteRedelegation[] = "complete_redelegation"; - constexpr char kEventTypeCreateValidator[] = "create_validator"; - constexpr char kEventTypeEditValidator[] = "edit_validator"; - constexpr char kEventTypeDelegate[] = "delegate"; - constexpr char kEventTypeUnbond[] = "unbond"; - constexpr char kEventTypeRedelegate[] = "redelegate"; - - constexpr char kAttributeKeyValidator[] = "validator"; - constexpr char kAttributeKeyCommissionRate[] = "commission_rate"; - constexpr char kAttributeKeyMinSelfDelegation[] = "min_self_delegation"; - constexpr char kAttributeKeySrcValidator[] = "source_validator"; - constexpr char kAttributeKeyDstValidator[] = "destination_validator"; - constexpr char kAttributeKeyDelegator[] = "delegator"; - constexpr char kAttributeKeyCompletionTime[] = "completion_time"; - constexpr char kAttributeValueStakingCategory[] = "staking"; + constexpr char kEventTypeCompleteUnbonding[] = "complete_unbonding"; + constexpr char kEventTypeCompleteRedelegation[] = "complete_redelegation"; + constexpr char kEventTypeCreateValidator[] = "create_validator"; + constexpr char kEventTypeEditValidator[] = "edit_validator"; + constexpr char kEventTypeDelegate[] = "delegate"; + constexpr char kEventTypeUnbond[] = "unbond"; + constexpr char kEventTypeRedelegate[] = "redelegate"; + + constexpr char kAttributeKeyValidator[] = "validator"; + constexpr char kAttributeKeyCommissionRate[] = "commission_rate"; + constexpr char kAttributeKeyMinSelfDelegation[] = "min_self_delegation"; + constexpr char kAttributeKeySrcValidator[] = "source_validator"; + constexpr char kAttributeKeyDstValidator[] = "destination_validator"; + constexpr char kAttributeKeyDelegator[] = "delegator"; + constexpr char kAttributeKeyCompletionTime[] = "completion_time"; + constexpr char kAttributeValueStakingCategory[] = "staking"; // Distribution - constexpr char kEventTypeSetWithdrawAddress[] = "set_withdraw_address"; - constexpr char kEventTypeRewards[] = "rewards"; - constexpr char kEventTypeCommission[] = "commission"; - constexpr char kEventTypeWithdrawRewards[] = "withdraw_rewards"; - constexpr char kEventTypeWithdrawCommission[] = "withdraw_commission"; - constexpr char kEventTypeProposerReward[] = "proposer_reward"; + constexpr char kEventTypeSetWithdrawAddress[] = "set_withdraw_address"; + constexpr char kEventTypeRewards[] = "rewards"; + constexpr char kEventTypeCommission[] = "commission"; + constexpr char kEventTypeWithdrawRewards[] = "withdraw_rewards"; + constexpr char kEventTypeWithdrawCommission[] = "withdraw_commission"; + constexpr char kEventTypeProposerReward[] = "proposer_reward"; - constexpr char kAttributeKeyWithdrawAddress[] = "withdraw_address"; + constexpr char kAttributeKeyWithdrawAddress[] = "withdraw_address"; - constexpr char kAttributeValueDistributionCategory[] = "distribution"; + constexpr char kAttributeValueDistributionCategory[] = "distribution"; // gov - constexpr char kEventTypeSubmitProposal[] = "submit_proposal"; - constexpr char kEventTypeProposalDeposit[] = "proposal_deposit"; - constexpr char kEventTypeProposalVote[] = "proposal_vote"; - constexpr char kEventTypeInactiveProposal[] = "inactive_proposal"; - constexpr char kEventTypeActiveProposal[] = "active_proposal"; - - constexpr char kAttributeKeyProposalResult[] = "proposal_result"; - constexpr char kAttributeKeyOption[] = "option"; - constexpr char kAttributeKeyProposalID[] = "proposal_id"; - constexpr char kAttributeKeyVotingPeriodStart[] = "voting_period_start"; - constexpr char kAttributeValueGovernanceCategory[] = "governance"; - constexpr char kAttributeValueProposalDropped[] = "proposal_dropped"; // didn't meet min deposit - constexpr char kAttributeValueProposalPassed[] = "proposal_passed"; // met vote quorum - constexpr char kAttributeValueProposalRejected[] = "proposal_rejected"; // didn't meet vote quorum - constexpr char kAttributeValueProposalFailed[] = "proposal_failed"; // error on proposal handler - constexpr char kAttributeKeyProposalType[] = "proposal_type"; - - constexpr char kVoteOptionAbstain[] = "Abstain"; - constexpr char kVoteOptionNo[] = "No"; - constexpr char kVoteOptionNoWithVeto[] = "NoWithVeto"; - constexpr char kVoteOptionYes[] = "Yes"; + constexpr char kEventTypeSubmitProposal[] = "submit_proposal"; + constexpr char kEventTypeProposalDeposit[] = "proposal_deposit"; + constexpr char kEventTypeProposalVote[] = "proposal_vote"; + constexpr char kEventTypeInactiveProposal[] = "inactive_proposal"; + constexpr char kEventTypeActiveProposal[] = "active_proposal"; + + constexpr char kAttributeKeyProposalResult[] = "proposal_result"; + constexpr char kAttributeKeyOption[] = "option"; + constexpr char kAttributeKeyProposalID[] = "proposal_id"; + constexpr char kAttributeKeyVotingPeriodStart[] = "voting_period_start"; + constexpr char kAttributeValueGovernanceCategory[] = "governance"; + constexpr char kAttributeValueProposalDropped[] = "proposal_dropped"; // didn't meet min deposit + constexpr char kAttributeValueProposalPassed[] = "proposal_passed"; // met vote quorum + constexpr char kAttributeValueProposalRejected[] = "proposal_rejected"; // didn't meet vote quorum + constexpr char kAttributeValueProposalFailed[] = "proposal_failed"; // error on proposal handler + constexpr char kAttributeKeyProposalType[] = "proposal_type"; + + constexpr char kVoteOptionAbstain[] = "Abstain"; + constexpr char kVoteOptionNo[] = "No"; + constexpr char kVoteOptionNoWithVeto[] = "NoWithVeto"; + constexpr char kVoteOptionYes[] = "Yes"; // bank - constexpr char kEventTypeTransfer[] = "transfer"; + constexpr char kEventTypeTransfer[] = "transfer"; - constexpr char kAttributeKeyRecipient[] = "recipient"; + constexpr char kAttributeKeyRecipient[] = "recipient"; - constexpr char kAttributeValueBankCategory[] = "bank"; + constexpr char kAttributeValueBankCategory[] = "bank"; // crisis - constexpr char kEventTypeInvariant[] = "invariant"; + constexpr char kEventTypeInvariant[] = "invariant"; - constexpr char kAttributeValueCrisis[] = "crisis"; - constexpr char kAttributeKeyRoute[] = "route"; + constexpr char kAttributeValueCrisis[] = "crisis"; + constexpr char kAttributeKeyRoute[] = "route"; // slashing - constexpr char kEventTypeSlash[] = "slash"; - constexpr char kEventTypeLiveness[] = "liveness"; + constexpr char kEventTypeSlash[] = "slash"; + constexpr char kEventTypeLiveness[] = "liveness"; - constexpr char kAttributeKeyAddress[] = "address"; - constexpr char kAttributeKeyHeight[] = "height"; - constexpr char kAttributeKeyPower[] = "power"; - constexpr char kAttributeKeyReason[] = "reason"; - constexpr char kAttributeKeyJailed[] = "jailed"; - constexpr char kAttributeKeyMissedBlocks[] = "missed_blocks"; + constexpr char kAttributeKeyAddress[] = "address"; + constexpr char kAttributeKeyHeight[] = "height"; + constexpr char kAttributeKeyPower[] = "power"; + constexpr char kAttributeKeyReason[] = "reason"; + constexpr char kAttributeKeyJailed[] = "jailed"; + constexpr char kAttributeKeyMissedBlocks[] = "missed_blocks"; - constexpr char kAttributeValueDoubleSign[] = "double_sign"; - constexpr char kAttributeValueMissingSignature[] = "missing_signature"; - constexpr char kAttributeValueSlashingCategory[] = "slashing"; + constexpr char kAttributeValueDoubleSign[] = "double_sign"; + constexpr char kAttributeValueMissingSignature[] = "missing_signature"; + constexpr char kAttributeValueSlashingCategory[] = "slashing"; // mint - constexpr char kEventTypeMint[] = "mint"; + constexpr char kEventTypeMint[] = "mint"; - constexpr char kAttributeKeyBondedRatio[] = "bonded_ratio"; - constexpr char kAttributeKeyInflation[] = "inflation"; - constexpr char kAttributeKeyAnnualProvisions[] = "annual_provisions"; + constexpr char kAttributeKeyBondedRatio[] = "bonded_ratio"; + constexpr char kAttributeKeyInflation[] = "inflation"; + constexpr char kAttributeKeyAnnualProvisions[] = "annual_provisions"; } // namespace constants static constexpr const char *msgTypeToChars(MsgType type) { diff --git a/core/src/wallet/cosmos/CosmosLikeMessage.cpp b/core/src/wallet/cosmos/CosmosLikeMessage.cpp index 650a2ecc30..64c5bd0a67 100644 --- a/core/src/wallet/cosmos/CosmosLikeMessage.cpp +++ b/core/src/wallet/cosmos/CosmosLikeMessage.cpp @@ -365,7 +365,7 @@ namespace ledger { } else if (_msgData.type == kMsgCreateValidator) { const auto &content = boost::get(_msgData.content); - auto jsonDesc = rapidjson::Value(rapidjson::kObjectType); + auto jsonDesc = rapidjson::Value(rapidjson::kObjectType); addString(kMoniker, content.descr.moniker, jsonDesc, allocator); addOptionalString(kIdentity, content.descr.identity, jsonDesc, allocator); addOptionalString(kWebsite, content.descr.website, jsonDesc, allocator); diff --git a/core/src/wallet/cosmos/cosmos.hpp b/core/src/wallet/cosmos/cosmos.hpp index 5fbf194924..83f56b9513 100644 --- a/core/src/wallet/cosmos/cosmos.hpp +++ b/core/src/wallet/cosmos/cosmos.hpp @@ -57,38 +57,38 @@ namespace ledger { namespace core { namespace cosmos { - using Block = ledger::core::Block; + using Block = ledger::core::Block; - using ProposalContent = api::CosmosLikeContent; - using VoteOption = api::CosmosLikeVoteOption; + using ProposalContent = api::CosmosLikeContent; + using VoteOption = api::CosmosLikeVoteOption; using ValidatorDescription = api::CosmosLikeValidatorDescription; using ValidatorCommission = api::CosmosLikeValidatorCommission; using ValidatorSigningInformation = api::CosmosLikeValidatorSigningInformation; using ValidatorDistributionInformation = api::CosmosLikeValidatorDistributionInformation; - using Validator = api::CosmosLikeValidator; - using CommissionRates = api::CosmosLikeCommissionRates; - - using MultiSendInput = api::CosmosLikeMultiSendInput; - using MultiSendOutput = api::CosmosLikeMultiSendOutput; - - using Coin = api::CosmosLikeAmount; - using MsgSend = api::CosmosLikeMsgSend; - using MsgDelegate = api::CosmosLikeMsgDelegate; - using MsgUndelegate = api::CosmosLikeMsgUndelegate; - using MsgBeginRedelegate = api::CosmosLikeMsgBeginRedelegate; - using MsgSubmitProposal = api::CosmosLikeMsgSubmitProposal; - using MsgVote = api::CosmosLikeMsgVote; - using MsgDeposit = api::CosmosLikeMsgDeposit; - using MsgWithdrawDelegationReward = api::CosmosLikeMsgWithdrawDelegationReward; - using MsgMultiSend = api::CosmosLikeMsgMultiSend; - using MsgCreateValidator = api::CosmosLikeMsgCreateValidator; - using MsgEditValidator = api::CosmosLikeMsgEditValidator; - using MsgSetWithdrawAddress = api::CosmosLikeMsgSetWithdrawAddress; - using MsgWithdrawDelegatorReward = api::CosmosLikeMsgWithdrawDelegatorReward; - using MsgWithdrawValidatorCommission = api::CosmosLikeMsgWithdrawValidatorCommission; - using MsgUnjail = api::CosmosLikeMsgUnjail; + using Validator = api::CosmosLikeValidator; + using CommissionRates = api::CosmosLikeCommissionRates; + + using MultiSendInput = api::CosmosLikeMultiSendInput; + using MultiSendOutput = api::CosmosLikeMultiSendOutput; + + using Coin = api::CosmosLikeAmount; + using MsgSend = api::CosmosLikeMsgSend; + using MsgDelegate = api::CosmosLikeMsgDelegate; + using MsgUndelegate = api::CosmosLikeMsgUndelegate; + using MsgBeginRedelegate = api::CosmosLikeMsgBeginRedelegate; + using MsgSubmitProposal = api::CosmosLikeMsgSubmitProposal; + using MsgVote = api::CosmosLikeMsgVote; + using MsgDeposit = api::CosmosLikeMsgDeposit; + using MsgWithdrawDelegationReward = api::CosmosLikeMsgWithdrawDelegationReward; + using MsgMultiSend = api::CosmosLikeMsgMultiSend; + using MsgCreateValidator = api::CosmosLikeMsgCreateValidator; + using MsgEditValidator = api::CosmosLikeMsgEditValidator; + using MsgSetWithdrawAddress = api::CosmosLikeMsgSetWithdrawAddress; + using MsgWithdrawDelegatorReward = api::CosmosLikeMsgWithdrawDelegatorReward; + using MsgWithdrawValidatorCommission = api::CosmosLikeMsgWithdrawValidatorCommission; + using MsgUnjail = api::CosmosLikeMsgUnjail; struct MsgFees final { std::string payerAddress; diff --git a/core/src/wallet/cosmos/database/CosmosLikeAccountDatabaseHelper.cpp b/core/src/wallet/cosmos/database/CosmosLikeAccountDatabaseHelper.cpp index cefab721dc..1538b4cb6b 100644 --- a/core/src/wallet/cosmos/database/CosmosLikeAccountDatabaseHelper.cpp +++ b/core/src/wallet/cosmos/database/CosmosLikeAccountDatabaseHelper.cpp @@ -74,14 +74,14 @@ namespace ledger { const auto COL_WITHDRAW_ADDRESS = 6; const auto COL_LAST_UPDATE = 7; for (auto &row : rows) { - entry.index = row.get(COL_IDX); - entry.pubkey = row.get(COL_PUBKEY); - auto accountType = row.get>(COL_ACC_TYPE); - auto accountNumber = row.get>(COL_ACC_NUM); - auto sequence = row.get>(COL_SEQUENCE); - auto balances = row.get>(COL_BALANCES); - auto withdrawAddress = row.get>(COL_WITHDRAW_ADDRESS); - auto lastUpdate = row.get>(COL_LAST_UPDATE); + entry.index = row.get(COL_IDX); + entry.pubkey = row.get(COL_PUBKEY); + auto accountType = row.get>(COL_ACC_TYPE); + auto accountNumber = row.get>(COL_ACC_NUM); + auto sequence = row.get>(COL_SEQUENCE); + auto balances = row.get>(COL_BALANCES); + auto withdrawAddress = row.get>(COL_WITHDRAW_ADDRESS); + auto lastUpdate = row.get>(COL_LAST_UPDATE); entry.details.type = accountType.getValueOr(""); entry.details.sequence = sequence.getValueOr("0"); @@ -91,8 +91,8 @@ namespace ledger { } entry.details.withdrawAddress = withdrawAddress.getValueOr(""); - entry.details.pubkey = entry.pubkey; - entry.lastUpdate = lastUpdate.getValueOr({}); + entry.details.pubkey = entry.pubkey; + entry.lastUpdate = lastUpdate.getValueOr({}); return true; } diff --git a/core/src/wallet/cosmos/database/CosmosLikeOperationDatabaseHelper.hpp b/core/src/wallet/cosmos/database/CosmosLikeOperationDatabaseHelper.hpp index 1d4049602e..3897272d98 100644 --- a/core/src/wallet/cosmos/database/CosmosLikeOperationDatabaseHelper.hpp +++ b/core/src/wallet/cosmos/database/CosmosLikeOperationDatabaseHelper.hpp @@ -61,7 +61,7 @@ namespace ledger { const auto COL_SEND = 4; const auto COL_RECV = 5; - auto filterList = [&](const std::vector &list) -> bool { + auto filterList = [&](const std::vector &list) -> bool { for (auto &elem : list) { if (filter(elem)) { return true; diff --git a/core/src/wallet/cosmos/database/CosmosLikeTransactionDatabaseHelper.cpp b/core/src/wallet/cosmos/database/CosmosLikeTransactionDatabaseHelper.cpp index 1be1b50341..a1f7106e54 100644 --- a/core/src/wallet/cosmos/database/CosmosLikeTransactionDatabaseHelper.cpp +++ b/core/src/wallet/cosmos/database/CosmosLikeTransactionDatabaseHelper.cpp @@ -165,9 +165,9 @@ namespace ledger { const constexpr int COL_BLK_TIME = 10; const constexpr int COL_BLK_CURRNAME = 11; - tx.uid = row.get(COL_TX_UID); - tx.hash = row.get(COL_TX_HASH); - tx.timestamp = row.get(COL_TX_TIME); + tx.uid = row.get(COL_TX_UID); + tx.hash = row.get(COL_TX_HASH); + tx.timestamp = row.get(COL_TX_TIME); soci::stringToCoins(row.get(COL_TX_FEE), tx.fee.amount); tx.fee.gas = row.get(COL_TX_GAS); tx.gasUsed = row.get>(COL_TX_GASUSED).map([](const std::string &v) { diff --git a/core/src/wallet/cosmos/database/SociCosmosAmount.hpp b/core/src/wallet/cosmos/database/SociCosmosAmount.hpp index cc6f81103d..42fb4bfe8d 100644 --- a/core/src/wallet/cosmos/database/SociCosmosAmount.hpp +++ b/core/src/wallet/cosmos/database/SociCosmosAmount.hpp @@ -73,7 +73,7 @@ namespace soci { Document d; auto &allocator = d.GetAllocator(); - auto &tuple = d.SetArray(); + auto &tuple = d.SetArray(); cosmos_coin_to_json_tuple(in, tuple, allocator); StringBuffer buffer; @@ -109,8 +109,8 @@ namespace soci { Document d; auto &allocator = d.GetAllocator(); - auto &obj = d.SetObject(); - auto gas = in.gas.toString(); + auto &obj = d.SetObject(); + auto gas = in.gas.toString(); obj["gas"].SetString(gas.data(), gas.size()); auto &array = obj["amount"].SetObject(); for (const auto &item : in.amount) { diff --git a/core/src/wallet/cosmos/explorers/CosmosLikeBlockchainExplorer.hpp b/core/src/wallet/cosmos/explorers/CosmosLikeBlockchainExplorer.hpp index f47792b403..e31c9720f2 100644 --- a/core/src/wallet/cosmos/explorers/CosmosLikeBlockchainExplorer.hpp +++ b/core/src/wallet/cosmos/explorers/CosmosLikeBlockchainExplorer.hpp @@ -61,7 +61,7 @@ namespace ledger { virtual FuturePtr> getDelegations( const std::string &delegatorAddr) const = 0; virtual FuturePtr> getPendingRewards( - const std::string &delegatorAddr) const = 0; + const std::string &delegatorAddr) const = 0; // Everything below is c/p from AbstractBlockchainExplorer, in sole purpose // of being able to use fromBlockHeight instead of fromBlockHash in getTransactions (see below) @@ -81,22 +81,22 @@ namespace ledger { virtual Future getUnbondingsByDelegator( const std::string &delegatorAddress) const = 0; virtual Future getRedelegationsByDelegator( - const std::string &delegatorAddress) const = 0; + const std::string &delegatorAddress) const = 0; // Balances /// Get Total Balance virtual FuturePtr getTotalBalance(const std::string &account) const = 0; /// Get Total Balance except pending rewards virtual FuturePtr getTotalBalanceWithoutPendingRewards( - const std::string &account) const = 0; + const std::string &account) const = 0; /// Get total balance in delegation - virtual FuturePtr getDelegatedBalance(const std::string &account) const = 0; + virtual FuturePtr getDelegatedBalance(const std::string &account) const = 0; /// Get total pending rewards virtual FuturePtr getPendingRewardsBalance(const std::string &account) const = 0; /// Get total unbonding balance - virtual FuturePtr getUnbondingBalance(const std::string &account) const = 0; + virtual FuturePtr getUnbondingBalance(const std::string &account) const = 0; /// Get total available (spendable) balance - virtual FuturePtr getSpendableBalance(const std::string &account) const = 0; + virtual FuturePtr getSpendableBalance(const std::string &account) const = 0; virtual FuturePtr getTransactionByHash( const String &transactionHash) const = 0; @@ -105,7 +105,7 @@ namespace ledger { virtual FuturePtr getTransactions( const std::vector &addresses, uint32_t fromBlockHeight = 0, - Option session = Option()) = 0; + Option session = Option()) = 0; // Validators virtual Future getActiveValidatorSet() const = 0; diff --git a/core/src/wallet/cosmos/explorers/GaiaCosmosLikeBlockchainExplorer.cpp b/core/src/wallet/cosmos/explorers/GaiaCosmosLikeBlockchainExplorer.cpp index 95f5758009..ff8bdfb993 100644 --- a/core/src/wallet/cosmos/explorers/GaiaCosmosLikeBlockchainExplorer.cpp +++ b/core/src/wallet/cosmos/explorers/GaiaCosmosLikeBlockchainExplorer.cpp @@ -172,12 +172,12 @@ namespace ledger { /// No need to check for this as this check is done in /// rpcs_parsers::parseTransaction and this function is /// only called once parseTransaction has finished. - const auto &vNode = node[kTx].GetObject()[kValue].GetObject(); + const auto &vNode = node[kTx].GetObject()[kValue].GetObject(); const auto index = transaction.messages.size(); auto msgFeesContent = cosmos::MsgFees(); - auto pubKey = std::string(); + auto pubKey = std::string(); rpcs_parsers::parseSignerPubKey(vNode, pubKey); const auto decoded = cereal::base64::decode(pubKey); const auto vPubKey = @@ -1040,7 +1040,7 @@ namespace ledger { // TODO: use fold expression when C++17 // (document.AddMember(std::forward(jsonObject).name, // std::forward(jsonObject).value, allocator), ...); - using _t = int[]; + using _t = int[]; (void)_t{0, (document.AddMember(std::forward(jsonObject).name, std::forward(jsonObject).value, allocator), @@ -1083,17 +1083,17 @@ namespace ledger { const std::string gasAdjustment) const { auto document = rapidjson::Document(); document.SetObject(); - auto &allocator = document.GetAllocator(); + auto &allocator = document.GetAllocator(); auto baseReqValue = rapidjson::Value(rapidjson::kObjectType); makeBaseReq(transaction, message, gasAdjustment, baseReqValue, allocator); - auto baseReq = JsonObject(cosmos::constants::kBaseReq, baseReqValue); + auto baseReq = JsonObject(cosmos::constants::kBaseReq, baseReqValue); const auto unwrappedMessage = CosmosLikeMessage::unwrapMsgSend(message); - auto amountValue = rapidjson::Value(rapidjson::kArrayType); + auto amountValue = rapidjson::Value(rapidjson::kArrayType); makeAmountArray(unwrappedMessage.amount, amountValue, allocator); - auto amount = JsonObject(cosmos::constants::kAmount, amountValue); + auto amount = JsonObject(cosmos::constants::kAmount, amountValue); const auto rawTransaction = makeJsonFrom(document, baseReq, amount); const auto endpoint = fmt::format(cosmos::constants::kGaiaTransfersEndpoint, @@ -1108,7 +1108,7 @@ namespace ledger { const std::string gasAdjustment) const { auto document = rapidjson::Document(); document.SetObject(); - auto &allocator = document.GetAllocator(); + auto &allocator = document.GetAllocator(); auto baseReqValue = rapidjson::Value(rapidjson::kObjectType); makeBaseReq(transaction, message, gasAdjustment, baseReqValue, allocator); @@ -1134,15 +1134,15 @@ namespace ledger { const std::string gasAdjustment) const { auto document = rapidjson::Document(); document.SetObject(); - auto &allocator = document.GetAllocator(); + auto &allocator = document.GetAllocator(); auto baseReqValue = rapidjson::Value(rapidjson::kObjectType); makeBaseReq(transaction, message, gasAdjustment, baseReqValue, allocator); - auto baseReq = JsonObject(cosmos::constants::kBaseReq, baseReqValue); + auto baseReq = JsonObject(cosmos::constants::kBaseReq, baseReqValue); const auto unwrappedMessage = CosmosLikeMessage::unwrapMsgDelegate(message); - auto delegatorAddressValue = rapidjson::Value(rapidjson::kStringType); + auto delegatorAddressValue = rapidjson::Value(rapidjson::kStringType); makeStringValue(unwrappedMessage.delegatorAddress, delegatorAddressValue, allocator); const auto delegatorAddress = @@ -1156,7 +1156,7 @@ namespace ledger { auto amountValue = rapidjson::Value(rapidjson::kObjectType); makeAmount(unwrappedMessage.amount, amountValue, allocator); - const auto amount = JsonObject(cosmos::constants::kAmount, amountValue); + const auto amount = JsonObject(cosmos::constants::kAmount, amountValue); const auto rawTransaction = makeJsonFrom(document, baseReq, delegatorAddress, validatorAddress, amount); @@ -1173,15 +1173,15 @@ namespace ledger { const std::string gasAdjustment) const { auto document = rapidjson::Document(); document.SetObject(); - auto &allocator = document.GetAllocator(); + auto &allocator = document.GetAllocator(); auto baseReqValue = rapidjson::Value(rapidjson::kObjectType); makeBaseReq(transaction, message, gasAdjustment, baseReqValue, allocator); - auto baseReq = JsonObject(cosmos::constants::kBaseReq, baseReqValue); + auto baseReq = JsonObject(cosmos::constants::kBaseReq, baseReqValue); const auto unwrappedMessage = CosmosLikeMessage::unwrapMsgUndelegate(message); - auto delegatorAddressValue = rapidjson::Value(rapidjson::kStringType); + auto delegatorAddressValue = rapidjson::Value(rapidjson::kStringType); makeStringValue(unwrappedMessage.delegatorAddress, delegatorAddressValue, allocator); const auto delegatorAddress = @@ -1195,7 +1195,7 @@ namespace ledger { auto amountValue = rapidjson::Value(rapidjson::kObjectType); makeAmount(unwrappedMessage.amount, amountValue, allocator); - const auto amount = JsonObject(cosmos::constants::kAmount, amountValue); + const auto amount = JsonObject(cosmos::constants::kAmount, amountValue); const auto rawTransaction = makeJsonFrom(document, baseReq, delegatorAddress, validatorAddress, amount); @@ -1212,7 +1212,7 @@ namespace ledger { const std::string gasAdjustment) const { auto document = rapidjson::Document(); document.SetObject(); - auto &allocator = document.GetAllocator(); + auto &allocator = document.GetAllocator(); auto baseReqValue = rapidjson::Value(rapidjson::kObjectType); makeBaseReq(transaction, message, gasAdjustment, baseReqValue, allocator); diff --git a/core/src/wallet/cosmos/factories/CosmosLikeWalletFactory.cpp b/core/src/wallet/cosmos/factories/CosmosLikeWalletFactory.cpp index bc5fc17db5..90c4070b71 100644 --- a/core/src/wallet/cosmos/factories/CosmosLikeWalletFactory.cpp +++ b/core/src/wallet/cosmos/factories/CosmosLikeWalletFactory.cpp @@ -152,7 +152,7 @@ namespace ledger { api::BlockchainExplorerEngines::COSMOS_NODE); auto &networkParams = getCurrency().cosmosLikeNetworkParameters.value(); - explorer = std::make_shared( + explorer = std::make_shared( context, http, networkParams, std::dynamic_pointer_cast(configuration)); } else { throw Exception( diff --git a/core/src/wallet/cosmos/synchronizers/CosmosLikeAccountSynchronizer.cpp b/core/src/wallet/cosmos/synchronizers/CosmosLikeAccountSynchronizer.cpp index 0c95b69df1..b3f737db35 100644 --- a/core/src/wallet/cosmos/synchronizers/CosmosLikeAccountSynchronizer.cpp +++ b/core/src/wallet/cosmos/synchronizers/CosmosLikeAccountSynchronizer.cpp @@ -101,7 +101,7 @@ namespace ledger { Future CosmosLikeAccountSynchronizer::performSynchronization( const std::shared_ptr &account) { - auto buddy = std::make_shared(); + auto buddy = std::make_shared(); buddy->account = account; buddy->preferences = std::static_pointer_cast(account) @@ -141,8 +141,8 @@ namespace ledger { return lhs.blockHeight < rhs.blockHeight; }); - auto currencyName = buddy->wallet->getCurrency().name; - size_t index = 0; + auto currencyName = buddy->wallet->getCurrency().name; + size_t index = 0; // Reorg can't happen until genesis block, safely initialize with 0 uint64_t deepestFailedBlockHeight = 0; while ( @@ -208,10 +208,10 @@ namespace ledger { // get the last block height treated during the synchronization // std::max_element returns an iterator hence the indirection here // We use an constant iterator variable for readability purpose - auto const batchIt = std::max_element( - std::cbegin(batches), - std::cend(batches), - [](auto const &lhs, auto const &rhs) { + auto const batchIt = std::max_element( + std::cbegin(batches), + std::cend(batches), + [](auto const &lhs, auto const &rhs) { return lhs.blockHeight < rhs.blockHeight; }); buddy->context.lastBlockHeight = batchIt->blockHeight; @@ -262,7 +262,7 @@ namespace ledger { auto self = shared_from_this(); auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; - auto benchmark = std::make_shared( + auto benchmark = std::make_shared( fmt::format("Synchronize batch {}", currentBatchIndex), buddy->logger); benchmark->start(); return synchronizeBatch(currentBatchIndex, buddy) @@ -369,8 +369,8 @@ namespace ledger { bool hadTransactions) { buddy->logger->info("SYNC BATCH {}", currentBatchIndex); - auto self = shared_from_this(); - auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; + auto self = shared_from_this(); + auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; auto derivationBenchmark = std::make_shared("Batch derivation", buddy->logger); derivationBenchmark->start(); diff --git a/core/src/wallet/cosmos/transaction_builders/CosmosLikeTransactionBuilder.cpp b/core/src/wallet/cosmos/transaction_builders/CosmosLikeTransactionBuilder.cpp index 6030f25f99..afa76f6046 100644 --- a/core/src/wallet/cosmos/transaction_builders/CosmosLikeTransactionBuilder.cpp +++ b/core/src/wallet/cosmos/transaction_builders/CosmosLikeTransactionBuilder.cpp @@ -152,10 +152,10 @@ namespace ledger { auto contentObject = valueObject[kContent].GetObject(); auto initialDepositArray = valueObject[kInitialDeposit].GetArray(); - auto content = api::CosmosLikeContent( - getString(contentObject, kType), - getString(contentObject, kTitle), - getString(contentObject, kDescription)); + auto content = api::CosmosLikeContent( + getString(contentObject, kType), + getString(contentObject, kTitle), + getString(contentObject, kDescription)); std::vector amounts; // the size of the array of amounts should be frequently equal to one @@ -500,22 +500,22 @@ namespace ledger { auto feeObject = document[kFee].GetObject(); // Gas Limit - auto gas = std::make_shared(getString(feeObject, kGas)); + auto gas = std::make_shared(getString(feeObject, kGas)); tx->setGas(gas); // Total Tx fees // Gas Price is then deduced with Total_Tx_fees / Gas Limit if (feeObject[kAmount].IsArray()) { - auto fee = BigInt(); + auto fee = BigInt(); auto getAmount = [=](const rjObject &object) -> Amount { auto denom = getString(object, kDenom); auto amount = getString(object, kAmount); - auto unit = std::find_if( - currency.units.begin(), - currency.units.end(), - [&](const api::CurrencyUnit &unit) { + auto unit = std::find_if( + currency.units.begin(), + currency.units.end(), + [&](const api::CurrencyUnit &unit) { return unit.name == denom; }); diff --git a/core/src/wallet/ethereum/EthereumLikeAccount.cpp b/core/src/wallet/ethereum/EthereumLikeAccount.cpp index 3f4bab9f26..72a518de74 100644 --- a/core/src/wallet/ethereum/EthereumLikeAccount.cpp +++ b/core/src/wallet/ethereum/EthereumLikeAccount.cpp @@ -207,7 +207,7 @@ namespace ledger { auto erc20AccountUid = AccountDatabaseHelper::createERC20AccountUid(getAccountUid(), erc20ContractAddress); // Check if account already exists - auto needNewAccount = true; + auto needNewAccount = true; for (auto &account : _erc20LikeAccounts) { auto erc20Account = std::static_pointer_cast(account); if (erc20Account->getToken().contractAddress == erc20ContractAddress && @@ -237,7 +237,7 @@ namespace ledger { } std::vector EthereumLikeAccount::getInternalOperations(soci::session &sql) { - auto addr = _keychain->getAddress()->toString(); + auto addr = _keychain->getAddress()->toString(); soci::rowset rows = (sql.prepare << "SELECT io.type, io.value, io.sender, io.receiver, io.gas_limit, io.gas_used, et.gas_price, op.date, et.status " "FROM internal_operations as io " @@ -261,9 +261,9 @@ namespace ledger { // auto from = row.get(2); // auto to = row.get(3); - auto gasLimit = BigInt::fromHex(row.get(4)); - auto gasUsed = BigInt::fromHex(row.get(5)); - auto gasPrice = BigInt::fromHex(row.get(6)); + auto gasLimit = BigInt::fromHex(row.get(4)); + auto gasUsed = BigInt::fromHex(row.get(5)); + auto gasPrice = BigInt::fromHex(row.get(6)); operation.date = DateUtils::fromJSON(row.get(7)); @@ -272,7 +272,7 @@ namespace ledger { // if the status is not okay, we have to change the amount of the operation because // it wasn’t really broadcasted, but the fees were still paid - auto status = soci::get_number(row, 8); + auto status = soci::get_number(row, 8); if (status == 0) { operation.amount = BigInt::ZERO; } else { @@ -281,7 +281,7 @@ namespace ledger { // required when computing balances EthereumLikeBlockchainExplorerTransaction etx; - etx.status = status; + etx.status = status; operation.ethereumTransaction = Option(etx); @@ -457,7 +457,7 @@ namespace ledger { std::lock_guard lock(_synchronizationLock); if (_currentSyncEventBus) return _currentSyncEventBus; - auto eventPublisher = std::make_shared(getContext()); + auto eventPublisher = std::make_shared(getContext()); _currentSyncEventBus = eventPublisher->getEventBus(); auto future = _synchronizer->synchronize(std::static_pointer_cast(shared_from_this()))->getFuture(); @@ -480,7 +480,7 @@ namespace ledger { auto duration = std::chrono::duration_cast(DateUtils::now() - startTime).count(); payload->putLong(api::Account::EV_SYNC_DURATION_MS, duration); if (result.isSuccess()) { - code = api::EventCode::SYNCHRONIZATION_SUCCEED; + code = api::EventCode::SYNCHRONIZATION_SUCCEED; auto const context = result.getValue(); self->getWallet()->invalidateBalanceCache(self->getIndex()); @@ -529,7 +529,7 @@ namespace ledger { txExplorer.receivedAt = std::chrono::system_clock::now(); txExplorer.inputData = tx->getData().value_or(std::vector()); // Create ERC20 Ops - auto strInputData = hex::toString(txExplorer.inputData); + auto strInputData = hex::toString(txExplorer.inputData); // 136 / 2 => 68 bytes = 4 bytes for transfer method ID (0xa9059cbb) + 32 bytes for receiver address + 32 bytes for amount if (strInputData.size() == 136 && strInputData.find(erc20Tokens::ERC20MethodsID.at("transfer")) != std::string::npos) { ERC20Transaction erc20Tx; @@ -542,8 +542,8 @@ namespace ledger { // Get rid of leading zeros auto skipEIP55Check = true; // auto toAddress = BigInt::fromHex(hex::toString(reader.read(32))).toHexString(); - erc20Tx.to = EthereumLikeAddress::fromEIP55("0x" + BigInt::fromHex(hex::toString(reader.read(32))).toHexString(), - account->getWallet()->getCurrency(), Option(""), skipEIP55Check) + erc20Tx.to = EthereumLikeAddress::fromEIP55("0x" + BigInt::fromHex(hex::toString(reader.read(32))).toHexString(), + account->getWallet()->getCurrency(), Option(""), skipEIP55Check) ->toEIP55(); erc20Tx.value = BigInt::fromHex(hex::toString(reader.read(32))); erc20Tx.type = api::OperationType::SEND; diff --git a/core/src/wallet/ethereum/EthereumLikeWallet.cpp b/core/src/wallet/ethereum/EthereumLikeWallet.cpp index 6e9df7bdd3..0919433982 100644 --- a/core/src/wallet/ethereum/EthereumLikeWallet.cpp +++ b/core/src/wallet/ethereum/EthereumLikeWallet.cpp @@ -208,7 +208,7 @@ namespace ledger { auto keychain = _keychainFactory->restore(entry.index, xpubPath, getConfig(), entry.address, getAccountInternalPreferences(entry.index), getCurrency()); - auto account = std::make_shared(shared_from_this(), + auto account = std::make_shared(shared_from_this(), entry.index, _explorer, _synchronizerFactory(), diff --git a/core/src/wallet/ethereum/api_impl/EthereumLikeTransactionApi.cpp b/core/src/wallet/ethereum/api_impl/EthereumLikeTransactionApi.cpp index 5904e15041..0e8ee723e2 100644 --- a/core/src/wallet/ethereum/api_impl/EthereumLikeTransactionApi.cpp +++ b/core/src/wallet/ethereum/api_impl/EthereumLikeTransactionApi.cpp @@ -58,20 +58,20 @@ namespace ledger { _block = nullptr; } - _hash = tx.hash; + _hash = tx.hash; - _currency = operation->getAccount()->getWallet()->getCurrency(); + _currency = operation->getAccount()->getWallet()->getCurrency(); - _gasPrice = std::make_shared(_currency, 0, tx.gasPrice); - _gasLimit = std::make_shared(_currency, 0, tx.gasLimit); - _gasUsed = std::make_shared(_currency, 0, tx.gasUsed.getValue()); - _value = std::make_shared(_currency, 0, tx.value); + _gasPrice = std::make_shared(_currency, 0, tx.gasPrice); + _gasLimit = std::make_shared(_currency, 0, tx.gasLimit); + _gasUsed = std::make_shared(_currency, 0, tx.gasUsed.getValue()); + _value = std::make_shared(_currency, 0, tx.value); - _nonce = std::make_shared((int64_t)tx.nonce); - _data = tx.inputData; - _status = tx.status; - _receiver = EthereumLikeAddress::fromEIP55(tx.receiver, _currency); - _sender = EthereumLikeAddress::fromEIP55(tx.sender, _currency); + _nonce = std::make_shared((int64_t)tx.nonce); + _data = tx.inputData; + _status = tx.status; + _receiver = EthereumLikeAddress::fromEIP55(tx.receiver, _currency); + _sender = EthereumLikeAddress::fromEIP55(tx.sender, _currency); auto vBigInt = BigInt(_currency.ethereumLikeNetworkParameters.value().ChainID) * BigInt(2) + BigInt(36); _vSignature = hex::toByteArray(vBigInt.toHexString()); diff --git a/core/src/wallet/ethereum/database/EthereumLikeTransactionDatabaseHelper.cpp b/core/src/wallet/ethereum/database/EthereumLikeTransactionDatabaseHelper.cpp index 40ae306ffc..588d0108a9 100644 --- a/core/src/wallet/ethereum/database/EthereumLikeTransactionDatabaseHelper.cpp +++ b/core/src/wallet/ethereum/database/EthereumLikeTransactionDatabaseHelper.cpp @@ -66,18 +66,18 @@ namespace ledger { bool EthereumLikeTransactionDatabaseHelper::inflateTransaction(soci::session &sql, const soci::row &row, EthereumLikeBlockchainExplorerTransaction &tx) { - tx.hash = row.get(0); - tx.value = BigInt::fromHex(row.get(1)); - tx.nonce = BigInt(row.get(2)).toUint64(); - tx.receivedAt = row.get(3); - tx.inputData = hex::toByteArray(row.get(4)); - - tx.gasPrice = BigInt::fromHex(row.get(5)); - tx.gasLimit = BigInt::fromHex(row.get(6)); - tx.gasUsed = BigInt::fromHex(row.get(7)); - - tx.sender = row.get(8); - tx.receiver = row.get(9); + tx.hash = row.get(0); + tx.value = BigInt::fromHex(row.get(1)); + tx.nonce = BigInt(row.get(2)).toUint64(); + tx.receivedAt = row.get(3); + tx.inputData = hex::toByteArray(row.get(4)); + + tx.gasPrice = BigInt::fromHex(row.get(5)); + tx.gasLimit = BigInt::fromHex(row.get(6)); + tx.gasUsed = BigInt::fromHex(row.get(7)); + + tx.sender = row.get(8); + tx.receiver = row.get(9); tx.confirmations = get_number(row, 10); tx.status = get_number(row, 11); diff --git a/core/src/wallet/ethereum/explorers/LedgerApiEthereumLikeBlockchainExplorer.cpp b/core/src/wallet/ethereum/explorers/LedgerApiEthereumLikeBlockchainExplorer.cpp index 78a163e074..27802c6b5f 100644 --- a/core/src/wallet/ethereum/explorers/LedgerApiEthereumLikeBlockchainExplorer.cpp +++ b/core/src/wallet/ethereum/explorers/LedgerApiEthereumLikeBlockchainExplorer.cpp @@ -116,7 +116,7 @@ namespace ledger { {"Content-Type", "application/json"}}; const bool jsonParseNumbersAsString = true; - const auto *const interestingField = "estimated_gas_limit"; + const auto *const interestingField = "estimated_gas_limit"; rapidjson::Document body; body.SetObject(); auto &allocator = body.GetAllocator(); @@ -254,7 +254,7 @@ namespace ledger { const std::size_t numAddresses = erc20Addresses.size(); - bool parseNumbersAsString = true; + bool parseNumbersAsString = true; std::unordered_map headers{{"Content-Type", "application/json"}}; return _http->POST(fmt::format("/blockchain/{}/{}/erc20/balances", getExplorerVersion(), diff --git a/core/src/wallet/ethereum/explorers/api/EthereumLikeTransactionParser.cpp b/core/src/wallet/ethereum/explorers/api/EthereumLikeTransactionParser.cpp index b311c06848..a48df11acd 100644 --- a/core/src/wallet/ethereum/explorers/api/EthereumLikeTransactionParser.cpp +++ b/core/src/wallet/ethereum/explorers/api/EthereumLikeTransactionParser.cpp @@ -237,7 +237,7 @@ namespace ledger { } void EthereumLikeTransactionParser::init(EthereumLikeBlockchainExplorerTransaction *transaction) { - _transaction = transaction; + _transaction = transaction; // Default receivedAt to `now`, in case the explorer doesn't return it. _transaction->receivedAt = std::chrono::system_clock::now(); } diff --git a/core/src/wallet/ethereum/keychains/EthereumLikeKeychain.cpp b/core/src/wallet/ethereum/keychains/EthereumLikeKeychain.cpp index c2b590707b..96fe48574d 100644 --- a/core/src/wallet/ethereum/keychains/EthereumLikeKeychain.cpp +++ b/core/src/wallet/ethereum/keychains/EthereumLikeKeychain.cpp @@ -163,12 +163,12 @@ namespace ledger { if (_address.empty()) { auto nodeScheme = getDerivationScheme() .getSchemeFrom(DerivationSchemeLevel::NODE); - auto p = nodeScheme.getPath().getDepth() > 0 ? nodeScheme + auto p = nodeScheme.getPath().getDepth() > 0 ? nodeScheme .shift(1) .setCoinType(coinType) .getPath() .toString() - : ""; + : ""; auto localNodeScheme = getDerivationScheme() .getSchemeTo(DerivationSchemeLevel::NODE) @@ -178,7 +178,7 @@ namespace ledger { auto xpub = localNodeScheme.getPath().getDepth() > 0 && localNodeScheme.getPath().isHardened(0) ? std::static_pointer_cast(_xpub)->derive(DerivationPath("")) : std::static_pointer_cast(_xpub)->derive(localNodeScheme.getPath()); auto strScheme = localNodeScheme.getPath().toString(); - _address = xpub->derive(p)->toEIP55(); + _address = xpub->derive(p)->toEIP55(); // Feed path -> address cache // Feed address -> path cache getPreferences() diff --git a/core/src/wallet/ethereum/transaction_builders/EthereumLikeTransactionBuilder.cpp b/core/src/wallet/ethereum/transaction_builders/EthereumLikeTransactionBuilder.cpp index 93aa2c4346..4c40f545c9 100644 --- a/core/src/wallet/ethereum/transaction_builders/EthereumLikeTransactionBuilder.cpp +++ b/core/src/wallet/ethereum/transaction_builders/EthereumLikeTransactionBuilder.cpp @@ -135,8 +135,8 @@ namespace ledger { auto children = decodedRawTx->getChildren(); // TODO: throw if size is KO - auto tx = std::make_shared(currency); - int index = 0; + auto tx = std::make_shared(currency); + int index = 0; std::vector vSignature, rSignature, sSignature; for (auto &child : children) { if (child->isList()) { diff --git a/core/src/wallet/pool/WalletPool.cpp b/core/src/wallet/pool/WalletPool.cpp index a65d4053ae..288a9720c3 100644 --- a/core/src/wallet/pool/WalletPool.cpp +++ b/core/src/wallet/pool/WalletPool.cpp @@ -62,21 +62,21 @@ namespace ledger { .value_or(api::ConfigurationDefaults::DEFAULT_TTL_CACHE))), _externalPreferencesBackend(std::move(externalPreferencesBackend)), _internalPreferencesBackend(std::move(internalPreferencesBackend)) { // General - _poolName = name; + _poolName = name; _configuration = std::static_pointer_cast(configuration); // File system management - _pathResolver = pathResolver; + _pathResolver = pathResolver; // HTTP management - _httpEngine = httpClient; + _httpEngine = httpClient; // Tracing management - _tracer = tracer; + _tracer = tracer; // WS management - _wsClient = std::make_shared(webSocketClient); + _wsClient = std::make_shared(webSocketClient); // Preferences management if (!_externalPreferencesBackend) { @@ -87,7 +87,7 @@ namespace ledger { throw make_exception(api::ErrorCode::NULL_POINTER, "No internal preferences backend provided."); } - _rng = rng; + _rng = rng; // Encrypt the preferences, if needed _password = password; if (!_password.empty()) { @@ -116,9 +116,9 @@ namespace ledger { password); // Threading management - _threadDispatcher = dispatcher; + _threadDispatcher = dispatcher; - _publisher = std::make_shared(getContext()); + _publisher = std::make_shared(getContext()); _threadPoolExecutionContext = _threadDispatcher->getThreadPoolExecutionContext(fmt::format("pool_{}_thread_pool", name)); } diff --git a/core/src/wallet/pool/database/CurrenciesDatabaseHelper.cpp b/core/src/wallet/pool/database/CurrenciesDatabaseHelper.cpp index 3e733d6a5c..4f89fc4dac 100644 --- a/core/src/wallet/pool/database/CurrenciesDatabaseHelper.cpp +++ b/core/src/wallet/pool/database/CurrenciesDatabaseHelper.cpp @@ -238,9 +238,9 @@ void ledger::core::CurrenciesDatabaseHelper::getAllCurrencies(soci::session &sql use(currency.name)); for (auto &btc_row : btc_rows) { api::BitcoinLikeNetworkParameters params; - params.P2PKHVersion = hex::toByteArray(btc_row.get(0)); - params.P2SHVersion = hex::toByteArray(btc_row.get(1)); - params.XPUBVersion = hex::toByteArray(btc_row.get(2)); + params.P2PKHVersion = hex::toByteArray(btc_row.get(0)); + params.P2SHVersion = hex::toByteArray(btc_row.get(1)); + params.XPUBVersion = hex::toByteArray(btc_row.get(2)); /* * On Linux, if we use int64_t, we get std::bad_cast exception thrown, * so we replace by a long long (which is supported by soci (soci::dt_long_long)) diff --git a/core/src/wallet/ripple/RippleLikeAccount.cpp b/core/src/wallet/ripple/RippleLikeAccount.cpp index 2aaf58d8ae..ce1a916309 100644 --- a/core/src/wallet/ripple/RippleLikeAccount.cpp +++ b/core/src/wallet/ripple/RippleLikeAccount.cpp @@ -304,7 +304,7 @@ namespace ledger { std::lock_guard lock(_synchronizationLock); if (_currentSyncEventBus) return _currentSyncEventBus; - auto eventPublisher = std::make_shared(getContext()); + auto eventPublisher = std::make_shared(getContext()); _currentSyncEventBus = eventPublisher->getEventBus(); auto future = _synchronizer->synchronizeAccount(std::static_pointer_cast(shared_from_this()))->getFuture(); @@ -388,7 +388,7 @@ namespace ledger { Future RippleLikeAccount::broadcastRawTransaction(const std::vector &transaction, const std::string &correlationId) { auto self = getSelf(); return _explorer->pushTransaction(transaction, correlationId).map(getContext(), [self, transaction](const String &seq) -> std::string { - auto txHash = seq.str(); + auto txHash = seq.str(); // optimisticUpdate auto txExplorer = getXRPLikeBlockchainExplorerTxFromRawTx(self, txHash, transaction); // Store in DB @@ -411,7 +411,7 @@ namespace ledger { } std::shared_ptr RippleLikeAccount::buildTransaction() { - auto self = std::dynamic_pointer_cast(shared_from_this()); + auto self = std::dynamic_pointer_cast(shared_from_this()); // TODO: rm this auto getTransaction = [self]( diff --git a/core/src/wallet/ripple/api_impl/RippleLikeTransactionApi.cpp b/core/src/wallet/ripple/api_impl/RippleLikeTransactionApi.cpp index a872b009a4..0ffb113f3a 100644 --- a/core/src/wallet/ripple/api_impl/RippleLikeTransactionApi.cpp +++ b/core/src/wallet/ripple/api_impl/RippleLikeTransactionApi.cpp @@ -90,12 +90,12 @@ namespace ledger { _block = nullptr; } - _hash = tx.hash; + _hash = tx.hash; _currency = operation->getAccount()->getWallet()->getCurrency(); - _fees = std::make_shared(_currency, 0, tx.fees); - _value = std::make_shared(_currency, 0, tx.value); + _fees = std::make_shared(_currency, 0, tx.fees); + _value = std::make_shared(_currency, 0, tx.value); _receiver = RippleLikeAddress::fromBase58(tx.receiver, _currency); _sender = RippleLikeAddress::fromBase58(tx.sender, _currency); diff --git a/core/src/wallet/ripple/database/RippleLikeTransactionDatabaseHelper.cpp b/core/src/wallet/ripple/database/RippleLikeTransactionDatabaseHelper.cpp index 6b3d69739f..14469934c3 100644 --- a/core/src/wallet/ripple/database/RippleLikeTransactionDatabaseHelper.cpp +++ b/core/src/wallet/ripple/database/RippleLikeTransactionDatabaseHelper.cpp @@ -120,7 +120,7 @@ namespace ledger { std::string RippleLikeTransactionDatabaseHelper::putTransaction(soci::session &sql, const std::string &accountUid, const RippleLikeBlockchainExplorerTransaction &tx) { - auto blockUid = tx.block.map([](const RippleLikeBlockchainExplorer::Block &block) { + auto blockUid = tx.block.map([](const RippleLikeBlockchainExplorer::Block &block) { return block.getUid(); }); diff --git a/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h b/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h index 0304d187d0..3aa302e9ba 100644 --- a/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h +++ b/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h @@ -99,9 +99,9 @@ namespace ledger { NodeRippleLikeBodyRequest &pushPagination( const std::string &ledger, const std::string &seq) { - std::string key = "marker"; - std::string ledgerKeyStr = "ledger"; - std::string seqKeyStr = "seq"; + std::string key = "marker"; + std::string ledgerKeyStr = "ledger"; + std::string seqKeyStr = "seq"; rapidjson::Document::AllocatorType &allocator = _document.GetAllocator(); diff --git a/core/src/wallet/ripple/explorers/api/RippleLikeBlockParser.h b/core/src/wallet/ripple/explorers/api/RippleLikeBlockParser.h index 39486bfab3..5de78d39c7 100644 --- a/core/src/wallet/ripple/explorers/api/RippleLikeBlockParser.h +++ b/core/src/wallet/ripple/explorers/api/RippleLikeBlockParser.h @@ -49,7 +49,7 @@ namespace ledger { _block->height = value.toUint64(); // Ledger index is not really a hash but since XRP doesn't have reorg // it's safe to use ledger index as a unique hash. - _block->hash = number; + _block->hash = number; } else if (getLastKey() == "close_time") { std::string number(str, length); BigInt value = BigInt::fromString(number); diff --git a/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp b/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp index 2ae45942d5..3c7395ad75 100644 --- a/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp +++ b/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp @@ -132,8 +132,8 @@ namespace ledger { _transaction->confirmations = value.toUint64(); } else if (_lastKey == "ledger_index") { RippleLikeBlockchainExplorer::Block block; - block.height = value.toUint64(); - block.currencyName = currencies::RIPPLE.name; + block.height = value.toUint64(); + block.currencyName = currencies::RIPPLE.name; // Ledger index is not really a hash but since XRP doesn't have reorg // it's safe to use ledger index as a unique hash. block.hash = number; diff --git a/core/src/wallet/ripple/keychains/RippleLikeKeychain.cpp b/core/src/wallet/ripple/keychains/RippleLikeKeychain.cpp index d294304712..adf8aa6208 100644 --- a/core/src/wallet/ripple/keychains/RippleLikeKeychain.cpp +++ b/core/src/wallet/ripple/keychains/RippleLikeKeychain.cpp @@ -165,23 +165,23 @@ namespace ledger { if (_address.empty()) { auto nodeScheme = getDerivationScheme() .getSchemeFrom(DerivationSchemeLevel::NODE); - auto p = nodeScheme.getPath().getDepth() > 0 ? nodeScheme + auto p = nodeScheme.getPath().getDepth() > 0 ? nodeScheme .shift(1) .setCoinType(getCurrency().bip44CoinType) .getPath() .toString() - : ""; + : ""; auto localNodeScheme = getDerivationScheme() .getSchemeTo(DerivationSchemeLevel::NODE) .setCoinType(getCurrency().bip44CoinType); // If node level is hardened we don't derive according to it since private // derivation are not supported - auto xpub = localNodeScheme.getPath().getDepth() > 0 && localNodeScheme.getPath().isHardened(0) ? std::static_pointer_cast(_xpub)->derive(DerivationPath("")) : std::static_pointer_cast(_xpub)->derive(localNodeScheme.getPath()); + auto xpub = localNodeScheme.getPath().getDepth() > 0 && localNodeScheme.getPath().isHardened(0) ? std::static_pointer_cast(_xpub)->derive(DerivationPath("")) : std::static_pointer_cast(_xpub)->derive(localNodeScheme.getPath()); auto strScheme = localNodeScheme.getPath().toString(); - _address = xpub->derive(p)->toBase58(); + _address = xpub->derive(p)->toBase58(); // Feed path -> address cache // Feed address -> path cache getPreferences() diff --git a/core/src/wallet/ripple/synchronizers/RippleLikeAccountSynchronizer.cpp b/core/src/wallet/ripple/synchronizers/RippleLikeAccountSynchronizer.cpp index bf7cb86c88..f0cd93cf6f 100644 --- a/core/src/wallet/ripple/synchronizers/RippleLikeAccountSynchronizer.cpp +++ b/core/src/wallet/ripple/synchronizers/RippleLikeAccountSynchronizer.cpp @@ -160,8 +160,8 @@ namespace ledger { return lhs.blockHeight < rhs.blockHeight; }); - auto currencyName = buddy->wallet->getCurrency().name; - size_t index = 0; + auto currencyName = buddy->wallet->getCurrency().name; + size_t index = 0; // Reorg can't happen until genesis block, safely initialize with 0 uint64_t deepestFailedBlockHeight = 0; while (index < sortedBatches.size() && @@ -249,7 +249,7 @@ namespace ledger { auto self = shared_from_this(); auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; - auto benchmark = std::make_shared( + auto benchmark = std::make_shared( fmt::format("full_batch/{}", buddy->synchronizationTag), buddy->logger); benchmark->start(); @@ -308,7 +308,7 @@ namespace ledger { AccountDatabaseHelper::removeBlockOperation(sql, buddy->account->getAccountUid(), blockToDelete); // Get last block not part from reorg - auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, buddy->wallet->getCurrency().name); + auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, buddy->wallet->getCurrency().name); // Resync from the "beginning" if no last block in DB int64_t lastBlockHeight = 0; @@ -416,7 +416,7 @@ namespace ledger { auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; // self->transactions.insert(self->transactions.end(), bulk->transactions.begin(), bulk->transactions.end()); buddy->logger->info("Got {} txs for account {}", bulk->transactions.size(), buddy->account->getAccountUid()); - auto count = 0; + auto count = 0; // NEW CODE Option lastBlock = Option::NONE; diff --git a/core/src/wallet/ripple/transaction_builders/RippleLikeTransactionBuilder.cpp b/core/src/wallet/ripple/transaction_builders/RippleLikeTransactionBuilder.cpp index 6369523b8e..a80e23451b 100644 --- a/core/src/wallet/ripple/transaction_builders/RippleLikeTransactionBuilder.cpp +++ b/core/src/wallet/ripple/transaction_builders/RippleLikeTransactionBuilder.cpp @@ -233,14 +233,14 @@ namespace ledger { // Nb of elements for R sigReader.readNextByte(); // R length - auto rSize = sigReader.readNextVarInt(); + auto rSize = sigReader.readNextVarInt(); // TODO: verify that we don't truncate leading null byte auto rSignature = sigReader.read(rSize); // Nb of elements for S sigReader.readNextByte(); // S length - auto sSize = sigReader.readNextVarInt(); + auto sSize = sigReader.readNextVarInt(); // TODO: verify that we don't truncate leading null byte auto sSignature = sigReader.read(sSize); tx->setSignature(rSignature, sSignature); diff --git a/core/src/wallet/stellar/StellarLikeAccount.cpp b/core/src/wallet/stellar/StellarLikeAccount.cpp index 0d06c56566..eb89b73358 100644 --- a/core/src/wallet/stellar/StellarLikeAccount.cpp +++ b/core/src/wallet/stellar/StellarLikeAccount.cpp @@ -81,7 +81,7 @@ namespace ledger { if (_currentSyncEventBus != nullptr) return _currentSyncEventBus; - auto eventPublisher = std::make_shared(getContext()); + auto eventPublisher = std::make_shared(getContext()); _currentSyncEventBus = eventPublisher->getEventBus(); auto self = std::dynamic_pointer_cast(shared_from_this()); @@ -150,7 +150,7 @@ namespace ledger { return balance.assetType == "native"; }); - BigInt amount = (balanceIt != account.balances.end()) ? balanceIt->value : BigInt::ZERO; + BigInt amount = (balanceIt != account.balances.end()) ? balanceIt->value : BigInt::ZERO; return std::make_shared(self->getWallet()->getCurrency(), 0, amount); }); } @@ -287,8 +287,8 @@ namespace ledger { block.height = tx.ledger; block.hash = fmt::format("{}", block.height); - operation.block = block; - operation.fees = tx.feePaid; + operation.block = block; + operation.fees = tx.feePaid; operation.senders.emplace_back(tx.sourceAccount); auto accountAddress = getKeychain()->getAddress()->toString(); diff --git a/core/src/wallet/stellar/StellarLikeOperation.cpp b/core/src/wallet/stellar/StellarLikeOperation.cpp index 52482add25..22b2f4dec2 100644 --- a/core/src/wallet/stellar/StellarLikeOperation.cpp +++ b/core/src/wallet/stellar/StellarLikeOperation.cpp @@ -74,7 +74,7 @@ namespace ledger { _envelope.tx.fee = op.transactionFee.toUnsignedInt(); _envelope.tx.memo.type = stellar::xdr::MemoType::MEMO_NONE; // Rebuild MEMO - auto memo = StellarLikeMemo::fromDatabase(tx.memoType, tx.memo); + auto memo = StellarLikeMemo::fromDatabase(tx.memoType, tx.memo); if (memo.isSuccess()) { _envelope.tx.memo = memo.getValue().getBackend(); } diff --git a/core/src/wallet/stellar/factories/StellarLikeWalletFactory.cpp b/core/src/wallet/stellar/factories/StellarLikeWalletFactory.cpp index ff92e7c536..3a7f8b0cdb 100644 --- a/core/src/wallet/stellar/factories/StellarLikeWalletFactory.cpp +++ b/core/src/wallet/stellar/factories/StellarLikeWalletFactory.cpp @@ -59,10 +59,10 @@ namespace ledger { DerivationScheme scheme(STRING(api::Configuration::KEYCHAIN_DERIVATION_SCHEME, "44'/'/'")); // Configure keychain factory - params.keychainFactory = std::make_shared(); + params.keychainFactory = std::make_shared(); // Configure explorer - params.blockchainExplorer = getExplorer(entry); + params.blockchainExplorer = getExplorer(entry); // Configure observer // Configure synchronizer diff --git a/core/src/wallet/stellar/synchronizers/StellarLikeBlockchainExplorerAccountSynchronizer.hpp b/core/src/wallet/stellar/synchronizers/StellarLikeBlockchainExplorerAccountSynchronizer.hpp index 0cb9cf15a9..639319cadc 100644 --- a/core/src/wallet/stellar/synchronizers/StellarLikeBlockchainExplorerAccountSynchronizer.hpp +++ b/core/src/wallet/stellar/synchronizers/StellarLikeBlockchainExplorerAccountSynchronizer.hpp @@ -65,7 +65,7 @@ namespace ledger { /** * Last block height fetched during last synchronization */ - uint64_t lastBlockHeight = 0; + uint64_t lastBlockHeight = 0; template void serialize(Archive &archive) { diff --git a/core/src/wallet/stellar/transaction_builders/StellarLikeTransactionBuilder.cpp b/core/src/wallet/stellar/transaction_builders/StellarLikeTransactionBuilder.cpp index 80975c68a8..d22eee8250 100644 --- a/core/src/wallet/stellar/transaction_builders/StellarLikeTransactionBuilder.cpp +++ b/core/src/wallet/stellar/transaction_builders/StellarLikeTransactionBuilder.cpp @@ -56,9 +56,9 @@ namespace ledger { stellar::xdr::Operation operation; stellar::xdr::PaymentOp op; StellarLikeAddress addr(address, _account->getWallet()->getCurrency(), Option::NONE); - op.destination = addr.toXdrMuxedAccount(); - op.asset.type = stellar::xdr::AssetType::ASSET_TYPE_NATIVE; - op.amount = std::static_pointer_cast(amount)->value()->toInt64(); + op.destination = addr.toXdrMuxedAccount(); + op.asset.type = stellar::xdr::AssetType::ASSET_TYPE_NATIVE; + op.amount = std::static_pointer_cast(amount)->value()->toInt64(); operation.type = stellar::OperationType::PAYMENT; operation.content = op; @@ -86,8 +86,8 @@ namespace ledger { std::copy(pubKey.begin(), pubKey.end(), op.destination.content.begin()); op.startingBalance = std::static_pointer_cast(amount)->value()->toInt64(); - operation.type = stellar::OperationType::CREATE_ACCOUNT; - operation.content = op; + operation.type = stellar::OperationType::CREATE_ACCOUNT; + operation.content = op; _envelope.tx.operations.emplace_back(operation); _balanceChange = _balanceChange + BigInt(op.startingBalance); diff --git a/core/src/wallet/stellar/xdr/models.hpp b/core/src/wallet/stellar/xdr/models.hpp index e2d388cfe8..e1ed66737b 100644 --- a/core/src/wallet/stellar/xdr/models.hpp +++ b/core/src/wallet/stellar/xdr/models.hpp @@ -48,9 +48,9 @@ namespace ledger { // user is attempting any invalid operation enum class CryptoKeyType : uint32_t { - KEY_TYPE_ED25519 = 0, - KEY_TYPE_PRE_AUTH_TX = 1, - KEY_TYPE_HASH_X = 2, + KEY_TYPE_ED25519 = 0, + KEY_TYPE_PRE_AUTH_TX = 1, + KEY_TYPE_HASH_X = 2, // MUXED enum values for supported type are derived from the enum values // above by ORing them with 0x100 KEY_TYPE_MUXED_ED25519 = 0x100 @@ -68,13 +68,13 @@ namespace ledger { using DataValue = std::vector; // String types (CHECK THE VALIDITY OF THE DATA BEFORE SETTING!) - using string32 = std::string; // Max 32 chars - using string28 = std::string; // Max 28 chars - using string64 = std::string; // Max 64 chars + using string32 = std::string; // Max 32 chars + using string28 = std::string; // Max 28 chars + using string64 = std::string; // Max 64 chars // Signature - using SignatureHint = std::array; - using Signature = std::vector; // Max length == 64 + using SignatureHint = std::array; + using Signature = std::vector; // Max length == 64 // TimeBounds structure struct TimeBounds { diff --git a/core/src/wallet/tezos/TezosLikeAccount.cpp b/core/src/wallet/tezos/TezosLikeAccount.cpp index 6cba56ed67..13d2f0027d 100644 --- a/core/src/wallet/tezos/TezosLikeAccount.cpp +++ b/core/src/wallet/tezos/TezosLikeAccount.cpp @@ -161,14 +161,14 @@ namespace ledger { } bool TezosLikeAccount::updateOriginatedAccounts(const Operation &operation) { - auto transaction = operation.tezosTransaction.getValue(); - auto self = std::dynamic_pointer_cast(shared_from_this()); - auto origAccount = transaction.originatedAccount.getValue(); + auto transaction = operation.tezosTransaction.getValue(); + auto self = std::dynamic_pointer_cast(shared_from_this()); + auto origAccount = transaction.originatedAccount.getValue(); auto originatedAccountUid = TezosLikeAccountDatabaseHelper::createOriginatedAccountUid(getAccountUid(), origAccount.address); - const auto found = std::find_if(_originatedAccounts.begin(), _originatedAccounts.end(), - [&originatedAccountUid](const std::shared_ptr &element) { + const auto found = std::find_if(_originatedAccounts.begin(), _originatedAccounts.end(), + [&originatedAccountUid](const std::shared_ptr &element) { return std::dynamic_pointer_cast(element)->getAccountUid() == originatedAccountUid; }); diff --git a/core/src/wallet/tezos/TezosLikeAccount2.cpp b/core/src/wallet/tezos/TezosLikeAccount2.cpp index a68fadff62..8ed9a41ad2 100644 --- a/core/src/wallet/tezos/TezosLikeAccount2.cpp +++ b/core/src/wallet/tezos/TezosLikeAccount2.cpp @@ -72,7 +72,7 @@ namespace ledger { static const std::size_t signatureSize{TezosLikeTransactionApi::SIGNATURE_SIZE_BYTES}; Future TezosLikeAccount::eraseDataSince(const std::chrono::system_clock::time_point &date) { - auto log = logger(); + auto log = logger(); auto eraseDataBenchmarker = std::make_shared( fmt::format("erase_data_since/{}", tracePrefix()), log); @@ -105,7 +105,7 @@ namespace ledger { std::lock_guard lock(_synchronizationLock); if (_currentSyncEventBus) return _currentSyncEventBus; - auto eventPublisher = std::make_shared(getContext()); + auto eventPublisher = std::make_shared(getContext()); _currentSyncEventBus = eventPublisher->getEventBus(); auto self = std::static_pointer_cast(shared_from_this()); @@ -451,7 +451,7 @@ namespace ledger { BigInt computedRevealFees = computeFees(txSize, gas->reveal); BigInt computedTransactionFees = computeFees(txSize, gas->transaction); - const auto revealFees = std::make_shared(std::move(computedRevealFees)); + const auto revealFees = std::make_shared(std::move(computedRevealFees)); filledTx->setRevealFees(revealFees); const auto transactionFees = std::make_shared(std::move(computedTransactionFees)); filledTx->setTransactionFees(transactionFees); @@ -541,7 +541,7 @@ namespace ledger { if (!sender) { throw make_exception(api::ErrorCode::RUNTIME_ERROR, "computeOperationUid: Sender must be provided"); } - auto receiver = parsedTx->getReceiver(); + auto receiver = parsedTx->getReceiver(); const std::string &senderAddress = sender->toBase58(); const std::string &receiverAddress = receiver ? receiver->toBase58() : std::string(); @@ -563,7 +563,7 @@ namespace ledger { std::string txIdBase = fmt::format("{}", parsedTx->getCounter()->intValue()); - std::string &&txId = Operation::computeTransactionId(txIdBase, parsedTx->getOperationTypeInTransaction(), additional); + std::string &&txId = Operation::computeTransactionId(txIdBase, parsedTx->getOperationTypeInTransaction(), additional); return OperationDatabaseHelper::createUid(getAccountUid(), txId, opType); } diff --git a/core/src/wallet/tezos/api_impl/TezosLikeTransactionApi.cpp b/core/src/wallet/tezos/api_impl/TezosLikeTransactionApi.cpp index 47e5cbd4e1..72fada72cf 100644 --- a/core/src/wallet/tezos/api_impl/TezosLikeTransactionApi.cpp +++ b/core/src/wallet/tezos/api_impl/TezosLikeTransactionApi.cpp @@ -71,24 +71,24 @@ namespace ledger { _block = nullptr; } - _hash = tx.hash; + _hash = tx.hash; - _currency = operation->getAccount()->getWallet()->getCurrency(); + _currency = operation->getAccount()->getWallet()->getCurrency(); _transactionFees = std::make_shared(_currency, 0, tx.fees); _transactionGasLimit = std::make_shared(_currency, 0, tx.gas_limit); _value = std::make_shared(_currency, 0, tx.value); - _receiver = TezosLikeAddress::fromBase58(tx.receiver, _currency); - _sender = TezosLikeAddress::fromBase58(tx.sender, _currency); + _receiver = TezosLikeAddress::fromBase58(tx.receiver, _currency); + _sender = TezosLikeAddress::fromBase58(tx.sender, _currency); - _type = tx.type; + _type = tx.type; - _revealedPubKey = tx.publicKey; - _revealFees = std::make_shared(_currency, 0, tx.fees); - _revealGasLimit = std::make_shared(_currency, 0, tx.gas_limit); + _revealedPubKey = tx.publicKey; + _revealFees = std::make_shared(_currency, 0, tx.fees); + _revealGasLimit = std::make_shared(_currency, 0, tx.gas_limit); - _status = tx.status; + _status = tx.status; } api::TezosOperationTag TezosLikeTransactionApi::getType() const { @@ -226,7 +226,7 @@ namespace ledger { auto params = _currency.tezosLikeNetworkParameters.value_or(networks::getTezosLikeNetworkParameters("tezos")); auto config = std::make_shared(); config->putString("networkIdentifier", params.Identifier); - auto decoded = Base58::checkAndDecode(_block->getHash(), config); + auto decoded = Base58::checkAndDecode(_block->getHash(), config); // Remove 2 first bytes (of version) auto blockHash = std::vector{decoded.getValue().begin() + 2, decoded.getValue().end()}; writer.writeByteArray(blockHash); diff --git a/core/src/wallet/tezos/database/TezosLikeAccountDatabaseHelper.cpp b/core/src/wallet/tezos/database/TezosLikeAccountDatabaseHelper.cpp index 5be4c428b6..d09a83f58c 100644 --- a/core/src/wallet/tezos/database/TezosLikeAccountDatabaseHelper.cpp +++ b/core/src/wallet/tezos/database/TezosLikeAccountDatabaseHelper.cpp @@ -103,7 +103,7 @@ namespace ledger { "WHERE op.account_uid = :uid AND orig_op.uid IS NULL ORDER BY op.date"; rowset rows = (sql.prepare << query, use(accountUid)); - auto filterList = [&](const std::vector &list) -> bool { + auto filterList = [&](const std::vector &list) -> bool { for (auto &elem : list) { if (filter(elem)) { return true; diff --git a/core/src/wallet/tezos/database/TezosLikeTransactionDatabaseHelper.cpp b/core/src/wallet/tezos/database/TezosLikeTransactionDatabaseHelper.cpp index 7848de65b8..13f2802bfb 100644 --- a/core/src/wallet/tezos/database/TezosLikeTransactionDatabaseHelper.cpp +++ b/core/src/wallet/tezos/database/TezosLikeTransactionDatabaseHelper.cpp @@ -86,7 +86,7 @@ namespace ledger { tx.originatedAccount = TezosLikeBlockchainExplorerOriginatedAccount(values[0], static_cast(std::stoi(values[1])), static_cast(std::stoi(values[2]))); } - tx.status = get_number(row, 12); + tx.status = get_number(row, 12); auto explorerId = row.get(13); if (!explorerId.empty()) { @@ -122,7 +122,7 @@ namespace ledger { std::string TezosLikeTransactionDatabaseHelper::putTransaction(soci::session &sql, const std::string &accountUid, const TezosLikeBlockchainExplorerTransaction &tx) { - auto blockUid = tx.block.map([](const TezosLikeBlockchainExplorer::Block &block) { + auto blockUid = tx.block.map([](const TezosLikeBlockchainExplorer::Block &block) { return block.getUid(); }); diff --git a/core/src/wallet/tezos/explorers/BakingBadTezosLikeBlockchainExplorer.cpp b/core/src/wallet/tezos/explorers/BakingBadTezosLikeBlockchainExplorer.cpp index 27baf72b6e..62809a9362 100644 --- a/core/src/wallet/tezos/explorers/BakingBadTezosLikeBlockchainExplorer.cpp +++ b/core/src/wallet/tezos/explorers/BakingBadTezosLikeBlockchainExplorer.cpp @@ -184,7 +184,7 @@ namespace ledger { fmt::format("Failed to get fees from network, no (or malformed) response")); } - const auto &json = jarray[static_cast(0)]; + const auto &json = jarray[static_cast(0)]; const auto getFieldValue = [&json](const char *fieldName) -> std::string { std::string value; @@ -197,7 +197,7 @@ namespace ledger { const std::string levelValueStr = getFieldValue("level"); // try first with "fee" else with "fees" - std::string feesValueStr = getFieldValue("fee"); + std::string feesValueStr = getFieldValue("fee"); if (feesValueStr.empty()) { feesValueStr = getFieldValue("fees"); } @@ -214,7 +214,7 @@ namespace ledger { if (result.isLeft()) { throw result.getLeft(); } - const auto &totalTx = result.getRight(); + const auto &totalTx = result.getRight(); const auto totalFees = BigInt::fromString(feesValueStr); BigInt fees = BigInt::fromString(api::TezosConfigurationDefaults::TEZOS_DEFAULT_FEES); @@ -312,7 +312,7 @@ namespace ledger { BakingBadTezosLikeBlockchainExplorer::getTransactions(const std::vector &addresses, Option offset, Option /*session*/) { - const auto tryOffset = Try::from([=]() -> uint64_t { + const auto tryOffset = Try::from([=]() -> uint64_t { return std::stoul(offset.getValueOr(""), nullptr, 10); }); @@ -446,7 +446,7 @@ namespace ledger { return _http->GET(fmt::format("v1/accounts/{}", address)) .json(false) .map(getExplorerContext(), [=](const HttpRequest::JsonResult &result) { - const auto &json = *std::get<1>(result); + const auto &json = *std::get<1>(result); // look for the delegate field const auto *const field = "delegate"; if (!json.IsObject()) { diff --git a/core/src/wallet/tezos/explorers/ExternalTezosLikeBlockchainExplorer.cpp b/core/src/wallet/tezos/explorers/ExternalTezosLikeBlockchainExplorer.cpp index 8ee7665b79..2daea52f18 100644 --- a/core/src/wallet/tezos/explorers/ExternalTezosLikeBlockchainExplorer.cpp +++ b/core/src/wallet/tezos/explorers/ExternalTezosLikeBlockchainExplorer.cpp @@ -181,7 +181,7 @@ namespace ledger { ExternalTezosLikeBlockchainExplorer::getTransactions(const std::vector &addresses, Option offset, Option /*session*/) { - auto tryOffset = Try::from([=]() -> uint64_t { + auto tryOffset = Try::from([=]() -> uint64_t { return std::stoul(offset.getValueOr(""), nullptr, 10); }); @@ -364,7 +364,7 @@ namespace ledger { } else if (connection.getStatusCode() < 200 || connection.getStatusCode() >= 300) { throw Exception(api::ErrorCode::HTTP_ERROR, connection.getStatusText()); } else { - auto &json = *std::get<1>(result); + auto &json = *std::get<1>(result); // look for the is_funded field const auto field = "is_funded"; @@ -383,7 +383,7 @@ namespace ledger { return _http->GET(fmt::format("account/{}", address)) .json(false) .map(getExplorerContext(), [=](const HttpRequest::JsonResult &result) { - auto &json = *std::get<1>(result); + auto &json = *std::get<1>(result); // look for the is_active_delegate field const auto field = "is_active_delegate"; if (!json.IsObject() || !json.HasMember(field) || diff --git a/core/src/wallet/tezos/explorers/NodeTezosLikeBlockchainExplorer.cpp b/core/src/wallet/tezos/explorers/NodeTezosLikeBlockchainExplorer.cpp index a98a255f58..a8ca21d7de 100644 --- a/core/src/wallet/tezos/explorers/NodeTezosLikeBlockchainExplorer.cpp +++ b/core/src/wallet/tezos/explorers/NodeTezosLikeBlockchainExplorer.cpp @@ -323,7 +323,7 @@ namespace ledger { } else if (connection.getStatusCode() < 200 || connection.getStatusCode() >= 300) { throw Exception(api::ErrorCode::HTTP_ERROR, connection.getStatusText()); } else { - auto &json = *std::get<1>(result); + auto &json = *std::get<1>(result); // look for the is_funded field const auto field = "is_funded"; @@ -345,7 +345,7 @@ namespace ledger { address)) .json(false) .map(getExplorerContext(), [=](const HttpRequest::JsonResult &result) { - auto &json = *std::get<1>(result); + auto &json = *std::get<1>(result); // look for the is_active_delegate field const auto field = "is_active_delegate"; if (!json.IsObject() || !json.HasMember(field) || diff --git a/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.cpp b/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.cpp index ea9eae5f2a..828855c7a3 100644 --- a/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.cpp +++ b/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.cpp @@ -301,7 +301,7 @@ namespace ledger { auto ecode = exception.getErrorCode(); // Tezos RPC returns a 500 when the transaction is not valid (bad counter, no // balance, etc.) so we rethrow the tezos node error for easier debugging - auto body = std::static_pointer_cast( + auto body = std::static_pointer_cast( exception.getUserData().getValue()); const auto &json = *std::get<1>(*body); rapidjson::StringBuffer buffer; diff --git a/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.h b/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.h index ebaf4202fa..7817141348 100644 --- a/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.h +++ b/core/src/wallet/tezos/explorers/TezosLikeBlockchainExplorer.h @@ -143,7 +143,7 @@ namespace ledger { getStorage(const std::string &address) = 0; virtual Future> - getCounter(const std::string &address) = 0; + getCounter(const std::string &address) = 0; virtual Future> forgeKTOperation(const std::shared_ptr &tx) = 0; // This a helper to manage legacy KT accounts @@ -174,9 +174,9 @@ namespace ledger { const std::string &rpcNode); /// Check that the account is funded. - virtual Future isFunded(const std::string &address) = 0; + virtual Future isFunded(const std::string &address) = 0; - virtual Future isDelegate(const std::string &address) = 0; + virtual Future isDelegate(const std::string &address) = 0; virtual Future getSynchronisationOffset(const std::shared_ptr &operations) = 0; diff --git a/core/src/wallet/tezos/synchronizers/TezosLikeAccountSynchronizer.cpp b/core/src/wallet/tezos/synchronizers/TezosLikeAccountSynchronizer.cpp index d6f5a7f7d6..1b4656e55c 100644 --- a/core/src/wallet/tezos/synchronizers/TezosLikeAccountSynchronizer.cpp +++ b/core/src/wallet/tezos/synchronizers/TezosLikeAccountSynchronizer.cpp @@ -156,8 +156,8 @@ namespace ledger { return lhs.blockHeight < rhs.blockHeight; }); - auto currencyName = buddy->wallet->getCurrency().name; - size_t index = 0; + auto currencyName = buddy->wallet->getCurrency().name; + size_t index = 0; // Reorg can't happen until genesis block, safely initialize with 0 uint64_t deepestFailedBlockHeight = 0; while (index < sortedBatches.size() && @@ -252,7 +252,7 @@ namespace ledger { auto self = shared_from_this(); auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; - auto benchmark = std::make_shared( + auto benchmark = std::make_shared( fmt::format("full_batch/{}", buddy->synchronizationTag), buddy->logger); benchmark->start(); @@ -327,7 +327,7 @@ namespace ledger { AccountDatabaseHelper::removeBlockOperation(sql, buddy->account->getAccountUid(), blockToDelete); // Get last block not part from reorg - auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, buddy->wallet->getCurrency().name); + auto lastBlock = BlockDatabaseHelper::getLastBlock(sql, buddy->wallet->getCurrency().name); // Resync from the "beginning" if no last block in DB int64_t lastBlockHeight = 0; @@ -433,7 +433,7 @@ namespace ledger { auto &batchState = buddy->savedState.getValue().batches[currentBatchIndex]; // self->transactions.insert(self->transactions.end(), bulk->transactions.begin(), bulk->transactions.end()); buddy->logger->info("Got {} txs for account {}", bulk->transactions.size(), buddy->account->getAccountUid()); - auto count = 0; + auto count = 0; // NEW CODE Option lastBlock = Option::NONE; @@ -461,7 +461,7 @@ namespace ledger { addedNewAddressInBatch = buddy->account->interpretTransaction(tx, operations); // Update first pendingTxHash in savedState - auto it = buddy->transactionsToDrop.find(tx.hash); + auto it = buddy->transactionsToDrop.find(tx.hash); if (it != buddy->transactionsToDrop.end()) { // If block non empty, tx is no longer pending if (tx.block.nonEmpty()) { diff --git a/core/src/wallet/tezos/transaction_builders/TezosLikeTransactionBuilder.cpp b/core/src/wallet/tezos/transaction_builders/TezosLikeTransactionBuilder.cpp index 94e598f5f9..a68167d242 100644 --- a/core/src/wallet/tezos/transaction_builders/TezosLikeTransactionBuilder.cpp +++ b/core/src/wallet/tezos/transaction_builders/TezosLikeTransactionBuilder.cpp @@ -165,8 +165,8 @@ namespace ledger { const std::string &protocolUpdate) { auto isBabylonActivated = protocolUpdate == api::TezosConfigurationDefaults::TEZOS_PROTOCOL_UPDATE_BABYLON; - auto params = currency.tezosLikeNetworkParameters.value(); - auto tx = std::make_shared(currency, protocolUpdate); + auto params = currency.tezosLikeNetworkParameters.value(); + auto tx = std::make_shared(currency, protocolUpdate); if (isSigned) { // if signed remove the signature @@ -191,7 +191,7 @@ namespace ledger { // Block Hash auto blockHashBytes = reader.read(32); - auto config = std::make_shared(); + auto config = std::make_shared(); config->putString("networkIdentifier", params.Identifier); // Magic bytes (or version ?) std::vector blockPrefix{0x01, 0x34}; @@ -214,8 +214,8 @@ namespace ledger { // First curve code ... senderCurveCode = reader.readNextByte(); // then hash160 ... - senderHash160 = reader.read(20); - version = TezosLikeAddress::getPrefixFromImplicitVersion(params.ImplicitPrefix, api::TezosCurve(senderCurveCode)); + senderHash160 = reader.read(20); + version = TezosLikeAddress::getPrefixFromImplicitVersion(params.ImplicitPrefix, api::TezosCurve(senderCurveCode)); } else { auto isSenderOriginated = reader.readNextByte(); if (isSenderOriginated) { @@ -228,8 +228,8 @@ namespace ledger { // Otherwise first curve code ... senderCurveCode = reader.readNextByte(); // then hash160 ... - senderHash160 = reader.read(20); - version = TezosLikeAddress::getPrefixFromImplicitVersion(params.ImplicitPrefix, api::TezosCurve(senderCurveCode)); + senderHash160 = reader.read(20); + version = TezosLikeAddress::getPrefixFromImplicitVersion(params.ImplicitPrefix, api::TezosCurve(senderCurveCode)); } } tx->setSender(std::make_shared(currency, senderHash160, version, Option()), @@ -292,8 +292,8 @@ namespace ledger { // Curve code auto receiverCurveCode = reader.readNextByte(); // 20 bytes of publicKey hash - receiverHash160 = reader.read(20); - receiverVersion = TezosLikeAddress::getPrefixFromImplicitVersion(params.ImplicitPrefix, api::TezosCurve(receiverCurveCode)); + receiverHash160 = reader.read(20); + receiverVersion = TezosLikeAddress::getPrefixFromImplicitVersion(params.ImplicitPrefix, api::TezosCurve(receiverCurveCode)); tx->setReceiver(std::make_shared(currency, receiverHash160, receiverVersion, @@ -328,7 +328,7 @@ namespace ledger { if (!isBabylonActivated) { auto managerCurveCode = reader.readNextByte(); // manager hash160 - auto managerHash160 = reader.read(20); + auto managerHash160 = reader.read(20); if (managerHash160 != senderHash160) { throw make_exception(api::ErrorCode::INVALID_ARGUMENT, "Origination error: Manager is different from sender"); } @@ -346,7 +346,7 @@ namespace ledger { // Curve Code auto delegateCurveCode = reader.readNextByte(); // Delegate hash160 - auto delegateHash160 = reader.read(20); + auto delegateHash160 = reader.read(20); tx->setReceiver(std::make_shared(currency, delegateHash160, TezosLikeAddress::getPrefixFromImplicitVersion( diff --git a/core/test/algorand/AlgorandAccountTests.cpp b/core/test/algorand/AlgorandAccountTests.cpp index 51352e63a8..33fb20feb2 100644 --- a/core/test/algorand/AlgorandAccountTests.cpp +++ b/core/test/algorand/AlgorandAccountTests.cpp @@ -206,14 +206,14 @@ class AlgorandAccountTest : public WalletFixture { const auto currency = currencies::ALGORAND; registerCurrency(currency); - accountInfo = api::AccountCreationInfo(1, {}, {}, {algorand::Address::toPublicKey(OBELIX)}, {}); + accountInfo = api::AccountCreationInfo(1, {}, {}, {algorand::Address::toPublicKey(OBELIX)}, {}); // NOTE: we run the tests on the staging environment which is on the TestNet auto configuration = DynamicObject::newInstance(); configuration->putString(api::Configuration::BLOCKCHAIN_EXPLORER_API_ENDPOINT, "https://algorand.coin.staging.aws.ledger.com"); - wallet = std::dynamic_pointer_cast(uv::wait(pool->createWallet("algorand", currency.name, configuration))); - account = createAlgorandAccount(wallet, accountInfo.index, accountInfo); + wallet = std::dynamic_pointer_cast(uv::wait(pool->createWallet("algorand", currency.name, configuration))); + account = createAlgorandAccount(wallet, accountInfo.index, accountInfo); accountUid = algorand::AccountDatabaseHelper::createAccountUid(wallet->getWalletUid(), accountInfo.index); @@ -238,9 +238,9 @@ class AlgorandAccountTest : public WalletFixture { }; TEST_F(AlgorandAccountTest, algosBalanceHistory) { - const auto start = "2019-12-29T00:00:00Z"; - const auto end = "2020-08-01T00:00:00Z"; - const auto period = api::TimePeriod::MONTH; + const auto start = "2019-12-29T00:00:00Z"; + const auto end = "2020-08-01T00:00:00Z"; + const auto period = api::TimePeriod::MONTH; const auto expected = std::vector{ 10000, @@ -259,10 +259,10 @@ TEST_F(AlgorandAccountTest, algosBalanceHistory) { } TEST_F(AlgorandAccountTest, assetBalanceHistory) { - const auto id = std::string("2"); - const auto start = "2019-12-29T00:00:00Z"; - const auto end = "2020-08-01T00:00:00Z"; - const auto period = api::TimePeriod::MONTH; + const auto id = std::string("2"); + const auto start = "2019-12-29T00:00:00Z"; + const auto end = "2020-08-01T00:00:00Z"; + const auto period = api::TimePeriod::MONTH; const auto expected = std::vector{ 0, diff --git a/core/test/algorand/AlgorandDatabaseTests.cpp b/core/test/algorand/AlgorandDatabaseTests.cpp index 15607c2d62..161bdc480c 100644 --- a/core/test/algorand/AlgorandDatabaseTests.cpp +++ b/core/test/algorand/AlgorandDatabaseTests.cpp @@ -53,14 +53,14 @@ class AlgorandDatabaseTest : public WalletFixture { auto const currency = currencies::ALGORAND; registerCurrency(currency); - accountInfo = api::AccountCreationInfo(1, {}, {}, {algorand::Address::toPublicKey(OBELIX_ADDRESS)}, {}); + accountInfo = api::AccountCreationInfo(1, {}, {}, {algorand::Address::toPublicKey(OBELIX_ADDRESS)}, {}); // NOTE: we run the tests on the staging environment which is on the TestNet auto configuration = DynamicObject::newInstance(); configuration->putString(api::Configuration::BLOCKCHAIN_EXPLORER_API_ENDPOINT, "https://algorand.coin.staging.aws.ledger.com"); - wallet = std::dynamic_pointer_cast(uv::wait(pool->createWallet("algorand", currency.name, configuration))); - account = createAlgorandAccount(wallet, accountInfo.index, accountInfo); + wallet = std::dynamic_pointer_cast(uv::wait(pool->createWallet("algorand", currency.name, configuration))); + account = createAlgorandAccount(wallet, accountInfo.index, accountInfo); accountUid = algorand::AccountDatabaseHelper::createAccountUid(wallet->getWalletUid(), accountInfo.index); } @@ -141,7 +141,7 @@ TEST_F(AlgorandDatabaseTest, DISABLED_OperationsDBTest) { auto ops = uv::wait(std::dynamic_pointer_cast(account->queryOperations()->complete())->execute()); EXPECT_EQ(ops.size(), 1); - auto op = std::dynamic_pointer_cast(ops[0]); + auto op = std::dynamic_pointer_cast(ops[0]); /* TODO ? EXPECT_EQ(op->getAccountIndex(), account->getIndex()); diff --git a/core/test/algorand/AlgorandExplorerTests.cpp b/core/test/algorand/AlgorandExplorerTests.cpp index 27a3291415..0ba9f2b983 100644 --- a/core/test/algorand/AlgorandExplorerTests.cpp +++ b/core/test/algorand/AlgorandExplorerTests.cpp @@ -43,10 +43,10 @@ class AlgorandExplorerTest : public BaseFixture { auto worker = dispatcher->getSerialExecutionContext("worker"); auto threadpoolWorker = dispatcher->getThreadPoolExecutionContext("threadpoolWorker"); // NOTE: we run the tests on the staging environment which is on the TestNet - auto client = std::make_shared("https://algorand.coin.staging.aws.ledger.com", http, worker, threadpoolWorker); + auto client = std::make_shared("https://algorand.coin.staging.aws.ledger.com", http, worker, threadpoolWorker); // NOTE: we run the tests on the staging environment which is on the TestNet - auto configuration = DynamicObject::newInstance(); + auto configuration = DynamicObject::newInstance(); configuration->putString(api::Configuration::BLOCKCHAIN_EXPLORER_API_ENDPOINT, "https://algorand.coin.staging.aws.ledger.com"); explorer = std::make_shared( diff --git a/core/test/algorand/AlgorandSynchronizationTests.cpp b/core/test/algorand/AlgorandSynchronizationTests.cpp index 69f7dce7ca..c4f240ed5f 100644 --- a/core/test/algorand/AlgorandSynchronizationTests.cpp +++ b/core/test/algorand/AlgorandSynchronizationTests.cpp @@ -59,7 +59,7 @@ class AlgorandSynchronizationTest : public WalletFixture { auto configuration = DynamicObject::newInstance(); configuration->putString(api::Configuration::BLOCKCHAIN_EXPLORER_API_ENDPOINT, "https://algorand.coin.staging.aws.ledger.com"); - auto wallet = std::dynamic_pointer_cast(uv::wait(pool->createWallet("test-wallet", "algorand", configuration))); + auto wallet = std::dynamic_pointer_cast(uv::wait(pool->createWallet("test-wallet", "algorand", configuration))); auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); @@ -71,7 +71,7 @@ class AlgorandSynchronizationTest : public WalletFixture { {algorand::Address::toPublicKey(accountAddress)}, {hex::toByteArray("")}); - _account = std::dynamic_pointer_cast(uv::wait(wallet->newAccountWithInfo(info))); + _account = std::dynamic_pointer_cast(uv::wait(wallet->newAccountWithInfo(info))); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -84,7 +84,7 @@ class AlgorandSynchronizationTest : public WalletFixture { getTestExecutionContext()->stop(); }); - auto bus = _account->synchronize(); + auto bus = _account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); } diff --git a/core/test/algorand/AlgorandTestFixtures.hpp b/core/test/algorand/AlgorandTestFixtures.hpp index f3bfe4c900..4dbfa789fc 100644 --- a/core/test/algorand/AlgorandTestFixtures.hpp +++ b/core/test/algorand/AlgorandTestFixtures.hpp @@ -55,7 +55,7 @@ namespace ledger { static const std::string ASSET_CONFIG_TX_ID = "GYF4N5DXRANS6AEJL4HZD53FHYSGL6AVYKLR4PG5DBSJJASWXD7Q"; static const std::string ASSET_TRANSFER_TX_ID = "P3TBX7WYKO5SIZIHV2Z3GUCOD7B556RF6PSOPINFB6QN7EMTF6JQ"; - static const std::string TESTNET_GENESIS_ID = ledger::core::networks::getAlgorandNetworkParameters("algorand-testnet").genesisID; + static const std::string TESTNET_GENESIS_ID = ledger::core::networks::getAlgorandNetworkParameters("algorand-testnet").genesisID; static const B64String TESTNET_GENESIS_HASH(ledger::core::networks::getAlgorandNetworkParameters("algorand-testnet").genesisHash); static const model::AssetParams testAsset() { @@ -98,10 +98,10 @@ namespace ledger { tx.header.receiverRewards = Option(0); tx.header.closeRewards = Option(0); - tx.details = model::PaymentTxnFields(); - auto &details = boost::get(tx.details); - details.receiverAddr = Address(TEST_ACCOUNT_ADDRESS); - details.amount = 1000; + tx.details = model::PaymentTxnFields(); + auto &details = boost::get(tx.details); + details.receiverAddr = Address(TEST_ACCOUNT_ADDRESS); + details.amount = 1000; } return tx; @@ -166,11 +166,11 @@ namespace ledger { tx.header.receiverRewards = Option(0); tx.header.closeRewards = Option(0); - tx.details = model::AssetTransferTxnFields(); - auto &details = boost::get(tx.details); - details.assetId = 342836; - details.assetReceiver = Address(TEST_ACCOUNT_ADDRESS); - details.assetAmount = 1000; + tx.details = model::AssetTransferTxnFields(); + auto &details = boost::get(tx.details); + details.assetId = 342836; + details.assetReceiver = Address(TEST_ACCOUNT_ADDRESS); + details.assetAmount = 1000; } return tx; diff --git a/core/test/bitcoin/address_test.cpp b/core/test/bitcoin/address_test.cpp index cdd14625f8..7fb05f6ba1 100644 --- a/core/test/bitcoin/address_test.cpp +++ b/core/test/bitcoin/address_test.cpp @@ -114,8 +114,8 @@ TEST(Address, XpubFromBase58StringToBech32) { TEST(Address, XpubFromBase58StringToBech32DGB) { const Currency currency = currencies::DIGIBYTE; // xpub6DFGdRPjroChgYV1heGwjnPBVi9ANtLGDp8oFSgZMezMimPBQweUmH4co6pkP1zUMSvK1NAmNJqFpewnqM1dc2UA62MhdjcZemCGtjWWK9s - auto bech32Address = "dgb1qgdg3hdysnpmaxpdpqqzhey2f5888av488hq0z6"; - auto config = std::make_shared(); + auto bech32Address = "dgb1qgdg3hdysnpmaxpdpqqzhey2f5888av488hq0z6"; + auto config = std::make_shared(); config->putString(api::Configuration::KEYCHAIN_ENGINE, api::KeychainEngines::BIP173_P2WPKH); auto xpub = ledger::core::BitcoinLikeExtendedPublicKey::fromRaw( currency, @@ -134,8 +134,8 @@ TEST(Address, XpubFromBase58StringToBech32DGB) { TEST(Address, XpubFromBase58StringToBech32LTC) { const Currency currency = currencies::LITECOIN; // Ltub2YC8XgcRjMJqvX8LsuBxdM7PKE5uih6247CpgK2rfEdzEGt1YHVHW4L865ss5eEy2K1KixTMkrHJbzTtqxpiGpM4wyrxYRFJFxuACSJqkyo - auto bech32Address = "ltc1q7qnj9xm8wp8ucmg64lk0h03as8k6ql6rk4wvsd"; - auto config = std::make_shared(); + auto bech32Address = "ltc1q7qnj9xm8wp8ucmg64lk0h03as8k6ql6rk4wvsd"; + auto config = std::make_shared(); config->putString(api::Configuration::KEYCHAIN_ENGINE, api::KeychainEngines::BIP173_P2WPKH); auto xpub = ledger::core::BitcoinLikeExtendedPublicKey::fromRaw( currency, diff --git a/core/test/bitcoin/bitcoin_utxo_picket_tests.cpp b/core/test/bitcoin/bitcoin_utxo_picket_tests.cpp index b5a4a95287..950f22de8d 100644 --- a/core/test/bitcoin/bitcoin_utxo_picket_tests.cpp +++ b/core/test/bitcoin/bitcoin_utxo_picket_tests.cpp @@ -123,7 +123,7 @@ TEST(OptimizeSize, BacktrackingCalculateChangeCorrectly) { int64_t outputAmount = 25000; std::vector inputAmounts{16500, 16500}; - auto buddy = createBuddy(feesPerByte, outputAmount, currency); + auto buddy = createBuddy(feesPerByte, outputAmount, currency); auto utxos = createUtxos(inputAmounts); auto pickedUtxos = BitcoinLikeStrategyUtxoPicker::filterWithOptimizeSize(buddy, utxos, BigInt(-1), currency); @@ -147,7 +147,7 @@ TEST(OptimizeSize, ChangeShouldBeBigEnoughToSpend) { int64_t outputAmount = 25000; std::vector inputAmounts{19090, 19090}; - auto buddy = createBuddy(feesPerByte, outputAmount, currency); + auto buddy = createBuddy(feesPerByte, outputAmount, currency); auto utxos = createUtxos(inputAmounts); auto pickedUtxos = BitcoinLikeStrategyUtxoPicker::filterWithOptimizeSize(buddy, utxos, BigInt(-1), currency); @@ -171,7 +171,7 @@ TEST(OptimizeSize, ApproximationShouldTookEnough) { int64_t outputAmount = 25000; std::vector inputAmounts{15000, 15000, 15000}; - auto buddy = createBuddy(feesPerByte, outputAmount, currency); + auto buddy = createBuddy(feesPerByte, outputAmount, currency); auto utxos = createUtxos(inputAmounts); auto pickedUtxos = BitcoinLikeStrategyUtxoPicker::filterWithOptimizeSize(buddy, utxos, BigInt(-1), currency); diff --git a/core/test/coin-integration/stellar/synchronization_tests.cpp b/core/test/coin-integration/stellar/synchronization_tests.cpp index 86e6810ea6..0c7fbfe4e1 100644 --- a/core/test/coin-integration/stellar/synchronization_tests.cpp +++ b/core/test/coin-integration/stellar/synchronization_tests.cpp @@ -110,7 +110,7 @@ TEST_F(StellarFixture, DISABLED_SynchronizeEmptyStellarAccount) { auto info = uv::wait(wallet->getNextAccountCreationInfo()); auto account = newAccount(wallet, 0, emptyAccount()); - auto exists = uv::wait(account->exists()); + auto exists = uv::wait(account->exists()); EXPECT_FALSE(exists); auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), diff --git a/core/test/coin-integration/stellar/transaction_tests.cpp b/core/test/coin-integration/stellar/transaction_tests.cpp index 4bbd84cce3..a254b0f42e 100644 --- a/core/test/coin-integration/stellar/transaction_tests.cpp +++ b/core/test/coin-integration/stellar/transaction_tests.cpp @@ -85,7 +85,7 @@ TEST_F(StellarFixture, DISABLED_ParseRawTransaction) { "83935fabfdc44749ad4d042dbc4df9b59442f325a27960519fba516adb8a5000000000000" "00000000000000000000000000000"; - auto tx = api::StellarLikeTransactionBuilder::parseRawTransaction(ledger::core::currencies::STELLAR, hex::toByteArray(strTx)); + auto tx = api::StellarLikeTransactionBuilder::parseRawTransaction(ledger::core::currencies::STELLAR, hex::toByteArray(strTx)); EXPECT_EQ(tx->getSourceAccount()->toString(), "GCQQQPIROIEFHIWEO2QH4KNWJYHZ5MX7RFHR4SCWFD5KPNR5455E6BR3"); EXPECT_EQ(tx->getSourceAccountSequence()->compare(api::BigInt::fromLong(98448948301135875L)), 0); @@ -101,7 +101,7 @@ TEST_F(StellarFixture, DISABLED_ParseSignatureBase) { "5fabfdc44749ad4d042dbc4df9b59442f325a27960519fba516adb8a500000000000000000" "0000000000000000"; - auto tx = api::StellarLikeTransactionBuilder::parseSignatureBase(ledger::core::currencies::STELLAR, hex::toByteArray(strTx)); + auto tx = api::StellarLikeTransactionBuilder::parseSignatureBase(ledger::core::currencies::STELLAR, hex::toByteArray(strTx)); EXPECT_EQ(tx->getSourceAccount()->toString(), "GCQQQPIROIEFHIWEO2QH4KNWJYHZ5MX7RFHR4SCWFD5KPNR5455E6BR3"); EXPECT_EQ(tx->getSourceAccountSequence()->compare(api::BigInt::fromLong(98448948301135875L)), 0); diff --git a/core/test/coin-integration/stellar/xdr_tests.cpp b/core/test/coin-integration/stellar/xdr_tests.cpp index 555d336a92..6a8b0c41cc 100644 --- a/core/test/coin-integration/stellar/xdr_tests.cpp +++ b/core/test/coin-integration/stellar/xdr_tests.cpp @@ -119,8 +119,8 @@ TEST_F(StellarFixture, XDRPaymentEncode) { PaymentOp op; op.destination = dest->toXdrMuxedAccount(); - op.amount = 250000000UL; - op.asset.type = AssetType::ASSET_TYPE_NATIVE; + op.amount = 250000000UL; + op.asset.type = AssetType::ASSET_TYPE_NATIVE; stellar::xdr::Operation operation; operation.type = stellar::OperationType::PAYMENT; @@ -146,8 +146,8 @@ TEST_F(StellarFixture, XDRPaymentDecode) { decoder >> envelope; EXPECT_EQ(envelope.type, EnvelopeType::ENVELOPE_TYPE_TX_V0); - const auto &v0 = boost::get(envelope.content); - const auto &tx = v0.tx; + const auto &v0 = boost::get(envelope.content); + const auto &tx = v0.tx; auto sourceAddr = StellarLikeAddress::convertPubkeyToAddress(std::vector(tx.sourceAccountEd25519.begin(), tx.sourceAccountEd25519.end()), Option::NONE, getCurrency().stellarLikeNetworkParameters.value()); EXPECT_EQ(sourceAddr, SOURCE_ADDR); diff --git a/core/test/common/balance_history.cpp b/core/test/common/balance_history.cpp index 3ccd0a22d6..8192ff4243 100644 --- a/core/test/common/balance_history.cpp +++ b/core/test/common/balance_history.cpp @@ -84,8 +84,8 @@ struct DummyOperationStrategy { TEST(BalanceHistory, ZeroesOutOfRange) { // a basic collections of “operations” with nothing std::vector operations; - auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); - auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); + auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); + auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); auto balances = agnostic::getBalanceHistoryFor( start, @@ -112,8 +112,8 @@ TEST(BalanceHistory, CorrectBalancesPerHour) { DummyOperation(5, api::OperationType::SEND, DateUtils::fromJSON("2019-01-01T04:00:00Z")), DummyOperation(3, api::OperationType::SEND, DateUtils::fromJSON("2019-01-01T07:30:00Z"))}; - auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); - auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); + auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); + auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); auto balances = agnostic::getBalanceHistoryFor( start, @@ -140,8 +140,8 @@ TEST(BalanceHistory, CorrectBalancesPerDay) { DummyOperation(5, api::OperationType::SEND, DateUtils::fromJSON("2019-01-02T04:00:00Z")), DummyOperation(3, api::OperationType::SEND, DateUtils::fromJSON("2019-01-02T04:30:00Z"))}; - auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); - auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); + auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); + auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); auto balances = agnostic::getBalanceHistoryFor( start, @@ -166,8 +166,8 @@ TEST(BalanceHistory, CorrectBalancesPerDay2) { DummyOperation(5, api::OperationType::SEND, DateUtils::fromJSON("2019-01-19T04:00:00Z")), DummyOperation(3, api::OperationType::SEND, DateUtils::fromJSON("2019-01-22T05:30:00Z"))}; - auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); - auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); + auto start = DateUtils::fromJSON("2019-01-01T00:00:00Z"); + auto end = DateUtils::fromJSON("2019-02-01T00:00:00Z"); auto balances = agnostic::getBalanceHistoryFor( start, diff --git a/core/test/cosmos/address_test.cpp b/core/test/cosmos/address_test.cpp index e479f1da4c..62155910b4 100644 --- a/core/test/cosmos/address_test.cpp +++ b/core/test/cosmos/address_test.cpp @@ -76,8 +76,8 @@ TEST(CosmosAddress, AddressFromPubKey) { std::string expectedBech32Addr = "cosmos16xkkyj97z7r83sx45xwk9uwq0mj0zszlf6c6mq"; // From bech32 pubKey to pubKeyHash160 - auto pkBech32 = std::make_shared(api::CosmosBech32Type::PUBLIC_KEY); - auto pkDecodedHash160 = pkBech32->decode(prefixedPubKey); + auto pkBech32 = std::make_shared(api::CosmosBech32Type::PUBLIC_KEY); + auto pkDecodedHash160 = pkBech32->decode(prefixedPubKey); // Byte array to encode : hence the + 5 std::vector secp256k1PubKey(pkDecodedHash160.second.begin() + 5, pkDecodedHash160.second.end()); @@ -105,9 +105,9 @@ TEST(CosmosAddress, AddressFromPubKey) { auto publicKeyHash160 = HASH160::hash(pubKey, hashAlgorithm); // To Bech32 - auto bech32 = std::make_shared(api::CosmosBech32Type::ADDRESS); - auto bech32Addr = bech32->encode(publicKeyHash160, std::vector()); - auto decodedHash160 = bech32->decode(bech32Addr); + auto bech32 = std::make_shared(api::CosmosBech32Type::ADDRESS); + auto bech32Addr = bech32->encode(publicKeyHash160, std::vector()); + auto decodedHash160 = bech32->decode(bech32Addr); EXPECT_EQ(hex::toString(decodedHash160.second), hex::toString(publicKeyHash160)); } } diff --git a/core/test/cosmos/db_test.cpp b/core/test/cosmos/db_test.cpp index 03013b72ae..cdfef4b055 100644 --- a/core/test/cosmos/db_test.cpp +++ b/core/test/cosmos/db_test.cpp @@ -61,8 +61,8 @@ TEST_F(CosmosDBTest, BasicDBTest) { std::chrono::system_clock::time_point timeRef = DateUtils::now(); - const auto msg = setupSendMessage(); - auto tx = setupTransactionResponse(std::vector{msg}, timeRef); + const auto msg = setupSendMessage(); + auto tx = setupTransactionResponse(std::vector{msg}, timeRef); // Test writing into DB { @@ -98,8 +98,8 @@ TEST_F(CosmosDBTest, OperationQueryTest) { std::chrono::system_clock::time_point timeRef = DateUtils::now(); - const auto msg = setupSendMessage(); - const auto tx = setupTransactionResponse(std::vector{msg}, timeRef); + const auto msg = setupSendMessage(); + const auto tx = setupTransactionResponse(std::vector{msg}, timeRef); { std::vector operations; @@ -110,7 +110,7 @@ TEST_F(CosmosDBTest, OperationQueryTest) { { auto ops = uv::wait(std::dynamic_pointer_cast(account->queryOperations()->complete())->execute()); ASSERT_EQ(ops.size(), 1); - auto op = ops[0]; + auto op = ops[0]; /* TODO EXPECT_EQ(op->getAccountIndex(), account->getIndex()); @@ -129,7 +129,7 @@ TEST_F(CosmosDBTest, OperationQueryTest) { */ // auto cosmosOp = std::dynamic_pointer_cast(op); - auto cosmosOp = op->asCosmosLikeOperation(); + auto cosmosOp = op->asCosmosLikeOperation(); auto txRetrieved = std::dynamic_pointer_cast(cosmosOp->getTransaction())->getRawData(); assertSameTransaction(tx, txRetrieved); @@ -145,8 +145,8 @@ TEST_F(CosmosDBTest, FeesMsgTypeFilteredOutTest) { std::chrono::system_clock::time_point timeRef = DateUtils::now(); - const auto msgFees = setupFeesMessage("cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl"); - auto tx = setupTransactionResponse(std::vector{msgFees}, timeRef); + const auto msgFees = setupFeesMessage("cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl"); + auto tx = setupTransactionResponse(std::vector{msgFees}, timeRef); { std::vector operations; @@ -170,8 +170,8 @@ TEST_F(CosmosDBTest, DISABLED_FeesMsgTypeTest) { std::chrono::system_clock::time_point timeRef = DateUtils::now(); - const auto msgFees = setupFeesMessage(account->getAddress()); - auto tx = setupTransactionResponse(std::vector{msgFees}, timeRef); + const auto msgFees = setupFeesMessage(account->getAddress()); + auto tx = setupTransactionResponse(std::vector{msgFees}, timeRef); { std::vector operations; @@ -183,7 +183,7 @@ TEST_F(CosmosDBTest, DISABLED_FeesMsgTypeTest) { auto ops = uv::wait(std::dynamic_pointer_cast(account->queryOperations()->complete())->execute()); ASSERT_EQ(ops.size(), 1); - auto op = ops[0]; + auto op = ops[0]; // auto cosmosOp = std::dynamic_pointer_cast(op); auto cosmosOp = op->asCosmosLikeOperation(); ASSERT_NE(cosmosOp, nullptr); @@ -207,11 +207,11 @@ TEST_F(CosmosDBTest, DISABLED_UnsuportedMsgTypeTest) { std::chrono::system_clock::time_point timeRef = DateUtils::now(); - const auto msg = setupSendMessage(); - auto tx = setupTransactionResponse(std::vector{msg}, timeRef); + const auto msg = setupSendMessage(); + auto tx = setupTransactionResponse(std::vector{msg}, timeRef); // Change message type - tx.messages[0].type = "unknown-message-type"; + tx.messages[0].type = "unknown-message-type"; { std::vector operations; @@ -223,7 +223,7 @@ TEST_F(CosmosDBTest, DISABLED_UnsuportedMsgTypeTest) { auto ops = uv::wait(std::dynamic_pointer_cast(account->queryOperations()->complete())->execute()); ASSERT_EQ(ops.size(), 1); - auto op = ops[0]; + auto op = ops[0]; // auto cosmosOp = std::dynamic_pointer_cast(op); auto cosmosOp = op->asCosmosLikeOperation(); const auto txRetrieved = std::dynamic_pointer_cast(cosmosOp->getTransaction())->getRawData(); @@ -239,9 +239,9 @@ TEST_F(CosmosDBTest, DISABLED_MultipleMsgTest) { std::chrono::system_clock::time_point timeRef = DateUtils::now(); - const auto msgSend = setupSendMessage(); - const auto msgVote = setupVoteMessage(); - const auto tx = setupTransactionResponse(std::vector{msgSend, msgVote}, timeRef); + const auto msgSend = setupSendMessage(); + const auto msgVote = setupVoteMessage(); + const auto tx = setupTransactionResponse(std::vector{msgSend, msgVote}, timeRef); { std::vector operations; @@ -254,7 +254,7 @@ TEST_F(CosmosDBTest, DISABLED_MultipleMsgTest) { ASSERT_EQ(ops.size(), 2); { - auto op = ops[0]; + auto op = ops[0]; // auto cosmosOp = std::dynamic_pointer_cast(op); auto cosmosOp = op->asCosmosLikeOperation(); ASSERT_NE(cosmosOp, nullptr); @@ -272,7 +272,7 @@ TEST_F(CosmosDBTest, DISABLED_MultipleMsgTest) { } { - auto op = ops[1]; + auto op = ops[1]; // auto cosmosOp = std::dynamic_pointer_cast(op); // auto txRetrieved = std::dynamic_pointer_cast(cosmosOp->getTransaction())->getRawData(); // auto msgRetrieved = std::dynamic_pointer_cast(cosmosOp->getMessage())->getRawData(); diff --git a/core/test/cosmos/parsers_test.cpp b/core/test/cosmos/parsers_test.cpp index bc68dfea5a..f322af1f9a 100644 --- a/core/test/cosmos/parsers_test.cpp +++ b/core/test/cosmos/parsers_test.cpp @@ -60,7 +60,7 @@ TEST(CosmosGaiaParser, Unbonding) { rpcs_parsers::parseUnbondingList(unbondingJSON.GetObject(), parsedResult); // Expected values - const auto delegator = std::string("cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl"); + const auto delegator = std::string("cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl"); const auto validator_a = std::string("cosmosvaloper1vf44d85es37hwl9f4h9gv0e064m0lla60j9luj"); const auto validator_b = std::string("cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"); diff --git a/core/test/cosmos/transactions_test.cpp b/core/test/cosmos/transactions_test.cpp index faa6f774ba..2bb8778d72 100644 --- a/core/test/cosmos/transactions_test.cpp +++ b/core/test/cosmos/transactions_test.cpp @@ -61,8 +61,8 @@ TEST(CosmosTransactionTest, BuildSignedSendTxForBroadcast) { "}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawSignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto sendMessage = api::CosmosLikeMessage::unwrapMsgSend(message); + auto message = tx->getMessages().front(); + auto sendMessage = api::CosmosLikeMessage::unwrapMsgSend(message); // ensure the values are correct EXPECT_EQ(tx->getFee()->toLong(), 5000L); @@ -90,8 +90,8 @@ TEST(CosmosTransactionTest, BuildDelegateTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto delegateMessage = api::CosmosLikeMessage::unwrapMsgDelegate(message); + auto message = tx->getMessages().front(); + auto delegateMessage = api::CosmosLikeMessage::unwrapMsgDelegate(message); EXPECT_EQ(tx->getFee()->toLong(), 5000L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(delegateMessage.delegatorAddress, "cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl"); @@ -116,8 +116,8 @@ TEST(CosmosTransactionTest, BuildUndelegateTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto undelegateMessage = api::CosmosLikeMessage::unwrapMsgUndelegate(message); + auto message = tx->getMessages().front(); + auto undelegateMessage = api::CosmosLikeMessage::unwrapMsgUndelegate(message); EXPECT_EQ(tx->getFee()->toLong(), 5000L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(undelegateMessage.delegatorAddress, "cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl"); @@ -143,8 +143,8 @@ TEST(CosmosTransactionTest, BuildBeginRedelegateTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto redelegateMessage = api::CosmosLikeMessage::unwrapMsgBeginRedelegate(message); + auto message = tx->getMessages().front(); + auto redelegateMessage = api::CosmosLikeMessage::unwrapMsgBeginRedelegate(message); EXPECT_EQ(tx->getFee()->toLong(), 5000L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(redelegateMessage.delegatorAddress, "cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl"); @@ -158,20 +158,20 @@ TEST(CosmosTransactionTest, BuildBeginRedelegateTxForBroadcast) { } TEST(CosmosTransactionTest, BuildSubmitProposalTxForBroadcast) { - const std::string strTx = "{" - "\"fee\":{\"amount\":[{\"amount\":\"5000\",\"denom\":\"uatom\"}],\"gas\":\"200000\"}," - "\"memo\":\"Sent from Ledger\"," - "\"msg\":[{" - "\"type\":\"cosmos-sdk/MsgSubmitProposal\"," - "\"value\":{" - "\"content\":{" - "\"description\":\"My awesome proposal\"," - "\"title\":\"Test Proposal\"," - "\"type\":\"Text\"}," - "\"initial_deposit\":[{\"amount\":\"1000000\",\"denom\":\"uatom\"}]," - "\"proposer\":\"cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl\"" - "}}]}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const std::string strTx = "{" + "\"fee\":{\"amount\":[{\"amount\":\"5000\",\"denom\":\"uatom\"}],\"gas\":\"200000\"}," + "\"memo\":\"Sent from Ledger\"," + "\"msg\":[{" + "\"type\":\"cosmos-sdk/MsgSubmitProposal\"," + "\"value\":{" + "\"content\":{" + "\"description\":\"My awesome proposal\"," + "\"title\":\"Test Proposal\"," + "\"type\":\"Text\"}," + "\"initial_deposit\":[{\"amount\":\"1000000\",\"denom\":\"uatom\"}]," + "\"proposer\":\"cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl\"" + "}}]}"; + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); auto message = tx->getMessages().front(); auto submitProposalMessage = api::CosmosLikeMessage::unwrapMsgSubmitProposal(message); @@ -201,8 +201,8 @@ TEST(CosmosTransactionTest, BuildVoteTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto voteMessage = api::CosmosLikeMessage::unwrapMsgVote(message); + auto message = tx->getMessages().front(); + auto voteMessage = api::CosmosLikeMessage::unwrapMsgVote(message); EXPECT_EQ(tx->getFee()->toLong(), 5000L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(to_string(voteMessage.option), "COSMOSVOTEYES"); @@ -226,8 +226,8 @@ TEST(CosmosTransactionTest, BuildDepositTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto depositMessage = api::CosmosLikeMessage::unwrapMsgDeposit(message); + auto message = tx->getMessages().front(); + auto depositMessage = api::CosmosLikeMessage::unwrapMsgDeposit(message); EXPECT_EQ(tx->getFee()->toLong(), 5000L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(depositMessage.proposalId, "123"); @@ -252,8 +252,8 @@ TEST(CosmosTransactionTest, BuildWithdrawDelegationRewardTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto withdrawMessage = api::CosmosLikeMessage::unwrapMsgWithdrawDelegationReward(message); + auto message = tx->getMessages().front(); + auto withdrawMessage = api::CosmosLikeMessage::unwrapMsgWithdrawDelegationReward(message); EXPECT_EQ(tx->getFee()->toLong(), 5000L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(withdrawMessage.delegatorAddress, "cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl"); @@ -277,8 +277,8 @@ TEST(CosmosTransactionTest, BuildMultiSendTxForBroadcast) { "}}]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto multiSendMessage = api::CosmosLikeMessage::unwrapMsgMultiSend(message); + auto message = tx->getMessages().front(); + auto multiSendMessage = api::CosmosLikeMessage::unwrapMsgMultiSend(message); EXPECT_EQ(tx->getFee()->toLong(), 5001L); EXPECT_EQ(tx->getGas()->toLong(), 200020L); ASSERT_EQ(multiSendMessage.inputs.size(), 1); @@ -300,21 +300,21 @@ TEST(CosmosTransactionTest, BuildCreateValidatorTxForBroadcast) { // TODO : find a transaction in Explorer to confirm the format here // For the time being we're using protobuf from cosmos-sdk as source : // https://github.com/cosmos/cosmos-sdk/blob/53bf2271d5bac054a8f74723732f21055c1b72d4/x/staking/types/types.pb.go - const std::string strTx = "{" - "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," - "\"memo\":\"Sent from Ledger\"," - "\"msg\":[{" - "\"type\":\"cosmos-sdk/MsgCreateValidator\"," - "\"value\":{" - "\"commission\":{\"max_change_rate\":\"0.05\",\"max_rate\":\"0.60\",\"rate\":\"0.45\",\"update_time\":\"2020-02-25T13:42:29Z\"}," - "\"delegator_address\":\"cosmostest\"," - "\"description\":{\"details\":\"It flies well\\\\nnewline\",\"identity\":\"Pocket Monsters\",\"moniker\":\"Hélédelle\",\"website\":\"https://www.pokepedia.fr/H%C3%A9l%C3%A9delle\"}," - "\"min_self_delegation\":\"1\"," - "\"pub_key\":\"0\"," - "\"validator_address\":\"cosmosvalopertest\"," - "\"value\":{\"amount\":\"1059860\",\"denom\":\"uatom\"}" - "}}]}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const std::string strTx = "{" + "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," + "\"memo\":\"Sent from Ledger\"," + "\"msg\":[{" + "\"type\":\"cosmos-sdk/MsgCreateValidator\"," + "\"value\":{" + "\"commission\":{\"max_change_rate\":\"0.05\",\"max_rate\":\"0.60\",\"rate\":\"0.45\",\"update_time\":\"2020-02-25T13:42:29Z\"}," + "\"delegator_address\":\"cosmostest\"," + "\"description\":{\"details\":\"It flies well\\\\nnewline\",\"identity\":\"Pocket Monsters\",\"moniker\":\"Hélédelle\",\"website\":\"https://www.pokepedia.fr/H%C3%A9l%C3%A9delle\"}," + "\"min_self_delegation\":\"1\"," + "\"pub_key\":\"0\"," + "\"validator_address\":\"cosmosvalopertest\"," + "\"value\":{\"amount\":\"1059860\",\"denom\":\"uatom\"}" + "}}]}"; + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); auto message = tx->getMessages().front(); auto createValidatorMessage = api::CosmosLikeMessage::unwrapMsgCreateValidator(message); @@ -343,18 +343,18 @@ TEST(CosmosTransactionTest, BuildEditValidatorTxForBroadcast) { // TODO : find a transaction in Explorer to confirm the format here // For the time being we're using protobuf from cosmos-sdk as source : // https://github.com/cosmos/cosmos-sdk/blob/53bf2271d5bac054a8f74723732f21055c1b72d4/x/staking/types/types.pb.go - const std::string strTx = "{" - "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," - "\"memo\":\"Sent from Ledger\"," - "\"msg\":[{" - "\"type\":\"cosmos-sdk/MsgEditValidator\"," - "\"value\":{" - "\"commission_rate\":\"0.50\"," - "\"description\":{\"details\":\"Cachabouée\",\"identity\":\"évolution de Wailmer\",\"moniker\":\"Wailord\",\"website\":\"https://www.pokepedia.fr/Wailord\"}," - "\"min_self_delegation\":\"800\"," - "\"validator_address\":\"cosmostest\"" - "}}]}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const std::string strTx = "{" + "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," + "\"memo\":\"Sent from Ledger\"," + "\"msg\":[{" + "\"type\":\"cosmos-sdk/MsgEditValidator\"," + "\"value\":{" + "\"commission_rate\":\"0.50\"," + "\"description\":{\"details\":\"Cachabouée\",\"identity\":\"évolution de Wailmer\",\"moniker\":\"Wailord\",\"website\":\"https://www.pokepedia.fr/Wailord\"}," + "\"min_self_delegation\":\"800\"," + "\"validator_address\":\"cosmostest\"" + "}}]}"; + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); auto message = tx->getMessages().front(); auto editValidatorMessage = api::CosmosLikeMessage::unwrapMsgEditValidator(message); @@ -380,16 +380,16 @@ TEST(CosmosTransactionTest, BuildEditValidatorTxForBroadcast) { TEST(CosmosTransactionTest, BuildSetWithdrawAddressTxForBroadcast) { // TODO : find a transaction in Explorer to confirm the format here - const std::string strTx = "{" - "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," - "\"memo\":\"Sent from Ledger\"," - "\"msg\":[{" - "\"type\":\"cosmos-sdk/MsgSetWithdrawAddress\"," - "\"value\":{" - "\"delegator_address\":\"cosmos1dafe\"," - "\"withdraw_address\":\"cosmos1erfdsa\"" - "}}]}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const std::string strTx = "{" + "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," + "\"memo\":\"Sent from Ledger\"," + "\"msg\":[{" + "\"type\":\"cosmos-sdk/MsgSetWithdrawAddress\"," + "\"value\":{" + "\"delegator_address\":\"cosmos1dafe\"," + "\"withdraw_address\":\"cosmos1erfdsa\"" + "}}]}"; + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); auto message = tx->getMessages().front(); auto setWithdrawAddressMessage = api::CosmosLikeMessage::unwrapMsgSetWithdrawAddress(message); @@ -404,16 +404,16 @@ TEST(CosmosTransactionTest, BuildSetWithdrawAddressTxForBroadcast) { TEST(CosmosTransactionTest, BuildWithdrawDelegatorRewardsTxForBroadcast) { // TODO : find a transaction in Explorer to confirm the format here - const std::string strTx = "{" - "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," - "\"memo\":\"Sent from Ledger\"," - "\"msg\":[{" - "\"type\":\"cosmos-sdk/MsgWithdrawDelegatorReward\"," - "\"value\":{" - "\"delegator_address\":\"cosmos1targ\"," - "\"validator_address\":\"cosmosvaloperwdfae\"" - "}}]}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const std::string strTx = "{" + "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," + "\"memo\":\"Sent from Ledger\"," + "\"msg\":[{" + "\"type\":\"cosmos-sdk/MsgWithdrawDelegatorReward\"," + "\"value\":{" + "\"delegator_address\":\"cosmos1targ\"," + "\"validator_address\":\"cosmosvaloperwdfae\"" + "}}]}"; + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); auto message = tx->getMessages().front(); auto withdrawDorRewardMessage = api::CosmosLikeMessage::unwrapMsgWithdrawDelegatorReward(message); @@ -428,14 +428,14 @@ TEST(CosmosTransactionTest, BuildWithdrawDelegatorRewardsTxForBroadcast) { TEST(CosmosTransactionTest, BuildWithdrawValidatorCommissionTxForBroadcast) { // TODO : find a transaction in Explorer to confirm the format here - const std::string strTx = "{" - "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," - "\"memo\":\"Sent from Ledger\"," - "\"msg\":[{" - "\"type\":\"cosmos-sdk/MsgWithdrawValidatorCommission\"," - "\"value\":{\"validator_address\":\"cosmosvaloper1234567890\"}}" - "]}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const std::string strTx = "{" + "\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"}," + "\"memo\":\"Sent from Ledger\"," + "\"msg\":[{" + "\"type\":\"cosmos-sdk/MsgWithdrawValidatorCommission\"," + "\"value\":{\"validator_address\":\"cosmosvaloper1234567890\"}}" + "]}"; + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); auto message = tx->getMessages().front(); auto withdrawVorCommissionMessage = api::CosmosLikeMessage::unwrapMsgWithdrawValidatorCommission(message); @@ -458,8 +458,8 @@ TEST(CosmosTransactionTest, BuildUnjailTxForBroadcast) { "]}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto unjailMessage = api::CosmosLikeMessage::unwrapMsgUnjail(message); + auto message = tx->getMessages().front(); + auto unjailMessage = api::CosmosLikeMessage::unwrapMsgUnjail(message); EXPECT_EQ(tx->getFee()->toLong(), 5001L); EXPECT_EQ(tx->getGas()->toLong(), 200020L); EXPECT_EQ(unjailMessage.validatorAddress, "cosmosvaloper1dalton"); @@ -484,7 +484,7 @@ TEST(CosmosTransactionTest, BuildSendTxForSignature) { "\"sequence\":\"0\"" "}"; - const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); + const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); EXPECT_EQ(tx->serializeForSignature(), strTx); } @@ -511,8 +511,8 @@ TEST(CosmosTransactionTest, BuildNoFeeTxForBroadcast) { "}}]}}"; const auto tx = api::CosmosLikeTransactionBuilder::parseRawUnsignedTransaction(currencies::ATOM, strTx); - auto message = tx->getMessages().front(); - auto withdrawMessage = api::CosmosLikeMessage::unwrapMsgWithdrawDelegationReward(message); + auto message = tx->getMessages().front(); + auto withdrawMessage = api::CosmosLikeMessage::unwrapMsgWithdrawDelegationReward(message); EXPECT_EQ(tx->getFee()->toLong(), 0L); EXPECT_EQ(tx->getGas()->toLong(), 200000L); EXPECT_EQ(withdrawMessage.delegatorAddress, "cosmos102hty0jv2s29lyc4u0tv97z9v298e24t3vwtpl"); diff --git a/core/test/crypto/encryption_test.cpp b/core/test/crypto/encryption_test.cpp index 61df6e732b..cf502af51c 100644 --- a/core/test/crypto/encryption_test.cpp +++ b/core/test/crypto/encryption_test.cpp @@ -98,7 +98,7 @@ TEST(Encryption, EncryptDecryptWithAES256CBCAndPBKDF2) { std::string salt = "Random salt"; std::vector encryptKey = PBKDF2::derive(vectorize(password), vectorize(salt), 10000, 32); - auto encrypted = AES256::encrypt(IV, encryptKey, vectorize(data)); + auto encrypted = AES256::encrypt(IV, encryptKey, vectorize(data)); EXPECT_NE(encrypted, vectorize(data)); auto decrypted = strigify(AES256::decrypt(IV, encryptKey, encrypted)); EXPECT_EQ(data, decrypted); diff --git a/core/test/database/pool_tests.cpp b/core/test/database/pool_tests.cpp index d31c212c85..4f57b8c9c6 100644 --- a/core/test/database/pool_tests.cpp +++ b/core/test/database/pool_tests.cpp @@ -95,10 +95,10 @@ TEST(DatabaseSessionPool, OpenAndMigrateForTheFirstTime) { } TEST(DatabaseSessionPool, InitializeCurrencies) { - auto dispatcher = std::make_shared(); - auto resolver = std::make_shared(); - auto backend = std::static_pointer_cast(DatabaseBackend::getPostgreSQLBackend(api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE, api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE)); - auto printer = std::make_shared(dispatcher->getMainExecutionContext()); + auto dispatcher = std::make_shared(); + auto resolver = std::make_shared(); + auto backend = std::static_pointer_cast(DatabaseBackend::getPostgreSQLBackend(api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE, api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE)); + auto printer = std::make_shared(dispatcher->getMainExecutionContext()); std::shared_ptr configuration = api::DynamicObject::newInstance(); configuration->putString(api::PoolConfiguration::DATABASE_NAME, getPostgresUrl()); @@ -148,10 +148,10 @@ TEST(DatabaseSessionPool, InitializeCurrencies) { } TEST(DatabaseSessionPool, ListingWalletsFilterUnsupportedOnes) { - auto dispatcher = std::make_shared(); - auto resolver = std::make_shared(); - auto backend = std::static_pointer_cast(DatabaseBackend::getPostgreSQLBackend(api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE, api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE)); - auto printer = std::make_shared(dispatcher->getMainExecutionContext()); + auto dispatcher = std::make_shared(); + auto resolver = std::make_shared(); + auto backend = std::static_pointer_cast(DatabaseBackend::getPostgreSQLBackend(api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE, api::ConfigurationDefaults::DEFAULT_PG_CONNECTION_POOL_SIZE)); + auto printer = std::make_shared(dispatcher->getMainExecutionContext()); std::shared_ptr configuration = api::DynamicObject::newInstance(); configuration->putString(api::PoolConfiguration::DATABASE_NAME, getPostgresUrl()); diff --git a/core/test/events/events_test.cpp b/core/test/events/events_test.cpp index b4b5227972..c6dd66a1fc 100644 --- a/core/test/events/events_test.cpp +++ b/core/test/events/events_test.cpp @@ -42,7 +42,7 @@ TEST(Events, SimpleCase) { auto dispatcher = std::make_shared(); auto eventPublisher = std::make_shared(dispatcher->getSerialExecutionContext("worker")); - auto receiver = make_receiver( + auto receiver = make_receiver( [&](const std::shared_ptr &event) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_STARTED); dispatcher->stop(); @@ -57,7 +57,7 @@ TEST(Events, SimpleCaseWithPayload) { auto dispatcher = std::make_shared(); auto eventPublisher = std::make_shared(dispatcher->getSerialExecutionContext("worker")); - auto receiver = make_receiver([&](const std::shared_ptr &event) { + auto receiver = make_receiver([&](const std::shared_ptr &event) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_STARTED); EXPECT_EQ(event->getPayload()->getString("hello"), Option("world").toOptional()); auto before = event->getPayload()->dump(); diff --git a/core/test/integration/BaseFixture.cpp b/core/test/integration/BaseFixture.cpp index 1eaa3c47f1..d1c141714a 100644 --- a/core/test/integration/BaseFixture.cpp +++ b/core/test/integration/BaseFixture.cpp @@ -186,9 +186,9 @@ void BaseFixture::SetUp() { printer = std::make_shared(dispatcher->getMainExecutionContext()); auto client = std::make_shared(dispatcher->getMainExecutionContext()); // client->setGenerateCacheFile(true); - http = std::make_shared(client); - ws = std::make_shared(); - rng = std::make_shared(); + http = std::make_shared(client); + ws = std::make_shared(); + rng = std::make_shared(); } void BaseFixture::TearDown() { @@ -367,5 +367,5 @@ void BaseFixture::resetDispatcher() { printer = std::make_shared(dispatcher->getMainExecutionContext()); auto client = std::make_shared(dispatcher->getMainExecutionContext()); // client->setGenerateCacheFile(true); - http = std::make_shared(client); + http = std::make_shared(client); } diff --git a/core/test/integration/account_info_test.cpp b/core/test/integration/account_info_test.cpp index 8e520870e9..70aeb2e45c 100644 --- a/core/test/integration/account_info_test.cpp +++ b/core/test/integration/account_info_test.cpp @@ -117,7 +117,7 @@ TEST_F(AccountInfoTests, DISABLED_GetAddressFromRange) { auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin", DynamicObject::newInstance())); auto account = createBitcoinLikeAccount(wallet, 0, P2PKH_MEDIUM_XPUB_INFO); - auto freshAddresses = uv::wait(account->getFreshPublicAddresses()); + auto freshAddresses = uv::wait(account->getFreshPublicAddresses()); auto from = 10, to = 100; auto addresses = uv::wait(account->getAddresses(from, to)); diff --git a/core/test/integration/keychains/common_bitcoin_keychain_test.cpp b/core/test/integration/keychains/common_bitcoin_keychain_test.cpp index d4f18e62ee..4e6f2ea62a 100644 --- a/core/test/integration/keychains/common_bitcoin_keychain_test.cpp +++ b/core/test/integration/keychains/common_bitcoin_keychain_test.cpp @@ -125,7 +125,7 @@ TEST_F(CommonBitcoinKeychains, CorrectStateProducedByMarkPathAsUsed) { TEST_F(CommonBitcoinKeychains, CorrectStateUsedAtMarkPathAsUsed) { testKeychain(BTC_TESTNET_DATA, [](ConcreteCommonBitcoinLikeKeychains &keychain) { - auto addresses = keychain.getAllObservableAddresses(0, 10); + auto addresses = keychain.getAllObservableAddresses(0, 10); // update state from outside KeychainPersistentState stateInput = keychain.getState(); diff --git a/core/test/integration/keychains/ethereum_keychain_test.cpp b/core/test/integration/keychains/ethereum_keychain_test.cpp index 13fcc718c5..30c2318646 100644 --- a/core/test/integration/keychains/ethereum_keychain_test.cpp +++ b/core/test/integration/keychains/ethereum_keychain_test.cpp @@ -173,7 +173,7 @@ TEST_F(EthereumKeychains, EthereumAddressValidationFromPubKeyAndChainCode) { auto chainCode = elem[3]; auto expectedAddress = elem[4]; - auto config = DynamicObject::newInstance(); + auto config = DynamicObject::newInstance(); config->putString(api::Configuration::KEYCHAIN_DERIVATION_SCHEME, derivationScheme); auto ethXpub = ledger::core::EthereumLikeExtendedPublicKey::fromRaw(ledger::core::currencies::ETHEREUM, experimental::optional>(), @@ -219,7 +219,7 @@ TEST_F(EthereumKeychains, DISABLED_EthereumDerivationSchemes) { auto derivationSchemes = elem.equivalentDerivationSchemes; for (auto &scheme : derivationSchemes) { configuration->putString(api::Configuration::KEYCHAIN_DERIVATION_SCHEME, scheme); - auto wallet = uv::wait(pool->createWallet(scheme, "ethereum", configuration)); + auto wallet = uv::wait(pool->createWallet(scheme, "ethereum", configuration)); // Create account as Live does api::AccountCreationInfo info = uv::wait(wallet->getNextAccountCreationInfo()); info.publicKeys.push_back(hex::toByteArray(elem.pubKey)); diff --git a/core/test/integration/keychains/p2wsh_keychain_test.cpp b/core/test/integration/keychains/p2wsh_keychain_test.cpp index f98adf839c..e9788ac68b 100644 --- a/core/test/integration/keychains/p2wsh_keychain_test.cpp +++ b/core/test/integration/keychains/p2wsh_keychain_test.cpp @@ -46,7 +46,7 @@ class BitcoinP2WSHKeychains : public KeychainFixture { }; TEST_F(BitcoinP2WSHKeychains, UnitTest) { - auto currency = currencies::BITCOIN; + auto currency = currencies::BITCOIN; // Script const auto ¶ms = currency.bitcoinLikeNetworkParameters.value(); HashAlgorithm hashAlgorithm(params.Identifier); diff --git a/core/test/integration/keychains/ripple_keychain_test.cpp b/core/test/integration/keychains/ripple_keychain_test.cpp index 93f97b0a62..4959200e88 100644 --- a/core/test/integration/keychains/ripple_keychain_test.cpp +++ b/core/test/integration/keychains/ripple_keychain_test.cpp @@ -93,7 +93,7 @@ TEST_F(RippleKeychains, RippleDerivationSchemes) { auto derivationSchemes = elem.equivalentDerivationSchemes; for (auto &scheme : derivationSchemes) { configuration->putString(api::Configuration::KEYCHAIN_DERIVATION_SCHEME, scheme); - auto wallet = uv::wait(pool->createWallet(scheme, "ripple", configuration)); + auto wallet = uv::wait(pool->createWallet(scheme, "ripple", configuration)); // Create account as Live does api::AccountCreationInfo info = uv::wait(wallet->getNextAccountCreationInfo()); EXPECT_EQ(info.derivations[0], elem.expectedDerivationPath); diff --git a/core/test/integration/synchronization/cosmos_synchronization.cpp b/core/test/integration/synchronization/cosmos_synchronization.cpp index 4cb5e02f3c..558a3c2913 100644 --- a/core/test/integration/synchronization/cosmos_synchronization.cpp +++ b/core/test/integration/synchronization/cosmos_synchronization.cpp @@ -73,7 +73,7 @@ class CosmosLikeWalletSynchronization : public BaseFixture { auto poolConfig = DynamicObject::newInstance(); poolConfig->putString(api::PoolConfiguration::DATABASE_NAME, getPostgresUrl()); - pool = newDefaultPool("postgres", "", poolConfig); + pool = newDefaultPool("postgres", "", poolConfig); explorer = std::make_shared( worker, @@ -87,7 +87,7 @@ class CosmosLikeWalletSynchronization : public BaseFixture { const std::string &pubKey) { auto configuration = DynamicObject::newInstance(); configuration->putString(api::Configuration::KEYCHAIN_DERIVATION_SCHEME, "44'/'/'//
"); - wallet = uv::wait(pool->createWallet("e847815f-488a-4301-b67c-378a5e9c8a61", "cosmos", configuration)); + wallet = uv::wait(pool->createWallet("e847815f-488a-4301-b67c-378a5e9c8a61", "cosmos", configuration)); auto accountInfo = uv::wait(wallet->getNextAccountCreationInfo()); EXPECT_EQ(accountInfo.index, 0); @@ -114,7 +114,7 @@ class CosmosLikeWalletSynchronization : public BaseFixture { getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); } @@ -150,9 +150,9 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_InternalFeesMessageInTransactio const auto &feeMessage = transaction->messages[feeMessageIndex]; const auto &feeMessageLog = transaction->logs[feeMessageIndex]; - auto reduceAmounts = [](const std::vector &coins) { + auto reduceAmounts = [](const std::vector &coins) { return std::accumulate(std::begin(coins), std::end(coins), BigInt::ZERO, - [](BigInt s, const cosmos::Coin &coin) { + [](BigInt s, const cosmos::Coin &coin) { return s + BigInt::fromString(coin.amount); }); }; @@ -212,7 +212,7 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetErrorTransaction) { auto validator = "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn"; auto delegator = "cosmos1k3kg9w60dd5x56vve2s28v3xjp7fp2vn2hjjsa"; - auto tx = uv::wait(explorer->getTransactionByHash(tx_hash)); + auto tx = uv::wait(explorer->getTransactionByHash(tx_hash)); ASSERT_EQ(tx->hash, tx_hash); EXPECT_EQ(tx->block->height, 768780); EXPECT_EQ(tx->logs.size(), 2); @@ -238,9 +238,9 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetSendWithExplorer) { auto tx_hash = "F4B8CB550B498F744CCC420907B80D0B068250972F975354A873CD1CCF9B000A"; auto receiver = "cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u"; // Note : the sender of the message is also the sender of the funds in this transaction. - auto sender = "cosmos15v50ymp6n5dn73erkqtmq0u8adpl8d3ujv2e74"; + auto sender = "cosmos15v50ymp6n5dn73erkqtmq0u8adpl8d3ujv2e74"; - auto tx = uv::wait(explorer->getTransactionByHash(tx_hash)); + auto tx = uv::wait(explorer->getTransactionByHash(tx_hash)); ASSERT_EQ(tx->hash, tx_hash); EXPECT_EQ(tx->block->height, 453223); EXPECT_EQ(tx->logs.size(), 2); @@ -262,15 +262,15 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetDelegateWithExplorer) { auto delegator = "cosmos1ytpz9gt59hssp5m5sknuzrwse88glqhgcrypxj"; auto validator = "cosmosvaloper1ey69r37gfxvxg62sh4r0ktpuc46pzjrm873ae8"; - auto filter = GaiaCosmosLikeBlockchainExplorer::fuseFilters( - {GaiaCosmosLikeBlockchainExplorer::filterWithAttribute( - cosmos::constants::kEventTypeMessage, - cosmos::constants::kAttributeKeyAction, - cosmos::constants::kEventTypeDelegate), - GaiaCosmosLikeBlockchainExplorer::filterWithAttribute( - cosmos::constants::kEventTypeMessage, - cosmos::constants::kAttributeKeySender, - delegator)}); + auto filter = GaiaCosmosLikeBlockchainExplorer::fuseFilters( + {GaiaCosmosLikeBlockchainExplorer::filterWithAttribute( + cosmos::constants::kEventTypeMessage, + cosmos::constants::kAttributeKeyAction, + cosmos::constants::kEventTypeDelegate), + GaiaCosmosLikeBlockchainExplorer::filterWithAttribute( + cosmos::constants::kEventTypeMessage, + cosmos::constants::kAttributeKeySender, + delegator)}); auto bulk = uv::wait(explorer->getTransactions(filter, 1, 10)); auto transactions = bulk->transactions; ASSERT_TRUE(transactions.size() >= 1); @@ -301,7 +301,7 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetDelegateWithExplorer) { TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetCurrentBlockWithExplorer) { std::string address = "cosmos16xkkyj97z7r83sx45xwk9uwq0mj0zszlf6c6mq"; - auto block = uv::wait(explorer->getCurrentBlock()); + auto block = uv::wait(explorer->getCurrentBlock()); EXPECT_TRUE(block->hash.size() > 0); EXPECT_TRUE(block->height > 0); } @@ -331,7 +331,7 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { auto address = uv::wait(account->getFreshPublicAddresses())[0]->toString(); EXPECT_EQ(address, DEFAULT_ADDRESS); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -385,11 +385,11 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_Balances) { const std::string address = account->getKeychain()->getAddress()->toBech32(); const std::string mintscanExplorer = fmt::format("https://www.mintscan.io/account/{}", address); - const auto totalBalance = uv::wait(account->getTotalBalance())->toLong(); - const auto delegatedBalance = uv::wait(account->getDelegatedBalance())->toLong(); - const auto pendingRewards = uv::wait(account->getPendingRewardsBalance())->toLong(); - const auto unbondingBalance = uv::wait(account->getUnbondingBalance())->toLong(); - const auto spendableBalance = uv::wait(account->getSpendableBalance())->toLong(); + const auto totalBalance = uv::wait(account->getTotalBalance())->toLong(); + const auto delegatedBalance = uv::wait(account->getDelegatedBalance())->toLong(); + const auto pendingRewards = uv::wait(account->getPendingRewardsBalance())->toLong(); + const auto unbondingBalance = uv::wait(account->getUnbondingBalance())->toLong(); + const auto spendableBalance = uv::wait(account->getSpendableBalance())->toLong(); EXPECT_LE(delegatedBalance, totalBalance) << "Delegated Coins fall under Total Balance, so delegatedBalance <= totalBalance"; @@ -538,7 +538,7 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_ValidatorSet) { const auto binance_staking_pub_address = "cosmosvalconspub1zcjduepqtw8862dhw8uty58d6t2szfd6kqram2t234zjteaaeem6l45wclaq8l60gn"; bool foundBinance = false; - auto set = uv::wait(explorer->getActiveValidatorSet()); + auto set = uv::wait(explorer->getActiveValidatorSet()); EXPECT_EQ(set.size(), 125) << "currently cosmoshub-3 has 125 active validators"; @@ -562,7 +562,7 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_ValidatorInfo) { const auto bisonTrailsValConsPubAddress = "cosmosvalconspub1zcjduepqc5y2du793cjut0cn6v7thp3xlvphggk6rt2dhw9ekjla5wtkm7nstmv5vy"; const auto mintscanAddress = fmt::format("https://www.mintscan.io/validators/{}", bisonTrailsAddress); - auto valInfo = uv::wait(explorer->getValidatorInfo(bisonTrailsAddress)); + auto valInfo = uv::wait(explorer->getValidatorInfo(bisonTrailsAddress)); ASSERT_EQ(valInfo.operatorAddress, bisonTrailsAddress) << "We should fetch the expected validator"; ASSERT_EQ(valInfo.consensusPubkey, bisonTrailsValConsPubAddress) << "We should fetch the expected validator"; diff --git a/core/test/integration/synchronization/cosmos_synchronization_benchmarks.cpp b/core/test/integration/synchronization/cosmos_synchronization_benchmarks.cpp index 7d0f19a3dc..7b9123a02a 100644 --- a/core/test/integration/synchronization/cosmos_synchronization_benchmarks.cpp +++ b/core/test/integration/synchronization/cosmos_synchronization_benchmarks.cpp @@ -95,7 +95,7 @@ class CosmosWalletSyncBenchmark : public BaseFixture { auto poolConfig = DynamicObject::newInstance(); poolConfig->putString(api::PoolConfiguration::DATABASE_NAME, getPostgresUrl()); - pool = newDefaultPool("postgres", "", poolConfig); + pool = newDefaultPool("postgres", "", poolConfig); explorer = std::make_shared( worker, client, PARAMS, std::make_shared()); @@ -138,7 +138,7 @@ class CosmosWalletSyncBenchmark : public BaseFixture { getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); } diff --git a/core/test/integration/synchronization/ethereum_synchronization.cpp b/core/test/integration/synchronization/ethereum_synchronization.cpp index 324bc982be..69bd16fe77 100644 --- a/core/test/integration/synchronization/ethereum_synchronization.cpp +++ b/core/test/integration/synchronization/ethereum_synchronization.cpp @@ -67,17 +67,17 @@ TEST_F(EthereumLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INFO_LIVE); + auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INFO_LIVE); - auto receiver = make_receiver([=, &erc20Count](const std::shared_ptr &event) { + auto receiver = make_receiver([=, &erc20Count](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); - auto balance = uv::wait(account->getBalance()); + auto balance = uv::wait(account->getBalance()); auto erc20Accounts = account->getERC20Accounts(); erc20Count = erc20Accounts.size(); @@ -108,7 +108,7 @@ TEST_F(EthereumLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { ->queryOperations() ->addOrder(api::OperationOrderKey::DATE, true) ->complete()) - ->execute()); + ->execute()); std::cout << "ERC20 Operations: " << operations.size() << std::endl; EXPECT_NE(operations.size(), 0); @@ -132,8 +132,8 @@ TEST_F(EthereumLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { auto ops = uv::wait(std::dynamic_pointer_cast(account->queryOperations()->complete())->execute()); std::cout << "Ops: " << ops.size() << std::endl; - auto block = uv::wait(account->getLastBlock()); - auto blockHash = block.blockHash; + auto block = uv::wait(account->getLastBlock()); + auto blockHash = block.blockHash; // ERC 20 tests auto ercAccount = std::dynamic_pointer_cast(account->getERC20Accounts()[0]); @@ -172,7 +172,7 @@ TEST_F(EthereumLikeWalletSynchronization, DISABLED_BalanceHistory) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INFO_LIVE); - auto receiver = make_receiver([=, &erc20Count, &balanceStr](const std::shared_ptr &event) { + auto receiver = make_receiver([=, &erc20Count, &balanceStr](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) @@ -181,14 +181,14 @@ TEST_F(EthereumLikeWalletSynchronization, DISABLED_BalanceHistory) { auto balance = uv::wait(account->getBalance()); balanceStr = balance->toString(); - auto now = std::time(nullptr); + auto now = std::time(nullptr); char now_str[256]; std::strftime(now_str, sizeof(now_str), "%Y-%m-%dT%H:%M:%SZ", std::localtime(&now)); auto history = uv::wait(account->getBalanceHistory( - "2019-09-20T00:00:00Z", - now_str, - api::TimePeriod::DAY)); + "2019-09-20T00:00:00Z", + now_str, + api::TimePeriod::DAY)); auto operations = uv::wait(std::dynamic_pointer_cast(account->queryOperations()->complete())->execute()); BigInt cumulated; BigInt cumulatedInt; @@ -221,7 +221,7 @@ TEST_F(EthereumLikeWalletSynchronization, DISABLED_BalanceHistory) { dispatcher->stop(); }); - auto eventBus = account->synchronize(); + auto eventBus = account->synchronize(); eventBus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); @@ -241,18 +241,18 @@ TEST_F(EthereumLikeWalletSynchronization, XpubSynchronization) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INFO_LIVE); - auto keychain = account->getRestoreKey(); + auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INFO_LIVE); + auto keychain = account->getRestoreKey(); - auto keyStore = account->getRestoreKey(); + auto keyStore = account->getRestoreKey(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { // NOLINT(readability-function-cognitive-complexity) + auto receiver = make_receiver([=](const std::shared_ptr &event) { // NOLINT(readability-function-cognitive-complexity) fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); auto balance = uv::wait(account->getBalance()); cout << " ETH Balance: " << balance->toLong() << endl; @@ -260,9 +260,9 @@ TEST_F(EthereumLikeWalletSynchronization, XpubSynchronization) { auto erc20Accounts = account->getERC20Accounts(); std::shared_ptr erc20Account; for (const auto &item : erc20Accounts) { - if (item->getToken().contractAddress == "0xE41d2489571d322189246DaFA5ebDe1F4699F498") { - erc20Account = item; - continue; + if (item->getToken().contractAddress == "0xE41d2489571d322189246DaFA5ebDe1F4699F498") { + erc20Account = item; + continue; } } EXPECT_GT(erc20Accounts.size(), 0); @@ -306,18 +306,18 @@ TEST_F(EthereumLikeWalletSynchronization, BigInputData) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INPUT_DATA); - auto keychain = account->getRestoreKey(); + auto account = createEthereumLikeAccount(wallet, nextIndex, ETH_KEYS_INPUT_DATA); + auto keychain = account->getRestoreKey(); - auto keyStore = account->getRestoreKey(); + auto keyStore = account->getRestoreKey(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); dispatcher->stop(); }); @@ -348,19 +348,19 @@ TEST_F(EthereumLikeWalletSynchronization, XpubETCSynchronization) { // Test that the cointype we use is the one set by KEYCHAIN_DERIVATION_SCHEME EXPECT_EQ(infos.derivations[0], "44'/60'/0'/0"); - auto account = createEthereumLikeAccount(wallet, infos.index, infos); + auto account = createEthereumLikeAccount(wallet, infos.index, infos); - auto keychain = account->getRestoreKey(); + auto keychain = account->getRestoreKey(); - auto keyStore = account->getRestoreKey(); + auto keyStore = account->getRestoreKey(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); auto balance = uv::wait(account->getBalance()); cout << " ETH Balance: " << balance->toLong() << endl; diff --git a/core/test/integration/synchronization/ripple_synchronization.cpp b/core/test/integration/synchronization/ripple_synchronization.cpp index 0dd674c08c..41f2abde0a 100644 --- a/core/test/integration/synchronization/ripple_synchronization.cpp +++ b/core/test/integration/synchronization/ripple_synchronization.cpp @@ -59,18 +59,18 @@ TEST_F(RippleLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { auto account = createRippleLikeAccount(wallet, nextIndex, XRP_KEYS_INFO); - auto fees = uv::wait(account->getFees()); + auto fees = uv::wait(account->getFees()); EXPECT_GT(fees->toLong(), 0L); auto baseReserve = uv::wait(account->getBaseReserve()); EXPECT_GT(baseReserve->toLong(), 0L); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); auto balance = uv::wait(account->getBalance()); std::cout << "Balance: " << balance->toString() << std::endl; @@ -133,13 +133,13 @@ TEST_F(RippleLikeWalletSynchronization, BalanceHistory) { std::shared_ptr balance; - auto receiver = make_receiver([&](const std::shared_ptr &event) { + auto receiver = make_receiver([&](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); balance = uv::wait(account->getBalance()); std::cout << "Balance: " << balance->toString() << std::endl; @@ -191,7 +191,7 @@ TEST_F(RippleLikeWalletSynchronization, VaultAccountSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); diff --git a/core/test/integration/synchronization/synchronization_P2SH_tests.cpp b/core/test/integration/synchronization/synchronization_P2SH_tests.cpp index b1cdc8d5ae..2cd1560c2f 100644 --- a/core/test/integration/synchronization/synchronization_P2SH_tests.cpp +++ b/core/test/integration/synchronization/synchronization_P2SH_tests.cpp @@ -53,7 +53,7 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, MediumXpubSynchronization) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createBitcoinLikeAccount(wallet, nextIndex, P2SH_XPUB_INFO); + auto account = createBitcoinLikeAccount(wallet, nextIndex, P2SH_XPUB_INFO); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -65,7 +65,7 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, MediumXpubSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); @@ -120,16 +120,16 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, DISABLED_SynchronizeFromLastBlock) auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin_testnet", configuration)); createBitcoinLikeAccount(wallet, 0, P2SH_XPUB_INFO); auto synchronize = [wallet, pool, this](std::shared_ptr context, bool expectNewOp) { - auto account = uv::wait(wallet->getAccount(0)); - auto numberOfOp = 0; + auto account = uv::wait(wallet->getAccount(0)); + auto numberOfOp = 0; auto receiverNumberOp = make_receiver([&numberOfOp](const std::shared_ptr &event) { numberOfOp += 1; }); - auto eventBus = pool->getEventBus(); + auto eventBus = pool->getEventBus(); eventBus->subscribe(context, receiverNumberOp); - auto bus = account->synchronize(); + auto bus = account->synchronize(); auto receiver = make_receiver([=, &numberOfOp](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -168,9 +168,9 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, EraseDataSinceAfterSynchronization) configuration->putString(api::Configuration::KEYCHAIN_DERIVATION_SCHEME, "49'/'/'//
"); // Create wallet - auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin_testnet", configuration)); + auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin_testnet", configuration)); // Create account - auto account = createBitcoinLikeAccount(wallet, 0, P2SH_XPUB_INFO); + auto account = createBitcoinLikeAccount(wallet, 0, P2SH_XPUB_INFO); // Sync account auto bus = account->synchronize(); auto receiver = make_receiver([=](const std::shared_ptr &event) { @@ -193,7 +193,7 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, EraseDataSinceAfterSynchronization) auto formatedDate = DateUtils::fromJSON(date); // Delete account - auto code = uv::wait(wallet->eraseDataSince(formatedDate)); + auto code = uv::wait(wallet->eraseDataSince(formatedDate)); EXPECT_EQ(code, api::ErrorCode::FUTURE_WAS_SUCCESSFULL); // Check if account was successfully deleted @@ -236,7 +236,7 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, TestNetSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); } diff --git a/core/test/integration/synchronization/synchronization_btc_rbf_tests.cpp b/core/test/integration/synchronization/synchronization_btc_rbf_tests.cpp index 787d6fd4ac..db75dad416 100644 --- a/core/test/integration/synchronization/synchronization_btc_rbf_tests.cpp +++ b/core/test/integration/synchronization/synchronization_btc_rbf_tests.cpp @@ -197,15 +197,15 @@ TEST_F(BitcoinLikeWalletBtcRbfSynchronization, DISABLED_SimpleRbfScenario) { Output receive3{3000000, "1DDBzjLyAmDr4qLRC2T2WJ831cxBM5v7G7"}; Output foreign{3000000, "1Bmpme646SNGa1jjjYAfuijdyBNJXLGEh"}; - auto tx1 = mockTransaction("0001", {Input("0000", 0, genesis)}, {receive1}, block1); - auto rbfTx1 = mockTransaction("0002", {Input("1000", 0, send1, 0xFFFFFFFB)}, {receive2}); - auto rbfTx2 = mockTransaction("0003", {Input("1001", 1, send2, 0xFFFFFFFA)}, {receive3}); + auto tx1 = mockTransaction("0001", {Input("0000", 0, genesis)}, {receive1}, block1); + auto rbfTx1 = mockTransaction("0002", {Input("1000", 0, send1, 0xFFFFFFFB)}, {receive2}); + auto rbfTx2 = mockTransaction("0003", {Input("1001", 1, send2, 0xFFFFFFFA)}, {receive3}); auto replaceTx1 = mockTransaction("0004", {Input("1000", 0, send1, 0xFFFFFFFC)}, {receive1}); auto replaceTx2 = mockTransaction("0005", {Input("1001", 1, send2, 0xFFFFFFFB)}, {foreign}); - auto finalTx1 = mockTransaction("0004", {Input("1000", 0, send1, 0xFFFFFFFC)}, {receive1}, block2); - auto finalTx2 = mockTransaction("0003", {Input("1001", 1, send2, 0xFFFFFFFA)}, {receive3}, block2); + auto finalTx1 = mockTransaction("0004", {Input("1000", 0, send1, 0xFFFFFFFC)}, {receive1}, block2); + auto finalTx2 = mockTransaction("0003", {Input("1001", 1, send2, 0xFFFFFFFA)}, {receive3}, block2); ; // Receive a single transaction diff --git a/core/test/integration/synchronization/synchronization_tests.cpp b/core/test/integration/synchronization/synchronization_tests.cpp index 418e465ea0..2cbcdf4774 100644 --- a/core/test/integration/synchronization/synchronization_tests.cpp +++ b/core/test/integration/synchronization/synchronization_tests.cpp @@ -50,7 +50,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumXpubSynchronization) { auto configuration = DynamicObject::newInstance(); configuration->putString(api::PoolConfiguration::DATABASE_NAME, getPostgresUrl()); - auto pool = newDefaultPool("postgres", "", configuration); + auto pool = newDefaultPool("postgres", "", configuration); const auto walletName = randomWalletName(); @@ -66,7 +66,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumXpubSynchronization) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createBitcoinLikeAccount(wallet, nextIndex, P2PKH_MEDIUM_XPUB_INFO); + auto account = createBitcoinLikeAccount(wallet, nextIndex, P2PKH_MEDIUM_XPUB_INFO); bool synchronizationDone = false; auto receiver = make_receiver([=, &synchronizationDone](const std::shared_ptr &event) { @@ -117,7 +117,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumXpubSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); @@ -137,7 +137,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumDGBXpubSynchronization) { auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createBitcoinLikeAccount(wallet, nextIndex, P2WPKH_DGB_MEDIUM_KEYS_INFO); + auto account = createBitcoinLikeAccount(wallet, nextIndex, P2WPKH_DGB_MEDIUM_KEYS_INFO); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -148,7 +148,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumDGBXpubSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); @@ -173,7 +173,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumLTCXpubSynchronization) { {"main"}, {"44'/20'/0'"}, {"Ltub2Yw5wCDWmsrhL78Lh8b1xYGdn2Hgq6nkav54oXHgXKLzdPXno8YoPp4AeNSiQW4XRcxRa7h23k1h7Pw8tLZe5qZGzDMe8xB2s9rRVFuTMtp"}}; - auto account = createBitcoinLikeAccount(wallet, nextIndex, info); + auto account = createBitcoinLikeAccount(wallet, nextIndex, info); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -184,7 +184,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MediumLTCXpubSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); fmt::print("BALANCE: {}\n", uv::wait(account->getBalance())->toString()); @@ -277,17 +277,17 @@ TEST_F(BitcoinLikeWalletSynchronization, DISABLED_SynchronizeFromLastBlock) { auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin", configuration)); createBitcoinLikeAccount(wallet, 0, P2PKH_MEDIUM_XPUB_INFO); auto synchronize = [wallet, pool, this](std::shared_ptr context, bool expectNewOp) { - auto account = uv::wait(wallet->getAccount(0)); - auto numberOfOp = 0; + auto account = uv::wait(wallet->getAccount(0)); + auto numberOfOp = 0; auto receiverNumberOp = make_receiver([&numberOfOp](const std::shared_ptr &event) { numberOfOp += 1; }); - auto eventBus = pool->getEventBus(); + auto eventBus = pool->getEventBus(); eventBus->subscribe(context, receiverNumberOp); - auto bus = account->synchronize(); + auto bus = account->synchronize(); auto receiver = make_receiver([=, &numberOfOp](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -324,7 +324,7 @@ TEST_F(BitcoinLikeWalletSynchronization, TestNetSynchronization) { auto info = uv::wait(wallet->getNextExtendedKeyAccountCreationInfo()); info.extendedKeys.push_back("tpubDCJarhe7f951cUufTWeGKh1w6hDgdBcJfvQgyMczbxWvwvLdryxZuchuNK3KmTKXwBNH6Ze6tHGrUqvKGJd1VvSZUhTVx58DrLn9hR16DVr"); EXPECT_EQ(nextIndex, 0); - auto account = createBitcoinLikeAccount(wallet, nextIndex, info); + auto account = createBitcoinLikeAccount(wallet, nextIndex, info); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -350,7 +350,7 @@ TEST_F(BitcoinLikeWalletSynchronization, TestNetSynchronization) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); } @@ -388,7 +388,7 @@ TEST_F(BitcoinLikeWalletSynchronization, MultipleSynchronization) { } }); - auto bus = accounts[index]->synchronize(); + auto bus = accounts[index]->synchronize(); bus->subscribe(getTestExecutionContext(), localReceiver); if (index == accounts.size() - 1) { dispatcher->waitUntilStopped(); @@ -408,8 +408,8 @@ TEST_F(BitcoinLikeWalletSynchronization, SynchronizationAfterErase) { auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin", api::DynamicObject::newInstance())); - auto nextIndex = uv::wait(wallet->getNextAccountIndex()); - auto info = uv::wait(wallet->getNextExtendedKeyAccountCreationInfo()); + auto nextIndex = uv::wait(wallet->getNextAccountIndex()); + auto info = uv::wait(wallet->getNextExtendedKeyAccountCreationInfo()); info.extendedKeys.push_back(P2PKH_MEDIUM_XPUB_INFO.extendedKeys[0]); auto account = createBitcoinLikeAccount(wallet, nextIndex, info); @@ -439,7 +439,7 @@ TEST_F(BitcoinLikeWalletSynchronization, SynchronizationAfterErase) { context->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(context, localReceiver); context->waitUntilStopped(); @@ -492,12 +492,12 @@ TEST_F(BitcoinLikeWalletSynchronization, GetSelfRecipients) { auto pool = newDefaultPool(); const auto walletName = randomWalletName(); { - auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin", api::DynamicObject::newInstance())); + auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin", api::DynamicObject::newInstance())); auto nextIndex = uv::wait(wallet->getNextAccountIndex()); auto info = uv::wait(wallet->getNextExtendedKeyAccountCreationInfo()); info.extendedKeys.push_back(SELF_RECIPIENT_XPUB_INFO.extendedKeys[0]); - auto account = createBitcoinLikeAccount(wallet, nextIndex, info); + auto account = createBitcoinLikeAccount(wallet, nextIndex, info); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -537,7 +537,7 @@ TEST_F(BitcoinLikeWalletSynchronization, GetSelfRecipients) { dispatcher->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); dispatcher->waitUntilStopped(); } diff --git a/core/test/integration/synchronization/tezos_synchronization.cpp b/core/test/integration/synchronization/tezos_synchronization.cpp index 807fff9cc2..411481d310 100644 --- a/core/test/integration/synchronization/tezos_synchronization.cpp +++ b/core/test/integration/synchronization/tezos_synchronization.cpp @@ -79,15 +79,15 @@ TEST_F(TezosLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { auto account = createTezosLikeAccount(wallet, nextIndex, XTZ_KEYS_INFO); const auto accountAddress = account->getKeychain()->getAddress()->toString(); - auto context = getTestExecutionContext(); + auto context = getTestExecutionContext(); - auto receiver = make_receiver([&](const std::shared_ptr &event) { + auto receiver = make_receiver([&](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; EXPECT_NE(event->getCode(), api::EventCode::SYNCHRONIZATION_FAILED) << event->getPayload()->dump(); EXPECT_EQ(event->getCode(), - api::EventCode::SYNCHRONIZATION_SUCCEED); + api::EventCode::SYNCHRONIZATION_SUCCEED); auto balance = uv::wait(account->getBalance()); EXPECT_GT(balance->toLong(), 0L) << "The account should have a non-zero balance"; @@ -95,8 +95,8 @@ TEST_F(TezosLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { auto originatedAccounts = account->getOriginatedAccounts(); EXPECT_GE(originatedAccounts.size(), 2) << fmt::format("{} should have at least 2 originated accounts. Check {}#contracts to make sure", - accountAddress, - externalExplorerUrl(accountAddress)); + accountAddress, + externalExplorerUrl(accountAddress)); for (auto &origAccount : originatedAccounts) { const auto address = origAccount->getAddress(); @@ -117,7 +117,7 @@ TEST_F(TezosLikeWalletSynchronization, DISABLED_MediumXpubSynchronization) { context->stop(); }); - auto restoreKey = account->getRestoreKey(); + auto restoreKey = account->getRestoreKey(); EXPECT_EQ(restoreKey, hex::toString(XTZ_KEYS_INFO.publicKeys[0])); auto bus = account->synchronize(); bus->subscribe(context, receiver); @@ -196,14 +196,14 @@ TEST_F(TezosLikeWalletSynchronization, NonActivated) { configuration->putString(api::Configuration::BLOCKCHAIN_EXPLORER_ENGINE, api::BlockchainExplorerEngines::TZKT_API); configuration->putString(api::Configuration::BLOCKCHAIN_EXPLORER_API_ENDPOINT, kExplorerUrl); - auto wallet = uv::wait(pool->createWallet("tezos wallet", "tezos", configuration)); + auto wallet = uv::wait(pool->createWallet("tezos wallet", "tezos", configuration)); auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = createTezosLikeAccount(wallet, nextIndex, XTZ_NON_ACTIVATED_KEYS_INFO); + auto account = createTezosLikeAccount(wallet, nextIndex, XTZ_NON_ACTIVATED_KEYS_INFO); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; diff --git a/core/test/integration/transactions/bitcoin_P2PKH_transaction_tests.cpp b/core/test/integration/transactions/bitcoin_P2PKH_transaction_tests.cpp index 16239a2345..50961eb4d5 100644 --- a/core/test/integration/transactions/bitcoin_P2PKH_transaction_tests.cpp +++ b/core/test/integration/transactions/bitcoin_P2PKH_transaction_tests.cpp @@ -202,7 +202,7 @@ TEST_F(BitcoinMakeP2PKHTransaction, Toto) { api::EventCode::SYNCHRONIZATION_SUCCEED_ON_PREVIOUSLY_EMPTY_ACCOUNT); p.success(unit); })); - Unit u = uv::wait(p.getFuture()); + Unit u = uv::wait(p.getFuture()); auto builder = std::dynamic_pointer_cast(bla->buildTransaction(false)); builder->sendToAddress(api::Amount::fromLong(currency, 1000), "ms8C1x7qHa3WJM986NKyx267i2LFGaHRZn"); diff --git a/core/test/integration/transactions/bitcoin_P2WSH_transaction_tests.cpp b/core/test/integration/transactions/bitcoin_P2WSH_transaction_tests.cpp index 741dce0f12..9711f88f1e 100644 --- a/core/test/integration/transactions/bitcoin_P2WSH_transaction_tests.cpp +++ b/core/test/integration/transactions/bitcoin_P2WSH_transaction_tests.cpp @@ -125,8 +125,8 @@ TEST_F(BitcoinMakeTransactionFromLegacyToP2WSH, CreateStandardP2WSHWithOneOutput std::vector tx_bin = generatedTx->serialize(); - auto parsedTx = BitcoinLikeTransactionBuilder::parseRawUnsignedTransaction(wallet->getCurrency(), - tx_bin, 0); + auto parsedTx = BitcoinLikeTransactionBuilder::parseRawUnsignedTransaction(wallet->getCurrency(), + tx_bin, 0); EXPECT_TRUE(verifyTransactionOutputs(parsedTx, output_descrs)); // Values in inputs are missing after parsing. Here we can test only outputs. diff --git a/core/test/integration/transactions/coin_selection_P2PKH.cpp b/core/test/integration/transactions/coin_selection_P2PKH.cpp index 8212736a7e..47b797ca8f 100644 --- a/core/test/integration/transactions/coin_selection_P2PKH.cpp +++ b/core/test/integration/transactions/coin_selection_P2PKH.cpp @@ -70,8 +70,8 @@ TEST_F(CoinSelectionP2PKH, DISABLED_PickOneUTXOWithChange) { builder->pickInputs(api::BitcoinLikePickingStrategy::OPTIMIZE_SIZE, 0xFFFFFFFF, optional()); int64_t fees = 10; builder->setFeesPerByte(api::Amount::fromLong(currency, 10)); - auto f = builder->build(); - auto tx = uv::wait(f); + auto f = builder->build(); + auto tx = uv::wait(f); auto firstInput = tx->getInputs().at(0)->getValue()->toLong(); EXPECT_EQ(tx->getInputs().size(), 1); diff --git a/core/test/integration/transactions/ethereum_transaction_tests.cpp b/core/test/integration/transactions/ethereum_transaction_tests.cpp index 013c690ad9..b11a59a26f 100644 --- a/core/test/integration/transactions/ethereum_transaction_tests.cpp +++ b/core/test/integration/transactions/ethereum_transaction_tests.cpp @@ -83,7 +83,7 @@ TEST_F(EthereumMakeTransaction, CreateStandardWithOneOutput) { auto formatedDate = DateUtils::fromJSON(date); // Delete account - auto code = uv::wait(wallet->eraseDataSince(formatedDate)); + auto code = uv::wait(wallet->eraseDataSince(formatedDate)); EXPECT_EQ(code, api::ErrorCode::FUTURE_WAS_SUCCESSFULL); // Check if account was successfully deleted diff --git a/core/test/integration/transactions/optimisticupdate_xrp_tests.cpp b/core/test/integration/transactions/optimisticupdate_xrp_tests.cpp index 280bfcdbc9..2bfba827f6 100644 --- a/core/test/integration/transactions/optimisticupdate_xrp_tests.cpp +++ b/core/test/integration/transactions/optimisticupdate_xrp_tests.cpp @@ -56,7 +56,7 @@ std::pair, ledger::core::Future> crea TEST_F(RippleLikeOptimisticTransactionUpdate, BroadcastTransaction) { auto fakeHttp = std::make_shared(); - auto pool = newDefaultPool(randomDBName(), "test", api::DynamicObject::newInstance(), fakeHttp); + auto pool = newDefaultPool(randomDBName(), "test", api::DynamicObject::newInstance(), fakeHttp); { auto configuration = DynamicObject::newInstance(); diff --git a/core/test/integration/transactions/ripple_transaction_tests.cpp b/core/test/integration/transactions/ripple_transaction_tests.cpp index cb55619bae..6194176267 100644 --- a/core/test/integration/transactions/ripple_transaction_tests.cpp +++ b/core/test/integration/transactions/ripple_transaction_tests.cpp @@ -52,7 +52,7 @@ struct RippleMakeTransaction : public RippleMakeBaseTransaction { }; TEST_F(RippleMakeTransaction, CreateTx) { - auto builder = tx_builder(); + auto builder = tx_builder(); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -68,7 +68,7 @@ TEST_F(RippleMakeTransaction, CreateTx) { getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -82,8 +82,8 @@ TEST_F(RippleMakeTransaction, CreateTx) { builder->setFees(api::Amount::fromLong(currency, 10)); builder->sendToAddress(api::Amount::fromLong(currency, 220000), "rMspb4Kxa3EwdF4uN5TMqhHfsAkBit6w7k"); - auto f = builder->build(); - auto tx = uv::wait(f); + auto f = builder->build(); + auto tx = uv::wait(f); auto destTag = tx->getDestinationTag(); EXPECT_EQ(destTag.value_or(0), 0); @@ -99,7 +99,7 @@ TEST_F(RippleMakeTransaction, CreateTx) { auto formatedDate = DateUtils::fromJSON(date); // Delete account - auto code = uv::wait(wallet->eraseDataSince(formatedDate)); + auto code = uv::wait(wallet->eraseDataSince(formatedDate)); EXPECT_EQ(code, api::ErrorCode::FUTURE_WAS_SUCCESSFULL); // Check if account was successfully deleted diff --git a/core/test/integration/transactions/tezos_transaction_tests.cpp b/core/test/integration/transactions/tezos_transaction_tests.cpp index 64fbad7cc0..5f8f605391 100644 --- a/core/test/integration/transactions/tezos_transaction_tests.cpp +++ b/core/test/integration/transactions/tezos_transaction_tests.cpp @@ -58,7 +58,7 @@ struct TezosMakeTransaction : public TezosMakeBaseTransaction { }; TEST_F(TezosMakeTransaction, DISABLED_CreateTx) { - auto builder = tx_builder(); + auto builder = tx_builder(); auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); @@ -71,7 +71,7 @@ TEST_F(TezosMakeTransaction, DISABLED_CreateTx) { getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -96,7 +96,7 @@ TEST_F(TezosMakeTransaction, DISABLED_CreateTx) { auto formatedDate = DateUtils::fromJSON(date); // Delete account - auto code = uv::wait(wallet->eraseDataSince(formatedDate)); + auto code = uv::wait(wallet->eraseDataSince(formatedDate)); EXPECT_EQ(code, api::ErrorCode::FUTURE_WAS_SUCCESSFULL); // Check if account was successfully deleted @@ -128,7 +128,7 @@ TEST_F(TezosMakeTransaction, DISABLED_CreateTx) { // auto parsedOriginatedTx = TezosLikeTransactionBuilder::parseRawUnsignedTransaction(wallet->getCurrency(), serializedOriginatedTx); // EXPECT_EQ(serializedOriginatedTx, parsedOriginatedTx->serialize()); // Delete wallet - auto walletCode = uv::wait(pool->eraseDataSince(formatedDate)); + auto walletCode = uv::wait(pool->eraseDataSince(formatedDate)); EXPECT_EQ(walletCode, api::ErrorCode::FUTURE_WAS_SUCCESSFULL); // Check if wallet was successfully deleted diff --git a/core/test/integration/transactions/transaction_test_helper.cpp b/core/test/integration/transactions/transaction_test_helper.cpp index f11ece7dee..cc115472d0 100644 --- a/core/test/integration/transactions/transaction_test_helper.cpp +++ b/core/test/integration/transactions/transaction_test_helper.cpp @@ -131,8 +131,8 @@ void BitcoinMakeBaseTransaction::createAndVerifyTransaction(const std::vector tx_bin = generatedTx->serialize(); - auto parsedTx = BitcoinLikeTransactionBuilder::parseRawUnsignedTransaction(wallet->getCurrency(), - tx_bin, 0); + auto parsedTx = BitcoinLikeTransactionBuilder::parseRawUnsignedTransaction(wallet->getCurrency(), + tx_bin, 0); EXPECT_TRUE(verifyTransactionOutputs(parsedTx, outputs)); // Values in inputs are missing after parsing. Here we can test only outputs. diff --git a/core/test/integration/wallet_database_tests.cpp b/core/test/integration/wallet_database_tests.cpp index 6fa9946a2d..c4872936b9 100644 --- a/core/test/integration/wallet_database_tests.cpp +++ b/core/test/integration/wallet_database_tests.cpp @@ -31,7 +31,7 @@ #include "BaseFixture.h" -static const std::string XPUB_1 = "xpub6EedcbfDs3pkzgqvoRxTW6P8NcCSaVbMQsb6xwCdEBzqZBronwY3Nte1Vjunza8f6eSMrYvbM5CMihGo6SbzpHxn4R5pvcr2ZbZ6wkDmgpy"; +static const std::string XPUB_1 = "xpub6EedcbfDs3pkzgqvoRxTW6P8NcCSaVbMQsb6xwCdEBzqZBronwY3Nte1Vjunza8f6eSMrYvbM5CMihGo6SbzpHxn4R5pvcr2ZbZ6wkDmgpy"; static const std::string SAMPLE_TRANSACTION = "{\"hash\":\"1700a71b4f833cc8f7a774c605a974c4f1e3c144b67ee18ec1bafe4e5d38aa47\",\"received_at\":\"2017-03-07T19:31:11Z\",\"lock_time\":0,\"block\":{\"hash\":\"000000000000000001c6fa7ba025f37f7e58e028b6c10a9c0bc832907e533515\",\"height\":456232,\"time\":\"2017-03-08T00:56:40Z\"},\"inputs\":[{\"input_index\":0,\"output_hash\":\"c423803deff204448535f9fe031aec757c24a509535cc114a86cc8f072977721\",\"output_index\":0,\"value\":2194550,\"address\":\"1Jwxc4n2gVebkxypFaTBSW51r2uREUtuHF\",\"script_signature\":\"47304402201df6c9075747d01c5ac7818843d7d26916212bb2cb63e3d980de65cabd4a96cf02204d8235067ae53c7e57d2fdb4664fd94a584039e1bf387b276c666d65cce842b30121035b108b92a2818149085bee328da06f5ae2c26cfb45b5ccab2dc5addc8761c789\"}],\"outputs\":[{\"output_index\":0,\"value\":2174550,\"address\":\"1HuZgLc5VFnjE4T4hqFURLvTDCUdDHq12S\",\"script_hex\":\"76a914b972ebc512c30746b4d53c58c7ea1e6b91b32e1e88ac\"}],\"fees\":20000,\"amount\":2174550,\"confirmations\":12804}"; static const std::string SAMPLE_TRANSACTION_2 = "{\"hash\":\"9585deb93fd3f769ad9727f31eba00fbc8eebfc96fe7be28e45ab10919ac0c72\",\"received_at\":\"2017-06-05T08:19:03Z\",\"lock_time\":469845,\"block\":{\"hash\":\"00000000000000000185ad65d72e2cd7614b6877344a965db193d4a9e7fa050b\",\"height\":469846,\"time\":\"2017-06-05T08:28:04Z\"},\"inputs\":[{\"input_index\":0,\"output_hash\":\"8608a13077d59639219b8ce65a66a049a75290cf2adcb7e6b2b38c7639124af5\",\"output_index\":1,\"value\":7738800,\"address\":\"1eWDVgQNWv5HATC7FPLbfJMi5ynVrMqsk\",\"script_signature\":\"483045022100bfef6fc0315cc8b5ef3435babcd3d1605d3996beb5b7eddb324b504cbfe3e4800220246cdd6316a7c2ab46253007ca2ce343e1fcba98744cc390eda1f46ab9bd74f9012103576667b83e7ad8af4dd890f3ff646eac4dc1cced9fc9dbcb85f1f6912337e84d\"},{\"input_index\":1,\"output_hash\":\"fa375899d875ba30fc3cc3ca4b5f383c7971a732393a7b6872fd29627cdf89d8\",\"output_index\":1,\"value\":60000000,\"address\":\"1M7sGxht7RUpkvXVY9N8NLWpvTk4aXer5r\",\"script_signature\":\"47304402204913df69cf49efbc2b505bd6056c6cc9057475c2427f032c8763499893754efc022049d3c9746dba096327f90b80932ef61bf90297e7890c526f99cb6e03f67033b9012102484018b108f9c9290fcaa5186eac0b3c24fd3a053aa1886ce8c4382d36617137\"},{\"input_index\":2,\"output_hash\":\"01609f4dec0f530ac40d81d966ff3257e4a504a8be0a3c3ddb8276a79e1da346\",\"output_index\":1,\"value\":316055,\"address\":\"1MWpTHpBUmafHiNnnxkkBgcspA7WMfgDCT\",\"script_signature\":\"473044022027c2843fdba15783fbfad292e9a43457b7032dc3f29b64453b330c2219eff036022075e54b376732e65d1284a0bd0e7c308818bda5198a2c885b736aa4bfb814d43301210384751e50350fb30f9ee91515b9dea0f1d952af13b09c5015186735b40574cc74\"},{\"input_index\":3,\"output_hash\":\"a7c6767fb954113bd48a7dd6b3464edeb44f08bf900c7415e27816a771d05268\",\"output_index\":0,\"value\":10000000,\"address\":\"1EuSDsLFQPjQuBgXUMCVAivBvrWoxPYuRz\",\"script_signature\":\"473044022003c0127b6870089b2a82aae0e30d700042d27b785cee757734ecc3e03b2ccf75022027468e7d2a9cf5968c312f4f2ef2f90bd3649aef372ec9aa5bb2b6c7af92bd1001210265142cc4212bc7cb918a91c3ff09fa6af890742efeee2a2d6b2ba116e6801425\"},{\"input_index\":4,\"output_hash\":\"67ddfc767b80fdac367360015bec16d583b594726d737f68a494bf88a8863193\",\"output_index\":0,\"value\":7920000,\"address\":\"1LrdWPT9ACz4bKApmucLxVtEdGmBjzsw3w\",\"script_signature\":\"483045022100aa7176bb40946fc812392ce87afc0a09682f75baf463652f6037aedb41500fbc02204a769e00d6f347748dafe389d4045970d850d5abeb97a546e3bbe1e1092c222c012103c2319da06f8223ba81044b0b517023b683997b5d6e820e87cd1662733d5011ba\"},{\"input_index\":5,\"output_hash\":\"67cb4ee1d131f83d2a1eaf784f5d63874702a1821b97886829badf9ee3b0101e\",\"output_index\":1,\"value\":10800000,\"address\":\"1N3k6LsSeZnvxJ4hYSnfcgBc6UqaGKgaR9\",\"script_signature\":\"483045022100e8a378d2ab82fbfc440b8400688718de1233752a3eefa833d41c9c352e8545d90220355f670cba768c2448d8dfebed263451aafe704df3908baed742e21f062d61840121030771f16140ea3c4319389a17914a8c929d1a532098fc8e23fe9ff1cba4edf02e\"},{\"input_index\":6,\"output_hash\":\"1a3f259f1db0823495890589b7f9e08d0211136bbeb893d4334ed5ef20a61818\",\"output_index\":1,\"value\":4883698,\"address\":\"163LXLgW3hkFfz8vDViUyPmXBFxT4P36TP\",\"script_signature\":\"4730440220466758c19b7be521889644c52a7201bf0c59fec7dceb5009f4c82b65199f284e02200506cd2d57fbdf61327f75df68c3e5714e7bdb618127987a17c6f2245fffaaea0121020bf202afffd525a11f7961c5f912c10b9cb041f71d0fff9c10a5de302b2c15e6\"},{\"input_index\":7,\"output_hash\":\"bf8cb8f6c1679764a63e943bdf965df0a922338dfb8c3408da957d662a3e7988\",\"output_index\":0,\"value\":5000000,\"address\":\"1FrhU5oWL6yiEu1CEbkXv1CEy6H7bEH6Sd\",\"script_signature\":\"48304502210086f4a79d6a97f23d572a8fafd3cd6ba7ee9331def6cd8623f2fd7b7f7ab4665c0220612a387178fe5d03217a8dff4b42d8b43e88bd4a3e43e10488485347f772e4f80121021106e00e05a7dc9b2e2c19f9b7653e80801d9735e1d6151c7286cf9b58c66b73\"},{\"input_index\":8,\"output_hash\":\"9bd650b03fa02c6a10e9a1f4a6a6efadf72134c7d786f84a8fc81a64573533e2\",\"output_index\":1,\"value\":4000000,\"address\":\"1KHgg8cCL37BATCM2JxjTFEvNsNUUE4kbg\",\"script_signature\":\"483045022100a4876199592533e77552299b94cae313ed099d1d07ccb0e8fc373b0a0e98a93c022071691da7daf8f739b81fb15e5c61690597b3de33c177ffd4d0027aaf698dbece0121029b87e782ff47a0d920edf87269635f5d4abce4e4e8959c40d98ef4d862cdae00\"},{\"input_index\":9,\"output_hash\":\"910feba8b2ccfb3ae6b7ab3cbd011681aca19595ee52844324b9f9c9929d754e\",\"output_index\":0,\"value\":5504231,\"address\":\"1FkZFkezsvtr5r72UCe9znoxxd8p625Eju\",\"script_signature\":\"483045022100b927e5922fe9bc5ba55de2ab9d0c56040e8cb6a6a67ba3fbfb81683eec304bfb02203e191f670dcf335a45269577441f7493a747c70977ccfeda195161d0dcd9cc70012103cda22d07be70defb2cc7bcbfd9af1b295cc0f00cd63aa8c18f6606454e1c11aa\"},{\"input_index\":10,\"output_hash\":\"84ea916b70b68433ed42da753977dd698814afdb9fbdf4105640df01cdd08cd2\",\"output_index\":1,\"value\":7900000,\"address\":\"1DRE89VftrcveVefszd4CSKmz6a9u5FS9Y\",\"script_signature\":\"483045022100eed5679e0e7b964504e37dabb61db1591740a01b686e6fd9ae53e24abd2c34dd022016fce52f8323a4bb09165b7babd32fa0f9fa710047ab869d4cba27b2fec809400121022108792d48c078563ba64078c0215a456051a9757df56b7273ce4a49fe8ea069\"},{\"input_index\":11,\"output_hash\":\"16965e0b01a159ee1cccbea463f59bcf213b2573f12a04bec88c2f260ee0659a\",\"output_index\":0,\"value\":20000000,\"address\":\"1AQQAAMgCatVW61rkswrutxvtJFxfs8MXx\",\"script_signature\":\"47304402201378efafaa58448f04b4710b4e48b078d461c5a1e60733371dab48a0f77e0a70022068d867f5461b0950c384eb6f9852c0a519a1e0210c2c70ea234154915cc18f4a012102db14b3a536a7d3286a6227aa9109a2cd08fbfa091597762562efbfe02e67649c\"},{\"input_index\":12,\"output_hash\":\"0a4aafbca924a640543b6fbbaa4a2297f66d3186860c0451c9293f42f34c2ee7\",\"output_index\":0,\"value\":3000000,\"address\":\"1EknqXyqNK7edoZR5BNHCsKUvn3ENKsqXj\",\"script_signature\":\"47304402202f2c62f9cafb09bbe39471bbdbad0fd5b4422c5a526fd1b6e5363b8d728a60d702206b409673df98e02c1a0acfcd49b0000a17da7ad22c6cf17f0e488308ccfe66cd012102c1be8cc0f32c0681fac38f391fd320b682dc91ad9fb6f8e0fed0d78627a427bf\"},{\"input_index\":13,\"output_hash\":\"6742cca46980523fd2f60b403f9b69922bd7fd57194d9db8b427440b28314382\",\"output_index\":0,\"value\":6201679,\"address\":\"1KgC9idNAPhsMyA2BsLENuQLz26eriuzBK\",\"script_signature\":\"47304402202073bd7a019eead4eb99f17bdc046dc58ed4d34df57aef7e8eb6d70a003c2ce0022032daf0c6a9b1b1b9df37eee0db9484b1e002f1d61cd20ff5363fcd5e00f25e9901210274596701e1218aa71139e6cbde442bc4f6e90d334106d4695e64a4c3ae0dc4ac\"}],\"outputs\":[{\"output_index\":0,\"value\":50000,\"address\":\"114T52xRqSbbAjLE9NcgkpqwakoJx5129\",\"script_hex\":\"76a9140002e1256226bc6154f6f94881b8dfc27362d61288ac\"},{\"output_index\":1,\"value\":95000,\"address\":\"173z8Kpt5ZDqgs1hVt1FGixsDcoFZ4uM1g\",\"script_hex\":\"76a914426145f3979e19d98dc3aafc94764745a809a15188ac\"},{\"output_index\":2,\"value\":9526042,\"address\":\"17NXj3YUK51PqT6TLH18N4MU5MqYuHTWGM\",\"script_hex\":\"76a91445e323439460696c2b864c16ef05484ff166e6da88ac\"},{\"output_index\":3,\"value\":1000016,\"address\":\"1N4YcMQxTj6ZnZnQ8wGXm4ew26kUdTJ5o8\",\"script_hex\":\"76a914e70646905a5bd233991eea9f558281f335e8c8fe88ac\"},{\"output_index\":4,\"value\":162774,\"address\":\"18H7d3CcgLB6BysJ14JxcmvpU7MUhjdjXt\",\"script_hex\":\"76a9144fd51026f5558ffc76825905f774724f0e2cfe3188ac\"},{\"output_index\":5,\"value\":52740000,\"address\":\"18kWw3MruU5kobKmD7mo42jkZNKgRsK9ZK\",\"script_hex\":\"76a9145503c0aa4795facc3aff6f3ff2b84e228a5225c888ac\"},{\"output_index\":6,\"value\":59770000,\"address\":\"1BUtgvRWVRUjqyMe5LhX1YA5baGszZbWaf\",\"script_hex\":\"76a91472f7a2d24cc7bc5fb12e06cf5a8fdf7828e56cfc88ac\"},{\"output_index\":7,\"value\":92000,\"address\":\"1CYMMpZJYjuXf9PWKifSNhgMGXsr9hZcuc\",\"script_hex\":\"76a9147e9745f35f6b3d1694a8d35b8a71dba1c0da825388ac\"},{\"output_index\":8,\"value\":600000,\"address\":\"1DzxtJXPZW23XXMmBBgP9MCieWftJPazDZ\",\"script_hex\":\"76a9148e97de88ce86d081b0afcf86e05bd965d8d4fff888ac\"},{\"output_index\":9,\"value\":112014,\"address\":\"1Gqfdh8JmgCXr6FwwDxybT9rmrzpuzHB2Q\",\"script_hex\":\"76a914adbe1a1012f28f871389b53546989c6b3dabc9ff88ac\"},{\"output_index\":10,\"value\":24789000,\"address\":\"1HhqAgtTMniZHKYVBV7oFru8migSfQPMm\",\"script_hex\":\"76a9140328bd2b83be40a25740b039c6cfd58462813dac88ac\"},{\"output_index\":11,\"value\":141680,\"address\":\"1M7k7mFpyE63P7UcMrrfcZXfEGDdCuFARG\",\"script_hex\":\"76a914dca900dd2a47f3fcda51f6a45a9147f131f823cd88ac\"},{\"output_index\":12,\"value\":500000,\"address\":\"1NHMCMzriXLVctAkhnHM88ZToAUtBQCeCg\",\"script_hex\":\"76a914e97227d10fe29e613f3923d4cb6f8b21915c892188ac\"},{\"output_index\":13,\"value\":63592,\"address\":\"36TLShVi5eBFSetDF5Yj9mgdzEF9NHPzYS\",\"script_hex\":\"a914344243ddc994ab6cfea02caa94ccbcfe0037fcd287\"}],\"fees\":3622345,\"amount\":149642118,\"confirmations\":4}"; @@ -114,7 +114,7 @@ TEST_F(BitcoinWalletDatabaseTests, PutOperations) { auto wallet = uv::wait(pool->createWallet(walletName, "bitcoin", api::DynamicObject::newInstance())); auto nextIndex = uv::wait(wallet->getNextAccountIndex()); EXPECT_EQ(nextIndex, 0); - auto account = std::dynamic_pointer_cast(uv::wait(wallet->newAccountWithExtendedKeyInfo(P2PKH_MEDIUM_XPUB_INFO))); + auto account = std::dynamic_pointer_cast(uv::wait(wallet->newAccountWithExtendedKeyInfo(P2PKH_MEDIUM_XPUB_INFO))); std::vector transactions = { *JSONUtils::parse(TX_1), @@ -140,7 +140,7 @@ TEST_F(BitcoinWalletDatabaseTests, PutOperations) { auto query = account->queryOperations()->complete(); auto queryWithOrders = query->addOrder(api::OperationOrderKey::DATE, false)->addOrder(api::OperationOrderKey::TYPE, false); - auto operations = uv::wait(std::static_pointer_cast(queryWithOrders)->execute()); + auto operations = uv::wait(std::static_pointer_cast(queryWithOrders)->execute()); EXPECT_EQ(operations.size(), 5); auto expectation_0 = std::make_tuple("666613fd82459f94c74211974e74ffcb4a4b96b62980a6ecaee16af7702bbbe5", 15, 1, diff --git a/core/test/math/base58_test.cpp b/core/test/math/base58_test.cpp index 4883f8f2da..5a573a17d1 100644 --- a/core/test/math/base58_test.cpp +++ b/core/test/math/base58_test.cpp @@ -40,17 +40,17 @@ const std::string BitcoinPrivateKeyPrefix = "80"; const std::string BitcoinExtendedPublicKeyPrefix = "0488B21E"; const std::string BitcoinExtendedPrivateKeyPrefix = "0488ADE4"; -std::vector> fixtures = { - {BitcoinPublicKeyHashPrefix, "010966776006953D5567439E5E39F86A0D273BEE", "16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM"}, - {BitcoinPublicKeyHashPrefix, "7b2f2061d66d57ffb9502a091ce236ed4c1ede2d", "1CELa15H4DMzHtHnuz7LCpSFgFWf61Ra6A"}, - {BitcoinPublicKeyHashPrefix, "89C907892A9D4F37B78D5F83F2FD6E008C4F795D", "1DZYQ3xEy8mkc7wToQZvKqeLrSLUMVVK41"}, - {BitcoinPublicKeyHashPrefix, "0000000000000000000000000000000000000000", "1111111111111111111114oLvT2"}, - {BitcoinPublicKeyHashPrefix, "0000000000000000000000000000000000000001", "11111111111111111111BZbvjr"}, - {BitcoinPrivateKeyPrefix, "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D", "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ"}, - {BitcoinPrivateKeyPrefix, "00000037FC2B523A9101D653ECB504EBB88FCCE6F7E77548A7B31FA734A00000", "5HpHagjigF1P3i1WyFp1uLPEo8gK32CFBRc2ekJU3nytmXnVbYv"}, - {BitcoinPrivateKeyPrefix, "3C80FA4C012E37402C6D43140EC7B111B931C33799C2A07E8172827B12EEA59F", "5JGw52y3UuZSwpZKYkuhmat8TNy1nZ6F6mbrHJaPNMt2pkETUVE"}, - {BitcoinExtendedPublicKeyPrefix, "000000000000000000873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d5080339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2", "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"}, - {BitcoinExtendedPrivateKeyPrefix, "0478412e3afffffffe637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e2900f1c7c871a54a804afe328b4c83a1c33b8e5ff48f5087273f04efa83b247d6a2d", "xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc"}, +std::vector> fixtures = { + {BitcoinPublicKeyHashPrefix, "010966776006953D5567439E5E39F86A0D273BEE", "16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM"}, + {BitcoinPublicKeyHashPrefix, "7b2f2061d66d57ffb9502a091ce236ed4c1ede2d", "1CELa15H4DMzHtHnuz7LCpSFgFWf61Ra6A"}, + {BitcoinPublicKeyHashPrefix, "89C907892A9D4F37B78D5F83F2FD6E008C4F795D", "1DZYQ3xEy8mkc7wToQZvKqeLrSLUMVVK41"}, + {BitcoinPublicKeyHashPrefix, "0000000000000000000000000000000000000000", "1111111111111111111114oLvT2"}, + {BitcoinPublicKeyHashPrefix, "0000000000000000000000000000000000000001", "11111111111111111111BZbvjr"}, + {BitcoinPrivateKeyPrefix, "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D", "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ"}, + {BitcoinPrivateKeyPrefix, "00000037FC2B523A9101D653ECB504EBB88FCCE6F7E77548A7B31FA734A00000", "5HpHagjigF1P3i1WyFp1uLPEo8gK32CFBRc2ekJU3nytmXnVbYv"}, + {BitcoinPrivateKeyPrefix, "3C80FA4C012E37402C6D43140EC7B111B931C33799C2A07E8172827B12EEA59F", "5JGw52y3UuZSwpZKYkuhmat8TNy1nZ6F6mbrHJaPNMt2pkETUVE"}, + {BitcoinExtendedPublicKeyPrefix, "000000000000000000873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d5080339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2", "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"}, + {BitcoinExtendedPrivateKeyPrefix, "0478412e3afffffffe637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e2900f1c7c871a54a804afe328b4c83a1c33b8e5ff48f5087273f04efa83b247d6a2d", "xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc"}, }; TEST(Base58, Encode) { diff --git a/core/test/tezos/ED25519_transaction_test.cpp b/core/test/tezos/ED25519_transaction_test.cpp index 2af66caab8..908eb200fb 100644 --- a/core/test/tezos/ED25519_transaction_test.cpp +++ b/core/test/tezos/ED25519_transaction_test.cpp @@ -85,8 +85,8 @@ Out[53]: '6e766ee0733ef0fb6385f2034cfbd437247afad4b301ebce1b929a67ce4a0b8d6c0090 const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -95,7 +95,7 @@ Out[53]: '6e766ee0733ef0fb6385f2034cfbd437247afad4b301ebce1b929a67ce4a0b8d6c0090 EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -149,8 +149,8 @@ Out[26]: 'ade89a7e5460a33ebabcab7cb7b6589cd7e48b512ebdc57e0acfc439934b04096b0090 */ const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -159,7 +159,7 @@ Out[26]: 'ade89a7e5460a33ebabcab7cb7b6589cd7e48b512ebdc57e0acfc439934b04096b0090 EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -237,8 +237,8 @@ TEST_F(ED25519TezosMakeTransaction, CreateDelegation) { const std::string DESTINATION = "tz1aRoaRhSpRYvFdyvgWLL6TGyRoGF51wDjM"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -247,7 +247,7 @@ TEST_F(ED25519TezosMakeTransaction, CreateDelegation) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); diff --git a/core/test/tezos/P256_transaction_test.cpp b/core/test/tezos/P256_transaction_test.cpp index df52a87f1f..8af8b24b64 100644 --- a/core/test/tezos/P256_transaction_test.cpp +++ b/core/test/tezos/P256_transaction_test.cpp @@ -80,8 +80,8 @@ Out[49]: 'fc90925a9641634831c1e7a5552270c4f7f954a974ec2596ac1fe3bfc14fc7cd6c02a9 */ const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -90,7 +90,7 @@ Out[49]: 'fc90925a9641634831c1e7a5552270c4f7f954a974ec2596ac1fe3bfc14fc7cd6c02a9 EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -136,8 +136,8 @@ Out[43]: '087bab85bf59327fe9c882c1346e47b7be4ed73c5afe229713ad8341131ed3eb6b02a9 */ const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -146,7 +146,7 @@ Out[43]: '087bab85bf59327fe9c882c1346e47b7be4ed73c5afe229713ad8341131ed3eb6b02a9 EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -224,8 +224,8 @@ TEST_F(P256TezosMakeTransaction, CreateDelegation) { const std::string DESTINATION = "tz1aRoaRhSpRYvFdyvgWLL6TGyRoGF51wDjM"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -234,7 +234,7 @@ TEST_F(P256TezosMakeTransaction, CreateDelegation) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); diff --git a/core/test/tezos/SECP256K1_transaction_test.cpp b/core/test/tezos/SECP256K1_transaction_test.cpp index 8962e2d9ea..493d697089 100644 --- a/core/test/tezos/SECP256K1_transaction_test.cpp +++ b/core/test/tezos/SECP256K1_transaction_test.cpp @@ -82,8 +82,8 @@ binary payload const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -92,7 +92,7 @@ binary payload EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -142,8 +142,8 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateTxWithReveal) { */ const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -152,7 +152,7 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateTxWithReveal) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -279,7 +279,7 @@ TEST_F(SECP256K1TezosMakeTransaction, incrementOptimisticCounter) { builder->setGasLimit(api::Amount::fromLong(currency, 10407)); builder->setStorageLimit(std::make_shared(BigInt::fromString("0"))); builder->sendToAddress(api::Amount::fromLong(currency, 5000), DESTINATION); - auto f = builder->build(); + auto f = builder->build(); auto tx = std::dynamic_pointer_cast(uv::wait(f)); auto explorerCounter = std::make_shared(tx->getCounter()->toString(10)); @@ -350,8 +350,8 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateDelegation) { const std::string DESTINATION = "tz1aRoaRhSpRYvFdyvgWLL6TGyRoGF51wDjM"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -360,7 +360,7 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateDelegation) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -402,8 +402,8 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateUndelegation) { const std::string DESTINATION = "tz1aRoaRhSpRYvFdyvgWLL6TGyRoGF51wDjM"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -412,7 +412,7 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateUndelegation) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); @@ -511,8 +511,8 @@ TEST_F(SECP256K1TezosMakeTransaction, ParseUnsignedRawDelegationWithReveal) { TEST_F(SECP256K1TezosMakeTransaction, CreateTxAutoFill) { const std::string DESTINATION = "tz2B7ibGZBtVFLvRYBfe4Q9uw7SRE62MKZCD"; - auto builder = tx_builder(); - auto receiver = make_receiver([=](const std::shared_ptr &event) { + auto builder = tx_builder(); + auto receiver = make_receiver([=](const std::shared_ptr &event) { fmt::print("Received event {}\n", api::to_string(event->getCode())); if (event->getCode() == api::EventCode::SYNCHRONIZATION_STARTED) return; @@ -521,15 +521,15 @@ TEST_F(SECP256K1TezosMakeTransaction, CreateTxAutoFill) { EXPECT_EQ(event->getCode(), api::EventCode::SYNCHRONIZATION_SUCCEED); getTestExecutionContext()->stop(); }); - auto bus = account->synchronize(); + auto bus = account->synchronize(); bus->subscribe(getTestExecutionContext(), receiver); getTestExecutionContext()->waitUntilStopped(); builder->setFees(api::Amount::fromLong(currency, 0)); builder->setGasLimit(api::Amount::fromLong(currency, 0)); builder->setStorageLimit(std::make_shared(BigInt::fromString("0"))); builder->wipeToAddress(DESTINATION); - auto f = builder->build(); - auto tx = std::dynamic_pointer_cast(uv::wait(f)); + auto f = builder->build(); + auto tx = std::dynamic_pointer_cast(uv::wait(f)); // tx->reveal(true); auto binaryPayload = tx->serialize(); std::cout << "TezosMakeTransaction.CreateTx - serialized tx: " << hex::toString(binaryPayload) << std::endl; diff --git a/core/test/tezos/address_test.cpp b/core/test/tezos/address_test.cpp index 2fc38f7483..8eca86b03d 100644 --- a/core/test/tezos/address_test.cpp +++ b/core/test/tezos/address_test.cpp @@ -88,7 +88,7 @@ TEST_P(AddressTest, AddressValidation) { auto currency = currencies::TEZOS; // Test valid adresses - auto address = KEY_ED25519.address; + auto address = KEY_ED25519.address; EXPECT_EQ(api::Address::isValid(address, currency), true); address = KEY_SECP256K1.address; EXPECT_EQ(api::Address::isValid(address, currency), true);