|
34 | 34 | from hiero_sdk_python.tokens.token_reject_transaction import TokenRejectTransaction |
35 | 35 | from hiero_sdk_python.tokens.token_revoke_kyc_transaction import TokenRevokeKycTransaction |
36 | 36 | from hiero_sdk_python.tokens.token_type import TokenType |
| 37 | +from hiero_sdk_python.tokens.token_wipe_transaction import TokenWipeTransaction |
37 | 38 | from hiero_sdk_python.transaction.transaction_receipt import TransactionReceipt |
38 | 39 | from tck.handlers.registry import rpc_method |
39 | 40 | from tck.param.custom_fee import CustomFeeParams, FixedFeeParams |
|
51 | 52 | PauseTokenParams, |
52 | 53 | RejectTokenParams, |
53 | 54 | RevokeTokenKycParams, |
| 55 | + WipeTokenParams, |
54 | 56 | ) |
55 | 57 | from tck.response.token import ( |
56 | 58 | AirdropTokenResponse, |
|
67 | 69 | PauseTokenResponse, |
68 | 70 | RejectTokenResponse, |
69 | 71 | RevokeTokenKycResponse, |
| 72 | + WipeTokenResponse, |
70 | 73 | ) |
71 | 74 | from tck.util.client_utils import get_client |
72 | 75 | from tck.util.constants import DEFAULT_GRPC_TIMEOUT |
@@ -776,3 +779,41 @@ def reject_token(params: RejectTokenParams) -> RejectTokenResponse: |
776 | 779 | return RejectTokenResponse( |
777 | 780 | status=ResponseCode(receipt.status).name, |
778 | 781 | ) |
| 782 | + |
| 783 | + |
| 784 | +def _build_wipe_token_transaction(params: WipeTokenParams) -> TokenWipeTransaction: |
| 785 | + """Build a TokenWipeTransaction from TCK params.""" |
| 786 | + |
| 787 | + transaction = TokenWipeTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
| 788 | + |
| 789 | + if params.tokenId is not None: |
| 790 | + transaction.set_token_id(TokenId.from_string(params.tokenId)) |
| 791 | + |
| 792 | + if params.accountId is not None: |
| 793 | + transaction.set_account_id(AccountId.from_string(params.accountId)) |
| 794 | + |
| 795 | + if params.amount is not None: |
| 796 | + transaction.set_amount(to_int(params.amount)) |
| 797 | + |
| 798 | + if params.serialNumbers is not None: |
| 799 | + serial_number_list = [int(serial_number) for serial_number in params.serialNumbers] |
| 800 | + transaction.set_serial(serial_number_list) |
| 801 | + |
| 802 | + return transaction |
| 803 | + |
| 804 | + |
| 805 | +@rpc_method("wipeToken") |
| 806 | +def wipe_token(params: WipeTokenParams) -> WipeTokenResponse: |
| 807 | + """Wipes the provided amount of fungible or non-fungible tokens from the specified Hedera account""" |
| 808 | + |
| 809 | + client = get_client(params.sessionId) |
| 810 | + |
| 811 | + transaction = _build_wipe_token_transaction(params) |
| 812 | + |
| 813 | + if params.commonTransactionParams is not None: |
| 814 | + params.commonTransactionParams.apply_common_params(transaction, client) |
| 815 | + |
| 816 | + response = transaction.execute(client, wait_for_receipt=False) |
| 817 | + receipt: TransactionReceipt = response.get_receipt(client, validate_status=True) |
| 818 | + |
| 819 | + return WipeTokenResponse(status=ResponseCode(receipt.status).name) |
0 commit comments