|
21 | 21 | from hiero_sdk_python.tokens.token_associate_transaction import TokenAssociateTransaction |
22 | 22 | from hiero_sdk_python.tokens.token_create_transaction import TokenCreateTransaction |
23 | 23 | from hiero_sdk_python.tokens.token_delete_transaction import TokenDeleteTransaction |
| 24 | +from hiero_sdk_python.tokens.token_dissociate_transaction import TokenDissociateTransaction |
24 | 25 | from hiero_sdk_python.tokens.token_freeze_status import TokenFreezeStatus |
25 | 26 | from hiero_sdk_python.tokens.token_freeze_transaction import TokenFreezeTransaction |
26 | 27 | from hiero_sdk_python.tokens.token_grant_kyc_transaction import TokenGrantKycTransaction |
|
41 | 42 | ClaimTokenParams, |
42 | 43 | CreateTokenParams, |
43 | 44 | DeleteTokenParams, |
| 45 | + DissociateTokenParams, |
44 | 46 | FreezeTokenParams, |
45 | 47 | GetTokenInfoParams, |
46 | 48 | GrantTokenKycParams, |
|
55 | 57 | CreateTokenResponse, |
56 | 58 | CustomFeeResponse, |
57 | 59 | DeleteTokenResponse, |
| 60 | + DissociateTokenResponse, |
58 | 61 | FreezeTokenResponse, |
59 | 62 | GetTokenInfoResponse, |
60 | 63 | GrantTokenKycResponse, |
@@ -289,6 +292,20 @@ def _build_associate_token_transaction(params: AssociateTokenParams) -> TokenAss |
289 | 292 | return transaction |
290 | 293 |
|
291 | 294 |
|
| 295 | +def _build_dissociate_token_transaction(params: DissociateTokenParams) -> TokenDissociateTransaction: |
| 296 | + """Build a TokenDissociateTransaction from TCK params.""" |
| 297 | + transaction = TokenDissociateTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
| 298 | + |
| 299 | + if params.accountId is not None: |
| 300 | + transaction.set_account_id(AccountId.from_string(params.accountId)) |
| 301 | + |
| 302 | + if params.tokenIds is not None: |
| 303 | + token_ids = [TokenId.from_string(tid) for tid in params.tokenIds] |
| 304 | + transaction.set_token_ids(token_ids) |
| 305 | + |
| 306 | + return transaction |
| 307 | + |
| 308 | + |
292 | 309 | def _build_delete_token_transaction(params: DeleteTokenParams) -> TokenDeleteTransaction: |
293 | 310 | """Build a TokenDeleteTransaction from TCK params.""" |
294 | 311 | transaction = TokenDeleteTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
@@ -374,6 +391,22 @@ def delete_token(params: DeleteTokenParams) -> DeleteTokenResponse: |
374 | 391 | return DeleteTokenResponse(status=ResponseCode(receipt.status).name) |
375 | 392 |
|
376 | 393 |
|
| 394 | +@rpc_method("dissociateToken") |
| 395 | +def dissociate_token(params: DissociateTokenParams) -> DissociateTokenResponse: |
| 396 | + """Dissociate tokens from an account using TCK dissociateToken parameters.""" |
| 397 | + client = get_client(params.sessionId) |
| 398 | + |
| 399 | + transaction = _build_dissociate_token_transaction(params) |
| 400 | + |
| 401 | + if params.commonTransactionParams is not None: |
| 402 | + params.commonTransactionParams.apply_common_params(transaction, client) |
| 403 | + |
| 404 | + response = transaction.execute(client, wait_for_receipt=False) |
| 405 | + receipt: TransactionReceipt = response.get_receipt(client, validate_status=True) |
| 406 | + |
| 407 | + return DissociateTokenResponse(status=ResponseCode(receipt.status).name) |
| 408 | + |
| 409 | + |
377 | 410 | @rpc_method("freezeToken") |
378 | 411 | def freeze_token(params: FreezeTokenParams) -> FreezeTokenResponse: |
379 | 412 | """Freeze a token for an account using TCK freezeToken parameters.""" |
|
0 commit comments