|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +from hiero_sdk_python import TokenWipeTransaction |
5 | 6 | from hiero_sdk_python.account.account_id import AccountId |
6 | 7 | from hiero_sdk_python.Duration import Duration |
7 | 8 | from hiero_sdk_python.hbar import Hbar |
|
43 | 44 | GetTokenInfoParams, |
44 | 45 | MintTokenParams, |
45 | 46 | PauseTokenParams, |
| 47 | + WipeTokenParams, |
46 | 48 | ) |
47 | 49 | from tck.response.token import ( |
48 | 50 | AirdropTokenResponse, |
|
55 | 57 | GetTokenInfoResponse, |
56 | 58 | MintTokenResponse, |
57 | 59 | PauseTokenResponse, |
| 60 | + WipeTokenResponse, |
58 | 61 | ) |
59 | 62 | from tck.util.client_utils import get_client |
60 | 63 | from tck.util.constants import DEFAULT_GRPC_TIMEOUT |
@@ -641,3 +644,42 @@ def get_token_info(params: GetTokenInfoParams) -> GetTokenInfoResponse: |
641 | 644 |
|
642 | 645 | info = query.execute(client) |
643 | 646 | return _build_token_info_response(info) |
| 647 | + |
| 648 | + |
| 649 | +def _build_wipe_token_transaction(params: WipeTokenParams) -> TokenWipeTransaction: |
| 650 | + """Build a TokenWipeTransaction from TCK params.""" |
| 651 | + |
| 652 | + transaction = TokenWipeTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
| 653 | + |
| 654 | + if params.tokenId is not None: |
| 655 | + transaction.set_token_id(TokenId.from_string(params.tokenId)) |
| 656 | + |
| 657 | + if params.accountId is not None: |
| 658 | + transaction.set_account_id(AccountId.from_string(params.accountId)) |
| 659 | + |
| 660 | + if params.amount is not None: |
| 661 | + transaction.set_amount(to_int(params.amount)) |
| 662 | + |
| 663 | + if params.serialNumbers is not None: |
| 664 | + serialNumberList = [int(serial_number) for serial_number in params.serialNumbers] |
| 665 | + |
| 666 | + transaction.set_serial(serialNumberList) |
| 667 | + |
| 668 | + return transaction |
| 669 | + |
| 670 | + |
| 671 | +@rpc_method("wipeToken") |
| 672 | +def wipe_token(params: WipeTokenParams) -> WipeTokenResponse: |
| 673 | + """Wipes the provided amount of fungible or non-fungible tokens from the specified Hedera account""" |
| 674 | + |
| 675 | + client = get_client(params.sessionId) |
| 676 | + |
| 677 | + transaction = _build_wipe_token_transaction(params) |
| 678 | + |
| 679 | + if params.commonTransactionParams is not None: |
| 680 | + params.commonTransactionParams.apply_common_params(transaction, client) |
| 681 | + |
| 682 | + response = transaction.execute(client, wait_for_receipt=False) |
| 683 | + reciept: TransactionReceipt = response.get_receipt(client, validate_status=True) |
| 684 | + |
| 685 | + return WipeTokenResponse(status=ResponseCode(reciept.status).name) |
0 commit comments