Skip to content

Commit

Permalink
refactor: make associate use hiero names
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Walworth <[email protected]>
  • Loading branch information
rwalworth committed Nov 22, 2024
1 parent 06e4f7e commit ef89605
Show file tree
Hide file tree
Showing 16 changed files with 1,210 additions and 1,227 deletions.
2 changes: 1 addition & 1 deletion src/sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ option(BUILD_EXAMPLES "Build the example builds" OFF)

if(BUILD_EXAMPLES)
message(STATUS "Including examples in the build.")
add_subdirectory(tests)
add_subdirectory(examples)
else()
message(STATUS "Examples are not included in the build.")
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/examples/ConstructClientExample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ int main(int argc, char** argv)

// Create a Client with a custom network.
const std::unordered_map<std::string, AccountId> network = {
{ "2.testnet.hedera.com:50211", AccountId(5ULL) },
{ "3.testnet.hedera.com:50211", AccountId(6ULL) }
{"2.testnet.hedera.com:50211", AccountId(5ULL)},
{ "3.testnet.hedera.com:50211", AccountId(6ULL)}
};
Client customClient = Client::forNetwork(network);

Expand Down
8 changes: 4 additions & 4 deletions src/sdk/main/include/FeeAssessmentMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ enum class FeeAssessmentMethod
* Map of FeeAssessmentMethod to its corresponding string.
*/
const std::unordered_map<FeeAssessmentMethod, std::string> gFeeAssessmentMethodToString = {
{ FeeAssessmentMethod::INCLUSIVE, "INCLUSIVE" },
{ FeeAssessmentMethod::EXCLUSIVE, "EXCLUSIVE" }
{FeeAssessmentMethod::INCLUSIVE, "INCLUSIVE"},
{ FeeAssessmentMethod::EXCLUSIVE, "EXCLUSIVE"}
};

/**
* Map of FeeAssessmentMethod string representation to its corresponding enum value.
*/
[[maybe_unused]] const std::unordered_map<std::string, FeeAssessmentMethod> gStringToFeeAssessmentMethod = {
{ "INCLUSIVE", FeeAssessmentMethod::INCLUSIVE },
{ "EXCLUSIVE", FeeAssessmentMethod::EXCLUSIVE }
{"INCLUSIVE", FeeAssessmentMethod::INCLUSIVE},
{ "EXCLUSIVE", FeeAssessmentMethod::EXCLUSIVE}
};

} // namespace Hiero
Expand Down
7 changes: 4 additions & 3 deletions src/sdk/main/include/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,10 @@ class Transaction
*/
[[nodiscard]]
typename Executable<SdkRequestType, proto::Transaction, proto::TransactionResponse, TransactionResponse>::
ExecutionStatus determineStatus(Status status,
const Client& client,
[[maybe_unused]] const proto::TransactionResponse& response) override;
ExecutionStatus
determineStatus(Status status,
const Client& client,
[[maybe_unused]] const proto::TransactionResponse& response) override;

/**
* Derived from Executable. Perform any needed actions for this Transaction when it is being submitted.
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/main/src/ContractFunctionParameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const std::vector<std::byte> NEGATIVE_PADDING(31, std::byte(0xFF));
{
const std::vector<std::byte>& padding = negative ? NEGATIVE_PADDING : POSITIVE_PADDING;
return internal::Utilities::concatenateVectors({
{ padding.cbegin(), padding.cbegin() + getPaddingAmount(bytes) },
{padding.cbegin(), padding.cbegin() + getPaddingAmount(bytes)},
bytes
});
}
Expand All @@ -63,7 +63,7 @@ const std::vector<std::byte> NEGATIVE_PADDING(31, std::byte(0xFF));
[[nodiscard]] std::vector<std::byte> rightPad(const std::vector<std::byte>& bytes, bool = false)
{
return internal::Utilities::concatenateVectors({
bytes, { POSITIVE_PADDING.cbegin(), POSITIVE_PADDING.cbegin() + getPaddingAmount(bytes) }
bytes, {POSITIVE_PADDING.cbegin(), POSITIVE_PADDING.cbegin() + getPaddingAmount(bytes)}
});
}

Expand Down
444 changes: 222 additions & 222 deletions src/sdk/main/src/RequestType.cc

Large diffs are not rendered by default.

1,878 changes: 939 additions & 939 deletions src/sdk/main/src/Status.cc

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/sdk/main/src/TokenType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ namespace Hiero
{
//-----
const std::unordered_map<proto::TokenType, TokenType> gProtobufTokenTypeToTokenType = {
{ proto::TokenType::FUNGIBLE_COMMON, TokenType::FUNGIBLE_COMMON },
{ proto::TokenType::NON_FUNGIBLE_UNIQUE, TokenType::NON_FUNGIBLE_UNIQUE }
{proto::TokenType::FUNGIBLE_COMMON, TokenType::FUNGIBLE_COMMON },
{ proto::TokenType::NON_FUNGIBLE_UNIQUE, TokenType::NON_FUNGIBLE_UNIQUE}
};

//-----
const std::unordered_map<TokenType, proto::TokenType> gTokenTypeToProtobufTokenType = {
{ TokenType::FUNGIBLE_COMMON, proto::TokenType::FUNGIBLE_COMMON },
{ TokenType::NON_FUNGIBLE_UNIQUE, proto::TokenType::NON_FUNGIBLE_UNIQUE }
{TokenType::FUNGIBLE_COMMON, proto::TokenType::FUNGIBLE_COMMON },
{ TokenType::NON_FUNGIBLE_UNIQUE, proto::TokenType::NON_FUNGIBLE_UNIQUE}
};

//-----
const std::unordered_map<TokenType, const char*> gTokenTypeToString = {
{ TokenType::FUNGIBLE_COMMON, "FUNGIBLE_COMMON" },
{ TokenType::NON_FUNGIBLE_UNIQUE, "NON_FUNGIBLE_UNIQUE" }
{TokenType::FUNGIBLE_COMMON, "FUNGIBLE_COMMON" },
{ TokenType::NON_FUNGIBLE_UNIQUE, "NON_FUNGIBLE_UNIQUE"}
};

} // namespace Hiero
2 changes: 1 addition & 1 deletion src/sdk/main/src/impl/ASN1ECPublicKey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void ASN1ECPublicKey::populateXYcoords()
BN_hex2bn(&yCoordBN, internal::HexConverter::bytesToHex(ecYcoord).c_str());
// if y even pad 0x02 byte else 0x03
ecXcoord = internal::Utilities::concatenateVectors({
// get x coordinate
// get x coordinate
{ std::byte(0x00) },
{ !BN_is_bit_set(yCoordBN, 0) ? std::byte(0x02) : std::byte(0x03) },
{ publicKey.begin() + 2, publicKey.end() - EC_KEY_LENGTH }
Expand Down
14 changes: 7 additions & 7 deletions src/sdk/tests/unit/ECDSAsecp256k1PrivateKeyUnitTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,24 @@ class ECDSAsecp256k1PrivateKeyUnitTests : public ::testing::Test
"302e0201010420a6170a6aa6389a5bd3a3a8f9375f57bd91aa7f7d8b8b46ce0b702e000a21a5fea00706052b8104000a";

const std::unordered_map<std::string_view, std::pair<std::string_view, std::string_view>> expectedPrivateKeyPairs{
{ unencryptedUncompressedPEMPrivateKey,
{unencryptedUncompressedPEMPrivateKey,
{ "6F08FA32A2FA21956BBB6D6DF9E59CC2F901DBCFBA06E00569EC7988EB95EEAA",
"02A9FE4198C781CE453545AF5401B649A37B72B553A56FB7AB4DCDFA2D12CFDB49" } },
"02A9FE4198C781CE453545AF5401B649A37B72B553A56FB7AB4DCDFA2D12CFDB49" }},
{ unencryptedCompressedPEMPrivateKey,
{ "E1F285C9701DB85ADDFDBCD4ABDDF3CE2B841CE5B71189C4267269009A807F63",
"02444AFA80565AE0AEE104FF9B036E5576043ED0004580CFA0E51630FD6E93D4E8" } },
"02444AFA80565AE0AEE104FF9B036E5576043ED0004580CFA0E51630FD6E93D4E8" }},
{ legacyDERPrivateKey,
{ "8C2CDC9575FE67493443967D74958FD7808A3787FD3337E99CFEEBBC7566B586",
"028173079D2E996EF6B2D064FC82D5FC7094367211E28422BEC50A2F75C365F5FD" } },
"028173079D2E996EF6B2D064FC82D5FC7094367211E28422BEC50A2F75C365F5FD" }},
{ openSSLCompatibleCompressedDERPrivateKey,
{ "AC318EA8FF8D991AB2F16172B4738E74DC35A56681199CFB1C0CB2E7CB560FFD",
"036843F5CB338BBB4CDB21B0DA4EA739D910951D6E8A5F703D313EFE31AFE788F4" } },
"036843F5CB338BBB4CDB21B0DA4EA739D910951D6E8A5F703D313EFE31AFE788F4" }},
{ openSSLCompatibleUncompressedDERPrivateKey,
{ "8927647AD12B29646A1D051DA8453462937BB2C813C6815CAC6C0B720526FFC6",
"03AAAC1C3AC1BEA0245B8E00CE1E2018F9EAB61B6331FBEF7266F2287750A65977" } },
"03AAAC1C3AC1BEA0245B8E00CE1E2018F9EAB61B6331FBEF7266F2287750A65977" }},
{ openSSLCompatibleDERPrivateKeyWithoutPublicKey,
{ "A6170A6AA6389A5BD3A3A8F9375F57BD91AA7F7D8B8B46CE0B702E000A21A5FE",
"03B69A75A5DDB1C0747E995D47555019E5D8A28003AB5202BD92F534361FB4EC8A" } }
"03B69A75A5DDB1C0747E995D47555019E5D8A28003AB5202BD92F534361FB4EC8A" }}
};
};

Expand Down
6 changes: 3 additions & 3 deletions src/sdk/tests/unit/ED25519PrivateKeyUnitTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class ED25519PrivateKeyUnitTests : public ::testing::Test
"KEY-----";

const std::unordered_map<std::string_view, std::pair<std::string_view, std::string_view>> expectedPrivateKeyPairs{
{ openSSLCompatiblePrivateKey,
{openSSLCompatiblePrivateKey,
{ "FEB858A4A69600A5EEF2D9C76F7FB84FC0B6627F29E0AB17E160F640C267D404",
"8CCD31B53D1835B467AAC795DAB19B274DD3B37E3DAF12FCEC6BC02BAC87B53D" } },
"8CCD31B53D1835B467AAC795DAB19B274DD3B37E3DAF12FCEC6BC02BAC87B53D" }},
{ unencryptedPemPrivateKey,
{ "E81B8DA1E012A17B3D8D2DD9D51FD95534BB5311A0A8A2FDFCB00E5CDEE25BE5",
"F7B9AA4A8E4EEE94E4277DFE757D8D7CDE027E7CD5349B7D8E6EE21C9B9395BE" } },
"F7B9AA4A8E4EEE94E4277DFE757D8D7CDE027E7CD5349B7D8E6EE21C9B9395BE" }},
};
};

Expand Down
4 changes: 2 additions & 2 deletions src/sdk/tests/unit/NetworkUnitTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ TEST_F(NetworkUnitTests, ConstructCustomNetwork)
{
// Given
const std::unordered_map<std::string, AccountId> testNetwork = {
{ "2.testnet.hedera.com:50211", AccountId(5ULL) },
{ "3.testnet.hedera.com:50211", AccountId(6ULL) }
{"2.testnet.hedera.com:50211", AccountId(5ULL)},
{ "3.testnet.hedera.com:50211", AccountId(6ULL)}
};

// When
Expand Down
6 changes: 3 additions & 3 deletions src/sdk/tests/unit/TokenMintTransactionUnitTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class TokenMintTransactionUnitTests : public ::testing::Test
const TokenId mTestTokenId = TokenId(1ULL, 2ULL, 3ULL);
const uint64_t mTestAmount = 4ULL;
const std::vector<std::vector<std::byte>> mTestMetadataList = {
{ std::byte(0x05), std::byte(0x06), std::byte(0x07) },
{ std::byte(0x08), std::byte(0x09), std::byte(0x0A) },
{ std::byte(0x0B), std::byte(0x0C), std::byte(0x0D) }
{std::byte(0x05), std::byte(0x06), std::byte(0x07)},
{ std::byte(0x08), std::byte(0x09), std::byte(0x0A)},
{ std::byte(0x0B), std::byte(0x0C), std::byte(0x0D)}
};
};

Expand Down
34 changes: 8 additions & 26 deletions src/tck/include/token/params/AssociateTokenParams.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera C++ SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// SPDX-License-Identifier: Apache-2.0
#ifndef HIERO_TCK_CPP_ASSOCIATE_TOKEN_PARAMS_H_
#define HIERO_TCK_CPP_ASSOCIATE_TOKEN_PARAMS_H_

Expand All @@ -28,7 +10,7 @@
#include <string>
#include <vector>

namespace Hedera::TCK::TokenService
namespace Hiero::TCK::TokenService
{
/**
* Struct to hold the arguments for an `associateToken` JSON-RPC method call.
Expand All @@ -51,28 +33,28 @@ struct AssociateTokenParams
std::optional<CommonTransactionParams> mCommonTxParams;
};

} // namespace Hedera::TCK::TokenService
} // namespace Hiero::TCK::TokenService

namespace nlohmann
{
/**
* JSON serializer template specialization required to convert AssociateTokenParams arguments properly.
*/
template<>
struct [[maybe_unused]] adl_serializer<Hedera::TCK::TokenService::AssociateTokenParams>
struct [[maybe_unused]] adl_serializer<Hiero::TCK::TokenService::AssociateTokenParams>
{
/**
* Convert a JSON object to a AssociateTokenParams.
*
* @param jsonFrom The JSON object with which to fill the AssociateTokenParams.
* @param params The AssociateTokenParams to fill with the JSON object.
*/
static void from_json(const json& jsonFrom, Hedera::TCK::TokenService::AssociateTokenParams& params)
static void from_json(const json& jsonFrom, Hiero::TCK::TokenService::AssociateTokenParams& params)
{
params.mAccountId = Hedera::TCK::getOptionalJsonParameter<std::string>(jsonFrom, "accountId");
params.mTokenIds = Hedera::TCK::getOptionalJsonParameter<std::vector<std::string>>(jsonFrom, "tokenIds");
params.mAccountId = Hiero::TCK::getOptionalJsonParameter<std::string>(jsonFrom, "accountId");
params.mTokenIds = Hiero::TCK::getOptionalJsonParameter<std::vector<std::string>>(jsonFrom, "tokenIds");
params.mCommonTxParams =
Hedera::TCK::getOptionalJsonParameter<Hedera::TCK::CommonTransactionParams>(jsonFrom, "commonTransactionParams");
Hiero::TCK::getOptionalJsonParameter<Hiero::TCK::CommonTransactionParams>(jsonFrom, "commonTransactionParams");
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/tck/src/sdk/SdkClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ nlohmann::json reset(const ResetParams&)
{
mClient.close();
return {
{ "status", "SUCCESS" }
{"status", "SUCCESS"}
};
}

Expand All @@ -36,7 +36,7 @@ nlohmann::json setup(const SetupParams& params)
if (params.nodeIp.has_value() && params.nodeAccountId.has_value() && params.mirrorNetworkIp.has_value())
{
mClient = Client::forNetwork({
{ params.nodeIp.value(), AccountId::fromString(params.nodeAccountId.value()) }
{params.nodeIp.value(), AccountId::fromString(params.nodeAccountId.value())}
});
mClient.setMirrorNetwork({ params.mirrorNetworkIp.value() });
clientType = "custom";
Expand All @@ -52,8 +52,8 @@ nlohmann::json setup(const SetupParams& params)
mClient.setRequestTimeout(DEFAULT_TCK_REQUEST_TIMEOUT);

return {
{ "message", "Successfully setup " + clientType + " client." },
{ "status", "SUCCESS" }
{"message", "Successfully setup " + clientType + " client."},
{ "status", "SUCCESS" }
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/tck/src/token/TokenService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ nlohmann::json createToken(const CreateTokenParams& params)
const TransactionReceipt txReceipt =
tokenCreateTransaction.execute(SdkClient::getClient()).getReceipt(SdkClient::getClient());
return {
{ "tokenId", txReceipt.mTokenId->toString() },
{ "status", gStatusToString.at(txReceipt.mStatus) }
{"tokenId", txReceipt.mTokenId->toString() },
{ "status", gStatusToString.at(txReceipt.mStatus)}
};
}

Expand Down

0 comments on commit ef89605

Please sign in to comment.