@@ -29,7 +29,8 @@ def __init__(
2929 self ,
3030 hbar_transfers : Optional [Dict [AccountId , int ]] = None ,
3131 token_transfers : Optional [Dict [TokenId , Dict [AccountId , int ]]] = None ,
32- nft_transfers : Optional [Dict [TokenId , List [Tuple [AccountId , AccountId , int , bool ]]]] = None ,
32+ nft_transfers : Optional [Dict [TokenId ,
33+ List [Tuple [AccountId , AccountId , int , bool ]]]] = None ,
3334 ) -> None :
3435 """
3536 Initializes a new TransferTransaction instance.
@@ -73,10 +74,19 @@ def _add_hbar_transfer(
7374 TransferTransaction: The current instance of the transaction for chaining.
7475 """
7576 self ._require_not_frozen ()
77+
7678 if not isinstance (account_id , AccountId ):
7779 raise TypeError ("account_id must be an AccountId instance." )
78- if not isinstance (amount , int ) or amount == 0 :
79- raise ValueError ("Amount must be a non-zero integer." )
80+
81+ if amount is None :
82+ raise TypeError ("amount cannot be None." )
83+
84+ if not isinstance (amount , int ):
85+ raise TypeError ("amount must be an integer." )
86+
87+ if amount == 0 :
88+ raise ValueError ("amount must be a non-zero integer." )
89+
8090 if not isinstance (is_approved , bool ):
8191 raise TypeError ("is_approved must be a boolean." )
8292
@@ -85,8 +95,9 @@ def _add_hbar_transfer(
8595 transfer .amount += amount
8696 return self
8797
88- self .hbar_transfers .append (HbarTransfer (account_id , amount , is_approved ))
89- return self
98+ self .hbar_transfers .append (
99+ HbarTransfer (account_id , amount , is_approved ))
100+ return self
90101
91102 def add_hbar_transfer (self , account_id : AccountId , amount : int ) -> "TransferTransaction" :
92103 """
@@ -190,7 +201,8 @@ def _from_protobuf(cls, transaction_body, body_bytes: bytes, sig_map):
190201
191202 if crypto_transfer .HasField ("transfers" ):
192203 for account_amount in crypto_transfer .transfers .accountAmounts :
193- account_id = AccountId ._from_proto (account_amount .accountID )
204+ account_id = AccountId ._from_proto (
205+ account_amount .accountID )
194206 amount = account_amount .amount
195207 is_approved = account_amount .is_approval
196208 transaction .hbar_transfers .append (
@@ -210,17 +222,21 @@ def _from_protobuf(cls, transaction_body, body_bytes: bytes, sig_map):
210222 expected_decimals = token_transfer_list .expected_decimals .value
211223
212224 transaction .token_transfers [token_id ].append (
213- TokenTransfer (token_id , account_id , amount , expected_decimals , is_approved )
225+ TokenTransfer (token_id , account_id , amount ,
226+ expected_decimals , is_approved )
214227 )
215228
216229 for nft_transfer in token_transfer_list .nftTransfers :
217- sender_id = AccountId ._from_proto (nft_transfer .senderAccountID )
218- receiver_id = AccountId ._from_proto (nft_transfer .receiverAccountID )
230+ sender_id = AccountId ._from_proto (
231+ nft_transfer .senderAccountID )
232+ receiver_id = AccountId ._from_proto (
233+ nft_transfer .receiverAccountID )
219234 serial_number = nft_transfer .serialNumber
220235 is_approved = nft_transfer .is_approval
221236
222237 transaction .nft_transfers [token_id ].append (
223- TokenNftTransfer (token_id , sender_id , receiver_id , serial_number , is_approved )
238+ TokenNftTransfer (
239+ token_id , sender_id , receiver_id , serial_number , is_approved )
224240 )
225241
226242 return transaction
0 commit comments