Skip to content

Commit d7238c7

Browse files
committed
chore: basic linting token update transaction
Signed-off-by: exploreriii <[email protected]>
1 parent 5beb61a commit d7238c7

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

src/hiero_sdk_python/tokens/token_update_transaction.py

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
hiero_sdk_python.transaction.token_update_transaction
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
5+
Defines TokenUpdateParams, TokenUpdateKeys, and TokenUpdateTransaction for updating
6+
token properties (settings and keys) on the Hedera network via the HTS API.
7+
"""
18
from typing import Optional
29
from dataclasses import dataclass
310
from hiero_sdk_python.crypto.private_key import PrivateKey
@@ -61,7 +68,7 @@ class TokenUpdateTransaction(Transaction):
6168
6269
Args:
6370
token_id (TokenId, optional): The ID of the token to update.
64-
token_params (TokenUpdateParams, optional): Parameters specifying token properties to update.
71+
token_params (TokenUpdateParams, optional): Parameters of token properties to update.
6572
token_keys (TokenUpdateKeys, optional): New keys to set for the token.
6673
token_key_validation (TokenKeyValidation, optional): The validation mode for token keys.
6774
Defaults to FULL_VALIDATION.
@@ -77,30 +84,30 @@ def __init__(
7784
Initializes a new TokenUpdateTransaction instance with token parameters and optional keys.
7885
7986
This transaction can be built in two ways to support flexibility:
80-
1) By passing a fully-formed TokenId, TokenUpdateParams and TokenUpdateKeys at construction time.
81-
2) By passing `None` (or partially filled objects) and then using the various `set_*` methods
82-
to set or override fields incrementally. Validation is deferred until build time (`build_transaction_body()`),
87+
1) By passing a fully-formed TokenId, TokenUpdateParams and TokenUpdateKeys
88+
2) By passing `None` (or partial) then using the `set_*` methods
89+
Validation is deferred until build time (`build_transaction_body()`),
8390
so you won't fail immediately if fields are missing at creation.
8491
8592
Args:
8693
token_id (TokenId, optional): The ID of the token to update.
87-
token_params (TokenUpdateParams, optional): Parameters specifying token properties to update.
94+
token_params (TokenUpdateParams, optional): the token properties to update.
8895
token_keys (TokenUpdateKeys, optional): New keys to set for the token.
8996
token_key_validation (TokenKeyValidation, optional): The validation mode for token keys.
9097
Defaults to FULL_VALIDATION.
9198
"""
9299
super().__init__()
93-
100+
94101
self.token_id: TokenId = token_id
95-
102+
96103
# Initialize params attributes
97104
params = token_params or TokenUpdateParams()
98105
self.treasury_account_id: Optional[AccountId] = params.treasury_account_id
99106
self.token_name: Optional[str] = params.token_name
100107
self.token_symbol: Optional[str] = params.token_symbol
101108
self.token_memo: Optional[str] = params.token_memo
102109
self.metadata: Optional[bytes] = params.metadata
103-
110+
104111
# Initialize keys attributes
105112
keys = token_keys or TokenUpdateKeys()
106113
self.admin_key: Optional[PrivateKey] = keys.admin_key
@@ -109,9 +116,9 @@ def __init__(
109116
self.supply_key: Optional[PrivateKey] = keys.supply_key
110117
self.pause_key: Optional[PrivateKey] = keys.pause_key
111118
self.metadata_key: Optional[PrivateKey] = keys.metadata_key
112-
119+
113120
self.token_key_verification_mode: TokenKeyValidation = token_key_verification_mode
114-
121+
115122
# Set default transaction fee to 2 HBAR for token update transactions
116123
self._default_transaction_fee = Hbar(2).to_tinybars()
117124

@@ -142,7 +149,7 @@ def set_treasury_account_id(self, treasury_account_id):
142149
self._require_not_frozen()
143150
self.treasury_account_id = treasury_account_id
144151
return self
145-
152+
146153
def set_token_name(self, token_name):
147154
"""
148155
Sets the new name for the token.
@@ -156,7 +163,7 @@ def set_token_name(self, token_name):
156163
self._require_not_frozen()
157164
self.token_name = token_name
158165
return self
159-
166+
160167
def set_token_symbol(self, token_symbol):
161168
"""
162169
Sets the new symbol for the token.
@@ -170,7 +177,7 @@ def set_token_symbol(self, token_symbol):
170177
self._require_not_frozen()
171178
self.token_symbol = token_symbol
172179
return self
173-
180+
174181
def set_token_memo(self, token_memo):
175182
"""
176183
Sets the new memo for the token.
@@ -184,7 +191,7 @@ def set_token_memo(self, token_memo):
184191
self._require_not_frozen()
185192
self.token_memo = token_memo
186193
return self
187-
194+
188195
def set_metadata(self, metadata):
189196
"""
190197
Sets the new metadata for the token.
@@ -198,7 +205,7 @@ def set_metadata(self, metadata):
198205
self._require_not_frozen()
199206
self.metadata = metadata
200207
return self
201-
208+
202209
def set_admin_key(self, admin_key):
203210
"""
204211
Sets the new admin key for the token.
@@ -212,7 +219,7 @@ def set_admin_key(self, admin_key):
212219
self._require_not_frozen()
213220
self.admin_key = admin_key
214221
return self
215-
222+
216223
def set_freeze_key(self, freeze_key):
217224
"""
218225
Sets the new freeze key for the token.
@@ -226,7 +233,7 @@ def set_freeze_key(self, freeze_key):
226233
self._require_not_frozen()
227234
self.freeze_key = freeze_key
228235
return self
229-
236+
230237
def set_wipe_key(self, wipe_key):
231238
"""
232239
Sets the new wipe key for the token.
@@ -240,7 +247,7 @@ def set_wipe_key(self, wipe_key):
240247
self._require_not_frozen()
241248
self.wipe_key = wipe_key
242249
return self
243-
250+
244251
def set_supply_key(self, supply_key):
245252
"""
246253
Sets the new supply key for the token.
@@ -254,7 +261,7 @@ def set_supply_key(self, supply_key):
254261
self._require_not_frozen()
255262
self.supply_key = supply_key
256263
return self
257-
264+
258265
def set_pause_key(self, pause_key):
259266
"""
260267
Sets the new pause key for the token.
@@ -268,7 +275,7 @@ def set_pause_key(self, pause_key):
268275
self._require_not_frozen()
269276
self.pause_key = pause_key
270277
return self
271-
278+
272279
def set_metadata_key(self, metadata_key):
273280
"""
274281
Sets the new metadata key for the token.
@@ -282,7 +289,7 @@ def set_metadata_key(self, metadata_key):
282289
self._require_not_frozen()
283290
self.metadata_key = metadata_key
284291
return self
285-
292+
286293
def set_key_verification_mode(self, key_verification_mode):
287294
"""
288295
Sets the key verification mode for the token.
@@ -309,7 +316,7 @@ def build_transaction_body(self):
309316
"""
310317
if self.token_id is None:
311318
raise ValueError("Missing token ID")
312-
319+
313320
token_update_body = TokenUpdateTransactionBody(
314321
token=self.token_id._to_proto(),
315322
treasury=self.treasury_account_id._to_proto() if self.treasury_account_id else None,
@@ -322,10 +329,9 @@ def build_transaction_body(self):
322329
self._set_keys_to_proto(token_update_body)
323330
transaction_body = self.build_base_transaction_body()
324331
transaction_body.tokenUpdate.CopyFrom(token_update_body)
325-
332+
326333
return transaction_body
327-
328-
334+
329335
def _get_method(self, channel: _Channel) -> _Method:
330336
"""
331337
Gets the method to execute the token update transaction.
@@ -343,7 +349,7 @@ def _get_method(self, channel: _Channel) -> _Method:
343349
transaction_func=channel.token.updateToken,
344350
query_func=None
345351
)
346-
352+
347353
def _set_keys_to_proto(self, token_update_body: TokenUpdateTransactionBody):
348354
"""
349355
Sets the keys to the protobuf transaction body.
@@ -359,4 +365,4 @@ def _set_keys_to_proto(self, token_update_body: TokenUpdateTransactionBody):
359365
if self.metadata_key:
360366
token_update_body.metadata_key.CopyFrom(self.metadata_key.public_key()._to_proto())
361367
if self.pause_key:
362-
token_update_body.pause_key.CopyFrom(self.pause_key.public_key()._to_proto())
368+
token_update_body.pause_key.CopyFrom(self.pause_key.public_key()._to_proto())

0 commit comments

Comments
 (0)