|
16 | 16 | #include "token/params/UnpauseTokenParams.h" |
17 | 17 | #include "token/params/UpdateTokenFeeScheduleParams.h" |
18 | 18 | #include "token/params/UpdateTokenParams.h" |
| 19 | +#include "token/params/WipeTokenParams.h" |
19 | 20 | #include "json/JsonErrorType.h" |
20 | 21 | #include "json/JsonRpcException.h" |
21 | 22 |
|
|
38 | 39 | #include <TokenUnfreezeTransaction.h> |
39 | 40 | #include <TokenUnpauseTransaction.h> |
40 | 41 | #include <TokenUpdateTransaction.h> |
| 42 | +#include <TokenWipeTransaction.h> |
41 | 43 | #include <TransactionReceipt.h> |
42 | 44 | #include <TransactionResponse.h> |
43 | 45 | #include <impl/EntityIdHelper.h> |
44 | 46 | #include <impl/HexConverter.h> |
45 | 47 | #include <impl/Utilities.h> |
46 | 48 |
|
| 49 | +#include <algorithm> |
47 | 50 | #include <chrono> |
48 | 51 | #include <cstdint> |
49 | 52 | #include <nlohmann/json.hpp> |
@@ -677,4 +680,47 @@ nlohmann::json updateToken(const UpdateTokenParams& params) |
677 | 680 | }; |
678 | 681 | } |
679 | 682 |
|
| 683 | +//----- |
| 684 | +nlohmann::json wipeToken(const WipeTokenParams& params) |
| 685 | +{ |
| 686 | + TokenWipeTransaction tokenWipeTransaction; |
| 687 | + tokenWipeTransaction.setGrpcDeadline(SdkClient::DEFAULT_TCK_REQUEST_TIMEOUT); |
| 688 | + |
| 689 | + if (params.mTokenId.has_value()) |
| 690 | + { |
| 691 | + tokenWipeTransaction.setTokenId(TokenId::fromString(params.mTokenId.value())); |
| 692 | + } |
| 693 | + |
| 694 | + if (params.mAccountId.has_value()) |
| 695 | + { |
| 696 | + tokenWipeTransaction.setAccountId(AccountId::fromString(params.mAccountId.value())); |
| 697 | + } |
| 698 | + |
| 699 | + if (params.mAmount.has_value()) |
| 700 | + { |
| 701 | + tokenWipeTransaction.setAmount(Hiero::internal::EntityIdHelper::getNum(params.mAmount.value())); |
| 702 | + } |
| 703 | + |
| 704 | + if (params.mSerialNumbers.has_value()) |
| 705 | + { |
| 706 | + std::vector<uint64_t> serialNumbers; |
| 707 | + for (const std::string& serialNumber : params.mSerialNumbers.value()) |
| 708 | + { |
| 709 | + serialNumbers.push_back(internal::EntityIdHelper::getNum(serialNumber)); |
| 710 | + } |
| 711 | + tokenWipeTransaction.setSerialNumbers(serialNumbers); |
| 712 | + } |
| 713 | + |
| 714 | + if (params.mCommonTxParams.has_value()) |
| 715 | + { |
| 716 | + params.mCommonTxParams->fillOutTransaction(tokenWipeTransaction, SdkClient::getClient()); |
| 717 | + } |
| 718 | + |
| 719 | + return { |
| 720 | + {"status", |
| 721 | + gStatusToString.at( |
| 722 | + tokenWipeTransaction.execute(SdkClient::getClient()).getReceipt(SdkClient::getClient()).mStatus)} |
| 723 | + }; |
| 724 | +} |
| 725 | + |
680 | 726 | } // namespace Hiero::TCK::TokenService |
0 commit comments