Description
Add regenerate_transaction_id support to the Transaction class, bringing the Python SDK closer with the transaction ID regeneration behavior supported by the other SDKs.
Specifically, add:
set_regenerate_transaction_id()
regenerate_transaction_id
This support is also required by the TCK CommonTransactionParams, which receive regenerateTransactionId parameter through JSON-RPC request parameters.
Proposed Solution
def __init__(self) -> None:
...
self._regenerate_transaction_id: bool | None = None
...
@proprty
def regenerate_transaction_id(self) -> bool | None:
return self._regenerate_transaction_id
def set_regenerate_transaction_id(self, value: bool):
self._regenerate_transaction_id = value
return self
def _should_retry(self, response):
...
if status == ResponseCode.TRANSACTION_EXPIRED:
# Regenerate the transaction ID and retry if enabled.
if self.regenerate_transaction_id:
self._handle_transaction_id_regeneration()
return _ExecutionState.RETRY
# Transaction ID regeneration is disabled.
return _ExecutionState.EXPIRED
...
def _handle_transaction_id_regeneration(self):
# unlock the transaction_ids list
new_trasnaction_id = TransactionId.generate(client.operator_account_id)
# transaction_ids.set(transaction_ids.index, new_transaction_id);
# lock the transaction_ids list
return self
self._regenerate_transaction_id = ( self._regenerate_transaction_id if self._regenerate_transaction_id is not None else client.default_regenerate_transaction_id )
Acceptance Criteria
Note
Once this issue is resolved, create a separate follow-up issue to update apply_common_params() to handle the regenerateTransactionId parameter from CommonTransactionParams and apply it to the transaction using set_regenerate_transaction_id().
Description
Add
regenerate_transaction_idsupport to theTransactionclass, bringing the Python SDK closer with the transaction ID regeneration behavior supported by the other SDKs.Specifically, add:
set_regenerate_transaction_id()regenerate_transaction_idThis support is also required by the TCK
CommonTransactionParams, which receiveregenerateTransactionIdparameter through JSON-RPC request parameters.Proposed Solution
regenerate_transaction_idproperty to TransactionTRANSACTION_EXPIREDtriggers a retry when transaction ID regeneration is enabled._handle_transaction_id_regenerationmethod to generate new transactionId.default_regenerate_transaction_id: bool = Trueto Client, default valueTrue.set_default_regenerate_transaction_id().freeze_with()method to to resolve the regenerate_transaction_idAcceptance Criteria
Transactionexposes aregenerate_transaction_idproperty.Transactionprovides a fluentset_regenerate_transaction_id(bool)method.Clientprovidesdefault_regenerate_transaction_id, with a default value ofTrue.freeze_with()usesClient.default_regenerate_transaction_id.TRANSACTION_EXPIREDis received and transaction ID regeneration is enabled, a new transaction ID is generated and the transaction is retried.TRANSACTION_EXPIREDresults in_ExecutionState.EXPIREDand the transaction is not retried.Note
Once this issue is resolved, create a separate follow-up issue to update
apply_common_params()to handle theregenerateTransactionIdparameter fromCommonTransactionParamsand apply it to the transaction usingset_regenerate_transaction_id().