|
23 | 23 | from hiero_sdk_python.tokens.token_id import TokenId |
24 | 24 | from hiero_sdk_python.tokens.token_mint_transaction import TokenMintTransaction |
25 | 25 | from hiero_sdk_python.tokens.token_pause_transaction import TokenPauseTransaction |
| 26 | +from hiero_sdk_python.tokens.token_reject_transaction import TokenRejectTransaction |
26 | 27 | from hiero_sdk_python.tokens.token_type import TokenType |
27 | 28 | from hiero_sdk_python.transaction.transaction_receipt import TransactionReceipt |
28 | 29 | from tck.handlers.registry import rpc_method |
|
36 | 37 | FreezeTokenParams, |
37 | 38 | MintTokenParams, |
38 | 39 | PauseTokenParams, |
| 40 | + RejectTokenParams, |
39 | 41 | ) |
40 | 42 | from tck.response.token import ( |
41 | 43 | AirdropTokenResponse, |
|
46 | 48 | FreezeTokenResponse, |
47 | 49 | MintTokenResponse, |
48 | 50 | PauseTokenResponse, |
| 51 | + RejectTokenResponse, |
49 | 52 | ) |
50 | 53 | from tck.util.client_utils import get_client |
51 | 54 | from tck.util.constants import DEFAULT_GRPC_TIMEOUT |
@@ -478,3 +481,37 @@ def claim_token(params: ClaimTokenParams) -> ClaimTokenResponse: |
478 | 481 | receipt: TransactionReceipt = response.get_receipt(client, validate_status=True) |
479 | 482 |
|
480 | 483 | return ClaimTokenResponse(status=ResponseCode(receipt.status).name) |
| 484 | + |
| 485 | + |
| 486 | +def _build_reject_token_transaction( |
| 487 | + params: RejectTokenParams, |
| 488 | +) -> TokenRejectTransaction: |
| 489 | + transaction = TokenRejectTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
| 490 | + |
| 491 | + if params.ownerId: |
| 492 | + transaction.set_owner_id(AccountId.from_string(params.ownerId)) |
| 493 | + |
| 494 | + if params.tokenIds: |
| 495 | + transaction.set_token_ids([TokenId.from_string(token) for token in params.tokenIds]) |
| 496 | + |
| 497 | + if params.serialNumbers: |
| 498 | + transaction.set_nft_ids([NftId.from_string(serial) for serial in params.serialNumbers]) |
| 499 | + |
| 500 | + return transaction |
| 501 | + |
| 502 | + |
| 503 | +@rpc_method("rejectToken") |
| 504 | +def reject_token(params: RejectTokenParams) -> RejectTokenResponse: |
| 505 | + client = get_client(params.sessionId) |
| 506 | + |
| 507 | + transaction = _build_reject_token_transaction(params) |
| 508 | + |
| 509 | + if params.commonTransactionParams is not None: |
| 510 | + params.commonTransactionParams.apply_common_params(transaction, params.commonTransactionParams) |
| 511 | + |
| 512 | + response = transaction.execute(client, wait_for_receipt=False) |
| 513 | + receipt = response.get_receipt(client, validate_status=True) |
| 514 | + |
| 515 | + return RejectTokenResponse( |
| 516 | + status=ResponseCode(receipt.status).name, |
| 517 | + ) |
0 commit comments